http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1507449/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java index 8d44be3..e182d15 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); 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 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -79,8 +79,8 @@ public class ODataJsonSerializerTest { final Entity entity = data.readAll(edmEntitySet).getEntities().get(0); InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity, EntitySerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) - .build()).getContent(); + .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) + .build()).getContent(); final String resultString = IOUtils.toString(result); final String expectedResult = "{" + "\"@odata.context\":\"$metadata#ESAllPrim/$entity\"," @@ -112,8 +112,8 @@ public class ODataJsonSerializerTest { final String resultString = IOUtils.toString(serializer.entity(metadata, edmEntitySet.getEntityType(), entity, EntitySerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) - .build()).getContent()); + .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) + .build()).getContent()); final String expectedResult = "{\"@odata.context\":\"$metadata#ESAllPrim/$entity\"," + "\"PropertyInt16\":32767," + "\"PropertyString\":null,\"PropertyBoolean\":null," @@ -133,8 +133,8 @@ public class ODataJsonSerializerTest { entity.getProperties().clear(); serializer.entity(metadata, edmEntitySet.getEntityType(), entity, EntitySerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) - .build()); + .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) + .build()); } @Test @@ -145,14 +145,14 @@ public class ODataJsonSerializerTest { try { serializer.entity(metadata, edmEntitySet.getEntityType(), entity, EntitySerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) - .build()); + .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) + .build()); Assert.fail("Expected exception not thrown!"); } catch (final SerializerException e) { Assert.assertEquals(SerializerException.MessageKeys.WRONG_PROPERTY_VALUE, e.getMessageKey()); - final String message = e.getLocalizedMessage(); - Assert.assertThat(message, CoreMatchers.containsString("PropertyInt16")); - Assert.assertThat(message, CoreMatchers.containsString("false")); + final String message = e.getLocalizedMessage(); + Assert.assertThat(message, CoreMatchers.containsString("PropertyInt16")); + Assert.assertThat(message, CoreMatchers.containsString("false")); } } @@ -166,9 +166,9 @@ public class ODataJsonSerializerTest { Mockito.when(countOption.getValue()).thenReturn(true); InputStream result = serializer.entityCollection(metadata, edmEntitySet.getEntityType(), entitySet, EntityCollectionSerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet).build()) - .count(countOption) - .build()).getContent(); + .contextURL(ContextURL.with().entitySet(edmEntitySet).build()) + .count(countOption) + .build()).getContent(); final String resultString = IOUtils.toString(result); Assert.assertThat(resultString, CoreMatchers.startsWith("{" @@ -191,8 +191,8 @@ public class ODataJsonSerializerTest { final Entity entity = data.readAll(edmEntitySet).getEntities().get(0); InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity, EntitySerializerOptions.with() - .contextURL(ContextURL.with().serviceRoot(URI.create("http://host/service/")) - .entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) + .contextURL(ContextURL.with().serviceRoot(URI.create("http://host/service/")) + .entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) .build()).getContent(); final String resultString = IOUtils.toString(result); final String expectedResult = "{" @@ -227,8 +227,8 @@ public class ODataJsonSerializerTest { final Entity entity = data.readAll(edmEntitySet).getEntities().get(0); InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity, EntitySerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) - .build()).getContent(); + .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) + .build()).getContent(); final String resultString = IOUtils.toString(result); final String expectedResult = "{" + "\"@odata.context\":\"$metadata#ESCompAllPrim/$entity\"," @@ -260,8 +260,8 @@ public class ODataJsonSerializerTest { final Entity entity = data.readAll(edmEntitySet).getEntities().get(0); InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity, EntitySerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) - .build()).getContent(); + .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) + .build()).getContent(); final String resultString = IOUtils.toString(result); final String expectedResult = "{" + "\"@odata.context\":\"$metadata#ESMixPrimCollComp/$entity\"," @@ -283,8 +283,8 @@ public class ODataJsonSerializerTest { entity.getProperties().retainAll(Arrays.asList(entity.getProperties().get(0))); final String resultString = IOUtils.toString(serializer.entity(metadata, edmEntitySet.getEntityType(), entity, EntitySerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) - .build()).getContent()); + .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) + .build()).getContent()); final String expectedResult = "{\"@odata.context\":\"$metadata#ESMixPrimCollComp/$entity\"," + "\"PropertyInt16\":32767," + "\"CollPropertyString\":null,\"PropertyComp\":null,\"CollPropertyComp\":null}"; @@ -296,7 +296,7 @@ public class ODataJsonSerializerTest { final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim"); final Entity entity = data.readAll(edmEntitySet).getEntities().get(0); InputStream result = new ODataJsonSerializer(ODataFormat.JSON_NO_METADATA) - .entity(metadata, edmEntitySet.getEntityType(), entity, null).getContent(); + .entity(metadata, edmEntitySet.getEntityType(), entity, null).getContent(); final String resultString = IOUtils.toString(result); final String expectedResult = "{\"PropertyInt16\":32766,\"PropertyString\":\"Test String1\"}"; Assert.assertEquals(expectedResult, resultString); @@ -307,9 +307,9 @@ public class ODataJsonSerializerTest { final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim"); final EntityCollection entitySet = data.readAll(edmEntitySet); InputStream result = new ODataJsonSerializer(ODataFormat.JSON_NO_METADATA) - .entityCollection(metadata, edmEntitySet.getEntityType(), entitySet, - EntityCollectionSerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet).build()).build()).getContent(); + .entityCollection(metadata, edmEntitySet.getEntityType(), entitySet, + EntityCollectionSerializerOptions.with() + .contextURL(ContextURL.with().entitySet(edmEntitySet).build()).build()).getContent(); final String resultString = IOUtils.toString(result); final String expectedResult = "{\"value\":[" + "{\"PropertyInt16\":32766,\"PropertyString\":\"Test String1\"}," @@ -327,8 +327,8 @@ public class ODataJsonSerializerTest { final String resultString = IOUtils.toString(serializer.entity(metadata, edmEntitySet.getEntityType(), entity, EntitySerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) - .build()).getContent()); + .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) + .build()).getContent()); final String expectedResult = "{\"@odata.context\":\"$metadata#ESMedia/$entity\"," + "\"@odata.mediaEtag\":\"theMediaETag\",\"@odata.mediaContentType\":\"image/svg+xml\"," + "\"PropertyInt16\":1}"; @@ -342,7 +342,7 @@ public class ODataJsonSerializerTest { final String resultString = IOUtils.toString(serializer.entityCollection(metadata, edmEntitySet.getEntityType(), entitySet, EntityCollectionSerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet).build()).build()).getContent()); + .contextURL(ContextURL.with().entitySet(edmEntitySet).build()).build()).getContent()); final String expectedResult = "{\"@odata.context\":\"$metadata#ESMedia\",\"value\":[" + "{\"@odata.mediaContentType\":\"image/svg+xml\",\"PropertyInt16\":1}," + "{\"@odata.mediaContentType\":\"image/svg+xml\",\"PropertyInt16\":2}," @@ -363,9 +363,9 @@ public class ODataJsonSerializerTest { InputStream result = serializer .entity(metadata, entityType, entity, EntitySerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet) - .selectList(helper.buildContextURLSelectList(entityType, null, select)) - .suffix(Suffix.ENTITY).build()) + .contextURL(ContextURL.with().entitySet(edmEntitySet) + .selectList(helper.buildContextURLSelectList(entityType, null, select)) + .suffix(Suffix.ENTITY).build()) .select(select) .build()).getContent(); final String resultString = IOUtils.toString(result); @@ -385,9 +385,9 @@ public class ODataJsonSerializerTest { final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(selectItem1, selectItem2)); InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity, EntitySerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) - .select(select) - .build()).getContent(); + .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) + .select(select) + .build()).getContent(); final String resultString = IOUtils.toString(result); final String expectedResult = "{\"@odata.context\":\"$metadata#ESTwoPrim/$entity\"," + "\"PropertyInt16\":32766,\"PropertyString\":\"Test String1\"}"; @@ -404,17 +404,17 @@ public class ODataJsonSerializerTest { InputStream result = serializer .entityCollection(metadata, entityType, entitySet, EntityCollectionSerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet) - .selectList(helper.buildContextURLSelectList(entityType, null, select)) - .build()) + .contextURL(ContextURL.with().entitySet(edmEntitySet) + .selectList(helper.buildContextURLSelectList(entityType, null, select)) + .build()) .select(select) .build()).getContent(); final String resultString = IOUtils.toString(result); Assert.assertEquals("{" - + "\"@odata.context\":\"$metadata#ESCompComp(PropertyComp/PropertyComp/PropertyString)\"," - + "\"value\":[" - + "{\"PropertyComp\":{\"PropertyComp\":{\"PropertyString\":\"String 1\"}}}," - + "{\"PropertyComp\":{\"PropertyComp\":{\"PropertyString\":\"String 2\"}}}]}", + + "\"@odata.context\":\"$metadata#ESCompComp(PropertyComp/PropertyComp/PropertyString)\"," + + "\"value\":[" + + "{\"PropertyComp\":{\"PropertyComp\":{\"PropertyString\":\"String 1\"}}}," + + "{\"PropertyComp\":{\"PropertyComp\":{\"PropertyString\":\"String 2\"}}}]}", resultString); } @@ -429,16 +429,16 @@ public class ODataJsonSerializerTest { final String resultString = IOUtils.toString(serializer .entityCollection(metadata, entityType, entitySet, EntityCollectionSerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet) - .selectList(helper.buildContextURLSelectList(entityType, null, select)) - .build()) + .contextURL(ContextURL.with().entitySet(edmEntitySet) + .selectList(helper.buildContextURLSelectList(entityType, null, select)) + .build()) .select(select) .build()).getContent()); Assert.assertEquals("{" - + "\"@odata.context\":\"$metadata#ESCompComp(PropertyComp/PropertyComp)\"," - + "\"value\":[" - + "{\"PropertyComp\":{\"PropertyComp\":{\"PropertyInt16\":123,\"PropertyString\":\"String 1\"}}}," - + "{\"PropertyComp\":{\"PropertyComp\":{\"PropertyInt16\":987,\"PropertyString\":\"String 2\"}}}]}", + + "\"@odata.context\":\"$metadata#ESCompComp(PropertyComp/PropertyComp)\"," + + "\"value\":[" + + "{\"PropertyComp\":{\"PropertyComp\":{\"PropertyInt16\":123,\"PropertyString\":\"String 1\"}}}," + + "{\"PropertyComp\":{\"PropertyComp\":{\"PropertyInt16\":987,\"PropertyString\":\"String 2\"}}}]}", resultString); } @@ -450,29 +450,29 @@ public class ODataJsonSerializerTest { ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETAllPrimOne"))); InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity, EntitySerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) - .expand(expand) - .build()).getContent(); + .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()) + .expand(expand) + .build()).getContent(); final String resultString = IOUtils.toString(result); Assert.assertEquals("{\"@odata.context\":\"$metadata#ESTwoPrim/$entity\"," - + "\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\"," - + "\"NavPropertyETAllPrimOne\":{" - + "\"PropertyInt16\":32767," - + "\"PropertyString\":\"First Resource - positive values\"," - + "\"PropertyBoolean\":true," - + "\"PropertyByte\":255," - + "\"PropertySByte\":127," - + "\"PropertyInt32\":2147483647," - + "\"PropertyInt64\":9223372036854775807," - + "\"PropertySingle\":1.79E20," - + "\"PropertyDouble\":-1.79E19," - + "\"PropertyDecimal\":34," - + "\"PropertyBinary\":\"ASNFZ4mrze8=\"," - + "\"PropertyDate\":\"2012-12-03\"," - + "\"PropertyDateTimeOffset\":\"2012-12-03T07:16:23Z\"," - + "\"PropertyDuration\":\"PT6S\"," - + "\"PropertyGuid\":\"01234567-89ab-cdef-0123-456789abcdef\"," - + "\"PropertyTimeOfDay\":\"03:26:05\"}}", + + "\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\"," + + "\"NavPropertyETAllPrimOne\":{" + + "\"PropertyInt16\":32767," + + "\"PropertyString\":\"First Resource - positive values\"," + + "\"PropertyBoolean\":true," + + "\"PropertyByte\":255," + + "\"PropertySByte\":127," + + "\"PropertyInt32\":2147483647," + + "\"PropertyInt64\":9223372036854775807," + + "\"PropertySingle\":1.79E20," + + "\"PropertyDouble\":-1.79E19," + + "\"PropertyDecimal\":34," + + "\"PropertyBinary\":\"ASNFZ4mrze8=\"," + + "\"PropertyDate\":\"2012-12-03\"," + + "\"PropertyDateTimeOffset\":\"2012-12-03T07:16:23Z\"," + + "\"PropertyDuration\":\"PT6S\"," + + "\"PropertyGuid\":\"01234567-89ab-cdef-0123-456789abcdef\"," + + "\"PropertyTimeOfDay\":\"03:26:05\"}}", resultString); } @@ -489,15 +489,15 @@ public class ODataJsonSerializerTest { final String resultString = IOUtils.toString(serializer .entity(metadata, entityType, entity, EntitySerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet) - .selectList(helper.buildContextURLSelectList(entityType, expand, select)) - .suffix(Suffix.ENTITY).build()) + .contextURL(ContextURL.with().entitySet(edmEntitySet) + .selectList(helper.buildContextURLSelectList(entityType, expand, select)) + .suffix(Suffix.ENTITY).build()) .expand(expand) .build()).getContent()); Assert.assertEquals("{" - + "\"@odata.context\":\"$metadata#ESTwoPrim(NavPropertyETAllPrimOne(PropertyDate))/$entity\"," - + "\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\"," - + "\"NavPropertyETAllPrimOne\":{\"PropertyDate\":\"2012-12-03\"}}", + + "\"@odata.context\":\"$metadata#ESTwoPrim(NavPropertyETAllPrimOne(PropertyDate))/$entity\"," + + "\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\"," + + "\"NavPropertyETAllPrimOne\":{\"PropertyDate\":\"2012-12-03\"}}", resultString); } @@ -516,17 +516,17 @@ public class ODataJsonSerializerTest { final String resultString = IOUtils.toString(serializer .entity(metadata, entityType, entity, EntitySerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet) - .selectList(helper.buildContextURLSelectList(entityType, expand, select)) - .suffix(Suffix.ENTITY).build()) + .contextURL(ContextURL.with().entitySet(edmEntitySet) + .selectList(helper.buildContextURLSelectList(entityType, expand, select)) + .suffix(Suffix.ENTITY).build()) .expand(expand) .select(select) .build()).getContent()); Assert.assertEquals("{" - + "\"@odata.context\":\"$metadata#ESAllPrim(PropertySByte)/$entity\"," - + "\"PropertySByte\":127," - + "\"NavPropertyETTwoPrimOne\":{\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\"}," - + "\"NavPropertyETTwoPrimMany\":[{\"PropertyInt16\":-365,\"PropertyString\":\"Test String2\"}]}", + + "\"@odata.context\":\"$metadata#ESAllPrim(PropertySByte)/$entity\"," + + "\"PropertySByte\":127," + + "\"NavPropertyETTwoPrimOne\":{\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\"}," + + "\"NavPropertyETTwoPrimMany\":[{\"PropertyInt16\":-365,\"PropertyString\":\"Test String2\"}]}", resultString); } @@ -543,16 +543,16 @@ public class ODataJsonSerializerTest { final String resultString = IOUtils.toString(serializer .entity(metadata, entityType, entity, EntitySerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet) - .selectList(helper.buildContextURLSelectList(entityType, expand, select)) - .suffix(Suffix.ENTITY).build()) + .contextURL(ContextURL.with().entitySet(edmEntitySet) + .selectList(helper.buildContextURLSelectList(entityType, expand, select)) + .suffix(Suffix.ENTITY).build()) .expand(expand) .select(select) .build()).getContent()); Assert.assertEquals("{" - + "\"@odata.context\":\"$metadata#ESAllPrim(PropertyTimeOfDay)/$entity\"," - + "\"PropertyTimeOfDay\":\"23:49:14\"," - + "\"NavPropertyETTwoPrimOne\":null,\"NavPropertyETTwoPrimMany\":[]}", + + "\"@odata.context\":\"$metadata#ESAllPrim(PropertyTimeOfDay)/$entity\"," + + "\"PropertyTimeOfDay\":\"23:49:14\"," + + "\"NavPropertyETTwoPrimOne\":null,\"NavPropertyETTwoPrimMany\":[]}", resultString); } @@ -574,21 +574,21 @@ public class ODataJsonSerializerTest { final String resultString = IOUtils.toString(serializer .entity(metadata, entityType, entity, EntitySerializerOptions.with() - .contextURL(ContextURL.with().entitySet(edmEntitySet) - .selectList(helper.buildContextURLSelectList(entityType, expand, select)) - .suffix(Suffix.ENTITY).build()) + .contextURL(ContextURL.with().entitySet(edmEntitySet) + .selectList(helper.buildContextURLSelectList(entityType, expand, select)) + .suffix(Suffix.ENTITY).build()) .expand(expand) .build()).getContent()); Assert.assertEquals("{" - + "\"@odata.context\":\"$metadata#ESTwoPrim(NavPropertyETAllPrimMany(PropertyInt32))/$entity\"," - + "\"PropertyInt16\":-365,\"PropertyString\":\"Test String2\"," - + "\"NavPropertyETAllPrimMany\":[" - + "{\"PropertyInt32\":-2147483648,\"NavPropertyETTwoPrimOne\":null,\"NavPropertyETTwoPrimMany\":[]}," - + "{\"PropertyInt32\":0,\"NavPropertyETTwoPrimOne\":null," - + "\"NavPropertyETTwoPrimMany\":[" - + "{\"PropertyInt16\":32766,\"PropertyString\":\"Test String1\"}," - + "{\"PropertyInt16\":-32766,\"PropertyString\":null}," - + "{\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\"}]}]}", + + "\"@odata.context\":\"$metadata#ESTwoPrim(NavPropertyETAllPrimMany(PropertyInt32))/$entity\"," + + "\"PropertyInt16\":-365,\"PropertyString\":\"Test String2\"," + + "\"NavPropertyETAllPrimMany\":[" + + "{\"PropertyInt32\":-2147483648,\"NavPropertyETTwoPrimOne\":null,\"NavPropertyETTwoPrimMany\":[]}," + + "{\"PropertyInt32\":0,\"NavPropertyETTwoPrimOne\":null," + + "\"NavPropertyETTwoPrimMany\":[" + + "{\"PropertyInt16\":32766,\"PropertyString\":\"Test String1\"}," + + "{\"PropertyInt16\":-32766,\"PropertyString\":null}," + + "{\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\"}]}]}", resultString); } @@ -600,13 +600,13 @@ public class ODataJsonSerializerTest { final String resultString = IOUtils.toString(serializer .primitive((EdmPrimitiveType) edmProperty.getType(), property, PrimitiveSerializerOptions.with() - .contextURL(ContextURL.with() - .entitySet(edmEntitySet).keyPath("32767").navOrPropertyPath(edmProperty.getName()) - .build()) + .contextURL(ContextURL.with() + .entitySet(edmEntitySet).keyPath("32767").navOrPropertyPath(edmProperty.getName()) + .build()) .build()).getContent()); Assert.assertEquals("{" - + "\"@odata.context\":\"$metadata#ESAllPrim(32767)/PropertyString\"," - + "\"value\":\"First Resource - positive values\"}", + + "\"@odata.context\":\"$metadata#ESAllPrim(32767)/PropertyString\"," + + "\"value\":\"First Resource - positive values\"}", resultString); } @@ -617,9 +617,9 @@ public class ODataJsonSerializerTest { final Property property = new Property("Edm.String", edmProperty.getName(), ValueType.PRIMITIVE, null); serializer.primitive((EdmPrimitiveType) edmProperty.getType(), property, PrimitiveSerializerOptions.with() - .contextURL(ContextURL.with() - .entitySet(edmEntitySet).keyPath("4242").navOrPropertyPath(edmProperty.getName()) - .build()) + .contextURL(ContextURL.with() + .entitySet(edmEntitySet).keyPath("4242").navOrPropertyPath(edmProperty.getName()) + .build()) .build()); } @@ -632,13 +632,13 @@ public class ODataJsonSerializerTest { final String resultString = IOUtils.toString(serializer .primitiveCollection((EdmPrimitiveType) edmProperty.getType(), property, PrimitiveSerializerOptions.with() - .contextURL(ContextURL.with() - .entitySet(edmEntitySet).keyPath("1").navOrPropertyPath(edmProperty.getName()) - .build()) + .contextURL(ContextURL.with() + .entitySet(edmEntitySet).keyPath("1").navOrPropertyPath(edmProperty.getName()) + .build()) .build()).getContent()); Assert.assertEquals("{" - + "\"@odata.context\":\"$metadata#ESCollAllPrim(1)/CollPropertyString\"," - + "\"value\":[\"[email protected]\",\"[email protected]\",\"[email protected]\"]}", + + "\"@odata.context\":\"$metadata#ESCollAllPrim(1)/CollPropertyString\"," + + "\"value\":[\"[email protected]\",\"[email protected]\",\"[email protected]\"]}", resultString); } @@ -651,13 +651,13 @@ public class ODataJsonSerializerTest { final String resultString = IOUtils.toString(serializer .complex(metadata, (EdmComplexType) edmProperty.getType(), property, ComplexSerializerOptions.with() - .contextURL(ContextURL.with() - .entitySet(edmEntitySet).keyPath("32767").navOrPropertyPath(edmProperty.getName()) - .build()) + .contextURL(ContextURL.with() + .entitySet(edmEntitySet).keyPath("32767").navOrPropertyPath(edmProperty.getName()) + .build()) .build()).getContent()); Assert.assertEquals("{" - + "\"@odata.context\":\"$metadata#ESMixPrimCollComp(32767)/PropertyComp\"," - + "\"PropertyInt16\":111,\"PropertyString\":\"TEST A\"}", + + "\"@odata.context\":\"$metadata#ESMixPrimCollComp(32767)/PropertyComp\"," + + "\"PropertyInt16\":111,\"PropertyString\":\"TEST A\"}", resultString); } @@ -670,15 +670,15 @@ public class ODataJsonSerializerTest { final String resultString = IOUtils.toString(serializer .complexCollection(metadata, (EdmComplexType) edmProperty.getType(), property, ComplexSerializerOptions.with() - .contextURL(ContextURL.with() - .entitySet(edmEntitySet).keyPath("32767").navOrPropertyPath(edmProperty.getName()) - .build()) + .contextURL(ContextURL.with() + .entitySet(edmEntitySet).keyPath("32767").navOrPropertyPath(edmProperty.getName()) + .build()) .build()).getContent()); Assert.assertEquals("{" - + "\"@odata.context\":\"$metadata#ESMixPrimCollComp(32767)/CollPropertyComp\"," - + "\"value\":[{\"PropertyInt16\":123,\"PropertyString\":\"TEST 1\"}," - + "{\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"}," - + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]}", + + "\"@odata.context\":\"$metadata#ESMixPrimCollComp(32767)/CollPropertyComp\"," + + "\"value\":[{\"PropertyInt16\":123,\"PropertyString\":\"TEST 1\"}," + + "{\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"}," + + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]}", resultString); } }
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1507449/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java index 08baea0..4d6ac45 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); 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 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -18,6 +18,16 @@ */ package org.apache.olingo.server.core.serializer.json; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + import org.apache.commons.io.IOUtils; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmEntityContainer; @@ -30,16 +40,6 @@ import org.apache.olingo.server.api.serializer.ODataSerializer; import org.junit.Before; import org.junit.Test; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - public class ServiceDocumentTest { private Edm edm; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1507449/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelperTest.java ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelperTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelperTest.java index 5397856..2416fbe 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelperTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelperTest.java @@ -1,18 +1,18 @@ /* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file + * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file + * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); 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 - * + * with the License. You may obtain a copy of the License at + * + * 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, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -44,7 +44,7 @@ import org.mockito.Mockito; public class ContextURLHelperTest { private static final Edm edm = OData.newInstance().createServiceMetadata( - new EdmTechProvider(), Collections.<EdmxReference>emptyList()).getEdm(); + new EdmTechProvider(), Collections.<EdmxReference> emptyList()).getEdm(); private static final EdmEntityContainer entityContainer = edm.getEntityContainer( new FullQualifiedName("olingo.odata.test1", "Container")); @@ -79,11 +79,11 @@ public class ContextURLHelperTest { final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList( ExpandSelectMock.mockSelectItem(entitySet, "PropertyMixedPrimCollComp", "PropertyComp", "PropertyString"), - ExpandSelectMock.mockSelectItem(entitySet, - "PropertyMixedPrimCollComp", "PropertyComp", "PropertyInt16"), - ExpandSelectMock.mockSelectItem(entitySet, "PropertyMixedPrimCollComp", "CollPropertyString"), - ExpandSelectMock.mockSelectItem(entitySet, "PropertyMixedPrimCollComp", "CollPropertyComp"), - ExpandSelectMock.mockSelectItem(entitySet, "PropertyInt16"))); + ExpandSelectMock.mockSelectItem(entitySet, + "PropertyMixedPrimCollComp", "PropertyComp", "PropertyInt16"), + ExpandSelectMock.mockSelectItem(entitySet, "PropertyMixedPrimCollComp", "CollPropertyString"), + ExpandSelectMock.mockSelectItem(entitySet, "PropertyMixedPrimCollComp", "CollPropertyComp"), + ExpandSelectMock.mockSelectItem(entitySet, "PropertyInt16"))); final ContextURL contextURL = ContextURL.with().entitySet(entitySet) .selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), null, select)).build(); assertEquals("$metadata#ESCompMixPrimCollComp(" http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1507449/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java index df7dd79..d3bdbac 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); 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 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -151,7 +151,7 @@ public class MetadataDocumentTest { * <edmx:Include Namespace="Org.OData.Core.V1" Alias="Core"/> * </edmx:Reference> * </code> - * + * * @return default emdx reference */ private List<EdmxReference> getEdmxReferences() { http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1507449/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java index 5e991b0..8945376 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); 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 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -18,16 +18,16 @@ */ package org.apache.olingo.server.core.uri; -import org.apache.olingo.server.core.uri.parser.RawUri; -import org.apache.olingo.server.core.uri.parser.UriDecoder; -import org.apache.olingo.server.core.uri.parser.UriParserSyntaxException; -import org.junit.Test; +import static org.junit.Assert.assertEquals; import java.util.Arrays; import java.util.Collections; import java.util.List; -import static org.junit.Assert.assertEquals; +import org.apache.olingo.server.core.uri.parser.RawUri; +import org.apache.olingo.server.core.uri.parser.UriDecoder; +import org.apache.olingo.server.core.uri.parser.UriParserSyntaxException; +import org.junit.Test; public class RawUriTest { http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1507449/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriHelperTest.java ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriHelperTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriHelperTest.java index fe44305..82653e9 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriHelperTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriHelperTest.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); 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 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1507449/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java index a13b929..5687035 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); 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 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -18,6 +18,12 @@ */ package org.apache.olingo.server.core.uri; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.ArrayList; +import java.util.List; + import org.apache.olingo.commons.api.ODataRuntimeException; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmEntityType; @@ -49,12 +55,6 @@ import org.apache.olingo.server.core.uri.testutil.EdmTechTestProvider; import org.apache.olingo.server.tecsvc.provider.EntityTypeProvider; import org.junit.Test; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - public class UriInfoImplTest { Edm edm = new EdmProviderImpl(new EdmTechTestProvider()); @@ -126,8 +126,8 @@ public class UriInfoImplTest { @Test(expected = ODataRuntimeException.class) public void doubleSystemQueryOptions() { new UriInfoImpl() - .setSystemQueryOption(new FormatOptionImpl()) - .setSystemQueryOption(new FormatOptionImpl()); + .setSystemQueryOption(new FormatOptionImpl()) + .setSystemQueryOption(new FormatOptionImpl()); } @Test http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d1507449/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java index 050cce1..1945fe5 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); 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 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -18,6 +18,14 @@ */ package org.apache.olingo.server.core.uri; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAction; import org.apache.olingo.commons.api.edm.EdmActionImport; @@ -28,11 +36,11 @@ import org.apache.olingo.commons.api.edm.EdmNavigationProperty; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.EdmProperty; import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; import org.apache.olingo.commons.core.edm.EdmComplexTypeImpl; import org.apache.olingo.commons.core.edm.EdmEntitySetImpl; import org.apache.olingo.commons.core.edm.EdmProviderImpl; import org.apache.olingo.commons.core.edm.EdmSingletonImpl; +import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; import org.apache.olingo.server.api.uri.UriResourceKind; import org.apache.olingo.server.core.uri.queryoption.expression.ExpressionImpl; import org.apache.olingo.server.core.uri.queryoption.expression.LiteralImpl; @@ -42,14 +50,6 @@ import org.apache.olingo.server.tecsvc.provider.ComplexTypeProvider; import org.apache.olingo.server.tecsvc.provider.EntityTypeProvider; import org.junit.Test; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - public class UriResourceImplTest { Edm edm = new EdmProviderImpl(new EdmTechTestProvider());
