use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteConceptDescriptionByIdResponse in project FAAAST-Service by FraunhoferIOSB.
the class RequestHandlerManagerTest method testDeleteConceptDescriptionByIdRequest.
@Test
public void testDeleteConceptDescriptionByIdRequest() throws ResourceNotFoundException {
when(persistence.get(environment.getConceptDescriptions().get(0).getIdentification(), new QueryModifier())).thenReturn(environment.getConceptDescriptions().get(0));
DeleteConceptDescriptionByIdRequest request = new DeleteConceptDescriptionByIdRequest.Builder().id(environment.getConceptDescriptions().get(0).getIdentification()).build();
DeleteConceptDescriptionByIdResponse response = manager.execute(request);
DeleteConceptDescriptionByIdResponse expected = new DeleteConceptDescriptionByIdResponse.Builder().statusCode(StatusCode.Success).build();
Assert.assertEquals(expected, response);
verify(persistence).remove(environment.getConceptDescriptions().get(0).getIdentification());
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteConceptDescriptionByIdResponse 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;
}
Aggregations