Search in sources :

Example 1 with PostProjectAnalysisTask

use of org.sonar.api.ce.posttask.PostProjectAnalysisTask 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();
}
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 2 with PostProjectAnalysisTask

use of org.sonar.api.ce.posttask.PostProjectAnalysisTask 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)

Aggregations

UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)2 Test (org.junit.Test)2 InOrder (org.mockito.InOrder)2 PostProjectAnalysisTask (org.sonar.api.ce.posttask.PostProjectAnalysisTask)2