CommentHandler { public List<DbComment> getComments(String entityId, String entityType) { return repositoryHandler.getComments(entityId, entityType); } CommentHandler(final RepositoryHandler repositoryHandler); void store(DbComment comment); List<DbComment> getComments(String entityId, String entityType); void store(String gavc,
                      String action,
                      String commentText,
                      DbCredential credential,
                      String entityType); DbComment getLatestComment(String entityId, String entityType);  }
@Test public void getComments() throws Exception { final String entityId = "com.axway.test:1.0.0::jar"; final String entityType = "DbArtifact"; DbComment dbComment = new DbComment(); dbComment.setEntityId(entityId); dbComment.setEntityType(entityType); dbComment.setDbCommentText("test comment"); dbComment.setDbCommentedBy("testUser"); dbComment.setDbCreatedDateTime(new Date()); DbComment dbCommentSecond = new DbComment(); dbCommentSecond.setEntityId(entityId); dbCommentSecond.setEntityType(entityType); dbCommentSecond.setDbCommentText("test comment second"); dbCommentSecond.setDbCommentedBy("testUser"); dbCommentSecond.setDbCreatedDateTime(new Date()); final RepositoryHandler repo = mock(RepositoryHandler.class); final CommentHandler commentHandler = new CommentHandler(repo); commentHandler.store(dbComment); commentHandler.store(dbCommentSecond); List<DbComment> commentList = new ArrayList<>(); commentList.add(dbComment); commentList.add(dbCommentSecond); when(repo.getComments(entityId, entityType)).thenReturn(commentList); assertEquals(repo.getComments(entityId, entityType), commentList); }