use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class PersistIssuesStepTest method add_comment.
@Test
public void add_comment() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
issueCache.newAppender().append(new DefaultIssue().setKey("ISSUE").setType(RuleType.CODE_SMELL).setRuleKey(RuleKey.of("xoo", "S01")).setComponentUuid("COMPONENT").setProjectUuid("PROJECT").setSeverity(Severity.BLOCKER).setStatus(Issue.STATUS_CLOSED).setResolution(Issue.RESOLUTION_FIXED).setNew(false).setChanged(true).addComment(new DefaultIssueComment().setKey("COMMENT").setIssueKey("ISSUE").setUserLogin("john").setMarkdownText("Some text").setNew(true))).close();
step.execute();
dbTester.assertDbUnit(getClass(), "add_comment-result.xml", new String[] { "id", "created_at", "updated_at" }, "issue_changes");
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class PersistIssuesStepTest method add_change.
@Test
public void add_change() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
issueCache.newAppender().append(new DefaultIssue().setKey("ISSUE").setType(RuleType.CODE_SMELL).setRuleKey(RuleKey.of("xoo", "S01")).setComponentUuid("COMPONENT").setProjectUuid("PROJECT").setSeverity(Severity.BLOCKER).setStatus(Issue.STATUS_CLOSED).setResolution(Issue.RESOLUTION_FIXED).setNew(false).setChanged(true).setCurrentChange(new FieldDiffs().setIssueKey("ISSUE").setUserLogin("john").setDiff("technicalDebt", null, 1L))).close();
step.execute();
dbTester.assertDbUnit(getClass(), "add_change-result.xml", new String[] { "id", "created_at", "updated_at" }, "issue_changes");
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class AddTagsActionTest method should_execute.
@Test
@SuppressWarnings("unchecked")
public void should_execute() {
Map<String, Object> properties = newHashMap();
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);
when(context.issue()).thenReturn(issue);
action.execute(properties, context);
verify(issueUpdater).setTags(eq(issue), (Collection<String>) Matchers.argThat(org.hamcrest.Matchers.containsInAnyOrder("tag1", "tag2", "tag3")), any(IssueChangeContext.class));
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class AssignActionTest method should_execute.
@Test
public void should_execute() {
User assignee = new DefaultUser();
Map<String, Object> properties = newHashMap();
properties.put(AssignAction.VERIFIED_ASSIGNEE, assignee);
DefaultIssue issue = mock(DefaultIssue.class);
Action.Context context = mock(Action.Context.class);
when(context.issue()).thenReturn(issue);
action.execute(properties, context);
verify(issueUpdater).assign(eq(issue), eq(assignee), any(IssueChangeContext.class));
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class AssignActionTest method should_verify_assignee_exists.
@Test
public void should_verify_assignee_exists() {
String assignee = "arthur";
Map<String, Object> properties = newHashMap();
properties.put("assignee", assignee);
User user = new DefaultUser().setLogin(assignee);
List<DefaultIssue> issues = newArrayList(new DefaultIssue().setKey("ABC"));
when(userFinder.findByLogin(assignee)).thenReturn(user);
assertThat(action.verify(properties, issues, mock(ThreadLocalUserSession.class))).isTrue();
assertThat(properties.get(AssignAction.VERIFIED_ASSIGNEE)).isEqualTo(user);
}
Aggregations