Search in sources :

Example 1 with GetAllSubmodelReferencesResponse

use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelReferencesResponse in project FAAAST-Service by FraunhoferIOSB.

the class RequestHandlerManagerTest method testGetAllSubmodelReferencesRequest.

@Test
public void testGetAllSubmodelReferencesRequest() throws ResourceNotFoundException {
    when(persistence.get(environment.getAssetAdministrationShells().get(0).getIdentification(), new OutputModifier())).thenReturn(environment.getAssetAdministrationShells().get(0));
    GetAllSubmodelReferencesRequest request = new GetAllSubmodelReferencesRequest.Builder().id(environment.getAssetAdministrationShells().get(0).getIdentification()).outputModifier(new OutputModifier()).build();
    GetAllSubmodelReferencesResponse response = manager.execute(request);
    GetAllSubmodelReferencesResponse expected = new GetAllSubmodelReferencesResponse.Builder().statusCode(StatusCode.Success).payload(environment.getAssetAdministrationShells().get(0).getSubmodels()).build();
    Assert.assertEquals(expected, response);
}
Also used : OutputModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier) GetAllSubmodelReferencesResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelReferencesResponse) GetAllSubmodelReferencesRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllSubmodelReferencesRequest) Test(org.junit.Test)

Example 2 with GetAllSubmodelReferencesResponse

use of de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelReferencesResponse in project FAAAST-Service by FraunhoferIOSB.

the class GetAllSubmodelsReferencesRequestHandler method process.

@Override
public GetAllSubmodelReferencesResponse process(GetAllSubmodelReferencesRequest request) {
    GetAllSubmodelReferencesResponse response = new GetAllSubmodelReferencesResponse();
    try {
        AssetAdministrationShell shell = (AssetAdministrationShell) persistence.get(request.getId(), request.getOutputModifier());
        List<Reference> submodelReferences = shell.getSubmodels();
        response.setPayload(submodelReferences);
        response.setStatusCode(StatusCode.Success);
        publishElementReadEventMessage(AasUtils.toReference(shell), shell);
    } catch (ResourceNotFoundException ex) {
        response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) GetAllSubmodelReferencesResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelReferencesResponse) Reference(io.adminshell.aas.v3.model.Reference) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)

Aggregations

GetAllSubmodelReferencesResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelReferencesResponse)2 ResourceNotFoundException (de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)1 OutputModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier)1 GetAllSubmodelReferencesRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.GetAllSubmodelReferencesRequest)1 AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)1 Reference (io.adminshell.aas.v3.model.Reference)1 Test (org.junit.Test)1