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);
}
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;
}
Aggregations