diff --git a/README.md b/README.md index c73cb24..52fd44b 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ The most simple way to use this SDK is to pull from the Predix Snapshot artifact com.ge.predix.eventhub predix-event-hub-sdk - 2.2.4 + 2.2.5 ... diff --git a/pom.xml b/pom.xml index 6ccf031..18873a7 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.ge.predix.eventhub predix-event-hub-sdk - 2.2.4 + 2.2.5 1.8 1.8 diff --git a/src/main/java/com/ge/predix/eventhub/EventHubUtils.java b/src/main/java/com/ge/predix/eventhub/EventHubUtils.java index 3f46ffb..060348f 100644 --- a/src/main/java/com/ge/predix/eventhub/EventHubUtils.java +++ b/src/main/java/com/ge/predix/eventhub/EventHubUtils.java @@ -191,7 +191,7 @@ private static void putIntoJson(JSONObject jsonObj, String key, Object value){ for(Object o : (List) value){ array.put(o); } - jsonObj.put(key, new JSONArray(value)); + jsonObj.put(key, new JSONArray(((List) value))); return; } jsonObj.put(key, value); diff --git a/src/main/java/com/ge/predix/eventhub/client/Client.java b/src/main/java/com/ge/predix/eventhub/client/Client.java index d724394..4d3340a 100644 --- a/src/main/java/com/ge/predix/eventhub/client/Client.java +++ b/src/main/java/com/ge/predix/eventhub/client/Client.java @@ -38,7 +38,7 @@ public class Client implements AutoCloseable { private static final String healthCheckUrl = "predix-event-hub.grpc.health"; private static final Long ttlHealth = 30000L; - private static final String sdkVersionString = "2.2.4"; + private static final String sdkVersionString = "2.2.5"; private Channel channel; diff --git a/src/test/java/com/ge/predix/eventhub/client/EventHubUtilsTest.java b/src/test/java/com/ge/predix/eventhub/client/EventHubUtilsTest.java index dc75c82..a49fc93 100644 --- a/src/test/java/com/ge/predix/eventhub/client/EventHubUtilsTest.java +++ b/src/test/java/com/ge/predix/eventhub/client/EventHubUtilsTest.java @@ -23,9 +23,13 @@ import com.fasterxml.jackson.databind.JsonNode; import com.ge.predix.eventhub.*; import com.ge.predix.eventhub.configuration.LoggerConfiguration; +import com.ge.predix.eventhub.test.categories.DefectTest; import com.ge.predix.eventhub.test.categories.SanityTest; import com.ge.predix.eventhub.test.categories.SmokeTest; import com.google.protobuf.ByteString; +import org.json.JSONArray; +import org.json.JSONObject; +import org.junit.Assert; import org.junit.FixMethodOrder; import org.junit.Rule; import org.junit.Test; @@ -313,4 +317,35 @@ public void testLogLevels(){ } } + /** + * test serializing messages for logging with nested object, e.g. + * { + * "publisher_msg":{ + * "msg":"ignoring values from config, don't apply to this publisher type", + * "ignores":[ + * "timeout", + * 10000 + * ] + * } + * } + */ + @Test + @Category(DefectTest.class) + public void test() { + final List ignores = new ArrayList<>(); + final String timeoutKey = "timeout"; + final long timeoutValue = 10000L; + ignores.add(timeoutKey); + ignores.add(timeoutValue); + JSONObject jsonObject = EventHubUtils.formatJson( + "publisher_msg", + "msg", + "ignoring values from config, don't apply to this publisher type", + "ignores", + ignores + ); + final JSONArray ignoresJsonValue = jsonObject.getJSONObject("publisher_msg").getJSONArray("ignores"); + Assert.assertEquals(ignores, ignoresJsonValue.toList()); + } + }