Search in sources :

Example 1 with GetSourceResponse

use of org.opensearch.client.opensearch.core.GetSourceResponse in project opensearch-java by opensearch-project.

the class SerializationTest method testGenericValueBody.

@Test
public void testGenericValueBody() {
    GetSourceResponse<String> r = GetSourceResponse.of(_0 -> _0.valueBody("The value"));
    String json = toJson(r);
    assertEquals("\"The value\"", json);
    JsonpDeserializer<GetSourceResponse<String>> deserializer = GetSourceResponse.createGetSourceResponseDeserializer(JsonpDeserializer.stringDeserializer());
    r = deserializer.deserialize(mapper.jsonProvider().createParser(new StringReader(json)), mapper);
    assertEquals("The value", r.valueBody());
}
Also used : StringReader(java.io.StringReader) GetSourceResponse(org.opensearch.client.opensearch.core.GetSourceResponse) Test(org.junit.Test)

Aggregations

StringReader (java.io.StringReader)1 Test (org.junit.Test)1 GetSourceResponse (org.opensearch.client.opensearch.core.GetSourceResponse)1