Package org.sonar.api.user

Examples of org.sonar.api.user.User


      throw new UnsupportedOperationException("TODO");
    }

    @Override
    public IssueHandler.Context assign(@Nullable String assignee) {
      User user = null;
      if(assignee != null) {
        user = new DefaultUser().setLogin(assignee).setName(assignee);
      }
      updater.assign(issue, user, changeContext);
      return this;
View Full Code Here


    updater = new IssueUpdater();
  }

  @Test
  public void assign() throws Exception {
    User user = new DefaultUser().setLogin("emmerik").setName("Emmerik");

    boolean updated = updater.assign(issue, user, context);
    assertThat(updated).isTrue();
    assertThat(issue.assignee()).isEqualTo("emmerik");
    assertThat(issue.mustSendNotifications()).isTrue();
View Full Code Here

    assertThat(diff.newValue()).isNull();
  }

  @Test
  public void change_assignee() throws Exception {
    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");
View Full Code Here

    assertThat(diff.newValue()).isEqualTo("Emmerik");
  }

  @Test
  public void not_change_assignee() throws Exception {
    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();
View Full Code Here

import static org.mockito.Mockito.*;

public class SetAssigneeTest {
  @Test
  public void assign() throws Exception {
    User user = new DefaultUser().setLogin("eric").setName("eric");
    SetAssignee function = new SetAssignee(user);
    Function.Context context = mock(Function.Context.class);
    function.execute(context);
    verify(context, times(1)).setAssignee(user);
  }
View Full Code Here

    assertThat(email.getFrom()).isNull();
  }

  @Test
  public void notification_sender_should_be_the_author_of_change() {
    User user = mock(User.class);
    when(user.name()).thenReturn("Simon");
    when(userFinder.findByLogin("simon")).thenReturn(user);

    Notification notification = new Notification("issue-changes")
      .setFieldValue("projectName", "Struts")
      .setFieldValue("projectKey", "org.apache:struts")
View Full Code Here

    if (!issueComments.isEmpty()) {
      json.name("comments").beginArray();
      String login = UserSession.get().login();
      for (IssueComment comment : issueComments) {
        String userLogin = comment.userLogin();
        User user = userLogin != null ? usersByLogin.get(userLogin) : null;
        json.beginObject()
          .prop("key", comment.key())
          .prop("login", comment.userLogin())
          .prop("userName", user != null ? user.name() : null)
          .prop("htmlText", Markdown.convertToHtml(comment.markdownText()))
          .prop("markdown", comment.markdownText())
          .prop("updatable", login != null && login.equals(userLogin))
          .prop("createdAt", DateUtils.formatDateTime(comment.createdAt()))
          .endObject();
View Full Code Here

        actionsWriter.writeTransitions(issue, json);
      }

      String assignee = issue.assignee();
      if (extraFields.contains(ASSIGNEE_NAME_EXTRA_FIELD) && assignee != null) {
        User user = usersByLogin.get(assignee);
        json.prop(ASSIGNEE_NAME_EXTRA_FIELD, user != null ? user.name() : null);
      }

      String reporter = issue.reporter();
      if (extraFields.contains(REPORTER_NAME_EXTRA_FIELD) && reporter != null) {
        User user = usersByLogin.get(reporter);
        json.prop(REPORTER_NAME_EXTRA_FIELD, user != null ? user.name() : null);
      }

      String actionPlanKey = issue.actionPlanKey();
      if (extraFields.contains(ACTION_PLAN_NAME_EXTRA_FIELD) && actionPlanKey != null) {
        ActionPlan actionPlan = actionPlanByKeys.get(actionPlanKey);
View Full Code Here

    verifyLoggedIn();

    DbSession session = dbClient.openSession(false);
    try {
      DefaultIssue issue = getByKeyForUpdate(session, issueKey).toDefaultIssue();
      User user = null;
      if (!Strings.isNullOrEmpty(assignee)) {
        user = userFinder.findByLogin(assignee);
        if (user == null) {
          throw new NotFoundException("Unknown user: " + assignee);
        }
View Full Code Here

  @Override
  public boolean verify(Map<String, Object> properties, List<Issue> issues, UserSession userSession){
    String assignee = assigneeValue(properties);
    if(!Strings.isNullOrEmpty(assignee)) {
      User user = selectUser(assignee);
      if (user == null) {
        throw new IllegalArgumentException("Unknown user: " + assignee);
      }
      properties.put(VERIFIED_ASSIGNEE, user);
    } else {
View Full Code Here

TOP

Related Classes of org.sonar.api.user.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.