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:47 UTC
[11/21] [OLINGO-77] Refactored java package names
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmParameterImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmParameterImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmParameterImpl.java
new file mode 100644
index 0000000..1722647
--- /dev/null
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmParameterImpl.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.odata4.commons.core.edm.provider;
+
+import org.apache.olingo.odata4.commons.api.edm.EdmException;
+import org.apache.olingo.odata4.commons.api.edm.EdmParameter;
+import org.apache.olingo.odata4.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.odata4.commons.api.edm.EdmType;
+import org.apache.olingo.odata4.commons.api.edm.helper.EdmMapping;
+import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName;
+import org.apache.olingo.odata4.commons.api.edm.provider.Parameter;
+import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
+
+public class EdmParameterImpl extends EdmElementImpl implements EdmParameter {
+
+ private final Parameter parameter;
+ private EdmType typeImpl;
+
+ public EdmParameterImpl(final EdmProviderImpl edm, final Parameter parameter) {
+ super(edm, parameter.getName());
+ this.parameter = parameter;
+ }
+
+ @Override
+ public EdmType getType() {
+ if (typeImpl == null) {
+ FullQualifiedName typeName = parameter.getType();
+ if (EdmPrimitiveType.EDM_NAMESPACE.equals(typeName.getNamespace())) {
+ EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.valueOf(typeName.getName());
+ if (kind != null) {
+ typeImpl = kind.getEdmPrimitiveTypeInstance();
+ } else {
+ throw new EdmException("Cant find type with name: " + typeName);
+ }
+ } else {
+ typeImpl = edm.getComplexType(typeName);
+ if (typeImpl == null) {
+ typeImpl = edm.getEntityType(typeName);
+ if (typeImpl == null) {
+ typeImpl = edm.getEnumType(typeName);
+ if (typeImpl == null) {
+ typeImpl = edm.getTypeDefinition(typeName);
+ if (typeImpl == null) {
+ throw new EdmException("Cant find type with name: " + typeName);
+ }
+ }
+ }
+ }
+ }
+ }
+ return typeImpl;
+ }
+
+ @Override
+ public boolean isCollection() {
+ return parameter.isCollection();
+ }
+
+ @Override
+ public EdmMapping getMapping() {
+ return parameter.getMapping();
+ }
+
+ @Override
+ public Boolean isNullable() {
+ return parameter.getNullable();
+ }
+
+ @Override
+ public Integer getMaxLength() {
+ return parameter.getMaxLength();
+ }
+
+ @Override
+ public Integer getPrecision() {
+ return parameter.getPrecision();
+ }
+
+ @Override
+ public Integer getScale() {
+ return parameter.getScale();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmPropertyImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmPropertyImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmPropertyImpl.java
new file mode 100644
index 0000000..5a0281f
--- /dev/null
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmPropertyImpl.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * 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.commons.core.edm.provider;
+
+import org.apache.olingo.odata4.commons.api.edm.EdmException;
+import org.apache.olingo.odata4.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
+import org.apache.olingo.odata4.commons.api.edm.EdmType;
+import org.apache.olingo.odata4.commons.api.edm.helper.EdmMapping;
+import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName;
+import org.apache.olingo.odata4.commons.api.edm.provider.Property;
+import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
+
+public class EdmPropertyImpl extends EdmElementImpl implements EdmProperty {
+
+ private final Property property;
+ private final boolean isPrimitive;
+ private EdmType propertyType;
+
+ public EdmPropertyImpl(final EdmProviderImpl edm, final Property property) {
+ super(edm, property.getName());
+ this.property = property;
+ if (EdmPrimitiveType.EDM_NAMESPACE.equals(property.getType().getNamespace())) {
+ isPrimitive = true;
+ } else {
+ isPrimitive = false;
+ }
+ }
+
+ @Override
+ public EdmType getType() {
+ if (propertyType == null) {
+ FullQualifiedName typeName = property.getType();
+ if (isPrimitive) {
+ EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.valueOf(typeName.getName());
+ if (kind != null) {
+ propertyType = kind.getEdmPrimitiveTypeInstance();
+ } else {
+ throw new EdmException("Can�t find type with name: " + typeName);
+ }
+ } else {
+ propertyType = edm.getComplexType(typeName);
+ if (propertyType == null) {
+ propertyType = edm.getEnumType(typeName);
+ if (propertyType == null) {
+ propertyType = edm.getTypeDefinition(typeName);
+ if (propertyType == null) {
+ throw new EdmException("Can�t find type with name: " + typeName);
+ }
+ }
+ }
+ }
+ }
+
+ return propertyType;
+ }
+
+ @Override
+ public boolean isCollection() {
+ return property.isCollection();
+ }
+
+ @Override
+ public EdmMapping getMapping() {
+ return property.getMapping();
+ }
+
+ @Override
+ public String getMimeType() {
+ return property.getMimeType();
+ }
+
+ @Override
+ public boolean isPrimitive() {
+ return isPrimitive;
+ }
+
+ @Override
+ public Boolean isNullable() {
+ return property.getNullable();
+ }
+
+ @Override
+ public Integer getMaxLength() {
+ return property.getMaxLength();
+ }
+
+ @Override
+ public Integer getPrecision() {
+ return property.getPrecision();
+ }
+
+ @Override
+ public Integer getScale() {
+ return property.getScale();
+ }
+
+ @Override
+ public Boolean isUnicode() {
+ return property.isUnicode();
+ }
+
+ @Override
+ public String getDefaultValue() {
+ return property.getDefaultValue();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImpl.java
new file mode 100644
index 0000000..08f5f15
--- /dev/null
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmProviderImpl.java
@@ -0,0 +1,253 @@
+/*******************************************************************************
+ * 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.commons.core.edm.provider;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata4.commons.api.edm.EdmAction;
+import org.apache.olingo.odata4.commons.api.edm.EdmComplexType;
+import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
+import org.apache.olingo.odata4.commons.api.edm.EdmEnumType;
+import org.apache.olingo.odata4.commons.api.edm.EdmException;
+import org.apache.olingo.odata4.commons.api.edm.EdmFunction;
+import org.apache.olingo.odata4.commons.api.edm.EdmServiceMetadata;
+import org.apache.olingo.odata4.commons.api.edm.EdmTypeDefinition;
+import org.apache.olingo.odata4.commons.api.edm.helper.AliasInfo;
+import org.apache.olingo.odata4.commons.api.edm.helper.EntityContainerInfo;
+import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName;
+import org.apache.olingo.odata4.commons.api.edm.provider.Action;
+import org.apache.olingo.odata4.commons.api.edm.provider.ComplexType;
+import org.apache.olingo.odata4.commons.api.edm.provider.EdmProvider;
+import org.apache.olingo.odata4.commons.api.edm.provider.EntityType;
+import org.apache.olingo.odata4.commons.api.edm.provider.EnumType;
+import org.apache.olingo.odata4.commons.api.edm.provider.Function;
+import org.apache.olingo.odata4.commons.api.edm.provider.Parameter;
+import org.apache.olingo.odata4.commons.api.edm.provider.TypeDefinition;
+import org.apache.olingo.odata4.commons.api.exception.ODataException;
+import org.apache.olingo.odata4.commons.core.edm.EdmImpl;
+
+public class EdmProviderImpl extends EdmImpl {
+
+ private final EdmProvider provider;
+
+ public EdmProviderImpl(final EdmProvider provider) {
+ this.provider = provider;
+
+ }
+
+ @Override
+ public EdmEntityContainer createEntityContainer(final FullQualifiedName containerName) {
+ try {
+ EntityContainerInfo entityContainerInfo = provider.getEntityContainerInfo(containerName);
+ if (entityContainerInfo != null) {
+ return new EdmEntityContainerImpl(this, provider, entityContainerInfo);
+ }
+ return null;
+ } catch (ODataException e) {
+ throw new EdmException(e);
+ }
+ }
+
+ @Override
+ public EdmEnumType createEnumType(final FullQualifiedName enumName) {
+ try {
+ EnumType enumType = provider.getEnumType(enumName);
+ if (enumType != null) {
+ return new EdmEnumImpl(this, enumName, enumType);
+ }
+ return null;
+ } catch (ODataException e) {
+ throw new EdmException(e);
+ }
+ }
+
+ @Override
+ public EdmTypeDefinition createTypeDefinition(final FullQualifiedName typeDefinitionName) {
+ try {
+ TypeDefinition typeDefinition = provider.getTypeDefinition(typeDefinitionName);
+ if (typeDefinition != null) {
+ return new EdmTypeDefinitionImpl(this, typeDefinitionName, typeDefinition);
+ }
+ return null;
+ } catch (ODataException e) {
+ throw new EdmException(e);
+ }
+ }
+
+ @Override
+ public EdmEntityType createEntityType(final FullQualifiedName entityTypeName) {
+ try {
+ EntityType entityType = provider.getEntityType(entityTypeName);
+ if (entityType != null) {
+ return new EdmEntityTypeImpl(this, entityTypeName, entityType);
+ }
+ return null;
+ } catch (ODataException e) {
+ throw new EdmException(e);
+ }
+ }
+
+ @Override
+ public EdmComplexType createComplexType(final FullQualifiedName complexTypeName) {
+ try {
+ ComplexType complexType = provider.getComplexType(complexTypeName);
+ if (complexType != null) {
+ return new EdmComplexTypeImpl(this, complexTypeName, complexType);
+ }
+ return null;
+ } catch (ODataException e) {
+ throw new EdmException(e);
+ }
+ }
+
+ @Override
+ public EdmAction createAction(final FullQualifiedName actionName, final FullQualifiedName bindingParameterTypeName,
+ final Boolean isBindingParameterCollection) {
+
+ try {
+ List<Action> actions = provider.getActions(actionName);
+ if (actions != null) {
+ EdmActionImpl actionImpl = null;
+ if (bindingParameterTypeName == null) {
+ // Search for first unbound action
+ for (Action action : actions) {
+ if (action.isBound() == false) {
+ actionImpl = new EdmActionImpl(this, actionName, action);
+ break;
+ }
+ }
+ } else {
+ // Search for bound action where binding parameter matches
+ boolean isCollection = false;
+ if (isBindingParameterCollection == null) {
+ isCollection = false;
+ } else {
+ isCollection = isBindingParameterCollection;
+ }
+ for (Action action : actions) {
+ if (action.isBound() == true) {
+ List<Parameter> parameters = action.getParameters();
+ Parameter parameter = parameters.get(0);
+ if (bindingParameterTypeName.equals(parameter.getType()) && isCollection == parameter.isCollection()) {
+ actionImpl = new EdmActionImpl(this, actionName, action);
+ break;
+ }
+
+ }
+ }
+ }
+
+ return actionImpl;
+ }
+ return null;
+ } catch (ODataException e) {
+ throw new EdmException(e);
+ }
+ }
+
+ @Override
+ public EdmFunction createFunction(final FullQualifiedName functionName,
+ final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection,
+ final List<String> parameterNames) {
+ try {
+ List<Function> functions = provider.getFunctions(functionName);
+ if (functions != null) {
+ EdmFunctionImpl functionImpl = null;
+ // TODO: Should we throw an edmexception when parameternames is null?
+ if (bindingParameterTypeName == null) {
+ // Search for matching unbound function
+ for (Function function : functions) {
+ if (function.isBound() == false) {
+ List<Parameter> parameters = function.getParameters();
+ if (parameterNames.size() == parameters.size()) {
+ List<String> functionParameterNames = new ArrayList<String>();
+ for (Parameter parameter : parameters) {
+ functionParameterNames.add(parameter.getName());
+ }
+
+ if (parameterNames.containsAll(functionParameterNames)) {
+ functionImpl = new EdmFunctionImpl(this, functionName, function);
+ break;
+ }
+ }
+ }
+ }
+ } else {
+ // Search for matching bound function
+ boolean isCollection = false;
+ if (isBindingParameterCollection == null) {
+ isCollection = false;
+ } else {
+ isCollection = isBindingParameterCollection;
+ }
+ for (Function function : functions) {
+ if (function.isBound() == true) {
+ List<Parameter> parameters = function.getParameters();
+ Parameter bindingParameter = parameters.get(0);
+ if (bindingParameterTypeName.equals(bindingParameter.getType())
+ && isCollection == bindingParameter.isCollection()) {
+ // bindingparameter type matches now only parameter names have to match
+ List<String> functionParameterNames = new ArrayList<String>();
+ for (int i = 1; i < parameters.size(); i++) {
+ functionParameterNames.add(parameters.get(i).getName());
+ }
+
+ if (parameterNames.containsAll(functionParameterNames)) {
+ functionImpl = new EdmFunctionImpl(this, functionName, function);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return functionImpl;
+ }
+ return null;
+ } catch (ODataException e) {
+ throw new EdmException(e);
+ }
+ }
+
+ @Override
+ public EdmServiceMetadata createServiceMetadata() {
+ return new EdmServiceMetadataImpl(provider);
+ }
+
+ @Override
+ protected Map<String, String> createAliasToNamespaceInfo() {
+ Map<String, String> aliasToNamespaceInfos = new HashMap<String, String>();
+ try {
+ List<AliasInfo> aliasInfos = provider.getAliasInfos();
+ if (aliasInfos != null) {
+ for (AliasInfo info : aliasInfos) {
+ aliasToNamespaceInfos.put(info.getAlias(), info.getNamespace());
+ }
+ }
+ } catch (ODataException e) {
+ throw new EdmException(e);
+ }
+ return aliasToNamespaceInfos;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmReturnTypeImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmReturnTypeImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmReturnTypeImpl.java
new file mode 100644
index 0000000..50d9788
--- /dev/null
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmReturnTypeImpl.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * 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.commons.core.edm.provider;
+
+import org.apache.olingo.odata4.commons.api.edm.EdmException;
+import org.apache.olingo.odata4.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.odata4.commons.api.edm.EdmReturnType;
+import org.apache.olingo.odata4.commons.api.edm.EdmType;
+import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName;
+import org.apache.olingo.odata4.commons.api.edm.provider.ReturnType;
+import org.apache.olingo.odata4.commons.core.edm.EdmImpl;
+import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
+
+public class EdmReturnTypeImpl implements EdmReturnType {
+
+ private final EdmImpl edm;
+ private final ReturnType returnType;
+ private EdmType typeImpl;
+
+ public EdmReturnTypeImpl(final EdmImpl edm, final ReturnType returnType) {
+ this.edm = edm;
+ this.returnType = returnType;
+ }
+
+ @Override
+ public EdmType getType() {
+ if (typeImpl == null) {
+ FullQualifiedName typeName = returnType.getType();
+ if (EdmPrimitiveType.EDM_NAMESPACE.equals(typeName.getNamespace())) {
+ EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.valueOf(typeName.getName());
+ if (kind != null) {
+ typeImpl = kind.getEdmPrimitiveTypeInstance();
+ } else {
+ throw new EdmException("Can�t find type with name: " + typeName);
+ }
+ } else {
+ typeImpl = edm.getComplexType(typeName);
+ if (typeImpl == null) {
+ typeImpl = edm.getEntityType(typeName);
+ if (typeImpl == null) {
+ typeImpl = edm.getEnumType(typeName);
+ if (typeImpl == null) {
+ typeImpl = edm.getTypeDefinition(typeName);
+ if (typeImpl == null) {
+ throw new EdmException("Cant find type with name: " + typeName);
+ }
+ }
+ }
+ }
+ }
+ }
+ return typeImpl;
+ }
+
+ @Override
+ public boolean isCollection() {
+ return returnType.isCollection();
+ }
+
+ @Override
+ public Boolean isNullable() {
+ return returnType.getNullable();
+ }
+
+ @Override
+ public Integer getMaxLength() {
+ return returnType.getMaxLength();
+ }
+
+ @Override
+ public Integer getPrecision() {
+ return returnType.getPrecision();
+ }
+
+ @Override
+ public Integer getScale() {
+ return returnType.getScale();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmServiceMetadataImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmServiceMetadataImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmServiceMetadataImpl.java
new file mode 100644
index 0000000..13934cf
--- /dev/null
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmServiceMetadataImpl.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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.commons.core.edm.provider;
+
+import java.io.InputStream;
+import java.util.List;
+
+import org.apache.olingo.odata4.commons.api.edm.EdmServiceMetadata;
+import org.apache.olingo.odata4.commons.api.edm.helper.EdmEntitySetInfo;
+import org.apache.olingo.odata4.commons.api.edm.helper.EdmFunctionImportInfo;
+import org.apache.olingo.odata4.commons.api.edm.helper.EdmSingletonInfo;
+import org.apache.olingo.odata4.commons.api.edm.provider.EdmProvider;
+
+public class EdmServiceMetadataImpl implements EdmServiceMetadata {
+
+ public EdmServiceMetadataImpl(final EdmProvider provider) {}
+
+ @Override
+ public InputStream getMetadata() {
+ return null;
+ }
+
+ @Override
+ public String getDataServiceVersion() {
+ // TODO: make constant
+ return "4.0";
+ }
+
+ @Override
+ public List<EdmEntitySetInfo> getEntitySetInfos() {
+ return null;
+ }
+
+ @Override
+ public List<EdmSingletonInfo> getSingletonInfos() {
+ return null;
+ }
+
+ @Override
+ public List<EdmFunctionImportInfo> getFunctionImportInfos() {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmSingletonImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmSingletonImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmSingletonImpl.java
new file mode 100644
index 0000000..46856af
--- /dev/null
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmSingletonImpl.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.odata4.commons.core.edm.provider;
+
+import org.apache.olingo.odata4.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.odata4.commons.api.edm.EdmSingleton;
+import org.apache.olingo.odata4.commons.api.edm.provider.Singleton;
+
+public class EdmSingletonImpl extends EdmBindingTargetImpl implements EdmSingleton {
+
+ public EdmSingletonImpl(final EdmProviderImpl edm, final EdmEntityContainer container, final Singleton singleton) {
+ super(edm, container, singleton);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmStructuralTypeImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmStructuralTypeImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmStructuralTypeImpl.java
new file mode 100644
index 0000000..10b3705
--- /dev/null
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmStructuralTypeImpl.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * 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.commons.core.edm.provider;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata4.commons.api.edm.EdmElement;
+import org.apache.olingo.odata4.commons.api.edm.EdmStructuralType;
+import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind;
+import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName;
+import org.apache.olingo.odata4.commons.api.edm.provider.NavigationProperty;
+import org.apache.olingo.odata4.commons.api.edm.provider.Property;
+import org.apache.olingo.odata4.commons.api.edm.provider.StructuralType;
+
+public abstract class EdmStructuralTypeImpl extends EdmTypeImpl implements EdmStructuralType {
+
+ private final Map<String, EdmElement> properties = new HashMap<String, EdmElement>();
+ private ArrayList<String> navigationPropertyNames;
+ private ArrayList<String> propertyNames;
+ protected final EdmStructuralType baseType;
+ private final StructuralType structuralType;
+
+ public EdmStructuralTypeImpl(final EdmProviderImpl edm, final FullQualifiedName name,
+ final StructuralType structuralType, final EdmTypeKind kind) {
+ super(edm, name, kind);
+ this.structuralType = structuralType;
+ baseType = buildBaseType(structuralType.getBaseType());
+ buildProperties(structuralType.getProperties());
+ buildNavigationProperties(structuralType.getNavigationProperties());
+ }
+
+ private void buildNavigationProperties(final List<NavigationProperty> providerNavigationProperties) {
+ if (providerNavigationProperties != null) {
+ for (NavigationProperty navigationProperty : providerNavigationProperties) {
+ properties.put(navigationProperty.getName(), new EdmNavigationPropertyImpl(edm, navigationProperty));
+ }
+ }
+
+ }
+
+ private void buildProperties(final List<Property> providerProperties) {
+ if (providerProperties != null) {
+ for (Property property : providerProperties) {
+ properties.put(property.getName(), new EdmPropertyImpl(edm, property));
+ }
+ }
+
+ }
+
+ @Override
+ public EdmElement getProperty(final String name) {
+ EdmElement property = null;
+ if (baseType != null) {
+ property = baseType.getProperty(name);
+ }
+ if (property == null) {
+ property = properties.get(name);
+ }
+ return property;
+ }
+
+ @Override
+ public List<String> getPropertyNames() {
+ if (propertyNames == null) {
+ propertyNames = new ArrayList<String>();
+ if (baseType != null) {
+ propertyNames.addAll(baseType.getPropertyNames());
+ }
+ for (Property property : structuralType.getProperties()) {
+ propertyNames.add(property.getName());
+ }
+ }
+ return propertyNames;
+ }
+
+ @Override
+ public List<String> getNavigationPropertyNames() {
+ if (navigationPropertyNames == null) {
+ navigationPropertyNames = new ArrayList<String>();
+ if (baseType != null) {
+ navigationPropertyNames.addAll(baseType.getNavigationPropertyNames());
+ }
+ for (NavigationProperty navProperty : structuralType.getNavigationProperties()) {
+ navigationPropertyNames.add(navProperty.getName());
+ }
+ }
+ return navigationPropertyNames;
+ }
+
+ protected abstract EdmStructuralType buildBaseType(FullQualifiedName baseTypeName);
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmTypeDefinitionImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmTypeDefinitionImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmTypeDefinitionImpl.java
new file mode 100644
index 0000000..d890242
--- /dev/null
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmTypeDefinitionImpl.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * 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.commons.core.edm.provider;
+
+import org.apache.olingo.odata4.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.odata4.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.odata4.commons.api.edm.EdmTypeDefinition;
+import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind;
+import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName;
+import org.apache.olingo.odata4.commons.api.edm.provider.TypeDefinition;
+
+public class EdmTypeDefinitionImpl extends EdmNamedImpl implements EdmTypeDefinition {
+
+ private final FullQualifiedName typeDefinitionName;
+
+ public EdmTypeDefinitionImpl(final EdmProviderImpl edm, final FullQualifiedName typeDefinitionName,
+ final TypeDefinition typeDefinition) {
+ super(edm, typeDefinitionName.getName());
+ this.typeDefinitionName = typeDefinitionName;
+ }
+
+ @Override
+ public boolean isCompatible(final EdmPrimitiveType primitiveType) {
+ return false;
+ }
+
+ @Override
+ public Class<?> getDefaultType() {
+ return null;
+ }
+
+ @Override
+ public boolean validate(final String value, final Boolean isNullable, final Integer maxLength,
+ final Integer precision, final Integer scale,
+ final Boolean isUnicode) {
+ return false;
+ }
+
+ @Override
+ public <T> T valueOfString(final String value, final Boolean isNullable, final Integer maxLength,
+ final Integer precision, final Integer scale,
+ final Boolean isUnicode, final Class<T> returnType) throws EdmPrimitiveTypeException {
+ return null;
+ }
+
+ @Override
+ public String valueToString(final Object value, final Boolean isNullable, final Integer maxLength,
+ final Integer precision, final Integer scale,
+ final Boolean isUnicode) throws EdmPrimitiveTypeException {
+ return null;
+ }
+
+ @Override
+ public String toUriLiteral(final String literal) {
+ return null;
+ }
+
+ @Override
+ public String fromUriLiteral(final String literal) throws EdmPrimitiveTypeException {
+ return null;
+ }
+
+ @Override
+ public String getNamespace() {
+ return typeDefinitionName.getNamespace();
+ }
+
+ @Override
+ public EdmTypeKind getKind() {
+ return null;
+ }
+
+ @Override
+ public EdmPrimitiveType getUnderlyingType() {
+ return null;
+ }
+
+ @Override
+ public Integer getMaxLength() {
+ return null;
+ }
+
+ @Override
+ public Integer getPrecision() {
+ return null;
+ }
+
+ @Override
+ public Integer getScale() {
+ return null;
+ }
+
+ @Override
+ public Boolean isUnicode() {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmTypeImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmTypeImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmTypeImpl.java
new file mode 100644
index 0000000..b666643
--- /dev/null
+++ b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/odata4/commons/core/edm/provider/EdmTypeImpl.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.commons.core.edm.provider;
+
+import org.apache.olingo.odata4.commons.api.edm.EdmType;
+import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind;
+import org.apache.olingo.odata4.commons.api.edm.helper.FullQualifiedName;
+
+public abstract class EdmTypeImpl extends EdmNamedImpl implements EdmType {
+
+ private final EdmTypeKind kind;
+ private final String namespace;
+
+ public EdmTypeImpl(final EdmProviderImpl edm, final FullQualifiedName name, final EdmTypeKind kind) {
+ super(edm, name.getName());
+ namespace = name.getNamespace();
+ this.kind = kind;
+ }
+
+ @Override
+ public String getNamespace() {
+ return namespace;
+ }
+
+ @Override
+ public EdmTypeKind getKind() {
+ return kind;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/ActionMapKeyTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/ActionMapKeyTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/ActionMapKeyTest.java
deleted file mode 100644
index c760e77..0000000
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/ActionMapKeyTest.java
+++ /dev/null
@@ -1,84 +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.commons.core.edm;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-
-import org.apache.olingo.commons.api.edm.helper.FullQualifiedName;
-import org.junit.Test;
-
-public class ActionMapKeyTest {
-
- private final FullQualifiedName fqn = new FullQualifiedName("namespace", "name");
- private final FullQualifiedName fqnType = new FullQualifiedName("namespace2", "name2");
-
- @Test
- public void testEqualsMethod() {
- ActionMapKey key1 = new ActionMapKey(fqn, null, null);
- ActionMapKey someKey = new ActionMapKey(fqn, null, null);
- assertEquals(key1, someKey);
-
- key1 = new ActionMapKey(fqn, null, new Boolean(true));
- someKey = new ActionMapKey(fqn, null, true);
- assertEquals(key1, someKey);
-
- key1 = new ActionMapKey(fqn, fqnType, false);
- someKey = new ActionMapKey(fqn, fqnType, false);
- assertEquals(key1, someKey);
-
- key1 = new ActionMapKey(fqn, fqnType, null);
- someKey = new ActionMapKey(fqn, fqnType, null);
- assertEquals(key1, someKey);
-
- key1 = new ActionMapKey(fqn, fqnType, true);
- someKey = new ActionMapKey(fqn, fqnType, null);
- assertNotSame(key1, someKey);
-
- key1 = new ActionMapKey(fqn, fqnType, true);
- someKey = new ActionMapKey(fqn, fqnType, false);
- assertNotSame(key1, someKey);
-
- key1 = new ActionMapKey(fqn, null, true);
- someKey = new ActionMapKey(fqn, fqnType, false);
- assertNotSame(key1, someKey);
-
- key1 = new ActionMapKey(fqn, null, true);
- someKey = new ActionMapKey(fqn, null, false);
- assertNotSame(key1, someKey);
- }
-
- @Test
- public void testHashMethod() {
- ActionMapKey key1 = new ActionMapKey(fqn, null, null);
- ActionMapKey someKey = new ActionMapKey(fqn, null, null);
- assertEquals(key1.hashCode(), someKey.hashCode());
-
- key1 = new ActionMapKey(fqn, null, new Boolean(true));
- someKey = new ActionMapKey(fqn, null, true);
- assertEquals(key1.hashCode(), someKey.hashCode());
-
- someKey = new ActionMapKey(fqn, fqnType, true);
- assertNotSame(key1.hashCode(), someKey.hashCode());
-
- someKey = new ActionMapKey(fqn, fqnType, false);
- assertNotSame(key1.hashCode(), someKey.hashCode());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java
deleted file mode 100644
index 9dcbfbc..0000000
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.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.commons.core.edm;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmAction;
-import org.apache.olingo.commons.api.edm.EdmComplexType;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-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.EdmServiceMetadata;
-import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
-import org.apache.olingo.commons.api.edm.helper.FullQualifiedName;
-import org.junit.Before;
-import org.junit.Test;
-
-public class EdmImplCachingTest {
-
- private final FullQualifiedName NAME1 = new FullQualifiedName("testNamespace1", "testName1");
- private final FullQualifiedName NAME2 = new FullQualifiedName("testNamespace2", "testName2");
- private Edm edm;
-
- // TODO: Test with alias
-
- @Test
- public void cacheEntityContainer() {
- EdmEntityContainer entityContainer = edm.getEntityContainer(null);
- assertNotNull(entityContainer);
-
- EdmEntityContainer cachedContainer = edm.getEntityContainer(NAME1);
- assertNotNull(entityContainer);
-
- assertTrue(entityContainer == cachedContainer);
- assertEquals(entityContainer, cachedContainer);
-
- cachedContainer = edm.getEntityContainer(NAME1);
- assertNotNull(cachedContainer);
-
- assertTrue(entityContainer == cachedContainer);
- assertEquals(entityContainer, cachedContainer);
-
- EdmEntityContainer entityContainer2 = edm.getEntityContainer(NAME2);
- assertNotNull(entityContainer2);
-
- assertNotSame(entityContainer, entityContainer2);
- }
-
- @Test
- public void cacheEnumType() {
- EdmEnumType enumType = edm.getEnumType(NAME1);
- assertNotNull(enumType);
-
- EdmEnumType cachedType = edm.getEnumType(NAME1);
- assertNotNull(cachedType);
-
- assertTrue(enumType == cachedType);
- assertEquals(enumType, cachedType);
-
- EdmEnumType enumType2 = edm.getEnumType(NAME2);
- assertNotNull(enumType2);
-
- assertNotSame(enumType, enumType2);
- }
-
- @Test
- public void cacheTypeDefinition() {
- EdmTypeDefinition typeDefinition = edm.getTypeDefinition(NAME1);
- assertNotNull(typeDefinition);
-
- EdmTypeDefinition cachedDefinition = edm.getTypeDefinition(NAME1);
- assertNotNull(cachedDefinition);
-
- assertTrue(typeDefinition == cachedDefinition);
- assertEquals(typeDefinition, cachedDefinition);
-
- EdmTypeDefinition typeDefinition2 = edm.getTypeDefinition(NAME2);
- assertNotNull(typeDefinition2);
-
- assertNotSame(typeDefinition, typeDefinition2);
- }
-
- @Test
- public void cacheEntityType() {
- EdmEntityType entityType = edm.getEntityType(NAME1);
- assertNotNull(entityType);
-
- EdmEntityType cachedType = edm.getEntityType(NAME1);
- assertNotNull(cachedType);
-
- assertTrue(entityType == cachedType);
- assertEquals(entityType, cachedType);
-
- EdmEntityType entityType2 = edm.getEntityType(NAME2);
- assertNotNull(entityType2);
-
- assertNotSame(entityType, entityType2);
- }
-
- @Test
- public void cacheComplexType() {
- EdmComplexType complexType = edm.getComplexType(NAME1);
- assertNotNull(complexType);
-
- EdmComplexType cachedType = edm.getComplexType(NAME1);
- assertNotNull(cachedType);
-
- assertTrue(complexType == cachedType);
- assertEquals(complexType, cachedType);
-
- EdmComplexType complexType2 = edm.getComplexType(NAME2);
- assertNotNull(complexType2);
-
- assertNotSame(complexType, complexType2);
- }
-
- @Test
- public void cacheActionSimple() {
- EdmAction action = edm.getAction(NAME1, null, null);
- assertNotNull(action);
-
- EdmAction cachedAction = edm.getAction(NAME1, null, null);
- assertNotNull(cachedAction);
-
- assertTrue(action == cachedAction);
- assertEquals(action, cachedAction);
-
- EdmAction action2 = edm.getAction(NAME2, null, false);
- assertNotNull(action2);
- assertNotSame(action, action2);
- }
-
- @Test
- public void cacheActionComlex() {
- EdmAction action = edm.getAction(NAME1, null, null);
- assertNotNull(action);
-
- EdmAction cachedAction = edm.getAction(NAME1, null, true);
- assertNull(cachedAction);
-
- cachedAction = edm.getAction(NAME1, null, false);
- assertNull(cachedAction);
-
- cachedAction = edm.getAction(NAME1, NAME2, null);
- assertNull(cachedAction);
-
- cachedAction = edm.getAction(NAME1, NAME2, true);
- assertNull(cachedAction);
-
- cachedAction = edm.getAction(NAME1, NAME2, false);
- assertNull(cachedAction);
-
- cachedAction = edm.getAction(NAME1, NAME1, null);
- assertNull(cachedAction);
-
- cachedAction = edm.getAction(NAME1, NAME1, true);
- assertNull(cachedAction);
-
- cachedAction = edm.getAction(NAME1, NAME1, false);
- assertNull(cachedAction);
- }
-
- @Test
- public void cacheFunctionSimple() {
- EdmFunction function = edm.getFunction(NAME1, null, null, null);
- assertNotNull(function);
-
- EdmFunction cachedfunction = edm.getFunction(NAME1, null, null, null);
- assertNotNull(cachedfunction);
-
- assertTrue(function == cachedfunction);
- assertEquals(function, cachedfunction);
-
- EdmFunction function2 = edm.getFunction(NAME2, null, false, null);
- assertNotNull(function2);
-
- assertNotSame(function, function2);
- }
-
- @Test
- public void cacheFunctionComplex() {
- EdmFunction function = edm.getFunction(NAME1, null, null, null);
- assertNotNull(function);
-
- EdmFunction cachedfunction = edm.getFunction(NAME1, null, false, null);
- assertNull(cachedfunction);
-
- cachedfunction = edm.getFunction(NAME1, null, true, null);
- assertNull(cachedfunction);
-
- cachedfunction = edm.getFunction(NAME1, null, new Boolean(true), null);
- assertNull(cachedfunction);
-
- cachedfunction = edm.getFunction(NAME1, NAME2, null, null);
- assertNull(cachedfunction);
-
- cachedfunction = edm.getFunction(NAME1, NAME2, true, null);
- assertNull(cachedfunction);
-
- cachedfunction = edm.getFunction(NAME1, NAME2, false, null);
- assertNull(cachedfunction);
-
- cachedfunction = edm.getFunction(NAME1, null, null, new ArrayList<String>());
- assertNull(cachedfunction);
- }
-
- @Test
- public void cacheFunctionComplexWithListContent() {
-
- }
-
- @Test
- public void cacheServiceMetadata() {
- EdmServiceMetadata serviceMetadata = edm.getServiceMetadata();
- EdmServiceMetadata cachedMetadata = edm.getServiceMetadata();
-
- assertTrue(serviceMetadata == cachedMetadata);
- assertEquals(serviceMetadata, cachedMetadata);
- }
-
- @Before
- public void setup() {
- edm = new LocalEdm();
- }
-
- private class LocalEdm extends EdmImpl {
- @Override
- public EdmEntityContainer createEntityContainer(final FullQualifiedName fqn) {
- if (NAME1.equals(fqn) || fqn == null) {
- EdmEntityContainer container = mock(EdmEntityContainer.class);
- when(container.getNamespace()).thenReturn(NAME1.getNamespace());
- when(container.getName()).thenReturn(NAME1.getName());
- return container;
- } else if (NAME2.equals(fqn)) {
- EdmEntityContainer container = mock(EdmEntityContainer.class);
- when(container.getNamespace()).thenReturn(fqn.getNamespace());
- when(container.getName()).thenReturn(fqn.getName());
- return container;
- }
- return null;
- }
-
- @Override
- public EdmEnumType createEnumType(final FullQualifiedName fqn) {
- if (NAME1.equals(fqn) || NAME2.equals(fqn)) {
- EdmEnumType enumType = mock(EdmEnumType.class);
- when(enumType.getNamespace()).thenReturn(fqn.getNamespace());
- when(enumType.getName()).thenReturn(fqn.getName());
- return enumType;
- }
- return null;
- }
-
- @Override
- public EdmTypeDefinition createTypeDefinition(final FullQualifiedName fqn) {
- if (NAME1.equals(fqn) || NAME2.equals(fqn)) {
- EdmTypeDefinition typeDefinition = mock(EdmTypeDefinition.class);
- when(typeDefinition.getNamespace()).thenReturn(fqn.getNamespace());
- when(typeDefinition.getName()).thenReturn(fqn.getName());
- return typeDefinition;
- }
- return null;
- }
-
- @Override
- public EdmEntityType createEntityType(final FullQualifiedName fqn) {
- if (NAME1.equals(fqn) || NAME2.equals(fqn)) {
- EdmEntityType entityType = mock(EdmEntityType.class);
- when(entityType.getNamespace()).thenReturn(fqn.getNamespace());
- when(entityType.getName()).thenReturn(fqn.getName());
- return entityType;
- }
- return null;
- }
-
- @Override
- public EdmComplexType createComplexType(final FullQualifiedName fqn) {
- if (NAME1.equals(fqn) || NAME2.equals(fqn)) {
- EdmComplexType complexType = mock(EdmComplexType.class);
- when(complexType.getNamespace()).thenReturn(fqn.getNamespace());
- when(complexType.getName()).thenReturn(fqn.getName());
- return complexType;
- }
- return null;
- }
-
- @Override
- public EdmAction createAction(final FullQualifiedName fqn, final FullQualifiedName bindingParameterTypeName,
- final Boolean isBindingParameterCollection) {
- if (NAME1.equals(fqn) && bindingParameterTypeName == null && isBindingParameterCollection == null) {
- EdmAction action = mock(EdmAction.class);
- when(action.getNamespace()).thenReturn(fqn.getNamespace());
- when(action.getName()).thenReturn(fqn.getName());
- return action;
- } else if (NAME2.equals(fqn)) {
- EdmAction action = mock(EdmAction.class);
- when(action.getNamespace()).thenReturn(fqn.getNamespace());
- when(action.getName()).thenReturn(fqn.getName());
- return action;
- }
- return null;
- }
-
- @Override
- public EdmFunction createFunction(final FullQualifiedName fqn, final FullQualifiedName bindingParameterTypeName,
- final Boolean isBindingParameterCollection, final List<String> bindingParameterNames) {
- if (NAME1.equals(fqn) && bindingParameterTypeName == null && isBindingParameterCollection == null
- && bindingParameterNames == null) {
- EdmFunction function = mock(EdmFunction.class);
- when(function.getNamespace()).thenReturn(fqn.getNamespace());
- when(function.getName()).thenReturn(fqn.getName());
- return function;
- } else if (NAME2.equals(fqn)) {
- EdmFunction function = mock(EdmFunction.class);
- when(function.getNamespace()).thenReturn(fqn.getNamespace());
- when(function.getName()).thenReturn(fqn.getName());
- return function;
- }
- return null;
- }
-
- @Override
- public EdmServiceMetadata createServiceMetadata() {
- return mock(EdmServiceMetadata.class);
- }
-
- @Override
- protected Map<String, String> createAliasToNamespaceInfo() {
- return new HashMap<String, String>();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java
deleted file mode 100644
index ee04340..0000000
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java
+++ /dev/null
@@ -1,225 +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.commons.core.edm;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmAction;
-import org.apache.olingo.commons.api.edm.EdmComplexType;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-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.EdmServiceMetadata;
-import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
-import org.apache.olingo.commons.api.edm.helper.FullQualifiedName;
-import org.junit.Before;
-import org.junit.Test;
-
-public class EdmImplCallCreateTest {
-
- private final FullQualifiedName FQN = new FullQualifiedName("testNamespace", "testName");
- private final FullQualifiedName WRONG_FQN = new FullQualifiedName("wrong", "wrong");
- private Edm edm;
-
- @Test
- public void callCreateEntityContainer() {
- EdmEntityContainer entityContainer = edm.getEntityContainer(FQN);
- assertNotNull(entityContainer);
- assertEquals(FQN.getNamespace(), entityContainer.getNamespace());
- assertEquals(FQN.getName(), entityContainer.getName());
-
- entityContainer = edm.getEntityContainer(null);
- assertNotNull(entityContainer);
- assertEquals(FQN.getNamespace(), entityContainer.getNamespace());
- assertEquals(FQN.getName(), entityContainer.getName());
-
- assertNull(edm.getEntityContainer(WRONG_FQN));
- }
-
- @Test
- public void callCreateEnumType() {
- EdmEnumType enumType = edm.getEnumType(FQN);
- assertNotNull(enumType);
- assertEquals(FQN.getNamespace(), enumType.getNamespace());
- assertEquals(FQN.getName(), enumType.getName());
-
- assertNull(edm.getEnumType(WRONG_FQN));
- }
-
- @Test
- public void callCreateTypeDefinition() {
- EdmTypeDefinition typeDefinition = edm.getTypeDefinition(FQN);
- assertNotNull(typeDefinition);
- assertEquals(FQN.getNamespace(), typeDefinition.getNamespace());
- assertEquals(FQN.getName(), typeDefinition.getName());
-
- assertNull(edm.getTypeDefinition(WRONG_FQN));
- }
-
- @Test
- public void callCreateEntityType() {
- EdmEntityType entityType = edm.getEntityType(FQN);
- assertNotNull(entityType);
- assertEquals(FQN.getNamespace(), entityType.getNamespace());
- assertEquals(FQN.getName(), entityType.getName());
-
- assertNull(edm.getEntityType(WRONG_FQN));
- }
-
- @Test
- public void callCreateComplexType() {
- EdmComplexType complexType = edm.getComplexType(FQN);
- assertNotNull(complexType);
- assertEquals(FQN.getNamespace(), complexType.getNamespace());
- assertEquals(FQN.getName(), complexType.getName());
-
- assertNull(edm.getComplexType(WRONG_FQN));
- }
-
- @Test
- public void callCreateAction() {
- EdmAction action = edm.getAction(FQN, null, null);
- assertNotNull(action);
- assertEquals(FQN.getNamespace(), action.getNamespace());
- assertEquals(FQN.getName(), action.getName());
-
- assertNull(edm.getAction(WRONG_FQN, null, null));
- }
-
- @Test
- public void callCreateFunction() {
- EdmFunction function = edm.getFunction(FQN, null, null, null);
- assertNotNull(function);
- assertEquals(FQN.getNamespace(), function.getNamespace());
- assertEquals(FQN.getName(), function.getName());
-
- assertNull(edm.getFunction(WRONG_FQN, null, null, null));
- }
-
- @Test
- public void callCreateServiceMetadata() {
- assertNotNull(edm.getServiceMetadata());
- }
-
- @Before
- public void setup() {
- edm = new LocalEdm();
- }
-
- private class LocalEdm extends EdmImpl {
- @Override
- public EdmEntityContainer createEntityContainer(final FullQualifiedName fqn) {
- if (fqn == null || FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
- EdmEntityContainer container = mock(EdmEntityContainer.class);
- when(container.getNamespace()).thenReturn(FQN.getNamespace());
- when(container.getName()).thenReturn(FQN.getName());
- return container;
- }
- return null;
- }
-
- @Override
- public EdmEnumType createEnumType(final FullQualifiedName fqn) {
- if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
- EdmEnumType enumType = mock(EdmEnumType.class);
- when(enumType.getNamespace()).thenReturn(fqn.getNamespace());
- when(enumType.getName()).thenReturn(fqn.getName());
- return enumType;
- }
- return null;
- }
-
- @Override
- public EdmTypeDefinition createTypeDefinition(final FullQualifiedName fqn) {
- if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
- EdmTypeDefinition typeDefinition = mock(EdmTypeDefinition.class);
- when(typeDefinition.getNamespace()).thenReturn(fqn.getNamespace());
- when(typeDefinition.getName()).thenReturn(fqn.getName());
- return typeDefinition;
- }
- return null;
- }
-
- @Override
- public EdmEntityType createEntityType(final FullQualifiedName fqn) {
- if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
- EdmEntityType entityType = mock(EdmEntityType.class);
- when(entityType.getNamespace()).thenReturn(fqn.getNamespace());
- when(entityType.getName()).thenReturn(fqn.getName());
- return entityType;
- }
- return null;
- }
-
- @Override
- public EdmComplexType createComplexType(final FullQualifiedName fqn) {
- if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
- EdmComplexType complexType = mock(EdmComplexType.class);
- when(complexType.getNamespace()).thenReturn(fqn.getNamespace());
- when(complexType.getName()).thenReturn(fqn.getName());
- return complexType;
- }
- return null;
- }
-
- @Override
- public EdmAction createAction(final FullQualifiedName fqn, final FullQualifiedName bindingParameterTypeName,
- final Boolean isBindingParameterCollection) {
- if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
- EdmAction action = mock(EdmAction.class);
- when(action.getNamespace()).thenReturn(fqn.getNamespace());
- when(action.getName()).thenReturn(fqn.getName());
- return action;
- }
- return null;
- }
-
- @Override
- public EdmFunction createFunction(final FullQualifiedName fqn, final FullQualifiedName bindingParameterTypeName,
- final Boolean isBindingParameterCollection, final List<String> bindingParameterNames) {
- if (FQN.getNamespace().equals(fqn.getNamespace()) && FQN.getName().equals(fqn.getName())) {
- EdmFunction function = mock(EdmFunction.class);
- when(function.getNamespace()).thenReturn(fqn.getNamespace());
- when(function.getName()).thenReturn(fqn.getName());
- return function;
- }
- return null;
- }
-
- @Override
- public EdmServiceMetadata createServiceMetadata() {
- return mock(EdmServiceMetadata.class);
- }
-
- @Override
- protected Map<String, String> createAliasToNamespaceInfo() {
- return new HashMap<String, String>();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/FunctionMapKeyTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/FunctionMapKeyTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/FunctionMapKeyTest.java
deleted file mode 100644
index 3e96659..0000000
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/FunctionMapKeyTest.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.commons.core.edm;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.commons.api.edm.helper.FullQualifiedName;
-import org.junit.Test;
-
-public class FunctionMapKeyTest {
-
- private final FullQualifiedName fqn = new FullQualifiedName("namespace", "name");
- private final FullQualifiedName fqnType = new FullQualifiedName("namespace2", "name2");
-
- @Test
- public void testEqualsPositive() {
- FunctionMapKey key = new FunctionMapKey(fqn, null, null, null);
- FunctionMapKey someKey = new FunctionMapKey(fqn, null, null, null);
- assertEquals(key, someKey);
-
- key = new FunctionMapKey(fqn, null, true, null);
- someKey = new FunctionMapKey(fqn, null, true, null);
- assertEquals(key, someKey);
-
- key = new FunctionMapKey(fqn, fqnType, true, null);
- someKey = new FunctionMapKey(fqn, fqnType, true, null);
- assertEquals(key, someKey);
-
- key = new FunctionMapKey(fqn, fqnType, false, null);
- someKey = new FunctionMapKey(fqn, fqnType, false, null);
- assertEquals(key, someKey);
-
- key = new FunctionMapKey(fqn, fqnType, false, new ArrayList<String>());
- someKey = new FunctionMapKey(fqn, fqnType, false, new ArrayList<String>());
- assertEquals(key, someKey);
-
- List<String> keyList = new ArrayList<String>();
- keyList.add("Employee");
- List<String> someKeyList = new ArrayList<String>();
- someKeyList.add("Employee");
- key = new FunctionMapKey(fqn, fqnType, false, keyList);
- someKey = new FunctionMapKey(fqn, fqnType, false, someKeyList);
- assertEquals(key, someKey);
-
- key = new FunctionMapKey(fqn, null, null, new ArrayList<String>());
- someKey = new FunctionMapKey(fqn, null, null, new ArrayList<String>());
- assertEquals(key, someKey);
-
- keyList = new ArrayList<String>();
- keyList.add("Employee");
- someKeyList = new ArrayList<String>();
- someKeyList.add("Employee");
- key = new FunctionMapKey(fqn, null, null, keyList);
- someKey = new FunctionMapKey(fqn, null, null, someKeyList);
- assertEquals(key, someKey);
- }
-
- @Test
- public void testEqualsNegative() {
- FunctionMapKey key = new FunctionMapKey(fqn, null, null, null);
- FunctionMapKey someKey = new FunctionMapKey(fqn, null, true, null);
- assertNotSame(key, someKey);
-
- key = new FunctionMapKey(fqn, null, true, null);
- someKey = new FunctionMapKey(fqn, null, false, null);
- assertNotSame(key, someKey);
-
- key = new FunctionMapKey(fqn, fqnType, true, null);
- someKey = new FunctionMapKey(fqn, null, true, null);
- assertNotSame(key, someKey);
-
- key = new FunctionMapKey(fqn, null, false, null);
- someKey = new FunctionMapKey(fqn, fqnType, true, null);
- assertNotSame(key, someKey);
-
- key = new FunctionMapKey(fqn, fqnType, false, null);
- someKey = new FunctionMapKey(fqn, fqnType, false, new ArrayList<String>());
- assertNotSame(key, someKey);
-
- List<String> keyList = new ArrayList<String>();
- keyList.add("Employee");
- List<String> someKeyList = new ArrayList<String>();
- someKeyList.add("Employee2");
- key = new FunctionMapKey(fqn, fqnType, false, keyList);
- someKey = new FunctionMapKey(fqn, fqnType, false, someKeyList);
- assertNotSame(key, someKey);
-
- key = new FunctionMapKey(fqn, null, null, new ArrayList<String>());
- someKey = new FunctionMapKey(fqn, null, null, new ArrayList<String>());
- assertNotSame(key, someKey);
-
- keyList = new ArrayList<String>();
- keyList.add("Employee");
- someKeyList = new ArrayList<String>();
- someKeyList.add("Employee2");
- key = new FunctionMapKey(fqn, null, null, keyList);
- someKey = new FunctionMapKey(fqn, null, null, someKeyList);
- assertNotSame(key, someKey);
-
- key = new FunctionMapKey(fqn, null, null, new ArrayList<String>());
- someKey = new FunctionMapKey(fqn, null, null, null);
- assertNotSame(key, someKey);
-
- keyList = new ArrayList<String>();
- keyList.add("Employee");
- someKeyList = new ArrayList<String>();
- key = new FunctionMapKey(fqn, null, null, keyList);
- someKey = new FunctionMapKey(fqn, null, null, someKeyList);
- assertNotSame(key, someKey);
-
- keyList = new ArrayList<String>();
- keyList.add("Employee");
- someKeyList = new ArrayList<String>();
- someKeyList.add("EmpLoYeE");
- key = new FunctionMapKey(fqn, null, null, keyList);
- someKey = new FunctionMapKey(fqn, null, null, someKeyList);
- assertNotSame(key, someKey);
- }
-
- @Test
- public void testHashCodePositive() {
- FunctionMapKey key = new FunctionMapKey(fqn, null, null, null);
- FunctionMapKey someKey = new FunctionMapKey(fqn, null, null, null);
- assertEquals(key.hashCode(), someKey.hashCode());
-
- key = new FunctionMapKey(fqn, null, true, null);
- someKey = new FunctionMapKey(fqn, null, true, null);
- assertEquals(key.hashCode(), someKey.hashCode());
-
- key = new FunctionMapKey(fqn, fqnType, true, null);
- someKey = new FunctionMapKey(fqn, fqnType, true, null);
- assertEquals(key.hashCode(), someKey.hashCode());
-
- key = new FunctionMapKey(fqn, fqnType, false, null);
- someKey = new FunctionMapKey(fqn, fqnType, false, null);
- assertEquals(key.hashCode(), someKey.hashCode());
-
- key = new FunctionMapKey(fqn, fqnType, false, new ArrayList<String>());
- someKey = new FunctionMapKey(fqn, fqnType, false, new ArrayList<String>());
- assertEquals(key.hashCode(), someKey.hashCode());
-
- List<String> keyList = new ArrayList<String>();
- keyList.add("Employee");
- List<String> someKeyList = new ArrayList<String>();
- someKeyList.add("Employee");
- key = new FunctionMapKey(fqn, fqnType, false, keyList);
- someKey = new FunctionMapKey(fqn, fqnType, false, someKeyList);
- assertEquals(key.hashCode(), someKey.hashCode());
-
- key = new FunctionMapKey(fqn, null, null, new ArrayList<String>());
- someKey = new FunctionMapKey(fqn, null, null, new ArrayList<String>());
- assertEquals(key.hashCode(), someKey.hashCode());
-
- keyList = new ArrayList<String>();
- keyList.add("Employee");
- someKeyList = new ArrayList<String>();
- someKeyList.add("Employee");
- key = new FunctionMapKey(fqn, null, null, keyList);
- someKey = new FunctionMapKey(fqn, null, null, someKeyList);
- assertEquals(key.hashCode(), someKey.hashCode());
-
- keyList = new ArrayList<String>();
- keyList.add("Employee");
- keyList.add("employee");
- someKeyList = new ArrayList<String>();
- someKeyList.add("Employee");
- someKeyList.add("employee");
- key = new FunctionMapKey(fqn, null, null, keyList);
- someKey = new FunctionMapKey(fqn, null, null, someKeyList);
- assertEquals(key.hashCode(), someKey.hashCode());
-
- keyList = new ArrayList<String>();
- keyList.add("Employee");
- keyList.add("Employee2");
- someKeyList = new ArrayList<String>();
- someKeyList.add("Employee2");
- someKeyList.add("Employee");
- key = new FunctionMapKey(fqn, null, null, keyList);
- someKey = new FunctionMapKey(fqn, null, null, someKeyList);
- assertEquals(key.hashCode(), someKey.hashCode());
- }
-
- @Test
- public void testHashCodeNegative() {
- FunctionMapKey key = new FunctionMapKey(fqn, null, null, null);
- FunctionMapKey someKey = new FunctionMapKey(fqn, null, true, null);
- assertNotSame(key.hashCode(), someKey.hashCode());
-
- key = new FunctionMapKey(fqn, null, true, null);
- someKey = new FunctionMapKey(fqn, null, false, null);
- assertNotSame(key.hashCode(), someKey.hashCode());
-
- key = new FunctionMapKey(fqn, fqnType, true, null);
- someKey = new FunctionMapKey(fqn, null, true, null);
- assertNotSame(key.hashCode(), someKey.hashCode());
-
- key = new FunctionMapKey(fqn, null, false, null);
- someKey = new FunctionMapKey(fqn, fqnType, true, null);
- assertNotSame(key.hashCode(), someKey.hashCode());
-
- key = new FunctionMapKey(fqn, fqnType, false, null);
- someKey = new FunctionMapKey(fqn, fqnType, false, new ArrayList<String>());
- assertNotSame(key.hashCode(), someKey.hashCode());
-
- List<String> keyList = new ArrayList<String>();
- keyList.add("Employee");
- List<String> someKeyList = new ArrayList<String>();
- someKeyList.add("Employee2");
- key = new FunctionMapKey(fqn, fqnType, false, keyList);
- someKey = new FunctionMapKey(fqn, fqnType, false, someKeyList);
- assertNotSame(key.hashCode(), someKey.hashCode());
-
- key = new FunctionMapKey(fqn, null, null, new ArrayList<String>());
- someKey = new FunctionMapKey(fqn, null, null, new ArrayList<String>());
- assertNotSame(key.hashCode(), someKey.hashCode());
-
- keyList = new ArrayList<String>();
- keyList.add("Employee");
- someKeyList = new ArrayList<String>();
- someKeyList.add("Employee2");
- key = new FunctionMapKey(fqn, null, null, keyList);
- someKey = new FunctionMapKey(fqn, null, null, someKeyList);
- assertNotSame(key.hashCode(), someKey.hashCode());
-
- key = new FunctionMapKey(fqn, null, null, new ArrayList<String>());
- someKey = new FunctionMapKey(fqn, null, null, null);
- assertNotSame(key.hashCode(), someKey.hashCode());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/CommonPrimitiveTypeTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/CommonPrimitiveTypeTest.java b/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/CommonPrimitiveTypeTest.java
deleted file mode 100644
index fc9870d..0000000
--- a/odata4-lib/odata4-commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/CommonPrimitiveTypeTest.java
+++ /dev/null
@@ -1,172 +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.commons.core.edm.primitivetype;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.math.BigDecimal;
-import java.util.Calendar;
-import java.util.UUID;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
-import org.junit.Test;
-
-public class CommonPrimitiveTypeTest extends PrimitiveTypeBaseTest {
-
- @Test
- public void nameSpace() throws Exception {
- assertEquals(EdmPrimitiveType.SYSTEM_NAMESPACE, Uint7.getInstance().getNamespace());
-
- assertEquals(EdmPrimitiveType.EDM_NAMESPACE, EdmNull.getInstance().getNamespace());
- for (EdmPrimitiveTypeKind kind : EdmPrimitiveTypeKind.values()) {
- final EdmPrimitiveType instance = kind.getEdmPrimitiveTypeInstance();
- assertEquals(EdmPrimitiveType.EDM_NAMESPACE, instance.getNamespace());
- }
- }
-
- @Test
- public void names() throws Exception {
- assertEquals("Uint7", Uint7.getInstance().getName());
-
- assertEquals("Null", EdmNull.getInstance().getName());
- assertEquals("Binary", EdmPrimitiveTypeKind.Binary.getEdmPrimitiveTypeInstance().getName());
- assertEquals("Boolean", EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance().getName());
- assertEquals("Byte", EdmPrimitiveTypeKind.Byte.getEdmPrimitiveTypeInstance().getName());
- assertEquals("Date", EdmPrimitiveTypeKind.Date.getEdmPrimitiveTypeInstance().getName());
- assertEquals("DateTimeOffset", EdmPrimitiveTypeKind.DateTimeOffset.getEdmPrimitiveTypeInstance().getName());
- assertEquals("Decimal", EdmPrimitiveTypeKind.Decimal.getEdmPrimitiveTypeInstance().getName());
- assertEquals("Double", EdmPrimitiveTypeKind.Double.getEdmPrimitiveTypeInstance().getName());
- assertEquals("Duration", EdmPrimitiveTypeKind.Duration.getEdmPrimitiveTypeInstance().getName());
- assertEquals("Guid", EdmPrimitiveTypeKind.Guid.getEdmPrimitiveTypeInstance().getName());
- assertEquals("Int16", EdmPrimitiveTypeKind.Int16.getEdmPrimitiveTypeInstance().getName());
- assertEquals("Int32", EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance().getName());
- assertEquals("Int64", EdmPrimitiveTypeKind.Int64.getEdmPrimitiveTypeInstance().getName());
- assertEquals("SByte", EdmPrimitiveTypeKind.SByte.getEdmPrimitiveTypeInstance().getName());
- assertEquals("Single", EdmPrimitiveTypeKind.Single.getEdmPrimitiveTypeInstance().getName());
- assertEquals("String", EdmPrimitiveTypeKind.String.getEdmPrimitiveTypeInstance().getName());
- assertEquals("TimeOfDay", EdmPrimitiveTypeKind.TimeOfDay.getEdmPrimitiveTypeInstance().getName());
- }
-
- @Test
- public void kind() throws Exception {
- for (EdmPrimitiveTypeKind kind : EdmPrimitiveTypeKind.values()) {
- assertEquals(EdmTypeKind.PRIMITIVE, kind.getEdmPrimitiveTypeInstance().getKind());
- }
- }
-
- @Test
- public void toStringAll() throws Exception {
- assertEquals("System.Uint7", Uint7.getInstance().toString());
-
- assertEquals("Edm.Null", EdmNull.getInstance().toString());
- assertEquals("Edm.Binary", EdmPrimitiveTypeKind.Binary.getEdmPrimitiveTypeInstance().toString());
- assertEquals("Edm.Boolean", EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance().toString());
- assertEquals("Edm.Byte", EdmPrimitiveTypeKind.Byte.getEdmPrimitiveTypeInstance().toString());
- assertEquals("Edm.Date", EdmPrimitiveTypeKind.Date.getEdmPrimitiveTypeInstance().toString());
- assertEquals("Edm.DateTimeOffset", EdmPrimitiveTypeKind.DateTimeOffset.getEdmPrimitiveTypeInstance().toString());
- assertEquals("Edm.Decimal", EdmPrimitiveTypeKind.Decimal.getEdmPrimitiveTypeInstance().toString());
- assertEquals("Edm.Double", EdmPrimitiveTypeKind.Double.getEdmPrimitiveTypeInstance().toString());
- assertEquals("Edm.Duration", EdmPrimitiveTypeKind.Duration.getEdmPrimitiveTypeInstance().toString());
- assertEquals("Edm.Guid", EdmPrimitiveTypeKind.Guid.getEdmPrimitiveTypeInstance().toString());
- assertEquals("Edm.Int16", EdmPrimitiveTypeKind.Int16.getEdmPrimitiveTypeInstance().toString());
- assertEquals("Edm.Int32", EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance().toString());
- assertEquals("Edm.Int64", EdmPrimitiveTypeKind.Int64.getEdmPrimitiveTypeInstance().toString());
- assertEquals("Edm.SByte", EdmPrimitiveTypeKind.SByte.getEdmPrimitiveTypeInstance().toString());
- assertEquals("Edm.Single", EdmPrimitiveTypeKind.Single.getEdmPrimitiveTypeInstance().toString());
- assertEquals("Edm.String", EdmPrimitiveTypeKind.String.getEdmPrimitiveTypeInstance().toString());
- assertEquals("Edm.TimeOfDay", EdmPrimitiveTypeKind.TimeOfDay.getEdmPrimitiveTypeInstance().toString());
-
- for (EdmPrimitiveTypeKind kind : EdmPrimitiveTypeKind.values()) {
- final EdmPrimitiveType instance = kind.getEdmPrimitiveTypeInstance();
- assertEquals(instance.toString(), kind.getFullQualifiedName().toString());
- }
- }
-
- @Test
- public void compatibility() {
- for (EdmPrimitiveTypeKind kind : EdmPrimitiveTypeKind.values()) {
- final EdmPrimitiveType instance = kind.getEdmPrimitiveTypeInstance();
- assertTrue(instance.isCompatible(instance));
- assertFalse(instance.isCompatible(
- (kind == EdmPrimitiveTypeKind.String ? EdmPrimitiveTypeKind.Binary : EdmPrimitiveTypeKind.String)
- .getEdmPrimitiveTypeInstance()));
- }
- }
-
- @Test
- public void defaultType() throws Exception {
- assertEquals(Byte.class, Uint7.getInstance().getDefaultType());
- assertNull(EdmNull.getInstance().getDefaultType());
-
- assertEquals(byte[].class, EdmPrimitiveTypeKind.Binary.getEdmPrimitiveTypeInstance().getDefaultType());
- assertEquals(Boolean.class, EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance().getDefaultType());
- assertEquals(Short.class, EdmPrimitiveTypeKind.Byte.getEdmPrimitiveTypeInstance().getDefaultType());
- assertEquals(Calendar.class, EdmPrimitiveTypeKind.Date.getEdmPrimitiveTypeInstance().getDefaultType());
- assertEquals(Calendar.class, EdmPrimitiveTypeKind.DateTimeOffset.getEdmPrimitiveTypeInstance().getDefaultType());
- assertEquals(BigDecimal.class, EdmPrimitiveTypeKind.Decimal.getEdmPrimitiveTypeInstance().getDefaultType());
- assertEquals(Double.class, EdmPrimitiveTypeKind.Double.getEdmPrimitiveTypeInstance().getDefaultType());
- assertEquals(BigDecimal.class, EdmPrimitiveTypeKind.Duration.getEdmPrimitiveTypeInstance().getDefaultType());
- assertEquals(UUID.class, EdmPrimitiveTypeKind.Guid.getEdmPrimitiveTypeInstance().getDefaultType());
- assertEquals(Short.class, EdmPrimitiveTypeKind.Int16.getEdmPrimitiveTypeInstance().getDefaultType());
- assertEquals(Integer.class, EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance().getDefaultType());
- assertEquals(Long.class, EdmPrimitiveTypeKind.Int64.getEdmPrimitiveTypeInstance().getDefaultType());
- assertEquals(Byte.class, EdmPrimitiveTypeKind.SByte.getEdmPrimitiveTypeInstance().getDefaultType());
- assertEquals(Float.class, EdmPrimitiveTypeKind.Single.getEdmPrimitiveTypeInstance().getDefaultType());
- assertEquals(String.class, EdmPrimitiveTypeKind.String.getEdmPrimitiveTypeInstance().getDefaultType());
- assertEquals(Calendar.class, EdmPrimitiveTypeKind.TimeOfDay.getEdmPrimitiveTypeInstance().getDefaultType());
- }
-
- @Test
- public void validate() throws Exception {
- for (EdmPrimitiveTypeKind kind : EdmPrimitiveTypeKind.values()) {
- final EdmPrimitiveType instance = kind.getEdmPrimitiveTypeInstance();
- assertTrue(instance.validate(null, null, null, null, null, null));
- assertTrue(instance.validate(null, true, null, null, null, null));
- assertFalse(instance.validate(null, false, null, null, null, null));
- assertFalse(instance.validate("ä", null, null, null, null, false));
- if (kind != EdmPrimitiveTypeKind.String && kind != EdmPrimitiveTypeKind.Binary) {
- assertFalse(instance.validate("", null, null, null, null, null));
- }
- if (kind != EdmPrimitiveTypeKind.String) {
- assertFalse(instance.validate("ä", null, null, null, null, null));
- }
- }
-
- assertTrue(EdmPrimitiveTypeKind.Binary.getEdmPrimitiveTypeInstance().validate("abcd", null, 3, null, null, null));
- assertFalse(EdmPrimitiveTypeKind.Binary.getEdmPrimitiveTypeInstance().validate("abcd", null, 2, null, null, null));
-
- assertTrue(EdmPrimitiveTypeKind.Decimal.getEdmPrimitiveTypeInstance().validate("1", null, null, null, null,
- null));
- assertFalse(EdmPrimitiveTypeKind.Decimal.getEdmPrimitiveTypeInstance().validate("1.2", null, null, null, 0, null));
- }
-
- @Test
- public void uriLiteral() throws Exception {
- for (EdmPrimitiveTypeKind kind : EdmPrimitiveTypeKind.values()) {
- final EdmPrimitiveType instance = kind.getEdmPrimitiveTypeInstance();
- assertEquals("test", instance.fromUriLiteral(instance.toUriLiteral("test")));
- assertNull(instance.toUriLiteral(null));
- assertNull(instance.fromUriLiteral(null));
- }
- }
-}