use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class EnableAnalysisStepTest method switch_islast_flag_and_mark_analysis_as_processed.
@Test
public void switch_islast_flag_and_mark_analysis_as_processed() {
ComponentDto project = ComponentTesting.newPrivateProjectDto(REPORT_PROJECT.getUuid());
db.components().insertComponent(project);
insertAnalysis(project, PREVIOUS_ANALYSIS_UUID, SnapshotDto.STATUS_PROCESSED, true);
insertAnalysis(project, CURRENT_ANALYSIS_UUID, SnapshotDto.STATUS_UNPROCESSED, false);
db.commit();
treeRootHolder.setRoot(REPORT_PROJECT);
analysisMetadataHolder.setUuid(CURRENT_ANALYSIS_UUID);
underTest.execute(new TestComputationStepContext());
verifyAnalysis(PREVIOUS_ANALYSIS_UUID, SnapshotDto.STATUS_PROCESSED, false);
verifyAnalysis(CURRENT_ANALYSIS_UUID, SnapshotDto.STATUS_PROCESSED, true);
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class BuildComponentTreeStepTest method verify_tree_is_correctly_built.
@Test
public void verify_tree_is_correctly_built() {
setAnalysisMetadataHolder();
reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, FILE_1_REF, FILE_2_REF, FILE_3_REF));
reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_PATH_1));
reportReader.putComponent(componentWithPath(FILE_2_REF, FILE, REPORT_FILE_PATH_2));
reportReader.putComponent(componentWithPath(FILE_3_REF, FILE, REPORT_FILE_PATH_3));
TestComputationStepContext context = new TestComputationStepContext();
underTest.execute(context);
Component root = treeRootHolder.getRoot();
assertThat(root).isNotNull();
verifyComponent(root, Component.Type.PROJECT, ROOT_REF, 1);
Component dir = root.getChildren().iterator().next();
verifyComponent(dir, Component.Type.DIRECTORY, null, 2);
Component dir1 = dir.getChildren().get(0);
verifyComponent(dir1, Component.Type.DIRECTORY, null, 1);
verifyComponent(dir1.getChildren().get(0), Component.Type.FILE, FILE_1_REF, 0);
Component dir2 = dir.getChildren().get(1);
verifyComponent(dir2, Component.Type.DIRECTORY, null, 2);
verifyComponent(dir2.getChildren().get(0), Component.Type.FILE, FILE_2_REF, 0);
verifyComponent(dir2.getChildren().get(1), Component.Type.FILE, FILE_3_REF, 0);
context.getStatistics().assertValue("components", 7);
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class BuildComponentTreeStepTest method generate_keys_when_using_new_branch.
@Test
public void generate_keys_when_using_new_branch() {
Branch branch = mock(Branch.class);
when(branch.getName()).thenReturn("origin/feature");
when(branch.isMain()).thenReturn(false);
when(branch.generateKey(any(), any())).thenReturn("generated");
analysisMetadataHolder.setRootComponentRef(ROOT_REF).setAnalysisDate(ANALYSIS_DATE).setProject(Project.from(newPrivateProjectDto().setDbKey(REPORT_PROJECT_KEY))).setBranch(branch);
BuildComponentTreeStep underTest = new BuildComponentTreeStep(dbClient, reportReader, treeRootHolder, analysisMetadataHolder, reportModulesPath);
reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY, FILE_1_REF));
reportReader.putComponent(componentWithPath(FILE_1_REF, FILE, REPORT_FILE_PATH_1));
underTest.execute(new TestComputationStepContext());
verifyComponentByRef(ROOT_REF, "generated", REPORT_PROJECT_KEY, analysisMetadataHolder.getProject().getName(), null);
verifyComponentByKey(REPORT_PROJECT_KEY + ":" + REPORT_DIR_PATH_1, "generated", REPORT_DIR_PATH_1);
verifyComponentByRef(FILE_1_REF, "generated", REPORT_PROJECT_KEY + ":" + REPORT_FILE_PATH_1, REPORT_FILE_NAME_1, null);
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class BuildComponentTreeStepTest method fails_if_root_component_does_not_exist_in_reportReader.
@Test
public void fails_if_root_component_does_not_exist_in_reportReader() {
setAnalysisMetadataHolder();
assertThatThrownBy(() -> underTest.execute(new TestComputationStepContext())).isInstanceOf(NullPointerException.class);
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class BuildComponentTreeStepTest method set_buildString.
@Test
@UseDataProvider("oneParameterNullNonNullCombinations")
public void set_buildString(@Nullable String buildString) {
String projectVersion = randomAlphabetic(7);
setAnalysisMetadataHolder();
reportReader.setMetadata(createReportMetadata(projectVersion, buildString));
reportReader.putComponent(component(ROOT_REF, PROJECT, REPORT_PROJECT_KEY));
underTest.execute(new TestComputationStepContext());
assertThat(treeRootHolder.getReportTreeRoot().getProjectAttributes().getBuildString()).isEqualTo(Optional.ofNullable(buildString));
}
Aggregations