dsmiley commented on code in PR #1154:
URL: https://github.com/apache/solr/pull/1154#discussion_r1018199451


##########
solr/core/src/test/org/apache/solr/search/QueryUtilsTest.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.search;
+
+import java.util.ArrayList;
+import java.util.Set;
+import org.apache.lucene.search.Query;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.handler.component.QueryComponent;
+import org.apache.solr.handler.component.ResponseBuilder;
+import org.apache.solr.handler.component.SearchComponent;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.junit.Test;
+
+/** Tests the utility methods in QueryUtils. */
+public class QueryUtilsTest extends SolrTestCaseJ4 {
+
+  @Test
+  public void testGetTaggedQueries() throws Exception {
+    try {
+      initCore("solrconfig.xml", "schema.xml");
+
+      SearchComponent queryComponent =
+          h.getCore().getSearchComponent(QueryComponent.COMPONENT_NAME);
+
+      // first make sure QueryUtils.getTaggedQueries() behaves properly on an 
"empty" request
+      try (SolrQueryRequest request = req()) {
+        ResponseBuilder rb =
+            new ResponseBuilder(request, new SolrQueryResponse(), new 
ArrayList<>());
+        assertEquals(0, QueryUtils.getTaggedQueries(request, 
Set.of("t0")).size());
+        queryComponent.prepare(rb);
+        assertEquals(0, QueryUtils.getTaggedQueries(request, 
Set.of("t0")).size());
+      }
+
+      // now test with a request that includes multiple tagged queries
+      try (SolrQueryRequest request =
+          req(
+              CommonParams.Q, "{!tag=t0}text:zzzz",
+              CommonParams.FQ, "{!tag=t1,t2}str_s:a",
+              CommonParams.FQ, "{!tag=t3}str_s:b",
+              CommonParams.FQ, "{!tag=t3}str_s:b",
+              CommonParams.FQ, "{!tag=t4}str_s:b",
+              CommonParams.FQ, "str_s:b",
+              CommonParams.FQ, "str_s:c")) {
+
+        ResponseBuilder rb =
+            new ResponseBuilder(request, new SolrQueryResponse(), new 
ArrayList<>());
+
+        // the "tag map" will not be populated in the SolrQueryRequest's 
"context" until
+        // the QParsers have been initialized; before such time, 
QueryUtils.getTaggedQueries will
+        // always return
+        // an empty set

Review Comment:
   Nice technique Kevin.  For me -- I use IntelliJ configured with the Google 
Java Format plugin, so I can easily use my IDE to reformat lines using standard 
hotkeys etc.  Often "tidy" has nothing left to do.



-- 
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: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to