final String ruleKeyParam = request.param("k");
Collection<Rule> foundRules = Collections.emptyList();
boolean hasMore = false;
+ long total = 0L;
if (ruleKeyParam == null) {
final String ruleSearchParam = request.param("s");
final int pageSize = request.paramAsInt("ps", 25);
.build());
foundRules = searchResult.results();
hasMore = searchResult.paging().hasNextPage();
+ total = searchResult.paging().total();
} else {
RuleKey ruleKey = RuleKey.parse(ruleKeyParam);
Rule rule = findRule(ruleKey);
if (rule != null) {
foundRules = Collections.singleton(rule);
+ total = 1L;
}
hasMore = false;
}
writeRule(rule, json);
json.endObject();
}
- json.endArray().prop("more", hasMore).endObject().close();
+ json.endArray().prop("more", hasMore).prop("total", total).endObject().close();
}
@CheckForNull
MockUserSession.set();
WsTester.TestRequest request = tester.newRequest("list").setParam("ps", "10").setParam("p", "2");
- request.execute().assertJson("{'more':false,'results':["
+ request.execute().assertJson("{'more':false,'total':1,'results':["
+ "{'key':'squid:AvoidCycle','name':'Avoid cycle','language':'Java'}"
+ "]}");
}
MockUserSession.set();
WsTester.TestRequest request = tester.newRequest("list").setParam("k", ruleKey);
- request.execute().assertJson("{'more':false,'results':["
+ request.execute().assertJson("{'more':false,'total':1,'results':["
+ "{'key':'squid:AvoidCycle','name':'Avoid cycle','language':'Java'}"
+ "]}");
}