Search in sources :

Example 1 with GetAllSubmodelsResponse

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);
}
Also used : GetAllSubmodelsRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllSubmodelsRequest) OutputModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier) GetAllSubmodelsResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelsResponse) Test(org.junit.Test)

Example 2 with GetAllSubmodelsResponse

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;
}
Also used : Submodel(io.adminshell.aas.v3.model.Submodel) Reference(io.adminshell.aas.v3.model.Reference) GetAllSubmodelsResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelsResponse)

Aggregations

GetAllSubmodelsResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelsResponse)2 OutputModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier)1 GetAllSubmodelsRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllSubmodelsRequest)1 Reference (io.adminshell.aas.v3.model.Reference)1 Submodel (io.adminshell.aas.v3.model.Submodel)1 Test (org.junit.Test)1