Search in sources :

Example 41 with DefaultIssue

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");
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) DefaultIssueComment(org.sonar.core.issue.DefaultIssueComment) Test(org.junit.Test)

Example 42 with DefaultIssue

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");
}
Also used : FieldDiffs(org.sonar.core.issue.FieldDiffs) DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 43 with DefaultIssue

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));
}
Also used : IssueChangeContext(org.sonar.core.issue.IssueChangeContext) DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 44 with DefaultIssue

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));
}
Also used : DefaultUser(org.sonar.core.user.DefaultUser) User(org.sonar.api.user.User) DefaultUser(org.sonar.core.user.DefaultUser) IssueChangeContext(org.sonar.core.issue.IssueChangeContext) DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 45 with DefaultIssue

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);
}
Also used : DefaultUser(org.sonar.core.user.DefaultUser) User(org.sonar.api.user.User) DefaultUser(org.sonar.core.user.DefaultUser) ThreadLocalUserSession(org.sonar.server.user.ThreadLocalUserSession) DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Aggregations

DefaultIssue (org.sonar.core.issue.DefaultIssue)140 Test (org.junit.Test)120 Date (java.util.Date)27 ActiveRule (org.sonar.server.computation.task.projectanalysis.qualityprofile.ActiveRule)15 IssueChangeContext (org.sonar.core.issue.IssueChangeContext)14 DefaultIssueComment (org.sonar.core.issue.DefaultIssueComment)8 IssueDto (org.sonar.db.issue.IssueDto)8 DbSession (org.sonar.db.DbSession)6 ComponentDto (org.sonar.db.component.ComponentDto)5 Issue (org.sonar.api.issue.Issue)4 FieldDiffs (org.sonar.core.issue.FieldDiffs)4 ArrayList (java.util.ArrayList)3 RuleKey (org.sonar.api.rule.RuleKey)3 User (org.sonar.api.user.User)3 IssueChangeMapper (org.sonar.db.issue.IssueChangeMapper)3 IssueMapper (org.sonar.db.issue.IssueMapper)3 RuleDto (org.sonar.db.rule.RuleDto)3 IssueChangeNotification (org.sonar.server.issue.notification.IssueChangeNotification)3 DefaultUser (org.sonar.core.user.DefaultUser)2 RuleTesting.newRuleDto (org.sonar.db.rule.RuleTesting.newRuleDto)2