CommentHandler { public void store(DbComment comment) { repositoryHandler.store(comment); } 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 store() throws Exception { DbComment dbComment = new DbComment(); final RepositoryHandler repo = mock(RepositoryHandler.class); final CommentHandler commentHandler = new CommentHandler(repo); commentHandler.store(dbComment); verify(repo, times(1)).store(dbComment); }
@Test public void storeViaParameters() throws Exception { final String entityId = "com.axway.test:1.0.0::jar"; final String entityType = "DbArtifact"; final String action = "Some Action"; final String commentText = "Test Comment"; DbCredential credential = new DbCredential(); credential.setUser("testUser"); final RepositoryHandler repo = mock(RepositoryHandler.class); final CommentHandler commentHandler = new CommentHandler(repo); commentHandler.store(entityId, action, commentText, credential, entityType); ArgumentCaptor<DbComment> captor = ArgumentCaptor.forClass(DbComment.class); verify(repo, times(1)).store(captor.capture()); final DbComment arg = captor.getValue(); assertEquals(action, arg.getAction()); assertEquals(commentText, arg.getDbCommentText()); }