use of de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Level 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() == null));
}
Aggregations