use of org.sonarqube.ws.Rules.Actives in project sonarqube by SonarSource.
the class DefaultActiveRulesLoaderTest method responseOfSize.
/**
* Generates an imaginary protobuf result.
*
* @param numberOfRules the number of rules, that the response should contain
* @param total the number of results on all pages
* @return the binary stream
*/
private InputStream responseOfSize(int numberOfRules, int total) {
Builder rules = SearchResponse.newBuilder();
Actives.Builder actives = Actives.newBuilder();
IntStream.rangeClosed(1, numberOfRules).mapToObj(i -> RuleKey.of("squid", "S" + i)).forEach(key -> {
Rule.Builder ruleBuilder = Rule.newBuilder();
ruleBuilder.setKey(key.toString());
rules.addRules(ruleBuilder);
Active.Builder activeBuilder = Active.newBuilder();
activeBuilder.setCreatedAt("2014-05-27T15:50:45+0100");
if (EXAMPLE_KEY.equals(key)) {
activeBuilder.addParams(Rules.Active.Param.newBuilder().setKey(FORMAT_KEY).setValue(FORMAT_VALUE));
activeBuilder.setSeverity(SEVERITY_VALUE);
}
ActiveList activeList = Rules.ActiveList.newBuilder().addActiveList(activeBuilder).build();
actives.putAllActives(ImmutableSortedMap.of(key.toString(), activeList));
});
rules.setActives(actives);
rules.setPs(numberOfRules);
rules.setTotal(total);
return new ByteArrayInputStream(rules.build().toByteArray());
}
Aggregations