use of io.adminshell.aas.v3.model.SubmodelElement in project FAAAST-Service by FraunhoferIOSB.
the class PersistenceInMemoryTest method removeByReferencePropertyInSubmodelElementCollectionTest.
@Test
public void removeByReferencePropertyInSubmodelElementCollectionTest() throws ResourceNotFoundException {
String AAS_IDENTIFIER = "https://acplt.org/Test_AssetAdministrationShell_Mandatory";
String SUBMODEL_IDENTIFIER = "https://acplt.org/Test_Submodel_Mandatory";
String SUBMODEL_ELEMENT_COLLECTION_IDSHORT = "ExampleSubmodelCollectionUnordered";
String SUBMODEL_ELEMENT_IDSHORT = "ExampleFile";
Reference reference = Util.createReference(AAS_IDENTIFIER, SUBMODEL_IDENTIFIER, SUBMODEL_ELEMENT_COLLECTION_IDSHORT, SUBMODEL_ELEMENT_IDSHORT);
SubmodelElement submodelElement = this.persistence.get(reference, new OutputModifier());
this.persistence.remove(reference);
Assert.assertThrows(ResourceNotFoundException.class, () -> this.persistence.get(reference, new QueryModifier()));
}
use of io.adminshell.aas.v3.model.SubmodelElement in project FAAAST-Service by FraunhoferIOSB.
the class PersistenceInMemoryTest method testQueryModifierLevel.
@Test
public void testQueryModifierLevel() throws ResourceNotFoundException {
String SUBMODEL_IDENTIFIER = "https://acplt.org/Test_Submodel_Mandatory";
QueryModifier queryModifier = new QueryModifier.Builder().level(Level.DEEP).build();
Identifier submodelId = new DefaultIdentifier.Builder().idType(IdentifierType.IRI).identifier(SUBMODEL_IDENTIFIER).build();
Submodel expected = this.environment.getSubmodels().stream().filter(x -> x.getIdentification().equals(submodelId)).findFirst().get();
Submodel actual = (Submodel) this.persistence.get(submodelId, queryModifier);
Assert.assertEquals(expected, actual);
queryModifier = new QueryModifier.Builder().level(Level.CORE).build();
actual = (Submodel) this.persistence.get(submodelId, queryModifier);
List<SubmodelElement> submodelElementCollections = actual.getSubmodelElements().stream().filter(x -> SubmodelElementCollection.class.isAssignableFrom(x.getClass())).collect(Collectors.toList());
Assert.assertTrue(submodelElementCollections.stream().allMatch(x -> ((SubmodelElementCollection) x).getValues().isEmpty()));
}
use of io.adminshell.aas.v3.model.SubmodelElement in project FAAAST-Service by FraunhoferIOSB.
the class PersistenceInMemoryTest method getSubmodelElementTest.
@Test
public void getSubmodelElementTest() throws ResourceNotFoundException {
String AAS_IDENTIFIER = "https://acplt.org/Test_AssetAdministrationShell";
String SUBMODEL_IDENTIFIER = "http://acplt.org/Submodels/Assets/TestAsset/BillOfMaterial";
String SUBMODEL_ELEMENT_IDSHORT = "ExampleEntity2";
Reference reference = Util.createReference(AAS_IDENTIFIER, SUBMODEL_IDENTIFIER, SUBMODEL_ELEMENT_IDSHORT);
SubmodelElement actualSubmodelElement = persistence.get(reference, new QueryModifier());
SubmodelElement expectedSubmodelElement = environment.getSubmodels().stream().filter(x -> x.getIdentification().getIdentifier().equalsIgnoreCase(SUBMODEL_IDENTIFIER)).findFirst().get().getSubmodelElements().stream().filter(x -> x.getIdShort().equalsIgnoreCase(SUBMODEL_ELEMENT_IDSHORT)).findFirst().get();
Assert.assertEquals(expectedSubmodelElement, actualSubmodelElement);
}
use of io.adminshell.aas.v3.model.SubmodelElement in project FAAAST-Service by FraunhoferIOSB.
the class PersistenceInMemoryTest method getSubmodelElementsWithSemanticIdTest.
@Test
public void getSubmodelElementsWithSemanticIdTest() throws ResourceNotFoundException {
String AAS_IDSHORT = "TestAssetAdministrationShell";
String SUBMODEL_IRI = "http://acplt.org/Submodels/Assets/TestAsset/Identification";
Reference submodelReference = Util.createReference(AAS_IDSHORT, SUBMODEL_IRI);
Reference semanticIdReference = new DefaultReference.Builder().key(new DefaultKey.Builder().type(KeyElements.GLOBAL_REFERENCE).value("0173-1#02-AAO677#002").idType(KeyType.IRI).build()).build();
List<SubmodelElement> actualSubmodelElements = persistence.getSubmodelElements(submodelReference, semanticIdReference, new QueryModifier());
List<SubmodelElement> expectedSubmodelElements = this.environment.getSubmodels().stream().filter(x -> x.getIdentification().getIdentifier().equalsIgnoreCase(SUBMODEL_IRI)).findFirst().get().getSubmodelElements().stream().filter(x -> x.getSemanticId().equals(semanticIdReference)).collect(Collectors.toList());
Assert.assertEquals(expectedSubmodelElements, actualSubmodelElements);
}
use of io.adminshell.aas.v3.model.SubmodelElement in project FAAAST-Service by FraunhoferIOSB.
the class PersistenceInMemoryTest method putSubmodelElementChangeInSubmodelElementCollectionTest.
@Test
public void putSubmodelElementChangeInSubmodelElementCollectionTest() throws ResourceNotFoundException {
String AAS_IDENTIFIER = "https://acplt.org/Test_AssetAdministrationShell_Mandatory";
String SUBMODEL_IDENTIFIER = "https://acplt.org/Test_Submodel_Mandatory";
String SUBMODEL_ELEMENT_COLLECTION_IDSHORT = "ExampleSubmodelCollectionUnordered";
SubmodelElement submodelElement = ((SubmodelElementCollection) this.environment.getSubmodels().stream().filter(x -> x.getIdentification().getIdentifier().equalsIgnoreCase(SUBMODEL_IDENTIFIER)).findFirst().get().getSubmodelElements().stream().filter(y -> y.getIdShort().equalsIgnoreCase(SUBMODEL_ELEMENT_COLLECTION_IDSHORT)).findFirst().orElse(null)).getValues().stream().findFirst().orElse(null);
SubmodelElement changedSubmodelElement = DeepCopyHelper.deepCopy(submodelElement, submodelElement.getClass());
String category = "NewCategory";
changedSubmodelElement.setCategory(category);
Reference reference = Util.createReference(AAS_IDENTIFIER, SUBMODEL_IDENTIFIER, SUBMODEL_ELEMENT_COLLECTION_IDSHORT, submodelElement.getIdShort());
this.persistence.put(null, reference, changedSubmodelElement);
SubmodelElement actualSubmodelelement = this.persistence.get(reference, new QueryModifier.Builder().extend(Extend.WITH_BLOB_VALUE).build());
Assert.assertEquals(changedSubmodelElement, actualSubmodelelement);
}
Aggregations