Search in sources :

Example 1 with GetConceptDescriptionByIdResponse

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

the class RequestHandlerManagerTest method testGetConceptDescriptionByIdRequest.

@Test
public void testGetConceptDescriptionByIdRequest() throws ResourceNotFoundException {
    when(persistence.get(environment.getConceptDescriptions().get(0).getIdentification(), new OutputModifier())).thenReturn(environment.getConceptDescriptions().get(0));
    GetConceptDescriptionByIdRequest request = new GetConceptDescriptionByIdRequest.Builder().outputModifier(new OutputModifier()).id(environment.getConceptDescriptions().get(0).getIdentification()).build();
    GetConceptDescriptionByIdResponse response = manager.execute(request);
    GetConceptDescriptionByIdResponse expected = new GetConceptDescriptionByIdResponse.Builder().payload(environment.getConceptDescriptions().get(0)).statusCode(StatusCode.Success).build();
    Assert.assertEquals(expected, response);
}
Also used : GetConceptDescriptionByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetConceptDescriptionByIdRequest) OutputModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier) GetConceptDescriptionByIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetConceptDescriptionByIdResponse) Test(org.junit.Test)

Example 2 with GetConceptDescriptionByIdResponse

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

the class GetConceptDescriptionByIdRequestHandler method process.

@Override
public GetConceptDescriptionByIdResponse process(GetConceptDescriptionByIdRequest request) {
    GetConceptDescriptionByIdResponse response = new GetConceptDescriptionByIdResponse();
    try {
        ConceptDescription conceptDescription = (ConceptDescription) persistence.get(request.getId(), request.getOutputModifier());
        response.setPayload(conceptDescription);
        response.setStatusCode(StatusCode.Success);
        if (conceptDescription != null) {
            publishElementReadEventMessage(AasUtils.toReference(conceptDescription), conceptDescription);
        }
    } catch (ResourceNotFoundException ex) {
        response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) GetConceptDescriptionByIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetConceptDescriptionByIdResponse) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)

Aggregations

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