Map<String, ActiveList> actives = response.getActives().getActives();
assertThat(result.getActives()).isNotNull(); assertThat(result.getActives().getActives().get(rule.getKey().toString())).isNotNull(); assertThat(result.getActives().getActives().get(rule.getKey().toString()).getActiveListList()).hasSize(1); Rules.Active activeList = result.getActives().getActives().get(rule.getKey().toString()).getActiveList(0); assertThat(activeList.getParamsCount()).isEqualTo(2); assertThat(activeList.getParamsList()).extracting("key", "value").containsExactlyInAnyOrder(
@Test public void active_rules_are_not_returned_when_not_member_of_paid_organization() { OrganizationDto organization = db.organizations().insert(o -> o.setSubscription(PAID)); QProfileDto profile = db.qualityProfiles().insert(organization, p -> p.setLanguage("java")); RuleDefinitionDto rule = db.rules().insert(r -> r.setLanguage("java")); RuleActivation activation = RuleActivation.create(rule.getId(), BLOCKER, null); qProfileRules.activateAndCommit(db.getSession(), profile, singleton(activation)); indexRules(); SearchResponse result = ws.newRequest() .setParam(FIELDS, "actives") .setParam(PARAM_ORGANIZATION, organization.getKey()) .executeProtobuf(SearchResponse.class); assertThat(result.getRulesCount()).isEqualTo(1); assertThat(result.getActives().getActivesMap()).isEmpty(); }
for (Map.Entry<String, ActiveList> entry : response.getActives().getActives().entrySet()) { RuleKey ruleKey = RuleKey.parse(entry.getKey()); for (org.sonarqube.ws.Rules.Active ar : entry.getValue().getActiveListList()) {
Map<String, ActiveList> actives = response.getActives().getActives();
Map<String, ActiveList> actives = response.getActives().getActives();
assertThat(result.getTotal()).isEqualTo(1); assertThat(result.getRulesCount()).isEqualTo(1); assertThat(result.getActives()).isNotNull(); assertThat(result.getActives().getActives().get(rule.getKey().toString())).isNotNull(); assertThat(result.getActives().getActives().get(rule.getKey().toString()).getActiveListList()).hasSize(1); Rules.Active activeList = result.getActives().getActives().get(rule.getKey().toString()).getActiveList(0); assertThat(activeList.getParamsCount()).isEqualTo(2); assertThat(activeList.getParamsList()).extracting("key", "value").containsExactlyInAnyOrder(
@Test public void active_rules_are_returned_when_member_of_paid_organization() { OrganizationDto organization = db.organizations().insert(o -> o.setSubscription(PAID)); QProfileDto profile = db.qualityProfiles().insert(organization, p -> p.setLanguage("java")); RuleDefinitionDto rule = db.rules().insert(r -> r.setLanguage("java")); RuleActivation activation = RuleActivation.create(rule.getId(), BLOCKER, null); qProfileRules.activateAndCommit(db.getSession(), profile, singleton(activation)); userSession.logIn(db.users().insertUser()).addMembership(organization); indexRules(); SearchResponse result = ws.newRequest() .setParam(FIELDS, "actives") .setParam(PARAM_ORGANIZATION, organization.getKey()) .executeProtobuf(SearchResponse.class); assertThat(result.getRulesCount()).isEqualTo(1); assertThat(result.getActives().getActivesMap()).isNotEmpty(); }