You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2013/12/06 15:51:38 UTC
[02/21] [OLINGO-77] Refactored java package names
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TokenValidator.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TokenValidator.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TokenValidator.java
new file mode 100644
index 0000000..32410ff
--- /dev/null
+++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TokenValidator.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.odata4.producer.core.testutil;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.List;
+
+import org.antlr.v4.runtime.ANTLRErrorListener;
+import org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.CharStream;
+import org.antlr.v4.runtime.Parser;
+import org.antlr.v4.runtime.RecognitionException;
+import org.antlr.v4.runtime.Recognizer;
+import org.antlr.v4.runtime.Token;
+import org.antlr.v4.runtime.atn.ATNConfigSet;
+import org.antlr.v4.runtime.dfa.DFA;
+import org.apache.olingo.producer.core.uri.antlr.UriLexer;
+
+public class TokenValidator {
+ private List<? extends Token> tokens = null;
+ private List<Exception> exceptions = new ArrayList<Exception>();
+ private Token curToken = null;
+ private Exception curException = null;
+ private String input = null;
+ private int logLevel = 0;
+
+ private int mode;
+
+ public TokenValidator run(final String uri) {
+ input = uri;
+ exceptions.clear();
+ tokens = parseInput(uri);
+ if (logLevel > 0) {
+ showTokens();
+ }
+
+ first();
+ exFirst();
+ return this;
+ }
+
+ 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;
+ }
+
+ public TokenValidator log(final int logLevel) {
+ this.logLevel = logLevel;
+ return this;
+ }
+
+ public TokenValidator isText(final String expected) {
+ assertEquals(expected, curToken.getText());
+ return this;
+ }
+
+ public TokenValidator isAllText(final String expected) {
+ String tmp = "";
+
+ for (Token curToken : tokens) {
+ tmp += curToken.getText();
+ }
+ assertEquals(expected, tmp);
+ return this;
+ }
+
+ public TokenValidator isAllInput() {
+ String tmp = "";
+
+ for (Token curToken : tokens) {
+ tmp += curToken.getText();
+ }
+ assertEquals(input, tmp);
+ 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()]);
+ assertEquals(UriLexer.tokenNames[expected], UriLexer.tokenNames[curToken.getType()]);
+ return this;
+ }
+
+ public TokenValidator isExType(final Class<?> exClass) {
+ assertEquals(exClass, curException.getClass());
+ return this;
+ }
+
+ private List<? extends Token> parseInput(final String input) {
+ ANTLRInputStream inputStream = new ANTLRInputStream(input);
+
+ UriLexer lexer = new TestUriLexer(this, inputStream, mode);
+ // lexer.setInSearch(searchMode);
+ // lexer.removeErrorListeners();
+ lexer.addErrorListener(new ErrorCollector(this));
+ return lexer.getAllTokens();
+ }
+
+ public TokenValidator first() {
+ try {
+ curToken = tokens.get(0);
+ } catch (IndexOutOfBoundsException ex) {
+ curToken = null;
+ }
+ return this;
+ }
+
+ public TokenValidator exFirst() {
+ try {
+ curException = exceptions.get(0);
+ } catch (IndexOutOfBoundsException ex) {
+ curException = null;
+ }
+ return this;
+
+ }
+
+ public TokenValidator last() {
+ curToken = tokens.get(tokens.size() - 1);
+ return this;
+ }
+
+ public TokenValidator exLast() {
+ curException = exceptions.get(exceptions.size() - 1);
+ return this;
+ }
+
+ public TokenValidator at(final int index) {
+ try {
+ curToken = tokens.get(index);
+ } catch (IndexOutOfBoundsException ex) {
+ curToken = null;
+ }
+ return this;
+ }
+
+ public TokenValidator exAt(final int index) {
+ try {
+ curException = exceptions.get(index);
+ } catch (IndexOutOfBoundsException ex) {
+ curException = null;
+ }
+ return this;
+ }
+
+ private static class TestUriLexer extends UriLexer {
+ private TokenValidator validator;
+
+ public TestUriLexer(final TokenValidator validator, final CharStream input, final int mode) {
+ super(input);
+ super.mode(mode);
+ this.validator = validator;
+ }
+
+ @Override
+ public void pushMode(final int m) {
+ if (validator.logLevel > 0) {
+ System.out.println("OnMode" + ": " + UriLexer.modeNames[m]);
+ }
+ super.pushMode(m);
+
+ }
+
+ @Override
+ public int popMode() {
+ int m = super.popMode();
+ if (validator.logLevel > 0) {
+ System.out.println("OnMode" + ": " + UriLexer.modeNames[m]);
+ }
+
+ return m;
+ }
+
+ }
+
+ private static class ErrorCollector implements ANTLRErrorListener {
+ TokenValidator tokenValidator;
+
+ public ErrorCollector(final TokenValidator tokenValidator) {
+ this.tokenValidator = tokenValidator;
+ }
+
+ @Override
+ public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line,
+ final int charPositionInLine,
+ final String msg, final RecognitionException e) {
+ tokenValidator.exceptions.add(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) {
+ fail("reportAmbiguity");
+ }
+
+ @Override
+ public void reportAttemptingFullContext(final Parser recognizer, final DFA dfa, final int startIndex,
+ final int stopIndex,
+ final BitSet conflictingAlts, final ATNConfigSet configs) {
+ fail("reportAttemptingFullContext");
+ }
+
+ @Override
+ public void reportContextSensitivity(final Parser recognizer, final DFA dfa, final int startIndex,
+ final int stopIndex, final int prediction,
+ final ATNConfigSet configs) {
+ fail("reportContextSensitivity");
+ }
+
+ }
+
+ public void globalMode(final int mode) {
+ this.mode = mode;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TokenWriter.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TokenWriter.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TokenWriter.java
new file mode 100644
index 0000000..ee9efbd
--- /dev/null
+++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TokenWriter.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * L icensed 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.odata4.producer.core.testutil;
+
+import org.antlr.v4.runtime.ParserRuleContext;
+import org.antlr.v4.runtime.tree.ErrorNode;
+import org.antlr.v4.runtime.tree.ParseTreeListener;
+import org.antlr.v4.runtime.tree.TerminalNode;
+
+public class TokenWriter implements ParseTreeListener {
+
+ @Override
+ public void visitTerminal(final TerminalNode node) {
+ /*
+ * String out = String.format("%1$-" + 20 + "s", node.getText()); ;
+ * int tokenType = node.getSymbol().getType();
+ * if (tokenType == -1 ) {
+ * out += "-1/EOF";
+ * } else {
+ * out += UriLexer.tokenNames[tokenType];
+ * }
+ * System.out.println(out);
+ */
+ }
+
+ @Override
+ public void visitErrorNode(final ErrorNode node) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void enterEveryRule(final ParserRuleContext ctx) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void exitEveryRule(final ParserRuleContext ctx) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TraceErrorHandler.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TraceErrorHandler.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TraceErrorHandler.java
new file mode 100644
index 0000000..4d218ca
--- /dev/null
+++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/TraceErrorHandler.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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.odata4.producer.core.testutil;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.antlr.v4.runtime.BaseErrorListener;
+import org.antlr.v4.runtime.Parser;
+import org.antlr.v4.runtime.RecognitionException;
+import org.antlr.v4.runtime.Recognizer;
+import org.apache.olingo.producer.core.uri.antlr.UriLexer;
+
+public class TraceErrorHandler<T> extends BaseErrorListener {
+ @Override
+ public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol,
+ final int line, final int charPositionInLine, final String msg, final RecognitionException e) {
+ System.err.println("-");
+ // check also http://stackoverflow.com/questions/14747952/ll-exact-ambig-detection-interpetation
+ List<String> stack = ((Parser) recognizer).getRuleInvocationStack();
+ Collections.reverse(stack);
+ System.err.println("rule stack: " + stack);
+ if (e != null && e.getOffendingToken() != null) {
+
+ // String lexerTokenName =TestSuiteLexer.tokenNames[e.getOffendingToken().getType()];
+ String lexerTokenName = "";
+ try {
+ lexerTokenName = UriLexer.tokenNames[e.getOffendingToken().getType()];
+ } catch (ArrayIndexOutOfBoundsException es) {
+ lexerTokenName = "token error";
+ }
+ System.err.println("line " + line + ":" + charPositionInLine + " at " +
+ offendingSymbol + "/" + lexerTokenName + ": " + msg);
+ } else {
+ System.err.println("line " + line + ":" + charPositionInLine + " at " + offendingSymbol + ": " + msg);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriResourcePathValidator.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriResourcePathValidator.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriResourcePathValidator.java
new file mode 100644
index 0000000..b6a45bb
--- /dev/null
+++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriResourcePathValidator.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.odata4.producer.core.testutil;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.olingo.odata4.commons.api.edm.Edm;
+import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
+import org.apache.olingo.odata4.producer.api.uri.UriPathInfoKind;
+import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
+import org.apache.olingo.odata4.producer.core.uri.UriParserImpl;
+import org.apache.olingo.odata4.producer.core.uri.UriPathInfoImpl;
+
+public class UriResourcePathValidator {
+ UriInfoImpl uriInfo = null;
+ UriPathInfoImpl uriPathInfo = null; // last
+ private Edm edm;
+
+ public UriResourcePathValidator setEdm(final Edm edm) {
+ this.edm = edm;
+ return this;
+ }
+
+ public UriResourcePathValidator run(final String uri) {
+ uriInfo = parseUri(uri);
+ last();
+ return this;
+ }
+
+ public UriResourcePathValidator isUriPathInfoKind(final UriPathInfoKind infoType) {
+
+ assertNotNull(uriPathInfo);
+ assertEquals(infoType, uriPathInfo.getKind());
+ return this;
+ }
+
+ private UriInfoImpl parseUri(final String uri) {
+ UriParserImpl reader = new UriParserImpl();
+ UriInfoImpl uriInfo = reader.readUri(uri, edm);
+ return uriInfo;
+ }
+
+ public UriResourcePathValidator last() {
+ // TODO implement
+ // uriPathInfo = uriInfo.getLastUriPathInfo();
+ return this;
+ }
+
+ public UriResourcePathValidator at(final int index) {
+ try {
+ // uriPathInfo = uriInfo.getUriPathInfo(index);
+ } catch (IndexOutOfBoundsException ex) {
+ uriPathInfo = null;
+ }
+ return this;
+ }
+
+ public UriResourcePathValidator first() {
+ try {
+ // uriPathInfo = uriInfo.getUriPathInfo(0);
+ } catch (IndexOutOfBoundsException ex) {
+ uriPathInfo = null;
+ }
+ return this;
+ }
+
+ public void isKind(final UriInfoKind batch) {
+
+ assertEquals(batch, uriInfo.getKind());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/producer/core/testutil/EdmMock.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/producer/core/testutil/EdmMock.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/producer/core/testutil/EdmMock.java
deleted file mode 100644
index 1910190..0000000
--- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/producer/core/testutil/EdmMock.java
+++ /dev/null
@@ -1,743 +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.producer.core.testutil;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-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.EdmComplexType;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.commons.api.edm.EdmEntitySet;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.EdmEnumType;
-import org.apache.olingo.commons.api.edm.EdmFunction;
-import org.apache.olingo.commons.api.edm.EdmFunctionImport;
-import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef;
-import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmProperty;
-import org.apache.olingo.commons.api.edm.EdmReturnType;
-import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
-import org.apache.olingo.commons.api.edm.EdmSingleton;
-import org.apache.olingo.commons.api.edm.EdmStructuralType;
-import org.apache.olingo.commons.api.edm.EdmType;
-import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
-import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
-import org.apache.olingo.commons.api.edm.helper.FullQualifiedName;
-
-public class EdmMock implements Edm {
- public static final String NAMESPACE_SCHEMA = "RefScenario";
- public static final FullQualifiedName CONTAINER_NAME = new FullQualifiedName(NAMESPACE_SCHEMA, "Container1");
-
- public static final FullQualifiedName ACTION_IMPORT1_NAME = new FullQualifiedName(NAMESPACE_SCHEMA, "actionImport1");
- public static final FullQualifiedName COMPANY_SINGLETON_NAME = new FullQualifiedName(NAMESPACE_SCHEMA, "Company");
- public static final FullQualifiedName TEAMS_SET_NAME = new FullQualifiedName(NAMESPACE_SCHEMA, "Teams");
- public static final FullQualifiedName MANAGERS_SET_NAME = new FullQualifiedName(NAMESPACE_SCHEMA, "Managers");
- public static final FullQualifiedName EMPLOYEES_SET_NAME = new FullQualifiedName(NAMESPACE_SCHEMA, "Employees");
- public static final FullQualifiedName EMPLOYEES_TYPE_NAME = new FullQualifiedName(NAMESPACE_SCHEMA, "EmployeeType");
- public static final FullQualifiedName TEAMS_TYPE_NAME = new FullQualifiedName(NAMESPACE_SCHEMA, "TeamType");
- public static final FullQualifiedName MANAGERS_TYPE_NAME = new FullQualifiedName(NAMESPACE_SCHEMA, "ManagerType");
- public static final FullQualifiedName COMPANY_TYPE_NAME = new FullQualifiedName(NAMESPACE_SCHEMA, "CompanyType");
- public static final FullQualifiedName FUNCTION1_NAME = new FullQualifiedName(NAMESPACE_SCHEMA, "function1");
- public static final FullQualifiedName FUNCTION_MAXIMAL_AGE_NAME = new FullQualifiedName(NAMESPACE_SCHEMA,
- "MaximalAge");
- public static final FullQualifiedName FUNCTION_EMPLOYEE_SEARCH_NAME = new FullQualifiedName(NAMESPACE_SCHEMA,
- "EmployeeSearch");
- public static final FullQualifiedName FUNCTION_ALL_USED_ROOMS_NAME = new FullQualifiedName(NAMESPACE_SCHEMA,
- "AllUsedRoomIds");
- public static final FullQualifiedName FUNCTION_MOST_COMMON_LOCATION_NAME = new FullQualifiedName(NAMESPACE_SCHEMA,
- "MostCommonLocation");
- public static final FullQualifiedName FUNCTION_ALL_LOCATIONS_NAME = new FullQualifiedName(NAMESPACE_SCHEMA,
- "AllLocations");
- public static final FullQualifiedName ACTION1_NAME = new FullQualifiedName(NAMESPACE_SCHEMA, "action1");
- public static final FullQualifiedName TYPE_DEF1_NAME = new FullQualifiedName(NAMESPACE_SCHEMA, "tdtypeDef1");
- public static final FullQualifiedName RATING_ENUM_TYPE_NAME = new FullQualifiedName(NAMESPACE_SCHEMA, "eRating");
- public static final FullQualifiedName LOCATION_TYPE_NAME = new FullQualifiedName(NAMESPACE_SCHEMA, "cLocation");
- public static final FullQualifiedName NON_BINDING_PARAMETER = new FullQualifiedName(NAMESPACE_SCHEMA,
- "NonBindingParameter");
-
- public static final FullQualifiedName FUNCTION_IMPORT1_NAME = new FullQualifiedName(NAMESPACE_SCHEMA,
- "functionImport1");
- public static final FullQualifiedName FUNCTION_IMPORT_EMPLOYEE_SEARCH_NAME = new FullQualifiedName(NAMESPACE_SCHEMA,
- "EmployeeSearch");
- public static final FullQualifiedName FUNCTION_IMPORT_MAXIMAL_AGE_NAME = new FullQualifiedName(NAMESPACE_SCHEMA,
- "MaximalAge");
- public static final FullQualifiedName FUNCTION_IMPORT_ALL_USED_ROOMS_NAME = new FullQualifiedName(NAMESPACE_SCHEMA,
- "AllUsedRoomIds");
- public static final FullQualifiedName FUNCTION_IMPORT_MOST_COMMON_LOCATION_NAME = new FullQualifiedName(
- NAMESPACE_SCHEMA, "MostCommonLocation");
- public static final FullQualifiedName FUNCTION_IMPORT_ALL_LOCATIONS_NAME = new FullQualifiedName(NAMESPACE_SCHEMA,
- "AllLocations");
- public static final FullQualifiedName BOUND_FUNCTION_ENTITY_SET_RT_ENTITY_NAME = new FullQualifiedName(
- NAMESPACE_SCHEMA, "bf_entity_set_rt_entity");
- public static final FullQualifiedName BOUND_FUNCTION_ENTITY_SET_RT_ENTITY_SET_NAME = new FullQualifiedName(
- NAMESPACE_SCHEMA, "bf_entity_set_rt_entity_set");
- public static final FullQualifiedName BOUND_FUNCTION_PPROP_RT_ENTITY_SET_NAME = new FullQualifiedName(
- NAMESPACE_SCHEMA, "bf_pprop_rt_entity_set");
- public static final FullQualifiedName BOUND_FUNCTION_ENTITY_SET_RT_PPROP_NAME = new FullQualifiedName(
- NAMESPACE_SCHEMA, "bf_entity_set_rt_pprop");
- public static final FullQualifiedName BOUND_FUNCTION_ENTITY_SET_RT_CPROP_NAME = new FullQualifiedName(
- NAMESPACE_SCHEMA, "bf_entity_set_rt_cprop");
- public static final FullQualifiedName BOUND_FUNCTION_ENTITY_SET_RT_CPROP_COLL_NAME = new FullQualifiedName(
- NAMESPACE_SCHEMA, "bf_entity_set_rt_cprop_coll");
- public static final FullQualifiedName BOUND_FUNCTION_ENTITY_SET_RT_PPROP_COLL_NAME = new FullQualifiedName(
- NAMESPACE_SCHEMA, "bf_entity_set_rt_pprop_coll");
- public static final FullQualifiedName BOUND_FUNCTION_SINGLETON_RT_ENTITY_SET_NAME = new FullQualifiedName(
- NAMESPACE_SCHEMA, "bf_singleton_rt_entity_set");
- public static final FullQualifiedName BOUND_ACTION_PPROP_RT_ENTITY_SET_NAME = new FullQualifiedName(NAMESPACE_SCHEMA,
- "ba_pprop_rt_entity_set");
- public static final FullQualifiedName BOUND_ACTION_ENTITY_RT_ENTITY_NAME = new FullQualifiedName(NAMESPACE_SCHEMA,
- "ba_entity_rt_entity");
- public static final FullQualifiedName BOUND_ACTION_ENTITY_RT_PPROP_NAME = new FullQualifiedName(NAMESPACE_SCHEMA,
- "ba_entity_rt_pprop");
- public static final FullQualifiedName BOUND_ACTION_ENTITY_RT_PPROP_COLL_NAME = new FullQualifiedName(
- NAMESPACE_SCHEMA, "ba_entity_rt_pprop_coll");
- public static final FullQualifiedName BOUND_ACTION_ENTITY_SET_RT_CPROP_NAME = new FullQualifiedName(NAMESPACE_SCHEMA,
- "ba_entity_set_rt_cprop");
-
- private final EdmEntityType companyType = mock(EdmEntityType.class);
- private final EdmEntityType managerType = mock(EdmEntityType.class);
- private final EdmEntityType employeeType = mock(EdmEntityType.class);
- private final EdmEntityType teamType = mock(EdmEntityType.class);
-
- private final EdmFunction function1 = mock(EdmFunction.class);
- private final EdmFunction maximalAgeFunction = mock(EdmFunction.class);
- private final EdmFunction mostCommonLocationFunction = mock(EdmFunction.class);
- private final EdmFunction allUsedRoomIdsFunction = mock(EdmFunction.class);
- private final EdmFunction employeeSearchFunction = mock(EdmFunction.class);
- private final EdmFunction allLocationsFunction = mock(EdmFunction.class);
-
- private final EdmFunction boundFunctionEntitySetRtEntity = mock(EdmFunction.class);
- private final EdmFunction boundEntityColFunction = mock(EdmFunction.class);
- private final EdmFunction boundFunctionPPropRtEntitySet = mock(EdmFunction.class);
- private final EdmFunction boundFunctionEntitySetRtPProp = mock(EdmFunction.class);
- private final EdmFunction boundFunctionEntitySetRtCProp = mock(EdmFunction.class);
- private final EdmFunction boundFunctionEntitySetRtCPropColl = mock(EdmFunction.class);
- private final EdmFunction boundFunctionEntitySetRtPPropColl = mock(EdmFunction.class);
- private final EdmFunction boundFunctionSingletonRtEntitySet = mock(EdmFunction.class);
-
- private final EdmAction action1 = mock(EdmAction.class);
- private final EdmAction boundActionPpropRtEntitySet = mock(EdmAction.class);
- private final EdmAction boundActionEntityRtEntity = mock(EdmAction.class);
- private final EdmAction boundActionEntityRtPProp = mock(EdmAction.class);
- private final EdmAction boundActionEntityRtPPropColl = mock(EdmAction.class);
- private final EdmAction boundActionEntitySetRtCProp = mock(EdmAction.class);
- private final EdmEnumType ratingEnumType = mock(EdmEnumType.class);
- private final EdmTypeDefinition typeDef1 = mock(EdmTypeDefinition.class);
- private final EdmComplexType locationType = mock(EdmComplexType.class);
-
- private final EdmEntitySet employeesSet = mock(EdmEntitySet.class);
- private final EdmEntitySet managersSet = mock(EdmEntitySet.class);
- private final EdmEntitySet teamsSet = mock(EdmEntitySet.class);
- private final EdmSingleton company = mock(EdmSingleton.class);
- private final EdmActionImport actionImport1 = mock(EdmActionImport.class);
- private final EdmFunctionImport functionImport1 = mock(EdmFunctionImport.class);
- private final EdmFunctionImport employeeSearchFunctionImport = mock(EdmFunctionImport.class);
- private final EdmFunctionImport maximalAgeFunctionImport = mock(EdmFunctionImport.class);
- private final EdmFunctionImport mostCommonLocationFunctionImport = mock(EdmFunctionImport.class);
- private final EdmFunctionImport allUsedRoomIdsFunctionImport = mock(EdmFunctionImport.class);
- private final EdmFunctionImport allLocationsFunctionImport = mock(EdmFunctionImport.class);
- private final EdmEntityContainer container1 = mock(EdmEntityContainer.class);
-
- public EdmMock() {
- enhanceEmployeesEntitySet();
- enhanceManagersEntitySet();
- enhanceTeamsEntitySet();
- enhanceCompany();
- enhanceContainer1();
-
- enhanceEmployeeType();
- enhanceManagerType();
- enhanceTeamType();
- enhanceCompanyType();
- enhanceLocationType();
-
- enhanceActionImport1();
- enhanceFunctionImport1();
- enhanceFunctionImportEmployeeSearch();
- enhanceMaximalAgeFunctionImport();
- enhanceMostCommonLocationFunctionImport();
- enhanceAllUsedRoomIdsFunctionImport();
- enhanceAllLocationsFunctionImport();
-
- enhanceAction1();
- enhanceFunction1();
- enhanceFunctionEmployeeSearch();
- enhanceMaximalAgeFunction();
- enhanceMostCommonLocationFunction();
- enhanceAllUsedRoomIdsFunction();
- enhanceAllLocationsFunction();
- enhanceBoundEntityFunction();
- enhanceBoundFunctionEntitySetRtEntitySet();
- enhanceBoundFunctionPPropRtEntitySet();
- enhanceBoundFunctionEntitySetRtPProp();
- enhanceBoundFunctionEntitySetRtPPropColl();
- enhanceBoundFunctionEntitySetRtCProp();
- enhanceBoundFunctionEntitySetRtCPropColl();
- enhanceBoundFunctionSingletonRtEntitySet();
- enhanceBoundActionPPropRtEntitySet();
- enhanceBoundActionEntityRtEntity();
- enhanceBoundActionEntityRtPProp();
- enhanceBoundActionEntityRtPPropColl();
- enhanceBoundActionEntitySetRtCProp();
- }
-
- private void enhanceTeamType() {
- when(teamType.getName()).thenReturn(TEAMS_TYPE_NAME.getName());
- when(teamType.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
- when(teamType.getKind()).thenReturn(EdmTypeKind.ENTITY);
- when(teamType.hasStream()).thenReturn(false);
- List<String> keyPredicateNames = new ArrayList<String>();
- when(teamType.getKeyPredicateNames()).thenReturn(keyPredicateNames);
- List<EdmKeyPropertyRef> keyPropertyRefs = new ArrayList<EdmKeyPropertyRef>();
- when(teamType.getKeyPropertyRefs()).thenReturn(keyPropertyRefs);
- List<String> navigationNames = new ArrayList<String>();
- when(teamType.getNavigationPropertyNames()).thenReturn(navigationNames);
- List<String> propertyNames = new ArrayList<String>();
- when(teamType.getPropertyNames()).thenReturn(propertyNames);
-
- addKeyProperty(teamType, "Id");
-
- addNavigationProperty(teamType, "nt_Employees", true, employeeType);
-
- addProperty(teamType, "Name", true, mock(EdmPrimitiveType.class));
- addProperty(teamType, "IsScrumTeam", true, mock(EdmPrimitiveType.class));
- addProperty(teamType, "Rating", true, mock(EdmPrimitiveType.class));
- }
-
- private void enhanceManagerType() {
- when(managerType.getName()).thenReturn(MANAGERS_TYPE_NAME.getName());
- when(managerType.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
- when(managerType.getKind()).thenReturn(EdmTypeKind.ENTITY);
- when(managerType.hasStream()).thenReturn(true);
- when(managerType.getBaseType()).thenReturn(employeeType);
- List<String> keyPredicateNames = new ArrayList<String>();
- when(managerType.getKeyPredicateNames()).thenReturn(keyPredicateNames);
- List<EdmKeyPropertyRef> keyPropertyRefs = new ArrayList<EdmKeyPropertyRef>();
- when(managerType.getKeyPropertyRefs()).thenReturn(keyPropertyRefs);
- List<String> navigationNames = new ArrayList<String>();
- when(managerType.getNavigationPropertyNames()).thenReturn(navigationNames);
- List<String> propertyNames = new ArrayList<String>();
- when(managerType.getPropertyNames()).thenReturn(propertyNames);
-
- addKeyProperty(managerType, "EmployeeId");
-
- addNavigationProperty(managerType, "ne_Manager", false, managerType);
- addNavigationProperty(managerType, "ne_Team", false, teamType);
- addNavigationProperty(managerType, "nm_Employees", true, employeeType);
-
- addProperty(managerType, "EmployeeName", true, mock(EdmPrimitiveType.class));
- addProperty(managerType, "ManagerId", true, mock(EdmPrimitiveType.class));
- addProperty(managerType, "Location", false, locationType);
- addProperty(managerType, "Age", true, mock(EdmPrimitiveType.class));
- addProperty(managerType, "EntryDate", true, mock(EdmPrimitiveType.class));
- addProperty(managerType, "ImageUrl", true, mock(EdmPrimitiveType.class));
- }
-
- // when().thenReturn();
- private void enhanceEmployeeType() {
- when(employeeType.getName()).thenReturn(EMPLOYEES_TYPE_NAME.getName());
- when(employeeType.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
- when(employeeType.getKind()).thenReturn(EdmTypeKind.ENTITY);
- when(employeeType.hasStream()).thenReturn(true);
- List<String> keyPredicateNames = new ArrayList<String>();
- when(employeeType.getKeyPredicateNames()).thenReturn(keyPredicateNames);
- List<EdmKeyPropertyRef> keyPropertyRefs = new ArrayList<EdmKeyPropertyRef>();
- when(employeeType.getKeyPropertyRefs()).thenReturn(keyPropertyRefs);
- List<String> navigationNames = new ArrayList<String>();
- when(employeeType.getNavigationPropertyNames()).thenReturn(navigationNames);
- List<String> propertyNames = new ArrayList<String>();
- when(employeeType.getPropertyNames()).thenReturn(propertyNames);
-
- addKeyProperty(employeeType, "EmployeeId");
-
- addNavigationProperty(employeeType, "ne_Manager", false, managerType);
- addNavigationProperty(employeeType, "ne_Team", false, teamType);
-
- addProperty(employeeType, "EmployeeName", true, mock(EdmPrimitiveType.class));
- addProperty(employeeType, "ManagerId", true, mock(EdmPrimitiveType.class));
- addProperty(employeeType, "Location", false, locationType);
- addProperty(employeeType, "Age", true, mock(EdmPrimitiveType.class));
- addProperty(employeeType, "EntryDate", true, mock(EdmPrimitiveType.class));
- addProperty(employeeType, "ImageUrl", true, mock(EdmPrimitiveType.class));
- }
-
- private void enhanceLocationType() {
- addProperty(locationType, "Country", true, mock(EdmPrimitiveType.class));
- when(locationType.getName()).thenReturn(LOCATION_TYPE_NAME.getName());
- }
-
- private void enhanceCompanyType() {
- when(companyType.getName()).thenReturn(COMPANY_TYPE_NAME.getName());
- when(companyType.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
- when(companyType.getKind()).thenReturn(EdmTypeKind.ENTITY);
- }
-
- private void addNavigationProperty(final EdmEntityType entityType, final String propertyName,
- final boolean isCollection, final EdmType type) {
- EdmNavigationProperty property = mock(EdmNavigationProperty.class);
- entityType.getNavigationPropertyNames().add(propertyName);
- when(property.getName()).thenReturn(propertyName);
- when(entityType.getProperty(propertyName)).thenReturn(property);
- when(property.isCollection()).thenReturn(isCollection);
- when(property.getType()).thenReturn(type);
- }
-
- private void addKeyProperty(final EdmEntityType entityType, final String propertyName) {
- entityType.getKeyPredicateNames().add(propertyName);
- EdmProperty keyProp = addProperty(entityType, propertyName, true, mock(EdmPrimitiveType.class));
- EdmKeyPropertyRef keyRef = mock(EdmKeyPropertyRef.class);
- when(keyRef.getKeyPropertyName()).thenReturn(propertyName);
- when(keyRef.getProperty()).thenReturn(keyProp);
- entityType.getKeyPropertyRefs().add(keyRef);
- when(entityType.getKeyPropertyRef(propertyName)).thenReturn(keyRef);
- }
-
- private EdmProperty addProperty(final EdmStructuralType structuralType, final String propertyName,
- final boolean isPrimitive, final EdmType type) {
- EdmProperty property = mock(EdmProperty.class);
- when(property.getName()).thenReturn(propertyName);
- structuralType.getPropertyNames().add(propertyName);
- when(structuralType.getProperty(propertyName)).thenReturn(property);
- when(property.isPrimitive()).thenReturn(isPrimitive);
- when(property.getType()).thenReturn(type);
- return property;
- }
-
- private void enhanceContainer1() {
- when(container1.getName()).thenReturn(CONTAINER_NAME.getName());
- when(container1.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
-
- when(container1.getEntitySet(EMPLOYEES_SET_NAME.getName())).thenReturn(employeesSet);
- when(container1.getEntitySet(MANAGERS_SET_NAME.getName())).thenReturn(managersSet);
- when(container1.getEntitySet(TEAMS_SET_NAME.getName())).thenReturn(teamsSet);
- when(container1.getSingleton(COMPANY_SINGLETON_NAME.getName())).thenReturn(company);
- when(container1.getActionImport(ACTION_IMPORT1_NAME.getName())).thenReturn(actionImport1);
- when(container1.getFunctionImport(FUNCTION_IMPORT1_NAME.getName())).thenReturn(functionImport1);
- when(container1.getFunctionImport(FUNCTION_IMPORT_MAXIMAL_AGE_NAME.getName())).thenReturn(maximalAgeFunctionImport);
- when(container1.getFunctionImport(FUNCTION_IMPORT_MOST_COMMON_LOCATION_NAME.getName())).thenReturn(
- mostCommonLocationFunctionImport);
- when(container1.getFunctionImport(FUNCTION_IMPORT_ALL_USED_ROOMS_NAME.getName())).thenReturn(
- allUsedRoomIdsFunctionImport);
- when(container1.getFunctionImport(FUNCTION_IMPORT_EMPLOYEE_SEARCH_NAME.getName())).thenReturn(
- employeeSearchFunctionImport);
- when(container1.getFunctionImport(FUNCTION_IMPORT_ALL_LOCATIONS_NAME.getName())).thenReturn(
- allLocationsFunctionImport);
-
- /*
- * when(container1.getElement(EMPLOYEES_SET_NAME.getName())).thenReturn(employeesSet);
- * when(container1.getElement(TEAMS_SET_NAME.getName())).thenReturn(teamsSet);
- * when(container1.getElement(COMPANY_SINGLETON_NAME.getName())).thenReturn(company);
- * when(container1.getElement(ACTION_IMPORT1_NAME.getName())).thenReturn(actionImport1);
- * when(container1.getElement(FUNCTION_IMPORT_MAXIMAL_AGE_NAME.getName())).thenReturn(maximalAgeFunctionImport);
- */
- }
-
- private void enhanceActionImport1() {
- when(actionImport1.getName()).thenReturn(ACTION_IMPORT1_NAME.getName());
- when(actionImport1.getEntityContainer()).thenReturn(container1);
- when(actionImport1.getReturnedEntitySet()).thenReturn(employeesSet);
- when(actionImport1.getAction()).thenReturn(action1);
- }
-
- private void enhanceFunctionImport1() {
- when(functionImport1.getName()).thenReturn(FUNCTION_IMPORT1_NAME.getName());
- when(functionImport1.getEntityContainer()).thenReturn(container1);
- when(functionImport1.getReturnedEntitySet()).thenReturn(teamsSet);
- when(functionImport1.getFunction(null)).thenReturn(function1);
- }
-
- private void enhanceFunctionImportEmployeeSearch() {
- when(employeeSearchFunctionImport.getName()).thenReturn(FUNCTION_IMPORT_EMPLOYEE_SEARCH_NAME.getName());
- when(employeeSearchFunctionImport.getEntityContainer()).thenReturn(container1);
- when(employeeSearchFunctionImport.getReturnedEntitySet()).thenReturn(teamsSet);
- when(employeeSearchFunctionImport.getFunction(null)).thenReturn(employeeSearchFunction);
- }
-
- private void enhanceFunctionEmployeeSearch() {
- when(employeeSearchFunction.getName()).thenReturn(FUNCTION1_NAME.getName());
- when(employeeSearchFunction.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(employeeSearchFunction.getReturnType().isCollection()).thenReturn(true);
- when(employeeSearchFunction.getReturnType().getType()).thenReturn(employeeType);
- }
-
- private void enhanceMaximalAgeFunctionImport() {
- when(maximalAgeFunctionImport.getName()).thenReturn(FUNCTION_IMPORT_MAXIMAL_AGE_NAME.getName());
- when(maximalAgeFunctionImport.getEntityContainer()).thenReturn(container1);
- when(maximalAgeFunctionImport.getFunction(null)).thenReturn(maximalAgeFunction);
- }
-
- private void enhanceMaximalAgeFunction() {
- when(maximalAgeFunction.getName()).thenReturn(FUNCTION_MAXIMAL_AGE_NAME.getName());
- when(maximalAgeFunction.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(maximalAgeFunction.getReturnType().isCollection()).thenReturn(false);
- when(maximalAgeFunction.getReturnType().getType()).thenReturn(mock(EdmPrimitiveType.class));
-
- }
-
- private void enhanceAllUsedRoomIdsFunctionImport() {
- when(allUsedRoomIdsFunctionImport.getName()).thenReturn(FUNCTION_IMPORT_ALL_USED_ROOMS_NAME.getName());
- when(allUsedRoomIdsFunctionImport.getEntityContainer()).thenReturn(container1);
- when(allUsedRoomIdsFunctionImport.getFunction(null)).thenReturn(allUsedRoomIdsFunction);
- }
-
- private void enhanceAllUsedRoomIdsFunction() {
- when(allUsedRoomIdsFunction.getName()).thenReturn(FUNCTION_ALL_USED_ROOMS_NAME.getName());
- when(allUsedRoomIdsFunction.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(allUsedRoomIdsFunction.getReturnType().isCollection()).thenReturn(true);
- when(allUsedRoomIdsFunction.getReturnType().getType()).thenReturn(mock(EdmPrimitiveType.class));
-
- }
-
- private void enhanceMostCommonLocationFunctionImport() {
- when(mostCommonLocationFunctionImport.getName()).thenReturn(FUNCTION_IMPORT_MOST_COMMON_LOCATION_NAME.getName());
- when(mostCommonLocationFunctionImport.getEntityContainer()).thenReturn(container1);
- when(mostCommonLocationFunctionImport.getFunction(null)).thenReturn(mostCommonLocationFunction);
- }
-
- private void enhanceMostCommonLocationFunction() {
- when(mostCommonLocationFunction.getName()).thenReturn(FUNCTION_MOST_COMMON_LOCATION_NAME.getName());
- when(mostCommonLocationFunction.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(mostCommonLocationFunction.getReturnType().isCollection()).thenReturn(false);
- when(mostCommonLocationFunction.getReturnType().getType()).thenReturn(locationType);
-
- }
-
- private void enhanceAllLocationsFunctionImport() {
- when(allLocationsFunctionImport.getName()).thenReturn(FUNCTION_IMPORT_ALL_LOCATIONS_NAME.getName());
- when(allLocationsFunctionImport.getEntityContainer()).thenReturn(container1);
- when(allLocationsFunctionImport.getFunction(null)).thenReturn(allLocationsFunction);
- }
-
- private void enhanceAllLocationsFunction() {
- when(allLocationsFunction.getName()).thenReturn(FUNCTION_ALL_LOCATIONS_NAME.getName());
- when(allLocationsFunction.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(allLocationsFunction.getReturnType().isCollection()).thenReturn(true);
- when(allLocationsFunction.getReturnType().getType()).thenReturn(locationType);
-
- }
-
- private void enhanceBoundEntityFunction() {
- when(boundFunctionEntitySetRtEntity.getName()).thenReturn(BOUND_FUNCTION_ENTITY_SET_RT_ENTITY_NAME.getName());
- when(boundFunctionEntitySetRtEntity.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(boundFunctionEntitySetRtEntity.getReturnType().isCollection()).thenReturn(false);
- when(boundFunctionEntitySetRtEntity.getReturnType().getType()).thenReturn(employeeType);
- when(boundFunctionEntitySetRtEntity.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
- when(boundFunctionEntitySetRtEntity.isBound()).thenReturn(true);
- }
-
- private void enhanceBoundFunctionEntitySetRtEntitySet() {
- when(boundEntityColFunction.getName()).thenReturn(BOUND_FUNCTION_ENTITY_SET_RT_ENTITY_SET_NAME.getName());
- when(boundEntityColFunction.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(boundEntityColFunction.getReturnType().isCollection()).thenReturn(true);
- when(boundEntityColFunction.getReturnType().getType()).thenReturn(employeeType);
- when(boundEntityColFunction.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
- when(boundEntityColFunction.isBound()).thenReturn(true);
- }
-
- private void enhanceBoundFunctionPPropRtEntitySet() {
- when(boundFunctionPPropRtEntitySet.getName()).thenReturn(BOUND_FUNCTION_PPROP_RT_ENTITY_SET_NAME.getName());
- when(boundFunctionPPropRtEntitySet.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(boundFunctionPPropRtEntitySet.getReturnType().isCollection()).thenReturn(true);
- when(boundFunctionPPropRtEntitySet.getReturnType().getType()).thenReturn(employeeType);
- when(boundFunctionPPropRtEntitySet.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
- when(boundFunctionPPropRtEntitySet.isBound()).thenReturn(true);
- }
-
- private void enhanceBoundFunctionEntitySetRtPProp() {
- when(boundFunctionEntitySetRtPProp.getName()).thenReturn(BOUND_FUNCTION_ENTITY_SET_RT_PPROP_NAME.getName());
- when(boundFunctionEntitySetRtPProp.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(boundFunctionEntitySetRtPProp.getReturnType().isCollection()).thenReturn(false);
- EdmPrimitiveType primitiveType = mock(EdmPrimitiveType.class);
- when(boundFunctionEntitySetRtPProp.getReturnType().getType()).thenReturn(primitiveType);
- when(boundFunctionEntitySetRtPProp.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
- when(boundFunctionEntitySetRtPProp.isBound()).thenReturn(true);
- }
-
- private void enhanceBoundFunctionEntitySetRtPPropColl() {
- when(boundFunctionEntitySetRtPPropColl.getName())
- .thenReturn(BOUND_FUNCTION_ENTITY_SET_RT_PPROP_COLL_NAME.getName());
- when(boundFunctionEntitySetRtPPropColl.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(boundFunctionEntitySetRtPPropColl.getReturnType().isCollection()).thenReturn(true);
- EdmPrimitiveType primitiveType = mock(EdmPrimitiveType.class);
- when(boundFunctionEntitySetRtPPropColl.getReturnType().getType()).thenReturn(primitiveType);
- when(boundFunctionEntitySetRtPPropColl.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
- when(boundFunctionEntitySetRtPPropColl.isBound()).thenReturn(true);
- }
-
- private void enhanceBoundFunctionEntitySetRtCProp() {
- when(boundFunctionEntitySetRtCProp.getName()).thenReturn(BOUND_FUNCTION_ENTITY_SET_RT_CPROP_NAME.getName());
- when(boundFunctionEntitySetRtCProp.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(boundFunctionEntitySetRtCProp.getReturnType().isCollection()).thenReturn(false);
- when(boundFunctionEntitySetRtCProp.getReturnType().getType()).thenReturn(locationType);
- when(boundFunctionEntitySetRtCProp.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
- when(boundFunctionEntitySetRtCProp.isBound()).thenReturn(true);
- }
-
- private void enhanceBoundFunctionEntitySetRtCPropColl() {
- when(boundFunctionEntitySetRtCPropColl.getName())
- .thenReturn(BOUND_FUNCTION_ENTITY_SET_RT_CPROP_COLL_NAME.getName());
- when(boundFunctionEntitySetRtCPropColl.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(boundFunctionEntitySetRtCPropColl.getReturnType().isCollection()).thenReturn(true);
- when(boundFunctionEntitySetRtCPropColl.getReturnType().getType()).thenReturn(locationType);
- when(boundFunctionEntitySetRtCPropColl.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
- when(boundFunctionEntitySetRtCPropColl.isBound()).thenReturn(true);
- }
-
- private void enhanceBoundFunctionSingletonRtEntitySet() {
- when(boundFunctionSingletonRtEntitySet.getName()).thenReturn(BOUND_FUNCTION_SINGLETON_RT_ENTITY_SET_NAME.getName());
- when(boundFunctionSingletonRtEntitySet.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(boundFunctionSingletonRtEntitySet.getReturnType().isCollection()).thenReturn(true);
- when(boundFunctionSingletonRtEntitySet.getReturnType().getType()).thenReturn(employeeType);
- when(boundFunctionSingletonRtEntitySet.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
- when(boundFunctionSingletonRtEntitySet.isBound()).thenReturn(true);
- }
-
- private void enhanceBoundActionPPropRtEntitySet() {
- when(boundActionPpropRtEntitySet.getName()).thenReturn(BOUND_ACTION_PPROP_RT_ENTITY_SET_NAME.getName());
- when(boundActionPpropRtEntitySet.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(boundActionPpropRtEntitySet.getReturnType().isCollection()).thenReturn(true);
- when(boundActionPpropRtEntitySet.getReturnType().getType()).thenReturn(employeeType);
- when(boundActionPpropRtEntitySet.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
- when(boundActionPpropRtEntitySet.isBound()).thenReturn(true);
- }
-
- private void enhanceBoundActionEntityRtEntity() {
- when(boundActionEntityRtEntity.getName()).thenReturn(BOUND_ACTION_ENTITY_RT_ENTITY_NAME.getName());
- when(boundActionEntityRtEntity.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(boundActionEntityRtEntity.getReturnType().isCollection()).thenReturn(false);
- when(boundActionEntityRtEntity.getReturnType().getType()).thenReturn(employeeType);
- when(boundActionEntityRtEntity.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
- when(boundActionEntityRtEntity.isBound()).thenReturn(true);
- }
-
- private void enhanceBoundActionEntityRtPProp() {
- when(boundActionEntityRtPProp.getName()).thenReturn(BOUND_ACTION_ENTITY_RT_PPROP_NAME.getName());
- when(boundActionEntityRtPProp.getReturnType()).thenReturn(mock(EdmReturnType.class));
- EdmPrimitiveType primitiveType = mock(EdmPrimitiveType.class);
- when(boundActionEntityRtPProp.getReturnType().isCollection()).thenReturn(false);
- when(boundActionEntityRtPProp.getReturnType().getType()).thenReturn(primitiveType);
- when(boundActionEntityRtPProp.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
- when(boundActionEntityRtPProp.isBound()).thenReturn(true);
- }
-
- private void enhanceBoundActionEntityRtPPropColl() {
- when(boundActionEntityRtPPropColl.getName()).thenReturn(BOUND_ACTION_ENTITY_RT_PPROP_NAME.getName());
- when(boundActionEntityRtPPropColl.getReturnType()).thenReturn(mock(EdmReturnType.class));
- EdmPrimitiveType primitiveType = mock(EdmPrimitiveType.class);
- when(boundActionEntityRtPPropColl.getReturnType().isCollection()).thenReturn(true);
- when(boundActionEntityRtPPropColl.getReturnType().getType()).thenReturn(primitiveType);
- when(boundActionEntityRtPPropColl.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
- when(boundActionEntityRtPPropColl.isBound()).thenReturn(true);
- }
-
- private void enhanceBoundActionEntitySetRtCProp() {
- when(boundActionEntitySetRtCProp.getName()).thenReturn(BOUND_ACTION_ENTITY_SET_RT_CPROP_NAME.getName());
- when(boundActionEntitySetRtCProp.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(boundActionEntitySetRtCProp.getReturnType().isCollection()).thenReturn(false);
- when(boundActionEntitySetRtCProp.getReturnType().getType()).thenReturn(locationType);
- when(boundActionEntitySetRtCProp.getNamespace()).thenReturn(NAMESPACE_SCHEMA);
- when(boundActionEntitySetRtCProp.isBound()).thenReturn(true);
- }
-
- private void enhanceFunction1() {
- when(function1.getName()).thenReturn(FUNCTION1_NAME.getName());
- when(function1.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(function1.getReturnType().isCollection()).thenReturn(false);
- when(function1.getReturnType().getType()).thenReturn(teamType);
- }
-
- private void enhanceAction1() {
- when(action1.getReturnType()).thenReturn(mock(EdmReturnType.class));
- when(action1.getReturnType().isCollection()).thenReturn(false);
- when(action1.getReturnType().getType()).thenReturn(employeeType);
- }
-
- private void enhanceCompany() {
- when(company.getName()).thenReturn(COMPANY_SINGLETON_NAME.getName());
- when(company.getEntityContainer()).thenReturn(container1);
- when(company.getEntityType()).thenReturn(companyType);
- }
-
- private void enhanceManagersEntitySet() {
- when(managersSet.getName()).thenReturn(MANAGERS_SET_NAME.getName());
- when(managersSet.getEntityContainer()).thenReturn(container1);
- when(managersSet.getEntityType()).thenReturn(managerType);
- }
-
- private void enhanceTeamsEntitySet() {
- when(teamsSet.getName()).thenReturn(TEAMS_SET_NAME.getName());
- when(teamsSet.getEntityContainer()).thenReturn(container1);
- when(teamsSet.getEntityType()).thenReturn(teamType);
- }
-
- private void enhanceEmployeesEntitySet() {
- when(employeesSet.getName()).thenReturn(EMPLOYEES_SET_NAME.getName());
- when(employeesSet.getEntityContainer()).thenReturn(container1);
- when(employeesSet.getEntityType()).thenReturn(employeeType);
- }
-
- @Override
- public EdmEntityContainer getEntityContainer(final FullQualifiedName fqn) {
-
- if (fqn == null || NAMESPACE_SCHEMA.equals(fqn.getNamespace()) && CONTAINER_NAME.equals(fqn.getName())) {
- return container1;
- }
-
- return null;
- }
-
- @Override
- public EdmEnumType getEnumType(final FullQualifiedName fqn) {
- if (RATING_ENUM_TYPE_NAME.equals(fqn)) {
- return ratingEnumType;
- }
-
- return null;
- }
-
- @Override
- public EdmTypeDefinition getTypeDefinition(final FullQualifiedName fqn) {
- if (TYPE_DEF1_NAME.equals(fqn)) {
- return typeDef1;
- }
- return null;
- }
-
- @Override
- public EdmEntityType getEntityType(final FullQualifiedName fqn) {
- if (NAMESPACE_SCHEMA.equals(fqn.getNamespace())) {
- if (EMPLOYEES_TYPE_NAME.equals(fqn)) {
- return employeeType;
- } else if (MANAGERS_TYPE_NAME.equals(fqn)) {
- return managerType;
- } else if (TEAMS_TYPE_NAME.equals(fqn)) {
- return teamType;
- } else if (COMPANY_TYPE_NAME.equals(fqn)) {
- return companyType;
- }
- }
- return null;
- }
-
- @Override
- public EdmComplexType getComplexType(final FullQualifiedName fqn) {
- if (LOCATION_TYPE_NAME.equals(fqn)) {
- return locationType;
- }
- return null;
- }
-
- @Override
- public EdmServiceMetadata getServiceMetadata() {
- return mock(EdmServiceMetadata.class);
- }
-
- @Override
- public EdmAction getAction(final FullQualifiedName actionFqn, final FullQualifiedName bindingParameterTypeFqn,
- final Boolean isBindingParameterTypeCollection) {
- if (NAMESPACE_SCHEMA.equals(actionFqn.getNamespace())) {
- if (ACTION1_NAME.equals(actionFqn)) {
- return action1;
- } else if (BOUND_ACTION_PPROP_RT_ENTITY_SET_NAME.equals(actionFqn)
- && Boolean.FALSE.equals(isBindingParameterTypeCollection)) {
- return boundActionPpropRtEntitySet;
- } else if (BOUND_ACTION_ENTITY_RT_ENTITY_NAME.equals(actionFqn)
- && EMPLOYEES_TYPE_NAME.equals(bindingParameterTypeFqn)
- && Boolean.FALSE.equals(isBindingParameterTypeCollection)) {
- return boundActionEntityRtEntity;
- } else if (BOUND_ACTION_ENTITY_RT_PPROP_NAME.equals(actionFqn)
- && EMPLOYEES_TYPE_NAME.equals(bindingParameterTypeFqn)
- && Boolean.FALSE.equals(isBindingParameterTypeCollection)) {
- return boundActionEntityRtPProp;
- } else if (BOUND_ACTION_ENTITY_RT_PPROP_COLL_NAME.equals(actionFqn)
- && EMPLOYEES_TYPE_NAME.equals(bindingParameterTypeFqn)
- && Boolean.FALSE.equals(isBindingParameterTypeCollection)) {
- return boundActionEntityRtPPropColl;
- } else if (BOUND_ACTION_ENTITY_SET_RT_CPROP_NAME.equals(actionFqn)
- && EMPLOYEES_TYPE_NAME.equals(bindingParameterTypeFqn)
- && Boolean.TRUE.equals(isBindingParameterTypeCollection)) {
- return boundActionEntitySetRtCProp;
- }
- }
- return null;
- }
-
- @Override
- public EdmFunction getFunction(final FullQualifiedName functionFqn,
- final FullQualifiedName bindingParameterTypeFqn,
- final Boolean isBindingParameterTypeCollection, final List<String> bindingParameterNames) {
- if (functionFqn != null) {
- if (NAMESPACE_SCHEMA.equals(functionFqn.getNamespace())) {
- if (FUNCTION1_NAME.equals(functionFqn)) {
- return function1;
- } else if (FUNCTION_ALL_LOCATIONS_NAME.equals(functionFqn)) {
- return allLocationsFunction;
- } else if (FUNCTION_EMPLOYEE_SEARCH_NAME.equals(functionFqn)) {
- return employeeSearchFunction;
- } else if (FUNCTION_MAXIMAL_AGE_NAME.equals(functionFqn)) {
- return maximalAgeFunction;
- } else if (FUNCTION_MOST_COMMON_LOCATION_NAME.equals(functionFqn)) {
- return mostCommonLocationFunction;
- } else if (FUNCTION_ALL_USED_ROOMS_NAME.equals(functionFqn)) {
- return allUsedRoomIdsFunction;
- } else if (BOUND_FUNCTION_ENTITY_SET_RT_ENTITY_NAME.equals(functionFqn)
- && EMPLOYEES_TYPE_NAME.equals(bindingParameterTypeFqn)
- && Boolean.TRUE.equals(isBindingParameterTypeCollection)) {
- return boundFunctionEntitySetRtEntity;
- } else if (BOUND_FUNCTION_ENTITY_SET_RT_ENTITY_SET_NAME.equals(functionFqn)
- && EMPLOYEES_TYPE_NAME.equals(bindingParameterTypeFqn)
- && Boolean.TRUE.equals(isBindingParameterTypeCollection)) {
- return boundEntityColFunction;
- } else if (BOUND_FUNCTION_PPROP_RT_ENTITY_SET_NAME.equals(functionFqn)
- && Boolean.FALSE.equals(isBindingParameterTypeCollection)) {
- return boundFunctionPPropRtEntitySet;
- } else if (BOUND_FUNCTION_ENTITY_SET_RT_PPROP_NAME.equals(functionFqn)
- && EMPLOYEES_TYPE_NAME.equals(bindingParameterTypeFqn)
- && Boolean.TRUE.equals(isBindingParameterTypeCollection)) {
- return boundFunctionEntitySetRtPProp;
- } else if (BOUND_FUNCTION_ENTITY_SET_RT_PPROP_COLL_NAME.equals(functionFqn)
- && EMPLOYEES_TYPE_NAME.equals(bindingParameterTypeFqn)
- && Boolean.TRUE.equals(isBindingParameterTypeCollection)) {
- return boundFunctionEntitySetRtPPropColl;
- } else if (BOUND_FUNCTION_ENTITY_SET_RT_CPROP_NAME.equals(functionFqn)
- && EMPLOYEES_TYPE_NAME.equals(bindingParameterTypeFqn)
- && Boolean.TRUE.equals(isBindingParameterTypeCollection)) {
- return boundFunctionEntitySetRtCProp;
- } else if (BOUND_FUNCTION_ENTITY_SET_RT_CPROP_COLL_NAME.equals(functionFqn)
- && EMPLOYEES_TYPE_NAME.equals(bindingParameterTypeFqn)
- && Boolean.TRUE.equals(isBindingParameterTypeCollection)) {
- return boundFunctionEntitySetRtCPropColl;
- } else if (BOUND_FUNCTION_SINGLETON_RT_ENTITY_SET_NAME.equals(functionFqn)
- && COMPANY_TYPE_NAME.equals(bindingParameterTypeFqn)
- && Boolean.FALSE.equals(isBindingParameterTypeCollection)) {
- return boundFunctionSingletonRtEntitySet;
- }
- }
- }
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/producer/core/testutil/EdmTechProvider.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/producer/core/testutil/EdmTechProvider.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/producer/core/testutil/EdmTechProvider.java
deleted file mode 100644
index 4760965..0000000
--- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/producer/core/testutil/EdmTechProvider.java
+++ /dev/null
@@ -1,216 +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.producer.core.testutil;
-
-import java.util.Arrays;
-
-import org.apache.olingo.commons.api.edm.helper.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.provider.EdmProviderAdapter;
-import org.apache.olingo.commons.api.edm.provider.EntitySet;
-import org.apache.olingo.commons.api.edm.provider.EntityType;
-import org.apache.olingo.commons.api.edm.provider.Property;
-import org.apache.olingo.commons.api.edm.provider.PropertyRef;
-import org.apache.olingo.commons.api.exception.ODataException;
-import org.apache.olingo.commons.api.exception.ODataNotImplementedException;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
-
-public class EdmTechProvider extends EdmProviderAdapter {
-
- Property propertyInt16NotNullable = new Property()
- .setName("PropertyInt16")
- .setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName())
- .setNullable(false);
-//Simple typed Properties
- Property propertyBinary = new Property()
- .setName("PropertyBinary")
- .setType(EdmPrimitiveTypeKind.Binary.getFullQualifiedName());
- Property propertyBoolean = new Property()
- .setName("PropertyBoolean")
- .setType(EdmPrimitiveTypeKind.Boolean.getFullQualifiedName());
- Property propertyByte = new Property()
- .setName("PropertyByte")
- .setType(EdmPrimitiveTypeKind.Byte.getFullQualifiedName());
- Property propertyDate = new Property()
- .setName("PropertyDate")
- .setType(EdmPrimitiveTypeKind.Date.getFullQualifiedName());
- Property propertyDateTimeOffset = new Property()
- .setName("PropertyDateTimeOffset")
- .setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName());
- Property propertyDecimal = new Property()
- .setName("PropertyDecimal")
- .setType(EdmPrimitiveTypeKind.Decimal.getFullQualifiedName());
- Property propertyDouble = new Property()
- .setName("PropertyDouble")
- .setType(EdmPrimitiveTypeKind.Double.getFullQualifiedName());
- Property propertyDuration = new Property()
- .setName("PropertyDuration")
- .setType(EdmPrimitiveTypeKind.Duration.getFullQualifiedName());
- Property propertyGuid = new Property()
- .setName("PropertyGuid")
- .setType(EdmPrimitiveTypeKind.Guid.getFullQualifiedName());
- Property propertyInt16 = new Property()
- .setName("PropertyInt16")
- .setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName());
- Property propertyInt32 = new Property()
- .setName("PropertyInt32")
- .setType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName());
- Property propertyInt64 = new Property()
- .setName("PropertyInt64")
- .setType(EdmPrimitiveTypeKind.Int64.getFullQualifiedName());
- Property propertySByte = new Property()
- .setName("PropertySByte")
- .setType(EdmPrimitiveTypeKind.SByte.getFullQualifiedName());
- Property propertySingle = new Property()
- .setName("PropertySingle")
- .setType(EdmPrimitiveTypeKind.Single.getFullQualifiedName());
- Property propertyString = new Property()
- .setName("PropertyString")
- .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
- Property propertyTimeOfDay = new Property()
- .setName("PropertyTimeOfDay")
- .setType(EdmPrimitiveTypeKind.TimeOfDay.getFullQualifiedName());
-
- // Properties typed as collection of simple types
- Property collectionPropertyBinary = new Property()
- .setName("CollPropertyBinary")
- .setType(EdmPrimitiveTypeKind.Binary.getFullQualifiedName())
- .setCollection(true);
- Property collectionPropertyBoolean = new Property()
- .setName("CollPropertyBoolean")
- .setType(EdmPrimitiveTypeKind.Boolean.getFullQualifiedName())
- .setCollection(true);
- Property collectionPropertyByte = new Property()
- .setName("CollPropertyByte")
- .setType(EdmPrimitiveTypeKind.Byte.getFullQualifiedName())
- .setCollection(true);
- Property collectionPropertyDate = new Property()
- .setName("CollPropertyDate")
- .setType(EdmPrimitiveTypeKind.Date.getFullQualifiedName())
- .setCollection(true);
- Property collectionPropertyDateTimeOffset = new Property()
- .setName("CollPropertyDateTimeOffset")
- .setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName())
- .setCollection(true);
- Property collectionPropertyDecimal = new Property()
- .setName("CollPropertyDecimal")
- .setType(EdmPrimitiveTypeKind.Decimal.getFullQualifiedName())
- .setCollection(true);
- Property collectionPropertyDouble = new Property()
- .setName("CollPropertyDouble")
- .setType(EdmPrimitiveTypeKind.Double.getFullQualifiedName())
- .setCollection(true);
- Property collectionPropertyDuration = new Property()
- .setName("CollPropertyDuration")
- .setType(EdmPrimitiveTypeKind.Duration.getFullQualifiedName())
- .setCollection(true);
- Property collectionPropertyGuid = new Property()
- .setName("CollPropertyGuid")
- .setType(EdmPrimitiveTypeKind.Guid.getFullQualifiedName())
- .setCollection(true);
- Property collectionPropertyInt16 = new Property()
- .setName("CollPropertyInt16")
- .setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName())
- .setCollection(true);
- Property collectionPropertyInt32 = new Property()
- .setName("CollPropertyInt32")
- .setType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName())
- .setCollection(true);
- Property collectionPropertyInt64 = new Property()
- .setName("CollPropertyInt64")
- .setType(EdmPrimitiveTypeKind.Int64.getFullQualifiedName())
- .setCollection(true);
- Property collectionPropertySByte = new Property()
- .setName("CollPropertySByte")
- .setType(EdmPrimitiveTypeKind.SByte.getFullQualifiedName())
- .setCollection(true);
- Property collectionPropertySingle = new Property()
- .setName("CollPropertySingle")
- .setType(EdmPrimitiveTypeKind.Single.getFullQualifiedName())
- .setCollection(true);
- Property collectionPropertyString = new Property()
- .setName("CollPropertyString")
- .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())
- .setCollection(true);
- Property collectionPropertyTimeOfDay = new Property()
- .setName("CollPropertyTimeOfDay")
- .setType(EdmPrimitiveTypeKind.TimeOfDay.getFullQualifiedName())
- .setCollection(true);
-
-// EdmEntityContainer entityContainerTest1 = new EdmEntityContainerImpl(
-// new EntityContainerInfo()
-// .setContainerName(new FullQualifiedName("com.sap.odata.test1", "Container"))
-// );
-
- @Override
- public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String name) throws ODataException {
- if (entityContainer == null) {
- if (name.equals("ESAllPrim")) {
-
- return new EntitySet()
- .setName("ETAllPrim")
- .setType(new FullQualifiedName("com.sap.odata.test1", "ESAllPrim"));
-
- } else if (name.equals("ESCollAllPrim")) {
-
- return new EntitySet()
- .setName("ESCollAllPrim")
- .setType(new FullQualifiedName("com.sap.odata.test1", "ETCollAllPrim"));
-
- }
- }
-
- throw new ODataNotImplementedException();
- }
-
- @Override
- public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException {
-
- if (entityTypeName.equals(new FullQualifiedName("com.sap.odata.test1", "ETAllPrim"))) {
- return new EntityType()
- .setName("ETAllPrim")
- .setProperties(Arrays.asList(
- propertyBinary, propertyBoolean, propertyByte,
- propertyDate, propertyDateTimeOffset, propertyDecimal,
- propertyDouble, propertyDuration, propertyDecimal,
- propertyInt16NotNullable, propertyInt32, propertyInt64,
- propertySByte, propertySingle, propertyString,
- propertyTimeOfDay))
- .setKey(Arrays.asList(
- new PropertyRef().setPropertyName("PropertyInt16")));
-
- } else if (entityTypeName.equals(new FullQualifiedName("com.sap.odata.test1", "ETCollAllPrim"))) {
- return new EntityType()
- .setName("ETCollAllPrim")
- .setProperties(Arrays.asList(
- propertyInt16NotNullable,
- collectionPropertyBinary, collectionPropertyBoolean, collectionPropertyByte,
- collectionPropertyDate, collectionPropertyDateTimeOffset, collectionPropertyDecimal,
- collectionPropertyDouble, collectionPropertyDuration, collectionPropertyDecimal,
- collectionPropertyInt16, collectionPropertyInt32, collectionPropertyInt64,
- collectionPropertySByte, collectionPropertySingle, collectionPropertyString,
- collectionPropertyTimeOfDay))
- .setKey(Arrays.asList(
- new PropertyRef().setPropertyName("PropertyInt16")));
- }
-
- throw new ODataNotImplementedException();
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/producer/core/testutil/ParseTreeSerializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/producer/core/testutil/ParseTreeSerializer.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/producer/core/testutil/ParseTreeSerializer.java
deleted file mode 100644
index 0de75f6..0000000
--- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/producer/core/testutil/ParseTreeSerializer.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.producer.core.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 ParseTreeSerializer {
-
- 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/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/producer/core/testutil/ParserValidator.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/producer/core/testutil/ParserValidator.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/producer/core/testutil/ParserValidator.java
deleted file mode 100644
index a7e19e1..0000000
--- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/producer/core/testutil/ParserValidator.java
+++ /dev/null
@@ -1,399 +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.producer.core.testutil;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.Collections;
-import java.util.List;
-
-import org.antlr.v4.runtime.ANTLRErrorListener;
-import org.antlr.v4.runtime.ANTLRInputStream;
-import org.antlr.v4.runtime.BailErrorStrategy;
-import org.antlr.v4.runtime.CommonTokenStream;
-import org.antlr.v4.runtime.DefaultErrorStrategy;
-import org.antlr.v4.runtime.Parser;
-import org.antlr.v4.runtime.ParserRuleContext;
-import org.antlr.v4.runtime.RecognitionException;
-import org.antlr.v4.runtime.Recognizer;
-import org.antlr.v4.runtime.Token;
-import org.antlr.v4.runtime.atn.ATNConfigSet;
-import org.antlr.v4.runtime.atn.PredictionMode;
-import org.antlr.v4.runtime.dfa.DFA;
-import org.antlr.v4.runtime.misc.Interval;
-import org.apache.olingo.producer.core.uri.antlr.UriLexer;
-import org.apache.olingo.producer.core.uri.antlr.UriParserParser;
-import org.apache.olingo.producer.core.uri.antlr.UriParserParser.OdataRelativeUriEOFContext;
-
-/**
- * @author d039346
- *
- */
-public class ParserValidator {
- public class UriLexerTrace extends UriLexer {
- ParserValidator parserValidator = null;
-
- public UriLexerTrace(ParserValidator parserValidator, ANTLRInputStream antlrInputStream) {
- super(antlrInputStream);
- this.parserValidator = parserValidator;
- }
-
- @Override
- public Token emit() {
- Token t =
- _factory.create(_tokenFactorySourcePair, _type, _text, _channel, _tokenStartCharIndex, getCharIndex() - 1,
- _tokenStartLine, _tokenStartCharPositionInLine);
-
- if (parserValidator.logLevel > 1) {
- String out = String.format("%1$-" + 20 + "s", t.getText());
- ;
- int tokenType = t.getType();
- if (tokenType == -1) {
- out += "-1/EOF";
- } else {
- out += UriLexer.tokenNames[tokenType];
- }
- System.out.println(out);
- }
- emit(t);
-
- return t;
- }
-
- @Override
- public void pushMode(int m) {
- String out = UriLexer.modeNames[this._mode] + "-->";
- super.pushMode(m);
- out += UriLexer.modeNames[this._mode];
- if (parserValidator.logLevel > 1) {
- System.out.print(out + " ");
- }
- ;
-
- }
-
- @Override
- public int popMode() {
- String out = UriLexer.modeNames[this._mode] + "-->";
- int m = super.popMode();
- out += UriLexer.modeNames[this._mode];
-
- if (parserValidator.logLevel > 1) {
- System.out.print(out + " ");
- }
-
- return m;
- }
-
- }
-
- private List<Exception> exceptions = new ArrayList<Exception>();
- private ParserRuleContext root;
-
- private String input = null;
- // private int exceptionOnStage = -1;
- private Exception curException = null;
- // private Exception curWeakException = null;
- private boolean allowFullContext;
- private boolean allowContextSensitifity;
- private boolean allowAmbiguity;
- private int logLevel = 0;
- private int lexerLogLevel = 0;
-
- // private int lexerLogLevel = 0;
-
- public ParserValidator run(String uri) {
- input = uri;
- if (lexerLogLevel > 0) {
- (new TokenValidator()).log(lexerLogLevel).run(input);
- }
- root = parseInput(uri);
- // LOG > 0 - Write serialized tree
- if (logLevel > 0) {
- if (root != null) {
- System.out.println(ParseTreeSerializer.getTreeAsText(root, new UriParserParser(null).getRuleNames()));
- } else {
- System.out.println("root == null");
- }
- }
-
- // reset for next test
- allowFullContext = false;
- allowContextSensitifity = false;
- allowAmbiguity = false;
- logLevel = 0;
-
- // exFirst();
- return this;
- }
-
- public ParserValidator log(int logLevel) {
- this.logLevel = logLevel;
- return this;
- }
-
- /**
- * Used in fast LL Parsing:
- * Don't stops 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;
- }
-
- public ParserValidator isText(String expected) {
- // make sure that there are no exceptions
- assertEquals(null, curException);
- assertEquals(0, exceptions.size());
-
- String text = ParseTreeSerializer.getTreeAsText(root, new UriParserParser(null).getRuleNames());
- assertEquals(expected, text);
- return this;
- }
-
- public ParserValidator isExType(Class<?> exClass) {
- assertEquals(exClass, curException.getClass());
- return this;
- }
-
- private OdataRelativeUriEOFContext parseInput(final String input) {
- UriParserParser parser = null;
- UriLexer lexer = null;
- OdataRelativeUriEOFContext ret = null;
-
- // Use 2 stage approach to improve performance
- // see https://github.com/antlr/antlr4/issues/192
- // TODO verify this
-
- // stage= 1
- try {
- curException = null;
- exceptions.clear();
- // create parser
- lexer = new UriLexerTrace(this, new ANTLRInputStream(input));
- parser = new UriParserParser(new CommonTokenStream(lexer));
-
- // write single tokens to System.out
- if (logLevel > 1) {
- // can not be used because the listener is called bevore the mode changes
- parser.addParseListener(new TokenWriter());
- }
- // write always a error message in case of syntax errors
- parser.addErrorListener(new TraceErrorHandler<Object>());
- // check error message if whether they are allowed or not
- parser.addErrorListener(new ErrorCollector(this));
-
- // Bail out of parser at first syntax error. --> procceds in catch block with step 2
- parser.setErrorHandler(new BailErrorStrategy());
-
- // User the faster LL parsing
- parser.getInterpreter().setPredictionMode(PredictionMode.LL);
- if (logLevel > 1) {
- System.out.println("Step 1 (LL)");
- }
- ret = parser.odataRelativeUriEOF();
-
- } catch (Exception ex) {
- curException = ex;
- try {
- // clear status
- curException = null;
- exceptions.clear();
-
- // create parser
- lexer = new UriLexerTrace(this, new ANTLRInputStream(input));
- parser = new UriParserParser(new CommonTokenStream(lexer));
-
- // write single tokens to System.out
- if (logLevel > 1) {
- parser.addParseListener(new TokenWriter());
- }
-
- // write always a error message in case of syntax errors
- parser.addErrorListener(new TraceErrorHandler<Object>());
- // check error message if whether they are allowed or not
- parser.addErrorListener(new ErrorCollector(this));
-
- // Used default error strategy
- parser.setErrorHandler(new DefaultErrorStrategy());
-
- // User the slower SLL parsing
- parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
-
- if (logLevel > 1) {
- System.out.println("Step 2 (SLL)");
- }
- ret = parser.odataRelativeUriEOF();
-
- } catch (Exception ex1) {
- curException = ex1;
- // exceptionOnStage = 2;
- }
- }
-
- return ret;
- }
-
- private static class ErrorCollector implements ANTLRErrorListener {
- ParserValidator tokenValidator;
-
- public ErrorCollector(ParserValidator tokenValidator) {
- this.tokenValidator = tokenValidator;
- }
-
- @Override
- public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine,
- String msg, RecognitionException e) {
-
- tokenValidator.exceptions.add(e);
- trace(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
-
- fail("syntaxError");
- }
-
- @Override
- public void reportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, boolean exact,
- BitSet ambigAlts, ATNConfigSet configs) {
-
- if (!tokenValidator.allowAmbiguity) {
- System.out.println("reportAmbiguity " +
- ambigAlts + ":" + configs +
- ", input=" + recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex)));
- printStack(recognizer);
- fail("reportAmbiguity");
- } else if (tokenValidator.logLevel > 0) {
- System.out.println("allowed Ambiguity " +
- ambigAlts + ":" + configs +
- ", input=" + recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex)));
- }
- }
-
- @Override
- public void reportAttemptingFullContext(Parser recognizer, DFA dfa, int startIndex, int stopIndex,
- BitSet conflictingAlts, ATNConfigSet configs) {
- // The grammar should be written in order to avoid attempting a full context parse because its negative
- // impact on the performance, so trace and stop here
-
- if (!tokenValidator.allowFullContext) {
- printStack(recognizer);
- fail("reportAttemptingFullContext");
- } else if (tokenValidator.logLevel > 0) {
- System.out.println("allowed AttemptingFullContext");
- }
- }
-
- @Override
- public void reportContextSensitivity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, int prediction,
- ATNConfigSet configs) {
- if (!tokenValidator.allowContextSensitifity) {
- printStack(recognizer);
- fail("reportContextSensitivity");
- } else if (tokenValidator.logLevel > 0) {
- System.out.println("allowed ContextSensitivity");
- }
- }
-
- private void printStack(Parser 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.err.println("-");
- // check also http://stackoverflow.com/questions/14747952/ll-exact-ambig-detection-interpetation
- List<String> stack = ((Parser) recognizer).getRuleInvocationStack();
- Collections.reverse(stack);
- System.err.println("rule stack: " + stack);
- if (e != null && e.getOffendingToken() != null) {
-
- // String lexerTokenName =TestSuiteLexer.tokenNames[e.getOffendingToken().getType()];
- String lexerTokenName = "";
- try {
- lexerTokenName = UriLexer.tokenNames[e.getOffendingToken().getType()];
- } catch (ArrayIndexOutOfBoundsException es) {
- lexerTokenName = "token error";
- }
- System.err.println("line " + line + ":" + charPositionInLine + " at " +
- offendingSymbol + "/" + lexerTokenName + ": " + msg);
- } else {
- System.err.println("line " + line + ":" + charPositionInLine + " at " + offendingSymbol + ": " + msg);
- }
- }
-
- }
-
- 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(int index) {
- try {
- // curWeakException = exceptions.get(index);
- } catch (IndexOutOfBoundsException ex) {
- // curWeakException = null;
- }
- return this;
- }
-
- public ParserValidator lexerLog(int i) {
- lexerLogLevel = i;
- return this;
- }
-
-}