[OLINGO-964] Add test for new expand type cast handling
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/bde34e59 Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/bde34e59 Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/bde34e59 Branch: refs/heads/master Commit: bde34e597fee96e8288f496556bb272a572a13fd Parents: 8a10f47 Author: Christian Amend <[email protected]> Authored: Thu Jul 28 14:53:44 2016 +0200 Committer: Christian Amend <[email protected]> Committed: Thu Jul 28 14:53:44 2016 +0200 ---------------------------------------------------------------------- .../core/uri/parser/TestFullResourcePath.java | 17 +++++++++++++++-- .../core/uri/testutil/ResourceValidator.java | 6 ++++++ 2 files changed, 21 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bde34e59/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/TestFullResourcePath.java ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/TestFullResourcePath.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/TestFullResourcePath.java index d60e6c3..82335a3 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/TestFullResourcePath.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/TestFullResourcePath.java @@ -2716,6 +2716,19 @@ public class TestFullResourcePath { .n() .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false); + testUri.run("ESKeyNav", "$expand=NavPropertyETTwoKeyNavMany/Namespace1_Alias.ETBaseTwoKeyNav" + + "($expand=NavPropertyETBaseTwoKeyNavOne)") + .isKind(UriInfoKind.resource) + .goExpand().goPath().first() + .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, true) + .isType(EntityTypeProvider.nameETTwoKeyNav, true) + .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav) + .goUpExpandValidator() + // go to the expand options of the current expand + .goExpand() + .goPath().first() + .isNavProperty("NavPropertyETBaseTwoKeyNavOne", EntityTypeProvider.nameETBaseTwoKeyNav, false); + testUri.run("ESKeyNav(1)", "$expand=NavPropertyETKeyNavMany/$ref,NavPropertyETTwoKeyNavMany($skip=2;$top=1)") .isKind(UriInfoKind.resource) .goExpand().first() @@ -5848,9 +5861,9 @@ public class TestFullResourcePath { testFilter.runOnETKeyNavEx("PropertyInt16 gt @alias") .isInAliasToValueMap("@alias", null); testFilter.runOnETKeyNavEx("PropertyInt16 gt @alias&@alias=@alias") - .isInAliasToValueMap("@alias", "@alias"); + .isInAliasToValueMap("@alias", "@alias"); testFilter.runOnETKeyNavEx("@alias&@alias=@alias2&@alias2=true or @alias") - .isInAliasToValueMap("@alias", "@alias2"); + .isInAliasToValueMap("@alias", "@alias2"); } @Test http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/bde34e59/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java index 90ac68c..2bcdbc1 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java @@ -223,6 +223,9 @@ public class ResourceValidator implements TestValidator { // input parameter type may be null in order to assert that the singleTypeFilter is not set EdmType actualType = uriPathInfoKeyPred.getTypeFilterOnEntry(); + if(actualType == null && type != null){ + fail("Expected an entry type filter of type: " + type.getFullQualifiedNameAsString()); + } assertEquals(type, type == null ? actualType : actualType.getFullQualifiedName()); return this; @@ -235,6 +238,9 @@ public class ResourceValidator implements TestValidator { // input parameter type may be null in order to assert that the collectionTypeFilter is not set EdmType actualType = uriPathInfoKeyPred.getTypeFilterOnCollection(); + if(actualType == null && expectedType != null){ + fail("Expected an collection type filter of type: " + expectedType.getFullQualifiedNameAsString()); + } assertEquals(expectedType, expectedType == null || actualType == null ? actualType : actualType.getFullQualifiedName());
