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