use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.
the class LoadPeriodsStepTest method feed_period_by_version.
@Test
@UseDataProvider("projectAndViewRoots")
public void feed_period_by_version(Component root) {
setupRoot(root);
dbTester.prepareDbUnit(getClass(), "shared.xml");
settings.setProperty("sonar.leak.period", "0.9");
underTest.execute();
// Analysis form 2008-11-11
Period period = periodsHolder.getPeriod();
assertThat(period).isNotNull();
assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_VERSION);
assertThat(period.getModeParameter()).isEqualTo("0.9");
assertThat(period.getSnapshotDate()).isEqualTo(1226379600000L);
assertThat(period.getAnalysisUuid()).isEqualTo("u1000");
assertThat(logTester.logs()).hasSize(1);
assertThat(logTester.logs().get(0)).startsWith("Compare to version (0.9) (");
}
use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.
the class EvaluationResultTextConverterTest method evaluate_adds_only_period_if_metric_starts_with_new_prefix.
@Test
@UseDataProvider("all_operators_for_error_warning_levels")
public void evaluate_adds_only_period_if_metric_starts_with_new_prefix(Condition.Operator operator, Measure.Level level) {
String metricMsg = "trololo_metric_msg";
int periodIndex = 1;
String periodLabel = "periodLabel";
when(i18n.message(Locale.ENGLISH, "metric." + SOME_VARIATION_METRIC.getKey() + ".name", SOME_VARIATION_METRIC.getName())).thenReturn(metricMsg);
Date date = new Date();
Period period = new Period(SOME_MODE, null, date.getTime(), SOME_ANALYSIS_UUID);
periodsHolder.setPeriod(period);
when(periods.label(period.getMode(), period.getModeParameter(), date)).thenReturn(periodLabel);
Condition condition = new Condition(SOME_VARIATION_METRIC, operator.getDbValue(), ERROR_THRESHOLD, WARNING_THRESHOLD, true);
assertThat(underTest.asText(condition, new EvaluationResult(level, null))).isEqualTo(metricMsg + " " + toSign(operator) + " " + (getThreshold(level)) + " " + periodLabel);
}
use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.
the class EvaluationResultTextConverterTest method evaluate_adds_variation_and_period_if_metric_does_not_starts_with_variation_prefix.
@Test
@UseDataProvider("all_operators_for_error_warning_levels")
public void evaluate_adds_variation_and_period_if_metric_does_not_starts_with_variation_prefix(Condition.Operator operator, Measure.Level level) {
String metricMsg = "trololo_metric_msg";
String variationMsg = "_variation_";
int periodIndex = 1;
String periodLabel = "periodLabel";
when(i18n.message(Locale.ENGLISH, "metric." + INT_METRIC.getKey() + ".name", INT_METRIC.getName())).thenReturn(metricMsg);
when(i18n.message(Locale.ENGLISH, "variation", "variation")).thenReturn(variationMsg);
Date date = new Date();
Period period = new Period(SOME_MODE, null, date.getTime(), SOME_ANALYSIS_UUID);
periodsHolder.setPeriod(period);
when(periods.label(period.getMode(), period.getModeParameter(), date)).thenReturn(periodLabel);
Condition condition = new Condition(INT_METRIC, operator.getDbValue(), ERROR_THRESHOLD, WARNING_THRESHOLD, true);
assertThat(underTest.asText(condition, new EvaluationResult(level, null))).isEqualTo(metricMsg + " " + variationMsg + " " + toSign(operator) + " " + (getThreshold(level)) + " " + periodLabel);
}
use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.
the class PurgeDatastoresStepTest method do_not_call_purge_method_of_the_purge_task_for_other_report_components.
@Test
@UseDataProvider("nonRootProjectComponentTypes")
public void do_not_call_purge_method_of_the_purge_task_for_other_report_components(Component.Type type) {
Component component = ReportComponent.builder(type, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).build();
verify_do_not_call_purge_method_of_the_purge_task(component);
}
use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.
the class DbMigrationStatusActionTest method defensive_test_all_values_of_Status_must_be_supported.
// this test will raise a IllegalArgumentException when an unsupported value is added to the Status enum
@Test
@UseDataProvider("statusRequiringDbMigration")
public void defensive_test_all_values_of_Status_must_be_supported(DatabaseVersion.Status status) throws Exception {
when(databaseVersion.getStatus()).thenReturn(status);
for (Status migrationStatus : filter(Arrays.asList(DatabaseMigrationState.Status.values()), not(in(ImmutableList.of(NONE, RUNNING, FAILED, SUCCEEDED))))) {
when(migrationState.getStatus()).thenReturn(migrationStatus);
underTest.handle(request, response);
}
}
Aggregations