Search in sources :

Example 1 with DeleteAssetAdministrationShellByIdResponse

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

the class RequestHandlerManagerTest method testDeleteAssetAdministrationShellByIdRequest.

@Test
public void testDeleteAssetAdministrationShellByIdRequest() throws ResourceNotFoundException {
    when(persistence.get(environment.getAssetAdministrationShells().get(0).getIdentification(), new QueryModifier())).thenReturn(environment.getAssetAdministrationShells().get(0));
    DeleteAssetAdministrationShellByIdRequest request = new DeleteAssetAdministrationShellByIdRequest().builder().id(environment.getAssetAdministrationShells().get(0).getIdentification()).build();
    DeleteAssetAdministrationShellByIdResponse response = manager.execute(request);
    DeleteAssetAdministrationShellByIdResponse expected = new DeleteAssetAdministrationShellByIdResponse.Builder().statusCode(StatusCode.Success).build();
    Assert.assertEquals(expected, response);
    verify(persistence).remove(environment.getAssetAdministrationShells().get(0).getIdentification());
}
Also used : DeleteAssetAdministrationShellByIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteAssetAdministrationShellByIdResponse) QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) DeleteAssetAdministrationShellByIdRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteAssetAdministrationShellByIdRequest) Test(org.junit.Test)

Example 2 with DeleteAssetAdministrationShellByIdResponse

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

the class DeleteAssetAdministrationShellByIdRequestHandler method process.

@Override
public DeleteAssetAdministrationShellByIdResponse process(DeleteAssetAdministrationShellByIdRequest request) {
    DeleteAssetAdministrationShellByIdResponse response = new DeleteAssetAdministrationShellByIdResponse();
    try {
        AssetAdministrationShell shell = (AssetAdministrationShell) persistence.get(request.getId(), new QueryModifier());
        persistence.remove(request.getId());
        response.setStatusCode(StatusCode.Success);
        publishElementDeleteEventMessage(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) DeleteAssetAdministrationShellByIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteAssetAdministrationShellByIdResponse) QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)

Aggregations

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