### Question:
IssueManager { @Transactional(propagation = Propagation.REQUIRED) public Issue createIssue(IssueVO issueVO) { validateIssueParameters(issueVO); EntityVO entityVO = issueVO.getEntity(); validateEntityParameters(entityVO); AbstractSecuredEntity entity = ensureEntityExists(entityVO); validateEntityCanBeModified(entityVO); Issue issue = issueMapper.toIssue(issueVO); issue.setAuthor(authManager.getAuthorizedUser()); issueDao.createIssue(issue); issueVO.getAttachments().forEach(a -> attachmentDao.updateAttachmentIssueId(a.getId(), issue.getId())); notificationManager.notifyIssue(issue, entity, StringUtils.defaultIfBlank(issueVO.getHtmlText(), issue.getText())); return issue; }  @Transactional(propagation = Propagation.REQUIRED) Issue createIssue(IssueVO issueVO); Issue loadIssue(Long id); PagedResult<List<Issue>> loadMy(Long page, Integer pageSize); List<Issue> loadIssuesForEntity(EntityVO entityVO); @Transactional(propagation = Propagation.REQUIRED) Issue updateIssue(Long issueId, IssueVO issueVO); @Transactional(propagation = Propagation.REQUIRED) Issue deleteIssue(Long issueId); @Transactional(propagation = Propagation.REQUIRED) List<Issue> deleteIssuesForEntity(EntityVO entity); @Transactional(propagation = Propagation.REQUIRED) IssueComment createComment(Long issueId, IssueCommentVO commentVO); IssueComment loadComment(Long issueId, Long commentId); @Transactional(propagation = Propagation.REQUIRED) IssueComment updateComment(Long issueId, Long commentId, IssueCommentVO commentVO); @Transactional(propagation = Propagation.REQUIRED) IssueComment deleteComment(Long issueId, Long commentId);  }### Answer:
@Test public void testCreateIssue() { when(authManager.getAuthorizedUser()).thenReturn(AUTHOR); IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO); Issue saved = issueManager.createIssue(issueVO); Issue loaded = issueManager.loadIssue(saved.getId()); compareIssues(saved, loaded); ArgumentCaptor<Issue> captor = ArgumentCaptor.forClass(Issue.class); ArgumentCaptor<String> htmlTextCaptor = ArgumentCaptor.forClass(String.class); verify(notificationManager).notifyIssue(captor.capture(), any(), htmlTextCaptor.capture()); assertEquals(ISSUE_TEXT, captor.getValue().getText()); assertEquals(ISSUE_TEXT, htmlTextCaptor.getValue()); }
@Test(expected = IllegalArgumentException.class) public void creatingIssueForNonExistentEntityShouldThrowException() { when(authManager.getAuthorizedUser()).thenReturn(AUTHOR); Long nonExistentEntityId = 1L; EntityVO nonExistentEntity = new EntityVO(nonExistentEntityId, AclClass.PIPELINE); IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, nonExistentEntity); issueManager.createIssue(issueVO); verify(notificationManager, Mockito.never()).notifyIssue(any(), any(), any()); }
@Test(expected = IllegalArgumentException.class) public void creatingIssueWithEmptyNameShouldThrowException() { when(authManager.getAuthorizedUser()).thenReturn(AUTHOR); IssueVO issueVO = getIssueVO("", ISSUE_TEXT, entityVO); issueManager.createIssue(issueVO); }