You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by sk...@apache.org on 2014/05/09 14:28:49 UTC
[01/15] git commit: [OLINGO-266] initial reference scenario servlet
Repository: olingo-odata4
Updated Branches:
refs/heads/olingo-266-ref 554c795e4 -> 8ca9b3c61
[OLINGO-266] initial reference scenario servlet
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/54aef886
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/54aef886
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/54aef886
Branch: refs/heads/olingo-266-ref
Commit: 54aef8866493a4b6cfeca07ca1fd1f85681f25fb
Parents: 554c795
Author: Stephan Klevenz <st...@sap.com>
Authored: Fri May 9 14:22:51 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Fri May 9 14:22:51 2014 +0200
----------------------------------------------------------------------
lib/ref/pom.xml | 10 ++++-
.../org/apache/olingo/ref/ReferenceServlet.java | 42 +++++++++++++++++++
.../src/main/resources/simplelogger.properties | 20 +++++++++
lib/ref/src/main/webapp/WEB-INF/web.xml | 42 +++++++++++++++++++
lib/ref/src/main/webapp/index.html | 32 ++++++++++++++
lib/server-api/pom.xml | 44 +++++++++++---------
.../apache/olingo/server/api/ODataServer.java | 5 +++
lib/server-core/pom.xml | 36 ++++++++--------
.../olingo/server/core/ODataServerImpl.java | 16 +++++++
9 files changed, 208 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/ref/pom.xml
----------------------------------------------------------------------
diff --git a/lib/ref/pom.xml b/lib/ref/pom.xml
index fe1da60..76ea188 100644
--- a/lib/ref/pom.xml
+++ b/lib/ref/pom.xml
@@ -24,7 +24,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>olingo-ref</artifactId>
- <packaging>jar</packaging>
+ <packaging>war</packaging>
<name>${project.artifactId}</name>
<parent>
@@ -36,6 +36,13 @@
<dependencies>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-server-api</artifactId>
<version>${project.version}</version>
@@ -55,7 +62,6 @@
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
</dependency>
-
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/ref/src/main/java/org/apache/olingo/ref/ReferenceServlet.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/java/org/apache/olingo/ref/ReferenceServlet.java b/lib/ref/src/main/java/org/apache/olingo/ref/ReferenceServlet.java
new file mode 100644
index 0000000..a3d30ee
--- /dev/null
+++ b/lib/ref/src/main/java/org/apache/olingo/ref/ReferenceServlet.java
@@ -0,0 +1,42 @@
+/*
+ * 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.ref;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.olingo.server.api.ODataServer;
+
+public class ReferenceServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+
+ ODataServer server = ODataServer.newInstance();
+ server.handle(req, resp);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/ref/src/main/resources/simplelogger.properties
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/resources/simplelogger.properties b/lib/ref/src/main/resources/simplelogger.properties
new file mode 100644
index 0000000..2a3350c
--- /dev/null
+++ b/lib/ref/src/main/resources/simplelogger.properties
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+org.slf4j.simpleLogger.defaultLogLevel=debug
+org.slf4j.simpleLogger.logFile=System.out
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/ref/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/webapp/WEB-INF/web.xml b/lib/ref/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..cc7de77
--- /dev/null
+++ b/lib/ref/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ id="WebApp_ID" version="2.5">
+
+ <display-name>Apache Olingo OData 4.0 Reference Scenario Service</display-name>
+
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+
+ <servlet>
+ <servlet-name>ODataServlet</servlet-name>
+ <servlet-class>org.apache.olingo.ref.ReferenceServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>ODataServlet</servlet-name>
+ <url-pattern>/odata.svc/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/ref/src/main/webapp/index.html
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/webapp/index.html b/lib/ref/src/main/webapp/index.html
new file mode 100644
index 0000000..e25f4fb
--- /dev/null
+++ b/lib/ref/src/main/webapp/index.html
@@ -0,0 +1,32 @@
+<html>
+<!--
+ 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.
+-->
+
+<body>
+ <h1>Olingo OData 4.0 Reference Scenario Service</h1>
+ <hr>
+ <h2>Reference Scenario Service</h2>
+ <lu>
+ <li><a href="odata.svc/">Service Document</a></li>
+ <li><a href="odata.svc/$metadata">Metadata</a></li>
+ </lu>
+
+</body>
+
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/server-api/pom.xml
----------------------------------------------------------------------
diff --git a/lib/server-api/pom.xml b/lib/server-api/pom.xml
index b0bdda3..3d8fa87 100644
--- a/lib/server-api/pom.xml
+++ b/lib/server-api/pom.xml
@@ -1,26 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- 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.
+ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>olingo-server-api</artifactId>
@@ -33,13 +33,19 @@
<version>0.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
-
+
<dependencies>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-commons-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
-
+
</project>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataServer.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataServer.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataServer.java
index a657392..7390189 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataServer.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataServer.java
@@ -18,6 +18,9 @@
*/
package org.apache.olingo.server.api;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.server.api.serializer.ODataFormat;
import org.apache.olingo.server.api.serializer.ODataSerializer;
@@ -45,4 +48,6 @@ public abstract class ODataServer {
public abstract ODataSerializer getSerializer(ODataFormat format);
+ public abstract void handle(HttpServletRequest req, HttpServletResponse resp);
+
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/server-core/pom.xml
----------------------------------------------------------------------
diff --git a/lib/server-core/pom.xml b/lib/server-core/pom.xml
index 28693fc..bc7ae71 100644
--- a/lib/server-core/pom.xml
+++ b/lib/server-core/pom.xml
@@ -1,26 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- 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
+ 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
+ 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.
+ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>olingo-server-core</artifactId>
@@ -45,7 +45,7 @@
<artifactId>olingo-commons-core</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
@@ -97,8 +97,8 @@
<!--<arguments><argument>-atn</argument></arguments> -->
<listener>true</listener>
<visitor>true</visitor>
- <!--maven antlr plugin has trouble with grammer import if the grammerfiles
- are not directly inside src/main/antlr4, hence we have to set the libDirectory -->
+ <!--maven antlr plugin has trouble with grammer import if the grammerfiles
+ are not directly inside src/main/antlr4, hence we have to set the libDirectory -->
<libDirectory>src/main/antlr4/org/apache/olingo/server/core/uri/antlr</libDirectory>
</configuration>
</plugin>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataServerImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataServerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataServerImpl.java
index 7beb90d..933422d 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataServerImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataServerImpl.java
@@ -18,6 +18,11 @@
*/
package org.apache.olingo.server.core;
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.server.api.ODataServer;
import org.apache.olingo.server.api.serializer.ODataFormat;
@@ -44,4 +49,15 @@ public class ODataServerImpl extends ODataServer {
return serializer;
}
+ @Override
+ public void handle(HttpServletRequest req, HttpServletResponse resp) {
+
+ try {
+ resp.getWriter().print("Hello World!");
+ } catch (IOException e) {
+ throw new ODataRuntimeException(e);
+ }
+
+ }
+
}
[12/15] [OLINGO-266] refactor ref module to server-ref
Posted by sk...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
deleted file mode 100644
index 702d559..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
+++ /dev/null
@@ -1,5110 +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.antlr;
-
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
-
-import org.apache.olingo.commons.api.ODataApplicationException;
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.core.Encoder;
-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.BinaryOperatorKind;
-import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
-import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
-import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
-import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
-import org.apache.olingo.server.core.testutil.techprovider.ComplexTypeProvider;
-import org.apache.olingo.server.core.testutil.techprovider.EntityTypeProvider;
-import org.apache.olingo.server.core.testutil.techprovider.EnumTypeProvider;
-import org.apache.olingo.server.core.testutil.techprovider.PropertyProvider;
-import org.apache.olingo.server.core.uri.parser.UriParserException;
-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;
-import org.junit.Test;
-
-public class TestFullResourcePath {
- Edm edm = null;
- TestUriValidator testUri = null;
- ResourceValidator testRes = null;
- FilterValidator testFilter = null;
-
- public TestFullResourcePath() {
- edm = new EdmProviderImpl(new EdmTechTestProvider());
- testUri = new TestUriValidator().setEdm(edm);
- testRes = new ResourceValidator().setEdm(edm);
- testFilter = new FilterValidator().setEdm(edm);
- }
-
- @Test
- public void test() throws UriParserException {
-
- }
-
- @Test
- public void testFunctionBound_varOverloading() {
- // on ESTwoKeyNav
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()").goPath()
- .at(0)
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETTwoKeyNav, true)
- .at(1)
- .isUriPathInfoKind(UriResourceKind.function)
- .isType(EntityTypeProvider.nameETTwoKeyNav);
-
- // with string parameter
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav(ParameterString='ABC')").goPath()
- .at(0)
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETTwoKeyNav, true)
- .at(1)
- .isUriPathInfoKind(UriResourceKind.function)
- .isType(EntityTypeProvider.nameETTwoKeyNav);
-
- // with string parameter
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()").goPath()
- .at(0)
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETTwoKeyNav, true)
- .at(1)
- .isUriPathInfoKind(UriResourceKind.function)
- .isType(EntityTypeProvider.nameETTwoKeyNav);
- }
-
- @Test
- public void runBfuncBnCpropCastRtEs() {
-
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
- + "/PropertyComplex/com.sap.odata.test1.BFCCTPrimCompRTESBaseTwoKeyNav()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isComplex("PropertyComplex")
- .isType(ComplexTypeProvider.nameCTPrimComp, false)
- .n()
- .isFunction("BFCCTPrimCompRTESBaseTwoKeyNav");
-
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
- + "/PropertyComplex/com.sap.odata.test1.BFCCTPrimCompRTESBaseTwoKeyNav()/$count")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isComplex("PropertyComplex")
- .isType(ComplexTypeProvider.nameCTPrimComp, false)
- .n()
- .isFunction("BFCCTPrimCompRTESBaseTwoKeyNav")
- .isType(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isUriPathInfoKind(UriResourceKind.count);
-
- }
-
- @Test
- public void runBfuncBnCpropCollRtEs() {
- testUri.run("ESKeyNav(PropertyInt16=1)/CollPropertyComplex/com.sap.odata.test1.BFCCollCTPrimCompRTESAllPrim()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isUriPathInfoKind(UriResourceKind.complexProperty)
- .isComplex("CollPropertyComplex")
- .isType(ComplexTypeProvider.nameCTPrimComp, true)
- .n()
- .isFunction("BFCCollCTPrimCompRTESAllPrim");
-
- testUri
- .run("ESKeyNav(PropertyInt16=1)/CollPropertyComplex/com.sap.odata.test1.BFCCollCTPrimCompRTESAllPrim()/$count")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isUriPathInfoKind(UriResourceKind.complexProperty)
- .isComplex("CollPropertyComplex")
- .isType(ComplexTypeProvider.nameCTPrimComp, true)
- .n()
- .isFunction("BFCCollCTPrimCompRTESAllPrim")
- .isType(EntityTypeProvider.nameETAllPrim, true)
- .n()
- .isUriPathInfoKind(UriResourceKind.count);
- }
-
- @Test
- public void runBfuncBnCpropRtEs() {
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')"
- + "/PropertyComplex/com.sap.odata.test1.BFCCTPrimCompRTESTwoKeyNav()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .n()
- .isUriPathInfoKind(UriResourceKind.complexProperty)
- .isComplex("PropertyComplex")
- .isType(ComplexTypeProvider.nameCTPrimComp, false)
- .n()
- .isFunction("BFCCTPrimCompRTESTwoKeyNav");
-
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')"
- + "/PropertyComplex/com.sap.odata.test1.BFCCTPrimCompRTESTwoKeyNav()/$count")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .n()
- .isUriPathInfoKind(UriResourceKind.complexProperty)
- .isComplex("PropertyComplex")
- .isType(ComplexTypeProvider.nameCTPrimComp, false)
- .n()
- .isFunction("BFCCTPrimCompRTESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .n()
- .isUriPathInfoKind(UriResourceKind.count);
-
- }
-
- @Test
- public void runBfuncBnEntityRtEs() {
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.BFCETTwoKeyNavRTESTwoKeyNav()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .n()
- .isFunction("BFCETTwoKeyNavRTESTwoKeyNav");
- }
-
- @Test
- public void runBfuncBnEntityCastRtEs() {
- testUri
- .run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
- + "/com.sap.odata.test1.BFCETBaseTwoKeyNavRTESTwoKeyNav()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isFunction("BFCETBaseTwoKeyNavRTESTwoKeyNav");
-
- testUri
- .run("ESTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=1,PropertyString='(''2'')')"
- + "/com.sap.odata.test1.BFCETBaseTwoKeyNavRTESTwoKeyNav()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'(''2'')'")
- .n()
- .isFunction("BFCETBaseTwoKeyNavRTESTwoKeyNav");
- }
-
- @Test
- public void runBfuncBnEsCastRtEs() {
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav"
- + "/com.sap.odata.test1.BFCESBaseTwoKeyNavRTESBaseTwoKey()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav, true)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isFunction("BFCESBaseTwoKeyNavRTESBaseTwoKey");
-
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav"
- + "/com.sap.odata.test1.BFCESBaseTwoKeyNavRTESBaseTwoKey()"
- + "/com.sap.odata.test1.ETTwoBaseTwoKeyNav")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav, true)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isFunction("BFCESBaseTwoKeyNavRTESBaseTwoKey")
- .isType(EntityTypeProvider.nameETBaseTwoKeyNav)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETTwoBaseTwoKeyNav);
-
- testUri.run("ESTwoKeyNav"
- + "/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()"
- + "/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=1,PropertyString='2')"
- + "/com.sap.odata.test1.ETTwoBaseTwoKeyNav")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETTwoBaseTwoKeyNav);
- }
-
- @Test
- public void runBfuncBnEsRtCprop() {
- testUri.run("ESAllPrim/com.sap.odata.test1.BFCESAllPrimRTCTAllPrim()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESAllPrim")
- .n()
- .isFunction("BFCESAllPrimRTCTAllPrim")
- .isType(ComplexTypeProvider.nameCTAllPrim);
-
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCTTwoPrim()/com.sap.odata.test1.CTBase")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTCTTwoPrim")
- .isType(ComplexTypeProvider.nameCTTwoPrim, false)
- .isTypeFilterOnEntry(ComplexTypeProvider.nameCTBase);
- }
-
- @Test
- public void runBfuncBnEsRtCpropColl() {
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCollCTTwoPrim()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTCollCTTwoPrim")
- .isType(ComplexTypeProvider.nameCTTwoPrim, true);
-
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCollCTTwoPrim()/$count")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTCollCTTwoPrim")
- .isType(ComplexTypeProvider.nameCTTwoPrim, true)
- .n()
- .isUriPathInfoKind(UriResourceKind.count);
- }
-
- @Test
- public void runBfuncBnEsRtEntityPpNp() {
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTTwoKeyNav()/NavPropertyETKeyNavOne")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTTwoKeyNav")
- .n()
- .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false);
-
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTTwoKeyNav()/NavPropertyETKeyNavOne/$ref")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTTwoKeyNav")
- .n()
- .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false)
- .n()
- .isUriPathInfoKind(UriResourceKind.ref);
-
- testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNav()/NavPropertyETMediaOne/$value")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .n()
- .isFunction("BFCESKeyNavRTETKeyNav")
- .n()
- .isNavProperty("NavPropertyETMediaOne", EntityTypeProvider.nameETMedia, false)
- .n()
- .isValue();
-
- testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNavParam(ParameterString='1')"
- + "/NavPropertyETTwoKeyNavOne")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .n()
- .isFunction("BFCESKeyNavRTETKeyNavParam")
- .isParameter(0, "ParameterString", "'1'")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false);
-
- testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNavParam(ParameterString='1')"
- + "/NavPropertyETTwoKeyNavOne/PropertyComplex")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .n()
- .isFunction("BFCESKeyNavRTETKeyNavParam")
- .isParameter(0, "ParameterString", "'1'")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
- .n()
- .isComplex("PropertyComplex")
- .isType(ComplexTypeProvider.nameCTPrimComp);
-
- testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNavParam(ParameterString='1')"
- + "/NavPropertyETTwoKeyNavOne/PropertyComplex/PropertyComplex")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .n()
- .isFunction("BFCESKeyNavRTETKeyNavParam")
- .isParameter(0, "ParameterString", "'1'")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
- .n()
- .isComplex("PropertyComplex")
- .isType(ComplexTypeProvider.nameCTPrimComp)
- .n()
- .isComplex("PropertyComplex")
- .isType(ComplexTypeProvider.nameCTAllPrim);
-
- testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNavParam(ParameterString='1')"
- + "/NavPropertyETTwoKeyNavOne/PropertyString")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .n()
- .isFunction("BFCESKeyNavRTETKeyNavParam")
- .isParameter(0, "ParameterString", "'1'")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
- .n()
- .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
-
- testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNavParam(ParameterString='1')"
- + "/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')/PropertyString")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .n()
- .isFunction("BFCESKeyNavRTETKeyNavParam")
- .isParameter(0, "ParameterString", "'1'")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "2")
- .isKeyPredicate(1, "PropertyString", "'3'")
- .n()
- .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
- }
-
- @Test
- public void runBfuncBnEsRtEntyPpNpCast() {
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTTwoKeyNav()"
- + "/NavPropertyETTwoKeyNavOne/com.sap.odata.test1.ETBaseTwoKeyNav")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTTwoKeyNav")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav);
-
- testUri
- .run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()(PropertyInt16=1,PropertyString='2')"
- + "/NavPropertyETTwoKeyNavOne/com.sap.odata.test1.ETTwoBaseTwoKeyNav")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .isTypeFilterOnEntry(EntityTypeProvider.nameETTwoBaseTwoKeyNav);
-
- }
-
- @Test
- public void runBfuncBnEsRtEntityPpCp() {
-
- testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNav()/PropertyComplex")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .n()
- .isFunction("BFCESKeyNavRTETKeyNav")
- .n()
- .isComplex("PropertyComplex")
- .isType(ComplexTypeProvider.nameCTNavFiveProp);
-
- testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNav()/PropertyComplex/PropertyInt16")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .n()
- .isFunction("BFCESKeyNavRTETKeyNav")
- .n()
- .isComplex("PropertyComplex")
- .isType(ComplexTypeProvider.nameCTNavFiveProp)
- .n()
- .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
-
- testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNav()/PropertyComplex/PropertyInt16/$value")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .n()
- .isFunction("BFCESKeyNavRTETKeyNav")
- .n()
- .isComplex("PropertyComplex")
- .isType(ComplexTypeProvider.nameCTNavFiveProp)
- .n()
- .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false)
- .n()
- .isValue();
-
- }
-
- @Test
- public void runBfuncBnEsRtEntyPpCpCast() {
-
- testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNavParam(ParameterString='1')"
- + "/PropertyComplexTwoPrim/com.sap.odata.test1.CTTwoBase")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .n()
- .isFunction("BFCESKeyNavRTETKeyNavParam")
- .isParameter(0, "ParameterString", "'1'")
- .n()
- .isComplex("PropertyComplexTwoPrim")
- .isType(ComplexTypeProvider.nameCTTwoPrim)
- .isTypeFilter(ComplexTypeProvider.nameCTTwoBase);
-
- testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNavParam(ParameterString='1')"
- + "/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')"
- + "/PropertyComplexTwoPrim/com.sap.odata.test1.CTTwoBase")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .n()
- .isFunction("BFCESKeyNavRTETKeyNavParam")
- .isParameter(0, "ParameterString", "'1'")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "2")
- .isKeyPredicate(1, "PropertyString", "'3'")
- .n()
- .isComplex("PropertyComplexTwoPrim")
- .isType(ComplexTypeProvider.nameCTTwoPrim)
- .isTypeFilter(ComplexTypeProvider.nameCTTwoBase);
- }
-
- @Test
- public void runBfuncBnEsRtEntityPpSp() {
- testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNav()/PropertyInt16")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .n()
- .isFunction("BFCESKeyNavRTETKeyNav")
- .n()
- .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
-
- testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNav()/PropertyInt16/$value")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .n()
- .isFunction("BFCESKeyNavRTETKeyNav")
- .n()
- .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false)
- .n()
- .isValue();
-
- }
-
- @Test
- public void runBfuncBnEsRtEs() {
-
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav);
-
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav(ParameterString='2')")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTESTwoKeyNav")
- .isParameter(0, "ParameterString", "'2'")
- .isType(EntityTypeProvider.nameETTwoKeyNav);
-
- testUri.run("ESKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav);
-
- testUri.run("ESKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav(ParameterString='3')")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTESTwoKeyNav")
- .isParameter(0, "ParameterString", "'3'")
- .isType(EntityTypeProvider.nameETTwoKeyNav);
-
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()/$count")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .n()
- .isCount();
-
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()(PropertyInt16=1,PropertyString='2')")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTESTwoKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'");
-
- }
-
- @Test
- public void runBfuncBnEsRtEsBa() {
-
- testUri.run("ESKeyNav(PropertyInt16=1)/CollPropertyComplex"
- + "/com.sap.odata.test1.BFCCollCTPrimCompRTESAllPrim()/com.sap.odata.test1.BAESAllPrimRTETAllPrim")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isComplex("CollPropertyComplex")
- .isType(ComplexTypeProvider.nameCTPrimComp)
- .n()
- .isFunction("BFCCollCTPrimCompRTESAllPrim")
- .n()
- .isAction("BAESAllPrimRTETAllPrim");
-
- }
-
- @Test
- public void runBfuncBnEsRtPrim() {
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTString()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTString");
-
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTString()/$value")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTString")
- .isType(PropertyProvider.nameString)
- .n()
- .isValue();
- }
-
- @Test
- public void runbfuncBnEsRtPrimColl() {
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCollString()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTCollString")
- .isType(PropertyProvider.nameString, true);
-
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCollString()/$count")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .n()
- .isFunction("BFCESTwoKeyNavRTCollString")
- .isType(PropertyProvider.nameString, true)
- .n()
- .isCount();
- }
-
- @Test
- public void runBfuncBnPpropCollRtEs() {
- testUri.run("ESKeyNav(1)/CollPropertyString/com.sap.odata.test1.BFCCollStringRTESTwoKeyNav()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isPrimitiveProperty("CollPropertyString", PropertyProvider.nameString, true)
- .n()
- .isFunction("BFCCollStringRTESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav, true);
-
- testUri.run("ESKeyNav(1)/CollPropertyString/com.sap.odata.test1.BFCCollStringRTESTwoKeyNav()/$count")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isPrimitiveProperty("CollPropertyString", PropertyProvider.nameString, true)
- .n()
- .isFunction("BFCCollStringRTESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav, true)
- .n()
- .isCount();
- }
-
- @Test
- public void runBfuncBnPpropRtEs() {
-
- testUri.run("ESKeyNav(1)/PropertyString/com.sap.odata.test1.BFCStringRTESTwoKeyNav()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false)
- .n()
- .isFunction("BFCStringRTESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav, true);
-
- testUri.run("ESKeyNav(1)/PropertyString/com.sap.odata.test1.BFCStringRTESTwoKeyNav()/$count")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false)
- .n()
- .isFunction("BFCStringRTESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav, true)
- .n()
- .isCount();
-
- testUri.run("ESKeyNav(1)/PropertyString/com.sap.odata.test1.BFCStringRTESTwoKeyNav()/$ref")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false)
- .n()
- .isFunction("BFCStringRTESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav, true)
- .n()
- .isRef();
- }
-
- @Test
- public void runBfuncBnSingleRtEs() {
-
- testUri.run("SINav/com.sap.odata.test1.BFCSINavRTESTwoKeyNav()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .n()
- .isFunction("BFCSINavRTESTwoKeyNav");
- }
-
- @Test
- public void runBfuncBnSingleCastRtEs() {
- testUri.run("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/com.sap.odata.test1.BFCETBaseTwoKeyNavRTESBaseTwoKey()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .isTypeFilter(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isFunction("BFCETBaseTwoKeyNavRTESBaseTwoKey");
- }
-
- @Test
- public void runActionBound_on_EntityEntry() {
-
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.BAETTwoKeyNavRTETTwoKeyNav")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .n()
- .isAction("BAETTwoKeyNavRTETTwoKeyNav");
-
- testUri.run("ESKeyNav(PropertyInt16=1)/com.sap.odata.test1.BAETTwoKeyNavRTETTwoKeyNav")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isAction("BAETTwoKeyNavRTETTwoKeyNav");
- }
-
- @Test
- public void runActionBound_on_EntityCollection() {
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BAESTwoKeyNavRTESTwoKeyNav")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .n()
- .isAction("BAESTwoKeyNavRTESTwoKeyNav");
- }
-
- @Test
- public void runFunctionBound_on_var_Types() {
-
- // on primitive
- testUri.run("ESAllPrim(1)/PropertyString/com.sap.odata.test1.BFCStringRTESTwoKeyNav()")
- .goPath()
- .at(0)
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETAllPrim, false)
- .at(1)
- .isUriPathInfoKind(UriResourceKind.primitiveProperty)
- .isType(PropertyProvider.nameString);
-
- // on collection of primitive
- testUri.run("ESCollAllPrim(1)/CollPropertyString/com.sap.odata.test1.BFCCollStringRTESTwoKeyNav()")
- .goPath()
- .at(0)
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETCollAllPrim, false)
- .at(1)
- .isUriPathInfoKind(UriResourceKind.primitiveProperty)
- .isType(PropertyProvider.nameString);
-
- // on complex
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='ABC')"
- + "/PropertyComplex/com.sap.odata.test1.BFCCTPrimCompRTESTwoKeyNav()")
- .goPath()
- .at(0)
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .at(1)
- .isUriPathInfoKind(UriResourceKind.complexProperty)
- .at(2)
- .isType(EntityTypeProvider.nameETTwoKeyNav);
-
- // on collection of complex
- testUri.run("ESKeyNav(1)/CollPropertyComplex/com.sap.odata.test1.BFCCollCTPrimCompRTESAllPrim()")
- .goPath()
- .at(0)
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .at(1)
- .isType(ComplexTypeProvider.nameCTPrimComp, true)
- .at(2)
- .isUriPathInfoKind(UriResourceKind.function)
- .isType(EntityTypeProvider.nameETAllPrim);
-
- // on entity
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='ABC')"
- + "/com.sap.odata.test1.BFCETTwoKeyNavRTESTwoKeyNav()")
- .goPath()
- .at(0)
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .at(1)
- .isUriPathInfoKind(UriResourceKind.function)
- .isType(EntityTypeProvider.nameETTwoKeyNav);
-
- // on collection of entity
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()")
- .goPath()
- .at(0)
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETTwoKeyNav, true)
- .at(1).isUriPathInfoKind(UriResourceKind.function)
- .isType(EntityTypeProvider.nameETTwoKeyNav);
- }
-
- @Test
- public void runActionBound_on_EntityCast() {
-
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
- + "/com.sap.odata.test1.BAETBaseTwoKeyNavRTETBaseTwoKeyNav")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isAction("BAETBaseTwoKeyNavRTETBaseTwoKeyNav");
-
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=1,PropertyString='2')"
- + "/com.sap.odata.test1.ETTwoBaseTwoKeyNav/com.sap.odata.test1.BAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETTwoBaseTwoKeyNav)
- .n()
- .isAction("BAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav");
- }
-
- @Test
- public void runCrossjoin() {
- testUri.run("$crossjoin(ESKeyNav)")
- .isKind(UriInfoKind.crossjoin)
- .isCrossJoinEntityList(Arrays.asList("ESKeyNav"));
-
- testUri.run("$crossjoin(ESKeyNav, ESTwoKeyNav)")
- .isKind(UriInfoKind.crossjoin)
- .isCrossJoinEntityList(Arrays.asList("ESKeyNav", "ESTwoKeyNav"));
- }
-
- @Test
- public void runCrossjoinError() {
- testUri.runEx("$crossjoin").isExSyntax(0);
- testUri.runEx("$crossjoin/error").isExSyntax(0);
- testUri.runEx("$crossjoin()").isExSyntax(0);
- // testUri.runEx("$crossjoin(ESKeyNav, ESTwoKeyNav)/invalid").isExSyntax(0);
- }
-
- @Test
- public void runEntityId() {
- testUri.run("$entity?$id=ESKeyNav(1)")
- .isKind(UriInfoKind.entityId)
- .isIdText("ESKeyNav(1)");
- testUri.run("$entity/com.sap.odata.test1.ETKeyNav?$id=ESKeyNav(1)")
- .isKind(UriInfoKind.entityId)
- .isEntityType(EntityTypeProvider.nameETKeyNav)
- .isIdText("ESKeyNav(1)");
- }
-
- @Test
- public void runEntityIdError() {
- // TODO planned: move to validator
- // testUri.runEx("$entity").isExSyntax(0);
- // testUri.runEx("$entity?$idfalse=ESKeyNav(1)").isExSyntax(0);
- // testUri.runEx("$entity/com.sap.odata.test1.invalidType?$id=ESKeyNav(1)").isExSemantic(0);
- // testUri.runEx("$entity/invalid?$id=ESKeyNav(1)").isExSyntax(0);
- }
-
- @Test
- public void runEsName() {
- testUri.run("ESAllPrim")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESAllPrim")
- .isType(EntityTypeProvider.nameETAllPrim, true);
-
- testUri.run("ESAllPrim/$count")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESAllPrim")
- .isType(EntityTypeProvider.nameETAllPrim, true)
- .n()
- .isCount();
- }
-
- @Test
- public void runEsNameError() {
-
- testUri.runEx("ESAllPrim/$count/$ref").isExSemantic(0);
- testUri.runEx("ESAllPrim/$ref/$count").isExSemantic(0);
- testUri.runEx("ESAllPrim/$ref/invalid").isExSemantic(0);
- testUri.runEx("ESAllPrim/$count/invalid").isExSemantic(0);
- testUri.runEx("ESAllPrim(1)/whatever").isExSemantic(0);
- // testUri.runEx("ESAllPrim(PropertyInt16='1')").isExSemantic(0);
- testUri.runEx("ESAllPrim(PropertyInt16)").isExSemantic(0);
- testUri.runEx("ESAllPrim(PropertyInt16=)").isExSyntax(0);
- testUri.runEx("ESAllPrim(PropertyInt16=1,Invalid='1')").isExSemantic(0);
-
- testUri.runEx("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETBaseTwoKeyTwoPrim"
- + "/com.sap.odata.test1.ETTwoBaseTwoKeyTwoPrim").isExSemantic(0);
-
- testUri.runEx("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETBaseTwoKeyTwoPrim(1)/com.sap.odata.test1.ETAllKey")
- .isExSemantic(0);
-
- testUri.runEx("ETBaseTwoKeyTwoPrim(1)/com.sap.odata.test1.ETBaseTwoKeyTwoPrim('1')/com.sap.odata.test1.ETAllKey")
- .isExSemantic(0);
-
- testUri.runEx("ETBaseTwoKeyTwoPrim(1)/com.sap.odata.test1.ETBaseTwoKeyTwoPrim"
- + "/com.sap.odata.test1.ETTwoBaseTwoKeyTwoPrim")
- .isExSemantic(0);
-
- testUri.runEx("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETBaseTwoKeyTwoPrim"
- + "/com.sap.odata.test1.ETTwoBaseTwoKeyTwoPrim(1)")
- .isExSemantic(0);
-
- testUri.runEx("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETAllKey")
- .isExSemantic(0);
-
- testUri.runEx("ETBaseTwoKeyTwoPrim()")
- .isExSemantic(0);
-
- testUri.runEx("ESAllNullable(1)/CollPropertyString/$value")
- .isExSemantic(0);
-
- testUri.runEx("ETMixPrimCollComp(1)/ComplexProperty/$value").isExSemantic(0);
- }
-
- @Test
- public void runEsNameCast() {
- testUri.run("ESTwoPrim/com.sap.odata.test1.ETBase")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoPrim")
- .isType(EntityTypeProvider.nameETTwoPrim, true)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBase);
-
- testUri.run("ESTwoPrim/com.sap.odata.test1.ETBase(-32768)/com.sap.odata.test1.ETTwoBase")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoPrim")
- .isType(EntityTypeProvider.nameETTwoPrim, false)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBase)
- .isKeyPredicate(0, "PropertyInt16", "-32768")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETTwoBase);
-
- testUri.run("ESTwoPrim/com.sap.odata.test1.ETTwoBase(-32768)")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoPrim")
- .isType(EntityTypeProvider.nameETTwoPrim, false)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETTwoBase)
- .isKeyPredicate(0, "PropertyInt16", "-32768");
-
- testUri.run("ESTwoPrim/Namespace1_Alias.ETTwoBase(-32768)")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoPrim")
- .isType(EntityTypeProvider.nameETTwoPrim, false)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETTwoBase)
- .isKeyPredicate(0, "PropertyInt16", "-32768");
-
- }
-
- @Test
- public void runEsNamePpSpCast() {
-
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isPrimitiveProperty("PropertyDate", PropertyProvider.nameDate, false);
-
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
- + "/PropertyComplex/PropertyInt16")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isComplex("PropertyComplex")
- .n()
- .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
- }
-
- @Test
- public void runEsNameKey() {
- testUri.run("ESCollAllPrim(1)")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESCollAllPrim");
-
- testUri.run("ESCollAllPrim(PropertyInt16=1)")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESCollAllPrim");
-
- testUri.run("ESFourKeyAlias(PropertyInt16=1,KeyAlias1=2,KeyAlias2='3',KeyAlias3='4')")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESFourKeyAlias")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "KeyAlias1", "2")
- .isKeyPredicate(2, "KeyAlias2", "'3'")
- .isKeyPredicate(3, "KeyAlias3", "'4'");
-
- testUri.run("ESCollAllPrim(null)")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESCollAllPrim");
- }
-
- @Test
- public void runEsNameParaKeys() throws UnsupportedEncodingException {
- testUri.run(encode("ESAllKey(PropertyString='O''Neil',PropertyBoolean=true,PropertyByte=255,"
- + "PropertySByte=-128,PropertyInt16=-32768,PropertyInt32=-2147483648,"
- + "PropertyInt64=-9223372036854775808,PropertyDecimal=0.1,PropertyDate=2013-09-25,"
- + "PropertyDateTimeOffset=2002-10-10T12:00:00-05:00,"
- + "PropertyDuration=duration'P10DT5H34M21.123456789012S',"
- + "PropertyGuid=12345678-1234-1234-1234-123456789012,"
- + "PropertyTimeOfDay=12:34:55.123456789012)"))
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESAllKey")
- .isKeyPredicate(0, "PropertyString", "'O''Neil'")
- .isKeyPredicate(1, "PropertyBoolean", "true")
- .isKeyPredicate(2, "PropertyByte", "255")
- .isKeyPredicate(3, "PropertySByte", "-128")
- .isKeyPredicate(4, "PropertyInt16", "-32768")
- .isKeyPredicate(5, "PropertyInt32", "-2147483648")
- .isKeyPredicate(6, "PropertyInt64", "-9223372036854775808")
- .isKeyPredicate(7, "PropertyDecimal", "0.1")
- .isKeyPredicate(8, "PropertyDate", "2013-09-25")
- .isKeyPredicate(9, "PropertyDateTimeOffset", "2002-10-10T12:00:00-05:00")
- .isKeyPredicate(10, "PropertyDuration", "duration'P10DT5H34M21.123456789012S'")
- .isKeyPredicate(11, "PropertyGuid", "12345678-1234-1234-1234-123456789012")
- .isKeyPredicate(12, "PropertyTimeOfDay", "12:34:55.123456789012");
- }
-
- @Test
- public void runEsNameKeyCast() {
- /*
- * testUri.runEx("ESTwoPrim(1)/com.sap.odata.test1.ETBase(1)")
- * .isExSemantic(0);
- *
- * testUri.runEx("ESTwoPrim/com.sap.odata.test1.ETBase(1)/com.sap.odata.test1.ETTwoBase(1)")
- * .isExSemantic(0);
- *
- * testUri.runEx("ESBase/com.sap.odata.test1.ETTwoPrim(1)")
- * .isExSemantic(0);
- */
-
- testUri.run("ESTwoPrim(1)/com.sap.odata.test1.ETBase")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoPrim")
- .isType(EntityTypeProvider.nameETTwoPrim)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBase);
-
- testUri.run("ESTwoPrim(1)/com.sap.odata.test1.ETTwoBase")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoPrim")
- .isType(EntityTypeProvider.nameETTwoPrim)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETTwoBase);
-
- testUri.run("ESTwoPrim/com.sap.odata.test1.ETBase(1)")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoPrim")
- .isType(EntityTypeProvider.nameETTwoPrim)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBase);
-
- testUri.run("ESTwoPrim/com.sap.odata.test1.ETTwoBase(1)")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoPrim")
- .isType(EntityTypeProvider.nameETTwoPrim)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isTypeFilterOnCollection(EntityTypeProvider.nameETTwoBase);
-
- testUri.run("ESTwoPrim/com.sap.odata.test1.ETBase(1)/com.sap.odata.test1.ETTwoBase")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoPrim")
- .isType(EntityTypeProvider.nameETTwoPrim)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBase);
-
- testUri.run("ESTwoPrim/com.sap.odata.test1.ETTwoBase")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoPrim")
- .isType(EntityTypeProvider.nameETTwoPrim)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETTwoBase);
- }
-
- @Test
- public void runEsNameParaKeysCast() {
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav);
-
- testUri.run("ESTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=1,PropertyString='2')")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'");
- }
-
- @Test
- public void run_EsNamePpCp() {
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyComplex")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .n()
- .isComplex("PropertyComplex");
-
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyComplex/PropertyComplex")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .n()
- .isComplex("PropertyComplex")
- .n()
- .isComplex("PropertyComplex");
- }
-
- @Test
- public void runEsNamePpCpColl() {
- testUri.run("ESMixPrimCollComp(5)/CollPropertyComplex")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESMixPrimCollComp")
- .isKeyPredicate(0, "PropertyInt16", "5")
- .n()
- .isComplex("CollPropertyComplex")
- .isType(ComplexTypeProvider.nameCTTwoPrim, true);
-
- testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne/CollPropertyComplex")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
- .n()
- .isComplex("CollPropertyComplex")
- .isType(ComplexTypeProvider.nameCTPrimComp, true);
-
- testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne/CollPropertyComplex/$count")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
- .n()
- .isComplex("CollPropertyComplex")
- .isType(ComplexTypeProvider.nameCTPrimComp, true)
- .n()
- .isCount();
- }
-
- @Test
- public void runEsNamePpCpCast() {
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyComplex")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isComplex("PropertyComplex");
-
- testUri
- .run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
- + "/PropertyComplex/PropertyComplex")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .n()
- .isComplex("PropertyComplex")
- .n()
- .isComplex("PropertyComplex");
-
- testUri
- .run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
- + "/PropertyComplexTwoPrim/com.sap.odata.test1.CTBase")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
-
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isComplex("PropertyComplexTwoPrim")
- .isType(ComplexTypeProvider.nameCTTwoPrim)
- .isTypeFilter(ComplexTypeProvider.nameCTBase);
-
- testUri
- .run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
- + "/PropertyComplexTwoPrim/com.sap.odata.test1.CTTwoBase")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isComplex("PropertyComplexTwoPrim")
- .isType(ComplexTypeProvider.nameCTTwoPrim)
- .isTypeFilter(ComplexTypeProvider.nameCTTwoBase);
- }
-
- @Test
- public void runNsNamePpNp() {
- testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, true);
-
- testUri.run("ESKeyNav(1)/NavPropertyETKeyNavMany(2)")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "2");
-
- testUri.run("ESKeyNav(PropertyInt16=1)/NavPropertyETKeyNavMany(PropertyInt16=2)")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "2");
-
- testUri.run("ESKeyNav(1)/NavPropertyETKeyNavMany(2)/PropertyInt16")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "2")
- .n()
- .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
-
- testUri.run("ESKeyNav(1)/NavPropertyETKeyNavMany(2)/PropertyComplex")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "2")
- .n()
- .isComplex("PropertyComplex");
-
- testUri.run("ESKeyNav(1)/NavPropertyETKeyNavMany(2)/NavPropertyETKeyNavOne")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "2")
- .n()
- .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false);
-
- testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')"
- + "/NavPropertyETKeyNavMany(4)")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "2")
- .isKeyPredicate(1, "PropertyString", "'3'")
- .n()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "4");
-
- testUri.run("ESKeyNav(1)/PropertyComplex/NavPropertyETTwoKeyNavOne")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isComplex("PropertyComplex")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false);
-
- testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='(3)')"
- + "/PropertyComplex/PropertyComplex/PropertyInt16")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "2")
- .isKeyPredicate(1, "PropertyString", "'(3)'")
- .n()
- .isComplex("PropertyComplex")
- .n()
- .isComplex("PropertyComplex")
- .n()
- .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
-
- testUri.run("ESKeyNav(1)/NavPropertyETMediaMany(2)/$value")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETMediaMany", EntityTypeProvider.nameETMedia, false)
- .isKeyPredicate(0, "PropertyInt16", "2")
- .n()
- .isValue();
-
- testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')"
- + "/NavPropertyETKeyNavOne/NavPropertyETMediaOne/$value")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "2")
- .isKeyPredicate(1, "PropertyString", "'3'")
- .n()
- .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false)
- .n()
- .isNavProperty("NavPropertyETMediaOne", EntityTypeProvider.nameETMedia, false)
- .n()
- .isValue();
-
- testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')"
- + "/NavPropertyETKeyNavOne/$ref")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "2")
- .isKeyPredicate(1, "PropertyString", "'3'")
- .n()
- .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false)
- .n()
- .isRef();
- }
-
- @Test
- public void runEsNamePpNpCast() {
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
- + "/NavPropertyETKeyNavMany")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true);
-
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
- + "/NavPropertyETKeyNavMany(3)")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "3");
-
- testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
- + "/NavPropertyETTwoKeyNavMany/com.sap.odata.test1.ETTwoBaseTwoKeyNav(PropertyInt16=3,PropertyString='4')")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESTwoKeyNav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "3")
- .isKeyPredicate(1, "PropertyString", "'4'")
- .isTypeFilterOnCollection(EntityTypeProvider.nameETTwoBaseTwoKeyNav);
-
- testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')"
- + "/NavPropertyETTwoKeyNavMany/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=4,PropertyString='5')"
- + "/com.sap.odata.test1.ETTwoBaseTwoKeyNav/NavPropertyETBaseTwoKeyNavMany")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "2")
- .isKeyPredicate(1, "PropertyString", "'3'")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "4")
- .isKeyPredicate(1, "PropertyString", "'5'")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETTwoBaseTwoKeyNav)
- .n()
- .isNavProperty("NavPropertyETBaseTwoKeyNavMany", EntityTypeProvider.nameETBaseTwoKeyNav, true);
-
- testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')/"
- + "NavPropertyETTwoKeyNavMany/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=4,PropertyString='5')/"
- + "NavPropertyETKeyNavMany")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "2")
- .isKeyPredicate(1, "PropertyString", "'3'")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "4")
- .isKeyPredicate(1, "PropertyString", "'5'")
- .n()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true);
- }
-
- @Test
- public void runEsNamePpNpRc() {
- // checks for using referential constrains to fill missing keys
- testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany('2')").goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicateRef(0, "PropertyInt16", "PropertyInt16")
- .isKeyPredicate(1, "PropertyString", "'2'");
-
- testUri.run("ESKeyNav(PropertyInt16=1)/NavPropertyETTwoKeyNavMany(PropertyString='2')").goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicateRef(0, "PropertyInt16", "PropertyInt16")
- .isKeyPredicate(1, "PropertyString", "'2'");
-
- }
-
- @Test
- public void runEsNamePpSp() {
- testUri.run("ESAllPrim(1)/PropertyByte")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESAllPrim")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isPrimitiveProperty("PropertyByte", PropertyProvider.nameByte, false);
-
- testUri.run("ESAllPrim(1)/PropertyByte/$value")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESAllPrim")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isPrimitiveProperty("PropertyByte", PropertyProvider.nameByte, false)
- .n()
- .isValue();
-
- testUri.run("ESMixPrimCollComp(1)/PropertyComplex/PropertyString")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESMixPrimCollComp")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isComplex("PropertyComplex")
- .n()
- .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
- }
-
- @Test
- public void runEsNamePpSpColl() {
- testUri.run("ESCollAllPrim(1)/CollPropertyString")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESCollAllPrim")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isPrimitiveProperty("CollPropertyString", PropertyProvider.nameString, true);
-
- testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')/CollPropertyString")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .n()
- .isPrimitiveProperty("CollPropertyString", PropertyProvider.nameString, true);
-
- testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')/CollPropertyString/$count")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "2")
- .isKeyPredicate(1, "PropertyString", "'3'")
- .n()
- .isPrimitiveProperty("CollPropertyString", PropertyProvider.nameString, true)
- .n()
- .isCount();
-
- }
-
- @Test
- public void runEsNameRef() {
- testUri.run("ESAllPrim/$ref")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESAllPrim")
- .n()
- .isRef();
-
- testUri.run("ESAllPrim(-32768)/$ref")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESAllPrim")
- .isKeyPredicate(0, "PropertyInt16", "-32768")
- .n()
- .isRef();
- testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany/$ref")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, true)
- .n()
- .isRef();
- testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=1,PropertyString='2')/$ref")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isEntitySet("ESKeyNav")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'")
- .n()
- .isRef();
- }
-
- @Test
- public void runFunctionImpBf() {
-
- testUri.run("FICRTString()/com.sap.odata.test1.BFCStringRTESTwoKeyNav()");
- }
-
- @Test
- public void runFunctionImpCastBf() {
-
- testUri.run("FICRTETTwoKeyNavParam(ParameterInt16=1)/com.sap.odata.test1.ETBaseTwoKeyNav"
- + "/com.sap.odata.test1.BFCETBaseTwoKeyNavRTETTwoKeyNav()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isFunctionImport("FICRTETTwoKeyNavParam")
- .isFunction("UFCRTETTwoKeyNavParam")
- .isParameter(0, "ParameterInt16", "1")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isFunction("BFCETBaseTwoKeyNavRTETTwoKeyNav");
-
- testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)"
- + "/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=2,PropertyString='3')"
- + "/com.sap.odata.test1.BFCETBaseTwoKeyNavRTETTwoKeyNav()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isFunctionImport("FICRTESTwoKeyNavParam")
- .isFunction("UFCRTESTwoKeyNavParam")
- .isParameter(0, "ParameterInt16", "1")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "2")
- .isKeyPredicate(1, "PropertyString", "'3'")
- .n()
- .isFunction("BFCETBaseTwoKeyNavRTETTwoKeyNav");
- }
-
- @Test
- public void runFunctionImpEntity() {
-
- testUri.run("FICRTETKeyNav()")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isFunctionImport("FICRTETKeyNav")
- .isFunction("UFCRTETKeyNav")
- .isType(EntityTypeProvider.nameETKeyNav);
-
- testUri.run("FICRTETTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=2,PropertyString='3')")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isFunctionImport("FICRTETTwoKeyNavParam")
- .isParameter(0, "ParameterInt16", "1")
- .isKeyPredicate(0, "PropertyInt16", "2")
- .isKeyPredicate(1, "PropertyString", "'3'");
-
- testUri.run("FICRTETMedia()/$value")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isFunctionImport("FICRTETMedia")
- .isFunction("UFCRTETMedia")
- .n()
- .isValue();
-
- testUri.run("FICRTETKeyNav()/$ref")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isFunctionImport("FICRTETKeyNav")
- .isFunction("UFCRTETKeyNav")
- .n()
- .isRef();
- testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)/$ref")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isFunctionImport("FICRTESTwoKeyNavParam")
- .isFunction("UFCRTESTwoKeyNavParam")
- .n()
- .isRef();
-
- testUri.run("FICRTETTwoKeyNavParam(ParameterInt16=1)/com.sap.odata.test1.ETBaseTwoKeyNav")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isFunctionImport("FICRTETTwoKeyNavParam")
- .isFunction("UFCRTETTwoKeyNavParam")
- .isParameter(0, "ParameterInt16", "1")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav);
-
- testUri.run("FICRTETTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=2,PropertyString='3')"
- + "/com.sap.odata.test1.ETBaseTwoKeyNav")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isFunctionImport("FICRTETTwoKeyNavParam")
- .isFunction("UFCRTETTwoKeyNavParam")
- .isParameter(0, "ParameterInt16", "1")
- .isKeyPredicate(0, "PropertyInt16", "2")
- .isKeyPredicate(1, "PropertyString", "'3'")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav);
-
- testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)"
- + "/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=2,PropertyString='3')")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isFunctionImport("FICRTESTwoKeyNavParam")
- .isFunction("UFCRTESTwoKeyNavParam")
- .isParameter(0, "ParameterInt16", "1")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "2")
- .isKeyPredicate(1, "PropertyString", "'3'");
- }
-
- @Test
- public void runFunctionImpEs() {
- /**/
- testUri.run("FICRTESMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='2')")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isFunctionImport("FICRTESMixPrimCollCompTwoParam")
- .isFunction("UFCRTESMixPrimCollCompTwoParam")
- .isParameter(0, "ParameterInt16", "1")
- .isParameter(1, "ParameterString", "'2'")
- .isType(EntityTypeProvider.nameETMixPrimCollComp);
-
- testUri.run("FINRTESMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='2')")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isFunctionImport("FINRTESMixPrimCollCompTwoParam")
- .isFunction("UFNRTESMixPrimCollCompTwoParam")
- .isParameter(0, "ParameterInt16", "1")
- .isParameter(1, "ParameterString", "'2'")
- .isType(EntityTypeProvider.nameETMixPrimCollComp);
-
- testUri.run("FICRTESMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='2')/$count")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isFunctionImport("FICRTESMixPrimCollCompTwoParam")
- .isFunction("UFCRTESMixPrimCollCompTwoParam")
- .isParameter(0, "ParameterInt16", "1")
- .isParameter(1, "ParameterString", "'2'")
- .isType(EntityTypeProvider.nameETMixPrimCollComp)
- .n()
- .isCount();
- }
-
- @Test
- public void runFunctionImpError() {
- testUri.runEx("FICRTCollCTTwoPrimParam()").isExSemantic(0);
- testUri.runEx("FICRTCollCTTwoPrimParam(invalidParam=2)").isExSemantic(0);
- }
-
- @Test
- public void runFunctionImpEsAlias() {
-
- testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=@parameterAlias)?@parameterAlias=1");
- testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=@parameterAlias)/$count?@parameterAlias=1");
- testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=@invalidAlias)?@validAlias=1");
- }
-
- @Test
- public void runFunctionImpEsCast() {
-
- testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)/com.sap.odata.test1.ETBaseTwoKeyNav")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isFunctionImport("FICRTESTwoKeyNavParam")
- .isFunction("UFCRTESTwoKeyNavParam")
- .isParameter(0, "ParameterInt16", "1")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav);
-
- testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)/com.sap.odata.test1.ETBaseTwoKeyNav/$count")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isFunctionImport("FICRTESTwoKeyNavParam")
- .isFunction("UFCRTESTwoKeyNavParam")
- .isParameter(0, "ParameterInt16", "1")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isCount();
-
- testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)"
- + "/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=2,PropertyString='3')")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isFunctionImport("FICRTESTwoKeyNavParam")
- .isFunction("UFCRTESTwoKeyNavParam")
- .isParameter(0, "ParameterInt16", "1")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "2")
- .isKeyPredicate(1, "PropertyString", "'3'");
-
- testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)"
- + "/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=2,PropertyString='3')"
- + "/com.sap.odata.test1.ETTwoBaseTwoKeyNav")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isFunctionImport("FICRTESTwoKeyNavParam")
- .isFunction("UFCRTESTwoKeyNavParam")
- .isParameter(0, "ParameterInt16", "1")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "2")
- .isKeyPredicate(1, "PropertyString", "'3'")
- .isTypeFilterOnEntry(EntityTypeProvider.nameETTwoBaseTwoKeyNav);
-
- }
-
- @Test
- public void runSingletonEntityValue() {
- testUri.run("SIMedia/$value")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SIMedia")
- .n().isValue();
- }
-
- @Test
- public void runSingletonPpNpCast() {
- testUri.run("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/NavPropertyETKeyNavMany")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilter(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true);
-
- testUri.run("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/NavPropertyETKeyNavMany(1)")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilter(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1");
-
- }
-
- @Test
- public void runSingletonPpCpCast() {
- testUri.run("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyComplex")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilter(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isComplex("PropertyComplex");
-
- testUri.run("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyComplex/PropertyComplex")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilter(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isComplex("PropertyComplex")
- .n()
- .isComplex("PropertyComplex");
-
- testUri.run("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyComplexTwoPrim/com.sap.odata.test1.CTBase")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilter(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isComplex("PropertyComplexTwoPrim")
- .isType(ComplexTypeProvider.nameCTTwoPrim)
- .isTypeFilter(ComplexTypeProvider.nameCTBase);
-
- }
-
- @Test
- public void runSingletonPpSpCast() {
- testUri.run("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyInt16")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilter(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
-
- testUri.run("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/CollPropertyString")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .isTypeFilter(EntityTypeProvider.nameETBaseTwoKeyNav)
- .n()
- .isPrimitiveProperty("CollPropertyString", PropertyProvider.nameString, true)
- .isType(PropertyProvider.nameString, true);
-
- }
-
- @Test
- public void runSingletonEntityPpNp() {
- testUri.run("SINav/NavPropertyETKeyNavMany")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .n()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true);
-
- testUri.run("SINav/NavPropertyETTwoKeyNavMany(PropertyInt16=1,PropertyString='2')")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .n()
- .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'2'");
-
- }
-
- @Test
- public void runSingletonEntityPpCp() {
- testUri.run("SINav/PropertyComplex")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .n()
- .isComplex("PropertyComplex");
-
- testUri.run("SINav/PropertyComplex/PropertyComplex")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .n()
- .isComplex("PropertyComplex")
- .n()
- .isComplex("PropertyComplex");
-
- }
-
- @Test
- public void runSingletonEntityPpCpColl() {
- testUri.run("SINav/CollPropertyComplex")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .n()
- .isComplex("CollPropertyComplex")
- .isType(ComplexTypeProvider.nameCTPrimComp, true);
-
- testUri.run("SINav/CollPropertyComplex/$count")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .n()
- .isComplex("CollPropertyComplex")
- .isType(ComplexTypeProvider.nameCTPrimComp, true)
- .n()
- .isCount();
- }
-
- @Test
- public void runSingletonEntityPpSp() {
- testUri.run("SINav/PropertyString")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .n()
- .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
- }
-
- @Test
- public void runSingletonEntityPpSpColl() {
- testUri.run("SINav/CollPropertyString")
-
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .n()
- .isPrimitiveProperty("CollPropertyString", PropertyProvider.nameString, true);
- testUri.run("SINav/CollPropertyString/$count")
- .isKind(UriInfoKind.resource).goPath()
- .first()
- .isSingleton("SINav")
- .n()
- .isPrimitiveProperty("CollPropertyString", PropertyProvider.nameString, true)
- .n()
- .isCount();
- }
-
- @Test
- public void runExpand() {
-
- testUri.run("ESKeyNav(1)?$expand=*")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .isSegmentStar(0);
-
- testUri.run("ESKeyNav(1)?$expand=*/$ref")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .isSegmentStar(0)
- .isSegmentRef(1);
-
- testUri.run("ESKeyNav(1)?$expand=*/$ref,NavPropertyETKeyNavMany")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .isSegmentStar(0).isSegmentRef(1)
- .next()
- .goPath().first()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true);
-
- testUri.run("ESKeyNav(1)?$expand=*($levels=3)")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .isSegmentStar(0)
- .isLevelText("3");
-
- testUri.run("ESKeyNav(1)?$expand=*($levels=max)")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .isSegmentStar(0)
- .isLevelText("max");
-
- testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .goPath().first()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
- .isType(EntityTypeProvider.nameETKeyNav, true)
- .n().isRef();
-
- testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavOne/$ref")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .goPath().first()
- .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false)
- .isType(EntityTypeProvider.nameETKeyNav, false)
- .n().isRef();
-
- testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($filter=PropertyInt16 eq 1)")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .goPath().first()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
- .isType(EntityTypeProvider.nameETKeyNav, true)
- .n().isRef()
- .goUpExpandValidator().isFilterSerialized("<<PropertyInt16> eq <1>>");
-
- testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($orderby=PropertyInt16)")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .goPath().first()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
- .isType(EntityTypeProvider.nameETKeyNav, true)
- .n().isRef()
- .goUpExpandValidator()
- .isSortOrder(0, false)
- .goOrder(0).goPath().isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
-
- testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($skip=1)")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .goPath().first()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
- .isType(EntityTypeProvider.nameETKeyNav, true)
- .n().isRef()
- .goUpExpandValidator()
- .isSkipText("1");
-
- testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($top=2)")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .goPath().first()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
- .isType(EntityTypeProvider.nameETKeyNav, true)
- .n().isRef()
- .goUpExpandValidator()
- .isTopText("2");
-
- testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($count=true)")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .goPath().first()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
- .isType(EntityTypeProvider.nameETKeyNav, true)
- .n().isRef()
- .goUpExpandValidator()
- .isInlineCountText("true");
-
- testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($skip=1;$top=3)")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .goPath().first()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
- .isType(EntityTypeProvider.nameETKeyNav, true)
- .n().isRef()
- .goUpExpandValidator()
- .isSkipText("1")
- .isTopText("3");
-
- testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($skip=1%3b$top=3)")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .goPath().first()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
- .isType(EntityTypeProvider.nameETKeyNav, true)
- .n().isRef()
- .goUpExpandValidator()
- .isSkipText("1")
- .isTopText("3");
-
- testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$count")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .goPath().first()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
- .isType(EntityTypeProvider.nameETKeyNav, true)
- .n().isCount();
-
- testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavOne/$count")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .goPath().first()
- .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false)
- .isType(EntityTypeProvider.nameETKeyNav, false)
- .n().isCount();
-
- testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$count($filter=PropertyInt16 gt 1)")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .goPath().first()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
- .isType(EntityTypeProvider.nameETKeyNav, true)
- .n().isCount()
- .goUpExpandValidator()
- .isFilterSerialized("<<PropertyInt16> gt <1>>");
-
- testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($filter=PropertyInt16 eq 1)")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .goPath().first()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
- .isType(EntityTypeProvider.nameETKeyNav, true)
- .goUpExpandValidator()
- .isFilterSerialized("<<PropertyInt16> eq <1>>");
-
- testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($orderby=PropertyInt16)")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .goPath().first()
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
- .isType(EntityTypeProvider.nameETKeyNav, true)
- .goUpExpandValidator()
- .isSortOrder(0, false)
- .goOrder(0).goPath().isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
-
- testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($skip=1)")
- .isKind(UriInfoKind.resource).goPath().goExpand()
- .first()
- .goPath().first()
- .isNavProperty("NavProper
<TRUNCATED>
[13/15] [OLINGO-266] refactor ref module to server-ref
Posted by sk...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java b/lib/ref/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
deleted file mode 100644
index 4bf5a99..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
+++ /dev/null
@@ -1,133 +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.serializer.json;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.commons.api.edm.EdmEntitySet;
-import org.apache.olingo.commons.api.edm.EdmFunctionImport;
-import org.apache.olingo.commons.api.edm.EdmSingleton;
-import org.apache.olingo.server.api.ODataServer;
-import org.apache.olingo.server.api.serializer.ODataFormat;
-import org.apache.olingo.server.api.serializer.ODataSerializer;
-import org.apache.olingo.server.core.testutil.StringUtils;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ServiceDocumentTest {
-
- private Edm edm;
-
- @Before
- public void before() {
-
- EdmEntitySet edmEntitySet1 = mock(EdmEntitySet.class);
- when(edmEntitySet1.getName()).thenReturn("entitySetName1");
- when(edmEntitySet1.isIncludeInServiceDocument()).thenReturn(true);
-
- EdmEntitySet edmEntitySet2 = mock(EdmEntitySet.class);
- when(edmEntitySet2.getName()).thenReturn("entitySetName2");
- when(edmEntitySet2.isIncludeInServiceDocument()).thenReturn(true);
-
- EdmEntitySet edmEntitySet3 = mock(EdmEntitySet.class);
- when(edmEntitySet3.getName()).thenReturn("entitySetName3");
- when(edmEntitySet3.isIncludeInServiceDocument()).thenReturn(false);
-
- List<EdmEntitySet> entitySets = new ArrayList<EdmEntitySet>();
- entitySets.add(edmEntitySet1);
- entitySets.add(edmEntitySet2);
- entitySets.add(edmEntitySet3);
-
- EdmFunctionImport functionImport1 = mock(EdmFunctionImport.class);
- when(functionImport1.getName()).thenReturn("functionImport1");
- when(functionImport1.isIncludeInServiceDocument()).thenReturn(true);
-
- EdmFunctionImport functionImport2 = mock(EdmFunctionImport.class);
- when(functionImport2.getName()).thenReturn("functionImport2");
- when(functionImport2.isIncludeInServiceDocument()).thenReturn(true);
-
- EdmFunctionImport functionImport3 = mock(EdmFunctionImport.class);
- when(functionImport3.getName()).thenReturn("functionImport3");
- when(functionImport3.isIncludeInServiceDocument()).thenReturn(false);
-
- List<EdmFunctionImport> functionImports = new ArrayList<EdmFunctionImport>();
- functionImports.add(functionImport1);
- functionImports.add(functionImport2);
- functionImports.add(functionImport3);
-
- EdmSingleton singleton1 = mock(EdmSingleton.class);
- when(singleton1.getName()).thenReturn("singleton1");
-
- EdmSingleton singleton2 = mock(EdmSingleton.class);
- when(singleton2.getName()).thenReturn("singleton2");
-
- EdmSingleton singleton3 = mock(EdmSingleton.class);
- when(singleton3.getName()).thenReturn("singleton3");
-
- List<EdmSingleton> singletons = new ArrayList<EdmSingleton>();
- singletons.add(singleton1);
- singletons.add(singleton2);
- singletons.add(singleton3);
-
- EdmEntityContainer edmEntityContainer = mock(EdmEntityContainer.class);
- when(edmEntityContainer.getEntitySets()).thenReturn(entitySets);
- when(edmEntityContainer.getFunctionImports()).thenReturn(functionImports);
- when(edmEntityContainer.getSingletons()).thenReturn(singletons);
-
- edm = mock(Edm.class);
- when(edm.getEntityContainer(null)).thenReturn(edmEntityContainer);
- }
-
- @Test
- public void writeServiceDocumentJson() throws Exception {
- String serviceRoot = "http://localhost:8080/odata.svc";
-
- ODataServer server = ODataServer.newInstance();
- assertNotNull(server);
-
- ODataSerializer serializer = server.getSerializer(ODataFormat.JSON);
- assertNotNull(serializer);
-
- InputStream result = serializer.serviceDocument(edm, serviceRoot);
- assertNotNull(result);
- String jsonString = StringUtils.inputStreamToString(result, true);
-
- assertTrue(jsonString.contains("entitySetName1"));
- assertTrue(jsonString.contains("entitySetName2"));
- assertFalse(jsonString.contains("entitySetName3"));
-
- assertTrue(jsonString.contains("functionImport1"));
- assertTrue(jsonString.contains("functionImport2"));
- assertFalse(jsonString.contains("functionImport3"));
-
- assertTrue(jsonString.contains("singleton1"));
- assertTrue(jsonString.contains("singleton2"));
- assertTrue(jsonString.contains("singleton3"));
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java b/lib/ref/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
deleted file mode 100644
index 6a19364..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
+++ /dev/null
@@ -1,252 +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.serializer.xml;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.ODataRuntimeException;
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.Target;
-import org.apache.olingo.server.api.ODataServer;
-import org.apache.olingo.server.api.edm.provider.Action;
-import org.apache.olingo.server.api.edm.provider.ActionImport;
-import org.apache.olingo.server.api.edm.provider.ComplexType;
-import org.apache.olingo.server.api.edm.provider.EdmProvider;
-import org.apache.olingo.server.api.edm.provider.EntityContainer;
-import org.apache.olingo.server.api.edm.provider.EntitySet;
-import org.apache.olingo.server.api.edm.provider.EntityType;
-import org.apache.olingo.server.api.edm.provider.EnumMember;
-import org.apache.olingo.server.api.edm.provider.EnumType;
-import org.apache.olingo.server.api.edm.provider.Function;
-import org.apache.olingo.server.api.edm.provider.FunctionImport;
-import org.apache.olingo.server.api.edm.provider.NavigationProperty;
-import org.apache.olingo.server.api.edm.provider.NavigationPropertyBinding;
-import org.apache.olingo.server.api.edm.provider.Parameter;
-import org.apache.olingo.server.api.edm.provider.Property;
-import org.apache.olingo.server.api.edm.provider.ReturnType;
-import org.apache.olingo.server.api.edm.provider.Schema;
-import org.apache.olingo.server.api.edm.provider.Singleton;
-import org.apache.olingo.server.api.edm.provider.TypeDefinition;
-import org.apache.olingo.server.api.serializer.ODataFormat;
-import org.apache.olingo.server.api.serializer.ODataSerializer;
-import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
-import org.apache.olingo.server.core.testutil.StringUtils;
-import org.apache.olingo.server.core.testutil.techprovider.EdmTechProvider;
-import org.junit.Test;
-
-public class MetadataDocumentTest {
-
- @Test(expected = ODataRuntimeException.class)
- public void metadataOnJsonResultsInException() {
- ODataSerializer serializer = ODataServer.newInstance().getSerializer(ODataFormat.JSON);
- serializer.metadataDocument(mock(Edm.class));
- }
-
- @Test
- public void writeMetadataWithEmptyMockedEdm() {
- ODataSerializer serializer = ODataServer.newInstance().getSerializer(ODataFormat.XML);
- Edm edm = mock(Edm.class);
- serializer.metadataDocument(edm);
- }
-
- @Test
- public void writeMetadataWithLocalTestEdm() {
- ODataSerializer serializer = ODataServer.newInstance().getSerializer(ODataFormat.XML);
- Edm edm = new EdmProviderImpl(new TestMetadataProvider());
- InputStream metadata = serializer.metadataDocument(edm);
- assertNotNull(metadata);
- String metadataString = StringUtils.inputStreamToString(metadata, false);
- assertTrue(metadataString
- .contains("<edmx:Edmx Version=\"4.0\" xmlns:edmx=\"http://docs.oasis-open.org/odata/ns/edmx\">"));
-
- assertTrue(metadataString
- .contains("<Schema xmlns=\"http://docs.oasis-open.org/odata/ns/edm\" " +
- "Namespace=\"namespace\" Alias=\"alias\">"));
-
- assertTrue(metadataString
- .contains("<EntityType Name=\"ETBaseName\"><Property Name=\"P1\" Type=\"Edm.Int16\"/><NavigationProperty " +
- "Name=\"N1\" Type=\"namespace.ETBaseName\" Nullable=\"true\" Partner=\"N1\"/></EntityType>"));
-
- assertTrue(metadataString
- .contains("<EntityType Name=\"ETDerivedName\" BaseType=\"namespace.ETBaseName\"><Property Name=\"P2\" " +
- "Type=\"Edm.Int16\"/><NavigationProperty Name=\"N2\" Type=\"namespace.ETDerivedName\" Nullable=\"true\" " +
- "Partner=\"N2\"/></EntityType>"));
-
- assertTrue(metadataString
- .contains("<ComplexType Name=\"CTBaseName\"><Property Name=\"P1\" Type=\"Edm.Int16\"/><NavigationProperty " +
- "Name=\"N1\" Type=\"namespace.ETBaseName\" Nullable=\"true\" Partner=\"N1\"/></ComplexType>"));
-
- assertTrue(metadataString
- .contains("<ComplexType Name=\"CTDerivedName\" BaseType=\"namespace.CTBaseName\"><Property Name=\"P2\" " +
- "Type=\"Edm.Int16\"/><NavigationProperty Name=\"N2\" Type=\"namespace.ETDerivedName\" Nullable=\"true\" " +
- "Partner=\"N2\"/></ComplexType>"));
-
- assertTrue(metadataString.contains("<TypeDefinition Name=\"typeDef\" Type=\"Edm.Int16\"/>"));
-
- assertTrue(metadataString.contains("<Action Name=\"ActionWOParameter\" IsBound=\"false\"/>"));
-
- assertTrue(metadataString
- .contains("<Action Name=\"ActionName\" IsBound=\"true\"><Parameter Name=\"param\" Type=\"Edm.Int16\"/>" +
- "<Parameter Name=\"param2\" Type=\"Collection(Edm.Int16)\"/><ReturnType Type=\"namespace.CTBaseName\"/>" +
- "</Action>"));
-
- assertTrue(metadataString
- .contains("<Function Name=\"FunctionWOParameter\" IsBound=\"false\" IsComposable=\"false\"><ReturnType " +
- "Type=\"namespace.CTBaseName\"/></Function>"));
-
- assertTrue(metadataString
- .contains("<Function Name=\"FunctionName\" IsBound=\"true\" IsComposable=\"false\"><Parameter Name=\"param\" " +
- "Type=\"Edm.Int16\"/><Parameter Name=\"param2\" Type=\"Collection(Edm.Int16)\"/><ReturnType " +
- "Type=\"namespace.CTBaseName\"/></Function>"));
-
- assertTrue(metadataString.contains("<EntityContainer Name=\"container\">"));
-
- assertTrue(metadataString
- .contains("<EntitySet Name=\"EntitySetName\" EntityType=\"namespace.ETBaseName\"><NavigationPropertyBinding " +
- "Path=\"N1\" Target=\"namespace.container/EntitySetName\"/></EntitySet>"));
- assertTrue(metadataString
- .contains("<Singleton Name=\"SingletonName\" EntityType=\"namespace.ETBaseName\"><NavigationPropertyBinding " +
- "Path=\"N1\" Target=\"namespace.container/EntitySetName\"/></Singleton>"));
-
- assertTrue(metadataString.contains("<ActionImport Name=\"actionImport\" Action=\"namespace.ActionWOParameter\"/>"));
-
- assertTrue(metadataString
- .contains("<FunctionImport Name=\"actionImport\" Function=\"namespace.FunctionName\" " +
- "EntitySet=\"namespace.EntitySetName\" IncludeInServiceDocument=\"false\"/>"));
-
- assertTrue(metadataString.contains("</EntityContainer></Schema></edmx:DataServices></edmx:Edmx>"));
- }
-
- @Test
- public void writeMetadataWithTechnicalScenario() {
- ODataSerializer serializer = ODataServer.newInstance().getSerializer(ODataFormat.XML);
- EdmProviderImpl edm = new EdmProviderImpl(new EdmTechProvider());
- InputStream metadata = serializer.metadataDocument(edm);
- assertNotNull(metadata);
- // The technical scenario is too big to verify. We are content for now to make sure we can serialize it.
- // System.out.println(StringUtils.inputStreamToString(metadata, false));
- }
-
- private class TestMetadataProvider extends EdmProvider {
-
- @Override
- public List<Schema> getSchemas() throws ODataException {
- Property p1 = new Property().setName("P1").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName());
- String ns = "namespace";
- NavigationProperty n1 = new NavigationProperty().setName("N1")
- .setType(new FullQualifiedName(ns, "ETBaseName")).setNullable(true).setPartner("N1");
- Property p2 = new Property().setName("P2").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName());
- NavigationProperty n2 = new NavigationProperty().setName("N2")
- .setType(new FullQualifiedName(ns, "ETDerivedName")).setNullable(true).setPartner("N2");
- Schema schema = new Schema().setNamespace(ns).setAlias("alias");
- List<ComplexType> complexTypes = new ArrayList<ComplexType>();
- schema.setComplexTypes(complexTypes);
- ComplexType ctBase =
- new ComplexType().setName("CTBaseName").setProperties(Arrays.asList(p1)).setNavigationProperties(
- Arrays.asList(n1));
- complexTypes.add(ctBase);
- ComplexType ctDerived =
- new ComplexType().setName("CTDerivedName").setBaseType(new FullQualifiedName(ns, "CTBaseName"))
- .setProperties(Arrays.asList(p2)).setNavigationProperties(Arrays.asList(n2));
- complexTypes.add(ctDerived);
-
- List<EntityType> entityTypes = new ArrayList<EntityType>();
- schema.setEntityTypes(entityTypes);
- EntityType etBase =
- new EntityType().setName("ETBaseName").setProperties(Arrays.asList(p1)).setNavigationProperties(
- Arrays.asList(n1));
- entityTypes.add(etBase);
- EntityType etDerived =
- new EntityType().setName("ETDerivedName").setBaseType(new FullQualifiedName(ns, "ETBaseName"))
- .setProperties(Arrays.asList(p2)).setNavigationProperties(Arrays.asList(n2));
- entityTypes.add(etDerived);
-
- List<Action> actions = new ArrayList<Action>();
- schema.setActions(actions);
- // TODO:EntitySetPath
- actions.add((new Action().setName("ActionWOParameter")));
- List<Parameter> parameters = new ArrayList<Parameter>();
- parameters.add(new Parameter().setName("param").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()));
- parameters.add(new Parameter().setName("param2").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName())
- .setCollection(true));
- actions.add(new Action().setName("ActionName").setBound(true).setParameters(parameters).setReturnType(
- new ReturnType().setType(new FullQualifiedName(ns, "CTBaseName"))));
-
- List<Function> functions = new ArrayList<Function>();
- schema.setFunctions(functions);
- functions.add((new Function().setName("FunctionWOParameter")
- .setReturnType(new ReturnType().setType(new FullQualifiedName(ns, "CTBaseName")))));
- functions.add(new Function().setName("FunctionName").setBound(true).setParameters(parameters).setReturnType(
- new ReturnType().setType(new FullQualifiedName(ns, "CTBaseName"))));
-
- List<EnumType> enumTypes = new ArrayList<EnumType>();
- schema.setEnumTypes(enumTypes);
- List<EnumMember> members = new ArrayList<EnumMember>();
- members.add(new EnumMember().setName("member").setValue("1"));
- enumTypes.add(new EnumType().setName("EnumName").setFlags(true).setMembers(members));
-
- List<TypeDefinition> typeDefinitions = new ArrayList<TypeDefinition>();
- schema.setTypeDefinitions(typeDefinitions);
- typeDefinitions.add(new TypeDefinition().setName("typeDef")
- .setUnderlyingType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()));
-
- EntityContainer container = new EntityContainer().setName("container");
- schema.setEntityContainer(container);
-
- List<ActionImport> actionImports = new ArrayList<ActionImport>();
- container.setActionImports(actionImports);
- actionImports.add(new ActionImport().setName("actionImport").setAction(
- new FullQualifiedName(ns, "ActionWOParameter")).setEntitySet(
- new Target().setEntityContainer(new FullQualifiedName(ns, "container")).setTargetName("EntitySetName")));
-
- List<FunctionImport> functionImports = new ArrayList<FunctionImport>();
- container.setFunctionImports(functionImports);
- functionImports.add(new FunctionImport().setName("actionImport").setFunction(
- new FullQualifiedName(ns, "FunctionName")).setEntitySet(
- new Target().setEntityContainer(new FullQualifiedName(ns, "container")).setTargetName("EntitySetName")));
-
- List<EntitySet> entitySets = new ArrayList<EntitySet>();
- container.setEntitySets(entitySets);
- List<NavigationPropertyBinding> nPB = new ArrayList<NavigationPropertyBinding>();
- nPB.add(new NavigationPropertyBinding().setPath("N1").setTarget(
- new Target().setEntityContainer(new FullQualifiedName(ns, "container")).setTargetName("EntitySetName")));
- entitySets.add(new EntitySet().setName("EntitySetName").setType(new FullQualifiedName(ns, "ETBaseName"))
- .setNavigationPropertyBindings(nPB));
-
- List<Singleton> singletons = new ArrayList<Singleton>();
- container.setSingletons(singletons);
- singletons.add(new Singleton().setName("SingletonName").setType(new FullQualifiedName(ns, "ETBaseName"))
- .setNavigationPropertyBindings(nPB));
-
- List<Schema> schemas = new ArrayList<Schema>();
- schemas.add(schema);
- return schemas;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java
deleted file mode 100644
index f54ad57..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java
+++ /dev/null
@@ -1,151 +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;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.olingo.server.core.uri.parser.RawUri;
-import org.apache.olingo.server.core.uri.parser.UriDecoder;
-import org.apache.olingo.server.core.uri.parser.UriParserSyntaxException;
-import org.junit.Test;
-
-public class RawUriTest {
-
- private RawUri runRawParser(final String uri, final int scipSegments) throws UriParserSyntaxException {
- return UriDecoder.decodeUri(uri, scipSegments);
- }
-
- @Test
- public void testOption() throws Exception {
- RawUri rawUri;
- rawUri = runRawParser("?", 0);
- checkOptionCount(rawUri, 0);
-
- rawUri = runRawParser("?a", 0);
- checkOption(rawUri, 0, "a", "");
-
- rawUri = runRawParser("?a=b", 0);
- checkOption(rawUri, 0, "a", "b");
-
- rawUri = runRawParser("?=", 0);
- checkOption(rawUri, 0, "", "");
-
- rawUri = runRawParser("?=b", 0);
- checkOption(rawUri, 0, "", "b");
-
- rawUri = runRawParser("?a&c", 0);
- checkOption(rawUri, 0, "a", "");
- checkOption(rawUri, 1, "c", "");
-
- rawUri = runRawParser("?a=b&c", 0);
- checkOption(rawUri, 0, "a", "b");
- checkOption(rawUri, 1, "c", "");
-
- rawUri = runRawParser("?a=b&c=d", 0);
- checkOption(rawUri, 0, "a", "b");
- checkOption(rawUri, 1, "c", "d");
-
- rawUri = runRawParser("?=&=", 0);
- checkOption(rawUri, 0, "", "");
- checkOption(rawUri, 1, "", "");
-
- rawUri = runRawParser("?=&c=d", 0);
- checkOption(rawUri, 0, "", "");
- checkOption(rawUri, 1, "c", "d");
- }
-
- private void checkOption(final RawUri rawUri, final int index, final String name, final String value) {
- RawUri.QueryOption option = rawUri.queryOptionListDecoded.get(index);
-
- assertEquals(name, option.name);
- assertEquals(value, option.value);
-
- }
-
- private void checkOptionCount(final RawUri rawUri, final int count) {
- assertEquals(count, rawUri.queryOptionListDecoded.size());
- }
-
- @Test
- public void testPath() throws Exception {
- RawUri rawUri;
-
- rawUri = runRawParser("http://test.org", 0);
- checkPath(rawUri, "", new ArrayList<String>());
-
- rawUri = runRawParser("http://test.org/", 0);
- checkPath(rawUri, "/", Arrays.asList(""));
-
- rawUri = runRawParser("http://test.org/entitySet", 0);
- checkPath(rawUri, "/entitySet", Arrays.asList("entitySet"));
-
- rawUri = runRawParser("http://test.org/nonServiceSegment/entitySet", 0);
- checkPath(rawUri, "/nonServiceSegment/entitySet", Arrays.asList("nonServiceSegment", "entitySet"));
-
- rawUri = runRawParser("http://test.org/nonServiceSegment/entitySet", 1);
- checkPath(rawUri, "/nonServiceSegment/entitySet", Arrays.asList("entitySet"));
-
- rawUri = runRawParser("", 0);
- checkPath(rawUri, "", new ArrayList<String>());
-
- rawUri = runRawParser("/", 0);
- checkPath(rawUri, "/", Arrays.asList(""));
-
- rawUri = runRawParser("/entitySet", 0);
- checkPath(rawUri, "/entitySet", Arrays.asList("entitySet"));
-
- rawUri = runRawParser("entitySet", 0);
- checkPath(rawUri, "entitySet", Arrays.asList("entitySet"));
-
- rawUri = runRawParser("nonServiceSegment/entitySet", 0);
- checkPath(rawUri, "nonServiceSegment/entitySet", Arrays.asList("nonServiceSegment", "entitySet"));
-
- rawUri = runRawParser("nonServiceSegment/entitySet", 1);
- checkPath(rawUri, "nonServiceSegment/entitySet", Arrays.asList("entitySet"));
-
- rawUri = runRawParser("http://test.org/a?abc=xx+yz", 0);
- }
-
- @Test
- public void testSplitt() {
- UriDecoder.splitt("", '/');
- UriDecoder.splitt("/", '/');
- UriDecoder.splitt("a", '/');
- UriDecoder.splitt("a/", '/');
- UriDecoder.splitt("/a", '/');
- UriDecoder.splitt("a/a", '/');
- }
-
- private void checkPath(final RawUri rawUri, final String path, final List<String> list) {
- assertEquals(path, rawUri.path);
-
- assertEquals(list.size(), rawUri.pathSegmentListDecoded.size());
-
- int i = 0;
- while (i < list.size()) {
- assertEquals(list.get(i), rawUri.pathSegmentListDecoded.get(i));
- i++;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java
deleted file mode 100644
index a9d516d..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java
+++ /dev/null
@@ -1,201 +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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.server.api.uri.UriInfoAll;
-import org.apache.olingo.server.api.uri.UriInfoBatch;
-import org.apache.olingo.server.api.uri.UriInfoCrossjoin;
-import org.apache.olingo.server.api.uri.UriInfoEntityId;
-import org.apache.olingo.server.api.uri.UriInfoKind;
-import org.apache.olingo.server.api.uri.UriInfoMetadata;
-import org.apache.olingo.server.api.uri.UriInfoResource;
-import org.apache.olingo.server.api.uri.UriInfoService;
-import org.apache.olingo.server.api.uri.queryoption.CustomQueryOption;
-import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
-import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
-import org.apache.olingo.server.core.testutil.techprovider.EntityTypeProvider;
-import org.apache.olingo.server.core.uri.queryoption.CountOptionImpl;
-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.FormatOptionImpl;
-import org.apache.olingo.server.core.uri.queryoption.IdOptionImpl;
-import org.apache.olingo.server.core.uri.queryoption.LevelsOptionImpl;
-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.SearchOptionImpl;
-import org.apache.olingo.server.core.uri.queryoption.SelectOptionImpl;
-import org.apache.olingo.server.core.uri.queryoption.SkipOptionImpl;
-import org.apache.olingo.server.core.uri.queryoption.SkipTokenOptionImpl;
-import org.apache.olingo.server.core.uri.queryoption.TopOptionImpl;
-import org.junit.Test;
-
-public class UriInfoImplTest {
-
- Edm edm = new EdmProviderImpl(new EdmTechTestProvider());
-
- @Test
- public void testKind() {
- UriInfoImpl uriInfo = new UriInfoImpl().setKind(UriInfoKind.all);
- assertEquals(UriInfoKind.all, uriInfo.getKind());
- }
-
- @Test
- public void testCasts() {
- UriInfoImpl uriInfo = new UriInfoImpl();
-
- UriInfoAll all = uriInfo.asUriInfoAll();
- assertEquals(uriInfo, all);
-
- UriInfoBatch batch = uriInfo.asUriInfoBatch();
- assertEquals(uriInfo, batch);
-
- UriInfoCrossjoin crossjoin = uriInfo.asUriInfoCrossjoin();
- assertEquals(uriInfo, crossjoin);
-
- UriInfoEntityId entityID = uriInfo.asUriInfoEntityId();
- assertEquals(uriInfo, entityID);
-
- UriInfoMetadata metadata = uriInfo.asUriInfoMetadata();
- assertEquals(uriInfo, metadata);
-
- UriInfoResource resource = uriInfo.asUriInfoResource();
- assertEquals(uriInfo, resource);
-
- UriInfoService service = uriInfo.asUriInfoService();
- assertEquals(uriInfo, service);
-
- }
-
- @Test
- public void testEntityNames() {
- UriInfoImpl uriInfo = new UriInfoImpl();
- uriInfo.addEntitySetName("A");
- uriInfo.addEntitySetName("B");
-
- assertEquals("A", uriInfo.getEntitySetNames().get(0));
- assertEquals("B", uriInfo.getEntitySetNames().get(1));
-
- }
-
- @Test
- public void testResourceParts() {
- UriInfoImpl uriInfo = new UriInfoImpl();
-
- UriResourceActionImpl action = new UriResourceActionImpl();
- UriResourceEntitySetImpl entitySet0 = new UriResourceEntitySetImpl();
- UriResourceEntitySetImpl entitySet1 = new UriResourceEntitySetImpl();
-
- uriInfo.addResourcePart(action);
- uriInfo.addResourcePart(entitySet0);
-
- assertEquals(action, uriInfo.getUriResourceParts().get(0));
- assertEquals(entitySet0, uriInfo.getUriResourceParts().get(1));
-
- assertEquals(entitySet0, uriInfo.getLastResourcePart());
-
- uriInfo.addResourcePart(entitySet1);
- assertEquals(entitySet1, uriInfo.getLastResourcePart());
- }
-
- @Test
- public void testCustomQueryOption() {
- UriInfoImpl uriInfo = new UriInfoImpl();
-
- List<QueryOptionImpl> queryOptions = new ArrayList<QueryOptionImpl>();
-
- ExpandOptionImpl expand = new ExpandOptionImpl();
- FilterOptionImpl filter = new FilterOptionImpl();
- FormatOptionImpl format = new FormatOptionImpl();
- IdOptionImpl id = new IdOptionImpl();
- CountOptionImpl inlinecount = new CountOptionImpl();
- OrderByOptionImpl orderby = new OrderByOptionImpl();
- SearchOptionImpl search = new SearchOptionImpl();
- SelectOptionImpl select = new SelectOptionImpl();
- SkipOptionImpl skip = new SkipOptionImpl();
- SkipTokenOptionImpl skipToken = new SkipTokenOptionImpl();
- TopOptionImpl top = new TopOptionImpl();
- LevelsOptionImpl levels = new LevelsOptionImpl();
-
- CustomQueryOptionImpl customOption0 = new CustomQueryOptionImpl();
- customOption0.setText("A");
- CustomQueryOptionImpl customOption1 = new CustomQueryOptionImpl();
- customOption1.setText("B");
-
- QueryOptionImpl queryOption = new QueryOptionImpl();
-
- queryOptions.add(expand);
- queryOptions.add(filter);
- queryOptions.add(format);
- queryOptions.add(id);
- queryOptions.add(inlinecount);
- queryOptions.add(orderby);
- queryOptions.add(search);
- queryOptions.add(select);
- queryOptions.add(skip);
- queryOptions.add(skipToken);
- queryOptions.add(top);
- queryOptions.add(customOption0);
- queryOptions.add(customOption1);
- queryOptions.add(levels);// not stored
- queryOptions.add(queryOption);// not stored
- uriInfo.setQueryOptions(queryOptions);
-
- assertEquals(expand, uriInfo.getExpandOption());
- assertEquals(filter, uriInfo.getFilterOption());
- assertEquals(format, uriInfo.getFormatOption());
- assertEquals(id, uriInfo.getIdOption());
- assertEquals(inlinecount, uriInfo.getCountOption());
- assertEquals(orderby, uriInfo.getOrderByOption());
- assertEquals(search, uriInfo.getSearchOption());
- assertEquals(select, uriInfo.getSelectOption());
- assertEquals(skip, uriInfo.getSkipOption());
- assertEquals(skipToken, uriInfo.getSkipTokenOption());
- assertEquals(top, uriInfo.getTopOption());
-
- List<CustomQueryOption> customQueryOptions = uriInfo.getCustomQueryOptions();
- assertEquals(customOption0, customQueryOptions.get(0));
- assertEquals(customOption1, customQueryOptions.get(1));
- }
-
- @Test
- public void testFragment() {
- UriInfoImpl uriInfo = new UriInfoImpl();
- uriInfo.setFragment("F");
- assertEquals("F", uriInfo.getFragment());
- }
-
- @Test
- public void testEntityTypeCast() {
- UriInfoImpl uriInfo = new UriInfoImpl();
- EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETKeyNav);
- assertNotNull(entityType);
-
- uriInfo.setEntityTypeCast(entityType);
- assertEquals(entityType, uriInfo.getEntityTypeCast());
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java
deleted file mode 100644
index bd4ac68..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java
+++ /dev/null
@@ -1,508 +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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmAction;
-import org.apache.olingo.commons.api.edm.EdmActionImport;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.EdmFunction;
-import org.apache.olingo.commons.api.edm.EdmFunctionImport;
-import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.EdmProperty;
-import org.apache.olingo.commons.api.edm.EdmType;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
-import org.apache.olingo.server.api.uri.UriResourceKind;
-import org.apache.olingo.server.core.edm.provider.EdmComplexTypeImpl;
-import org.apache.olingo.server.core.edm.provider.EdmEntitySetImpl;
-import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
-import org.apache.olingo.server.core.edm.provider.EdmSingletonImpl;
-import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
-import org.apache.olingo.server.core.testutil.techprovider.ActionProvider;
-import org.apache.olingo.server.core.testutil.techprovider.ComplexTypeProvider;
-import org.apache.olingo.server.core.testutil.techprovider.EntityTypeProvider;
-import org.apache.olingo.server.core.uri.queryoption.expression.ExpressionImpl;
-import org.apache.olingo.server.core.uri.queryoption.expression.LiteralImpl;
-import org.junit.Test;
-
-public class UriResourceImplTest {
-
- Edm edm = new EdmProviderImpl(new EdmTechTestProvider());
-
- @Test
- public void testUriParameterImpl() {
- UriParameterImpl impl = new UriParameterImpl();
- ExpressionImpl expression = new LiteralImpl().setText("Expression");
-
- impl.setText("Text");
- impl.setName("A");
- impl.setAlias("@A");
- impl.setExpression(expression);
-
- assertEquals("Text", impl.getText());
- assertEquals("A", impl.getName());
- assertEquals("@A", impl.getAlias());
- assertEquals(expression, impl.getExression());
- }
-
- @Test
- public void testUriResourceActionImpl() {
- UriResourceActionImpl impl = new UriResourceActionImpl();
- assertEquals(UriResourceKind.action, impl.getKind());
- assertEquals("", impl.toString());
-
- // action
- EdmAction action = edm.getUnboundAction(ActionProvider.nameUARTETParam);
- impl.setAction(action);
- assertEquals(action, impl.getAction());
- assertEquals(ActionProvider.nameUARTETParam.getName(), impl.toString());
-
- // action import
- impl = new UriResourceActionImpl();
- EdmActionImport actionImport = edm.getEntityContainer(null).getActionImport("AIRTPrimParam");
- impl.setActionImport(actionImport);
- assertEquals(actionImport, impl.getActionImport());
- assertEquals(actionImport.getUnboundAction(), impl.getAction());
- assertEquals(false, impl.isCollection());
- assertEquals("AIRTPrimParam", impl.toString());
- assertEquals(actionImport.getUnboundAction().getReturnType().getType(), impl.getType());
- }
-
- @Test
- public void testUriResourceLambdaAllImpl() {
- UriResourceLambdaAllImpl impl = new UriResourceLambdaAllImpl();
- assertEquals(UriResourceKind.lambdaAll, impl.getKind());
-
- ExpressionImpl expression = new LiteralImpl().setText("Expression");
- impl.setExpression(expression);
- impl.setLamdaVariable("A");
-
- assertEquals(false, impl.isCollection());
- assertEquals(expression, impl.getExpression());
- assertEquals("A", impl.getLambdaVariable());
- assertEquals(EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean), impl.getType());
- assertEquals("all", impl.toString());
- }
-
- @Test
- public void testUriResourceLambdaAnyImpl() {
- UriResourceLambdaAnyImpl impl = new UriResourceLambdaAnyImpl();
- assertEquals(UriResourceKind.lambdaAny, impl.getKind());
-
- ExpressionImpl expression = new LiteralImpl().setText("Expression");
- impl.setExpression(expression);
- impl.setLamdaVariable("A");
-
- assertEquals(false, impl.isCollection());
- assertEquals(expression, impl.getExpression());
- assertEquals("A", impl.getLamdaVariable());
- assertEquals(EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean), impl.getType());
- assertEquals("any", impl.toString());
- }
-
- @Test
- public void testUriResourceComplexPropertyImpl() {
- UriResourceComplexPropertyImpl impl = new UriResourceComplexPropertyImpl();
- assertEquals(UriResourceKind.complexProperty, impl.getKind());
-
- EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETKeyNav);
- EdmProperty property = (EdmProperty) entityType.getProperty("PropertyComplex");
- impl.setProperty(property);
-
- assertEquals(property, impl.getProperty());
- assertEquals(property.getName(), impl.toString());
- assertEquals(false, impl.isCollection());
- assertEquals(property.getType(), impl.getType());
- assertEquals(property.getType(), impl.getComplexType());
- impl.getComplexType();
-
- EdmComplexTypeImpl complexTypeImplType =
- (EdmComplexTypeImpl) edm.getComplexType(ComplexTypeProvider.nameCTBasePrimCompNav);
-
- impl.setTypeFilter(complexTypeImplType);
- assertEquals(complexTypeImplType, impl.getTypeFilter());
- assertEquals(complexTypeImplType, impl.getComplexTypeFilter());
- impl.getComplexTypeFilter();
-
- }
-
- @Test
- public void testUriResourcePrimitivePropertyImpl() {
- UriResourcePrimitivePropertyImpl impl = new UriResourcePrimitivePropertyImpl();
- assertEquals(UriResourceKind.primitiveProperty, impl.getKind());
-
- EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETKeyNav);
- EdmProperty property = (EdmProperty) entityType.getProperty("PropertyInt16");
- impl.setProperty(property);
-
- assertEquals(property, impl.getProperty());
- assertEquals(property.getName(), impl.toString());
- assertEquals(false, impl.isCollection());
- assertEquals(property.getType(), impl.getType());
- }
-
- @Test
- public void testUriResourceCountImpl() {
- UriResourceCountImpl impl = new UriResourceCountImpl();
- assertEquals(UriResourceKind.count, impl.getKind());
- assertEquals("$count", impl.toString());
- }
-
- @Test
- public void testUriResourceEntitySetImpl() {
- UriResourceEntitySetImpl impl = new UriResourceEntitySetImpl();
- assertEquals(UriResourceKind.entitySet, impl.getKind());
-
- EdmEntitySetImpl entitySet = (EdmEntitySetImpl) edm.getEntityContainer(null).getEntitySet("ESAllPrim");
- impl.setEntitSet(entitySet);
-
- assertEquals("ESAllPrim", impl.toString());
- assertEquals(entitySet, impl.getEntitySet());
-
- assertEquals(entitySet.getEntityType(), impl.getType());
- assertEquals(entitySet.getEntityType(), impl.getEntityType());
- impl.getEntityType();
-
- // is Collection
- assertEquals(true, impl.isCollection());
- impl.setKeyPredicates(new ArrayList<UriParameterImpl>());
- assertEquals(false, impl.isCollection());
- }
-
- @Test
- public void testUriResourceFunctionImpl() {
- UriResourceFunctionImpl impl = new UriResourceFunctionImpl();
- assertEquals(UriResourceKind.function, impl.getKind());
- assertEquals("", impl.toString());
-
- // function
- EdmFunction function = (EdmFunction) edm.getEntityContainer(null).getFunctionImport("FINRTInt16")
- .getUnboundFunction(new ArrayList<String>());
- assertNotNull(function);
- impl.setFunction(function);
-
- assertEquals(function, impl.getFunction());
- assertEquals("UFNRTInt16", impl.toString());
- assertEquals(function.getReturnType().getType(), impl.getType());
- assertEquals(false, impl.isParameterListFilled());
-
- // function import
- impl = new UriResourceFunctionImpl();
- EdmFunctionImport functionImport = edm.getEntityContainer(null).getFunctionImport("FINRTInt16");
- impl.setFunctionImport(functionImport, new ArrayList<UriParameterImpl>());
- assertEquals(functionImport, impl.getFunctionImport());
- assertEquals("FINRTInt16", impl.toString());
-
- // function collection
- impl = new UriResourceFunctionImpl();
- functionImport = edm.getEntityContainer(null).getFunctionImport("FICRTESTwoKeyNavParam");
- assertNotNull(function);
- UriParameterImpl parameter = new UriParameterImpl().setName("ParameterInt16");
- impl.setFunctionImport(functionImport, Arrays.asList(parameter));
- assertEquals("FICRTESTwoKeyNavParam", impl.toString());
-
- impl.setFunction(functionImport.getUnboundFunction(Arrays.asList("ParameterInt16")));
- assertEquals(true, impl.isCollection());
- impl.setKeyPredicates(new ArrayList<UriParameterImpl>());
- assertEquals(false, impl.isCollection());
-
- assertEquals(parameter, impl.getParameters().get(0));
- assertEquals(true, impl.isParameterListFilled());
- }
-
- @Test
- public void testUriResourceImplKeyPred() {
- class Mock extends UriResourceWithKeysImpl {
-
- EdmType type;
-
- public Mock() {
- super(UriResourceKind.action);
- }
-
- @Override
- public EdmType getType() {
- return type;
- }
-
- public Mock setType(final EdmType type) {
- this.type = type;
- return this;
- }
-
- @Override
- public boolean isCollection() {
- return false;
- }
-
- @Override
- public String toString() {
- return "mock";
- }
- }
-
- Mock impl = new Mock();
- EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav);
- EdmEntityType entityTypeBaseColl = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
- EdmEntityType entityTypeBaseEntry = edm.getEntityType(EntityTypeProvider.nameETTwoBaseTwoKeyNav);
-
- impl.setType(entityType);
- assertEquals(entityType, impl.getType());
- assertEquals("mock", impl.toString(false));
- assertEquals("mock", impl.toString(true));
-
- // set both
- impl.setCollectionTypeFilter(entityTypeBaseColl);
- assertEquals(entityTypeBaseColl, impl.getTypeFilterOnCollection());
- assertEquals("mock", impl.toString(false));
- assertEquals("mock/com.sap.odata.test1.ETBaseTwoKeyNav", impl.toString(true));
- impl.setEntryTypeFilter(entityTypeBaseEntry);
- assertEquals(entityTypeBaseEntry, impl.getTypeFilterOnEntry());
- assertEquals("mock", impl.toString(false));
- assertEquals("mock/com.sap.odata.test1.ETBaseTwoKeyNav/()com.sap.odata.test1.ETTwoBaseTwoKeyNav",
- impl.toString(true));
-
- // set entry
- impl = new Mock();
- impl.setType(entityType);
- impl.setEntryTypeFilter(entityTypeBaseEntry);
- assertEquals(entityTypeBaseEntry, impl.getTypeFilterOnEntry());
- assertEquals("mock", impl.toString(false));
- assertEquals("mock/com.sap.odata.test1.ETTwoBaseTwoKeyNav", impl.toString(true));
-
- // set collection
- impl = new Mock();
- impl.setType(entityType);
- impl.setCollectionTypeFilter(entityTypeBaseColl);
- assertEquals(entityTypeBaseColl, impl.getTypeFilterOnCollection());
- assertEquals("mock", impl.toString(false));
- assertEquals("mock/com.sap.odata.test1.ETBaseTwoKeyNav", impl.toString(true));
-
- impl = new Mock();
- UriParameterImpl parameter = new UriParameterImpl().setName("ParameterInt16");
- List<UriParameterImpl> keyPredicates = new ArrayList<UriParameterImpl>();
- keyPredicates.add(parameter);
-
- impl.setKeyPredicates(keyPredicates);
- assertNotNull(null, impl.getKeyPredicates());
-
- }
-
- @Test
- public void testUriResourceImplTyped() {
- class Mock extends UriResourceTypedImpl {
-
- EdmType type;
-
- public Mock() {
- super(UriResourceKind.action);
- }
-
- @Override
- public EdmType getType() {
- return type;
- }
-
- @Override
- public boolean isCollection() {
- return false;
- }
-
- public Mock setType(final EdmType type) {
- this.type = type;
- return this;
- }
-
- @Override
- public String toString() {
- return "mock";
- }
-
- }
-
- Mock impl = new Mock();
- EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav);
- EdmEntityType entityTypeBaseColl = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
- edm.getEntityType(EntityTypeProvider.nameETTwoBaseTwoKeyNav);
-
- impl.setType(entityType);
- assertEquals("mock", impl.toString());
- assertEquals("mock", impl.toString(true));
- assertEquals("mock", impl.toString(false));
-
- impl.setTypeFilter(entityTypeBaseColl);
- assertEquals(entityTypeBaseColl, impl.getTypeFilter());
- assertEquals("mock", impl.toString());
- assertEquals("mock/com.sap.odata.test1.ETBaseTwoKeyNav", impl.toString(true));
- assertEquals("mock", impl.toString(false));
- //
- }
-
- @Test
- public void testUriResourceItImpl() {
- UriResourceItImpl impl = new UriResourceItImpl();
- assertEquals(UriResourceKind.it, impl.getKind());
-
- EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav);
- assertEquals("$it", impl.toString());
-
- impl.setType(entityType);
- assertEquals(entityType, impl.getType());
-
- UriParameterImpl parameter = new UriParameterImpl().setName("ParameterInt16");
- List<UriParameterImpl> keyPredicates = new ArrayList<UriParameterImpl>();
- keyPredicates.add(parameter);
-
- assertEquals(false, impl.isCollection());
- impl.setCollection(true);
- assertEquals(true, impl.isCollection());
- impl.setKeyPredicates(keyPredicates);
- assertEquals(false, impl.isCollection());
- }
-
- @Test
- public void testUriResourceNavigationPropertyImpl() {
- UriResourceNavigationPropertyImpl impl = new UriResourceNavigationPropertyImpl();
- assertEquals(UriResourceKind.navigationProperty, impl.getKind());
-
- EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav);
- EdmNavigationProperty property = (EdmNavigationProperty) entityType.getProperty("NavPropertyETKeyNavMany");
- assertNotNull(property);
-
- impl.setNavigationProperty(property);
- assertEquals(property, impl.getProperty());
-
- assertEquals("NavPropertyETKeyNavMany", impl.toString());
- assertEquals(property.getType(), impl.getType());
-
- UriParameterImpl parameter = new UriParameterImpl().setName("ParameterInt16");
- List<UriParameterImpl> keyPredicates = new ArrayList<UriParameterImpl>();
- keyPredicates.add(parameter);
-
- assertEquals(true, impl.isCollection());
- impl.setKeyPredicates(keyPredicates);
- assertEquals(false, impl.isCollection());
- }
-
- @Test
- public void testUriResourceRefImpl() {
- UriResourceRefImpl impl = new UriResourceRefImpl();
- assertEquals(UriResourceKind.ref, impl.getKind());
- assertEquals("$ref", impl.toString());
- }
-
- @Test
- public void testUriResourceRootImpl() {
- UriResourceRootImpl impl = new UriResourceRootImpl();
- assertEquals(UriResourceKind.root, impl.getKind());
-
- EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav);
- assertEquals("$root", impl.toString());
-
- impl.setType(entityType);
- assertEquals(entityType, impl.getType());
-
- UriParameterImpl parameter = new UriParameterImpl().setName("ParameterInt16");
- List<UriParameterImpl> keyPredicates = new ArrayList<UriParameterImpl>();
- keyPredicates.add(parameter);
-
- assertEquals(false, impl.isCollection());
- impl.setCollection(true);
- assertEquals(true, impl.isCollection());
- impl.setKeyPredicates(keyPredicates);
- assertEquals(false, impl.isCollection());
- }
-
- @Test
- public void testUriResourceSingletonImpl() {
- UriResourceSingletonImpl impl = new UriResourceSingletonImpl();
- assertEquals(UriResourceKind.singleton, impl.getKind());
-
- EdmSingletonImpl singleton = (EdmSingletonImpl) edm.getEntityContainer(null).getSingleton("SINav");
- EdmEntityType entityTypeBaseColl = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
- impl.setSingleton(singleton);
-
- assertEquals("SINav", impl.toString());
- assertEquals(singleton, impl.getSingleton());
-
- assertEquals(singleton.getEntityType(), impl.getType());
- assertEquals(singleton.getEntityType(), impl.getEntityType());
- impl.getEntityType();
-
- impl.setTypeFilter(entityTypeBaseColl);
- assertEquals(entityTypeBaseColl, impl.getEntityTypeFilter());
-
- // is Collection
- assertEquals(false, impl.isCollection());
- }
-
- @Test
- public void testUriResourceValueImpl() {
- UriResourceValueImpl impl = new UriResourceValueImpl();
- assertEquals(UriResourceKind.value, impl.getKind());
- assertEquals("$value", impl.toString());
- }
-
- @Test
- public void testUriResourceLambdaVarImpl() {
- UriResourceLambdaVarImpl impl = new UriResourceLambdaVarImpl();
- assertEquals(UriResourceKind.lambdaVariable, impl.getKind());
-
- EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav);
- impl.setType(entityType);
- impl.setVariableText("A");
-
- assertEquals("A", impl.toString());
- assertEquals(entityType, impl.getType());
- assertEquals("A", impl.getVariableName());
- assertEquals(false, impl.isCollection());
- impl.setCollection(true);
- assertEquals(true, impl.isCollection());
- }
-
- @Test
- public void testUriResourceStartingTypeFilterImpl() {
- UriResourceStartingTypeFilterImpl impl = new UriResourceStartingTypeFilterImpl();
-
- EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav);
-
- impl.setType(entityType);
- assertEquals("com.sap.odata.test1.ETTwoKeyNav", impl.toString());
- assertEquals(entityType, impl.getType());
-
- UriParameterImpl parameter = new UriParameterImpl().setName("ParameterInt16");
- List<UriParameterImpl> keyPredicates = new ArrayList<UriParameterImpl>();
- keyPredicates.add(parameter);
-
- assertEquals(false, impl.isCollection());
- impl.setCollection(true);
- assertEquals(true, impl.isCollection());
- impl.setKeyPredicates(keyPredicates);
- assertEquals(false, impl.isCollection());
-
- }
-}
[15/15] git commit: [OLINGO-266] refactor ref module to server-ref
Posted by sk...@apache.org.
[OLINGO-266] refactor ref module to server-ref
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/8ca9b3c6
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/8ca9b3c6
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/8ca9b3c6
Branch: refs/heads/olingo-266-ref
Commit: 8ca9b3c616864dbbdf0c07a0dd443fc7655e884a
Parents: 54aef88
Author: Stephan Klevenz <st...@sap.com>
Authored: Fri May 9 14:27:56 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Fri May 9 14:27:56 2014 +0200
----------------------------------------------------------------------
lib/pom.xml | 10 +-
lib/ref/pom.xml | 67 -
.../org/apache/olingo/ref/ReferenceServlet.java | 42 -
.../core/testutil/EdmTechTestProvider.java | 100 -
.../server/core/testutil/StringUtils.java | 52 -
.../testutil/techprovider/ActionProvider.java | 191 -
.../techprovider/ComplexTypeProvider.java | 175 -
.../techprovider/ContainerProvider.java | 361 --
.../testutil/techprovider/EdmTechProvider.java | 147 -
.../techprovider/EntityTypeProvider.java | 408 --
.../testutil/techprovider/EnumTypeProvider.java | 47 -
.../testutil/techprovider/FunctionProvider.java | 852 ---
.../testutil/techprovider/PropertyProvider.java | 590 --
.../testutil/techprovider/SchemaProvider.java | 250 -
.../techprovider/TypeDefinitionProvider.java | 30 -
.../src/main/resources/simplelogger.properties | 20 -
lib/ref/src/main/webapp/WEB-INF/web.xml | 42 -
lib/ref/src/main/webapp/index.html | 32 -
.../serializer/json/ServiceDocumentTest.java | 133 -
.../serializer/xml/MetadataDocumentTest.java | 252 -
.../olingo/server/core/uri/RawUriTest.java | 151 -
.../olingo/server/core/uri/UriInfoImplTest.java | 201 -
.../server/core/uri/UriResourceImplTest.java | 508 --
.../core/uri/antlr/TestFullResourcePath.java | 5110 ------------------
.../olingo/server/core/uri/antlr/TestLexer.java | 248 -
.../core/uri/antlr/TestUriParserImpl.java | 1144 ----
.../core/uri/queryoption/QueryOptionTest.java | 303 --
.../queryoption/expression/ExpressionTest.java | 239 -
.../core/uri/testutil/ExpandValidator.java | 230 -
.../core/uri/testutil/FilterTreeToText.java | 154 -
.../core/uri/testutil/FilterValidator.java | 534 --
.../core/uri/testutil/ParseTreeToText.java | 82 -
.../core/uri/testutil/ParserValidator.java | 162 -
.../core/uri/testutil/ParserWithLogging.java | 56 -
.../core/uri/testutil/ResourceValidator.java | 599 --
.../core/uri/testutil/TestErrorLogger.java | 105 -
.../core/uri/testutil/TestUriValidator.java | 258 -
.../server/core/uri/testutil/TestValidator.java | 23 -
.../core/uri/testutil/TokenValidator.java | 194 -
.../core/uri/testutil/UriLexerWithTrace.java | 85 -
.../core/uri/validator/UriValidatorTest.java | 378 --
lib/server-ref/pom.xml | 67 +
.../org/apache/olingo/ref/ReferenceServlet.java | 42 +
.../core/testutil/EdmTechTestProvider.java | 100 +
.../server/core/testutil/StringUtils.java | 52 +
.../testutil/techprovider/ActionProvider.java | 191 +
.../techprovider/ComplexTypeProvider.java | 175 +
.../techprovider/ContainerProvider.java | 361 ++
.../testutil/techprovider/EdmTechProvider.java | 147 +
.../techprovider/EntityTypeProvider.java | 408 ++
.../testutil/techprovider/EnumTypeProvider.java | 47 +
.../testutil/techprovider/FunctionProvider.java | 852 +++
.../testutil/techprovider/PropertyProvider.java | 590 ++
.../testutil/techprovider/SchemaProvider.java | 250 +
.../techprovider/TypeDefinitionProvider.java | 30 +
.../src/main/resources/simplelogger.properties | 20 +
lib/server-ref/src/main/webapp/WEB-INF/web.xml | 42 +
lib/server-ref/src/main/webapp/index.html | 32 +
.../serializer/json/ServiceDocumentTest.java | 133 +
.../serializer/xml/MetadataDocumentTest.java | 252 +
.../olingo/server/core/uri/RawUriTest.java | 151 +
.../olingo/server/core/uri/UriInfoImplTest.java | 201 +
.../server/core/uri/UriResourceImplTest.java | 508 ++
.../core/uri/antlr/TestFullResourcePath.java | 5110 ++++++++++++++++++
.../olingo/server/core/uri/antlr/TestLexer.java | 248 +
.../core/uri/antlr/TestUriParserImpl.java | 1144 ++++
.../core/uri/queryoption/QueryOptionTest.java | 303 ++
.../queryoption/expression/ExpressionTest.java | 239 +
.../core/uri/testutil/ExpandValidator.java | 230 +
.../core/uri/testutil/FilterTreeToText.java | 154 +
.../core/uri/testutil/FilterValidator.java | 534 ++
.../core/uri/testutil/ParseTreeToText.java | 82 +
.../core/uri/testutil/ParserValidator.java | 162 +
.../core/uri/testutil/ParserWithLogging.java | 56 +
.../core/uri/testutil/ResourceValidator.java | 599 ++
.../core/uri/testutil/TestErrorLogger.java | 105 +
.../core/uri/testutil/TestUriValidator.java | 258 +
.../server/core/uri/testutil/TestValidator.java | 23 +
.../core/uri/testutil/TokenValidator.java | 194 +
.../core/uri/testutil/UriLexerWithTrace.java | 85 +
.../core/uri/validator/UriValidatorTest.java | 378 ++
81 files changed, 14560 insertions(+), 14560 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/pom.xml
----------------------------------------------------------------------
diff --git a/lib/pom.xml b/lib/pom.xml
index ae179b7..ed0cdd7 100644
--- a/lib/pom.xml
+++ b/lib/pom.xml
@@ -36,12 +36,12 @@
</parent>
<modules>
- <module>server-api</module>
- <module>server-core</module>
- <module>client-api</module>
- <module>client-core</module>
<module>commons-api</module>
<module>commons-core</module>
- <module>ref</module>
+ <module>client-api</module>
+ <module>client-core</module>
+ <module>server-api</module>
+ <module>server-core</module>
+ <module>server-ref</module>
</modules>
</project>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/pom.xml
----------------------------------------------------------------------
diff --git a/lib/ref/pom.xml b/lib/ref/pom.xml
deleted file mode 100644
index 76ea188..0000000
--- a/lib/ref/pom.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>olingo-ref</artifactId>
- <packaging>war</packaging>
- <name>${project.artifactId}</name>
-
- <parent>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-lib</artifactId>
- <version>0.1.0-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <dependencies>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-server-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-server-core</artifactId>
- <version>${project.version}</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/main/java/org/apache/olingo/ref/ReferenceServlet.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/java/org/apache/olingo/ref/ReferenceServlet.java b/lib/ref/src/main/java/org/apache/olingo/ref/ReferenceServlet.java
deleted file mode 100644
index a3d30ee..0000000
--- a/lib/ref/src/main/java/org/apache/olingo/ref/ReferenceServlet.java
+++ /dev/null
@@ -1,42 +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.ref;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.olingo.server.api.ODataServer;
-
-public class ReferenceServlet extends HttpServlet {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
-
- ODataServer server = ODataServer.newInstance();
- server.handle(req, resp);
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/EdmTechTestProvider.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/EdmTechTestProvider.java b/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/EdmTechTestProvider.java
deleted file mode 100644
index bee5f90..0000000
--- a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/EdmTechTestProvider.java
+++ /dev/null
@@ -1,100 +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.testutil;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.server.api.edm.provider.ComplexType;
-import org.apache.olingo.server.api.edm.provider.EntitySet;
-import org.apache.olingo.server.api.edm.provider.EntityType;
-import org.apache.olingo.server.api.edm.provider.Property;
-import org.apache.olingo.server.api.edm.provider.PropertyRef;
-import org.apache.olingo.server.core.testutil.techprovider.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 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>
- */
-public class EdmTechTestProvider extends EdmTechProvider {
-
- private static final FullQualifiedName nameInt16 = EdmPrimitiveTypeKind.Int16.getFullQualifiedName();
- public static final String nameSpace = "com.sap.odata.test1";
- public static final FullQualifiedName nameContainer = new FullQualifiedName(nameSpace, "Container");
-
- Property propertyAInt16 = new Property().setName("a").setType(nameInt16);
- Property propertyBInt16 = new Property().setName("b").setType(nameInt16);
- Property propertyCInt16 = new Property().setName("c").setType(nameInt16);
- Property propertyDInt16 = new Property().setName("d").setType(nameInt16);
- Property propertyEInt16 = new Property().setName("e").setType(nameInt16);
- Property propertyFInt16 = new Property().setName("f").setType(nameInt16);
-
- public static final FullQualifiedName nameCTabc = new FullQualifiedName(nameSpace, "CTabc");
- public static final FullQualifiedName nameETabc = new FullQualifiedName(nameSpace, "ETabc");
-
- @Override
- public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException {
- if (complexTypeName.equals(nameCTabc)) {
- return new ComplexType()
- .setName("CTabc")
- .setProperties(Arrays.asList(
- propertyAInt16, propertyBInt16, propertyCInt16,
- propertyDInt16, propertyEInt16, propertyFInt16
- ));
-
- }
-
- return super.getComplexType(complexTypeName);
- }
-
- @Override
- public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String name) throws ODataException {
- if (nameContainer.equals(entityContainer)) {
- if (name.equals("ESabc")) {
- return new EntitySet()
- .setName("ESabc")
- .setType(nameETabc);
- }
- }
-
- return super.getEntitySet(entityContainer, name);
- }
-
- @Override
- public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException {
- List<PropertyRef> oneKeyPropertyInt16 = Arrays.asList(new PropertyRef().setPropertyName("a"));
-
- if (entityTypeName.equals(nameETabc)) {
- return new EntityType()
- .setName("ETabc")
- .setProperties(Arrays.asList(
- propertyAInt16, propertyBInt16, propertyCInt16,
- propertyDInt16, propertyEInt16, propertyFInt16))
- .setKey(oneKeyPropertyInt16);
- }
-
- return super.getEntityType(entityTypeName);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/StringUtils.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/StringUtils.java b/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/StringUtils.java
deleted file mode 100644
index 8cabcf1..0000000
--- a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/StringUtils.java
+++ /dev/null
@@ -1,52 +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.testutil;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.Charset;
-
-public class StringUtils {
-
- public static String inputStreamToString(final InputStream in, final boolean preserveLineBreaks) {
- try {
- final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in, Charset.forName("UTF-8")));
- final StringBuilder stringBuilder = new StringBuilder();
- String line = null;
-
- while ((line = bufferedReader.readLine()) != null) {
- stringBuilder.append(line);
- if (preserveLineBreaks) {
- stringBuilder.append("\n");
- }
- }
-
- bufferedReader.close();
-
- final String result = stringBuilder.toString();
-
- return result;
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ActionProvider.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ActionProvider.java b/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ActionProvider.java
deleted file mode 100644
index f1748a7..0000000
--- a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ActionProvider.java
+++ /dev/null
@@ -1,191 +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.testutil.techprovider;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.server.api.edm.provider.Action;
-import org.apache.olingo.server.api.edm.provider.Parameter;
-import org.apache.olingo.server.api.edm.provider.ReturnType;
-
-public class ActionProvider {
-
- // Bound Actions
- public static final FullQualifiedName nameBAESAllPrimRTETAllPrim =
- new FullQualifiedName(SchemaProvider.nameSpace, "BAESAllPrimRTETAllPrim");
-
- public static final FullQualifiedName nameBAESTwoKeyNavRTESTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BAESTwoKeyNavRTESTwoKeyNav");
-
- public static final FullQualifiedName nameBAETBaseTwoKeyNavRTETBaseTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BAETBaseTwoKeyNavRTETBaseTwoKeyNav");
-
- public static final FullQualifiedName nameBAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav");
-
- public static final FullQualifiedName nameBAETTwoKeyNavRTETTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BAETTwoKeyNavRTETTwoKeyNav");
-
- // Unbound Actions
- public static final FullQualifiedName nameUARTCompCollParam = new FullQualifiedName(SchemaProvider.nameSpace,
- "UARTCompCollParam");
- public static final FullQualifiedName nameUARTCompParam = new FullQualifiedName(SchemaProvider.nameSpace,
- "UARTCompParam");
- public static final FullQualifiedName nameUARTESParam =
- new FullQualifiedName(SchemaProvider.nameSpace, "UARTESParam");
-
- public static final FullQualifiedName nameUARTETParam =
- new FullQualifiedName(SchemaProvider.nameSpace, "UARTETParam");
-
- public static final FullQualifiedName nameUARTPrimParam = new FullQualifiedName(SchemaProvider.nameSpace,
- "UARTPrimParam");
- public static final FullQualifiedName nameUARTPrimCollParam = new FullQualifiedName(SchemaProvider.nameSpace,
- "UARTPrimCollParam");
-
- public List<Action> getActions(final FullQualifiedName actionName) throws ODataException {
- if (actionName.equals(nameUARTPrimParam)) {
- return Arrays.asList(
- new Action().setName("UARTPrimParam")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
-
- .setReturnType(new ReturnType().setType(PropertyProvider.nameString))
- );
-
- } else if (actionName.equals(nameUARTPrimCollParam)) {
- return Arrays.asList(
- new Action().setName("UARTPrimCollParam")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
-
- .setReturnType(
- new ReturnType().setType(PropertyProvider.nameString).setCollection(true))
- );
-
- } else if (actionName.equals(nameUARTCompParam)) {
- return Arrays.asList(
- new Action().setName("UARTCompParam")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
-
- .setReturnType(
- new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim))
- );
-
- } else if (actionName.equals(nameUARTCompCollParam)) {
- return Arrays.asList(
- new Action().setName("UARTCompCollParam")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
-
- .setReturnType(
- new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setCollection(true))
- );
-
- } else if (actionName.equals(nameUARTETParam)) {
- return Arrays.asList(
- new Action().setName("UARTETParam")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyTwoPrim))
- );
-
- } else if (actionName.equals(nameUARTESParam)) {
- return Arrays.asList(
- new Action().setName("UARTESParam")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setCollection(true))
- );
-
- } else if (actionName.equals(nameBAETTwoKeyNavRTETTwoKeyNav)) {
- return Arrays.asList(
- new Action().setName("BAETTwoKeyNavRTETTwoKeyNav")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterETTwoKeyNav").setType(EntityTypeProvider.nameETTwoKeyNav)
- .setNullable(false)))
- .setBound(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav))
- ,
- new Action().setName("BAETTwoKeyNavRTETTwoKeyNav")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterETKeyNav").setType(EntityTypeProvider.nameETKeyNav)
- .setNullable(false)))
- .setBound(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav))
- );
-
- } else if (actionName.equals(nameBAESAllPrimRTETAllPrim)) {
- return Arrays.asList(
- new Action().setName("BAESAllPrimRTETAllPrim")
- .setParameters(
- Arrays.asList(
- new Parameter().setName("ParameterESAllPrim").setType(EntityTypeProvider.nameETAllPrim)
- .setCollection(true).setNullable(false)))
- .setBound(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETAllPrim))
- );
-
- } else if (actionName.equals(nameBAESTwoKeyNavRTESTwoKeyNav)) {
- return Arrays.asList(
- new Action().setName("BAESTwoKeyNavRTESTwoKeyNav")
- .setParameters(
- Arrays.asList(
- new Parameter().setName("ParameterETTwoKeyNav").setType(EntityTypeProvider.nameETTwoKeyNav)
- .setCollection(true).setNullable(false)))
- .setBound(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true))
- );
-
- } else if (actionName.equals(nameBAETBaseTwoKeyNavRTETBaseTwoKeyNav)) {
- return Arrays.asList(
- new Action().setName("BAETBaseTwoKeyNavRTETBaseTwoKeyNav")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterETTwoKeyNav").setType(EntityTypeProvider.nameETBaseTwoKeyNav)
- .setNullable(false)))
- .setBound(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav))
- );
-
- } else if (actionName.equals(nameBAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav)) {
- return Arrays.asList(
- new Action().setName("BAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav")
- .setParameters(
- Arrays.asList(
- new Parameter().setName("ParameterETTwoBaseTwoKeyNav").setType(
- EntityTypeProvider.nameETTwoBaseTwoKeyNav).setNullable(false)))
- .setBound(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETBaseTwoKeyNav))
- );
- }
-
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ComplexTypeProvider.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ComplexTypeProvider.java b/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ComplexTypeProvider.java
deleted file mode 100644
index 2db6d0e..0000000
--- a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ComplexTypeProvider.java
+++ /dev/null
@@ -1,175 +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.testutil.techprovider;
-
-import java.util.Arrays;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.server.api.edm.provider.ComplexType;
-import org.apache.olingo.server.api.edm.provider.NavigationProperty;
-import org.apache.olingo.server.api.edm.provider.Property;
-
-public class ComplexTypeProvider {
-
- public static final FullQualifiedName nameCTAllPrim = new FullQualifiedName(SchemaProvider.nameSpace, "CTAllPrim");
- public static final FullQualifiedName nameCTBase = new FullQualifiedName(SchemaProvider.nameSpace, "CTBase");
- public static final FullQualifiedName nameCTBasePrimCompNav = new FullQualifiedName(SchemaProvider.nameSpace,
- "CTBasePrimCompNav");
- public static final FullQualifiedName nameCTCollAllPrim = new FullQualifiedName(SchemaProvider.nameSpace,
- "CTCollAllPrim");
- public static final FullQualifiedName nameCTCompCollComp = new FullQualifiedName(SchemaProvider.nameSpace,
- "CTCompCollComp");
- public static final FullQualifiedName nameCTCompComp = new FullQualifiedName(SchemaProvider.nameSpace, "CTCompComp");
- public static final FullQualifiedName nameCTCompNav = new FullQualifiedName(SchemaProvider.nameSpace, "CTCompNav");
-
- public static final FullQualifiedName nameCTMixPrimCollComp = new FullQualifiedName(SchemaProvider.nameSpace,
- "CTMixPrimCollComp");
- public static final FullQualifiedName nameCTNavFiveProp = new FullQualifiedName(SchemaProvider.nameSpace,
- "CTNavFiveProp");
- public static final FullQualifiedName nameCTPrim = new FullQualifiedName(SchemaProvider.nameSpace, "CTPrim");
- public static final FullQualifiedName nameCTPrimComp = new FullQualifiedName(SchemaProvider.nameSpace, "CTPrimComp");
- public static final FullQualifiedName nameCTPrimEnum = new FullQualifiedName(SchemaProvider.nameSpace, "CTPrimEnum");
- public static final FullQualifiedName nameCTTwoBase = new FullQualifiedName(SchemaProvider.nameSpace, "CTTwoBase");
- public static final FullQualifiedName nameCTTwoBasePrimCompNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "CTTwoBasePrimCompNav");
- public static final FullQualifiedName nameCTTwoPrim = new FullQualifiedName(SchemaProvider.nameSpace, "CTTwoPrim");
-
- public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException {
-
- if (complexTypeName.equals(nameCTPrim)) {
- return new ComplexType()
- .setName("CTPrim")
- .setProperties(Arrays.asList(PropertyProvider.propertyInt16));
-
- } else if (complexTypeName.equals(nameCTAllPrim)) {
- return new ComplexType()
- .setName("CTAllPrim")
- .setProperties(
- Arrays.asList(PropertyProvider.propertyString, PropertyProvider.propertyBinary,
- PropertyProvider.propertyBoolean, PropertyProvider.propertyByte, PropertyProvider.propertyDate,
- PropertyProvider.propertyDateTimeOffset, PropertyProvider.propertyDecimal,
- PropertyProvider.propertySingle, PropertyProvider.propertyDouble, PropertyProvider.propertyDuration,
- PropertyProvider.propertyGuid, PropertyProvider.propertyInt16, PropertyProvider.propertyInt32,
- PropertyProvider.propertyInt64, PropertyProvider.propertySByte, PropertyProvider.propertyTimeOfDay
- /* TODO add propertyStream */));
-
- } else if (complexTypeName.equals(nameCTCollAllPrim)) {
- return new ComplexType()
- .setName("CTCollAllPrim")
- .setProperties(
- Arrays.asList(
- PropertyProvider.collPropertyString, PropertyProvider.collPropertyBoolean,
- PropertyProvider.collPropertyByte, PropertyProvider.collPropertySByte,
- PropertyProvider.collPropertyInt16, PropertyProvider.collPropertyInt32,
- PropertyProvider.collPropertyInt64, PropertyProvider.collPropertySingle,
- PropertyProvider.collPropertyDouble, PropertyProvider.collPropertyDecimal,
- PropertyProvider.collPropertyBinary, PropertyProvider.collPropertyDate,
- PropertyProvider.collPropertyDateTimeOffset, PropertyProvider.collPropertyDuration,
- PropertyProvider.collPropertyGuid, PropertyProvider.collPropertyTimeOfDay
- /* TODO add collectionPropertyStream */));
-
- } else if (complexTypeName.equals(nameCTTwoPrim)) {
- return new ComplexType()
- .setName("CTTwoPrim")
- .setProperties(Arrays.asList(PropertyProvider.propertyInt16, PropertyProvider.propertyString));
-
- } else if (complexTypeName.equals(nameCTCompNav)) {
- return new ComplexType()
- .setName("CTCompNav")
- .setProperties(Arrays.asList(PropertyProvider.propertyString,
- PropertyProvider.propertyComplex_CTNavFiveProp));
-
- } else if (complexTypeName.equals(nameCTMixPrimCollComp)) {
- return new ComplexType()
- .setName("CTMixPrimCollComp")
- .setProperties(
- Arrays.asList(PropertyProvider.propertyInt16, PropertyProvider.collPropertyString,
- PropertyProvider.propertyComplex_CTTwoPrim, PropertyProvider.collPropertyComplex_CTTwoPrim));
-
- } else if (complexTypeName.equals(nameCTBase)) {
- return new ComplexType()
- .setName("CTBase")
- .setBaseType(nameCTTwoPrim)
- .setProperties(Arrays.asList(
- new Property()
- .setName("AdditionalPropString")
- .setType(new FullQualifiedName("Edm", "String"))));
-
- } else if (complexTypeName.equals(nameCTTwoBase)) {
- return new ComplexType()
- .setName("CTTwoBase")
- .setBaseType(nameCTBase);
-
- } else if (complexTypeName.equals(nameCTCompComp)) {
- return new ComplexType()
- .setName("CTCompComp")
- .setProperties(Arrays.asList(PropertyProvider.propertyComplex_CTTwoPrim));
-
- } else if (complexTypeName.equals(nameCTCompCollComp)) {
- return new ComplexType()
- .setName("CTCompCollComp")
- .setProperties(Arrays.asList(PropertyProvider.collPropertyComplex_CTTwoPrim));
-
- } else if (complexTypeName.equals(nameCTPrimComp)) {
- return new ComplexType()
- .setName("CTPrimComp")
- .setProperties(Arrays.asList(PropertyProvider.propertyInt16, PropertyProvider.propertyComplex_CTAllPrim));
-
- } else if (complexTypeName.equals(nameCTNavFiveProp)) {
- return new ComplexType()
- .setName("CTNavFiveProp")
- .setProperties(Arrays.asList(PropertyProvider.propertyInt16))
- .setNavigationProperties((Arrays.asList(
- PropertyProvider.collectionNavPropertyETTwoKeyNavOne_ETTwoKeyNav,
- PropertyProvider.collectionNavPropertyETTwoKeyNavMany_ETTwoKeyNav,
- new NavigationProperty()
- .setName("NavPropertyETMediaOne")
- .setType(EntityTypeProvider.nameETMedia),
- new NavigationProperty()
- .setName("NavPropertyETMediaMany")
- .setType(EntityTypeProvider.nameETMedia).setCollection(true)
- )));
-
- } else if (complexTypeName.equals(nameCTBasePrimCompNav)) {
- return new ComplexType()
- .setName("CTBasePrimCompNav")
- .setBaseType(nameCTPrimComp)
- .setNavigationProperties(Arrays.asList(
- PropertyProvider.collectionNavPropertyETTwoKeyNavMany_ETTwoKeyNav,
- PropertyProvider.collectionNavPropertyETTwoKeyNavOne_ETTwoKeyNav,
- PropertyProvider.navPropertyETKeyNavOne_ETKeyNav,
- PropertyProvider.collectionNavPropertyETKeyNavMany_ETKeyNav));
-
- } else if (complexTypeName.equals(nameCTPrimEnum)) {
- return new ComplexType()
- .setName("CTPrimEnum")
- .setProperties(Arrays.asList(PropertyProvider.propertyInt16, PropertyProvider.propertyEnumString_ENString));
-
- } else if (complexTypeName.equals(nameCTTwoBasePrimCompNav)) {
- return new ComplexType()
- .setName("CTTwoBasePrimCompNav")
- .setBaseType(nameCTBasePrimCompNav);
-
- }
-
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ContainerProvider.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ContainerProvider.java b/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ContainerProvider.java
deleted file mode 100644
index 5b92317..0000000
--- a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ContainerProvider.java
+++ /dev/null
@@ -1,361 +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.testutil.techprovider;
-
-import java.util.Arrays;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.Target;
-import org.apache.olingo.server.api.edm.provider.ActionImport;
-import org.apache.olingo.server.api.edm.provider.EntityContainer;
-import org.apache.olingo.server.api.edm.provider.EntityContainerInfo;
-import org.apache.olingo.server.api.edm.provider.EntitySet;
-import org.apache.olingo.server.api.edm.provider.FunctionImport;
-import org.apache.olingo.server.api.edm.provider.NavigationPropertyBinding;
-import org.apache.olingo.server.api.edm.provider.Singleton;
-
-public class ContainerProvider {
-
- public static final FullQualifiedName nameContainer = new FullQualifiedName(SchemaProvider.nameSpace, "Container");
-
- EntityContainerInfo entityContainerInfoTest1 =
- new EntityContainerInfo().setContainerName(nameContainer);
-
- public EntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName) throws ODataException {
- if (entityContainerName == null) {
- return entityContainerInfoTest1;
- } else if (entityContainerName.equals(nameContainer)) {
- return entityContainerInfoTest1;
- }
-
- return null;
- }
-
- public EntityContainer getEntityContainer() throws ODataException {
- return null;
- }
-
- public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String name) throws ODataException {
- if (entityContainer == nameContainer) {
- if (name.equals("ESAllPrim")) {
- return new EntitySet()
- .setName("ESAllPrim")
- .setType(EntityTypeProvider.nameETAllPrim);
-
- } else if (name.equals("ESCollAllPrim")) {
- return new EntitySet()
- .setName("ESCollAllPrim")
- .setType(EntityTypeProvider.nameETCollAllPrim);
-
- } else if (name.equals("ESTwoPrim")) {
- return new EntitySet()
- .setName("ESTwoPrim")
- .setType(EntityTypeProvider.nameETTwoPrim);
-
- } else if (name.equals("ESMixPrimCollComp")) {
- return new EntitySet()
- .setName("ESMixPrimCollComp")
- .setType(EntityTypeProvider.nameETMixPrimCollComp);
-
- } else if (name.equals("ESBase")) {
- return new EntitySet()
- .setName("ESBase")
- .setType(EntityTypeProvider.nameETBase);
-
- } else if (name.equals("ESTwoBase")) {
- return new EntitySet()
- .setName("ESTwoBase")
- .setType(EntityTypeProvider.nameETTwoBase);
-
- } else if (name.equals("ESTwoKeyTwoPrim")) {
- return new EntitySet()
- .setName("ESTwoKeyTwoPrim")
- .setType(EntityTypeProvider.nameETTwoKeyTwoPrim);
-
- } else if (name.equals("ESBaseTwoKeyTwoPrim")) {
- return new EntitySet()
- .setName("ESBaseTwoKeyTwoPrim")
- .setType(EntityTypeProvider.nameETBaseTwoKeyTwoPrim);
-
- } else if (name.equals("ESTwoBaseTwoKeyTwoPrim")) {
- return new EntitySet()
- .setName("ESTwoBaseTwoKeyTwoPrim")
- .setType(EntityTypeProvider.nameETTwoBaseTwoKeyTwoPrim);
-
- } else if (name.equals("ESAllKey")) {
- return new EntitySet()
- .setName("ESAllKey")
- .setType(EntityTypeProvider.nameETAllKey);
-
- } else if (name.equals("ESCompAllPrim")) {
- return new EntitySet()
- .setName("ESCompAllPrim")
- .setType(EntityTypeProvider.nameETCompAllPrim);
-
- } else if (name.equals("ESCompCollAllPrim")) {
- return new EntitySet()
- .setName("ESCompCollAllPrim")
- .setType(EntityTypeProvider.nameETCompCollAllPrim);
-
- } else if (name.equals("ESCompComp")) {
- return new EntitySet()
- .setName("ESCompComp")
- .setType(EntityTypeProvider.nameETCompComp);
-
- } else if (name.equals("ESCompCollComp")) {
- return new EntitySet()
- .setName("ESCompCollComp")
- .setType(EntityTypeProvider.nameETCompCollComp);
-
- } else if (name.equals("ESMedia")) {
- return new EntitySet()
- .setName("ESMedia")
- .setType(EntityTypeProvider.nameETMedia)
- .setIncludeInServiceDocument(true);
-
- } else if (name.equals("ESKeyTwoKeyComp")) {
- return new EntitySet()
- .setName("ESKeyTwoKeyComp")
- .setType(EntityTypeProvider.nameETKeyTwoKeyComp);
-
- } else if (name.equals("ESInvisible")) {
- return new EntitySet()
- .setName("ESInvisible")
- .setType(EntityTypeProvider.nameETAllPrim);
-
- } else if (name.equals("ESServerSidePaging")) {
- return new EntitySet()
- .setName("ESServerSidePaging")
- .setType(EntityTypeProvider.nameETServerSidePaging);
-
- } else if (name.equals("ESAllNullable")) {
- return new EntitySet()
- .setName("ESAllNullable")
- .setType(EntityTypeProvider.nameETAllNullable);
-
- } else if (name.equals("ESKeyNav")) {
- return new EntitySet()
- .setName("ESKeyNav")
- .setType(EntityTypeProvider.nameETKeyNav);
-
- } else if (name.equals("ESTwoKeyNav")) {
- return new EntitySet()
- .setName("ESTwoKeyNav")
- .setType(EntityTypeProvider.nameETTwoKeyNav);
-
- } else if (name.equals("ESBaseTwoKeyNav")) {
- return new EntitySet()
- .setName("ESBaseTwoKeyNav")
- .setType(EntityTypeProvider.nameETBaseTwoKeyNav);
-
- } else if (name.equals("ESCompMixPrimCollComp")) {
- return new EntitySet()
- .setName("ESCompMixPrimCollComp")
- .setType(EntityTypeProvider.nameETCompMixPrimCollComp);
-
- } else if (name.equals("ESFourKeyAlias")) {
- return new EntitySet()
- .setName("ESFourKeyAlias")
- .setType(EntityTypeProvider.nameETFourKeyAlias);
- }
- }
-
- return null;
- }
-
- public ActionImport getActionImport(final FullQualifiedName entityContainer, final String name) throws ODataException
- {
- if (entityContainer.equals(nameContainer)) {
- if (name.equals("AIRTPrimParam")) {
- return new ActionImport()
- .setName("AIRTPrimParam")
- .setAction(ActionProvider.nameUARTPrimParam);
-
- } else if (name.equals("AIRTPrimCollParam")) {
- return new ActionImport()
- .setName("AIRTPrimCollParam")
- .setAction(ActionProvider.nameUARTPrimCollParam);
-
- } else if (name.equals("AIRTCompParam")) {
- return new ActionImport()
- .setName("AIRTCompParam")
- .setAction(ActionProvider.nameUARTCompParam);
-
- } else if (name.equals("AIRTCompCollParam")) {
- return new ActionImport()
- .setName("AIRTCompCollParam")
- .setAction(ActionProvider.nameUARTCompCollParam);
-
- } else if (name.equals("AIRTETParam")) {
- return new ActionImport()
- .setName("AIRTETParam")
- .setAction(ActionProvider.nameUARTETParam);
-
- } else if (name.equals("AIRTETCollAllPrimParam")) {
- return new ActionImport()
- .setName("AIRTETCollAllPrimParam")
- .setAction(ActionProvider.nameUARTESParam);
- }
- }
-
- return null;
- }
-
- public FunctionImport getFunctionImport(final FullQualifiedName entityContainer, final String name)
- throws ODataException {
-
- if (entityContainer.equals(nameContainer)) {
- if (name.equals("FINRTInt16")) {
- return new FunctionImport()
- .setName("FINRTInt16")
- .setFunction(FunctionProvider.nameUFNRTInt16)
- .setIncludeInServiceDocument(true);
-
- } else if (name.equals("FINInvisibleRTInt16")) {
- return new FunctionImport()
- .setName("FINInvisibleRTInt16")
- .setFunction(FunctionProvider.nameUFNRTInt16);
-
- } else if (name.equals("FINInvisible2RTInt16")) {
- return new FunctionImport()
- .setName("FINInvisible2RTInt16")
- .setFunction(FunctionProvider.nameUFNRTInt16);
-
- } else if (name.equals("FICRTETKeyNav")) {
- return new FunctionImport()
- .setName("FICRTETKeyNav")
- .setFunction(FunctionProvider.nameUFCRTETKeyNav);
-
- } else if (name.equals("FICRTETTwoKeyNavParam")) {
- return new FunctionImport()
- .setName("FICRTETTwoKeyNavParam")
- .setFunction(FunctionProvider.nameUFCRTETTwoKeyNavParam)
- .setIncludeInServiceDocument(true);
-
- } else if (name.equals("FICRTStringTwoParam")) {
- return new FunctionImport()
- .setName("FICRTStringTwoParam")
- .setFunction(FunctionProvider.nameUFCRTStringTwoParam)
- .setIncludeInServiceDocument(true);
-
- } else if (name.equals("FICRTCollStringTwoParam")) {
- return new FunctionImport()
- .setName("FICRTCollStringTwoParam")
- .setFunction(FunctionProvider.nameUFCRTCollStringTwoParam)
- .setIncludeInServiceDocument(true);
-
- } else if (name.equals("FICRTCTAllPrimTwoParam")) {
- return new FunctionImport()
- .setName("FICRTCTAllPrimTwoParam")
- .setFunction(FunctionProvider.nameUFCRTCTAllPrimTwoParam)
- .setIncludeInServiceDocument(true);
-
- } else if (name.equals("FICRTESMixPrimCollCompTwoParam")) {
- return new FunctionImport()
- .setName("FICRTESMixPrimCollCompTwoParam")
- .setFunction(FunctionProvider.nameUFCRTESMixPrimCollCompTwoParam)
- .setIncludeInServiceDocument(true);
-
- } else if (name.equals("FINRTESMixPrimCollCompTwoParam")) {
- return new FunctionImport()
- .setName("FINRTESMixPrimCollCompTwoParam")
- .setFunction(FunctionProvider.nameUFNRTESMixPrimCollCompTwoParam)
- .setIncludeInServiceDocument(true);
-
- } else if (name.equals("FICRTCollCTTwoPrim")) {
- return new FunctionImport()
- .setName("FICRTCollCTTwoPrim")
- .setFunction(FunctionProvider.nameUFCRTCollCTTwoPrim)
- .setIncludeInServiceDocument(true);
-
- } else if (name.equals("FICRTETMedia")) {
- return new FunctionImport()
- .setName("FICRTETMedia")
- .setFunction(FunctionProvider.nameUFCRTETMedia)
- .setIncludeInServiceDocument(true);
-
- } else if (name.equals("FICRTCTTwoPrimParam")) {
- return new FunctionImport()
- .setName("FICRTCTTwoPrimParam")
- .setFunction(FunctionProvider.nameUFCRTCTTwoPrimParam)
- .setIncludeInServiceDocument(true);
-
- } else if (name.equals("FICRTCTTwoPrim")) {
- return new FunctionImport()
- .setName("FICRTCTTwoPrim")
- .setFunction(FunctionProvider.nameUFCRTCTTwoPrim)
- .setIncludeInServiceDocument(true);
-
- } else if (name.equals("FICRTCollString")) {
- return new FunctionImport()
- .setName("FICRTCollString")
- .setFunction(FunctionProvider.nameUFCRTCollString)
- .setIncludeInServiceDocument(true);
-
- } else if (name.equals("FICRTString")) {
- return new FunctionImport()
- .setName("FICRTString")
- .setFunction(FunctionProvider.nameUFCRTString)
- .setIncludeInServiceDocument(true);
-
- } else if (name.equals("FICRTESTwoKeyNavParam")) {
- return new FunctionImport()
- .setName("FICRTESTwoKeyNavParam")
- .setFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam)
- .setIncludeInServiceDocument(true);
-
- } else if (name.equals("FICRTCollCTTwoPrimParam")) {
- return new FunctionImport()
- .setName("FICRTCollCTTwoPrimParam")
- .setFunction(FunctionProvider.nameUFCRTCollCTTwoPrimParam)
- .setIncludeInServiceDocument(true);
-
- }
- }
-
- return null;
- }
-
- public Singleton getSingleton(final FullQualifiedName entityContainer, final String name) throws ODataException {
- if (entityContainer.equals(nameContainer)) {
-
- if (name.equals("SI")) {
- return new Singleton()
- .setName("SI")
- .setType(EntityTypeProvider.nameETTwoPrim);
-
- } else if (name.equals("SINav")) {
- return new Singleton()
- .setName("SINav")
- .setType(EntityTypeProvider.nameETTwoKeyNav)
- .setNavigationPropertyBindings(Arrays.asList(
- new NavigationPropertyBinding()
- .setPath("NavPropertyETTwoKeyNavMany")
- .setTarget(new Target().setTargetName("ESTwoKeyNav"))));
-
- } else if (name.equals("SIMedia")) {
- return new Singleton()
- .setName("SIMedia")
- .setType(EntityTypeProvider.nameETMedia);
- }
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EdmTechProvider.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EdmTechProvider.java b/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EdmTechProvider.java
deleted file mode 100644
index 93e9c9d..0000000
--- a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EdmTechProvider.java
+++ /dev/null
@@ -1,147 +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.testutil.techprovider;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.server.api.edm.provider.Action;
-import org.apache.olingo.server.api.edm.provider.ActionImport;
-import org.apache.olingo.server.api.edm.provider.AliasInfo;
-import org.apache.olingo.server.api.edm.provider.ComplexType;
-import org.apache.olingo.server.api.edm.provider.EdmProvider;
-import org.apache.olingo.server.api.edm.provider.EntityContainer;
-import org.apache.olingo.server.api.edm.provider.EntityContainerInfo;
-import org.apache.olingo.server.api.edm.provider.EntitySet;
-import org.apache.olingo.server.api.edm.provider.EntityType;
-import org.apache.olingo.server.api.edm.provider.EnumType;
-import org.apache.olingo.server.api.edm.provider.Function;
-import org.apache.olingo.server.api.edm.provider.FunctionImport;
-import org.apache.olingo.server.api.edm.provider.Schema;
-import org.apache.olingo.server.api.edm.provider.Singleton;
-import org.apache.olingo.server.api.edm.provider.Term;
-import org.apache.olingo.server.api.edm.provider.TypeDefinition;
-
-public class EdmTechProvider extends EdmProvider {
-
- public static final String nameSpace = "com.sap.odata.test1";
-
- private final SchemaProvider schemaProvider;
- private final EntityTypeProvider entityTypeProvider;
- private final ContainerProvider containerProvider;
- private final ComplexTypeProvider complexTypeProvider;
- private final EnumTypeProvider enumTypeProvider;
- private final ActionProvider actionProvider;
- private final FunctionProvider functionProvider;
- private final TypeDefinitionProvider typeDefinitionProvider;
-
- public EdmTechProvider() {
- containerProvider = new ContainerProvider();
- entityTypeProvider = new EntityTypeProvider();
- complexTypeProvider = new ComplexTypeProvider();
- enumTypeProvider = new EnumTypeProvider();
- actionProvider = new ActionProvider();
- functionProvider = new FunctionProvider();
- typeDefinitionProvider = new TypeDefinitionProvider();
- schemaProvider = new SchemaProvider(this);
- }
-
- @Override
- public List<AliasInfo> getAliasInfos() throws ODataException {
- return Arrays.asList(
- new AliasInfo().setAlias("Namespace1_Alias").setNamespace(nameSpace)
- );
- }
-
- @Override
- public EnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException {
- return enumTypeProvider.getEnumType(enumTypeName);
- }
-
- @Override
- public TypeDefinition getTypeDefinition(final FullQualifiedName typeDefinitionName) throws ODataException {
- return typeDefinitionProvider.getTypeDefinition(typeDefinitionName);
- }
-
- @Override
- public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException {
- return entityTypeProvider.getEntityType(entityTypeName);
- }
-
- @Override
- public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException {
- return complexTypeProvider.getComplexType(complexTypeName);
- }
-
- @Override
- public List<Action> getActions(final FullQualifiedName actionName) throws ODataException {
- return actionProvider.getActions(actionName);
- }
-
- @Override
- public List<Function> getFunctions(final FullQualifiedName functionName) throws ODataException {
- return functionProvider.getFunctions(functionName);
- }
-
- @Override
- public Term getTerm(final FullQualifiedName termName) throws ODataException {
- return null;
- }
-
- @Override
- public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName)
- throws ODataException {
- return containerProvider.getEntitySet(entityContainer, entitySetName);
- }
-
- @Override
- public Singleton getSingleton(final FullQualifiedName entityContainer, final String singletonName)
- throws ODataException {
- return containerProvider.getSingleton(entityContainer, singletonName);
- }
-
- @Override
- public ActionImport getActionImport(final FullQualifiedName entityContainer, final String actionImportName)
- throws ODataException {
- return containerProvider.getActionImport(entityContainer, actionImportName);
- }
-
- @Override
- public FunctionImport getFunctionImport(final FullQualifiedName entityContainer, final String functionImportName)
- throws ODataException {
- return containerProvider.getFunctionImport(entityContainer, functionImportName);
- }
-
- @Override
- public List<Schema> getSchemas() throws ODataException {
- return schemaProvider.getSchemas();
- }
-
- @Override
- public EntityContainer getEntityContainer() throws ODataException {
- return containerProvider.getEntityContainer();
- }
-
- @Override
- public EntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName) throws ODataException {
- return containerProvider.getEntityContainerInfo(entityContainerName);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EntityTypeProvider.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EntityTypeProvider.java b/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EntityTypeProvider.java
deleted file mode 100644
index 9072234..0000000
--- a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EntityTypeProvider.java
+++ /dev/null
@@ -1,408 +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.testutil.techprovider;
-
-import java.util.Arrays;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.server.api.edm.provider.EntityType;
-import org.apache.olingo.server.api.edm.provider.NavigationProperty;
-import org.apache.olingo.server.api.edm.provider.Property;
-import org.apache.olingo.server.api.edm.provider.PropertyRef;
-import org.apache.olingo.server.api.edm.provider.ReferentialConstraint;
-
-public class EntityTypeProvider {
-
- public static final FullQualifiedName nameETAllKey = new FullQualifiedName(SchemaProvider.nameSpace, "ETAllKey");
- public static final FullQualifiedName nameETAllNullable = new FullQualifiedName(SchemaProvider.nameSpace,
- "ETAllNullable");
- public static final FullQualifiedName nameETAllPrim = new FullQualifiedName(SchemaProvider.nameSpace, "ETAllPrim");
- public static final FullQualifiedName nameETBase = new FullQualifiedName(SchemaProvider.nameSpace, "ETBase");
- public static final FullQualifiedName nameETBaseTwoKeyNav = new FullQualifiedName(SchemaProvider.nameSpace,
- "ETBaseTwoKeyNav");
- public static final FullQualifiedName nameETBaseTwoKeyTwoPrim =
- new FullQualifiedName(SchemaProvider.nameSpace, "ETBaseTwoKeyTwoPrim");
- public static final FullQualifiedName nameETCollAllPrim = new FullQualifiedName(SchemaProvider.nameSpace,
- "ETCollAllPrim");
- public static final FullQualifiedName nameETCompAllPrim = new FullQualifiedName(SchemaProvider.nameSpace,
- "ETCompAllPrim");
- public static final FullQualifiedName nameETCompCollAllPrim = new FullQualifiedName(SchemaProvider.nameSpace,
- "ETCompCollAllPrim");
- public static final FullQualifiedName nameETCompCollComp = new FullQualifiedName(SchemaProvider.nameSpace,
- "ETCompCollComp");
- public static final FullQualifiedName nameETCompComp = new FullQualifiedName(SchemaProvider.nameSpace, "ETCompComp");
- public static final FullQualifiedName nameETCompMixPrimCollComp =
- new FullQualifiedName(SchemaProvider.nameSpace, "ETCompMixPrimCollComp");
- public static final FullQualifiedName nameETFourKeyAlias = new FullQualifiedName(SchemaProvider.nameSpace,
- "ETFourKeyAlias");
- public static final FullQualifiedName nameETKeyNav = new FullQualifiedName(SchemaProvider.nameSpace, "ETKeyNav");
- public static final FullQualifiedName nameETKeyPrimNav = new FullQualifiedName(SchemaProvider.nameSpace,
- "ETKeyPrimNav");
- public static final FullQualifiedName nameETKeyTwoKeyComp = new FullQualifiedName(SchemaProvider.nameSpace,
- "ETKeyTwoKeyComp");
- public static final FullQualifiedName nameETMedia = new FullQualifiedName(SchemaProvider.nameSpace, "ETMedia");
- public static final FullQualifiedName nameETMixPrimCollComp = new FullQualifiedName(SchemaProvider.nameSpace,
- "ETMixPrimCollComp");
- public static final FullQualifiedName nameETServerSidePaging =
- new FullQualifiedName(SchemaProvider.nameSpace, "ETServerSidePaging");
- public static final FullQualifiedName nameETTwoBase = new FullQualifiedName(SchemaProvider.nameSpace, "ETTwoBase");
- public static final FullQualifiedName nameETTwoBaseTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "ETTwoBaseTwoKeyNav");
- public static final FullQualifiedName nameETTwoBaseTwoKeyTwoPrim =
- new FullQualifiedName(SchemaProvider.nameSpace, "ETTwoBaseTwoKeyTwoPrim");
- public static final FullQualifiedName nameETTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "ETTwoKeyNav");
- public static final FullQualifiedName nameETTwoKeyTwoPrim = new FullQualifiedName(SchemaProvider.nameSpace,
- "ETTwoKeyTwoPrim");
- public static final FullQualifiedName nameETTwoPrim = new FullQualifiedName(SchemaProvider.nameSpace, "ETTwoPrim");
-
- public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException {
- if (entityTypeName.equals(nameETAllPrim)) {
- return new EntityType()
- .setName("ETAllPrim")
- .setKey(Arrays.asList(
- new PropertyRef().setPropertyName("PropertyInt16")))
- .setProperties(Arrays.asList(
- PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString,
- PropertyProvider.propertyBoolean, PropertyProvider.propertyByte, PropertyProvider.propertySByte,
- PropertyProvider.propertyInt32, PropertyProvider.propertyInt64,
- PropertyProvider.propertySingle, PropertyProvider.propertyDouble, PropertyProvider.propertyDecimal,
- PropertyProvider.propertyBinary, PropertyProvider.propertyDate, PropertyProvider.propertyDateTimeOffset,
- PropertyProvider.propertyDuration, PropertyProvider.propertyGuid, PropertyProvider.propertyTimeOfDay
- /* TODO add propertyStream */))
- .setNavigationProperties(Arrays.asList(PropertyProvider.navPropertyETTwoPrimOne_ETTwoPrim,
- PropertyProvider.collectionNavPropertyETTwoPrimMany_ETTwoPrim));
-
- } else if (entityTypeName.equals(nameETCollAllPrim)) {
- return new EntityType()
- .setName("ETCollAllPrim")
- .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
-
- .setProperties(
- Arrays.asList(
- PropertyProvider.propertyInt16_NotNullable, PropertyProvider.collPropertyString,
- PropertyProvider.collPropertyBoolean, PropertyProvider.collPropertyByte,
- PropertyProvider.collPropertySByte, PropertyProvider.collPropertyInt16,
- PropertyProvider.collPropertyInt32, PropertyProvider.collPropertyInt64,
- PropertyProvider.collPropertySingle, PropertyProvider.collPropertyDouble,
- PropertyProvider.collPropertyDecimal, PropertyProvider.collPropertyBinary,
- PropertyProvider.collPropertyDate, PropertyProvider.collPropertyDateTimeOffset,
- PropertyProvider.collPropertyDuration, PropertyProvider.collPropertyGuid,
- PropertyProvider.collPropertyTimeOfDay /* TODO add propertyStream */));
-
- } else if (entityTypeName.equals(nameETTwoPrim)) {
- return new EntityType()
- .setName("ETTwoPrim")
- .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
- .setProperties(Arrays.asList(
- PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString))
- .setNavigationProperties(
- Arrays.asList(PropertyProvider.navPropertyETAllPrimOne_ETAllPrim,
- PropertyProvider.collectionNavPropertyETAllPrimMany_ETAllPrim));
-
- } else if (entityTypeName.equals(nameETMixPrimCollComp)) {
- return new EntityType()
- .setName("ETMixPrimCollComp")
- .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
- .setProperties(Arrays.asList(
- PropertyProvider.propertyInt16_NotNullable, PropertyProvider.collPropertyString,
- PropertyProvider.propertyComplex_CTTwoPrim, PropertyProvider.collPropertyComplex_CTTwoPrim));
-
- } else if (entityTypeName.equals(nameETTwoKeyTwoPrim)) {
- return new EntityType()
- .setName("ETTwoKeyTwoPrim")
- .setKey(Arrays.asList(
- new PropertyRef().setPropertyName("PropertyInt16"),
- new PropertyRef().setPropertyName("PropertyString")))
- .setProperties(Arrays.asList(
- PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString));
-
- } else if (entityTypeName.equals(nameETBaseTwoKeyTwoPrim)) {
- return new EntityType()
- .setName("ETBaseTwoKeyTwoPrim")
- .setBaseType(nameETTwoKeyTwoPrim);
-
- } else if (entityTypeName.equals(nameETTwoBaseTwoKeyTwoPrim)) {
- return new EntityType()
- .setName("ETTwoBaseTwoKeyTwoPrim")
- .setBaseType(nameETTwoKeyTwoPrim);
-
- } else if (entityTypeName.equals(nameETBase)) {
- return new EntityType()
- .setName("ETBase")
- .setBaseType(nameETTwoPrim)
- .setProperties(Arrays.asList(new Property()
- .setName("AdditionalPropertyString_5")
- .setType(PropertyProvider.nameString)));
-
- } else if (entityTypeName.equals(nameETTwoBase)) {
- return new EntityType()
- .setName("ETTwoBase")
- .setBaseType(nameETBase)
- .setProperties(Arrays.asList(new Property()
- .setName("AdditionalPropertyString_6")
- .setType(PropertyProvider.nameString))
- );
-
- } else if (entityTypeName.equals(nameETAllKey)) {
- return new EntityType()
- .setName("ETAllKey")
- .setKey(Arrays.asList(
- new PropertyRef().setPropertyName("PropertyString"),
- new PropertyRef().setPropertyName("PropertyBoolean"),
- new PropertyRef().setPropertyName("PropertyByte"),
- new PropertyRef().setPropertyName("PropertySByte"),
- new PropertyRef().setPropertyName("PropertyInt16"),
- new PropertyRef().setPropertyName("PropertyInt32"),
- new PropertyRef().setPropertyName("PropertyInt64"),
- new PropertyRef().setPropertyName("PropertyDecimal"),
- new PropertyRef().setPropertyName("PropertyDate"),
- new PropertyRef().setPropertyName("PropertyDateTimeOffset"),
- new PropertyRef().setPropertyName("PropertyDuration"),
- new PropertyRef().setPropertyName("PropertyGuid"),
- new PropertyRef().setPropertyName("PropertyTimeOfDay")))
- .setProperties(
- Arrays.asList(
- PropertyProvider.propertyString_NotNullable, PropertyProvider.propertyBoolean_NotNullable,
- PropertyProvider.propertyByte_NotNullable, PropertyProvider.propertySByte_NotNullable,
- PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyInt32_NotNullable,
- PropertyProvider.propertyInt64_NotNullable,
- PropertyProvider.propertyDecimal_NotNullable, PropertyProvider.propertyDate_NotNullable,
- PropertyProvider.propertyDateTimeOffset_NotNullable,
- PropertyProvider.propertyDuration_NotNullable, PropertyProvider.propertyGuid_NotNullable,
- PropertyProvider.propertyTimeOfDay_NotNullable /* TODO add propertyStream */));
-
- } else if (entityTypeName.equals(nameETCompAllPrim)) {
- return new EntityType()
- .setName("ETCompAllPrim")
- .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
- .setProperties(
- Arrays.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComplex_CTAllPrim));
-
- } else if (entityTypeName.equals(nameETCompCollAllPrim)) {
- return new EntityType()
- .setName("ETCompCollAllPrim")
- .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
-
- .setProperties(
- Arrays.asList(PropertyProvider.propertyInt16_NotNullable,
- PropertyProvider.propertyComplex_CTCollAllPrim));
-
- } else if (entityTypeName.equals(nameETCompComp)) {
- return new EntityType()
- .setName("ETCompComp")
- .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
- .setProperties(
- Arrays.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComplex_CTCompComp));
-
- } else if (entityTypeName.equals(nameETCompCollComp)) {
- return new EntityType()
- .setName("ETCompCollComp")
- .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
- .setProperties(
- Arrays
- .asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComplex_CTCompCollComp));
-
- } else if (entityTypeName.equals(nameETMedia)) {
- return new EntityType()
- .setName("ETMedia")
- .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
- .setProperties(Arrays.asList(PropertyProvider.propertyInt16_NotNullable))
- .setHasStream(true);
-
- } else if (entityTypeName.equals(nameETKeyTwoKeyComp)) {
- return new EntityType()
- .setName("ETKeyTwoKeyComp")
- .setKey(Arrays.asList(
- new PropertyRef()
- .setPropertyName("PropertyInt16"),
- new PropertyRef()
- .setPropertyName("PropertyComplex/PropertyInt16")
- .setAlias("KeyAlias1"),
- new PropertyRef()
- .setPropertyName("PropertyComplex/PropertyString")
- .setAlias("KeyAlias2"),
- new PropertyRef()
- .setPropertyName("PropertyComplexComplex/PropertyComplex/PropertyString")
- .setAlias("KeyAlias3")))
- .setProperties(
- Arrays.asList(
- PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComplex_CTTwoPrim,
- PropertyProvider.propertyComplexComplex_CTCompComp));
-
- } else if (entityTypeName.equals(nameETServerSidePaging)) {
- return new EntityType()
- .setName(nameETServerSidePaging.getName())
- .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
- .setProperties(Arrays.asList(PropertyProvider.propertyInt16_NotNullable,
- PropertyProvider.propertyString_NotNullable));
-
- } else if (entityTypeName.equals(nameETAllNullable)) {
- return new EntityType()
- .setName("ETAllNullable")
- .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyKey")))
- .setProperties(
- Arrays.asList(
- new Property()
- .setName("PropertyKey").setType(PropertyProvider.nameInt16).setNullable(false),
- PropertyProvider.propertyInt16_ExplicitNullable, PropertyProvider.propertyString_ExplicitNullable,
- PropertyProvider.propertyBoolean_ExplicitNullable, PropertyProvider.propertyByte_ExplicitNullable,
- PropertyProvider.propertySByte_ExplicitNullable, PropertyProvider.propertyInt32_ExplicitNullable,
- PropertyProvider.propertyInt64_ExplicitNullable, PropertyProvider.propertySingle_ExplicitNullable,
- PropertyProvider.propertyDouble_ExplicitNullable, PropertyProvider.propertyDecimal_ExplicitNullable,
- PropertyProvider.propertyBinary_ExplicitNullable, PropertyProvider.propertyDate_ExplicitNullable,
- PropertyProvider.propertyDateTimeOffset_ExplicitNullable,
- PropertyProvider.propertyDuration_ExplicitNullable, PropertyProvider.propertyGuid_ExplicitNullable,
- PropertyProvider.propertyTimeOfDay_ExplicitNullable /* TODO add propertyStream */,
- PropertyProvider.collPropertyString_ExplicitNullable,
- PropertyProvider.collPropertyBoolean_ExplicitNullable,
- PropertyProvider.collPropertyByte_ExplicitNullable,
- PropertyProvider.collPropertySByte_ExplicitNullable,
- PropertyProvider.collPropertyInt16_ExplicitNullable,
- PropertyProvider.collPropertyInt32_ExplicitNullable,
- PropertyProvider.collPropertyInt64_ExplicitNullable,
- PropertyProvider.collPropertySingle_ExplicitNullable,
- PropertyProvider.collPropertyDouble_ExplicitNullable,
- PropertyProvider.collPropertyDecimal_ExplicitNullable,
- PropertyProvider.collPropertyBinary_ExplicitNullable,
- PropertyProvider.collPropertyDate_ExplicitNullable,
- PropertyProvider.collPropertyDateTimeOffset_ExplicitNullable,
- PropertyProvider.collPropertyDuration_ExplicitNullable,
- PropertyProvider.collPropertyGuid_ExplicitNullable,
- PropertyProvider.collPropertyTimeOfDay_ExplicitNullable /* TODO add propertyStream */));
-
- } else if (entityTypeName.equals(nameETKeyNav)) {
- return new EntityType()
- .setName("ETKeyNav")
- .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
- .setProperties(
- Arrays.asList(
- PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_NotNullable,
- PropertyProvider.propertyComplex_CTNavFiveProp,
- PropertyProvider.propertyComplexAllPrim_CTAllPrim, PropertyProvider.propertyComplexTwoPrim_CTTwoPrim,
- PropertyProvider.collPropertyString, PropertyProvider.collPropertyInt16,
- PropertyProvider.collPropertyComplex_CTPrimComp,
- new Property()
- .setName("PropertyComplexComplex").setType(ComplexTypeProvider.nameCTCompNav)
- ))
- .setNavigationProperties(
- Arrays.asList(
- PropertyProvider.navPropertyETTwoKeyNavOne_ETTwoKeyNav_NotNullable,
- PropertyProvider.collectionNavPropertyETTwoKeyNavMany_ETTwoKeyNav,
- PropertyProvider.navPropertyETKeyNavOne_ETKeyNav,
- PropertyProvider.collectionNavPropertyETKeyNavMany_ETKeyNav,
- PropertyProvider.navPropertyETMediaOne_ETMedia,
- PropertyProvider.collectionNavPropertyETMediaMany_ETMedia
- ));
- } else if (entityTypeName.equals(nameETKeyPrimNav)) {
- return new EntityType()
- .setName("ETKeyPrimNav")
- .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
- .setProperties(Arrays.asList(
- PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_ExplicitNullable))
- .setNavigationProperties(
- Arrays.asList(
- PropertyProvider.navPropertyETKeyPrimNavOne_ETKeyPrimNav));
-
- } else if (entityTypeName.equals(nameETTwoKeyNav)) {
- return new EntityType()
- .setName("ETTwoKeyNav")
- .setKey(Arrays.asList(
- new PropertyRef().setPropertyName("PropertyInt16"),
- new PropertyRef().setPropertyName("PropertyString")))
- .setProperties(
- Arrays.asList(
- PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_NotNullable,
- PropertyProvider.propertyComplex_CTPrimComp_NotNullable,
- new Property().setName("PropertyComplexNav").setType(ComplexTypeProvider.nameCTBasePrimCompNav)
- .setNullable(false),
- PropertyProvider.propertyComplexEnum_CTPrimEnum_NotNullable,
- PropertyProvider.collPropertyComplex_CTPrimComp,
- new Property().setName("CollPropertyComplexNav").setType(ComplexTypeProvider.nameCTNavFiveProp)
- .setCollection(true),
- PropertyProvider.collPropertyString, PropertyProvider.propertyComplexTwoPrim_CTTwoPrim,
- PropertyProvider.propertyEnumString_ENString
- ))
- .setNavigationProperties(Arrays.asList(
- new NavigationProperty()
- .setName("NavPropertyETKeyNavOne")
- .setType(nameETKeyNav)
- .setReferentialConstraints(Arrays.asList(
- new ReferentialConstraint()
- .setProperty("PropertyInt16")
- .setReferencedProperty("PropertyInt16"))),
- PropertyProvider.collectionNavPropertyETKeyNavMany_ETKeyNav,
- PropertyProvider.navPropertyETTwoKeyNavOne_ETTwoKeyNav,
- PropertyProvider.collectionNavPropertyETTwoKeyNavMany_ETTwoKeyNav));
-
- } else if (entityTypeName.equals(nameETBaseTwoKeyNav)) {
- return new EntityType()
- .setName("ETBaseTwoKeyNav")
- .setBaseType(nameETTwoKeyNav)
- .setProperties(Arrays.asList(PropertyProvider.propertyDate_ExplicitNullable))
- .setNavigationProperties(Arrays.asList(
- new NavigationProperty()
- .setName("NavPropertyETBaseTwoKeyNavOne")
- .setType(nameETBaseTwoKeyNav),
- new NavigationProperty()
- .setName("NavPropertyETTwoBaseTwoKeyNavOne")
- .setType(nameETTwoBaseTwoKeyNav)));
-
- } else if (entityTypeName.equals(nameETTwoBaseTwoKeyNav)) {
- return new EntityType()
- .setName("ETTwoBaseTwoKeyNav")
- .setBaseType(nameETBaseTwoKeyNav)
- .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
- .setProperties(Arrays.asList(PropertyProvider.propertyGuid_ExplicitNullable))
- .setNavigationProperties(Arrays.asList(
- new NavigationProperty()
- .setName("NavPropertyETBaseTwoKeyNavMany")
- .setType(nameETBaseTwoKeyNav)
- .setCollection(true)
- ));
-
- } else if (entityTypeName.equals(nameETFourKeyAlias)) {
- return new EntityType()
- .setName("ETFourKeyAlias")
- .setKey(
- Arrays.asList(
- new PropertyRef().setPropertyName("PropertyInt16"),
- new PropertyRef().setPath("PropertyComplex/PropertyInt16").setPropertyName("PropertyInt16").setAlias(
- "KeyAlias1"),
- new PropertyRef().setPath("PropertyComplex/PropertyString").setPropertyName("PropertyString")
- .setAlias("KeyAlias2"),
- new PropertyRef().setPath("PropertyComplexComplex/PropertyComplex/PropertyString").setPropertyName(
- "PropertyString").setAlias("KeyAlias3"))).setProperties(
- Arrays.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComplex_CTTwoPrim,
- PropertyProvider.propertyComplexComplex_CTCompComp));
- } else if (entityTypeName.equals(nameETCompMixPrimCollComp)) {
- return new EntityType()
- .setName("ETCompMixPrimCollComp")
- .setKey(Arrays.asList(
- new PropertyRef()
- .setPropertyName("PropertyInt16")))
- .setProperties(
- Arrays.asList(PropertyProvider.propertyInt16_NotNullable,
- PropertyProvider.propertyMixedPrimCollComp_CTMixPrimCollComp));
- }
-
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EnumTypeProvider.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EnumTypeProvider.java b/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EnumTypeProvider.java
deleted file mode 100644
index 94ea6ea..0000000
--- a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EnumTypeProvider.java
+++ /dev/null
@@ -1,47 +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.testutil.techprovider;
-
-import java.util.Arrays;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.server.api.edm.provider.EnumMember;
-import org.apache.olingo.server.api.edm.provider.EnumType;
-
-public class EnumTypeProvider {
-
- public static final FullQualifiedName nameENString = new FullQualifiedName(SchemaProvider.nameSpace, "ENString");
-
- public EnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException {
- if (enumTypeName.equals(nameENString)) {
- return new EnumType()
- .setName("ENString")
- .setFlags(true)
- .setUnderlyingType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName())
- .setMembers(Arrays.asList(
- new EnumMember().setName("String1").setValue("1"),
- new EnumMember().setName("String2").setValue("2"),
- new EnumMember().setName("String3").setValue("3")));
- }
-
- return null;
- }
-}
[06/15] [OLINGO-266] refactor ref module to server-ref
Posted by sk...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java
new file mode 100644
index 0000000..bd4ac68
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java
@@ -0,0 +1,508 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmAction;
+import org.apache.olingo.commons.api.edm.EdmActionImport;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmFunction;
+import org.apache.olingo.commons.api.edm.EdmFunctionImport;
+import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
+import org.apache.olingo.server.api.uri.UriResourceKind;
+import org.apache.olingo.server.core.edm.provider.EdmComplexTypeImpl;
+import org.apache.olingo.server.core.edm.provider.EdmEntitySetImpl;
+import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
+import org.apache.olingo.server.core.edm.provider.EdmSingletonImpl;
+import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
+import org.apache.olingo.server.core.testutil.techprovider.ActionProvider;
+import org.apache.olingo.server.core.testutil.techprovider.ComplexTypeProvider;
+import org.apache.olingo.server.core.testutil.techprovider.EntityTypeProvider;
+import org.apache.olingo.server.core.uri.queryoption.expression.ExpressionImpl;
+import org.apache.olingo.server.core.uri.queryoption.expression.LiteralImpl;
+import org.junit.Test;
+
+public class UriResourceImplTest {
+
+ Edm edm = new EdmProviderImpl(new EdmTechTestProvider());
+
+ @Test
+ public void testUriParameterImpl() {
+ UriParameterImpl impl = new UriParameterImpl();
+ ExpressionImpl expression = new LiteralImpl().setText("Expression");
+
+ impl.setText("Text");
+ impl.setName("A");
+ impl.setAlias("@A");
+ impl.setExpression(expression);
+
+ assertEquals("Text", impl.getText());
+ assertEquals("A", impl.getName());
+ assertEquals("@A", impl.getAlias());
+ assertEquals(expression, impl.getExression());
+ }
+
+ @Test
+ public void testUriResourceActionImpl() {
+ UriResourceActionImpl impl = new UriResourceActionImpl();
+ assertEquals(UriResourceKind.action, impl.getKind());
+ assertEquals("", impl.toString());
+
+ // action
+ EdmAction action = edm.getUnboundAction(ActionProvider.nameUARTETParam);
+ impl.setAction(action);
+ assertEquals(action, impl.getAction());
+ assertEquals(ActionProvider.nameUARTETParam.getName(), impl.toString());
+
+ // action import
+ impl = new UriResourceActionImpl();
+ EdmActionImport actionImport = edm.getEntityContainer(null).getActionImport("AIRTPrimParam");
+ impl.setActionImport(actionImport);
+ assertEquals(actionImport, impl.getActionImport());
+ assertEquals(actionImport.getUnboundAction(), impl.getAction());
+ assertEquals(false, impl.isCollection());
+ assertEquals("AIRTPrimParam", impl.toString());
+ assertEquals(actionImport.getUnboundAction().getReturnType().getType(), impl.getType());
+ }
+
+ @Test
+ public void testUriResourceLambdaAllImpl() {
+ UriResourceLambdaAllImpl impl = new UriResourceLambdaAllImpl();
+ assertEquals(UriResourceKind.lambdaAll, impl.getKind());
+
+ ExpressionImpl expression = new LiteralImpl().setText("Expression");
+ impl.setExpression(expression);
+ impl.setLamdaVariable("A");
+
+ assertEquals(false, impl.isCollection());
+ assertEquals(expression, impl.getExpression());
+ assertEquals("A", impl.getLambdaVariable());
+ assertEquals(EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean), impl.getType());
+ assertEquals("all", impl.toString());
+ }
+
+ @Test
+ public void testUriResourceLambdaAnyImpl() {
+ UriResourceLambdaAnyImpl impl = new UriResourceLambdaAnyImpl();
+ assertEquals(UriResourceKind.lambdaAny, impl.getKind());
+
+ ExpressionImpl expression = new LiteralImpl().setText("Expression");
+ impl.setExpression(expression);
+ impl.setLamdaVariable("A");
+
+ assertEquals(false, impl.isCollection());
+ assertEquals(expression, impl.getExpression());
+ assertEquals("A", impl.getLamdaVariable());
+ assertEquals(EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean), impl.getType());
+ assertEquals("any", impl.toString());
+ }
+
+ @Test
+ public void testUriResourceComplexPropertyImpl() {
+ UriResourceComplexPropertyImpl impl = new UriResourceComplexPropertyImpl();
+ assertEquals(UriResourceKind.complexProperty, impl.getKind());
+
+ EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETKeyNav);
+ EdmProperty property = (EdmProperty) entityType.getProperty("PropertyComplex");
+ impl.setProperty(property);
+
+ assertEquals(property, impl.getProperty());
+ assertEquals(property.getName(), impl.toString());
+ assertEquals(false, impl.isCollection());
+ assertEquals(property.getType(), impl.getType());
+ assertEquals(property.getType(), impl.getComplexType());
+ impl.getComplexType();
+
+ EdmComplexTypeImpl complexTypeImplType =
+ (EdmComplexTypeImpl) edm.getComplexType(ComplexTypeProvider.nameCTBasePrimCompNav);
+
+ impl.setTypeFilter(complexTypeImplType);
+ assertEquals(complexTypeImplType, impl.getTypeFilter());
+ assertEquals(complexTypeImplType, impl.getComplexTypeFilter());
+ impl.getComplexTypeFilter();
+
+ }
+
+ @Test
+ public void testUriResourcePrimitivePropertyImpl() {
+ UriResourcePrimitivePropertyImpl impl = new UriResourcePrimitivePropertyImpl();
+ assertEquals(UriResourceKind.primitiveProperty, impl.getKind());
+
+ EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETKeyNav);
+ EdmProperty property = (EdmProperty) entityType.getProperty("PropertyInt16");
+ impl.setProperty(property);
+
+ assertEquals(property, impl.getProperty());
+ assertEquals(property.getName(), impl.toString());
+ assertEquals(false, impl.isCollection());
+ assertEquals(property.getType(), impl.getType());
+ }
+
+ @Test
+ public void testUriResourceCountImpl() {
+ UriResourceCountImpl impl = new UriResourceCountImpl();
+ assertEquals(UriResourceKind.count, impl.getKind());
+ assertEquals("$count", impl.toString());
+ }
+
+ @Test
+ public void testUriResourceEntitySetImpl() {
+ UriResourceEntitySetImpl impl = new UriResourceEntitySetImpl();
+ assertEquals(UriResourceKind.entitySet, impl.getKind());
+
+ EdmEntitySetImpl entitySet = (EdmEntitySetImpl) edm.getEntityContainer(null).getEntitySet("ESAllPrim");
+ impl.setEntitSet(entitySet);
+
+ assertEquals("ESAllPrim", impl.toString());
+ assertEquals(entitySet, impl.getEntitySet());
+
+ assertEquals(entitySet.getEntityType(), impl.getType());
+ assertEquals(entitySet.getEntityType(), impl.getEntityType());
+ impl.getEntityType();
+
+ // is Collection
+ assertEquals(true, impl.isCollection());
+ impl.setKeyPredicates(new ArrayList<UriParameterImpl>());
+ assertEquals(false, impl.isCollection());
+ }
+
+ @Test
+ public void testUriResourceFunctionImpl() {
+ UriResourceFunctionImpl impl = new UriResourceFunctionImpl();
+ assertEquals(UriResourceKind.function, impl.getKind());
+ assertEquals("", impl.toString());
+
+ // function
+ EdmFunction function = (EdmFunction) edm.getEntityContainer(null).getFunctionImport("FINRTInt16")
+ .getUnboundFunction(new ArrayList<String>());
+ assertNotNull(function);
+ impl.setFunction(function);
+
+ assertEquals(function, impl.getFunction());
+ assertEquals("UFNRTInt16", impl.toString());
+ assertEquals(function.getReturnType().getType(), impl.getType());
+ assertEquals(false, impl.isParameterListFilled());
+
+ // function import
+ impl = new UriResourceFunctionImpl();
+ EdmFunctionImport functionImport = edm.getEntityContainer(null).getFunctionImport("FINRTInt16");
+ impl.setFunctionImport(functionImport, new ArrayList<UriParameterImpl>());
+ assertEquals(functionImport, impl.getFunctionImport());
+ assertEquals("FINRTInt16", impl.toString());
+
+ // function collection
+ impl = new UriResourceFunctionImpl();
+ functionImport = edm.getEntityContainer(null).getFunctionImport("FICRTESTwoKeyNavParam");
+ assertNotNull(function);
+ UriParameterImpl parameter = new UriParameterImpl().setName("ParameterInt16");
+ impl.setFunctionImport(functionImport, Arrays.asList(parameter));
+ assertEquals("FICRTESTwoKeyNavParam", impl.toString());
+
+ impl.setFunction(functionImport.getUnboundFunction(Arrays.asList("ParameterInt16")));
+ assertEquals(true, impl.isCollection());
+ impl.setKeyPredicates(new ArrayList<UriParameterImpl>());
+ assertEquals(false, impl.isCollection());
+
+ assertEquals(parameter, impl.getParameters().get(0));
+ assertEquals(true, impl.isParameterListFilled());
+ }
+
+ @Test
+ public void testUriResourceImplKeyPred() {
+ class Mock extends UriResourceWithKeysImpl {
+
+ EdmType type;
+
+ public Mock() {
+ super(UriResourceKind.action);
+ }
+
+ @Override
+ public EdmType getType() {
+ return type;
+ }
+
+ public Mock setType(final EdmType type) {
+ this.type = type;
+ return this;
+ }
+
+ @Override
+ public boolean isCollection() {
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return "mock";
+ }
+ }
+
+ Mock impl = new Mock();
+ EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav);
+ EdmEntityType entityTypeBaseColl = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
+ EdmEntityType entityTypeBaseEntry = edm.getEntityType(EntityTypeProvider.nameETTwoBaseTwoKeyNav);
+
+ impl.setType(entityType);
+ assertEquals(entityType, impl.getType());
+ assertEquals("mock", impl.toString(false));
+ assertEquals("mock", impl.toString(true));
+
+ // set both
+ impl.setCollectionTypeFilter(entityTypeBaseColl);
+ assertEquals(entityTypeBaseColl, impl.getTypeFilterOnCollection());
+ assertEquals("mock", impl.toString(false));
+ assertEquals("mock/com.sap.odata.test1.ETBaseTwoKeyNav", impl.toString(true));
+ impl.setEntryTypeFilter(entityTypeBaseEntry);
+ assertEquals(entityTypeBaseEntry, impl.getTypeFilterOnEntry());
+ assertEquals("mock", impl.toString(false));
+ assertEquals("mock/com.sap.odata.test1.ETBaseTwoKeyNav/()com.sap.odata.test1.ETTwoBaseTwoKeyNav",
+ impl.toString(true));
+
+ // set entry
+ impl = new Mock();
+ impl.setType(entityType);
+ impl.setEntryTypeFilter(entityTypeBaseEntry);
+ assertEquals(entityTypeBaseEntry, impl.getTypeFilterOnEntry());
+ assertEquals("mock", impl.toString(false));
+ assertEquals("mock/com.sap.odata.test1.ETTwoBaseTwoKeyNav", impl.toString(true));
+
+ // set collection
+ impl = new Mock();
+ impl.setType(entityType);
+ impl.setCollectionTypeFilter(entityTypeBaseColl);
+ assertEquals(entityTypeBaseColl, impl.getTypeFilterOnCollection());
+ assertEquals("mock", impl.toString(false));
+ assertEquals("mock/com.sap.odata.test1.ETBaseTwoKeyNav", impl.toString(true));
+
+ impl = new Mock();
+ UriParameterImpl parameter = new UriParameterImpl().setName("ParameterInt16");
+ List<UriParameterImpl> keyPredicates = new ArrayList<UriParameterImpl>();
+ keyPredicates.add(parameter);
+
+ impl.setKeyPredicates(keyPredicates);
+ assertNotNull(null, impl.getKeyPredicates());
+
+ }
+
+ @Test
+ public void testUriResourceImplTyped() {
+ class Mock extends UriResourceTypedImpl {
+
+ EdmType type;
+
+ public Mock() {
+ super(UriResourceKind.action);
+ }
+
+ @Override
+ public EdmType getType() {
+ return type;
+ }
+
+ @Override
+ public boolean isCollection() {
+ return false;
+ }
+
+ public Mock setType(final EdmType type) {
+ this.type = type;
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return "mock";
+ }
+
+ }
+
+ Mock impl = new Mock();
+ EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav);
+ EdmEntityType entityTypeBaseColl = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
+ edm.getEntityType(EntityTypeProvider.nameETTwoBaseTwoKeyNav);
+
+ impl.setType(entityType);
+ assertEquals("mock", impl.toString());
+ assertEquals("mock", impl.toString(true));
+ assertEquals("mock", impl.toString(false));
+
+ impl.setTypeFilter(entityTypeBaseColl);
+ assertEquals(entityTypeBaseColl, impl.getTypeFilter());
+ assertEquals("mock", impl.toString());
+ assertEquals("mock/com.sap.odata.test1.ETBaseTwoKeyNav", impl.toString(true));
+ assertEquals("mock", impl.toString(false));
+ //
+ }
+
+ @Test
+ public void testUriResourceItImpl() {
+ UriResourceItImpl impl = new UriResourceItImpl();
+ assertEquals(UriResourceKind.it, impl.getKind());
+
+ EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav);
+ assertEquals("$it", impl.toString());
+
+ impl.setType(entityType);
+ assertEquals(entityType, impl.getType());
+
+ UriParameterImpl parameter = new UriParameterImpl().setName("ParameterInt16");
+ List<UriParameterImpl> keyPredicates = new ArrayList<UriParameterImpl>();
+ keyPredicates.add(parameter);
+
+ assertEquals(false, impl.isCollection());
+ impl.setCollection(true);
+ assertEquals(true, impl.isCollection());
+ impl.setKeyPredicates(keyPredicates);
+ assertEquals(false, impl.isCollection());
+ }
+
+ @Test
+ public void testUriResourceNavigationPropertyImpl() {
+ UriResourceNavigationPropertyImpl impl = new UriResourceNavigationPropertyImpl();
+ assertEquals(UriResourceKind.navigationProperty, impl.getKind());
+
+ EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav);
+ EdmNavigationProperty property = (EdmNavigationProperty) entityType.getProperty("NavPropertyETKeyNavMany");
+ assertNotNull(property);
+
+ impl.setNavigationProperty(property);
+ assertEquals(property, impl.getProperty());
+
+ assertEquals("NavPropertyETKeyNavMany", impl.toString());
+ assertEquals(property.getType(), impl.getType());
+
+ UriParameterImpl parameter = new UriParameterImpl().setName("ParameterInt16");
+ List<UriParameterImpl> keyPredicates = new ArrayList<UriParameterImpl>();
+ keyPredicates.add(parameter);
+
+ assertEquals(true, impl.isCollection());
+ impl.setKeyPredicates(keyPredicates);
+ assertEquals(false, impl.isCollection());
+ }
+
+ @Test
+ public void testUriResourceRefImpl() {
+ UriResourceRefImpl impl = new UriResourceRefImpl();
+ assertEquals(UriResourceKind.ref, impl.getKind());
+ assertEquals("$ref", impl.toString());
+ }
+
+ @Test
+ public void testUriResourceRootImpl() {
+ UriResourceRootImpl impl = new UriResourceRootImpl();
+ assertEquals(UriResourceKind.root, impl.getKind());
+
+ EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav);
+ assertEquals("$root", impl.toString());
+
+ impl.setType(entityType);
+ assertEquals(entityType, impl.getType());
+
+ UriParameterImpl parameter = new UriParameterImpl().setName("ParameterInt16");
+ List<UriParameterImpl> keyPredicates = new ArrayList<UriParameterImpl>();
+ keyPredicates.add(parameter);
+
+ assertEquals(false, impl.isCollection());
+ impl.setCollection(true);
+ assertEquals(true, impl.isCollection());
+ impl.setKeyPredicates(keyPredicates);
+ assertEquals(false, impl.isCollection());
+ }
+
+ @Test
+ public void testUriResourceSingletonImpl() {
+ UriResourceSingletonImpl impl = new UriResourceSingletonImpl();
+ assertEquals(UriResourceKind.singleton, impl.getKind());
+
+ EdmSingletonImpl singleton = (EdmSingletonImpl) edm.getEntityContainer(null).getSingleton("SINav");
+ EdmEntityType entityTypeBaseColl = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
+ impl.setSingleton(singleton);
+
+ assertEquals("SINav", impl.toString());
+ assertEquals(singleton, impl.getSingleton());
+
+ assertEquals(singleton.getEntityType(), impl.getType());
+ assertEquals(singleton.getEntityType(), impl.getEntityType());
+ impl.getEntityType();
+
+ impl.setTypeFilter(entityTypeBaseColl);
+ assertEquals(entityTypeBaseColl, impl.getEntityTypeFilter());
+
+ // is Collection
+ assertEquals(false, impl.isCollection());
+ }
+
+ @Test
+ public void testUriResourceValueImpl() {
+ UriResourceValueImpl impl = new UriResourceValueImpl();
+ assertEquals(UriResourceKind.value, impl.getKind());
+ assertEquals("$value", impl.toString());
+ }
+
+ @Test
+ public void testUriResourceLambdaVarImpl() {
+ UriResourceLambdaVarImpl impl = new UriResourceLambdaVarImpl();
+ assertEquals(UriResourceKind.lambdaVariable, impl.getKind());
+
+ EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav);
+ impl.setType(entityType);
+ impl.setVariableText("A");
+
+ assertEquals("A", impl.toString());
+ assertEquals(entityType, impl.getType());
+ assertEquals("A", impl.getVariableName());
+ assertEquals(false, impl.isCollection());
+ impl.setCollection(true);
+ assertEquals(true, impl.isCollection());
+ }
+
+ @Test
+ public void testUriResourceStartingTypeFilterImpl() {
+ UriResourceStartingTypeFilterImpl impl = new UriResourceStartingTypeFilterImpl();
+
+ EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav);
+
+ impl.setType(entityType);
+ assertEquals("com.sap.odata.test1.ETTwoKeyNav", impl.toString());
+ assertEquals(entityType, impl.getType());
+
+ UriParameterImpl parameter = new UriParameterImpl().setName("ParameterInt16");
+ List<UriParameterImpl> keyPredicates = new ArrayList<UriParameterImpl>();
+ keyPredicates.add(parameter);
+
+ assertEquals(false, impl.isCollection());
+ impl.setCollection(true);
+ assertEquals(true, impl.isCollection());
+ impl.setKeyPredicates(keyPredicates);
+ assertEquals(false, impl.isCollection());
+
+ }
+}
[14/15] [OLINGO-266] refactor ref module to server-ref
Posted by sk...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/FunctionProvider.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/FunctionProvider.java b/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/FunctionProvider.java
deleted file mode 100644
index fe6fefb..0000000
--- a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/FunctionProvider.java
+++ /dev/null
@@ -1,852 +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.testutil.techprovider;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.server.api.edm.provider.Function;
-import org.apache.olingo.server.api.edm.provider.Parameter;
-import org.apache.olingo.server.api.edm.provider.ReturnType;
-
-public class FunctionProvider {
-
- // Bound Functions
- public static final FullQualifiedName nameBFCCollCTPrimCompRTESAllPrim =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCCollCTPrimCompRTESAllPrim");
-
- public static final FullQualifiedName nameBFCCollStringRTESTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCCollStringRTESTwoKeyNav");
-
- public static final FullQualifiedName nameBFCCTPrimCompRTESBaseTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCCTPrimCompRTESBaseTwoKeyNav");
-
- public static final FullQualifiedName nameBFCCTPrimCompRTESTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCCTPrimCompRTESTwoKeyNav");
-
- public static final FullQualifiedName nameBFCCTPrimCompRTESTwoKeyNavParam =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCCTPrimCompRTESTwoKeyNavParam");
-
- public static final FullQualifiedName nameBFCCTPrimCompRTETTwoKeyNavParam =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCCTPrimCompRTETTwoKeyNavParam");
-
- public static final FullQualifiedName nameBFCESAllPrimRTCTAllPrim =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCESAllPrimRTCTAllPrim");
-
- public static final FullQualifiedName nameBFCESBaseTwoKeyNavRTESBaseTwoKey =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCESBaseTwoKeyNavRTESBaseTwoKey");
-
- public static final FullQualifiedName nameBFCESKeyNavRTETKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCESKeyNavRTETKeyNav");
-
- public static final FullQualifiedName nameBFCESKeyNavRTETKeyNavParam =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCESKeyNavRTETKeyNavParam");
-
- public static final FullQualifiedName nameBFCESTwoKeyNavRTCollCTTwoPrim =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCESTwoKeyNavRTCollCTTwoPrim");
-
- public static final FullQualifiedName nameBFCESTwoKeyNavRTCollString =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCESTwoKeyNavRTCollString");
-
- public static final FullQualifiedName nameBFCESTwoKeyNavRTCTTwoPrim =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCESTwoKeyNavRTCTTwoPrim");
-
- public static final FullQualifiedName nameBFCESTwoKeyNavRTESTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCESTwoKeyNavRTESTwoKeyNav");
-
- public static final FullQualifiedName nameBFCESTwoKeyNavRTString =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCESTwoKeyNavRTString");
-
- public static final FullQualifiedName nameBFCESTwoKeyNavRTStringParam =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCESTwoKeyNavRTStringParam");
-
- public static final FullQualifiedName nameBFCESTwoKeyNavRTTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCESTwoKeyNavRTTwoKeyNav");
-
- public static final FullQualifiedName nameBFCETBaseTwoKeyNavRTESBaseTwoKey =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCETBaseTwoKeyNavRTESBaseTwoKey");
-
- public static final FullQualifiedName nameBFCETBaseTwoKeyNavRTESTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCETBaseTwoKeyNavRTESTwoKeyNav");
-
- public static final FullQualifiedName nameBFCETBaseTwoKeyNavRTETTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCETBaseTwoKeyNavRTETTwoKeyNav");
-
- public static final FullQualifiedName nameBFCETKeyNavRTETKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCETKeyNavRTETKeyNav");
-
- public static final FullQualifiedName nameBFCETTwoKeyNavRTCTTwoPrim =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCETTwoKeyNavRTCTTwoPrim");
-
- public static final FullQualifiedName nameBFCETTwoKeyNavRTESTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCETTwoKeyNavRTESTwoKeyNav");
-
- public static final FullQualifiedName nameBFCETTwoKeyNavRTETTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCETTwoKeyNavRTETTwoKeyNav");
-
- public static final FullQualifiedName nameBFCSINavRTESTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCSINavRTESTwoKeyNav");
-
- public static final FullQualifiedName nameBFCStringRTESTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFCStringRTESTwoKeyNav");
-
- public static final FullQualifiedName nameBFESTwoKeyNavRTESTwoKeyNav =
- new FullQualifiedName(SchemaProvider.nameSpace, "BFESTwoKeyNavRTESTwoKeyNav");
-
- // Unbound Functions
- public static final FullQualifiedName nameUFCRTCollCTTwoPrim =
- new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTCollCTTwoPrim");
- public static final FullQualifiedName nameUFCRTCollCTTwoPrimParam =
- new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTCollCTTwoPrimParam");
- public static final FullQualifiedName nameUFCRTCollString = new FullQualifiedName(SchemaProvider.nameSpace,
- "UFCRTCollString");
- public static final FullQualifiedName nameUFCRTCollStringTwoParam =
- new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTCollStringTwoParam");
- public static final FullQualifiedName nameUFCRTCTAllPrimTwoParam =
- new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTCTAllPrimTwoParam");
- public static final FullQualifiedName nameUFCRTCTTwoPrim = new FullQualifiedName(SchemaProvider.nameSpace,
- "UFCRTCTTwoPrim");
- public static final FullQualifiedName nameUFCRTCTTwoPrimParam =
- new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTCTTwoPrimParam");
- public static final FullQualifiedName nameUFCRTESMixPrimCollCompTwoParam =
- new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTESMixPrimCollCompTwoParam");
- public static final FullQualifiedName nameUFCRTESTwoKeyNavParam =
- new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTESTwoKeyNavParam");
- public static final FullQualifiedName nameUFCRTETAllPrimTwoParam =
- new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTETAllPrimTwoParam");
- public static final FullQualifiedName nameUFCRTETKeyNav = new FullQualifiedName(SchemaProvider.nameSpace,
- "UFCRTETKeyNav");
- public static final FullQualifiedName nameUFCRTETMedia = new FullQualifiedName(SchemaProvider.nameSpace,
- "UFCRTETMedia");
-
- public static final FullQualifiedName nameUFCRTETTwoKeyNavParam =
- new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTETTwoKeyNavParam");
-
- public static final FullQualifiedName nameUFCRTETTwoKeyNavParamCTTwoPrim =
- new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTETTwoKeyNavParamCTTwoPrim");
-
- public static final FullQualifiedName nameUFCRTString =
- new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTString");
-
- public static final FullQualifiedName nameUFCRTStringTwoParam =
- new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTStringTwoParam");
-
- public static final FullQualifiedName nameUFNRTESMixPrimCollCompTwoParam =
- new FullQualifiedName(SchemaProvider.nameSpace, "UFNRTESMixPrimCollCompTwoParam");
- public static final FullQualifiedName nameUFNRTInt16 =
- new FullQualifiedName(SchemaProvider.nameSpace, "UFNRTInt16");
-
- public static final FullQualifiedName nameUFNRTCollCTNavFiveProp = new FullQualifiedName(SchemaProvider.nameSpace,
- "UFNRTCollCTNavFiveProp");
-
- public static final FullQualifiedName nameBFCESTwoKeyNavRTCTNavFiveProp = new FullQualifiedName(
- SchemaProvider.nameSpace, "BFCESTwoKeyNavRTCTNavFiveProp");
-
- public static final FullQualifiedName nameBFCESTwoKeyNavRTCollCTNavFiveProp = new FullQualifiedName(
- SchemaProvider.nameSpace, "BFCESTwoKeyNavRTCollCTNavFiveProp");
-
- public List<Function> getFunctions(final FullQualifiedName functionName) throws ODataException {
-
- if (functionName.equals(nameUFNRTInt16)) {
- return Arrays.asList(
- new Function()
- .setName("UFNRTInt16")
- .setParameters(new ArrayList<Parameter>())
- .setReturnType(
- new ReturnType().setType(PropertyProvider.nameInt16))
- );
-
- } else if (functionName.equals(nameUFCRTETKeyNav)) {
- return Arrays.asList(
- new Function()
- .setName("UFCRTETKeyNav")
- .setParameters(new ArrayList<Parameter>())
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setNullable(false))
- );
-
- } else if (functionName.equals(nameUFCRTETTwoKeyNavParam)) {
- return Arrays.asList(
- new Function()
- .setName("UFCRTETTwoKeyNavParam")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(false)
- )
- );
-
- } else if (functionName.equals(nameUFCRTETTwoKeyNavParamCTTwoPrim)) {
- return Arrays.asList(
- new Function()
- .setName("UFCRTETTwoKeyNavParamCTTwoPrim")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterCTTwoPrim").setType(ComplexTypeProvider.nameCTTwoPrim)
- .setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(false)
- )
- );
-
- } else if (functionName.equals(nameUFCRTStringTwoParam)) {
- return Arrays.asList(
- new Function()
- .setName("UFCRTStringTwoParam")
- .setParameters(Arrays.asList(
- new Parameter()
- .setName("ParameterInt16")
- .setType(PropertyProvider.nameInt16)
- .setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(PropertyProvider.nameString).setNullable(false)),
- new Function()
- .setName("UFCRTStringTwoParam")
- .setParameters(Arrays.asList(
- new Parameter()
- .setName("ParameterString")
- .setType(PropertyProvider.nameString)
- .setNullable(false),
- new Parameter()
- .setName("ParameterInt16")
- .setType(PropertyProvider.nameInt16)
- .setNullable(false)))
- .setComposable(true)
- .setReturnType(new ReturnType().setType(PropertyProvider.nameString).setNullable(false))
-
- );
-
- } else if (functionName.equals(nameUFCRTESTwoKeyNavParam)) {
- return Arrays.asList(
- new Function()
- .setName("UFCRTESTwoKeyNavParam")
- .setParameters(Arrays.asList(
- new Parameter()
- .setName("ParameterInt16")
- .setType(PropertyProvider.nameInt16)
- .setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
- );
-
- } else if (functionName.equals(nameUFCRTString)) {
- return Arrays.asList(
- new Function()
- .setName("UFCRTString")
-
- .setComposable(true)
- .setParameters(new ArrayList<Parameter>())
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(PropertyProvider.nameString).setNullable(false)
- )
- );
-
- } else if (functionName.equals(nameUFCRTCollStringTwoParam)) {
- return Arrays.asList(
- new Function()
- .setName("UFCRTCollStringTwoParam")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterString").setType(PropertyProvider.nameString).setNullable(false),
- new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(PropertyProvider.nameString).setCollection(true).setNullable(false))
- );
-
- } else if (functionName.equals(nameUFCRTCollString)) {
- return Arrays.asList(
- new Function()
- .setName("UFCRTCollString")
- .setParameters(new ArrayList<Parameter>())
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(PropertyProvider.nameString).setCollection(true).setNullable(false))
- );
-
- } else if (functionName.equals(nameUFCRTCTAllPrimTwoParam)) {
- return Arrays.asList(
- new Function()
- .setName("UFCRTCTAllPrimTwoParam")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterString").setType(PropertyProvider.nameString).setNullable(false),
- new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(ComplexTypeProvider.nameCTAllPrim).setNullable(false))
- );
-
- } else if (functionName.equals(nameUFCRTCTTwoPrimParam)) {
- return Arrays.asList(
- new Function()
- .setName("UFCRTCTTwoPrimParam")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(false),
- new Parameter().setName("ParameterString").setType(PropertyProvider.nameString).setNullable(true)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setNullable(false))
- );
- } else if (functionName.equals(nameUFCRTCollCTTwoPrimParam)) {
- return Arrays.asList(
- new Function()
- .setName("UFCRTCollCTTwoPrimParam")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(false),
- new Parameter().setName("ParameterString").setType(PropertyProvider.nameString).setNullable(true)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setCollection(true).setNullable(false))
- );
-
- } else if (functionName.equals(nameUFCRTCTTwoPrim)) {
- return Arrays.asList(
- new Function()
- .setName("UFCRTCTTwoPrim")
- .setParameters(new ArrayList<Parameter>())
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setNullable(false))
- );
-
- } else if (functionName.equals(nameUFCRTCollCTTwoPrim)) {
- return Arrays.asList(
- new Function()
- .setName("UFCRTCollCTTwoPrim")
- .setComposable(true)
- .setParameters(new ArrayList<Parameter>())
- .setReturnType(
- new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setCollection(true).setNullable(false))
- );
-
- } else if (functionName.equals(nameUFCRTETMedia)) {
- return Arrays.asList(
- new Function()
- .setName("UFCRTETMedia")
- .setParameters(new ArrayList<Parameter>())
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETMedia).setNullable(false))
- );
-
- } else if (functionName.equals(nameUFNRTESMixPrimCollCompTwoParam)) {
- return Arrays.asList(
- new Function()
- .setName("UFNRTESMixPrimCollCompTwoParam")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterString").setType(PropertyProvider.nameString).setNullable(false),
- new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(false)))
- .setComposable(false)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETMixPrimCollComp).setCollection(true)
- .setNullable(false))
- );
-
- } else if (functionName.equals(nameUFCRTETAllPrimTwoParam)) {
- return Arrays.asList(
- new Function()
- .setName("UFCRTETAllPrimTwoParam")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterString").setType(PropertyProvider.nameString).setNullable(false),
- new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETAllPrim).setNullable(false))
- );
-
- } else if (functionName.equals(nameUFCRTESMixPrimCollCompTwoParam)) {
- return Arrays.asList(
- new Function()
- .setName("UFCRTESMixPrimCollCompTwoParam")
- .setParameters(Arrays.asList(
- new Parameter().setName("ParameterString").setType(PropertyProvider.nameString).setNullable(false),
- new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(false)
- ))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETMixPrimCollComp).setCollection(true)
- .setNullable(false))
- );
-
- } else if (functionName.equals(nameUFNRTCollCTNavFiveProp)) {
- return Arrays.asList(
- new Function()
- .setName("UFNRTCollCTNavFiveProp")
- .setReturnType(
- new ReturnType().setType(ComplexTypeProvider.nameCTNavFiveProp).setCollection(true))
- );
- } else if (functionName.equals(nameBFCESTwoKeyNavRTESTwoKeyNav)) {
- return Arrays
- .asList(
- new Function()
- .setName("BFCESTwoKeyNavRTESTwoKeyNav")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
- .setCollection(true).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true)
- .setNullable(false)),
-
- new Function()
- .setName("BFCESTwoKeyNavRTESTwoKeyNav")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
- .setCollection(true).setNullable(false),
- new Parameter().setName("ParameterString").setType(PropertyProvider.nameString)
- .setCollection(false).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true)
- .setNullable(false)),
- new Function()
- .setName("BFCESTwoKeyNavRTESTwoKeyNav")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETKeyNav)
- .setCollection(true).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true)
- .setNullable(false)),
- new Function()
- .setName("BFCESTwoKeyNavRTESTwoKeyNav")
- .setBound(true)
- .setParameters(
- Arrays.asList(new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETKeyNav)
- .setCollection(true).setNullable(false),
- new Parameter().setName("ParameterString").setType(PropertyProvider.nameString)
- .setCollection(false).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true)
- .setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCStringRTESTwoKeyNav)) {
- return Arrays.asList(
- new Function().setName("BFCStringRTESTwoKeyNav")
- .setBound(true)
- .setParameters(Arrays.asList(
- new Parameter().setName("BindingParam").setType(PropertyProvider.nameString).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCETBaseTwoKeyNavRTETTwoKeyNav)) {
- return Arrays.asList(
- new Function()
- .setName("BFCETBaseTwoKeyNavRTETTwoKeyNav")
- .setBound(true)
- .setParameters(Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETBaseTwoKeyNav)
- .setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(false)
- )
- );
-
- } else if (functionName.equals(nameBFCESBaseTwoKeyNavRTESBaseTwoKey)) {
- return Arrays.asList(
- new Function()
- .setName("BFCESBaseTwoKeyNavRTESBaseTwoKey")
- .setBound(true)
- .setParameters(Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETBaseTwoKeyNav)
- .setCollection(true).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETBaseTwoKeyNav).setCollection(true)
- .setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCESAllPrimRTCTAllPrim)) {
- return Arrays.asList(
- new Function()
- .setName("BFCESAllPrimRTCTAllPrim")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETAllPrim)
- .setCollection(true).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(ComplexTypeProvider.nameCTAllPrim).setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCESTwoKeyNavRTCTTwoPrim)) {
- return Arrays.asList(
- new Function()
- .setName("BFCESTwoKeyNavRTCTTwoPrim")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
- .setCollection(true).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCESTwoKeyNavRTCollCTTwoPrim)) {
- return Arrays.asList(
- new Function()
- .setName("BFCESTwoKeyNavRTCollCTTwoPrim")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
- .setCollection(true).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setCollection(true).setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCESTwoKeyNavRTString)) {
- return Arrays.asList(
- new Function()
- .setName("BFCESTwoKeyNavRTString")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
- .setCollection(true).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(PropertyProvider.nameString).setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCESTwoKeyNavRTCollString)) {
- return Arrays.asList(
- new Function()
- .setName("BFCESTwoKeyNavRTCollString")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
- .setCollection(true).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(PropertyProvider.nameString).setCollection(true).setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCETTwoKeyNavRTESTwoKeyNav)) {
- return Arrays.asList(
- new Function()
- .setName("BFCETTwoKeyNavRTESTwoKeyNav")
- .setBound(true)
- .setParameters(Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
- .setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCETBaseTwoKeyNavRTESTwoKeyNav)) {
- return Arrays.asList(
- new Function()
- .setName("BFCETBaseTwoKeyNavRTESTwoKeyNav")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETBaseTwoKeyNav)
- .setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCSINavRTESTwoKeyNav)) {
- return Arrays.asList(
- new Function()
- .setName("BFCSINavRTESTwoKeyNav")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(
- false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCETBaseTwoKeyNavRTESBaseTwoKey)) {
- return Arrays.asList(
- new Function()
- .setName("BFCETBaseTwoKeyNavRTESBaseTwoKey")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETBaseTwoKeyNav)
- .setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETBaseTwoKeyNav).setCollection(true).setNullable(
- false))
- );
-
- } else if (functionName.equals(nameBFCCollStringRTESTwoKeyNav)) {
- return Arrays.asList(
- new Function()
- .setName("BFCCollStringRTESTwoKeyNav")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(PropertyProvider.nameString).setCollection(true)
- .setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCCTPrimCompRTESTwoKeyNav)) {
- return Arrays.asList(
- new Function()
- .setName("BFCCTPrimCompRTESTwoKeyNav")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(ComplexTypeProvider.nameCTPrimComp).setNullable(
- false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCCTPrimCompRTESBaseTwoKeyNav)) {
- return Arrays.asList(
- new Function()
- .setName("BFCCTPrimCompRTESBaseTwoKeyNav")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(ComplexTypeProvider.nameCTPrimComp).setNullable(
- false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETBaseTwoKeyNav).setCollection(true).setNullable(
- false))
- );
-
- } else if (functionName.equals(nameBFCCollCTPrimCompRTESAllPrim)) {
- return Arrays.asList(
- new Function()
- .setName("BFCCollCTPrimCompRTESAllPrim")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(ComplexTypeProvider.nameCTPrimComp)
- .setCollection(true).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETAllPrim).setCollection(true).setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCESTwoKeyNavRTTwoKeyNav)) {
- return Arrays.asList(
- new Function()
- .setName("BFCESTwoKeyNavRTTwoKeyNav")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
- .setCollection(true).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCESKeyNavRTETKeyNav)) {
- return Arrays
- .asList(
- new Function()
- .setName("BFCESKeyNavRTETKeyNav")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETKeyNav).setCollection(
- true).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCETKeyNavRTETKeyNav)) {
- return Arrays.asList(
- new Function()
- .setName("BFCETKeyNavRTETKeyNav")
- .setBound(true)
- .setParameters(Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETKeyNav).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setNullable(false))
- );
- } else if (functionName.equals(nameBFESTwoKeyNavRTESTwoKeyNav)) {
- return Arrays.asList(
- new Function()
- .setName("BFESTwoKeyNavRTESTwoKeyNav")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
- .setCollection(true).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
-
- );
-
- } else if (functionName.equals(nameBFCETTwoKeyNavRTETTwoKeyNav)) {
- return Arrays.asList(
- new Function()
- .setName("BFCETTwoKeyNavRTETTwoKeyNav")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(
- false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCETTwoKeyNavRTCTTwoPrim)) {
- return Arrays.asList(
- new Function()
- .setName("BFCETTwoKeyNavRTCTTwoPrim")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(
- false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setNullable(false))
- );
- } else if (functionName.equals(nameBFCESTwoKeyNavRTCTNavFiveProp)) {
- return Arrays.asList(
- new Function()
- .setName("BFCESTwoKeyNavRTCTNavFiveProp")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
- .setCollection(true).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(ComplexTypeProvider.nameCTNavFiveProp).setNullable(false))
- );
- } else if (functionName.equals(nameBFCESTwoKeyNavRTCollCTNavFiveProp)) {
- return Arrays.asList(
- new Function()
- .setName("BFCESTwoKeyNavRTCollCTNavFiveProp")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
- .setCollection(true).setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(ComplexTypeProvider.nameCTNavFiveProp).setCollection(true)
- .setNullable(false))
- );
- } else if (functionName.equals(nameBFCESTwoKeyNavRTStringParam)) {
- return Arrays.asList(
- new Function()
- .setName("BFCESTwoKeyNavRTStringParam")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
- .setCollection(true).setNullable(false),
- new Parameter().setName("ParameterComplex").setType(ComplexTypeProvider.nameCTTwoPrim)
- .setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(PropertyProvider.nameString).setNullable(false))
- );
-
- } else if (functionName.equals(nameBFCESKeyNavRTETKeyNavParam)) {
- return Arrays.asList(
- new Function()
- .setName("BFCESKeyNavRTETKeyNavParam")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETKeyNav).setCollection(
- true).setNullable(false),
- new Parameter().setName("ParameterString").setType(PropertyProvider.nameString)
- .setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setNullable(false))
- );
- } else if (functionName.equals(nameBFCCTPrimCompRTETTwoKeyNavParam)) {
- return Arrays.asList(
- new Function()
- .setName("BFCCTPrimCompRTETTwoKeyNavParam")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(ComplexTypeProvider.nameCTPrimComp).setNullable(
- false),
- new Parameter().setName("ParameterString").setType(PropertyProvider.nameString)
- .setNullable(false)))
- .setComposable(true)
- .setReturnType(new ReturnType()
- .setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(false)
- )
- );
- } else if (functionName.equals(nameBFCCTPrimCompRTESTwoKeyNavParam)) {
- return Arrays.asList(
- new Function()
- .setName("BFCCTPrimCompRTESTwoKeyNavParam")
- .setBound(true)
- .setParameters(
- Arrays.asList(
- new Parameter().setName("BindingParam").setType(ComplexTypeProvider.nameCTPrimComp).setNullable(
- false),
- new Parameter().setName("ParameterString").setType(PropertyProvider.nameString)
- .setNullable(false)))
- .setComposable(true)
- .setReturnType(
- new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
- );
- }
-
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/PropertyProvider.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/PropertyProvider.java b/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/PropertyProvider.java
deleted file mode 100644
index 5d1ad3b..0000000
--- a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/PropertyProvider.java
+++ /dev/null
@@ -1,590 +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.testutil.techprovider;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.server.api.edm.provider.NavigationProperty;
-import org.apache.olingo.server.api.edm.provider.Property;
-
-public class PropertyProvider {
-
- // Primitive Type Names
- public static final FullQualifiedName nameBinary = EdmPrimitiveTypeKind.Binary.getFullQualifiedName();
- public static final FullQualifiedName nameBoolean = EdmPrimitiveTypeKind.Boolean.getFullQualifiedName();
- public static final FullQualifiedName nameByte = EdmPrimitiveTypeKind.Byte.getFullQualifiedName();
-
- public static final FullQualifiedName nameDate = EdmPrimitiveTypeKind.Date.getFullQualifiedName();
- public static final FullQualifiedName nameDateTimeOffset =
- EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName();
-
- public static final FullQualifiedName nameDecimal = EdmPrimitiveTypeKind.Decimal.getFullQualifiedName();
- public static final FullQualifiedName nameDouble = EdmPrimitiveTypeKind.Double.getFullQualifiedName();
- public static final FullQualifiedName nameDuration = EdmPrimitiveTypeKind.Duration.getFullQualifiedName();
-
- public static final FullQualifiedName nameGuid = EdmPrimitiveTypeKind.Guid.getFullQualifiedName();
- public static final FullQualifiedName nameInt16 = EdmPrimitiveTypeKind.Int16.getFullQualifiedName();
- public static final FullQualifiedName nameInt32 = EdmPrimitiveTypeKind.Int32.getFullQualifiedName();
- public static final FullQualifiedName nameInt64 = EdmPrimitiveTypeKind.Int64.getFullQualifiedName();
-
- public static final FullQualifiedName nameSByte = EdmPrimitiveTypeKind.SByte.getFullQualifiedName();
- public static final FullQualifiedName nameSingle = EdmPrimitiveTypeKind.Single.getFullQualifiedName();
-
- public static final FullQualifiedName nameString = EdmPrimitiveTypeKind.String.getFullQualifiedName();
- public static final FullQualifiedName nameTimeOfDay = EdmPrimitiveTypeKind.TimeOfDay.getFullQualifiedName();
-
- // Primitive Properties --------------------------------------------------------------------------------------------
- public static final Property collPropertyBinary = new Property()
- .setName("CollPropertyBinary")
- .setType(nameBinary)
- .setCollection(true);
-
- public static final Property collPropertyBinary_ExplicitNullable = new Property()
- .setName("CollPropertyBinary")
- .setType(nameBinary)
- .setNullable(true)
- .setCollection(true);
-
- public static final Property collPropertyBoolean = new Property()
- .setName("CollPropertyBoolean")
- .setType(nameBoolean)
- .setCollection(true);
-
- public static final Property collPropertyBoolean_ExplicitNullable = new Property()
- .setName("CollPropertyBoolean")
- .setType(nameBoolean)
- .setNullable(true)
- .setCollection(true);
-
- public static final Property collPropertyByte = new Property()
- .setName("CollPropertyByte")
- .setType(nameByte)
- .setCollection(true);
-
- public static final Property collPropertyByte_ExplicitNullable = new Property()
- .setName("CollPropertyByte")
- .setType(nameByte)
- .setNullable(true)
- .setCollection(true);
-
- public static final Property collPropertyDate = new Property()
- .setName("CollPropertyDate")
- .setType(nameDate)
- .setCollection(true);
-
- public static final Property collPropertyDate_ExplicitNullable = new Property()
- .setName("CollPropertyDate")
- .setType(nameDate)
- .setNullable(true)
- .setCollection(true);
-
- public static final Property collPropertyDateTimeOffset = new Property()
- .setName("CollPropertyDateTimeOffset")
- .setType(nameDateTimeOffset)
- .setCollection(true);
-
- public static final Property collPropertyDateTimeOffset_ExplicitNullable = new Property()
- .setName("CollPropertyDateTimeOffset")
- .setType(nameDateTimeOffset)
- .setNullable(true)
- .setCollection(true);
-
- public static final Property collPropertyDecimal = new Property()
- .setName("CollPropertyDecimal")
- .setType(nameDecimal)
- .setCollection(true);
-
- public static final Property collPropertyDecimal_ExplicitNullable = new Property()
- .setName("CollPropertyDecimal")
- .setType(nameDecimal)
- .setNullable(true)
- .setCollection(true);
-
- public static final Property collPropertyDouble = new Property()
- .setName("CollPropertyDouble")
- .setType(nameDouble)
- .setCollection(true);
-
- public static final Property collPropertyDouble_ExplicitNullable = new Property()
- .setName("CollPropertyDouble")
- .setType(nameDouble)
- .setNullable(true)
- .setCollection(true);
-
- public static final Property collPropertyDuration = new Property()
- .setName("CollPropertyDuration")
- .setType(nameDuration)
- .setCollection(true);
-
- public static final Property collPropertyDuration_ExplicitNullable = new Property()
- .setName("CollPropertyDuration")
- .setType(nameDuration)
- .setNullable(true)
- .setCollection(true);
-
- public static final Property collPropertyGuid = new Property()
- .setName("CollPropertyGuid")
- .setType(nameGuid)
- .setCollection(true);
-
- public static final Property collPropertyGuid_ExplicitNullable = new Property()
- .setName("CollPropertyGuid")
- .setType(nameGuid)
- .setNullable(true)
- .setCollection(true);
-
- public static final Property collPropertyInt16 = new Property()
- .setName("CollPropertyInt16")
- .setType(nameInt16)
- .setCollection(true);
-
- public static final Property collPropertyInt16_ExplicitNullable = new Property()
- .setName("CollPropertyInt16")
- .setType(nameInt16)
- .setNullable(true)
- .setCollection(true);
-
- public static final Property collPropertyInt32 = new Property()
- .setName("CollPropertyInt32")
- .setType(nameInt32)
- .setCollection(true);
-
- public static final Property collPropertyInt32_ExplicitNullable = new Property()
- .setName("CollPropertyInt32")
- .setType(nameInt32)
- .setNullable(true)
- .setCollection(true);
-
- public static final Property collPropertyInt64 = new Property()
- .setName("CollPropertyInt64")
- .setType(nameInt64)
- .setCollection(true);
-
- public static final Property collPropertyInt64_ExplicitNullable = new Property()
- .setName("CollPropertyInt64")
- .setType(nameInt64)
- .setNullable(true)
- .setCollection(true);
-
- public static final Property collPropertySByte = new Property()
- .setName("CollPropertySByte")
- .setType(nameSByte)
- .setCollection(true);
-
- public static final Property collPropertySByte_ExplicitNullable = new Property()
- .setName("CollPropertySByte")
- .setType(nameSByte)
- .setNullable(true)
- .setCollection(true);
-
- public static final Property collPropertySingle = new Property()
- .setName("CollPropertySingle")
- .setType(nameSingle)
- .setCollection(true);
-
- public static final Property collPropertySingle_ExplicitNullable = new Property()
- .setName("CollPropertySingle")
- .setType(nameSingle)
- .setNullable(true)
- .setCollection(true);
-
- public static final Property collPropertyString = new Property()
- .setName("CollPropertyString")
- .setType(nameString)
- .setCollection(true);
-
- public static final Property collPropertyString_ExplicitNullable = new Property()
- .setName("CollPropertyString")
- .setType(nameString)
- .setNullable(true)
- .setCollection(true);
-
- public static final Property collPropertyTimeOfDay = new Property()
- .setName("CollPropertyTimeOfDay")
- .setType(nameTimeOfDay)
- .setCollection(true);
-
- public static final Property collPropertyTimeOfDay_ExplicitNullable = new Property()
- .setName("CollPropertyTimeOfDay")
- .setType(nameTimeOfDay)
- .setNullable(true)
- .setCollection(true);
-
- public static final Property propertyBinary = new Property()
- .setName("PropertyBinary")
- .setType(nameBinary);
-
- public static final Property propertyBinary_NotNullable = new Property()
- .setName("PropertyBinary")
- .setType(nameBinary)
- .setNullable(false);
-
- public static final Property propertyBinary_ExplicitNullable = new Property()
- .setName("PropertyBinary")
- .setType(nameBinary)
- .setNullable(true);
-
- public static final Property propertyBoolean = new Property()
- .setName("PropertyBoolean")
- .setType(nameBoolean);
-
- public static final Property propertyBoolean_NotNullable = new Property()
- .setName("PropertyBoolean")
- .setType(nameBoolean)
- .setNullable(false);
-
- public static final Property propertyBoolean_ExplicitNullable = new Property()
- .setName("PropertyBoolean")
- .setType(nameBoolean)
- .setNullable(true);
-
- public static final Property propertyByte = new Property()
- .setName("PropertyByte")
- .setType(nameByte);
-
- public static final Property propertyByte_NotNullable = new Property()
- .setName("PropertyByte")
- .setType(nameByte)
- .setNullable(false);
-
- public static final Property propertyByte_ExplicitNullable = new Property()
- .setName("PropertyByte")
- .setType(nameByte)
- .setNullable(true);
-
- public static final Property propertyDate = new Property()
- .setName("PropertyDate")
- .setType(nameDate);
-
- public static final Property propertyDate_NotNullable = new Property()
- .setName("PropertyDate")
- .setType(nameDate)
- .setNullable(false);
-
- public static final Property propertyDate_ExplicitNullable = new Property()
- .setName("PropertyDate")
- .setType(nameDate)
- .setNullable(true);
-
- public static final Property propertyDateTimeOffset = new Property()
- .setName("PropertyDateTimeOffset")
- .setType(nameDateTimeOffset);
-
- public static final Property propertyDateTimeOffset_NotNullable = new Property()
- .setName("PropertyDateTimeOffset")
- .setType(nameDateTimeOffset)
- .setNullable(false);
-
- public static final Property propertyDateTimeOffset_ExplicitNullable = new Property()
- .setName("PropertyDateTimeOffset")
- .setType(nameDateTimeOffset)
- .setNullable(true);
-
- public static final Property propertyDecimal = new Property()
- .setName("PropertyDecimal")
- .setType(nameDecimal);
-
- public static final Property propertyDecimal_NotNullable = new Property()
- .setName("PropertyDecimal")
- .setType(nameDecimal)
- .setNullable(false);
-
- public static final Property propertyDecimal_ExplicitNullable = new Property()
- .setName("PropertyDecimal")
- .setType(nameDecimal)
- .setNullable(true);
-
- public static final Property propertyDouble = new Property()
- .setName("PropertyDouble")
- .setType(nameDouble);
-
- public static final Property propertyDouble_NotNullable = new Property()
- .setName("PropertyDouble")
- .setType(nameDouble)
- .setNullable(false);
-
- public static final Property propertyDouble_ExplicitNullable = new Property()
- .setName("PropertyDouble")
- .setType(nameDouble)
- .setNullable(true);
-
- public static final Property propertyDuration = new Property()
- .setName("PropertyDuration")
- .setType(nameDuration);
-
- public static final Property propertyDuration_NotNullable = new Property()
- .setName("PropertyDuration")
- .setType(nameDuration)
- .setNullable(false);
-
- public static final Property propertyDuration_ExplicitNullable = new Property()
- .setName("PropertyDuration")
- .setType(nameDuration)
- .setNullable(true);
-
- public static final Property propertyGuid = new Property()
- .setName("PropertyGuid")
- .setType(nameGuid);
-
- public static final Property propertyGuid_NotNullable = new Property()
- .setName("PropertyGuid")
- .setType(nameGuid)
- .setNullable(false);
-
- public static final Property propertyGuid_ExplicitNullable = new Property()
- .setName("PropertyGuid")
- .setType(nameGuid)
- .setNullable(true);
-
- public static final Property propertyInt16 = new Property()
- .setName("PropertyInt16")
- .setType(nameInt16);
-
- public static final Property propertyInt16_NotNullable = new Property()
- .setName("PropertyInt16")
- .setType(nameInt16)
- .setNullable(false);
-
- public static final Property propertyInt16_ExplicitNullable = new Property()
- .setName("PropertyInt16")
- .setType(nameInt16)
- .setNullable(true);
-
- public static final Property propertyInt32 = new Property()
- .setName("PropertyInt32")
- .setType(nameInt32);
-
- public static final Property propertyInt32_NotNullable = new Property()
- .setName("PropertyInt32")
- .setType(nameInt32)
- .setNullable(false);
-
- public static final Property propertyInt32_ExplicitNullable = new Property()
- .setName("PropertyInt32")
- .setType(nameInt32)
- .setNullable(true);
-
- public static final Property propertyInt64 = new Property()
- .setName("PropertyInt64")
- .setType(nameInt64);
-
- public static final Property propertyInt64_NotNullable = new Property()
- .setName("PropertyInt64")
- .setType(nameInt64)
- .setNullable(false);
-
- public static final Property propertyInt64_ExplicitNullable = new Property()
- .setName("PropertyInt64")
- .setType(nameInt64)
- .setNullable(true);
-
- public static final Property propertySByte = new Property()
- .setName("PropertySByte")
- .setType(nameSByte);
-
- public static final Property propertySByte_NotNullable = new Property()
- .setName("PropertySByte")
- .setType(nameSByte)
- .setNullable(false);
-
- public static final Property propertySByte_ExplicitNullable = new Property()
- .setName("PropertySByte")
- .setType(nameSByte)
- .setNullable(true);
-
- public static final Property propertySingle = new Property()
- .setName("PropertySingle")
- .setType(nameSingle);
-
- public static final Property propertySingle_NotNullable = new Property()
- .setName("PropertySingle")
- .setType(nameSingle)
- .setNullable(false);
-
- public static final Property propertySingle_ExplicitNullable = new Property()
- .setName("PropertySingle")
- .setType(nameSingle)
- .setNullable(true);
-
- public static final Property propertyString = new Property()
- .setName("PropertyString")
- .setType(nameString);
-
- public static final Property propertyString_NotNullable = new Property()
- .setName("PropertyString")
- .setType(nameString)
- .setNullable(false);
-
- public static final Property propertyString_ExplicitNullable = new Property()
- .setName("PropertyString")
- .setType(nameString)
- .setNullable(true);
-
- public static final Property propertyTimeOfDay = new Property()
- .setName("PropertyTimeOfDay")
- .setType(nameTimeOfDay);
-
- public static final Property propertyTimeOfDay_NotNullable = new Property()
- .setName("PropertyTimeOfDay")
- .setType(nameTimeOfDay)
- .setNullable(false);
-
- public static final Property propertyTimeOfDay_ExplicitNullable = new Property()
- .setName("PropertyTimeOfDay")
- .setType(nameTimeOfDay)
- .setNullable(true);
-
- /*
- * TODO add propertyStream
- * Property propertyStream = new Property()
- * .setName("PropertyStream")
- * .setType(EdmStream.getFullQualifiedName());
- */
-
- // Complex Properties ----------------------------------------------------------------------------------------------
- public static final Property collPropertyComplex_CTPrimComp = new Property()
- .setName("CollPropertyComplex")
- .setType(ComplexTypeProvider.nameCTPrimComp)
- .setCollection(true);
-
- public static final Property collPropertyComplex_CTTwoPrim = new Property()
- .setName("CollPropertyComplex")
- .setType(ComplexTypeProvider.nameCTTwoPrim)
- .setCollection(true);
-
- public static final Property propertyComplex_CTAllPrim = new Property()
- .setName("PropertyComplex")
- .setType(ComplexTypeProvider.nameCTAllPrim);
-
- public static final Property propertyComplex_CTCollAllPrim = new Property()
- .setName("PropertyComplex")
- .setType(ComplexTypeProvider.nameCTCollAllPrim);
-
- public static final Property propertyComplex_CTCompCollComp = new Property()
- .setName("PropertyComplex")
- .setType(ComplexTypeProvider.nameCTCompCollComp);
-
- public static final Property propertyComplex_CTCompComp = new Property()
- .setName("PropertyComplex")
- .setType(ComplexTypeProvider.nameCTCompComp);
-
- public static final Property propertyComplex_CTNavFiveProp = new Property()
- .setName("PropertyComplex")
- .setType(ComplexTypeProvider.nameCTNavFiveProp);
-
- public static final Property propertyComplex_CTPrimComp_NotNullable = new Property()
- .setName("PropertyComplex")
- .setType(ComplexTypeProvider.nameCTPrimComp)
- .setNullable(false);
-
- public static final Property propertyComplex_CTTwoPrim = new Property()
- .setName("PropertyComplex")
- .setType(ComplexTypeProvider.nameCTTwoPrim);
-
- public static final Property propertyComplexAllPrim_CTAllPrim = new Property()
- .setName("PropertyComplexAllPrim")
- .setType(ComplexTypeProvider.nameCTAllPrim);
-
- public static final Property propertyComplexComplex_CTCompComp = new Property()
- .setName("PropertyComplexComplex")
- .setType(ComplexTypeProvider.nameCTCompComp);
-
- public static final Property propertyComplexEnum_CTPrimEnum_NotNullable = new Property()
- .setName("PropertyComplexEnum")
- .setType(ComplexTypeProvider.nameCTPrimEnum)
- .setNullable(false);
-
- public static final Property propertyComplexTwoPrim_CTTwoPrim = new Property()
- .setName("PropertyComplexTwoPrim")
- .setType(ComplexTypeProvider.nameCTTwoPrim);
-
- public static final Property propertyMixedPrimCollComp_CTMixPrimCollComp = new Property()
- .setName("PropertyMixedPrimCollComp")
- .setType(ComplexTypeProvider.nameCTMixPrimCollComp);
-
- // Navigation Properties -------------------------------------------------------------------------------------------
- public static final NavigationProperty collectionNavPropertyETKeyNavMany_ETKeyNav = new NavigationProperty()
- .setName("NavPropertyETKeyNavMany")
- .setType(EntityTypeProvider.nameETKeyNav)
- .setCollection(true);
-
- public static final NavigationProperty collectionNavPropertyETMediaMany_ETMedia = new NavigationProperty()
- .setName("NavPropertyETMediaMany")
- .setType(EntityTypeProvider.nameETMedia)
- .setCollection(true);
-
- public static final NavigationProperty collectionNavPropertyETTwoKeyNavMany_ETTwoKeyNav = new NavigationProperty()
- .setName("NavPropertyETTwoKeyNavMany")
- .setType(EntityTypeProvider.nameETTwoKeyNav)
- .setCollection(true)
- .setPartner("NavPropertyETKeyNavOne");
-
- public static final NavigationProperty collectionNavPropertyETTwoKeyNavOne_ETTwoKeyNav = new NavigationProperty()
- .setName("NavPropertyETTwoKeyNavOne")
- .setType(EntityTypeProvider.nameETTwoKeyNav);
-
- public static final NavigationProperty collectionNavPropertyETTwoPrimMany_ETTwoPrim = new NavigationProperty()
- .setName("NavPropertyETTwoPrimMany")
- .setType(EntityTypeProvider.nameETTwoPrim)
- .setCollection(true)
- .setNullable(false);
-
- public static final NavigationProperty collectionNavPropertyETAllPrimMany_ETAllPrim = new NavigationProperty()
- .setName("NavPropertyETAllPrimMany")
- .setType(EntityTypeProvider.nameETAllPrim)
- .setCollection(true);
-
- public static final NavigationProperty navPropertyETKeyNavOne_ETKeyNav = new NavigationProperty()
- .setName("NavPropertyETKeyNavOne")
- .setType(EntityTypeProvider.nameETKeyNav);
-
- public static final NavigationProperty navPropertyETMediaOne_ETMedia = new NavigationProperty()
- .setName("NavPropertyETMediaOne")
- .setType(EntityTypeProvider.nameETMedia);
-
- public static final NavigationProperty navPropertyETKeyPrimNavOne_ETKeyPrimNav = new NavigationProperty()
- .setName("NavPropertyETKeyPrimNavOne")
- .setType(EntityTypeProvider.nameETKeyPrimNav);
-
- public static final NavigationProperty navPropertyETTwoKeyNavOne_ETTwoKeyNav_NotNullable = new NavigationProperty()
- .setName("NavPropertyETTwoKeyNavOne")
- .setType(EntityTypeProvider.nameETTwoKeyNav)
- .setNullable(false);
-
- public static final NavigationProperty navPropertyETTwoKeyNavOne_ETTwoKeyNav = new NavigationProperty()
- .setName("NavPropertyETTwoKeyNavOne")
- .setType(EntityTypeProvider.nameETTwoKeyNav);
-
- public static final NavigationProperty navPropertyETTwoPrimOne_ETTwoPrim = new NavigationProperty()
- .setName("NavPropertyETTwoPrimOne")
- .setType(EntityTypeProvider.nameETTwoPrim)
- .setNullable(false);
-
- public static final NavigationProperty navPropertyETAllPrimOne_ETAllPrim = new NavigationProperty()
- .setName("NavPropertyETAllPrimOne")
- .setType(EntityTypeProvider.nameETAllPrim);
-
- // EnumProperties --------------------------------------------------------------------------------------------------
- public static final Property propertyEnumString_ENString = new Property()
- .setName("PropertyEnumString")
- .setType(EnumTypeProvider.nameENString);
-
- // TypeDefinition Properties ---------------------------------------------------------------------------------------
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/SchemaProvider.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/SchemaProvider.java b/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/SchemaProvider.java
deleted file mode 100644
index 70d9987..0000000
--- a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/SchemaProvider.java
+++ /dev/null
@@ -1,250 +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.testutil.techprovider;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.server.api.edm.provider.Action;
-import org.apache.olingo.server.api.edm.provider.ActionImport;
-import org.apache.olingo.server.api.edm.provider.ComplexType;
-import org.apache.olingo.server.api.edm.provider.EntityContainer;
-import org.apache.olingo.server.api.edm.provider.EntitySet;
-import org.apache.olingo.server.api.edm.provider.EntityType;
-import org.apache.olingo.server.api.edm.provider.EnumType;
-import org.apache.olingo.server.api.edm.provider.Function;
-import org.apache.olingo.server.api.edm.provider.FunctionImport;
-import org.apache.olingo.server.api.edm.provider.Schema;
-import org.apache.olingo.server.api.edm.provider.Singleton;
-
-public class SchemaProvider {
-
- private EdmTechProvider prov;
-
- public static final String nameSpace = "com.sap.odata.test1";
-
- public SchemaProvider(final EdmTechProvider prov) {
- this.prov = prov;
- }
-
- public List<Schema> getSchemas() throws ODataException {
- List<Schema> schemas = new ArrayList<Schema>();
- Schema schema = new Schema();
- schema.setNamespace("com.sap.odata.test1");
- schema.setAlias("Namespace1_Alias");
- schemas.add(schema);
- // EnumTypes
- List<EnumType> enumTypes = new ArrayList<EnumType>();
- schema.setEnumTypes(enumTypes);
- enumTypes.add(prov.getEnumType(EnumTypeProvider.nameENString));
- // EntityTypes
- List<EntityType> entityTypes = new ArrayList<EntityType>();
- schema.setEntityTypes(entityTypes);
-
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETAllPrim));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETCollAllPrim));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETTwoPrim));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETMixPrimCollComp));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETTwoKeyTwoPrim));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETBase));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETTwoBase));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETAllKey));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETCompAllPrim));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETCompCollAllPrim));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETCompComp));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETCompCollComp));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETMedia));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETFourKeyAlias));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETServerSidePaging));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETAllNullable));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETKeyNav));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETTwoKeyNav));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETTwoBaseTwoKeyNav));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETCompMixPrimCollComp));
- entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETKeyPrimNav));
-
- // ComplexTypes
- List<ComplexType> complexType = new ArrayList<ComplexType>();
- schema.setComplexTypes(complexType);
- complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTPrim));
- complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTAllPrim));
- complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTCollAllPrim));
- complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTTwoPrim));
- complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTMixPrimCollComp));
- complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTBase));
- complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTTwoBase));
- complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTCompComp));
- complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTCompCollComp));
- complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTPrimComp));
- complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTNavFiveProp));
- complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTPrimEnum));
- complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTBasePrimCompNav));
- complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTTwoBasePrimCompNav));
- complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTCompNav));
-
- // TypeDefinitions
-
- // Actions
- List<Action> actions = new ArrayList<Action>();
- schema.setActions(actions);
- actions.addAll(prov.getActions(ActionProvider.nameBAETTwoKeyNavRTETTwoKeyNav));
- actions.addAll(prov.getActions(ActionProvider.nameBAESAllPrimRTETAllPrim));
- actions.addAll(prov.getActions(ActionProvider.nameBAESTwoKeyNavRTESTwoKeyNav));
- actions.addAll(prov.getActions(ActionProvider.nameBAETBaseTwoKeyNavRTETBaseTwoKeyNav));
- actions.addAll(prov.getActions(ActionProvider.nameBAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav));
- actions.addAll(prov.getActions(ActionProvider.nameUARTPrimParam));
- actions.addAll(prov.getActions(ActionProvider.nameUARTPrimCollParam));
- actions.addAll(prov.getActions(ActionProvider.nameUARTCompParam));
- actions.addAll(prov.getActions(ActionProvider.nameUARTCompCollParam));
- actions.addAll(prov.getActions(ActionProvider.nameUARTETParam));
- actions.addAll(prov.getActions(ActionProvider.nameUARTESParam));
-
- // Functions
- List<Function> functions = new ArrayList<Function>();
- schema.setFunctions(functions);
-
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFNRTInt16));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTETKeyNav));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTETTwoKeyNavParam));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTETTwoKeyNavParamCTTwoPrim));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTStringTwoParam));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTESTwoKeyNavParam));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTString));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollStringTwoParam));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollString));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCTAllPrimTwoParam));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCTTwoPrimParam));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollCTTwoPrimParam));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCTTwoPrim));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollCTTwoPrim));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTETMedia));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFNRTESMixPrimCollCompTwoParam));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTETAllPrimTwoParam));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTESMixPrimCollCompTwoParam));
- functions.addAll(prov.getFunctions(FunctionProvider.nameUFNRTCollCTNavFiveProp));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTESTwoKeyNav));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCStringRTESTwoKeyNav));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCETBaseTwoKeyNavRTETTwoKeyNav));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESBaseTwoKeyNavRTESBaseTwoKey));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESAllPrimRTCTAllPrim));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTCTTwoPrim));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTCollCTTwoPrim));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTString));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTCollString));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCETTwoKeyNavRTESTwoKeyNav));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCETBaseTwoKeyNavRTESTwoKeyNav));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCSINavRTESTwoKeyNav));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCETBaseTwoKeyNavRTESBaseTwoKey));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCCollStringRTESTwoKeyNav));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCCTPrimCompRTESTwoKeyNav));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCCTPrimCompRTESBaseTwoKeyNav));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCCollCTPrimCompRTESAllPrim));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTTwoKeyNav));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESKeyNavRTETKeyNav));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCETKeyNavRTETKeyNav));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFESTwoKeyNavRTESTwoKeyNav));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCETTwoKeyNavRTETTwoKeyNav));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCETTwoKeyNavRTCTTwoPrim));
-
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTCTNavFiveProp));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTCollCTNavFiveProp));
-
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTStringParam));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESKeyNavRTETKeyNavParam));
- functions.addAll(prov.getFunctions(FunctionProvider.nameBFCCTPrimCompRTETTwoKeyNavParam));
- // functions.addAll(prov.getFunctions(FunctionProvider.nameBFCCTPrimCompRTESTwoKeyNavParam));
-
- // EntityContainer
- EntityContainer container = new EntityContainer();
- schema.setEntityContainer(container);
- container.setName(ContainerProvider.nameContainer.getName());
-
- // EntitySets
- List<EntitySet> entitySets = new ArrayList<EntitySet>();
- container.setEntitySets(entitySets);
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESAllPrim"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESCollAllPrim"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESTwoPrim"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESMixPrimCollComp"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESBase"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESTwoBase"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESTwoKeyTwoPrim"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESBaseTwoKeyTwoPrim"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESTwoBaseTwoKeyTwoPrim"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESAllKey"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESCompAllPrim"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESCompCollAllPrim"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESCompComp"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESCompCollComp"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESMedia"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESKeyTwoKeyComp"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESInvisible"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESServerSidePaging"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESAllNullable"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESKeyNav"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESTwoKeyNav"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESBaseTwoKeyNav"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESCompMixPrimCollComp"));
- entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESFourKeyAlias"));
-
- // Singletons
- List<Singleton> singletons = new ArrayList<Singleton>();
- container.setSingletons(singletons);
- singletons.add(prov.getSingleton(ContainerProvider.nameContainer, "SI"));
- singletons.add(prov.getSingleton(ContainerProvider.nameContainer, "SINav"));
- singletons.add(prov.getSingleton(ContainerProvider.nameContainer, "SIMedia"));
-
- // ActionImports
- List<ActionImport> actionImports = new ArrayList<ActionImport>();
- container.setActionImports(actionImports);
- actionImports.add(prov.getActionImport(ContainerProvider.nameContainer, "AIRTPrimParam"));
- actionImports.add(prov.getActionImport(ContainerProvider.nameContainer, "AIRTPrimCollParam"));
- actionImports.add(prov.getActionImport(ContainerProvider.nameContainer, "AIRTCompParam"));
- actionImports.add(prov.getActionImport(ContainerProvider.nameContainer, "AIRTCompCollParam"));
- actionImports.add(prov.getActionImport(ContainerProvider.nameContainer, "AIRTETParam"));
- actionImports.add(prov.getActionImport(ContainerProvider.nameContainer, "AIRTETCollAllPrimParam"));
-
- // FunctionImports
- List<FunctionImport> functionImports = new ArrayList<FunctionImport>();
- container.setFunctionImports(functionImports);
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FINRTInt16"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FINInvisibleRTInt16"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FINInvisible2RTInt16"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTETKeyNav"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTETTwoKeyNavParam"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTStringTwoParam"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollStringTwoParam"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCTAllPrimTwoParam"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTESMixPrimCollCompTwoParam"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FINRTESMixPrimCollCompTwoParam"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollCTTwoPrim"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTETMedia"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCTTwoPrimParam"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCTTwoPrim"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollString"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTString"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTESTwoKeyNavParam"));
- functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollCTTwoPrimParam"));
-
- return schemas;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/TypeDefinitionProvider.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/TypeDefinitionProvider.java b/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/TypeDefinitionProvider.java
deleted file mode 100644
index dc34b31..0000000
--- a/lib/ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/TypeDefinitionProvider.java
+++ /dev/null
@@ -1,30 +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.testutil.techprovider;
-
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.server.api.edm.provider.TypeDefinition;
-
-public class TypeDefinitionProvider {
-
- public TypeDefinition getTypeDefinition(final FullQualifiedName typeDefinitionName) {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/main/resources/simplelogger.properties
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/resources/simplelogger.properties b/lib/ref/src/main/resources/simplelogger.properties
deleted file mode 100644
index 2a3350c..0000000
--- a/lib/ref/src/main/resources/simplelogger.properties
+++ /dev/null
@@ -1,20 +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.
-#
-org.slf4j.simpleLogger.defaultLogLevel=debug
-org.slf4j.simpleLogger.logFile=System.out
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/webapp/WEB-INF/web.xml b/lib/ref/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index cc7de77..0000000
--- a/lib/ref/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- id="WebApp_ID" version="2.5">
-
- <display-name>Apache Olingo OData 4.0 Reference Scenario Service</display-name>
-
- <welcome-file-list>
- <welcome-file>index.html</welcome-file>
- </welcome-file-list>
-
- <servlet>
- <servlet-name>ODataServlet</servlet-name>
- <servlet-class>org.apache.olingo.ref.ReferenceServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>ODataServlet</servlet-name>
- <url-pattern>/odata.svc/*</url-pattern>
- </servlet-mapping>
-
-</web-app>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/main/webapp/index.html
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/webapp/index.html b/lib/ref/src/main/webapp/index.html
deleted file mode 100644
index e25f4fb..0000000
--- a/lib/ref/src/main/webapp/index.html
+++ /dev/null
@@ -1,32 +0,0 @@
-<html>
-<!--
- 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.
--->
-
-<body>
- <h1>Olingo OData 4.0 Reference Scenario Service</h1>
- <hr>
- <h2>Reference Scenario Service</h2>
- <lu>
- <li><a href="odata.svc/">Service Document</a></li>
- <li><a href="odata.svc/$metadata">Metadata</a></li>
- </lu>
-
-</body>
-
-</html>
\ No newline at end of file
[10/15] [OLINGO-266] refactor ref module to server-ref
Posted by sk...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
deleted file mode 100644
index fde13c8..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
+++ /dev/null
@@ -1,230 +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 static org.junit.Assert.fail;
-
-import org.apache.olingo.commons.api.ODataApplicationException;
-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.uri.UriInfoKind;
-import org.apache.olingo.server.api.uri.queryoption.ExpandItem;
-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.queryoption.ExpandOptionImpl;
-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.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 ExpandItem expandItem;
-
- // --- Setup ---
-
- public ExpandValidator setUpValidator(final TestValidator validator) {
- invokedByValidator = validator;
- return this;
- }
-
- public ExpandValidator setExpand(final ExpandOptionImpl expand) {
- expandOption = expand;
- first();
- return this;
- }
-
- public ExpandValidator setEdm(final Edm edm) {
- this.edm = edm;
- return this;
- }
-
- // --- Navigation ---
-
- public ExpandValidator goUpToExpandValidator() {
- return (ExpandValidator) invokedByValidator;
- }
-
- public ResourceValidator goUpToUriResourceValidator() {
- return (ResourceValidator) invokedByValidator;
- }
-
- 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);
-
- }
-
- public FilterValidator goOrder(final int index) {
- OrderByOptionImpl orderBy = (OrderByOptionImpl) expandItem.getOrderByOption();
-
- return new FilterValidator()
- .setValidator(this)
- .setEdm(edm)
- .setExpression(orderBy.getOrders().get(index).getExpression());
- }
-
- public ResourceValidator goSelectItem(final int index) {
- SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
-
- SelectItem item = select.getSelectItems().get(index);
- UriInfoImpl uriInfo = (UriInfoImpl) item.getResourcePath();
-
- return new ResourceValidator()
- .setUpValidator(this)
- .setEdm(edm)
- .setUriInfoImplPath(uriInfo);
-
- }
-
- public ExpandValidator goExpand() {
- ExpandValidator val = new ExpandValidator()
- .setExpand((ExpandOptionImpl) expandItem.getExpandOption())
- .setUpValidator(this);
- return val;
- }
-
- public ExpandValidator first() {
- expandItemIndex = 0;
- expandItem = expandOption.getExpandItems().get(expandItemIndex);
- return this;
- }
-
- public ExpandValidator next() {
- expandItemIndex++;
-
- try {
- expandItem = expandOption.getExpandItems().get(expandItemIndex);
- } catch (IndexOutOfBoundsException ex) {
- fail("not enought segments");
- }
- return this;
-
- }
-
- public ExpandValidator isSegmentStar(final int index) {
- assertEquals(true, expandItem.isStar());
- return this;
- }
-
- public ExpandValidator isSegmentRef(final int index) {
- assertEquals(true, expandItem.isRef());
- return this;
- }
-
- public ExpandValidator isLevelText(final String text) {
- QueryOptionImpl option = (QueryOptionImpl) expandItem.getLevelsOption();
- assertEquals(text, option.getText());
- return this;
- }
-
- public ExpandValidator isSkipText(final String text) {
- QueryOptionImpl option = (QueryOptionImpl) expandItem.getSkipOption();
- assertEquals(text, option.getText());
- return this;
- }
-
- public ExpandValidator isTopText(final String text) {
- QueryOptionImpl option = (QueryOptionImpl) expandItem.getTopOption();
- assertEquals(text, option.getText());
- return this;
- }
-
- public ExpandValidator isInlineCountText(final String text) {
- QueryOptionImpl option = (QueryOptionImpl) expandItem.getCountOption();
- assertEquals(text, option.getText());
- return this;
- }
-
- public ExpandValidator isSelectText(final String text) {
- QueryOptionImpl option = (QueryOptionImpl) expandItem.getSelectOption();
- assertEquals(text, option.getText());
- return this;
- }
-
- public ExpandValidator isSelectItemStar(final int index) {
- SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
-
- SelectItem item = select.getSelectItems().get(index);
- assertEquals(true, item.isStar());
- return this;
- }
-
- public ExpandValidator isSelectItemAllOperations(final int index, final FullQualifiedName fqn) {
- SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
-
- SelectItem item = select.getSelectItems().get(index);
- assertEquals(fqn.toString(), item.getAllOperationsInSchemaNameSpace().toString());
- return this;
- }
-
- public ExpandValidator isFilterOptionText(final String text) {
- QueryOptionImpl option = (QueryOptionImpl) expandItem.getFilterOption();
- assertEquals(text, option.getText());
- return this;
- }
-
- public ExpandValidator isFilterSerialized(final String serialized) {
- FilterOptionImpl filter = (FilterOptionImpl) expandItem.getFilterOption();
-
- try {
- String tmp = FilterTreeToText.Serialize(filter);
- assertEquals(serialized, tmp);
- } catch (ExpressionVisitException e) {
- fail("Exception occured while converting the filterTree into text" + "\n"
- + " Exception: " + e.getMessage());
- } catch (ODataApplicationException e) {
- fail("Exception occured while converting the filterTree into text" + "\n"
- + " Exception: " + e.getMessage());
- }
-
- return this;
- }
-
- public ExpandValidator isSortOrder(final int index, final boolean descending) {
- OrderByOptionImpl orderBy = (OrderByOptionImpl) 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);
- return this;
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
deleted file mode 100644
index 06056e0..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
+++ /dev/null
@@ -1,154 +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.List;
-
-import org.apache.olingo.commons.api.ODataApplicationException;
-import org.apache.olingo.commons.api.edm.EdmEnumType;
-import org.apache.olingo.commons.api.edm.EdmType;
-import org.apache.olingo.server.api.uri.UriInfoResource;
-import org.apache.olingo.server.api.uri.UriResource;
-import org.apache.olingo.server.api.uri.UriResourceLambdaAll;
-import org.apache.olingo.server.api.uri.UriResourceLambdaAny;
-import org.apache.olingo.server.api.uri.UriResourcePartTyped;
-import org.apache.olingo.server.api.uri.queryoption.FilterOption;
-import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
-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.ExpressionVisitor;
-import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
-import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind;
-
-public class FilterTreeToText implements ExpressionVisitor<String> {
-
- public static String Serialize(final FilterOption filter)
- throws ExpressionVisitException, ODataApplicationException {
-
- Expression expression = filter.getExpression();
- return expression.accept(new FilterTreeToText());
- }
-
- public static String Serialize(final Expression expression)
- throws ExpressionVisitException, ODataApplicationException {
-
- return expression.accept(new FilterTreeToText());
- }
-
- @Override
- public String visitBinaryOperator(final BinaryOperatorKind operator, final String left, final String right)
- throws ExpressionVisitException {
-
- return "<" + left + " " + operator.toString() + " " + right + ">";
- }
-
- @Override
- public String visitUnaryOperator(final UnaryOperatorKind operator, final String operand)
- throws ExpressionVisitException {
-
- return "<" + operator + " " + operand.toString() + ">";
- }
-
- @Override
- public String visitMethodCall(final MethodKind methodCall, final List<String> parameters)
- throws ExpressionVisitException {
-
- String text = "<" + methodCall + "(";
- int i = 0;
- while (i < parameters.size()) {
- if (i > 0) {
- text += ",";
- }
- text += parameters.get(i);
- i++;
- }
- return text + ")>";
- }
-
- @Override
- public String visitLiteral(final String literal) throws ExpressionVisitException {
- return "<" + literal + ">";
- }
-
- @Override
- public String visitMember(final UriInfoResource resource) throws ExpressionVisitException, ODataApplicationException {
- String ret = "";
-
- UriInfoResource path = resource;
-
- for (UriResource item : path.getUriResourceParts()) {
- String tmp = "";
- if (item instanceof UriResourceLambdaAll) {
- UriResourceLambdaAll all = (UriResourceLambdaAll) item;
- tmp = visitLambdaExpression("ALL", all.getLambdaVariable(), all.getExpression());
- } else if (item instanceof UriResourceLambdaAny) {
- UriResourceLambdaAny any = (UriResourceLambdaAny) item;
- tmp = visitLambdaExpression("ANY", any.getLamdaVariable(), any.getExpression());
- } else if (item instanceof UriResourcePartTyped) {
- UriResourcePartTyped typed = (UriResourcePartTyped) item;
- tmp = typed.toString(true);
- }
-
- if (ret.length() != 0) {
- ret += "/";
- }
- ret += tmp;
-
- }
- return "<" + ret + ">";
- }
-
- @Override
- public String visitAlias(final String referenceName) throws ExpressionVisitException {
- return "<" + referenceName + ">";
- }
-
- @Override
- public String visitLambdaExpression(final String functionText, final String string, final Expression expression)
- throws ExpressionVisitException, ODataApplicationException {
-
- return "<" + functionText + ";" + ((expression == null) ? "" : expression.accept(this)) + ">";
- }
-
- @Override
- public String visitTypeLiteral(final EdmType type) {
- return "<" + type.getNamespace() + "." + type.getName() + ">";
- }
-
- @Override
- public String visitLambdaReference(final String variableText) {
- return "<" + variableText + ">";
- }
-
- @Override
- public String visitEnum(final EdmEnumType type, final List<String> enumValues)
- throws ExpressionVisitException, ODataApplicationException {
- String tmp = "";
-
- for (String item : enumValues) {
- if (tmp.length() > 0) {
- tmp += ",";
- }
- tmp += item;
- }
-
- return "<" + type.getNamespace() + "." + type.getName() + "<" + tmp + ">>";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
deleted file mode 100644
index 58e429f..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
+++ /dev/null
@@ -1,534 +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 static org.junit.Assert.fail;
-
-import java.util.List;
-
-import org.apache.olingo.commons.api.ODataApplicationException;
-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.uri.UriInfo;
-import org.apache.olingo.server.api.uri.UriInfoKind;
-import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
-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.Member;
-import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
-import org.apache.olingo.server.core.uri.UriInfoImpl;
-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 Expression curExpression;
- private Expression rootExpression;
-
- private OrderByOptionImpl orderBy;
-
- private UriParserException exception;
-
- // --- Setup ---
- public FilterValidator setUriResourcePathValidator(final ResourceValidator uriResourcePathValidator) {
- invokedByValidator = uriResourcePathValidator;
- return this;
- }
-
- public FilterValidator setUriValidator(final TestUriValidator uriValidator) {
- invokedByValidator = uriValidator;
- return this;
- }
-
- public FilterValidator setValidator(final TestValidator uriValidator) {
- invokedByValidator = uriValidator;
- return this;
- }
-
- public FilterValidator setEdm(final Edm edm) {
- this.edm = edm;
- return this;
- }
-
- public FilterValidator setFilter(final FilterOptionImpl filter) {
- this.filter = filter;
-
- if (filter.getExpression() == null) {
- fail("FilterValidator: no filter found");
- }
- setExpression(filter.getExpression());
- return this;
- }
-
- public FilterValidator setOrderBy(final OrderByOptionImpl orderBy) {
- this.orderBy = orderBy;
-
- return this;
- }
-
- public FilterValidator setExpression(final Expression expression) {
- rootExpression = curExpression = expression;
- return this;
- }
-
- // --- Execution ---
-
- public FilterValidator runOrderByOnETAllPrim(final String orderBy) throws UriParserException {
- String uri = "ESAllPrim?$orderby=" + orderBy.trim();
- return runUriOrderBy(uri);
- }
-
- public FilterValidator runOrderByOnETTwoKeyNav(final String orderBy) throws UriParserException {
- String uri = "ESTwoKeyNav?$orderby=" + orderBy.trim();
- return runUriOrderBy(uri);
- }
-
- public FilterValidator runOrderByOnETTwoKeyNavEx(final String orderBy) throws UriParserException {
- String uri = "ESTwoKeyNav?$orderby=" + orderBy.trim();
- return runUriOrderByEx(uri);
- }
-
- public FilterValidator runOnETTwoKeyNav(final String filter) throws UriParserException {
- String uri = "ESTwoKeyNav?$filter=" + filter.trim();
- return runUri(uri);
- }
-
- public FilterValidator runOnETTwoKeyNavSingle(final String filter) throws UriParserException {
- String uri = "SINav?$filter=" + filter.trim();
- return runUri(uri);
- }
-
- public FilterValidator runOnETTwoKeyNavEx(final String filter) throws UriParserException {
- String uri = "ESTwoKeyNav?$filter=" + filter.trim();
- return runUriEx(uri);
- }
-
- public FilterValidator runOnETAllPrim(final String filter) throws UriParserException {
- String uri = "ESAllPrim(1)?$filter=" + filter.trim();
- return runUri(uri);
- }
-
- public FilterValidator runOnETKeyNav(final String filter) throws UriParserException {
- String uri = "ESKeyNav(1)?$filter=" + filter.trim();
- return runUri(uri);
- }
-
- public FilterValidator runOnETKeyNavEx(final String filter) throws UriParserException {
- String uri = "ESKeyNav(1)?$filter=" + filter.trim();
- return runUriEx(uri);
- }
-
- public FilterValidator runOnCTTwoPrim(final String filter) throws UriParserException {
- String uri = "SINav/PropertyComplexTwoPrim?$filter=" + filter.trim();
- return runUri(uri);
- }
-
- public FilterValidator runOnString(final String filter) throws UriParserException {
- String uri = "SINav/PropertyString?$filter=" + filter.trim();
- return runUri(uri);
- }
-
- public FilterValidator runOnInt32(final String filter) throws UriParserException {
- String uri = "ESCollAllPrim(1)/CollPropertyInt32?$filter=" + filter.trim();
- return runUri(uri);
- }
-
- public FilterValidator runOnDateTimeOffset(final String filter) throws UriParserException {
- String uri = "ESCollAllPrim(1)/CollPropertyDateTimeOffset?$filter=" + filter.trim();
- return runUri(uri);
- }
-
- public FilterValidator runOnDuration(final String filter) throws UriParserException {
- String uri = "ESCollAllPrim(1)/CollPropertyDuration?$filter=" + filter.trim();
- return runUri(uri);
- }
-
- public FilterValidator runOnTimeOfDay(final String filter) throws UriParserException {
- String uri = "ESCollAllPrim(1)/CollPropertyTimeOfDay?$filter=" + filter.trim();
- return runUri(uri);
- }
-
- public FilterValidator runESabc(final String filter) throws UriParserException {
- String uri = "ESabc?$filter=" + filter.trim();
- return runUri(uri);
- }
-
- public FilterValidator runUri(final String uri) throws UriParserException {
- Parser parser = new Parser();
- UriInfo uriInfo = null;
-
- uriInfo = parser.parseUri(uri, edm);
-
- if (uriInfo.getKind() != UriInfoKind.resource) {
- fail("Filtervalidator can only be used on resourcePaths");
- }
-
- setFilter((FilterOptionImpl) uriInfo.getFilterOption());
- curExpression = filter.getExpression();
- return this;
- }
-
- public FilterValidator runUriEx(final String uri) {
- Parser parser = new Parser();
- UriInfo uriInfo = null;
-
- try {
- uriInfo = parser.parseUri(uri, edm);
- } catch (UriParserException e) {
- exception = e;
- return this;
- }
-
- if (uriInfo.getKind() != UriInfoKind.resource) {
- fail("Filtervalidator can only be used on resourcePaths");
- }
-
- setFilter((FilterOptionImpl) uriInfo.getFilterOption());
- curExpression = filter.getExpression();
- return this;
- }
-
- public FilterValidator runUriOrderBy(final String uri) throws UriParserException {
- Parser parser = new Parser();
- UriInfo uriInfo = null;
-
- uriInfo = parser.parseUri(uri, edm);
-
- if (uriInfo.getKind() != UriInfoKind.resource) {
- fail("Filtervalidator can only be used on resourcePaths");
- }
-
- setOrderBy((OrderByOptionImpl) uriInfo.getOrderByOption());
- return this;
- }
-
- public FilterValidator runUriOrderByEx(final String uri) {
- Parser parser = new Parser();
- UriInfo uriInfo = null;
-
- try {
- uriInfo = parser.parseUri(uri, edm);
- } catch (UriParserException e) {
- exception = e;
- return this;
- }
-
- if (uriInfo.getKind() != UriInfoKind.resource) {
- fail("Filtervalidator can only be used on resourcePaths");
- }
-
- setOrderBy((OrderByOptionImpl) uriInfo.getOrderByOption());
- return this;
- }
-
- // --- Navigation ---
-
- public ExpandValidator goUpToExpandValidator() {
- return (ExpandValidator) invokedByValidator;
- }
-
- public ResourceValidator goUpToResourceValidator() {
- return (ResourceValidator) invokedByValidator;
- }
-
- public ResourceValidator goPath() {
- if (!(curExpression instanceof MemberImpl)) {
- fail("Current expression not a member");
- }
-
- MemberImpl member = (MemberImpl) curExpression;
-
- return new ResourceValidator()
- .setEdm(edm)
- .setUriInfoImplPath((UriInfoImpl) member.getResourcePath())
- .setUpValidator(this);
-
- }
-
- public FilterValidator goParameter(final int parameterIndex) {
- if (curExpression instanceof MethodImpl) {
- MethodImpl methodCall = (MethodImpl) curExpression;
- curExpression = methodCall.getParameters().get(parameterIndex);
- } else {
- fail("Current expression not a methodCall");
- }
- return this;
- }
-
- // --- Validation ---
-
- /**
- * Validates the serialized filterTree against a given filterString
- * The given expected filterString is compressed before to allow better readable code in the unit tests
- * @param toBeCompr
- * @return
- */
- public FilterValidator isCompr(final String toBeCompr) {
- return is(compress(toBeCompr));
- }
-
- public FilterValidator is(final String expectedFilterAsString) {
- try {
- String actualFilterAsText = FilterTreeToText.Serialize((FilterOptionImpl) filter);
- assertEquals(expectedFilterAsString, actualFilterAsText);
- } catch (ExpressionVisitException e) {
- fail("Exception occured while converting the filterTree into text" + "\n"
- + " Exception: " + e.getMessage());
- } catch (ODataApplicationException e) {
- fail("Exception occured while converting the filterTree into text" + "\n"
- + " Exception: " + e.getMessage());
- }
-
- return this;
- }
-
- // --- Helper ---
-
- private String compress(final String expected) {
- String ret = expected.replaceAll("\\s+", " ");
- ret = ret.replaceAll("< ", "<");
- ret = ret.replaceAll(" >", ">");
- return ret;
- }
-
- public FilterValidator isType(final FullQualifiedName fullName) {
- EdmType actualType = null;
-
- if (curExpression instanceof MemberImpl) {
- Member member = (Member) curExpression;
- actualType = member.getType();
- } else if (curExpression instanceof TypeLiteralImpl) {
- TypeLiteralImpl typeLiteral = (TypeLiteralImpl) curExpression;
- actualType = typeLiteral.getType();
- } else if (curExpression instanceof LiteralImpl) {
- LiteralImpl typeLiteral = (LiteralImpl) curExpression;
- actualType = typeLiteral.getType();
- }
-
- if (actualType == null) {
- fail("Current expression not typed");
- }
-
- FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
- assertEquals(fullName, actualName);
- return this;
- }
-
- public FilterValidator left() {
- if (!(curExpression instanceof BinaryImpl)) {
- fail("Current expression not a binary operator");
- }
-
- curExpression = ((BinaryImpl) curExpression).getLeftOperand();
-
- return this;
- }
-
- public FilterValidator root() {
- if (filter != null) {
- curExpression = filter.getExpression();
- } else {
- curExpression = rootExpression;
- }
-
- return this;
- }
-
- public FilterValidator right() {
- if (!(curExpression instanceof BinaryImpl)) {
- fail("Current expression is not a binary operator");
- }
-
- curExpression = ((BinaryImpl) curExpression).getRightOperand();
-
- return this;
-
- }
-
- public FilterValidator isLiteral(final String literalText) {
- if (!(curExpression instanceof LiteralImpl)) {
- fail("Current expression is not a literal");
- }
-
- String actualLiteralText = ((LiteralImpl) curExpression).getText();
- assertEquals(literalText, actualLiteralText);
-
- return this;
- }
-
- public FilterValidator isMethod(final MethodKind methodKind, final int parameterCount) {
- if (!(curExpression instanceof MethodImpl)) {
- fail("Current expression is not a methodCall");
- }
-
- MethodImpl methodCall = (MethodImpl) 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)) {
- fail("Current expression is not a method");
- }
-
- MethodImpl methodCall = (MethodImpl) 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)) {
- fail("Current expression is not a binary operator");
- }
-
- BinaryImpl binary = (BinaryImpl) curExpression;
- assertEquals(binaryOperator, binary.getOperator());
-
- return this;
- }
-
- public FilterValidator isTypedLiteral(final FullQualifiedName fullName) {
- if (!(curExpression instanceof TypeLiteralImpl)) {
- fail("Current expression not a typeLiteral");
- }
-
- isType(fullName);
-
- return this;
- }
-
- public FilterValidator isMember() {
- if (!(curExpression instanceof MemberImpl)) {
- 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;
- EdmType actualType = member.getStartTypeFilter();
-
- FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
- assertEquals(fullName, actualName);
- return this;
- }
-
- public FilterValidator isEnum(final FullQualifiedName nameenstring, final List<String> enumValues) {
- if (!(curExpression instanceof EnumerationImpl)) {
- fail("Current expression not a enumeration");
- }
-
- EnumerationImpl enumeration = (EnumerationImpl) curExpression;
-
- FullQualifiedName actualName =
- new FullQualifiedName(enumeration.getType().getNamespace(), enumeration.getType().getName());
-
- // check name
- assertEquals(nameenstring.toString(), actualName.toString());
-
- // check values
- int i = 0;
- for (String item : enumValues) {
- assertEquals(item, enumeration.getValues().get(i));
- i++;
- }
-
- return this;
- }
-
- public FilterValidator isSortOrder(final int index, final boolean descending) {
- assertEquals(descending, orderBy.getOrders().get(index).isDescending());
- return this;
- }
-
- public FilterValidator goOrder(final int index) {
- curExpression = orderBy.getOrders().get(index).getExpression();
- return this;
- }
-
- public FilterValidator isExSyntax(final long errorID) {
- assertEquals(UriParserSyntaxException.class, exception.getClass());
- return this;
- }
-
- public FilterValidator isExSemantic(final long errorID) {
- assertEquals(UriParserSemanticException.class, exception.getClass());
- return this;
- }
-
- public FilterValidator isNull() {
- if (!(curExpression instanceof LiteralImpl)) {
- fail("Current expression is not a literal");
- }
-
- String actualLiteralText = ((LiteralImpl) curExpression).getText();
- assertEquals("null", actualLiteralText);
- return this;
- }
-
- public FilterValidator isTrue() {
- if (!(curExpression instanceof LiteralImpl)) {
- fail("Current expression is not a literal");
- }
-
- String actualLiteralText = ((LiteralImpl) curExpression).getText();
- assertEquals("true", actualLiteralText);
- return this;
- }
-
- 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/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParseTreeToText.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParseTreeToText.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParseTreeToText.java
deleted file mode 100644
index f6a3086..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParseTreeToText.java
+++ /dev/null
@@ -1,82 +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) {
- String s = symbol.getText();
- return s;
- }
- }
- }
- // 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/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java
deleted file mode 100644
index 3f73b97..0000000
--- a/lib/ref/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
- */
- 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
- */
- public ParserValidator aCS() {
- allowContextSensitifity = true;
- return this;
- }
-
- /**
- * Used in fast LL Parsing:
- * Allows ambiguities
- * @return
- */
- 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/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserWithLogging.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserWithLogging.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserWithLogging.java
deleted file mode 100644
index 524a38a..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserWithLogging.java
+++ /dev/null
@@ -1,56 +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 org.antlr.v4.runtime.DefaultErrorStrategy;
-import org.antlr.v4.runtime.DiagnosticErrorListener;
-import org.apache.olingo.server.core.uri.antlr.UriParserParser;
-import org.apache.olingo.server.core.uri.parser.Parser;
-
-public class ParserWithLogging extends Parser {
- TestErrorLogger errorCollector1;
- TestErrorLogger errorCollector2;
-
- public ParserWithLogging() {
- errorCollector1 = new TestErrorLogger("Stage 1", 1);
- errorCollector2 = new TestErrorLogger("Stage 2", 1);
- }
-
- @Override
- protected void addStage2ErrorStategy(final UriParserParser parser) {
- // Don't throw an at first syntax error, so the error listener will be called
- parser.setErrorHandler(new DefaultErrorStrategy());
- }
-
- @Override
- protected void addStage1ErrorListener(final UriParserParser parser) {
- // Log error to console
- parser.removeErrorListeners();
- parser.addErrorListener(errorCollector1);
- parser.addErrorListener(new DiagnosticErrorListener());
- }
-
- @Override
- protected void addStage2ErrorListener(final UriParserParser parser) {
- // Log error to console
- parser.removeErrorListeners();
- parser.addErrorListener(errorCollector2);
- parser.addErrorListener(new DiagnosticErrorListener());
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
deleted file mode 100644
index 143871a..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
+++ /dev/null
@@ -1,599 +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 static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import java.util.List;
-
-import org.apache.olingo.commons.api.ODataApplicationException;
-import org.apache.olingo.commons.api.edm.Edm;
-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.server.api.uri.UriInfo;
-import org.apache.olingo.server.api.uri.UriInfoKind;
-import org.apache.olingo.server.api.uri.UriParameter;
-import org.apache.olingo.server.api.uri.UriResourceKind;
-import org.apache.olingo.server.api.uri.UriResourcePartTyped;
-import org.apache.olingo.server.api.uri.queryoption.CustomQueryOption;
-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.core.uri.UriResourceWithKeysImpl;
-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.UriValidator;
-
-public class ResourceValidator implements TestValidator {
- private Edm edm;
- private TestValidator invokedBy;
- private UriInfo uriInfo = null;
-
- private UriResourceImpl uriPathInfo = null;
- private int uriResourceIndex;
-
- // --- Setup ---
-
- public ResourceValidator setUpValidator(final TestValidator uriValidator) {
- invokedBy = uriValidator;
- return this;
- }
-
- public ResourceValidator setEdm(final Edm edm) {
- this.edm = edm;
- return this;
- }
-
- public ResourceValidator setUriInfoImplPath(final UriInfoImpl uriInfoPath) {
- uriInfo = uriInfoPath;
- last();
- return this;
- }
-
- // --- Execution ---
-
- public ResourceValidator run(final String uri) {
- ParserWithLogging testParser = new ParserWithLogging();
-
- UriInfoImpl uriInfoTmp = null;
- uriPathInfo = null;
- try {
- uriInfoTmp = (UriInfoImpl) testParser.parseUri(uri, edm);
-
- UriValidator uriValidator = new UriValidator();
- uriValidator.validate(uriInfoTmp, "GET");
- } catch (Exception e) {
- fail("Exception occured while parsing the URI: " + uri + "\n"
- + " Message: " + e.getMessage());
- }
-
- if (uriInfoTmp.getKind() != UriInfoKind.resource) {
- fail("Invalid UriInfoKind: " + uriInfoTmp.getKind().toString());
- }
- uriInfo = uriInfoTmp;
-
- first();
- return this;
- }
-
- // --- Navigation ---
-
- public TestUriValidator goUpUriValidator() {
- return (TestUriValidator) invokedBy;
- }
-
- public ExpandValidator goUpExpandValidator() {
- return (ExpandValidator) invokedBy;
- }
-
- public FilterValidator goUpFilterValidator() {
- return (FilterValidator) invokedBy;
- }
-
- public FilterValidator goParameter(final int index) {
- assertEquals(UriResourceKind.function, uriPathInfo.getKind());
- UriResourceFunctionImpl function = (UriResourceFunctionImpl) uriPathInfo;
-
- return new FilterValidator()
- .setEdm(edm)
- .setExpression(function.getParameters().get(index).getExression())
- .setValidator(this);
- }
-
- public FilterValidator goLambdaExpression() {
- if (uriPathInfo.getKind() == UriResourceKind.lambdaAll) {
- return new FilterValidator()
- .setEdm(edm)
- .setExpression(((UriResourceLambdaAllImpl) uriPathInfo).getExpression());
-
- } else if (uriPathInfo.getKind() == UriResourceKind.lambdaAny) {
- return new FilterValidator()
- .setEdm(edm)
- .setExpression(((UriResourceLambdaAnyImpl) uriPathInfo).getExpression());
- } else {
- fail("invalid resource kind: " + uriPathInfo.getKind().toString());
- }
- return null;
- }
-
- public ResourceValidator goSelectItem(final int index) {
- SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
-
- SelectItem item = select.getSelectItems().get(index);
- UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourcePath();
-
- return new ResourceValidator()
- .setUpValidator(this)
- .setEdm(edm)
- .setUriInfoImplPath(uriInfo1);
-
- }
-
- public ExpandValidator goExpand() {
- ExpandOptionImpl expand = (ExpandOptionImpl) uriInfo.getExpandOption();
- if (expand == null) {
- fail("invalid resource kind: " + uriPathInfo.getKind().toString());
- }
-
- return new ExpandValidator().setUpValidator(this).setExpand(expand);
- }
-
- public ResourceValidator first() {
- uriResourceIndex = 0;
- uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(0);
- return this;
- }
-
- public ResourceValidator last() {
- uriResourceIndex = 0;
-
- try {
- uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriInfo.getUriResourceParts().size() - 1);
- uriResourceIndex = uriInfo.getUriResourceParts().size() - 1;
- } catch (IndexOutOfBoundsException ex) {
- fail("not enough segments");
- }
-
- return this;
- }
-
- public ResourceValidator n() {
- uriResourceIndex++;
-
- try {
- uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriResourceIndex);
- } catch (IndexOutOfBoundsException ex) {
- fail("not enough segments");
- }
-
- return this;
- }
-
- public ResourceValidator at(final int index) {
- uriResourceIndex = index;
- try {
- uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(index);
- } catch (IndexOutOfBoundsException ex) {
- fail("not enough segments");
- }
- return this;
- }
-
- // --- Validation ---
-
- public ResourceValidator isLambdaVar(final String var) {
- String actualVar = null;
- if (uriPathInfo.getKind() == UriResourceKind.lambdaAll) {
- actualVar = ((UriResourceLambdaAllImpl) uriPathInfo).getLambdaVariable();
- } else if (uriPathInfo.getKind() == UriResourceKind.lambdaAny) {
- actualVar = ((UriResourceLambdaAnyImpl) uriPathInfo).getLamdaVariable();
- } else {
- fail("invalid resource kind: " + uriPathInfo.getKind().toString());
- }
-
- assertEquals(var, actualVar);
- return this;
- }
-
- public ResourceValidator isTypeFilter(final FullQualifiedName expectedType) {
-
- if (uriPathInfo.getKind() != UriResourceKind.complexProperty &&
- uriPathInfo.getKind() != UriResourceKind.singleton) {
- fail("invalid resource kind: " + uriPathInfo.getKind().toString());
- }
-
- EdmType actualType = null;
- if (uriPathInfo instanceof UriResourceComplexPropertyImpl) {
- actualType = ((UriResourceComplexPropertyImpl) uriPathInfo).getComplexTypeFilter();
- } else if (uriPathInfo instanceof UriResourceSingletonImpl) {
- actualType = ((UriResourceSingletonImpl) uriPathInfo).getEntityTypeFilter();
- }
-
- if (actualType == null) {
- fail("type information not set");
- }
-
- FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
-
- assertEquals(expectedType.toString(), actualName.toString());
- return this;
- }
-
- public ResourceValidator isType(final FullQualifiedName type) {
- if (!(uriPathInfo instanceof UriResourcePartTyped)) {
- fail("invalid resource kind: " + uriPathInfo.getKind().toString());
- }
- UriResourcePartTyped uriPathInfoTyped = (UriResourcePartTyped) uriPathInfo;
-
- EdmType actualType = uriPathInfoTyped.getType();
- if (actualType == null) {
- fail("type information not set");
- }
-
- FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
-
- assertEquals(type.toString(), actualName.toString());
-
- return this;
- }
-
- public ResourceValidator isType(final FullQualifiedName type, final boolean isFinallyACollection) {
- isType(type);
- assertEquals(isFinallyACollection, ((UriResourcePartTyped) uriPathInfo).isCollection());
- return this;
- }
-
- public ResourceValidator isTypeFilterOnEntry(final FullQualifiedName type) {
- if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
- fail("invalid resource kind: " + uriPathInfo.getKind().toString());
- }
-
- UriResourceWithKeysImpl uriPathInfoKeyPred = (UriResourceWithKeysImpl) uriPathInfo;
-
- // 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());
- }
-
- return this;
- }
-
- public ResourceValidator isTypeFilterOnCollection(final FullQualifiedName expectedType) {
- if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
- fail("invalid resource kind: " + uriPathInfo.getKind().toString());
- }
- UriResourceWithKeysImpl uriPathInfoKeyPred = (UriResourceWithKeysImpl) uriPathInfo;
-
- // 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());
- }
-
- 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;
- }
-
- // TODO remove
- /*
- * public ResourceValidator isCollection(final boolean isCollection) {
- * if (!(uriPathInfo instanceof UriResourcePartTyped)) {
- * fail("invalid resource kind: " + uriPathInfo.getKind().toString());
- * }
- * UriResourcePartTyped uriPathInfoTyped = (UriResourcePartTyped) uriPathInfo;
- *
- * EdmType type = uriPathInfoTyped.getType();
- * if (type == null) {
- * fail("isCollection: type == null");
- * }
- * assertEquals(isCollection, uriPathInfoTyped.isCollection());
- * 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());
- }
-
- UriResourceWithKeysImpl info = (UriResourceWithKeysImpl) uriPathInfo;
- List<UriParameter> keyPredicates = info.getKeyPredicates();
- assertEquals(name, keyPredicates.get(index).getName());
- assertEquals(refencedProperty, keyPredicates.get(index).getRefencedProperty());
- return this;
-
- }
-
- public ResourceValidator isKeyPredicateAlias(final int index, final String name, final String alias) {
- if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
- fail("invalid resource kind: " + uriPathInfo.getKind().toString());
- }
-
- UriResourceWithKeysImpl info = (UriResourceWithKeysImpl) uriPathInfo;
- List<UriParameter> keyPredicates = info.getKeyPredicates();
- assertEquals(name, keyPredicates.get(index).getName());
- assertEquals(alias, keyPredicates.get(index).getAlias());
- return this;
-
- }
-
- public ResourceValidator isKeyPredicate(final int index, final String name, final String text) {
- if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
- fail("invalid resource kind: " + uriPathInfo.getKind().toString());
- }
-
- UriResourceWithKeysImpl info = (UriResourceWithKeysImpl) uriPathInfo;
- List<UriParameter> keyPredicates = info.getKeyPredicates();
- assertEquals(name, keyPredicates.get(index).getName());
- assertEquals(text, keyPredicates.get(index).getText());
- return this;
-
- }
-
- public ResourceValidator isParameter(final int index, final String name, final String text) {
- if (!(uriPathInfo instanceof UriResourceFunctionImpl)) {
- fail("invalid resource kind: " + uriPathInfo.getKind().toString());
- }
-
- UriResourceFunctionImpl info = (UriResourceFunctionImpl) uriPathInfo;
- List<UriParameter> keyPredicates = info.getParameters();
- assertEquals(name, keyPredicates.get(index).getName());
- assertEquals(text, keyPredicates.get(index).getText());
- return this;
-
- }
-
- public ResourceValidator isParameterAlias(final int index, final String name, final String alias) {
- if (!(uriPathInfo instanceof UriResourceFunctionImpl)) {
- fail("invalid resource kind: " + uriPathInfo.getKind().toString());
- }
-
- UriResourceFunctionImpl info = (UriResourceFunctionImpl) uriPathInfo;
- List<UriParameter> keyPredicates = info.getParameters();
- assertEquals(name, keyPredicates.get(index).getName());
- assertEquals(alias, keyPredicates.get(index).getAlias());
- return this;
-
- }
-
- public ResourceValidator isKind(final UriInfoKind kind) {
- assertEquals(kind, uriInfo.getKind());
- return this;
- }
-
- public ResourceValidator isPrimitiveProperty(final String name,
- final FullQualifiedName type, final boolean isCollection) {
- if (!(uriPathInfo instanceof UriResourcePrimitivePropertyImpl)) {
- fail("invalid resource kind: " + uriPathInfo.getKind().toString());
- }
-
- UriResourcePrimitivePropertyImpl uriPathInfoProp = (UriResourcePrimitivePropertyImpl) uriPathInfo;
-
- EdmElement property = uriPathInfoProp.getProperty();
-
- assertEquals(name, property.getName());
- assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName()));
- assertEquals(isCollection, property.isCollection());
- return this;
- }
-
- public ResourceValidator
- isComplexProperty(final String name, final FullQualifiedName type, final boolean isCollection) {
- if (!(uriPathInfo instanceof UriResourceComplexPropertyImpl)) {
- fail("invalid resource kind: " + uriPathInfo.getKind().toString());
- }
-
- UriResourceComplexPropertyImpl uriPathInfoProp = (UriResourceComplexPropertyImpl) uriPathInfo;
-
- EdmElement property = uriPathInfoProp.getProperty();
-
- assertEquals(name, property.getName());
- assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName()));
- assertEquals(isCollection, property.isCollection());
- return this;
- }
-
- public ResourceValidator isNavProperty(final String name, final FullQualifiedName type, final boolean isCollection) {
- if (!(uriPathInfo instanceof UriResourceNavigationPropertyImpl)) {
- fail("invalid resource kind: " + uriPathInfo.getKind().toString());
- }
-
- UriResourceNavigationPropertyImpl uriPathInfoProp = (UriResourceNavigationPropertyImpl) uriPathInfo;
-
- EdmElement property = uriPathInfoProp.getProperty();
-
- assertEquals(name, property.getName());
- assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName()));
- assertEquals(isCollection, uriPathInfoProp.isCollection());
- return this;
- }
-
- public ResourceValidator isUriPathInfoKind(final UriResourceKind infoType) {
- assertNotNull(uriPathInfo);
- assertEquals(infoType, uriPathInfo.getKind());
- return this;
- }
-
- public ResourceValidator isAction(final String name) {
- assertEquals(UriResourceKind.action, uriPathInfo.getKind());
- assertEquals(name, ((UriResourceActionImpl) uriPathInfo).getAction().getName());
- return this;
- }
-
- public ResourceValidator isFunction(final String name) {
- assertEquals(UriResourceKind.function, uriPathInfo.getKind());
- assertEquals(name, ((UriResourceFunctionImpl) uriPathInfo).getFunction().getName());
- return this;
- }
-
- public ResourceValidator isFunctionImport(final String name) {
- assertEquals(UriResourceKind.function, uriPathInfo.getKind());
- assertEquals(name, ((UriResourceFunctionImpl) uriPathInfo).getFunctionImport().getName());
- return this;
- }
-
- public ResourceValidator isEntitySet(final String name) {
- assertEquals(UriResourceKind.entitySet, uriPathInfo.getKind());
- assertEquals(name, ((UriResourceEntitySetImpl) uriPathInfo).getEntitySet().getName());
- return this;
- }
-
- public ResourceValidator isComplex(final String name) {
- assertEquals(UriResourceKind.complexProperty, uriPathInfo.getKind());
- assertEquals(name, ((UriResourceComplexPropertyImpl) uriPathInfo).getProperty().getName());
- return this;
- }
-
- public ResourceValidator isSingleton(final String name) {
- assertEquals(UriResourceKind.singleton, uriPathInfo.getKind());
- assertEquals(name, ((UriResourceSingletonImpl) uriPathInfo).getSingleton().getName());
- return this;
- }
-
- public ResourceValidator isValue() {
- assertEquals(UriResourceKind.value, uriPathInfo.getKind());
- return this;
- }
-
- public ResourceValidator isCount() {
- assertEquals(UriResourceKind.count, uriPathInfo.getKind());
- return this;
- }
-
- public ResourceValidator isRef() {
- assertEquals(UriResourceKind.ref, uriPathInfo.getKind());
- return this;
- }
-
- public ResourceValidator isActionImport(final String actionName) {
- assertEquals(UriResourceKind.action, uriPathInfo.getKind());
- assertEquals(actionName, ((UriResourceActionImpl) uriPathInfo).getActionImport().getName());
- return this;
- }
-
- public ResourceValidator isIt() {
- assertEquals(UriResourceKind.it, uriPathInfo.getKind());
- return this;
- }
-
- public ResourceValidator isTopText(final String topText) {
- assertEquals(topText, uriInfo.getTopOption().getText());
- return this;
- }
-
- public ResourceValidator isFormatText(final String formatText) {
- assertEquals(formatText, uriInfo.getFormatOption().getText());
- return this;
- }
-
- public ResourceValidator isInlineCountText(final String inlineCountText) {
- assertEquals(inlineCountText, uriInfo.getCountOption().getText());
- return this;
- }
-
- public ResourceValidator isSkipText(final String skipText) {
- assertEquals(skipText, uriInfo.getSkipOption().getText());
- return this;
- }
-
- public ResourceValidator isSkipTokenText(final String skipTokenText) {
- assertEquals(skipTokenText, uriInfo.getSkipTokenOption().getText());
- return this;
- }
-
- public ResourceValidator isSelectItemStar(final int index) {
- SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
-
- SelectItem item = select.getSelectItems().get(index);
- assertEquals(true, item.isStar());
- return this;
- }
-
- public ResourceValidator isSelectItemAllOp(final int index, final FullQualifiedName fqn) {
- SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
-
- SelectItem item = select.getSelectItems().get(index);
- assertEquals(fqn.toString(), item.getAllOperationsInSchemaNameSpace().toString());
- return this;
- }
-
- public ResourceValidator isSelectStartType(final int index, final FullQualifiedName fullName) {
- SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
- SelectItem item = select.getSelectItems().get(index);
-
- EdmType actualType = item.getStartTypeFilter();
-
- FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
- assertEquals(fullName, actualName);
- return this;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestErrorLogger.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestErrorLogger.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestErrorLogger.java
deleted file mode 100644
index 0153036..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestErrorLogger.java
+++ /dev/null
@@ -1,105 +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.BitSet;
-import java.util.Collections;
-import java.util.List;
-
-import org.antlr.v4.runtime.ANTLRErrorListener;
-import org.antlr.v4.runtime.Parser;
-import org.antlr.v4.runtime.RecognitionException;
-import org.antlr.v4.runtime.Recognizer;
-import org.antlr.v4.runtime.atn.ATNConfigSet;
-import org.antlr.v4.runtime.dfa.DFA;
-import org.apache.olingo.server.core.uri.antlr.UriLexer;
-
-class TestErrorLogger implements ANTLRErrorListener {
-
- private String prefix;
- private int logLevel = 0;
-
- public TestErrorLogger(final String prefix, final int logLevel) {
- this.prefix = prefix;
- this.logLevel = logLevel;
- }
-
- @Override
- public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line,
- final int charPositionInLine,
- final String msg, final RecognitionException e) {
-
- if (logLevel > 0) {
- System.out.println("\n" + prefix + " -- SyntaxError");
- trace(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
- }
-
- }
-
- @Override
- public void reportAmbiguity(final Parser recognizer, final DFA dfa, final int startIndex, final int stopIndex,
- final boolean exact,
- final BitSet ambigAlts, final ATNConfigSet configs) {
-
- }
-
- @Override
- public void reportAttemptingFullContext(final Parser recognizer, final DFA dfa, final int startIndex,
- final int stopIndex,
- final BitSet conflictingAlts, final ATNConfigSet configs) {
-
- }
-
- @Override
- public void reportContextSensitivity(final Parser recognizer, final DFA dfa, final int startIndex,
- final int stopIndex, final int prediction,
- final ATNConfigSet configs) {
-
- }
-
- private void printStack(final Recognizer<?, ?> recognizer) {
- List<String> stack = ((Parser) recognizer).getRuleInvocationStack();
- Collections.reverse(stack);
- System.out.println(" rule stack: " + stack);
- }
-
- public void trace(final Recognizer<?, ?> recognizer, final Object offendingSymbol,
- final int line, final int charPositionInLine, final String msg, final RecognitionException e) {
-
- System.out.println("Error message: " + msg);
-
- printStack(recognizer);
-
- System.out.println(" line/char :" + line + " / " + charPositionInLine);
- System.out.println(" sym :" + offendingSymbol);
- if (e != null && e.getOffendingToken() != null) {
-
- String lexerTokenName = "";
- try {
- lexerTokenName = UriLexer.tokenNames[e.getOffendingToken().getType()];
- } catch (ArrayIndexOutOfBoundsException es) {
- lexerTokenName = "token error";
- }
-
- System.out.println(" tokenname:" + lexerTokenName);
- }
-
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
deleted file mode 100644
index 35687f6..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
+++ /dev/null
@@ -1,258 +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 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.server.api.uri.UriInfoKind;
-import org.apache.olingo.server.api.uri.queryoption.CustomQueryOption;
-import org.apache.olingo.server.api.uri.queryoption.SelectItem;
-import org.apache.olingo.server.core.uri.UriInfoImpl;
-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.UriValidator;
-
-public class TestUriValidator implements TestValidator {
- private Edm edm;
-
- private UriInfoImpl uriInfo;
- private Exception exception;
-
- // Setup
- public TestUriValidator setEdm(final Edm edm) {
- this.edm = edm;
- return this;
- }
-
- // Execution
- public TestUriValidator run(final String uri) {
- Parser parser = new Parser();
- UriValidator validator = new UriValidator();
-
- uriInfo = null;
- try {
- uriInfo = (UriInfoImpl) parser.parseUri(uri, edm);
- validator.validate(uriInfo, "GET");
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- return this;
- }
-
- public TestUriValidator runEx(final String uri) {
- Parser parser = new Parser();
- uriInfo = null;
- try {
- uriInfo = (UriInfoImpl) parser.parseUri(uri, edm);
- fail("Exception expected");
- } catch (UriParserException e) {
- exception = e;
- }
-
- return this;
- }
-
- public TestUriValidator log(final String uri) {
- ParserWithLogging parserTest = new ParserWithLogging();
- parserTest.setLogLevel(1);
- uriInfo = null;
- try {
- // uriInfoTmp = new UriParserImpl(edm).ParseUri(uri);
- uriInfo = (UriInfoImpl) parserTest.parseUri(uri, edm);
- } catch (UriParserException e) {
- fail("Exception occured while parsing the URI: " + uri + "\n"
- + " Exception: " + e.getMessage());
- }
-
- return this;
- }
-
- // Navigation
- public ResourceValidator goPath() {
- if (uriInfo.getKind() != UriInfoKind.resource) {
- fail("invalid resource kind: " + uriInfo.getKind().toString());
- }
-
- return new ResourceValidator()
- .setUpValidator(this)
- .setEdm(edm)
- .setUriInfoImplPath(uriInfo);
- }
-
- public FilterValidator goFilter() {
- FilterOptionImpl filter = (FilterOptionImpl) uriInfo.getFilterOption();
- if (filter == null) {
- fail("no filter found");
- }
- return new FilterValidator().setUriValidator(this).setFilter(filter);
-
- }
-
- public ExpandValidator goExpand() {
- ExpandOptionImpl expand = (ExpandOptionImpl) uriInfo.getExpandOption();
- if (expand == null) {
- fail("invalid resource kind: " + uriInfo.getKind().toString());
- }
-
- return new ExpandValidator().setUpValidator(this).setExpand(expand);
- }
-
- public ResourceValidator goSelectItemPath(final int index) {
- SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
-
- SelectItem item = select.getSelectItems().get(index);
- UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourcePath();
-
- return new ResourceValidator()
- .setUpValidator(this)
- .setEdm(edm)
- .setUriInfoImplPath(uriInfo1);
-
- }
-
- public TestUriValidator isSelectStartType(final int index, final FullQualifiedName fullName) {
- SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
- SelectItem item = select.getSelectItems().get(index);
- EdmType actualType = item.getStartTypeFilter();
-
- FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
- assertEquals(fullName, actualName);
- return this;
-
- }
-
- // Validation
- public TestUriValidator isKind(final UriInfoKind kind) {
- assertEquals(kind, uriInfo.getKind());
- return this;
- }
-
- public TestUriValidator isCustomParameter(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 enought queryParameters");
- }
-
- CustomQueryOptionImpl option = (CustomQueryOptionImpl) list.get(index);
- assertEquals(name, option.getName());
- assertEquals(value, option.getText());
- return this;
- }
-
- public void isCrossJoinEntityList(final List<String> entitySets) {
- if (uriInfo.getKind() != UriInfoKind.crossjoin) {
- fail("invalid resource kind: " + uriInfo.getKind().toString());
- }
-
- int i = 0;
- for (String entitySet : entitySets) {
- assertEquals(entitySet, uriInfo.getEntitySetNames().get(i));
- i++;
- }
-
- }
-
- public TestUriValidator isExSyntax(final long errorID) {
- assertEquals(UriParserSyntaxException.class, exception.getClass());
- return this;
- }
-
- public TestUriValidator isExSemantic(final long errorID) {
- assertEquals(UriParserSemanticException.class, exception.getClass());
- return this;
- }
-
- public TestUriValidator isIdText(final String text) {
- assertEquals(text, uriInfo.getIdOption().getText());
- return this;
- }
-
- public TestUriValidator isExpandText(final String text) {
- assertEquals(text, uriInfo.getExpandOption().getText());
- return this;
- }
-
- public TestUriValidator isSelectText(final String text) {
- assertEquals(text, uriInfo.getSelectOption().getText());
- return this;
- }
-
- public TestUriValidator isFormatText(final String text) {
- assertEquals(text, uriInfo.getFormatOption().getText());
- return this;
- }
-
- public TestUriValidator isFragmentText(final String text) {
- if (uriInfo.getKind() != UriInfoKind.metadata) {
- fail("invalid resource kind: " + uriInfo.getKind().toString());
- }
-
- assertEquals(text, uriInfo.getFragment());
-
- return this;
- }
-
- public TestUriValidator isEntityType(final FullQualifiedName fullName) {
- if (uriInfo.getKind() != UriInfoKind.entityId) {
- fail("invalid resource kind: " + uriInfo.getKind().toString());
- }
-
- assertEquals(fullName.toString(), fullName(uriInfo.getEntityTypeCast()));
- return this;
- }
-
- private String fullName(final EdmEntityType type) {
- return type.getNamespace() + "." + type.getName();
- }
-
- public TestUriValidator isSelectItemStar(final int index) {
- SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
-
- SelectItem item = select.getSelectItems().get(index);
- assertEquals(true, item.isStar());
- return this;
- }
-
- public TestUriValidator isSelectItemAllOp(final int index, final FullQualifiedName fqn) {
- SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
-
- SelectItem item = select.getSelectItems().get(index);
- assertEquals(fqn.toString(), item.getAllOperationsInSchemaNameSpace().toString());
- return this;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestValidator.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestValidator.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestValidator.java
deleted file mode 100644
index 7e64f86..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestValidator.java
+++ /dev/null
@@ -1,23 +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;
-
-public interface TestValidator {
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TokenValidator.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TokenValidator.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TokenValidator.java
deleted file mode 100644
index 4a94bb3..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TokenValidator.java
+++ /dev/null
@@ -1,194 +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.List;
-
-import org.antlr.v4.runtime.ANTLRInputStream;
-import org.antlr.v4.runtime.Token;
-import org.apache.olingo.server.core.uri.antlr.UriLexer;
-
-//TODO extend to test also exception which can occure while paring
-public class TokenValidator {
-
- private String input = null;
-
- private List<? extends Token> tokens = null;
- private Token curToken = null;
- private Exception curException = null;
-
- private int startMode;
- private int logLevel = 0;
-
- // --- Setup ---
-
- public TokenValidator log(final int logLevel) {
- this.logLevel = logLevel;
- return this;
- }
-
- // --- Execution ---
-
- public TokenValidator run(final String uri) {
- input = uri;
-
- tokens = parseInput(uri);
- if (logLevel > 0) {
- showTokens();
- }
-
- first();
- exFirst();
- logLevel = 0;
-
- return this;
- }
-
- // --- Navigation ---
-
- // navigate within the tokenlist
- public TokenValidator first() {
- try {
- curToken = tokens.get(0);
- } catch (IndexOutOfBoundsException ex) {
- curToken = null;
- }
- return this;
- }
-
- public TokenValidator last() {
- curToken = tokens.get(tokens.size() - 1);
- return this;
- }
-
- public TokenValidator at(final int index) {
- try {
- curToken = tokens.get(index);
- } catch (IndexOutOfBoundsException ex) {
- curToken = null;
- }
- return this;
- }
-
- public TokenValidator exLast() {
- // curException = exceptions.get(exceptions.size() - 1);
- return this;
- }
-
- // navigate within the exception list
- public TokenValidator exFirst() {
- try {
- // curException = exceptions.get(0);
- } catch (IndexOutOfBoundsException ex) {
- curException = null;
- }
- return this;
-
- }
-
- public TokenValidator exAt(final int index) {
- try {
- // curException = exceptions.get(index);
- } catch (IndexOutOfBoundsException ex) {
- curException = null;
- }
- return this;
- }
-
- // --- Validation ---
-
- public TokenValidator isText(final String expected) {
- assertEquals(expected, curToken.getText());
- return this;
- }
-
- public TokenValidator isAllText(final String expected) {
- String actual = "";
-
- for (Token curToken : tokens) {
- actual += curToken.getText();
- }
- assertEquals(expected, actual);
- return this;
- }
-
- public TokenValidator isAllInput() {
- String actual = "";
-
- for (Token curToken : tokens) {
- actual += curToken.getText();
- }
- assertEquals(input, actual);
- return this;
- }
-
- public TokenValidator isInput() {
- assertEquals(input, curToken.getText());
- return this;
- }
-
- public TokenValidator isType(final int expected) {
- assertEquals(UriLexer.tokenNames[expected], UriLexer.tokenNames[curToken.getType()]);
- return this;
- }
-
- public TokenValidator isExType(final Class<?> exClass) {
- assertEquals(exClass, curException.getClass());
- return this;
- }
-
- public void globalMode(final int mode) {
- startMode = mode;
- }
-
- // --- Helper ---
-
- private List<? extends Token> parseInput(final String input) {
- ANTLRInputStream inputStream = new ANTLRInputStream(input);
-
- UriLexer lexer = new UriLexerWithTrace(inputStream, logLevel, startMode);
- // lexer.addErrorListener(new ErrorCollector(this));
- return lexer.getAllTokens();
- }
-
- public TokenValidator showTokens() {
- boolean first = true;
- System.out.println("input: " + input);
- String nL = "\n";
- String out = "[" + nL;
- for (Token token : tokens) {
- if (!first) {
- out += ",";
- first = false;
- }
- int index = token.getType();
- if (index != -1) {
- out += "\"" + token.getText() + "\"" + " " + UriLexer.tokenNames[index] + nL;
- } else {
- out += "\"" + token.getText() + "\"" + " " + index + nL;
- }
- }
- out += ']';
- System.out.println("tokens: " + out);
- return this;
- }
-
-}
[11/15] [OLINGO-266] refactor ref module to server-ref
Posted by sk...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java
deleted file mode 100644
index e8aa9ce..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java
+++ /dev/null
@@ -1,248 +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.antlr;
-
-import org.antlr.v4.runtime.Lexer;
-import org.apache.olingo.server.core.uri.testutil.TokenValidator;
-import org.junit.Test;
-
-public class TestLexer {
-
- private TokenValidator test = null;
-
- private static final String cPCT_ENCODED = "%45%46%47" + "%22" + "%5C";// last two chars are not in
- // cPCT_ENCODED_UNESCAPED
- private static final String cUNRESERVED = "ABCabc123-._~";
- private static final String cOTHER_DELIMS = "!()*+,;";
- private static final String cSUB_DELIMS = "$&'=" + cOTHER_DELIMS;
-
- private static final String cPCHAR = cUNRESERVED + cPCT_ENCODED + cSUB_DELIMS + ":@";
-
- public TestLexer() {
- test = new TokenValidator();
- }
-
- @Test
- public void test() {
-
- // test.log(1).run("ESAllPrim?$orderby=PropertyDouble eq 3.5E+38");
- }
-
- // ;------------------------------------------------------------------------------
- // ; 0. URI
- // ;------------------------------------------------------------------------------
-
- @Test
- public void testUriTokens() {
- test.globalMode(UriLexer.MODE_QUERY);
- test.run("#").isText("#").isType(UriLexer.FRAGMENT);
- test.run("$count").isText("$count").isType(UriLexer.COUNT);
- test.run("$ref").isText("$ref").isType(UriLexer.REF);
- test.run("$value").isText("$value").isType(UriLexer.VALUE);
- }
-
- // ;------------------------------------------------------------------------------
- // ; 2. Query Options
- // ;------------------------------------------------------------------------------
- @Test
- public void testQueryOptionsTokens() {
-
- test.globalMode(UriLexer.MODE_QUERY);
- test.run("$skip=1").isAllText("$skip=1").isType(UriLexer.SKIP);
- test.run("$skip=2").isAllText("$skip=2").isType(UriLexer.SKIP);
- test.run("$skip=123").isAllText("$skip=123").isType(UriLexer.SKIP);
-
- test.run("$top=1").isAllText("$top=1").isType(UriLexer.TOP);
- test.run("$top=2").isAllText("$top=2").isType(UriLexer.TOP);
- test.run("$top=123").isAllText("$top=123").isType(UriLexer.TOP);
-
- test.run("$levels=1").isAllText("$levels=1").isType(UriLexer.LEVELS);
- test.run("$levels=2").isAllText("$levels=2").isType(UriLexer.LEVELS);
- test.run("$levels=123").isAllText("$levels=123").isType(UriLexer.LEVELS);
- test.run("$levels=max").isAllText("$levels=max").isType(UriLexer.LEVELS);
-
- test.run("$format=atom").isAllText("$format=atom").isType(UriLexer.FORMAT);
- test.run("$format=json").isAllText("$format=json").isType(UriLexer.FORMAT);
- test.run("$format=xml").isAllText("$format=xml").isType(UriLexer.FORMAT);
- test.run("$format=abc/def").isAllText("$format=abc/def").isType(UriLexer.FORMAT);
-
- test.run("$id=123").isAllText("$id=123").isType(UriLexer.ID);
- test.run("$id=ABC").isAllText("$id=ABC").isType(UriLexer.ID);
-
- test.run("$skiptoken=ABC").isAllText("$skiptoken=ABC").isType(UriLexer.SKIPTOKEN);
- test.run("$skiptoken=ABC").isAllText("$skiptoken=ABC").isType(UriLexer.SKIPTOKEN);
-
- test.run("$search=\"ABC\"").isAllText("$search=\"ABC\"").isType(UriLexer.SEARCH);
- test.run("$search=ABC").isAllText("$search=ABC").isType(UriLexer.SEARCH);
- test.run("$search=\"A%20B%20C\"").isAllText("$search=\"A%20B%20C\"").isType(UriLexer.SEARCH);
- }
-
- // ;------------------------------------------------------------------------------
- // ; 4. Expressions
- // ;------------------------------------------------------------------------------
- @Test
- public void testQueryExpressions() {
- test.globalMode(Lexer.DEFAULT_MODE);
-
- test.run("$it").isText("$it").isType(UriLexer.IT);
-
- test.run("$filter=contains(").at(2).isText("contains(").isType(UriLexer.CONTAINS_WORD);
-
- test.run("$filter=containsabc").at(2).isText("containsabc")
- .isType(UriLexer.ODATAIDENTIFIER); // test that this is a ODI
-
- test.run("$filter=startswith(").at(2).isText("startswith(").isType(UriLexer.STARTSWITH_WORD);
- test.run("$filter=endswith(").at(2).isText("endswith(").isType(UriLexer.ENDSWITH_WORD);
- test.run("$filter=length(").at(2).isText("length(").isType(UriLexer.LENGTH_WORD);
- test.run("$filter=indexof(").at(2).isText("indexof(").isType(UriLexer.INDEXOF_WORD);
- test.run("$filter=substring(").at(2).isText("substring(").isType(UriLexer.SUBSTRING_WORD);
- test.run("$filter=tolower(").at(2).isText("tolower(").isType(UriLexer.TOLOWER_WORD);
- test.run("$filter=toupper(").at(2).isText("toupper(").isType(UriLexer.TOUPPER_WORD);
- test.run("$filter=trim(").at(2).isText("trim(").isType(UriLexer.TRIM_WORD);
- test.run("$filter=concat(").at(2).isText("concat(").isType(UriLexer.CONCAT_WORD);
-
- }
-
- // ;------------------------------------------------------------------------------
- // ; 7. Literal Data Values
- // ;------------------------------------------------------------------------------
-
- @Test
- public void testLiteralDataValues() {
- test.globalMode(Lexer.DEFAULT_MODE);
- // null
- test.run("null").isInput().isType(UriLexer.NULLVALUE);
-
- // binary
- test.run("binary'ABCD'").isInput().isType(UriLexer.BINARY);
- test.run("BiNaRy'ABCD'").isInput().isType(UriLexer.BINARY);
-
- // boolean
- test.run("true").isInput().isType(UriLexer.TRUE);
- test.run("false").isInput().isType(UriLexer.FALSE);
- test.run("TrUe").isInput().isType(UriLexer.BOOLEAN);
- test.run("FaLsE").isInput().isType(UriLexer.BOOLEAN);
-
- // Lexer rule INT
- test.run("123").isInput().isType(UriLexer.INT);
- test.run("123456789").isInput().isType(UriLexer.INT);
- test.run("+123").isInput().isType(UriLexer.INT);
- test.run("+123456789").isInput().isType(UriLexer.INT);
- test.run("-123").isInput().isType(UriLexer.INT);
- test.run("-123456789").isInput().isType(UriLexer.INT);
-
- // Lexer rule DECIMAL
- test.run("0.1").isInput().isType(UriLexer.DECIMAL);
- test.run("1.1").isInput().isType(UriLexer.DECIMAL);
- test.run("+0.1").isInput().isType(UriLexer.DECIMAL);
- test.run("+1.1").isInput().isType(UriLexer.DECIMAL);
- test.run("-0.1").isInput().isType(UriLexer.DECIMAL);
- test.run("-1.1").isInput().isType(UriLexer.DECIMAL);
-
- // Lexer rule EXP
- test.run("1.1e+1").isInput().isType(UriLexer.DECIMAL);
- test.run("1.1e-1").isInput().isType(UriLexer.DECIMAL);
-
- test.run("NaN").isInput().isType(UriLexer.NANINFINITY);
- test.run("-INF").isInput().isType(UriLexer.NANINFINITY);
- test.run("INF").isInput().isType(UriLexer.NANINFINITY);
-
- // Lexer rule GUID
- test.run("1234ABCD-12AB-23CD-45EF-123456780ABC").isInput().isType(UriLexer.GUID);
- test.run("1234ABCD-12AB-23CD-45EF-123456780ABC").isInput().isType(UriLexer.GUID);
-
- // Lexer rule DATE
- test.run("2013-11-15").isInput().isType(UriLexer.DATE);
-
- // Lexer rule DATETIMEOFFSET
- test.run("2013-11-15T13:35Z").isInput().isType(UriLexer.DATETIMEOFFSET);
- test.run("2013-11-15T13:35:10Z").isInput().isType(UriLexer.DATETIMEOFFSET);
- test.run("2013-11-15T13:35:10.1234Z").isInput().isType(UriLexer.DATETIMEOFFSET);
-
- test.run("2013-11-15T13:35:10.1234+01:30").isInput().isType(UriLexer.DATETIMEOFFSET);
- test.run("2013-11-15T13:35:10.1234-01:12").isInput().isType(UriLexer.DATETIMEOFFSET);
-
- test.run("2013-11-15T13:35Z").isInput().isType(UriLexer.DATETIMEOFFSET);
-
- // Lexer rule DURATION
- test.run("duration'PT67S'").isInput().isType(UriLexer.DURATION);
- test.run("duration'PT67.89S'").isInput().isType(UriLexer.DURATION);
-
- test.run("duration'PT5M'").isInput().isType(UriLexer.DURATION);
- test.run("duration'PT5M67S'").isInput().isType(UriLexer.DURATION);
- test.run("duration'PT5M67.89S'").isInput().isType(UriLexer.DURATION);
-
- test.run("duration'PT4H'").isInput().isType(UriLexer.DURATION);
- test.run("duration'PT4H67S'").isInput().isType(UriLexer.DURATION);
- test.run("duration'PT4H67.89S'").isInput().isType(UriLexer.DURATION);
- test.run("duration'PT4H5M'").isInput().isType(UriLexer.DURATION);
- test.run("duration'PT4H5M67S'").isInput().isType(UriLexer.DURATION);
- test.run("duration'PT4H5M67.89S'").isInput().isType(UriLexer.DURATION);
-
- test.run("duration'P3D'");
- test.run("duration'P3DT67S'").isInput().isType(UriLexer.DURATION);
- test.run("duration'P3DT67.89S'").isInput().isType(UriLexer.DURATION);
- test.run("duration'P3DT5M'").isInput().isType(UriLexer.DURATION);
- test.run("duration'P3DT5M67S'").isInput().isType(UriLexer.DURATION);
- test.run("duration'P3DT5M67.89S'").isInput().isType(UriLexer.DURATION);
- test.run("duration'P3DT4H'").isInput().isType(UriLexer.DURATION);
- test.run("duration'P3DT4H67S'").isInput().isType(UriLexer.DURATION);
- test.run("duration'P3DT4H67.89S'").isInput().isType(UriLexer.DURATION);
- test.run("duration'P3DT4H5M'").isInput().isType(UriLexer.DURATION);
- test.run("duration'P3DT4H5M67S'").isInput().isType(UriLexer.DURATION);
- test.run("duration'P3DT4H5M67.89S'").isInput().isType(UriLexer.DURATION);
-
- test.run("DuRaTiOn'P3DT4H5M67.89S'").isInput().isType(UriLexer.DURATION);
- test.run("DuRaTiOn'-P3DT4H5M67.89S'").isInput().isType(UriLexer.DURATION);
-
- test.run("20:00").isInput().isType(UriLexer.TIMEOFDAY);
- test.run("20:15:01").isInput().isType(UriLexer.TIMEOFDAY);
- test.run("20:15:01.02").isInput().isType(UriLexer.TIMEOFDAY);
-
- test.run("20:15:01.02").isInput().isType(UriLexer.TIMEOFDAY);
-
- // String
- test.run("'ABC'").isText("'ABC'").isType(UriLexer.STRING);
- test.run("'A%20C'").isInput().isType(UriLexer.STRING);
- test.run("'%20%20%20ABC'").isInput().isType(UriLexer.STRING);
-
- }
-
- @Test
- public void testDelims() {
- String reserved = "/";
- test.globalMode(UriLexer.MODE_QUERY);
- // Test lexer rule UNRESERVED
- test.run("$format=A/" + cUNRESERVED).isAllInput().isType(UriLexer.FORMAT);
- test.run("$format=A/" + cUNRESERVED + reserved).isType(UriLexer.FORMAT).at(4).isText(cUNRESERVED);
- // Test lexer rule PCT_ENCODED
- test.run("$format=A/" + cPCT_ENCODED).isAllInput().isType(UriLexer.FORMAT);
- test.run("$format=A/" + cPCT_ENCODED + reserved).isType(UriLexer.FORMAT).at(4).isText(cPCT_ENCODED);
- // Test lexer rule SUB_DELIMS
- test.run("$format=A/" + cSUB_DELIMS).isAllInput().isType(UriLexer.FORMAT);
- test.run("$format=A/" + cSUB_DELIMS + reserved).isType(UriLexer.FORMAT).at(4).isText("$");
- // Test lexer rule PCHAR rest
- test.run("$format=A/:@").isAllText("$format=A/:@").isType(UriLexer.FORMAT);
- test.run("$format=A/:@" + reserved).isType(UriLexer.FORMAT).at(4).isText(":@");
- // Test lexer rule PCHAR all
- test.run("$format=" + cPCHAR + "/" + cPCHAR).isAllInput().isType(UriLexer.FORMAT);
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
deleted file mode 100644
index 9a05cfb..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
+++ /dev/null
@@ -1,1144 +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.antlr;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.Arrays;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-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.edm.provider.EdmProviderImpl;
-import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
-import org.apache.olingo.server.core.testutil.techprovider.ComplexTypeProvider;
-import org.apache.olingo.server.core.testutil.techprovider.EntityTypeProvider;
-import org.apache.olingo.server.core.testutil.techprovider.PropertyProvider;
-import org.apache.olingo.server.core.uri.parser.UriParserException;
-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;
-import org.junit.Test;
-
-public class TestUriParserImpl {
- Edm edm = null;
- 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";
- private final String PropertyDuration = "PropertyDuration=duration'P10DT5H34M21.123456789012S'";
- private final String PropertyGuid = "PropertyGuid=12345678-1234-1234-1234-123456789012";
- private final String PropertyInt16 = "PropertyInt16=1";
- private final String PropertyInt32 = "PropertyInt32=12";
- private final String PropertyInt64 = "PropertyInt64=64";
- private final String PropertySByte = "PropertySByte=1";
- private final String PropertyString = "PropertyString='ABC'";
- private final String PropertyTimeOfDay = "PropertyTimeOfDay=12:34:55.123456789012";
-
- private final String allKeys = PropertyString + "," + PropertyInt16 + "," + PropertyBoolean + "," + PropertyByte
- + "," + 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 test() throws UriParserException, UnsupportedEncodingException {
-
- }
-
- @Test
- public void testBoundFunctionImport_VarParameters() {
-
- // no input
- testRes.run("ESKeyNav(1)/com.sap.odata.test1.BFCETKeyNavRTETKeyNav()")
- .at(0).isUriPathInfoKind(UriResourceKind.entitySet)
- .at(1).isUriPathInfoKind(UriResourceKind.function);
-
- // one input
- testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav(ParameterString='ABC')")
- .at(0).isUriPathInfoKind(UriResourceKind.entitySet)
- .at(1).isUriPathInfoKind(UriResourceKind.function)
- .isParameter(0, "ParameterString", "'ABC'");
-
- // two input
- testRes.run("FICRTESMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='2')")
- .at(0)
- .isUriPathInfoKind(UriResourceKind.function)
- .isParameter(0, "ParameterInt16", "1")
- .isParameter(1, "ParameterString", "'2'");
- }
-
- @Test
- public void testFunctionBound_varReturnType() {
-
- String esTwoKeyNav = "ESTwoKeyNav(PropertyInt16=1,PropertyString='ABC')";
-
- // returning primitive
- testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTString()")
- .at(0)
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETTwoKeyNav, true)
- .at(1)
- .isUriPathInfoKind(UriResourceKind.function)
- .isType(PropertyProvider.nameString, false);
-
- // returning collection of primitive
- testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCollString()")
- .at(0)
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETTwoKeyNav, true)
- .at(1)
- .isUriPathInfoKind(UriResourceKind.function)
- .isType(PropertyProvider.nameString, true);
-
- // returning single complex
- testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCTTwoPrim()")
- .at(0)
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETTwoKeyNav, true)
- .at(1)
- .isUriPathInfoKind(UriResourceKind.function)
- .isType(ComplexTypeProvider.nameCTTwoPrim, false);
-
- // returning collection of complex
- testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCollCTTwoPrim()")
- .at(0)
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETTwoKeyNav, true)
- .at(1)
- .isUriPathInfoKind(UriResourceKind.function)
- .isType(ComplexTypeProvider.nameCTTwoPrim, true);
-
- // returning single entity
- testRes.run(
- esTwoKeyNav + "/com.sap.odata.test1.ETBaseTwoKeyNav/com.sap.odata.test1.BFCETBaseTwoKeyNavRTETTwoKeyNav()")
- .at(0)
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
- .at(1)
- .isUriPathInfoKind(UriResourceKind.function)
- .isType(EntityTypeProvider.nameETTwoKeyNav, false);
-
- // returning collection of entity (aka entitySet)
- testRes.run(esTwoKeyNav + "/com.sap.odata.test1.BFCSINavRTESTwoKeyNav()")
- .at(0)
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .at(1)
- .isUriPathInfoKind(UriResourceKind.function)
- .isType(EntityTypeProvider.nameETTwoKeyNav, true);
- }
-
- @Test
- public void runActionImport_VarReturnType() {
-
- testRes.run("AIRTPrimParam").isKind(UriInfoKind.resource)
- .first()
- .isActionImport("AIRTPrimParam")
- .isAction("UARTPrimParam")
- .isType(PropertyProvider.nameString, false);
-
- testRes.run("AIRTPrimCollParam").isKind(UriInfoKind.resource)
- .first()
- .isActionImport("AIRTPrimCollParam")
- .isAction("UARTPrimCollParam")
- .isType(PropertyProvider.nameString, true);
-
- testRes.run("AIRTCompParam").isKind(UriInfoKind.resource)
- .first()
- .isActionImport("AIRTCompParam")
- .isAction("UARTCompParam")
- .isType(ComplexTypeProvider.nameCTTwoPrim, false);
-
- testRes.run("AIRTCompCollParam").isKind(UriInfoKind.resource)
- .first()
- .isActionImport("AIRTCompCollParam")
- .isAction("UARTCompCollParam")
- .isType(ComplexTypeProvider.nameCTTwoPrim, true);
-
- testRes.run("AIRTETParam").isKind(UriInfoKind.resource)
- .first()
- .isActionImport("AIRTETParam")
- .isAction("UARTETParam")
- .isType(EntityTypeProvider.nameETTwoKeyTwoPrim, false);
-
- testUri.runEx("AIRTPrimParam/invalidElement").isExSemantic(0);
- }
-
- @Test
- public void runCount() {
-
- // count entity set
- testRes.run("ESAllPrim/$count")
- .at(0)
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETAllPrim, true)
- .at(1)
- .isUriPathInfoKind(UriResourceKind.count);
-
- // count on collection of complex
- testRes.run("ESKeyNav(1)/CollPropertyComplex/$count")
- .at(0)
- .isType(EntityTypeProvider.nameETKeyNav)
- .at(1)
- .isType(ComplexTypeProvider.nameCTPrimComp, true)
- .at(2)
- .isUriPathInfoKind(UriResourceKind.count);
-
- // count on collection of primitive
- testRes.run("ESCollAllPrim(1)/CollPropertyString/$count")
- .at(1)
- .isType(PropertyProvider.nameString, true)
- .at(2)
- .isUriPathInfoKind(UriResourceKind.count);
- }
-
- @Test
- public void runCrossJoin() {
- testUri.run("$crossjoin(ESAllKey)")
- .isKind(UriInfoKind.crossjoin)
- .isCrossJoinEntityList(Arrays.asList("ESAllKey"));
-
- testUri.run("$crossjoin(ESAllKey,ESTwoPrim)")
- .isKind(UriInfoKind.crossjoin)
- .isCrossJoinEntityList(Arrays.asList("ESAllKey", "ESTwoPrim"));
- }
-
- @Test(expected = Exception.class)
- public void testEntityFailOnValidation1() {
- // simple entity set; with qualifiedentityTypeName; with filter
- testUri.run("$entity/com.sap.odata.test1.ETTwoPrim?$filter=PropertyInt16 eq 123&$id=ESAllKey")
- .isIdText("ESAllKey")
- .goFilter().is("<<PropertyInt16> eq <123>>");
- }
-
- @Test(expected = Exception.class)
- public void testEntityFailOnValidation2() {
- // simple entity set; with qualifiedentityTypeName; with 2xformat(before and after), expand, filter
- testUri.run("$entity/com.sap.odata.test1.ETTwoPrim?"
- + "$format=xml&$expand=*&abc=123&$id=ESBase&xyz=987&$filter=PropertyInt16 eq 123&$format=atom&$select=*")
- .isFormatText("atom")
- .isCustomParameter(0, "abc", "123")
- .isIdText("ESBase")
- .isCustomParameter(1, "xyz", "987")
- .isSelectItemStar(0);
- }
-
- @Test
- public void testEntity() {
-
- // simple entity set
- testUri.run("$entity?$id=ESAllPrim").isKind(UriInfoKind.entityId)
- .isKind(UriInfoKind.entityId)
- .isIdText("ESAllPrim");
-
- // simple entity set; $format before $id
- testUri.run("$entity?$format=xml&$id=ETAllPrim").isKind(UriInfoKind.entityId)
- .isFormatText("xml")
- .isIdText("ETAllPrim");
-
- testUri.run("$entity?$format=xml&abc=123&$id=ESAllKey").isKind(UriInfoKind.entityId)
- .isFormatText("xml")
- .isCustomParameter(0, "abc", "123")
- .isIdText("ESAllKey");
-
- // simple entity set; $format after $id
- testUri.run("$entity?$id=ETAllPrim&$format=xml").isKind(UriInfoKind.entityId)
- .isIdText("ETAllPrim")
- .isFormatText("xml");
-
- // simple entity set; $format and custom parameter after $id
- testUri.run("$entity?$id=ETAllPrim&$format=xml&abc=123").isKind(UriInfoKind.entityId)
- .isIdText("ETAllPrim")
- .isFormatText("xml")
- .isCustomParameter(0, "abc", "123");
-
- // simple entity set; $format before $id and custom parameter after $id
- testUri.run("$entity?$format=xml&$id=ETAllPrim&abc=123").isKind(UriInfoKind.entityId)
- .isFormatText("xml")
- .isIdText("ETAllPrim")
- .isCustomParameter(0, "abc", "123");
-
- // simple entity set; with qualifiedentityTypeName
- testUri.run("$entity/com.sap.odata.test1.ETTwoPrim?$id=ESBase")
- .isEntityType(EntityTypeProvider.nameETTwoPrim)
- .isIdText("ESBase");
-
- // simple entity set; with qualifiedentityTypeName;
- testUri.run("$entity/com.sap.odata.test1.ETBase?$id=ESTwoPrim")
- .isEntityType(EntityTypeProvider.nameETBase)
- .isKind(UriInfoKind.entityId)
- .isIdText("ESTwoPrim");
-
- // simple entity set; with qualifiedentityTypeName; with format
- testUri.run("$entity/com.sap.odata.test1.ETBase?$id=ESTwoPrim&$format=atom")
- .isKind(UriInfoKind.entityId)
- .isEntityType(EntityTypeProvider.nameETBase)
- .isIdText("ESTwoPrim")
- .isFormatText("atom");
-
- // simple entity set; with qualifiedentityTypeName; with select
- testUri.run("$entity/com.sap.odata.test1.ETBase?$id=ESTwoPrim&$select=*")
- .isKind(UriInfoKind.entityId)
- .isEntityType(EntityTypeProvider.nameETBase)
- .isIdText("ESTwoPrim")
- .isSelectItemStar(0);
-
- // simple entity set; with qualifiedentityTypeName; with expand
- testUri.run("$entity/com.sap.odata.test1.ETBase?$id=ESTwoPrim&$expand=*")
- .isKind(UriInfoKind.entityId)
- .isEntityType(EntityTypeProvider.nameETBase)
- .isIdText("ESTwoPrim")
- .isExpandText("*")
- .goExpand().first().isSegmentStar(0);
-
- }
-
- @Test
- public void testEntitySet() throws UnsupportedEncodingException {
-
- // plain entity set
- testRes.run("ESAllPrim")
- .isEntitySet("ESAllPrim")
- .isType(EntityTypeProvider.nameETAllPrim);
-
- // with one key; simple key notation
- testRes.run("ESAllPrim(1)")
- .isEntitySet("ESAllPrim")
- .isType(EntityTypeProvider.nameETAllPrim)
- .isKeyPredicate(0, "PropertyInt16", "1");
-
- // with one key; name value key notation
- testRes.run("ESAllPrim(PropertyInt16=1)")
- .isEntitySet("ESAllPrim")
- .isKeyPredicate(0, "PropertyInt16", "1");
-
- // with two keys
- testRes.run("ESTwoKeyTwoPrim(PropertyInt16=1, PropertyString='ABC')")
- .isEntitySet("ESTwoKeyTwoPrim")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'ABC'");
-
- // with all keys
- testRes.run("ESAllKey(" + encode(allKeys) + ")")
- .isEntitySet("ESAllKey")
- .isKeyPredicate(0, "PropertyString", "'ABC'")
- .isKeyPredicate(1, "PropertyInt16", "1")
- .isKeyPredicate(2, "PropertyBoolean", "true")
- .isKeyPredicate(3, "PropertyByte", "1")
- .isKeyPredicate(4, "PropertySByte", "1")
- .isKeyPredicate(5, "PropertyInt32", "12")
- .isKeyPredicate(6, "PropertyInt64", "64")
- .isKeyPredicate(7, "PropertyDecimal", "12")
- .isKeyPredicate(8, "PropertyDate", "2013-09-25")
- .isKeyPredicate(9, "PropertyDateTimeOffset", "2002-10-10T12:00:00-05:00")
- .isKeyPredicate(10, "PropertyDuration", "duration'P10DT5H34M21.123456789012S'")
- .isKeyPredicate(11, "PropertyGuid", "12345678-1234-1234-1234-123456789012")
- .isKeyPredicate(12, "PropertyTimeOfDay", "12:34:55.123456789012");
- }
-
- @Test
- public void testEntitySet_NavigationPropperty() {
-
- // plain entity set ...
-
- // with navigation property
- testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne")
- .at(0)
- .isEntitySet("ESKeyNav")
- .isType(EntityTypeProvider.nameETKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .at(1)
- .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
- .isType(EntityTypeProvider.nameETTwoKeyNav);
-
- // with navigation property -> property
- testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne/PropertyString")
- .at(0)
- .isEntitySet("ESKeyNav")
- .isType(EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .at(1)
- .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
- .at(2)
- .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
-
- // with navigation property -> navigation property -> navigation property
- testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne/NavPropertyETKeyNavOne")
- .at(0)
- .isEntitySet("ESKeyNav")
- .isType(EntityTypeProvider.nameETKeyNav)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .at(1)
- .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .at(2)
- .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false)
- .isType(EntityTypeProvider.nameETKeyNav);
-
- // with navigation property(key)
- testRes.run("ESKeyNav(1)/NavPropertyETKeyNavMany(1)")
- .at(0)
- .isEntitySet("ESKeyNav")
- .at(1)
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1");
-
- // with navigation property(key) -> property
- testRes.run("ESKeyNav(1)/NavPropertyETKeyNavMany(1)/PropertyString").at(0)
- .at(0)
- .isEntitySet("ESKeyNav")
- .at(1)
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .at(2)
- .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
-
- // with navigation property(key) -> navigation property
- testRes.run("ESKeyNav(1)/NavPropertyETKeyNavMany(1)/NavPropertyETKeyNavOne")
- .isEntitySet("ESKeyNav")
- .at(1)
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .at(2)
- .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false);
-
- // with navigation property(key) -> navigation property(key)
- testRes.run("ESKeyNav(1)/NavPropertyETKeyNavMany(1)/NavPropertyETKeyNavMany(1)")
- .isEntitySet("ESKeyNav")
- .isType(EntityTypeProvider.nameETKeyNav)
- .at(1)
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .at(2)
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1");
-
- // with navigation property(key) -> navigation property -> property
- testRes.run("ESKeyNav(1)/NavPropertyETKeyNavMany(1)/NavPropertyETKeyNavOne/PropertyString")
- .at(0)
- .isEntitySet("ESKeyNav")
- .isType(EntityTypeProvider.nameETKeyNav)
- .at(1)
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .at(2)
- .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false)
- .isType(EntityTypeProvider.nameETKeyNav)
- .at(3)
- .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
-
- // with navigation property(key) -> navigation property(key) -> property
- testRes.run("ESKeyNav(1)/NavPropertyETKeyNavMany(1)/NavPropertyETKeyNavMany(1)/PropertyString")
- .at(0)
- .isEntitySet("ESKeyNav")
- .isType(EntityTypeProvider.nameETKeyNav)
- .at(1)
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .at(2)
- .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .at(3)
- .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
-
- }
-
- @Test
- public void testEntitySet_Property() {
-
- // plain entity set ...
-
- // with property
- testRes.run("ESAllPrim(1)/PropertyString")
- .at(0)
- .isEntitySet("ESAllPrim")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .at(1)
- .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
-
- // with complex property
- testRes.run("ESCompAllPrim(1)/PropertyComplex")
- .at(0)
- .isEntitySet("ESCompAllPrim")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .at(1)
- .isComplexProperty("PropertyComplex", ComplexTypeProvider.nameCTAllPrim, false);
-
- // with two properties
- testRes.run("ESCompAllPrim(1)/PropertyComplex/PropertyString")
- .at(0)
- .isEntitySet("ESCompAllPrim")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .at(1)
- .isComplexProperty("PropertyComplex", ComplexTypeProvider.nameCTAllPrim, false)
- .at(2)
- .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
- }
-
- @Test
- public void testEntitySet_TypeFilter() {
-
- // filter
- testRes.run("ESTwoPrim/com.sap.odata.test1.ETBase")
- .at(0)
- .isEntitySet("ESTwoPrim")
- .isType(EntityTypeProvider.nameETTwoPrim, true)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBase)
- .isTypeFilterOnEntry(null);
-
- // filter before key predicate
- testRes.run("ESTwoPrim/com.sap.odata.test1.ETBase(PropertyInt16=1)")
- .at(0)
- .isEntitySet("ESTwoPrim")
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETTwoPrim)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBase)
- .isTypeFilterOnEntry(null)
- .at(0)
- .isType(EntityTypeProvider.nameETTwoPrim, false)
- .isKeyPredicate(0, "PropertyInt16", "1");
-
- // filter before key predicate; property of sub type
- testRes.run("ESTwoPrim/com.sap.odata.test1.ETBase(PropertyInt16=1)/AdditionalPropertyString_5")
- .at(0)
- .isEntitySet("ESTwoPrim")
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETTwoPrim)
- .isTypeFilterOnCollection(EntityTypeProvider.nameETBase)
- .isTypeFilterOnEntry(null)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .at(1)
- .isType(PropertyProvider.nameString)
- .isPrimitiveProperty("AdditionalPropertyString_5", PropertyProvider.nameString, false);
-
- // filter after key predicate
- testRes.run("ESTwoPrim(PropertyInt16=1)/com.sap.odata.test1.ETBase")
- .at(0)
- .isEntitySet("ESTwoPrim")
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETTwoPrim, false)
- .isTypeFilterOnCollection(null)
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBase)
- .isKeyPredicate(0, "PropertyInt16", "1");
-
- // filter after key predicate; property of sub type
- testRes.run("ESTwoPrim(PropertyInt16=1)/com.sap.odata.test1.ETBase/AdditionalPropertyString_5")
- .at(0)
- .isEntitySet("ESTwoPrim")
- .isUriPathInfoKind(UriResourceKind.entitySet)
- .isType(EntityTypeProvider.nameETTwoPrim)
- .isTypeFilterOnCollection(null)
- .isTypeFilterOnEntry(EntityTypeProvider.nameETBase)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .at(1)
- .isPrimitiveProperty("AdditionalPropertyString_5", PropertyProvider.nameString, false)
- .isType(PropertyProvider.nameString);
-
- }
-
- @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>>>>");
- }
-
- @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>>");
-
- }
-
- @Test
- public void testFunctionImport_VarParameters() {
-
- // no input
- testRes.run("FINRTInt16()")
- .isFunctionImport("FINRTInt16")
- .isFunction("UFNRTInt16")
- .isType(PropertyProvider.nameInt16);
-
- // one input
- testRes.run("FICRTETTwoKeyNavParam(ParameterInt16=1)")
- .isFunctionImport("FICRTETTwoKeyNavParam")
- .isFunction("UFCRTETTwoKeyNavParam")
- .isType(EntityTypeProvider.nameETTwoKeyNav);
-
- // two input
- testRes.run("FICRTStringTwoParam(ParameterString='ABC',ParameterInt16=1)")
- .isFunctionImport("FICRTStringTwoParam")
- .isFunction("UFCRTStringTwoParam")
- .isType(PropertyProvider.nameString);
- }
-
- @Test
- public void testFunctionImport_VarRetruning() {
- // returning primitive
- testRes.run("FINRTInt16()")
- .isFunctionImport("FINRTInt16")
- .isFunction("UFNRTInt16")
- .isType(PropertyProvider.nameInt16, false);
-
- // returning collection of primitive
- testRes.run("FICRTCollStringTwoParam(ParameterString='ABC',ParameterInt16=1)")
- .isFunctionImport("FICRTCollStringTwoParam")
- .isFunction("UFCRTCollStringTwoParam")
- .isType(PropertyProvider.nameString, true);
-
- // returning single complex
- testRes.run("FICRTCTAllPrimTwoParam(ParameterString='ABC',ParameterInt16=1)")
- .isFunctionImport("FICRTCTAllPrimTwoParam")
- .isFunction("UFCRTCTAllPrimTwoParam")
- .isType(ComplexTypeProvider.nameCTAllPrim, false);
-
- // returning collection of complex
- testRes.run("FICRTCollCTTwoPrim()")
- .isFunctionImport("FICRTCollCTTwoPrim")
- .isFunction("UFCRTCollCTTwoPrim")
- .isType(ComplexTypeProvider.nameCTTwoPrim, true);
-
- // returning single entity
- testRes.run("FICRTETTwoKeyNavParam(ParameterInt16=1)")
- .isFunctionImport("FICRTETTwoKeyNavParam")
- .isFunction("UFCRTETTwoKeyNavParam")
- .isType(EntityTypeProvider.nameETTwoKeyNav, false);
-
- // returning collection of entity (aka entitySet)
- testRes.run("FICRTESTwoKeyNavParam(ParameterInt16=1)")
- .isFunctionImport("FICRTESTwoKeyNavParam")
- .isFunction("UFCRTESTwoKeyNavParam")
- .isType(EntityTypeProvider.nameETTwoKeyNav, true);
- }
-
- @Test
- public void testFunctionImportChain() {
-
- // test chain; returning single complex
- testRes.run("FICRTCTAllPrimTwoParam(ParameterString='ABC',ParameterInt16=1)/PropertyInt16")
- .at(0)
- .isFunctionImport("FICRTCTAllPrimTwoParam")
- .isFunction("UFCRTCTAllPrimTwoParam")
- .isType(ComplexTypeProvider.nameCTAllPrim, false)
- .isParameter(0, "ParameterString", "'ABC'")
- .isParameter(1, "ParameterInt16", "1")
- .at(1)
- .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
-
- // test chains; returning single entity
- testRes.run("FICRTETTwoKeyNavParam(ParameterInt16=1)/PropertyInt16")
- .at(0)
- .isFunctionImport("FICRTETTwoKeyNavParam")
- .isFunction("UFCRTETTwoKeyNavParam")
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .isParameter(0, "ParameterInt16", "1")
- .at(1)
- .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
-
- // test chains; returning collection of entity (aka entitySet)
- testRes.run("FICRTESTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=1,PropertyString='ABC')")
- .at(0)
- .isFunctionImport("FICRTESTwoKeyNavParam")
- .isFunction("UFCRTESTwoKeyNavParam")
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .isParameter(0, "ParameterInt16", "1")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'ABC'");
-
- // test chains; returning collection of entity (aka entitySet)
- testRes.run("FICRTESTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=1,PropertyString='ABC')/PropertyInt16")
- .at(0)
- .isFunctionImport("FICRTESTwoKeyNavParam")
- .isFunction("UFCRTESTwoKeyNavParam")
- .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- .isParameter(0, "ParameterInt16", "1")
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'ABC'")
- .at(1)
- .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
-
- }
-
- @Test
- public void testMetaData() {
-
- // Parsing the fragment may be used if a uri has to be parsed on the consumer side.
- // On the producer side this feature is currently not supported, so the context fragment
- // part is only available as text.
-
- testUri.run("$metadata")
- .isKind(UriInfoKind.metadata);
-
- testUri.run("$metadata?$format=atom")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom");
-
- // with context (client usage)
-
- testUri.run("$metadata#$ref")
- .isKind(UriInfoKind.metadata)
- .isFragmentText("$ref");
-
- testUri.run("$metadata?$format=atom#$ref")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("$ref");
-
- testUri.run("$metadata?$format=atom#Collection($ref)")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("Collection($ref)");
-
- testUri.run("$metadata?$format=atom#Collection(Edm.EntityType)")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("Collection(Edm.EntityType)");
-
- testUri.run("$metadata?$format=atom#Collection(Edm.ComplexType)")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("Collection(Edm.ComplexType)");
-
- testUri.run("$metadata?$format=atom#SINav")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("SINav");
-
- testUri.run("$metadata?$format=atom#SINav/PropertyInt16")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("SINav/PropertyInt16");
-
- testUri.run("$metadata?$format=atom#SINav/NavPropertyETKeyNavOne")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("SINav/NavPropertyETKeyNavOne");
-
- testUri.run("$metadata?$format=atom#SINav/NavPropertyETKeyNavMany(1)")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("SINav/NavPropertyETKeyNavMany(1)");
-
- testUri.run("$metadata?$format=atom#SINav/NavPropertyETKeyNavOne/PropertyInt16")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("SINav/NavPropertyETKeyNavOne/PropertyInt16");
-
- testUri.run("$metadata?$format=atom#SINav/NavPropertyETKeyNavMany(1)/PropertyInt16")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("SINav/NavPropertyETKeyNavMany(1)/PropertyInt16");
-
- testUri.run("$metadata?$format=atom#SINav/com.sap.odata.test1.ETTwoPrim/NavPropertyETKeyNavOne/PropertyInt16")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("SINav/com.sap.odata.test1.ETTwoPrim/NavPropertyETKeyNavOne/PropertyInt16");
-
- testUri.run("$metadata?$format=atom#SINav/com.sap.odata.test1.ETTwoPrim/NavPropertyETKeyNavMany(1)/PropertyInt16")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("SINav/com.sap.odata.test1.ETTwoPrim/NavPropertyETKeyNavMany(1)/PropertyInt16");
-
- testUri.run("$metadata?$format=atom#com.sap.odata.test1.ETAllKey")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("com.sap.odata.test1.ETAllKey");
-
- testUri.run("$metadata?$format=atom#ESTwoPrim/$deletedEntity")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("ESTwoPrim/$deletedEntity");
-
- testUri.run("$metadata?$format=atom#ESTwoPrim/$link")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("ESTwoPrim/$link");
-
- testUri.run("$metadata?$format=atom#ESTwoPrim/$deletedLink")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("ESTwoPrim/$deletedLink");
-
- testUri.run("$metadata?$format=atom#ESKeyNav")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("ESKeyNav");
-
- testUri.run("$metadata?$format=atom#ESKeyNav/PropertyInt16")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("ESKeyNav/PropertyInt16");
-
- testUri.run("$metadata?$format=atom#ESKeyNav/NavPropertyETKeyNavOne")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("ESKeyNav/NavPropertyETKeyNavOne");
-
- testUri.run("$metadata?$format=atom#ESKeyNav/NavPropertyETKeyNavMany(1)")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("ESKeyNav/NavPropertyETKeyNavMany(1)");
-
- testUri.run("$metadata?$format=atom#ESKeyNav/NavPropertyETKeyNavOne/PropertyInt16")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("ESKeyNav/NavPropertyETKeyNavOne/PropertyInt16");
-
- testUri.run("$metadata?$format=atom#ESKeyNav/NavPropertyETKeyNavMany(1)/PropertyInt16")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("ESKeyNav/NavPropertyETKeyNavMany(1)/PropertyInt16");
-
- testUri.run("$metadata?$format=atom#ESKeyNav/com.sap.odata.test1.ETTwoPrim/NavPropertyETKeyNavOne/PropertyInt16")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("ESKeyNav/com.sap.odata.test1.ETTwoPrim/NavPropertyETKeyNavOne/PropertyInt16");
-
- testUri.run(
- "$metadata?$format=atom#ESKeyNav/com.sap.odata.test1.ETTwoPrim/NavPropertyETKeyNavMany(1)/PropertyInt16")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("ESKeyNav/com.sap.odata.test1.ETTwoPrim/NavPropertyETKeyNavMany(1)/PropertyInt16");
-
- testUri.run("$metadata?$format=atom#ESKeyNav(PropertyInt16,PropertyString)")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("ESKeyNav(PropertyInt16,PropertyString)");
-
- testUri.run("$metadata?$format=atom#ESKeyNav/$entity")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("ESKeyNav/$entity");
-
- testUri.run("$metadata?$format=atom#ESKeyNav/$delta")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("ESKeyNav/$delta");
-
- testUri.run("$metadata?$format=atom#ESKeyNav/(PropertyInt16,PropertyString)/$delta")
- .isKind(UriInfoKind.metadata)
- .isFormatText("atom")
- .isFragmentText("ESKeyNav/(PropertyInt16,PropertyString)/$delta");
-
- }
-
- @Test
- public void testRef() {
- testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne/$ref");
- }
-
- @Test
- public void testSingleton() {
- // plain singleton
- testRes.run("SINav")
- .isSingleton("SINav")
- .isType(EntityTypeProvider.nameETTwoKeyNav);
- }
-
- @Test
- public void testNavigationProperty() {
-
- // plain entity set ...
-
- // with navigation property
- testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne")
- .at(0).isEntitySet("ESKeyNav")
- .at(1).isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false);
-
- // with navigation property -> property
- testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne/PropertyString")
- .at(0).isEntitySet("ESKeyNav")
- .at(1).isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
- .at(2).isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
-
- // with navigation property -> navigation property -> navigation property
- testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne/NavPropertyETKeyNavOne")
- .at(0).isEntitySet("ESKeyNav")
- .at(1).isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
- .at(2).isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false);
-
- // with navigation property(key)
- testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=1,PropertyString='1')")
- .at(0).isEntitySet("ESKeyNav")
- .at(1).isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'1'");
-
- // with navigation property(key) -> property
- testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=1,PropertyString='1')/PropertyString")
- .at(0).isEntitySet("ESKeyNav")
- .at(1).isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'1'")
- .at(2).isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
-
- // with navigation property(key) -> navigation property
- testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=1,PropertyString='1')/NavPropertyETKeyNavOne")
- .at(0).isEntitySet("ESKeyNav")
- .at(1).isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'1'")
- .at(2).isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false);
-
- // with navigation property(key) -> navigation property(key)
- testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=1,PropertyString='1')"
- + "/NavPropertyETKeyNavMany(1)")
- .at(0).isEntitySet("ESKeyNav")
- .at(1).isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'1'")
- .at(2).isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1");
-
- // with navigation property(key) -> navigation property -> property
- testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=1,PropertyString='1')"
- + "/NavPropertyETKeyNavOne/PropertyString")
- .at(0).isEntitySet("ESKeyNav")
- .at(1).isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'1'")
- .at(2).isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false)
- .at(3).isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
-
- // with navigation property(key) -> navigation property(key) -> property
- testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=1,PropertyString='1')"
- + "/NavPropertyETKeyNavMany(1)/PropertyString")
- .at(0).isEntitySet("ESKeyNav")
- .at(1).isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .isKeyPredicate(1, "PropertyString", "'1'")
- .at(2).isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
- .isKeyPredicate(0, "PropertyInt16", "1")
- .at(3).isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
- }
-
- @Test
- public void testSingleton_Property() {
-
- // plain singleton ...
-
- // with property
- testRes.run("SINav/PropertyInt16")
- .at(0)
- .isSingleton("SINav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .at(1)
- .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
-
- // with complex property
- testRes.run("SINav/PropertyComplex")
- .at(0)
- .isSingleton("SINav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .at(1)
- .isComplexProperty("PropertyComplex", ComplexTypeProvider.nameCTPrimComp, false);
-
- // with two properties
- testRes.run("SINav/PropertyComplex/PropertyInt16")
- .at(0)
- .isSingleton("SINav")
- .isType(EntityTypeProvider.nameETTwoKeyNav)
- .at(1)
- .isComplexProperty("PropertyComplex", ComplexTypeProvider.nameCTPrimComp, false)
- .at(2)
- .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
-
- }
-
- @Test
- public void testValue() {
- testUri.run("ESAllPrim(1)/PropertyString/$value");
- }
-
- @Test(expected = Exception.class)
- public void testMemberStartingWithCastFailOnValidation1() {
- // on EntityType entry
- testUri.run("ESTwoKeyNav(ParameterInt16=1,PropertyString='ABC')?"
- + "$filter=com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate")
- .goFilter().root().isMember()
- .isMemberStartType(EntityTypeProvider.nameETBaseTwoKeyNav).goPath()
- // .at(0)
- // .isUriPathInfoKind(UriResourceKind.startingTypeFilter)
- // .isType(EntityTypeProvider.nameETTwoKeyNav, false)
- // .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
- .at(0).isType(PropertyProvider.nameDate);
- }
-
- @Test(expected = Exception.class)
- public void testMemberStartingWithCastFailOnValidation2() {
- testUri.run("FICRTCTTwoPrimParam(ParameterInt16=1,ParameterString='2')?"
- + "$filter=com.sap.odata.test1.CTBase/AdditionalPropString")
- .goFilter().root().isMember()
- .isMemberStartType(ComplexTypeProvider.nameCTBase).goPath()
- // .at(0)
- // .isUriPathInfoKind(UriResourceKind.startingTypeFilter)
- // .isType(ComplexTypeProvider.nameCTTwoPrim, false)
- // .isTypeFilterOnEntry(ComplexTypeProvider.nameCTBase)
- .at(0).isType(PropertyProvider.nameString);
- }
-
- @Test
- public void testMemberStartingWithCast() {
-
- // on EntityType collection
- testUri.run("ESTwoKeyNav?$filter=com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate")
- .goFilter().root().isMember()
- .isMemberStartType(EntityTypeProvider.nameETBaseTwoKeyNav).goPath()
- // .at(0)
- // .isUriPathInfoKind(UriResourceKind.startingTypeFilter)
- // .isType(EntityTypeProvider.nameETTwoKeyNav, true)
- // .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
- .at(0).isType(PropertyProvider.nameDate);
-
- // on Complex collection
- testUri.run("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')?"
- + "$filter=com.sap.odata.test1.CTBase/AdditionalPropString")
- .goFilter().root().isMember()
- .isMemberStartType(ComplexTypeProvider.nameCTBase).goPath()
- // .at(0)
- // .isUriPathInfoKind(UriResourceKind.startingTypeFilter)
- // .isType(ComplexTypeProvider.nameCTTwoPrim, true)
- // .isTypeFilterOnCollection(ComplexTypeProvider.nameCTBase)
- .at(0).isType(PropertyProvider.nameString);
-
- }
-
- @Test
- public void testComplexTypeCastFollowingAsCollection() {
- testUri.run("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')/com.sap.odata.test1.CTBase");
- }
-
- @Test
- public void testLambda() {
- testUri.run("ESTwoKeyNav?$filter=CollPropertyComplex/all( l : true )")
- .goFilter().is("<CollPropertyComplex/<ALL;<true>>>");
-
- testUri.run("ESTwoKeyNav?$filter=CollPropertyComplex/any( l : true )")
- .goFilter().is("<CollPropertyComplex/<ANY;<true>>>");
- testUri.run("ESTwoKeyNav?$filter=CollPropertyComplex/any( )")
- .goFilter().is("<CollPropertyComplex/<ANY;>>");
-
- testUri.run("ESTwoKeyNav?$filter=all( l : true )")
- .goFilter().is("<<ALL;<true>>>");
- testUri.run("ESTwoKeyNav?$filter=any( l : true )")
- .goFilter().is("<<ANY;<true>>>");
- testUri.run("ESTwoKeyNav?$filter=any( )")
- .goFilter().is("<<ANY;>>");
- }
-
- @Test
- public void testCustomQueryOption() {
- testUri.run("ESTwoKeyNav?custom")
- .isCustomParameter(0, "custom", "");
- testUri.run("ESTwoKeyNav?custom=ABC")
- .isCustomParameter(0, "custom", "ABC");
- }
-
- @Test
- public void testGeo() throws UriParserException {
- // TODO sync
- testFilter.runOnETAllPrim("geo.distance(PropertySByte,PropertySByte)")
- .is("<geo.distance(<PropertySByte>,<PropertySByte>)>")
- .isMethod(MethodKind.GEODISTANCE, 2);
- testFilter.runOnETAllPrim("geo.length(PropertySByte)")
- .is("<geo.length(<PropertySByte>)>")
- .isMethod(MethodKind.GEOLENGTH, 1);
- testFilter.runOnETAllPrim("geo.intersects(PropertySByte,PropertySByte)")
- .is("<geo.intersects(<PropertySByte>,<PropertySByte>)>")
- .isMethod(MethodKind.GEOINTERSECTS, 2);
- }
-
- @Test
- public void testSelect() {
- testUri.run("ESTwoKeyNav?$select=*")
- .isSelectItemStar(0);
-
- testUri.run("ESTwoKeyNav?$select=com.sap.odata.test1.*")
- .isSelectItemAllOp(0, new FullQualifiedName("com.sap.odata.test1", "*"));
-
- testUri.run("ESTwoKeyNav?$select=PropertyString")
- .goSelectItemPath(0).isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
-
- testUri.run("ESTwoKeyNav?$select=PropertyComplex")
- .goSelectItemPath(0).isComplexProperty("PropertyComplex", ComplexTypeProvider.nameCTPrimComp, false);
-
- testUri.run("ESTwoKeyNav?$select=PropertyComplex/PropertyInt16")
- .goSelectItemPath(0)
- .first()
- .isComplexProperty("PropertyComplex", ComplexTypeProvider.nameCTPrimComp, false)
- .n()
- .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
-
- testUri.run("ESTwoKeyNav?$select=PropertyComplex/PropertyComplex")
- .goSelectItemPath(0)
- .first()
- .isComplexProperty("PropertyComplex", ComplexTypeProvider.nameCTPrimComp, false)
- .n()
- .isComplexProperty("PropertyComplex", ComplexTypeProvider.nameCTAllPrim, false);
-
- testUri.run("ESTwoKeyNav?$select=com.sap.odata.test1.ETBaseTwoKeyNav")
- .isSelectStartType(0, EntityTypeProvider.nameETBaseTwoKeyNav);
-
- testUri.run("ESTwoKeyNav/PropertyComplexNav?$select=com.sap.odata.test1.CTTwoBasePrimCompNav")
- .isSelectStartType(0, ComplexTypeProvider.nameCTTwoBasePrimCompNav);
-
- testUri.run("ESTwoKeyNav?$select=PropertyComplexNav/com.sap.odata.test1.CTTwoBasePrimCompNav")
- .goSelectItemPath(0)
- .first()
- .isComplexProperty("PropertyComplexNav", ComplexTypeProvider.nameCTBasePrimCompNav, false)
- .n()
- .isTypeFilterOnCollection(ComplexTypeProvider.nameCTTwoBasePrimCompNav);
- ;
-
- }
-
- public static String encode(final String decoded) throws UnsupportedEncodingException {
-
- return URLEncoder.encode(decoded, "UTF-8");
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/queryoption/QueryOptionTest.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/queryoption/QueryOptionTest.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/queryoption/QueryOptionTest.java
deleted file mode 100644
index cce237e..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/queryoption/QueryOptionTest.java
+++ /dev/null
@@ -1,303 +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.queryoption;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.server.api.uri.UriInfoResource;
-import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
-import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
-import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
-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.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();
-
- option.setAliasValue(expression);
- assertEquals(expression, option.getValue());
- }
-
- @Test
- public void testExandItemImpl() {
- ExpandItemImpl option = new ExpandItemImpl();
-
- // input options
- ExpandOptionImpl expand = new ExpandOptionImpl();
- FilterOptionImpl filter = new FilterOptionImpl();
- CountOptionImpl inlinecount = new CountOptionImpl();
- OrderByOptionImpl orderby = new OrderByOptionImpl();
- SearchOptionImpl search = new SearchOptionImpl();
- SelectOptionImpl select = new SelectOptionImpl();
- SkipOptionImpl skip = new SkipOptionImpl();
- TopOptionImpl top = new TopOptionImpl();
- LevelsOptionImpl levels = new LevelsOptionImpl();
-
- option.setSystemQueryOption(expand);
- option.setSystemQueryOption(filter);
- option.setSystemQueryOption(inlinecount);
- option.setSystemQueryOption(orderby);
- option.setSystemQueryOption(search);
- option.setSystemQueryOption(select);
- option.setSystemQueryOption(skip);
- option.setSystemQueryOption(top);
- option.setSystemQueryOption(levels);
-
- assertEquals(expand, option.getExpandOption());
- assertEquals(filter, option.getFilterOption());
- assertEquals(inlinecount, option.getCountOption());
- assertEquals(orderby, option.getOrderByOption());
- assertEquals(search, option.getSearchOption());
- assertEquals(select, option.getSelectOption());
- assertEquals(skip, option.getSkipOption());
- assertEquals(top, option.getTopOption());
- assertEquals(levels, option.getLevelsOption());
-
- // just for completeness
- option = new ExpandItemImpl();
- option.setSystemQueryOption(new IdOptionImpl());
-
- option = new ExpandItemImpl();
- List<SystemQueryOptionImpl> list = new ArrayList<SystemQueryOptionImpl>();
- list.add(expand);
- list.add(filter);
- option.setSystemQueryOptions(list);
- assertEquals(expand, option.getExpandOption());
- assertEquals(filter, option.getFilterOption());
-
- option = new ExpandItemImpl();
- assertEquals(false, option.isRef());
- option.setIsRef(true);
- assertEquals(true, option.isRef());
-
- option = new ExpandItemImpl();
- assertEquals(false, option.isStar());
- option.setIsStar(true);
- assertEquals(true, option.isStar());
-
- option = new ExpandItemImpl();
- UriInfoResource resource = new UriInfoImpl().asUriInfoResource();
- option.setResourcePath(resource);
- assertEquals(resource, option.getResourcePath());
-
- }
-
- @Test
- public void testExpandOptionImpl() {
- ExpandOptionImpl option = new ExpandOptionImpl();
- assertEquals(SystemQueryOptionKind.EXPAND, option.getKind());
-
- ExpandItemImpl item1 = new ExpandItemImpl();
- ExpandItemImpl item2 = new ExpandItemImpl();
- option.addExpandItem(item1);
- option.addExpandItem(item2);
- assertEquals(item1, option.getExpandItems().get(0));
- assertEquals(item2, option.getExpandItems().get(1));
- }
-
- @Test
- public void testFilterOptionImpl() {
- FilterOptionImpl option = new FilterOptionImpl();
- assertEquals(SystemQueryOptionKind.FILTER, option.getKind());
-
- AliasImpl expression = new AliasImpl();
-
- option.setExpression(expression);
- assertEquals(expression, option.getExpression());
- }
-
- @Test
- public void testFormatOptionImpl() {
- FormatOptionImpl option = new FormatOptionImpl();
- assertEquals(SystemQueryOptionKind.FORMAT, option.getKind());
-
- option.setFormat("A");
-
- assertEquals("A", option.getFormat());
- }
-
- @Test
- public void testIdOptionImpl() {
- IdOptionImpl option = new IdOptionImpl();
- assertEquals(SystemQueryOptionKind.ID, option.getKind());
-
- option.setValue("A");
-
- assertEquals("A", option.getValue());
- }
-
- @Test
- public void testInlineCountImpl() {
- CountOptionImpl option = new CountOptionImpl();
- assertEquals(SystemQueryOptionKind.COUNT, option.getKind());
-
- assertEquals(false, option.getValue());
- option.setValue(true);
- assertEquals(true, option.getValue());
- }
-
- @Test
- public void testLevelsExpandOptionImpl() {
- LevelsOptionImpl option = new LevelsOptionImpl();
- assertEquals(SystemQueryOptionKind.LEVELS, option.getKind());
-
- assertEquals(0, option.getValue());
- option.setValue(1);
- assertEquals(1, option.getValue());
-
- option = new LevelsOptionImpl();
- option.setMax();
- assertEquals(true, option.isMax());
- }
-
- @Test
- public void testOrderByItemImpl() {
- OrderByItemImpl option = new OrderByItemImpl();
-
- AliasImpl expression = new AliasImpl();
- option.setExpression(expression);
- assertEquals(expression, option.getExpression());
-
- assertEquals(false, option.isDescending());
- option.setDescending(true);
- assertEquals(true, option.isDescending());
- }
-
- @Test
- public void testOrderByOptionImpl() {
- OrderByOptionImpl option = new OrderByOptionImpl();
-
- OrderByItemImpl order0 = new OrderByItemImpl();
- OrderByItemImpl order1 = new OrderByItemImpl();
- option.addOrder(order0);
- option.addOrder(order1);
-
- assertEquals(order0, option.getOrders().get(0));
- assertEquals(order1, option.getOrders().get(1));
- }
-
- @Test
- public void testQueryOptionImpl() {
- QueryOptionImpl option = new AliasQueryOptionImpl();
-
- option.setName("A");
- option.setText("B");
- assertEquals("A", option.getName());
- assertEquals("B", option.getText());
- }
-
- @Test
- public void testSearchOptionImpl() {
- SearchOptionImpl option = new SearchOptionImpl();
- assertEquals(SystemQueryOptionKind.SEARCH, option.getKind());
- // TODO $search is not supported yet
- }
-
- @Test
- public void testSelectItemImpl() {
- SelectItemImpl option = new SelectItemImpl();
-
- // no typed collection else case ( e.g. if not path is added)
- option = new SelectItemImpl();
-
- option = new SelectItemImpl();
- assertEquals(false, option.isStar());
- option.setStar(true);
- assertEquals(true, option.isStar());
-
- option = new SelectItemImpl();
- assertEquals(false, option.isAllOperationsInSchema());
- FullQualifiedName fqName = new FullQualifiedName("Namespace", "Name");
- option.addAllOperationsInSchema(fqName);
- assertEquals(true, option.isAllOperationsInSchema());
- assertEquals(fqName, option.getAllOperationsInSchemaNameSpace());
-
- }
-
- @Test
- public void testSelectOptionImpl() {
- 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);
-
- assertEquals(item0, option.getSelectItems().get(0));
- assertEquals(item1, option.getSelectItems().get(1));
-
- }
-
- @Test
- public void testSkipOptionImpl() {
- SkipOptionImpl option = new SkipOptionImpl();
- assertEquals(SystemQueryOptionKind.SKIP, option.getKind());
-
- option.setValue(10);
- assertEquals(10, option.getValue());
- }
-
- @Test
- public void testSkipTokenOptionImpl() {
- SkipTokenOptionImpl option = new SkipTokenOptionImpl();
- assertEquals(SystemQueryOptionKind.SKIPTOKEN, option.getKind());
-
- option.setValue("A");
- assertEquals("A", option.getValue());
- }
-
- @Test
- public void testSystemQueryOptionImpl() {
- SystemQueryOptionImpl option = new SystemQueryOptionImpl();
-
- option.setKind(SystemQueryOptionKind.EXPAND);
- assertEquals(SystemQueryOptionKind.EXPAND, option.getKind());
-
- assertEquals("$expand", option.getName());
- }
-
- @Test
- public void testTopOptionImpl() {
- TopOptionImpl option = new TopOptionImpl();
- assertEquals(SystemQueryOptionKind.TOP, option.getKind());
-
- option.setValue(11);
- assertEquals(11, option.getValue());
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java
deleted file mode 100644
index 2902bdc..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java
+++ /dev/null
@@ -1,239 +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.queryoption.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.Arrays;
-
-import org.apache.olingo.commons.api.ODataApplicationException;
-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.server.api.uri.UriInfoKind;
-import org.apache.olingo.server.api.uri.UriInfoResource;
-import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
-import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
-import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
-import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind;
-import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
-import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
-import org.apache.olingo.server.core.testutil.techprovider.ActionProvider;
-import org.apache.olingo.server.core.testutil.techprovider.EntityTypeProvider;
-import org.apache.olingo.server.core.testutil.techprovider.EnumTypeProvider;
-import org.apache.olingo.server.core.testutil.techprovider.FunctionProvider;
-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.FilterTreeToText;
-import org.junit.Test;
-
-public class ExpressionTest {
- Edm edm = new EdmProviderImpl(new EdmTechTestProvider());
-
- @Test
- public void testSupportedOperators() {
- assertEquals(UnaryOperatorKind.MINUS, UnaryOperatorKind.get("-"));
- assertEquals(null, UnaryOperatorKind.get("XXX"));
-
- assertEquals(BinaryOperatorKind.MOD, BinaryOperatorKind.get("mod"));
- assertEquals(null, BinaryOperatorKind.get("XXX"));
-
- assertEquals(MethodKind.CONCAT, MethodKind.get("concat"));
- assertEquals(null, MethodKind.get("XXX"));
- }
-
- @Test
- public void testAliasExpression() throws ExpressionVisitException, ODataApplicationException {
- AliasImpl expression = new AliasImpl();
-
- expression.setParameter("Test");
-
- assertEquals("Test", expression.getParameterName());
-
- String output = expression.accept(new FilterTreeToText());
- assertEquals("<Test>", output);
-
- }
-
- @Test
- public void testBinaryExpression() throws ExpressionVisitException, ODataApplicationException {
- BinaryImpl expression = new BinaryImpl();
-
- ExpressionImpl expressionLeft = new LiteralImpl().setText("A");
- ExpressionImpl expressionRight = new LiteralImpl().setText("B");
-
- expression.setLeftOperand(expressionLeft);
- expression.setRightOperand(expressionRight);
- expression.setOperator(BinaryOperatorKind.SUB);
-
- assertEquals(expressionLeft, expression.getLeftOperand());
- assertEquals(expressionRight, expression.getRightOperand());
- assertEquals(BinaryOperatorKind.SUB, expression.getOperator());
-
- String output = expression.accept(new FilterTreeToText());
- assertEquals("<<A> sub <B>>", output);
- }
-
- @Test
- public void testEnumerationExpression() throws ExpressionVisitException, ODataApplicationException {
- EnumerationImpl expression = new EnumerationImpl();
- EdmEnumType type = (EdmEnumType) edm.getEnumType(EnumTypeProvider.nameENString);
- assertNotNull(type);
- expression.setType(type);
-
- assertEquals(type, expression.getType());
-
- expression.addValue("A");
- expression.addValue("B");
- assertEquals("A", expression.getValues().get(0));
- assertEquals("B", expression.getValues().get(1));
- assertEquals("<com.sap.odata.test1.ENString<A,B>>", expression.accept(new FilterTreeToText()));
- }
-
- @Test
- public void testLambdaRefExpression() throws ExpressionVisitException, ODataApplicationException {
- LambdaRefImpl expression = new LambdaRefImpl();
- expression.setVariableText("A");
- assertEquals("A", expression.getVariableName());
-
- assertEquals("<A>", expression.accept(new FilterTreeToText()));
-
- }
-
- @Test
- public void testLiteralExpresion() throws ExpressionVisitException, ODataApplicationException {
- LiteralImpl expression = new LiteralImpl();
- expression.setText("A");
- assertEquals("A", expression.getText());
-
- assertEquals("<A>", expression.accept(new FilterTreeToText()));
- }
-
- @Test
- public void testMemberExpression() throws ExpressionVisitException, ODataApplicationException {
- MemberImpl expression = new MemberImpl();
- EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETKeyNav);
-
- // UriResourceImplTyped
- EdmAction action = edm.getUnboundAction(ActionProvider.nameUARTPrimParam);
- UriInfoResource uriInfo = new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
- new UriResourceActionImpl().setAction(action)).asUriInfoResource();
- expression.setResourcePath(uriInfo);
- assertEquals(action.getReturnType().getType(), expression.getType());
-
- // check accept and path
- assertEquals(uriInfo, expression.getResourcePath());
- assertEquals("<UARTPrimParam>", expression.accept(new FilterTreeToText()));
-
- // UriResourceImplTyped check collection = false case
- assertEquals(false, expression.isCollection());
-
- // UriResourceImplTyped check collection = true case
- action = edm.getUnboundAction(ActionProvider.nameUARTPrimCollParam);
- expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
- new UriResourceActionImpl().setAction(action))
- .asUriInfoResource());
- assertEquals(true, expression.isCollection());
-
- // UriResourceImplTyped with filter
- action = edm.getUnboundAction(ActionProvider.nameUARTPrimParam);
- expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
- new UriResourceActionImpl().setAction(action).setTypeFilter(entityType))
- .asUriInfoResource());
- assertEquals(entityType, expression.getType());
-
- // UriResourceImplKeyPred
- EdmFunction function = edm.getUnboundFunction(FunctionProvider.nameUFCRTETKeyNav, null);
- expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
- new UriResourceFunctionImpl().setFunction(function))
- .asUriInfoResource());
- assertEquals(function.getReturnType().getType(), expression.getType());
-
- // UriResourceImplKeyPred typeFilter on entry
- EdmEntityType entityBaseType = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
- function = edm.getUnboundFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam, Arrays.asList("ParameterInt16"));
- expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
- new UriResourceFunctionImpl().setFunction(function).setEntryTypeFilter(entityBaseType))
- .asUriInfoResource());
- assertEquals(entityBaseType, expression.getType());
-
- // UriResourceImplKeyPred typeFilter on entry
- entityBaseType = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
- function = edm.getUnboundFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam, Arrays.asList("ParameterInt16"));
- expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
- new UriResourceFunctionImpl().setFunction(function).setCollectionTypeFilter(entityBaseType))
- .asUriInfoResource());
- assertEquals(entityBaseType, expression.getType());
-
- // no typed
- entityBaseType = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
- function = edm.getUnboundFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam, Arrays.asList("ParameterInt16"));
- expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.all));
- assertEquals(null, expression.getType());
-
- // no typed collection else case
- assertEquals(false, expression.isCollection());
- }
-
- @Test
- public void testMethodCallExpression() throws ExpressionVisitException, ODataApplicationException {
- MethodImpl expression = new MethodImpl();
- expression.setMethod(MethodKind.CONCAT);
-
- ExpressionImpl p0 = new LiteralImpl().setText("A");
- ExpressionImpl p1 = new LiteralImpl().setText("B");
- expression.addParameter(p0);
- expression.addParameter(p1);
-
- assertEquals(MethodKind.CONCAT, expression.getMethod());
- assertEquals("<concat(<A>,<B>)>", expression.accept(new FilterTreeToText()));
-
- assertEquals(p0, expression.getParameters().get(0));
- assertEquals(p1, expression.getParameters().get(1));
- }
-
- @Test
- public void testTypeLiteralExpression() throws ExpressionVisitException, ODataApplicationException {
- TypeLiteralImpl expression = new TypeLiteralImpl();
- EdmEntityType entityBaseType = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
- expression.setType(entityBaseType);
-
- assertEquals(entityBaseType, expression.getType());
- assertEquals("<com.sap.odata.test1.ETBaseTwoKeyNav>", expression.accept(new FilterTreeToText()));
- }
-
- @Test
- public void testUnaryExpression() throws ExpressionVisitException, ODataApplicationException {
- UnaryImpl expression = new UnaryImpl();
- expression.setOperator(UnaryOperatorKind.MINUS);
-
- ExpressionImpl operand = new LiteralImpl().setText("A");
- expression.setOperand(operand);
-
- assertEquals(UnaryOperatorKind.MINUS, expression.getOperator());
- assertEquals(operand, expression.getOperand());
-
- assertEquals("<- <A>>", expression.accept(new FilterTreeToText()));
- }
-
-}
[07/15] [OLINGO-266] refactor ref module to server-ref
Posted by sk...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/PropertyProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/PropertyProvider.java b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/PropertyProvider.java
new file mode 100644
index 0000000..5d1ad3b
--- /dev/null
+++ b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/PropertyProvider.java
@@ -0,0 +1,590 @@
+/*
+ * 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.testutil.techprovider;
+
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.server.api.edm.provider.NavigationProperty;
+import org.apache.olingo.server.api.edm.provider.Property;
+
+public class PropertyProvider {
+
+ // Primitive Type Names
+ public static final FullQualifiedName nameBinary = EdmPrimitiveTypeKind.Binary.getFullQualifiedName();
+ public static final FullQualifiedName nameBoolean = EdmPrimitiveTypeKind.Boolean.getFullQualifiedName();
+ public static final FullQualifiedName nameByte = EdmPrimitiveTypeKind.Byte.getFullQualifiedName();
+
+ public static final FullQualifiedName nameDate = EdmPrimitiveTypeKind.Date.getFullQualifiedName();
+ public static final FullQualifiedName nameDateTimeOffset =
+ EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName();
+
+ public static final FullQualifiedName nameDecimal = EdmPrimitiveTypeKind.Decimal.getFullQualifiedName();
+ public static final FullQualifiedName nameDouble = EdmPrimitiveTypeKind.Double.getFullQualifiedName();
+ public static final FullQualifiedName nameDuration = EdmPrimitiveTypeKind.Duration.getFullQualifiedName();
+
+ public static final FullQualifiedName nameGuid = EdmPrimitiveTypeKind.Guid.getFullQualifiedName();
+ public static final FullQualifiedName nameInt16 = EdmPrimitiveTypeKind.Int16.getFullQualifiedName();
+ public static final FullQualifiedName nameInt32 = EdmPrimitiveTypeKind.Int32.getFullQualifiedName();
+ public static final FullQualifiedName nameInt64 = EdmPrimitiveTypeKind.Int64.getFullQualifiedName();
+
+ public static final FullQualifiedName nameSByte = EdmPrimitiveTypeKind.SByte.getFullQualifiedName();
+ public static final FullQualifiedName nameSingle = EdmPrimitiveTypeKind.Single.getFullQualifiedName();
+
+ public static final FullQualifiedName nameString = EdmPrimitiveTypeKind.String.getFullQualifiedName();
+ public static final FullQualifiedName nameTimeOfDay = EdmPrimitiveTypeKind.TimeOfDay.getFullQualifiedName();
+
+ // Primitive Properties --------------------------------------------------------------------------------------------
+ public static final Property collPropertyBinary = new Property()
+ .setName("CollPropertyBinary")
+ .setType(nameBinary)
+ .setCollection(true);
+
+ public static final Property collPropertyBinary_ExplicitNullable = new Property()
+ .setName("CollPropertyBinary")
+ .setType(nameBinary)
+ .setNullable(true)
+ .setCollection(true);
+
+ public static final Property collPropertyBoolean = new Property()
+ .setName("CollPropertyBoolean")
+ .setType(nameBoolean)
+ .setCollection(true);
+
+ public static final Property collPropertyBoolean_ExplicitNullable = new Property()
+ .setName("CollPropertyBoolean")
+ .setType(nameBoolean)
+ .setNullable(true)
+ .setCollection(true);
+
+ public static final Property collPropertyByte = new Property()
+ .setName("CollPropertyByte")
+ .setType(nameByte)
+ .setCollection(true);
+
+ public static final Property collPropertyByte_ExplicitNullable = new Property()
+ .setName("CollPropertyByte")
+ .setType(nameByte)
+ .setNullable(true)
+ .setCollection(true);
+
+ public static final Property collPropertyDate = new Property()
+ .setName("CollPropertyDate")
+ .setType(nameDate)
+ .setCollection(true);
+
+ public static final Property collPropertyDate_ExplicitNullable = new Property()
+ .setName("CollPropertyDate")
+ .setType(nameDate)
+ .setNullable(true)
+ .setCollection(true);
+
+ public static final Property collPropertyDateTimeOffset = new Property()
+ .setName("CollPropertyDateTimeOffset")
+ .setType(nameDateTimeOffset)
+ .setCollection(true);
+
+ public static final Property collPropertyDateTimeOffset_ExplicitNullable = new Property()
+ .setName("CollPropertyDateTimeOffset")
+ .setType(nameDateTimeOffset)
+ .setNullable(true)
+ .setCollection(true);
+
+ public static final Property collPropertyDecimal = new Property()
+ .setName("CollPropertyDecimal")
+ .setType(nameDecimal)
+ .setCollection(true);
+
+ public static final Property collPropertyDecimal_ExplicitNullable = new Property()
+ .setName("CollPropertyDecimal")
+ .setType(nameDecimal)
+ .setNullable(true)
+ .setCollection(true);
+
+ public static final Property collPropertyDouble = new Property()
+ .setName("CollPropertyDouble")
+ .setType(nameDouble)
+ .setCollection(true);
+
+ public static final Property collPropertyDouble_ExplicitNullable = new Property()
+ .setName("CollPropertyDouble")
+ .setType(nameDouble)
+ .setNullable(true)
+ .setCollection(true);
+
+ public static final Property collPropertyDuration = new Property()
+ .setName("CollPropertyDuration")
+ .setType(nameDuration)
+ .setCollection(true);
+
+ public static final Property collPropertyDuration_ExplicitNullable = new Property()
+ .setName("CollPropertyDuration")
+ .setType(nameDuration)
+ .setNullable(true)
+ .setCollection(true);
+
+ public static final Property collPropertyGuid = new Property()
+ .setName("CollPropertyGuid")
+ .setType(nameGuid)
+ .setCollection(true);
+
+ public static final Property collPropertyGuid_ExplicitNullable = new Property()
+ .setName("CollPropertyGuid")
+ .setType(nameGuid)
+ .setNullable(true)
+ .setCollection(true);
+
+ public static final Property collPropertyInt16 = new Property()
+ .setName("CollPropertyInt16")
+ .setType(nameInt16)
+ .setCollection(true);
+
+ public static final Property collPropertyInt16_ExplicitNullable = new Property()
+ .setName("CollPropertyInt16")
+ .setType(nameInt16)
+ .setNullable(true)
+ .setCollection(true);
+
+ public static final Property collPropertyInt32 = new Property()
+ .setName("CollPropertyInt32")
+ .setType(nameInt32)
+ .setCollection(true);
+
+ public static final Property collPropertyInt32_ExplicitNullable = new Property()
+ .setName("CollPropertyInt32")
+ .setType(nameInt32)
+ .setNullable(true)
+ .setCollection(true);
+
+ public static final Property collPropertyInt64 = new Property()
+ .setName("CollPropertyInt64")
+ .setType(nameInt64)
+ .setCollection(true);
+
+ public static final Property collPropertyInt64_ExplicitNullable = new Property()
+ .setName("CollPropertyInt64")
+ .setType(nameInt64)
+ .setNullable(true)
+ .setCollection(true);
+
+ public static final Property collPropertySByte = new Property()
+ .setName("CollPropertySByte")
+ .setType(nameSByte)
+ .setCollection(true);
+
+ public static final Property collPropertySByte_ExplicitNullable = new Property()
+ .setName("CollPropertySByte")
+ .setType(nameSByte)
+ .setNullable(true)
+ .setCollection(true);
+
+ public static final Property collPropertySingle = new Property()
+ .setName("CollPropertySingle")
+ .setType(nameSingle)
+ .setCollection(true);
+
+ public static final Property collPropertySingle_ExplicitNullable = new Property()
+ .setName("CollPropertySingle")
+ .setType(nameSingle)
+ .setNullable(true)
+ .setCollection(true);
+
+ public static final Property collPropertyString = new Property()
+ .setName("CollPropertyString")
+ .setType(nameString)
+ .setCollection(true);
+
+ public static final Property collPropertyString_ExplicitNullable = new Property()
+ .setName("CollPropertyString")
+ .setType(nameString)
+ .setNullable(true)
+ .setCollection(true);
+
+ public static final Property collPropertyTimeOfDay = new Property()
+ .setName("CollPropertyTimeOfDay")
+ .setType(nameTimeOfDay)
+ .setCollection(true);
+
+ public static final Property collPropertyTimeOfDay_ExplicitNullable = new Property()
+ .setName("CollPropertyTimeOfDay")
+ .setType(nameTimeOfDay)
+ .setNullable(true)
+ .setCollection(true);
+
+ public static final Property propertyBinary = new Property()
+ .setName("PropertyBinary")
+ .setType(nameBinary);
+
+ public static final Property propertyBinary_NotNullable = new Property()
+ .setName("PropertyBinary")
+ .setType(nameBinary)
+ .setNullable(false);
+
+ public static final Property propertyBinary_ExplicitNullable = new Property()
+ .setName("PropertyBinary")
+ .setType(nameBinary)
+ .setNullable(true);
+
+ public static final Property propertyBoolean = new Property()
+ .setName("PropertyBoolean")
+ .setType(nameBoolean);
+
+ public static final Property propertyBoolean_NotNullable = new Property()
+ .setName("PropertyBoolean")
+ .setType(nameBoolean)
+ .setNullable(false);
+
+ public static final Property propertyBoolean_ExplicitNullable = new Property()
+ .setName("PropertyBoolean")
+ .setType(nameBoolean)
+ .setNullable(true);
+
+ public static final Property propertyByte = new Property()
+ .setName("PropertyByte")
+ .setType(nameByte);
+
+ public static final Property propertyByte_NotNullable = new Property()
+ .setName("PropertyByte")
+ .setType(nameByte)
+ .setNullable(false);
+
+ public static final Property propertyByte_ExplicitNullable = new Property()
+ .setName("PropertyByte")
+ .setType(nameByte)
+ .setNullable(true);
+
+ public static final Property propertyDate = new Property()
+ .setName("PropertyDate")
+ .setType(nameDate);
+
+ public static final Property propertyDate_NotNullable = new Property()
+ .setName("PropertyDate")
+ .setType(nameDate)
+ .setNullable(false);
+
+ public static final Property propertyDate_ExplicitNullable = new Property()
+ .setName("PropertyDate")
+ .setType(nameDate)
+ .setNullable(true);
+
+ public static final Property propertyDateTimeOffset = new Property()
+ .setName("PropertyDateTimeOffset")
+ .setType(nameDateTimeOffset);
+
+ public static final Property propertyDateTimeOffset_NotNullable = new Property()
+ .setName("PropertyDateTimeOffset")
+ .setType(nameDateTimeOffset)
+ .setNullable(false);
+
+ public static final Property propertyDateTimeOffset_ExplicitNullable = new Property()
+ .setName("PropertyDateTimeOffset")
+ .setType(nameDateTimeOffset)
+ .setNullable(true);
+
+ public static final Property propertyDecimal = new Property()
+ .setName("PropertyDecimal")
+ .setType(nameDecimal);
+
+ public static final Property propertyDecimal_NotNullable = new Property()
+ .setName("PropertyDecimal")
+ .setType(nameDecimal)
+ .setNullable(false);
+
+ public static final Property propertyDecimal_ExplicitNullable = new Property()
+ .setName("PropertyDecimal")
+ .setType(nameDecimal)
+ .setNullable(true);
+
+ public static final Property propertyDouble = new Property()
+ .setName("PropertyDouble")
+ .setType(nameDouble);
+
+ public static final Property propertyDouble_NotNullable = new Property()
+ .setName("PropertyDouble")
+ .setType(nameDouble)
+ .setNullable(false);
+
+ public static final Property propertyDouble_ExplicitNullable = new Property()
+ .setName("PropertyDouble")
+ .setType(nameDouble)
+ .setNullable(true);
+
+ public static final Property propertyDuration = new Property()
+ .setName("PropertyDuration")
+ .setType(nameDuration);
+
+ public static final Property propertyDuration_NotNullable = new Property()
+ .setName("PropertyDuration")
+ .setType(nameDuration)
+ .setNullable(false);
+
+ public static final Property propertyDuration_ExplicitNullable = new Property()
+ .setName("PropertyDuration")
+ .setType(nameDuration)
+ .setNullable(true);
+
+ public static final Property propertyGuid = new Property()
+ .setName("PropertyGuid")
+ .setType(nameGuid);
+
+ public static final Property propertyGuid_NotNullable = new Property()
+ .setName("PropertyGuid")
+ .setType(nameGuid)
+ .setNullable(false);
+
+ public static final Property propertyGuid_ExplicitNullable = new Property()
+ .setName("PropertyGuid")
+ .setType(nameGuid)
+ .setNullable(true);
+
+ public static final Property propertyInt16 = new Property()
+ .setName("PropertyInt16")
+ .setType(nameInt16);
+
+ public static final Property propertyInt16_NotNullable = new Property()
+ .setName("PropertyInt16")
+ .setType(nameInt16)
+ .setNullable(false);
+
+ public static final Property propertyInt16_ExplicitNullable = new Property()
+ .setName("PropertyInt16")
+ .setType(nameInt16)
+ .setNullable(true);
+
+ public static final Property propertyInt32 = new Property()
+ .setName("PropertyInt32")
+ .setType(nameInt32);
+
+ public static final Property propertyInt32_NotNullable = new Property()
+ .setName("PropertyInt32")
+ .setType(nameInt32)
+ .setNullable(false);
+
+ public static final Property propertyInt32_ExplicitNullable = new Property()
+ .setName("PropertyInt32")
+ .setType(nameInt32)
+ .setNullable(true);
+
+ public static final Property propertyInt64 = new Property()
+ .setName("PropertyInt64")
+ .setType(nameInt64);
+
+ public static final Property propertyInt64_NotNullable = new Property()
+ .setName("PropertyInt64")
+ .setType(nameInt64)
+ .setNullable(false);
+
+ public static final Property propertyInt64_ExplicitNullable = new Property()
+ .setName("PropertyInt64")
+ .setType(nameInt64)
+ .setNullable(true);
+
+ public static final Property propertySByte = new Property()
+ .setName("PropertySByte")
+ .setType(nameSByte);
+
+ public static final Property propertySByte_NotNullable = new Property()
+ .setName("PropertySByte")
+ .setType(nameSByte)
+ .setNullable(false);
+
+ public static final Property propertySByte_ExplicitNullable = new Property()
+ .setName("PropertySByte")
+ .setType(nameSByte)
+ .setNullable(true);
+
+ public static final Property propertySingle = new Property()
+ .setName("PropertySingle")
+ .setType(nameSingle);
+
+ public static final Property propertySingle_NotNullable = new Property()
+ .setName("PropertySingle")
+ .setType(nameSingle)
+ .setNullable(false);
+
+ public static final Property propertySingle_ExplicitNullable = new Property()
+ .setName("PropertySingle")
+ .setType(nameSingle)
+ .setNullable(true);
+
+ public static final Property propertyString = new Property()
+ .setName("PropertyString")
+ .setType(nameString);
+
+ public static final Property propertyString_NotNullable = new Property()
+ .setName("PropertyString")
+ .setType(nameString)
+ .setNullable(false);
+
+ public static final Property propertyString_ExplicitNullable = new Property()
+ .setName("PropertyString")
+ .setType(nameString)
+ .setNullable(true);
+
+ public static final Property propertyTimeOfDay = new Property()
+ .setName("PropertyTimeOfDay")
+ .setType(nameTimeOfDay);
+
+ public static final Property propertyTimeOfDay_NotNullable = new Property()
+ .setName("PropertyTimeOfDay")
+ .setType(nameTimeOfDay)
+ .setNullable(false);
+
+ public static final Property propertyTimeOfDay_ExplicitNullable = new Property()
+ .setName("PropertyTimeOfDay")
+ .setType(nameTimeOfDay)
+ .setNullable(true);
+
+ /*
+ * TODO add propertyStream
+ * Property propertyStream = new Property()
+ * .setName("PropertyStream")
+ * .setType(EdmStream.getFullQualifiedName());
+ */
+
+ // Complex Properties ----------------------------------------------------------------------------------------------
+ public static final Property collPropertyComplex_CTPrimComp = new Property()
+ .setName("CollPropertyComplex")
+ .setType(ComplexTypeProvider.nameCTPrimComp)
+ .setCollection(true);
+
+ public static final Property collPropertyComplex_CTTwoPrim = new Property()
+ .setName("CollPropertyComplex")
+ .setType(ComplexTypeProvider.nameCTTwoPrim)
+ .setCollection(true);
+
+ public static final Property propertyComplex_CTAllPrim = new Property()
+ .setName("PropertyComplex")
+ .setType(ComplexTypeProvider.nameCTAllPrim);
+
+ public static final Property propertyComplex_CTCollAllPrim = new Property()
+ .setName("PropertyComplex")
+ .setType(ComplexTypeProvider.nameCTCollAllPrim);
+
+ public static final Property propertyComplex_CTCompCollComp = new Property()
+ .setName("PropertyComplex")
+ .setType(ComplexTypeProvider.nameCTCompCollComp);
+
+ public static final Property propertyComplex_CTCompComp = new Property()
+ .setName("PropertyComplex")
+ .setType(ComplexTypeProvider.nameCTCompComp);
+
+ public static final Property propertyComplex_CTNavFiveProp = new Property()
+ .setName("PropertyComplex")
+ .setType(ComplexTypeProvider.nameCTNavFiveProp);
+
+ public static final Property propertyComplex_CTPrimComp_NotNullable = new Property()
+ .setName("PropertyComplex")
+ .setType(ComplexTypeProvider.nameCTPrimComp)
+ .setNullable(false);
+
+ public static final Property propertyComplex_CTTwoPrim = new Property()
+ .setName("PropertyComplex")
+ .setType(ComplexTypeProvider.nameCTTwoPrim);
+
+ public static final Property propertyComplexAllPrim_CTAllPrim = new Property()
+ .setName("PropertyComplexAllPrim")
+ .setType(ComplexTypeProvider.nameCTAllPrim);
+
+ public static final Property propertyComplexComplex_CTCompComp = new Property()
+ .setName("PropertyComplexComplex")
+ .setType(ComplexTypeProvider.nameCTCompComp);
+
+ public static final Property propertyComplexEnum_CTPrimEnum_NotNullable = new Property()
+ .setName("PropertyComplexEnum")
+ .setType(ComplexTypeProvider.nameCTPrimEnum)
+ .setNullable(false);
+
+ public static final Property propertyComplexTwoPrim_CTTwoPrim = new Property()
+ .setName("PropertyComplexTwoPrim")
+ .setType(ComplexTypeProvider.nameCTTwoPrim);
+
+ public static final Property propertyMixedPrimCollComp_CTMixPrimCollComp = new Property()
+ .setName("PropertyMixedPrimCollComp")
+ .setType(ComplexTypeProvider.nameCTMixPrimCollComp);
+
+ // Navigation Properties -------------------------------------------------------------------------------------------
+ public static final NavigationProperty collectionNavPropertyETKeyNavMany_ETKeyNav = new NavigationProperty()
+ .setName("NavPropertyETKeyNavMany")
+ .setType(EntityTypeProvider.nameETKeyNav)
+ .setCollection(true);
+
+ public static final NavigationProperty collectionNavPropertyETMediaMany_ETMedia = new NavigationProperty()
+ .setName("NavPropertyETMediaMany")
+ .setType(EntityTypeProvider.nameETMedia)
+ .setCollection(true);
+
+ public static final NavigationProperty collectionNavPropertyETTwoKeyNavMany_ETTwoKeyNav = new NavigationProperty()
+ .setName("NavPropertyETTwoKeyNavMany")
+ .setType(EntityTypeProvider.nameETTwoKeyNav)
+ .setCollection(true)
+ .setPartner("NavPropertyETKeyNavOne");
+
+ public static final NavigationProperty collectionNavPropertyETTwoKeyNavOne_ETTwoKeyNav = new NavigationProperty()
+ .setName("NavPropertyETTwoKeyNavOne")
+ .setType(EntityTypeProvider.nameETTwoKeyNav);
+
+ public static final NavigationProperty collectionNavPropertyETTwoPrimMany_ETTwoPrim = new NavigationProperty()
+ .setName("NavPropertyETTwoPrimMany")
+ .setType(EntityTypeProvider.nameETTwoPrim)
+ .setCollection(true)
+ .setNullable(false);
+
+ public static final NavigationProperty collectionNavPropertyETAllPrimMany_ETAllPrim = new NavigationProperty()
+ .setName("NavPropertyETAllPrimMany")
+ .setType(EntityTypeProvider.nameETAllPrim)
+ .setCollection(true);
+
+ public static final NavigationProperty navPropertyETKeyNavOne_ETKeyNav = new NavigationProperty()
+ .setName("NavPropertyETKeyNavOne")
+ .setType(EntityTypeProvider.nameETKeyNav);
+
+ public static final NavigationProperty navPropertyETMediaOne_ETMedia = new NavigationProperty()
+ .setName("NavPropertyETMediaOne")
+ .setType(EntityTypeProvider.nameETMedia);
+
+ public static final NavigationProperty navPropertyETKeyPrimNavOne_ETKeyPrimNav = new NavigationProperty()
+ .setName("NavPropertyETKeyPrimNavOne")
+ .setType(EntityTypeProvider.nameETKeyPrimNav);
+
+ public static final NavigationProperty navPropertyETTwoKeyNavOne_ETTwoKeyNav_NotNullable = new NavigationProperty()
+ .setName("NavPropertyETTwoKeyNavOne")
+ .setType(EntityTypeProvider.nameETTwoKeyNav)
+ .setNullable(false);
+
+ public static final NavigationProperty navPropertyETTwoKeyNavOne_ETTwoKeyNav = new NavigationProperty()
+ .setName("NavPropertyETTwoKeyNavOne")
+ .setType(EntityTypeProvider.nameETTwoKeyNav);
+
+ public static final NavigationProperty navPropertyETTwoPrimOne_ETTwoPrim = new NavigationProperty()
+ .setName("NavPropertyETTwoPrimOne")
+ .setType(EntityTypeProvider.nameETTwoPrim)
+ .setNullable(false);
+
+ public static final NavigationProperty navPropertyETAllPrimOne_ETAllPrim = new NavigationProperty()
+ .setName("NavPropertyETAllPrimOne")
+ .setType(EntityTypeProvider.nameETAllPrim);
+
+ // EnumProperties --------------------------------------------------------------------------------------------------
+ public static final Property propertyEnumString_ENString = new Property()
+ .setName("PropertyEnumString")
+ .setType(EnumTypeProvider.nameENString);
+
+ // TypeDefinition Properties ---------------------------------------------------------------------------------------
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/SchemaProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/SchemaProvider.java b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/SchemaProvider.java
new file mode 100644
index 0000000..70d9987
--- /dev/null
+++ b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/SchemaProvider.java
@@ -0,0 +1,250 @@
+/*
+ * 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.testutil.techprovider;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.server.api.edm.provider.Action;
+import org.apache.olingo.server.api.edm.provider.ActionImport;
+import org.apache.olingo.server.api.edm.provider.ComplexType;
+import org.apache.olingo.server.api.edm.provider.EntityContainer;
+import org.apache.olingo.server.api.edm.provider.EntitySet;
+import org.apache.olingo.server.api.edm.provider.EntityType;
+import org.apache.olingo.server.api.edm.provider.EnumType;
+import org.apache.olingo.server.api.edm.provider.Function;
+import org.apache.olingo.server.api.edm.provider.FunctionImport;
+import org.apache.olingo.server.api.edm.provider.Schema;
+import org.apache.olingo.server.api.edm.provider.Singleton;
+
+public class SchemaProvider {
+
+ private EdmTechProvider prov;
+
+ public static final String nameSpace = "com.sap.odata.test1";
+
+ public SchemaProvider(final EdmTechProvider prov) {
+ this.prov = prov;
+ }
+
+ public List<Schema> getSchemas() throws ODataException {
+ List<Schema> schemas = new ArrayList<Schema>();
+ Schema schema = new Schema();
+ schema.setNamespace("com.sap.odata.test1");
+ schema.setAlias("Namespace1_Alias");
+ schemas.add(schema);
+ // EnumTypes
+ List<EnumType> enumTypes = new ArrayList<EnumType>();
+ schema.setEnumTypes(enumTypes);
+ enumTypes.add(prov.getEnumType(EnumTypeProvider.nameENString));
+ // EntityTypes
+ List<EntityType> entityTypes = new ArrayList<EntityType>();
+ schema.setEntityTypes(entityTypes);
+
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETAllPrim));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETCollAllPrim));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETTwoPrim));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETMixPrimCollComp));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETTwoKeyTwoPrim));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETBase));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETTwoBase));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETAllKey));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETCompAllPrim));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETCompCollAllPrim));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETCompComp));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETCompCollComp));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETMedia));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETFourKeyAlias));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETServerSidePaging));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETAllNullable));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETKeyNav));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETTwoKeyNav));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETTwoBaseTwoKeyNav));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETCompMixPrimCollComp));
+ entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETKeyPrimNav));
+
+ // ComplexTypes
+ List<ComplexType> complexType = new ArrayList<ComplexType>();
+ schema.setComplexTypes(complexType);
+ complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTPrim));
+ complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTAllPrim));
+ complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTCollAllPrim));
+ complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTTwoPrim));
+ complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTMixPrimCollComp));
+ complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTBase));
+ complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTTwoBase));
+ complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTCompComp));
+ complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTCompCollComp));
+ complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTPrimComp));
+ complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTNavFiveProp));
+ complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTPrimEnum));
+ complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTBasePrimCompNav));
+ complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTTwoBasePrimCompNav));
+ complexType.add(prov.getComplexType(ComplexTypeProvider.nameCTCompNav));
+
+ // TypeDefinitions
+
+ // Actions
+ List<Action> actions = new ArrayList<Action>();
+ schema.setActions(actions);
+ actions.addAll(prov.getActions(ActionProvider.nameBAETTwoKeyNavRTETTwoKeyNav));
+ actions.addAll(prov.getActions(ActionProvider.nameBAESAllPrimRTETAllPrim));
+ actions.addAll(prov.getActions(ActionProvider.nameBAESTwoKeyNavRTESTwoKeyNav));
+ actions.addAll(prov.getActions(ActionProvider.nameBAETBaseTwoKeyNavRTETBaseTwoKeyNav));
+ actions.addAll(prov.getActions(ActionProvider.nameBAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav));
+ actions.addAll(prov.getActions(ActionProvider.nameUARTPrimParam));
+ actions.addAll(prov.getActions(ActionProvider.nameUARTPrimCollParam));
+ actions.addAll(prov.getActions(ActionProvider.nameUARTCompParam));
+ actions.addAll(prov.getActions(ActionProvider.nameUARTCompCollParam));
+ actions.addAll(prov.getActions(ActionProvider.nameUARTETParam));
+ actions.addAll(prov.getActions(ActionProvider.nameUARTESParam));
+
+ // Functions
+ List<Function> functions = new ArrayList<Function>();
+ schema.setFunctions(functions);
+
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFNRTInt16));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTETKeyNav));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTETTwoKeyNavParam));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTETTwoKeyNavParamCTTwoPrim));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTStringTwoParam));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTESTwoKeyNavParam));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTString));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollStringTwoParam));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollString));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCTAllPrimTwoParam));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCTTwoPrimParam));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollCTTwoPrimParam));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCTTwoPrim));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTCollCTTwoPrim));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTETMedia));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFNRTESMixPrimCollCompTwoParam));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTETAllPrimTwoParam));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFCRTESMixPrimCollCompTwoParam));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameUFNRTCollCTNavFiveProp));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTESTwoKeyNav));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCStringRTESTwoKeyNav));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCETBaseTwoKeyNavRTETTwoKeyNav));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESBaseTwoKeyNavRTESBaseTwoKey));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESAllPrimRTCTAllPrim));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTCTTwoPrim));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTCollCTTwoPrim));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTString));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTCollString));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCETTwoKeyNavRTESTwoKeyNav));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCETBaseTwoKeyNavRTESTwoKeyNav));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCSINavRTESTwoKeyNav));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCETBaseTwoKeyNavRTESBaseTwoKey));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCCollStringRTESTwoKeyNav));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCCTPrimCompRTESTwoKeyNav));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCCTPrimCompRTESBaseTwoKeyNav));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCCollCTPrimCompRTESAllPrim));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTTwoKeyNav));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESKeyNavRTETKeyNav));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCETKeyNavRTETKeyNav));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFESTwoKeyNavRTESTwoKeyNav));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCETTwoKeyNavRTETTwoKeyNav));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCETTwoKeyNavRTCTTwoPrim));
+
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTCTNavFiveProp));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTCollCTNavFiveProp));
+
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTStringParam));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESKeyNavRTETKeyNavParam));
+ functions.addAll(prov.getFunctions(FunctionProvider.nameBFCCTPrimCompRTETTwoKeyNavParam));
+ // functions.addAll(prov.getFunctions(FunctionProvider.nameBFCCTPrimCompRTESTwoKeyNavParam));
+
+ // EntityContainer
+ EntityContainer container = new EntityContainer();
+ schema.setEntityContainer(container);
+ container.setName(ContainerProvider.nameContainer.getName());
+
+ // EntitySets
+ List<EntitySet> entitySets = new ArrayList<EntitySet>();
+ container.setEntitySets(entitySets);
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESAllPrim"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESCollAllPrim"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESTwoPrim"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESMixPrimCollComp"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESBase"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESTwoBase"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESTwoKeyTwoPrim"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESBaseTwoKeyTwoPrim"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESTwoBaseTwoKeyTwoPrim"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESAllKey"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESCompAllPrim"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESCompCollAllPrim"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESCompComp"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESCompCollComp"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESMedia"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESKeyTwoKeyComp"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESInvisible"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESServerSidePaging"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESAllNullable"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESKeyNav"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESTwoKeyNav"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESBaseTwoKeyNav"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESCompMixPrimCollComp"));
+ entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESFourKeyAlias"));
+
+ // Singletons
+ List<Singleton> singletons = new ArrayList<Singleton>();
+ container.setSingletons(singletons);
+ singletons.add(prov.getSingleton(ContainerProvider.nameContainer, "SI"));
+ singletons.add(prov.getSingleton(ContainerProvider.nameContainer, "SINav"));
+ singletons.add(prov.getSingleton(ContainerProvider.nameContainer, "SIMedia"));
+
+ // ActionImports
+ List<ActionImport> actionImports = new ArrayList<ActionImport>();
+ container.setActionImports(actionImports);
+ actionImports.add(prov.getActionImport(ContainerProvider.nameContainer, "AIRTPrimParam"));
+ actionImports.add(prov.getActionImport(ContainerProvider.nameContainer, "AIRTPrimCollParam"));
+ actionImports.add(prov.getActionImport(ContainerProvider.nameContainer, "AIRTCompParam"));
+ actionImports.add(prov.getActionImport(ContainerProvider.nameContainer, "AIRTCompCollParam"));
+ actionImports.add(prov.getActionImport(ContainerProvider.nameContainer, "AIRTETParam"));
+ actionImports.add(prov.getActionImport(ContainerProvider.nameContainer, "AIRTETCollAllPrimParam"));
+
+ // FunctionImports
+ List<FunctionImport> functionImports = new ArrayList<FunctionImport>();
+ container.setFunctionImports(functionImports);
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FINRTInt16"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FINInvisibleRTInt16"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FINInvisible2RTInt16"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTETKeyNav"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTETTwoKeyNavParam"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTStringTwoParam"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollStringTwoParam"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCTAllPrimTwoParam"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTESMixPrimCollCompTwoParam"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FINRTESMixPrimCollCompTwoParam"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollCTTwoPrim"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTETMedia"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCTTwoPrimParam"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCTTwoPrim"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollString"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTString"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTESTwoKeyNavParam"));
+ functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollCTTwoPrimParam"));
+
+ return schemas;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/TypeDefinitionProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/TypeDefinitionProvider.java b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/TypeDefinitionProvider.java
new file mode 100644
index 0000000..dc34b31
--- /dev/null
+++ b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/TypeDefinitionProvider.java
@@ -0,0 +1,30 @@
+/*
+ * 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.testutil.techprovider;
+
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.server.api.edm.provider.TypeDefinition;
+
+public class TypeDefinitionProvider {
+
+ public TypeDefinition getTypeDefinition(final FullQualifiedName typeDefinitionName) {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/main/resources/simplelogger.properties
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/main/resources/simplelogger.properties b/lib/server-ref/src/main/resources/simplelogger.properties
new file mode 100644
index 0000000..2a3350c
--- /dev/null
+++ b/lib/server-ref/src/main/resources/simplelogger.properties
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+org.slf4j.simpleLogger.defaultLogLevel=debug
+org.slf4j.simpleLogger.logFile=System.out
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/main/webapp/WEB-INF/web.xml b/lib/server-ref/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..cc7de77
--- /dev/null
+++ b/lib/server-ref/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ id="WebApp_ID" version="2.5">
+
+ <display-name>Apache Olingo OData 4.0 Reference Scenario Service</display-name>
+
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+
+ <servlet>
+ <servlet-name>ODataServlet</servlet-name>
+ <servlet-class>org.apache.olingo.ref.ReferenceServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>ODataServlet</servlet-name>
+ <url-pattern>/odata.svc/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/main/webapp/index.html
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/main/webapp/index.html b/lib/server-ref/src/main/webapp/index.html
new file mode 100644
index 0000000..e25f4fb
--- /dev/null
+++ b/lib/server-ref/src/main/webapp/index.html
@@ -0,0 +1,32 @@
+<html>
+<!--
+ 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.
+-->
+
+<body>
+ <h1>Olingo OData 4.0 Reference Scenario Service</h1>
+ <hr>
+ <h2>Reference Scenario Service</h2>
+ <lu>
+ <li><a href="odata.svc/">Service Document</a></li>
+ <li><a href="odata.svc/$metadata">Metadata</a></li>
+ </lu>
+
+</body>
+
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
new file mode 100644
index 0000000..4bf5a99
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
@@ -0,0 +1,133 @@
+/*
+ * 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.serializer.json;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmFunctionImport;
+import org.apache.olingo.commons.api.edm.EdmSingleton;
+import org.apache.olingo.server.api.ODataServer;
+import org.apache.olingo.server.api.serializer.ODataFormat;
+import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.core.testutil.StringUtils;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ServiceDocumentTest {
+
+ private Edm edm;
+
+ @Before
+ public void before() {
+
+ EdmEntitySet edmEntitySet1 = mock(EdmEntitySet.class);
+ when(edmEntitySet1.getName()).thenReturn("entitySetName1");
+ when(edmEntitySet1.isIncludeInServiceDocument()).thenReturn(true);
+
+ EdmEntitySet edmEntitySet2 = mock(EdmEntitySet.class);
+ when(edmEntitySet2.getName()).thenReturn("entitySetName2");
+ when(edmEntitySet2.isIncludeInServiceDocument()).thenReturn(true);
+
+ EdmEntitySet edmEntitySet3 = mock(EdmEntitySet.class);
+ when(edmEntitySet3.getName()).thenReturn("entitySetName3");
+ when(edmEntitySet3.isIncludeInServiceDocument()).thenReturn(false);
+
+ List<EdmEntitySet> entitySets = new ArrayList<EdmEntitySet>();
+ entitySets.add(edmEntitySet1);
+ entitySets.add(edmEntitySet2);
+ entitySets.add(edmEntitySet3);
+
+ EdmFunctionImport functionImport1 = mock(EdmFunctionImport.class);
+ when(functionImport1.getName()).thenReturn("functionImport1");
+ when(functionImport1.isIncludeInServiceDocument()).thenReturn(true);
+
+ EdmFunctionImport functionImport2 = mock(EdmFunctionImport.class);
+ when(functionImport2.getName()).thenReturn("functionImport2");
+ when(functionImport2.isIncludeInServiceDocument()).thenReturn(true);
+
+ EdmFunctionImport functionImport3 = mock(EdmFunctionImport.class);
+ when(functionImport3.getName()).thenReturn("functionImport3");
+ when(functionImport3.isIncludeInServiceDocument()).thenReturn(false);
+
+ List<EdmFunctionImport> functionImports = new ArrayList<EdmFunctionImport>();
+ functionImports.add(functionImport1);
+ functionImports.add(functionImport2);
+ functionImports.add(functionImport3);
+
+ EdmSingleton singleton1 = mock(EdmSingleton.class);
+ when(singleton1.getName()).thenReturn("singleton1");
+
+ EdmSingleton singleton2 = mock(EdmSingleton.class);
+ when(singleton2.getName()).thenReturn("singleton2");
+
+ EdmSingleton singleton3 = mock(EdmSingleton.class);
+ when(singleton3.getName()).thenReturn("singleton3");
+
+ List<EdmSingleton> singletons = new ArrayList<EdmSingleton>();
+ singletons.add(singleton1);
+ singletons.add(singleton2);
+ singletons.add(singleton3);
+
+ EdmEntityContainer edmEntityContainer = mock(EdmEntityContainer.class);
+ when(edmEntityContainer.getEntitySets()).thenReturn(entitySets);
+ when(edmEntityContainer.getFunctionImports()).thenReturn(functionImports);
+ when(edmEntityContainer.getSingletons()).thenReturn(singletons);
+
+ edm = mock(Edm.class);
+ when(edm.getEntityContainer(null)).thenReturn(edmEntityContainer);
+ }
+
+ @Test
+ public void writeServiceDocumentJson() throws Exception {
+ String serviceRoot = "http://localhost:8080/odata.svc";
+
+ ODataServer server = ODataServer.newInstance();
+ assertNotNull(server);
+
+ ODataSerializer serializer = server.getSerializer(ODataFormat.JSON);
+ assertNotNull(serializer);
+
+ InputStream result = serializer.serviceDocument(edm, serviceRoot);
+ assertNotNull(result);
+ String jsonString = StringUtils.inputStreamToString(result, true);
+
+ assertTrue(jsonString.contains("entitySetName1"));
+ assertTrue(jsonString.contains("entitySetName2"));
+ assertFalse(jsonString.contains("entitySetName3"));
+
+ assertTrue(jsonString.contains("functionImport1"));
+ assertTrue(jsonString.contains("functionImport2"));
+ assertFalse(jsonString.contains("functionImport3"));
+
+ assertTrue(jsonString.contains("singleton1"));
+ assertTrue(jsonString.contains("singleton2"));
+ assertTrue(jsonString.contains("singleton3"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
new file mode 100644
index 0000000..6a19364
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
@@ -0,0 +1,252 @@
+/*
+ * 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.serializer.xml;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.ODataRuntimeException;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.Target;
+import org.apache.olingo.server.api.ODataServer;
+import org.apache.olingo.server.api.edm.provider.Action;
+import org.apache.olingo.server.api.edm.provider.ActionImport;
+import org.apache.olingo.server.api.edm.provider.ComplexType;
+import org.apache.olingo.server.api.edm.provider.EdmProvider;
+import org.apache.olingo.server.api.edm.provider.EntityContainer;
+import org.apache.olingo.server.api.edm.provider.EntitySet;
+import org.apache.olingo.server.api.edm.provider.EntityType;
+import org.apache.olingo.server.api.edm.provider.EnumMember;
+import org.apache.olingo.server.api.edm.provider.EnumType;
+import org.apache.olingo.server.api.edm.provider.Function;
+import org.apache.olingo.server.api.edm.provider.FunctionImport;
+import org.apache.olingo.server.api.edm.provider.NavigationProperty;
+import org.apache.olingo.server.api.edm.provider.NavigationPropertyBinding;
+import org.apache.olingo.server.api.edm.provider.Parameter;
+import org.apache.olingo.server.api.edm.provider.Property;
+import org.apache.olingo.server.api.edm.provider.ReturnType;
+import org.apache.olingo.server.api.edm.provider.Schema;
+import org.apache.olingo.server.api.edm.provider.Singleton;
+import org.apache.olingo.server.api.edm.provider.TypeDefinition;
+import org.apache.olingo.server.api.serializer.ODataFormat;
+import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
+import org.apache.olingo.server.core.testutil.StringUtils;
+import org.apache.olingo.server.core.testutil.techprovider.EdmTechProvider;
+import org.junit.Test;
+
+public class MetadataDocumentTest {
+
+ @Test(expected = ODataRuntimeException.class)
+ public void metadataOnJsonResultsInException() {
+ ODataSerializer serializer = ODataServer.newInstance().getSerializer(ODataFormat.JSON);
+ serializer.metadataDocument(mock(Edm.class));
+ }
+
+ @Test
+ public void writeMetadataWithEmptyMockedEdm() {
+ ODataSerializer serializer = ODataServer.newInstance().getSerializer(ODataFormat.XML);
+ Edm edm = mock(Edm.class);
+ serializer.metadataDocument(edm);
+ }
+
+ @Test
+ public void writeMetadataWithLocalTestEdm() {
+ ODataSerializer serializer = ODataServer.newInstance().getSerializer(ODataFormat.XML);
+ Edm edm = new EdmProviderImpl(new TestMetadataProvider());
+ InputStream metadata = serializer.metadataDocument(edm);
+ assertNotNull(metadata);
+ String metadataString = StringUtils.inputStreamToString(metadata, false);
+ assertTrue(metadataString
+ .contains("<edmx:Edmx Version=\"4.0\" xmlns:edmx=\"http://docs.oasis-open.org/odata/ns/edmx\">"));
+
+ assertTrue(metadataString
+ .contains("<Schema xmlns=\"http://docs.oasis-open.org/odata/ns/edm\" " +
+ "Namespace=\"namespace\" Alias=\"alias\">"));
+
+ assertTrue(metadataString
+ .contains("<EntityType Name=\"ETBaseName\"><Property Name=\"P1\" Type=\"Edm.Int16\"/><NavigationProperty " +
+ "Name=\"N1\" Type=\"namespace.ETBaseName\" Nullable=\"true\" Partner=\"N1\"/></EntityType>"));
+
+ assertTrue(metadataString
+ .contains("<EntityType Name=\"ETDerivedName\" BaseType=\"namespace.ETBaseName\"><Property Name=\"P2\" " +
+ "Type=\"Edm.Int16\"/><NavigationProperty Name=\"N2\" Type=\"namespace.ETDerivedName\" Nullable=\"true\" " +
+ "Partner=\"N2\"/></EntityType>"));
+
+ assertTrue(metadataString
+ .contains("<ComplexType Name=\"CTBaseName\"><Property Name=\"P1\" Type=\"Edm.Int16\"/><NavigationProperty " +
+ "Name=\"N1\" Type=\"namespace.ETBaseName\" Nullable=\"true\" Partner=\"N1\"/></ComplexType>"));
+
+ assertTrue(metadataString
+ .contains("<ComplexType Name=\"CTDerivedName\" BaseType=\"namespace.CTBaseName\"><Property Name=\"P2\" " +
+ "Type=\"Edm.Int16\"/><NavigationProperty Name=\"N2\" Type=\"namespace.ETDerivedName\" Nullable=\"true\" " +
+ "Partner=\"N2\"/></ComplexType>"));
+
+ assertTrue(metadataString.contains("<TypeDefinition Name=\"typeDef\" Type=\"Edm.Int16\"/>"));
+
+ assertTrue(metadataString.contains("<Action Name=\"ActionWOParameter\" IsBound=\"false\"/>"));
+
+ assertTrue(metadataString
+ .contains("<Action Name=\"ActionName\" IsBound=\"true\"><Parameter Name=\"param\" Type=\"Edm.Int16\"/>" +
+ "<Parameter Name=\"param2\" Type=\"Collection(Edm.Int16)\"/><ReturnType Type=\"namespace.CTBaseName\"/>" +
+ "</Action>"));
+
+ assertTrue(metadataString
+ .contains("<Function Name=\"FunctionWOParameter\" IsBound=\"false\" IsComposable=\"false\"><ReturnType " +
+ "Type=\"namespace.CTBaseName\"/></Function>"));
+
+ assertTrue(metadataString
+ .contains("<Function Name=\"FunctionName\" IsBound=\"true\" IsComposable=\"false\"><Parameter Name=\"param\" " +
+ "Type=\"Edm.Int16\"/><Parameter Name=\"param2\" Type=\"Collection(Edm.Int16)\"/><ReturnType " +
+ "Type=\"namespace.CTBaseName\"/></Function>"));
+
+ assertTrue(metadataString.contains("<EntityContainer Name=\"container\">"));
+
+ assertTrue(metadataString
+ .contains("<EntitySet Name=\"EntitySetName\" EntityType=\"namespace.ETBaseName\"><NavigationPropertyBinding " +
+ "Path=\"N1\" Target=\"namespace.container/EntitySetName\"/></EntitySet>"));
+ assertTrue(metadataString
+ .contains("<Singleton Name=\"SingletonName\" EntityType=\"namespace.ETBaseName\"><NavigationPropertyBinding " +
+ "Path=\"N1\" Target=\"namespace.container/EntitySetName\"/></Singleton>"));
+
+ assertTrue(metadataString.contains("<ActionImport Name=\"actionImport\" Action=\"namespace.ActionWOParameter\"/>"));
+
+ assertTrue(metadataString
+ .contains("<FunctionImport Name=\"actionImport\" Function=\"namespace.FunctionName\" " +
+ "EntitySet=\"namespace.EntitySetName\" IncludeInServiceDocument=\"false\"/>"));
+
+ assertTrue(metadataString.contains("</EntityContainer></Schema></edmx:DataServices></edmx:Edmx>"));
+ }
+
+ @Test
+ public void writeMetadataWithTechnicalScenario() {
+ ODataSerializer serializer = ODataServer.newInstance().getSerializer(ODataFormat.XML);
+ EdmProviderImpl edm = new EdmProviderImpl(new EdmTechProvider());
+ InputStream metadata = serializer.metadataDocument(edm);
+ assertNotNull(metadata);
+ // The technical scenario is too big to verify. We are content for now to make sure we can serialize it.
+ // System.out.println(StringUtils.inputStreamToString(metadata, false));
+ }
+
+ private class TestMetadataProvider extends EdmProvider {
+
+ @Override
+ public List<Schema> getSchemas() throws ODataException {
+ Property p1 = new Property().setName("P1").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName());
+ String ns = "namespace";
+ NavigationProperty n1 = new NavigationProperty().setName("N1")
+ .setType(new FullQualifiedName(ns, "ETBaseName")).setNullable(true).setPartner("N1");
+ Property p2 = new Property().setName("P2").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName());
+ NavigationProperty n2 = new NavigationProperty().setName("N2")
+ .setType(new FullQualifiedName(ns, "ETDerivedName")).setNullable(true).setPartner("N2");
+ Schema schema = new Schema().setNamespace(ns).setAlias("alias");
+ List<ComplexType> complexTypes = new ArrayList<ComplexType>();
+ schema.setComplexTypes(complexTypes);
+ ComplexType ctBase =
+ new ComplexType().setName("CTBaseName").setProperties(Arrays.asList(p1)).setNavigationProperties(
+ Arrays.asList(n1));
+ complexTypes.add(ctBase);
+ ComplexType ctDerived =
+ new ComplexType().setName("CTDerivedName").setBaseType(new FullQualifiedName(ns, "CTBaseName"))
+ .setProperties(Arrays.asList(p2)).setNavigationProperties(Arrays.asList(n2));
+ complexTypes.add(ctDerived);
+
+ List<EntityType> entityTypes = new ArrayList<EntityType>();
+ schema.setEntityTypes(entityTypes);
+ EntityType etBase =
+ new EntityType().setName("ETBaseName").setProperties(Arrays.asList(p1)).setNavigationProperties(
+ Arrays.asList(n1));
+ entityTypes.add(etBase);
+ EntityType etDerived =
+ new EntityType().setName("ETDerivedName").setBaseType(new FullQualifiedName(ns, "ETBaseName"))
+ .setProperties(Arrays.asList(p2)).setNavigationProperties(Arrays.asList(n2));
+ entityTypes.add(etDerived);
+
+ List<Action> actions = new ArrayList<Action>();
+ schema.setActions(actions);
+ // TODO:EntitySetPath
+ actions.add((new Action().setName("ActionWOParameter")));
+ List<Parameter> parameters = new ArrayList<Parameter>();
+ parameters.add(new Parameter().setName("param").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()));
+ parameters.add(new Parameter().setName("param2").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName())
+ .setCollection(true));
+ actions.add(new Action().setName("ActionName").setBound(true).setParameters(parameters).setReturnType(
+ new ReturnType().setType(new FullQualifiedName(ns, "CTBaseName"))));
+
+ List<Function> functions = new ArrayList<Function>();
+ schema.setFunctions(functions);
+ functions.add((new Function().setName("FunctionWOParameter")
+ .setReturnType(new ReturnType().setType(new FullQualifiedName(ns, "CTBaseName")))));
+ functions.add(new Function().setName("FunctionName").setBound(true).setParameters(parameters).setReturnType(
+ new ReturnType().setType(new FullQualifiedName(ns, "CTBaseName"))));
+
+ List<EnumType> enumTypes = new ArrayList<EnumType>();
+ schema.setEnumTypes(enumTypes);
+ List<EnumMember> members = new ArrayList<EnumMember>();
+ members.add(new EnumMember().setName("member").setValue("1"));
+ enumTypes.add(new EnumType().setName("EnumName").setFlags(true).setMembers(members));
+
+ List<TypeDefinition> typeDefinitions = new ArrayList<TypeDefinition>();
+ schema.setTypeDefinitions(typeDefinitions);
+ typeDefinitions.add(new TypeDefinition().setName("typeDef")
+ .setUnderlyingType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()));
+
+ EntityContainer container = new EntityContainer().setName("container");
+ schema.setEntityContainer(container);
+
+ List<ActionImport> actionImports = new ArrayList<ActionImport>();
+ container.setActionImports(actionImports);
+ actionImports.add(new ActionImport().setName("actionImport").setAction(
+ new FullQualifiedName(ns, "ActionWOParameter")).setEntitySet(
+ new Target().setEntityContainer(new FullQualifiedName(ns, "container")).setTargetName("EntitySetName")));
+
+ List<FunctionImport> functionImports = new ArrayList<FunctionImport>();
+ container.setFunctionImports(functionImports);
+ functionImports.add(new FunctionImport().setName("actionImport").setFunction(
+ new FullQualifiedName(ns, "FunctionName")).setEntitySet(
+ new Target().setEntityContainer(new FullQualifiedName(ns, "container")).setTargetName("EntitySetName")));
+
+ List<EntitySet> entitySets = new ArrayList<EntitySet>();
+ container.setEntitySets(entitySets);
+ List<NavigationPropertyBinding> nPB = new ArrayList<NavigationPropertyBinding>();
+ nPB.add(new NavigationPropertyBinding().setPath("N1").setTarget(
+ new Target().setEntityContainer(new FullQualifiedName(ns, "container")).setTargetName("EntitySetName")));
+ entitySets.add(new EntitySet().setName("EntitySetName").setType(new FullQualifiedName(ns, "ETBaseName"))
+ .setNavigationPropertyBindings(nPB));
+
+ List<Singleton> singletons = new ArrayList<Singleton>();
+ container.setSingletons(singletons);
+ singletons.add(new Singleton().setName("SingletonName").setType(new FullQualifiedName(ns, "ETBaseName"))
+ .setNavigationPropertyBindings(nPB));
+
+ List<Schema> schemas = new ArrayList<Schema>();
+ schemas.add(schema);
+ return schemas;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java
new file mode 100644
index 0000000..f54ad57
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/RawUriTest.java
@@ -0,0 +1,151 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.olingo.server.core.uri.parser.RawUri;
+import org.apache.olingo.server.core.uri.parser.UriDecoder;
+import org.apache.olingo.server.core.uri.parser.UriParserSyntaxException;
+import org.junit.Test;
+
+public class RawUriTest {
+
+ private RawUri runRawParser(final String uri, final int scipSegments) throws UriParserSyntaxException {
+ return UriDecoder.decodeUri(uri, scipSegments);
+ }
+
+ @Test
+ public void testOption() throws Exception {
+ RawUri rawUri;
+ rawUri = runRawParser("?", 0);
+ checkOptionCount(rawUri, 0);
+
+ rawUri = runRawParser("?a", 0);
+ checkOption(rawUri, 0, "a", "");
+
+ rawUri = runRawParser("?a=b", 0);
+ checkOption(rawUri, 0, "a", "b");
+
+ rawUri = runRawParser("?=", 0);
+ checkOption(rawUri, 0, "", "");
+
+ rawUri = runRawParser("?=b", 0);
+ checkOption(rawUri, 0, "", "b");
+
+ rawUri = runRawParser("?a&c", 0);
+ checkOption(rawUri, 0, "a", "");
+ checkOption(rawUri, 1, "c", "");
+
+ rawUri = runRawParser("?a=b&c", 0);
+ checkOption(rawUri, 0, "a", "b");
+ checkOption(rawUri, 1, "c", "");
+
+ rawUri = runRawParser("?a=b&c=d", 0);
+ checkOption(rawUri, 0, "a", "b");
+ checkOption(rawUri, 1, "c", "d");
+
+ rawUri = runRawParser("?=&=", 0);
+ checkOption(rawUri, 0, "", "");
+ checkOption(rawUri, 1, "", "");
+
+ rawUri = runRawParser("?=&c=d", 0);
+ checkOption(rawUri, 0, "", "");
+ checkOption(rawUri, 1, "c", "d");
+ }
+
+ private void checkOption(final RawUri rawUri, final int index, final String name, final String value) {
+ RawUri.QueryOption option = rawUri.queryOptionListDecoded.get(index);
+
+ assertEquals(name, option.name);
+ assertEquals(value, option.value);
+
+ }
+
+ private void checkOptionCount(final RawUri rawUri, final int count) {
+ assertEquals(count, rawUri.queryOptionListDecoded.size());
+ }
+
+ @Test
+ public void testPath() throws Exception {
+ RawUri rawUri;
+
+ rawUri = runRawParser("http://test.org", 0);
+ checkPath(rawUri, "", new ArrayList<String>());
+
+ rawUri = runRawParser("http://test.org/", 0);
+ checkPath(rawUri, "/", Arrays.asList(""));
+
+ rawUri = runRawParser("http://test.org/entitySet", 0);
+ checkPath(rawUri, "/entitySet", Arrays.asList("entitySet"));
+
+ rawUri = runRawParser("http://test.org/nonServiceSegment/entitySet", 0);
+ checkPath(rawUri, "/nonServiceSegment/entitySet", Arrays.asList("nonServiceSegment", "entitySet"));
+
+ rawUri = runRawParser("http://test.org/nonServiceSegment/entitySet", 1);
+ checkPath(rawUri, "/nonServiceSegment/entitySet", Arrays.asList("entitySet"));
+
+ rawUri = runRawParser("", 0);
+ checkPath(rawUri, "", new ArrayList<String>());
+
+ rawUri = runRawParser("/", 0);
+ checkPath(rawUri, "/", Arrays.asList(""));
+
+ rawUri = runRawParser("/entitySet", 0);
+ checkPath(rawUri, "/entitySet", Arrays.asList("entitySet"));
+
+ rawUri = runRawParser("entitySet", 0);
+ checkPath(rawUri, "entitySet", Arrays.asList("entitySet"));
+
+ rawUri = runRawParser("nonServiceSegment/entitySet", 0);
+ checkPath(rawUri, "nonServiceSegment/entitySet", Arrays.asList("nonServiceSegment", "entitySet"));
+
+ rawUri = runRawParser("nonServiceSegment/entitySet", 1);
+ checkPath(rawUri, "nonServiceSegment/entitySet", Arrays.asList("entitySet"));
+
+ rawUri = runRawParser("http://test.org/a?abc=xx+yz", 0);
+ }
+
+ @Test
+ public void testSplitt() {
+ UriDecoder.splitt("", '/');
+ UriDecoder.splitt("/", '/');
+ UriDecoder.splitt("a", '/');
+ UriDecoder.splitt("a/", '/');
+ UriDecoder.splitt("/a", '/');
+ UriDecoder.splitt("a/a", '/');
+ }
+
+ private void checkPath(final RawUri rawUri, final String path, final List<String> list) {
+ assertEquals(path, rawUri.path);
+
+ assertEquals(list.size(), rawUri.pathSegmentListDecoded.size());
+
+ int i = 0;
+ while (i < list.size()) {
+ assertEquals(list.get(i), rawUri.pathSegmentListDecoded.get(i));
+ i++;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java
new file mode 100644
index 0000000..a9d516d
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java
@@ -0,0 +1,201 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.server.api.uri.UriInfoAll;
+import org.apache.olingo.server.api.uri.UriInfoBatch;
+import org.apache.olingo.server.api.uri.UriInfoCrossjoin;
+import org.apache.olingo.server.api.uri.UriInfoEntityId;
+import org.apache.olingo.server.api.uri.UriInfoKind;
+import org.apache.olingo.server.api.uri.UriInfoMetadata;
+import org.apache.olingo.server.api.uri.UriInfoResource;
+import org.apache.olingo.server.api.uri.UriInfoService;
+import org.apache.olingo.server.api.uri.queryoption.CustomQueryOption;
+import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
+import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
+import org.apache.olingo.server.core.testutil.techprovider.EntityTypeProvider;
+import org.apache.olingo.server.core.uri.queryoption.CountOptionImpl;
+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.FormatOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.IdOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.LevelsOptionImpl;
+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.SearchOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.SelectOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.SkipOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.SkipTokenOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.TopOptionImpl;
+import org.junit.Test;
+
+public class UriInfoImplTest {
+
+ Edm edm = new EdmProviderImpl(new EdmTechTestProvider());
+
+ @Test
+ public void testKind() {
+ UriInfoImpl uriInfo = new UriInfoImpl().setKind(UriInfoKind.all);
+ assertEquals(UriInfoKind.all, uriInfo.getKind());
+ }
+
+ @Test
+ public void testCasts() {
+ UriInfoImpl uriInfo = new UriInfoImpl();
+
+ UriInfoAll all = uriInfo.asUriInfoAll();
+ assertEquals(uriInfo, all);
+
+ UriInfoBatch batch = uriInfo.asUriInfoBatch();
+ assertEquals(uriInfo, batch);
+
+ UriInfoCrossjoin crossjoin = uriInfo.asUriInfoCrossjoin();
+ assertEquals(uriInfo, crossjoin);
+
+ UriInfoEntityId entityID = uriInfo.asUriInfoEntityId();
+ assertEquals(uriInfo, entityID);
+
+ UriInfoMetadata metadata = uriInfo.asUriInfoMetadata();
+ assertEquals(uriInfo, metadata);
+
+ UriInfoResource resource = uriInfo.asUriInfoResource();
+ assertEquals(uriInfo, resource);
+
+ UriInfoService service = uriInfo.asUriInfoService();
+ assertEquals(uriInfo, service);
+
+ }
+
+ @Test
+ public void testEntityNames() {
+ UriInfoImpl uriInfo = new UriInfoImpl();
+ uriInfo.addEntitySetName("A");
+ uriInfo.addEntitySetName("B");
+
+ assertEquals("A", uriInfo.getEntitySetNames().get(0));
+ assertEquals("B", uriInfo.getEntitySetNames().get(1));
+
+ }
+
+ @Test
+ public void testResourceParts() {
+ UriInfoImpl uriInfo = new UriInfoImpl();
+
+ UriResourceActionImpl action = new UriResourceActionImpl();
+ UriResourceEntitySetImpl entitySet0 = new UriResourceEntitySetImpl();
+ UriResourceEntitySetImpl entitySet1 = new UriResourceEntitySetImpl();
+
+ uriInfo.addResourcePart(action);
+ uriInfo.addResourcePart(entitySet0);
+
+ assertEquals(action, uriInfo.getUriResourceParts().get(0));
+ assertEquals(entitySet0, uriInfo.getUriResourceParts().get(1));
+
+ assertEquals(entitySet0, uriInfo.getLastResourcePart());
+
+ uriInfo.addResourcePart(entitySet1);
+ assertEquals(entitySet1, uriInfo.getLastResourcePart());
+ }
+
+ @Test
+ public void testCustomQueryOption() {
+ UriInfoImpl uriInfo = new UriInfoImpl();
+
+ List<QueryOptionImpl> queryOptions = new ArrayList<QueryOptionImpl>();
+
+ ExpandOptionImpl expand = new ExpandOptionImpl();
+ FilterOptionImpl filter = new FilterOptionImpl();
+ FormatOptionImpl format = new FormatOptionImpl();
+ IdOptionImpl id = new IdOptionImpl();
+ CountOptionImpl inlinecount = new CountOptionImpl();
+ OrderByOptionImpl orderby = new OrderByOptionImpl();
+ SearchOptionImpl search = new SearchOptionImpl();
+ SelectOptionImpl select = new SelectOptionImpl();
+ SkipOptionImpl skip = new SkipOptionImpl();
+ SkipTokenOptionImpl skipToken = new SkipTokenOptionImpl();
+ TopOptionImpl top = new TopOptionImpl();
+ LevelsOptionImpl levels = new LevelsOptionImpl();
+
+ CustomQueryOptionImpl customOption0 = new CustomQueryOptionImpl();
+ customOption0.setText("A");
+ CustomQueryOptionImpl customOption1 = new CustomQueryOptionImpl();
+ customOption1.setText("B");
+
+ QueryOptionImpl queryOption = new QueryOptionImpl();
+
+ queryOptions.add(expand);
+ queryOptions.add(filter);
+ queryOptions.add(format);
+ queryOptions.add(id);
+ queryOptions.add(inlinecount);
+ queryOptions.add(orderby);
+ queryOptions.add(search);
+ queryOptions.add(select);
+ queryOptions.add(skip);
+ queryOptions.add(skipToken);
+ queryOptions.add(top);
+ queryOptions.add(customOption0);
+ queryOptions.add(customOption1);
+ queryOptions.add(levels);// not stored
+ queryOptions.add(queryOption);// not stored
+ uriInfo.setQueryOptions(queryOptions);
+
+ assertEquals(expand, uriInfo.getExpandOption());
+ assertEquals(filter, uriInfo.getFilterOption());
+ assertEquals(format, uriInfo.getFormatOption());
+ assertEquals(id, uriInfo.getIdOption());
+ assertEquals(inlinecount, uriInfo.getCountOption());
+ assertEquals(orderby, uriInfo.getOrderByOption());
+ assertEquals(search, uriInfo.getSearchOption());
+ assertEquals(select, uriInfo.getSelectOption());
+ assertEquals(skip, uriInfo.getSkipOption());
+ assertEquals(skipToken, uriInfo.getSkipTokenOption());
+ assertEquals(top, uriInfo.getTopOption());
+
+ List<CustomQueryOption> customQueryOptions = uriInfo.getCustomQueryOptions();
+ assertEquals(customOption0, customQueryOptions.get(0));
+ assertEquals(customOption1, customQueryOptions.get(1));
+ }
+
+ @Test
+ public void testFragment() {
+ UriInfoImpl uriInfo = new UriInfoImpl();
+ uriInfo.setFragment("F");
+ assertEquals("F", uriInfo.getFragment());
+ }
+
+ @Test
+ public void testEntityTypeCast() {
+ UriInfoImpl uriInfo = new UriInfoImpl();
+ EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETKeyNav);
+ assertNotNull(entityType);
+
+ uriInfo.setEntityTypeCast(entityType);
+ assertEquals(entityType, uriInfo.getEntityTypeCast());
+ }
+}
[04/15] [OLINGO-266] refactor ref module to server-ref
Posted by sk...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java
new file mode 100644
index 0000000..e8aa9ce
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestLexer.java
@@ -0,0 +1,248 @@
+/*
+ * 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.antlr;
+
+import org.antlr.v4.runtime.Lexer;
+import org.apache.olingo.server.core.uri.testutil.TokenValidator;
+import org.junit.Test;
+
+public class TestLexer {
+
+ private TokenValidator test = null;
+
+ private static final String cPCT_ENCODED = "%45%46%47" + "%22" + "%5C";// last two chars are not in
+ // cPCT_ENCODED_UNESCAPED
+ private static final String cUNRESERVED = "ABCabc123-._~";
+ private static final String cOTHER_DELIMS = "!()*+,;";
+ private static final String cSUB_DELIMS = "$&'=" + cOTHER_DELIMS;
+
+ private static final String cPCHAR = cUNRESERVED + cPCT_ENCODED + cSUB_DELIMS + ":@";
+
+ public TestLexer() {
+ test = new TokenValidator();
+ }
+
+ @Test
+ public void test() {
+
+ // test.log(1).run("ESAllPrim?$orderby=PropertyDouble eq 3.5E+38");
+ }
+
+ // ;------------------------------------------------------------------------------
+ // ; 0. URI
+ // ;------------------------------------------------------------------------------
+
+ @Test
+ public void testUriTokens() {
+ test.globalMode(UriLexer.MODE_QUERY);
+ test.run("#").isText("#").isType(UriLexer.FRAGMENT);
+ test.run("$count").isText("$count").isType(UriLexer.COUNT);
+ test.run("$ref").isText("$ref").isType(UriLexer.REF);
+ test.run("$value").isText("$value").isType(UriLexer.VALUE);
+ }
+
+ // ;------------------------------------------------------------------------------
+ // ; 2. Query Options
+ // ;------------------------------------------------------------------------------
+ @Test
+ public void testQueryOptionsTokens() {
+
+ test.globalMode(UriLexer.MODE_QUERY);
+ test.run("$skip=1").isAllText("$skip=1").isType(UriLexer.SKIP);
+ test.run("$skip=2").isAllText("$skip=2").isType(UriLexer.SKIP);
+ test.run("$skip=123").isAllText("$skip=123").isType(UriLexer.SKIP);
+
+ test.run("$top=1").isAllText("$top=1").isType(UriLexer.TOP);
+ test.run("$top=2").isAllText("$top=2").isType(UriLexer.TOP);
+ test.run("$top=123").isAllText("$top=123").isType(UriLexer.TOP);
+
+ test.run("$levels=1").isAllText("$levels=1").isType(UriLexer.LEVELS);
+ test.run("$levels=2").isAllText("$levels=2").isType(UriLexer.LEVELS);
+ test.run("$levels=123").isAllText("$levels=123").isType(UriLexer.LEVELS);
+ test.run("$levels=max").isAllText("$levels=max").isType(UriLexer.LEVELS);
+
+ test.run("$format=atom").isAllText("$format=atom").isType(UriLexer.FORMAT);
+ test.run("$format=json").isAllText("$format=json").isType(UriLexer.FORMAT);
+ test.run("$format=xml").isAllText("$format=xml").isType(UriLexer.FORMAT);
+ test.run("$format=abc/def").isAllText("$format=abc/def").isType(UriLexer.FORMAT);
+
+ test.run("$id=123").isAllText("$id=123").isType(UriLexer.ID);
+ test.run("$id=ABC").isAllText("$id=ABC").isType(UriLexer.ID);
+
+ test.run("$skiptoken=ABC").isAllText("$skiptoken=ABC").isType(UriLexer.SKIPTOKEN);
+ test.run("$skiptoken=ABC").isAllText("$skiptoken=ABC").isType(UriLexer.SKIPTOKEN);
+
+ test.run("$search=\"ABC\"").isAllText("$search=\"ABC\"").isType(UriLexer.SEARCH);
+ test.run("$search=ABC").isAllText("$search=ABC").isType(UriLexer.SEARCH);
+ test.run("$search=\"A%20B%20C\"").isAllText("$search=\"A%20B%20C\"").isType(UriLexer.SEARCH);
+ }
+
+ // ;------------------------------------------------------------------------------
+ // ; 4. Expressions
+ // ;------------------------------------------------------------------------------
+ @Test
+ public void testQueryExpressions() {
+ test.globalMode(Lexer.DEFAULT_MODE);
+
+ test.run("$it").isText("$it").isType(UriLexer.IT);
+
+ test.run("$filter=contains(").at(2).isText("contains(").isType(UriLexer.CONTAINS_WORD);
+
+ test.run("$filter=containsabc").at(2).isText("containsabc")
+ .isType(UriLexer.ODATAIDENTIFIER); // test that this is a ODI
+
+ test.run("$filter=startswith(").at(2).isText("startswith(").isType(UriLexer.STARTSWITH_WORD);
+ test.run("$filter=endswith(").at(2).isText("endswith(").isType(UriLexer.ENDSWITH_WORD);
+ test.run("$filter=length(").at(2).isText("length(").isType(UriLexer.LENGTH_WORD);
+ test.run("$filter=indexof(").at(2).isText("indexof(").isType(UriLexer.INDEXOF_WORD);
+ test.run("$filter=substring(").at(2).isText("substring(").isType(UriLexer.SUBSTRING_WORD);
+ test.run("$filter=tolower(").at(2).isText("tolower(").isType(UriLexer.TOLOWER_WORD);
+ test.run("$filter=toupper(").at(2).isText("toupper(").isType(UriLexer.TOUPPER_WORD);
+ test.run("$filter=trim(").at(2).isText("trim(").isType(UriLexer.TRIM_WORD);
+ test.run("$filter=concat(").at(2).isText("concat(").isType(UriLexer.CONCAT_WORD);
+
+ }
+
+ // ;------------------------------------------------------------------------------
+ // ; 7. Literal Data Values
+ // ;------------------------------------------------------------------------------
+
+ @Test
+ public void testLiteralDataValues() {
+ test.globalMode(Lexer.DEFAULT_MODE);
+ // null
+ test.run("null").isInput().isType(UriLexer.NULLVALUE);
+
+ // binary
+ test.run("binary'ABCD'").isInput().isType(UriLexer.BINARY);
+ test.run("BiNaRy'ABCD'").isInput().isType(UriLexer.BINARY);
+
+ // boolean
+ test.run("true").isInput().isType(UriLexer.TRUE);
+ test.run("false").isInput().isType(UriLexer.FALSE);
+ test.run("TrUe").isInput().isType(UriLexer.BOOLEAN);
+ test.run("FaLsE").isInput().isType(UriLexer.BOOLEAN);
+
+ // Lexer rule INT
+ test.run("123").isInput().isType(UriLexer.INT);
+ test.run("123456789").isInput().isType(UriLexer.INT);
+ test.run("+123").isInput().isType(UriLexer.INT);
+ test.run("+123456789").isInput().isType(UriLexer.INT);
+ test.run("-123").isInput().isType(UriLexer.INT);
+ test.run("-123456789").isInput().isType(UriLexer.INT);
+
+ // Lexer rule DECIMAL
+ test.run("0.1").isInput().isType(UriLexer.DECIMAL);
+ test.run("1.1").isInput().isType(UriLexer.DECIMAL);
+ test.run("+0.1").isInput().isType(UriLexer.DECIMAL);
+ test.run("+1.1").isInput().isType(UriLexer.DECIMAL);
+ test.run("-0.1").isInput().isType(UriLexer.DECIMAL);
+ test.run("-1.1").isInput().isType(UriLexer.DECIMAL);
+
+ // Lexer rule EXP
+ test.run("1.1e+1").isInput().isType(UriLexer.DECIMAL);
+ test.run("1.1e-1").isInput().isType(UriLexer.DECIMAL);
+
+ test.run("NaN").isInput().isType(UriLexer.NANINFINITY);
+ test.run("-INF").isInput().isType(UriLexer.NANINFINITY);
+ test.run("INF").isInput().isType(UriLexer.NANINFINITY);
+
+ // Lexer rule GUID
+ test.run("1234ABCD-12AB-23CD-45EF-123456780ABC").isInput().isType(UriLexer.GUID);
+ test.run("1234ABCD-12AB-23CD-45EF-123456780ABC").isInput().isType(UriLexer.GUID);
+
+ // Lexer rule DATE
+ test.run("2013-11-15").isInput().isType(UriLexer.DATE);
+
+ // Lexer rule DATETIMEOFFSET
+ test.run("2013-11-15T13:35Z").isInput().isType(UriLexer.DATETIMEOFFSET);
+ test.run("2013-11-15T13:35:10Z").isInput().isType(UriLexer.DATETIMEOFFSET);
+ test.run("2013-11-15T13:35:10.1234Z").isInput().isType(UriLexer.DATETIMEOFFSET);
+
+ test.run("2013-11-15T13:35:10.1234+01:30").isInput().isType(UriLexer.DATETIMEOFFSET);
+ test.run("2013-11-15T13:35:10.1234-01:12").isInput().isType(UriLexer.DATETIMEOFFSET);
+
+ test.run("2013-11-15T13:35Z").isInput().isType(UriLexer.DATETIMEOFFSET);
+
+ // Lexer rule DURATION
+ test.run("duration'PT67S'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'PT67.89S'").isInput().isType(UriLexer.DURATION);
+
+ test.run("duration'PT5M'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'PT5M67S'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'PT5M67.89S'").isInput().isType(UriLexer.DURATION);
+
+ test.run("duration'PT4H'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'PT4H67S'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'PT4H67.89S'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'PT4H5M'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'PT4H5M67S'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'PT4H5M67.89S'").isInput().isType(UriLexer.DURATION);
+
+ test.run("duration'P3D'");
+ test.run("duration'P3DT67S'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'P3DT67.89S'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'P3DT5M'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'P3DT5M67S'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'P3DT5M67.89S'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'P3DT4H'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'P3DT4H67S'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'P3DT4H67.89S'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'P3DT4H5M'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'P3DT4H5M67S'").isInput().isType(UriLexer.DURATION);
+ test.run("duration'P3DT4H5M67.89S'").isInput().isType(UriLexer.DURATION);
+
+ test.run("DuRaTiOn'P3DT4H5M67.89S'").isInput().isType(UriLexer.DURATION);
+ test.run("DuRaTiOn'-P3DT4H5M67.89S'").isInput().isType(UriLexer.DURATION);
+
+ test.run("20:00").isInput().isType(UriLexer.TIMEOFDAY);
+ test.run("20:15:01").isInput().isType(UriLexer.TIMEOFDAY);
+ test.run("20:15:01.02").isInput().isType(UriLexer.TIMEOFDAY);
+
+ test.run("20:15:01.02").isInput().isType(UriLexer.TIMEOFDAY);
+
+ // String
+ test.run("'ABC'").isText("'ABC'").isType(UriLexer.STRING);
+ test.run("'A%20C'").isInput().isType(UriLexer.STRING);
+ test.run("'%20%20%20ABC'").isInput().isType(UriLexer.STRING);
+
+ }
+
+ @Test
+ public void testDelims() {
+ String reserved = "/";
+ test.globalMode(UriLexer.MODE_QUERY);
+ // Test lexer rule UNRESERVED
+ test.run("$format=A/" + cUNRESERVED).isAllInput().isType(UriLexer.FORMAT);
+ test.run("$format=A/" + cUNRESERVED + reserved).isType(UriLexer.FORMAT).at(4).isText(cUNRESERVED);
+ // Test lexer rule PCT_ENCODED
+ test.run("$format=A/" + cPCT_ENCODED).isAllInput().isType(UriLexer.FORMAT);
+ test.run("$format=A/" + cPCT_ENCODED + reserved).isType(UriLexer.FORMAT).at(4).isText(cPCT_ENCODED);
+ // Test lexer rule SUB_DELIMS
+ test.run("$format=A/" + cSUB_DELIMS).isAllInput().isType(UriLexer.FORMAT);
+ test.run("$format=A/" + cSUB_DELIMS + reserved).isType(UriLexer.FORMAT).at(4).isText("$");
+ // Test lexer rule PCHAR rest
+ test.run("$format=A/:@").isAllText("$format=A/:@").isType(UriLexer.FORMAT);
+ test.run("$format=A/:@" + reserved).isType(UriLexer.FORMAT).at(4).isText(":@");
+ // Test lexer rule PCHAR all
+ test.run("$format=" + cPCHAR + "/" + cPCHAR).isAllInput().isType(UriLexer.FORMAT);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
new file mode 100644
index 0000000..9a05cfb
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
@@ -0,0 +1,1144 @@
+/*
+ * 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.antlr;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.Arrays;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+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.edm.provider.EdmProviderImpl;
+import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
+import org.apache.olingo.server.core.testutil.techprovider.ComplexTypeProvider;
+import org.apache.olingo.server.core.testutil.techprovider.EntityTypeProvider;
+import org.apache.olingo.server.core.testutil.techprovider.PropertyProvider;
+import org.apache.olingo.server.core.uri.parser.UriParserException;
+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;
+import org.junit.Test;
+
+public class TestUriParserImpl {
+ Edm edm = null;
+ 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";
+ private final String PropertyDuration = "PropertyDuration=duration'P10DT5H34M21.123456789012S'";
+ private final String PropertyGuid = "PropertyGuid=12345678-1234-1234-1234-123456789012";
+ private final String PropertyInt16 = "PropertyInt16=1";
+ private final String PropertyInt32 = "PropertyInt32=12";
+ private final String PropertyInt64 = "PropertyInt64=64";
+ private final String PropertySByte = "PropertySByte=1";
+ private final String PropertyString = "PropertyString='ABC'";
+ private final String PropertyTimeOfDay = "PropertyTimeOfDay=12:34:55.123456789012";
+
+ private final String allKeys = PropertyString + "," + PropertyInt16 + "," + PropertyBoolean + "," + PropertyByte
+ + "," + 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 test() throws UriParserException, UnsupportedEncodingException {
+
+ }
+
+ @Test
+ public void testBoundFunctionImport_VarParameters() {
+
+ // no input
+ testRes.run("ESKeyNav(1)/com.sap.odata.test1.BFCETKeyNavRTETKeyNav()")
+ .at(0).isUriPathInfoKind(UriResourceKind.entitySet)
+ .at(1).isUriPathInfoKind(UriResourceKind.function);
+
+ // one input
+ testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav(ParameterString='ABC')")
+ .at(0).isUriPathInfoKind(UriResourceKind.entitySet)
+ .at(1).isUriPathInfoKind(UriResourceKind.function)
+ .isParameter(0, "ParameterString", "'ABC'");
+
+ // two input
+ testRes.run("FICRTESMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='2')")
+ .at(0)
+ .isUriPathInfoKind(UriResourceKind.function)
+ .isParameter(0, "ParameterInt16", "1")
+ .isParameter(1, "ParameterString", "'2'");
+ }
+
+ @Test
+ public void testFunctionBound_varReturnType() {
+
+ String esTwoKeyNav = "ESTwoKeyNav(PropertyInt16=1,PropertyString='ABC')";
+
+ // returning primitive
+ testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTString()")
+ .at(0)
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETTwoKeyNav, true)
+ .at(1)
+ .isUriPathInfoKind(UriResourceKind.function)
+ .isType(PropertyProvider.nameString, false);
+
+ // returning collection of primitive
+ testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCollString()")
+ .at(0)
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETTwoKeyNav, true)
+ .at(1)
+ .isUriPathInfoKind(UriResourceKind.function)
+ .isType(PropertyProvider.nameString, true);
+
+ // returning single complex
+ testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCTTwoPrim()")
+ .at(0)
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETTwoKeyNav, true)
+ .at(1)
+ .isUriPathInfoKind(UriResourceKind.function)
+ .isType(ComplexTypeProvider.nameCTTwoPrim, false);
+
+ // returning collection of complex
+ testRes.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCollCTTwoPrim()")
+ .at(0)
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETTwoKeyNav, true)
+ .at(1)
+ .isUriPathInfoKind(UriResourceKind.function)
+ .isType(ComplexTypeProvider.nameCTTwoPrim, true);
+
+ // returning single entity
+ testRes.run(
+ esTwoKeyNav + "/com.sap.odata.test1.ETBaseTwoKeyNav/com.sap.odata.test1.BFCETBaseTwoKeyNavRTETTwoKeyNav()")
+ .at(0)
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .at(1)
+ .isUriPathInfoKind(UriResourceKind.function)
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false);
+
+ // returning collection of entity (aka entitySet)
+ testRes.run(esTwoKeyNav + "/com.sap.odata.test1.BFCSINavRTESTwoKeyNav()")
+ .at(0)
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .at(1)
+ .isUriPathInfoKind(UriResourceKind.function)
+ .isType(EntityTypeProvider.nameETTwoKeyNav, true);
+ }
+
+ @Test
+ public void runActionImport_VarReturnType() {
+
+ testRes.run("AIRTPrimParam").isKind(UriInfoKind.resource)
+ .first()
+ .isActionImport("AIRTPrimParam")
+ .isAction("UARTPrimParam")
+ .isType(PropertyProvider.nameString, false);
+
+ testRes.run("AIRTPrimCollParam").isKind(UriInfoKind.resource)
+ .first()
+ .isActionImport("AIRTPrimCollParam")
+ .isAction("UARTPrimCollParam")
+ .isType(PropertyProvider.nameString, true);
+
+ testRes.run("AIRTCompParam").isKind(UriInfoKind.resource)
+ .first()
+ .isActionImport("AIRTCompParam")
+ .isAction("UARTCompParam")
+ .isType(ComplexTypeProvider.nameCTTwoPrim, false);
+
+ testRes.run("AIRTCompCollParam").isKind(UriInfoKind.resource)
+ .first()
+ .isActionImport("AIRTCompCollParam")
+ .isAction("UARTCompCollParam")
+ .isType(ComplexTypeProvider.nameCTTwoPrim, true);
+
+ testRes.run("AIRTETParam").isKind(UriInfoKind.resource)
+ .first()
+ .isActionImport("AIRTETParam")
+ .isAction("UARTETParam")
+ .isType(EntityTypeProvider.nameETTwoKeyTwoPrim, false);
+
+ testUri.runEx("AIRTPrimParam/invalidElement").isExSemantic(0);
+ }
+
+ @Test
+ public void runCount() {
+
+ // count entity set
+ testRes.run("ESAllPrim/$count")
+ .at(0)
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETAllPrim, true)
+ .at(1)
+ .isUriPathInfoKind(UriResourceKind.count);
+
+ // count on collection of complex
+ testRes.run("ESKeyNav(1)/CollPropertyComplex/$count")
+ .at(0)
+ .isType(EntityTypeProvider.nameETKeyNav)
+ .at(1)
+ .isType(ComplexTypeProvider.nameCTPrimComp, true)
+ .at(2)
+ .isUriPathInfoKind(UriResourceKind.count);
+
+ // count on collection of primitive
+ testRes.run("ESCollAllPrim(1)/CollPropertyString/$count")
+ .at(1)
+ .isType(PropertyProvider.nameString, true)
+ .at(2)
+ .isUriPathInfoKind(UriResourceKind.count);
+ }
+
+ @Test
+ public void runCrossJoin() {
+ testUri.run("$crossjoin(ESAllKey)")
+ .isKind(UriInfoKind.crossjoin)
+ .isCrossJoinEntityList(Arrays.asList("ESAllKey"));
+
+ testUri.run("$crossjoin(ESAllKey,ESTwoPrim)")
+ .isKind(UriInfoKind.crossjoin)
+ .isCrossJoinEntityList(Arrays.asList("ESAllKey", "ESTwoPrim"));
+ }
+
+ @Test(expected = Exception.class)
+ public void testEntityFailOnValidation1() {
+ // simple entity set; with qualifiedentityTypeName; with filter
+ testUri.run("$entity/com.sap.odata.test1.ETTwoPrim?$filter=PropertyInt16 eq 123&$id=ESAllKey")
+ .isIdText("ESAllKey")
+ .goFilter().is("<<PropertyInt16> eq <123>>");
+ }
+
+ @Test(expected = Exception.class)
+ public void testEntityFailOnValidation2() {
+ // simple entity set; with qualifiedentityTypeName; with 2xformat(before and after), expand, filter
+ testUri.run("$entity/com.sap.odata.test1.ETTwoPrim?"
+ + "$format=xml&$expand=*&abc=123&$id=ESBase&xyz=987&$filter=PropertyInt16 eq 123&$format=atom&$select=*")
+ .isFormatText("atom")
+ .isCustomParameter(0, "abc", "123")
+ .isIdText("ESBase")
+ .isCustomParameter(1, "xyz", "987")
+ .isSelectItemStar(0);
+ }
+
+ @Test
+ public void testEntity() {
+
+ // simple entity set
+ testUri.run("$entity?$id=ESAllPrim").isKind(UriInfoKind.entityId)
+ .isKind(UriInfoKind.entityId)
+ .isIdText("ESAllPrim");
+
+ // simple entity set; $format before $id
+ testUri.run("$entity?$format=xml&$id=ETAllPrim").isKind(UriInfoKind.entityId)
+ .isFormatText("xml")
+ .isIdText("ETAllPrim");
+
+ testUri.run("$entity?$format=xml&abc=123&$id=ESAllKey").isKind(UriInfoKind.entityId)
+ .isFormatText("xml")
+ .isCustomParameter(0, "abc", "123")
+ .isIdText("ESAllKey");
+
+ // simple entity set; $format after $id
+ testUri.run("$entity?$id=ETAllPrim&$format=xml").isKind(UriInfoKind.entityId)
+ .isIdText("ETAllPrim")
+ .isFormatText("xml");
+
+ // simple entity set; $format and custom parameter after $id
+ testUri.run("$entity?$id=ETAllPrim&$format=xml&abc=123").isKind(UriInfoKind.entityId)
+ .isIdText("ETAllPrim")
+ .isFormatText("xml")
+ .isCustomParameter(0, "abc", "123");
+
+ // simple entity set; $format before $id and custom parameter after $id
+ testUri.run("$entity?$format=xml&$id=ETAllPrim&abc=123").isKind(UriInfoKind.entityId)
+ .isFormatText("xml")
+ .isIdText("ETAllPrim")
+ .isCustomParameter(0, "abc", "123");
+
+ // simple entity set; with qualifiedentityTypeName
+ testUri.run("$entity/com.sap.odata.test1.ETTwoPrim?$id=ESBase")
+ .isEntityType(EntityTypeProvider.nameETTwoPrim)
+ .isIdText("ESBase");
+
+ // simple entity set; with qualifiedentityTypeName;
+ testUri.run("$entity/com.sap.odata.test1.ETBase?$id=ESTwoPrim")
+ .isEntityType(EntityTypeProvider.nameETBase)
+ .isKind(UriInfoKind.entityId)
+ .isIdText("ESTwoPrim");
+
+ // simple entity set; with qualifiedentityTypeName; with format
+ testUri.run("$entity/com.sap.odata.test1.ETBase?$id=ESTwoPrim&$format=atom")
+ .isKind(UriInfoKind.entityId)
+ .isEntityType(EntityTypeProvider.nameETBase)
+ .isIdText("ESTwoPrim")
+ .isFormatText("atom");
+
+ // simple entity set; with qualifiedentityTypeName; with select
+ testUri.run("$entity/com.sap.odata.test1.ETBase?$id=ESTwoPrim&$select=*")
+ .isKind(UriInfoKind.entityId)
+ .isEntityType(EntityTypeProvider.nameETBase)
+ .isIdText("ESTwoPrim")
+ .isSelectItemStar(0);
+
+ // simple entity set; with qualifiedentityTypeName; with expand
+ testUri.run("$entity/com.sap.odata.test1.ETBase?$id=ESTwoPrim&$expand=*")
+ .isKind(UriInfoKind.entityId)
+ .isEntityType(EntityTypeProvider.nameETBase)
+ .isIdText("ESTwoPrim")
+ .isExpandText("*")
+ .goExpand().first().isSegmentStar(0);
+
+ }
+
+ @Test
+ public void testEntitySet() throws UnsupportedEncodingException {
+
+ // plain entity set
+ testRes.run("ESAllPrim")
+ .isEntitySet("ESAllPrim")
+ .isType(EntityTypeProvider.nameETAllPrim);
+
+ // with one key; simple key notation
+ testRes.run("ESAllPrim(1)")
+ .isEntitySet("ESAllPrim")
+ .isType(EntityTypeProvider.nameETAllPrim)
+ .isKeyPredicate(0, "PropertyInt16", "1");
+
+ // with one key; name value key notation
+ testRes.run("ESAllPrim(PropertyInt16=1)")
+ .isEntitySet("ESAllPrim")
+ .isKeyPredicate(0, "PropertyInt16", "1");
+
+ // with two keys
+ testRes.run("ESTwoKeyTwoPrim(PropertyInt16=1, PropertyString='ABC')")
+ .isEntitySet("ESTwoKeyTwoPrim")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'ABC'");
+
+ // with all keys
+ testRes.run("ESAllKey(" + encode(allKeys) + ")")
+ .isEntitySet("ESAllKey")
+ .isKeyPredicate(0, "PropertyString", "'ABC'")
+ .isKeyPredicate(1, "PropertyInt16", "1")
+ .isKeyPredicate(2, "PropertyBoolean", "true")
+ .isKeyPredicate(3, "PropertyByte", "1")
+ .isKeyPredicate(4, "PropertySByte", "1")
+ .isKeyPredicate(5, "PropertyInt32", "12")
+ .isKeyPredicate(6, "PropertyInt64", "64")
+ .isKeyPredicate(7, "PropertyDecimal", "12")
+ .isKeyPredicate(8, "PropertyDate", "2013-09-25")
+ .isKeyPredicate(9, "PropertyDateTimeOffset", "2002-10-10T12:00:00-05:00")
+ .isKeyPredicate(10, "PropertyDuration", "duration'P10DT5H34M21.123456789012S'")
+ .isKeyPredicate(11, "PropertyGuid", "12345678-1234-1234-1234-123456789012")
+ .isKeyPredicate(12, "PropertyTimeOfDay", "12:34:55.123456789012");
+ }
+
+ @Test
+ public void testEntitySet_NavigationPropperty() {
+
+ // plain entity set ...
+
+ // with navigation property
+ testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne")
+ .at(0)
+ .isEntitySet("ESKeyNav")
+ .isType(EntityTypeProvider.nameETKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .at(1)
+ .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isType(EntityTypeProvider.nameETTwoKeyNav);
+
+ // with navigation property -> property
+ testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne/PropertyString")
+ .at(0)
+ .isEntitySet("ESKeyNav")
+ .isType(EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .at(1)
+ .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
+ .at(2)
+ .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
+
+ // with navigation property -> navigation property -> navigation property
+ testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne/NavPropertyETKeyNavOne")
+ .at(0)
+ .isEntitySet("ESKeyNav")
+ .isType(EntityTypeProvider.nameETKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .at(1)
+ .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .at(2)
+ .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false)
+ .isType(EntityTypeProvider.nameETKeyNav);
+
+ // with navigation property(key)
+ testRes.run("ESKeyNav(1)/NavPropertyETKeyNavMany(1)")
+ .at(0)
+ .isEntitySet("ESKeyNav")
+ .at(1)
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1");
+
+ // with navigation property(key) -> property
+ testRes.run("ESKeyNav(1)/NavPropertyETKeyNavMany(1)/PropertyString").at(0)
+ .at(0)
+ .isEntitySet("ESKeyNav")
+ .at(1)
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .at(2)
+ .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
+
+ // with navigation property(key) -> navigation property
+ testRes.run("ESKeyNav(1)/NavPropertyETKeyNavMany(1)/NavPropertyETKeyNavOne")
+ .isEntitySet("ESKeyNav")
+ .at(1)
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .at(2)
+ .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false);
+
+ // with navigation property(key) -> navigation property(key)
+ testRes.run("ESKeyNav(1)/NavPropertyETKeyNavMany(1)/NavPropertyETKeyNavMany(1)")
+ .isEntitySet("ESKeyNav")
+ .isType(EntityTypeProvider.nameETKeyNav)
+ .at(1)
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .at(2)
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1");
+
+ // with navigation property(key) -> navigation property -> property
+ testRes.run("ESKeyNav(1)/NavPropertyETKeyNavMany(1)/NavPropertyETKeyNavOne/PropertyString")
+ .at(0)
+ .isEntitySet("ESKeyNav")
+ .isType(EntityTypeProvider.nameETKeyNav)
+ .at(1)
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .at(2)
+ .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false)
+ .isType(EntityTypeProvider.nameETKeyNav)
+ .at(3)
+ .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
+
+ // with navigation property(key) -> navigation property(key) -> property
+ testRes.run("ESKeyNav(1)/NavPropertyETKeyNavMany(1)/NavPropertyETKeyNavMany(1)/PropertyString")
+ .at(0)
+ .isEntitySet("ESKeyNav")
+ .isType(EntityTypeProvider.nameETKeyNav)
+ .at(1)
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .at(2)
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .at(3)
+ .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
+
+ }
+
+ @Test
+ public void testEntitySet_Property() {
+
+ // plain entity set ...
+
+ // with property
+ testRes.run("ESAllPrim(1)/PropertyString")
+ .at(0)
+ .isEntitySet("ESAllPrim")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .at(1)
+ .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
+
+ // with complex property
+ testRes.run("ESCompAllPrim(1)/PropertyComplex")
+ .at(0)
+ .isEntitySet("ESCompAllPrim")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .at(1)
+ .isComplexProperty("PropertyComplex", ComplexTypeProvider.nameCTAllPrim, false);
+
+ // with two properties
+ testRes.run("ESCompAllPrim(1)/PropertyComplex/PropertyString")
+ .at(0)
+ .isEntitySet("ESCompAllPrim")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .at(1)
+ .isComplexProperty("PropertyComplex", ComplexTypeProvider.nameCTAllPrim, false)
+ .at(2)
+ .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
+ }
+
+ @Test
+ public void testEntitySet_TypeFilter() {
+
+ // filter
+ testRes.run("ESTwoPrim/com.sap.odata.test1.ETBase")
+ .at(0)
+ .isEntitySet("ESTwoPrim")
+ .isType(EntityTypeProvider.nameETTwoPrim, true)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBase)
+ .isTypeFilterOnEntry(null);
+
+ // filter before key predicate
+ testRes.run("ESTwoPrim/com.sap.odata.test1.ETBase(PropertyInt16=1)")
+ .at(0)
+ .isEntitySet("ESTwoPrim")
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETTwoPrim)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBase)
+ .isTypeFilterOnEntry(null)
+ .at(0)
+ .isType(EntityTypeProvider.nameETTwoPrim, false)
+ .isKeyPredicate(0, "PropertyInt16", "1");
+
+ // filter before key predicate; property of sub type
+ testRes.run("ESTwoPrim/com.sap.odata.test1.ETBase(PropertyInt16=1)/AdditionalPropertyString_5")
+ .at(0)
+ .isEntitySet("ESTwoPrim")
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETTwoPrim)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBase)
+ .isTypeFilterOnEntry(null)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .at(1)
+ .isType(PropertyProvider.nameString)
+ .isPrimitiveProperty("AdditionalPropertyString_5", PropertyProvider.nameString, false);
+
+ // filter after key predicate
+ testRes.run("ESTwoPrim(PropertyInt16=1)/com.sap.odata.test1.ETBase")
+ .at(0)
+ .isEntitySet("ESTwoPrim")
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETTwoPrim, false)
+ .isTypeFilterOnCollection(null)
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBase)
+ .isKeyPredicate(0, "PropertyInt16", "1");
+
+ // filter after key predicate; property of sub type
+ testRes.run("ESTwoPrim(PropertyInt16=1)/com.sap.odata.test1.ETBase/AdditionalPropertyString_5")
+ .at(0)
+ .isEntitySet("ESTwoPrim")
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETTwoPrim)
+ .isTypeFilterOnCollection(null)
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBase)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .at(1)
+ .isPrimitiveProperty("AdditionalPropertyString_5", PropertyProvider.nameString, false)
+ .isType(PropertyProvider.nameString);
+
+ }
+
+ @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>>>>");
+ }
+
+ @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>>");
+
+ }
+
+ @Test
+ public void testFunctionImport_VarParameters() {
+
+ // no input
+ testRes.run("FINRTInt16()")
+ .isFunctionImport("FINRTInt16")
+ .isFunction("UFNRTInt16")
+ .isType(PropertyProvider.nameInt16);
+
+ // one input
+ testRes.run("FICRTETTwoKeyNavParam(ParameterInt16=1)")
+ .isFunctionImport("FICRTETTwoKeyNavParam")
+ .isFunction("UFCRTETTwoKeyNavParam")
+ .isType(EntityTypeProvider.nameETTwoKeyNav);
+
+ // two input
+ testRes.run("FICRTStringTwoParam(ParameterString='ABC',ParameterInt16=1)")
+ .isFunctionImport("FICRTStringTwoParam")
+ .isFunction("UFCRTStringTwoParam")
+ .isType(PropertyProvider.nameString);
+ }
+
+ @Test
+ public void testFunctionImport_VarRetruning() {
+ // returning primitive
+ testRes.run("FINRTInt16()")
+ .isFunctionImport("FINRTInt16")
+ .isFunction("UFNRTInt16")
+ .isType(PropertyProvider.nameInt16, false);
+
+ // returning collection of primitive
+ testRes.run("FICRTCollStringTwoParam(ParameterString='ABC',ParameterInt16=1)")
+ .isFunctionImport("FICRTCollStringTwoParam")
+ .isFunction("UFCRTCollStringTwoParam")
+ .isType(PropertyProvider.nameString, true);
+
+ // returning single complex
+ testRes.run("FICRTCTAllPrimTwoParam(ParameterString='ABC',ParameterInt16=1)")
+ .isFunctionImport("FICRTCTAllPrimTwoParam")
+ .isFunction("UFCRTCTAllPrimTwoParam")
+ .isType(ComplexTypeProvider.nameCTAllPrim, false);
+
+ // returning collection of complex
+ testRes.run("FICRTCollCTTwoPrim()")
+ .isFunctionImport("FICRTCollCTTwoPrim")
+ .isFunction("UFCRTCollCTTwoPrim")
+ .isType(ComplexTypeProvider.nameCTTwoPrim, true);
+
+ // returning single entity
+ testRes.run("FICRTETTwoKeyNavParam(ParameterInt16=1)")
+ .isFunctionImport("FICRTETTwoKeyNavParam")
+ .isFunction("UFCRTETTwoKeyNavParam")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false);
+
+ // returning collection of entity (aka entitySet)
+ testRes.run("FICRTESTwoKeyNavParam(ParameterInt16=1)")
+ .isFunctionImport("FICRTESTwoKeyNavParam")
+ .isFunction("UFCRTESTwoKeyNavParam")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, true);
+ }
+
+ @Test
+ public void testFunctionImportChain() {
+
+ // test chain; returning single complex
+ testRes.run("FICRTCTAllPrimTwoParam(ParameterString='ABC',ParameterInt16=1)/PropertyInt16")
+ .at(0)
+ .isFunctionImport("FICRTCTAllPrimTwoParam")
+ .isFunction("UFCRTCTAllPrimTwoParam")
+ .isType(ComplexTypeProvider.nameCTAllPrim, false)
+ .isParameter(0, "ParameterString", "'ABC'")
+ .isParameter(1, "ParameterInt16", "1")
+ .at(1)
+ .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
+
+ // test chains; returning single entity
+ testRes.run("FICRTETTwoKeyNavParam(ParameterInt16=1)/PropertyInt16")
+ .at(0)
+ .isFunctionImport("FICRTETTwoKeyNavParam")
+ .isFunction("UFCRTETTwoKeyNavParam")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .isParameter(0, "ParameterInt16", "1")
+ .at(1)
+ .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
+
+ // test chains; returning collection of entity (aka entitySet)
+ testRes.run("FICRTESTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=1,PropertyString='ABC')")
+ .at(0)
+ .isFunctionImport("FICRTESTwoKeyNavParam")
+ .isFunction("UFCRTESTwoKeyNavParam")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .isParameter(0, "ParameterInt16", "1")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'ABC'");
+
+ // test chains; returning collection of entity (aka entitySet)
+ testRes.run("FICRTESTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=1,PropertyString='ABC')/PropertyInt16")
+ .at(0)
+ .isFunctionImport("FICRTESTwoKeyNavParam")
+ .isFunction("UFCRTESTwoKeyNavParam")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .isParameter(0, "ParameterInt16", "1")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'ABC'")
+ .at(1)
+ .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
+
+ }
+
+ @Test
+ public void testMetaData() {
+
+ // Parsing the fragment may be used if a uri has to be parsed on the consumer side.
+ // On the producer side this feature is currently not supported, so the context fragment
+ // part is only available as text.
+
+ testUri.run("$metadata")
+ .isKind(UriInfoKind.metadata);
+
+ testUri.run("$metadata?$format=atom")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom");
+
+ // with context (client usage)
+
+ testUri.run("$metadata#$ref")
+ .isKind(UriInfoKind.metadata)
+ .isFragmentText("$ref");
+
+ testUri.run("$metadata?$format=atom#$ref")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("$ref");
+
+ testUri.run("$metadata?$format=atom#Collection($ref)")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("Collection($ref)");
+
+ testUri.run("$metadata?$format=atom#Collection(Edm.EntityType)")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("Collection(Edm.EntityType)");
+
+ testUri.run("$metadata?$format=atom#Collection(Edm.ComplexType)")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("Collection(Edm.ComplexType)");
+
+ testUri.run("$metadata?$format=atom#SINav")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("SINav");
+
+ testUri.run("$metadata?$format=atom#SINav/PropertyInt16")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("SINav/PropertyInt16");
+
+ testUri.run("$metadata?$format=atom#SINav/NavPropertyETKeyNavOne")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("SINav/NavPropertyETKeyNavOne");
+
+ testUri.run("$metadata?$format=atom#SINav/NavPropertyETKeyNavMany(1)")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("SINav/NavPropertyETKeyNavMany(1)");
+
+ testUri.run("$metadata?$format=atom#SINav/NavPropertyETKeyNavOne/PropertyInt16")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("SINav/NavPropertyETKeyNavOne/PropertyInt16");
+
+ testUri.run("$metadata?$format=atom#SINav/NavPropertyETKeyNavMany(1)/PropertyInt16")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("SINav/NavPropertyETKeyNavMany(1)/PropertyInt16");
+
+ testUri.run("$metadata?$format=atom#SINav/com.sap.odata.test1.ETTwoPrim/NavPropertyETKeyNavOne/PropertyInt16")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("SINav/com.sap.odata.test1.ETTwoPrim/NavPropertyETKeyNavOne/PropertyInt16");
+
+ testUri.run("$metadata?$format=atom#SINav/com.sap.odata.test1.ETTwoPrim/NavPropertyETKeyNavMany(1)/PropertyInt16")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("SINav/com.sap.odata.test1.ETTwoPrim/NavPropertyETKeyNavMany(1)/PropertyInt16");
+
+ testUri.run("$metadata?$format=atom#com.sap.odata.test1.ETAllKey")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("com.sap.odata.test1.ETAllKey");
+
+ testUri.run("$metadata?$format=atom#ESTwoPrim/$deletedEntity")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("ESTwoPrim/$deletedEntity");
+
+ testUri.run("$metadata?$format=atom#ESTwoPrim/$link")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("ESTwoPrim/$link");
+
+ testUri.run("$metadata?$format=atom#ESTwoPrim/$deletedLink")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("ESTwoPrim/$deletedLink");
+
+ testUri.run("$metadata?$format=atom#ESKeyNav")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("ESKeyNav");
+
+ testUri.run("$metadata?$format=atom#ESKeyNav/PropertyInt16")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("ESKeyNav/PropertyInt16");
+
+ testUri.run("$metadata?$format=atom#ESKeyNav/NavPropertyETKeyNavOne")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("ESKeyNav/NavPropertyETKeyNavOne");
+
+ testUri.run("$metadata?$format=atom#ESKeyNav/NavPropertyETKeyNavMany(1)")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("ESKeyNav/NavPropertyETKeyNavMany(1)");
+
+ testUri.run("$metadata?$format=atom#ESKeyNav/NavPropertyETKeyNavOne/PropertyInt16")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("ESKeyNav/NavPropertyETKeyNavOne/PropertyInt16");
+
+ testUri.run("$metadata?$format=atom#ESKeyNav/NavPropertyETKeyNavMany(1)/PropertyInt16")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("ESKeyNav/NavPropertyETKeyNavMany(1)/PropertyInt16");
+
+ testUri.run("$metadata?$format=atom#ESKeyNav/com.sap.odata.test1.ETTwoPrim/NavPropertyETKeyNavOne/PropertyInt16")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("ESKeyNav/com.sap.odata.test1.ETTwoPrim/NavPropertyETKeyNavOne/PropertyInt16");
+
+ testUri.run(
+ "$metadata?$format=atom#ESKeyNav/com.sap.odata.test1.ETTwoPrim/NavPropertyETKeyNavMany(1)/PropertyInt16")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("ESKeyNav/com.sap.odata.test1.ETTwoPrim/NavPropertyETKeyNavMany(1)/PropertyInt16");
+
+ testUri.run("$metadata?$format=atom#ESKeyNav(PropertyInt16,PropertyString)")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("ESKeyNav(PropertyInt16,PropertyString)");
+
+ testUri.run("$metadata?$format=atom#ESKeyNav/$entity")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("ESKeyNav/$entity");
+
+ testUri.run("$metadata?$format=atom#ESKeyNav/$delta")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("ESKeyNav/$delta");
+
+ testUri.run("$metadata?$format=atom#ESKeyNav/(PropertyInt16,PropertyString)/$delta")
+ .isKind(UriInfoKind.metadata)
+ .isFormatText("atom")
+ .isFragmentText("ESKeyNav/(PropertyInt16,PropertyString)/$delta");
+
+ }
+
+ @Test
+ public void testRef() {
+ testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne/$ref");
+ }
+
+ @Test
+ public void testSingleton() {
+ // plain singleton
+ testRes.run("SINav")
+ .isSingleton("SINav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav);
+ }
+
+ @Test
+ public void testNavigationProperty() {
+
+ // plain entity set ...
+
+ // with navigation property
+ testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne")
+ .at(0).isEntitySet("ESKeyNav")
+ .at(1).isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false);
+
+ // with navigation property -> property
+ testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne/PropertyString")
+ .at(0).isEntitySet("ESKeyNav")
+ .at(1).isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
+ .at(2).isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
+
+ // with navigation property -> navigation property -> navigation property
+ testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne/NavPropertyETKeyNavOne")
+ .at(0).isEntitySet("ESKeyNav")
+ .at(1).isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
+ .at(2).isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false);
+
+ // with navigation property(key)
+ testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=1,PropertyString='1')")
+ .at(0).isEntitySet("ESKeyNav")
+ .at(1).isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'1'");
+
+ // with navigation property(key) -> property
+ testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=1,PropertyString='1')/PropertyString")
+ .at(0).isEntitySet("ESKeyNav")
+ .at(1).isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'1'")
+ .at(2).isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
+
+ // with navigation property(key) -> navigation property
+ testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=1,PropertyString='1')/NavPropertyETKeyNavOne")
+ .at(0).isEntitySet("ESKeyNav")
+ .at(1).isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'1'")
+ .at(2).isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false);
+
+ // with navigation property(key) -> navigation property(key)
+ testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=1,PropertyString='1')"
+ + "/NavPropertyETKeyNavMany(1)")
+ .at(0).isEntitySet("ESKeyNav")
+ .at(1).isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'1'")
+ .at(2).isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1");
+
+ // with navigation property(key) -> navigation property -> property
+ testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=1,PropertyString='1')"
+ + "/NavPropertyETKeyNavOne/PropertyString")
+ .at(0).isEntitySet("ESKeyNav")
+ .at(1).isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'1'")
+ .at(2).isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false)
+ .at(3).isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
+
+ // with navigation property(key) -> navigation property(key) -> property
+ testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=1,PropertyString='1')"
+ + "/NavPropertyETKeyNavMany(1)/PropertyString")
+ .at(0).isEntitySet("ESKeyNav")
+ .at(1).isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'1'")
+ .at(2).isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .at(3).isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
+ }
+
+ @Test
+ public void testSingleton_Property() {
+
+ // plain singleton ...
+
+ // with property
+ testRes.run("SINav/PropertyInt16")
+ .at(0)
+ .isSingleton("SINav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .at(1)
+ .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
+
+ // with complex property
+ testRes.run("SINav/PropertyComplex")
+ .at(0)
+ .isSingleton("SINav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .at(1)
+ .isComplexProperty("PropertyComplex", ComplexTypeProvider.nameCTPrimComp, false);
+
+ // with two properties
+ testRes.run("SINav/PropertyComplex/PropertyInt16")
+ .at(0)
+ .isSingleton("SINav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .at(1)
+ .isComplexProperty("PropertyComplex", ComplexTypeProvider.nameCTPrimComp, false)
+ .at(2)
+ .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
+
+ }
+
+ @Test
+ public void testValue() {
+ testUri.run("ESAllPrim(1)/PropertyString/$value");
+ }
+
+ @Test(expected = Exception.class)
+ public void testMemberStartingWithCastFailOnValidation1() {
+ // on EntityType entry
+ testUri.run("ESTwoKeyNav(ParameterInt16=1,PropertyString='ABC')?"
+ + "$filter=com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate")
+ .goFilter().root().isMember()
+ .isMemberStartType(EntityTypeProvider.nameETBaseTwoKeyNav).goPath()
+ // .at(0)
+ // .isUriPathInfoKind(UriResourceKind.startingTypeFilter)
+ // .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ // .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .at(0).isType(PropertyProvider.nameDate);
+ }
+
+ @Test(expected = Exception.class)
+ public void testMemberStartingWithCastFailOnValidation2() {
+ testUri.run("FICRTCTTwoPrimParam(ParameterInt16=1,ParameterString='2')?"
+ + "$filter=com.sap.odata.test1.CTBase/AdditionalPropString")
+ .goFilter().root().isMember()
+ .isMemberStartType(ComplexTypeProvider.nameCTBase).goPath()
+ // .at(0)
+ // .isUriPathInfoKind(UriResourceKind.startingTypeFilter)
+ // .isType(ComplexTypeProvider.nameCTTwoPrim, false)
+ // .isTypeFilterOnEntry(ComplexTypeProvider.nameCTBase)
+ .at(0).isType(PropertyProvider.nameString);
+ }
+
+ @Test
+ public void testMemberStartingWithCast() {
+
+ // on EntityType collection
+ testUri.run("ESTwoKeyNav?$filter=com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate")
+ .goFilter().root().isMember()
+ .isMemberStartType(EntityTypeProvider.nameETBaseTwoKeyNav).goPath()
+ // .at(0)
+ // .isUriPathInfoKind(UriResourceKind.startingTypeFilter)
+ // .isType(EntityTypeProvider.nameETTwoKeyNav, true)
+ // .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .at(0).isType(PropertyProvider.nameDate);
+
+ // on Complex collection
+ testUri.run("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')?"
+ + "$filter=com.sap.odata.test1.CTBase/AdditionalPropString")
+ .goFilter().root().isMember()
+ .isMemberStartType(ComplexTypeProvider.nameCTBase).goPath()
+ // .at(0)
+ // .isUriPathInfoKind(UriResourceKind.startingTypeFilter)
+ // .isType(ComplexTypeProvider.nameCTTwoPrim, true)
+ // .isTypeFilterOnCollection(ComplexTypeProvider.nameCTBase)
+ .at(0).isType(PropertyProvider.nameString);
+
+ }
+
+ @Test
+ public void testComplexTypeCastFollowingAsCollection() {
+ testUri.run("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')/com.sap.odata.test1.CTBase");
+ }
+
+ @Test
+ public void testLambda() {
+ testUri.run("ESTwoKeyNav?$filter=CollPropertyComplex/all( l : true )")
+ .goFilter().is("<CollPropertyComplex/<ALL;<true>>>");
+
+ testUri.run("ESTwoKeyNav?$filter=CollPropertyComplex/any( l : true )")
+ .goFilter().is("<CollPropertyComplex/<ANY;<true>>>");
+ testUri.run("ESTwoKeyNav?$filter=CollPropertyComplex/any( )")
+ .goFilter().is("<CollPropertyComplex/<ANY;>>");
+
+ testUri.run("ESTwoKeyNav?$filter=all( l : true )")
+ .goFilter().is("<<ALL;<true>>>");
+ testUri.run("ESTwoKeyNav?$filter=any( l : true )")
+ .goFilter().is("<<ANY;<true>>>");
+ testUri.run("ESTwoKeyNav?$filter=any( )")
+ .goFilter().is("<<ANY;>>");
+ }
+
+ @Test
+ public void testCustomQueryOption() {
+ testUri.run("ESTwoKeyNav?custom")
+ .isCustomParameter(0, "custom", "");
+ testUri.run("ESTwoKeyNav?custom=ABC")
+ .isCustomParameter(0, "custom", "ABC");
+ }
+
+ @Test
+ public void testGeo() throws UriParserException {
+ // TODO sync
+ testFilter.runOnETAllPrim("geo.distance(PropertySByte,PropertySByte)")
+ .is("<geo.distance(<PropertySByte>,<PropertySByte>)>")
+ .isMethod(MethodKind.GEODISTANCE, 2);
+ testFilter.runOnETAllPrim("geo.length(PropertySByte)")
+ .is("<geo.length(<PropertySByte>)>")
+ .isMethod(MethodKind.GEOLENGTH, 1);
+ testFilter.runOnETAllPrim("geo.intersects(PropertySByte,PropertySByte)")
+ .is("<geo.intersects(<PropertySByte>,<PropertySByte>)>")
+ .isMethod(MethodKind.GEOINTERSECTS, 2);
+ }
+
+ @Test
+ public void testSelect() {
+ testUri.run("ESTwoKeyNav?$select=*")
+ .isSelectItemStar(0);
+
+ testUri.run("ESTwoKeyNav?$select=com.sap.odata.test1.*")
+ .isSelectItemAllOp(0, new FullQualifiedName("com.sap.odata.test1", "*"));
+
+ testUri.run("ESTwoKeyNav?$select=PropertyString")
+ .goSelectItemPath(0).isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
+
+ testUri.run("ESTwoKeyNav?$select=PropertyComplex")
+ .goSelectItemPath(0).isComplexProperty("PropertyComplex", ComplexTypeProvider.nameCTPrimComp, false);
+
+ testUri.run("ESTwoKeyNav?$select=PropertyComplex/PropertyInt16")
+ .goSelectItemPath(0)
+ .first()
+ .isComplexProperty("PropertyComplex", ComplexTypeProvider.nameCTPrimComp, false)
+ .n()
+ .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
+
+ testUri.run("ESTwoKeyNav?$select=PropertyComplex/PropertyComplex")
+ .goSelectItemPath(0)
+ .first()
+ .isComplexProperty("PropertyComplex", ComplexTypeProvider.nameCTPrimComp, false)
+ .n()
+ .isComplexProperty("PropertyComplex", ComplexTypeProvider.nameCTAllPrim, false);
+
+ testUri.run("ESTwoKeyNav?$select=com.sap.odata.test1.ETBaseTwoKeyNav")
+ .isSelectStartType(0, EntityTypeProvider.nameETBaseTwoKeyNav);
+
+ testUri.run("ESTwoKeyNav/PropertyComplexNav?$select=com.sap.odata.test1.CTTwoBasePrimCompNav")
+ .isSelectStartType(0, ComplexTypeProvider.nameCTTwoBasePrimCompNav);
+
+ testUri.run("ESTwoKeyNav?$select=PropertyComplexNav/com.sap.odata.test1.CTTwoBasePrimCompNav")
+ .goSelectItemPath(0)
+ .first()
+ .isComplexProperty("PropertyComplexNav", ComplexTypeProvider.nameCTBasePrimCompNav, false)
+ .n()
+ .isTypeFilterOnCollection(ComplexTypeProvider.nameCTTwoBasePrimCompNav);
+ ;
+
+ }
+
+ public static String encode(final String decoded) throws UnsupportedEncodingException {
+
+ return URLEncoder.encode(decoded, "UTF-8");
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/queryoption/QueryOptionTest.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/queryoption/QueryOptionTest.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/queryoption/QueryOptionTest.java
new file mode 100644
index 0000000..cce237e
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/queryoption/QueryOptionTest.java
@@ -0,0 +1,303 @@
+/*
+ * 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.queryoption;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.server.api.uri.UriInfoResource;
+import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
+import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
+import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
+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.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();
+
+ option.setAliasValue(expression);
+ assertEquals(expression, option.getValue());
+ }
+
+ @Test
+ public void testExandItemImpl() {
+ ExpandItemImpl option = new ExpandItemImpl();
+
+ // input options
+ ExpandOptionImpl expand = new ExpandOptionImpl();
+ FilterOptionImpl filter = new FilterOptionImpl();
+ CountOptionImpl inlinecount = new CountOptionImpl();
+ OrderByOptionImpl orderby = new OrderByOptionImpl();
+ SearchOptionImpl search = new SearchOptionImpl();
+ SelectOptionImpl select = new SelectOptionImpl();
+ SkipOptionImpl skip = new SkipOptionImpl();
+ TopOptionImpl top = new TopOptionImpl();
+ LevelsOptionImpl levels = new LevelsOptionImpl();
+
+ option.setSystemQueryOption(expand);
+ option.setSystemQueryOption(filter);
+ option.setSystemQueryOption(inlinecount);
+ option.setSystemQueryOption(orderby);
+ option.setSystemQueryOption(search);
+ option.setSystemQueryOption(select);
+ option.setSystemQueryOption(skip);
+ option.setSystemQueryOption(top);
+ option.setSystemQueryOption(levels);
+
+ assertEquals(expand, option.getExpandOption());
+ assertEquals(filter, option.getFilterOption());
+ assertEquals(inlinecount, option.getCountOption());
+ assertEquals(orderby, option.getOrderByOption());
+ assertEquals(search, option.getSearchOption());
+ assertEquals(select, option.getSelectOption());
+ assertEquals(skip, option.getSkipOption());
+ assertEquals(top, option.getTopOption());
+ assertEquals(levels, option.getLevelsOption());
+
+ // just for completeness
+ option = new ExpandItemImpl();
+ option.setSystemQueryOption(new IdOptionImpl());
+
+ option = new ExpandItemImpl();
+ List<SystemQueryOptionImpl> list = new ArrayList<SystemQueryOptionImpl>();
+ list.add(expand);
+ list.add(filter);
+ option.setSystemQueryOptions(list);
+ assertEquals(expand, option.getExpandOption());
+ assertEquals(filter, option.getFilterOption());
+
+ option = new ExpandItemImpl();
+ assertEquals(false, option.isRef());
+ option.setIsRef(true);
+ assertEquals(true, option.isRef());
+
+ option = new ExpandItemImpl();
+ assertEquals(false, option.isStar());
+ option.setIsStar(true);
+ assertEquals(true, option.isStar());
+
+ option = new ExpandItemImpl();
+ UriInfoResource resource = new UriInfoImpl().asUriInfoResource();
+ option.setResourcePath(resource);
+ assertEquals(resource, option.getResourcePath());
+
+ }
+
+ @Test
+ public void testExpandOptionImpl() {
+ ExpandOptionImpl option = new ExpandOptionImpl();
+ assertEquals(SystemQueryOptionKind.EXPAND, option.getKind());
+
+ ExpandItemImpl item1 = new ExpandItemImpl();
+ ExpandItemImpl item2 = new ExpandItemImpl();
+ option.addExpandItem(item1);
+ option.addExpandItem(item2);
+ assertEquals(item1, option.getExpandItems().get(0));
+ assertEquals(item2, option.getExpandItems().get(1));
+ }
+
+ @Test
+ public void testFilterOptionImpl() {
+ FilterOptionImpl option = new FilterOptionImpl();
+ assertEquals(SystemQueryOptionKind.FILTER, option.getKind());
+
+ AliasImpl expression = new AliasImpl();
+
+ option.setExpression(expression);
+ assertEquals(expression, option.getExpression());
+ }
+
+ @Test
+ public void testFormatOptionImpl() {
+ FormatOptionImpl option = new FormatOptionImpl();
+ assertEquals(SystemQueryOptionKind.FORMAT, option.getKind());
+
+ option.setFormat("A");
+
+ assertEquals("A", option.getFormat());
+ }
+
+ @Test
+ public void testIdOptionImpl() {
+ IdOptionImpl option = new IdOptionImpl();
+ assertEquals(SystemQueryOptionKind.ID, option.getKind());
+
+ option.setValue("A");
+
+ assertEquals("A", option.getValue());
+ }
+
+ @Test
+ public void testInlineCountImpl() {
+ CountOptionImpl option = new CountOptionImpl();
+ assertEquals(SystemQueryOptionKind.COUNT, option.getKind());
+
+ assertEquals(false, option.getValue());
+ option.setValue(true);
+ assertEquals(true, option.getValue());
+ }
+
+ @Test
+ public void testLevelsExpandOptionImpl() {
+ LevelsOptionImpl option = new LevelsOptionImpl();
+ assertEquals(SystemQueryOptionKind.LEVELS, option.getKind());
+
+ assertEquals(0, option.getValue());
+ option.setValue(1);
+ assertEquals(1, option.getValue());
+
+ option = new LevelsOptionImpl();
+ option.setMax();
+ assertEquals(true, option.isMax());
+ }
+
+ @Test
+ public void testOrderByItemImpl() {
+ OrderByItemImpl option = new OrderByItemImpl();
+
+ AliasImpl expression = new AliasImpl();
+ option.setExpression(expression);
+ assertEquals(expression, option.getExpression());
+
+ assertEquals(false, option.isDescending());
+ option.setDescending(true);
+ assertEquals(true, option.isDescending());
+ }
+
+ @Test
+ public void testOrderByOptionImpl() {
+ OrderByOptionImpl option = new OrderByOptionImpl();
+
+ OrderByItemImpl order0 = new OrderByItemImpl();
+ OrderByItemImpl order1 = new OrderByItemImpl();
+ option.addOrder(order0);
+ option.addOrder(order1);
+
+ assertEquals(order0, option.getOrders().get(0));
+ assertEquals(order1, option.getOrders().get(1));
+ }
+
+ @Test
+ public void testQueryOptionImpl() {
+ QueryOptionImpl option = new AliasQueryOptionImpl();
+
+ option.setName("A");
+ option.setText("B");
+ assertEquals("A", option.getName());
+ assertEquals("B", option.getText());
+ }
+
+ @Test
+ public void testSearchOptionImpl() {
+ SearchOptionImpl option = new SearchOptionImpl();
+ assertEquals(SystemQueryOptionKind.SEARCH, option.getKind());
+ // TODO $search is not supported yet
+ }
+
+ @Test
+ public void testSelectItemImpl() {
+ SelectItemImpl option = new SelectItemImpl();
+
+ // no typed collection else case ( e.g. if not path is added)
+ option = new SelectItemImpl();
+
+ option = new SelectItemImpl();
+ assertEquals(false, option.isStar());
+ option.setStar(true);
+ assertEquals(true, option.isStar());
+
+ option = new SelectItemImpl();
+ assertEquals(false, option.isAllOperationsInSchema());
+ FullQualifiedName fqName = new FullQualifiedName("Namespace", "Name");
+ option.addAllOperationsInSchema(fqName);
+ assertEquals(true, option.isAllOperationsInSchema());
+ assertEquals(fqName, option.getAllOperationsInSchemaNameSpace());
+
+ }
+
+ @Test
+ public void testSelectOptionImpl() {
+ 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);
+
+ assertEquals(item0, option.getSelectItems().get(0));
+ assertEquals(item1, option.getSelectItems().get(1));
+
+ }
+
+ @Test
+ public void testSkipOptionImpl() {
+ SkipOptionImpl option = new SkipOptionImpl();
+ assertEquals(SystemQueryOptionKind.SKIP, option.getKind());
+
+ option.setValue(10);
+ assertEquals(10, option.getValue());
+ }
+
+ @Test
+ public void testSkipTokenOptionImpl() {
+ SkipTokenOptionImpl option = new SkipTokenOptionImpl();
+ assertEquals(SystemQueryOptionKind.SKIPTOKEN, option.getKind());
+
+ option.setValue("A");
+ assertEquals("A", option.getValue());
+ }
+
+ @Test
+ public void testSystemQueryOptionImpl() {
+ SystemQueryOptionImpl option = new SystemQueryOptionImpl();
+
+ option.setKind(SystemQueryOptionKind.EXPAND);
+ assertEquals(SystemQueryOptionKind.EXPAND, option.getKind());
+
+ assertEquals("$expand", option.getName());
+ }
+
+ @Test
+ public void testTopOptionImpl() {
+ TopOptionImpl option = new TopOptionImpl();
+ assertEquals(SystemQueryOptionKind.TOP, option.getKind());
+
+ option.setValue(11);
+ assertEquals(11, option.getValue());
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java
new file mode 100644
index 0000000..2902bdc
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/queryoption/expression/ExpressionTest.java
@@ -0,0 +1,239 @@
+/*
+ * 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.queryoption.expression;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Arrays;
+
+import org.apache.olingo.commons.api.ODataApplicationException;
+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.server.api.uri.UriInfoKind;
+import org.apache.olingo.server.api.uri.UriInfoResource;
+import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
+import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
+import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
+import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind;
+import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
+import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
+import org.apache.olingo.server.core.testutil.techprovider.ActionProvider;
+import org.apache.olingo.server.core.testutil.techprovider.EntityTypeProvider;
+import org.apache.olingo.server.core.testutil.techprovider.EnumTypeProvider;
+import org.apache.olingo.server.core.testutil.techprovider.FunctionProvider;
+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.FilterTreeToText;
+import org.junit.Test;
+
+public class ExpressionTest {
+ Edm edm = new EdmProviderImpl(new EdmTechTestProvider());
+
+ @Test
+ public void testSupportedOperators() {
+ assertEquals(UnaryOperatorKind.MINUS, UnaryOperatorKind.get("-"));
+ assertEquals(null, UnaryOperatorKind.get("XXX"));
+
+ assertEquals(BinaryOperatorKind.MOD, BinaryOperatorKind.get("mod"));
+ assertEquals(null, BinaryOperatorKind.get("XXX"));
+
+ assertEquals(MethodKind.CONCAT, MethodKind.get("concat"));
+ assertEquals(null, MethodKind.get("XXX"));
+ }
+
+ @Test
+ public void testAliasExpression() throws ExpressionVisitException, ODataApplicationException {
+ AliasImpl expression = new AliasImpl();
+
+ expression.setParameter("Test");
+
+ assertEquals("Test", expression.getParameterName());
+
+ String output = expression.accept(new FilterTreeToText());
+ assertEquals("<Test>", output);
+
+ }
+
+ @Test
+ public void testBinaryExpression() throws ExpressionVisitException, ODataApplicationException {
+ BinaryImpl expression = new BinaryImpl();
+
+ ExpressionImpl expressionLeft = new LiteralImpl().setText("A");
+ ExpressionImpl expressionRight = new LiteralImpl().setText("B");
+
+ expression.setLeftOperand(expressionLeft);
+ expression.setRightOperand(expressionRight);
+ expression.setOperator(BinaryOperatorKind.SUB);
+
+ assertEquals(expressionLeft, expression.getLeftOperand());
+ assertEquals(expressionRight, expression.getRightOperand());
+ assertEquals(BinaryOperatorKind.SUB, expression.getOperator());
+
+ String output = expression.accept(new FilterTreeToText());
+ assertEquals("<<A> sub <B>>", output);
+ }
+
+ @Test
+ public void testEnumerationExpression() throws ExpressionVisitException, ODataApplicationException {
+ EnumerationImpl expression = new EnumerationImpl();
+ EdmEnumType type = (EdmEnumType) edm.getEnumType(EnumTypeProvider.nameENString);
+ assertNotNull(type);
+ expression.setType(type);
+
+ assertEquals(type, expression.getType());
+
+ expression.addValue("A");
+ expression.addValue("B");
+ assertEquals("A", expression.getValues().get(0));
+ assertEquals("B", expression.getValues().get(1));
+ assertEquals("<com.sap.odata.test1.ENString<A,B>>", expression.accept(new FilterTreeToText()));
+ }
+
+ @Test
+ public void testLambdaRefExpression() throws ExpressionVisitException, ODataApplicationException {
+ LambdaRefImpl expression = new LambdaRefImpl();
+ expression.setVariableText("A");
+ assertEquals("A", expression.getVariableName());
+
+ assertEquals("<A>", expression.accept(new FilterTreeToText()));
+
+ }
+
+ @Test
+ public void testLiteralExpresion() throws ExpressionVisitException, ODataApplicationException {
+ LiteralImpl expression = new LiteralImpl();
+ expression.setText("A");
+ assertEquals("A", expression.getText());
+
+ assertEquals("<A>", expression.accept(new FilterTreeToText()));
+ }
+
+ @Test
+ public void testMemberExpression() throws ExpressionVisitException, ODataApplicationException {
+ MemberImpl expression = new MemberImpl();
+ EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETKeyNav);
+
+ // UriResourceImplTyped
+ EdmAction action = edm.getUnboundAction(ActionProvider.nameUARTPrimParam);
+ UriInfoResource uriInfo = new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
+ new UriResourceActionImpl().setAction(action)).asUriInfoResource();
+ expression.setResourcePath(uriInfo);
+ assertEquals(action.getReturnType().getType(), expression.getType());
+
+ // check accept and path
+ assertEquals(uriInfo, expression.getResourcePath());
+ assertEquals("<UARTPrimParam>", expression.accept(new FilterTreeToText()));
+
+ // UriResourceImplTyped check collection = false case
+ assertEquals(false, expression.isCollection());
+
+ // UriResourceImplTyped check collection = true case
+ action = edm.getUnboundAction(ActionProvider.nameUARTPrimCollParam);
+ expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
+ new UriResourceActionImpl().setAction(action))
+ .asUriInfoResource());
+ assertEquals(true, expression.isCollection());
+
+ // UriResourceImplTyped with filter
+ action = edm.getUnboundAction(ActionProvider.nameUARTPrimParam);
+ expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
+ new UriResourceActionImpl().setAction(action).setTypeFilter(entityType))
+ .asUriInfoResource());
+ assertEquals(entityType, expression.getType());
+
+ // UriResourceImplKeyPred
+ EdmFunction function = edm.getUnboundFunction(FunctionProvider.nameUFCRTETKeyNav, null);
+ expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
+ new UriResourceFunctionImpl().setFunction(function))
+ .asUriInfoResource());
+ assertEquals(function.getReturnType().getType(), expression.getType());
+
+ // UriResourceImplKeyPred typeFilter on entry
+ EdmEntityType entityBaseType = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
+ function = edm.getUnboundFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam, Arrays.asList("ParameterInt16"));
+ expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
+ new UriResourceFunctionImpl().setFunction(function).setEntryTypeFilter(entityBaseType))
+ .asUriInfoResource());
+ assertEquals(entityBaseType, expression.getType());
+
+ // UriResourceImplKeyPred typeFilter on entry
+ entityBaseType = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
+ function = edm.getUnboundFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam, Arrays.asList("ParameterInt16"));
+ expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
+ new UriResourceFunctionImpl().setFunction(function).setCollectionTypeFilter(entityBaseType))
+ .asUriInfoResource());
+ assertEquals(entityBaseType, expression.getType());
+
+ // no typed
+ entityBaseType = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
+ function = edm.getUnboundFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam, Arrays.asList("ParameterInt16"));
+ expression.setResourcePath(new UriInfoImpl().setKind(UriInfoKind.all));
+ assertEquals(null, expression.getType());
+
+ // no typed collection else case
+ assertEquals(false, expression.isCollection());
+ }
+
+ @Test
+ public void testMethodCallExpression() throws ExpressionVisitException, ODataApplicationException {
+ MethodImpl expression = new MethodImpl();
+ expression.setMethod(MethodKind.CONCAT);
+
+ ExpressionImpl p0 = new LiteralImpl().setText("A");
+ ExpressionImpl p1 = new LiteralImpl().setText("B");
+ expression.addParameter(p0);
+ expression.addParameter(p1);
+
+ assertEquals(MethodKind.CONCAT, expression.getMethod());
+ assertEquals("<concat(<A>,<B>)>", expression.accept(new FilterTreeToText()));
+
+ assertEquals(p0, expression.getParameters().get(0));
+ assertEquals(p1, expression.getParameters().get(1));
+ }
+
+ @Test
+ public void testTypeLiteralExpression() throws ExpressionVisitException, ODataApplicationException {
+ TypeLiteralImpl expression = new TypeLiteralImpl();
+ EdmEntityType entityBaseType = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
+ expression.setType(entityBaseType);
+
+ assertEquals(entityBaseType, expression.getType());
+ assertEquals("<com.sap.odata.test1.ETBaseTwoKeyNav>", expression.accept(new FilterTreeToText()));
+ }
+
+ @Test
+ public void testUnaryExpression() throws ExpressionVisitException, ODataApplicationException {
+ UnaryImpl expression = new UnaryImpl();
+ expression.setOperator(UnaryOperatorKind.MINUS);
+
+ ExpressionImpl operand = new LiteralImpl().setText("A");
+ expression.setOperand(operand);
+
+ assertEquals(UnaryOperatorKind.MINUS, expression.getOperator());
+ assertEquals(operand, expression.getOperand());
+
+ assertEquals("<- <A>>", expression.accept(new FilterTreeToText()));
+ }
+
+}
[08/15] [OLINGO-266] refactor ref module to server-ref
Posted by sk...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EntityTypeProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EntityTypeProvider.java b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EntityTypeProvider.java
new file mode 100644
index 0000000..9072234
--- /dev/null
+++ b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EntityTypeProvider.java
@@ -0,0 +1,408 @@
+/*
+ * 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.testutil.techprovider;
+
+import java.util.Arrays;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.server.api.edm.provider.EntityType;
+import org.apache.olingo.server.api.edm.provider.NavigationProperty;
+import org.apache.olingo.server.api.edm.provider.Property;
+import org.apache.olingo.server.api.edm.provider.PropertyRef;
+import org.apache.olingo.server.api.edm.provider.ReferentialConstraint;
+
+public class EntityTypeProvider {
+
+ public static final FullQualifiedName nameETAllKey = new FullQualifiedName(SchemaProvider.nameSpace, "ETAllKey");
+ public static final FullQualifiedName nameETAllNullable = new FullQualifiedName(SchemaProvider.nameSpace,
+ "ETAllNullable");
+ public static final FullQualifiedName nameETAllPrim = new FullQualifiedName(SchemaProvider.nameSpace, "ETAllPrim");
+ public static final FullQualifiedName nameETBase = new FullQualifiedName(SchemaProvider.nameSpace, "ETBase");
+ public static final FullQualifiedName nameETBaseTwoKeyNav = new FullQualifiedName(SchemaProvider.nameSpace,
+ "ETBaseTwoKeyNav");
+ public static final FullQualifiedName nameETBaseTwoKeyTwoPrim =
+ new FullQualifiedName(SchemaProvider.nameSpace, "ETBaseTwoKeyTwoPrim");
+ public static final FullQualifiedName nameETCollAllPrim = new FullQualifiedName(SchemaProvider.nameSpace,
+ "ETCollAllPrim");
+ public static final FullQualifiedName nameETCompAllPrim = new FullQualifiedName(SchemaProvider.nameSpace,
+ "ETCompAllPrim");
+ public static final FullQualifiedName nameETCompCollAllPrim = new FullQualifiedName(SchemaProvider.nameSpace,
+ "ETCompCollAllPrim");
+ public static final FullQualifiedName nameETCompCollComp = new FullQualifiedName(SchemaProvider.nameSpace,
+ "ETCompCollComp");
+ public static final FullQualifiedName nameETCompComp = new FullQualifiedName(SchemaProvider.nameSpace, "ETCompComp");
+ public static final FullQualifiedName nameETCompMixPrimCollComp =
+ new FullQualifiedName(SchemaProvider.nameSpace, "ETCompMixPrimCollComp");
+ public static final FullQualifiedName nameETFourKeyAlias = new FullQualifiedName(SchemaProvider.nameSpace,
+ "ETFourKeyAlias");
+ public static final FullQualifiedName nameETKeyNav = new FullQualifiedName(SchemaProvider.nameSpace, "ETKeyNav");
+ public static final FullQualifiedName nameETKeyPrimNav = new FullQualifiedName(SchemaProvider.nameSpace,
+ "ETKeyPrimNav");
+ public static final FullQualifiedName nameETKeyTwoKeyComp = new FullQualifiedName(SchemaProvider.nameSpace,
+ "ETKeyTwoKeyComp");
+ public static final FullQualifiedName nameETMedia = new FullQualifiedName(SchemaProvider.nameSpace, "ETMedia");
+ public static final FullQualifiedName nameETMixPrimCollComp = new FullQualifiedName(SchemaProvider.nameSpace,
+ "ETMixPrimCollComp");
+ public static final FullQualifiedName nameETServerSidePaging =
+ new FullQualifiedName(SchemaProvider.nameSpace, "ETServerSidePaging");
+ public static final FullQualifiedName nameETTwoBase = new FullQualifiedName(SchemaProvider.nameSpace, "ETTwoBase");
+ public static final FullQualifiedName nameETTwoBaseTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "ETTwoBaseTwoKeyNav");
+ public static final FullQualifiedName nameETTwoBaseTwoKeyTwoPrim =
+ new FullQualifiedName(SchemaProvider.nameSpace, "ETTwoBaseTwoKeyTwoPrim");
+ public static final FullQualifiedName nameETTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "ETTwoKeyNav");
+ public static final FullQualifiedName nameETTwoKeyTwoPrim = new FullQualifiedName(SchemaProvider.nameSpace,
+ "ETTwoKeyTwoPrim");
+ public static final FullQualifiedName nameETTwoPrim = new FullQualifiedName(SchemaProvider.nameSpace, "ETTwoPrim");
+
+ public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException {
+ if (entityTypeName.equals(nameETAllPrim)) {
+ return new EntityType()
+ .setName("ETAllPrim")
+ .setKey(Arrays.asList(
+ new PropertyRef().setPropertyName("PropertyInt16")))
+ .setProperties(Arrays.asList(
+ PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString,
+ PropertyProvider.propertyBoolean, PropertyProvider.propertyByte, PropertyProvider.propertySByte,
+ PropertyProvider.propertyInt32, PropertyProvider.propertyInt64,
+ PropertyProvider.propertySingle, PropertyProvider.propertyDouble, PropertyProvider.propertyDecimal,
+ PropertyProvider.propertyBinary, PropertyProvider.propertyDate, PropertyProvider.propertyDateTimeOffset,
+ PropertyProvider.propertyDuration, PropertyProvider.propertyGuid, PropertyProvider.propertyTimeOfDay
+ /* TODO add propertyStream */))
+ .setNavigationProperties(Arrays.asList(PropertyProvider.navPropertyETTwoPrimOne_ETTwoPrim,
+ PropertyProvider.collectionNavPropertyETTwoPrimMany_ETTwoPrim));
+
+ } else if (entityTypeName.equals(nameETCollAllPrim)) {
+ return new EntityType()
+ .setName("ETCollAllPrim")
+ .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
+
+ .setProperties(
+ Arrays.asList(
+ PropertyProvider.propertyInt16_NotNullable, PropertyProvider.collPropertyString,
+ PropertyProvider.collPropertyBoolean, PropertyProvider.collPropertyByte,
+ PropertyProvider.collPropertySByte, PropertyProvider.collPropertyInt16,
+ PropertyProvider.collPropertyInt32, PropertyProvider.collPropertyInt64,
+ PropertyProvider.collPropertySingle, PropertyProvider.collPropertyDouble,
+ PropertyProvider.collPropertyDecimal, PropertyProvider.collPropertyBinary,
+ PropertyProvider.collPropertyDate, PropertyProvider.collPropertyDateTimeOffset,
+ PropertyProvider.collPropertyDuration, PropertyProvider.collPropertyGuid,
+ PropertyProvider.collPropertyTimeOfDay /* TODO add propertyStream */));
+
+ } else if (entityTypeName.equals(nameETTwoPrim)) {
+ return new EntityType()
+ .setName("ETTwoPrim")
+ .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
+ .setProperties(Arrays.asList(
+ PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString))
+ .setNavigationProperties(
+ Arrays.asList(PropertyProvider.navPropertyETAllPrimOne_ETAllPrim,
+ PropertyProvider.collectionNavPropertyETAllPrimMany_ETAllPrim));
+
+ } else if (entityTypeName.equals(nameETMixPrimCollComp)) {
+ return new EntityType()
+ .setName("ETMixPrimCollComp")
+ .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
+ .setProperties(Arrays.asList(
+ PropertyProvider.propertyInt16_NotNullable, PropertyProvider.collPropertyString,
+ PropertyProvider.propertyComplex_CTTwoPrim, PropertyProvider.collPropertyComplex_CTTwoPrim));
+
+ } else if (entityTypeName.equals(nameETTwoKeyTwoPrim)) {
+ return new EntityType()
+ .setName("ETTwoKeyTwoPrim")
+ .setKey(Arrays.asList(
+ new PropertyRef().setPropertyName("PropertyInt16"),
+ new PropertyRef().setPropertyName("PropertyString")))
+ .setProperties(Arrays.asList(
+ PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString));
+
+ } else if (entityTypeName.equals(nameETBaseTwoKeyTwoPrim)) {
+ return new EntityType()
+ .setName("ETBaseTwoKeyTwoPrim")
+ .setBaseType(nameETTwoKeyTwoPrim);
+
+ } else if (entityTypeName.equals(nameETTwoBaseTwoKeyTwoPrim)) {
+ return new EntityType()
+ .setName("ETTwoBaseTwoKeyTwoPrim")
+ .setBaseType(nameETTwoKeyTwoPrim);
+
+ } else if (entityTypeName.equals(nameETBase)) {
+ return new EntityType()
+ .setName("ETBase")
+ .setBaseType(nameETTwoPrim)
+ .setProperties(Arrays.asList(new Property()
+ .setName("AdditionalPropertyString_5")
+ .setType(PropertyProvider.nameString)));
+
+ } else if (entityTypeName.equals(nameETTwoBase)) {
+ return new EntityType()
+ .setName("ETTwoBase")
+ .setBaseType(nameETBase)
+ .setProperties(Arrays.asList(new Property()
+ .setName("AdditionalPropertyString_6")
+ .setType(PropertyProvider.nameString))
+ );
+
+ } else if (entityTypeName.equals(nameETAllKey)) {
+ return new EntityType()
+ .setName("ETAllKey")
+ .setKey(Arrays.asList(
+ new PropertyRef().setPropertyName("PropertyString"),
+ new PropertyRef().setPropertyName("PropertyBoolean"),
+ new PropertyRef().setPropertyName("PropertyByte"),
+ new PropertyRef().setPropertyName("PropertySByte"),
+ new PropertyRef().setPropertyName("PropertyInt16"),
+ new PropertyRef().setPropertyName("PropertyInt32"),
+ new PropertyRef().setPropertyName("PropertyInt64"),
+ new PropertyRef().setPropertyName("PropertyDecimal"),
+ new PropertyRef().setPropertyName("PropertyDate"),
+ new PropertyRef().setPropertyName("PropertyDateTimeOffset"),
+ new PropertyRef().setPropertyName("PropertyDuration"),
+ new PropertyRef().setPropertyName("PropertyGuid"),
+ new PropertyRef().setPropertyName("PropertyTimeOfDay")))
+ .setProperties(
+ Arrays.asList(
+ PropertyProvider.propertyString_NotNullable, PropertyProvider.propertyBoolean_NotNullable,
+ PropertyProvider.propertyByte_NotNullable, PropertyProvider.propertySByte_NotNullable,
+ PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyInt32_NotNullable,
+ PropertyProvider.propertyInt64_NotNullable,
+ PropertyProvider.propertyDecimal_NotNullable, PropertyProvider.propertyDate_NotNullable,
+ PropertyProvider.propertyDateTimeOffset_NotNullable,
+ PropertyProvider.propertyDuration_NotNullable, PropertyProvider.propertyGuid_NotNullable,
+ PropertyProvider.propertyTimeOfDay_NotNullable /* TODO add propertyStream */));
+
+ } else if (entityTypeName.equals(nameETCompAllPrim)) {
+ return new EntityType()
+ .setName("ETCompAllPrim")
+ .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
+ .setProperties(
+ Arrays.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComplex_CTAllPrim));
+
+ } else if (entityTypeName.equals(nameETCompCollAllPrim)) {
+ return new EntityType()
+ .setName("ETCompCollAllPrim")
+ .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
+
+ .setProperties(
+ Arrays.asList(PropertyProvider.propertyInt16_NotNullable,
+ PropertyProvider.propertyComplex_CTCollAllPrim));
+
+ } else if (entityTypeName.equals(nameETCompComp)) {
+ return new EntityType()
+ .setName("ETCompComp")
+ .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
+ .setProperties(
+ Arrays.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComplex_CTCompComp));
+
+ } else if (entityTypeName.equals(nameETCompCollComp)) {
+ return new EntityType()
+ .setName("ETCompCollComp")
+ .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
+ .setProperties(
+ Arrays
+ .asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComplex_CTCompCollComp));
+
+ } else if (entityTypeName.equals(nameETMedia)) {
+ return new EntityType()
+ .setName("ETMedia")
+ .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
+ .setProperties(Arrays.asList(PropertyProvider.propertyInt16_NotNullable))
+ .setHasStream(true);
+
+ } else if (entityTypeName.equals(nameETKeyTwoKeyComp)) {
+ return new EntityType()
+ .setName("ETKeyTwoKeyComp")
+ .setKey(Arrays.asList(
+ new PropertyRef()
+ .setPropertyName("PropertyInt16"),
+ new PropertyRef()
+ .setPropertyName("PropertyComplex/PropertyInt16")
+ .setAlias("KeyAlias1"),
+ new PropertyRef()
+ .setPropertyName("PropertyComplex/PropertyString")
+ .setAlias("KeyAlias2"),
+ new PropertyRef()
+ .setPropertyName("PropertyComplexComplex/PropertyComplex/PropertyString")
+ .setAlias("KeyAlias3")))
+ .setProperties(
+ Arrays.asList(
+ PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComplex_CTTwoPrim,
+ PropertyProvider.propertyComplexComplex_CTCompComp));
+
+ } else if (entityTypeName.equals(nameETServerSidePaging)) {
+ return new EntityType()
+ .setName(nameETServerSidePaging.getName())
+ .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
+ .setProperties(Arrays.asList(PropertyProvider.propertyInt16_NotNullable,
+ PropertyProvider.propertyString_NotNullable));
+
+ } else if (entityTypeName.equals(nameETAllNullable)) {
+ return new EntityType()
+ .setName("ETAllNullable")
+ .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyKey")))
+ .setProperties(
+ Arrays.asList(
+ new Property()
+ .setName("PropertyKey").setType(PropertyProvider.nameInt16).setNullable(false),
+ PropertyProvider.propertyInt16_ExplicitNullable, PropertyProvider.propertyString_ExplicitNullable,
+ PropertyProvider.propertyBoolean_ExplicitNullable, PropertyProvider.propertyByte_ExplicitNullable,
+ PropertyProvider.propertySByte_ExplicitNullable, PropertyProvider.propertyInt32_ExplicitNullable,
+ PropertyProvider.propertyInt64_ExplicitNullable, PropertyProvider.propertySingle_ExplicitNullable,
+ PropertyProvider.propertyDouble_ExplicitNullable, PropertyProvider.propertyDecimal_ExplicitNullable,
+ PropertyProvider.propertyBinary_ExplicitNullable, PropertyProvider.propertyDate_ExplicitNullable,
+ PropertyProvider.propertyDateTimeOffset_ExplicitNullable,
+ PropertyProvider.propertyDuration_ExplicitNullable, PropertyProvider.propertyGuid_ExplicitNullable,
+ PropertyProvider.propertyTimeOfDay_ExplicitNullable /* TODO add propertyStream */,
+ PropertyProvider.collPropertyString_ExplicitNullable,
+ PropertyProvider.collPropertyBoolean_ExplicitNullable,
+ PropertyProvider.collPropertyByte_ExplicitNullable,
+ PropertyProvider.collPropertySByte_ExplicitNullable,
+ PropertyProvider.collPropertyInt16_ExplicitNullable,
+ PropertyProvider.collPropertyInt32_ExplicitNullable,
+ PropertyProvider.collPropertyInt64_ExplicitNullable,
+ PropertyProvider.collPropertySingle_ExplicitNullable,
+ PropertyProvider.collPropertyDouble_ExplicitNullable,
+ PropertyProvider.collPropertyDecimal_ExplicitNullable,
+ PropertyProvider.collPropertyBinary_ExplicitNullable,
+ PropertyProvider.collPropertyDate_ExplicitNullable,
+ PropertyProvider.collPropertyDateTimeOffset_ExplicitNullable,
+ PropertyProvider.collPropertyDuration_ExplicitNullable,
+ PropertyProvider.collPropertyGuid_ExplicitNullable,
+ PropertyProvider.collPropertyTimeOfDay_ExplicitNullable /* TODO add propertyStream */));
+
+ } else if (entityTypeName.equals(nameETKeyNav)) {
+ return new EntityType()
+ .setName("ETKeyNav")
+ .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
+ .setProperties(
+ Arrays.asList(
+ PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_NotNullable,
+ PropertyProvider.propertyComplex_CTNavFiveProp,
+ PropertyProvider.propertyComplexAllPrim_CTAllPrim, PropertyProvider.propertyComplexTwoPrim_CTTwoPrim,
+ PropertyProvider.collPropertyString, PropertyProvider.collPropertyInt16,
+ PropertyProvider.collPropertyComplex_CTPrimComp,
+ new Property()
+ .setName("PropertyComplexComplex").setType(ComplexTypeProvider.nameCTCompNav)
+ ))
+ .setNavigationProperties(
+ Arrays.asList(
+ PropertyProvider.navPropertyETTwoKeyNavOne_ETTwoKeyNav_NotNullable,
+ PropertyProvider.collectionNavPropertyETTwoKeyNavMany_ETTwoKeyNav,
+ PropertyProvider.navPropertyETKeyNavOne_ETKeyNav,
+ PropertyProvider.collectionNavPropertyETKeyNavMany_ETKeyNav,
+ PropertyProvider.navPropertyETMediaOne_ETMedia,
+ PropertyProvider.collectionNavPropertyETMediaMany_ETMedia
+ ));
+ } else if (entityTypeName.equals(nameETKeyPrimNav)) {
+ return new EntityType()
+ .setName("ETKeyPrimNav")
+ .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
+ .setProperties(Arrays.asList(
+ PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_ExplicitNullable))
+ .setNavigationProperties(
+ Arrays.asList(
+ PropertyProvider.navPropertyETKeyPrimNavOne_ETKeyPrimNav));
+
+ } else if (entityTypeName.equals(nameETTwoKeyNav)) {
+ return new EntityType()
+ .setName("ETTwoKeyNav")
+ .setKey(Arrays.asList(
+ new PropertyRef().setPropertyName("PropertyInt16"),
+ new PropertyRef().setPropertyName("PropertyString")))
+ .setProperties(
+ Arrays.asList(
+ PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_NotNullable,
+ PropertyProvider.propertyComplex_CTPrimComp_NotNullable,
+ new Property().setName("PropertyComplexNav").setType(ComplexTypeProvider.nameCTBasePrimCompNav)
+ .setNullable(false),
+ PropertyProvider.propertyComplexEnum_CTPrimEnum_NotNullable,
+ PropertyProvider.collPropertyComplex_CTPrimComp,
+ new Property().setName("CollPropertyComplexNav").setType(ComplexTypeProvider.nameCTNavFiveProp)
+ .setCollection(true),
+ PropertyProvider.collPropertyString, PropertyProvider.propertyComplexTwoPrim_CTTwoPrim,
+ PropertyProvider.propertyEnumString_ENString
+ ))
+ .setNavigationProperties(Arrays.asList(
+ new NavigationProperty()
+ .setName("NavPropertyETKeyNavOne")
+ .setType(nameETKeyNav)
+ .setReferentialConstraints(Arrays.asList(
+ new ReferentialConstraint()
+ .setProperty("PropertyInt16")
+ .setReferencedProperty("PropertyInt16"))),
+ PropertyProvider.collectionNavPropertyETKeyNavMany_ETKeyNav,
+ PropertyProvider.navPropertyETTwoKeyNavOne_ETTwoKeyNav,
+ PropertyProvider.collectionNavPropertyETTwoKeyNavMany_ETTwoKeyNav));
+
+ } else if (entityTypeName.equals(nameETBaseTwoKeyNav)) {
+ return new EntityType()
+ .setName("ETBaseTwoKeyNav")
+ .setBaseType(nameETTwoKeyNav)
+ .setProperties(Arrays.asList(PropertyProvider.propertyDate_ExplicitNullable))
+ .setNavigationProperties(Arrays.asList(
+ new NavigationProperty()
+ .setName("NavPropertyETBaseTwoKeyNavOne")
+ .setType(nameETBaseTwoKeyNav),
+ new NavigationProperty()
+ .setName("NavPropertyETTwoBaseTwoKeyNavOne")
+ .setType(nameETTwoBaseTwoKeyNav)));
+
+ } else if (entityTypeName.equals(nameETTwoBaseTwoKeyNav)) {
+ return new EntityType()
+ .setName("ETTwoBaseTwoKeyNav")
+ .setBaseType(nameETBaseTwoKeyNav)
+ .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16")))
+ .setProperties(Arrays.asList(PropertyProvider.propertyGuid_ExplicitNullable))
+ .setNavigationProperties(Arrays.asList(
+ new NavigationProperty()
+ .setName("NavPropertyETBaseTwoKeyNavMany")
+ .setType(nameETBaseTwoKeyNav)
+ .setCollection(true)
+ ));
+
+ } else if (entityTypeName.equals(nameETFourKeyAlias)) {
+ return new EntityType()
+ .setName("ETFourKeyAlias")
+ .setKey(
+ Arrays.asList(
+ new PropertyRef().setPropertyName("PropertyInt16"),
+ new PropertyRef().setPath("PropertyComplex/PropertyInt16").setPropertyName("PropertyInt16").setAlias(
+ "KeyAlias1"),
+ new PropertyRef().setPath("PropertyComplex/PropertyString").setPropertyName("PropertyString")
+ .setAlias("KeyAlias2"),
+ new PropertyRef().setPath("PropertyComplexComplex/PropertyComplex/PropertyString").setPropertyName(
+ "PropertyString").setAlias("KeyAlias3"))).setProperties(
+ Arrays.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComplex_CTTwoPrim,
+ PropertyProvider.propertyComplexComplex_CTCompComp));
+ } else if (entityTypeName.equals(nameETCompMixPrimCollComp)) {
+ return new EntityType()
+ .setName("ETCompMixPrimCollComp")
+ .setKey(Arrays.asList(
+ new PropertyRef()
+ .setPropertyName("PropertyInt16")))
+ .setProperties(
+ Arrays.asList(PropertyProvider.propertyInt16_NotNullable,
+ PropertyProvider.propertyMixedPrimCollComp_CTMixPrimCollComp));
+ }
+
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EnumTypeProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EnumTypeProvider.java b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EnumTypeProvider.java
new file mode 100644
index 0000000..94ea6ea
--- /dev/null
+++ b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EnumTypeProvider.java
@@ -0,0 +1,47 @@
+/*
+ * 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.testutil.techprovider;
+
+import java.util.Arrays;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.server.api.edm.provider.EnumMember;
+import org.apache.olingo.server.api.edm.provider.EnumType;
+
+public class EnumTypeProvider {
+
+ public static final FullQualifiedName nameENString = new FullQualifiedName(SchemaProvider.nameSpace, "ENString");
+
+ public EnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException {
+ if (enumTypeName.equals(nameENString)) {
+ return new EnumType()
+ .setName("ENString")
+ .setFlags(true)
+ .setUnderlyingType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName())
+ .setMembers(Arrays.asList(
+ new EnumMember().setName("String1").setValue("1"),
+ new EnumMember().setName("String2").setValue("2"),
+ new EnumMember().setName("String3").setValue("3")));
+ }
+
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/FunctionProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/FunctionProvider.java b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/FunctionProvider.java
new file mode 100644
index 0000000..fe6fefb
--- /dev/null
+++ b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/FunctionProvider.java
@@ -0,0 +1,852 @@
+/*
+ * 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.testutil.techprovider;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.server.api.edm.provider.Function;
+import org.apache.olingo.server.api.edm.provider.Parameter;
+import org.apache.olingo.server.api.edm.provider.ReturnType;
+
+public class FunctionProvider {
+
+ // Bound Functions
+ public static final FullQualifiedName nameBFCCollCTPrimCompRTESAllPrim =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCCollCTPrimCompRTESAllPrim");
+
+ public static final FullQualifiedName nameBFCCollStringRTESTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCCollStringRTESTwoKeyNav");
+
+ public static final FullQualifiedName nameBFCCTPrimCompRTESBaseTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCCTPrimCompRTESBaseTwoKeyNav");
+
+ public static final FullQualifiedName nameBFCCTPrimCompRTESTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCCTPrimCompRTESTwoKeyNav");
+
+ public static final FullQualifiedName nameBFCCTPrimCompRTESTwoKeyNavParam =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCCTPrimCompRTESTwoKeyNavParam");
+
+ public static final FullQualifiedName nameBFCCTPrimCompRTETTwoKeyNavParam =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCCTPrimCompRTETTwoKeyNavParam");
+
+ public static final FullQualifiedName nameBFCESAllPrimRTCTAllPrim =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCESAllPrimRTCTAllPrim");
+
+ public static final FullQualifiedName nameBFCESBaseTwoKeyNavRTESBaseTwoKey =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCESBaseTwoKeyNavRTESBaseTwoKey");
+
+ public static final FullQualifiedName nameBFCESKeyNavRTETKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCESKeyNavRTETKeyNav");
+
+ public static final FullQualifiedName nameBFCESKeyNavRTETKeyNavParam =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCESKeyNavRTETKeyNavParam");
+
+ public static final FullQualifiedName nameBFCESTwoKeyNavRTCollCTTwoPrim =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCESTwoKeyNavRTCollCTTwoPrim");
+
+ public static final FullQualifiedName nameBFCESTwoKeyNavRTCollString =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCESTwoKeyNavRTCollString");
+
+ public static final FullQualifiedName nameBFCESTwoKeyNavRTCTTwoPrim =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCESTwoKeyNavRTCTTwoPrim");
+
+ public static final FullQualifiedName nameBFCESTwoKeyNavRTESTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCESTwoKeyNavRTESTwoKeyNav");
+
+ public static final FullQualifiedName nameBFCESTwoKeyNavRTString =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCESTwoKeyNavRTString");
+
+ public static final FullQualifiedName nameBFCESTwoKeyNavRTStringParam =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCESTwoKeyNavRTStringParam");
+
+ public static final FullQualifiedName nameBFCESTwoKeyNavRTTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCESTwoKeyNavRTTwoKeyNav");
+
+ public static final FullQualifiedName nameBFCETBaseTwoKeyNavRTESBaseTwoKey =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCETBaseTwoKeyNavRTESBaseTwoKey");
+
+ public static final FullQualifiedName nameBFCETBaseTwoKeyNavRTESTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCETBaseTwoKeyNavRTESTwoKeyNav");
+
+ public static final FullQualifiedName nameBFCETBaseTwoKeyNavRTETTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCETBaseTwoKeyNavRTETTwoKeyNav");
+
+ public static final FullQualifiedName nameBFCETKeyNavRTETKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCETKeyNavRTETKeyNav");
+
+ public static final FullQualifiedName nameBFCETTwoKeyNavRTCTTwoPrim =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCETTwoKeyNavRTCTTwoPrim");
+
+ public static final FullQualifiedName nameBFCETTwoKeyNavRTESTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCETTwoKeyNavRTESTwoKeyNav");
+
+ public static final FullQualifiedName nameBFCETTwoKeyNavRTETTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCETTwoKeyNavRTETTwoKeyNav");
+
+ public static final FullQualifiedName nameBFCSINavRTESTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCSINavRTESTwoKeyNav");
+
+ public static final FullQualifiedName nameBFCStringRTESTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFCStringRTESTwoKeyNav");
+
+ public static final FullQualifiedName nameBFESTwoKeyNavRTESTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BFESTwoKeyNavRTESTwoKeyNav");
+
+ // Unbound Functions
+ public static final FullQualifiedName nameUFCRTCollCTTwoPrim =
+ new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTCollCTTwoPrim");
+ public static final FullQualifiedName nameUFCRTCollCTTwoPrimParam =
+ new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTCollCTTwoPrimParam");
+ public static final FullQualifiedName nameUFCRTCollString = new FullQualifiedName(SchemaProvider.nameSpace,
+ "UFCRTCollString");
+ public static final FullQualifiedName nameUFCRTCollStringTwoParam =
+ new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTCollStringTwoParam");
+ public static final FullQualifiedName nameUFCRTCTAllPrimTwoParam =
+ new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTCTAllPrimTwoParam");
+ public static final FullQualifiedName nameUFCRTCTTwoPrim = new FullQualifiedName(SchemaProvider.nameSpace,
+ "UFCRTCTTwoPrim");
+ public static final FullQualifiedName nameUFCRTCTTwoPrimParam =
+ new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTCTTwoPrimParam");
+ public static final FullQualifiedName nameUFCRTESMixPrimCollCompTwoParam =
+ new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTESMixPrimCollCompTwoParam");
+ public static final FullQualifiedName nameUFCRTESTwoKeyNavParam =
+ new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTESTwoKeyNavParam");
+ public static final FullQualifiedName nameUFCRTETAllPrimTwoParam =
+ new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTETAllPrimTwoParam");
+ public static final FullQualifiedName nameUFCRTETKeyNav = new FullQualifiedName(SchemaProvider.nameSpace,
+ "UFCRTETKeyNav");
+ public static final FullQualifiedName nameUFCRTETMedia = new FullQualifiedName(SchemaProvider.nameSpace,
+ "UFCRTETMedia");
+
+ public static final FullQualifiedName nameUFCRTETTwoKeyNavParam =
+ new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTETTwoKeyNavParam");
+
+ public static final FullQualifiedName nameUFCRTETTwoKeyNavParamCTTwoPrim =
+ new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTETTwoKeyNavParamCTTwoPrim");
+
+ public static final FullQualifiedName nameUFCRTString =
+ new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTString");
+
+ public static final FullQualifiedName nameUFCRTStringTwoParam =
+ new FullQualifiedName(SchemaProvider.nameSpace, "UFCRTStringTwoParam");
+
+ public static final FullQualifiedName nameUFNRTESMixPrimCollCompTwoParam =
+ new FullQualifiedName(SchemaProvider.nameSpace, "UFNRTESMixPrimCollCompTwoParam");
+ public static final FullQualifiedName nameUFNRTInt16 =
+ new FullQualifiedName(SchemaProvider.nameSpace, "UFNRTInt16");
+
+ public static final FullQualifiedName nameUFNRTCollCTNavFiveProp = new FullQualifiedName(SchemaProvider.nameSpace,
+ "UFNRTCollCTNavFiveProp");
+
+ public static final FullQualifiedName nameBFCESTwoKeyNavRTCTNavFiveProp = new FullQualifiedName(
+ SchemaProvider.nameSpace, "BFCESTwoKeyNavRTCTNavFiveProp");
+
+ public static final FullQualifiedName nameBFCESTwoKeyNavRTCollCTNavFiveProp = new FullQualifiedName(
+ SchemaProvider.nameSpace, "BFCESTwoKeyNavRTCollCTNavFiveProp");
+
+ public List<Function> getFunctions(final FullQualifiedName functionName) throws ODataException {
+
+ if (functionName.equals(nameUFNRTInt16)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFNRTInt16")
+ .setParameters(new ArrayList<Parameter>())
+ .setReturnType(
+ new ReturnType().setType(PropertyProvider.nameInt16))
+ );
+
+ } else if (functionName.equals(nameUFCRTETKeyNav)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFCRTETKeyNav")
+ .setParameters(new ArrayList<Parameter>())
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameUFCRTETTwoKeyNavParam)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFCRTETTwoKeyNavParam")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(false)
+ )
+ );
+
+ } else if (functionName.equals(nameUFCRTETTwoKeyNavParamCTTwoPrim)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFCRTETTwoKeyNavParamCTTwoPrim")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterCTTwoPrim").setType(ComplexTypeProvider.nameCTTwoPrim)
+ .setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(false)
+ )
+ );
+
+ } else if (functionName.equals(nameUFCRTStringTwoParam)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFCRTStringTwoParam")
+ .setParameters(Arrays.asList(
+ new Parameter()
+ .setName("ParameterInt16")
+ .setType(PropertyProvider.nameInt16)
+ .setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(PropertyProvider.nameString).setNullable(false)),
+ new Function()
+ .setName("UFCRTStringTwoParam")
+ .setParameters(Arrays.asList(
+ new Parameter()
+ .setName("ParameterString")
+ .setType(PropertyProvider.nameString)
+ .setNullable(false),
+ new Parameter()
+ .setName("ParameterInt16")
+ .setType(PropertyProvider.nameInt16)
+ .setNullable(false)))
+ .setComposable(true)
+ .setReturnType(new ReturnType().setType(PropertyProvider.nameString).setNullable(false))
+
+ );
+
+ } else if (functionName.equals(nameUFCRTESTwoKeyNavParam)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFCRTESTwoKeyNavParam")
+ .setParameters(Arrays.asList(
+ new Parameter()
+ .setName("ParameterInt16")
+ .setType(PropertyProvider.nameInt16)
+ .setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameUFCRTString)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFCRTString")
+
+ .setComposable(true)
+ .setParameters(new ArrayList<Parameter>())
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(PropertyProvider.nameString).setNullable(false)
+ )
+ );
+
+ } else if (functionName.equals(nameUFCRTCollStringTwoParam)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFCRTCollStringTwoParam")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterString").setType(PropertyProvider.nameString).setNullable(false),
+ new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(PropertyProvider.nameString).setCollection(true).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameUFCRTCollString)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFCRTCollString")
+ .setParameters(new ArrayList<Parameter>())
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(PropertyProvider.nameString).setCollection(true).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameUFCRTCTAllPrimTwoParam)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFCRTCTAllPrimTwoParam")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterString").setType(PropertyProvider.nameString).setNullable(false),
+ new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(ComplexTypeProvider.nameCTAllPrim).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameUFCRTCTTwoPrimParam)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFCRTCTTwoPrimParam")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(false),
+ new Parameter().setName("ParameterString").setType(PropertyProvider.nameString).setNullable(true)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setNullable(false))
+ );
+ } else if (functionName.equals(nameUFCRTCollCTTwoPrimParam)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFCRTCollCTTwoPrimParam")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(false),
+ new Parameter().setName("ParameterString").setType(PropertyProvider.nameString).setNullable(true)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setCollection(true).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameUFCRTCTTwoPrim)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFCRTCTTwoPrim")
+ .setParameters(new ArrayList<Parameter>())
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameUFCRTCollCTTwoPrim)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFCRTCollCTTwoPrim")
+ .setComposable(true)
+ .setParameters(new ArrayList<Parameter>())
+ .setReturnType(
+ new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setCollection(true).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameUFCRTETMedia)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFCRTETMedia")
+ .setParameters(new ArrayList<Parameter>())
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETMedia).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameUFNRTESMixPrimCollCompTwoParam)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFNRTESMixPrimCollCompTwoParam")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterString").setType(PropertyProvider.nameString).setNullable(false),
+ new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(false)))
+ .setComposable(false)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETMixPrimCollComp).setCollection(true)
+ .setNullable(false))
+ );
+
+ } else if (functionName.equals(nameUFCRTETAllPrimTwoParam)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFCRTETAllPrimTwoParam")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterString").setType(PropertyProvider.nameString).setNullable(false),
+ new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETAllPrim).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameUFCRTESMixPrimCollCompTwoParam)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFCRTESMixPrimCollCompTwoParam")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterString").setType(PropertyProvider.nameString).setNullable(false),
+ new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(false)
+ ))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETMixPrimCollComp).setCollection(true)
+ .setNullable(false))
+ );
+
+ } else if (functionName.equals(nameUFNRTCollCTNavFiveProp)) {
+ return Arrays.asList(
+ new Function()
+ .setName("UFNRTCollCTNavFiveProp")
+ .setReturnType(
+ new ReturnType().setType(ComplexTypeProvider.nameCTNavFiveProp).setCollection(true))
+ );
+ } else if (functionName.equals(nameBFCESTwoKeyNavRTESTwoKeyNav)) {
+ return Arrays
+ .asList(
+ new Function()
+ .setName("BFCESTwoKeyNavRTESTwoKeyNav")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
+ .setCollection(true).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true)
+ .setNullable(false)),
+
+ new Function()
+ .setName("BFCESTwoKeyNavRTESTwoKeyNav")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
+ .setCollection(true).setNullable(false),
+ new Parameter().setName("ParameterString").setType(PropertyProvider.nameString)
+ .setCollection(false).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true)
+ .setNullable(false)),
+ new Function()
+ .setName("BFCESTwoKeyNavRTESTwoKeyNav")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETKeyNav)
+ .setCollection(true).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true)
+ .setNullable(false)),
+ new Function()
+ .setName("BFCESTwoKeyNavRTESTwoKeyNav")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETKeyNav)
+ .setCollection(true).setNullable(false),
+ new Parameter().setName("ParameterString").setType(PropertyProvider.nameString)
+ .setCollection(false).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true)
+ .setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCStringRTESTwoKeyNav)) {
+ return Arrays.asList(
+ new Function().setName("BFCStringRTESTwoKeyNav")
+ .setBound(true)
+ .setParameters(Arrays.asList(
+ new Parameter().setName("BindingParam").setType(PropertyProvider.nameString).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCETBaseTwoKeyNavRTETTwoKeyNav)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCETBaseTwoKeyNavRTETTwoKeyNav")
+ .setBound(true)
+ .setParameters(Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(false)
+ )
+ );
+
+ } else if (functionName.equals(nameBFCESBaseTwoKeyNavRTESBaseTwoKey)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCESBaseTwoKeyNavRTESBaseTwoKey")
+ .setBound(true)
+ .setParameters(Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .setCollection(true).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETBaseTwoKeyNav).setCollection(true)
+ .setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCESAllPrimRTCTAllPrim)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCESAllPrimRTCTAllPrim")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETAllPrim)
+ .setCollection(true).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(ComplexTypeProvider.nameCTAllPrim).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCESTwoKeyNavRTCTTwoPrim)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCESTwoKeyNavRTCTTwoPrim")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
+ .setCollection(true).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCESTwoKeyNavRTCollCTTwoPrim)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCESTwoKeyNavRTCollCTTwoPrim")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
+ .setCollection(true).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setCollection(true).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCESTwoKeyNavRTString)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCESTwoKeyNavRTString")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
+ .setCollection(true).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(PropertyProvider.nameString).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCESTwoKeyNavRTCollString)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCESTwoKeyNavRTCollString")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
+ .setCollection(true).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(PropertyProvider.nameString).setCollection(true).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCETTwoKeyNavRTESTwoKeyNav)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCETTwoKeyNavRTESTwoKeyNav")
+ .setBound(true)
+ .setParameters(Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
+ .setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCETBaseTwoKeyNavRTESTwoKeyNav)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCETBaseTwoKeyNavRTESTwoKeyNav")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCSINavRTESTwoKeyNav)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCSINavRTESTwoKeyNav")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(
+ false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCETBaseTwoKeyNavRTESBaseTwoKey)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCETBaseTwoKeyNavRTESBaseTwoKey")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETBaseTwoKeyNav).setCollection(true).setNullable(
+ false))
+ );
+
+ } else if (functionName.equals(nameBFCCollStringRTESTwoKeyNav)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCCollStringRTESTwoKeyNav")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(PropertyProvider.nameString).setCollection(true)
+ .setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCCTPrimCompRTESTwoKeyNav)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCCTPrimCompRTESTwoKeyNav")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(ComplexTypeProvider.nameCTPrimComp).setNullable(
+ false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCCTPrimCompRTESBaseTwoKeyNav)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCCTPrimCompRTESBaseTwoKeyNav")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(ComplexTypeProvider.nameCTPrimComp).setNullable(
+ false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETBaseTwoKeyNav).setCollection(true).setNullable(
+ false))
+ );
+
+ } else if (functionName.equals(nameBFCCollCTPrimCompRTESAllPrim)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCCollCTPrimCompRTESAllPrim")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(ComplexTypeProvider.nameCTPrimComp)
+ .setCollection(true).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETAllPrim).setCollection(true).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCESTwoKeyNavRTTwoKeyNav)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCESTwoKeyNavRTTwoKeyNav")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
+ .setCollection(true).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCESKeyNavRTETKeyNav)) {
+ return Arrays
+ .asList(
+ new Function()
+ .setName("BFCESKeyNavRTETKeyNav")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETKeyNav).setCollection(
+ true).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCETKeyNavRTETKeyNav)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCETKeyNavRTETKeyNav")
+ .setBound(true)
+ .setParameters(Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETKeyNav).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setNullable(false))
+ );
+ } else if (functionName.equals(nameBFESTwoKeyNavRTESTwoKeyNav)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFESTwoKeyNavRTESTwoKeyNav")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
+ .setCollection(true).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
+
+ );
+
+ } else if (functionName.equals(nameBFCETTwoKeyNavRTETTwoKeyNav)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCETTwoKeyNavRTETTwoKeyNav")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(
+ false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCETTwoKeyNavRTCTTwoPrim)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCETTwoKeyNavRTCTTwoPrim")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(
+ false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setNullable(false))
+ );
+ } else if (functionName.equals(nameBFCESTwoKeyNavRTCTNavFiveProp)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCESTwoKeyNavRTCTNavFiveProp")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
+ .setCollection(true).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(ComplexTypeProvider.nameCTNavFiveProp).setNullable(false))
+ );
+ } else if (functionName.equals(nameBFCESTwoKeyNavRTCollCTNavFiveProp)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCESTwoKeyNavRTCollCTNavFiveProp")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
+ .setCollection(true).setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(ComplexTypeProvider.nameCTNavFiveProp).setCollection(true)
+ .setNullable(false))
+ );
+ } else if (functionName.equals(nameBFCESTwoKeyNavRTStringParam)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCESTwoKeyNavRTStringParam")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav)
+ .setCollection(true).setNullable(false),
+ new Parameter().setName("ParameterComplex").setType(ComplexTypeProvider.nameCTTwoPrim)
+ .setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(PropertyProvider.nameString).setNullable(false))
+ );
+
+ } else if (functionName.equals(nameBFCESKeyNavRTETKeyNavParam)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCESKeyNavRTETKeyNavParam")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETKeyNav).setCollection(
+ true).setNullable(false),
+ new Parameter().setName("ParameterString").setType(PropertyProvider.nameString)
+ .setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setNullable(false))
+ );
+ } else if (functionName.equals(nameBFCCTPrimCompRTETTwoKeyNavParam)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCCTPrimCompRTETTwoKeyNavParam")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(ComplexTypeProvider.nameCTPrimComp).setNullable(
+ false),
+ new Parameter().setName("ParameterString").setType(PropertyProvider.nameString)
+ .setNullable(false)))
+ .setComposable(true)
+ .setReturnType(new ReturnType()
+ .setType(EntityTypeProvider.nameETTwoKeyNav).setNullable(false)
+ )
+ );
+ } else if (functionName.equals(nameBFCCTPrimCompRTESTwoKeyNavParam)) {
+ return Arrays.asList(
+ new Function()
+ .setName("BFCCTPrimCompRTESTwoKeyNavParam")
+ .setBound(true)
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("BindingParam").setType(ComplexTypeProvider.nameCTPrimComp).setNullable(
+ false),
+ new Parameter().setName("ParameterString").setType(PropertyProvider.nameString)
+ .setNullable(false)))
+ .setComposable(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true).setNullable(false))
+ );
+ }
+
+ return null;
+ }
+
+}
[03/15] [OLINGO-266] refactor ref module to server-ref
Posted by sk...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
new file mode 100644
index 0000000..fde13c8
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java
@@ -0,0 +1,230 @@
+/*
+ * 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 static org.junit.Assert.fail;
+
+import org.apache.olingo.commons.api.ODataApplicationException;
+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.uri.UriInfoKind;
+import org.apache.olingo.server.api.uri.queryoption.ExpandItem;
+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.queryoption.ExpandOptionImpl;
+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.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 ExpandItem expandItem;
+
+ // --- Setup ---
+
+ public ExpandValidator setUpValidator(final TestValidator validator) {
+ invokedByValidator = validator;
+ return this;
+ }
+
+ public ExpandValidator setExpand(final ExpandOptionImpl expand) {
+ expandOption = expand;
+ first();
+ return this;
+ }
+
+ public ExpandValidator setEdm(final Edm edm) {
+ this.edm = edm;
+ return this;
+ }
+
+ // --- Navigation ---
+
+ public ExpandValidator goUpToExpandValidator() {
+ return (ExpandValidator) invokedByValidator;
+ }
+
+ public ResourceValidator goUpToUriResourceValidator() {
+ return (ResourceValidator) invokedByValidator;
+ }
+
+ 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);
+
+ }
+
+ public FilterValidator goOrder(final int index) {
+ OrderByOptionImpl orderBy = (OrderByOptionImpl) expandItem.getOrderByOption();
+
+ return new FilterValidator()
+ .setValidator(this)
+ .setEdm(edm)
+ .setExpression(orderBy.getOrders().get(index).getExpression());
+ }
+
+ public ResourceValidator goSelectItem(final int index) {
+ SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
+
+ SelectItem item = select.getSelectItems().get(index);
+ UriInfoImpl uriInfo = (UriInfoImpl) item.getResourcePath();
+
+ return new ResourceValidator()
+ .setUpValidator(this)
+ .setEdm(edm)
+ .setUriInfoImplPath(uriInfo);
+
+ }
+
+ public ExpandValidator goExpand() {
+ ExpandValidator val = new ExpandValidator()
+ .setExpand((ExpandOptionImpl) expandItem.getExpandOption())
+ .setUpValidator(this);
+ return val;
+ }
+
+ public ExpandValidator first() {
+ expandItemIndex = 0;
+ expandItem = expandOption.getExpandItems().get(expandItemIndex);
+ return this;
+ }
+
+ public ExpandValidator next() {
+ expandItemIndex++;
+
+ try {
+ expandItem = expandOption.getExpandItems().get(expandItemIndex);
+ } catch (IndexOutOfBoundsException ex) {
+ fail("not enought segments");
+ }
+ return this;
+
+ }
+
+ public ExpandValidator isSegmentStar(final int index) {
+ assertEquals(true, expandItem.isStar());
+ return this;
+ }
+
+ public ExpandValidator isSegmentRef(final int index) {
+ assertEquals(true, expandItem.isRef());
+ return this;
+ }
+
+ public ExpandValidator isLevelText(final String text) {
+ QueryOptionImpl option = (QueryOptionImpl) expandItem.getLevelsOption();
+ assertEquals(text, option.getText());
+ return this;
+ }
+
+ public ExpandValidator isSkipText(final String text) {
+ QueryOptionImpl option = (QueryOptionImpl) expandItem.getSkipOption();
+ assertEquals(text, option.getText());
+ return this;
+ }
+
+ public ExpandValidator isTopText(final String text) {
+ QueryOptionImpl option = (QueryOptionImpl) expandItem.getTopOption();
+ assertEquals(text, option.getText());
+ return this;
+ }
+
+ public ExpandValidator isInlineCountText(final String text) {
+ QueryOptionImpl option = (QueryOptionImpl) expandItem.getCountOption();
+ assertEquals(text, option.getText());
+ return this;
+ }
+
+ public ExpandValidator isSelectText(final String text) {
+ QueryOptionImpl option = (QueryOptionImpl) expandItem.getSelectOption();
+ assertEquals(text, option.getText());
+ return this;
+ }
+
+ public ExpandValidator isSelectItemStar(final int index) {
+ SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
+
+ SelectItem item = select.getSelectItems().get(index);
+ assertEquals(true, item.isStar());
+ return this;
+ }
+
+ public ExpandValidator isSelectItemAllOperations(final int index, final FullQualifiedName fqn) {
+ SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
+
+ SelectItem item = select.getSelectItems().get(index);
+ assertEquals(fqn.toString(), item.getAllOperationsInSchemaNameSpace().toString());
+ return this;
+ }
+
+ public ExpandValidator isFilterOptionText(final String text) {
+ QueryOptionImpl option = (QueryOptionImpl) expandItem.getFilterOption();
+ assertEquals(text, option.getText());
+ return this;
+ }
+
+ public ExpandValidator isFilterSerialized(final String serialized) {
+ FilterOptionImpl filter = (FilterOptionImpl) expandItem.getFilterOption();
+
+ try {
+ String tmp = FilterTreeToText.Serialize(filter);
+ assertEquals(serialized, tmp);
+ } catch (ExpressionVisitException e) {
+ fail("Exception occured while converting the filterTree into text" + "\n"
+ + " Exception: " + e.getMessage());
+ } catch (ODataApplicationException e) {
+ fail("Exception occured while converting the filterTree into text" + "\n"
+ + " Exception: " + e.getMessage());
+ }
+
+ return this;
+ }
+
+ public ExpandValidator isSortOrder(final int index, final boolean descending) {
+ OrderByOptionImpl orderBy = (OrderByOptionImpl) 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);
+ return this;
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
new file mode 100644
index 0000000..06056e0
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
@@ -0,0 +1,154 @@
+/*
+ * 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.List;
+
+import org.apache.olingo.commons.api.ODataApplicationException;
+import org.apache.olingo.commons.api.edm.EdmEnumType;
+import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.server.api.uri.UriInfoResource;
+import org.apache.olingo.server.api.uri.UriResource;
+import org.apache.olingo.server.api.uri.UriResourceLambdaAll;
+import org.apache.olingo.server.api.uri.UriResourceLambdaAny;
+import org.apache.olingo.server.api.uri.UriResourcePartTyped;
+import org.apache.olingo.server.api.uri.queryoption.FilterOption;
+import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
+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.ExpressionVisitor;
+import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
+import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind;
+
+public class FilterTreeToText implements ExpressionVisitor<String> {
+
+ public static String Serialize(final FilterOption filter)
+ throws ExpressionVisitException, ODataApplicationException {
+
+ Expression expression = filter.getExpression();
+ return expression.accept(new FilterTreeToText());
+ }
+
+ public static String Serialize(final Expression expression)
+ throws ExpressionVisitException, ODataApplicationException {
+
+ return expression.accept(new FilterTreeToText());
+ }
+
+ @Override
+ public String visitBinaryOperator(final BinaryOperatorKind operator, final String left, final String right)
+ throws ExpressionVisitException {
+
+ return "<" + left + " " + operator.toString() + " " + right + ">";
+ }
+
+ @Override
+ public String visitUnaryOperator(final UnaryOperatorKind operator, final String operand)
+ throws ExpressionVisitException {
+
+ return "<" + operator + " " + operand.toString() + ">";
+ }
+
+ @Override
+ public String visitMethodCall(final MethodKind methodCall, final List<String> parameters)
+ throws ExpressionVisitException {
+
+ String text = "<" + methodCall + "(";
+ int i = 0;
+ while (i < parameters.size()) {
+ if (i > 0) {
+ text += ",";
+ }
+ text += parameters.get(i);
+ i++;
+ }
+ return text + ")>";
+ }
+
+ @Override
+ public String visitLiteral(final String literal) throws ExpressionVisitException {
+ return "<" + literal + ">";
+ }
+
+ @Override
+ public String visitMember(final UriInfoResource resource) throws ExpressionVisitException, ODataApplicationException {
+ String ret = "";
+
+ UriInfoResource path = resource;
+
+ for (UriResource item : path.getUriResourceParts()) {
+ String tmp = "";
+ if (item instanceof UriResourceLambdaAll) {
+ UriResourceLambdaAll all = (UriResourceLambdaAll) item;
+ tmp = visitLambdaExpression("ALL", all.getLambdaVariable(), all.getExpression());
+ } else if (item instanceof UriResourceLambdaAny) {
+ UriResourceLambdaAny any = (UriResourceLambdaAny) item;
+ tmp = visitLambdaExpression("ANY", any.getLamdaVariable(), any.getExpression());
+ } else if (item instanceof UriResourcePartTyped) {
+ UriResourcePartTyped typed = (UriResourcePartTyped) item;
+ tmp = typed.toString(true);
+ }
+
+ if (ret.length() != 0) {
+ ret += "/";
+ }
+ ret += tmp;
+
+ }
+ return "<" + ret + ">";
+ }
+
+ @Override
+ public String visitAlias(final String referenceName) throws ExpressionVisitException {
+ return "<" + referenceName + ">";
+ }
+
+ @Override
+ public String visitLambdaExpression(final String functionText, final String string, final Expression expression)
+ throws ExpressionVisitException, ODataApplicationException {
+
+ return "<" + functionText + ";" + ((expression == null) ? "" : expression.accept(this)) + ">";
+ }
+
+ @Override
+ public String visitTypeLiteral(final EdmType type) {
+ return "<" + type.getNamespace() + "." + type.getName() + ">";
+ }
+
+ @Override
+ public String visitLambdaReference(final String variableText) {
+ return "<" + variableText + ">";
+ }
+
+ @Override
+ public String visitEnum(final EdmEnumType type, final List<String> enumValues)
+ throws ExpressionVisitException, ODataApplicationException {
+ String tmp = "";
+
+ for (String item : enumValues) {
+ if (tmp.length() > 0) {
+ tmp += ",";
+ }
+ tmp += item;
+ }
+
+ return "<" + type.getNamespace() + "." + type.getName() + "<" + tmp + ">>";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
new file mode 100644
index 0000000..58e429f
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
@@ -0,0 +1,534 @@
+/*
+ * 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 static org.junit.Assert.fail;
+
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataApplicationException;
+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.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriInfoKind;
+import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
+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.Member;
+import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
+import org.apache.olingo.server.core.uri.UriInfoImpl;
+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 Expression curExpression;
+ private Expression rootExpression;
+
+ private OrderByOptionImpl orderBy;
+
+ private UriParserException exception;
+
+ // --- Setup ---
+ public FilterValidator setUriResourcePathValidator(final ResourceValidator uriResourcePathValidator) {
+ invokedByValidator = uriResourcePathValidator;
+ return this;
+ }
+
+ public FilterValidator setUriValidator(final TestUriValidator uriValidator) {
+ invokedByValidator = uriValidator;
+ return this;
+ }
+
+ public FilterValidator setValidator(final TestValidator uriValidator) {
+ invokedByValidator = uriValidator;
+ return this;
+ }
+
+ public FilterValidator setEdm(final Edm edm) {
+ this.edm = edm;
+ return this;
+ }
+
+ public FilterValidator setFilter(final FilterOptionImpl filter) {
+ this.filter = filter;
+
+ if (filter.getExpression() == null) {
+ fail("FilterValidator: no filter found");
+ }
+ setExpression(filter.getExpression());
+ return this;
+ }
+
+ public FilterValidator setOrderBy(final OrderByOptionImpl orderBy) {
+ this.orderBy = orderBy;
+
+ return this;
+ }
+
+ public FilterValidator setExpression(final Expression expression) {
+ rootExpression = curExpression = expression;
+ return this;
+ }
+
+ // --- Execution ---
+
+ public FilterValidator runOrderByOnETAllPrim(final String orderBy) throws UriParserException {
+ String uri = "ESAllPrim?$orderby=" + orderBy.trim();
+ return runUriOrderBy(uri);
+ }
+
+ public FilterValidator runOrderByOnETTwoKeyNav(final String orderBy) throws UriParserException {
+ String uri = "ESTwoKeyNav?$orderby=" + orderBy.trim();
+ return runUriOrderBy(uri);
+ }
+
+ public FilterValidator runOrderByOnETTwoKeyNavEx(final String orderBy) throws UriParserException {
+ String uri = "ESTwoKeyNav?$orderby=" + orderBy.trim();
+ return runUriOrderByEx(uri);
+ }
+
+ public FilterValidator runOnETTwoKeyNav(final String filter) throws UriParserException {
+ String uri = "ESTwoKeyNav?$filter=" + filter.trim();
+ return runUri(uri);
+ }
+
+ public FilterValidator runOnETTwoKeyNavSingle(final String filter) throws UriParserException {
+ String uri = "SINav?$filter=" + filter.trim();
+ return runUri(uri);
+ }
+
+ public FilterValidator runOnETTwoKeyNavEx(final String filter) throws UriParserException {
+ String uri = "ESTwoKeyNav?$filter=" + filter.trim();
+ return runUriEx(uri);
+ }
+
+ public FilterValidator runOnETAllPrim(final String filter) throws UriParserException {
+ String uri = "ESAllPrim(1)?$filter=" + filter.trim();
+ return runUri(uri);
+ }
+
+ public FilterValidator runOnETKeyNav(final String filter) throws UriParserException {
+ String uri = "ESKeyNav(1)?$filter=" + filter.trim();
+ return runUri(uri);
+ }
+
+ public FilterValidator runOnETKeyNavEx(final String filter) throws UriParserException {
+ String uri = "ESKeyNav(1)?$filter=" + filter.trim();
+ return runUriEx(uri);
+ }
+
+ public FilterValidator runOnCTTwoPrim(final String filter) throws UriParserException {
+ String uri = "SINav/PropertyComplexTwoPrim?$filter=" + filter.trim();
+ return runUri(uri);
+ }
+
+ public FilterValidator runOnString(final String filter) throws UriParserException {
+ String uri = "SINav/PropertyString?$filter=" + filter.trim();
+ return runUri(uri);
+ }
+
+ public FilterValidator runOnInt32(final String filter) throws UriParserException {
+ String uri = "ESCollAllPrim(1)/CollPropertyInt32?$filter=" + filter.trim();
+ return runUri(uri);
+ }
+
+ public FilterValidator runOnDateTimeOffset(final String filter) throws UriParserException {
+ String uri = "ESCollAllPrim(1)/CollPropertyDateTimeOffset?$filter=" + filter.trim();
+ return runUri(uri);
+ }
+
+ public FilterValidator runOnDuration(final String filter) throws UriParserException {
+ String uri = "ESCollAllPrim(1)/CollPropertyDuration?$filter=" + filter.trim();
+ return runUri(uri);
+ }
+
+ public FilterValidator runOnTimeOfDay(final String filter) throws UriParserException {
+ String uri = "ESCollAllPrim(1)/CollPropertyTimeOfDay?$filter=" + filter.trim();
+ return runUri(uri);
+ }
+
+ public FilterValidator runESabc(final String filter) throws UriParserException {
+ String uri = "ESabc?$filter=" + filter.trim();
+ return runUri(uri);
+ }
+
+ public FilterValidator runUri(final String uri) throws UriParserException {
+ Parser parser = new Parser();
+ UriInfo uriInfo = null;
+
+ uriInfo = parser.parseUri(uri, edm);
+
+ if (uriInfo.getKind() != UriInfoKind.resource) {
+ fail("Filtervalidator can only be used on resourcePaths");
+ }
+
+ setFilter((FilterOptionImpl) uriInfo.getFilterOption());
+ curExpression = filter.getExpression();
+ return this;
+ }
+
+ public FilterValidator runUriEx(final String uri) {
+ Parser parser = new Parser();
+ UriInfo uriInfo = null;
+
+ try {
+ uriInfo = parser.parseUri(uri, edm);
+ } catch (UriParserException e) {
+ exception = e;
+ return this;
+ }
+
+ if (uriInfo.getKind() != UriInfoKind.resource) {
+ fail("Filtervalidator can only be used on resourcePaths");
+ }
+
+ setFilter((FilterOptionImpl) uriInfo.getFilterOption());
+ curExpression = filter.getExpression();
+ return this;
+ }
+
+ public FilterValidator runUriOrderBy(final String uri) throws UriParserException {
+ Parser parser = new Parser();
+ UriInfo uriInfo = null;
+
+ uriInfo = parser.parseUri(uri, edm);
+
+ if (uriInfo.getKind() != UriInfoKind.resource) {
+ fail("Filtervalidator can only be used on resourcePaths");
+ }
+
+ setOrderBy((OrderByOptionImpl) uriInfo.getOrderByOption());
+ return this;
+ }
+
+ public FilterValidator runUriOrderByEx(final String uri) {
+ Parser parser = new Parser();
+ UriInfo uriInfo = null;
+
+ try {
+ uriInfo = parser.parseUri(uri, edm);
+ } catch (UriParserException e) {
+ exception = e;
+ return this;
+ }
+
+ if (uriInfo.getKind() != UriInfoKind.resource) {
+ fail("Filtervalidator can only be used on resourcePaths");
+ }
+
+ setOrderBy((OrderByOptionImpl) uriInfo.getOrderByOption());
+ return this;
+ }
+
+ // --- Navigation ---
+
+ public ExpandValidator goUpToExpandValidator() {
+ return (ExpandValidator) invokedByValidator;
+ }
+
+ public ResourceValidator goUpToResourceValidator() {
+ return (ResourceValidator) invokedByValidator;
+ }
+
+ public ResourceValidator goPath() {
+ if (!(curExpression instanceof MemberImpl)) {
+ fail("Current expression not a member");
+ }
+
+ MemberImpl member = (MemberImpl) curExpression;
+
+ return new ResourceValidator()
+ .setEdm(edm)
+ .setUriInfoImplPath((UriInfoImpl) member.getResourcePath())
+ .setUpValidator(this);
+
+ }
+
+ public FilterValidator goParameter(final int parameterIndex) {
+ if (curExpression instanceof MethodImpl) {
+ MethodImpl methodCall = (MethodImpl) curExpression;
+ curExpression = methodCall.getParameters().get(parameterIndex);
+ } else {
+ fail("Current expression not a methodCall");
+ }
+ return this;
+ }
+
+ // --- Validation ---
+
+ /**
+ * Validates the serialized filterTree against a given filterString
+ * The given expected filterString is compressed before to allow better readable code in the unit tests
+ * @param toBeCompr
+ * @return
+ */
+ public FilterValidator isCompr(final String toBeCompr) {
+ return is(compress(toBeCompr));
+ }
+
+ public FilterValidator is(final String expectedFilterAsString) {
+ try {
+ String actualFilterAsText = FilterTreeToText.Serialize((FilterOptionImpl) filter);
+ assertEquals(expectedFilterAsString, actualFilterAsText);
+ } catch (ExpressionVisitException e) {
+ fail("Exception occured while converting the filterTree into text" + "\n"
+ + " Exception: " + e.getMessage());
+ } catch (ODataApplicationException e) {
+ fail("Exception occured while converting the filterTree into text" + "\n"
+ + " Exception: " + e.getMessage());
+ }
+
+ return this;
+ }
+
+ // --- Helper ---
+
+ private String compress(final String expected) {
+ String ret = expected.replaceAll("\\s+", " ");
+ ret = ret.replaceAll("< ", "<");
+ ret = ret.replaceAll(" >", ">");
+ return ret;
+ }
+
+ public FilterValidator isType(final FullQualifiedName fullName) {
+ EdmType actualType = null;
+
+ if (curExpression instanceof MemberImpl) {
+ Member member = (Member) curExpression;
+ actualType = member.getType();
+ } else if (curExpression instanceof TypeLiteralImpl) {
+ TypeLiteralImpl typeLiteral = (TypeLiteralImpl) curExpression;
+ actualType = typeLiteral.getType();
+ } else if (curExpression instanceof LiteralImpl) {
+ LiteralImpl typeLiteral = (LiteralImpl) curExpression;
+ actualType = typeLiteral.getType();
+ }
+
+ if (actualType == null) {
+ fail("Current expression not typed");
+ }
+
+ FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
+ assertEquals(fullName, actualName);
+ return this;
+ }
+
+ public FilterValidator left() {
+ if (!(curExpression instanceof BinaryImpl)) {
+ fail("Current expression not a binary operator");
+ }
+
+ curExpression = ((BinaryImpl) curExpression).getLeftOperand();
+
+ return this;
+ }
+
+ public FilterValidator root() {
+ if (filter != null) {
+ curExpression = filter.getExpression();
+ } else {
+ curExpression = rootExpression;
+ }
+
+ return this;
+ }
+
+ public FilterValidator right() {
+ if (!(curExpression instanceof BinaryImpl)) {
+ fail("Current expression is not a binary operator");
+ }
+
+ curExpression = ((BinaryImpl) curExpression).getRightOperand();
+
+ return this;
+
+ }
+
+ public FilterValidator isLiteral(final String literalText) {
+ if (!(curExpression instanceof LiteralImpl)) {
+ fail("Current expression is not a literal");
+ }
+
+ String actualLiteralText = ((LiteralImpl) curExpression).getText();
+ assertEquals(literalText, actualLiteralText);
+
+ return this;
+ }
+
+ public FilterValidator isMethod(final MethodKind methodKind, final int parameterCount) {
+ if (!(curExpression instanceof MethodImpl)) {
+ fail("Current expression is not a methodCall");
+ }
+
+ MethodImpl methodCall = (MethodImpl) 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)) {
+ fail("Current expression is not a method");
+ }
+
+ MethodImpl methodCall = (MethodImpl) 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)) {
+ fail("Current expression is not a binary operator");
+ }
+
+ BinaryImpl binary = (BinaryImpl) curExpression;
+ assertEquals(binaryOperator, binary.getOperator());
+
+ return this;
+ }
+
+ public FilterValidator isTypedLiteral(final FullQualifiedName fullName) {
+ if (!(curExpression instanceof TypeLiteralImpl)) {
+ fail("Current expression not a typeLiteral");
+ }
+
+ isType(fullName);
+
+ return this;
+ }
+
+ public FilterValidator isMember() {
+ if (!(curExpression instanceof MemberImpl)) {
+ 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;
+ EdmType actualType = member.getStartTypeFilter();
+
+ FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
+ assertEquals(fullName, actualName);
+ return this;
+ }
+
+ public FilterValidator isEnum(final FullQualifiedName nameenstring, final List<String> enumValues) {
+ if (!(curExpression instanceof EnumerationImpl)) {
+ fail("Current expression not a enumeration");
+ }
+
+ EnumerationImpl enumeration = (EnumerationImpl) curExpression;
+
+ FullQualifiedName actualName =
+ new FullQualifiedName(enumeration.getType().getNamespace(), enumeration.getType().getName());
+
+ // check name
+ assertEquals(nameenstring.toString(), actualName.toString());
+
+ // check values
+ int i = 0;
+ for (String item : enumValues) {
+ assertEquals(item, enumeration.getValues().get(i));
+ i++;
+ }
+
+ return this;
+ }
+
+ public FilterValidator isSortOrder(final int index, final boolean descending) {
+ assertEquals(descending, orderBy.getOrders().get(index).isDescending());
+ return this;
+ }
+
+ public FilterValidator goOrder(final int index) {
+ curExpression = orderBy.getOrders().get(index).getExpression();
+ return this;
+ }
+
+ public FilterValidator isExSyntax(final long errorID) {
+ assertEquals(UriParserSyntaxException.class, exception.getClass());
+ return this;
+ }
+
+ public FilterValidator isExSemantic(final long errorID) {
+ assertEquals(UriParserSemanticException.class, exception.getClass());
+ return this;
+ }
+
+ public FilterValidator isNull() {
+ if (!(curExpression instanceof LiteralImpl)) {
+ fail("Current expression is not a literal");
+ }
+
+ String actualLiteralText = ((LiteralImpl) curExpression).getText();
+ assertEquals("null", actualLiteralText);
+ return this;
+ }
+
+ public FilterValidator isTrue() {
+ if (!(curExpression instanceof LiteralImpl)) {
+ fail("Current expression is not a literal");
+ }
+
+ String actualLiteralText = ((LiteralImpl) curExpression).getText();
+ assertEquals("true", actualLiteralText);
+ return this;
+ }
+
+ 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/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParseTreeToText.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParseTreeToText.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParseTreeToText.java
new file mode 100644
index 0000000..f6a3086
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParseTreeToText.java
@@ -0,0 +1,82 @@
+/*
+ * 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) {
+ String s = symbol.getText();
+ return s;
+ }
+ }
+ }
+ // 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/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java
new file mode 100644
index 0000000..3f73b97
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java
@@ -0,0 +1,162 @@
+/*
+ * 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
+ */
+ 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
+ */
+ public ParserValidator aCS() {
+ allowContextSensitifity = true;
+ return this;
+ }
+
+ /**
+ * Used in fast LL Parsing:
+ * Allows ambiguities
+ * @return
+ */
+ 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/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserWithLogging.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserWithLogging.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserWithLogging.java
new file mode 100644
index 0000000..524a38a
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserWithLogging.java
@@ -0,0 +1,56 @@
+/*
+ * 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 org.antlr.v4.runtime.DefaultErrorStrategy;
+import org.antlr.v4.runtime.DiagnosticErrorListener;
+import org.apache.olingo.server.core.uri.antlr.UriParserParser;
+import org.apache.olingo.server.core.uri.parser.Parser;
+
+public class ParserWithLogging extends Parser {
+ TestErrorLogger errorCollector1;
+ TestErrorLogger errorCollector2;
+
+ public ParserWithLogging() {
+ errorCollector1 = new TestErrorLogger("Stage 1", 1);
+ errorCollector2 = new TestErrorLogger("Stage 2", 1);
+ }
+
+ @Override
+ protected void addStage2ErrorStategy(final UriParserParser parser) {
+ // Don't throw an at first syntax error, so the error listener will be called
+ parser.setErrorHandler(new DefaultErrorStrategy());
+ }
+
+ @Override
+ protected void addStage1ErrorListener(final UriParserParser parser) {
+ // Log error to console
+ parser.removeErrorListeners();
+ parser.addErrorListener(errorCollector1);
+ parser.addErrorListener(new DiagnosticErrorListener());
+ }
+
+ @Override
+ protected void addStage2ErrorListener(final UriParserParser parser) {
+ // Log error to console
+ parser.removeErrorListeners();
+ parser.addErrorListener(errorCollector2);
+ parser.addErrorListener(new DiagnosticErrorListener());
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
new file mode 100644
index 0000000..143871a
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
@@ -0,0 +1,599 @@
+/*
+ * 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 static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataApplicationException;
+import org.apache.olingo.commons.api.edm.Edm;
+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.server.api.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriInfoKind;
+import org.apache.olingo.server.api.uri.UriParameter;
+import org.apache.olingo.server.api.uri.UriResourceKind;
+import org.apache.olingo.server.api.uri.UriResourcePartTyped;
+import org.apache.olingo.server.api.uri.queryoption.CustomQueryOption;
+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.core.uri.UriResourceWithKeysImpl;
+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.UriValidator;
+
+public class ResourceValidator implements TestValidator {
+ private Edm edm;
+ private TestValidator invokedBy;
+ private UriInfo uriInfo = null;
+
+ private UriResourceImpl uriPathInfo = null;
+ private int uriResourceIndex;
+
+ // --- Setup ---
+
+ public ResourceValidator setUpValidator(final TestValidator uriValidator) {
+ invokedBy = uriValidator;
+ return this;
+ }
+
+ public ResourceValidator setEdm(final Edm edm) {
+ this.edm = edm;
+ return this;
+ }
+
+ public ResourceValidator setUriInfoImplPath(final UriInfoImpl uriInfoPath) {
+ uriInfo = uriInfoPath;
+ last();
+ return this;
+ }
+
+ // --- Execution ---
+
+ public ResourceValidator run(final String uri) {
+ ParserWithLogging testParser = new ParserWithLogging();
+
+ UriInfoImpl uriInfoTmp = null;
+ uriPathInfo = null;
+ try {
+ uriInfoTmp = (UriInfoImpl) testParser.parseUri(uri, edm);
+
+ UriValidator uriValidator = new UriValidator();
+ uriValidator.validate(uriInfoTmp, "GET");
+ } catch (Exception e) {
+ fail("Exception occured while parsing the URI: " + uri + "\n"
+ + " Message: " + e.getMessage());
+ }
+
+ if (uriInfoTmp.getKind() != UriInfoKind.resource) {
+ fail("Invalid UriInfoKind: " + uriInfoTmp.getKind().toString());
+ }
+ uriInfo = uriInfoTmp;
+
+ first();
+ return this;
+ }
+
+ // --- Navigation ---
+
+ public TestUriValidator goUpUriValidator() {
+ return (TestUriValidator) invokedBy;
+ }
+
+ public ExpandValidator goUpExpandValidator() {
+ return (ExpandValidator) invokedBy;
+ }
+
+ public FilterValidator goUpFilterValidator() {
+ return (FilterValidator) invokedBy;
+ }
+
+ public FilterValidator goParameter(final int index) {
+ assertEquals(UriResourceKind.function, uriPathInfo.getKind());
+ UriResourceFunctionImpl function = (UriResourceFunctionImpl) uriPathInfo;
+
+ return new FilterValidator()
+ .setEdm(edm)
+ .setExpression(function.getParameters().get(index).getExression())
+ .setValidator(this);
+ }
+
+ public FilterValidator goLambdaExpression() {
+ if (uriPathInfo.getKind() == UriResourceKind.lambdaAll) {
+ return new FilterValidator()
+ .setEdm(edm)
+ .setExpression(((UriResourceLambdaAllImpl) uriPathInfo).getExpression());
+
+ } else if (uriPathInfo.getKind() == UriResourceKind.lambdaAny) {
+ return new FilterValidator()
+ .setEdm(edm)
+ .setExpression(((UriResourceLambdaAnyImpl) uriPathInfo).getExpression());
+ } else {
+ fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+ }
+ return null;
+ }
+
+ public ResourceValidator goSelectItem(final int index) {
+ SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+
+ SelectItem item = select.getSelectItems().get(index);
+ UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourcePath();
+
+ return new ResourceValidator()
+ .setUpValidator(this)
+ .setEdm(edm)
+ .setUriInfoImplPath(uriInfo1);
+
+ }
+
+ public ExpandValidator goExpand() {
+ ExpandOptionImpl expand = (ExpandOptionImpl) uriInfo.getExpandOption();
+ if (expand == null) {
+ fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+ }
+
+ return new ExpandValidator().setUpValidator(this).setExpand(expand);
+ }
+
+ public ResourceValidator first() {
+ uriResourceIndex = 0;
+ uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(0);
+ return this;
+ }
+
+ public ResourceValidator last() {
+ uriResourceIndex = 0;
+
+ try {
+ uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriInfo.getUriResourceParts().size() - 1);
+ uriResourceIndex = uriInfo.getUriResourceParts().size() - 1;
+ } catch (IndexOutOfBoundsException ex) {
+ fail("not enough segments");
+ }
+
+ return this;
+ }
+
+ public ResourceValidator n() {
+ uriResourceIndex++;
+
+ try {
+ uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriResourceIndex);
+ } catch (IndexOutOfBoundsException ex) {
+ fail("not enough segments");
+ }
+
+ return this;
+ }
+
+ public ResourceValidator at(final int index) {
+ uriResourceIndex = index;
+ try {
+ uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(index);
+ } catch (IndexOutOfBoundsException ex) {
+ fail("not enough segments");
+ }
+ return this;
+ }
+
+ // --- Validation ---
+
+ public ResourceValidator isLambdaVar(final String var) {
+ String actualVar = null;
+ if (uriPathInfo.getKind() == UriResourceKind.lambdaAll) {
+ actualVar = ((UriResourceLambdaAllImpl) uriPathInfo).getLambdaVariable();
+ } else if (uriPathInfo.getKind() == UriResourceKind.lambdaAny) {
+ actualVar = ((UriResourceLambdaAnyImpl) uriPathInfo).getLamdaVariable();
+ } else {
+ fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+ }
+
+ assertEquals(var, actualVar);
+ return this;
+ }
+
+ public ResourceValidator isTypeFilter(final FullQualifiedName expectedType) {
+
+ if (uriPathInfo.getKind() != UriResourceKind.complexProperty &&
+ uriPathInfo.getKind() != UriResourceKind.singleton) {
+ fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+ }
+
+ EdmType actualType = null;
+ if (uriPathInfo instanceof UriResourceComplexPropertyImpl) {
+ actualType = ((UriResourceComplexPropertyImpl) uriPathInfo).getComplexTypeFilter();
+ } else if (uriPathInfo instanceof UriResourceSingletonImpl) {
+ actualType = ((UriResourceSingletonImpl) uriPathInfo).getEntityTypeFilter();
+ }
+
+ if (actualType == null) {
+ fail("type information not set");
+ }
+
+ FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
+
+ assertEquals(expectedType.toString(), actualName.toString());
+ return this;
+ }
+
+ public ResourceValidator isType(final FullQualifiedName type) {
+ if (!(uriPathInfo instanceof UriResourcePartTyped)) {
+ fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+ }
+ UriResourcePartTyped uriPathInfoTyped = (UriResourcePartTyped) uriPathInfo;
+
+ EdmType actualType = uriPathInfoTyped.getType();
+ if (actualType == null) {
+ fail("type information not set");
+ }
+
+ FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
+
+ assertEquals(type.toString(), actualName.toString());
+
+ return this;
+ }
+
+ public ResourceValidator isType(final FullQualifiedName type, final boolean isFinallyACollection) {
+ isType(type);
+ assertEquals(isFinallyACollection, ((UriResourcePartTyped) uriPathInfo).isCollection());
+ return this;
+ }
+
+ public ResourceValidator isTypeFilterOnEntry(final FullQualifiedName type) {
+ if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
+ fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+ }
+
+ UriResourceWithKeysImpl uriPathInfoKeyPred = (UriResourceWithKeysImpl) uriPathInfo;
+
+ // 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());
+ }
+
+ return this;
+ }
+
+ public ResourceValidator isTypeFilterOnCollection(final FullQualifiedName expectedType) {
+ if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
+ fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+ }
+ UriResourceWithKeysImpl uriPathInfoKeyPred = (UriResourceWithKeysImpl) uriPathInfo;
+
+ // 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());
+ }
+
+ 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;
+ }
+
+ // TODO remove
+ /*
+ * public ResourceValidator isCollection(final boolean isCollection) {
+ * if (!(uriPathInfo instanceof UriResourcePartTyped)) {
+ * fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+ * }
+ * UriResourcePartTyped uriPathInfoTyped = (UriResourcePartTyped) uriPathInfo;
+ *
+ * EdmType type = uriPathInfoTyped.getType();
+ * if (type == null) {
+ * fail("isCollection: type == null");
+ * }
+ * assertEquals(isCollection, uriPathInfoTyped.isCollection());
+ * 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());
+ }
+
+ UriResourceWithKeysImpl info = (UriResourceWithKeysImpl) uriPathInfo;
+ List<UriParameter> keyPredicates = info.getKeyPredicates();
+ assertEquals(name, keyPredicates.get(index).getName());
+ assertEquals(refencedProperty, keyPredicates.get(index).getRefencedProperty());
+ return this;
+
+ }
+
+ public ResourceValidator isKeyPredicateAlias(final int index, final String name, final String alias) {
+ if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
+ fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+ }
+
+ UriResourceWithKeysImpl info = (UriResourceWithKeysImpl) uriPathInfo;
+ List<UriParameter> keyPredicates = info.getKeyPredicates();
+ assertEquals(name, keyPredicates.get(index).getName());
+ assertEquals(alias, keyPredicates.get(index).getAlias());
+ return this;
+
+ }
+
+ public ResourceValidator isKeyPredicate(final int index, final String name, final String text) {
+ if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
+ fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+ }
+
+ UriResourceWithKeysImpl info = (UriResourceWithKeysImpl) uriPathInfo;
+ List<UriParameter> keyPredicates = info.getKeyPredicates();
+ assertEquals(name, keyPredicates.get(index).getName());
+ assertEquals(text, keyPredicates.get(index).getText());
+ return this;
+
+ }
+
+ public ResourceValidator isParameter(final int index, final String name, final String text) {
+ if (!(uriPathInfo instanceof UriResourceFunctionImpl)) {
+ fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+ }
+
+ UriResourceFunctionImpl info = (UriResourceFunctionImpl) uriPathInfo;
+ List<UriParameter> keyPredicates = info.getParameters();
+ assertEquals(name, keyPredicates.get(index).getName());
+ assertEquals(text, keyPredicates.get(index).getText());
+ return this;
+
+ }
+
+ public ResourceValidator isParameterAlias(final int index, final String name, final String alias) {
+ if (!(uriPathInfo instanceof UriResourceFunctionImpl)) {
+ fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+ }
+
+ UriResourceFunctionImpl info = (UriResourceFunctionImpl) uriPathInfo;
+ List<UriParameter> keyPredicates = info.getParameters();
+ assertEquals(name, keyPredicates.get(index).getName());
+ assertEquals(alias, keyPredicates.get(index).getAlias());
+ return this;
+
+ }
+
+ public ResourceValidator isKind(final UriInfoKind kind) {
+ assertEquals(kind, uriInfo.getKind());
+ return this;
+ }
+
+ public ResourceValidator isPrimitiveProperty(final String name,
+ final FullQualifiedName type, final boolean isCollection) {
+ if (!(uriPathInfo instanceof UriResourcePrimitivePropertyImpl)) {
+ fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+ }
+
+ UriResourcePrimitivePropertyImpl uriPathInfoProp = (UriResourcePrimitivePropertyImpl) uriPathInfo;
+
+ EdmElement property = uriPathInfoProp.getProperty();
+
+ assertEquals(name, property.getName());
+ assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName()));
+ assertEquals(isCollection, property.isCollection());
+ return this;
+ }
+
+ public ResourceValidator
+ isComplexProperty(final String name, final FullQualifiedName type, final boolean isCollection) {
+ if (!(uriPathInfo instanceof UriResourceComplexPropertyImpl)) {
+ fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+ }
+
+ UriResourceComplexPropertyImpl uriPathInfoProp = (UriResourceComplexPropertyImpl) uriPathInfo;
+
+ EdmElement property = uriPathInfoProp.getProperty();
+
+ assertEquals(name, property.getName());
+ assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName()));
+ assertEquals(isCollection, property.isCollection());
+ return this;
+ }
+
+ public ResourceValidator isNavProperty(final String name, final FullQualifiedName type, final boolean isCollection) {
+ if (!(uriPathInfo instanceof UriResourceNavigationPropertyImpl)) {
+ fail("invalid resource kind: " + uriPathInfo.getKind().toString());
+ }
+
+ UriResourceNavigationPropertyImpl uriPathInfoProp = (UriResourceNavigationPropertyImpl) uriPathInfo;
+
+ EdmElement property = uriPathInfoProp.getProperty();
+
+ assertEquals(name, property.getName());
+ assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName()));
+ assertEquals(isCollection, uriPathInfoProp.isCollection());
+ return this;
+ }
+
+ public ResourceValidator isUriPathInfoKind(final UriResourceKind infoType) {
+ assertNotNull(uriPathInfo);
+ assertEquals(infoType, uriPathInfo.getKind());
+ return this;
+ }
+
+ public ResourceValidator isAction(final String name) {
+ assertEquals(UriResourceKind.action, uriPathInfo.getKind());
+ assertEquals(name, ((UriResourceActionImpl) uriPathInfo).getAction().getName());
+ return this;
+ }
+
+ public ResourceValidator isFunction(final String name) {
+ assertEquals(UriResourceKind.function, uriPathInfo.getKind());
+ assertEquals(name, ((UriResourceFunctionImpl) uriPathInfo).getFunction().getName());
+ return this;
+ }
+
+ public ResourceValidator isFunctionImport(final String name) {
+ assertEquals(UriResourceKind.function, uriPathInfo.getKind());
+ assertEquals(name, ((UriResourceFunctionImpl) uriPathInfo).getFunctionImport().getName());
+ return this;
+ }
+
+ public ResourceValidator isEntitySet(final String name) {
+ assertEquals(UriResourceKind.entitySet, uriPathInfo.getKind());
+ assertEquals(name, ((UriResourceEntitySetImpl) uriPathInfo).getEntitySet().getName());
+ return this;
+ }
+
+ public ResourceValidator isComplex(final String name) {
+ assertEquals(UriResourceKind.complexProperty, uriPathInfo.getKind());
+ assertEquals(name, ((UriResourceComplexPropertyImpl) uriPathInfo).getProperty().getName());
+ return this;
+ }
+
+ public ResourceValidator isSingleton(final String name) {
+ assertEquals(UriResourceKind.singleton, uriPathInfo.getKind());
+ assertEquals(name, ((UriResourceSingletonImpl) uriPathInfo).getSingleton().getName());
+ return this;
+ }
+
+ public ResourceValidator isValue() {
+ assertEquals(UriResourceKind.value, uriPathInfo.getKind());
+ return this;
+ }
+
+ public ResourceValidator isCount() {
+ assertEquals(UriResourceKind.count, uriPathInfo.getKind());
+ return this;
+ }
+
+ public ResourceValidator isRef() {
+ assertEquals(UriResourceKind.ref, uriPathInfo.getKind());
+ return this;
+ }
+
+ public ResourceValidator isActionImport(final String actionName) {
+ assertEquals(UriResourceKind.action, uriPathInfo.getKind());
+ assertEquals(actionName, ((UriResourceActionImpl) uriPathInfo).getActionImport().getName());
+ return this;
+ }
+
+ public ResourceValidator isIt() {
+ assertEquals(UriResourceKind.it, uriPathInfo.getKind());
+ return this;
+ }
+
+ public ResourceValidator isTopText(final String topText) {
+ assertEquals(topText, uriInfo.getTopOption().getText());
+ return this;
+ }
+
+ public ResourceValidator isFormatText(final String formatText) {
+ assertEquals(formatText, uriInfo.getFormatOption().getText());
+ return this;
+ }
+
+ public ResourceValidator isInlineCountText(final String inlineCountText) {
+ assertEquals(inlineCountText, uriInfo.getCountOption().getText());
+ return this;
+ }
+
+ public ResourceValidator isSkipText(final String skipText) {
+ assertEquals(skipText, uriInfo.getSkipOption().getText());
+ return this;
+ }
+
+ public ResourceValidator isSkipTokenText(final String skipTokenText) {
+ assertEquals(skipTokenText, uriInfo.getSkipTokenOption().getText());
+ return this;
+ }
+
+ public ResourceValidator isSelectItemStar(final int index) {
+ SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+
+ SelectItem item = select.getSelectItems().get(index);
+ assertEquals(true, item.isStar());
+ return this;
+ }
+
+ public ResourceValidator isSelectItemAllOp(final int index, final FullQualifiedName fqn) {
+ SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+
+ SelectItem item = select.getSelectItems().get(index);
+ assertEquals(fqn.toString(), item.getAllOperationsInSchemaNameSpace().toString());
+ return this;
+ }
+
+ public ResourceValidator isSelectStartType(final int index, final FullQualifiedName fullName) {
+ SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+ SelectItem item = select.getSelectItems().get(index);
+
+ EdmType actualType = item.getStartTypeFilter();
+
+ FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
+ assertEquals(fullName, actualName);
+ return this;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestErrorLogger.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestErrorLogger.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestErrorLogger.java
new file mode 100644
index 0000000..0153036
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestErrorLogger.java
@@ -0,0 +1,105 @@
+/*
+ * 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.BitSet;
+import java.util.Collections;
+import java.util.List;
+
+import org.antlr.v4.runtime.ANTLRErrorListener;
+import org.antlr.v4.runtime.Parser;
+import org.antlr.v4.runtime.RecognitionException;
+import org.antlr.v4.runtime.Recognizer;
+import org.antlr.v4.runtime.atn.ATNConfigSet;
+import org.antlr.v4.runtime.dfa.DFA;
+import org.apache.olingo.server.core.uri.antlr.UriLexer;
+
+class TestErrorLogger implements ANTLRErrorListener {
+
+ private String prefix;
+ private int logLevel = 0;
+
+ public TestErrorLogger(final String prefix, final int logLevel) {
+ this.prefix = prefix;
+ this.logLevel = logLevel;
+ }
+
+ @Override
+ public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line,
+ final int charPositionInLine,
+ final String msg, final RecognitionException e) {
+
+ if (logLevel > 0) {
+ System.out.println("\n" + prefix + " -- SyntaxError");
+ trace(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
+ }
+
+ }
+
+ @Override
+ public void reportAmbiguity(final Parser recognizer, final DFA dfa, final int startIndex, final int stopIndex,
+ final boolean exact,
+ final BitSet ambigAlts, final ATNConfigSet configs) {
+
+ }
+
+ @Override
+ public void reportAttemptingFullContext(final Parser recognizer, final DFA dfa, final int startIndex,
+ final int stopIndex,
+ final BitSet conflictingAlts, final ATNConfigSet configs) {
+
+ }
+
+ @Override
+ public void reportContextSensitivity(final Parser recognizer, final DFA dfa, final int startIndex,
+ final int stopIndex, final int prediction,
+ final ATNConfigSet configs) {
+
+ }
+
+ private void printStack(final Recognizer<?, ?> recognizer) {
+ List<String> stack = ((Parser) recognizer).getRuleInvocationStack();
+ Collections.reverse(stack);
+ System.out.println(" rule stack: " + stack);
+ }
+
+ public void trace(final Recognizer<?, ?> recognizer, final Object offendingSymbol,
+ final int line, final int charPositionInLine, final String msg, final RecognitionException e) {
+
+ System.out.println("Error message: " + msg);
+
+ printStack(recognizer);
+
+ System.out.println(" line/char :" + line + " / " + charPositionInLine);
+ System.out.println(" sym :" + offendingSymbol);
+ if (e != null && e.getOffendingToken() != null) {
+
+ String lexerTokenName = "";
+ try {
+ lexerTokenName = UriLexer.tokenNames[e.getOffendingToken().getType()];
+ } catch (ArrayIndexOutOfBoundsException es) {
+ lexerTokenName = "token error";
+ }
+
+ System.out.println(" tokenname:" + lexerTokenName);
+ }
+
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
new file mode 100644
index 0000000..35687f6
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
@@ -0,0 +1,258 @@
+/*
+ * 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 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.server.api.uri.UriInfoKind;
+import org.apache.olingo.server.api.uri.queryoption.CustomQueryOption;
+import org.apache.olingo.server.api.uri.queryoption.SelectItem;
+import org.apache.olingo.server.core.uri.UriInfoImpl;
+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.UriValidator;
+
+public class TestUriValidator implements TestValidator {
+ private Edm edm;
+
+ private UriInfoImpl uriInfo;
+ private Exception exception;
+
+ // Setup
+ public TestUriValidator setEdm(final Edm edm) {
+ this.edm = edm;
+ return this;
+ }
+
+ // Execution
+ public TestUriValidator run(final String uri) {
+ Parser parser = new Parser();
+ UriValidator validator = new UriValidator();
+
+ uriInfo = null;
+ try {
+ uriInfo = (UriInfoImpl) parser.parseUri(uri, edm);
+ validator.validate(uriInfo, "GET");
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ return this;
+ }
+
+ public TestUriValidator runEx(final String uri) {
+ Parser parser = new Parser();
+ uriInfo = null;
+ try {
+ uriInfo = (UriInfoImpl) parser.parseUri(uri, edm);
+ fail("Exception expected");
+ } catch (UriParserException e) {
+ exception = e;
+ }
+
+ return this;
+ }
+
+ public TestUriValidator log(final String uri) {
+ ParserWithLogging parserTest = new ParserWithLogging();
+ parserTest.setLogLevel(1);
+ uriInfo = null;
+ try {
+ // uriInfoTmp = new UriParserImpl(edm).ParseUri(uri);
+ uriInfo = (UriInfoImpl) parserTest.parseUri(uri, edm);
+ } catch (UriParserException e) {
+ fail("Exception occured while parsing the URI: " + uri + "\n"
+ + " Exception: " + e.getMessage());
+ }
+
+ return this;
+ }
+
+ // Navigation
+ public ResourceValidator goPath() {
+ if (uriInfo.getKind() != UriInfoKind.resource) {
+ fail("invalid resource kind: " + uriInfo.getKind().toString());
+ }
+
+ return new ResourceValidator()
+ .setUpValidator(this)
+ .setEdm(edm)
+ .setUriInfoImplPath(uriInfo);
+ }
+
+ public FilterValidator goFilter() {
+ FilterOptionImpl filter = (FilterOptionImpl) uriInfo.getFilterOption();
+ if (filter == null) {
+ fail("no filter found");
+ }
+ return new FilterValidator().setUriValidator(this).setFilter(filter);
+
+ }
+
+ public ExpandValidator goExpand() {
+ ExpandOptionImpl expand = (ExpandOptionImpl) uriInfo.getExpandOption();
+ if (expand == null) {
+ fail("invalid resource kind: " + uriInfo.getKind().toString());
+ }
+
+ return new ExpandValidator().setUpValidator(this).setExpand(expand);
+ }
+
+ public ResourceValidator goSelectItemPath(final int index) {
+ SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+
+ SelectItem item = select.getSelectItems().get(index);
+ UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourcePath();
+
+ return new ResourceValidator()
+ .setUpValidator(this)
+ .setEdm(edm)
+ .setUriInfoImplPath(uriInfo1);
+
+ }
+
+ public TestUriValidator isSelectStartType(final int index, final FullQualifiedName fullName) {
+ SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+ SelectItem item = select.getSelectItems().get(index);
+ EdmType actualType = item.getStartTypeFilter();
+
+ FullQualifiedName actualName = new FullQualifiedName(actualType.getNamespace(), actualType.getName());
+ assertEquals(fullName, actualName);
+ return this;
+
+ }
+
+ // Validation
+ public TestUriValidator isKind(final UriInfoKind kind) {
+ assertEquals(kind, uriInfo.getKind());
+ return this;
+ }
+
+ public TestUriValidator isCustomParameter(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 enought queryParameters");
+ }
+
+ CustomQueryOptionImpl option = (CustomQueryOptionImpl) list.get(index);
+ assertEquals(name, option.getName());
+ assertEquals(value, option.getText());
+ return this;
+ }
+
+ public void isCrossJoinEntityList(final List<String> entitySets) {
+ if (uriInfo.getKind() != UriInfoKind.crossjoin) {
+ fail("invalid resource kind: " + uriInfo.getKind().toString());
+ }
+
+ int i = 0;
+ for (String entitySet : entitySets) {
+ assertEquals(entitySet, uriInfo.getEntitySetNames().get(i));
+ i++;
+ }
+
+ }
+
+ public TestUriValidator isExSyntax(final long errorID) {
+ assertEquals(UriParserSyntaxException.class, exception.getClass());
+ return this;
+ }
+
+ public TestUriValidator isExSemantic(final long errorID) {
+ assertEquals(UriParserSemanticException.class, exception.getClass());
+ return this;
+ }
+
+ public TestUriValidator isIdText(final String text) {
+ assertEquals(text, uriInfo.getIdOption().getText());
+ return this;
+ }
+
+ public TestUriValidator isExpandText(final String text) {
+ assertEquals(text, uriInfo.getExpandOption().getText());
+ return this;
+ }
+
+ public TestUriValidator isSelectText(final String text) {
+ assertEquals(text, uriInfo.getSelectOption().getText());
+ return this;
+ }
+
+ public TestUriValidator isFormatText(final String text) {
+ assertEquals(text, uriInfo.getFormatOption().getText());
+ return this;
+ }
+
+ public TestUriValidator isFragmentText(final String text) {
+ if (uriInfo.getKind() != UriInfoKind.metadata) {
+ fail("invalid resource kind: " + uriInfo.getKind().toString());
+ }
+
+ assertEquals(text, uriInfo.getFragment());
+
+ return this;
+ }
+
+ public TestUriValidator isEntityType(final FullQualifiedName fullName) {
+ if (uriInfo.getKind() != UriInfoKind.entityId) {
+ fail("invalid resource kind: " + uriInfo.getKind().toString());
+ }
+
+ assertEquals(fullName.toString(), fullName(uriInfo.getEntityTypeCast()));
+ return this;
+ }
+
+ private String fullName(final EdmEntityType type) {
+ return type.getNamespace() + "." + type.getName();
+ }
+
+ public TestUriValidator isSelectItemStar(final int index) {
+ SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+
+ SelectItem item = select.getSelectItems().get(index);
+ assertEquals(true, item.isStar());
+ return this;
+ }
+
+ public TestUriValidator isSelectItemAllOp(final int index, final FullQualifiedName fqn) {
+ SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
+
+ SelectItem item = select.getSelectItems().get(index);
+ assertEquals(fqn.toString(), item.getAllOperationsInSchemaNameSpace().toString());
+ return this;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestValidator.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestValidator.java
new file mode 100644
index 0000000..7e64f86
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TestValidator.java
@@ -0,0 +1,23 @@
+/*
+ * 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;
+
+public interface TestValidator {
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TokenValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TokenValidator.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TokenValidator.java
new file mode 100644
index 0000000..4a94bb3
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/TokenValidator.java
@@ -0,0 +1,194 @@
+/*
+ * 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.List;
+
+import org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.Token;
+import org.apache.olingo.server.core.uri.antlr.UriLexer;
+
+//TODO extend to test also exception which can occure while paring
+public class TokenValidator {
+
+ private String input = null;
+
+ private List<? extends Token> tokens = null;
+ private Token curToken = null;
+ private Exception curException = null;
+
+ private int startMode;
+ private int logLevel = 0;
+
+ // --- Setup ---
+
+ public TokenValidator log(final int logLevel) {
+ this.logLevel = logLevel;
+ return this;
+ }
+
+ // --- Execution ---
+
+ public TokenValidator run(final String uri) {
+ input = uri;
+
+ tokens = parseInput(uri);
+ if (logLevel > 0) {
+ showTokens();
+ }
+
+ first();
+ exFirst();
+ logLevel = 0;
+
+ return this;
+ }
+
+ // --- Navigation ---
+
+ // navigate within the tokenlist
+ public TokenValidator first() {
+ try {
+ curToken = tokens.get(0);
+ } catch (IndexOutOfBoundsException ex) {
+ curToken = null;
+ }
+ return this;
+ }
+
+ public TokenValidator last() {
+ curToken = tokens.get(tokens.size() - 1);
+ return this;
+ }
+
+ public TokenValidator at(final int index) {
+ try {
+ curToken = tokens.get(index);
+ } catch (IndexOutOfBoundsException ex) {
+ curToken = null;
+ }
+ return this;
+ }
+
+ public TokenValidator exLast() {
+ // curException = exceptions.get(exceptions.size() - 1);
+ return this;
+ }
+
+ // navigate within the exception list
+ public TokenValidator exFirst() {
+ try {
+ // curException = exceptions.get(0);
+ } catch (IndexOutOfBoundsException ex) {
+ curException = null;
+ }
+ return this;
+
+ }
+
+ public TokenValidator exAt(final int index) {
+ try {
+ // curException = exceptions.get(index);
+ } catch (IndexOutOfBoundsException ex) {
+ curException = null;
+ }
+ return this;
+ }
+
+ // --- Validation ---
+
+ public TokenValidator isText(final String expected) {
+ assertEquals(expected, curToken.getText());
+ return this;
+ }
+
+ public TokenValidator isAllText(final String expected) {
+ String actual = "";
+
+ for (Token curToken : tokens) {
+ actual += curToken.getText();
+ }
+ assertEquals(expected, actual);
+ return this;
+ }
+
+ public TokenValidator isAllInput() {
+ String actual = "";
+
+ for (Token curToken : tokens) {
+ actual += curToken.getText();
+ }
+ assertEquals(input, actual);
+ return this;
+ }
+
+ public TokenValidator isInput() {
+ assertEquals(input, curToken.getText());
+ return this;
+ }
+
+ public TokenValidator isType(final int expected) {
+ assertEquals(UriLexer.tokenNames[expected], UriLexer.tokenNames[curToken.getType()]);
+ return this;
+ }
+
+ public TokenValidator isExType(final Class<?> exClass) {
+ assertEquals(exClass, curException.getClass());
+ return this;
+ }
+
+ public void globalMode(final int mode) {
+ startMode = mode;
+ }
+
+ // --- Helper ---
+
+ private List<? extends Token> parseInput(final String input) {
+ ANTLRInputStream inputStream = new ANTLRInputStream(input);
+
+ UriLexer lexer = new UriLexerWithTrace(inputStream, logLevel, startMode);
+ // lexer.addErrorListener(new ErrorCollector(this));
+ return lexer.getAllTokens();
+ }
+
+ public TokenValidator showTokens() {
+ boolean first = true;
+ System.out.println("input: " + input);
+ String nL = "\n";
+ String out = "[" + nL;
+ for (Token token : tokens) {
+ if (!first) {
+ out += ",";
+ first = false;
+ }
+ int index = token.getType();
+ if (index != -1) {
+ out += "\"" + token.getText() + "\"" + " " + UriLexer.tokenNames[index] + nL;
+ } else {
+ out += "\"" + token.getText() + "\"" + " " + index + nL;
+ }
+ }
+ out += ']';
+ System.out.println("tokens: " + out);
+ return this;
+ }
+
+}
[02/15] [OLINGO-266] refactor ref module to server-ref
Posted by sk...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/UriLexerWithTrace.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/UriLexerWithTrace.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/UriLexerWithTrace.java
new file mode 100644
index 0000000..9005080
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/testutil/UriLexerWithTrace.java
@@ -0,0 +1,85 @@
+/*
+ * 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 org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.Token;
+import org.apache.olingo.server.core.uri.antlr.UriLexer;
+
+public class UriLexerWithTrace extends UriLexer {
+ int logLevel = 0;
+
+ public UriLexerWithTrace(final ANTLRInputStream antlrInputStream, final int logLevel) {
+ super(antlrInputStream);
+ this.logLevel = logLevel;
+ }
+
+ public UriLexerWithTrace(final ANTLRInputStream antlrInputStream, final int logLevel, final int mode) {
+ super(antlrInputStream);
+ super.mode(mode);
+ this.logLevel = logLevel;
+ }
+
+ @Override
+ public void emit(final Token token) {
+ if (logLevel > 1) {
+ String out = String.format("%1$-" + 20 + "s", token.getText());
+
+ int tokenType = token.getType();
+ if (tokenType == -1) {
+ out += "-1/EOF";
+ } else {
+ out += UriLexer.tokenNames[tokenType];
+ }
+ System.out.println("Lexer.emit(...):" + out);
+ }
+
+ super.emit(token);
+ }
+
+ @Override
+ public void pushMode(final int m) {
+
+ String out = UriLexer.modeNames[_mode] + "-->";
+
+ super.pushMode(m);
+
+ out += UriLexer.modeNames[_mode];
+
+ if (logLevel > 1) {
+ System.out.println(out + " ");
+ }
+ }
+
+ @Override
+ public int popMode() {
+
+ String out = UriLexer.modeNames[_mode] + "-->";
+
+ int m = super.popMode();
+
+ out += UriLexer.modeNames[_mode];
+
+ if (logLevel > 1) {
+ System.out.println(out + " ");
+ }
+
+ return m;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
new file mode 100644
index 0000000..0374b25
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
@@ -0,0 +1,378 @@
+/*
+ * 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.validator;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.server.api.uri.UriInfo;
+import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
+import org.apache.olingo.server.core.testutil.techprovider.EdmTechProvider;
+import org.apache.olingo.server.core.uri.parser.Parser;
+import org.apache.olingo.server.core.uri.parser.UriParserException;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class UriValidatorTest {
+
+ private static final String URI_ALL = "$all";
+ private static final String URI_BATCH = "$batch";
+ private static final String URI_CROSSJOIN = "$crossjoin(ESAllPrim)";
+ private static final String URI_ENTITY_ID = "/$entity";
+ private static final String URI_METADATA = "$metadata";
+ private static final String URI_SERVICE = "";
+ private static final String URI_ENTITY_SET = "/ESAllPrim";
+ private static final String URI_ENTITY_SET_COUNT = "/ESAllPrim/$count";
+ private static final String URI_ENTITY = "/ESAllPrim(1)";
+ private static final String URI_MEDIA_STREAM = "/ESMedia(1)/$value";
+ private static final String URI_REFERENCES = "/ESAllPrim/$ref";
+ private static final String URI_REFERENCE = "/ESAllPrim(1)/$ref";
+ private static final String URI_PROPERTY_COMPLEX = "/ESCompComp(1)/PropertyComplex";
+ private static final String URI_PROPERTY_COMPLEX_COLLECTION =
+ "/ESCompCollComp(1)/PropertyComplex/CollPropertyComplex";
+ private static final String URI_PROPERTY_COMPLEX_COLLECTION_COUNT =
+ "/ESCompCollComp(1)/PropertyComplex/CollPropertyComplex/$count";
+ private static final String URI_PROPERTY_PRIMITIVE = "/ESAllPrim(1)/PropertyString";
+ private static final String URI_PROPERTY_PRIMITIVE_COLLECTION = "/ESCollAllPrim/CollPropertyString";
+ private static final String URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT =
+ "/ESCollAllPrim/CollPropertyString/$count";
+ private static final String URI_PROPERTY_PRIMITIVE_VALUE = "/ESAllPrim(1)/PropertyString/$value";
+ private static final String URI_SINGLETON = "/SI";
+ private static final String URI_NAV_ENTITY = "/ESKeyNav/NavPropertyETKeyNavOne";
+ private static final String URI_NAV_ENTITY_SET = "/ESKeyNav/NavPropertyETKeyNavMany";
+
+ private static final String QO_FILTER = "$filter='1' eq '1'";
+ private static final String QO_FORMAT = "$format=bla";
+ private static final String QO_EXPAND = "$expand=*";
+ private static final String QO_ID = "$id=Products(0)";
+ private static final String QO_COUNT = "$count";
+ private static final String QO_ORDERBY = "$orderby=true";
+// private static final String QO_SEARCH = "$search='bla'";
+ private static final String QO_SELECT = "$select=*";
+ private static final String QO_SKIP = "$skip=3";
+ private static final String QO_SKIPTOKEN = "$skiptoken=123";
+ private static final String QO_LEVELS = "$expand=*($levels=1)";
+ private static final String QO_TOP = "$top=1";
+
+ private String[][] urisWithValidSystemQueryOptions = {
+ { URI_ALL, QO_FILTER, }, { URI_ALL, QO_FORMAT }, { URI_ALL, QO_EXPAND }, { URI_ALL, QO_COUNT },
+ { URI_ALL, QO_ORDERBY }, /* { URI_ALL, QO_SEARCH }, */{ URI_ALL, QO_SELECT }, { URI_ALL, QO_SKIP },
+ { URI_ALL, QO_SKIPTOKEN }, { URI_ALL, QO_LEVELS },
+
+ { URI_CROSSJOIN, QO_FILTER, }, { URI_CROSSJOIN, QO_FORMAT },
+ { URI_CROSSJOIN, QO_EXPAND }, { URI_CROSSJOIN, QO_COUNT }, { URI_CROSSJOIN, QO_ORDERBY },
+ /* { URI_CROSSJOIN, QO_SEARCH }, */{ URI_CROSSJOIN, QO_SELECT }, { URI_CROSSJOIN, QO_SKIP },
+ { URI_CROSSJOIN, QO_SKIPTOKEN }, { URI_CROSSJOIN, QO_LEVELS }, { URI_CROSSJOIN, QO_TOP },
+
+ { URI_ENTITY_ID, QO_ID, QO_FORMAT }, { URI_ENTITY_ID, QO_ID, }, { URI_ENTITY_ID, QO_ID, QO_EXPAND },
+ { URI_ENTITY_ID, QO_ID, QO_SELECT }, { URI_ENTITY_ID, QO_ID, QO_LEVELS },
+
+ { URI_METADATA, QO_FORMAT },
+
+ { URI_SERVICE, QO_FORMAT },
+
+ { URI_ENTITY_SET, QO_FILTER, }, { URI_ENTITY_SET, QO_FORMAT }, { URI_ENTITY_SET, QO_EXPAND },
+ { URI_ENTITY_SET, QO_COUNT }, { URI_ENTITY_SET, QO_ORDERBY }, /* { URI_ENTITY_SET, QO_SEARCH }, */
+ { URI_ENTITY_SET, QO_SELECT },
+ { URI_ENTITY_SET, QO_SKIP }, { URI_ENTITY_SET, QO_SKIPTOKEN }, { URI_ENTITY_SET, QO_LEVELS },
+ { URI_ENTITY_SET, QO_TOP },
+
+ { URI_ENTITY_SET_COUNT, QO_FILTER }, /* { URI_ENTITY_SET_COUNT, QO_SEARCH }, */
+
+ { URI_ENTITY, QO_FORMAT }, { URI_ENTITY, QO_EXPAND }, { URI_ENTITY, QO_SELECT }, { URI_ENTITY, QO_LEVELS },
+
+ { URI_MEDIA_STREAM, QO_FORMAT },
+
+ { URI_REFERENCES, QO_FILTER }, { URI_REFERENCES, QO_FORMAT }, { URI_REFERENCES, QO_ORDERBY },
+ /* { URI_REFERENCES, QO_SEARCH }, */{ URI_REFERENCES, QO_SKIP }, { URI_REFERENCES, QO_SKIPTOKEN },
+ { URI_REFERENCES, QO_TOP },
+
+ { URI_REFERENCE, QO_FORMAT },
+
+ { URI_PROPERTY_COMPLEX, QO_FORMAT }, { URI_PROPERTY_COMPLEX, QO_SELECT }, { URI_PROPERTY_COMPLEX, QO_EXPAND },
+ { URI_PROPERTY_COMPLEX, QO_LEVELS },
+
+ { URI_PROPERTY_COMPLEX_COLLECTION, QO_FILTER }, { URI_PROPERTY_COMPLEX_COLLECTION, QO_FORMAT },
+ { URI_PROPERTY_COMPLEX_COLLECTION, QO_EXPAND }, { URI_PROPERTY_COMPLEX_COLLECTION, QO_COUNT },
+ { URI_PROPERTY_COMPLEX_COLLECTION, QO_SKIP }, { URI_PROPERTY_COMPLEX_COLLECTION, QO_SKIPTOKEN },
+ { URI_PROPERTY_COMPLEX_COLLECTION, QO_LEVELS }, { URI_PROPERTY_COMPLEX_COLLECTION, QO_TOP },
+ { URI_PROPERTY_COMPLEX_COLLECTION, QO_ORDERBY },
+
+ { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_FILTER }, /* { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_SEARCH }, */
+
+ { URI_PROPERTY_PRIMITIVE, QO_FORMAT },
+
+ { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_FILTER }, { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_FORMAT },
+ { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_ORDERBY }, { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_SKIP },
+ { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_SKIPTOKEN }, { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_TOP },
+
+ { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_FILTER },
+ /* { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_SEARCH }, */
+
+ { URI_PROPERTY_PRIMITIVE_VALUE, QO_FORMAT },
+
+ { URI_SINGLETON, QO_FORMAT }, { URI_SINGLETON, QO_EXPAND }, { URI_SINGLETON, QO_SELECT },
+ { URI_SINGLETON, QO_LEVELS },
+
+ { URI_NAV_ENTITY, QO_FORMAT }, { URI_NAV_ENTITY, QO_EXPAND }, { URI_NAV_ENTITY, QO_SELECT },
+ { URI_NAV_ENTITY, QO_LEVELS },
+
+ { URI_NAV_ENTITY_SET, QO_FILTER, }, { URI_NAV_ENTITY_SET, QO_FORMAT }, { URI_NAV_ENTITY_SET, QO_EXPAND },
+ { URI_NAV_ENTITY_SET, QO_COUNT }, { URI_NAV_ENTITY_SET, QO_ORDERBY },
+ /* { URI_NAV_ENTITY_SET, QO_SEARCH }, */{ URI_NAV_ENTITY_SET, QO_SELECT }, { URI_NAV_ENTITY_SET, QO_SKIP },
+ { URI_NAV_ENTITY_SET, QO_SKIPTOKEN }, { URI_NAV_ENTITY_SET, QO_LEVELS }, { URI_NAV_ENTITY_SET, QO_TOP },
+
+ { "FINRTInt16()" },
+ { "FICRTETKeyNav()" },
+ { "FICRTESTwoKeyNavParam(ParameterInt16=1)" },
+ { "FICRTCollString()" },
+ { "FICRTCTTwoPrim()" },
+ { "FICRTCollCTTwoPrim()" },
+ { "FICRTETMedia()" },
+
+ { "ESTwoKeyNav/com.sap.odata.test1.BAESTwoKeyNavRTESTwoKeyNav" },
+ { "ESAllPrim/com.sap.odata.test1.BAESAllPrimRTETAllPrim" },
+ { "AIRTPrimCollParam" },
+ { "AIRTETParam" },
+ { "AIRTPrimParam" },
+
+ };
+
+ private String[][] urisWithNonValidSystemQueryOptions = {
+ { URI_ALL, QO_ID, }, { URI_ALL, QO_TOP },
+
+ { URI_BATCH, QO_FILTER, }, { URI_BATCH, QO_FORMAT }, { URI_BATCH, QO_ID, }, { URI_BATCH, QO_EXPAND },
+ { URI_BATCH, QO_COUNT }, { URI_BATCH, QO_ORDERBY }, /* { URI_BATCH, QO_SEARCH }, */{ URI_BATCH, QO_SELECT },
+ { URI_BATCH, QO_SKIP }, { URI_BATCH, QO_SKIPTOKEN }, { URI_BATCH, QO_LEVELS }, { URI_BATCH, QO_TOP },
+
+ { URI_CROSSJOIN, QO_ID, },
+
+ { URI_ENTITY_ID, QO_ID, QO_FILTER, },
+ { URI_ENTITY_ID, QO_ID, QO_COUNT }, { URI_ENTITY_ID, QO_ORDERBY }, /* { URI_ENTITY_ID, QO_SEARCH }, */
+
+ { URI_ENTITY_ID, QO_ID, QO_SKIP }, { URI_ENTITY_ID, QO_ID, QO_SKIPTOKEN }, { URI_ENTITY_ID, QO_ID, QO_TOP },
+
+ { URI_METADATA, QO_FILTER, }, { URI_METADATA, QO_ID, }, { URI_METADATA, QO_EXPAND },
+ { URI_METADATA, QO_COUNT }, { URI_METADATA, QO_ORDERBY }, /* { URI_METADATA, QO_SEARCH }, */
+ { URI_METADATA, QO_SELECT }, { URI_METADATA, QO_SKIP }, { URI_METADATA, QO_SKIPTOKEN },
+ { URI_METADATA, QO_LEVELS }, { URI_METADATA, QO_TOP },
+
+ { URI_SERVICE, QO_FILTER }, { URI_SERVICE, QO_ID }, { URI_SERVICE, QO_EXPAND }, { URI_SERVICE, QO_COUNT },
+ { URI_SERVICE, QO_ORDERBY }, /* { URI_SERVICE, QO_SEARCH }, */{ URI_SERVICE, QO_SELECT },
+ { URI_SERVICE, QO_SKIP }, { URI_SERVICE, QO_SKIPTOKEN }, { URI_SERVICE, QO_LEVELS }, { URI_SERVICE, QO_TOP },
+
+ { URI_ENTITY_SET, QO_ID },
+
+ { URI_ENTITY_SET_COUNT, QO_FORMAT }, { URI_ENTITY_SET_COUNT, QO_ID },
+ { URI_ENTITY_SET_COUNT, QO_EXPAND }, { URI_ENTITY_SET_COUNT, QO_COUNT },
+ { URI_ENTITY_SET_COUNT, QO_ORDERBY },
+ { URI_ENTITY_SET_COUNT, QO_SELECT }, { URI_ENTITY_SET_COUNT, QO_SKIP }, { URI_ENTITY_SET_COUNT, QO_SKIPTOKEN },
+ { URI_ENTITY_SET_COUNT, QO_LEVELS }, { URI_ENTITY_SET_COUNT, QO_TOP },
+
+ { URI_ENTITY, QO_FILTER }, { URI_ENTITY, QO_ID }, { URI_ENTITY, QO_COUNT }, /* { URI_ENTITY, QO_ORDERBY }, */
+ /* { URI_ENTITY, QO_SEARCH }, */{ URI_ENTITY, QO_SKIP }, { URI_ENTITY, QO_SKIPTOKEN }, { URI_ENTITY, QO_TOP },
+
+ { URI_MEDIA_STREAM, QO_FILTER }, { URI_MEDIA_STREAM, QO_ID, }, { URI_MEDIA_STREAM, QO_EXPAND },
+ { URI_MEDIA_STREAM, QO_COUNT }, { URI_MEDIA_STREAM, QO_ORDERBY }, /* { URI_MEDIA_STREAM, QO_SEARCH }, */
+ { URI_MEDIA_STREAM, QO_SELECT }, { URI_MEDIA_STREAM, QO_SKIP }, { URI_MEDIA_STREAM, QO_SKIPTOKEN },
+ { URI_MEDIA_STREAM, QO_LEVELS }, { URI_MEDIA_STREAM, QO_TOP },
+
+ { URI_REFERENCES, QO_ID, }, { URI_REFERENCES, QO_EXPAND }, { URI_REFERENCES, QO_COUNT },
+ { URI_REFERENCES, QO_SELECT }, { URI_REFERENCES, QO_LEVELS },
+
+ { URI_REFERENCE, QO_FILTER }, { URI_REFERENCE, QO_ID, }, { URI_REFERENCE, QO_EXPAND },
+ { URI_REFERENCE, QO_COUNT }, { URI_REFERENCE, QO_ORDERBY }, /* { URI_REFERENCE, QO_SEARCH }, */
+ { URI_REFERENCE, QO_SELECT }, { URI_REFERENCE, QO_SKIP }, { URI_REFERENCE, QO_SKIPTOKEN },
+ { URI_REFERENCE, QO_LEVELS }, { URI_REFERENCE, QO_TOP },
+
+ { URI_PROPERTY_COMPLEX, QO_FILTER }, { URI_PROPERTY_COMPLEX, QO_ID, }, { URI_PROPERTY_COMPLEX, QO_COUNT },
+ { URI_PROPERTY_COMPLEX, QO_ORDERBY }, /* { URI_PROPERTY_COMPLEX, QO_SEARCH }, */
+ { URI_PROPERTY_COMPLEX, QO_SKIP }, { URI_PROPERTY_COMPLEX, QO_SKIPTOKEN }, { URI_PROPERTY_COMPLEX, QO_TOP },
+
+ { URI_PROPERTY_COMPLEX_COLLECTION, QO_ID, },
+ /* { URI_PROPERTY_COMPLEX_COLLECTION, QO_SEARCH }, */{ URI_PROPERTY_COMPLEX_COLLECTION, QO_SELECT },
+
+ { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_FORMAT },
+ { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_ID, }, { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_EXPAND },
+ { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_COUNT }, { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_ORDERBY },
+ { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_SELECT },
+ { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_SKIP }, { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_SKIPTOKEN },
+ { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_LEVELS }, { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_TOP },
+
+ { URI_PROPERTY_PRIMITIVE, QO_FILTER }, { URI_PROPERTY_PRIMITIVE, QO_ID, }, { URI_PROPERTY_PRIMITIVE, QO_EXPAND },
+ { URI_PROPERTY_PRIMITIVE, QO_COUNT }, { URI_PROPERTY_PRIMITIVE, QO_ORDERBY },
+ /* { URI_PROPERTY_PRIMITIVE, QO_SEARCH }, */{ URI_PROPERTY_PRIMITIVE, QO_SELECT },
+ { URI_PROPERTY_PRIMITIVE, QO_SKIP }, { URI_PROPERTY_PRIMITIVE, QO_SKIPTOKEN },
+ { URI_PROPERTY_PRIMITIVE, QO_LEVELS }, { URI_PROPERTY_PRIMITIVE, QO_TOP },
+
+ { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_ID, }, { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_EXPAND },
+ { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_COUNT }, /* { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_SEARCH }, */
+ { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_SELECT }, { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_LEVELS },
+
+ { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_FORMAT },
+ { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_ID, }, { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_EXPAND },
+ { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_COUNT },
+ { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_ORDERBY },
+ { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_SELECT }, { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_SKIP },
+ { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_SKIPTOKEN },
+ { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_LEVELS }, { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_TOP },
+
+ { URI_PROPERTY_PRIMITIVE_VALUE, QO_FILTER }, { URI_PROPERTY_PRIMITIVE_VALUE, QO_ID, },
+ { URI_PROPERTY_PRIMITIVE_VALUE, QO_EXPAND }, { URI_PROPERTY_PRIMITIVE_VALUE, QO_COUNT },
+ { URI_PROPERTY_PRIMITIVE_VALUE, QO_ORDERBY },/* { URI_PROPERTY_PRIMITIVE_VALUE, QO_SEARCH }, */
+ { URI_PROPERTY_PRIMITIVE_VALUE, QO_SELECT }, { URI_PROPERTY_PRIMITIVE_VALUE, QO_SKIP },
+ { URI_PROPERTY_PRIMITIVE_VALUE, QO_SKIPTOKEN }, { URI_PROPERTY_PRIMITIVE_VALUE, QO_LEVELS },
+ { URI_PROPERTY_PRIMITIVE_VALUE, QO_TOP },
+
+ { URI_SINGLETON, QO_FILTER }, { URI_SINGLETON, QO_ID }, { URI_SINGLETON, QO_COUNT },
+ { URI_SINGLETON, QO_ORDERBY }, /* { URI_SINGLETON, QO_SEARCH }, */{ URI_SINGLETON, QO_SKIP },
+ { URI_SINGLETON, QO_SKIPTOKEN }, { URI_SINGLETON, QO_TOP },
+
+ { URI_NAV_ENTITY, QO_FILTER }, { URI_NAV_ENTITY, QO_ID }, { URI_NAV_ENTITY, QO_COUNT },
+ { URI_NAV_ENTITY, QO_ORDERBY }, /* { URI_NAV_ENTITY, QO_SEARCH }, */{ URI_NAV_ENTITY, QO_SKIP },
+ { URI_NAV_ENTITY, QO_SKIPTOKEN }, { URI_SINGLETON, QO_TOP },
+
+ { URI_NAV_ENTITY_SET, QO_ID },
+
+ };
+
+ private Parser parser;
+ private Edm edm;
+
+ @Before
+ public void before() {
+ parser = new Parser();
+ edm = new EdmProviderImpl(new EdmTechProvider());
+ }
+
+ @Test
+ public void validateSelect() throws Exception {
+ String[] uris = { "/ESAllPrim(1)?$select=PropertyString" };
+ for (String uri : uris) {
+ parseAndValidate(uri, "GET");
+ }
+ }
+
+ @Test(expected = UriValidationException.class)
+ public void validateForHttpMethodsFail() throws Exception {
+ String uri = URI_ENTITY;
+ parseAndValidate(uri, "xyz");
+ }
+
+ @Test
+ public void validateForHttpMethods() throws Exception {
+ String uri = URI_ENTITY;
+ parseAndValidate(uri, "GET");
+ parseAndValidate(uri, "POST");
+ parseAndValidate(uri, "PUT");
+ parseAndValidate(uri, "DELETE");
+ parseAndValidate(uri, "PATCH");
+ parseAndValidate(uri, "MERGE");
+ }
+
+ @Test
+ public void validateOrderBy() throws Exception {
+ String[] uris = { "/ESAllPrim?$orderby=PropertyString" };
+ for (String uri : uris) {
+ parseAndValidate(uri, "GET");
+ }
+ }
+
+ @Test(expected = UriValidationException.class)
+ @Ignore("uri parser doen't support orderby yet")
+ public void validateOrderByInvalid() throws Exception {
+ String uri = "/ESAllPrim(1)?$orderBy=XXXX";
+ parseAndValidate(uri, "GET");
+ }
+
+ @Test(expected = UriValidationException.class)
+ public void validateKeyPredicatesWrongKey() throws Exception {
+ String uri = "ESTwoKeyNav(xxx=1, yyy='abc')";
+ parseAndValidate(uri, "GET");
+ }
+
+ @Test
+ public void validateKeyPredicates() throws Exception {
+ String uri = "ESTwoKeyNav(PropertyInt16=1, PropertyString='abc')";
+ parseAndValidate(uri, "GET");
+ }
+
+ @Test(expected = UriValidationException.class)
+ public void validateKeyPredicatesWrongValueType() throws Exception {
+ String uri = "ESTwoKeyNav(PropertyInt16='abc', PropertyString=1)";
+ parseAndValidate(uri, "GET");
+ }
+
+ @Test
+ public void checkValidSystemQueryOption() throws Exception {
+ String[] uris = constructUri(urisWithValidSystemQueryOptions);
+
+ for (String uri : uris) {
+ try {
+ parseAndValidate(uri, "GET");
+ } catch (Exception e) {
+ throw new Exception("Faild for uri: " + uri, e);
+ }
+ }
+ }
+
+ @Test
+ public void checkNonValidSystemQueryOption() throws Exception {
+ String[] uris = constructUri(urisWithNonValidSystemQueryOptions);
+
+ for (String uri : uris) {
+ try {
+ parseAndValidate(uri, "GET");
+ fail("Validation Exception not thrown: " + uri);
+ } catch (UriValidationException e) {
+ assertTrue(e instanceof UriValidationException);
+ }
+ }
+ }
+
+ private String[] constructUri(final String[][] uriParameterMatrix) {
+ ArrayList<String> uris = new ArrayList<String>();
+ for (String[] uriParameter : uriParameterMatrix) {
+ String uri = uriParameter[0];
+ if (uriParameter.length > 1) {
+ uri += "?";
+ }
+ for (int i = 1; i < uriParameter.length; i++) {
+ uri += uriParameter[i];
+ if (i < (uriParameter.length - 1)) {
+ uri += "&";
+ }
+ }
+ uris.add(uri);
+ }
+ return uris.toArray(new String[0]);
+ }
+
+ private void parseAndValidate(final String uri, String method) throws UriParserException, UriValidationException {
+ UriInfo uriInfo = parser.parseUri(uri.trim(), edm);
+ UriValidator validator = new UriValidator();
+
+ validator.validate(uriInfo, method);
+ }
+
+}
[05/15] [OLINGO-266] refactor ref module to server-ref
Posted by sk...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
new file mode 100644
index 0000000..702d559
--- /dev/null
+++ b/lib/server-ref/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
@@ -0,0 +1,5110 @@
+/*
+ * 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.antlr;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+
+import org.apache.olingo.commons.api.ODataApplicationException;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.core.Encoder;
+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.BinaryOperatorKind;
+import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
+import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
+import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
+import org.apache.olingo.server.core.testutil.EdmTechTestProvider;
+import org.apache.olingo.server.core.testutil.techprovider.ComplexTypeProvider;
+import org.apache.olingo.server.core.testutil.techprovider.EntityTypeProvider;
+import org.apache.olingo.server.core.testutil.techprovider.EnumTypeProvider;
+import org.apache.olingo.server.core.testutil.techprovider.PropertyProvider;
+import org.apache.olingo.server.core.uri.parser.UriParserException;
+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;
+import org.junit.Test;
+
+public class TestFullResourcePath {
+ Edm edm = null;
+ TestUriValidator testUri = null;
+ ResourceValidator testRes = null;
+ FilterValidator testFilter = null;
+
+ public TestFullResourcePath() {
+ edm = new EdmProviderImpl(new EdmTechTestProvider());
+ testUri = new TestUriValidator().setEdm(edm);
+ testRes = new ResourceValidator().setEdm(edm);
+ testFilter = new FilterValidator().setEdm(edm);
+ }
+
+ @Test
+ public void test() throws UriParserException {
+
+ }
+
+ @Test
+ public void testFunctionBound_varOverloading() {
+ // on ESTwoKeyNav
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()").goPath()
+ .at(0)
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETTwoKeyNav, true)
+ .at(1)
+ .isUriPathInfoKind(UriResourceKind.function)
+ .isType(EntityTypeProvider.nameETTwoKeyNav);
+
+ // with string parameter
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav(ParameterString='ABC')").goPath()
+ .at(0)
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETTwoKeyNav, true)
+ .at(1)
+ .isUriPathInfoKind(UriResourceKind.function)
+ .isType(EntityTypeProvider.nameETTwoKeyNav);
+
+ // with string parameter
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()").goPath()
+ .at(0)
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETTwoKeyNav, true)
+ .at(1)
+ .isUriPathInfoKind(UriResourceKind.function)
+ .isType(EntityTypeProvider.nameETTwoKeyNav);
+ }
+
+ @Test
+ public void runBfuncBnCpropCastRtEs() {
+
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
+ + "/PropertyComplex/com.sap.odata.test1.BFCCTPrimCompRTESBaseTwoKeyNav()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isComplex("PropertyComplex")
+ .isType(ComplexTypeProvider.nameCTPrimComp, false)
+ .n()
+ .isFunction("BFCCTPrimCompRTESBaseTwoKeyNav");
+
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
+ + "/PropertyComplex/com.sap.odata.test1.BFCCTPrimCompRTESBaseTwoKeyNav()/$count")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isComplex("PropertyComplex")
+ .isType(ComplexTypeProvider.nameCTPrimComp, false)
+ .n()
+ .isFunction("BFCCTPrimCompRTESBaseTwoKeyNav")
+ .isType(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isUriPathInfoKind(UriResourceKind.count);
+
+ }
+
+ @Test
+ public void runBfuncBnCpropCollRtEs() {
+ testUri.run("ESKeyNav(PropertyInt16=1)/CollPropertyComplex/com.sap.odata.test1.BFCCollCTPrimCompRTESAllPrim()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isUriPathInfoKind(UriResourceKind.complexProperty)
+ .isComplex("CollPropertyComplex")
+ .isType(ComplexTypeProvider.nameCTPrimComp, true)
+ .n()
+ .isFunction("BFCCollCTPrimCompRTESAllPrim");
+
+ testUri
+ .run("ESKeyNav(PropertyInt16=1)/CollPropertyComplex/com.sap.odata.test1.BFCCollCTPrimCompRTESAllPrim()/$count")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isUriPathInfoKind(UriResourceKind.complexProperty)
+ .isComplex("CollPropertyComplex")
+ .isType(ComplexTypeProvider.nameCTPrimComp, true)
+ .n()
+ .isFunction("BFCCollCTPrimCompRTESAllPrim")
+ .isType(EntityTypeProvider.nameETAllPrim, true)
+ .n()
+ .isUriPathInfoKind(UriResourceKind.count);
+ }
+
+ @Test
+ public void runBfuncBnCpropRtEs() {
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')"
+ + "/PropertyComplex/com.sap.odata.test1.BFCCTPrimCompRTESTwoKeyNav()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .n()
+ .isUriPathInfoKind(UriResourceKind.complexProperty)
+ .isComplex("PropertyComplex")
+ .isType(ComplexTypeProvider.nameCTPrimComp, false)
+ .n()
+ .isFunction("BFCCTPrimCompRTESTwoKeyNav");
+
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')"
+ + "/PropertyComplex/com.sap.odata.test1.BFCCTPrimCompRTESTwoKeyNav()/$count")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .n()
+ .isUriPathInfoKind(UriResourceKind.complexProperty)
+ .isComplex("PropertyComplex")
+ .isType(ComplexTypeProvider.nameCTPrimComp, false)
+ .n()
+ .isFunction("BFCCTPrimCompRTESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .n()
+ .isUriPathInfoKind(UriResourceKind.count);
+
+ }
+
+ @Test
+ public void runBfuncBnEntityRtEs() {
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.BFCETTwoKeyNavRTESTwoKeyNav()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .n()
+ .isFunction("BFCETTwoKeyNavRTESTwoKeyNav");
+ }
+
+ @Test
+ public void runBfuncBnEntityCastRtEs() {
+ testUri
+ .run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
+ + "/com.sap.odata.test1.BFCETBaseTwoKeyNavRTESTwoKeyNav()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isFunction("BFCETBaseTwoKeyNavRTESTwoKeyNav");
+
+ testUri
+ .run("ESTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=1,PropertyString='(''2'')')"
+ + "/com.sap.odata.test1.BFCETBaseTwoKeyNavRTESTwoKeyNav()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'(''2'')'")
+ .n()
+ .isFunction("BFCETBaseTwoKeyNavRTESTwoKeyNav");
+ }
+
+ @Test
+ public void runBfuncBnEsCastRtEs() {
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav"
+ + "/com.sap.odata.test1.BFCESBaseTwoKeyNavRTESBaseTwoKey()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, true)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isFunction("BFCESBaseTwoKeyNavRTESBaseTwoKey");
+
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav"
+ + "/com.sap.odata.test1.BFCESBaseTwoKeyNavRTESBaseTwoKey()"
+ + "/com.sap.odata.test1.ETTwoBaseTwoKeyNav")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, true)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isFunction("BFCESBaseTwoKeyNavRTESBaseTwoKey")
+ .isType(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETTwoBaseTwoKeyNav);
+
+ testUri.run("ESTwoKeyNav"
+ + "/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()"
+ + "/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=1,PropertyString='2')"
+ + "/com.sap.odata.test1.ETTwoBaseTwoKeyNav")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETTwoBaseTwoKeyNav);
+ }
+
+ @Test
+ public void runBfuncBnEsRtCprop() {
+ testUri.run("ESAllPrim/com.sap.odata.test1.BFCESAllPrimRTCTAllPrim()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESAllPrim")
+ .n()
+ .isFunction("BFCESAllPrimRTCTAllPrim")
+ .isType(ComplexTypeProvider.nameCTAllPrim);
+
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCTTwoPrim()/com.sap.odata.test1.CTBase")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTCTTwoPrim")
+ .isType(ComplexTypeProvider.nameCTTwoPrim, false)
+ .isTypeFilterOnEntry(ComplexTypeProvider.nameCTBase);
+ }
+
+ @Test
+ public void runBfuncBnEsRtCpropColl() {
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCollCTTwoPrim()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTCollCTTwoPrim")
+ .isType(ComplexTypeProvider.nameCTTwoPrim, true);
+
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCollCTTwoPrim()/$count")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTCollCTTwoPrim")
+ .isType(ComplexTypeProvider.nameCTTwoPrim, true)
+ .n()
+ .isUriPathInfoKind(UriResourceKind.count);
+ }
+
+ @Test
+ public void runBfuncBnEsRtEntityPpNp() {
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTTwoKeyNav()/NavPropertyETKeyNavOne")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTTwoKeyNav")
+ .n()
+ .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false);
+
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTTwoKeyNav()/NavPropertyETKeyNavOne/$ref")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTTwoKeyNav")
+ .n()
+ .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false)
+ .n()
+ .isUriPathInfoKind(UriResourceKind.ref);
+
+ testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNav()/NavPropertyETMediaOne/$value")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .n()
+ .isFunction("BFCESKeyNavRTETKeyNav")
+ .n()
+ .isNavProperty("NavPropertyETMediaOne", EntityTypeProvider.nameETMedia, false)
+ .n()
+ .isValue();
+
+ testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNavParam(ParameterString='1')"
+ + "/NavPropertyETTwoKeyNavOne")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .n()
+ .isFunction("BFCESKeyNavRTETKeyNavParam")
+ .isParameter(0, "ParameterString", "'1'")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false);
+
+ testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNavParam(ParameterString='1')"
+ + "/NavPropertyETTwoKeyNavOne/PropertyComplex")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .n()
+ .isFunction("BFCESKeyNavRTETKeyNavParam")
+ .isParameter(0, "ParameterString", "'1'")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
+ .n()
+ .isComplex("PropertyComplex")
+ .isType(ComplexTypeProvider.nameCTPrimComp);
+
+ testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNavParam(ParameterString='1')"
+ + "/NavPropertyETTwoKeyNavOne/PropertyComplex/PropertyComplex")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .n()
+ .isFunction("BFCESKeyNavRTETKeyNavParam")
+ .isParameter(0, "ParameterString", "'1'")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
+ .n()
+ .isComplex("PropertyComplex")
+ .isType(ComplexTypeProvider.nameCTPrimComp)
+ .n()
+ .isComplex("PropertyComplex")
+ .isType(ComplexTypeProvider.nameCTAllPrim);
+
+ testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNavParam(ParameterString='1')"
+ + "/NavPropertyETTwoKeyNavOne/PropertyString")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .n()
+ .isFunction("BFCESKeyNavRTETKeyNavParam")
+ .isParameter(0, "ParameterString", "'1'")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
+ .n()
+ .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
+
+ testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNavParam(ParameterString='1')"
+ + "/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')/PropertyString")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .n()
+ .isFunction("BFCESKeyNavRTETKeyNavParam")
+ .isParameter(0, "ParameterString", "'1'")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .isKeyPredicate(1, "PropertyString", "'3'")
+ .n()
+ .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
+ }
+
+ @Test
+ public void runBfuncBnEsRtEntyPpNpCast() {
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTTwoKeyNav()"
+ + "/NavPropertyETTwoKeyNavOne/com.sap.odata.test1.ETBaseTwoKeyNav")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTTwoKeyNav")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav);
+
+ testUri
+ .run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()(PropertyInt16=1,PropertyString='2')"
+ + "/NavPropertyETTwoKeyNavOne/com.sap.odata.test1.ETTwoBaseTwoKeyNav")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETTwoBaseTwoKeyNav);
+
+ }
+
+ @Test
+ public void runBfuncBnEsRtEntityPpCp() {
+
+ testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNav()/PropertyComplex")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .n()
+ .isFunction("BFCESKeyNavRTETKeyNav")
+ .n()
+ .isComplex("PropertyComplex")
+ .isType(ComplexTypeProvider.nameCTNavFiveProp);
+
+ testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNav()/PropertyComplex/PropertyInt16")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .n()
+ .isFunction("BFCESKeyNavRTETKeyNav")
+ .n()
+ .isComplex("PropertyComplex")
+ .isType(ComplexTypeProvider.nameCTNavFiveProp)
+ .n()
+ .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
+
+ testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNav()/PropertyComplex/PropertyInt16/$value")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .n()
+ .isFunction("BFCESKeyNavRTETKeyNav")
+ .n()
+ .isComplex("PropertyComplex")
+ .isType(ComplexTypeProvider.nameCTNavFiveProp)
+ .n()
+ .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false)
+ .n()
+ .isValue();
+
+ }
+
+ @Test
+ public void runBfuncBnEsRtEntyPpCpCast() {
+
+ testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNavParam(ParameterString='1')"
+ + "/PropertyComplexTwoPrim/com.sap.odata.test1.CTTwoBase")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .n()
+ .isFunction("BFCESKeyNavRTETKeyNavParam")
+ .isParameter(0, "ParameterString", "'1'")
+ .n()
+ .isComplex("PropertyComplexTwoPrim")
+ .isType(ComplexTypeProvider.nameCTTwoPrim)
+ .isTypeFilter(ComplexTypeProvider.nameCTTwoBase);
+
+ testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNavParam(ParameterString='1')"
+ + "/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')"
+ + "/PropertyComplexTwoPrim/com.sap.odata.test1.CTTwoBase")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .n()
+ .isFunction("BFCESKeyNavRTETKeyNavParam")
+ .isParameter(0, "ParameterString", "'1'")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .isKeyPredicate(1, "PropertyString", "'3'")
+ .n()
+ .isComplex("PropertyComplexTwoPrim")
+ .isType(ComplexTypeProvider.nameCTTwoPrim)
+ .isTypeFilter(ComplexTypeProvider.nameCTTwoBase);
+ }
+
+ @Test
+ public void runBfuncBnEsRtEntityPpSp() {
+ testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNav()/PropertyInt16")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .n()
+ .isFunction("BFCESKeyNavRTETKeyNav")
+ .n()
+ .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
+
+ testUri.run("ESKeyNav/com.sap.odata.test1.BFCESKeyNavRTETKeyNav()/PropertyInt16/$value")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .n()
+ .isFunction("BFCESKeyNavRTETKeyNav")
+ .n()
+ .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false)
+ .n()
+ .isValue();
+
+ }
+
+ @Test
+ public void runBfuncBnEsRtEs() {
+
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav);
+
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav(ParameterString='2')")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTESTwoKeyNav")
+ .isParameter(0, "ParameterString", "'2'")
+ .isType(EntityTypeProvider.nameETTwoKeyNav);
+
+ testUri.run("ESKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav);
+
+ testUri.run("ESKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav(ParameterString='3')")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTESTwoKeyNav")
+ .isParameter(0, "ParameterString", "'3'")
+ .isType(EntityTypeProvider.nameETTwoKeyNav);
+
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()/$count")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .n()
+ .isCount();
+
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()(PropertyInt16=1,PropertyString='2')")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTESTwoKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'");
+
+ }
+
+ @Test
+ public void runBfuncBnEsRtEsBa() {
+
+ testUri.run("ESKeyNav(PropertyInt16=1)/CollPropertyComplex"
+ + "/com.sap.odata.test1.BFCCollCTPrimCompRTESAllPrim()/com.sap.odata.test1.BAESAllPrimRTETAllPrim")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isComplex("CollPropertyComplex")
+ .isType(ComplexTypeProvider.nameCTPrimComp)
+ .n()
+ .isFunction("BFCCollCTPrimCompRTESAllPrim")
+ .n()
+ .isAction("BAESAllPrimRTETAllPrim");
+
+ }
+
+ @Test
+ public void runBfuncBnEsRtPrim() {
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTString()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTString");
+
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTString()/$value")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTString")
+ .isType(PropertyProvider.nameString)
+ .n()
+ .isValue();
+ }
+
+ @Test
+ public void runbfuncBnEsRtPrimColl() {
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCollString()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTCollString")
+ .isType(PropertyProvider.nameString, true);
+
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTCollString()/$count")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .n()
+ .isFunction("BFCESTwoKeyNavRTCollString")
+ .isType(PropertyProvider.nameString, true)
+ .n()
+ .isCount();
+ }
+
+ @Test
+ public void runBfuncBnPpropCollRtEs() {
+ testUri.run("ESKeyNav(1)/CollPropertyString/com.sap.odata.test1.BFCCollStringRTESTwoKeyNav()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isPrimitiveProperty("CollPropertyString", PropertyProvider.nameString, true)
+ .n()
+ .isFunction("BFCCollStringRTESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, true);
+
+ testUri.run("ESKeyNav(1)/CollPropertyString/com.sap.odata.test1.BFCCollStringRTESTwoKeyNav()/$count")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isPrimitiveProperty("CollPropertyString", PropertyProvider.nameString, true)
+ .n()
+ .isFunction("BFCCollStringRTESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, true)
+ .n()
+ .isCount();
+ }
+
+ @Test
+ public void runBfuncBnPpropRtEs() {
+
+ testUri.run("ESKeyNav(1)/PropertyString/com.sap.odata.test1.BFCStringRTESTwoKeyNav()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false)
+ .n()
+ .isFunction("BFCStringRTESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, true);
+
+ testUri.run("ESKeyNav(1)/PropertyString/com.sap.odata.test1.BFCStringRTESTwoKeyNav()/$count")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false)
+ .n()
+ .isFunction("BFCStringRTESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, true)
+ .n()
+ .isCount();
+
+ testUri.run("ESKeyNav(1)/PropertyString/com.sap.odata.test1.BFCStringRTESTwoKeyNav()/$ref")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false)
+ .n()
+ .isFunction("BFCStringRTESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, true)
+ .n()
+ .isRef();
+ }
+
+ @Test
+ public void runBfuncBnSingleRtEs() {
+
+ testUri.run("SINav/com.sap.odata.test1.BFCSINavRTESTwoKeyNav()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .n()
+ .isFunction("BFCSINavRTESTwoKeyNav");
+ }
+
+ @Test
+ public void runBfuncBnSingleCastRtEs() {
+ testUri.run("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/com.sap.odata.test1.BFCETBaseTwoKeyNavRTESBaseTwoKey()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .isTypeFilter(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isFunction("BFCETBaseTwoKeyNavRTESBaseTwoKey");
+ }
+
+ @Test
+ public void runActionBound_on_EntityEntry() {
+
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.BAETTwoKeyNavRTETTwoKeyNav")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .n()
+ .isAction("BAETTwoKeyNavRTETTwoKeyNav");
+
+ testUri.run("ESKeyNav(PropertyInt16=1)/com.sap.odata.test1.BAETTwoKeyNavRTETTwoKeyNav")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isAction("BAETTwoKeyNavRTETTwoKeyNav");
+ }
+
+ @Test
+ public void runActionBound_on_EntityCollection() {
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BAESTwoKeyNavRTESTwoKeyNav")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .n()
+ .isAction("BAESTwoKeyNavRTESTwoKeyNav");
+ }
+
+ @Test
+ public void runFunctionBound_on_var_Types() {
+
+ // on primitive
+ testUri.run("ESAllPrim(1)/PropertyString/com.sap.odata.test1.BFCStringRTESTwoKeyNav()")
+ .goPath()
+ .at(0)
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETAllPrim, false)
+ .at(1)
+ .isUriPathInfoKind(UriResourceKind.primitiveProperty)
+ .isType(PropertyProvider.nameString);
+
+ // on collection of primitive
+ testUri.run("ESCollAllPrim(1)/CollPropertyString/com.sap.odata.test1.BFCCollStringRTESTwoKeyNav()")
+ .goPath()
+ .at(0)
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETCollAllPrim, false)
+ .at(1)
+ .isUriPathInfoKind(UriResourceKind.primitiveProperty)
+ .isType(PropertyProvider.nameString);
+
+ // on complex
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='ABC')"
+ + "/PropertyComplex/com.sap.odata.test1.BFCCTPrimCompRTESTwoKeyNav()")
+ .goPath()
+ .at(0)
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .at(1)
+ .isUriPathInfoKind(UriResourceKind.complexProperty)
+ .at(2)
+ .isType(EntityTypeProvider.nameETTwoKeyNav);
+
+ // on collection of complex
+ testUri.run("ESKeyNav(1)/CollPropertyComplex/com.sap.odata.test1.BFCCollCTPrimCompRTESAllPrim()")
+ .goPath()
+ .at(0)
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .at(1)
+ .isType(ComplexTypeProvider.nameCTPrimComp, true)
+ .at(2)
+ .isUriPathInfoKind(UriResourceKind.function)
+ .isType(EntityTypeProvider.nameETAllPrim);
+
+ // on entity
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='ABC')"
+ + "/com.sap.odata.test1.BFCETTwoKeyNavRTESTwoKeyNav()")
+ .goPath()
+ .at(0)
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .at(1)
+ .isUriPathInfoKind(UriResourceKind.function)
+ .isType(EntityTypeProvider.nameETTwoKeyNav);
+
+ // on collection of entity
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()")
+ .goPath()
+ .at(0)
+ .isUriPathInfoKind(UriResourceKind.entitySet)
+ .isType(EntityTypeProvider.nameETTwoKeyNav, true)
+ .at(1).isUriPathInfoKind(UriResourceKind.function)
+ .isType(EntityTypeProvider.nameETTwoKeyNav);
+ }
+
+ @Test
+ public void runActionBound_on_EntityCast() {
+
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
+ + "/com.sap.odata.test1.BAETBaseTwoKeyNavRTETBaseTwoKeyNav")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isAction("BAETBaseTwoKeyNavRTETBaseTwoKeyNav");
+
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=1,PropertyString='2')"
+ + "/com.sap.odata.test1.ETTwoBaseTwoKeyNav/com.sap.odata.test1.BAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETTwoBaseTwoKeyNav)
+ .n()
+ .isAction("BAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav");
+ }
+
+ @Test
+ public void runCrossjoin() {
+ testUri.run("$crossjoin(ESKeyNav)")
+ .isKind(UriInfoKind.crossjoin)
+ .isCrossJoinEntityList(Arrays.asList("ESKeyNav"));
+
+ testUri.run("$crossjoin(ESKeyNav, ESTwoKeyNav)")
+ .isKind(UriInfoKind.crossjoin)
+ .isCrossJoinEntityList(Arrays.asList("ESKeyNav", "ESTwoKeyNav"));
+ }
+
+ @Test
+ public void runCrossjoinError() {
+ testUri.runEx("$crossjoin").isExSyntax(0);
+ testUri.runEx("$crossjoin/error").isExSyntax(0);
+ testUri.runEx("$crossjoin()").isExSyntax(0);
+ // testUri.runEx("$crossjoin(ESKeyNav, ESTwoKeyNav)/invalid").isExSyntax(0);
+ }
+
+ @Test
+ public void runEntityId() {
+ testUri.run("$entity?$id=ESKeyNav(1)")
+ .isKind(UriInfoKind.entityId)
+ .isIdText("ESKeyNav(1)");
+ testUri.run("$entity/com.sap.odata.test1.ETKeyNav?$id=ESKeyNav(1)")
+ .isKind(UriInfoKind.entityId)
+ .isEntityType(EntityTypeProvider.nameETKeyNav)
+ .isIdText("ESKeyNav(1)");
+ }
+
+ @Test
+ public void runEntityIdError() {
+ // TODO planned: move to validator
+ // testUri.runEx("$entity").isExSyntax(0);
+ // testUri.runEx("$entity?$idfalse=ESKeyNav(1)").isExSyntax(0);
+ // testUri.runEx("$entity/com.sap.odata.test1.invalidType?$id=ESKeyNav(1)").isExSemantic(0);
+ // testUri.runEx("$entity/invalid?$id=ESKeyNav(1)").isExSyntax(0);
+ }
+
+ @Test
+ public void runEsName() {
+ testUri.run("ESAllPrim")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESAllPrim")
+ .isType(EntityTypeProvider.nameETAllPrim, true);
+
+ testUri.run("ESAllPrim/$count")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESAllPrim")
+ .isType(EntityTypeProvider.nameETAllPrim, true)
+ .n()
+ .isCount();
+ }
+
+ @Test
+ public void runEsNameError() {
+
+ testUri.runEx("ESAllPrim/$count/$ref").isExSemantic(0);
+ testUri.runEx("ESAllPrim/$ref/$count").isExSemantic(0);
+ testUri.runEx("ESAllPrim/$ref/invalid").isExSemantic(0);
+ testUri.runEx("ESAllPrim/$count/invalid").isExSemantic(0);
+ testUri.runEx("ESAllPrim(1)/whatever").isExSemantic(0);
+ // testUri.runEx("ESAllPrim(PropertyInt16='1')").isExSemantic(0);
+ testUri.runEx("ESAllPrim(PropertyInt16)").isExSemantic(0);
+ testUri.runEx("ESAllPrim(PropertyInt16=)").isExSyntax(0);
+ testUri.runEx("ESAllPrim(PropertyInt16=1,Invalid='1')").isExSemantic(0);
+
+ testUri.runEx("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETBaseTwoKeyTwoPrim"
+ + "/com.sap.odata.test1.ETTwoBaseTwoKeyTwoPrim").isExSemantic(0);
+
+ testUri.runEx("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETBaseTwoKeyTwoPrim(1)/com.sap.odata.test1.ETAllKey")
+ .isExSemantic(0);
+
+ testUri.runEx("ETBaseTwoKeyTwoPrim(1)/com.sap.odata.test1.ETBaseTwoKeyTwoPrim('1')/com.sap.odata.test1.ETAllKey")
+ .isExSemantic(0);
+
+ testUri.runEx("ETBaseTwoKeyTwoPrim(1)/com.sap.odata.test1.ETBaseTwoKeyTwoPrim"
+ + "/com.sap.odata.test1.ETTwoBaseTwoKeyTwoPrim")
+ .isExSemantic(0);
+
+ testUri.runEx("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETBaseTwoKeyTwoPrim"
+ + "/com.sap.odata.test1.ETTwoBaseTwoKeyTwoPrim(1)")
+ .isExSemantic(0);
+
+ testUri.runEx("ETBaseTwoKeyTwoPrim/com.sap.odata.test1.ETAllKey")
+ .isExSemantic(0);
+
+ testUri.runEx("ETBaseTwoKeyTwoPrim()")
+ .isExSemantic(0);
+
+ testUri.runEx("ESAllNullable(1)/CollPropertyString/$value")
+ .isExSemantic(0);
+
+ testUri.runEx("ETMixPrimCollComp(1)/ComplexProperty/$value").isExSemantic(0);
+ }
+
+ @Test
+ public void runEsNameCast() {
+ testUri.run("ESTwoPrim/com.sap.odata.test1.ETBase")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoPrim")
+ .isType(EntityTypeProvider.nameETTwoPrim, true)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBase);
+
+ testUri.run("ESTwoPrim/com.sap.odata.test1.ETBase(-32768)/com.sap.odata.test1.ETTwoBase")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoPrim")
+ .isType(EntityTypeProvider.nameETTwoPrim, false)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBase)
+ .isKeyPredicate(0, "PropertyInt16", "-32768")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETTwoBase);
+
+ testUri.run("ESTwoPrim/com.sap.odata.test1.ETTwoBase(-32768)")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoPrim")
+ .isType(EntityTypeProvider.nameETTwoPrim, false)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETTwoBase)
+ .isKeyPredicate(0, "PropertyInt16", "-32768");
+
+ testUri.run("ESTwoPrim/Namespace1_Alias.ETTwoBase(-32768)")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoPrim")
+ .isType(EntityTypeProvider.nameETTwoPrim, false)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETTwoBase)
+ .isKeyPredicate(0, "PropertyInt16", "-32768");
+
+ }
+
+ @Test
+ public void runEsNamePpSpCast() {
+
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isPrimitiveProperty("PropertyDate", PropertyProvider.nameDate, false);
+
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
+ + "/PropertyComplex/PropertyInt16")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isComplex("PropertyComplex")
+ .n()
+ .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
+ }
+
+ @Test
+ public void runEsNameKey() {
+ testUri.run("ESCollAllPrim(1)")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESCollAllPrim");
+
+ testUri.run("ESCollAllPrim(PropertyInt16=1)")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESCollAllPrim");
+
+ testUri.run("ESFourKeyAlias(PropertyInt16=1,KeyAlias1=2,KeyAlias2='3',KeyAlias3='4')")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESFourKeyAlias")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "KeyAlias1", "2")
+ .isKeyPredicate(2, "KeyAlias2", "'3'")
+ .isKeyPredicate(3, "KeyAlias3", "'4'");
+
+ testUri.run("ESCollAllPrim(null)")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESCollAllPrim");
+ }
+
+ @Test
+ public void runEsNameParaKeys() throws UnsupportedEncodingException {
+ testUri.run(encode("ESAllKey(PropertyString='O''Neil',PropertyBoolean=true,PropertyByte=255,"
+ + "PropertySByte=-128,PropertyInt16=-32768,PropertyInt32=-2147483648,"
+ + "PropertyInt64=-9223372036854775808,PropertyDecimal=0.1,PropertyDate=2013-09-25,"
+ + "PropertyDateTimeOffset=2002-10-10T12:00:00-05:00,"
+ + "PropertyDuration=duration'P10DT5H34M21.123456789012S',"
+ + "PropertyGuid=12345678-1234-1234-1234-123456789012,"
+ + "PropertyTimeOfDay=12:34:55.123456789012)"))
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESAllKey")
+ .isKeyPredicate(0, "PropertyString", "'O''Neil'")
+ .isKeyPredicate(1, "PropertyBoolean", "true")
+ .isKeyPredicate(2, "PropertyByte", "255")
+ .isKeyPredicate(3, "PropertySByte", "-128")
+ .isKeyPredicate(4, "PropertyInt16", "-32768")
+ .isKeyPredicate(5, "PropertyInt32", "-2147483648")
+ .isKeyPredicate(6, "PropertyInt64", "-9223372036854775808")
+ .isKeyPredicate(7, "PropertyDecimal", "0.1")
+ .isKeyPredicate(8, "PropertyDate", "2013-09-25")
+ .isKeyPredicate(9, "PropertyDateTimeOffset", "2002-10-10T12:00:00-05:00")
+ .isKeyPredicate(10, "PropertyDuration", "duration'P10DT5H34M21.123456789012S'")
+ .isKeyPredicate(11, "PropertyGuid", "12345678-1234-1234-1234-123456789012")
+ .isKeyPredicate(12, "PropertyTimeOfDay", "12:34:55.123456789012");
+ }
+
+ @Test
+ public void runEsNameKeyCast() {
+ /*
+ * testUri.runEx("ESTwoPrim(1)/com.sap.odata.test1.ETBase(1)")
+ * .isExSemantic(0);
+ *
+ * testUri.runEx("ESTwoPrim/com.sap.odata.test1.ETBase(1)/com.sap.odata.test1.ETTwoBase(1)")
+ * .isExSemantic(0);
+ *
+ * testUri.runEx("ESBase/com.sap.odata.test1.ETTwoPrim(1)")
+ * .isExSemantic(0);
+ */
+
+ testUri.run("ESTwoPrim(1)/com.sap.odata.test1.ETBase")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoPrim")
+ .isType(EntityTypeProvider.nameETTwoPrim)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBase);
+
+ testUri.run("ESTwoPrim(1)/com.sap.odata.test1.ETTwoBase")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoPrim")
+ .isType(EntityTypeProvider.nameETTwoPrim)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETTwoBase);
+
+ testUri.run("ESTwoPrim/com.sap.odata.test1.ETBase(1)")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoPrim")
+ .isType(EntityTypeProvider.nameETTwoPrim)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBase);
+
+ testUri.run("ESTwoPrim/com.sap.odata.test1.ETTwoBase(1)")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoPrim")
+ .isType(EntityTypeProvider.nameETTwoPrim)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETTwoBase);
+
+ testUri.run("ESTwoPrim/com.sap.odata.test1.ETBase(1)/com.sap.odata.test1.ETTwoBase")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoPrim")
+ .isType(EntityTypeProvider.nameETTwoPrim)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBase);
+
+ testUri.run("ESTwoPrim/com.sap.odata.test1.ETTwoBase")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoPrim")
+ .isType(EntityTypeProvider.nameETTwoPrim)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETTwoBase);
+ }
+
+ @Test
+ public void runEsNameParaKeysCast() {
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav);
+
+ testUri.run("ESTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=1,PropertyString='2')")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'");
+ }
+
+ @Test
+ public void run_EsNamePpCp() {
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyComplex")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .n()
+ .isComplex("PropertyComplex");
+
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyComplex/PropertyComplex")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .n()
+ .isComplex("PropertyComplex")
+ .n()
+ .isComplex("PropertyComplex");
+ }
+
+ @Test
+ public void runEsNamePpCpColl() {
+ testUri.run("ESMixPrimCollComp(5)/CollPropertyComplex")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESMixPrimCollComp")
+ .isKeyPredicate(0, "PropertyInt16", "5")
+ .n()
+ .isComplex("CollPropertyComplex")
+ .isType(ComplexTypeProvider.nameCTTwoPrim, true);
+
+ testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne/CollPropertyComplex")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
+ .n()
+ .isComplex("CollPropertyComplex")
+ .isType(ComplexTypeProvider.nameCTPrimComp, true);
+
+ testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavOne/CollPropertyComplex/$count")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false)
+ .n()
+ .isComplex("CollPropertyComplex")
+ .isType(ComplexTypeProvider.nameCTPrimComp, true)
+ .n()
+ .isCount();
+ }
+
+ @Test
+ public void runEsNamePpCpCast() {
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyComplex")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isComplex("PropertyComplex");
+
+ testUri
+ .run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
+ + "/PropertyComplex/PropertyComplex")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .n()
+ .isComplex("PropertyComplex")
+ .n()
+ .isComplex("PropertyComplex");
+
+ testUri
+ .run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
+ + "/PropertyComplexTwoPrim/com.sap.odata.test1.CTBase")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isComplex("PropertyComplexTwoPrim")
+ .isType(ComplexTypeProvider.nameCTTwoPrim)
+ .isTypeFilter(ComplexTypeProvider.nameCTBase);
+
+ testUri
+ .run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
+ + "/PropertyComplexTwoPrim/com.sap.odata.test1.CTTwoBase")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isComplex("PropertyComplexTwoPrim")
+ .isType(ComplexTypeProvider.nameCTTwoPrim)
+ .isTypeFilter(ComplexTypeProvider.nameCTTwoBase);
+ }
+
+ @Test
+ public void runNsNamePpNp() {
+ testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, true);
+
+ testUri.run("ESKeyNav(1)/NavPropertyETKeyNavMany(2)")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "2");
+
+ testUri.run("ESKeyNav(PropertyInt16=1)/NavPropertyETKeyNavMany(PropertyInt16=2)")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "2");
+
+ testUri.run("ESKeyNav(1)/NavPropertyETKeyNavMany(2)/PropertyInt16")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .n()
+ .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
+
+ testUri.run("ESKeyNav(1)/NavPropertyETKeyNavMany(2)/PropertyComplex")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .n()
+ .isComplex("PropertyComplex");
+
+ testUri.run("ESKeyNav(1)/NavPropertyETKeyNavMany(2)/NavPropertyETKeyNavOne")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .n()
+ .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false);
+
+ testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')"
+ + "/NavPropertyETKeyNavMany(4)")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .isKeyPredicate(1, "PropertyString", "'3'")
+ .n()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "4");
+
+ testUri.run("ESKeyNav(1)/PropertyComplex/NavPropertyETTwoKeyNavOne")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isComplex("PropertyComplex")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavOne", EntityTypeProvider.nameETTwoKeyNav, false);
+
+ testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='(3)')"
+ + "/PropertyComplex/PropertyComplex/PropertyInt16")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .isKeyPredicate(1, "PropertyString", "'(3)'")
+ .n()
+ .isComplex("PropertyComplex")
+ .n()
+ .isComplex("PropertyComplex")
+ .n()
+ .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
+
+ testUri.run("ESKeyNav(1)/NavPropertyETMediaMany(2)/$value")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETMediaMany", EntityTypeProvider.nameETMedia, false)
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .n()
+ .isValue();
+
+ testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')"
+ + "/NavPropertyETKeyNavOne/NavPropertyETMediaOne/$value")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .isKeyPredicate(1, "PropertyString", "'3'")
+ .n()
+ .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false)
+ .n()
+ .isNavProperty("NavPropertyETMediaOne", EntityTypeProvider.nameETMedia, false)
+ .n()
+ .isValue();
+
+ testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')"
+ + "/NavPropertyETKeyNavOne/$ref")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .isKeyPredicate(1, "PropertyString", "'3'")
+ .n()
+ .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false)
+ .n()
+ .isRef();
+ }
+
+ @Test
+ public void runEsNamePpNpCast() {
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
+ + "/NavPropertyETKeyNavMany")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true);
+
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
+ + "/NavPropertyETKeyNavMany(3)")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "3");
+
+ testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"
+ + "/NavPropertyETTwoKeyNavMany/com.sap.odata.test1.ETTwoBaseTwoKeyNav(PropertyInt16=3,PropertyString='4')")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESTwoKeyNav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "3")
+ .isKeyPredicate(1, "PropertyString", "'4'")
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETTwoBaseTwoKeyNav);
+
+ testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')"
+ + "/NavPropertyETTwoKeyNavMany/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=4,PropertyString='5')"
+ + "/com.sap.odata.test1.ETTwoBaseTwoKeyNav/NavPropertyETBaseTwoKeyNavMany")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .isKeyPredicate(1, "PropertyString", "'3'")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "4")
+ .isKeyPredicate(1, "PropertyString", "'5'")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETTwoBaseTwoKeyNav)
+ .n()
+ .isNavProperty("NavPropertyETBaseTwoKeyNavMany", EntityTypeProvider.nameETBaseTwoKeyNav, true);
+
+ testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')/"
+ + "NavPropertyETTwoKeyNavMany/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=4,PropertyString='5')/"
+ + "NavPropertyETKeyNavMany")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .isKeyPredicate(1, "PropertyString", "'3'")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "4")
+ .isKeyPredicate(1, "PropertyString", "'5'")
+ .n()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true);
+ }
+
+ @Test
+ public void runEsNamePpNpRc() {
+ // checks for using referential constrains to fill missing keys
+ testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany('2')").goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicateRef(0, "PropertyInt16", "PropertyInt16")
+ .isKeyPredicate(1, "PropertyString", "'2'");
+
+ testUri.run("ESKeyNav(PropertyInt16=1)/NavPropertyETTwoKeyNavMany(PropertyString='2')").goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicateRef(0, "PropertyInt16", "PropertyInt16")
+ .isKeyPredicate(1, "PropertyString", "'2'");
+
+ }
+
+ @Test
+ public void runEsNamePpSp() {
+ testUri.run("ESAllPrim(1)/PropertyByte")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESAllPrim")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isPrimitiveProperty("PropertyByte", PropertyProvider.nameByte, false);
+
+ testUri.run("ESAllPrim(1)/PropertyByte/$value")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESAllPrim")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isPrimitiveProperty("PropertyByte", PropertyProvider.nameByte, false)
+ .n()
+ .isValue();
+
+ testUri.run("ESMixPrimCollComp(1)/PropertyComplex/PropertyString")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESMixPrimCollComp")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isComplex("PropertyComplex")
+ .n()
+ .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
+ }
+
+ @Test
+ public void runEsNamePpSpColl() {
+ testUri.run("ESCollAllPrim(1)/CollPropertyString")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESCollAllPrim")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isPrimitiveProperty("CollPropertyString", PropertyProvider.nameString, true);
+
+ testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')/CollPropertyString")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .n()
+ .isPrimitiveProperty("CollPropertyString", PropertyProvider.nameString, true);
+
+ testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=2,PropertyString='3')/CollPropertyString/$count")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .isKeyPredicate(1, "PropertyString", "'3'")
+ .n()
+ .isPrimitiveProperty("CollPropertyString", PropertyProvider.nameString, true)
+ .n()
+ .isCount();
+
+ }
+
+ @Test
+ public void runEsNameRef() {
+ testUri.run("ESAllPrim/$ref")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESAllPrim")
+ .n()
+ .isRef();
+
+ testUri.run("ESAllPrim(-32768)/$ref")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESAllPrim")
+ .isKeyPredicate(0, "PropertyInt16", "-32768")
+ .n()
+ .isRef();
+ testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany/$ref")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, true)
+ .n()
+ .isRef();
+ testUri.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=1,PropertyString='2')/$ref")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isEntitySet("ESKeyNav")
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'")
+ .n()
+ .isRef();
+ }
+
+ @Test
+ public void runFunctionImpBf() {
+
+ testUri.run("FICRTString()/com.sap.odata.test1.BFCStringRTESTwoKeyNav()");
+ }
+
+ @Test
+ public void runFunctionImpCastBf() {
+
+ testUri.run("FICRTETTwoKeyNavParam(ParameterInt16=1)/com.sap.odata.test1.ETBaseTwoKeyNav"
+ + "/com.sap.odata.test1.BFCETBaseTwoKeyNavRTETTwoKeyNav()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FICRTETTwoKeyNavParam")
+ .isFunction("UFCRTETTwoKeyNavParam")
+ .isParameter(0, "ParameterInt16", "1")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isFunction("BFCETBaseTwoKeyNavRTETTwoKeyNav");
+
+ testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)"
+ + "/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=2,PropertyString='3')"
+ + "/com.sap.odata.test1.BFCETBaseTwoKeyNavRTETTwoKeyNav()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FICRTESTwoKeyNavParam")
+ .isFunction("UFCRTESTwoKeyNavParam")
+ .isParameter(0, "ParameterInt16", "1")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .isKeyPredicate(1, "PropertyString", "'3'")
+ .n()
+ .isFunction("BFCETBaseTwoKeyNavRTETTwoKeyNav");
+ }
+
+ @Test
+ public void runFunctionImpEntity() {
+
+ testUri.run("FICRTETKeyNav()")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FICRTETKeyNav")
+ .isFunction("UFCRTETKeyNav")
+ .isType(EntityTypeProvider.nameETKeyNav);
+
+ testUri.run("FICRTETTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=2,PropertyString='3')")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FICRTETTwoKeyNavParam")
+ .isParameter(0, "ParameterInt16", "1")
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .isKeyPredicate(1, "PropertyString", "'3'");
+
+ testUri.run("FICRTETMedia()/$value")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FICRTETMedia")
+ .isFunction("UFCRTETMedia")
+ .n()
+ .isValue();
+
+ testUri.run("FICRTETKeyNav()/$ref")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FICRTETKeyNav")
+ .isFunction("UFCRTETKeyNav")
+ .n()
+ .isRef();
+ testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)/$ref")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FICRTESTwoKeyNavParam")
+ .isFunction("UFCRTESTwoKeyNavParam")
+ .n()
+ .isRef();
+
+ testUri.run("FICRTETTwoKeyNavParam(ParameterInt16=1)/com.sap.odata.test1.ETBaseTwoKeyNav")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FICRTETTwoKeyNavParam")
+ .isFunction("UFCRTETTwoKeyNavParam")
+ .isParameter(0, "ParameterInt16", "1")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav);
+
+ testUri.run("FICRTETTwoKeyNavParam(ParameterInt16=1)(PropertyInt16=2,PropertyString='3')"
+ + "/com.sap.odata.test1.ETBaseTwoKeyNav")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FICRTETTwoKeyNavParam")
+ .isFunction("UFCRTETTwoKeyNavParam")
+ .isParameter(0, "ParameterInt16", "1")
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .isKeyPredicate(1, "PropertyString", "'3'")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav);
+
+ testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)"
+ + "/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=2,PropertyString='3')")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FICRTESTwoKeyNavParam")
+ .isFunction("UFCRTESTwoKeyNavParam")
+ .isParameter(0, "ParameterInt16", "1")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .isKeyPredicate(1, "PropertyString", "'3'");
+ }
+
+ @Test
+ public void runFunctionImpEs() {
+ /**/
+ testUri.run("FICRTESMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='2')")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FICRTESMixPrimCollCompTwoParam")
+ .isFunction("UFCRTESMixPrimCollCompTwoParam")
+ .isParameter(0, "ParameterInt16", "1")
+ .isParameter(1, "ParameterString", "'2'")
+ .isType(EntityTypeProvider.nameETMixPrimCollComp);
+
+ testUri.run("FINRTESMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='2')")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FINRTESMixPrimCollCompTwoParam")
+ .isFunction("UFNRTESMixPrimCollCompTwoParam")
+ .isParameter(0, "ParameterInt16", "1")
+ .isParameter(1, "ParameterString", "'2'")
+ .isType(EntityTypeProvider.nameETMixPrimCollComp);
+
+ testUri.run("FICRTESMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='2')/$count")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FICRTESMixPrimCollCompTwoParam")
+ .isFunction("UFCRTESMixPrimCollCompTwoParam")
+ .isParameter(0, "ParameterInt16", "1")
+ .isParameter(1, "ParameterString", "'2'")
+ .isType(EntityTypeProvider.nameETMixPrimCollComp)
+ .n()
+ .isCount();
+ }
+
+ @Test
+ public void runFunctionImpError() {
+ testUri.runEx("FICRTCollCTTwoPrimParam()").isExSemantic(0);
+ testUri.runEx("FICRTCollCTTwoPrimParam(invalidParam=2)").isExSemantic(0);
+ }
+
+ @Test
+ public void runFunctionImpEsAlias() {
+
+ testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=@parameterAlias)?@parameterAlias=1");
+ testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=@parameterAlias)/$count?@parameterAlias=1");
+ testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=@invalidAlias)?@validAlias=1");
+ }
+
+ @Test
+ public void runFunctionImpEsCast() {
+
+ testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)/com.sap.odata.test1.ETBaseTwoKeyNav")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FICRTESTwoKeyNavParam")
+ .isFunction("UFCRTESTwoKeyNavParam")
+ .isParameter(0, "ParameterInt16", "1")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav);
+
+ testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)/com.sap.odata.test1.ETBaseTwoKeyNav/$count")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FICRTESTwoKeyNavParam")
+ .isFunction("UFCRTESTwoKeyNavParam")
+ .isParameter(0, "ParameterInt16", "1")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isCount();
+
+ testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)"
+ + "/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=2,PropertyString='3')")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FICRTESTwoKeyNavParam")
+ .isFunction("UFCRTESTwoKeyNavParam")
+ .isParameter(0, "ParameterInt16", "1")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .isKeyPredicate(1, "PropertyString", "'3'");
+
+ testUri.run("FICRTESTwoKeyNavParam(ParameterInt16=1)"
+ + "/com.sap.odata.test1.ETBaseTwoKeyNav(PropertyInt16=2,PropertyString='3')"
+ + "/com.sap.odata.test1.ETTwoBaseTwoKeyNav")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isFunctionImport("FICRTESTwoKeyNavParam")
+ .isFunction("UFCRTESTwoKeyNavParam")
+ .isParameter(0, "ParameterInt16", "1")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilterOnCollection(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .isKeyPredicate(0, "PropertyInt16", "2")
+ .isKeyPredicate(1, "PropertyString", "'3'")
+ .isTypeFilterOnEntry(EntityTypeProvider.nameETTwoBaseTwoKeyNav);
+
+ }
+
+ @Test
+ public void runSingletonEntityValue() {
+ testUri.run("SIMedia/$value")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SIMedia")
+ .n().isValue();
+ }
+
+ @Test
+ public void runSingletonPpNpCast() {
+ testUri.run("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/NavPropertyETKeyNavMany")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilter(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true);
+
+ testUri.run("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/NavPropertyETKeyNavMany(1)")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilter(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1");
+
+ }
+
+ @Test
+ public void runSingletonPpCpCast() {
+ testUri.run("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyComplex")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilter(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isComplex("PropertyComplex");
+
+ testUri.run("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyComplex/PropertyComplex")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilter(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isComplex("PropertyComplex")
+ .n()
+ .isComplex("PropertyComplex");
+
+ testUri.run("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyComplexTwoPrim/com.sap.odata.test1.CTBase")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilter(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isComplex("PropertyComplexTwoPrim")
+ .isType(ComplexTypeProvider.nameCTTwoPrim)
+ .isTypeFilter(ComplexTypeProvider.nameCTBase);
+
+ }
+
+ @Test
+ public void runSingletonPpSpCast() {
+ testUri.run("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/PropertyInt16")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilter(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
+
+ testUri.run("SINav/com.sap.odata.test1.ETBaseTwoKeyNav/CollPropertyString")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .isType(EntityTypeProvider.nameETTwoKeyNav)
+ .isTypeFilter(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .n()
+ .isPrimitiveProperty("CollPropertyString", PropertyProvider.nameString, true)
+ .isType(PropertyProvider.nameString, true);
+
+ }
+
+ @Test
+ public void runSingletonEntityPpNp() {
+ testUri.run("SINav/NavPropertyETKeyNavMany")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .n()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true);
+
+ testUri.run("SINav/NavPropertyETTwoKeyNavMany(PropertyInt16=1,PropertyString='2')")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .n()
+ .isNavProperty("NavPropertyETTwoKeyNavMany", EntityTypeProvider.nameETTwoKeyNav, false)
+ .isKeyPredicate(0, "PropertyInt16", "1")
+ .isKeyPredicate(1, "PropertyString", "'2'");
+
+ }
+
+ @Test
+ public void runSingletonEntityPpCp() {
+ testUri.run("SINav/PropertyComplex")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .n()
+ .isComplex("PropertyComplex");
+
+ testUri.run("SINav/PropertyComplex/PropertyComplex")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .n()
+ .isComplex("PropertyComplex")
+ .n()
+ .isComplex("PropertyComplex");
+
+ }
+
+ @Test
+ public void runSingletonEntityPpCpColl() {
+ testUri.run("SINav/CollPropertyComplex")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .n()
+ .isComplex("CollPropertyComplex")
+ .isType(ComplexTypeProvider.nameCTPrimComp, true);
+
+ testUri.run("SINav/CollPropertyComplex/$count")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .n()
+ .isComplex("CollPropertyComplex")
+ .isType(ComplexTypeProvider.nameCTPrimComp, true)
+ .n()
+ .isCount();
+ }
+
+ @Test
+ public void runSingletonEntityPpSp() {
+ testUri.run("SINav/PropertyString")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .n()
+ .isPrimitiveProperty("PropertyString", PropertyProvider.nameString, false);
+ }
+
+ @Test
+ public void runSingletonEntityPpSpColl() {
+ testUri.run("SINav/CollPropertyString")
+
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .n()
+ .isPrimitiveProperty("CollPropertyString", PropertyProvider.nameString, true);
+ testUri.run("SINav/CollPropertyString/$count")
+ .isKind(UriInfoKind.resource).goPath()
+ .first()
+ .isSingleton("SINav")
+ .n()
+ .isPrimitiveProperty("CollPropertyString", PropertyProvider.nameString, true)
+ .n()
+ .isCount();
+ }
+
+ @Test
+ public void runExpand() {
+
+ testUri.run("ESKeyNav(1)?$expand=*")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .isSegmentStar(0);
+
+ testUri.run("ESKeyNav(1)?$expand=*/$ref")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .isSegmentStar(0)
+ .isSegmentRef(1);
+
+ testUri.run("ESKeyNav(1)?$expand=*/$ref,NavPropertyETKeyNavMany")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .isSegmentStar(0).isSegmentRef(1)
+ .next()
+ .goPath().first()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true);
+
+ testUri.run("ESKeyNav(1)?$expand=*($levels=3)")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .isSegmentStar(0)
+ .isLevelText("3");
+
+ testUri.run("ESKeyNav(1)?$expand=*($levels=max)")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .isSegmentStar(0)
+ .isLevelText("max");
+
+ testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .goPath().first()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
+ .isType(EntityTypeProvider.nameETKeyNav, true)
+ .n().isRef();
+
+ testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavOne/$ref")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .goPath().first()
+ .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false)
+ .isType(EntityTypeProvider.nameETKeyNav, false)
+ .n().isRef();
+
+ testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($filter=PropertyInt16 eq 1)")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .goPath().first()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
+ .isType(EntityTypeProvider.nameETKeyNav, true)
+ .n().isRef()
+ .goUpExpandValidator().isFilterSerialized("<<PropertyInt16> eq <1>>");
+
+ testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($orderby=PropertyInt16)")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .goPath().first()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
+ .isType(EntityTypeProvider.nameETKeyNav, true)
+ .n().isRef()
+ .goUpExpandValidator()
+ .isSortOrder(0, false)
+ .goOrder(0).goPath().isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
+
+ testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($skip=1)")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .goPath().first()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
+ .isType(EntityTypeProvider.nameETKeyNav, true)
+ .n().isRef()
+ .goUpExpandValidator()
+ .isSkipText("1");
+
+ testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($top=2)")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .goPath().first()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
+ .isType(EntityTypeProvider.nameETKeyNav, true)
+ .n().isRef()
+ .goUpExpandValidator()
+ .isTopText("2");
+
+ testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($count=true)")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .goPath().first()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
+ .isType(EntityTypeProvider.nameETKeyNav, true)
+ .n().isRef()
+ .goUpExpandValidator()
+ .isInlineCountText("true");
+
+ testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($skip=1;$top=3)")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .goPath().first()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
+ .isType(EntityTypeProvider.nameETKeyNav, true)
+ .n().isRef()
+ .goUpExpandValidator()
+ .isSkipText("1")
+ .isTopText("3");
+
+ testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($skip=1%3b$top=3)")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .goPath().first()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
+ .isType(EntityTypeProvider.nameETKeyNav, true)
+ .n().isRef()
+ .goUpExpandValidator()
+ .isSkipText("1")
+ .isTopText("3");
+
+ testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$count")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .goPath().first()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
+ .isType(EntityTypeProvider.nameETKeyNav, true)
+ .n().isCount();
+
+ testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavOne/$count")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .goPath().first()
+ .isNavProperty("NavPropertyETKeyNavOne", EntityTypeProvider.nameETKeyNav, false)
+ .isType(EntityTypeProvider.nameETKeyNav, false)
+ .n().isCount();
+
+ testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$count($filter=PropertyInt16 gt 1)")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .goPath().first()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
+ .isType(EntityTypeProvider.nameETKeyNav, true)
+ .n().isCount()
+ .goUpExpandValidator()
+ .isFilterSerialized("<<PropertyInt16> gt <1>>");
+
+ testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($filter=PropertyInt16 eq 1)")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .goPath().first()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
+ .isType(EntityTypeProvider.nameETKeyNav, true)
+ .goUpExpandValidator()
+ .isFilterSerialized("<<PropertyInt16> eq <1>>");
+
+ testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($orderby=PropertyInt16)")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .goPath().first()
+ .isNavProperty("NavPropertyETKeyNavMany", EntityTypeProvider.nameETKeyNav, true)
+ .isType(EntityTypeProvider.nameETKeyNav, true)
+ .goUpExpandValidator()
+ .isSortOrder(0, false)
+ .goOrder(0).goPath().isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
+
+ testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($skip=1)")
+ .isKind(UriInfoKind.resource).goPath().goExpand()
+ .first()
+ .goPath().first()
+ .
<TRUNCATED>
[09/15] [OLINGO-266] refactor ref module to server-ref
Posted by sk...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/UriLexerWithTrace.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/UriLexerWithTrace.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/UriLexerWithTrace.java
deleted file mode 100644
index 9005080..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/testutil/UriLexerWithTrace.java
+++ /dev/null
@@ -1,85 +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 org.antlr.v4.runtime.ANTLRInputStream;
-import org.antlr.v4.runtime.Token;
-import org.apache.olingo.server.core.uri.antlr.UriLexer;
-
-public class UriLexerWithTrace extends UriLexer {
- int logLevel = 0;
-
- public UriLexerWithTrace(final ANTLRInputStream antlrInputStream, final int logLevel) {
- super(antlrInputStream);
- this.logLevel = logLevel;
- }
-
- public UriLexerWithTrace(final ANTLRInputStream antlrInputStream, final int logLevel, final int mode) {
- super(antlrInputStream);
- super.mode(mode);
- this.logLevel = logLevel;
- }
-
- @Override
- public void emit(final Token token) {
- if (logLevel > 1) {
- String out = String.format("%1$-" + 20 + "s", token.getText());
-
- int tokenType = token.getType();
- if (tokenType == -1) {
- out += "-1/EOF";
- } else {
- out += UriLexer.tokenNames[tokenType];
- }
- System.out.println("Lexer.emit(...):" + out);
- }
-
- super.emit(token);
- }
-
- @Override
- public void pushMode(final int m) {
-
- String out = UriLexer.modeNames[_mode] + "-->";
-
- super.pushMode(m);
-
- out += UriLexer.modeNames[_mode];
-
- if (logLevel > 1) {
- System.out.println(out + " ");
- }
- }
-
- @Override
- public int popMode() {
-
- String out = UriLexer.modeNames[_mode] + "-->";
-
- int m = super.popMode();
-
- out += UriLexer.modeNames[_mode];
-
- if (logLevel > 1) {
- System.out.println(out + " ");
- }
-
- return m;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/ref/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
----------------------------------------------------------------------
diff --git a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java b/lib/ref/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
deleted file mode 100644
index 0374b25..0000000
--- a/lib/ref/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
+++ /dev/null
@@ -1,378 +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.validator;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.server.api.uri.UriInfo;
-import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
-import org.apache.olingo.server.core.testutil.techprovider.EdmTechProvider;
-import org.apache.olingo.server.core.uri.parser.Parser;
-import org.apache.olingo.server.core.uri.parser.UriParserException;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class UriValidatorTest {
-
- private static final String URI_ALL = "$all";
- private static final String URI_BATCH = "$batch";
- private static final String URI_CROSSJOIN = "$crossjoin(ESAllPrim)";
- private static final String URI_ENTITY_ID = "/$entity";
- private static final String URI_METADATA = "$metadata";
- private static final String URI_SERVICE = "";
- private static final String URI_ENTITY_SET = "/ESAllPrim";
- private static final String URI_ENTITY_SET_COUNT = "/ESAllPrim/$count";
- private static final String URI_ENTITY = "/ESAllPrim(1)";
- private static final String URI_MEDIA_STREAM = "/ESMedia(1)/$value";
- private static final String URI_REFERENCES = "/ESAllPrim/$ref";
- private static final String URI_REFERENCE = "/ESAllPrim(1)/$ref";
- private static final String URI_PROPERTY_COMPLEX = "/ESCompComp(1)/PropertyComplex";
- private static final String URI_PROPERTY_COMPLEX_COLLECTION =
- "/ESCompCollComp(1)/PropertyComplex/CollPropertyComplex";
- private static final String URI_PROPERTY_COMPLEX_COLLECTION_COUNT =
- "/ESCompCollComp(1)/PropertyComplex/CollPropertyComplex/$count";
- private static final String URI_PROPERTY_PRIMITIVE = "/ESAllPrim(1)/PropertyString";
- private static final String URI_PROPERTY_PRIMITIVE_COLLECTION = "/ESCollAllPrim/CollPropertyString";
- private static final String URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT =
- "/ESCollAllPrim/CollPropertyString/$count";
- private static final String URI_PROPERTY_PRIMITIVE_VALUE = "/ESAllPrim(1)/PropertyString/$value";
- private static final String URI_SINGLETON = "/SI";
- private static final String URI_NAV_ENTITY = "/ESKeyNav/NavPropertyETKeyNavOne";
- private static final String URI_NAV_ENTITY_SET = "/ESKeyNav/NavPropertyETKeyNavMany";
-
- private static final String QO_FILTER = "$filter='1' eq '1'";
- private static final String QO_FORMAT = "$format=bla";
- private static final String QO_EXPAND = "$expand=*";
- private static final String QO_ID = "$id=Products(0)";
- private static final String QO_COUNT = "$count";
- private static final String QO_ORDERBY = "$orderby=true";
-// private static final String QO_SEARCH = "$search='bla'";
- private static final String QO_SELECT = "$select=*";
- private static final String QO_SKIP = "$skip=3";
- private static final String QO_SKIPTOKEN = "$skiptoken=123";
- private static final String QO_LEVELS = "$expand=*($levels=1)";
- private static final String QO_TOP = "$top=1";
-
- private String[][] urisWithValidSystemQueryOptions = {
- { URI_ALL, QO_FILTER, }, { URI_ALL, QO_FORMAT }, { URI_ALL, QO_EXPAND }, { URI_ALL, QO_COUNT },
- { URI_ALL, QO_ORDERBY }, /* { URI_ALL, QO_SEARCH }, */{ URI_ALL, QO_SELECT }, { URI_ALL, QO_SKIP },
- { URI_ALL, QO_SKIPTOKEN }, { URI_ALL, QO_LEVELS },
-
- { URI_CROSSJOIN, QO_FILTER, }, { URI_CROSSJOIN, QO_FORMAT },
- { URI_CROSSJOIN, QO_EXPAND }, { URI_CROSSJOIN, QO_COUNT }, { URI_CROSSJOIN, QO_ORDERBY },
- /* { URI_CROSSJOIN, QO_SEARCH }, */{ URI_CROSSJOIN, QO_SELECT }, { URI_CROSSJOIN, QO_SKIP },
- { URI_CROSSJOIN, QO_SKIPTOKEN }, { URI_CROSSJOIN, QO_LEVELS }, { URI_CROSSJOIN, QO_TOP },
-
- { URI_ENTITY_ID, QO_ID, QO_FORMAT }, { URI_ENTITY_ID, QO_ID, }, { URI_ENTITY_ID, QO_ID, QO_EXPAND },
- { URI_ENTITY_ID, QO_ID, QO_SELECT }, { URI_ENTITY_ID, QO_ID, QO_LEVELS },
-
- { URI_METADATA, QO_FORMAT },
-
- { URI_SERVICE, QO_FORMAT },
-
- { URI_ENTITY_SET, QO_FILTER, }, { URI_ENTITY_SET, QO_FORMAT }, { URI_ENTITY_SET, QO_EXPAND },
- { URI_ENTITY_SET, QO_COUNT }, { URI_ENTITY_SET, QO_ORDERBY }, /* { URI_ENTITY_SET, QO_SEARCH }, */
- { URI_ENTITY_SET, QO_SELECT },
- { URI_ENTITY_SET, QO_SKIP }, { URI_ENTITY_SET, QO_SKIPTOKEN }, { URI_ENTITY_SET, QO_LEVELS },
- { URI_ENTITY_SET, QO_TOP },
-
- { URI_ENTITY_SET_COUNT, QO_FILTER }, /* { URI_ENTITY_SET_COUNT, QO_SEARCH }, */
-
- { URI_ENTITY, QO_FORMAT }, { URI_ENTITY, QO_EXPAND }, { URI_ENTITY, QO_SELECT }, { URI_ENTITY, QO_LEVELS },
-
- { URI_MEDIA_STREAM, QO_FORMAT },
-
- { URI_REFERENCES, QO_FILTER }, { URI_REFERENCES, QO_FORMAT }, { URI_REFERENCES, QO_ORDERBY },
- /* { URI_REFERENCES, QO_SEARCH }, */{ URI_REFERENCES, QO_SKIP }, { URI_REFERENCES, QO_SKIPTOKEN },
- { URI_REFERENCES, QO_TOP },
-
- { URI_REFERENCE, QO_FORMAT },
-
- { URI_PROPERTY_COMPLEX, QO_FORMAT }, { URI_PROPERTY_COMPLEX, QO_SELECT }, { URI_PROPERTY_COMPLEX, QO_EXPAND },
- { URI_PROPERTY_COMPLEX, QO_LEVELS },
-
- { URI_PROPERTY_COMPLEX_COLLECTION, QO_FILTER }, { URI_PROPERTY_COMPLEX_COLLECTION, QO_FORMAT },
- { URI_PROPERTY_COMPLEX_COLLECTION, QO_EXPAND }, { URI_PROPERTY_COMPLEX_COLLECTION, QO_COUNT },
- { URI_PROPERTY_COMPLEX_COLLECTION, QO_SKIP }, { URI_PROPERTY_COMPLEX_COLLECTION, QO_SKIPTOKEN },
- { URI_PROPERTY_COMPLEX_COLLECTION, QO_LEVELS }, { URI_PROPERTY_COMPLEX_COLLECTION, QO_TOP },
- { URI_PROPERTY_COMPLEX_COLLECTION, QO_ORDERBY },
-
- { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_FILTER }, /* { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_SEARCH }, */
-
- { URI_PROPERTY_PRIMITIVE, QO_FORMAT },
-
- { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_FILTER }, { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_FORMAT },
- { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_ORDERBY }, { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_SKIP },
- { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_SKIPTOKEN }, { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_TOP },
-
- { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_FILTER },
- /* { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_SEARCH }, */
-
- { URI_PROPERTY_PRIMITIVE_VALUE, QO_FORMAT },
-
- { URI_SINGLETON, QO_FORMAT }, { URI_SINGLETON, QO_EXPAND }, { URI_SINGLETON, QO_SELECT },
- { URI_SINGLETON, QO_LEVELS },
-
- { URI_NAV_ENTITY, QO_FORMAT }, { URI_NAV_ENTITY, QO_EXPAND }, { URI_NAV_ENTITY, QO_SELECT },
- { URI_NAV_ENTITY, QO_LEVELS },
-
- { URI_NAV_ENTITY_SET, QO_FILTER, }, { URI_NAV_ENTITY_SET, QO_FORMAT }, { URI_NAV_ENTITY_SET, QO_EXPAND },
- { URI_NAV_ENTITY_SET, QO_COUNT }, { URI_NAV_ENTITY_SET, QO_ORDERBY },
- /* { URI_NAV_ENTITY_SET, QO_SEARCH }, */{ URI_NAV_ENTITY_SET, QO_SELECT }, { URI_NAV_ENTITY_SET, QO_SKIP },
- { URI_NAV_ENTITY_SET, QO_SKIPTOKEN }, { URI_NAV_ENTITY_SET, QO_LEVELS }, { URI_NAV_ENTITY_SET, QO_TOP },
-
- { "FINRTInt16()" },
- { "FICRTETKeyNav()" },
- { "FICRTESTwoKeyNavParam(ParameterInt16=1)" },
- { "FICRTCollString()" },
- { "FICRTCTTwoPrim()" },
- { "FICRTCollCTTwoPrim()" },
- { "FICRTETMedia()" },
-
- { "ESTwoKeyNav/com.sap.odata.test1.BAESTwoKeyNavRTESTwoKeyNav" },
- { "ESAllPrim/com.sap.odata.test1.BAESAllPrimRTETAllPrim" },
- { "AIRTPrimCollParam" },
- { "AIRTETParam" },
- { "AIRTPrimParam" },
-
- };
-
- private String[][] urisWithNonValidSystemQueryOptions = {
- { URI_ALL, QO_ID, }, { URI_ALL, QO_TOP },
-
- { URI_BATCH, QO_FILTER, }, { URI_BATCH, QO_FORMAT }, { URI_BATCH, QO_ID, }, { URI_BATCH, QO_EXPAND },
- { URI_BATCH, QO_COUNT }, { URI_BATCH, QO_ORDERBY }, /* { URI_BATCH, QO_SEARCH }, */{ URI_BATCH, QO_SELECT },
- { URI_BATCH, QO_SKIP }, { URI_BATCH, QO_SKIPTOKEN }, { URI_BATCH, QO_LEVELS }, { URI_BATCH, QO_TOP },
-
- { URI_CROSSJOIN, QO_ID, },
-
- { URI_ENTITY_ID, QO_ID, QO_FILTER, },
- { URI_ENTITY_ID, QO_ID, QO_COUNT }, { URI_ENTITY_ID, QO_ORDERBY }, /* { URI_ENTITY_ID, QO_SEARCH }, */
-
- { URI_ENTITY_ID, QO_ID, QO_SKIP }, { URI_ENTITY_ID, QO_ID, QO_SKIPTOKEN }, { URI_ENTITY_ID, QO_ID, QO_TOP },
-
- { URI_METADATA, QO_FILTER, }, { URI_METADATA, QO_ID, }, { URI_METADATA, QO_EXPAND },
- { URI_METADATA, QO_COUNT }, { URI_METADATA, QO_ORDERBY }, /* { URI_METADATA, QO_SEARCH }, */
- { URI_METADATA, QO_SELECT }, { URI_METADATA, QO_SKIP }, { URI_METADATA, QO_SKIPTOKEN },
- { URI_METADATA, QO_LEVELS }, { URI_METADATA, QO_TOP },
-
- { URI_SERVICE, QO_FILTER }, { URI_SERVICE, QO_ID }, { URI_SERVICE, QO_EXPAND }, { URI_SERVICE, QO_COUNT },
- { URI_SERVICE, QO_ORDERBY }, /* { URI_SERVICE, QO_SEARCH }, */{ URI_SERVICE, QO_SELECT },
- { URI_SERVICE, QO_SKIP }, { URI_SERVICE, QO_SKIPTOKEN }, { URI_SERVICE, QO_LEVELS }, { URI_SERVICE, QO_TOP },
-
- { URI_ENTITY_SET, QO_ID },
-
- { URI_ENTITY_SET_COUNT, QO_FORMAT }, { URI_ENTITY_SET_COUNT, QO_ID },
- { URI_ENTITY_SET_COUNT, QO_EXPAND }, { URI_ENTITY_SET_COUNT, QO_COUNT },
- { URI_ENTITY_SET_COUNT, QO_ORDERBY },
- { URI_ENTITY_SET_COUNT, QO_SELECT }, { URI_ENTITY_SET_COUNT, QO_SKIP }, { URI_ENTITY_SET_COUNT, QO_SKIPTOKEN },
- { URI_ENTITY_SET_COUNT, QO_LEVELS }, { URI_ENTITY_SET_COUNT, QO_TOP },
-
- { URI_ENTITY, QO_FILTER }, { URI_ENTITY, QO_ID }, { URI_ENTITY, QO_COUNT }, /* { URI_ENTITY, QO_ORDERBY }, */
- /* { URI_ENTITY, QO_SEARCH }, */{ URI_ENTITY, QO_SKIP }, { URI_ENTITY, QO_SKIPTOKEN }, { URI_ENTITY, QO_TOP },
-
- { URI_MEDIA_STREAM, QO_FILTER }, { URI_MEDIA_STREAM, QO_ID, }, { URI_MEDIA_STREAM, QO_EXPAND },
- { URI_MEDIA_STREAM, QO_COUNT }, { URI_MEDIA_STREAM, QO_ORDERBY }, /* { URI_MEDIA_STREAM, QO_SEARCH }, */
- { URI_MEDIA_STREAM, QO_SELECT }, { URI_MEDIA_STREAM, QO_SKIP }, { URI_MEDIA_STREAM, QO_SKIPTOKEN },
- { URI_MEDIA_STREAM, QO_LEVELS }, { URI_MEDIA_STREAM, QO_TOP },
-
- { URI_REFERENCES, QO_ID, }, { URI_REFERENCES, QO_EXPAND }, { URI_REFERENCES, QO_COUNT },
- { URI_REFERENCES, QO_SELECT }, { URI_REFERENCES, QO_LEVELS },
-
- { URI_REFERENCE, QO_FILTER }, { URI_REFERENCE, QO_ID, }, { URI_REFERENCE, QO_EXPAND },
- { URI_REFERENCE, QO_COUNT }, { URI_REFERENCE, QO_ORDERBY }, /* { URI_REFERENCE, QO_SEARCH }, */
- { URI_REFERENCE, QO_SELECT }, { URI_REFERENCE, QO_SKIP }, { URI_REFERENCE, QO_SKIPTOKEN },
- { URI_REFERENCE, QO_LEVELS }, { URI_REFERENCE, QO_TOP },
-
- { URI_PROPERTY_COMPLEX, QO_FILTER }, { URI_PROPERTY_COMPLEX, QO_ID, }, { URI_PROPERTY_COMPLEX, QO_COUNT },
- { URI_PROPERTY_COMPLEX, QO_ORDERBY }, /* { URI_PROPERTY_COMPLEX, QO_SEARCH }, */
- { URI_PROPERTY_COMPLEX, QO_SKIP }, { URI_PROPERTY_COMPLEX, QO_SKIPTOKEN }, { URI_PROPERTY_COMPLEX, QO_TOP },
-
- { URI_PROPERTY_COMPLEX_COLLECTION, QO_ID, },
- /* { URI_PROPERTY_COMPLEX_COLLECTION, QO_SEARCH }, */{ URI_PROPERTY_COMPLEX_COLLECTION, QO_SELECT },
-
- { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_FORMAT },
- { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_ID, }, { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_EXPAND },
- { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_COUNT }, { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_ORDERBY },
- { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_SELECT },
- { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_SKIP }, { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_SKIPTOKEN },
- { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_LEVELS }, { URI_PROPERTY_COMPLEX_COLLECTION_COUNT, QO_TOP },
-
- { URI_PROPERTY_PRIMITIVE, QO_FILTER }, { URI_PROPERTY_PRIMITIVE, QO_ID, }, { URI_PROPERTY_PRIMITIVE, QO_EXPAND },
- { URI_PROPERTY_PRIMITIVE, QO_COUNT }, { URI_PROPERTY_PRIMITIVE, QO_ORDERBY },
- /* { URI_PROPERTY_PRIMITIVE, QO_SEARCH }, */{ URI_PROPERTY_PRIMITIVE, QO_SELECT },
- { URI_PROPERTY_PRIMITIVE, QO_SKIP }, { URI_PROPERTY_PRIMITIVE, QO_SKIPTOKEN },
- { URI_PROPERTY_PRIMITIVE, QO_LEVELS }, { URI_PROPERTY_PRIMITIVE, QO_TOP },
-
- { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_ID, }, { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_EXPAND },
- { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_COUNT }, /* { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_SEARCH }, */
- { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_SELECT }, { URI_PROPERTY_PRIMITIVE_COLLECTION, QO_LEVELS },
-
- { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_FORMAT },
- { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_ID, }, { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_EXPAND },
- { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_COUNT },
- { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_ORDERBY },
- { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_SELECT }, { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_SKIP },
- { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_SKIPTOKEN },
- { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_LEVELS }, { URI_PROPERTY_PRIMITIVE_COLLECTION_COUNT, QO_TOP },
-
- { URI_PROPERTY_PRIMITIVE_VALUE, QO_FILTER }, { URI_PROPERTY_PRIMITIVE_VALUE, QO_ID, },
- { URI_PROPERTY_PRIMITIVE_VALUE, QO_EXPAND }, { URI_PROPERTY_PRIMITIVE_VALUE, QO_COUNT },
- { URI_PROPERTY_PRIMITIVE_VALUE, QO_ORDERBY },/* { URI_PROPERTY_PRIMITIVE_VALUE, QO_SEARCH }, */
- { URI_PROPERTY_PRIMITIVE_VALUE, QO_SELECT }, { URI_PROPERTY_PRIMITIVE_VALUE, QO_SKIP },
- { URI_PROPERTY_PRIMITIVE_VALUE, QO_SKIPTOKEN }, { URI_PROPERTY_PRIMITIVE_VALUE, QO_LEVELS },
- { URI_PROPERTY_PRIMITIVE_VALUE, QO_TOP },
-
- { URI_SINGLETON, QO_FILTER }, { URI_SINGLETON, QO_ID }, { URI_SINGLETON, QO_COUNT },
- { URI_SINGLETON, QO_ORDERBY }, /* { URI_SINGLETON, QO_SEARCH }, */{ URI_SINGLETON, QO_SKIP },
- { URI_SINGLETON, QO_SKIPTOKEN }, { URI_SINGLETON, QO_TOP },
-
- { URI_NAV_ENTITY, QO_FILTER }, { URI_NAV_ENTITY, QO_ID }, { URI_NAV_ENTITY, QO_COUNT },
- { URI_NAV_ENTITY, QO_ORDERBY }, /* { URI_NAV_ENTITY, QO_SEARCH }, */{ URI_NAV_ENTITY, QO_SKIP },
- { URI_NAV_ENTITY, QO_SKIPTOKEN }, { URI_SINGLETON, QO_TOP },
-
- { URI_NAV_ENTITY_SET, QO_ID },
-
- };
-
- private Parser parser;
- private Edm edm;
-
- @Before
- public void before() {
- parser = new Parser();
- edm = new EdmProviderImpl(new EdmTechProvider());
- }
-
- @Test
- public void validateSelect() throws Exception {
- String[] uris = { "/ESAllPrim(1)?$select=PropertyString" };
- for (String uri : uris) {
- parseAndValidate(uri, "GET");
- }
- }
-
- @Test(expected = UriValidationException.class)
- public void validateForHttpMethodsFail() throws Exception {
- String uri = URI_ENTITY;
- parseAndValidate(uri, "xyz");
- }
-
- @Test
- public void validateForHttpMethods() throws Exception {
- String uri = URI_ENTITY;
- parseAndValidate(uri, "GET");
- parseAndValidate(uri, "POST");
- parseAndValidate(uri, "PUT");
- parseAndValidate(uri, "DELETE");
- parseAndValidate(uri, "PATCH");
- parseAndValidate(uri, "MERGE");
- }
-
- @Test
- public void validateOrderBy() throws Exception {
- String[] uris = { "/ESAllPrim?$orderby=PropertyString" };
- for (String uri : uris) {
- parseAndValidate(uri, "GET");
- }
- }
-
- @Test(expected = UriValidationException.class)
- @Ignore("uri parser doen't support orderby yet")
- public void validateOrderByInvalid() throws Exception {
- String uri = "/ESAllPrim(1)?$orderBy=XXXX";
- parseAndValidate(uri, "GET");
- }
-
- @Test(expected = UriValidationException.class)
- public void validateKeyPredicatesWrongKey() throws Exception {
- String uri = "ESTwoKeyNav(xxx=1, yyy='abc')";
- parseAndValidate(uri, "GET");
- }
-
- @Test
- public void validateKeyPredicates() throws Exception {
- String uri = "ESTwoKeyNav(PropertyInt16=1, PropertyString='abc')";
- parseAndValidate(uri, "GET");
- }
-
- @Test(expected = UriValidationException.class)
- public void validateKeyPredicatesWrongValueType() throws Exception {
- String uri = "ESTwoKeyNav(PropertyInt16='abc', PropertyString=1)";
- parseAndValidate(uri, "GET");
- }
-
- @Test
- public void checkValidSystemQueryOption() throws Exception {
- String[] uris = constructUri(urisWithValidSystemQueryOptions);
-
- for (String uri : uris) {
- try {
- parseAndValidate(uri, "GET");
- } catch (Exception e) {
- throw new Exception("Faild for uri: " + uri, e);
- }
- }
- }
-
- @Test
- public void checkNonValidSystemQueryOption() throws Exception {
- String[] uris = constructUri(urisWithNonValidSystemQueryOptions);
-
- for (String uri : uris) {
- try {
- parseAndValidate(uri, "GET");
- fail("Validation Exception not thrown: " + uri);
- } catch (UriValidationException e) {
- assertTrue(e instanceof UriValidationException);
- }
- }
- }
-
- private String[] constructUri(final String[][] uriParameterMatrix) {
- ArrayList<String> uris = new ArrayList<String>();
- for (String[] uriParameter : uriParameterMatrix) {
- String uri = uriParameter[0];
- if (uriParameter.length > 1) {
- uri += "?";
- }
- for (int i = 1; i < uriParameter.length; i++) {
- uri += uriParameter[i];
- if (i < (uriParameter.length - 1)) {
- uri += "&";
- }
- }
- uris.add(uri);
- }
- return uris.toArray(new String[0]);
- }
-
- private void parseAndValidate(final String uri, String method) throws UriParserException, UriValidationException {
- UriInfo uriInfo = parser.parseUri(uri.trim(), edm);
- UriValidator validator = new UriValidator();
-
- validator.validate(uriInfo, method);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/pom.xml
----------------------------------------------------------------------
diff --git a/lib/server-ref/pom.xml b/lib/server-ref/pom.xml
new file mode 100644
index 0000000..fc5cf4e
--- /dev/null
+++ b/lib/server-ref/pom.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>olingo-server-ref</artifactId>
+ <packaging>war</packaging>
+ <name>${project.artifactId}</name>
+
+ <parent>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-lib</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-server-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-server-core</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/main/java/org/apache/olingo/ref/ReferenceServlet.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/main/java/org/apache/olingo/ref/ReferenceServlet.java b/lib/server-ref/src/main/java/org/apache/olingo/ref/ReferenceServlet.java
new file mode 100644
index 0000000..a3d30ee
--- /dev/null
+++ b/lib/server-ref/src/main/java/org/apache/olingo/ref/ReferenceServlet.java
@@ -0,0 +1,42 @@
+/*
+ * 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.ref;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.olingo.server.api.ODataServer;
+
+public class ReferenceServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+
+ ODataServer server = ODataServer.newInstance();
+ server.handle(req, resp);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/EdmTechTestProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/EdmTechTestProvider.java b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/EdmTechTestProvider.java
new file mode 100644
index 0000000..bee5f90
--- /dev/null
+++ b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/EdmTechTestProvider.java
@@ -0,0 +1,100 @@
+/*
+ * 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.testutil;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.server.api.edm.provider.ComplexType;
+import org.apache.olingo.server.api.edm.provider.EntitySet;
+import org.apache.olingo.server.api.edm.provider.EntityType;
+import org.apache.olingo.server.api.edm.provider.Property;
+import org.apache.olingo.server.api.edm.provider.PropertyRef;
+import org.apache.olingo.server.core.testutil.techprovider.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 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>
+ */
+public class EdmTechTestProvider extends EdmTechProvider {
+
+ private static final FullQualifiedName nameInt16 = EdmPrimitiveTypeKind.Int16.getFullQualifiedName();
+ public static final String nameSpace = "com.sap.odata.test1";
+ public static final FullQualifiedName nameContainer = new FullQualifiedName(nameSpace, "Container");
+
+ Property propertyAInt16 = new Property().setName("a").setType(nameInt16);
+ Property propertyBInt16 = new Property().setName("b").setType(nameInt16);
+ Property propertyCInt16 = new Property().setName("c").setType(nameInt16);
+ Property propertyDInt16 = new Property().setName("d").setType(nameInt16);
+ Property propertyEInt16 = new Property().setName("e").setType(nameInt16);
+ Property propertyFInt16 = new Property().setName("f").setType(nameInt16);
+
+ public static final FullQualifiedName nameCTabc = new FullQualifiedName(nameSpace, "CTabc");
+ public static final FullQualifiedName nameETabc = new FullQualifiedName(nameSpace, "ETabc");
+
+ @Override
+ public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException {
+ if (complexTypeName.equals(nameCTabc)) {
+ return new ComplexType()
+ .setName("CTabc")
+ .setProperties(Arrays.asList(
+ propertyAInt16, propertyBInt16, propertyCInt16,
+ propertyDInt16, propertyEInt16, propertyFInt16
+ ));
+
+ }
+
+ return super.getComplexType(complexTypeName);
+ }
+
+ @Override
+ public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String name) throws ODataException {
+ if (nameContainer.equals(entityContainer)) {
+ if (name.equals("ESabc")) {
+ return new EntitySet()
+ .setName("ESabc")
+ .setType(nameETabc);
+ }
+ }
+
+ return super.getEntitySet(entityContainer, name);
+ }
+
+ @Override
+ public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException {
+ List<PropertyRef> oneKeyPropertyInt16 = Arrays.asList(new PropertyRef().setPropertyName("a"));
+
+ if (entityTypeName.equals(nameETabc)) {
+ return new EntityType()
+ .setName("ETabc")
+ .setProperties(Arrays.asList(
+ propertyAInt16, propertyBInt16, propertyCInt16,
+ propertyDInt16, propertyEInt16, propertyFInt16))
+ .setKey(oneKeyPropertyInt16);
+ }
+
+ return super.getEntityType(entityTypeName);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/StringUtils.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/StringUtils.java b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/StringUtils.java
new file mode 100644
index 0000000..8cabcf1
--- /dev/null
+++ b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/StringUtils.java
@@ -0,0 +1,52 @@
+/*
+ * 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.testutil;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.Charset;
+
+public class StringUtils {
+
+ public static String inputStreamToString(final InputStream in, final boolean preserveLineBreaks) {
+ try {
+ final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in, Charset.forName("UTF-8")));
+ final StringBuilder stringBuilder = new StringBuilder();
+ String line = null;
+
+ while ((line = bufferedReader.readLine()) != null) {
+ stringBuilder.append(line);
+ if (preserveLineBreaks) {
+ stringBuilder.append("\n");
+ }
+ }
+
+ bufferedReader.close();
+
+ final String result = stringBuilder.toString();
+
+ return result;
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ActionProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ActionProvider.java b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ActionProvider.java
new file mode 100644
index 0000000..f1748a7
--- /dev/null
+++ b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ActionProvider.java
@@ -0,0 +1,191 @@
+/*
+ * 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.testutil.techprovider;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.server.api.edm.provider.Action;
+import org.apache.olingo.server.api.edm.provider.Parameter;
+import org.apache.olingo.server.api.edm.provider.ReturnType;
+
+public class ActionProvider {
+
+ // Bound Actions
+ public static final FullQualifiedName nameBAESAllPrimRTETAllPrim =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BAESAllPrimRTETAllPrim");
+
+ public static final FullQualifiedName nameBAESTwoKeyNavRTESTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BAESTwoKeyNavRTESTwoKeyNav");
+
+ public static final FullQualifiedName nameBAETBaseTwoKeyNavRTETBaseTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BAETBaseTwoKeyNavRTETBaseTwoKeyNav");
+
+ public static final FullQualifiedName nameBAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav");
+
+ public static final FullQualifiedName nameBAETTwoKeyNavRTETTwoKeyNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "BAETTwoKeyNavRTETTwoKeyNav");
+
+ // Unbound Actions
+ public static final FullQualifiedName nameUARTCompCollParam = new FullQualifiedName(SchemaProvider.nameSpace,
+ "UARTCompCollParam");
+ public static final FullQualifiedName nameUARTCompParam = new FullQualifiedName(SchemaProvider.nameSpace,
+ "UARTCompParam");
+ public static final FullQualifiedName nameUARTESParam =
+ new FullQualifiedName(SchemaProvider.nameSpace, "UARTESParam");
+
+ public static final FullQualifiedName nameUARTETParam =
+ new FullQualifiedName(SchemaProvider.nameSpace, "UARTETParam");
+
+ public static final FullQualifiedName nameUARTPrimParam = new FullQualifiedName(SchemaProvider.nameSpace,
+ "UARTPrimParam");
+ public static final FullQualifiedName nameUARTPrimCollParam = new FullQualifiedName(SchemaProvider.nameSpace,
+ "UARTPrimCollParam");
+
+ public List<Action> getActions(final FullQualifiedName actionName) throws ODataException {
+ if (actionName.equals(nameUARTPrimParam)) {
+ return Arrays.asList(
+ new Action().setName("UARTPrimParam")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
+
+ .setReturnType(new ReturnType().setType(PropertyProvider.nameString))
+ );
+
+ } else if (actionName.equals(nameUARTPrimCollParam)) {
+ return Arrays.asList(
+ new Action().setName("UARTPrimCollParam")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
+
+ .setReturnType(
+ new ReturnType().setType(PropertyProvider.nameString).setCollection(true))
+ );
+
+ } else if (actionName.equals(nameUARTCompParam)) {
+ return Arrays.asList(
+ new Action().setName("UARTCompParam")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
+
+ .setReturnType(
+ new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim))
+ );
+
+ } else if (actionName.equals(nameUARTCompCollParam)) {
+ return Arrays.asList(
+ new Action().setName("UARTCompCollParam")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
+
+ .setReturnType(
+ new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setCollection(true))
+ );
+
+ } else if (actionName.equals(nameUARTETParam)) {
+ return Arrays.asList(
+ new Action().setName("UARTETParam")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyTwoPrim))
+ );
+
+ } else if (actionName.equals(nameUARTESParam)) {
+ return Arrays.asList(
+ new Action().setName("UARTESParam")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setCollection(true))
+ );
+
+ } else if (actionName.equals(nameBAETTwoKeyNavRTETTwoKeyNav)) {
+ return Arrays.asList(
+ new Action().setName("BAETTwoKeyNavRTETTwoKeyNav")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterETTwoKeyNav").setType(EntityTypeProvider.nameETTwoKeyNav)
+ .setNullable(false)))
+ .setBound(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav))
+ ,
+ new Action().setName("BAETTwoKeyNavRTETTwoKeyNav")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterETKeyNav").setType(EntityTypeProvider.nameETKeyNav)
+ .setNullable(false)))
+ .setBound(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav))
+ );
+
+ } else if (actionName.equals(nameBAESAllPrimRTETAllPrim)) {
+ return Arrays.asList(
+ new Action().setName("BAESAllPrimRTETAllPrim")
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("ParameterESAllPrim").setType(EntityTypeProvider.nameETAllPrim)
+ .setCollection(true).setNullable(false)))
+ .setBound(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETAllPrim))
+ );
+
+ } else if (actionName.equals(nameBAESTwoKeyNavRTESTwoKeyNav)) {
+ return Arrays.asList(
+ new Action().setName("BAESTwoKeyNavRTESTwoKeyNav")
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("ParameterETTwoKeyNav").setType(EntityTypeProvider.nameETTwoKeyNav)
+ .setCollection(true).setNullable(false)))
+ .setBound(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true))
+ );
+
+ } else if (actionName.equals(nameBAETBaseTwoKeyNavRTETBaseTwoKeyNav)) {
+ return Arrays.asList(
+ new Action().setName("BAETBaseTwoKeyNavRTETBaseTwoKeyNav")
+ .setParameters(Arrays.asList(
+ new Parameter().setName("ParameterETTwoKeyNav").setType(EntityTypeProvider.nameETBaseTwoKeyNav)
+ .setNullable(false)))
+ .setBound(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav))
+ );
+
+ } else if (actionName.equals(nameBAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav)) {
+ return Arrays.asList(
+ new Action().setName("BAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav")
+ .setParameters(
+ Arrays.asList(
+ new Parameter().setName("ParameterETTwoBaseTwoKeyNav").setType(
+ EntityTypeProvider.nameETTwoBaseTwoKeyNav).setNullable(false)))
+ .setBound(true)
+ .setReturnType(
+ new ReturnType().setType(EntityTypeProvider.nameETBaseTwoKeyNav))
+ );
+ }
+
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ComplexTypeProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ComplexTypeProvider.java b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ComplexTypeProvider.java
new file mode 100644
index 0000000..2db6d0e
--- /dev/null
+++ b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ComplexTypeProvider.java
@@ -0,0 +1,175 @@
+/*
+ * 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.testutil.techprovider;
+
+import java.util.Arrays;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.server.api.edm.provider.ComplexType;
+import org.apache.olingo.server.api.edm.provider.NavigationProperty;
+import org.apache.olingo.server.api.edm.provider.Property;
+
+public class ComplexTypeProvider {
+
+ public static final FullQualifiedName nameCTAllPrim = new FullQualifiedName(SchemaProvider.nameSpace, "CTAllPrim");
+ public static final FullQualifiedName nameCTBase = new FullQualifiedName(SchemaProvider.nameSpace, "CTBase");
+ public static final FullQualifiedName nameCTBasePrimCompNav = new FullQualifiedName(SchemaProvider.nameSpace,
+ "CTBasePrimCompNav");
+ public static final FullQualifiedName nameCTCollAllPrim = new FullQualifiedName(SchemaProvider.nameSpace,
+ "CTCollAllPrim");
+ public static final FullQualifiedName nameCTCompCollComp = new FullQualifiedName(SchemaProvider.nameSpace,
+ "CTCompCollComp");
+ public static final FullQualifiedName nameCTCompComp = new FullQualifiedName(SchemaProvider.nameSpace, "CTCompComp");
+ public static final FullQualifiedName nameCTCompNav = new FullQualifiedName(SchemaProvider.nameSpace, "CTCompNav");
+
+ public static final FullQualifiedName nameCTMixPrimCollComp = new FullQualifiedName(SchemaProvider.nameSpace,
+ "CTMixPrimCollComp");
+ public static final FullQualifiedName nameCTNavFiveProp = new FullQualifiedName(SchemaProvider.nameSpace,
+ "CTNavFiveProp");
+ public static final FullQualifiedName nameCTPrim = new FullQualifiedName(SchemaProvider.nameSpace, "CTPrim");
+ public static final FullQualifiedName nameCTPrimComp = new FullQualifiedName(SchemaProvider.nameSpace, "CTPrimComp");
+ public static final FullQualifiedName nameCTPrimEnum = new FullQualifiedName(SchemaProvider.nameSpace, "CTPrimEnum");
+ public static final FullQualifiedName nameCTTwoBase = new FullQualifiedName(SchemaProvider.nameSpace, "CTTwoBase");
+ public static final FullQualifiedName nameCTTwoBasePrimCompNav =
+ new FullQualifiedName(SchemaProvider.nameSpace, "CTTwoBasePrimCompNav");
+ public static final FullQualifiedName nameCTTwoPrim = new FullQualifiedName(SchemaProvider.nameSpace, "CTTwoPrim");
+
+ public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException {
+
+ if (complexTypeName.equals(nameCTPrim)) {
+ return new ComplexType()
+ .setName("CTPrim")
+ .setProperties(Arrays.asList(PropertyProvider.propertyInt16));
+
+ } else if (complexTypeName.equals(nameCTAllPrim)) {
+ return new ComplexType()
+ .setName("CTAllPrim")
+ .setProperties(
+ Arrays.asList(PropertyProvider.propertyString, PropertyProvider.propertyBinary,
+ PropertyProvider.propertyBoolean, PropertyProvider.propertyByte, PropertyProvider.propertyDate,
+ PropertyProvider.propertyDateTimeOffset, PropertyProvider.propertyDecimal,
+ PropertyProvider.propertySingle, PropertyProvider.propertyDouble, PropertyProvider.propertyDuration,
+ PropertyProvider.propertyGuid, PropertyProvider.propertyInt16, PropertyProvider.propertyInt32,
+ PropertyProvider.propertyInt64, PropertyProvider.propertySByte, PropertyProvider.propertyTimeOfDay
+ /* TODO add propertyStream */));
+
+ } else if (complexTypeName.equals(nameCTCollAllPrim)) {
+ return new ComplexType()
+ .setName("CTCollAllPrim")
+ .setProperties(
+ Arrays.asList(
+ PropertyProvider.collPropertyString, PropertyProvider.collPropertyBoolean,
+ PropertyProvider.collPropertyByte, PropertyProvider.collPropertySByte,
+ PropertyProvider.collPropertyInt16, PropertyProvider.collPropertyInt32,
+ PropertyProvider.collPropertyInt64, PropertyProvider.collPropertySingle,
+ PropertyProvider.collPropertyDouble, PropertyProvider.collPropertyDecimal,
+ PropertyProvider.collPropertyBinary, PropertyProvider.collPropertyDate,
+ PropertyProvider.collPropertyDateTimeOffset, PropertyProvider.collPropertyDuration,
+ PropertyProvider.collPropertyGuid, PropertyProvider.collPropertyTimeOfDay
+ /* TODO add collectionPropertyStream */));
+
+ } else if (complexTypeName.equals(nameCTTwoPrim)) {
+ return new ComplexType()
+ .setName("CTTwoPrim")
+ .setProperties(Arrays.asList(PropertyProvider.propertyInt16, PropertyProvider.propertyString));
+
+ } else if (complexTypeName.equals(nameCTCompNav)) {
+ return new ComplexType()
+ .setName("CTCompNav")
+ .setProperties(Arrays.asList(PropertyProvider.propertyString,
+ PropertyProvider.propertyComplex_CTNavFiveProp));
+
+ } else if (complexTypeName.equals(nameCTMixPrimCollComp)) {
+ return new ComplexType()
+ .setName("CTMixPrimCollComp")
+ .setProperties(
+ Arrays.asList(PropertyProvider.propertyInt16, PropertyProvider.collPropertyString,
+ PropertyProvider.propertyComplex_CTTwoPrim, PropertyProvider.collPropertyComplex_CTTwoPrim));
+
+ } else if (complexTypeName.equals(nameCTBase)) {
+ return new ComplexType()
+ .setName("CTBase")
+ .setBaseType(nameCTTwoPrim)
+ .setProperties(Arrays.asList(
+ new Property()
+ .setName("AdditionalPropString")
+ .setType(new FullQualifiedName("Edm", "String"))));
+
+ } else if (complexTypeName.equals(nameCTTwoBase)) {
+ return new ComplexType()
+ .setName("CTTwoBase")
+ .setBaseType(nameCTBase);
+
+ } else if (complexTypeName.equals(nameCTCompComp)) {
+ return new ComplexType()
+ .setName("CTCompComp")
+ .setProperties(Arrays.asList(PropertyProvider.propertyComplex_CTTwoPrim));
+
+ } else if (complexTypeName.equals(nameCTCompCollComp)) {
+ return new ComplexType()
+ .setName("CTCompCollComp")
+ .setProperties(Arrays.asList(PropertyProvider.collPropertyComplex_CTTwoPrim));
+
+ } else if (complexTypeName.equals(nameCTPrimComp)) {
+ return new ComplexType()
+ .setName("CTPrimComp")
+ .setProperties(Arrays.asList(PropertyProvider.propertyInt16, PropertyProvider.propertyComplex_CTAllPrim));
+
+ } else if (complexTypeName.equals(nameCTNavFiveProp)) {
+ return new ComplexType()
+ .setName("CTNavFiveProp")
+ .setProperties(Arrays.asList(PropertyProvider.propertyInt16))
+ .setNavigationProperties((Arrays.asList(
+ PropertyProvider.collectionNavPropertyETTwoKeyNavOne_ETTwoKeyNav,
+ PropertyProvider.collectionNavPropertyETTwoKeyNavMany_ETTwoKeyNav,
+ new NavigationProperty()
+ .setName("NavPropertyETMediaOne")
+ .setType(EntityTypeProvider.nameETMedia),
+ new NavigationProperty()
+ .setName("NavPropertyETMediaMany")
+ .setType(EntityTypeProvider.nameETMedia).setCollection(true)
+ )));
+
+ } else if (complexTypeName.equals(nameCTBasePrimCompNav)) {
+ return new ComplexType()
+ .setName("CTBasePrimCompNav")
+ .setBaseType(nameCTPrimComp)
+ .setNavigationProperties(Arrays.asList(
+ PropertyProvider.collectionNavPropertyETTwoKeyNavMany_ETTwoKeyNav,
+ PropertyProvider.collectionNavPropertyETTwoKeyNavOne_ETTwoKeyNav,
+ PropertyProvider.navPropertyETKeyNavOne_ETKeyNav,
+ PropertyProvider.collectionNavPropertyETKeyNavMany_ETKeyNav));
+
+ } else if (complexTypeName.equals(nameCTPrimEnum)) {
+ return new ComplexType()
+ .setName("CTPrimEnum")
+ .setProperties(Arrays.asList(PropertyProvider.propertyInt16, PropertyProvider.propertyEnumString_ENString));
+
+ } else if (complexTypeName.equals(nameCTTwoBasePrimCompNav)) {
+ return new ComplexType()
+ .setName("CTTwoBasePrimCompNav")
+ .setBaseType(nameCTBasePrimCompNav);
+
+ }
+
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ContainerProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ContainerProvider.java b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ContainerProvider.java
new file mode 100644
index 0000000..5b92317
--- /dev/null
+++ b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/ContainerProvider.java
@@ -0,0 +1,361 @@
+/*
+ * 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.testutil.techprovider;
+
+import java.util.Arrays;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.Target;
+import org.apache.olingo.server.api.edm.provider.ActionImport;
+import org.apache.olingo.server.api.edm.provider.EntityContainer;
+import org.apache.olingo.server.api.edm.provider.EntityContainerInfo;
+import org.apache.olingo.server.api.edm.provider.EntitySet;
+import org.apache.olingo.server.api.edm.provider.FunctionImport;
+import org.apache.olingo.server.api.edm.provider.NavigationPropertyBinding;
+import org.apache.olingo.server.api.edm.provider.Singleton;
+
+public class ContainerProvider {
+
+ public static final FullQualifiedName nameContainer = new FullQualifiedName(SchemaProvider.nameSpace, "Container");
+
+ EntityContainerInfo entityContainerInfoTest1 =
+ new EntityContainerInfo().setContainerName(nameContainer);
+
+ public EntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName) throws ODataException {
+ if (entityContainerName == null) {
+ return entityContainerInfoTest1;
+ } else if (entityContainerName.equals(nameContainer)) {
+ return entityContainerInfoTest1;
+ }
+
+ return null;
+ }
+
+ public EntityContainer getEntityContainer() throws ODataException {
+ return null;
+ }
+
+ public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String name) throws ODataException {
+ if (entityContainer == nameContainer) {
+ if (name.equals("ESAllPrim")) {
+ return new EntitySet()
+ .setName("ESAllPrim")
+ .setType(EntityTypeProvider.nameETAllPrim);
+
+ } else if (name.equals("ESCollAllPrim")) {
+ return new EntitySet()
+ .setName("ESCollAllPrim")
+ .setType(EntityTypeProvider.nameETCollAllPrim);
+
+ } else if (name.equals("ESTwoPrim")) {
+ return new EntitySet()
+ .setName("ESTwoPrim")
+ .setType(EntityTypeProvider.nameETTwoPrim);
+
+ } else if (name.equals("ESMixPrimCollComp")) {
+ return new EntitySet()
+ .setName("ESMixPrimCollComp")
+ .setType(EntityTypeProvider.nameETMixPrimCollComp);
+
+ } else if (name.equals("ESBase")) {
+ return new EntitySet()
+ .setName("ESBase")
+ .setType(EntityTypeProvider.nameETBase);
+
+ } else if (name.equals("ESTwoBase")) {
+ return new EntitySet()
+ .setName("ESTwoBase")
+ .setType(EntityTypeProvider.nameETTwoBase);
+
+ } else if (name.equals("ESTwoKeyTwoPrim")) {
+ return new EntitySet()
+ .setName("ESTwoKeyTwoPrim")
+ .setType(EntityTypeProvider.nameETTwoKeyTwoPrim);
+
+ } else if (name.equals("ESBaseTwoKeyTwoPrim")) {
+ return new EntitySet()
+ .setName("ESBaseTwoKeyTwoPrim")
+ .setType(EntityTypeProvider.nameETBaseTwoKeyTwoPrim);
+
+ } else if (name.equals("ESTwoBaseTwoKeyTwoPrim")) {
+ return new EntitySet()
+ .setName("ESTwoBaseTwoKeyTwoPrim")
+ .setType(EntityTypeProvider.nameETTwoBaseTwoKeyTwoPrim);
+
+ } else if (name.equals("ESAllKey")) {
+ return new EntitySet()
+ .setName("ESAllKey")
+ .setType(EntityTypeProvider.nameETAllKey);
+
+ } else if (name.equals("ESCompAllPrim")) {
+ return new EntitySet()
+ .setName("ESCompAllPrim")
+ .setType(EntityTypeProvider.nameETCompAllPrim);
+
+ } else if (name.equals("ESCompCollAllPrim")) {
+ return new EntitySet()
+ .setName("ESCompCollAllPrim")
+ .setType(EntityTypeProvider.nameETCompCollAllPrim);
+
+ } else if (name.equals("ESCompComp")) {
+ return new EntitySet()
+ .setName("ESCompComp")
+ .setType(EntityTypeProvider.nameETCompComp);
+
+ } else if (name.equals("ESCompCollComp")) {
+ return new EntitySet()
+ .setName("ESCompCollComp")
+ .setType(EntityTypeProvider.nameETCompCollComp);
+
+ } else if (name.equals("ESMedia")) {
+ return new EntitySet()
+ .setName("ESMedia")
+ .setType(EntityTypeProvider.nameETMedia)
+ .setIncludeInServiceDocument(true);
+
+ } else if (name.equals("ESKeyTwoKeyComp")) {
+ return new EntitySet()
+ .setName("ESKeyTwoKeyComp")
+ .setType(EntityTypeProvider.nameETKeyTwoKeyComp);
+
+ } else if (name.equals("ESInvisible")) {
+ return new EntitySet()
+ .setName("ESInvisible")
+ .setType(EntityTypeProvider.nameETAllPrim);
+
+ } else if (name.equals("ESServerSidePaging")) {
+ return new EntitySet()
+ .setName("ESServerSidePaging")
+ .setType(EntityTypeProvider.nameETServerSidePaging);
+
+ } else if (name.equals("ESAllNullable")) {
+ return new EntitySet()
+ .setName("ESAllNullable")
+ .setType(EntityTypeProvider.nameETAllNullable);
+
+ } else if (name.equals("ESKeyNav")) {
+ return new EntitySet()
+ .setName("ESKeyNav")
+ .setType(EntityTypeProvider.nameETKeyNav);
+
+ } else if (name.equals("ESTwoKeyNav")) {
+ return new EntitySet()
+ .setName("ESTwoKeyNav")
+ .setType(EntityTypeProvider.nameETTwoKeyNav);
+
+ } else if (name.equals("ESBaseTwoKeyNav")) {
+ return new EntitySet()
+ .setName("ESBaseTwoKeyNav")
+ .setType(EntityTypeProvider.nameETBaseTwoKeyNav);
+
+ } else if (name.equals("ESCompMixPrimCollComp")) {
+ return new EntitySet()
+ .setName("ESCompMixPrimCollComp")
+ .setType(EntityTypeProvider.nameETCompMixPrimCollComp);
+
+ } else if (name.equals("ESFourKeyAlias")) {
+ return new EntitySet()
+ .setName("ESFourKeyAlias")
+ .setType(EntityTypeProvider.nameETFourKeyAlias);
+ }
+ }
+
+ return null;
+ }
+
+ public ActionImport getActionImport(final FullQualifiedName entityContainer, final String name) throws ODataException
+ {
+ if (entityContainer.equals(nameContainer)) {
+ if (name.equals("AIRTPrimParam")) {
+ return new ActionImport()
+ .setName("AIRTPrimParam")
+ .setAction(ActionProvider.nameUARTPrimParam);
+
+ } else if (name.equals("AIRTPrimCollParam")) {
+ return new ActionImport()
+ .setName("AIRTPrimCollParam")
+ .setAction(ActionProvider.nameUARTPrimCollParam);
+
+ } else if (name.equals("AIRTCompParam")) {
+ return new ActionImport()
+ .setName("AIRTCompParam")
+ .setAction(ActionProvider.nameUARTCompParam);
+
+ } else if (name.equals("AIRTCompCollParam")) {
+ return new ActionImport()
+ .setName("AIRTCompCollParam")
+ .setAction(ActionProvider.nameUARTCompCollParam);
+
+ } else if (name.equals("AIRTETParam")) {
+ return new ActionImport()
+ .setName("AIRTETParam")
+ .setAction(ActionProvider.nameUARTETParam);
+
+ } else if (name.equals("AIRTETCollAllPrimParam")) {
+ return new ActionImport()
+ .setName("AIRTETCollAllPrimParam")
+ .setAction(ActionProvider.nameUARTESParam);
+ }
+ }
+
+ return null;
+ }
+
+ public FunctionImport getFunctionImport(final FullQualifiedName entityContainer, final String name)
+ throws ODataException {
+
+ if (entityContainer.equals(nameContainer)) {
+ if (name.equals("FINRTInt16")) {
+ return new FunctionImport()
+ .setName("FINRTInt16")
+ .setFunction(FunctionProvider.nameUFNRTInt16)
+ .setIncludeInServiceDocument(true);
+
+ } else if (name.equals("FINInvisibleRTInt16")) {
+ return new FunctionImport()
+ .setName("FINInvisibleRTInt16")
+ .setFunction(FunctionProvider.nameUFNRTInt16);
+
+ } else if (name.equals("FINInvisible2RTInt16")) {
+ return new FunctionImport()
+ .setName("FINInvisible2RTInt16")
+ .setFunction(FunctionProvider.nameUFNRTInt16);
+
+ } else if (name.equals("FICRTETKeyNav")) {
+ return new FunctionImport()
+ .setName("FICRTETKeyNav")
+ .setFunction(FunctionProvider.nameUFCRTETKeyNav);
+
+ } else if (name.equals("FICRTETTwoKeyNavParam")) {
+ return new FunctionImport()
+ .setName("FICRTETTwoKeyNavParam")
+ .setFunction(FunctionProvider.nameUFCRTETTwoKeyNavParam)
+ .setIncludeInServiceDocument(true);
+
+ } else if (name.equals("FICRTStringTwoParam")) {
+ return new FunctionImport()
+ .setName("FICRTStringTwoParam")
+ .setFunction(FunctionProvider.nameUFCRTStringTwoParam)
+ .setIncludeInServiceDocument(true);
+
+ } else if (name.equals("FICRTCollStringTwoParam")) {
+ return new FunctionImport()
+ .setName("FICRTCollStringTwoParam")
+ .setFunction(FunctionProvider.nameUFCRTCollStringTwoParam)
+ .setIncludeInServiceDocument(true);
+
+ } else if (name.equals("FICRTCTAllPrimTwoParam")) {
+ return new FunctionImport()
+ .setName("FICRTCTAllPrimTwoParam")
+ .setFunction(FunctionProvider.nameUFCRTCTAllPrimTwoParam)
+ .setIncludeInServiceDocument(true);
+
+ } else if (name.equals("FICRTESMixPrimCollCompTwoParam")) {
+ return new FunctionImport()
+ .setName("FICRTESMixPrimCollCompTwoParam")
+ .setFunction(FunctionProvider.nameUFCRTESMixPrimCollCompTwoParam)
+ .setIncludeInServiceDocument(true);
+
+ } else if (name.equals("FINRTESMixPrimCollCompTwoParam")) {
+ return new FunctionImport()
+ .setName("FINRTESMixPrimCollCompTwoParam")
+ .setFunction(FunctionProvider.nameUFNRTESMixPrimCollCompTwoParam)
+ .setIncludeInServiceDocument(true);
+
+ } else if (name.equals("FICRTCollCTTwoPrim")) {
+ return new FunctionImport()
+ .setName("FICRTCollCTTwoPrim")
+ .setFunction(FunctionProvider.nameUFCRTCollCTTwoPrim)
+ .setIncludeInServiceDocument(true);
+
+ } else if (name.equals("FICRTETMedia")) {
+ return new FunctionImport()
+ .setName("FICRTETMedia")
+ .setFunction(FunctionProvider.nameUFCRTETMedia)
+ .setIncludeInServiceDocument(true);
+
+ } else if (name.equals("FICRTCTTwoPrimParam")) {
+ return new FunctionImport()
+ .setName("FICRTCTTwoPrimParam")
+ .setFunction(FunctionProvider.nameUFCRTCTTwoPrimParam)
+ .setIncludeInServiceDocument(true);
+
+ } else if (name.equals("FICRTCTTwoPrim")) {
+ return new FunctionImport()
+ .setName("FICRTCTTwoPrim")
+ .setFunction(FunctionProvider.nameUFCRTCTTwoPrim)
+ .setIncludeInServiceDocument(true);
+
+ } else if (name.equals("FICRTCollString")) {
+ return new FunctionImport()
+ .setName("FICRTCollString")
+ .setFunction(FunctionProvider.nameUFCRTCollString)
+ .setIncludeInServiceDocument(true);
+
+ } else if (name.equals("FICRTString")) {
+ return new FunctionImport()
+ .setName("FICRTString")
+ .setFunction(FunctionProvider.nameUFCRTString)
+ .setIncludeInServiceDocument(true);
+
+ } else if (name.equals("FICRTESTwoKeyNavParam")) {
+ return new FunctionImport()
+ .setName("FICRTESTwoKeyNavParam")
+ .setFunction(FunctionProvider.nameUFCRTESTwoKeyNavParam)
+ .setIncludeInServiceDocument(true);
+
+ } else if (name.equals("FICRTCollCTTwoPrimParam")) {
+ return new FunctionImport()
+ .setName("FICRTCollCTTwoPrimParam")
+ .setFunction(FunctionProvider.nameUFCRTCollCTTwoPrimParam)
+ .setIncludeInServiceDocument(true);
+
+ }
+ }
+
+ return null;
+ }
+
+ public Singleton getSingleton(final FullQualifiedName entityContainer, final String name) throws ODataException {
+ if (entityContainer.equals(nameContainer)) {
+
+ if (name.equals("SI")) {
+ return new Singleton()
+ .setName("SI")
+ .setType(EntityTypeProvider.nameETTwoPrim);
+
+ } else if (name.equals("SINav")) {
+ return new Singleton()
+ .setName("SINav")
+ .setType(EntityTypeProvider.nameETTwoKeyNav)
+ .setNavigationPropertyBindings(Arrays.asList(
+ new NavigationPropertyBinding()
+ .setPath("NavPropertyETTwoKeyNavMany")
+ .setTarget(new Target().setTargetName("ESTwoKeyNav"))));
+
+ } else if (name.equals("SIMedia")) {
+ return new Singleton()
+ .setName("SIMedia")
+ .setType(EntityTypeProvider.nameETMedia);
+ }
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8ca9b3c6/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EdmTechProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EdmTechProvider.java b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EdmTechProvider.java
new file mode 100644
index 0000000..93e9c9d
--- /dev/null
+++ b/lib/server-ref/src/main/java/org/apache/olingo/server/core/testutil/techprovider/EdmTechProvider.java
@@ -0,0 +1,147 @@
+/*
+ * 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.testutil.techprovider;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.server.api.edm.provider.Action;
+import org.apache.olingo.server.api.edm.provider.ActionImport;
+import org.apache.olingo.server.api.edm.provider.AliasInfo;
+import org.apache.olingo.server.api.edm.provider.ComplexType;
+import org.apache.olingo.server.api.edm.provider.EdmProvider;
+import org.apache.olingo.server.api.edm.provider.EntityContainer;
+import org.apache.olingo.server.api.edm.provider.EntityContainerInfo;
+import org.apache.olingo.server.api.edm.provider.EntitySet;
+import org.apache.olingo.server.api.edm.provider.EntityType;
+import org.apache.olingo.server.api.edm.provider.EnumType;
+import org.apache.olingo.server.api.edm.provider.Function;
+import org.apache.olingo.server.api.edm.provider.FunctionImport;
+import org.apache.olingo.server.api.edm.provider.Schema;
+import org.apache.olingo.server.api.edm.provider.Singleton;
+import org.apache.olingo.server.api.edm.provider.Term;
+import org.apache.olingo.server.api.edm.provider.TypeDefinition;
+
+public class EdmTechProvider extends EdmProvider {
+
+ public static final String nameSpace = "com.sap.odata.test1";
+
+ private final SchemaProvider schemaProvider;
+ private final EntityTypeProvider entityTypeProvider;
+ private final ContainerProvider containerProvider;
+ private final ComplexTypeProvider complexTypeProvider;
+ private final EnumTypeProvider enumTypeProvider;
+ private final ActionProvider actionProvider;
+ private final FunctionProvider functionProvider;
+ private final TypeDefinitionProvider typeDefinitionProvider;
+
+ public EdmTechProvider() {
+ containerProvider = new ContainerProvider();
+ entityTypeProvider = new EntityTypeProvider();
+ complexTypeProvider = new ComplexTypeProvider();
+ enumTypeProvider = new EnumTypeProvider();
+ actionProvider = new ActionProvider();
+ functionProvider = new FunctionProvider();
+ typeDefinitionProvider = new TypeDefinitionProvider();
+ schemaProvider = new SchemaProvider(this);
+ }
+
+ @Override
+ public List<AliasInfo> getAliasInfos() throws ODataException {
+ return Arrays.asList(
+ new AliasInfo().setAlias("Namespace1_Alias").setNamespace(nameSpace)
+ );
+ }
+
+ @Override
+ public EnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException {
+ return enumTypeProvider.getEnumType(enumTypeName);
+ }
+
+ @Override
+ public TypeDefinition getTypeDefinition(final FullQualifiedName typeDefinitionName) throws ODataException {
+ return typeDefinitionProvider.getTypeDefinition(typeDefinitionName);
+ }
+
+ @Override
+ public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException {
+ return entityTypeProvider.getEntityType(entityTypeName);
+ }
+
+ @Override
+ public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException {
+ return complexTypeProvider.getComplexType(complexTypeName);
+ }
+
+ @Override
+ public List<Action> getActions(final FullQualifiedName actionName) throws ODataException {
+ return actionProvider.getActions(actionName);
+ }
+
+ @Override
+ public List<Function> getFunctions(final FullQualifiedName functionName) throws ODataException {
+ return functionProvider.getFunctions(functionName);
+ }
+
+ @Override
+ public Term getTerm(final FullQualifiedName termName) throws ODataException {
+ return null;
+ }
+
+ @Override
+ public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName)
+ throws ODataException {
+ return containerProvider.getEntitySet(entityContainer, entitySetName);
+ }
+
+ @Override
+ public Singleton getSingleton(final FullQualifiedName entityContainer, final String singletonName)
+ throws ODataException {
+ return containerProvider.getSingleton(entityContainer, singletonName);
+ }
+
+ @Override
+ public ActionImport getActionImport(final FullQualifiedName entityContainer, final String actionImportName)
+ throws ODataException {
+ return containerProvider.getActionImport(entityContainer, actionImportName);
+ }
+
+ @Override
+ public FunctionImport getFunctionImport(final FullQualifiedName entityContainer, final String functionImportName)
+ throws ODataException {
+ return containerProvider.getFunctionImport(entityContainer, functionImportName);
+ }
+
+ @Override
+ public List<Schema> getSchemas() throws ODataException {
+ return schemaProvider.getSchemas();
+ }
+
+ @Override
+ public EntityContainer getEntityContainer() throws ODataException {
+ return containerProvider.getEntityContainer();
+ }
+
+ @Override
+ public EntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName) throws ODataException {
+ return containerProvider.getEntityContainerInfo(entityContainerName);
+ }
+}