Search in sources :

Example 21 with UseDataProvider

use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.

the class LoadPeriodsStepTest method feed_period_by_previous_analysis.

@Test
@UseDataProvider("projectAndViewRoots")
public void feed_period_by_previous_analysis(Component root) {
    setupRoot(root);
    dbTester.prepareDbUnit(getClass(), "shared.xml");
    settings.setProperty("sonar.leak.period", "previous_analysis");
    underTest.execute();
    // return analysis from 2008-11-29
    Period period = periodsHolder.getPeriod();
    assertThat(period).isNotNull();
    assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS);
    assertThat(period.getModeParameter()).isNotNull();
    assertThat(period.getSnapshotDate()).isEqualTo(1227934800000L);
    assertThat(period.getAnalysisUuid()).isEqualTo("u1004");
    assertThat(logTester.logs()).hasSize(1);
    assertThat(logTester.logs().get(0)).startsWith("Compare to previous analysis (");
}
Also used : Period(org.sonar.server.computation.task.projectanalysis.period.Period) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 22 with UseDataProvider

use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.

the class LoadPeriodsStepTest method feed_one_period.

@Test
@UseDataProvider("projectAndViewRoots")
public void feed_one_period(Component root) {
    setupRoot(root);
    dbTester.prepareDbUnit(getClass(), "shared.xml");
    String textDate = "2008-11-22";
    settings.setProperty("sonar.leak.period", textDate);
    underTest.execute();
    Period period = periodsHolder.getPeriod();
    assertThat(period).isNotNull();
    assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_DATE);
    assertThat(period.getModeParameter()).isEqualTo(textDate);
    assertThat(period.getSnapshotDate()).isEqualTo(1227358680000L);
    assertThat(period.getAnalysisUuid()).isEqualTo("u1003");
}
Also used : Period(org.sonar.server.computation.task.projectanalysis.period.Period) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 23 with UseDataProvider

use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.

the class LoadPeriodsStepTest method feed_period_by_date.

@Test
@UseDataProvider("projectAndViewRoots")
public void feed_period_by_date(Component root) {
    setupRoot(root);
    dbTester.prepareDbUnit(getClass(), "shared.xml");
    String textDate = "2008-11-22";
    settings.setProperty("sonar.leak.period", textDate);
    underTest.execute();
    // Return analysis from given date 2008-11-22
    Period period = periodsHolder.getPeriod();
    assertThat(period).isNotNull();
    assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_DATE);
    assertThat(period.getModeParameter()).isEqualTo(textDate);
    assertThat(period.getSnapshotDate()).isEqualTo(1227358680000L);
    assertThat(period.getAnalysisUuid()).isEqualTo("u1003");
    assertThat(logTester.logs()).hasSize(1);
    assertThat(logTester.logs().get(0)).startsWith("Compare to date 2008-11-22 (analysis of ");
}
Also used : Period(org.sonar.server.computation.task.projectanalysis.period.Period) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 24 with UseDataProvider

use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.

the class LoadPeriodsStepTest method feed_period_by_days.

@Test
@UseDataProvider("projectAndViewRoots")
public void feed_period_by_days(Component root) {
    setupRoot(root);
    dbTester.prepareDbUnit(getClass(), "shared.xml");
    settings.setProperty("sonar.leak.period", "10");
    underTest.execute();
    // return analysis from 2008-11-20
    Period period = periodsHolder.getPeriod();
    assertThat(period).isNotNull();
    assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_DAYS);
    assertThat(period.getModeParameter()).isEqualTo("10");
    assertThat(period.getSnapshotDate()).isEqualTo(1227157200000L);
    assertThat(period.getAnalysisUuid()).isEqualTo("u1002");
    assertThat(logTester.logs()).hasSize(1);
    assertThat(logTester.logs().get(0)).startsWith("Compare over 10 days (2008-11-20, analysis of ");
}
Also used : Period(org.sonar.server.computation.task.projectanalysis.period.Period) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 25 with UseDataProvider

use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.

the class LoadPeriodsStepTest method search_by_date_return_nearest_later_analysis.

@Test
@UseDataProvider("projectAndViewRoots")
public void search_by_date_return_nearest_later_analysis(Component root) {
    setupRoot(root);
    dbTester.prepareDbUnit(getClass(), "shared.xml");
    String date = "2008-11-24";
    settings.setProperty("sonar.leak.period", date);
    underTest.execute();
    // Analysis form 2008-11-29
    Period period = periodsHolder.getPeriod();
    assertThat(period).isNotNull();
    assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_DATE);
    assertThat(period.getModeParameter()).isEqualTo(date);
    assertThat(period.getSnapshotDate()).isEqualTo(1227934800000L);
    assertThat(period.getAnalysisUuid()).isEqualTo("u1004");
}
Also used : Period(org.sonar.server.computation.task.projectanalysis.period.Period) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Aggregations

UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)32 Test (org.junit.Test)32 Period (org.sonar.server.computation.task.projectanalysis.period.Period)8 Component (org.sonar.server.computation.task.projectanalysis.component.Component)5 ReportComponent (org.sonar.server.computation.task.projectanalysis.component.ReportComponent)4 MeasureDto (org.sonar.db.measure.MeasureDto)3 PropertyTesting.newComponentPropertyDto (org.sonar.db.property.PropertyTesting.newComponentPropertyDto)3 PropertyTesting.newGlobalPropertyDto (org.sonar.db.property.PropertyTesting.newGlobalPropertyDto)3 PropertyTesting.newUserPropertyDto (org.sonar.db.property.PropertyTesting.newUserPropertyDto)3 Date (java.util.Date)2 InOrder (org.mockito.InOrder)2 PostProjectAnalysisTask (org.sonar.api.ce.posttask.PostProjectAnalysisTask)2 ComponentDto (org.sonar.db.component.ComponentDto)2 ViewsComponent (org.sonar.server.computation.task.projectanalysis.component.ViewsComponent)2 Metric (org.sonar.server.computation.task.projectanalysis.metric.Metric)2 MetricImpl (org.sonar.server.computation.task.projectanalysis.metric.MetricImpl)2 LoggerContext (ch.qos.logback.classic.LoggerContext)1 ErrorResponseBody (com.nike.riposte.server.error.handler.ErrorResponseBody)1 PipelineContinuationBehavior (com.nike.riposte.server.handler.base.PipelineContinuationBehavior)1 Endpoint (com.nike.riposte.server.http.Endpoint)1