@Test public void shouldAddCustomFieldParamsOnDelete() throws Exception { final CustomField customField1 = createMock(CustomField.class); expect(customField1.getId()).andReturn("customfield_10000"); expect(customField1.getValue(issue)).andReturn("Value1"); final CustomField customField2 = createMock(CustomField.class); expect(customField2.getId()).andReturn("customfield_10001"); expect(customField2.getValue(issue)).andReturn("Value2"); replay(customField1, customField2); expect(customFieldManager.getCustomFieldObjects(issue)) .andReturn(ImmutableList.of(customField1, customField2)); IssueDeleteHelper tested = getIssueDeleteHelper(); setUpEmptyWatchers(); expect(mockSubTaskManager.isSubTask(issueGenericValue)).andReturn(false); replayMocks(); tested.deleteIssue((User) null, issue, EventDispatchOption.ISSUE_DELETED, true); makeAssertions(); verify(customField1, customField2); final Map<String, Object> expected = ImmutableMap.<String, Object>of( "customfield_10000", "Value1", "customfield_10001", "Value2"); assertEquals(expected, capturedEventParams.get(IssueEvent.CUSTOM_FIELDS_PARAM_NAME)); assertTrue(capturedSendMailFlag); }
@Test public void shouldDeleteNotSubtask() throws Exception { setUpEmptyCustomFields(); IssueDeleteHelper tested = getIssueDeleteHelper(); setUpEmptyWatchers(); expect(mockSubTaskManager.isSubTask(issueGenericValue)).andReturn(false); replayMocks(); tested.deleteIssue((User) null, issue, EventDispatchOption.ISSUE_DELETED, false); makeAssertions(); assertFalse(capturedSendMailFlag); }
@Test public void shouldAddWatchersParamOnDelete() throws Exception { setUpEmptyCustomFields(); IssueDeleteHelper tested = getIssueDeleteHelper(); expect(mockIssueManager.getWatchers(issue)) .andReturn(ImmutableList.<User>of(new MockUser("one"), new MockUser("two"))); expect(mockSubTaskManager.isSubTask(issueGenericValue)).andReturn(false); replayMocks(); tested.deleteIssue((User) null, issue, EventDispatchOption.ISSUE_DELETED, true); makeAssertions(); final List<User> expected = ImmutableList.<User>of(new MockUser("one"), new MockUser("two")); assertEquals(expected, capturedEventParams.get(IssueEvent.WATCHERS_PARAM_NAME)); assertTrue(capturedSendMailFlag); }
@Test public void shouldDeleteSubTaskWithLinks() throws Exception { setUpEmptyCustomFields(); IssueDeleteHelper tested = getIssueDeleteHelper(); setUpEmptyWatchers(); MutableIssue parentIssue = createNiceMock(MutableIssue.class); expect(parentIssue.getId()).andReturn(PARENT_ISSUE_ID); replay(parentIssue); expect(mockSubTaskManager.isSubTask(issueGenericValue)).andReturn(true); expect(mockSubTaskManager.getParentIssueId(issueGenericValue)).andReturn(PARENT_ISSUE_ID); mockSubTaskManager.resetSequences(parentIssue); expectLastCall(); expect(mockIssueManager.getIssueObject(PARENT_ISSUE_ID)).andReturn(parentIssue); replayMocks(); tested.deleteIssue((User) null, issue, EventDispatchOption.ISSUE_DELETED, true); makeAssertions(); assertTrue(capturedSendMailFlag); }