use of org.wso2.carbon.humantask.core.engine.commands.DeleteComment in project carbon-apimgt by wso2.
the class APIStoreImplTestCase method testDeleteComment.
@Test(description = "Delete comment")
public void testDeleteComment() throws APIManagementException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
APIStore apiStore = getApiStoreImpl(apiDAO);
API api = SampleTestObjectCreator.createDefaultAPI().build();
Mockito.when(apiDAO.isAPIExists(api.getId())).thenReturn(true);
Comment comment = SampleTestObjectCreator.createDefaultComment(api.getId());
Mockito.when(apiDAO.getCommentByUUID(comment.getUuid(), api.getId())).thenReturn(comment);
apiStore.deleteComment(comment.getUuid(), api.getId(), "admin");
Mockito.verify(apiDAO, Mockito.times(1)).isAPIExists(api.getId());
Mockito.verify(apiDAO, Mockito.times(1)).deleteComment(comment.getUuid(), api.getId());
}
use of org.wso2.carbon.humantask.core.engine.commands.DeleteComment in project carbon-business-process by wso2.
the class TaskOperationsImpl method deleteComment.
/**
* Deletes the identified comment.
* @param taskIdURI : task identifier
* @param commentId : comment identifier
* @throws IllegalStateFault
* @throws IllegalOperationFault
* @throws IllegalArgumentFault
* @throws IllegalAccessFault
*/
public void deleteComment(final URI taskIdURI, final URI commentId) throws IllegalStateFault, IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
try {
final Long taskId = validateTaskId(taskIdURI);
HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Object>() {
public Object call() throws Exception {
DeleteComment deleteComment = new DeleteComment(getCaller(), taskId, new Long(commentId.toString()));
deleteComment.execute();
return null;
}
});
} catch (Exception ex) {
handleException(ex);
}
}
use of org.wso2.carbon.humantask.core.engine.commands.DeleteComment in project carbon-business-process by wso2.
the class WorkflowTaskService method deleteComment.
@DELETE
@Path("/{taskId}/comments/{commentId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response deleteComment(@PathParam("taskId") String taskId, @PathParam("commentId") String commentId) {
// Check if task exists
Task task = getTaskFromRequest(taskId);
TaskService taskService = BPMNOSGIService.getTaskService();
Comment comment = taskService.getComment(commentId);
if (comment == null || comment.getTaskId() == null || !comment.getTaskId().equals(task.getId())) {
throw new ActivitiObjectNotFoundException("Task '" + task.getId() + "' doesn't have a comment with id '" + commentId + "'.", Comment.class);
}
taskService.deleteComment(commentId);
return Response.ok().status(Response.Status.NO_CONTENT).build();
}
use of org.wso2.carbon.humantask.core.engine.commands.DeleteComment in project carbon-apimgt by wso2.
the class ApisApiServiceImplTestCase method testApisApiIdCommentsCommentIdDelete.
@Test
public void testApisApiIdCommentsCommentIdDelete() throws NotFoundException, APIManagementException {
printTestMethodName();
String apiId = UUID.randomUUID().toString();
String commentId = UUID.randomUUID().toString();
ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
APIStore apiStore = Mockito.mock(APIStoreImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getConsumer(USER)).thenReturn(apiStore);
Request request = getRequest();
PowerMockito.when(RestApiUtil.getLoggedInUsername(request)).thenReturn(USER);
Mockito.doNothing().doThrow(new IllegalArgumentException()).when(apiStore).deleteComment(commentId, apiId, USER);
javax.ws.rs.core.Response response = apisApiService.apisApiIdCommentsCommentIdDelete(null, apiId, null, null, request);
Assert.assertEquals(200, response.getStatus());
}
Aggregations