Skip to content

Commit

Permalink
ran ./gradlew :java-client:spotlessApply
Browse files Browse the repository at this point in the history
Signed-off-by: brentam <[email protected]>
  • Loading branch information
brentam committed Dec 23, 2023
1 parent 98332a1 commit 633741b
Showing 1 changed file with 17 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
package org.opensearch.client.opensearch.core.search;

import jakarta.json.spi.JsonProvider;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import jakarta.json.stream.JsonGenerator;
import jakarta.json.stream.JsonParser;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.List;
import org.junit.Test;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.JsonpSerializable;
import org.opensearch.client.json.jsonb.JsonbJsonpMapper;
import org.opensearch.client.opensearch.core.SearchRequest;

import java.io.StringReader;
import java.io.StringWriter;
import java.util.List;

import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class InnerHitsTest {
private JsonpMapper mapper = new JsonbJsonpMapper();
private String storedSalary = "details.salary";
private String storedJobId = "details.jobId";
private final JsonpMapper mapper = new JsonbJsonpMapper();
private final String storedSalary = "details.salary";
private final String storedJobId = "details.jobId";

/**
* test if the json field for storedFields is generated with the correct name "stored_fields"
Expand All @@ -44,7 +42,6 @@ public void testInnerHitFromParsed() {
String actualJson = toJson(innerHits);
assertEquals(innerHitsJson, actualJson);


}

/**
Expand All @@ -68,13 +65,11 @@ private String toJson(JsonpSerializable obj) {
}
return stringWriter.toString();
}
private String innerHitsJson = String.format(
"{\"_source\":false,\"stored_fields\":[\"%s\",\"%s\"]}",
storedJobId,
storedSalary

private final String innerHitsJson = String.format("{\"_source\":false,\"stored_fields\":[\"%s\",\"%s\"]}", storedJobId, storedSalary);
private final String searchRequestJson = String.format(
"{\"_source\":false,\"query\":{\"bool\":{\"must\":[{\"match_all\":{}},{\"nested\":{\"inner_hits\":%s,\"path\":\"details\","
+ "\"query\":{\"match_all\":{}}}}]}},\"stored_fields\":[\"title\",\"companyName\"]}",
innerHitsJson
);
private String searchRequestJson = String.format(
"{\"_source\":false,\"query\":{\"bool\":{\"must\":[{\"match_all\":{}},{\"nested\":{\"inner_hits\":%s,\"path\":\"details\","
+ "\"query\":{\"match_all\":{}}}}]}},\"stored_fields\":[\"title\",\"companyName\"]}",
innerHitsJson);
}

0 comments on commit 633741b

Please sign in to comment.