コード例 #1
0
  @Before
  public void setUp() {
    EmailSettings settings = mock(EmailSettings.class);
    when(settings.getServerBaseURL()).thenReturn("http://nemo.sonarsource.org");
    i18n = mock(DefaultI18n.class);
    userIndex = mock(UserIndex.class);
    // returns the login passed in parameter
    when(userIndex.getNullableByLogin(anyString()))
        .thenAnswer(
            new Answer<UserDoc>() {
              @Override
              public UserDoc answer(InvocationOnMock invocationOnMock) throws Throwable {
                return new UserDoc().setName((String) invocationOnMock.getArguments()[0]);
              }
            });
    when(i18n.message(any(Locale.class), eq("severity.BLOCKER"), anyString()))
        .thenReturn("Blocker");
    when(i18n.message(any(Locale.class), eq("severity.CRITICAL"), anyString()))
        .thenReturn("Critical");
    when(i18n.message(any(Locale.class), eq("severity.MAJOR"), anyString())).thenReturn("Major");
    when(i18n.message(any(Locale.class), eq("severity.MINOR"), anyString())).thenReturn("Minor");
    when(i18n.message(any(Locale.class), eq("severity.INFO"), anyString())).thenReturn("Info");

    template = new NewIssuesEmailTemplate(settings, i18n);
  }
コード例 #2
0
ファイル: IssueService.java プロジェクト: icloudkit/sonarqube
 @CheckForNull
 private String findSourceLineUser(DbSession dbSession, String fileUuid, @Nullable Integer line) {
   if (line != null) {
     Optional<DbFileSources.Line> sourceLine = sourceService.getLine(dbSession, fileUuid, line);
     if (sourceLine.isPresent() && sourceLine.get().hasScmAuthor()) {
       UserDoc userDoc = userIndex.getNullableByScmAccount(sourceLine.get().getScmAuthor());
       if (userDoc != null) {
         return userDoc.login();
       }
     }
   }
   return null;
 }
コード例 #3
0
  @Test
  public void do_not_assign_default_assignee_when_not_found_in_index() {
    inputIssue.setIsNew(true);
    String wolinski = "wolinski";
    projectSettings.setProperty(CoreProperties.DEFAULT_ISSUE_ASSIGNEE, wolinski);
    when(userIndex.getNullableByLogin(wolinski)).thenReturn(null);

    process();

    assertThat(Iterators.getOnlyElement(outputIssues.traverse()).assignee()).isNull();
    assertThat(logTester.logs())
        .contains(
            String.format(
                "the %s property was set with an unknown login: %s",
                CoreProperties.DEFAULT_ISSUE_ASSIGNEE, wolinski));
  }
コード例 #4
0
ファイル: UsersAction.java プロジェクト: CodeLeague/sonarqube
  @Override
  public void handle(Request request, Response response) throws Exception {
    userSession.checkLoggedIn();
    List<String> logins = request.mandatoryParamAsStrings(PARAM_LOGINS);

    response.stream().setMediaType(MediaTypes.PROTOBUF);
    ScannerInput.User.Builder userBuilder = ScannerInput.User.newBuilder();
    OutputStream output = response.stream().output();
    try {
      for (Iterator<UserDoc> userDocIterator = userIndex.selectUsersForBatch(logins);
          userDocIterator.hasNext(); ) {
        handleUser(userDocIterator.next(), userBuilder, output);
      }
    } finally {
      output.close();
    }
  }