From 1272c4e78b5f89edf98a3f418a6ed1bfb831f273 Mon Sep 17 00:00:00 2001 From: Andrew Omondi Date: Mon, 6 May 2024 11:50:45 +0300 Subject: [PATCH] Assert we can handle multi dimensional arrays --- .../kiota/serialization/JsonParseNodeTests.java | 11 +++++++++++ .../serialization/mocks/UntypedTestEntity.java | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/components/serialization/json/src/test/java/com/microsoft/kiota/serialization/JsonParseNodeTests.java b/components/serialization/json/src/test/java/com/microsoft/kiota/serialization/JsonParseNodeTests.java index 3fe648711..96fed600f 100644 --- a/components/serialization/json/src/test/java/com/microsoft/kiota/serialization/JsonParseNodeTests.java +++ b/components/serialization/json/src/test/java/com/microsoft/kiota/serialization/JsonParseNodeTests.java @@ -60,6 +60,7 @@ class JsonParseNodeTests { + " }\r\n" + " ],\r\n" + " \"detail\": null,\r\n" + + " \"table\": [[1,2,3],[4,5,6],[7,8,9]],\r\n" + " \"extra\": {\r\n" + " \"createdDateTime\":\"2024-01-15T00:00:00\\u002B00:00\"\r\n" + " }\r\n" @@ -160,5 +161,15 @@ void GetEntityWithUntypedNodesFromJson() throws UnsupportedEncodingException { assertNull(entity.getDetail()); var extra = entity.getAdditionalData().get("extra"); assertNotNull(extra); + assertNotNull(entity.getTable()); + var table = (UntypedArray) entity.getTable(); // the table is a collection + for (var value : table.getValue()) { + var row = (UntypedArray) value; + assertNotNull(row); // The values are a nested collection + for (var item : row.getValue()) { + var rowItem = (UntypedDouble) item; + assertNotNull(rowItem); // The values are UntypedInteger + } + } } } diff --git a/components/serialization/json/src/test/java/com/microsoft/kiota/serialization/mocks/UntypedTestEntity.java b/components/serialization/json/src/test/java/com/microsoft/kiota/serialization/mocks/UntypedTestEntity.java index b5051edda..1e11f432e 100644 --- a/components/serialization/json/src/test/java/com/microsoft/kiota/serialization/mocks/UntypedTestEntity.java +++ b/components/serialization/json/src/test/java/com/microsoft/kiota/serialization/mocks/UntypedTestEntity.java @@ -50,6 +50,16 @@ public void setDetail(UntypedNode _detail) { this._detail = _detail; } + private UntypedNode _table; + + public UntypedNode getTable() { + return _table; + } + + public void setTable(UntypedNode _table) { + this._table = _table; + } + @Override public Map> getFieldDeserializers() { return new HashMap<>() { @@ -76,6 +86,11 @@ public Map> getFieldDeserializers() { (n) -> { setDetail(n.getObjectValue(UntypedNode::createFromDiscriminatorValue)); }); + put( + "table", + (n) -> { + setTable(n.getObjectValue(UntypedNode::createFromDiscriminatorValue)); + }); } }; } @@ -87,6 +102,7 @@ public void serialize(SerializationWriter writer) { writer.writeObjectValue("location", getLocation()); writer.writeObjectValue("keywords", getKeywords()); writer.writeObjectValue("detail", getDetail()); + writer.writeObjectValue("table", getDetail()); writer.writeAdditionalData(getAdditionalData()); }