Repository: olingo-odata4 Updated Branches: refs/heads/master 0f3930654 -> 58ec0358c
[OLINGO-1287]Deep Update support for Version 4.01 Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/58ec0358 Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/58ec0358 Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/58ec0358 Branch: refs/heads/master Commit: 58ec0358c2b52829e35a8bc8f0dfc777c9a58940 Parents: 0f39306 Author: Archana Rai <archana....@sap.com> Authored: Fri Aug 17 14:32:30 2018 +0530 Committer: Archana Rai <archana....@sap.com> Committed: Fri Aug 17 14:32:30 2018 +0530 ---------------------------------------------------------------------- .../org/apache/olingo/server/api/OData.java | 21 ++ .../netty/server/core/ODataNettyImpl.java | 12 ++ .../olingo/server/core/ContentNegotiator.java | 1 - .../apache/olingo/server/core/ODataImpl.java | 37 ++++ .../json/ODataJsonDeserializer.java | 112 +++++++++- .../core/serializer/utils/ContextURLHelper.java | 1 - .../json/ODataDeserializerDeepUpdateTest.java | 209 +++++++++++++++++++ .../json/ODataJsonDeserializerEntityTest.java | 7 + .../src/test/resources/ESAllPrimUpdate.json | 56 +++++ .../ESAllPrimWithCustomAnnotationsUpdate.json | 57 +++++ .../resources/ESAllPrimWithDoubleKeyUpdate.json | 57 +++++ .../ESAllPrimWithODataAnnotationsUpdate.json | 59 ++++++ .../test/resources/ESCompCollCompUpdate.json | 35 ++++ ...imExpandedNavPropertyETTwoPrimManyDelta.json | 48 +++++ ...imExpandedNavPropertyETTwoPrimManyError.json | 48 +++++ ...mExpandedNavPropertyETTwoPrimManyUpdate.json | 28 +++ ...ETTwoPrimManyWithODataAnnotationsUpdate.json | 27 +++ ...imExpandedNavPropertyETTwoPrimOneUpdate.json | 23 ++ ...yETTwoPrimOneWithODataAnnotationsUpdate.json | 26 +++ .../EntityETMixEnumDefCollCompUpdate.json | 24 +++ ...MixEnumDefCollCompWithEnumStringsUpdate.json | 24 +++ .../UnbalancedESAllPrimFeedUpdate.json | 23 ++ 22 files changed, 927 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java index 16cca29..01a8b0f 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java @@ -161,6 +161,27 @@ public abstract class OData { ServiceMetadata metadata) throws DeserializerException; /** + * Creates a new deserializer object for reading content in the specified format. + * Deserializers are used in Processor implementations. + * + * @param contentType any content type supported by Olingo (XML, JSON ...) + * @param service version + */ + public abstract ODataDeserializer createDeserializer(ContentType contentType, + final List<String> versions) throws DeserializerException; + + /** + * Creates a new deserializer object for reading content in the specified format. + * Deserializers are used in Processor implementations. + * + * @param contentType any content type supported by Olingo (XML, JSON ...) + * @param metadata ServiceMetada of the service + * @param service version + */ + public abstract ODataDeserializer createDeserializer(ContentType contentType, + ServiceMetadata metadata, final List<String> versions) throws DeserializerException; + + /** * Creates a primitive-type instance. * @param kind the kind of the primitive type * @return an {@link EdmPrimitiveType} instance for the type kind http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-core/src/main/java/org/apache/olingo/netty/server/core/ODataNettyImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/netty/server/core/ODataNettyImpl.java b/lib/server-core/src/main/java/org/apache/olingo/netty/server/core/ODataNettyImpl.java index 113eb03..7250e33 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/netty/server/core/ODataNettyImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/netty/server/core/ODataNettyImpl.java @@ -160,5 +160,17 @@ public class ODataNettyImpl extends ODataNetty { throws SerializerException { return odata.createEdmDeltaSerializer(contentType, versions); } + + @Override + public ODataDeserializer createDeserializer(ContentType contentType, List<String> versions) + throws DeserializerException { + return odata.createDeserializer(contentType, versions); + } + + @Override + public ODataDeserializer createDeserializer(ContentType contentType, ServiceMetadata metadata, List<String> versions) + throws DeserializerException { + return odata.createDeserializer(contentType, metadata, versions); + } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java index a598308..407264c 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java @@ -18,7 +18,6 @@ */ package org.apache.olingo.server.core; -import java.nio.charset.Charset; import java.nio.charset.UnsupportedCharsetException; import java.util.Arrays; import java.util.Collections; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java index c3507fb..db9bffc 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java @@ -238,4 +238,41 @@ public class ODataImpl extends OData { // TODO: Support more debug formats return new DebugResponseHelperImpl(debugFormat); } + + @Override + public ODataDeserializer createDeserializer(ContentType contentType, List<String> versions) + throws DeserializerException { + IConstants constants = new Constantsv00(); + if(versions!=null && versions.size()>0 && getMaxVersion(versions)>4){ + constants = new Constantsv01() ; + } + if (contentType.isCompatible(ContentType.JSON)) { + return new ODataJsonDeserializer(contentType, constants); + } else if (contentType.isCompatible(ContentType.APPLICATION_XML) + || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) { + return new ODataXmlDeserializer(); + } else { + throw new DeserializerException("Unsupported format: " + contentType.toContentTypeString(), + DeserializerException.MessageKeys.UNSUPPORTED_FORMAT, contentType.toContentTypeString()); + } + + } + + @Override + public ODataDeserializer createDeserializer(ContentType contentType, ServiceMetadata metadata, List<String> versions) + throws DeserializerException { + IConstants constants = new Constantsv00(); + if(versions!=null && versions.size()>0 && getMaxVersion(versions)>4){ + constants = new Constantsv01() ; + } + if (contentType.isCompatible(ContentType.JSON)) { + return new ODataJsonDeserializer(contentType, metadata, constants); + } else if (contentType.isCompatible(ContentType.APPLICATION_XML) + || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) { + return new ODataXmlDeserializer(metadata); + } else { + throw new DeserializerException("Unsupported format: " + contentType.toContentTypeString(), + DeserializerException.MessageKeys.UNSUPPORTED_FORMAT, contentType.toContentTypeString()); + } + } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java index 71aee42..0e8fbf9 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java @@ -33,7 +33,13 @@ import java.util.Map; import java.util.Map.Entry; import org.apache.olingo.commons.api.Constants; +import org.apache.olingo.commons.api.IConstants; +import org.apache.olingo.commons.api.constants.Constantsv00; +import org.apache.olingo.commons.api.constants.Constantsv01; import org.apache.olingo.commons.api.data.ComplexValue; +import org.apache.olingo.commons.api.data.DeletedEntity; +import org.apache.olingo.commons.api.data.DeletedEntity.Reason; +import org.apache.olingo.commons.api.data.Delta; import org.apache.olingo.commons.api.data.Entity; import org.apache.olingo.commons.api.data.EntityCollection; import org.apache.olingo.commons.api.data.Link; @@ -70,6 +76,7 @@ import org.apache.olingo.server.api.deserializer.DeserializerException; import org.apache.olingo.server.api.deserializer.DeserializerException.MessageKeys; import org.apache.olingo.server.api.deserializer.DeserializerResult; import org.apache.olingo.server.api.deserializer.ODataDeserializer; +import org.apache.olingo.server.api.serializer.SerializerException; import org.apache.olingo.server.core.deserializer.DeserializerResultImpl; import org.apache.olingo.server.core.deserializer.helper.ExpandTreeBuilder; import org.apache.olingo.server.core.deserializer.helper.ExpandTreeBuilderImpl; @@ -102,17 +109,31 @@ public class ODataJsonDeserializer implements ODataDeserializer { private static final String ODATA_ANNOTATION_MARKER = "@"; private static final String ODATA_CONTROL_INFORMATION_PREFIX = "@odata."; + private static final String REASON = "reason"; private final boolean isIEEE754Compatible; private ServiceMetadata serviceMetadata; + private IConstants constants; public ODataJsonDeserializer(final ContentType contentType) { - this(contentType, null); + this(contentType, null, new Constantsv00()); } public ODataJsonDeserializer(final ContentType contentType, final ServiceMetadata serviceMetadata) { isIEEE754Compatible = ContentTypeHelper.isODataIEEE754Compatible(contentType); this.serviceMetadata = serviceMetadata; + this.constants = new Constantsv00(); + } + + public ODataJsonDeserializer(ContentType contentType, ServiceMetadata serviceMetadata, IConstants constants) { + isIEEE754Compatible = ContentTypeHelper.isODataIEEE754Compatible(contentType); + this.serviceMetadata = serviceMetadata; + this.constants = constants; + } + + public ODataJsonDeserializer(ContentType contentType, IConstants constants) { + isIEEE754Compatible = ContentTypeHelper.isODataIEEE754Compatible(contentType); + this.constants = constants; } @Override @@ -189,6 +210,9 @@ public class ODataJsonDeserializer implements ODataDeserializer { final ExpandTreeBuilder expandBuilder) throws DeserializerException { Entity entity = new Entity(); entity.setType(edmEntityType.getFullQualifiedName().getFullQualifiedNameAsString()); + + // Check and consume @id for v4.01 + consumeId(edmEntityType, tree, entity); // Check and consume all Properties consumeEntityProperties(edmEntityType, tree, entity); @@ -196,6 +220,9 @@ public class ODataJsonDeserializer implements ODataDeserializer { // Check and consume all expanded Navigation Properties consumeExpandedNavigationProperties(edmEntityType, tree, entity, expandBuilder); + // consume delta json node fields for v4.01 + consumeDeltaJsonNodeFields(edmEntityType, tree, entity, expandBuilder); + // consume remaining json node fields consumeRemainingJsonNodeFields(edmEntityType, tree, entity); @@ -204,6 +231,75 @@ public class ODataJsonDeserializer implements ODataDeserializer { return entity; } + private void consumeDeltaJsonNodeFields(EdmEntityType edmEntityType, ObjectNode node, + Entity entity, ExpandTreeBuilder expandBuilder) + throws DeserializerException { + if (constants instanceof Constantsv01) { + List<String> navigationPropertyNames = edmEntityType.getNavigationPropertyNames(); + for (String navigationPropertyName : navigationPropertyNames) { + // read expanded navigation property for delta + String delta = navigationPropertyName + Constants.AT + Constants.DELTAVALUE; + JsonNode jsonNode = node.get(delta); + EdmNavigationProperty edmNavigationProperty = edmEntityType.getNavigationProperty(navigationPropertyName); + if (jsonNode != null && jsonNode.isArray() && edmNavigationProperty.isCollection()) { + checkNotNullOrValidNull(jsonNode, edmNavigationProperty); + Link link = new Link(); + link.setType(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE); + link.setTitle(navigationPropertyName); + Delta deltaValue = new Delta(); + for (JsonNode arrayElement : jsonNode) { + String removed = Constants.AT + Constants.REMOVED; + if (arrayElement.get(removed) != null) { + //if @removed is present create a DeletedEntity Object + JsonNode reasonNode = arrayElement.get(removed); + DeletedEntity deletedEntity = new DeletedEntity(); + Reason reason = null; + if (reasonNode.get(REASON) != null) { + if(reasonNode.get(REASON).asText().equals(Reason.changed.name())){ + reason = Reason.changed; + }else if(reasonNode.get(REASON).asText().equals(Reason.deleted.name())){ + reason = Reason.deleted; + } + }else{ + throw new DeserializerException("DeletedEntity reason is null.", + SerializerException.MessageKeys.MISSING_DELTA_PROPERTY, Constants.REASON); + } + deletedEntity.setReason(reason); + try { + deletedEntity.setId(new URI(arrayElement.get(constants.getId()).asText())); + } catch (URISyntaxException e) { + throw new DeserializerException("Could not set Id for deleted Entity", e, + DeserializerException.MessageKeys.UNKNOWN_CONTENT); + } + deltaValue.getDeletedEntities().add(deletedEntity); + } else { + //For @id and properties create normal entity + Entity inlineEntity = consumeEntityNode(edmEntityType, (ObjectNode) arrayElement, expandBuilder); + deltaValue.getEntities().add(inlineEntity); + } + } + link.setInlineEntitySet(deltaValue); + entity.getNavigationLinks().add(link); + node.remove(navigationPropertyName); + } + } + } + + } + + private void consumeId(EdmEntityType edmEntityType, ObjectNode node, Entity entity) + throws DeserializerException { + if (node.get(constants.getId()) != null && constants instanceof Constantsv01) { + try { + entity.setId(new URI(node.get(constants.getId()).textValue())); + node.remove(constants.getId()); + } catch (URISyntaxException e) { + throw new DeserializerException("Could not form Id", e, + DeserializerException.MessageKeys.UNKNOWN_CONTENT); + } + } + } + @Override public DeserializerResult actionParameters(final InputStream stream, final EdmAction edmAction) throws DeserializerException { @@ -337,7 +433,7 @@ public class ODataJsonDeserializer implements ODataDeserializer { while (fieldsIterator.hasNext()) { Entry<String, JsonNode> field = fieldsIterator.next(); - if (field.getKey().contains(Constants.JSON_BIND_LINK_SUFFIX)) { + if (field.getKey().contains(constants.getBind())) { Link bindingLink = consumeBindingLink(field.getKey(), field.getValue(), edmEntityType); entity.getNavigationBindings().add(bindingLink); toRemove.add(field.getKey()); @@ -432,7 +528,7 @@ public class ODataJsonDeserializer implements ODataDeserializer { } return link; } - + private Link consumeBindingLink(final String key, final JsonNode jsonNode, final EdmEntityType edmEntityType) throws DeserializerException { String[] splitKey = key.split(ODATA_ANNOTATION_MARKER); @@ -822,8 +918,12 @@ public class ODataJsonDeserializer implements ODataDeserializer { // Control Information is ignored for requests as per specification chapter "4.5 Control Information" toRemove.add(field.getKey()); } else if (field.getKey().contains(ODATA_ANNOTATION_MARKER)) { - throw new DeserializerException("Custom annotation with field name: " + field.getKey() + " not supported", + if(constants instanceof Constantsv01){ + toRemove.add(field.getKey()); + }else{ + throw new DeserializerException("Custom annotation with field name: " + field.getKey() + " not supported", DeserializerException.MessageKeys.NOT_IMPLEMENTED); + } } } // remove here to avoid iterator issues. @@ -937,7 +1037,7 @@ public class ODataJsonDeserializer implements ODataDeserializer { try { List<URI> parsedValues = new ArrayList<URI>(); final ObjectNode tree = parseJsonTree(stream); - final String key = Constants.JSON_ID; + final String key = constants.getId(); JsonNode jsonNode = tree.get(Constants.VALUE); if (jsonNode != null) { if (jsonNode.isArray()) { @@ -984,7 +1084,7 @@ public class ODataJsonDeserializer implements ODataDeserializer { private EdmType getDerivedType(final EdmStructuredType edmType, final JsonNode jsonNode) throws DeserializerException { - JsonNode odataTypeNode = jsonNode.get(Constants.JSON_TYPE); + JsonNode odataTypeNode = jsonNode.get(constants.getType()); if (odataTypeNode != null) { String odataType = odataTypeNode.asText(); if (!odataType.isEmpty()) { http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelper.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelper.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelper.java index 8e2a1be..8352ef4 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelper.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelper.java @@ -27,7 +27,6 @@ import org.apache.olingo.commons.api.edm.EdmAction; import org.apache.olingo.commons.api.edm.EdmComplexType; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmFunction; -import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; import org.apache.olingo.commons.api.edm.EdmNavigationProperty; import org.apache.olingo.commons.api.edm.EdmProperty; import org.apache.olingo.commons.api.edm.EdmStructuredType; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepUpdateTest.java ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepUpdateTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepUpdateTest.java new file mode 100644 index 0000000..6c76ba6 --- /dev/null +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepUpdateTest.java @@ -0,0 +1,209 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * 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 + * + * 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 + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.server.core.deserializer.json; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.olingo.commons.api.Constants; +import org.apache.olingo.commons.api.data.DeletedEntity.Reason; +import org.apache.olingo.commons.api.data.Delta; +import org.apache.olingo.commons.api.data.Entity; +import org.apache.olingo.commons.api.data.Link; +import org.apache.olingo.commons.api.edm.EdmEntityType; +import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.api.format.ContentType; +import org.apache.olingo.server.api.deserializer.DeserializerException; +import org.apache.olingo.server.api.deserializer.DeserializerResult; +import org.apache.olingo.server.api.serializer.SerializerException; +import org.apache.olingo.server.api.uri.queryoption.ExpandItem; +import org.apache.olingo.server.api.uri.queryoption.ExpandOption; +import org.apache.olingo.server.core.deserializer.AbstractODataDeserializerTest; +import org.junit.Test; + +public class ODataDeserializerDeepUpdateTest extends AbstractODataDeserializerTest { + + @Test + public void unbalancedESAllPrim() throws Exception { + final DeserializerResult result = deserializeWithResult("UnbalancedESAllPrimFeedUpdate.json"); + ExpandOption root = result.getExpandTree(); + assertEquals(1, root.getExpandItems().size()); + + ExpandItem etTwoPrimManyLevel = root.getExpandItems().get(0); + assertEquals("NavPropertyETTwoPrimMany", etTwoPrimManyLevel.getResourcePath().getUriResourceParts().get(0) + .getSegmentValue()); + assertEquals(1, etTwoPrimManyLevel.getExpandOption().getExpandItems().size()); + + ExpandItem etAllPrimOneLevel = etTwoPrimManyLevel.getExpandOption().getExpandItems().get(0); + assertEquals("NavPropertyETAllPrimOne", etAllPrimOneLevel.getResourcePath().getUriResourceParts().get(0) + .getSegmentValue()); + assertEquals(1, etAllPrimOneLevel.getExpandOption().getExpandItems().size()); + + ExpandItem etTwoPrimOneLevel = etAllPrimOneLevel.getExpandOption().getExpandItems().get(0); + assertEquals("NavPropertyETTwoPrimOne", etTwoPrimOneLevel.getResourcePath().getUriResourceParts().get(0) + .getSegmentValue()); + assertNull(etTwoPrimOneLevel.getExpandOption()); + } + + @Test + public void esAllPrimExpandedToOne() throws Exception { + final Entity entity = deserialize("EntityESAllPrimExpandedNavPropertyETTwoPrimOneUpdate.json"); + + Link navigationLink = entity.getNavigationLink("NavPropertyETTwoPrimOne"); + assertNotNull(navigationLink); + + assertEquals("NavPropertyETTwoPrimOne", navigationLink.getTitle()); + assertEquals(Constants.ENTITY_NAVIGATION_LINK_TYPE, navigationLink.getType()); + assertNotNull(navigationLink.getInlineEntity()); + assertNull(navigationLink.getInlineEntitySet()); + } + + @Test + public void esAllPrimExpandedToOneWithODataAnnotations() throws Exception { + deserialize("EntityESAllPrimExpandedNavPropertyETTwoPrimOneWithODataAnnotationsUpdate.json"); + } + + @Test + public void esAllPrimExpandedToMany() throws Exception { + final Entity entity = deserialize("EntityESAllPrimExpandedNavPropertyETTwoPrimManyUpdate.json"); + + Link navigationLink = entity.getNavigationLink("NavPropertyETTwoPrimMany"); + assertNotNull(navigationLink); + + assertEquals("NavPropertyETTwoPrimMany", navigationLink.getTitle()); + assertEquals(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE, navigationLink.getType()); + assertNull(navigationLink.getInlineEntity()); + assertNotNull(navigationLink.getInlineEntitySet()); + assertEquals(2, navigationLink.getInlineEntitySet().getEntities().size()); + assertNull(navigationLink.getInlineEntitySet().getEntities().get(0).getId()); + assertNotNull(navigationLink.getInlineEntitySet().getEntities().get(1).getId()); + } + + @Test + public void esAllPrimExpandedToManyError() throws Exception { + try{ + deserialize("EntityESAllPrimExpandedNavPropertyETTwoPrimManyError.json"); + fail("Expected exception not thrown."); + } catch (final DeserializerException e) { + assertEquals(SerializerException.MessageKeys.MISSING_DELTA_PROPERTY, e.getMessageKey()); + } + } + + @Test + public void esAllPrimExpandedToManyDelta() throws Exception { + final Entity entity = deserialize("EntityESAllPrimExpandedNavPropertyETTwoPrimManyDelta.json"); + + Link navigationLink = entity.getNavigationLink("NavPropertyETTwoPrimMany"); + assertNotNull(navigationLink); + + assertEquals("NavPropertyETTwoPrimMany", navigationLink.getTitle()); + assertEquals(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE, navigationLink.getType()); + assertNull(navigationLink.getInlineEntity()); + assertNotNull(navigationLink.getInlineEntitySet()); + assertEquals(3, navigationLink.getInlineEntitySet().getEntities().size()); + assertEquals("ESAllPrim(5)",navigationLink.getInlineEntitySet().getEntities().get(0).getId().toString()); + assertEquals("ESAllPrim(6)",navigationLink.getInlineEntitySet().getEntities().get(1).getId().toString()); + assertNull(navigationLink.getInlineEntitySet().getEntities().get(2).getId()); + Delta delta = ((Delta)navigationLink.getInlineEntitySet()); + assertEquals(2, delta.getDeletedEntities().size()); + assertNotNull(delta.getDeletedEntities().get(0).getId()); + assertNotNull(delta.getDeletedEntities().get(1).getId()); + assertEquals(Reason.deleted, delta.getDeletedEntities().get(0).getReason()); + assertEquals(Reason.changed, delta.getDeletedEntities().get(1).getReason()); + } + + @Test + public void esAllPrimExpandedToManyWithODataAnnotations() throws Exception { + deserialize("EntityESAllPrimExpandedNavPropertyETTwoPrimManyWithODataAnnotationsUpdate.json"); + } + + + @Test + public void expandedToOneInvalidNullValue() throws Exception { + ODataJsonDeserializerEntityTest.expectException( + "{\"PropertyInt16\":32767," + + "\"NavPropertyETTwoPrimOne\":null" + + "}", + "ETAllPrim", + DeserializerException.MessageKeys.INVALID_NULL_PROPERTY); + } + + @Test + public void expandedToOneValidNullValue() throws Exception { + final Entity entity = ODataJsonDeserializerEntityTest.deserialize( + "{\"PropertyInt16\":32767," + + "\"NavPropertyETAllPrimOne\":null" + + "}", + "ETTwoPrim"); + + assertEquals(1, entity.getNavigationLinks().size()); + final Link link = entity.getNavigationLinks().get(0); + + assertEquals("NavPropertyETAllPrimOne", link.getTitle()); + assertNull(link.getInlineEntity()); + assertNull(link.getInlineEntitySet()); + } + + @Test + public void expandedToOneInvalidStringValue() throws Exception { + ODataJsonDeserializerEntityTest.expectException( + "{\"PropertyInt16\":32767," + + "\"NavPropertyETTwoPrimOne\":\"First Resource - positive values\"" + + "}", + "ETAllPrim", + DeserializerException.MessageKeys.INVALID_VALUE_FOR_NAVIGATION_PROPERTY); + } + + @Test + public void expandedToManyInvalidNullValue() throws Exception { + ODataJsonDeserializerEntityTest.expectException( + "{\"PropertyInt16\":32767," + + "\"NavPropertyETTwoPrimMany\":null" + + "}", + "ETAllPrim", + DeserializerException.MessageKeys.INVALID_NULL_PROPERTY); + } + + @Test + public void expandedToManyInvalidStringValue() throws Exception { + ODataJsonDeserializerEntityTest.expectException( + "{\"PropertyInt16\":32767," + + "\"NavPropertyETTwoPrimMany\":\"First Resource - positive values\"" + + "}", + "ETAllPrim", + DeserializerException.MessageKeys.INVALID_VALUE_FOR_NAVIGATION_PROPERTY); + } + + private Entity deserialize(final String resourceName) throws IOException, DeserializerException { + return deserializeWithResult(resourceName).getEntity(); + } + + private DeserializerResult deserializeWithResult(final String resourceName) throws IOException, + DeserializerException { + InputStream stream = getFileAsStream(resourceName); + final EdmEntityType entityType = edm.getEntityType(new FullQualifiedName(NAMESPACE, "ETAllPrim")); + return ODataJsonDeserializerEntityTest.deserializeWithResultv401(stream , + entityType, ContentType.JSON); + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java index 34ccb55..1eb96a9 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java @@ -1876,4 +1876,11 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe assertEquals(messageKey, e.getMessageKey()); } } + + public static DeserializerResult deserializeWithResultv401(InputStream stream, EdmEntityType entityType, + ContentType contentType) throws DeserializerException { + List<String> version = new ArrayList<String>(); + version.add("4.01"); + return odata.createDeserializer(contentType, metadata, version).entity(stream, entityType); + } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-test/src/test/resources/ESAllPrimUpdate.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/ESAllPrimUpdate.json b/lib/server-test/src/test/resources/ESAllPrimUpdate.json new file mode 100644 index 0000000..8407d9c --- /dev/null +++ b/lib/server-test/src/test/resources/ESAllPrimUpdate.json @@ -0,0 +1,56 @@ +{ + "@context" : "$metadata#ESAllPrim", + "value" : [{ + "PropertyInt16" : 32767, + "PropertyString" : "First Resource - positive values", + "PropertyBoolean" : true, + "PropertyByte" : 255, + "PropertySByte" : 127, + "PropertyInt32" : 2147483647, + "PropertyInt64" : 9223372036854775807, + "PropertySingle" : 1.79000000E+20, + "PropertyDouble" : -1.7900000000000000E+19, + "PropertyDecimal" : 34, + "PropertyBinary" : "ASNFZ4mrze8=", + "PropertyDate" : "2012-12-03", + "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", + "PropertyDuration" : "P0DT0H0M6S", + "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", + "PropertyTimeOfDay" : "03:26:05" + }, { + "PropertyInt16" : -32768, + "PropertyString" : "Second Resource - negative values", + "PropertyBoolean" : false, + "PropertyByte" : 0, + "PropertySByte" : -128, + "PropertyInt32" : -2147483648, + "PropertyInt64" : -9223372036854775808, + "PropertySingle" : -1.79000000E+08, + "PropertyDouble" : -1.7900000000000000E+05, + "PropertyDecimal" : -34, + "PropertyBinary" : "ASNFZ4mrze8=", + "PropertyDate" : "2015-11-05", + "PropertyDateTimeOffset" : "2005-12-03T07:17:08Z", + "PropertyDuration" : "P0DT0H0M9S", + "PropertyGuid" : "76543201-23ab-cdef-0123-456789dddfff", + "PropertyTimeOfDay" : "23:49:14" + }, { + "PropertyInt16" : 0, + "PropertyString" : "", + "PropertyBoolean" : false, + "PropertyByte" : 0, + "PropertySByte" : 0, + "PropertyInt32" : 0, + "PropertyInt64" : 0, + "PropertySingle" : 0.00000000E+00, + "PropertyDouble" : 0.0000000000000000E+00, + "PropertyDecimal" : 0, + "PropertyBinary" : "", + "PropertyDate" : "1970-01-01", + "PropertyDateTimeOffset" : "2005-12-03T00:00:00Z", + "PropertyDuration" : "P0DT0H0M0S", + "PropertyGuid" : "76543201-23ab-cdef-0123-456789cccddd", + "PropertyTimeOfDay" : "00:01:01" + } + ] +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-test/src/test/resources/ESAllPrimWithCustomAnnotationsUpdate.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/ESAllPrimWithCustomAnnotationsUpdate.json b/lib/server-test/src/test/resources/ESAllPrimWithCustomAnnotationsUpdate.json new file mode 100644 index 0000000..8016b15 --- /dev/null +++ b/lib/server-test/src/test/resources/ESAllPrimWithCustomAnnotationsUpdate.json @@ -0,0 +1,57 @@ +{ + "@context" : "$metadata#ESAllPrim", + "@custom.annotation" : "customValue", + "value" : [{ + "PropertyInt16" : 32767, + "PropertyString" : "First Resource - positive values", + "PropertyBoolean" : true, + "PropertyByte" : 255, + "PropertySByte" : 127, + "PropertyInt32" : 2147483647, + "PropertyInt64" : 9223372036854775807, + "PropertySingle" : 1.79000000E+20, + "PropertyDouble" : -1.7900000000000000E+19, + "PropertyDecimal" : 34, + "PropertyBinary" : "ASNFZ4mrze8=", + "PropertyDate" : "2012-12-03", + "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", + "PropertyDuration" : "P0DT0H0M6S", + "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", + "PropertyTimeOfDay" : "03:26:05" + }, { + "PropertyInt16" : -32768, + "PropertyString" : "Second Resource - negative values", + "PropertyBoolean" : false, + "PropertyByte" : 0, + "PropertySByte" : -128, + "PropertyInt32" : -2147483648, + "PropertyInt64" : -9223372036854775808, + "PropertySingle" : -1.79000000E+08, + "PropertyDouble" : -1.7900000000000000E+05, + "PropertyDecimal" : -34, + "PropertyBinary" : "ASNFZ4mrze8=", + "PropertyDate" : "2015-11-05", + "PropertyDateTimeOffset" : "2005-12-03T07:17:08Z", + "PropertyDuration" : "P0DT0H0M9S", + "PropertyGuid" : "76543201-23ab-cdef-0123-456789dddfff", + "PropertyTimeOfDay" : "23:49:14" + }, { + "PropertyInt16" : 0, + "PropertyString" : "", + "PropertyBoolean" : false, + "PropertyByte" : 0, + "PropertySByte" : 0, + "PropertyInt32" : 0, + "PropertyInt64" : 0, + "PropertySingle" : 0.00000000E+00, + "PropertyDouble" : 0.0000000000000000E+00, + "PropertyDecimal" : 0, + "PropertyBinary" : "", + "PropertyDate" : "1970-01-01", + "PropertyDateTimeOffset" : "2005-12-03T00:00:00Z", + "PropertyDuration" : "P0DT0H0M0S", + "PropertyGuid" : "76543201-23ab-cdef-0123-456789cccddd", + "PropertyTimeOfDay" : "00:01:01" + } + ] +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-test/src/test/resources/ESAllPrimWithDoubleKeyUpdate.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/ESAllPrimWithDoubleKeyUpdate.json b/lib/server-test/src/test/resources/ESAllPrimWithDoubleKeyUpdate.json new file mode 100644 index 0000000..1669c77 --- /dev/null +++ b/lib/server-test/src/test/resources/ESAllPrimWithDoubleKeyUpdate.json @@ -0,0 +1,57 @@ +{ + "@context" : "$metadata#ESAllPrim", + "value" : [], + "value" : [{ + "PropertyInt16" : 32767, + "PropertyString" : "First Resource - positive values", + "PropertyBoolean" : true, + "PropertyByte" : 255, + "PropertySByte" : 127, + "PropertyInt32" : 2147483647, + "PropertyInt64" : 9223372036854775807, + "PropertySingle" : 1.79000000E+20, + "PropertyDouble" : -1.7900000000000000E+19, + "PropertyDecimal" : 34, + "PropertyBinary" : "ASNFZ4mrze8=", + "PropertyDate" : "2012-12-03", + "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", + "PropertyDuration" : "P0DT0H0M6S", + "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", + "PropertyTimeOfDay" : "03:26:05" + }, { + "PropertyInt16" : -32768, + "PropertyString" : "Second Resource - negative values", + "PropertyBoolean" : false, + "PropertyByte" : 0, + "PropertySByte" : -128, + "PropertyInt32" : -2147483648, + "PropertyInt64" : -9223372036854775808, + "PropertySingle" : -1.79000000E+08, + "PropertyDouble" : -1.7900000000000000E+05, + "PropertyDecimal" : -34, + "PropertyBinary" : "ASNFZ4mrze8=", + "PropertyDate" : "2015-11-05", + "PropertyDateTimeOffset" : "2005-12-03T07:17:08Z", + "PropertyDuration" : "P0DT0H0M9S", + "PropertyGuid" : "76543201-23ab-cdef-0123-456789dddfff", + "PropertyTimeOfDay" : "23:49:14" + }, { + "PropertyInt16" : 0, + "PropertyString" : "", + "PropertyBoolean" : false, + "PropertyByte" : 0, + "PropertySByte" : 0, + "PropertyInt32" : 0, + "PropertyInt64" : 0, + "PropertySingle" : 0.00000000E+00, + "PropertyDouble" : 0.0000000000000000E+00, + "PropertyDecimal" : 0, + "PropertyBinary" : "", + "PropertyDate" : "1970-01-01", + "PropertyDateTimeOffset" : "2005-12-03T00:00:00Z", + "PropertyDuration" : "P0DT0H0M0S", + "PropertyGuid" : "76543201-23ab-cdef-0123-456789cccddd", + "PropertyTimeOfDay" : "00:01:01" + } + ] +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-test/src/test/resources/ESAllPrimWithODataAnnotationsUpdate.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/ESAllPrimWithODataAnnotationsUpdate.json b/lib/server-test/src/test/resources/ESAllPrimWithODataAnnotationsUpdate.json new file mode 100644 index 0000000..af58c99 --- /dev/null +++ b/lib/server-test/src/test/resources/ESAllPrimWithODataAnnotationsUpdate.json @@ -0,0 +1,59 @@ +{ + "@context" : "$metadata#ESAllPrim", + "@count" : 3, + "@nextLink" : "http://localhost:8080/nextLink", + "@deltaLink" : "http://localhost:8080/deltaLink", + "value" : [{ + "PropertyInt16" : 32767, + "PropertyString" : "First Resource - positive values", + "PropertyBoolean" : true, + "PropertyByte" : 255, + "PropertySByte" : 127, + "PropertyInt32" : 2147483647, + "PropertyInt64" : 9223372036854775807, + "PropertySingle" : 1.79000000E+20, + "PropertyDouble" : -1.7900000000000000E+19, + "PropertyDecimal" : 34, + "PropertyBinary" : "ASNFZ4mrze8=", + "PropertyDate" : "2012-12-03", + "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", + "PropertyDuration" : "P0DT0H0M6S", + "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", + "PropertyTimeOfDay" : "03:26:05" + }, { + "PropertyInt16" : -32768, + "PropertyString" : "Second Resource - negative values", + "PropertyBoolean" : false, + "PropertyByte" : 0, + "PropertySByte" : -128, + "PropertyInt32" : -2147483648, + "PropertyInt64" : -9223372036854775808, + "PropertySingle" : -1.79000000E+08, + "PropertyDouble" : -1.7900000000000000E+05, + "PropertyDecimal" : -34, + "PropertyBinary" : "ASNFZ4mrze8=", + "PropertyDate" : "2015-11-05", + "PropertyDateTimeOffset" : "2005-12-03T07:17:08Z", + "PropertyDuration" : "P0DT0H0M9S", + "PropertyGuid" : "76543201-23ab-cdef-0123-456789dddfff", + "PropertyTimeOfDay" : "23:49:14" + }, { + "PropertyInt16" : 0, + "PropertyString" : "", + "PropertyBoolean" : false, + "PropertyByte" : 0, + "PropertySByte" : 0, + "PropertyInt32" : 0, + "PropertyInt64" : 0, + "PropertySingle" : 0.00000000E+00, + "PropertyDouble" : 0.0000000000000000E+00, + "PropertyDecimal" : 0, + "PropertyBinary" : "", + "PropertyDate" : "1970-01-01", + "PropertyDateTimeOffset" : "2005-12-03T00:00:00Z", + "PropertyDuration" : "P0DT0H0M0S", + "PropertyGuid" : "76543201-23ab-cdef-0123-456789cccddd", + "PropertyTimeOfDay" : "00:01:01" + } + ] +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-test/src/test/resources/ESCompCollCompUpdate.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/ESCompCollCompUpdate.json b/lib/server-test/src/test/resources/ESCompCollCompUpdate.json new file mode 100644 index 0000000..ec1abee --- /dev/null +++ b/lib/server-test/src/test/resources/ESCompCollCompUpdate.json @@ -0,0 +1,35 @@ +{ + "@context" : "$metadata#ESCompCollComp", + "value" : [{ + "PropertyInt16" : 32767, + "PropertyComp" : { + "CollPropertyComp" : [{ + "PropertyInt16" : 555, + "PropertyString" : "1 Test Complex in Complex Property" + }, { + "PropertyInt16" : 666, + "PropertyString" : "2 Test Complex in Complex property" + }, { + "PropertyInt16" : 777, + "PropertyString" : "3 Test Complex in Complex property" + } + ] + } + }, { + "PropertyInt16" : 12345, + "PropertyComp" : { + "CollPropertyComp" : [{ + "PropertyInt16" : 888, + "PropertyString" : "11 Test Complex in Complex property" + }, { + "PropertyInt16" : 999, + "PropertyString" : "12 Test Complex in Complex property" + }, { + "PropertyInt16" : 0, + "PropertyString" : "13 Test Complex in Complex property" + } + ] + } + } + ] +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyDelta.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyDelta.json b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyDelta.json new file mode 100644 index 0000000..9964e52 --- /dev/null +++ b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyDelta.json @@ -0,0 +1,48 @@ +{ + "@context" : "$metadata#ESAllPrim/$entity", + "PropertyInt16" : 32767, + "PropertyString" : "First Resource - positive values", + "PropertyBoolean" : true, + "PropertyByte" : 255, + "PropertySByte" : 127, + "PropertyInt32" : 2147483647, + "PropertyInt64" : 9223372036854775807, + "PropertySingle" : 1.79000000E+20, + "PropertyDouble" : -1.7900000000000000E+19, + "PropertyDecimal" : 34, + "PropertyBinary" : "ASNFZ4mrze8=", + "PropertyDate" : "2012-12-03", + "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", + "PropertyDuration" : "P0DT0H0M6S", + "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", + "PropertyTimeOfDay" : "03:26:05", + "NavPropertyETTwoPrimMany@delta" : [{ + "@removed": { + "reason": "deleted" + }, + "@id": "ESAllPrim(32767)" + }, + { + "@removed": { + "reason": "changed" + }, + "@id": "ESAllPrim(-365)" + }, + { + "@id": "ESAllPrim(5)" + }, + { + "@id": "ESAllPrim(6)", + "PropertyString" : "Test String2" + + }, + { + "PropertyInt16" : -365, + "PropertyString" : "Test String2" + } + ], + "NavPropertyETTwoPrimOne" : { + "@id" : "ESTwoPrim(32767)", + "PropertyString" : "Test String" + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyError.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyError.json b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyError.json new file mode 100644 index 0000000..4057780 --- /dev/null +++ b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyError.json @@ -0,0 +1,48 @@ +{ + "@context" : "$metadata#ESAllPrim/$entity", + "PropertyInt16" : 32767, + "PropertyString" : "First Resource - positive values", + "PropertyBoolean" : true, + "PropertyByte" : 255, + "PropertySByte" : 127, + "PropertyInt32" : 2147483647, + "PropertyInt64" : 9223372036854775807, + "PropertySingle" : 1.79000000E+20, + "PropertyDouble" : -1.7900000000000000E+19, + "PropertyDecimal" : 34, + "PropertyBinary" : "ASNFZ4mrze8=", + "PropertyDate" : "2012-12-03", + "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", + "PropertyDuration" : "P0DT0H0M6S", + "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", + "PropertyTimeOfDay" : "03:26:05", + "NavPropertyETTwoPrimMany@delta" : [{ + "@removed": { + "error": "deleted" + }, + "@id": "ESAllPrim(32767)" + }, + { + "@removed": { + "reason": "changed" + }, + "@id": "ESAllPrim(-365)" + }, + { + "@id": "ESAllPrim(5)" + }, + { + "@id": "ESAllPrim(6)", + "PropertyString" : "Test String2" + + }, + { + "PropertyInt16" : -365, + "PropertyString" : "Test String2" + } + ], + "NavPropertyETTwoPrimOne" : { + "@id" : "ESTwoPrim(32767)", + "PropertyString" : "Test String" + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyUpdate.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyUpdate.json b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyUpdate.json new file mode 100644 index 0000000..7475a13 --- /dev/null +++ b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyUpdate.json @@ -0,0 +1,28 @@ +{ + "@context" : "$metadata#ESAllPrim/$entity", + "PropertyInt16" : 32767, + "PropertyString" : "First Resource - positive values", + "PropertyBoolean" : true, + "PropertyByte" : 255, + "PropertySByte" : 127, + "PropertyInt32" : 2147483647, + "PropertyInt64" : 9223372036854775807, + "PropertySingle" : 1.79000000E+20, + "PropertyDouble" : -1.7900000000000000E+19, + "PropertyDecimal" : 34, + "PropertyBinary" : "ASNFZ4mrze8=", + "PropertyDate" : "2012-12-03", + "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", + "PropertyDuration" : "P0DT0H0M6S", + "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", + "PropertyTimeOfDay" : "03:26:05", + "NavPropertyETTwoPrimMany" : [{ + "PropertyInt16" : -365, + "PropertyString" : "Test String2" + }, + { + "@id" : "ESAllPrim(32767)", + "PropertyString" : "Test String" + } + ] +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyWithODataAnnotationsUpdate.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyWithODataAnnotationsUpdate.json b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyWithODataAnnotationsUpdate.json new file mode 100644 index 0000000..4ceaee1 --- /dev/null +++ b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimManyWithODataAnnotationsUpdate.json @@ -0,0 +1,27 @@ +{ + "@context" : "$metadata#ESAllPrim/$entity", + "PropertyInt16" : 32767, + "PropertyString" : "First Resource - positive values", + "PropertyBoolean" : true, + "PropertyByte" : 255, + "PropertySByte" : 127, + "PropertyInt32" : 2147483647, + "PropertyInt64" : 9223372036854775807, + "PropertySingle" : 1.79000000E+20, + "PropertyDouble" : -1.7900000000000000E+19, + "PropertyDecimal" : 34, + "PropertyBinary" : "ASNFZ4mrze8=", + "PropertyDate" : "2012-12-03", + "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", + "PropertyDuration" : "P0DT0H0M6S", + "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", + "PropertyTimeOfDay" : "03:26:05", + "NavPropertyETTwoPrimMany@context" : "http://localhost:8080/context", + "NavPropertyETTwoPrimMany@count" : 12, + "NavPropertyETTwoPrimMany@nextLink" : "http://localhost:8080/nextLink", + "NavPropertyETTwoPrimMany" : [{ + "PropertyInt16" : -365, + "PropertyString" : "Test String2" + } + ] +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOneUpdate.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOneUpdate.json b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOneUpdate.json new file mode 100644 index 0000000..5303bbf --- /dev/null +++ b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOneUpdate.json @@ -0,0 +1,23 @@ +{ + "@context" : "$metadata#ESAllPrim/$entity", + "PropertyInt16" : 32767, + "PropertyString" : "First Resource - positive values", + "PropertyBoolean" : true, + "PropertyByte" : 255, + "PropertySByte" : 127, + "PropertyInt32" : 2147483647, + "PropertyInt64" : 9223372036854775807, + "PropertySingle" : 1.79000000E+20, + "PropertyDouble" : -1.7900000000000000E+19, + "PropertyDecimal" : 34, + "PropertyBinary" : "ASNFZ4mrze8=", + "PropertyDate" : "2012-12-03", + "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", + "PropertyDuration" : "P0DT0H0M6S", + "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", + "PropertyTimeOfDay" : "03:26:05", + "NavPropertyETTwoPrimOne" : { + "PropertyInt16" : 32767, + "PropertyString" : "Test String4" + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOneWithODataAnnotationsUpdate.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOneWithODataAnnotationsUpdate.json b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOneWithODataAnnotationsUpdate.json new file mode 100644 index 0000000..b24f4b8 --- /dev/null +++ b/lib/server-test/src/test/resources/EntityESAllPrimExpandedNavPropertyETTwoPrimOneWithODataAnnotationsUpdate.json @@ -0,0 +1,26 @@ +{ + "@context" : "$metadata#ESAllPrim/$entity", + "PropertyInt16" : 32767, + "PropertyString" : "First Resource - positive values", + "PropertyBoolean" : true, + "PropertyByte" : 255, + "PropertySByte" : 127, + "PropertyInt32" : 2147483647, + "PropertyInt64" : 9223372036854775807, + "PropertySingle" : 1.79000000E+20, + "PropertyDouble" : -1.7900000000000000E+19, + "PropertyDecimal" : 34, + "PropertyBinary" : "ASNFZ4mrze8=", + "PropertyDate" : "2012-12-03", + "PropertyDateTimeOffset" : "2012-12-03T07:16:23Z", + "PropertyDuration" : "P0DT0H0M6S", + "PropertyGuid" : "01234567-89ab-cdef-0123-456789abcdef", + "PropertyTimeOfDay" : "03:26:05", + "NavPropertyETTwoPrimOne@context" : "http://localhost:8080/context", + "NavPropertyETTwoPrimOne@count" : 12, + "NavPropertyETTwoPrimOne@nextLink" : "http://localhost:8080/nextLink", + "NavPropertyETTwoPrimOne" : { + "PropertyInt16" : 32767, + "PropertyString" : "Test String4" + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-test/src/test/resources/EntityETMixEnumDefCollCompUpdate.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/EntityETMixEnumDefCollCompUpdate.json b/lib/server-test/src/test/resources/EntityETMixEnumDefCollCompUpdate.json new file mode 100644 index 0000000..f081ca8 --- /dev/null +++ b/lib/server-test/src/test/resources/EntityETMixEnumDefCollCompUpdate.json @@ -0,0 +1,24 @@ +{ + "PropertyEnumString" : "2", + "PropertyDefString" : "string", + "CollPropertyEnumString" : ["1", "2"], + "CollPropertyDefString" : ["string1", "string2"], + "PropertyCompMixedEnumDef" : { + "PropertyEnumString" : "2", + "PropertyDefString" : "string", + "CollPropertyEnumString" : ["1", "2"], + "CollPropertyDefString" : ["string1", "string2"] + }, + "CollPropertyCompMixedEnumDef" : [{ + "PropertyEnumString" : "2", + "PropertyDefString" : "string", + "CollPropertyEnumString" : ["1", "2"], + "CollPropertyDefString" : ["string1", "string2"] + }, { + "PropertyEnumString" : "2", + "PropertyDefString" : "string", + "CollPropertyEnumString" : ["1", "2"], + "CollPropertyDefString" : ["string1", "string2"] + } + ] +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-test/src/test/resources/EntityETMixEnumDefCollCompWithEnumStringsUpdate.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/EntityETMixEnumDefCollCompWithEnumStringsUpdate.json b/lib/server-test/src/test/resources/EntityETMixEnumDefCollCompWithEnumStringsUpdate.json new file mode 100644 index 0000000..0207d29 --- /dev/null +++ b/lib/server-test/src/test/resources/EntityETMixEnumDefCollCompWithEnumStringsUpdate.json @@ -0,0 +1,24 @@ +{ + "PropertyEnumString" : "String2", + "PropertyDefString" : "def", + "CollPropertyEnumString" : ["String1", "String2"], + "CollPropertyDefString" : ["def1", "def2"], + "PropertyCompMixedEnumDef" : { + "PropertyEnumString" : "String2", + "PropertyDefString" : "def", + "CollPropertyEnumString" : ["String1", "String2"], + "CollPropertyDefString" : ["def1", "def2"] + }, + "CollPropertyCompMixedEnumDef" : [{ + "PropertyEnumString" : "String2", + "PropertyDefString" : "def", + "CollPropertyEnumString" : ["String1", "String2"], + "CollPropertyDefString" : ["def1", "def2"] + }, { + "PropertyEnumString" : "String2", + "PropertyDefString" : "def", + "CollPropertyEnumString" : ["String1", "String2"], + "CollPropertyDefString" : ["def1", "def2"] + } + ] +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ec0358/lib/server-test/src/test/resources/UnbalancedESAllPrimFeedUpdate.json ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/resources/UnbalancedESAllPrimFeedUpdate.json b/lib/server-test/src/test/resources/UnbalancedESAllPrimFeedUpdate.json new file mode 100644 index 0000000..cdf8b24 --- /dev/null +++ b/lib/server-test/src/test/resources/UnbalancedESAllPrimFeedUpdate.json @@ -0,0 +1,23 @@ +{ + "@context": "$metadata#ESAllPrim\/$entity", + "@metadataEtag": "W\/\"4efd6576-89c0-487c-8d6c-584e2acbae16\"", + "PropertyInt16": 1, + "NavPropertyETTwoPrimMany": [ + { + "PropertyInt16": 2, + "NavPropertyETAllPrimOne": { + "PropertyInt16": 3 + } + }, + { + "PropertyInt16": 2, + "NavPropertyETAllPrimOne": { + "PropertyInt16": 3, + "NavPropertyETTwoPrimOne": { + "PropertyInt16": 32766, + "PropertyString": "Innermost Entry" + } + } + } + ] +} \ No newline at end of file