use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class ExportIssuesStepTest method setUp.
@Before
public void setUp() {
ProjectDto project = createProject();
when(projectHolder.projectDto()).thenReturn(project);
when(projectHolder.branches()).thenReturn(newArrayList(new BranchDto().setBranchType(BranchType.BRANCH).setKey("master").setProjectUuid(SOME_PROJECT_UUID).setUuid(SOME_PROJECT_UUID)));
// adds a random number of Rules to db and repository so that READY_RULE_KEY does always get id=ref=1
for (int i = 0; i < new Random().nextInt(150); i++) {
RuleKey ruleKey = RuleKey.of("repo_" + i, "key_" + i);
RuleDto ruleDto = insertRule(ruleKey.toString());
ruleRepository.register(ruleDto.getUuid(), ruleKey);
}
this.readyRuleDto = insertRule(READY_RULE_KEY);
componentRepository.register(12, SOME_PROJECT_UUID, false);
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class ExportLiveMeasuresStepTest method export_zero_measures.
@Test
public void export_zero_measures() {
when(projectHolder.branches()).thenReturn(newArrayList());
when(projectHolder.projectDto()).thenReturn(new ProjectDto().setUuid("does not exist"));
underTest.execute(new TestComputationStepContext());
assertThat(dumpWriter.getWrittenMessagesOf(DumpElement.LIVE_MEASURES)).isEmpty();
assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("0 live measures exported");
assertThat(metricRepository.getRefByUuid()).isEmpty();
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class BranchDaoTest method selectProjectUuidsWithIssuesNeedSync.
@Test
public void selectProjectUuidsWithIssuesNeedSync() {
ComponentDto project1 = db.components().insertPrivateProject();
ComponentDto project2 = db.components().insertPrivateProject();
ComponentDto project3 = db.components().insertPrivateProject();
ComponentDto project4 = db.components().insertPrivateProject();
ProjectDto project1Dto = db.components().getProjectDto(project1);
ProjectDto project2Dto = db.components().getProjectDto(project2);
ProjectDto project3Dto = db.components().getProjectDto(project3);
ProjectDto project4Dto = db.components().getProjectDto(project4);
BranchDto branch1 = db.components().insertProjectBranch(project1Dto, branchDto -> branchDto.setNeedIssueSync(true));
BranchDto branch2 = db.components().insertProjectBranch(project1Dto, branchDto -> branchDto.setNeedIssueSync(false));
BranchDto branch3 = db.components().insertProjectBranch(project2Dto);
assertThat(underTest.selectProjectUuidsWithIssuesNeedSync(db.getSession(), Sets.newHashSet(project1Dto.getUuid(), project2Dto.getUuid(), project3Dto.getUuid(), project4Dto.getUuid()))).containsOnly(project1.uuid());
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class BranchDaoTest method selectByBranchKeys.
@Test
public void selectByBranchKeys() {
ProjectDto project1 = db.components().insertPrivateProjectDto();
ProjectDto project2 = db.components().insertPrivateProjectDto();
ProjectDto project3 = db.components().insertPrivateProjectDto();
BranchDto branch1 = db.components().insertProjectBranch(project1, b -> b.setKey("branch1"));
BranchDto branch2 = db.components().insertProjectBranch(project2, b -> b.setKey("branch2"));
BranchDto branch3 = db.components().insertProjectBranch(project3, b -> b.setKey("branch3"));
Map<String, String> branchKeysByProjectUuid = new HashMap<>();
branchKeysByProjectUuid.put(project1.getUuid(), "branch1");
branchKeysByProjectUuid.put(project2.getUuid(), "branch2");
branchKeysByProjectUuid.put(project3.getUuid(), "nonexisting");
List<BranchDto> branchDtos = underTest.selectByBranchKeys(dbSession, branchKeysByProjectUuid);
assertThat(branchDtos).hasSize(2);
assertThat(branchDtos).extracting(BranchDto::getUuid).containsExactlyInAnyOrder(branch1.getUuid(), branch2.getUuid());
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class BranchDaoTest method selectByProjectUuid.
@Test
public void selectByProjectUuid() {
ComponentDto project1 = db.components().insertPrivateProject();
ComponentDto project2 = db.components().insertPrivateProject();
ComponentDto branch1 = db.components().insertProjectBranch(project1);
ComponentDto branch2 = db.components().insertProjectBranch(project1);
ComponentDto branch3 = db.components().insertProjectBranch(project2);
ComponentDto branch4 = db.components().insertProjectBranch(project2);
assertThat(underTest.selectByProject(dbSession, new ProjectDto().setUuid(project1.uuid()))).extracting(BranchDto::getUuid).containsExactlyInAnyOrder(project1.uuid(), branch1.uuid(), branch2.uuid());
assertThat(underTest.selectByProject(dbSession, new ProjectDto().setUuid(project2.uuid()))).extracting(BranchDto::getUuid).containsExactlyInAnyOrder(project2.uuid(), branch3.uuid(), branch4.uuid());
}
Aggregations