Task task = ( Task ) eval( new StringReader( str ), vars );
client.addTask( task, null, addTaskResponseHandler );
long taskId = addTaskResponseHandler.getTaskId();
Comment comment = new Comment();
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!!!!!" );