Search in sources :

Example 1 with PutAssetAdministrationShellResponse

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

the class RequestHandlerManagerTest method testPutAssetAdministrationShellRequest.

@Test
public void testPutAssetAdministrationShellRequest() throws ResourceNotFoundException {
    // @TODO: open/unclear
    // expected Identifiable
    when(persistence.put(environment.getAssetAdministrationShells().get(0))).thenReturn(environment.getAssetAdministrationShells().get(0));
    PutAssetAdministrationShellRequest request = new PutAssetAdministrationShellRequest.Builder().aas(environment.getAssetAdministrationShells().get(0)).id(AAS.getIdentification()).build();
    PutAssetAdministrationShellResponse response = manager.execute(request);
    PutAssetAdministrationShellResponse expected = new PutAssetAdministrationShellResponse.Builder().payload(environment.getAssetAdministrationShells().get(0)).statusCode(StatusCode.Success).build();
    Assert.assertEquals(expected, response);
}
Also used : PutAssetAdministrationShellResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutAssetAdministrationShellResponse) PutAssetAdministrationShellRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PutAssetAdministrationShellRequest) Test(org.junit.Test)

Example 2 with PutAssetAdministrationShellResponse

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

the class PutAssetAdministrationShellRequestHandler method process.

@Override
public PutAssetAdministrationShellResponse process(PutAssetAdministrationShellRequest request) {
    PutAssetAdministrationShellResponse response = new PutAssetAdministrationShellResponse();
    try {
        AssetAdministrationShell shell = (AssetAdministrationShell) persistence.get(request.getAas().getIdentification(), new OutputModifier());
        shell = (AssetAdministrationShell) persistence.put(request.getAas());
        response.setPayload(shell);
        response.setStatusCode(StatusCode.Success);
        publishElementUpdateEventMessage(AasUtils.toReference(shell), shell);
    } catch (ResourceNotFoundException ex) {
        response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : PutAssetAdministrationShellResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutAssetAdministrationShellResponse) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) OutputModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)

Aggregations

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