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 2015/03/31 14:42:59 UTC
[1/2] olingo-odata4 git commit: [OLINGO-595] Make EdmProvider an
Interface
Repository: olingo-odata4
Updated Branches:
refs/heads/master 92e201b0a -> 3e8c50646
[OLINGO-595] Make EdmProvider an Interface
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/d94edf56
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/d94edf56
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/d94edf56
Branch: refs/heads/master
Commit: d94edf568c03022872411b3b5343ea251941edf2
Parents: 92e201b
Author: Christian Amend <ch...@apache.org>
Authored: Tue Mar 31 13:47:15 2015 +0200
Committer: Christian Amend <ch...@apache.org>
Committed: Tue Mar 31 13:47:15 2015 +0200
----------------------------------------------------------------------
.../client/core/edm/ClientEdmProvider.java | 4 +-
.../api/edm/provider/AbstractEdmProvider.java | 116 +++++++++++++++++++
.../commons/api/edm/provider/EdmProvider.java | 70 +++--------
.../provider/EdmEntityContainerImplTest.java | 25 ++--
.../core/edm/provider/EdmSchemaImplTest.java | 21 ++--
.../xml/MetadataDocumentXmlSerializerTest.java | 3 +-
.../server/tecsvc/provider/EdmTechProvider.java | 14 +--
.../olingo/server/core/ODataHandlerTest.java | 4 +-
.../sample/edmprovider/CarsEdmProvider.java | 4 +-
9 files changed, 173 insertions(+), 88 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d94edf56/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/ClientEdmProvider.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/ClientEdmProvider.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/ClientEdmProvider.java
index 4327e62..b062447 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/ClientEdmProvider.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/ClientEdmProvider.java
@@ -24,13 +24,13 @@ import java.util.Map;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.AbstractEdmProvider;
import org.apache.olingo.commons.api.edm.provider.Action;
import org.apache.olingo.commons.api.edm.provider.ActionImport;
import org.apache.olingo.commons.api.edm.provider.AliasInfo;
import org.apache.olingo.commons.api.edm.provider.Annotatable;
import org.apache.olingo.commons.api.edm.provider.Annotations;
import org.apache.olingo.commons.api.edm.provider.ComplexType;
-import org.apache.olingo.commons.api.edm.provider.EdmProvider;
import org.apache.olingo.commons.api.edm.provider.EntityContainer;
import org.apache.olingo.commons.api.edm.provider.EntityContainerInfo;
import org.apache.olingo.commons.api.edm.provider.EntitySet;
@@ -43,7 +43,7 @@ import org.apache.olingo.commons.api.edm.provider.Singleton;
import org.apache.olingo.commons.api.edm.provider.Term;
import org.apache.olingo.commons.api.edm.provider.TypeDefinition;
-public class ClientEdmProvider extends EdmProvider {
+public class ClientEdmProvider extends AbstractEdmProvider {
private final Map<String, Schema> xmlSchemas;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d94edf56/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/AbstractEdmProvider.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/AbstractEdmProvider.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/AbstractEdmProvider.java
new file mode 100644
index 0000000..d1ada55
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/AbstractEdmProvider.java
@@ -0,0 +1,116 @@
+/*
+ * 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.api.edm.provider;
+
+import java.util.List;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+
+public abstract class AbstractEdmProvider implements EdmProvider {
+
+ @Override
+ public EnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException {
+ return null;
+ }
+
+ @Override
+ public TypeDefinition getTypeDefinition(final FullQualifiedName typeDefinitionName) throws ODataException {
+ return null;
+ }
+
+ @Override
+ public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException {
+ return null;
+ }
+
+ @Override
+ public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException {
+ return null;
+ }
+
+ @Override
+ public List<Action> getActions(final FullQualifiedName actionName) throws ODataException {
+ return null;
+ }
+
+ @Override
+ public List<Function> getFunctions(final FullQualifiedName functionName) throws ODataException {
+ return null;
+ }
+
+ @Override
+ public Term getTerm(final FullQualifiedName termName) throws ODataException {
+ return null;
+ }
+
+ @Override
+ public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName)
+ throws ODataException {
+ return null;
+ }
+
+ @Override
+ public Singleton getSingleton(final FullQualifiedName entityContainer, final String singletonName)
+ throws ODataException {
+ return null;
+ }
+
+ @Override
+ public ActionImport getActionImport(final FullQualifiedName entityContainer, final String actionImportName)
+ throws ODataException {
+ return null;
+ }
+
+ @Override
+ public FunctionImport getFunctionImport(final FullQualifiedName entityContainer, final String functionImportName)
+ throws ODataException {
+ return null;
+ }
+
+ @Override
+ public EntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName) throws ODataException {
+ return null;
+ }
+
+ @Override
+ public List<AliasInfo> getAliasInfos() throws ODataException {
+ return null;
+ }
+
+ @Override
+ public List<Schema> getSchemas() throws ODataException {
+ return null;
+ }
+
+ @Override
+ public EntityContainer getEntityContainer() throws ODataException {
+ return null;
+ }
+
+ @Override
+ public Annotations getAnnotationsGroup(FullQualifiedName targetName) throws ODataException {
+ return null;
+ }
+
+ @Override
+ public Annotatable getAnnoatatable(FullQualifiedName annotatedName) throws ODataException {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d94edf56/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/EdmProvider.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/EdmProvider.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/EdmProvider.java
index 38a03d7..f3511d7 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/EdmProvider.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/EdmProvider.java
@@ -23,7 +23,7 @@ import java.util.List;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
-public abstract class EdmProvider {
+public interface EdmProvider {
/**
* This method should return an {@link EnumType} or <b>null</b> if nothing is found
@@ -32,9 +32,7 @@ public abstract class EdmProvider {
* @return {@link EnumType} for given name
* @throws ODataException
*/
- public EnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException {
- return null;
- }
+ public EnumType getEnumType(final FullQualifiedName enumTypeName) throws ODataException;
/**
* This method should return an {@link TypeDefinition} or <b>null</b> if nothing is found
@@ -43,9 +41,7 @@ public abstract class EdmProvider {
* @return {@link TypeDefinition} for given name
* @throws ODataException
*/
- public TypeDefinition getTypeDefinition(final FullQualifiedName typeDefinitionName) throws ODataException {
- return null;
- }
+ public TypeDefinition getTypeDefinition(final FullQualifiedName typeDefinitionName) throws ODataException;
/**
* This method should return an {@link EntityType} or <b>null</b> if nothing is found
@@ -54,9 +50,7 @@ public abstract class EdmProvider {
* @return {@link EntityType} for the given name
* @throws ODataException
*/
- public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException {
- return null;
- }
+ public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException;
/**
* This method should return a {@link ComplexType} or <b>null</b> if nothing is found.
@@ -65,9 +59,7 @@ public abstract class EdmProvider {
* @return {@link ComplexType} for the given name
* @throws ODataException
*/
- public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException {
- return null;
- }
+ public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException;
/**
* This method should return a list of all {@link Action} for the FullQualifiedname or <b>null</b> if nothing is found
@@ -76,9 +68,7 @@ public abstract class EdmProvider {
* @return List of {@link Action} or null
* @throws ODataException
*/
- public List<Action> getActions(final FullQualifiedName actionName) throws ODataException {
- return null;
- }
+ public List<Action> getActions(final FullQualifiedName actionName) throws ODataException;
/**
* This method should return a list of all {@link Function} for the FullQualifiedname or <b>null</b> if nothing is
@@ -88,9 +78,7 @@ public abstract class EdmProvider {
* @return List of {@link Function} or null
* @throws ODataException
*/
- public List<Function> getFunctions(final FullQualifiedName functionName) throws ODataException {
- return null;
- }
+ public List<Function> getFunctions(final FullQualifiedName functionName) throws ODataException;
/**
* This method should return a {@link Term} for the FullQualifiedName or <b>null</b> if nothing is found.
@@ -98,9 +86,7 @@ public abstract class EdmProvider {
* @return {@link Term} or null
* @throws ODataException
*/
- public Term getTerm(final FullQualifiedName termName) throws ODataException {
- return null;
- }
+ public Term getTerm(final FullQualifiedName termName) throws ODataException;
/**
* This method should return an {@link EntitySet} or <b>null</b> if nothing is found
@@ -111,9 +97,7 @@ public abstract class EdmProvider {
* @throws ODataException
*/
public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName)
- throws ODataException {
- return null;
- }
+ throws ODataException;
/**
* This method should return an {@link Singleton} or <b>null</b> if nothing is found
@@ -124,9 +108,7 @@ public abstract class EdmProvider {
* @throws ODataException
*/
public Singleton getSingleton(final FullQualifiedName entityContainer, final String singletonName)
- throws ODataException {
- return null;
- }
+ throws ODataException;
/**
* This method should return an {@link ActionImport} or <b>null</b> if nothing is found
@@ -137,9 +119,7 @@ public abstract class EdmProvider {
* @throws ODataException
*/
public ActionImport getActionImport(final FullQualifiedName entityContainer, final String actionImportName)
- throws ODataException {
- return null;
- }
+ throws ODataException;
/**
* This method should return a {@link FunctionImport} or <b>null</b> if nothing is found
@@ -150,9 +130,7 @@ public abstract class EdmProvider {
* @throws ODataException
*/
public FunctionImport getFunctionImport(final FullQualifiedName entityContainer, final String functionImportName)
- throws ODataException {
- return null;
- }
+ throws ODataException;
/**
* This method should return an {@link EntityContainerInfo} or <b>null</b> if nothing is found
@@ -161,9 +139,7 @@ public abstract class EdmProvider {
* @return {@link EntityContainerInfo} for the given name
* @throws ODataException
*/
- public EntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName) throws ODataException {
- return null;
- }
+ public EntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName) throws ODataException;
/**
* This method should return a list of all namespaces which have an alias
@@ -171,9 +147,7 @@ public abstract class EdmProvider {
* @return List of alias info
* @throws ODataException
*/
- public List<AliasInfo> getAliasInfos() throws ODataException {
- return null;
- }
+ public List<AliasInfo> getAliasInfos() throws ODataException;
/**
* This method should return a collection of all {@link Schema}
@@ -181,31 +155,23 @@ public abstract class EdmProvider {
* @return List<{@link Schema}>
* @throws ODataException
*/
- public List<Schema> getSchemas() throws ODataException {
- return null;
- }
+ public List<Schema> getSchemas() throws ODataException;
/**
* Returns the entity container of this edm
* @return {@link EntityContainer} of this edm
*/
- public EntityContainer getEntityContainer() throws ODataException {
- return null;
- }
+ public EntityContainer getEntityContainer() throws ODataException;
/**
* @param targetName
* @return {@link Annotations} group for the given Target
*/
- public Annotations getAnnotationsGroup(FullQualifiedName targetName) throws ODataException {
- return null;
- }
+ public Annotations getAnnotationsGroup(FullQualifiedName targetName) throws ODataException;
/**
* @param annotatedName
* @return Annotatble element by target name
*/
- public Annotatable getAnnoatatable(FullQualifiedName annotatedName) throws ODataException {
- return null;
- }
+ public Annotatable getAnnoatatable(FullQualifiedName annotatedName) throws ODataException;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d94edf56/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEntityContainerImplTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEntityContainerImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEntityContainerImplTest.java
index 5eba34f..312d636 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEntityContainerImplTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEntityContainerImplTest.java
@@ -18,6 +18,17 @@
*/
package org.apache.olingo.server.core.edm.provider;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+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.ODataException;
import org.apache.olingo.commons.api.edm.EdmActionImport;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
@@ -26,6 +37,7 @@ import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmFunctionImport;
import org.apache.olingo.commons.api.edm.EdmSingleton;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.AbstractEdmProvider;
import org.apache.olingo.commons.api.edm.provider.ActionImport;
import org.apache.olingo.commons.api.edm.provider.EdmProvider;
import org.apache.olingo.commons.api.edm.provider.EntityContainer;
@@ -38,17 +50,6 @@ import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Before;
import org.junit.Test;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
public class EdmEntityContainerImplTest {
EdmEntityContainer container;
@@ -231,7 +232,7 @@ public class EdmEntityContainerImplTest {
assertNull(container.getEntitySet(null));
}
- private class CustomProvider extends EdmProvider {
+ private class CustomProvider extends AbstractEdmProvider {
@Override
public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName)
throws ODataException {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d94edf56/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImplTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImplTest.java
index 465dca3..9e0b44e 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImplTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImplTest.java
@@ -18,6 +18,15 @@
*/
package org.apache.olingo.server.core.edm.provider;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAction;
@@ -34,6 +43,7 @@ import org.apache.olingo.commons.api.edm.EdmSchema;
import org.apache.olingo.commons.api.edm.EdmSingleton;
import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.AbstractEdmProvider;
import org.apache.olingo.commons.api.edm.provider.Action;
import org.apache.olingo.commons.api.edm.provider.ActionImport;
import org.apache.olingo.commons.api.edm.provider.AliasInfo;
@@ -54,15 +64,6 @@ import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
import org.junit.Before;
import org.junit.Test;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
public class EdmSchemaImplTest {
private EdmSchema schema;
@@ -204,7 +205,7 @@ public class EdmSchemaImplTest {
assertTrue(container == edm.getEntityContainer(null));
}
- private class LocalProvider extends EdmProvider {
+ private class LocalProvider extends AbstractEdmProvider {
private static final String ALIAS = "alias";
private static final String NAMESPACE = "org.namespace";
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d94edf56/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
index 2e2d4a6..d092ae9 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
@@ -38,6 +38,7 @@ import org.apache.olingo.commons.api.edm.EdmComplexType;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.EdmSchema;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.AbstractEdmProvider;
import org.apache.olingo.commons.api.edm.provider.Action;
import org.apache.olingo.commons.api.edm.provider.ActionImport;
import org.apache.olingo.commons.api.edm.provider.AliasInfo;
@@ -262,7 +263,7 @@ public class MetadataDocumentXmlSerializerTest {
+ "</ComplexType>"));
}
- private class LocalProvider extends EdmProvider {
+ private class LocalProvider extends AbstractEdmProvider {
private final static String nameSpace = "namespace";
private final FullQualifiedName nameETAbstract = new FullQualifiedName(nameSpace, "ETAbstract");
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d94edf56/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EdmTechProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EdmTechProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EdmTechProvider.java
index 2a94c03..410a0bc 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EdmTechProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EdmTechProvider.java
@@ -18,14 +18,17 @@
*/
package org.apache.olingo.server.tecsvc.provider;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.server.api.edmx.EdmxReference;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.AbstractEdmProvider;
import org.apache.olingo.commons.api.edm.provider.Action;
import org.apache.olingo.commons.api.edm.provider.ActionImport;
import org.apache.olingo.commons.api.edm.provider.AliasInfo;
import org.apache.olingo.commons.api.edm.provider.ComplexType;
-import org.apache.olingo.commons.api.edm.provider.EdmProvider;
import org.apache.olingo.commons.api.edm.provider.EntityContainer;
import org.apache.olingo.commons.api.edm.provider.EntityContainerInfo;
import org.apache.olingo.commons.api.edm.provider.EntitySet;
@@ -37,12 +40,9 @@ import org.apache.olingo.commons.api.edm.provider.Schema;
import org.apache.olingo.commons.api.edm.provider.Singleton;
import org.apache.olingo.commons.api.edm.provider.Term;
import org.apache.olingo.commons.api.edm.provider.TypeDefinition;
+import org.apache.olingo.server.api.edmx.EdmxReference;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-public class EdmTechProvider extends EdmProvider {
+public class EdmTechProvider extends AbstractEdmProvider {
public static final String nameSpace = "olingo.odata.test1";
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d94edf56/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
index 45728e1..c317d0c 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
@@ -39,7 +39,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.edm.provider.EdmProvider;
+import org.apache.olingo.commons.api.edm.provider.AbstractEdmProvider;
import org.apache.olingo.commons.api.edm.provider.EntitySet;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.format.ODataFormat;
@@ -223,7 +223,7 @@ public class ODataHandlerTest {
public void uriParserExceptionResultsInRightResponseEdmCause() throws Exception {
final OData odata = OData.newInstance();
final ServiceMetadata serviceMetadata = odata.createServiceMetadata(
- new EdmProvider() {
+ new AbstractEdmProvider() {
public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName)
throws ODataException {
throw new ODataException("msg");
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d94edf56/samples/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java
----------------------------------------------------------------------
diff --git a/samples/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java b/samples/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java
index dac970d..8036c8f 100644
--- a/samples/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java
+++ b/samples/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java
@@ -25,8 +25,8 @@ import java.util.List;
import org.apache.olingo.commons.api.ODataException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.AbstractEdmProvider;
import org.apache.olingo.commons.api.edm.provider.ComplexType;
-import org.apache.olingo.commons.api.edm.provider.EdmProvider;
import org.apache.olingo.commons.api.edm.provider.EntityContainer;
import org.apache.olingo.commons.api.edm.provider.EntityContainerInfo;
import org.apache.olingo.commons.api.edm.provider.EntitySet;
@@ -37,7 +37,7 @@ import org.apache.olingo.commons.api.edm.provider.Property;
import org.apache.olingo.commons.api.edm.provider.PropertyRef;
import org.apache.olingo.commons.api.edm.provider.Schema;
-public class CarsEdmProvider extends EdmProvider {
+public class CarsEdmProvider extends AbstractEdmProvider {
// Service Namespace
public static final String NAMESPACE = "olingo.odata.sample";
[2/2] olingo-odata4 git commit: [OLINGO-603] Refactor action
parameter deserialization part 1
Posted by ch...@apache.org.
[OLINGO-603] Refactor action parameter deserialization part 1
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/3e8c5064
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/3e8c5064
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/3e8c5064
Branch: refs/heads/master
Commit: 3e8c50646e12bde57d24bbc783372442df82a40c
Parents: d94edf5
Author: Christian Amend <ch...@apache.org>
Authored: Tue Mar 31 14:42:08 2015 +0200
Committer: Christian Amend <ch...@apache.org>
Committed: Tue Mar 31 14:42:08 2015 +0200
----------------------------------------------------------------------
.../olingo/commons/api/data/Parameter.java | 32 +++++++++++
.../olingo/commons/api/data/ValueType.java | 5 +-
.../commons/core/data/AbstractValuable.java | 11 ++++
.../commons/core/data/AnnotationImpl.java | 11 ----
.../olingo/commons/core/data/ParameterImpl.java | 47 ++++++++++++++++
.../olingo/commons/core/data/PropertyImpl.java | 15 +----
.../core/serialization/AtomSerializer.java | 4 ++
.../api/deserializer/ODataDeserializer.java | 6 +-
.../json/ODataJsonDeserializer.java | 58 +++++++++++---------
...ataJsonDeserializerActionParametersTest.java | 33 +++++------
10 files changed, 150 insertions(+), 72 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3e8c5064/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Parameter.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Parameter.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Parameter.java
new file mode 100644
index 0000000..87058ec
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Parameter.java
@@ -0,0 +1,32 @@
+/*
+ * 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.api.data;
+
+public interface Parameter extends Valuable {
+
+ /**
+ * @return name of the parameter
+ */
+ String getName();
+
+ boolean isEntity();
+
+ Entity asEntity();
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3e8c5064/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ValueType.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ValueType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ValueType.java
index 7b6d942..6dc460f 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ValueType.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ValueType.java
@@ -19,11 +19,12 @@
package org.apache.olingo.commons.api.data;
public enum ValueType {
- PRIMITIVE, GEOSPATIAL, ENUM, COMPLEX,
+ PRIMITIVE, GEOSPATIAL, ENUM, COMPLEX, ENTITY,
COLLECTION_PRIMITIVE(PRIMITIVE),
COLLECTION_GEOSPATIAL(GEOSPATIAL),
COLLECTION_ENUM(ENUM),
- COLLECTION_COMPLEX(COMPLEX);
+ COLLECTION_COMPLEX(COMPLEX),
+ COLLECTION_ENTITY(ENTITY);
private final ValueType baseType;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3e8c5064/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValuable.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValuable.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValuable.java
index 15a7a03..6a5a96f 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValuable.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValuable.java
@@ -37,6 +37,7 @@ public abstract class AbstractValuable implements Valuable, Annotatable {
private ValueType valueType = null;
private Object value = null;
private final List<Annotation> annotations = new ArrayList<Annotation>();
+ private String type;
@Override
public boolean isNull() {
@@ -44,6 +45,16 @@ public abstract class AbstractValuable implements Valuable, Annotatable {
}
@Override
+ public String getType() {
+ return type;
+ }
+
+ @Override
+ public void setType(final String type) {
+ this.type = type;
+ }
+
+ @Override
public boolean isPrimitive() {
return valueType == ValueType.PRIMITIVE;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3e8c5064/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java
index 6a53ef3..4e9953b 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java
@@ -23,7 +23,6 @@ import org.apache.olingo.commons.api.data.Annotation;
public class AnnotationImpl extends AbstractValuable implements Annotation {
private String term;
- private String type;
@Override
public String getTerm() {
@@ -34,14 +33,4 @@ public class AnnotationImpl extends AbstractValuable implements Annotation {
public void setTerm(final String term) {
this.term = term;
}
-
- @Override
- public String getType() {
- return type;
- }
-
- @Override
- public void setType(final String type) {
- this.type = type;
- }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3e8c5064/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ParameterImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ParameterImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ParameterImpl.java
new file mode 100644
index 0000000..fc2a1a9
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ParameterImpl.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.data;
+
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.Parameter;
+import org.apache.olingo.commons.api.data.ValueType;
+
+public class ParameterImpl extends AbstractValuable implements Parameter {
+
+ String name;
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public boolean isEntity() {
+ return getValueType() == ValueType.ENTITY;
+ }
+
+ @Override
+ public Entity asEntity() {
+ return isEntity() ? (Entity) getValue() : null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3e8c5064/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
index 31583e3..7b31da7 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
@@ -24,13 +24,12 @@ import org.apache.olingo.commons.api.data.ValueType;
public class PropertyImpl extends AbstractValuable implements Property {
private String name;
- private String type;
public PropertyImpl() {}
public PropertyImpl(final String type, final String name) {
this.name = name;
- this.type = type;
+ super.setType(type);
}
public PropertyImpl(String type, String name, ValueType valueType, Object value) {
@@ -49,17 +48,7 @@ public class PropertyImpl extends AbstractValuable implements Property {
}
@Override
- public String getType() {
- return type;
- }
-
- @Override
- public void setType(final String type) {
- this.type = type;
- }
-
- @Override
public boolean isNull() {
- return getValue() == null || "Edm.Null".equals(type);
+ return getValue() == null || "Edm.Null".equals(getType());
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3e8c5064/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
index b6d9a74..6bd5fbb 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
@@ -30,6 +30,7 @@ import javax.xml.stream.XMLStreamWriter;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.data.Annotation;
import org.apache.olingo.commons.api.data.ComplexValue;
import org.apache.olingo.commons.api.data.ContextURL;
@@ -113,6 +114,9 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
property(writer, property, false);
}
break;
+ case ENTITY:
+ case COLLECTION_ENTITY:
+ throw new ODataRuntimeException("Entities cannot appear in this payload");
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3e8c5064/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java
index d5f7343..b361844 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java
@@ -19,9 +19,11 @@
package org.apache.olingo.server.api.deserializer;
import java.io.InputStream;
+import java.util.List;
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Parameter;
import org.apache.olingo.commons.api.edm.EdmAction;
import org.apache.olingo.commons.api.edm.EdmEntityType;
@@ -54,8 +56,8 @@ public interface ODataDeserializer {
* Validates: parameter types, no double parameters, correct json types.
* @param stream
* @param edmAction
- * @return deserialized {@link Entity} object
+ * @return deserialized list of {@link Parameter} objects
* @throws DeserializerException
*/
- Entity actionParameters(InputStream stream, EdmAction edmAction) throws DeserializerException;
+ List<Parameter> actionParameters(InputStream stream, EdmAction edmAction) throws DeserializerException;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3e8c5064/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
index ed3454c..74c73c8 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
@@ -31,6 +31,7 @@ import org.apache.olingo.commons.api.data.ComplexValue;
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.EntitySet;
import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Parameter;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.data.ValueType;
import org.apache.olingo.commons.api.domain.ODataLinkType;
@@ -51,6 +52,7 @@ import org.apache.olingo.commons.core.data.ComplexValueImpl;
import org.apache.olingo.commons.core.data.EntityImpl;
import org.apache.olingo.commons.core.data.EntitySetImpl;
import org.apache.olingo.commons.core.data.LinkImpl;
+import org.apache.olingo.commons.core.data.ParameterImpl;
import org.apache.olingo.commons.core.data.PropertyImpl;
import org.apache.olingo.server.api.deserializer.DeserializerException;
import org.apache.olingo.server.api.deserializer.ODataDeserializer;
@@ -58,6 +60,7 @@ import org.apache.olingo.server.api.deserializer.ODataDeserializer;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
@@ -72,10 +75,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
@Override
public EntitySet entityCollection(InputStream stream, EdmEntityType edmEntityType) throws DeserializerException {
try {
- ObjectMapper objectMapper = new ObjectMapper();
- objectMapper.configure(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY, true);
- JsonParser parser = new JsonFactory(objectMapper).createParser(stream);
- final ObjectNode tree = parser.getCodec().readTree(parser);
+ final ObjectNode tree = parseJsonTree(stream);
return consumeEntitySetNode(edmEntityType, tree);
} catch (JsonParseException e) {
@@ -145,10 +145,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
@Override
public Entity entity(InputStream stream, EdmEntityType edmEntityType) throws DeserializerException {
try {
- ObjectMapper objectMapper = new ObjectMapper();
- objectMapper.configure(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY, true);
- JsonParser parser = new JsonFactory(objectMapper).createParser(stream);
- final ObjectNode tree = parser.getCodec().readTree(parser);
+ final ObjectNode tree = parseJsonTree(stream);
return consumeEntityNode(edmEntityType, tree);
@@ -183,16 +180,13 @@ public class ODataJsonDeserializer implements ODataDeserializer {
}
@Override
- public Entity actionParameters(InputStream stream, final EdmAction edmAction) throws DeserializerException {
+ public List<Parameter> actionParameters(InputStream stream, final EdmAction edmAction) throws DeserializerException {
try {
- ObjectMapper objectMapper = new ObjectMapper();
- objectMapper.configure(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY, true);
- JsonParser parser = new JsonFactory(objectMapper).createParser(stream);
- ObjectNode tree = parser.getCodec().readTree(parser);
- EntityImpl entity = new EntityImpl();
- consumeParameters(edmAction, tree, entity);
+ ObjectNode tree = parseJsonTree(stream);
+ ArrayList<Parameter> parameters = new ArrayList<Parameter>();
+ consumeParameters(edmAction, tree, parameters);
assertJsonNodeIsEmpty(tree);
- return entity;
+ return parameters;
} catch (final JsonParseException e) {
throw new DeserializerException("An JsonParseException occurred", e,
@@ -206,22 +200,36 @@ public class ODataJsonDeserializer implements ODataDeserializer {
}
}
- private void consumeParameters(final EdmAction edmAction, ObjectNode node, EntityImpl entity)
+ private ObjectNode parseJsonTree(InputStream stream) throws IOException, JsonParseException, JsonProcessingException {
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.configure(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY, true);
+ JsonParser parser = new JsonFactory(objectMapper).createParser(stream);
+ ObjectNode tree = parser.getCodec().readTree(parser);
+ return tree;
+ }
+
+ private void consumeParameters(final EdmAction edmAction, ObjectNode node, ArrayList<Parameter> parameters)
throws DeserializerException {
for (final String name : edmAction.getParameterNames()) {
- final EdmParameter parameter = edmAction.getParameter(name);
+ final EdmParameter edmParameter = edmAction.getParameter(name);
+ ParameterImpl parameter = new ParameterImpl();
+ parameter.setName(name);
JsonNode jsonNode = node.get(name);
if (jsonNode == null) {
- if (!parameter.isNullable()) {
+ if (!edmParameter.isNullable()) {
// TODO: new message key.
throw new DeserializerException("Non-nullable parameter not present or null",
DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, name);
}
} else {
- entity.addProperty(consumePropertyNode(parameter.getName(), parameter.getType(), parameter.isCollection(),
- parameter.isNullable(), parameter.getMaxLength(), parameter.getPrecision(), parameter.getScale(),
- true, parameter.getMapping(),
- jsonNode));
+ Property consumePropertyNode =
+ consumePropertyNode(edmParameter.getName(), edmParameter.getType(), edmParameter.isCollection(),
+ edmParameter.isNullable(), edmParameter.getMaxLength(), edmParameter.getPrecision(), edmParameter
+ .getScale(),
+ true, edmParameter.getMapping(),
+ jsonNode);
+ parameter.setValue(consumePropertyNode.getValueType(), consumePropertyNode.getValue());
+ parameters.add(parameter);
node.remove(name);
}
}
@@ -302,7 +310,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
EntitySetImpl inlineEntitySet = new EntitySetImpl();
inlineEntitySet.getEntities().addAll(consumeEntitySetArray(edmNavigationProperty.getType(), jsonNode));
link.setInlineEntitySet(inlineEntitySet);
- } else if (!jsonNode.isArray() && (!jsonNode.isValueNode() || jsonNode.isNull())
+ } else if (!jsonNode.isArray() && (!jsonNode.isValueNode() || jsonNode.isNull())
&& !edmNavigationProperty.isCollection()) {
link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
if (!jsonNode.isNull()) {
@@ -623,7 +631,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
/**
* Check if JsonNode is a value node (<code>jsonNode.isValueNode()</code>) and if not throw
* an DeserializerException.
- * @param name name of property which is checked
+ * @param name name of property which is checked
* @param jsonNode node which is checked
* @throws DeserializerException is thrown if json node is not a value node
*/
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3e8c5064/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
index 2e6a181..80668eb 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
@@ -26,8 +26,7 @@ import java.io.ByteArrayInputStream;
import java.math.BigDecimal;
import java.util.List;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.Parameter;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.server.api.OData;
@@ -39,27 +38,23 @@ public class ODataJsonDeserializerActionParametersTest extends AbstractODataDese
@Test
public void empty() throws Exception {
final String input = "{}";
- final Entity entity = deserialize(input, "UART");
- assertNotNull(entity);
- final List<Property> properties = entity.getProperties();
- assertNotNull(properties);
- assertTrue(properties.isEmpty());
+ final List<Parameter> parameters = deserialize(input, "UART");
+ assertNotNull(parameters);
+ assertTrue(parameters.isEmpty());
}
@Test
public void primitive() throws Exception {
final String input = "{\"ParameterDuration\":\"P42DT11H22M33S\",\"ParameterInt16\":42}";
- final Entity entity = deserialize(input, "UARTTwoParam");
- assertNotNull(entity);
- final List<Property> properties = entity.getProperties();
- assertNotNull(properties);
- assertEquals(2, properties.size());
- Property property = properties.get(0);
- assertNotNull(property);
- assertEquals((short) 42, property.getValue());
- property = properties.get(1);
- assertNotNull(property);
- assertEquals(BigDecimal.valueOf(3669753), property.getValue());
+ final List<Parameter> parameters = deserialize(input, "UARTTwoParam");
+ assertNotNull(parameters);
+ assertEquals(2, parameters.size());
+ Parameter parameter = parameters.get(0);
+ assertNotNull(parameter);
+ assertEquals((short) 42, parameter.getValue());
+ parameter = parameters.get(1);
+ assertNotNull(parameter);
+ assertEquals(BigDecimal.valueOf(3669753), parameter.getValue());
}
@Test(expected = DeserializerException.class)
@@ -77,7 +72,7 @@ public class ODataJsonDeserializerActionParametersTest extends AbstractODataDese
deserialize("{\"ParameterInt16\":\"42\"}", "UARTParam");
}
- private Entity deserialize(final String input, final String actionName) throws DeserializerException {
+ private List<Parameter> deserialize(final String input, final String actionName) throws DeserializerException {
return OData.newInstance().createDeserializer(ODataFormat.JSON)
.actionParameters(new ByteArrayInputStream(input.getBytes()),
edm.getUnboundAction(new FullQualifiedName("Namespace1_Alias", actionName)));