use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteSubmodelReferenceResponse in project FAAAST-Service by FraunhoferIOSB.
the class DeleteSubmodelReferenceRequestHandler method process.
@Override
public DeleteSubmodelReferenceResponse process(DeleteSubmodelReferenceRequest request) {
DeleteSubmodelReferenceResponse response = new DeleteSubmodelReferenceResponse();
try {
AssetAdministrationShell aas = (AssetAdministrationShell) persistence.get(request.getId(), new QueryModifier());
aas.getSubmodels().remove(request.getSubmodelRef());
persistence.put(aas);
response.setStatusCode(StatusCode.Success);
publishElementUpdateEventMessage(AasUtils.toReference(aas), aas);
} 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.response.DeleteSubmodelReferenceResponse in project FAAAST-Service by FraunhoferIOSB.
the class RequestHandlerManagerTest method testDeleteSubmodelReferenceRequest.
@Test
public void testDeleteSubmodelReferenceRequest() throws ResourceNotFoundException {
when(persistence.get(environment.getAssetAdministrationShells().get(0).getIdentification(), new QueryModifier())).thenReturn(environment.getAssetAdministrationShells().get(0));
DeleteSubmodelReferenceRequest request = new DeleteSubmodelReferenceRequest.Builder().id(environment.getAssetAdministrationShells().get(0).getIdentification()).submodelRef(SUBMODEL_ELEMENT_REF).build();
DeleteSubmodelReferenceResponse response = manager.execute(request);
DeleteSubmodelReferenceResponse expected = new DeleteSubmodelReferenceResponse.Builder().statusCode(StatusCode.Success).build();
Assert.assertEquals(expected, response);
}
Aggregations