-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix PutIndexTemplateRequest deserialization Signed-off-by: Matthew Bogner <matt@ibogner.net> * CHANGELOG.md Signed-off-by: Matthew Bogner <matt@ibogner.net> * spotless Signed-off-by: Matthew Bogner <matt@ibogner.net> --------- Signed-off-by: Matthew Bogner <matt@ibogner.net> (cherry picked from commit d4aade4)
- Loading branch information
1 parent
73be144
commit cd38878
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...ient/src/test/java/org/opensearch/client/opensearch/core/PutIndexTemplateRequestTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.opensearch.client.opensearch.core; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import java.io.StringReader; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.opensearch.client.json.JsonpMapper; | ||
import org.opensearch.client.json.jsonb.JsonbJsonpMapper; | ||
import org.opensearch.client.opensearch.indices.PutIndexTemplateRequest; | ||
|
||
public class PutIndexTemplateRequestTest extends Assert { | ||
|
||
@Test | ||
public void deserialize_validFieldsIncluded_RequestIsBuilt() throws JsonProcessingException { | ||
final JsonpMapper mapper = new JsonbJsonpMapper(); | ||
final Map<String, Object> indexTemplateMap = Map.of("name", "test", "index_patterns", "*", "create", true, "priority", 1); | ||
|
||
final String indexTemplate = new ObjectMapper().writeValueAsString(indexTemplateMap); | ||
final var parser = mapper.jsonProvider().createParser(new StringReader(indexTemplate)); | ||
|
||
final PutIndexTemplateRequest putIndexTemplateRequest = PutIndexTemplateRequest._DESERIALIZER.deserialize(parser, mapper); | ||
|
||
assertEquals(putIndexTemplateRequest.name(), "test"); | ||
assertEquals(putIndexTemplateRequest.indexPatterns(), List.of("*")); | ||
assertEquals((int) putIndexTemplateRequest.priority(), 1); | ||
} | ||
|
||
} |