use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.
the class PropertiesDaoTest method selectEnabledDescendantModuleProperties_supports_all_values.
@Test
@UseDataProvider("allValuesForSelect")
public void selectEnabledDescendantModuleProperties_supports_all_values(String dbValue, String expected) throws SQLException {
String projectUuid = "A";
ComponentDto project = ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), projectUuid);
dbClient.componentDao().insert(session, project);
long projectId = project.getId();
insertProperty("project.one", dbValue, projectId, null);
List<PropertyDto> dtos = underTest.selectEnabledDescendantModuleProperties(projectUuid, dbTester.getSession());
assertThat(dtos).hasSize(1);
assertThatDto(dtos.iterator().next()).hasKey("project.one").hasResourceId(projectId).hasNoUserId().hasValue(expected);
}
use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.
the class PropertiesDaoTest method saveProperty_deletes_then_inserts_global_properties_when_they_exist_in_db.
@Test
@UseDataProvider("valueUpdatesDataProvider")
public void saveProperty_deletes_then_inserts_global_properties_when_they_exist_in_db(@Nullable String oldValue, @Nullable String newValue) throws SQLException {
long id = insertProperty("global", oldValue, null, null, DATE_1);
when(system2.now()).thenReturn(DATE_4);
underTest.saveProperty(new PropertyDto().setKey("global").setValue(newValue));
assertThatPropertiesRow(id).doesNotExist();
PropertiesRowAssert propertiesRowAssert = assertThatPropertiesRow("global").hasNoResourceId().hasNoUserId().hasCreatedAt(DATE_4);
if (newValue == null || newValue.isEmpty()) {
propertiesRowAssert.isEmpty();
} else if (newValue.length() > 4000) {
propertiesRowAssert.hasClobValue(newValue);
} else {
propertiesRowAssert.hasTextValue(newValue);
}
}
use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.
the class PostProjectAnalysisTasksExecutorTest method finished_does_not_fail_if_listener_throws_exception_and_execute_subsequent_listeners.
@Test
@UseDataProvider("booleanValues")
public void finished_does_not_fail_if_listener_throws_exception_and_execute_subsequent_listeners(boolean allStepsExecuted) {
PostProjectAnalysisTask postProjectAnalysisTask1 = mock(PostProjectAnalysisTask.class);
PostProjectAnalysisTask postProjectAnalysisTask2 = mock(PostProjectAnalysisTask.class);
PostProjectAnalysisTask postProjectAnalysisTask3 = mock(PostProjectAnalysisTask.class);
InOrder inOrder = inOrder(postProjectAnalysisTask1, postProjectAnalysisTask2, postProjectAnalysisTask3);
doThrow(new RuntimeException("Faking a listener throws an exception")).when(postProjectAnalysisTask2).finished(any(PostProjectAnalysisTask.ProjectAnalysis.class));
new PostProjectAnalysisTasksExecutor(ceTask, analysisMetadataHolder, qualityGateHolder, qualityGateStatusHolder, reportReader, system2, new PostProjectAnalysisTask[] { postProjectAnalysisTask1, postProjectAnalysisTask2, postProjectAnalysisTask3 }).finished(allStepsExecuted);
inOrder.verify(postProjectAnalysisTask1).finished(projectAnalysisArgumentCaptor.capture());
inOrder.verify(postProjectAnalysisTask2).finished(projectAnalysisArgumentCaptor.capture());
inOrder.verify(postProjectAnalysisTask3).finished(projectAnalysisArgumentCaptor.capture());
inOrder.verifyNoMoreInteractions();
}
use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.
the class DuplicationRepositoryImplTest method addDuplication_inner_throws_IAE_if_file_type_is_not_FILE.
@Test
@UseDataProvider("allComponentTypesButFile")
public void addDuplication_inner_throws_IAE_if_file_type_is_not_FILE(Component.Type type) {
expectFileTypeIAE();
Component component = mockComponentGetType(type);
underTest.add(component, SOME_DUPLICATION);
}
use of com.tngtech.java.junit.dataprovider.UseDataProvider in project sonarqube by SonarSource.
the class MeasureRepositoryImplTest method update_throws_IAE_if_valueType_of_Measure_is_not_the_same_as_the_Metric_valueType_unless_NO_VALUE.
@Test
@UseDataProvider("measures")
public void update_throws_IAE_if_valueType_of_Measure_is_not_the_same_as_the_Metric_valueType_unless_NO_VALUE(Measure measure) {
for (Metric.MetricType metricType : Metric.MetricType.values()) {
if (metricType.getValueType() == measure.getValueType() || measure.getValueType() == Measure.ValueType.NO_VALUE) {
continue;
}
try {
final MetricImpl metric = new MetricImpl(1, "key" + metricType, "name" + metricType, metricType);
underTest.add(FILE_COMPONENT, metric, getSomeMeasureByValueType(metricType));
underTest.update(FILE_COMPONENT, metric, measure);
fail("An IllegalArgumentException should have been raised");
} catch (IllegalArgumentException e) {
assertThat(e).hasMessage(format("Measure's ValueType (%s) is not consistent with the Metric's ValueType (%s)", measure.getValueType(), metricType.getValueType()));
}
}
}
Aggregations