summaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com>2023-08-29 17:02:12 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-08-29 23:37:31 +0200
commit9ad528fdbc466133b67d55baadf1c01181cefea3 (patch)
treebf7b540188f9a64d99ac8b9f4cb6ff579c25dab1 /container-search
parent306dce28ed3cfa0d2f4679fd2519db3d1ac780c7 (diff)
- Update dependency org.jvnet.mimepull:mimepull to v1.10.0
- Update dependency org.apache.opennlp:opennlp-tools to v1.9.4 - Use dependency-versions - Bring jimfs up to date. - Bring some more libraries up-2-date. - Reduce usage of assertj
Diffstat (limited to 'container-search')
-rw-r--r--container-search/pom.xml5
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/vespa/RequestBuilderTestCase.java30
-rw-r--r--container-search/src/test/java/com/yahoo/search/handler/JSONSearchHandlerTestCase.java120
3 files changed, 71 insertions, 84 deletions
diff --git a/container-search/pom.xml b/container-search/pom.xml
index 31ce9a00e44..4c1d337d8ad 100644
--- a/container-search/pom.xml
+++ b/container-search/pom.xml
@@ -162,11 +162,6 @@
</exclusions>
</dependency>
<dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/vespa/RequestBuilderTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/vespa/RequestBuilderTestCase.java
index f8e67a10076..f474088fa0e 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/vespa/RequestBuilderTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/vespa/RequestBuilderTestCase.java
@@ -25,10 +25,8 @@ import com.yahoo.searchlib.expression.StrCatFunctionNode;
import com.yahoo.searchlib.expression.StringResultNode;
import com.yahoo.searchlib.expression.TimeStampFunctionNode;
import com.yahoo.searchlib.expression.ToStringFunctionNode;
-import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
-import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -468,29 +466,29 @@ public class RequestBuilderTestCase {
String expectedA = "[{ Attribute, result = [Count] }]";
assertLayout("all(group(a) each(output(count())))",
- Arrays.asList(expectedA).toString());
+ List.of(expectedA).toString());
assertLayout("all(group(a) each(output(count()) all()))",
- Arrays.asList(expectedA).toString());
+ List.of(expectedA).toString());
assertLayout("all(group(a) each(output(count()) all(group(b))))",
- Arrays.asList(expectedA).toString());
+ List.of(expectedA).toString());
assertLayout("all(group(a) each(output(count()) all(group(b) each())))",
- Arrays.asList(expectedA).toString());
+ List.of(expectedA).toString());
assertLayout("all(group(a) each(output(count()) all(group(b) each())))",
- Arrays.asList(expectedA).toString());
+ List.of(expectedA).toString());
assertLayout("all(group(a) each(output(count()) all(group(b) each())) as(foo)" +
" each())",
- Arrays.asList(expectedA).toString());
+ List.of(expectedA).toString());
assertLayout("all(group(a) each(output(count()) all(group(b) each())) as(foo)" +
" each(group(b)))",
- Arrays.asList(expectedA).toString());
+ List.of(expectedA).toString());
assertLayout("all(group(a) each(output(count()) all(group(b) each())) as(foo)" +
" each(group(b) each()))",
- Arrays.asList(expectedA).toString());
+ List.of(expectedA).toString());
String expectedB = "[{ Attribute }, { Attribute, result = [Count] }]";
assertLayout("all(group(a) each(output(count()) all(group(b) each())) as(foo)" +
" each(group(b) each(output(count()))))",
- Arrays.asList(expectedB, expectedA).toString());
+ List.of(expectedB, expectedA).toString());
}
@Test
@@ -650,8 +648,8 @@ public class RequestBuilderTestCase {
@Test
void requireThatTimeZoneIsAppliedToTimeFunctions() {
- for (String timePart : Arrays.asList("dayofmonth", "dayofweek", "dayofyear", "hourofday",
- "minuteofhour", "monthofyear", "secondofminute", "year"))
+ for (String timePart : List.of("dayofmonth", "dayofweek", "dayofyear", "hourofday",
+ "minuteofhour", "monthofyear", "secondofminute", "year"))
{
String request = "all(output(avg(time." + timePart + "(foo))))";
assertTimeZone(request, "GMT-2", -7200L);
@@ -686,7 +684,7 @@ public class RequestBuilderTestCase {
test.expectedOutput = Boolean.toString(true);
test.request = "all(output(avg(now() - foo)))";
test.outputWriter = new OutputWriter() {
- long before = System.currentTimeMillis();
+ final long before = System.currentTimeMillis();
@Override
public String write(List<Grouping> groupingList, GroupingTransform transform) {
@@ -836,7 +834,7 @@ public class RequestBuilderTestCase {
builder.build();
fail();
} catch (IllegalInputException e) {
- Assertions.assertThat(e.getMessage()).contains(errorSubstring);
+ assertTrue(e.getMessage().contains(errorSubstring));
}
}
@@ -924,7 +922,7 @@ public class RequestBuilderTestCase {
RequestBuilder builder = new RequestBuilder(0);
builder.setRootOperation(GroupingOperation.fromString(test.request));
builder.setTimeZone(TimeZone.getTimeZone(test.timeZone));
- builder.addContinuations(Arrays.asList(test.continuation));
+ builder.addContinuations(List.of(test.continuation));
try {
builder.build();
if (test.expectedException != null) {
diff --git a/container-search/src/test/java/com/yahoo/search/handler/JSONSearchHandlerTestCase.java b/container-search/src/test/java/com/yahoo/search/handler/JSONSearchHandlerTestCase.java
index 7536a8c4914..7b8015044c6 100644
--- a/container-search/src/test/java/com/yahoo/search/handler/JSONSearchHandlerTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/handler/JSONSearchHandlerTestCase.java
@@ -16,7 +16,6 @@ import com.yahoo.search.searchchain.config.test.SearchChainConfigurerTestCase;
import com.yahoo.slime.Inspector;
import com.yahoo.slime.SlimeUtils;
import com.yahoo.test.json.JsonTestHelper;
-import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
@@ -149,7 +148,7 @@ public class JSONSearchHandlerTestCase {
configurer.reloadConfig();
SearchHandler newSearchHandler = fetchSearchHandler(configurer);
- assertTrue(searchHandler != newSearchHandler, "Do I have a new instance of the search handler?");
+ assertNotSame(searchHandler, newSearchHandler, "Do I have a new instance of the search handler?");
try (RequestHandlerTestDriver newDriver = new RequestHandlerTestDriver(newSearchHandler)) {
ObjectNode json = jsonMapper.createObjectNode();
json.put("yql", "selectz * from foo where bar > 1453501295");
@@ -193,13 +192,15 @@ public class JSONSearchHandlerTestCase {
ObjectNode json = jsonMapper.createObjectNode();
json.put("format", "xml");
- assertEquals("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" +
- "<result total-hit-count=\"0\">\n" +
- " <hit relevancy=\"1.0\">\n" +
- " <field name=\"relevancy\">1.0</field>\n" +
- " <field name=\"uri\">testHit</field>\n" +
- " </hit>\n" +
- "</result>\n", driver.sendRequest(uri, com.yahoo.jdisc.http.HttpRequest.Method.POST, json.toString(), JSON_CONTENT_TYPE).readAll());
+ assertEquals("""
+ <?xml version="1.0" encoding="utf-8" ?>
+ <result total-hit-count="0">
+ <hit relevancy="1.0">
+ <field name="relevancy">1.0</field>
+ <field name="uri">testHit</field>
+ </hit>
+ </result>
+ """, driver.sendRequest(uri, com.yahoo.jdisc.http.HttpRequest.Method.POST, json.toString(), JSON_CONTENT_TYPE).readAll());
}
@Test
@@ -253,13 +254,15 @@ public class JSONSearchHandlerTestCase {
}
private static final String xmlResult =
- "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" +
- "<result total-hit-count=\"0\">\n" +
- " <hit relevancy=\"1.0\">\n" +
- " <field name=\"relevancy\">1.0</field>\n" +
- " <field name=\"uri\">testHit</field>\n" +
- " </hit>\n" +
- "</result>\n";
+ """
+ <?xml version="1.0" encoding="utf-8" ?>
+ <result total-hit-count="0">
+ <hit relevancy="1.0">
+ <field name="relevancy">1.0</field>
+ <field name="uri">testHit</field>
+ </hit>
+ </result>
+ """;
private void assertXmlResult(JsonNode json, RequestHandlerTestDriver driver) {
assertOkResult(driver.sendRequest(uri, com.yahoo.jdisc.http.HttpRequest.Method.POST, json.toString(), JSON_CONTENT_TYPE), xmlResult);
@@ -276,19 +279,6 @@ public class JSONSearchHandlerTestCase {
}
- private static final String pageResult =
- "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" +
- "<page version=\"1.0\">\n" +
- "\n" +
- " <content>\n" +
- " <hit relevance=\"1.0\">\n" +
- " <id>testHit</id>\n" +
- " <uri>testHit</uri>\n" +
- " </hit>\n" +
- " </content>\n" +
- "\n" +
- "</page>\n";
-
private void assertOkResult(RequestHandlerTestDriver.MockResponseHandler response, String expected) {
assertEquals(expected, response.readAll());
assertEquals(200, response.getStatus());
@@ -302,7 +292,7 @@ public class JSONSearchHandlerTestCase {
configurer.reloadConfig();
SearchHandler newSearchHandler = fetchSearchHandler(configurer);
- assertTrue(searchHandler != newSearchHandler, "Do I have a new instance of the search handler?");
+ assertNotSame(searchHandler, newSearchHandler, "Do I have a new instance of the search handler?");
return new RequestHandlerTestDriver(newSearchHandler);
}
@@ -368,23 +358,25 @@ public class JSONSearchHandlerTestCase {
@Test
void testJsonWithWhereAndGroupingUnderSelect() {
- String query = "{\n" +
- " \"select\": {\n" +
- " \"where\": {\n" +
- " \"contains\": [\n" +
- " \"field\",\n" +
- " \"term\"\n" +
- " ]\n" +
- " },\n" +
- " \"grouping\":[\n" +
- " {\n" +
- " \"all\": {\n" +
- " \"output\": \"count()\"\n" +
- " }\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- "}\n";
+ String query = """
+ {
+ "select": {
+ "where": {
+ "contains": [
+ "field",
+ "term"
+ ]
+ },
+ "grouping":[
+ {
+ "all": {
+ "output": "count()"
+ }
+ }
+ ]
+ }
+ }
+ """;
String result = driver.sendRequest(uri + "searchChain=echoingQuery", com.yahoo.jdisc.http.HttpRequest.Method.POST, query, JSON_CONTENT_TYPE).readAll();
String expected = "{\"root\":{\"id\":\"toplevel\",\"relevance\":1.0,\"fields\":{\"totalCount\":0},\"children\":[{\"id\":\"Query\",\"relevance\":1.0,\"fields\":{\"query\":\"select * from sources * where field contains \\\"term\\\" | all(output(count()))\"}}]}}";
@@ -393,21 +385,23 @@ public class JSONSearchHandlerTestCase {
@Test
void testJsonWithWhereAndGroupingSeparate() {
- String query = "{\n" +
- " \"select.where\": {\n" +
- " \"contains\": [\n" +
- " \"field\",\n" +
- " \"term\"\n" +
- " ]\n" +
- " },\n" +
- " \"select.grouping\":[\n" +
- " {\n" +
- " \"all\": {\n" +
- " \"output\": \"count()\"\n" +
- " }\n" +
- " }\n" +
- " ]\n" +
- "}\n";
+ String query = """
+ {
+ "select.where": {
+ "contains": [
+ "field",
+ "term"
+ ]
+ },
+ "select.grouping":[
+ {
+ "all": {
+ "output": "count()"
+ }
+ }
+ ]
+ }
+ """;
String result = driver.sendRequest(uri + "searchChain=echoingQuery", com.yahoo.jdisc.http.HttpRequest.Method.POST, query, JSON_CONTENT_TYPE).readAll();
String expected = "{\"root\":{\"id\":\"toplevel\",\"relevance\":1.0,\"fields\":{\"totalCount\":0},\"children\":[{\"id\":\"Query\",\"relevance\":1.0,\"fields\":{\"query\":\"select * from sources * where field contains \\\"term\\\" | all(output(count()))\"}}]}}";
@@ -539,7 +533,7 @@ public class JSONSearchHandlerTestCase {
// Get mapping
Map<String, String> propertyMap = request.propertyMap();
- Assertions.assertThat(propertyMap).isEqualTo(map);
+ assertEquals(propertyMap, map);
}
@Test