Search in sources :

Example 1 with PutConceptDescriptionByIdResponse

use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutConceptDescriptionByIdResponse in project FAAAST-Service by FraunhoferIOSB.

the class RequestHandlerManagerTest method testPutConceptDescriptionByIdRequest.

@Test
public void testPutConceptDescriptionByIdRequest() throws ResourceNotFoundException {
    when(persistence.put(environment.getConceptDescriptions().get(0))).thenReturn(environment.getConceptDescriptions().get(0));
    PutConceptDescriptionByIdRequest request = new PutConceptDescriptionByIdRequest.Builder().conceptDescription(environment.getConceptDescriptions().get(0)).build();
    PutConceptDescriptionByIdResponse response = manager.execute(request);
    PutConceptDescriptionByIdResponse expected = new PutConceptDescriptionByIdResponse.Builder().payload(environment.getConceptDescriptions().get(0)).statusCode(StatusCode.Success).build();
    Assert.assertEquals(expected, response);
}
Also used : PutConceptDescriptionByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutConceptDescriptionByIdRequest) PutConceptDescriptionByIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutConceptDescriptionByIdResponse) Test(org.junit.Test)

Example 2 with PutConceptDescriptionByIdResponse

use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutConceptDescriptionByIdResponse in project FAAAST-Service by FraunhoferIOSB.

the class PutConceptDescriptionByIdRequestHandler method process.

@Override
public PutConceptDescriptionByIdResponse process(PutConceptDescriptionByIdRequest request) {
    PutConceptDescriptionByIdResponse response = new PutConceptDescriptionByIdResponse();
    try {
        ConceptDescription conceptDescription = (ConceptDescription) persistence.get(request.getConceptDescription().getIdentification(), new OutputModifier());
        conceptDescription = (ConceptDescription) persistence.put(request.getConceptDescription());
        response.setPayload(conceptDescription);
        response.setStatusCode(StatusCode.Success);
        publishElementUpdateEventMessage(AasUtils.toReference(conceptDescription), conceptDescription);
    } catch (ResourceNotFoundException ex) {
        response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : OutputModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) PutConceptDescriptionByIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutConceptDescriptionByIdResponse) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)

Aggregations

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