use of de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Extend 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.WithBLOBValue).build());
Assert.assertEquals(changedSubmodelElement, actualSubmodelelement);
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Extend in project FAAAST-Service by FraunhoferIOSB.
the class PersistenceInMemoryTest method getSubmodelElementTestWithBlob.
@Test
public void getSubmodelElementTestWithBlob() 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 = "ExampleBlob";
Reference reference = Util.createReference(AAS_IDENTIFIER, SUBMODEL_IDENTIFIER, SUBMODEL_ELEMENT_COLLECTION_IDSHORT, SUBMODEL_ELEMENT_IDSHORT);
QueryModifier queryModifier = new QueryModifier.Builder().extend(Extend.WithBLOBValue).build();
SubmodelElement actualSubmodelElement = persistence.get(reference, queryModifier);
SubmodelElement expectedSubmodelElementExpected = ((SubmodelElementCollection) environment.getSubmodels().stream().filter(x -> x.getIdentification().getIdentifier().equalsIgnoreCase(SUBMODEL_IDENTIFIER)).findFirst().get().getSubmodelElements().stream().filter(x -> x.getIdShort().equalsIgnoreCase(SUBMODEL_ELEMENT_COLLECTION_IDSHORT)).findFirst().get()).getValues().stream().filter(x -> x.getIdShort().equalsIgnoreCase(SUBMODEL_ELEMENT_IDSHORT)).findFirst().get();
Assert.assertEquals(expectedSubmodelElementExpected, actualSubmodelElement);
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Extend in project FAAAST-Service by FraunhoferIOSB.
the class PersistenceInMemoryTest method testQueryModifierExtend.
@Test
public void testQueryModifierExtend() 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 = "ExampleBlob";
Reference reference = Util.createReference(AAS_IDENTIFIER, SUBMODEL_IDENTIFIER, SUBMODEL_ELEMENT_COLLECTION_IDSHORT, SUBMODEL_ELEMENT_IDSHORT);
QueryModifier queryModifier = new QueryModifier.Builder().extend(Extend.WithBLOBValue).build();
Identifier submodelId = new DefaultIdentifier.Builder().idType(IdentifierType.IRI).identifier(SUBMODEL_IDENTIFIER).build();
SubmodelElement actual = this.persistence.get(reference, queryModifier);
SubmodelElement expected = ((SubmodelElementCollection) this.environment.getSubmodels().stream().filter(x -> x.getIdentification().equals(submodelId)).findFirst().get().getSubmodelElements().stream().filter(y -> y.getIdShort().equalsIgnoreCase(SUBMODEL_ELEMENT_COLLECTION_IDSHORT)).findFirst().get()).getValues().stream().filter(z -> z.getIdShort().equalsIgnoreCase(SUBMODEL_ELEMENT_IDSHORT)).findFirst().get();
Assert.assertEquals(expected, actual);
queryModifier = new QueryModifier.Builder().extend(Extend.WithoutBLOBValue).build();
actual = this.persistence.get(reference, queryModifier);
expected = null;
Assert.assertEquals(expected, actual);
}
Aggregations