use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteAssetAdministrationShellByIdResponse in project FAAAST-Service by FraunhoferIOSB.
the class RequestHandlerManagerTest method testDeleteAssetAdministrationShellByIdRequest.
@Test
public void testDeleteAssetAdministrationShellByIdRequest() throws ResourceNotFoundException {
when(persistence.get(environment.getAssetAdministrationShells().get(0).getIdentification(), new QueryModifier())).thenReturn(environment.getAssetAdministrationShells().get(0));
DeleteAssetAdministrationShellByIdRequest request = new DeleteAssetAdministrationShellByIdRequest().builder().id(environment.getAssetAdministrationShells().get(0).getIdentification()).build();
DeleteAssetAdministrationShellByIdResponse response = manager.execute(request);
DeleteAssetAdministrationShellByIdResponse expected = new DeleteAssetAdministrationShellByIdResponse.Builder().statusCode(StatusCode.Success).build();
Assert.assertEquals(expected, response);
verify(persistence).remove(environment.getAssetAdministrationShells().get(0).getIdentification());
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteAssetAdministrationShellByIdResponse in project FAAAST-Service by FraunhoferIOSB.
the class DeleteAssetAdministrationShellByIdRequestHandler method process.
@Override
public DeleteAssetAdministrationShellByIdResponse process(DeleteAssetAdministrationShellByIdRequest request) {
DeleteAssetAdministrationShellByIdResponse response = new DeleteAssetAdministrationShellByIdResponse();
try {
AssetAdministrationShell shell = (AssetAdministrationShell) persistence.get(request.getId(), new QueryModifier());
persistence.remove(request.getId());
response.setStatusCode(StatusCode.Success);
publishElementDeleteEventMessage(AasUtils.toReference(shell), shell);
} catch (ResourceNotFoundException ex) {
response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
} catch (Exception ex) {
response.setStatusCode(StatusCode.ServerInternalError);
}
return response;
}
Aggregations