Package org.sonar.api.user

Examples of org.sonar.api.user.User


  @Override
  public boolean execute(Map<String, Object> properties, Context context) {
    if(!properties.containsKey(VERIFIED_ASSIGNEE)) {
      throw new IllegalArgumentException("Assignee is missing from the execution parameters");
    }
    User assignee = (User) properties.get(VERIFIED_ASSIGNEE);
    return issueUpdater.assign((DefaultIssue) context.issue(), assignee, context.issueChangeContext());
  }
View Full Code Here


    Map<String, User> usersByLogin = newHashMap();
    List<DefaultIssueComment> comments = commentService.findComments(issue.key());
    for (IssueComment comment : comments) {
      String userLogin = comment.userLogin();
      User user = usersByLogin.get(userLogin);
      if (user == null) {
        user = userFinder.findByLogin(userLogin);
        if (user != null) {
          usersByLogin.put(userLogin, user);
        }
      }
    }

    for (IssueComment comment : comments) {
      String userLogin = comment.userLogin();
      User user = usersByLogin.get(userLogin);
      json
        .beginObject()
        .prop("key", comment.key())
        .prop("userName", user != null ? user.name() : null)
        .prop("raw", comment.markdownText())
        .prop("html", Markdown.convertToHtml(comment.markdownText()))
        .prop("createdAt", DateUtils.formatDateTime(comment.createdAt()))
        .prop("fCreatedAge", formatAgeDate(comment.createdAt()))
        .prop("updatable", login != null && login.equals(userLogin))
View Full Code Here

      .endArray()
      .endObject();

    IssueChangelog changelog = issueChangelogService.changelog(issue);
    for (FieldDiffs diffs : changelog.changes()) {
      User user = changelog.user(diffs);
      json
        .beginObject()
        .prop("userName", user != null ? user.name() : null)
        .prop("creationDate", DateUtils.formatDateTime(diffs.creationDate()))
        .prop("fCreationDate", formatDate(diffs.creationDate()));
      json.name("diffs").beginArray();
      List<String> diffsFormatted = issueChangelogService.formatDiffs(diffs);
      for (String diff : diffsFormatted) {
View Full Code Here

    json.endArray();
  }

  private void addUserWithLabel(@Nullable String value, String field, JsonWriter json) {
    if (value != null) {
      User user = userFinder.findByLogin(value);
      json
        .prop(field, value)
        .prop(field + "Name", user != null ? user.name() : null);
    }
  }
View Full Code Here

    action = new AssignAction(userFinder, issueUpdater);
  }

  @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);
View Full Code Here

  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<Issue> issues = newArrayList((Issue) new DefaultIssue().setKey("ABC"));
    when(userFinder.findByLogin(assignee)).thenReturn(user);
    assertThat(action.verify(properties, issues, mock(UserSession.class))).isTrue();
    assertThat(properties.get(AssignAction.VERIFIED_ASSIGNEE)).isEqualTo(user);
View Full Code Here

  @Test
  public void load_changelog_and_related_users() throws Exception {
    FieldDiffs userChange = new FieldDiffs().setUserLogin("arthur").setDiff("severity", "MAJOR", "BLOCKER");
    FieldDiffs scanChange = new FieldDiffs().setDiff("status", "RESOLVED", "CLOSED");
    when(changeDao.selectChangelogByIssue("ABCDE")).thenReturn(Arrays.asList(userChange, scanChange));
    User arthur = new DefaultUser().setLogin("arthur").setName("Arthur");
    when(userFinder.findByLogins(Arrays.asList("arthur"))).thenReturn(Arrays.asList(arthur));

    when(issueService.getByKey("ABCDE")).thenReturn(new DefaultIssue().setKey("ABCDE"));

    IssueChangelog changelog = service.changelog("ABCDE");
View Full Code Here

  private String getUserFullName(@Nullable String login) {
    if (login == null) {
      return null;
    }
    User user = userFinder.findByLogin(login);
    if (user == null) {
      // most probably user was deleted
      return login;
    }
    return StringUtils.defaultIfBlank(user.name(), login);
  }
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.