.mustNot(FilterBuilders.hasParentFilter(this.getParentType(),
FilterBuilders.termFilter(RuleNormalizer.RuleField.STATUS.field(), RuleStatus.REMOVED.name())))))
.addAggregation(AggregationBuilders.terms(ActiveRuleNormalizer.ActiveRuleField.PROFILE_KEY.field())
- .field(ActiveRuleNormalizer.ActiveRuleField.PROFILE_KEY.field())
+ .field(ActiveRuleNormalizer.ActiveRuleField.PROFILE_KEY.field()).size(0)
.subAggregation(AggregationBuilders.terms(ActiveRuleNormalizer.ActiveRuleField.INHERITANCE.field())
.field(ActiveRuleNormalizer.ActiveRuleField.INHERITANCE.field()))
.subAggregation(AggregationBuilders.terms(ActiveRuleNormalizer.ActiveRuleField.SEVERITY.field())
import java.util.List;
import java.util.Map;
+import static com.google.common.collect.Lists.newArrayList;
import static org.fest.assertions.Assertions.assertThat;
public class ActiveRuleBackendMediumTest extends SearchMediumTest {
assertThat(stats).hasSize(2);
}
+ /**
+ * SONAR-5844
+ */
+ @Test
+ public void stats_for_all_with_lof_of_profiles() {
+ RuleDto ruleDto1 = newRuleDto(RuleTesting.XOO_X1);
+ RuleDto ruleDto2 = newRuleDto(RuleTesting.XOO_X2);
+ db.ruleDao().insert(dbSession, ruleDto1, ruleDto2);
+
+ List<String> profileKeys = newArrayList();
+ for (int i = 0; i<30; i++) {
+ QualityProfileDto profileDto = QProfileTesting.newDto(QProfileName.createFor("xoo", "profile-" + i), "profile-" + i);
+ profileKeys.add(profileDto.getKey());
+ db.qualityProfileDao().insert(dbSession, profileDto);
+
+ db.activeRuleDao().insert(dbSession,
+ ActiveRuleDto.createFor(profileDto, ruleDto1)
+ .setSeverity(Severity.BLOCKER),
+ ActiveRuleDto.createFor(profileDto, ruleDto2)
+ .setSeverity(Severity.MAJOR)
+ );
+ }
+ dbSession.commit();
+ dbSession.clearCache();
+
+ Map<String, Multimap<String, FacetValue>> stats = index.get(ActiveRuleIndex.class).getStatsByProfileKeys(profileKeys);
+ assertThat(stats).hasSize(30);
+ }
+
private RuleDto newRuleDto(RuleKey ruleKey) {
return new RuleDto()
.setRuleKey(ruleKey.rule())