Search in sources :

Example 1 with Context

use of org.sonar.ce.task.projectanalysis.measure.PostMeasuresComputationCheck.Context in project sonarqube by SonarSource.

the class PostMeasuresComputationChecksStepTest method context_contains_ncloc_when_available.

@Test
public void context_contains_ncloc_when_available() {
    PostMeasuresComputationCheck check = mock(PostMeasuresComputationCheck.class);
    measureRepository.addRawMeasure(DUMB_PROJECT.getReportAttributes().getRef(), CoreMetrics.NCLOC_KEY, Measure.newMeasureBuilder().create(10));
    newStep(check).execute(new TestComputationStepContext());
    ArgumentCaptor<Context> contextArgumentCaptor = ArgumentCaptor.forClass(Context.class);
    verify(check).onCheck(contextArgumentCaptor.capture());
    assertThat(contextArgumentCaptor.getValue().getNcloc()).isEqualTo(10);
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Context(org.sonar.ce.task.projectanalysis.measure.PostMeasuresComputationCheck.Context) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Example 2 with Context

use of org.sonar.ce.task.projectanalysis.measure.PostMeasuresComputationCheck.Context in project sonarqube by SonarSource.

the class PostMeasuresComputationChecksStepTest method context_contains_project_uuid_from_analysis_metada_holder.

@Test
public void context_contains_project_uuid_from_analysis_metada_holder() {
    Project project = Project.from(newPrivateProjectDto());
    analysisMetadataHolder.setProject(project);
    PostMeasuresComputationCheck check = mock(PostMeasuresComputationCheck.class);
    newStep(check).execute(new TestComputationStepContext());
    ArgumentCaptor<Context> contextArgumentCaptor = ArgumentCaptor.forClass(Context.class);
    verify(check).onCheck(contextArgumentCaptor.capture());
    assertThat(contextArgumentCaptor.getValue().getProjectUuid()).isEqualTo(project.getUuid());
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Context(org.sonar.ce.task.projectanalysis.measure.PostMeasuresComputationCheck.Context) Project(org.sonar.server.project.Project) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Example 3 with Context

use of org.sonar.ce.task.projectanalysis.measure.PostMeasuresComputationCheck.Context in project sonarqube by SonarSource.

the class PostMeasuresComputationChecksStepTest method ncloc_is_zero_in_context_when_not_available.

@Test
public void ncloc_is_zero_in_context_when_not_available() {
    PostMeasuresComputationCheck check = mock(PostMeasuresComputationCheck.class);
    newStep(check).execute(new TestComputationStepContext());
    ArgumentCaptor<Context> contextArgumentCaptor = ArgumentCaptor.forClass(Context.class);
    verify(check).onCheck(contextArgumentCaptor.capture());
    assertThat(contextArgumentCaptor.getValue().getNcloc()).isZero();
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Context(org.sonar.ce.task.projectanalysis.measure.PostMeasuresComputationCheck.Context) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 Context (org.sonar.ce.task.projectanalysis.measure.PostMeasuresComputationCheck.Context)3 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)3 Project (org.sonar.server.project.Project)1