### Question:
IssueManager { @Transactional(propagation = Propagation.REQUIRED) public Issue updateIssue(Long issueId, IssueVO issueVO) { validateIssueParameters(issueVO); Issue existingIssue = loadIssueAndCheckIfNotClosed(issueId); Issue issue = updateIssueObject(existingIssue, issueVO); issueDao.updateIssue(issue); HashSet<Attachment> newAttachments = new HashSet<>(issueVO.getAttachments()); List<Attachment> allAttachments = attachmentDao.loadAttachmentsByIssueId(issueId); List<Attachment> toDelete = allAttachments.stream().filter(a -> !newAttachments.contains(a)) .collect(Collectors.toList()); attachmentFileManager.deleteAttachments(toDelete); issueVO.getAttachments().forEach(a -> attachmentDao.updateAttachmentIssueId(a.getId(), issueId)); 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 testUpdateIssue() { when(authManager.getAuthorizedUser()).thenReturn(AUTHOR); IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO); Issue saved = issueManager.createIssue(issueVO); issueVO.setName(ISSUE_NAME2); issueVO.setText(ISSUE_TEXT2); issueVO.setStatus(IssueStatus.OPEN); issueVO.setLabels(Arrays.asList(LABEL1, LABEL2, LABEL3)); Long issueId = saved.getId(); issueManager.updateIssue(issueId, issueVO); Issue updated = issueMapper.toIssue(issueVO); updated.setAuthor(AUTHOR); compareIssues(issueManager.loadIssue(issueId), updated); }
@Test(expected = IllegalArgumentException.class) public void updatingClosedIssueShouldThrowException() { when(authManager.getAuthorizedUser()).thenReturn(AUTHOR); Issue closedIssue = getClosedIssue(); IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO); issueVO.setLabels(Collections.singletonList(LABEL1)); issueManager.updateIssue(closedIssue.getId(), issueVO); }