Skip to content
This repository was archived by the owner on Feb 15, 2024. It is now read-only.

Commit 2e5b670

Browse files
author
changqin26
committed
Added shapes for AASd026, but have no idea how to create unit tests.
1 parent 071520c commit 2e5b670

2 files changed

Lines changed: 73 additions & 0 deletions

File tree

validator/src/main/resources/constraint_shapes.ttl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,41 @@ aas:AASd-023Shape a sh:NodeShape ;
273273
""" ;
274274
] .
275275

276+
# AASd-026
277+
aas:AASd-026Shape a sh:NodeShape ;
278+
sh:targetClass aas:SubmodelElementCollection ;
279+
sh:prefixes xsd: ;
280+
sh:sparql [
281+
a sh:SPARQLConstraint ;
282+
sh:message "If allowDuplicates==false then it is not allowed that the collection contains several elements with the same semantics (i.e. the same semanticId)." ;
283+
sh:select """
284+
SELECT ?keyType
285+
WHERE {
286+
?SubmodelElementCollection a <https://admin-shell.io/aas/3/0/RC01/SubmodelElementCollection> .
287+
?SubmodelElementCollection <https://admin-shell.io/aas/3/0/RC01/Referable/idShort> ?SubmodelElementCollectionIdShort .
288+
?SubmodelElementCollection <https://admin-shell.io/aas/3/0/RC01/SubmodelElementCollection/allowDuplicates> "False"^^xsd:boolean.
289+
290+
?SubmodelElementCollection <https://admin-shell.io/aas/3/0/RC01/SubmodelElementCollection/value> ?Value1 .
291+
?Value1 <https://admin-shell.io/aas/3/0/RC01/HasSemantics/semanticId> ?Value1SemanticId .
292+
?Value1SemanticId <https://admin-shell.io/aas/3/0/RC01/Reference/key> ?Value1Key .
293+
?Value1Key <https://admin-shell.io/aas/3/0/RC01/Key/type> ?Value1KeyType .
294+
?Value1Key <https://admin-shell.io/aas/3/0/RC01/Key/value> ?Value1KeyValue .
295+
?Value1Key <https://admin-shell.io/aas/3/0/RC01/Key/idType> ?Value1KeyIdType .
296+
297+
?SubmodelElementCollection <https://admin-shell.io/aas/3/0/RC01/SubmodelElementCollection/value> ?Value2 .
298+
?Value2 <https://admin-shell.io/aas/3/0/RC01/HasSemantics/semanticId> ?Value2SemanticId .
299+
?Value2SemanticId <https://admin-shell.io/aas/3/0/RC01/Reference/key> ?Value2Key .
300+
?Value2Key <https://admin-shell.io/aas/3/0/RC01/Key/type> ?Value2KeyType .
301+
?Value2Key <https://admin-shell.io/aas/3/0/RC01/Key/value> ?Value2KeyValue .
302+
?Value2Key <https://admin-shell.io/aas/3/0/RC01/Key/idType> ?Value2KeyIdType .
303+
304+
305+
FILTER (?Value1SemanticId = ?Value2SemanticId )
306+
307+
}
308+
""" ;
309+
] .
310+
276311
# AASd-051
277312
aas:ConceptDescriptionAllowedCategories a sh:NodeShape ;
278313
sh:targetClass aas:ConceptDescription ;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package io.adminshell.aas.v3.model.validator;
2+
3+
import io.adminshell.aas.v3.model.*;
4+
import io.adminshell.aas.v3.model.impl.DefaultKey;
5+
import io.adminshell.aas.v3.model.impl.DefaultReference;
6+
import io.adminshell.aas.v3.model.impl.DefaultSubmodel;
7+
import io.adminshell.aas.v3.model.impl.DefaultSubmodelElementCollection;
8+
import org.junit.Test;
9+
10+
import java.util.*;
11+
12+
/**
13+
* Tests the following constraint:
14+
* <p>
15+
* <i> If allowDuplicates==false then it is not allowed that the collection contains several elements with the same semantics (i.e. the same semanticId). </i>
16+
* </p>
17+
*
18+
* @author bader, chang
19+
*
20+
*/
21+
22+
public class TestAASd_026 {
23+
24+
25+
private SubmodelElementCollection createSubmodelElementCollection(Collection<SubmodelElement> values) {
26+
return new DefaultSubmodelElementCollection.Builder()
27+
.idShort("idShort")
28+
.value((SubmodelElement) values)
29+
.semanticId(new DefaultReference.Builder()
30+
.key(new DefaultKey.Builder()
31+
.idType(KeyType.CUSTOM)
32+
.value("the value of the semantic id")
33+
.type(KeyElements.CONCEPT_DESCRIPTION)
34+
.build())
35+
.build())
36+
.build();
37+
}
38+
}

0 commit comments

Comments
 (0)