Search in sources :

Example 1 with DeleteSubmodelByIdResponse

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

the class RequestHandlerManagerTest method testDeleteSubmodelByIdRequest.

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

Example 2 with DeleteSubmodelByIdResponse

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

the class ApiTest method testHashCode.

@Test
public void testHashCode() {
    DeleteSubmodelByIdResponse deleteSubmodelByIdResponseA = new DeleteSubmodelByIdResponse();
    DeleteSubmodelByIdResponse deleteSubmodelByIdResponseB = new DeleteSubmodelByIdResponse();
    deleteSubmodelByIdResponseB.setStatusCode(ClientErrorBadRequest);
    Assert.assertNotEquals(deleteSubmodelByIdResponseA.hashCode(), deleteSubmodelByIdResponseB.hashCode());
}
Also used : DeleteSubmodelByIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteSubmodelByIdResponse) Test(org.junit.Test)

Example 3 with DeleteSubmodelByIdResponse

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

the class DeleteSubmodelByIdRequestHandler method process.

@Override
public DeleteSubmodelByIdResponse process(DeleteSubmodelByIdRequest request) {
    DeleteSubmodelByIdResponse response = new DeleteSubmodelByIdResponse();
    try {
        Submodel submodel = (Submodel) persistence.get(request.getId(), new QueryModifier());
        persistence.remove(request.getId());
        response.setStatusCode(StatusCode.Success);
        // TODO: Delete AssetConnections of underlying submodel elements?
        publishElementDeleteEventMessage(AasUtils.toReference(submodel), submodel);
    } catch (ResourceNotFoundException ex) {
        response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : Submodel(io.adminshell.aas.v3.model.Submodel) DeleteSubmodelByIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteSubmodelByIdResponse) 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)

Example 4 with DeleteSubmodelByIdResponse

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

the class ApiTest method testEqualsNotSame.

@Test
public void testEqualsNotSame() {
    DeleteSubmodelByIdResponse deleteSubmodelByIdResponseA = new DeleteSubmodelByIdResponse();
    DeleteSubmodelByIdResponse deleteSubmodelByIdResponseB = new DeleteSubmodelByIdResponse();
    deleteSubmodelByIdResponseB.setStatusCode(ClientErrorBadRequest);
    Assert.assertNotEquals(deleteSubmodelByIdResponseA, deleteSubmodelByIdResponseB);
}
Also used : DeleteSubmodelByIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteSubmodelByIdResponse) Test(org.junit.Test)

Example 5 with DeleteSubmodelByIdResponse

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

the class ApiTest method testEqualsSame.

@Test
public void testEqualsSame() {
    DeleteSubmodelByIdResponse deleteSubmodelByIdResponse = new DeleteSubmodelByIdResponse();
    Assert.assertEquals(deleteSubmodelByIdResponse, deleteSubmodelByIdResponse);
}
Also used : DeleteSubmodelByIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteSubmodelByIdResponse) Test(org.junit.Test)

Aggregations

DeleteSubmodelByIdResponse (de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteSubmodelByIdResponse)5 Test (org.junit.Test)4 QueryModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier)2 ResourceNotFoundException (de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)1 DeleteSubmodelByIdRequest (de.fraunhofer.iosb.ilt.faaast.service.model.request.DeleteSubmodelByIdRequest)1 Submodel (io.adminshell.aas.v3.model.Submodel)1