dsmiley commented on code in PR #3860:
URL: https://github.com/apache/solr/pull/3860#discussion_r2529063780
##########
solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java:
##########
@@ -508,38 +487,38 @@ private void assertRTG(final SolrInputDocument[]
knownDocs, final int[] docIds)
}
String wt = params.get(CommonParams.WT, "javabin");
- final SolrClient client = getRandomClient(random(), wt);
+ final SolrClient client = getRandomClient(random());
// If we have chosen a CloudSolrClient, then override wt parameter back to
javabin format,
// regardless of what was randomly picked.
if (client instanceof CloudSolrClient) {
wt = "javabin";
}
- final Object rsp;
- final SolrDocumentList docs;
- if ("javabin".equals(wt)) {
- // the most common case
- final QueryResponse qRsp = client.query(params);
- assertNotNull(params.toString(), qRsp);
- rsp = qRsp;
- docs = getDocsFromRTGResponse(askForList, qRsp);
- } else {
- final NamedList<Object> nlRsp = client.request(new QueryRequest(params));
- assertNotNull(params.toString(), nlRsp);
- rsp = nlRsp;
- final String textResult =
InputStreamResponseParser.consumeResponseToString(nlRsp);
- switch (wt) {
- case "json":
- docs = getDocsFromJsonResponse(askForList, textResult);
- break;
- case "xml":
- docs = getDocsFromXmlResponse(askForList, textResult);
- break;
- default:
- throw new IllegalStateException();
- }
- }
+ final Object rsp; // only here for an assertion message
+
+ var qr = new QueryRequest(params);
+ final SolrDocumentList docs =
Review Comment:
I liked using JDK switch expression here. Maybe not totally elegant but
fine. But most especially one switch for the 3 writer types, instead of the
awkward if-else and smaller switch.
##########
solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java:
##########
@@ -621,29 +599,17 @@ private static SolrDocumentList getDocsFromJsonResponse(
}
}
+ @SuppressWarnings("unchecked")
private static SolrDocumentList getDocsFromXmlResponse(
- final boolean expectList, final String rsp) {
- return getDocsFromRTGResponse(
- expectList,
- new QueryResponse(
- new RawCapableXMLResponseParser().processResponse(new
StringReader(rsp))));
+ final boolean expectList, final NamedList<?> rsp) {
Review Comment:
no longer parsing a string since we used an XML based ResponseWriter
##########
solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java:
##########
@@ -607,8 +586,7 @@ private static SolrDocumentList
getSolrDocumentList(Map<String, Object> response
@SuppressWarnings("unchecked")
private static SolrDocumentList getDocsFromJsonResponse(
- final boolean expectList, final String rsp) throws IOException {
- Map<String, Object> nl = (Map<String, Object>) ObjectBuilder.fromJSON(rsp);
+ final boolean expectList, final NamedList<?> nl) throws IOException {
Review Comment:
no longer parsing a string since we used a JSON based ResponseWriter
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]