Search in sources :

Example 1 with DefaultUser

use of org.sonar.core.user.DefaultUser 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 2 with DefaultUser

use of org.sonar.core.user.DefaultUser 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)

Example 3 with DefaultUser

use of org.sonar.core.user.DefaultUser in project sonarqube by SonarSource.

the class IssueFieldsSetterTest method change_assignee.

@Test
public void change_assignee() {
    User user = new DefaultUser().setLogin("emmerik").setName("Emmerik");
    issue.setAssignee("morgan");
    boolean updated = updater.assign(issue, user, context);
    assertThat(updated).isTrue();
    assertThat(issue.assignee()).isEqualTo("emmerik");
    assertThat(issue.mustSendNotifications()).isTrue();
    FieldDiffs.Diff diff = issue.currentChange().get(ASSIGNEE);
    assertThat(diff.oldValue()).isEqualTo(UNUSED);
    assertThat(diff.newValue()).isEqualTo("Emmerik");
}
Also used : DefaultUser(org.sonar.core.user.DefaultUser) User(org.sonar.api.user.User) DefaultUser(org.sonar.core.user.DefaultUser) FieldDiffs(org.sonar.core.issue.FieldDiffs) Test(org.junit.Test)

Example 4 with DefaultUser

use of org.sonar.core.user.DefaultUser in project sonarqube by SonarSource.

the class DefaultUserTest method test_email.

@Test
public void test_email() {
    DefaultUser user = new DefaultUser();
    assertThat(user.email()).isNull();
    user.setEmail("");
    assertThat(user.email()).isNull();
    user.setEmail("  ");
    assertThat(user.email()).isNull();
    user.setEmail("s@b.com");
    assertThat(user.email()).isEqualTo("s@b.com");
}
Also used : DefaultUser(org.sonar.core.user.DefaultUser) Test(org.junit.Test)

Example 5 with DefaultUser

use of org.sonar.core.user.DefaultUser in project sonarqube by SonarSource.

the class IssueFieldsSetterTest method not_change_assignee.

@Test
public void not_change_assignee() {
    User user = new DefaultUser().setLogin("morgan").setName("Morgan");
    issue.setAssignee("morgan");
    boolean updated = updater.assign(issue, user, context);
    assertThat(updated).isFalse();
    assertThat(issue.currentChange()).isNull();
    assertThat(issue.mustSendNotifications()).isFalse();
}
Also used : DefaultUser(org.sonar.core.user.DefaultUser) User(org.sonar.api.user.User) DefaultUser(org.sonar.core.user.DefaultUser) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 DefaultUser (org.sonar.core.user.DefaultUser)7 User (org.sonar.api.user.User)5 DefaultIssue (org.sonar.core.issue.DefaultIssue)2 FieldDiffs (org.sonar.core.issue.FieldDiffs)2 IssueChangeContext (org.sonar.core.issue.IssueChangeContext)1 ThreadLocalUserSession (org.sonar.server.user.ThreadLocalUserSession)1