use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PostSubmodelResponse in project FAAAST-Service by FraunhoferIOSB.
the class RequestHandlerManagerTest method testPostSubmodelRequest.
@Test
public void testPostSubmodelRequest() throws ResourceNotFoundException {
when(persistence.put(environment.getSubmodels().get(0))).thenReturn(environment.getSubmodels().get(0));
PostSubmodelRequest request = new PostSubmodelRequest.Builder().submodel(environment.getSubmodels().get(0)).build();
PostSubmodelResponse response = manager.execute(request);
PostSubmodelResponse expected = new PostSubmodelResponse.Builder().payload(environment.getSubmodels().get(0)).statusCode(StatusCode.SuccessCreated).build();
Assert.assertEquals(expected, response);
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PostSubmodelResponse in project FAAAST-Service by FraunhoferIOSB.
the class PostSubmodelRequestHandler method process.
@Override
public PostSubmodelResponse process(PostSubmodelRequest request) {
PostSubmodelResponse response = new PostSubmodelResponse();
try {
Submodel submodel = (Submodel) persistence.put(request.getSubmodel());
response.setPayload(submodel);
response.setStatusCode(StatusCode.SuccessCreated);
Reference reference = AasUtils.toReference(submodel);
readValueFromAssetConnectionAndUpdatePersistence(reference, submodel.getSubmodelElements());
publishElementCreateEventMessage(reference, submodel);
} catch (Exception ex) {
response.setStatusCode(StatusCode.ServerInternalError);
}
return response;
}
Aggregations