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());
}
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());
}
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;
}
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);
}
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);
}
Aggregations