Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make MonitorSolrQueryTest.validate's expectedValue argument type more specific #4

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -369,35 +369,31 @@ public void testDeleteByQueryId() throws Exception {
assertEquals(0, ((SolrDocumentList) response.getResponse().get("response")).size());
}

void validate(QueryResponse response, int doc, Object expectedValue, boolean writeToDocList) {
void validate(
QueryResponse response, int doc, List<String> expectedValue, boolean writeToDocList) {
var monitorQueries = monitorQueries(response, doc);
assertEquals(expectedValue, monitorQueries);
if (writeToDocList) {
validateDocList(response, doc, expectedValue);
}
}

void validateDocList(QueryResponse response, int doc, List<String> expectedList) {
// TODO
}

void validate(
QueryResponse response, int doc, int query, Object expectedValue, boolean writeToDocList) {
QueryResponse response, int doc, int query, String expectedValue, boolean writeToDocList) {
var monitorQueries = monitorQueries(response, doc);
assertTrue(monitorQueries.size() > query);
assertEquals(expectedValue, monitorQueries.get(query));
if (writeToDocList) {
validateDocList(response, doc, expectedValue);
validateDocList(response, doc, query, expectedValue);
}
}

void validateDocList(QueryResponse response, int doc, Object expectedValue) {
SolrDocumentList actualValues = (SolrDocumentList) response.getResponse().get("response");
// minimal checks only so far; TODO: make this more comprehensive
if (expectedValue instanceof List) {
List<Object> expectedValues = (List) expectedValue;
if (expectedValues.size() == 1 && actualValues.size() <= 2) {
assertEquals(
expectedValues.get(0),
actualValues.get(actualValues.size() - 1 - doc).getFieldValue(MonitorFields.QUERY_ID));
}
}
void validateDocList(QueryResponse response, int doc, int query, String expectedValue) {
// TODO
}

List<Object> monitorQueries(QueryResponse response, int doc) {
Expand Down