Search in sources :

Example 1 with PostAssetAdministrationShellResponse

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

the class RequestHandlerManagerTest method testPostAssetAdministrationShellRequest.

@Test
public void testPostAssetAdministrationShellRequest() {
    when(persistence.put(environment.getAssetAdministrationShells().get(0))).thenReturn(environment.getAssetAdministrationShells().get(0));
    PostAssetAdministrationShellRequest request = new PostAssetAdministrationShellRequest.Builder().aas(environment.getAssetAdministrationShells().get(0)).build();
    PostAssetAdministrationShellResponse response = manager.execute(request);
    PostAssetAdministrationShellResponse expected = new PostAssetAdministrationShellResponse.Builder().payload(environment.getAssetAdministrationShells().get(0)).statusCode(StatusCode.SuccessCreated).build();
    Assert.assertEquals(expected, response);
}
Also used : PostAssetAdministrationShellResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PostAssetAdministrationShellResponse) PostAssetAdministrationShellRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.PostAssetAdministrationShellRequest) Test(org.junit.Test)

Example 2 with PostAssetAdministrationShellResponse

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

the class PostAssetAdministrationShellRequestHandler method process.

@Override
public PostAssetAdministrationShellResponse process(PostAssetAdministrationShellRequest request) {
    PostAssetAdministrationShellResponse response = new PostAssetAdministrationShellResponse();
    try {
        AssetAdministrationShell shell = (AssetAdministrationShell) persistence.put(request.getAas());
        response.setPayload(shell);
        response.setStatusCode(StatusCode.SuccessCreated);
        publishElementCreateEventMessage(AasUtils.toReference(shell), shell);
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) PostAssetAdministrationShellResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PostAssetAdministrationShellResponse)

Aggregations

PostAssetAdministrationShellResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PostAssetAdministrationShellResponse)2 PostAssetAdministrationShellRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.PostAssetAdministrationShellRequest)1 AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)1 Test (org.junit.Test)1