@Test public void should_fail_if_tag_is_not_valid() { throwable.expect(IllegalArgumentException.class); throwable.expectMessage("Tag 'th ag' is invalid. Rule tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'"); Map<String, Object> properties = new HashMap<>(); properties.put("tags", "th ag"); DefaultIssue issue = mock(DefaultIssue.class); when(issue.tags()).thenReturn(ImmutableSet.of("tag1", "tag3")); Action.Context context = mock(Action.Context.class); when(context.issue()).thenReturn(issue); underTest.execute(properties, context); } }
@Override public boolean execute(Map<String, Object> properties, Context context) { checkArgument(properties.containsKey(VERIFIED_ASSIGNEE), "Assignee is missing from the execution parameters"); UserDto assignee = (UserDto) properties.get(VERIFIED_ASSIGNEE); return isAssigneeMemberOfIssueOrganization(assignee, properties, context) && issueFieldsSetter.assign(context.issue(), assignee, context.issueChangeContext()); }
private static boolean isAssigneeMemberOfIssueOrganization(@Nullable UserDto assignee, Map<String, Object> properties, Context context) { return assignee == null || ((Set<String>) properties.get(ASSIGNEE_ORGANIZATIONS)).contains(context.project().getOrganizationUuid()); } }
@Override public boolean execute(Map<String, Object> properties, Context context) { return issueUpdater.setManualSeverity(context.issue(), verifySeverityParameter(properties), context.issueChangeContext()); }
@Override protected Collection<String> getTagsToSet(Context context, Collection<String> tagsFromParams) { Set<String> newTags = new HashSet<>(context.issue().tags()); newTags.removeAll(tagsFromParams); return newTags; } }
@Override protected Collection<String> getTagsToSet(Context context, Collection<String> tagsFromParams) { Set<String> allTags = new HashSet<>(context.issue().tags()); allTags.addAll(tagsFromParams); return allTags; } }
@Override public boolean execute(Map<String, Object> properties, Context context) { checkArgument(properties.containsKey(VERIFIED_ASSIGNEE), "Assignee is missing from the execution parameters"); UserDto assignee = (UserDto) properties.get(VERIFIED_ASSIGNEE); return isAssigneeMemberOfIssueOrganization(assignee, properties, context) && issueFieldsSetter.assign(context.issue(), assignee, context.issueChangeContext()); }
@Override public boolean execute(Map<String, Object> properties, Context context) { DefaultIssue issue = context.issue(); String transition = transition(properties); return canExecuteTransition(issue, transition) && transitionService.doTransition(context.issue(), context.issueChangeContext(), transition(properties)); }
private static boolean isAssigneeMemberOfIssueOrganization(@Nullable UserDto assignee, Map<String, Object> properties, Context context) { return assignee == null || ((Set<String>) properties.get(ASSIGNEE_ORGANIZATIONS)).contains(context.project().getOrganizationUuid()); } }
@Override public boolean execute(Map<String, Object> properties, Context context) { String type = verifyTypeParameter(properties); return issueUpdater.setType(context.issue(), RuleType.valueOf(type), context.issueChangeContext()); }
@Override public boolean execute(Map<String, Object> properties, Context context) { Collection<String> tags = getTagsToSet(context, parseTags(properties)); return issueUpdater.setTags(context.issue(), tags, context.issueChangeContext()); }
@Override public boolean execute(Map<String, Object> properties, Context context) { issueUpdater.addComment(context.issue(), comment(properties), context.issueChangeContext()); return true; }
@Test public void should_fail_if_tag_is_not_valid() { throwable.expect(IllegalArgumentException.class); throwable.expectMessage("Tag 'th ag' is invalid. Rule tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'"); Map<String, Object> properties = newHashMap(); properties.put("tags", "th ag"); DefaultIssue issue = mock(DefaultIssue.class); when(issue.tags()).thenReturn(ImmutableSet.of("tag1", "tag3")); Action.Context context = mock(Action.Context.class); when(context.issue()).thenReturn(issue); action.execute(properties, context); } }
@Test public void should_execute() { String comment = "My bulk change comment"; Map<String, Object> properties = newHashMap(); properties.put("comment", comment); DefaultIssue issue = mock(DefaultIssue.class); Action.Context context = mock(Action.Context.class); when(context.issue()).thenReturn(issue); action.execute(properties, context); verify(issueUpdater).addComment(eq(issue), eq(comment), any()); }
@Override public boolean execute(Map<String, Object> properties, Context context) { issueUpdater.addComment(context.issue(), comment(properties), context.issueChangeContext()); return true; }
@Override public boolean execute(Map<String, Object> properties, Context context) { String type = verifyTypeParameter(properties); return issueUpdater.setType(context.issue(), RuleType.valueOf(type), context.issueChangeContext()); }
@Test @SuppressWarnings("unchecked") public void should_execute() { Map<String, Object> properties = new HashMap<>(); properties.put("tags", "tag2,tag3"); DefaultIssue issue = mock(DefaultIssue.class); when(issue.tags()).thenReturn(ImmutableSet.of("tag1", "tag3")); Action.Context context = mock(Action.Context.class, Mockito.RETURNS_DEEP_STUBS); when(context.issue()).thenReturn(issue); underTest.execute(properties, context); verify(issue).setTags(ImmutableSet.of("tag1", "tag2", "tag3")); }
@Override public boolean execute(Map<String, Object> properties, Context context) { Collection<String> tags = getTagsToSet(context, parseTags(properties)); return issueUpdater.setTags(context.issue(), tags, context.issueChangeContext()); }
@Override public boolean execute(Map<String, Object> properties, Context context) { return issueUpdater.setManualSeverity(context.issue(), verifySeverityParameter(properties), context.issueChangeContext()); }
@Override protected Collection<String> getTagsToSet(Context context, Collection<String> tagsFromParams) { Set<String> allTags = new HashSet<>(context.issue().tags()); allTags.addAll(tagsFromParams); return allTags; } }