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