From f30394adb66b891140fd6cd5719d0f3f789c775b Mon Sep 17 00:00:00 2001 From: Viktor Sidochenko Date: Thu, 13 Jul 2023 16:44:18 +0600 Subject: [PATCH] Fix #42 --- .../tag/datajack/providers/AbstractDataProvider.java | 3 +++ .../tag/datajack/providers/json/JsonDataTest.java | 8 ++++++++ .../json-provider/src/test/resources/json/issue.json | 11 +++++++++++ 3 files changed, 22 insertions(+) create mode 100644 providers/json-provider/src/test/resources/json/issue.json diff --git a/datajack-api/src/main/java/ru/sbtqa/tag/datajack/providers/AbstractDataProvider.java b/datajack-api/src/main/java/ru/sbtqa/tag/datajack/providers/AbstractDataProvider.java index 9d0d954..4f35350 100644 --- a/datajack-api/src/main/java/ru/sbtqa/tag/datajack/providers/AbstractDataProvider.java +++ b/datajack-api/src/main/java/ru/sbtqa/tag/datajack/providers/AbstractDataProvider.java @@ -471,6 +471,9 @@ private DBObject resolveDbObject() throws DataException { if (instance.basicObject.keySet().contains(key) && instance .basicObject.get(key) == null) { resolvedDbObject.put(key, null); + }else if(basicObject.get(key) instanceof BasicDBList){ + BasicDBList array = (BasicDBList) basicObject.get(key); + resolvedDbObject.put(key, array); } else { resolvedDbObject.put(key, instance.getValue()); } diff --git a/providers/json-provider/src/test/java/ru/sbtqa/tag/datajack/providers/json/JsonDataTest.java b/providers/json-provider/src/test/java/ru/sbtqa/tag/datajack/providers/json/JsonDataTest.java index e20e3c6..f303fb0 100644 --- a/providers/json-provider/src/test/java/ru/sbtqa/tag/datajack/providers/json/JsonDataTest.java +++ b/providers/json-provider/src/test/java/ru/sbtqa/tag/datajack/providers/json/JsonDataTest.java @@ -40,6 +40,14 @@ public void differentExtensionTest() throws DataException { testDataProvider.get("Common.password2").getValue()); } + @Test + public void issue42() throws DataException { + String collectionName = "issue"; + TestDataProvider testDataProvider = new JsonDataProvider(JSON_DATA_PATH, collectionName, "json"); + assertEquals("{ \"systemId\" : \"QJ160\" , \"customerIds\" : [ { \"id\" : \"93V\" , \"branch\" : \"Cu19\"}]}", + testDataProvider.get("X-User").getValue()); + } + @Test public void simpleArrayTest() throws DataException { String collectionName = "Tests"; diff --git a/providers/json-provider/src/test/resources/json/issue.json b/providers/json-provider/src/test/resources/json/issue.json new file mode 100644 index 0000000..1527bd1 --- /dev/null +++ b/providers/json-provider/src/test/resources/json/issue.json @@ -0,0 +1,11 @@ +{ + "X-User": { + "systemId": "QJ160", + "customerIds": [ + { + "id": "93V", + "branch": "Cu19" + } + ] + } +} \ No newline at end of file