use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelsResponse in project FAAAST-Service by FraunhoferIOSB.
the class RequestHandlerManagerTest method testGetAllSubmodelsRequest.
@Test
public void testGetAllSubmodelsRequest() throws ResourceNotFoundException {
when(persistence.get(null, (Reference) null, new OutputModifier())).thenReturn(environment.getSubmodels());
GetAllSubmodelsRequest request = new GetAllSubmodelsRequest.Builder().outputModifier(new OutputModifier()).build();
GetAllSubmodelsResponse response = manager.execute(request);
GetAllSubmodelsResponse expected = new GetAllSubmodelsResponse.Builder().payload(environment.getSubmodels()).statusCode(StatusCode.Success).build();
Assert.assertEquals(expected, response);
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelsResponse in project FAAAST-Service by FraunhoferIOSB.
the class GetAllSubmodelsRequestHandler method process.
@Override
public GetAllSubmodelsResponse process(GetAllSubmodelsRequest request) {
GetAllSubmodelsResponse response = new GetAllSubmodelsResponse();
try {
List<Submodel> submodels = persistence.get(null, (Reference) null, request.getOutputModifier());
response.setPayload(submodels);
response.setStatusCode(StatusCode.Success);
if (submodels != null) {
for (Submodel submodel : submodels) {
Reference reference = AasUtils.toReference(submodel);
readValueFromAssetConnectionAndUpdatePersistence(reference, submodel.getSubmodelElements());
publishElementReadEventMessage(reference, submodel);
}
}
} catch (Exception ex) {
response.setStatusCode(StatusCode.ServerInternalError);
}
return response;
}
Aggregations