From 4c7a3be4a6418097bd7ef4d8363eae133c763e21 Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Fri, 24 Mar 2023 12:50:01 -0700 Subject: [PATCH] Fixed tests --- .../connect/sink/StructToJsonMapTest.java | 2 +- .../id/strategy/ProvidedInStrategyTest.java | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/test/java/com/azure/cosmos/kafka/connect/sink/StructToJsonMapTest.java b/src/test/java/com/azure/cosmos/kafka/connect/sink/StructToJsonMapTest.java index e905a66b..b0e6350a 100644 --- a/src/test/java/com/azure/cosmos/kafka/connect/sink/StructToJsonMapTest.java +++ b/src/test/java/com/azure/cosmos/kafka/connect/sink/StructToJsonMapTest.java @@ -36,7 +36,7 @@ public void structWithEmptyArrayToMap() { .field("array_of_boolean", SchemaBuilder.array(Schema.BOOLEAN_SCHEMA).build()); Struct struct = new Struct(schema) - .put("array_of_boolean", Map.of()); + .put("array_of_boolean", List.of()); Map converted = StructToJsonMap.toJsonMap(struct); assertEquals(List.of(), converted.get("array_of_boolean")); diff --git a/src/test/java/com/azure/cosmos/kafka/connect/sink/id/strategy/ProvidedInStrategyTest.java b/src/test/java/com/azure/cosmos/kafka/connect/sink/id/strategy/ProvidedInStrategyTest.java index 44dd59c1..876acb44 100644 --- a/src/test/java/com/azure/cosmos/kafka/connect/sink/id/strategy/ProvidedInStrategyTest.java +++ b/src/test/java/com/azure/cosmos/kafka/connect/sink/id/strategy/ProvidedInStrategyTest.java @@ -14,6 +14,7 @@ import org.junit.runners.Parameterized; import org.mockito.Mock; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -158,15 +159,15 @@ public void jsonPathNotExistThrows() { @Test public void complexJsonPath() { - returnOnKeyOrValue(null, - Map.of("id", List.of( - Map.of("id", 0, - "name", "cosmos kramer", - "occupation", "unknown"), - Map.of("id", 1, - "name", "franz kafka", - "occupation", "writer") - ))); + Map map1 = new LinkedHashMap<>(); + map1.put("id", 0); + map1.put("name", "cosmos kramer"); + map1.put("occupation", "unknown"); + Map map2 = new LinkedHashMap<>(); + map2.put("id", 1); + map2.put("name", "franz kafka"); + map2.put("occupation", "writer"); + returnOnKeyOrValue(null, Map.of("id", List.of(map1, map2))); strategy.configure(Map.of(ProvidedInConfig.JSON_PATH_CONFIG, "$.id[0].name")); assertEquals("cosmos kramer", strategy.generateId(record));