Search in sources :

Example 16 with UseDataProvider

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

the class PostProjectAnalysisTasksExecutorTest method finished_calls_all_PostProjectAnalysisTask_in_order_of_the_array_and_passes_the_same_object_to_all.

@Test
@UseDataProvider("booleanValues")
public void finished_calls_all_PostProjectAnalysisTask_in_order_of_the_array_and_passes_the_same_object_to_all(boolean allStepsExecuted) {
    PostProjectAnalysisTask postProjectAnalysisTask1 = mock(PostProjectAnalysisTask.class);
    PostProjectAnalysisTask postProjectAnalysisTask2 = mock(PostProjectAnalysisTask.class);
    InOrder inOrder = inOrder(postProjectAnalysisTask1, postProjectAnalysisTask2);
    new PostProjectAnalysisTasksExecutor(ceTask, analysisMetadataHolder, qualityGateHolder, qualityGateStatusHolder, reportReader, system2, new PostProjectAnalysisTask[] { postProjectAnalysisTask1, postProjectAnalysisTask2 }).finished(allStepsExecuted);
    inOrder.verify(postProjectAnalysisTask1).finished(projectAnalysisArgumentCaptor.capture());
    inOrder.verify(postProjectAnalysisTask2).finished(projectAnalysisArgumentCaptor.capture());
    inOrder.verifyNoMoreInteractions();
    List<PostProjectAnalysisTask.ProjectAnalysis> allValues = projectAnalysisArgumentCaptor.getAllValues();
    assertThat(allValues).hasSize(2);
    assertThat(allValues.get(0)).isSameAs(allValues.get(1));
}
Also used : InOrder(org.mockito.InOrder) PostProjectAnalysisTask(org.sonar.api.ce.posttask.PostProjectAnalysisTask) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 17 with UseDataProvider

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

the class DuplicationRepositoryImplTest method getDuplications_throws_IAE_if_Component_type_is_not_FILE.

@Test
@UseDataProvider("allComponentTypesButFile")
public void getDuplications_throws_IAE_if_Component_type_is_not_FILE(Component.Type type) {
    expectFileTypeIAE();
    Component component = mockComponentGetType(type);
    underTest.getDuplications(component);
}
Also used : Component(org.sonar.server.computation.task.projectanalysis.component.Component) ReportComponent(org.sonar.server.computation.task.projectanalysis.component.ReportComponent) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 18 with UseDataProvider

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

the class MapBasedRawMeasureRepositoryTest 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()));
        }
    }
}
Also used : MetricImpl(org.sonar.server.computation.task.projectanalysis.metric.MetricImpl) Metric(org.sonar.server.computation.task.projectanalysis.metric.Metric) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 19 with UseDataProvider

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

the class ScmInfoRepositoryImplTest method do_not_query_db_nor_report_if_component_type_is_not_FILE.

@Test
@UseDataProvider("allTypeComponentButFile")
public void do_not_query_db_nor_report_if_component_type_is_not_FILE(Component component) {
    BatchReportReader batchReportReader = mock(BatchReportReader.class);
    AnalysisMetadataHolder analysisMetadataHolder = mock(AnalysisMetadataHolder.class);
    DbClient dbClient = mock(DbClient.class);
    SourceHashRepository sourceHashRepository = mock(SourceHashRepository.class);
    ScmInfoRepositoryImpl underTest = new ScmInfoRepositoryImpl(batchReportReader, analysisMetadataHolder, dbClient, sourceHashRepository);
    assertThat(underTest.getScmInfo(component)).isAbsent();
    verifyNoMoreInteractions(batchReportReader, analysisMetadataHolder, dbClient, sourceHashRepository);
}
Also used : AnalysisMetadataHolder(org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetadataHolder) DbClient(org.sonar.db.DbClient) SourceHashRepository(org.sonar.server.computation.task.projectanalysis.source.SourceHashRepository) BatchReportReader(org.sonar.server.computation.task.projectanalysis.batch.BatchReportReader) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 20 with UseDataProvider

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

the class BuildComponentTreeStepTest method verify_ref_and_type.

@Test
@UseDataProvider("allComponentTypes")
public void verify_ref_and_type(ComponentType componentType) {
    int componentRef = 1;
    reportReader.putComponent(component(componentRef, componentType));
    underTest.execute();
    Component root = treeRootHolder.getRoot();
    assertThat(root).isNotNull();
    assertThat(root.getType()).isEqualTo(Component.Type.valueOf(componentType.name()));
    assertThat(root.getReportAttributes().getRef()).isEqualTo(ROOT_REF);
    assertThat(root.getChildren()).isEmpty();
}
Also used : Component(org.sonar.server.computation.task.projectanalysis.component.Component) 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