[OLINGO-1114] Minor test fix

This commit is contained in:
Michael Bolz 2019-11-26 07:57:47 +01:00
parent 820b462f49
commit 35e2302576
1 changed files with 45 additions and 51 deletions

View File

@ -15,7 +15,11 @@
*/ */
package org.apache.olingo.client.core.serialization; package org.apache.olingo.client.core.serialization;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import java.io.StringWriter; import java.io.StringWriter;
import org.apache.olingo.client.api.ODataClient; import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.domain.ClientEntity; import org.apache.olingo.client.api.domain.ClientEntity;
import org.apache.olingo.client.api.domain.ClientObjectFactory; import org.apache.olingo.client.api.domain.ClientObjectFactory;
@ -23,8 +27,6 @@ import org.apache.olingo.client.api.serialization.ODataSerializerException;
import org.apache.olingo.client.core.ODataClientFactory; import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.commons.api.format.ContentType;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Test; import org.junit.Test;
public class JsonSerializerTest { public class JsonSerializerTest {
@ -48,29 +50,21 @@ public class JsonSerializerTest {
clientEntity.getProperties().add( clientEntity.getProperties().add(
objFactory.newPrimitiveProperty( objFactory.newPrimitiveProperty(
"testInt32", "testInt32",
objFactory.newPrimitiveValueBuilder().buildInt32(12) objFactory.newPrimitiveValueBuilder().buildInt32(12)));
)
);
clientEntity.getProperties().add( clientEntity.getProperties().add(
objFactory.newPrimitiveProperty( objFactory.newPrimitiveProperty(
"testInt32Null", "testInt32Null",
objFactory.newPrimitiveValueBuilder().buildInt32(null) objFactory.newPrimitiveValueBuilder().buildInt32(null)));
)
);
clientEntity.getProperties().add( clientEntity.getProperties().add(
objFactory.newPrimitiveProperty( objFactory.newPrimitiveProperty(
"testString", "testString",
objFactory.newPrimitiveValueBuilder().buildString("testString") objFactory.newPrimitiveValueBuilder().buildString("testString")));
)
);
clientEntity.getProperties().add( clientEntity.getProperties().add(
objFactory.newPrimitiveProperty( objFactory.newPrimitiveProperty(
"testStringNull", "testStringNull",
objFactory.newPrimitiveValueBuilder().buildString(null) objFactory.newPrimitiveValueBuilder().buildString(null)));
)
);
JsonSerializer jsonSerializer = new JsonSerializer(false, ContentType.JSON); JsonSerializer jsonSerializer = new JsonSerializer(false, ContentType.JSON_FULL_METADATA);
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter();
jsonSerializer.write(writer, odataClient.getBinder().getEntity(clientEntity)); jsonSerializer.write(writer, odataClient.getBinder().getEntity(clientEntity));