use of org.wso2.carbon.apimgt.api.model.Comment in project carbon-apimgt by wso2.
the class APIStoreImplTestCase method testDeleteCommentMissingException.
@Test(description = "Comment not found in db when retrieving comment before delete", expectedExceptions = APIMgtResourceNotFoundException.class)
public void testDeleteCommentMissingException() throws APIManagementException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
APIStore apiStore = getApiStoreImpl(apiDAO);
API api = SampleTestObjectCreator.createDefaultAPI().build();
Mockito.when(apiDAO.getAPI(api.getId())).thenReturn(api);
String randomUUIDForComment = java.util.UUID.randomUUID().toString();
Mockito.when(apiDAO.getCommentByUUID(randomUUIDForComment, api.getId())).thenReturn(null);
apiStore.deleteComment(randomUUIDForComment, api.getId(), "admin");
}
use of org.wso2.carbon.apimgt.api.model.Comment in project carbon-apimgt by wso2.
the class APIStoreImplTestCase method testGetComment.
@Test(description = "Get comment")
public void testGetComment() 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.getCommentByUUID(comment.getUuid(), api.getId());
Mockito.verify(apiDAO, Mockito.times(1)).isAPIExists(api.getId());
Mockito.verify(apiDAO, Mockito.times(1)).getCommentByUUID(comment.getUuid(), api.getId());
}
use of org.wso2.carbon.apimgt.api.model.Comment in project carbon-apimgt by wso2.
the class CommentMappingUtilTestCase method testFromCommentListToDTO.
@Test
public void testFromCommentListToDTO() {
Comment comment1 = new Comment();
comment1.setUuid(UUID.randomUUID().toString());
comment1.setCommentedUser("commentedUser1");
comment1.setCommentText("this is a comment 1");
comment1.setCreatedUser("createdUser1");
comment1.setUpdatedUser("updatedUser1");
comment1.setCreatedTime(LocalDateTime.now().minusHours(1));
comment1.setUpdatedTime(LocalDateTime.now());
Comment comment2 = new Comment();
comment2.setUuid(UUID.randomUUID().toString());
comment2.setCommentedUser("commentedUser2");
comment2.setCommentText("this is a comment 2");
comment2.setCreatedUser("createdUser2");
comment2.setUpdatedUser("updatedUser2");
comment2.setCreatedTime(LocalDateTime.now().minusHours(1));
comment2.setUpdatedTime(LocalDateTime.now());
List<Comment> commentList = new ArrayList<>();
commentList.add(comment1);
commentList.add(comment2);
CommentListDTO commentListDTO = commentMappingUtil.fromCommentListToDTO(commentList, 10, 0);
Assert.assertEquals(commentListDTO.getList().get(0).getUsername().toString(), "commentedUser1");
}
use of org.wso2.carbon.apimgt.api.model.Comment 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.apimgt.api.model.Comment in project carbon-business-process by wso2.
the class WorkflowTaskService method getComment.
@GET
@Path("/{taskId}/comments/{commentId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getComment(@PathParam("taskId") String taskId, @PathParam("commentId") String commentId) {
HistoricTaskInstance task = getHistoricTaskFromRequest(taskId);
TaskService taskService = BPMNOSGIService.getTaskService();
Comment comment = taskService.getComment(commentId);
if (comment == null || !task.getId().equals(comment.getTaskId())) {
throw new ActivitiObjectNotFoundException("Task '" + task.getId() + "' doesn't have a comment with id '" + commentId + "'.", Comment.class);
}
return Response.ok().entity(new RestResponseFactory().createRestComment(comment, uriInfo.getBaseUri().toString())).build();
}
Aggregations