@Test public void set_message() { boolean updated = underTest.setMessage(issue, "the message", context); assertThat(updated).isTrue(); assertThat(issue.isChanged()).isTrue(); assertThat(issue.message()).isEqualTo("the message"); assertThat(issue.mustSendNotifications()).isFalse(); }
@Test public void not_update_attribute() { issue.setAttribute("JIRA", "FOO-123"); boolean updated = underTest.setAttribute(issue, "JIRA", "FOO-123", context); assertThat(updated).isFalse(); assertThat(issue.mustSendNotifications()).isFalse(); }
@Test public void not_set_new_assignee_if_new_assignee_is_null() { boolean updated = underTest.setNewAssignee(issue, null, context); assertThat(updated).isFalse(); assertThat(issue.currentChange()).isNull(); assertThat(issue.mustSendNotifications()).isFalse(); }
@Test public void not_set_new_author_if_new_author_is_null() { boolean updated = underTest.setNewAuthor(issue, null, context); assertThat(updated).isFalse(); assertThat(issue.currentChange()).isNull(); assertThat(issue.mustSendNotifications()).isFalse(); }
@Test public void set_new_assignee() { boolean updated = underTest.setNewAssignee(issue, "user_uuid", context); assertThat(updated).isTrue(); assertThat(issue.assignee()).isEqualTo("user_uuid"); assertThat(issue.mustSendNotifications()).isTrue(); FieldDiffs.Diff diff = issue.currentChange().get(ASSIGNEE); assertThat(diff.oldValue()).isEqualTo(UNUSED); assertThat(diff.newValue()).isEqualTo("user_uuid"); }
@Test public void set_past_line() { issue.setLine(42); boolean updated = underTest.setPastLine(issue, 123); assertThat(updated).isTrue(); assertThat(issue.isChanged()).isTrue(); assertThat(issue.line()).isEqualTo(42); assertThat(issue.mustSendNotifications()).isFalse(); // do not save change assertThat(issue.currentChange()).isNull(); }
@Test public void not_set_gap_to_fix_if_unchanged() { issue.setGap(3.14); boolean updated = underTest.setGap(issue, 3.14, context); assertThat(updated).isFalse(); assertThat(issue.isChanged()).isFalse(); assertThat(issue.gap()).isEqualTo(3.14); assertThat(issue.mustSendNotifications()).isFalse(); }
@Test public void change_locations() { issue.setLocations("[1-3]"); boolean updated = underTest.setLocations(issue, "[1-4]"); assertThat(updated).isTrue(); assertThat(issue.getLocations().toString()).isEqualTo("[1-4]"); assertThat(issue.currentChange()).isNull(); assertThat(issue.mustSendNotifications()).isFalse(); }
@Test public void set_locations_for_the_first_time() { issue.setLocations(null); boolean updated = underTest.setLocations(issue, "[1-4]"); assertThat(updated).isTrue(); assertThat(issue.getLocations().toString()).isEqualTo("[1-4]"); assertThat(issue.currentChange()).isNull(); assertThat(issue.mustSendNotifications()).isFalse(); }
@Test public void set_past_line_has_no_effect_if_line_already_had_value() { issue.setLine(42); boolean updated = underTest.setPastLine(issue, 42); assertThat(updated).isFalse(); assertThat(issue.isChanged()).isFalse(); assertThat(issue.line()).isEqualTo(42); assertThat(issue.mustSendNotifications()).isFalse(); // do not save change assertThat(issue.currentChange()).isNull(); }
@Test public void not_change_severity() { issue.setSeverity("MINOR"); boolean updated = underTest.setSeverity(issue, "MINOR", context); assertThat(updated).isFalse(); assertThat(issue.mustSendNotifications()).isFalse(); assertThat(issue.currentChange()).isNull(); }
@Test public void set_resolution() { boolean updated = underTest.setResolution(issue, "OPEN", context); assertThat(updated).isTrue(); assertThat(issue.resolution()).isEqualTo("OPEN"); FieldDiffs.Diff diff = issue.currentChange().get(RESOLUTION); assertThat(diff.oldValue()).isNull(); assertThat(diff.newValue()).isEqualTo("OPEN"); assertThat(issue.mustSendNotifications()).isTrue(); }
@Test public void setIssueMoved_has_no_effect_if_component_uuid_is_not_changed() { String componentUuid = "a"; issue.setComponentUuid(componentUuid); underTest.setIssueMoved(issue, componentUuid, context); assertThat(issue.changes()).isEmpty(); assertThat(issue.componentUuid()).isEqualTo(componentUuid); assertThat(issue.isChanged()).isFalse(); assertThat(issue.updateDate()).isNull(); assertThat(issue.mustSendNotifications()).isFalse(); }
@Test public void unset_line_has_no_effect_if_line_is_already_null() { issue.setLine(null); boolean updated = underTest.unsetLine(issue, context); assertThat(updated).isFalse(); assertThat(issue.line()).isNull(); assertThat(issue.isChanged()).isFalse(); assertThat(issue.currentChange()).isNull(); assertThat(issue.mustSendNotifications()).isFalse(); }
@Test public void not_change_manual_severity() { issue.setSeverity("MINOR").setManualSeverity(true); boolean updated = underTest.setManualSeverity(issue, "MINOR", context); assertThat(updated).isFalse(); assertThat(issue.currentChange()).isNull(); assertThat(issue.mustSendNotifications()).isFalse(); }
@Test public void set_past_gap() { issue.setGap(3.14); boolean updated = underTest.setPastGap(issue, 1.0, context); assertThat(updated).isTrue(); assertThat(issue.gap()).isEqualTo(3.14); // do not save change assertThat(issue.currentChange()).isNull(); assertThat(issue.mustSendNotifications()).isFalse(); }
@Test public void set_past_technical_debt_without_previous_value() { Duration newDebt = Duration.create(15 * 8 * 60); issue.setEffort(newDebt); boolean updated = underTest.setPastEffort(issue, null, context); assertThat(updated).isTrue(); assertThat(issue.effort()).isEqualTo(newDebt); assertThat(issue.mustSendNotifications()).isFalse(); FieldDiffs.Diff diff = issue.currentChange().get(TECHNICAL_DEBT); assertThat(diff.oldValue()).isNull(); assertThat(diff.newValue()).isEqualTo(15L * 8 * 60); }
@Test public void assign() { UserDto user = newUserDto().setLogin("emmerik").setName("Emmerik"); boolean updated = underTest.assign(issue, user, context); assertThat(updated).isTrue(); assertThat(issue.assignee()).isEqualTo(user.getUuid()); assertThat(issue.mustSendNotifications()).isTrue(); FieldDiffs.Diff diff = issue.currentChange().get(ASSIGNEE); assertThat(diff.oldValue()).isEqualTo(UNUSED); assertThat(diff.newValue()).isEqualTo(user.getName()); }
@Test public void change_assignee() { UserDto user = newUserDto().setLogin("emmerik").setName("Emmerik"); issue.setAssigneeUuid("user_uuid"); boolean updated = underTest.assign(issue, user, context); assertThat(updated).isTrue(); assertThat(issue.assignee()).isEqualTo(user.getUuid()); assertThat(issue.mustSendNotifications()).isTrue(); FieldDiffs.Diff diff = issue.currentChange().get(ASSIGNEE); assertThat(diff.oldValue()).isEqualTo(UNUSED); assertThat(diff.newValue()).isEqualTo(user.getName()); }
@Test public void set_new_attribute_value() { boolean updated = underTest.setAttribute(issue, "JIRA", "FOO-123", context); assertThat(updated).isTrue(); assertThat(issue.attribute("JIRA")).isEqualTo("FOO-123"); assertThat(issue.currentChange().diffs()).hasSize(1); assertThat(issue.currentChange().get("JIRA").oldValue()).isNull(); assertThat(issue.currentChange().get("JIRA").newValue()).isEqualTo("FOO-123"); assertThat(issue.mustSendNotifications()).isFalse(); }