Search in sources :

Example 1 with DeleteConceptDescriptionByIdResponse

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());
}
Also used : QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) DeleteConceptDescriptionByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteConceptDescriptionByIdRequest) DeleteConceptDescriptionByIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteConceptDescriptionByIdResponse) Test(org.junit.Test)

Example 2 with DeleteConceptDescriptionByIdResponse

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;
}
Also used : QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) DeleteConceptDescriptionByIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteConceptDescriptionByIdResponse)

Aggregations

QueryModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier)2 DeleteConceptDescriptionByIdResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteConceptDescriptionByIdResponse)2 ResourceNotFoundException (de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)1 DeleteConceptDescriptionByIdRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteConceptDescriptionByIdRequest)1 ConceptDescription (io.adminshell.aas.v3.model.ConceptDescription)1 Test (org.junit.Test)1