}).collect(MoreCollectors.toList(projectUuids.size()));
}
- public List<BranchStatistics> searchBranchStatistics(List<String> branchUuids) {
+ public List<BranchStatistics> searchBranchStatistics(String projectUuid, List<String> branchUuids) {
if (branchUuids.isEmpty()) {
return Collections.emptyList();
}
SearchRequestBuilder request = client.prepareSearch(IssueIndexDefinition.INDEX_TYPE_ISSUE)
+ .setRouting(projectUuid)
.setQuery(
boolQuery()
.must(termsQuery(IssueIndexDefinition.FIELD_ISSUE_BRANCH_UUID, branchUuids))
Map<String, MeasureDto> qualityGateMeasuresByComponentUuids = dbClient.measureDao()
.selectByComponentsAndMetrics(dbSession, branches.stream().map(BranchDto::getUuid).collect(toList()), singletonList(qualityGateMetric.getId()))
.stream().collect(uniqueIndex(MeasureDto::getComponentUuid));
- Map<String, BranchStatistics> branchStatisticsByBranchUuid = issueIndex.searchBranchStatistics(branches.stream()
+ Map<String, BranchStatistics> branchStatisticsByBranchUuid = issueIndex.searchBranchStatistics(project.uuid(), branches.stream()
.filter(b -> b.getBranchType().equals(SHORT))
.map(BranchDto::getUuid).collect(toList()))
.stream().collect(uniqueIndex(BranchStatistics::getBranchUuid, Function.identity()));
newDoc(branch1).setType(BUG), newDoc(branch1).setType(VULNERABILITY), newDoc(branch1).setType(CODE_SMELL),
newDoc(branch3).setType(CODE_SMELL), newDoc(branch3).setType(CODE_SMELL), newDoc(fileOnBranch3).setType(CODE_SMELL));
- List<BranchStatistics> branchStatistics = underTest.searchBranchStatistics(asList(branch1.uuid(), branch2.uuid(), branch3.uuid()));
+ List<BranchStatistics> branchStatistics = underTest.searchBranchStatistics(project.uuid(), asList(branch1.uuid(), branch2.uuid(), branch3.uuid()));
assertThat(branchStatistics).extracting(BranchStatistics::getBranchUuid, BranchStatistics::getBugs, BranchStatistics::getVulnerabilities, BranchStatistics::getCodeSmells)
.containsExactlyInAnyOrder(
branchUuids.add(branch.uuid());
});
- List<BranchStatistics> branchStatistics = underTest.searchBranchStatistics(branchUuids);
+ List<BranchStatistics> branchStatistics = underTest.searchBranchStatistics(project.uuid(), branchUuids);
assertThat(branchStatistics)
.extracting(BranchStatistics::getBranchUuid, BranchStatistics::getBugs, BranchStatistics::getVulnerabilities, BranchStatistics::getCodeSmells)
@Test
public void searchBranchStatistics_on_empty_list() {
- assertThat(underTest.searchBranchStatistics(emptyList())).isEmpty();
- assertThat(underTest.searchBranchStatistics(singletonList("unknown"))).isEmpty();
+ ComponentDto project = db.components().insertMainBranch();
+
+ assertThat(underTest.searchBranchStatistics(project.uuid(), emptyList())).isEmpty();
+ assertThat(underTest.searchBranchStatistics(project.uuid(), singletonList("unknown"))).isEmpty();
}
private void addIssues(ComponentDto branch, int bugs, int vulnerabilities, int codeSmelles) {