You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2015/10/26 09:07:29 UTC
[2/4] olingo-odata4 git commit: [OLINGO-806] Minor clean-up
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/837c3565/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
index b115fb8..a94bf13 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
@@ -19,18 +19,18 @@
package org.apache.olingo.server.core.uri.antlr;
import java.util.Arrays;
+import java.util.Collections;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.core.Encoder;
-import org.apache.olingo.commons.core.edm.EdmProviderImpl;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.edmx.EdmxReference;
import org.apache.olingo.server.api.uri.UriInfoKind;
import org.apache.olingo.server.api.uri.UriResourceKind;
import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
import org.apache.olingo.server.core.uri.parser.UriParserException;
import org.apache.olingo.server.core.uri.parser.UriParserSemanticException;
import org.apache.olingo.server.core.uri.parser.UriParserSyntaxException;
-import org.apache.olingo.server.core.uri.testutil.EdmTechTestProvider;
import org.apache.olingo.server.core.uri.testutil.FilterValidator;
import org.apache.olingo.server.core.uri.testutil.ResourceValidator;
import org.apache.olingo.server.core.uri.testutil.TestUriValidator;
@@ -38,15 +38,20 @@ import org.apache.olingo.server.core.uri.validator.UriValidationException;
import org.apache.olingo.server.tecsvc.provider.ActionProvider;
import org.apache.olingo.server.tecsvc.provider.ComplexTypeProvider;
import org.apache.olingo.server.tecsvc.provider.ContainerProvider;
+import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
import org.apache.olingo.server.tecsvc.provider.EntityTypeProvider;
import org.apache.olingo.server.tecsvc.provider.PropertyProvider;
import org.junit.Test;
public class TestUriParserImpl {
- Edm edm = null;
+ private final Edm edm = OData.newInstance().createServiceMetadata(
+ new EdmTechProvider(), Collections.<EdmxReference> emptyList()).getEdm();
+ private final TestUriValidator testUri = new TestUriValidator().setEdm(edm);
+ private final ResourceValidator testRes = new ResourceValidator().setEdm(edm);
+ private final FilterValidator testFilter = new FilterValidator().setEdm(edm);
+
private final String PropertyBoolean = "PropertyBoolean=true";
private final String PropertyByte = "PropertyByte=1";
-
private final String PropertyDate = "PropertyDate=2013-09-25";
private final String PropertyDateTimeOffset = "PropertyDateTimeOffset=2002-10-10T12:00:00-05:00";
private final String PropertyDecimal = "PropertyDecimal=12";
@@ -63,17 +68,6 @@ public class TestUriParserImpl {
+ "," + PropertySByte + "," + PropertyInt32 + "," + PropertyInt64 + "," + PropertyDecimal + "," + PropertyDate
+ "," + PropertyDateTimeOffset + "," + PropertyDuration + "," + PropertyGuid + "," + PropertyTimeOfDay;
- TestUriValidator testUri = null;
- ResourceValidator testRes = null;
- FilterValidator testFilter = null;
-
- public TestUriParserImpl() {
- edm = new EdmProviderImpl(new EdmTechTestProvider());
- testUri = new TestUriValidator().setEdm(edm);
- testRes = new ResourceValidator().setEdm(edm);
- testFilter = new FilterValidator().setEdm(edm);
- }
-
@Test
public void testBoundFunctionImport_VarParameters() {
@@ -350,7 +344,7 @@ public class TestUriParserImpl {
.isKeyPredicate(1, "PropertyString", "'ABC'");
// with all keys
- testRes.run("ESAllKey(" + Encoder.encode(allKeys) + ")")
+ testRes.run("ESAllKey(" + encode(allKeys) + ")")
.isEntitySet("ESAllKey")
.isKeyPredicate(0, "PropertyString", "'ABC'")
.isKeyPredicate(1, "PropertyInt16", "1")
@@ -569,34 +563,46 @@ public class TestUriParserImpl {
@Test
public void testUnary() throws UriParserException {
- testFilter.runESabc("not a").isCompr("<not <a>>");
- testFilter.runESabc("- a eq a").isCompr("<<- <a>> eq <a>>");
- testFilter.runESabc("-a eq a").isCompr("<<- <a>> eq <a>>");
+ testFilter.runOnETAllPrim("not PropertyBoolean").isCompr("<not <PropertyBoolean>>");
+ testFilter.runOnETAllPrim("- PropertyInt16 eq PropertyInt16").isCompr("<<- <PropertyInt16>> eq <PropertyInt16>>");
+ testFilter.runOnETAllPrim("-PropertyInt16 eq PropertyInt16").isCompr("<<- <PropertyInt16>> eq <PropertyInt16>>");
}
@Test
public void testFilterComplexMixedPriority() throws UriParserException {
- testFilter.runESabc("a or c and e ").isCompr("< <a> or < <c> and <e> >>");
- testFilter.runESabc("a or c and e eq f").isCompr("< <a> or < <c> and <<e> eq <f>>>>");
- testFilter.runESabc("a or c eq d and e ").isCompr("< <a> or <<<c> eq <d>> and <e> >>");
- testFilter.runESabc("a or c eq d and e eq f").isCompr("< <a> or <<<c> eq <d>> and <<e> eq <f>>>>");
- testFilter.runESabc("a eq b or c and e ").isCompr("<<<a> eq <b>> or < <c> and <e> >>");
- testFilter.runESabc("a eq b or c and e eq f").isCompr("<<<a> eq <b>> or < <c> and <<e> eq <f>>>>");
- testFilter.runESabc("a eq b or c eq d and e ").isCompr("<<<a> eq <b>> or <<<c> eq <d>> and <e> >>");
- testFilter.runESabc("a eq b or c eq d and e eq f").isCompr("<<<a> eq <b>> or <<<c> eq <d>> and <<e> eq <f>>>>");
+ testFilter.runOnETAllPrim("PropertyInt16 or PropertyInt32 and PropertyInt64")
+ .isCompr("<<PropertyInt16> or <<PropertyInt32> and <PropertyInt64>>>");
+ testFilter.runOnETAllPrim("PropertyInt16 or PropertyInt32 and PropertyInt64 eq PropertyByte")
+ .isCompr("<<PropertyInt16> or <<PropertyInt32> and <<PropertyInt64> eq <PropertyByte>>>>");
+ testFilter.runOnETAllPrim("PropertyInt16 or PropertyInt32 eq PropertyInt64 and PropertyByte")
+ .isCompr("<<PropertyInt16> or <<<PropertyInt32> eq <PropertyInt64>> and <PropertyByte>>>");
+ testFilter.runOnETAllPrim("PropertyInt16 or PropertyInt32 eq PropertyInt64 and PropertyByte eq PropertySByte")
+ .isCompr("<<PropertyInt16> or <<<PropertyInt32> eq <PropertyInt64>> "
+ + "and <<PropertyByte> eq <PropertySByte>>>>");
+ testFilter.runOnETAllPrim("PropertyInt16 eq PropertyInt32 or PropertyInt64 and PropertyByte")
+ .isCompr("<<<PropertyInt16> eq <PropertyInt32>> or <<PropertyInt64> and <PropertyByte>>>");
+ testFilter.runOnETAllPrim("PropertyInt16 eq PropertyInt32 or PropertyInt64 and PropertyByte eq PropertySByte")
+ .isCompr("<<<PropertyInt16> eq <PropertyInt32>> "
+ + "or <<PropertyInt64> and <<PropertyByte> eq <PropertySByte>>>>");
+ testFilter.runOnETAllPrim("PropertyInt16 eq PropertyInt32 or PropertyInt64 eq PropertyByte and PropertySByte")
+ .isCompr("<<<PropertyInt16> eq <PropertyInt32>> "
+ + "or <<<PropertyInt64> eq <PropertyByte>> and <PropertySByte>>>");
+ testFilter.runOnETAllPrim("PropertyInt16 eq PropertyInt32 or PropertyInt64 eq PropertyByte "
+ + "and PropertySByte eq PropertyDecimal")
+ .isCompr("<<<PropertyInt16> eq <PropertyInt32>> or <<<PropertyInt64> eq <PropertyByte>> "
+ + "and <<PropertySByte> eq <PropertyDecimal>>>>");
}
@Test
public void testFilterSimpleSameBinaryBinaryBinaryPriority() throws UriParserException {
-
- testFilter.runESabc("1 add 2 add 3 add 4").isCompr("<<< <1> add <2>> add <3>> add <4>>");
- testFilter.runESabc("1 add 2 add 3 div 4").isCompr("<< <1> add <2>> add <<3> div <4>>>");
- testFilter.runESabc("1 add 2 div 3 add 4").isCompr("<< <1> add <<2> div <3>>> add <4>>");
- testFilter.runESabc("1 add 2 div 3 div 4").isCompr("< <1> add <<<2> div <3>> div <4>>>");
- testFilter.runESabc("1 div 2 add 3 add 4").isCompr("<<< <1> div <2>> add <3>> add <4>>");
- testFilter.runESabc("1 div 2 add 3 div 4").isCompr("<< <1> div <2>> add <<3> div <4>>>");
- testFilter.runESabc("1 div 2 div 3 add 4").isCompr("<<< <1> div <2>> div <3>> add <4>>");
- testFilter.runESabc("1 div 2 div 3 div 4").isCompr("<<< <1> div <2>> div <3>> div <4>>");
+ testFilter.runOnETAllPrim("1 add 2 add 3 add 4").isCompr("<<< <1> add <2>> add <3>> add <4>>");
+ testFilter.runOnETAllPrim("1 add 2 add 3 div 4").isCompr("<< <1> add <2>> add <<3> div <4>>>");
+ testFilter.runOnETAllPrim("1 add 2 div 3 add 4").isCompr("<< <1> add <<2> div <3>>> add <4>>");
+ testFilter.runOnETAllPrim("1 add 2 div 3 div 4").isCompr("< <1> add <<<2> div <3>> div <4>>>");
+ testFilter.runOnETAllPrim("1 div 2 add 3 add 4").isCompr("<<< <1> div <2>> add <3>> add <4>>");
+ testFilter.runOnETAllPrim("1 div 2 add 3 div 4").isCompr("<< <1> div <2>> add <<3> div <4>>>");
+ testFilter.runOnETAllPrim("1 div 2 div 3 add 4").isCompr("<<< <1> div <2>> div <3>> add <4>>");
+ testFilter.runOnETAllPrim("1 div 2 div 3 div 4").isCompr("<<< <1> div <2>> div <3>> div <4>>");
}
@Test
@@ -1164,4 +1170,8 @@ public class TestUriParserImpl {
testUri.runEx("ESMixPrimCollComp", "$select=/PropertyInt16")
.isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
}
+
+ private final String encode(final String uriPart) {
+ return uriPart.replaceAll(":", "%3A");
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/837c3565/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ParserTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ParserTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ParserTest.java
index e27289d..3d67c48 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ParserTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/ParserTest.java
@@ -54,6 +54,7 @@ public class ParserTest {
EdmNavigationProperty productsNavigation = Mockito.mock(EdmNavigationProperty.class);
EdmEntityType productsType = Mockito.mock(EdmEntityType.class);
+ final FullQualifiedName nameProducts = new FullQualifiedName("NS", "Products");
Mockito.when(mockEdm.getEntityContainer(null)).thenReturn(container);
Mockito.when(typeCategory.getName()).thenReturn("Category");
Mockito.when(typeCategory.getNamespace()).thenReturn("NS");
@@ -62,7 +63,7 @@ public class ParserTest {
Mockito.when(typeCategory.getProperty("Products")).thenReturn(productsNavigation);
Mockito.when(container.getEntitySet("Category")).thenReturn(esCategory);
Mockito.when(container.getEntitySet("Products")).thenReturn(esProduct);
- Mockito.when(productsType.getName()).thenReturn("Products");
+ Mockito.when(productsType.getFullQualifiedName()).thenReturn(nameProducts);
Mockito.when(productsType.getNamespace()).thenReturn("NS");
Mockito.when(productsNavigation.getType()).thenReturn(productsType);
@@ -72,13 +73,13 @@ public class ParserTest {
.isKind(UriInfoKind.resource).goPath().goExpand()
.first()
.goPath().first()
- .isNavProperty("Products", new FullQualifiedName("NS", "Products"), false)
- .isType(new FullQualifiedName("NS", "Products"), false);
+ .isNavProperty("Products", nameProducts, false)
+ .isType(nameProducts, false);
Mockito.verifyZeroInteractions(esProduct);
}
/**
- * Test for EntitySet with navigation to an not existing NavigationProperty (name)
+ * Test for EntitySet with navigation to a not existing NavigationProperty (name)
* but with another EntitySet with this name defined in metadata.
* (related to Olingo issue OLINGO-755)
*/
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/837c3565/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/QueryOptionTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/QueryOptionTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/QueryOptionTest.java
index 27212ee..93cdf86 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/QueryOptionTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/QueryOptionTest.java
@@ -19,32 +19,32 @@
package org.apache.olingo.server.core.uri.queryoption;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
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.FullQualifiedName;
-import org.apache.olingo.commons.core.edm.EdmProviderImpl;
import org.apache.olingo.server.api.uri.UriInfoResource;
+import org.apache.olingo.server.api.uri.queryoption.SelectItem;
+import org.apache.olingo.server.api.uri.queryoption.SystemQueryOption;
import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
+import org.apache.olingo.server.api.uri.queryoption.expression.Expression;
import org.apache.olingo.server.core.uri.UriInfoImpl;
import org.apache.olingo.server.core.uri.queryoption.expression.AliasImpl;
-import org.apache.olingo.server.core.uri.queryoption.expression.ExpressionImpl;
import org.apache.olingo.server.core.uri.queryoption.expression.LiteralImpl;
-import org.apache.olingo.server.core.uri.testutil.EdmTechTestProvider;
import org.junit.Test;
//TOOD add getKind check to all
public class QueryOptionTest {
- Edm edm = new EdmProviderImpl(new EdmTechTestProvider());
-
@Test
public void testAliasQueryOption() {
AliasQueryOptionImpl option = new AliasQueryOptionImpl();
- ExpressionImpl expression = new LiteralImpl();
+ Expression expression = new LiteralImpl();
option.setAliasValue(expression);
assertEquals(expression, option.getValue());
@@ -90,7 +90,7 @@ public class QueryOptionTest {
option.setSystemQueryOption(new IdOptionImpl());
option = new ExpandItemImpl();
- List<SystemQueryOptionImpl> list = new ArrayList<SystemQueryOptionImpl>();
+ List<SystemQueryOption> list = new ArrayList<SystemQueryOption>();
list.add(expand);
list.add(filter);
option.setSystemQueryOptions(list);
@@ -98,14 +98,14 @@ public class QueryOptionTest {
assertEquals(filter, option.getFilterOption());
option = new ExpandItemImpl();
- assertEquals(false, option.isRef());
+ assertFalse(option.isRef());
option.setIsRef(true);
- assertEquals(true, option.isRef());
+ assertTrue(option.isRef());
option = new ExpandItemImpl();
- assertEquals(false, option.isStar());
+ assertFalse(option.isStar());
option.setIsStar(true);
- assertEquals(true, option.isStar());
+ assertTrue(option.isStar());
option = new ExpandItemImpl();
UriInfoResource resource = new UriInfoImpl().asUriInfoResource();
@@ -144,7 +144,6 @@ public class QueryOptionTest {
assertEquals(SystemQueryOptionKind.FORMAT, option.getKind());
option.setFormat("A");
-
assertEquals("A", option.getFormat());
}
@@ -154,7 +153,6 @@ public class QueryOptionTest {
assertEquals(SystemQueryOptionKind.ID, option.getKind());
option.setValue("A");
-
assertEquals("A", option.getValue());
}
@@ -163,9 +161,9 @@ public class QueryOptionTest {
CountOptionImpl option = new CountOptionImpl();
assertEquals(SystemQueryOptionKind.COUNT, option.getKind());
- assertEquals(false, option.getValue());
+ assertFalse(option.getValue());
option.setValue(true);
- assertEquals(true, option.getValue());
+ assertTrue(option.getValue());
}
@Test
@@ -179,7 +177,7 @@ public class QueryOptionTest {
option = new LevelsOptionImpl();
option.setMax();
- assertEquals(true, option.isMax());
+ assertTrue(option.isMax());
}
@Test
@@ -190,9 +188,9 @@ public class QueryOptionTest {
option.setExpression(expression);
assertEquals(expression, option.getExpression());
- assertEquals(false, option.isDescending());
+ assertFalse(option.isDescending());
option.setDescending(true);
- assertEquals(true, option.isDescending());
+ assertTrue(option.isDescending());
}
@Test
@@ -233,17 +231,16 @@ public class QueryOptionTest {
option = new SelectItemImpl();
option = new SelectItemImpl();
- assertEquals(false, option.isStar());
+ assertFalse(option.isStar());
option.setStar(true);
- assertEquals(true, option.isStar());
+ assertTrue(option.isStar());
option = new SelectItemImpl();
- assertEquals(false, option.isAllOperationsInSchema());
+ assertFalse(option.isAllOperationsInSchema());
FullQualifiedName fqName = new FullQualifiedName("Namespace", "Name");
option.addAllOperationsInSchema(fqName);
- assertEquals(true, option.isAllOperationsInSchema());
+ assertTrue(option.isAllOperationsInSchema());
assertEquals(fqName, option.getAllOperationsInSchemaNameSpace());
-
}
@Test
@@ -251,17 +248,12 @@ public class QueryOptionTest {
SelectOptionImpl option = new SelectOptionImpl();
assertEquals(SystemQueryOptionKind.SELECT, option.getKind());
- SelectItemImpl item0 = new SelectItemImpl();
- SelectItemImpl item1 = new SelectItemImpl();
-
- ArrayList<SelectItemImpl> list = new ArrayList<SelectItemImpl>();
- list.add(item0);
- list.add(item1);
- option.setSelectItems(list);
+ SelectItem item0 = new SelectItemImpl();
+ SelectItem item1 = new SelectItemImpl();
+ option.setSelectItems(Arrays.asList(item0, item1));
assertEquals(item0, option.getSelectItems().get(0));
assertEquals(item1, option.getSelectItems().get(1));
-
}
@Test
@@ -284,11 +276,8 @@ public class QueryOptionTest {
@Test
public void testSystemQueryOptionImpl() {
- SystemQueryOptionImpl option = new SystemQueryOptionImpl();
-
- option.setKind(SystemQueryOptionKind.EXPAND);
+ SystemQueryOptionImpl option = new ExpandOptionImpl();
assertEquals(SystemQueryOptionKind.EXPAND, option.getKind());
-
assertEquals("$expand", option.getName());
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/837c3565/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java
index 98abf20..e8a9b38 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java
@@ -24,14 +24,16 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
+import java.util.Collections;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAction;
import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.commons.api.edm.EdmFunction;
-import org.apache.olingo.commons.core.edm.EdmProviderImpl;
+import org.apache.olingo.server.api.OData;
import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.edmx.EdmxReference;
import org.apache.olingo.server.api.uri.UriInfoKind;
import org.apache.olingo.server.api.uri.UriInfoResource;
import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
@@ -41,16 +43,17 @@ import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind
import org.apache.olingo.server.core.uri.UriInfoImpl;
import org.apache.olingo.server.core.uri.UriResourceActionImpl;
import org.apache.olingo.server.core.uri.UriResourceFunctionImpl;
-import org.apache.olingo.server.core.uri.testutil.EdmTechTestProvider;
import org.apache.olingo.server.core.uri.testutil.FilterTreeToText;
import org.apache.olingo.server.tecsvc.provider.ActionProvider;
+import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
import org.apache.olingo.server.tecsvc.provider.EntityTypeProvider;
import org.apache.olingo.server.tecsvc.provider.EnumTypeProvider;
import org.apache.olingo.server.tecsvc.provider.FunctionProvider;
import org.junit.Test;
public class ExpressionTest {
- Edm edm = new EdmProviderImpl(new EdmTechTestProvider());
+ private static final Edm edm = OData.newInstance().createServiceMetadata(
+ new EdmTechProvider(), Collections.<EdmxReference> emptyList()).getEdm();
@Test
public void testSupportedOperators() {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/837c3565/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/EdmTechTestProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/EdmTechTestProvider.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/EdmTechTestProvider.java
deleted file mode 100644
index 08c6c91..0000000
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/EdmTechTestProvider.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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.uri.testutil;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.olingo.commons.api.ex.ODataException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.provider.CsdlComplexType;
-import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet;
-import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;
-import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty;
-import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
-import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef;
-import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
-
-/**
- * Implement the EdmTechProvider and
- * <li>adds a entity type <b>ETabc with</b> properties a,b,c,d,e,f</li>
- * <li>adds a entity type <b>ETNavProp with</b> with a navigation property ESNavProp (named like the entity set)</li>
- * <li>adds a complex type <b>CTabc</b> with properties a,b,c,d,e,f</li>
- * <li>adds a <b>abc</b> entity set of type <b>ETabc</b></li>
- * <li>adds a <b>ESNavProp</b> entity set of type <b>ETNavProp</b></li>
- */
-public class EdmTechTestProvider extends EdmTechProvider {
-
- private static final FullQualifiedName nameInt16 = EdmPrimitiveTypeKind.Int16.getFullQualifiedName();
- public static final String NAMESPACE = "olingo.odata.test1";
- public static final FullQualifiedName nameContainer = new FullQualifiedName(NAMESPACE, "Container");
-
- CsdlProperty propertyAInt16 = new CsdlProperty().setName("a").setType(nameInt16);
- CsdlProperty propertyBInt16 = new CsdlProperty().setName("b").setType(nameInt16);
- CsdlProperty propertyCInt16 = new CsdlProperty().setName("c").setType(nameInt16);
- CsdlProperty propertyDInt16 = new CsdlProperty().setName("d").setType(nameInt16);
- CsdlProperty propertyEInt16 = new CsdlProperty().setName("e").setType(nameInt16);
- CsdlProperty propertyFInt16 = new CsdlProperty().setName("f").setType(nameInt16);
-
- public static final FullQualifiedName nameETNavProp = new FullQualifiedName(NAMESPACE, "ETNavProp");
- public static final FullQualifiedName nameCTabc = new FullQualifiedName(NAMESPACE, "CTabc");
- public static final FullQualifiedName nameETabc = new FullQualifiedName(NAMESPACE, "ETabc");
-
- @Override
- public CsdlComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException {
- if (complexTypeName.equals(nameCTabc)) {
- return new CsdlComplexType()
- .setName("CTabc")
- .setProperties(Arrays.asList(
- propertyAInt16, propertyBInt16, propertyCInt16,
- propertyDInt16, propertyEInt16, propertyFInt16
- ));
-
- }
-
- return super.getComplexType(complexTypeName);
- }
-
- @Override
- public CsdlEntitySet getEntitySet(final FullQualifiedName entityContainer, final String name) throws ODataException {
- if (nameContainer.equals(entityContainer)) {
- if (name.equals("ESabc")) {
- return new CsdlEntitySet()
- .setName("ESabc")
- .setType(nameETabc);
- } else if(name.equals("ESNavProp")) {
- return new CsdlEntitySet()
- .setName("ESNavProp")
- .setType(nameETNavProp);
- }
- }
-
- return super.getEntitySet(entityContainer, name);
- }
-
- @Override
- public CsdlEntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException {
- List<CsdlPropertyRef> oneKeyPropertyInt16 = Arrays.asList(new CsdlPropertyRef().setName("a"));
-
- if (entityTypeName.equals(nameETabc)) {
- return new CsdlEntityType()
- .setName("ETabc")
- .setProperties(Arrays.asList(
- propertyAInt16, propertyBInt16, propertyCInt16,
- propertyDInt16, propertyEInt16, propertyFInt16))
- .setKey(oneKeyPropertyInt16);
- } else if(entityTypeName.equals(nameETNavProp)) {
- return new CsdlEntityType()
- .setName("ETNavProp")
- .setProperties(Arrays.asList(propertyAInt16))
- .setKey(oneKeyPropertyInt16)
- .setNavigationProperties(Arrays.asList(new CsdlNavigationProperty[] {
- new CsdlNavigationProperty()
- .setCollection(true)
- .setName("ESNavProp")
- .setType(nameETNavProp)
- }));
- }
-
- return super.getEntityType(entityTypeName);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/837c3565/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
index bc038cd..5638227 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
@@ -23,28 +23,23 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmType;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.server.api.ODataApplicationException;
-import org.apache.olingo.server.api.uri.UriInfoKind;
import org.apache.olingo.server.api.uri.queryoption.ExpandItem;
+import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
import org.apache.olingo.server.api.uri.queryoption.FilterOption;
+import org.apache.olingo.server.api.uri.queryoption.OrderByOption;
import org.apache.olingo.server.api.uri.queryoption.QueryOption;
import org.apache.olingo.server.api.uri.queryoption.SelectItem;
import org.apache.olingo.server.api.uri.queryoption.SelectOption;
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
-import org.apache.olingo.server.core.uri.UriInfoImpl;
-import org.apache.olingo.server.core.uri.queryoption.ExpandOptionImpl;
-import org.apache.olingo.server.core.uri.queryoption.OrderByOptionImpl;
-import org.apache.olingo.server.core.uri.queryoption.QueryOptionImpl;
-import org.apache.olingo.server.core.uri.queryoption.SelectOptionImpl;
public class ExpandValidator implements TestValidator {
private Edm edm;
private TestValidator invokedByValidator;
private int expandItemIndex;
- private ExpandOptionImpl expandOption;
+ private ExpandOption expandOption;
private ExpandItem expandItem;
// --- Setup ---
@@ -54,7 +49,7 @@ public class ExpandValidator implements TestValidator {
return this;
}
- public ExpandValidator setExpand(final ExpandOptionImpl expand) {
+ public ExpandValidator setExpand(final ExpandOption expand) {
expandOption = expand;
first();
return this;
@@ -76,45 +71,33 @@ public class ExpandValidator implements TestValidator {
}
public ResourceValidator goPath() {
- UriInfoImpl uriInfo = (UriInfoImpl) expandItem.getResourcePath();
-
- if (uriInfo.getKind() != UriInfoKind.resource) {
- fail("goPath() can only be used on UriInfoKind.resource");
- }
-
return new ResourceValidator()
- .setUpValidator(this)
- .setEdm(edm)
- .setUriInfoImplPath(uriInfo);
-
+ .setUpValidator(this)
+ .setEdm(edm)
+ .setUriInfoPath(expandItem.getResourcePath());
}
public FilterValidator goOrder(final int index) {
- OrderByOptionImpl orderBy = (OrderByOptionImpl) expandItem.getOrderByOption();
-
+ final OrderByOption orderBy = expandItem.getOrderByOption();
return new FilterValidator()
- .setValidator(this)
- .setEdm(edm)
- .setExpression(orderBy.getOrders().get(index).getExpression());
+ .setValidator(this)
+ .setEdm(edm)
+ .setExpression(orderBy.getOrders().get(index).getExpression());
}
public ResourceValidator goSelectItem(final int index) {
- SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
-
+ final SelectOption select = expandItem.getSelectOption();
SelectItem item = select.getSelectItems().get(index);
- UriInfoImpl uriInfo = (UriInfoImpl) item.getResourcePath();
-
return new ResourceValidator()
- .setUpValidator(this)
- .setEdm(edm)
- .setUriInfoImplPath(uriInfo);
-
+ .setUpValidator(this)
+ .setEdm(edm)
+ .setUriInfoPath(item.getResourcePath());
}
public ExpandValidator goExpand() {
return new ExpandValidator()
- .setExpand((ExpandOptionImpl) expandItem.getExpandOption())
- .setUpValidator(this);
+ .setExpand(expandItem.getExpandOption())
+ .setUpValidator(this);
}
public ExpandValidator first() {
@@ -132,7 +115,6 @@ public class ExpandValidator implements TestValidator {
fail("not enough segments");
}
return this;
-
}
public ExpandValidator isSegmentStar() {
@@ -146,31 +128,31 @@ public class ExpandValidator implements TestValidator {
}
public ExpandValidator isLevelText(final String text) {
- QueryOptionImpl option = (QueryOptionImpl) expandItem.getLevelsOption();
+ final QueryOption option = (QueryOption) expandItem.getLevelsOption();
assertEquals(text, option.getText());
return this;
}
public ExpandValidator isSkipText(final String text) {
- QueryOptionImpl option = (QueryOptionImpl) expandItem.getSkipOption();
+ final QueryOption option = expandItem.getSkipOption();
assertEquals(text, option.getText());
return this;
}
public ExpandValidator isTopText(final String text) {
- QueryOptionImpl option = (QueryOptionImpl) expandItem.getTopOption();
+ final QueryOption option = expandItem.getTopOption();
assertEquals(text, option.getText());
return this;
}
public ExpandValidator isInlineCountText(final String text) {
- QueryOptionImpl option = (QueryOptionImpl) expandItem.getCountOption();
+ final QueryOption option = expandItem.getCountOption();
assertEquals(text, option.getText());
return this;
}
public ExpandValidator isSelectText(final String text) {
- QueryOptionImpl option = (QueryOptionImpl) expandItem.getSelectOption();
+ final QueryOption option = expandItem.getSelectOption();
assertEquals(text, option.getText());
return this;
}
@@ -213,18 +195,13 @@ public class ExpandValidator implements TestValidator {
}
public ExpandValidator isSortOrder(final int index, final boolean descending) {
- OrderByOptionImpl orderBy = (OrderByOptionImpl) expandItem.getOrderByOption();
+ OrderByOption orderBy = expandItem.getOrderByOption();
assertEquals(descending, orderBy.getOrders().get(index).isDescending());
return this;
}
public ExpandValidator isExpandStartType(final FullQualifiedName fullName) {
- EdmType actualType = expandItem.getStartTypeFilter();
-
- FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
- assertEquals(fullName, actualName);
+ assertEquals(fullName, expandItem.getStartTypeFilter().getFullQualifiedName());
return this;
-
}
-
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/837c3565/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
index 14ddbc6..96a3226 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
@@ -127,7 +127,7 @@ public class FilterTreeToText implements ExpressionVisitor<String> {
@Override
public String visitTypeLiteral(final EdmType type) {
- return "<" + type.getNamespace() + "." + type.getName() + ">";
+ return "<" + type.getFullQualifiedName().getFullQualifiedNameAsString() + ">";
}
@Override
@@ -147,7 +147,7 @@ public class FilterTreeToText implements ExpressionVisitor<String> {
tmp += item;
}
- return "<" + type.getNamespace() + "." + type.getName() + "<" + tmp + ">>";
+ return "<" + type.getFullQualifiedName().getFullQualifiedNameAsString() + "<" + tmp + ">>";
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/837c3565/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
index 02cf29e..ad9d4eb 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
@@ -31,36 +31,33 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.server.api.ODataApplicationException;
import org.apache.olingo.server.api.uri.UriInfo;
import org.apache.olingo.server.api.uri.UriInfoKind;
+import org.apache.olingo.server.api.uri.queryoption.FilterOption;
+import org.apache.olingo.server.api.uri.queryoption.OrderByOption;
+import org.apache.olingo.server.api.uri.queryoption.expression.Binary;
import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
+import org.apache.olingo.server.api.uri.queryoption.expression.Enumeration;
import org.apache.olingo.server.api.uri.queryoption.expression.Expression;
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
+import org.apache.olingo.server.api.uri.queryoption.expression.Literal;
import org.apache.olingo.server.api.uri.queryoption.expression.Member;
+import org.apache.olingo.server.api.uri.queryoption.expression.Method;
import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
-import org.apache.olingo.server.core.uri.UriInfoImpl;
+import org.apache.olingo.server.api.uri.queryoption.expression.TypeLiteral;
import org.apache.olingo.server.core.uri.parser.Parser;
import org.apache.olingo.server.core.uri.parser.UriParserException;
import org.apache.olingo.server.core.uri.parser.UriParserSemanticException;
import org.apache.olingo.server.core.uri.parser.UriParserSyntaxException;
-import org.apache.olingo.server.core.uri.queryoption.FilterOptionImpl;
-import org.apache.olingo.server.core.uri.queryoption.OrderByOptionImpl;
-import org.apache.olingo.server.core.uri.queryoption.expression.BinaryImpl;
-import org.apache.olingo.server.core.uri.queryoption.expression.EnumerationImpl;
-import org.apache.olingo.server.core.uri.queryoption.expression.LiteralImpl;
-import org.apache.olingo.server.core.uri.queryoption.expression.MemberImpl;
-import org.apache.olingo.server.core.uri.queryoption.expression.MethodImpl;
-import org.apache.olingo.server.core.uri.queryoption.expression.TypeLiteralImpl;
public class FilterValidator implements TestValidator {
private Edm edm;
private TestValidator invokedByValidator;
- private FilterOptionImpl filter;
+ private FilterOption filter;
+ private OrderByOption orderBy;
private Expression curExpression;
private Expression rootExpression;
- private OrderByOptionImpl orderBy;
-
private UriParserException exception;
// --- Setup ---
@@ -84,7 +81,7 @@ public class FilterValidator implements TestValidator {
return this;
}
- public FilterValidator setFilter(final FilterOptionImpl filter) {
+ public FilterValidator setFilter(final FilterOption filter) {
this.filter = filter;
if (filter.getExpression() == null) {
@@ -94,9 +91,8 @@ public class FilterValidator implements TestValidator {
return this;
}
- public FilterValidator setOrderBy(final OrderByOptionImpl orderBy) {
+ public FilterValidator setOrderBy(final OrderByOption orderBy) {
this.orderBy = orderBy;
-
return this;
}
@@ -175,10 +171,6 @@ public class FilterValidator implements TestValidator {
return runUri("ESCollAllPrim(1)/CollPropertyTimeOfDay", "$filter=" + filter.trim());
}
- public FilterValidator runESabc(final String filter) throws UriParserException {
- return runUri("ESabc", "$filter=" + filter.trim());
- }
-
public FilterValidator runUri(final String path, final String query) throws UriParserException {
Parser parser = new Parser();
UriInfo uriInfo = null;
@@ -189,7 +181,7 @@ public class FilterValidator implements TestValidator {
fail("Filtervalidator can only be used on resourcePaths");
}
- setFilter((FilterOptionImpl) uriInfo.getFilterOption());
+ setFilter(uriInfo.getFilterOption());
curExpression = filter.getExpression();
return this;
}
@@ -215,7 +207,7 @@ public class FilterValidator implements TestValidator {
fail("Filtervalidator can only be used on resourcePaths");
}
- setOrderBy((OrderByOptionImpl) uriInfo.getOrderByOption());
+ setOrderBy(uriInfo.getOrderByOption());
return this;
}
@@ -241,22 +233,21 @@ public class FilterValidator implements TestValidator {
}
public ResourceValidator goPath() {
- if (!(curExpression instanceof MemberImpl)) {
+ if (!(curExpression instanceof Member)) {
fail("Current expression not a member");
}
- MemberImpl member = (MemberImpl) curExpression;
+ Member member = (Member) curExpression;
return new ResourceValidator()
- .setEdm(edm)
- .setUriInfoImplPath((UriInfoImpl) member.getResourcePath())
- .setUpValidator(this);
-
+ .setEdm(edm)
+ .setUriInfoPath(member.getResourcePath())
+ .setUpValidator(this);
}
public FilterValidator goParameter(final int parameterIndex) {
- if (curExpression instanceof MethodImpl) {
- MethodImpl methodCall = (MethodImpl) curExpression;
+ if (curExpression instanceof Method) {
+ Method methodCall = (Method) curExpression;
curExpression = methodCall.getParameters().get(parameterIndex);
} else {
fail("Current expression not a methodCall");
@@ -281,13 +272,12 @@ public class FilterValidator implements TestValidator {
String actualFilterAsText = FilterTreeToText.Serialize(filter);
assertEquals(expectedFilterAsString, actualFilterAsText);
} catch (ExpressionVisitException e) {
- fail("Exception occured while converting the filterTree into text" + "\n"
+ fail("Exception occurred while converting the filterTree into text" + "\n"
+ " Exception: " + e.getMessage());
} catch (ODataApplicationException e) {
- fail("Exception occured while converting the filterTree into text" + "\n"
+ fail("Exception occurred while converting the filterTree into text" + "\n"
+ " Exception: " + e.getMessage());
}
-
return this;
}
@@ -303,14 +293,14 @@ public class FilterValidator implements TestValidator {
public FilterValidator isType(final FullQualifiedName fullName) {
EdmType actualType = null;
- if (curExpression instanceof MemberImpl) {
+ if (curExpression instanceof Member) {
Member member = (Member) curExpression;
actualType = member.getType();
- } else if (curExpression instanceof TypeLiteralImpl) {
- TypeLiteralImpl typeLiteral = (TypeLiteralImpl) curExpression;
+ } else if (curExpression instanceof TypeLiteral) {
+ TypeLiteral typeLiteral = (TypeLiteral) curExpression;
actualType = typeLiteral.getType();
- } else if (curExpression instanceof LiteralImpl) {
- LiteralImpl typeLiteral = (LiteralImpl) curExpression;
+ } else if (curExpression instanceof Literal) {
+ Literal typeLiteral = (Literal) curExpression;
actualType = typeLiteral.getType();
}
@@ -318,158 +308,134 @@ public class FilterValidator implements TestValidator {
fail("Current expression not typed");
}
- FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
- assertEquals(fullName, actualName);
+ assertEquals(fullName, actualType.getFullQualifiedName());
return this;
}
public FilterValidator left() {
- if (!(curExpression instanceof BinaryImpl)) {
+ if (!(curExpression instanceof Binary)) {
fail("Current expression not a binary operator");
}
- curExpression = ((BinaryImpl) curExpression).getLeftOperand();
-
+ curExpression = ((Binary) curExpression).getLeftOperand();
return this;
}
public FilterValidator root() {
- if (filter != null) {
- curExpression = filter.getExpression();
- } else {
- curExpression = rootExpression;
- }
-
+ curExpression = filter == null ? rootExpression : filter.getExpression();
return this;
}
public FilterValidator right() {
- if (!(curExpression instanceof BinaryImpl)) {
+ if (!(curExpression instanceof Binary)) {
fail("Current expression is not a binary operator");
}
- curExpression = ((BinaryImpl) curExpression).getRightOperand();
-
+ curExpression = ((Binary) curExpression).getRightOperand();
return this;
}
public FilterValidator isLiteral(final String literalText) {
- if (!(curExpression instanceof LiteralImpl)) {
+ if (!(curExpression instanceof Literal)) {
fail("Current expression is not a literal");
}
- String actualLiteralText = ((LiteralImpl) curExpression).getText();
+ String actualLiteralText = ((Literal) curExpression).getText();
assertEquals(literalText, actualLiteralText);
-
return this;
}
public FilterValidator isLiteralType(EdmType edmType) {
- if(!(curExpression instanceof LiteralImpl)) {
- fail("Current expression is nit a literal");
+ if(!(curExpression instanceof Literal)) {
+ fail("Current expression is not a literal");
}
- final EdmType type = ((LiteralImpl) curExpression).getType();
+ final EdmType type = ((Literal) curExpression).getType();
assertNotNull(type);
- assertEquals(edmType.getClass(), type.getClass());
-
+ assertEquals(edmType, type);
return this;
}
-
+
public FilterValidator isNullLiteralType() {
- if(!(curExpression instanceof LiteralImpl)) {
- fail("Current expression is nit a literal");
+ if(!(curExpression instanceof Literal)) {
+ fail("Current expression is not a literal");
}
-
- final EdmType type = ((LiteralImpl) curExpression).getType();
+
+ final EdmType type = ((Literal) curExpression).getType();
assertNull(type);
-
return this;
}
-
+
public FilterValidator isMethod(final MethodKind methodKind, final int parameterCount) {
- if (!(curExpression instanceof MethodImpl)) {
+ if (!(curExpression instanceof Method)) {
fail("Current expression is not a methodCall");
}
- MethodImpl methodCall = (MethodImpl) curExpression;
+ Method methodCall = (Method) curExpression;
assertEquals(methodKind, methodCall.getMethod());
assertEquals(parameterCount, methodCall.getParameters().size());
-
return this;
}
public FilterValidator isParameterText(final int parameterIndex, final String parameterText)
throws ExpressionVisitException, ODataApplicationException {
- if (!(curExpression instanceof MethodImpl)) {
+ if (!(curExpression instanceof Method)) {
fail("Current expression is not a method");
}
- MethodImpl methodCall = (MethodImpl) curExpression;
+ Method methodCall = (Method) curExpression;
Expression parameter = methodCall.getParameters().get(parameterIndex);
String actualParameterText = FilterTreeToText.Serialize(parameter);
assertEquals(parameterText, actualParameterText);
-
return this;
}
public FilterValidator isBinary(final BinaryOperatorKind binaryOperator) {
- if (!(curExpression instanceof BinaryImpl)) {
+ if (!(curExpression instanceof Binary)) {
fail("Current expression is not a binary operator");
}
- BinaryImpl binary = (BinaryImpl) curExpression;
+ Binary binary = (Binary) curExpression;
assertEquals(binaryOperator, binary.getOperator());
-
return this;
}
public FilterValidator isTypedLiteral(final FullQualifiedName fullName) {
- if (!(curExpression instanceof TypeLiteralImpl)) {
+ if (!(curExpression instanceof TypeLiteral)) {
fail("Current expression not a typeLiteral");
}
isType(fullName);
-
return this;
}
public FilterValidator isMember() {
- if (!(curExpression instanceof MemberImpl)) {
+ if (!(curExpression instanceof Member)) {
fail("Current expression not a member");
}
-
return this;
}
public FilterValidator isMemberStartType(final FullQualifiedName fullName) {
- if (!(curExpression instanceof MemberImpl)) {
- fail("Current expression not a member");
- }
-
- MemberImpl member = (MemberImpl) curExpression;
+ isMember();
+ Member member = (Member) curExpression;
EdmType actualType = member.getStartTypeFilter();
-
- FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
- assertEquals(fullName, actualName);
+ assertEquals(fullName, actualType.getFullQualifiedName());
return this;
}
public FilterValidator isEnum(final FullQualifiedName nameenstring, final List<String> enumValues) {
- if (!(curExpression instanceof EnumerationImpl)) {
+ if (!(curExpression instanceof Enumeration)) {
fail("Current expression not a enumeration");
}
- EnumerationImpl enumeration = (EnumerationImpl) curExpression;
-
- FullQualifiedName actualName =
- new FullQualifiedName(enumeration.getType().getNamespace(), enumeration.getType().getName());
+ Enumeration enumeration = (Enumeration) curExpression;
// check name
- assertEquals(nameenstring.toString(), actualName.toString());
+ assertEquals(nameenstring, enumeration.getType().getFullQualifiedName());
// check values
int i = 0;
@@ -504,33 +470,10 @@ public class FilterValidator implements TestValidator {
}
public FilterValidator isNull() {
- if (!(curExpression instanceof LiteralImpl)) {
- fail("Current expression is not a literal");
- }
-
- String actualLiteralText = ((LiteralImpl) curExpression).getText();
- assertEquals("null", actualLiteralText);
- return this;
+ return isLiteral("null");
}
public FilterValidator isTrue() {
- if (!(curExpression instanceof LiteralImpl)) {
- fail("Current expression is not a literal");
- }
-
- String actualLiteralText = ((LiteralImpl) curExpression).getText();
- assertEquals("true", actualLiteralText);
- return this;
+ return isLiteral("true");
}
-
- public FilterValidator isFalse() {
- if (!(curExpression instanceof LiteralImpl)) {
- fail("Current expression is not a literal");
- }
-
- String actualLiteralText = ((LiteralImpl) curExpression).getText();
- assertEquals("false", actualLiteralText);
- return this;
- }
-
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/837c3565/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ParseTreeToText.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ParseTreeToText.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ParseTreeToText.java
deleted file mode 100644
index 46126c6..0000000
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ParseTreeToText.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.uri.testutil;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.antlr.v4.runtime.Token;
-import org.antlr.v4.runtime.misc.NotNull;
-import org.antlr.v4.runtime.misc.Nullable;
-import org.antlr.v4.runtime.misc.Utils;
-import org.antlr.v4.runtime.tree.ErrorNode;
-import org.antlr.v4.runtime.tree.RuleNode;
-import org.antlr.v4.runtime.tree.TerminalNode;
-import org.antlr.v4.runtime.tree.Tree;
-
-public class ParseTreeToText {
-
- public static String getTreeAsText(final Tree contextTree, final String[] ruleNames) {
- return toStringTree(contextTree, Arrays.asList(ruleNames));
- }
-
- private static String toStringTree(final Tree t, @Nullable final List<String> ruleNames) {
-
- if (t.getChildCount() == 0) {
- return Utils.escapeWhitespace(getNodeText(t, ruleNames), false);
- }
-
- StringBuilder buf = new StringBuilder();
- String s = Utils.escapeWhitespace(getNodeText(t, ruleNames), false);
- buf.append(s);
- buf.append("(");
-
- for (int i = 0; i < t.getChildCount(); i++) {
- if (i > 0) {
- buf.append(' ');
- }
- buf.append(toStringTree(t.getChild(i), ruleNames));
- }
- buf.append(")");
- return buf.toString();
- }
-
- private static String getNodeText(@NotNull final Tree t, @Nullable final List<String> ruleNames) {
- if (ruleNames != null) {
- if (t instanceof RuleNode) {
- int ruleIndex = ((RuleNode) t).getRuleContext().getRuleIndex();
- return ruleNames.get(ruleIndex);
- } else if (t instanceof ErrorNode) {
- return t.toString();
- } else if (t instanceof TerminalNode) {
- Token symbol = ((TerminalNode) t).getSymbol();
- if (symbol != null) {
- return symbol.getText();
- }
- }
- }
- // no recog for rule names
- Object payload = t.getPayload();
- if (payload instanceof Token) {
- return ((Token) payload).getText();
- }
- return t.getPayload().toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/837c3565/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java
deleted file mode 100644
index 4911624..0000000
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * 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.uri.testutil;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.antlr.v4.runtime.ParserRuleContext;
-import org.apache.olingo.server.core.uri.antlr.UriParserParser;
-
-public class ParserValidator {
-
- private String input = null;
- private ParserRuleContext root;
-
- int logLevel = 0;
- private int lexerLogLevel = 0;
-
- boolean allowFullContext;
- boolean allowContextSensitifity;
- boolean allowAmbiguity;
-
- List<Exception> exceptions = new ArrayList<Exception>();
- private Exception curException = null;
-
- // --- Setup ---
-
- public ParserValidator log(final int logLevel) {
- this.logLevel = logLevel;
- return this;
- }
-
- public ParserValidator lexerLog(final int logLevel) {
- lexerLogLevel = logLevel;
- return this;
- }
-
- /**
- * Used in fast LL Parsing:
- * Don't stop the parsing process when the slower full context parsing (with prediction mode SLL) is
- * required
- * @return {@link ParserValidator}
- */
- public ParserValidator aFC() {
- allowFullContext = true;
- return this;
- }
-
- /**
- * Used in fast LL Parsing:
- * Allows ContextSensitifity Errors which occur often when using the slower full context parsing
- * and indicate that there is a context sensitivity ( which may not be an error).
- * @return {@link ParserValidator}
- */
- public ParserValidator aCS() {
- allowContextSensitifity = true;
- return this;
- }
-
- /**
- * Used in fast LL Parsing:
- * Allows ambiguities
- * @return {@link ParserValidator}
- */
- public ParserValidator aAM() {
- allowAmbiguity = true;
- return this;
- }
-
- // --- Execution ---
-
- public ParserValidator run(final String uri) {
- input = uri;
-
- // just run a short lexer step. E.g. to print the tokens
- if (lexerLogLevel > 0) {
- (new TokenValidator()).log(lexerLogLevel).run(input);
- }
-
- /**/// root = parseInput(uri);
-
- // if LOG > 0 - Write serialized tree
- if (logLevel > 0) {
- if (root != null) {
- System.out.println(ParseTreeToText.getTreeAsText(root, new UriParserParser(null).getRuleNames()));
- } else {
- System.out.println("root == null");
- }
- }
-
- // reset for next test
- allowFullContext = false;
- allowContextSensitifity = false;
- allowAmbiguity = false;
- logLevel = 0;
-
- return this;
- }
-
- // --- Navigation ---
-
- public ParserValidator exFirst() {
- try {
- // curWeakException = exceptions.get(0);
- } catch (IndexOutOfBoundsException ex) {
- // curWeakException = null;
- }
- return this;
-
- }
-
- public ParserValidator exLast() {
- // curWeakException = exceptions.get(exceptions.size() - 1);
- return this;
- }
-
- public ParserValidator exAt(final int index) {
- try {
- // curWeakException = exceptions.get(index);
- } catch (IndexOutOfBoundsException ex) {
- // curWeakException = null;
- }
- return this;
- }
-
- // --- Validation ---
-
- public ParserValidator isText(final String expected) {
-
- assertEquals(null, curException);
- assertEquals(0, exceptions.size());
-
- String actualTreeAsText = ParseTreeToText.getTreeAsText(root, new UriParserParser(null).getRuleNames());
-
- assertEquals(expected, actualTreeAsText);
- return this;
- }
-
- public ParserValidator isExeptionType(final Class<?> exClass) {
- assertEquals(exClass, curException.getClass());
- return this;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/837c3565/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 f6c9937..994b6b2 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
@@ -20,6 +20,7 @@ package org.apache.olingo.server.core.uri.testutil;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.List;
@@ -29,32 +30,27 @@ import org.apache.olingo.commons.api.edm.EdmElement;
import org.apache.olingo.commons.api.edm.EdmType;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.http.HttpMethod;
-import org.apache.olingo.server.api.ODataApplicationException;
import org.apache.olingo.server.api.uri.UriInfo;
import org.apache.olingo.server.api.uri.UriInfoKind;
+import org.apache.olingo.server.api.uri.UriInfoResource;
import org.apache.olingo.server.api.uri.UriParameter;
+import org.apache.olingo.server.api.uri.UriResource;
+import org.apache.olingo.server.api.uri.UriResourceAction;
+import org.apache.olingo.server.api.uri.UriResourceComplexProperty;
+import org.apache.olingo.server.api.uri.UriResourceEntitySet;
+import org.apache.olingo.server.api.uri.UriResourceFunction;
import org.apache.olingo.server.api.uri.UriResourceKind;
+import org.apache.olingo.server.api.uri.UriResourceLambdaAll;
+import org.apache.olingo.server.api.uri.UriResourceLambdaAny;
+import org.apache.olingo.server.api.uri.UriResourceNavigation;
import org.apache.olingo.server.api.uri.UriResourcePartTyped;
-import org.apache.olingo.server.api.uri.queryoption.CustomQueryOption;
+import org.apache.olingo.server.api.uri.UriResourcePrimitiveProperty;
+import org.apache.olingo.server.api.uri.UriResourceSingleton;
+import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
import org.apache.olingo.server.api.uri.queryoption.SelectItem;
-import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
-import org.apache.olingo.server.core.uri.UriInfoImpl;
-import org.apache.olingo.server.core.uri.UriResourceActionImpl;
-import org.apache.olingo.server.core.uri.UriResourceComplexPropertyImpl;
-import org.apache.olingo.server.core.uri.UriResourceEntitySetImpl;
-import org.apache.olingo.server.core.uri.UriResourceFunctionImpl;
-import org.apache.olingo.server.core.uri.UriResourceImpl;
-import org.apache.olingo.server.core.uri.UriResourceLambdaAllImpl;
-import org.apache.olingo.server.core.uri.UriResourceLambdaAnyImpl;
-import org.apache.olingo.server.core.uri.UriResourceNavigationPropertyImpl;
-import org.apache.olingo.server.core.uri.UriResourcePrimitivePropertyImpl;
-import org.apache.olingo.server.core.uri.UriResourceSingletonImpl;
+import org.apache.olingo.server.api.uri.queryoption.SelectOption;
import org.apache.olingo.server.core.uri.UriResourceWithKeysImpl;
import org.apache.olingo.server.core.uri.parser.UriParserException;
-import org.apache.olingo.server.core.uri.queryoption.CustomQueryOptionImpl;
-import org.apache.olingo.server.core.uri.queryoption.ExpandOptionImpl;
-import org.apache.olingo.server.core.uri.queryoption.SelectOptionImpl;
-import org.apache.olingo.server.core.uri.queryoption.expression.ExpressionImpl;
import org.apache.olingo.server.core.uri.validator.UriValidationException;
import org.apache.olingo.server.core.uri.validator.UriValidator;
@@ -63,7 +59,7 @@ public class ResourceValidator implements TestValidator {
private TestValidator invokedBy;
private UriInfo uriInfo = null;
- private UriResourceImpl uriPathInfo = null;
+ private UriResource uriPathInfo = null;
private int uriResourceIndex;
// --- Setup ---
@@ -78,8 +74,8 @@ public class ResourceValidator implements TestValidator {
return this;
}
- public ResourceValidator setUriInfoImplPath(final UriInfo uriInfoPath) {
- uriInfo = uriInfoPath;
+ public ResourceValidator setUriInfoPath(final UriInfoResource uriInfoPath) {
+ uriInfo = (UriInfo) uriInfoPath;
last();
return this;
}
@@ -130,7 +126,7 @@ public class ResourceValidator implements TestValidator {
public FilterValidator goParameter(final int index) {
assertEquals(UriResourceKind.function, uriPathInfo.getKind());
- UriResourceFunctionImpl function = (UriResourceFunctionImpl) uriPathInfo;
+ UriResourceFunction function = (UriResourceFunction) uriPathInfo;
return new FilterValidator()
.setEdm(edm)
@@ -142,12 +138,12 @@ public class ResourceValidator implements TestValidator {
if (uriPathInfo.getKind() == UriResourceKind.lambdaAll) {
return new FilterValidator()
.setEdm(edm)
- .setExpression(((UriResourceLambdaAllImpl) uriPathInfo).getExpression());
+ .setExpression(((UriResourceLambdaAll) uriPathInfo).getExpression());
} else if (uriPathInfo.getKind() == UriResourceKind.lambdaAny) {
return new FilterValidator()
.setEdm(edm)
- .setExpression(((UriResourceLambdaAnyImpl) uriPathInfo).getExpression());
+ .setExpression(((UriResourceLambdaAny) uriPathInfo).getExpression());
} else {
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
}
@@ -155,20 +151,16 @@ public class ResourceValidator implements TestValidator {
}
public ResourceValidator goSelectItem(final int index) {
- SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
-
+ final SelectOption select = uriInfo.getSelectOption();
SelectItem item = select.getSelectItems().get(index);
- UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourcePath();
-
return new ResourceValidator()
- .setUpValidator(this)
- .setEdm(edm)
- .setUriInfoImplPath(uriInfo1);
-
+ .setUpValidator(this)
+ .setEdm(edm)
+ .setUriInfoPath(item.getResourcePath());
}
public ExpandValidator goExpand() {
- ExpandOptionImpl expand = (ExpandOptionImpl) uriInfo.getExpandOption();
+ final ExpandOption expand = uriInfo.getExpandOption();
if (expand == null) {
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
}
@@ -177,41 +169,30 @@ public class ResourceValidator implements TestValidator {
}
public ResourceValidator first() {
- uriResourceIndex = 0;
- uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(0);
- return this;
+ return at(0);
}
public ResourceValidator last() {
- uriResourceIndex = 0;
-
- try {
- uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriInfo.getUriResourceParts().size() - 1);
- uriResourceIndex = uriInfo.getUriResourceParts().size() - 1;
- } catch (IndexOutOfBoundsException ex) {
+ final List<UriResource> parts = uriInfo.getUriResourceParts();
+ if (parts.isEmpty()) {
+ uriResourceIndex = 0;
fail("not enough segments");
+ } else {
+ uriResourceIndex = parts.size() - 1;
+ uriPathInfo = parts.get(uriResourceIndex);
}
-
return this;
}
public ResourceValidator n() {
- uriResourceIndex++;
-
- try {
- uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriResourceIndex);
- } catch (IndexOutOfBoundsException ex) {
- fail("not enough segments");
- }
-
- return this;
+ return at(uriResourceIndex + 1);
}
public ResourceValidator at(final int index) {
uriResourceIndex = index;
- try {
- uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(index);
- } catch (IndexOutOfBoundsException ex) {
+ if (index < uriInfo.getUriResourceParts().size()) {
+ uriPathInfo = uriInfo.getUriResourceParts().get(index);
+ } else {
fail("not enough segments");
}
return this;
@@ -222,9 +203,9 @@ public class ResourceValidator implements TestValidator {
public ResourceValidator isLambdaVar(final String var) {
String actualVar = null;
if (uriPathInfo.getKind() == UriResourceKind.lambdaAll) {
- actualVar = ((UriResourceLambdaAllImpl) uriPathInfo).getLambdaVariable();
+ actualVar = ((UriResourceLambdaAll) uriPathInfo).getLambdaVariable();
} else if (uriPathInfo.getKind() == UriResourceKind.lambdaAny) {
- actualVar = ((UriResourceLambdaAnyImpl) uriPathInfo).getLambdaVariable();
+ actualVar = ((UriResourceLambdaAny) uriPathInfo).getLambdaVariable();
} else {
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
}
@@ -241,19 +222,17 @@ public class ResourceValidator implements TestValidator {
}
EdmType actualType = null;
- if (uriPathInfo instanceof UriResourceComplexPropertyImpl) {
- actualType = ((UriResourceComplexPropertyImpl) uriPathInfo).getComplexTypeFilter();
- } else if (uriPathInfo instanceof UriResourceSingletonImpl) {
- actualType = ((UriResourceSingletonImpl) uriPathInfo).getEntityTypeFilter();
+ if (uriPathInfo instanceof UriResourceComplexProperty) {
+ actualType = ((UriResourceComplexProperty) uriPathInfo).getComplexTypeFilter();
+ } else if (uriPathInfo instanceof UriResourceSingleton) {
+ actualType = ((UriResourceSingleton) uriPathInfo).getEntityTypeFilter();
}
if (actualType == null) {
fail("type information not set");
}
- FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
-
- assertEquals(expectedType.toString(), actualName.toString());
+ assertEquals(expectedType, actualType.getFullQualifiedName());
return this;
}
@@ -267,10 +246,7 @@ public class ResourceValidator implements TestValidator {
if (actualType == null) {
fail("type information not set");
}
-
- FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
-
- assertEquals(type.toString(), actualName.toString());
+ assertEquals(type, actualType.getFullQualifiedName());
return this;
}
@@ -290,11 +266,7 @@ 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 (type == null) {
- assertEquals(type, actualType);
- } else {
- assertEquals(type.toString(), new FullQualifiedName(actualType.getNamespace(), actualType.getName()).toString());
- }
+ assertEquals(type, type == null ? actualType : actualType.getFullQualifiedName());
return this;
}
@@ -307,48 +279,12 @@ 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 (expectedType == null) {
- assertEquals(expectedType, actualType);
- } else {
- FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
- assertEquals(expectedType.toString(), actualName.toString());
- }
+ assertEquals(expectedType, expectedType == null ? actualType : actualType.getFullQualifiedName());
return this;
}
// other functions
- public ResourceValidator checkCustomParameter(final int index, final String name, final String value) {
- if (uriInfo == null) {
- fail("hasQueryParameter: uriInfo == null");
- }
-
- List<CustomQueryOption> list = uriInfo.getCustomQueryOptions();
- if (list.size() <= index) {
- fail("not enough queryParameters");
- }
-
- CustomQueryOptionImpl option = (CustomQueryOptionImpl) list.get(index);
- assertEquals(name, option.getName());
- assertEquals(value, option.getText());
- return this;
- }
-
- public ResourceValidator isFilterString(final String expectedFilterTreeAsString) {
-
- ExpressionImpl filterTree = (ExpressionImpl) uriInfo.getFilterOption().getExpression();
- try {
- String filterTreeAsString = filterTree.accept(new FilterTreeToText());
- assertEquals(expectedFilterTreeAsString, filterTreeAsString);
- } catch (ExpressionVisitException e) {
- fail("isFilterString: Exception " + e.getMessage() + " occured");
- } catch (ODataApplicationException e) {
- fail("isFilterString: Exception " + e.getMessage() + " occured");
- }
-
- return this;
- }
-
public ResourceValidator isKeyPredicateRef(final int index, final String name, final String refencedProperty) {
if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
@@ -359,7 +295,6 @@ public class ResourceValidator implements TestValidator {
assertEquals(name, keyPredicates.get(index).getName());
assertEquals(refencedProperty, keyPredicates.get(index).getReferencedProperty());
return this;
-
}
public ResourceValidator isKeyPredicateAlias(final int index, final String name, final String alias) {
@@ -389,11 +324,11 @@ public class ResourceValidator implements TestValidator {
}
public ResourceValidator isParameter(final int index, final String name, final String text) {
- if (!(uriPathInfo instanceof UriResourceFunctionImpl)) {
+ if (!(uriPathInfo instanceof UriResourceFunction)) {
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
}
- UriResourceFunctionImpl info = (UriResourceFunctionImpl) uriPathInfo;
+ UriResourceFunction info = (UriResourceFunction) uriPathInfo;
List<UriParameter> keyPredicates = info.getParameters();
assertEquals(name, keyPredicates.get(index).getName());
assertEquals(text, keyPredicates.get(index).getText());
@@ -402,11 +337,11 @@ public class ResourceValidator implements TestValidator {
}
public ResourceValidator isParameterAlias(final int index, final String name, final String alias) {
- if (!(uriPathInfo instanceof UriResourceFunctionImpl)) {
+ if (!(uriPathInfo instanceof UriResourceFunction)) {
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
}
- UriResourceFunctionImpl info = (UriResourceFunctionImpl) uriPathInfo;
+ UriResourceFunction info = (UriResourceFunction) uriPathInfo;
List<UriParameter> keyPredicates = info.getParameters();
assertEquals(name, keyPredicates.get(index).getName());
assertEquals(alias, keyPredicates.get(index).getAlias());
@@ -421,47 +356,47 @@ public class ResourceValidator implements TestValidator {
public ResourceValidator isPrimitiveProperty(final String name,
final FullQualifiedName type, final boolean isCollection) {
- if (!(uriPathInfo instanceof UriResourcePrimitivePropertyImpl)) {
+ if (!(uriPathInfo instanceof UriResourcePrimitiveProperty)) {
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
}
- UriResourcePrimitivePropertyImpl uriPathInfoProp = (UriResourcePrimitivePropertyImpl) uriPathInfo;
+ UriResourcePrimitiveProperty uriPathInfoProp = (UriResourcePrimitiveProperty) uriPathInfo;
EdmElement property = uriPathInfoProp.getProperty();
assertEquals(name, property.getName());
- assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName()));
+ assertEquals(type, property.getType().getFullQualifiedName());
assertEquals(isCollection, property.isCollection());
return this;
}
- public ResourceValidator
- isComplexProperty(final String name, final FullQualifiedName type, final boolean isCollection) {
- if (!(uriPathInfo instanceof UriResourceComplexPropertyImpl)) {
+ public ResourceValidator isComplexProperty(final String name, final FullQualifiedName type,
+ final boolean isCollection) {
+ if (!(uriPathInfo instanceof UriResourceComplexProperty)) {
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
}
- UriResourceComplexPropertyImpl uriPathInfoProp = (UriResourceComplexPropertyImpl) uriPathInfo;
+ UriResourceComplexProperty uriPathInfoProp = (UriResourceComplexProperty) uriPathInfo;
EdmElement property = uriPathInfoProp.getProperty();
assertEquals(name, property.getName());
- assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName()));
+ assertEquals(type, property.getType().getFullQualifiedName());
assertEquals(isCollection, property.isCollection());
return this;
}
public ResourceValidator isNavProperty(final String name, final FullQualifiedName type, final boolean isCollection) {
- if (!(uriPathInfo instanceof UriResourceNavigationPropertyImpl)) {
+ if (!(uriPathInfo instanceof UriResourceNavigation)) {
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
}
- UriResourceNavigationPropertyImpl uriPathInfoProp = (UriResourceNavigationPropertyImpl) uriPathInfo;
+ UriResourceNavigation uriPathInfoProp = (UriResourceNavigation) uriPathInfo;
EdmElement property = uriPathInfoProp.getProperty();
assertEquals(name, property.getName());
- assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName()));
+ assertEquals(type, property.getType().getFullQualifiedName());
assertEquals(isCollection, uriPathInfoProp.isCollection());
return this;
}
@@ -473,65 +408,61 @@ public class ResourceValidator implements TestValidator {
}
public ResourceValidator isAction(final String name) {
- assertEquals(UriResourceKind.action, uriPathInfo.getKind());
- assertEquals(name, ((UriResourceActionImpl) uriPathInfo).getAction().getName());
+ isUriPathInfoKind(UriResourceKind.action);
+ assertEquals(name, ((UriResourceAction) uriPathInfo).getAction().getName());
return this;
}
public ResourceValidator isFunction(final String name) {
- assertEquals(UriResourceKind.function, uriPathInfo.getKind());
- assertEquals(name, ((UriResourceFunctionImpl) uriPathInfo).getFunction().getName());
+ isUriPathInfoKind(UriResourceKind.function);
+ assertEquals(name, ((UriResourceFunction) uriPathInfo).getFunction().getName());
return this;
}
public ResourceValidator isFunctionImport(final String name) {
- assertEquals(UriResourceKind.function, uriPathInfo.getKind());
- assertEquals(name, ((UriResourceFunctionImpl) uriPathInfo).getFunctionImport().getName());
+ isUriPathInfoKind(UriResourceKind.function);
+ assertEquals(name, ((UriResourceFunction) uriPathInfo).getFunctionImport().getName());
return this;
}
public ResourceValidator isEntitySet(final String name) {
- assertEquals(UriResourceKind.entitySet, uriPathInfo.getKind());
- assertEquals(name, ((UriResourceEntitySetImpl) uriPathInfo).getEntitySet().getName());
+ isUriPathInfoKind(UriResourceKind.entitySet);
+ assertEquals(name, ((UriResourceEntitySet) uriPathInfo).getEntitySet().getName());
return this;
}
public ResourceValidator isComplex(final String name) {
- assertEquals(UriResourceKind.complexProperty, uriPathInfo.getKind());
- assertEquals(name, ((UriResourceComplexPropertyImpl) uriPathInfo).getProperty().getName());
+ isUriPathInfoKind(UriResourceKind.complexProperty);
+ assertEquals(name, ((UriResourceComplexProperty) uriPathInfo).getProperty().getName());
return this;
}
public ResourceValidator isSingleton(final String name) {
- assertEquals(UriResourceKind.singleton, uriPathInfo.getKind());
- assertEquals(name, ((UriResourceSingletonImpl) uriPathInfo).getSingleton().getName());
+ isUriPathInfoKind(UriResourceKind.singleton);
+ assertEquals(name, ((UriResourceSingleton) uriPathInfo).getSingleton().getName());
return this;
}
public ResourceValidator isValue() {
- assertEquals(UriResourceKind.value, uriPathInfo.getKind());
- return this;
+ return isUriPathInfoKind(UriResourceKind.value);
}
public ResourceValidator isCount() {
- assertEquals(UriResourceKind.count, uriPathInfo.getKind());
- return this;
+ return isUriPathInfoKind(UriResourceKind.count);
}
public ResourceValidator isRef() {
- assertEquals(UriResourceKind.ref, uriPathInfo.getKind());
- return this;
+ return isUriPathInfoKind(UriResourceKind.ref);
}
public ResourceValidator isActionImport(final String actionName) {
- assertEquals(UriResourceKind.action, uriPathInfo.getKind());
- assertEquals(actionName, ((UriResourceActionImpl) uriPathInfo).getActionImport().getName());
+ isUriPathInfoKind(UriResourceKind.action);
+ assertEquals(actionName, ((UriResourceAction) uriPathInfo).getActionImport().getName());
return this;
}
public ResourceValidator isIt() {
- assertEquals(UriResourceKind.it, uriPathInfo.getKind());
- return this;
+ return isUriPathInfoKind(UriResourceKind.it);
}
public ResourceValidator isTopText(final String topText) {
@@ -560,29 +491,24 @@ public class ResourceValidator implements TestValidator {
}
public ResourceValidator isSelectItemStar(final int index) {
- SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
-
+ final SelectOption select = uriInfo.getSelectOption();
SelectItem item = select.getSelectItems().get(index);
- assertEquals(true, item.isStar());
+ assertTrue(item.isStar());
return this;
}
public ResourceValidator isSelectItemAllOp(final int index, final FullQualifiedName fqn) {
- SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
-
+ final SelectOption select = uriInfo.getSelectOption();
SelectItem item = select.getSelectItems().get(index);
- assertEquals(fqn.toString(), item.getAllOperationsInSchemaNameSpace().toString());
+ assertEquals(fqn, item.getAllOperationsInSchemaNameSpace());
return this;
}
public ResourceValidator isSelectStartType(final int index, final FullQualifiedName fullName) {
- SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+ final SelectOption select = uriInfo.getSelectOption();
SelectItem item = select.getSelectItems().get(index);
-
EdmType actualType = item.getStartTypeFilter();
-
- FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
- assertEquals(fullName, actualName);
+ assertEquals(fullName, actualType.getFullQualifiedName());
return this;
}
@@ -591,5 +517,4 @@ public class ResourceValidator implements TestValidator {
assertEquals(value, valueForAlias);
return this;
}
-
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/837c3565/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
index 0eb0378..6a2e5b4 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
@@ -19,12 +19,12 @@
package org.apache.olingo.server.core.uri.testutil;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmType;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.http.HttpMethod;
@@ -32,16 +32,14 @@ import org.apache.olingo.server.api.ODataLibraryException;
import org.apache.olingo.server.api.uri.UriInfo;
import org.apache.olingo.server.api.uri.UriInfoKind;
import org.apache.olingo.server.api.uri.queryoption.CustomQueryOption;
+import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
+import org.apache.olingo.server.api.uri.queryoption.FilterOption;
import org.apache.olingo.server.api.uri.queryoption.SelectItem;
-import org.apache.olingo.server.core.uri.UriInfoImpl;
+import org.apache.olingo.server.api.uri.queryoption.SelectOption;
import org.apache.olingo.server.core.uri.parser.Parser;
import org.apache.olingo.server.core.uri.parser.UriParserException;
import org.apache.olingo.server.core.uri.parser.UriParserSemanticException;
import org.apache.olingo.server.core.uri.parser.UriParserSyntaxException;
-import org.apache.olingo.server.core.uri.queryoption.CustomQueryOptionImpl;
-import org.apache.olingo.server.core.uri.queryoption.ExpandOptionImpl;
-import org.apache.olingo.server.core.uri.queryoption.FilterOptionImpl;
-import org.apache.olingo.server.core.uri.queryoption.SelectOptionImpl;
import org.apache.olingo.server.core.uri.validator.UriValidationException;
import org.apache.olingo.server.core.uri.validator.UriValidator;
@@ -95,7 +93,6 @@ public class TestUriValidator implements TestValidator {
} catch (UriValidationException e) {
exception = e;
}
-
return this;
}
@@ -106,22 +103,21 @@ public class TestUriValidator implements TestValidator {
}
return new ResourceValidator()
- .setUpValidator(this)
- .setEdm(edm)
- .setUriInfoImplPath(uriInfo);
+ .setUpValidator(this)
+ .setEdm(edm)
+ .setUriInfoPath(uriInfo);
}
public FilterValidator goFilter() {
- FilterOptionImpl filter = (FilterOptionImpl) uriInfo.getFilterOption();
+ final FilterOption filter = uriInfo.getFilterOption();
if (filter == null) {
fail("no filter found");
}
return new FilterValidator().setUriValidator(this).setFilter(filter);
-
}
public ExpandValidator goExpand() {
- ExpandOptionImpl expand = (ExpandOptionImpl) uriInfo.getExpandOption();
+ final ExpandOption expand = uriInfo.getExpandOption();
if (expand == null) {
fail("invalid resource kind: " + uriInfo.getKind().toString());
}
@@ -130,27 +126,20 @@ public class TestUriValidator implements TestValidator {
}
public ResourceValidator goSelectItemPath(final int index) {
- SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
-
+ final SelectOption select = uriInfo.getSelectOption();
SelectItem item = select.getSelectItems().get(index);
- UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourcePath();
-
return new ResourceValidator()
- .setUpValidator(this)
- .setEdm(edm)
- .setUriInfoImplPath(uriInfo1);
-
+ .setUpValidator(this)
+ .setEdm(edm)
+ .setUriInfoPath(item.getResourcePath());
}
public TestUriValidator isSelectStartType(final int index, final FullQualifiedName fullName) {
- SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+ final SelectOption select = uriInfo.getSelectOption();
SelectItem item = select.getSelectItems().get(index);
EdmType actualType = item.getStartTypeFilter();
-
- FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
- assertEquals(fullName, actualName);
+ assertEquals(fullName, actualType.getFullQualifiedName());
return this;
-
}
// Validation
@@ -169,7 +158,7 @@ public class TestUriValidator implements TestValidator {
fail("not enough queryParameters");
}
- CustomQueryOptionImpl option = (CustomQueryOptionImpl) list.get(index);
+ CustomQueryOption option = list.get(index);
assertEquals(name, option.getName());
assertEquals(value, option.getText());
return this;
@@ -185,7 +174,6 @@ public class TestUriValidator implements TestValidator {
assertEquals(entitySet, uriInfo.getEntitySetNames().get(i));
i++;
}
-
}
public TestUriValidator isExSyntax(final UriParserSyntaxException.MessageKeys messageKey) {
@@ -232,7 +220,6 @@ public class TestUriValidator implements TestValidator {
}
assertEquals(text, uriInfo.getFragment());
-
return this;
}
@@ -241,27 +228,21 @@ public class TestUriValidator implements TestValidator {
fail("invalid resource kind: " + uriInfo.getKind().toString());
}
- assertEquals(fullName.toString(), fullName(uriInfo.getEntityTypeCast()));
+ assertEquals(fullName, uriInfo.getEntityTypeCast().getFullQualifiedName());
return this;
}
- private String fullName(final EdmEntityType type) {
- return type.getNamespace() + "." + type.getName();
- }
-
public TestUriValidator isSelectItemStar(final int index) {
- SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
-
+ final SelectOption select = uriInfo.getSelectOption();
SelectItem item = select.getSelectItems().get(index);
- assertEquals(true, item.isStar());
+ assertTrue(item.isStar());
return this;
}
public TestUriValidator isSelectItemAllOp(final int index, final FullQualifiedName fqn) {
- SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
-
+ final SelectOption select = uriInfo.getSelectOption();
SelectItem item = select.getSelectItems().get(index);
- assertEquals(fqn.toString(), item.getAllOperationsInSchemaNameSpace().toString());
+ assertEquals(fqn, item.getAllOperationsInSchemaNameSpace());
return this;
}
}