use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelsByIdShortResponse in project FAAAST-Service by FraunhoferIOSB.
the class RequestHandlerManagerTest method testGetAllSubmodelsByIdShortRequest.
@Test
public void testGetAllSubmodelsByIdShortRequest() throws ResourceNotFoundException {
when(persistence.get("Test", (Reference) null, new OutputModifier())).thenReturn(environment.getSubmodels());
GetAllSubmodelsByIdShortRequest request = new GetAllSubmodelsByIdShortRequest.Builder().idShort("Test").outputModifier(new OutputModifier()).build();
GetAllSubmodelsByIdShortResponse response = manager.execute(request);
GetAllSubmodelsByIdShortResponse expected = new GetAllSubmodelsByIdShortResponse.Builder().payload(environment.getSubmodels()).statusCode(StatusCode.Success).build();
Assert.assertEquals(expected, response);
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelsByIdShortResponse in project FAAAST-Service by FraunhoferIOSB.
the class GetAllSubmodelsByIdShortRequestHandler method process.
@Override
public GetAllSubmodelsByIdShortResponse process(GetAllSubmodelsByIdShortRequest request) {
GetAllSubmodelsByIdShortResponse response = new GetAllSubmodelsByIdShortResponse();
try {
List<Submodel> submodels = persistence.get(request.getIdShort(), (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