@Test
  public void trace_logs() {
    logTester.setLevel(LoggerLevel.TRACE);

    ClusterHealthRequestBuilder requestBuilder = esTester.client().prepareHealth();
    ClusterHealthResponse state = requestBuilder.get();
    assertThat(state.getStatus()).isEqualTo(ClusterHealthStatus.GREEN);

    assertThat(logTester.logs()).hasSize(1);
  }
  @Test
  public void no_trace_logs() {
    logTester.setLevel(LoggerLevel.DEBUG);

    SearchResponse response =
        esTester
            .client()
            .prepareSearch(FakeIndexDefinition.INDEX)
            .setSearchType(SearchType.SCAN)
            .setScroll(TimeValue.timeValueMinutes(1))
            .get();
    logTester.clear();
    esTester.client().prepareSearchScroll(response.getScrollId()).get();
    assertThat(logTester.logs()).isEmpty();
  }
Пример #3
0
  @Test
  public void log_and_dump_information_about_report_uploading() throws IOException {
    ReportPublisher underTest =
        new ReportPublisher(
            settings,
            wsClient,
            server,
            contextPublisher,
            reactor,
            mode,
            mock(TempFolder.class),
            new ReportPublisherStep[0]);

    underTest.logSuccess("TASK-123");

    assertThat(logTester.logs(LoggerLevel.INFO))
        .contains("ANALYSIS SUCCESSFUL, you can browse https://localhost/dashboard/index/struts")
        .contains(
            "Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report")
        .contains("More about the report processing at https://localhost/api/ce/task?id=TASK-123");

    File detailsFile = new File(temp.getRoot(), "report-task.txt");
    assertThat(readFileToString(detailsFile))
        .isEqualTo(
            "projectKey=struts\n"
                + "serverUrl=https://localhost\n"
                + "dashboardUrl=https://localhost/dashboard/index/struts\n"
                + "ceTaskId=TASK-123\n"
                + "ceTaskUrl=https://localhost/api/ce/task?id=TASK-123\n");
  }
Пример #4
0
  @Test
  public void log_public_url_if_defined() throws IOException {
    when(server.getPublicRootUrl()).thenReturn("https://publicserver/sonarqube");
    ReportPublisher underTest =
        new ReportPublisher(
            settings,
            wsClient,
            server,
            contextPublisher,
            reactor,
            mode,
            mock(TempFolder.class),
            new ReportPublisherStep[0]);

    underTest.logSuccess("TASK-123");

    assertThat(logTester.logs(LoggerLevel.INFO))
        .contains(
            "ANALYSIS SUCCESSFUL, you can browse https://publicserver/sonarqube/dashboard/index/struts")
        .contains(
            "More about the report processing at https://publicserver/sonarqube/api/ce/task?id=TASK-123");

    File detailsFile = new File(temp.getRoot(), "report-task.txt");
    assertThat(readFileToString(detailsFile))
        .isEqualTo(
            "projectKey=struts\n"
                + "serverUrl=https://publicserver/sonarqube\n"
                + "dashboardUrl=https://publicserver/sonarqube/dashboard/index/struts\n"
                + "ceTaskId=TASK-123\n"
                + "ceTaskUrl=https://publicserver/sonarqube/api/ce/task?id=TASK-123\n");
  }
  @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));
  }
Пример #6
0
  @Test
  public void log_but_not_dump_information_when_report_is_not_uploaded() {
    ReportPublisher underTest =
        new ReportPublisher(
            settings,
            wsClient,
            server,
            contextPublisher,
            reactor,
            mode,
            mock(TempFolder.class),
            new ReportPublisherStep[0]);

    underTest.logSuccess(/* report not uploaded, no server task */ null);

    assertThat(logTester.logs(LoggerLevel.INFO))
        .contains("ANALYSIS SUCCESSFUL")
        .doesNotContain("dashboard/index");

    File detailsFile = new File(temp.getRoot(), ReportPublisher.METADATA_DUMP_FILENAME);
    assertThat(detailsFile).doesNotExist();
  }