use of de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier in project FAAAST-Service by FraunhoferIOSB.
the class PersistenceInMemoryTest method removeAASTest.
@Test
public void removeAASTest() throws ResourceNotFoundException {
String AAS_IDENTIFIER = "https://acplt.org/Test_AssetAdministrationShell_Mandatory";
Identifier aasId = new DefaultIdentifier.Builder().idType(IdentifierType.IRI).identifier(AAS_IDENTIFIER).build();
this.persistence.remove(aasId);
Assert.assertThrows(ResourceNotFoundException.class, () -> this.persistence.get(aasId, new QueryModifier()));
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier in project FAAAST-Service by FraunhoferIOSB.
the class PersistenceInMemoryTest method putIdentifiableChangeTest.
@Test
public void putIdentifiableChangeTest() throws ResourceNotFoundException {
ConceptDescription expected = DeepCopyHelper.deepCopy(this.environment.getConceptDescriptions().get(0), this.environment.getConceptDescriptions().get(0).getClass());
String category = "NewCategory";
expected.setCategory(category);
this.persistence.put(expected);
ConceptDescription actual = (ConceptDescription) this.persistence.get(expected.getIdentification(), new QueryModifier());
Assert.assertEquals(expected, actual);
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier in project FAAAST-Service by FraunhoferIOSB.
the class PersistenceInMemoryTest method getConceptDescriptionsWithIsCaseOfTest.
@Test
public void getConceptDescriptionsWithIsCaseOfTest() {
String conceptDescriptionIdShort = "TestConceptDescription";
Reference isCaseOf = new DefaultReference.Builder().key(new DefaultKey.Builder().type(null).idType(KeyType.IRI).value("http://acplt.org/DataSpecifications/ConceptDescriptions/TestConceptDescription").build()).build();
List<ConceptDescription> actualConceptDescriptions = this.persistence.get(null, isCaseOf, (Reference) null, new QueryModifier());
List<ConceptDescription> expectedConceptDescriptions = this.environment.getConceptDescriptions().stream().filter(x -> x.getIdShort().equalsIgnoreCase(conceptDescriptionIdShort)).collect(Collectors.toList());
Assert.assertEquals(actualConceptDescriptions, expectedConceptDescriptions);
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier in project FAAAST-Service by FraunhoferIOSB.
the class DeleteConceptDescriptionByIdRequestHandler method process.
@Override
public DeleteConceptDescriptionByIdResponse process(DeleteConceptDescriptionByIdRequest request) {
DeleteConceptDescriptionByIdResponse response = new DeleteConceptDescriptionByIdResponse();
try {
ConceptDescription conceptDescription = (ConceptDescription) persistence.get(request.getId(), new QueryModifier());
persistence.remove(request.getId());
response.setStatusCode(StatusCode.Success);
publishElementDeleteEventMessage(AasUtils.toReference(conceptDescription), conceptDescription);
} catch (ResourceNotFoundException ex) {
response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
} catch (Exception ex) {
response.setStatusCode(StatusCode.ServerInternalError);
}
return response;
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier in project FAAAST-Service by FraunhoferIOSB.
the class DeleteSubmodelElementByPathRequestHandler method process.
@Override
public DeleteSubmodelElementByPathResponse process(DeleteSubmodelElementByPathRequest request) {
DeleteSubmodelElementByPathResponse response = new DeleteSubmodelElementByPathResponse();
try {
Reference reference = ReferenceHelper.toReference(request.getPath(), request.getId(), Submodel.class);
SubmodelElement submodelElement = persistence.get(reference, new QueryModifier());
persistence.remove(reference);
response.setStatusCode(StatusCode.Success);
publishElementDeleteEventMessage(reference, submodelElement);
} catch (ResourceNotFoundException ex) {
response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
} catch (Exception ex) {
response.setStatusCode(StatusCode.ServerInternalError);
}
return response;
}
Aggregations