use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetSubmodelResponse in project FAAAST-Service by FraunhoferIOSB.
the class GetSubmodelRequestHandler method process.
@Override
public GetSubmodelResponse process(GetSubmodelRequest request) {
GetSubmodelResponse response = new GetSubmodelResponse();
try {
Submodel submodel = (Submodel) persistence.get(request.getId(), request.getOutputModifier());
response.setPayload(submodel);
response.setStatusCode(StatusCode.Success);
Reference reference = AasUtils.toReference(submodel);
readValueFromAssetConnectionAndUpdatePersistence(reference, submodel.getSubmodelElements());
publishElementReadEventMessage(reference, submodel);
} catch (ResourceNotFoundException ex) {
response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
} catch (Exception ex) {
response.setStatusCode(StatusCode.ServerInternalError);
}
return response;
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetSubmodelResponse in project FAAAST-Service by FraunhoferIOSB.
the class RequestHandlerManagerTest method testGetSubmodelRequest.
@Test
public void testGetSubmodelRequest() throws ResourceNotFoundException {
when(persistence.get(environment.getSubmodels().get(0).getIdentification(), new OutputModifier())).thenReturn(environment.getSubmodels().get(0));
GetSubmodelRequest request = new GetSubmodelRequest.Builder().id(environment.getSubmodels().get(0).getIdentification()).outputModifier(new OutputModifier()).build();
GetSubmodelResponse response = manager.execute(request);
GetSubmodelResponse expected = new GetSubmodelResponse.Builder().payload(environment.getSubmodels().get(0)).statusCode(StatusCode.Success).build();
Assert.assertEquals(expected, response);
}
Aggregations