From 6fb73006027387e29ed85214a7f5400e9d9d2ac9 Mon Sep 17 00:00:00 2001 From: Siddhant Deshmukh Date: Tue, 3 Sep 2024 15:59:52 -0700 Subject: [PATCH] Spotless apply Signed-off-by: Siddhant Deshmukh --- .../insights/QueryInsightsRestTestCase.java | 47 ++++++------- .../grouper/MinMaxQueryGrouperByNoneIT.java | 25 +++---- .../MinMaxQueryGrouperBySimilarityIT.java | 68 ++++++------------- 3 files changed, 53 insertions(+), 87 deletions(-) diff --git a/src/test/java/org/opensearch/plugin/insights/QueryInsightsRestTestCase.java b/src/test/java/org/opensearch/plugin/insights/QueryInsightsRestTestCase.java index d973b26a..2852dec0 100644 --- a/src/test/java/org/opensearch/plugin/insights/QueryInsightsRestTestCase.java +++ b/src/test/java/org/opensearch/plugin/insights/QueryInsightsRestTestCase.java @@ -194,7 +194,6 @@ protected String defaultTopQueriesSettings() { + "}"; } - protected String defaultTopQueryGroupingSettings() { return "{\n" + " \"persistent\" : {\n" @@ -248,38 +247,32 @@ private String searchBody(String queryType) { switch (queryType) { case "match": // Query shape 1: Match query - return "{\n" + - " \"query\": {\n" + - " \"match\": {\n" + - " \"field1\": \"value1\"\n" + - " }\n" + - " }\n" + - "}"; + return "{\n" + " \"query\": {\n" + " \"match\": {\n" + " \"field1\": \"value1\"\n" + " }\n" + " }\n" + "}"; case "range": // Query shape 2: Range query - return "{\n" + - " \"query\": {\n" + - " \"range\": {\n" + - " \"field2\": {\n" + - " \"gte\": 10,\n" + - " \"lte\": 50\n" + - " }\n" + - " }\n" + - " }\n" + - "}"; + return "{\n" + + " \"query\": {\n" + + " \"range\": {\n" + + " \"field2\": {\n" + + " \"gte\": 10,\n" + + " \"lte\": 50\n" + + " }\n" + + " }\n" + + " }\n" + + "}"; case "term": // Query shape 3: Term query - return "{\n" + - " \"query\": {\n" + - " \"term\": {\n" + - " \"field3\": {\n" + - " \"value\": \"exact-value\"\n" + - " }\n" + - " }\n" + - " }\n" + - "}"; + return "{\n" + + " \"query\": {\n" + + " \"term\": {\n" + + " \"field3\": {\n" + + " \"value\": \"exact-value\"\n" + + " }\n" + + " }\n" + + " }\n" + + "}"; default: throw new IllegalArgumentException("Unknown query type: " + queryType); diff --git a/src/test/java/org/opensearch/plugin/insights/core/service/grouper/MinMaxQueryGrouperByNoneIT.java b/src/test/java/org/opensearch/plugin/insights/core/service/grouper/MinMaxQueryGrouperByNoneIT.java index 6d9ef132..86ae2440 100644 --- a/src/test/java/org/opensearch/plugin/insights/core/service/grouper/MinMaxQueryGrouperByNoneIT.java +++ b/src/test/java/org/opensearch/plugin/insights/core/service/grouper/MinMaxQueryGrouperByNoneIT.java @@ -7,15 +7,14 @@ */ package org.opensearch.plugin.insights.core.service.grouper; +import java.io.IOException; +import java.nio.charset.StandardCharsets; import org.junit.Assert; import org.opensearch.client.Request; import org.opensearch.client.Response; import org.opensearch.plugin.insights.QueryInsightsRestTestCase; import org.opensearch.plugin.insights.settings.QueryInsightsSettings; -import java.io.IOException; -import java.nio.charset.StandardCharsets; - /** * ITs for Grouping Top Queries by none */ @@ -60,16 +59,14 @@ public void testGroupingByNone() throws IOException, InterruptedException { } private String groupByNoneSettings() { - return "{\n" + - " \"persistent\" : {\n" + - " \"search.insights.top_queries.latency.enabled\" : \"true\",\n" + - " \"search.insights.top_queries.latency.window_size\" : \"1m\",\n" + - " \"search.insights.top_queries.latency.top_n_size\" : 100,\n" + - " \"search.insights.top_queries.group_by\" : \"none\",\n" + - " \"search.insights.top_queries.max_groups\" : 5\n" + - " }\n" + - "}"; + return "{\n" + + " \"persistent\" : {\n" + + " \"search.insights.top_queries.latency.enabled\" : \"true\",\n" + + " \"search.insights.top_queries.latency.window_size\" : \"1m\",\n" + + " \"search.insights.top_queries.latency.top_n_size\" : 100,\n" + + " \"search.insights.top_queries.group_by\" : \"none\",\n" + + " \"search.insights.top_queries.max_groups\" : 5\n" + + " }\n" + + "}"; } } - - diff --git a/src/test/java/org/opensearch/plugin/insights/core/service/grouper/MinMaxQueryGrouperBySimilarityIT.java b/src/test/java/org/opensearch/plugin/insights/core/service/grouper/MinMaxQueryGrouperBySimilarityIT.java index 2af9ec6f..66567b18 100644 --- a/src/test/java/org/opensearch/plugin/insights/core/service/grouper/MinMaxQueryGrouperBySimilarityIT.java +++ b/src/test/java/org/opensearch/plugin/insights/core/service/grouper/MinMaxQueryGrouperBySimilarityIT.java @@ -7,6 +7,8 @@ */ package org.opensearch.plugin.insights.core.service.grouper; +import java.io.IOException; +import java.nio.charset.StandardCharsets; import org.junit.Assert; import org.opensearch.client.Request; import org.opensearch.client.Response; @@ -14,9 +16,6 @@ import org.opensearch.plugin.insights.QueryInsightsRestTestCase; import org.opensearch.plugin.insights.settings.QueryInsightsSettings; -import java.io.IOException; -import java.nio.charset.StandardCharsets; - /** * ITs for Grouping Top Queries by similarity */ @@ -98,63 +97,40 @@ public void testValidQueryGroupingSettings() throws IOException { private String[] invalidQueryGroupingSettings() { return new String[] { // Invalid max_groups: below minimum (0) - "{\n" + - " \"persistent\" : {\n" + - " \"search.insights.top_queries.max_groups\" : 0\n" + - " }\n" + - "}", + "{\n" + " \"persistent\" : {\n" + " \"search.insights.top_queries.max_groups\" : 0\n" + " }\n" + "}", // Invalid max_groups: above maximum (10001) - "{\n" + - " \"persistent\" : {\n" + - " \"search.insights.top_queries.max_groups\" : 10001\n" + - " }\n" + - "}", + "{\n" + " \"persistent\" : {\n" + " \"search.insights.top_queries.max_groups\" : 10001\n" + " }\n" + "}", // Invalid group_by: unsupported value - "{\n" + - " \"persistent\" : {\n" + - " \"search.insights.top_queries.group_by\" : \"unsupported_value\"\n" + - " }\n" + - "}" - }; + "{\n" + + " \"persistent\" : {\n" + + " \"search.insights.top_queries.group_by\" : \"unsupported_value\"\n" + + " }\n" + + "}" }; } private String[] validQueryGroupingSettings() { - return new String[]{ + return new String[] { // Valid max_groups: minimum value (1) - "{\n" + - " \"persistent\" : {\n" + - " \"search.insights.top_queries.max_groups\" : 1\n" + - " }\n" + - "}", + "{\n" + " \"persistent\" : {\n" + " \"search.insights.top_queries.max_groups\" : 1\n" + " }\n" + "}", // Valid max_groups: maximum value (10000) - "{\n" + - " \"persistent\" : {\n" + - " \"search.insights.top_queries.max_groups\" : 10000\n" + - " }\n" + - "}", + "{\n" + " \"persistent\" : {\n" + " \"search.insights.top_queries.max_groups\" : 10000\n" + " }\n" + "}", // Valid group_by: supported value (SIMILARITY) - "{\n" + - " \"persistent\" : {\n" + - " \"search.insights.top_queries.group_by\" : \"SIMILARITY\"\n" + - " }\n" + - "}" - }; + "{\n" + " \"persistent\" : {\n" + " \"search.insights.top_queries.group_by\" : \"SIMILARITY\"\n" + " }\n" + "}" }; } private String groupByNoneSettings() { - return "{\n" + - " \"persistent\" : {\n" + - " \"search.insights.top_queries.latency.enabled\" : \"true\",\n" + - " \"search.insights.top_queries.latency.window_size\" : \"1m\",\n" + - " \"search.insights.top_queries.latency.top_n_size\" : 100,\n" + - " \"search.insights.top_queries.group_by\" : \"none\",\n" + - " \"search.insights.top_queries.max_groups\" : 5\n" + - " }\n" + - "}"; + return "{\n" + + " \"persistent\" : {\n" + + " \"search.insights.top_queries.latency.enabled\" : \"true\",\n" + + " \"search.insights.top_queries.latency.window_size\" : \"1m\",\n" + + " \"search.insights.top_queries.latency.top_n_size\" : 100,\n" + + " \"search.insights.top_queries.group_by\" : \"none\",\n" + + " \"search.insights.top_queries.max_groups\" : 5\n" + + " }\n" + + "}"; } } -