Search in sources :

Example 1 with GetAllSubmodelsByIdShortResponse

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

Example 2 with GetAllSubmodelsByIdShortResponse

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

Aggregations

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