Date addedAt = new Date( System.currentTimeMillis() );
comment.setAddedAt( addedAt );
comment.setAddedBy( users.get( "luke" ) );
comment.setText( "This is my comment1!!!!!" );
BlockingAddCommentResponseHandler addCommentResponseHandler = new BlockingAddCommentResponseHandler();
client.addComment( taskId, comment,addCommentResponseHandler );
assertTrue( addCommentResponseHandler.getCommentId() != comment.getId() );
BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
client.getTask( taskId, getTaskResponseHandler );
Task task1 = getTaskResponseHandler.getTask();
assertNotSame(task, task1);
assertFalse( task.equals( task1) );
List<Comment> comments1 = task1.getTaskData().getComments();
assertEquals(1, comments1.size() );
Comment returnedComment = comments1.get( 0 );
assertEquals( "This is my comment1!!!!!", returnedComment.getText() );
assertEquals( addedAt, returnedComment.getAddedAt() );
assertEquals( users.get( "luke" ), returnedComment.getAddedBy() );
assertEquals( (long)addCommentResponseHandler.getCommentId(), (long) returnedComment.getId() );
// Make the same as the returned tasks, so we can test equals
task.getTaskData().setComments( comments1 );
task.getTaskData().setStatus( Status.Created );
assertEquals(task, task1);
// test we can have multiple comments
comment = new Comment();
addedAt = new Date( System.currentTimeMillis() );
comment.setAddedAt( addedAt );
comment.setAddedBy( users.get( "tony" ) );
comment.setText( "This is my comment2!!!!!" );
addCommentResponseHandler = new BlockingAddCommentResponseHandler();
client.addComment( taskId, comment, addCommentResponseHandler );
getTaskResponseHandler = new BlockingGetTaskResponseHandler();
client.getTask( taskId, getTaskResponseHandler );
task1 = getTaskResponseHandler.getTask();
List<Comment> comments2 = task1.getTaskData().getComments();
assertEquals(2, comments2.size() );
// make two collections the same and compare
comments1.add( comment );
assertTrue( CollectionUtils.equals( comments1, comments2 ) );
BlockingDeleteCommentResponseHandler deleteCommentResponseHandler = new BlockingDeleteCommentResponseHandler();
client.deleteComment( taskId, addCommentResponseHandler.getCommentId(), deleteCommentResponseHandler );
deleteCommentResponseHandler.waitTillDone( 3000 );
getTaskResponseHandler = new BlockingGetTaskResponseHandler();
client.getTask( taskId, getTaskResponseHandler );
task1 = getTaskResponseHandler.getTask();