Skip to content

Commit

Permalink
update for pr review
Browse files Browse the repository at this point in the history
Signed-off-by: bfindlay <[email protected]>
  • Loading branch information
Bfindlay committed Nov 13, 2023
1 parent cfa1157 commit 7744f3a
Showing 1 changed file with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,26 @@
import org.opensearch.client.opensearch.indices.PutTemplateRequest;

public class PutTemplateRequestTest extends Assert {
private static String INDEX_NAME_FIELD = "name";
private static String INDEX_PATTERNS_FIELD = "index_patterns";
private static String CREATE_FIELD = "create";
private static String ORDER_FIELD = "order";

@Test
public void deserialize_validFieldsIncluded_RequestIsBuilt() throws JsonProcessingException {
// Arrange
final JsonpMapper mapper = new JsonbJsonpMapper();
final Map<String, Object> indexTemplateMap = Map.of(
INDEX_NAME_FIELD,
"name",
"test",
INDEX_PATTERNS_FIELD,
"index_patterns",
"*",
CREATE_FIELD,
"create",
true,
ORDER_FIELD,
"order",
1

);
final String indexTemplate = new ObjectMapper().writeValueAsString(indexTemplateMap);
final var parser = mapper.jsonProvider().createParser(new StringReader(indexTemplate));

// Act
final PutTemplateRequest putTemplateRequest = PutTemplateRequest._DESERIALIZER.deserialize(parser, mapper);

// Assert
assertEquals(putTemplateRequest.name(), "test");
assertEquals(putTemplateRequest.indexPatterns(), List.of("*"));
assertEquals((long) putTemplateRequest.order(), 1L);
Expand Down

0 comments on commit 7744f3a

Please sign in to comment.