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/26 06:57:54 UTC
[olingo-odata4] branch master updated: [OLINGO-1114] Minor test fix
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
The following commit(s) were added to refs/heads/master by this push:
new 35e2302 [OLINGO-1114] Minor test fix
35e2302 is described below
commit 35e2302576748c36f3b6719dcc311019672a30a6
Author: Michael Bolz <mi...@sap.com>
AuthorDate: Tue Nov 26 07:57:47 2019 +0100
[OLINGO-1114] Minor test fix
---
.../core/serialization/JsonSerializerTest.java | 96 ++++++++++------------
1 file changed, 45 insertions(+), 51 deletions(-)
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/serialization/JsonSerializerTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/serialization/JsonSerializerTest.java
index 7894aba..99f026d 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/serialization/JsonSerializerTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/serialization/JsonSerializerTest.java
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,7 +15,11 @@
*/
package org.apache.olingo.client.core.serialization;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
import java.io.StringWriter;
+
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.domain.ClientEntity;
import org.apache.olingo.client.api.domain.ClientObjectFactory;
@@ -23,57 +27,47 @@ import org.apache.olingo.client.api.serialization.ODataSerializerException;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ContentType;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
import org.junit.Test;
public class JsonSerializerTest {
-
- @Test
- public void testClientEntityJSONWithNull() throws ODataSerializerException {
- String expectedJson = "{\"@odata.type\":\"#test.testClientEntity\","
- + "\"testInt32@odata.type\":\"Int32\","
- + "\"testInt32\":12,"
- + "\"testInt32Null@odata.type\":\"Int32\""
- + ",\"testInt32Null\":null,"
- + "\"testString@odata.type\":\"String\","
- + "\"testString\":\"testString\","
- + "\"testStringNull@odata.type\":\"String\","
- + "\"testStringNull\":null}";
-
- ODataClient odataClient = ODataClientFactory.getClient();
- ClientObjectFactory objFactory = odataClient.getObjectFactory();
- ClientEntity clientEntity = objFactory.newEntity(new FullQualifiedName("test", "testClientEntity"));
-
- clientEntity.getProperties().add(
- objFactory.newPrimitiveProperty(
- "testInt32",
- objFactory.newPrimitiveValueBuilder().buildInt32(12)
- )
- );
- clientEntity.getProperties().add(
- objFactory.newPrimitiveProperty(
- "testInt32Null",
- objFactory.newPrimitiveValueBuilder().buildInt32(null)
- )
- );
- clientEntity.getProperties().add(
- objFactory.newPrimitiveProperty(
- "testString",
- objFactory.newPrimitiveValueBuilder().buildString("testString")
- )
- );
- clientEntity.getProperties().add(
- objFactory.newPrimitiveProperty(
- "testStringNull",
- objFactory.newPrimitiveValueBuilder().buildString(null)
- )
- );
-
- JsonSerializer jsonSerializer = new JsonSerializer(false, ContentType.JSON);
-
- StringWriter writer = new StringWriter();
- jsonSerializer.write(writer, odataClient.getBinder().getEntity(clientEntity));
- assertThat(writer.toString(), is(expectedJson));
- }
+
+ @Test
+ public void testClientEntityJSONWithNull() throws ODataSerializerException {
+ String expectedJson = "{\"@odata.type\":\"#test.testClientEntity\","
+ + "\"testInt32@odata.type\":\"Int32\","
+ + "\"testInt32\":12,"
+ + "\"testInt32Null@odata.type\":\"Int32\""
+ + ",\"testInt32Null\":null,"
+ + "\"testString@odata.type\":\"String\","
+ + "\"testString\":\"testString\","
+ + "\"testStringNull@odata.type\":\"String\","
+ + "\"testStringNull\":null}";
+
+ ODataClient odataClient = ODataClientFactory.getClient();
+ ClientObjectFactory objFactory = odataClient.getObjectFactory();
+ ClientEntity clientEntity = objFactory.newEntity(new FullQualifiedName("test", "testClientEntity"));
+
+ clientEntity.getProperties().add(
+ objFactory.newPrimitiveProperty(
+ "testInt32",
+ objFactory.newPrimitiveValueBuilder().buildInt32(12)));
+ clientEntity.getProperties().add(
+ objFactory.newPrimitiveProperty(
+ "testInt32Null",
+ objFactory.newPrimitiveValueBuilder().buildInt32(null)));
+ clientEntity.getProperties().add(
+ objFactory.newPrimitiveProperty(
+ "testString",
+ objFactory.newPrimitiveValueBuilder().buildString("testString")));
+ clientEntity.getProperties().add(
+ objFactory.newPrimitiveProperty(
+ "testStringNull",
+ objFactory.newPrimitiveValueBuilder().buildString(null)));
+
+ JsonSerializer jsonSerializer = new JsonSerializer(false, ContentType.JSON_FULL_METADATA);
+
+ StringWriter writer = new StringWriter();
+ jsonSerializer.write(writer, odataClient.getBinder().getEntity(clientEntity));
+ assertThat(writer.toString(), is(expectedJson));
+ }
}