use of org.sonar.db.component.BranchDto in project sonarqube by SonarSource.
the class IgnoreOrphanBranchStepTest method execute_on_already_indexed_branch.
@Test
public void execute_on_already_indexed_branch() {
BranchDto branchDto = new BranchDto().setBranchType(BRANCH).setKey("branchName").setUuid(BRANCH_UUID).setProjectUuid("project_uuid").setNeedIssueSync(false);
dbClient.branchDao().insert(dbTester.getSession(), branchDto);
dbTester.commit();
underTest.execute(() -> null);
Optional<BranchDto> branch = dbClient.branchDao().selectByUuid(dbTester.getSession(), BRANCH_UUID);
assertThat(branch.get().isNeedIssueSync()).isFalse();
assertThat(branch.get().isExcludeFromPurge()).isFalse();
}
use of org.sonar.db.component.BranchDto in project sonarqube by SonarSource.
the class IndexIssuesStepTest method execute.
@Test
public void execute() {
BranchDto branchDto = new BranchDto().setBranchType(BRANCH).setKey("branchName").setUuid(BRANCH_UUID).setProjectUuid("project_uuid").setNeedIssueSync(true);
dbClient.branchDao().insert(dbTester.getSession(), branchDto);
dbTester.commit();
underTest.execute(() -> null);
verify(issueIndexer, times(1)).indexOnAnalysis(BRANCH_UUID);
Optional<BranchDto> branch = dbClient.branchDao().selectByUuid(dbTester.getSession(), BRANCH_UUID);
assertThat(branch.get().isNeedIssueSync()).isFalse();
}
use of org.sonar.db.component.BranchDto in project sonarqube by SonarSource.
the class ExportLiveMeasuresStepTest method do_not_export_measures_on_disabled_projects.
@Test
public void do_not_export_measures_on_disabled_projects() {
ComponentDto project = createProject(false);
componentRepository.register(1, project.uuid(), false);
MetricDto metric = dbTester.measures().insertMetric(m -> m.setValueType(INT.name()));
dbTester.measures().insertLiveMeasure(project, metric, m -> m.setValue(4711.0d));
when(projectHolder.projectDto()).thenReturn(dbTester.components().getProjectDto(project));
when(projectHolder.branches()).thenReturn(newArrayList(new BranchDto().setProjectUuid(project.uuid()).setUuid(project.uuid()).setKey("master").setBranchType(BranchType.BRANCH)));
underTest.execute(new TestComputationStepContext());
List<ProjectDump.LiveMeasure> exportedMeasures = dumpWriter.getWrittenMessagesOf(DumpElement.LIVE_MEASURES);
assertThat(exportedMeasures).isEmpty();
}
use of org.sonar.db.component.BranchDto in project sonarqube by SonarSource.
the class ExportLiveMeasuresStepTest method test_null_exported_fields.
@Test
public void test_null_exported_fields() {
ComponentDto project = createProject(true);
componentRepository.register(1, project.uuid(), false);
MetricDto metric = dbTester.measures().insertMetric(m -> m.setValueType(INT.name()));
dbTester.measures().insertLiveMeasure(project, metric, m -> m.setProjectUuid(project.uuid()).setValue(null).setData((String) null).setVariation(null));
when(projectHolder.projectDto()).thenReturn(dbTester.components().getProjectDto(project));
when(projectHolder.branches()).thenReturn(newArrayList(new BranchDto().setProjectUuid(project.uuid()).setUuid(project.uuid()).setKey("master").setBranchType(BranchType.BRANCH)));
underTest.execute(new TestComputationStepContext());
List<ProjectDump.LiveMeasure> exportedMeasures = dumpWriter.getWrittenMessagesOf(DumpElement.LIVE_MEASURES);
assertThat(exportedMeasures).hasSize(1);
assertThat(exportedMeasures).extracting(ProjectDump.LiveMeasure::hasDoubleValue, ProjectDump.LiveMeasure::getTextValue, ProjectDump.LiveMeasure::hasVariation).containsOnly(tuple(false, "", false));
assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("1 live measures exported");
assertThat(metricRepository.getRefByUuid()).containsOnlyKeys(metric.getUuid());
}
use of org.sonar.db.component.BranchDto in project sonarqube by SonarSource.
the class ExportLiveMeasuresStepTest method do_not_export_measures_on_disabled_metrics.
@Test
public void do_not_export_measures_on_disabled_metrics() {
ComponentDto project = createProject(true);
componentRepository.register(1, project.uuid(), false);
MetricDto metric = dbTester.measures().insertMetric(m -> m.setValueType(INT.name()).setEnabled(false));
dbTester.measures().insertLiveMeasure(project, metric, m -> m.setValue(4711.0d));
when(projectHolder.projectDto()).thenReturn(dbTester.components().getProjectDto(project));
when(projectHolder.branches()).thenReturn(newArrayList(new BranchDto().setProjectUuid(project.uuid()).setUuid(project.uuid()).setKey("master").setBranchType(BranchType.BRANCH)));
underTest.execute(new TestComputationStepContext());
List<ProjectDump.LiveMeasure> exportedMeasures = dumpWriter.getWrittenMessagesOf(DumpElement.LIVE_MEASURES);
assertThat(exportedMeasures).isEmpty();
}
Aggregations