Search in sources :

Example 1 with SearchHistoryResponse

use of org.sonarqube.ws.WsMeasures.SearchHistoryResponse in project sonarqube by SonarSource.

the class TimeMachineTest method testHistoryOfIssues.

@Test
public void testHistoryOfIssues() {
    SearchHistoryResponse response = searchHistory("blocker_violations", "critical_violations", "info_violations", "major_violations", "minor_violations");
    assertThat(response.getPaging().getTotal()).isEqualTo(2);
    assertHistory(response, "blocker_violations", "0", "0");
    assertHistory(response, "critical_violations", "0", "0");
    assertHistory(response, "info_violations", "0", "0");
    assertHistory(response, "major_violations", "0", "0");
    assertHistory(response, "minor_violations", "26", "43");
}
Also used : SearchHistoryResponse(org.sonarqube.ws.WsMeasures.SearchHistoryResponse) Test(org.junit.Test)

Example 2 with SearchHistoryResponse

use of org.sonarqube.ws.WsMeasures.SearchHistoryResponse in project sonarqube by SonarSource.

the class SearchHistoryActionTest method do_not_return_developer_measures.

@Test
public void do_not_return_developer_measures() {
    wsRequest.setMetrics(singletonList(complexityMetric.getKey()));
    dbClient.measureDao().insert(dbSession, newMeasureDto(complexityMetric, project, analysis).setDeveloperId(42L));
    db.commit();
    SearchHistoryResponse result = call();
    assertThat(result.getMeasuresCount()).isEqualTo(1);
    assertThat(result.getMeasures(0).getHistoryCount()).isEqualTo(0);
}
Also used : SearchHistoryResponse(org.sonarqube.ws.WsMeasures.SearchHistoryResponse) Test(org.junit.Test)

Example 3 with SearchHistoryResponse

use of org.sonarqube.ws.WsMeasures.SearchHistoryResponse in project sonarqube by SonarSource.

the class TimeMachineTest method testHistoryOfMeasures.

@Test
public void testHistoryOfMeasures() {
    SearchHistoryResponse response = searchHistory("lines", "ncloc");
    assertThat(response.getPaging().getTotal()).isEqualTo(2);
    assertHistory(response, "lines", "26", "43");
    assertHistory(response, "ncloc", "24", "40");
}
Also used : SearchHistoryResponse(org.sonarqube.ws.WsMeasures.SearchHistoryResponse) Test(org.junit.Test)

Example 4 with SearchHistoryResponse

use of org.sonarqube.ws.WsMeasures.SearchHistoryResponse in project sonarqube by SonarSource.

the class TimeMachineTest method measure_variations_are_only_meaningful_when_additional_fields_contains_periods.

/**
   * SONAR-4962
   */
@Test
public void measure_variations_are_only_meaningful_when_additional_fields_contains_periods() {
    Map<String, Measure> measures = getMeasuresWithVariationsByMetricKey(orchestrator, PROJECT, "violations", "new_violations");
    assertThat(measures.get("violations")).isNotNull();
    assertThat(measures.get("new_violations")).isNotNull();
    SearchHistoryResponse response = searchHistory("new_violations");
    assertThat(response.getMeasures(0).getHistoryCount()).isGreaterThan(0);
    measures = getMeasuresByMetricKey(orchestrator, PROJECT, "violations", "new_violations");
    assertThat(measures.get("violations")).isNotNull();
    assertThat(measures.get("new_violations")).isNull();
}
Also used : SearchHistoryResponse(org.sonarqube.ws.WsMeasures.SearchHistoryResponse) Measure(org.sonarqube.ws.WsMeasures.Measure) Test(org.junit.Test)

Example 5 with SearchHistoryResponse

use of org.sonarqube.ws.WsMeasures.SearchHistoryResponse in project sonarqube by SonarSource.

the class TimeMachineTest method noDataForInterval.

@Test
public void noDataForInterval() {
    Date now = new Date();
    SearchHistoryResponse response = wsMeasures.searchHistory(SearchHistoryRequest.builder().setComponent(PROJECT).setMetrics(singletonList("lines")).setFrom(formatDate(now)).setTo(formatDate(now)).build());
    assertThat(response.getPaging().getTotal()).isEqualTo(0);
    assertThat(response.getMeasures(0).getHistoryList()).isEmpty();
}
Also used : SearchHistoryResponse(org.sonarqube.ws.WsMeasures.SearchHistoryResponse) ItUtils.formatDate(util.ItUtils.formatDate) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 SearchHistoryResponse (org.sonarqube.ws.WsMeasures.SearchHistoryResponse)5 Date (java.util.Date)1 Measure (org.sonarqube.ws.WsMeasures.Measure)1 ItUtils.formatDate (util.ItUtils.formatDate)1