Search in sources :

Example 1 with GetAssetAdministrationShellResponse

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

the class GetAssetAdministrationShellRequestHandler method process.

@Override
public GetAssetAdministrationShellResponse process(GetAssetAdministrationShellRequest request) {
    GetAssetAdministrationShellResponse response = new GetAssetAdministrationShellResponse();
    try {
        AssetAdministrationShell shell = (AssetAdministrationShell) persistence.get(request.getId(), request.getOutputModifier());
        response.setPayload(shell);
        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 : GetAssetAdministrationShellResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAssetAdministrationShellResponse) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)

Example 2 with GetAssetAdministrationShellResponse

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

the class RequestHandlerManagerTest method testGetAssetAdministrationShellRequest.

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

Aggregations

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