You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2019/11/27 07:51:00 UTC

[olingo-odata4] branch master updated (2df6c17 -> 68cfa45)

This is an automated email from the ASF dual-hosted git repository.

mibo pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/olingo-odata4.git.


    from 2df6c17  [OLINGO-1406] added some toString() methods (#26)
     new 5cf7e1c  [OLINGO-1114] Fix NULL PrimitiveValue change the type when convert (#21)
     new 68cfa45  [OLINGO-1114] Minor test fix

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/olingo/client/core/JSONTest.java    | 70 ++++++++++++++++++++++
 .../org/apache/olingo/client/core/olingo1114.json  | 17 ++++++
 2 files changed, 87 insertions(+)
 create mode 100644 lib/client-core/src/test/resources/org/apache/olingo/client/core/olingo1114.json


[olingo-odata4] 02/02: [OLINGO-1114] Minor test fix

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mibo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/olingo-odata4.git

commit 68cfa4546df212edf5ff412b786f132c519fb21e
Author: Michael Bolz <mi...@sap.com>
AuthorDate: Wed Nov 27 08:41:47 2019 +0100

    [OLINGO-1114] Minor test fix
---
 .../src/test/java/org/apache/olingo/client/core/JSONTest.java         | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java
index d6af25a..a1e1ed3 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java
@@ -47,8 +47,8 @@ import org.apache.olingo.client.api.domain.ClientProperty;
 import org.apache.olingo.client.api.domain.ClientValue;
 import org.apache.olingo.client.core.domain.ClientAnnotationImpl;
 import org.apache.olingo.client.core.serialization.JsonDeserializer;
-import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.client.core.serialization.JsonSerializer;
+import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Delta;
@@ -966,7 +966,7 @@ public class JSONTest extends AbstractTest {
     ClientProperty testInt16 = client.getObjectFactory().newPrimitiveProperty("testInt16", valueBuilder.build());
     properties.add(testInt16);
 
-    InputStream inputStream = client.getWriter().writeEntity(entityIncNullValue, ContentType.JSON);
+    InputStream inputStream = client.getWriter().writeEntity(entityIncNullValue, ContentType.JSON_FULL_METADATA);
     HttpEntity httpEntity = URIUtils.buildInputStreamEntity(client, inputStream);
 
     final String actual = EntityUtils.toString(httpEntity);


[olingo-odata4] 01/02: [OLINGO-1114] Fix NULL PrimitiveValue change the type when convert (#21)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mibo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/olingo-odata4.git

commit 5cf7e1c0c67b01d03e53f8e46f77b8a4c26ada8d
Author: jzhao <jz...@talend.com>
AuthorDate: Wed Nov 27 15:38:27 2019 +0800

    [OLINGO-1114] Fix NULL PrimitiveValue change the type when convert (#21)
    
    ClientEntity to a HttpEntity
---
 .../org/apache/olingo/client/core/JSONTest.java    | 70 ++++++++++++++++++++++
 .../org/apache/olingo/client/core/olingo1114.json  | 17 ++++++
 2 files changed, 87 insertions(+)

diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java
index 29a5222..d6af25a 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java
@@ -32,6 +32,8 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.util.EntityUtils;
 import org.apache.olingo.client.api.data.ResWrap;
 import org.apache.olingo.client.api.domain.ClientAnnotation;
 import org.apache.olingo.client.api.domain.ClientCollectionValue;
@@ -45,6 +47,7 @@ import org.apache.olingo.client.api.domain.ClientProperty;
 import org.apache.olingo.client.api.domain.ClientValue;
 import org.apache.olingo.client.core.domain.ClientAnnotationImpl;
 import org.apache.olingo.client.core.serialization.JsonDeserializer;
+import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.client.core.serialization.JsonSerializer;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.ComplexValue;
@@ -907,6 +910,73 @@ public class JSONTest extends AbstractTest {
       i++;
     }
   }
+
+  @Test
+  public void testOLINGO1114() throws Exception {
+    ClientEntity entityIncNullValue = client.getObjectFactory()
+            .newEntity(new FullQualifiedName("Microsoft.Dynamics.CRM", "account"));
+    List<ClientProperty> properties = entityIncNullValue.getProperties();
+
+    // Property "name"
+    ClientPrimitiveValue.Builder valueBuilder = client.getObjectFactory().newPrimitiveValueBuilder();
+    valueBuilder.setType(EdmPrimitiveTypeKind.String);
+    valueBuilder.setValue("testString");
+    ClientProperty name = client.getObjectFactory().newPrimitiveProperty("name", valueBuilder.build());
+    properties.add(name);
+
+    // Property "testDecimal"
+    valueBuilder = client.getObjectFactory().newPrimitiveValueBuilder();
+    valueBuilder.setType(EdmPrimitiveTypeKind.Decimal);
+    valueBuilder.setValue(null);
+    ClientProperty revenue = client.getObjectFactory().newPrimitiveProperty("testDecimal", valueBuilder.build());
+    properties.add(revenue);
+
+    // Property "testByte"
+    valueBuilder = client.getObjectFactory().newPrimitiveValueBuilder();
+    valueBuilder.setType(EdmPrimitiveTypeKind.Byte);
+    valueBuilder.setValue(null);
+    ClientProperty testByte = client.getObjectFactory().newPrimitiveProperty("testByte", valueBuilder.build());
+    properties.add(testByte);
+
+    // Property "testDouble"
+    valueBuilder = client.getObjectFactory().newPrimitiveValueBuilder();
+    valueBuilder.setType(EdmPrimitiveTypeKind.Double);
+    valueBuilder.setValue(null);
+    ClientProperty testDouble = client.getObjectFactory().newPrimitiveProperty("testDouble", valueBuilder.build());
+    properties.add(testDouble);
+
+    // Property "testInt64"
+    valueBuilder = client.getObjectFactory().newPrimitiveValueBuilder();
+    valueBuilder.setType(EdmPrimitiveTypeKind.Int64);
+    valueBuilder.setValue(null);
+    ClientProperty testInt64 = client.getObjectFactory().newPrimitiveProperty("testInt64", valueBuilder.build());
+    properties.add(testInt64);
+
+    // Property "testInt32"
+    valueBuilder = client.getObjectFactory().newPrimitiveValueBuilder();
+    valueBuilder.setType(EdmPrimitiveTypeKind.Int32);
+    valueBuilder.setValue(null);
+    ClientProperty testInt32 = client.getObjectFactory().newPrimitiveProperty("testInt32", valueBuilder.build());
+    properties.add(testInt32);
+
+    // Property "testInt16"
+    valueBuilder = client.getObjectFactory().newPrimitiveValueBuilder();
+    valueBuilder.setType(EdmPrimitiveTypeKind.Int16);
+    valueBuilder.setValue(null);
+    ClientProperty testInt16 = client.getObjectFactory().newPrimitiveProperty("testInt16", valueBuilder.build());
+    properties.add(testInt16);
+
+    InputStream inputStream = client.getWriter().writeEntity(entityIncNullValue, ContentType.JSON);
+    HttpEntity httpEntity = URIUtils.buildInputStreamEntity(client, inputStream);
+
+    final String actual = EntityUtils.toString(httpEntity);
+    final JsonNode expected =
+            OBJECT_MAPPER.readTree(IOUtils.toString(getClass().getResourceAsStream("olingo1114.json")).
+                    replace(Constants.JSON_NAVIGATION_LINK, Constants.JSON_BIND_LINK_SUFFIX));
+    final ObjectNode actualNode = (ObjectNode) OBJECT_MAPPER.readTree(new ByteArrayInputStream(actual.getBytes()));
+    assertEquals(expected, actualNode);
+  }
+
   
   @Test
   public void issueOLINGO1152() throws Exception {
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/olingo1114.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/olingo1114.json
new file mode 100644
index 0000000..fbf5e0d
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/olingo1114.json
@@ -0,0 +1,17 @@
+{
+  "@odata.type":"#Microsoft.Dynamics.CRM.account",
+  "name@odata.type":"String",
+  "name":"testString",
+  "testDecimal@odata.type":"Decimal",
+  "testDecimal":null,
+  "testByte@odata.type":"Byte",
+  "testByte":null,
+  "testDouble@odata.type":"Double",
+  "testDouble":null,
+  "testInt64@odata.type":"Int64",
+  "testInt64":null,
+  "testInt32@odata.type":"Int32",
+  "testInt32":null,
+  "testInt16@odata.type":"Int16",
+  "testInt16":null
+}
\ No newline at end of file