olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject olingo-odata2 git commit: [OLINGO-723] Fixed missing multiplicity for EDMX read
Date Fri, 03 Jul 2015 13:52:19 GMT
Repository: olingo-odata2
Updated Branches:
  refs/heads/master dd0625e3f -> 2b3bce1ea


[OLINGO-723] Fixed missing multiplicity for EDMX read


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/2b3bce1e
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/2b3bce1e
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/2b3bce1e

Branch: refs/heads/master
Commit: 2b3bce1ea5472ae13d395da6fb4e0f6b5c0ec68b
Parents: dd0625e
Author: Michael Bolz <michael.bolz@sap.com>
Authored: Fri Jul 3 13:08:56 2015 +0200
Committer: Michael Bolz <michael.bolz@sap.com>
Committed: Fri Jul 3 15:31:42 2015 +0200

----------------------------------------------------------------------
 .../core/ep/consumer/XmlMetadataConsumer.java   |  2 ++
 .../ep/consumer/XmlMetadataConsumerTest.java    | 26 ++++++++++++++++----
 2 files changed, 23 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/2b3bce1e/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumer.java
b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumer.java
index 686d579..2bcc2e6 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumer.java
@@ -269,6 +269,8 @@ public class XmlMetadataConsumer {
       if (returnTypeString.startsWith("Collection") || returnTypeString.startsWith("collection"))
{
         returnType.setMultiplicity(EdmMultiplicity.MANY);
         returnTypeString = returnTypeString.substring(returnTypeString.indexOf("(") + 1,
returnTypeString.length() - 1);
+      } else {
+        returnType.setMultiplicity(EdmMultiplicity.ONE);
       }
       FullQualifiedName fqName = extractFQName(returnTypeString);
       returnType.setTypeName(fqName);

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/2b3bce1e/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumerTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumerTest.java
b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumerTest.java
index 4077c68..83d234f 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumerTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumerTest.java
@@ -39,6 +39,7 @@ import org.apache.olingo.odata2.api.edm.EdmContentKind;
 import org.apache.olingo.odata2.api.edm.EdmFacets;
 import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
 import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
 import org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute;
 import org.apache.olingo.odata2.api.edm.provider.AnnotationElement;
 import org.apache.olingo.odata2.api.edm.provider.Association;
@@ -704,6 +705,9 @@ public class XmlMetadataConsumerTest extends AbstractXmlConsumerTest {
             + "</FunctionImport>"
             + "<FunctionImport Name=\"NoReturn\" " +
             "EntitySet=\"Rooms\" m:HttpMethod=\"GET\"/>"
+            + "<FunctionImport Name=\"SingleRoomReturnType\" ReturnType=\"RefScenario.Room\"
" +
+            "EntitySet=\"Rooms\" m:HttpMethod=\"GET\">"
+            + "</FunctionImport>"
             + "</EntityContainer>" + "</Schema>" + "</edmx:DataServices>"
+ "</edmx:Edmx>";
     XmlMetadataConsumer parser = new XmlMetadataConsumer();
     XMLStreamReader reader = createStreamReader(xmWithEntityContainer);
@@ -713,7 +717,7 @@ public class XmlMetadataConsumerTest extends AbstractXmlConsumerTest {
         assertEquals("Container1", container.getName());
         assertEquals(Boolean.TRUE, container.isDefaultEntityContainer());
 
-        assertEquals(4, container.getFunctionImports().size());
+        assertEquals(5, container.getFunctionImports().size());
         FunctionImport functionImport1 = container.getFunctionImports().get(0);
 
         assertEquals("EmployeeSearch", functionImport1.getName());
@@ -732,8 +736,8 @@ public class XmlMetadataConsumerTest extends AbstractXmlConsumerTest {
         assertEquals(EdmSimpleTypeKind.Int32, functionImport1.getParameters().get(1).getType());
         assertEquals(Boolean.FALSE, functionImport1.getParameters().get(1).getFacets().isNullable());
 
-        FunctionImport functionImport2 = container.getFunctionImports().get(1);
 
+        FunctionImport functionImport2 = container.getFunctionImports().get(1);
         assertEquals("RoomSearch", functionImport2.getName());
         assertEquals("Rooms", functionImport2.getEntitySet());
         assertEquals(NAMESPACE, functionImport2.getReturnType().getTypeName().getNamespace());
@@ -741,12 +745,15 @@ public class XmlMetadataConsumerTest extends AbstractXmlConsumerTest
{
         assertEquals(EdmMultiplicity.MANY, functionImport2.getReturnType().getMultiplicity());
         assertEquals("GET", functionImport2.getHttpMethod());
         assertEquals(2, functionImport2.getParameters().size());
+        assertEquals(new FullQualifiedName("RefScenario","Room"),
+            functionImport2.getReturnType().getTypeName());
+        assertEquals(EdmMultiplicity.MANY, functionImport2.getReturnType().getMultiplicity());
 
         FunctionImportParameter functionImportParameter = functionImport2.getParameters().get(0);
-		assertEquals("q1", functionImportParameter.getName());
+    		assertEquals("q1", functionImportParameter.getName());
         assertEquals(EdmSimpleTypeKind.String, functionImport2.getParameters().get(0).getType());
         assertEquals(Boolean.TRUE, functionImport2.getParameters().get(0).getFacets().isNullable());
-        assertEquals("In", functionImportParameter.getMode()); 
+        assertEquals("In", functionImportParameter.getMode());
 
         assertEquals("q2", functionImport2.getParameters().get(1).getName());
         assertEquals(EdmSimpleTypeKind.Int32, functionImport2.getParameters().get(1).getType());
@@ -754,7 +761,6 @@ public class XmlMetadataConsumerTest extends AbstractXmlConsumerTest {
         assertEquals(null, functionImport2.getParameters().get(1).getMode()); 
 
         FunctionImport functionImport3 = container.getFunctionImports().get(2);
-
         assertEquals("NoParamters", functionImport3.getName());
         List<FunctionImportParameter> parameters3 = functionImport3.getParameters();
         assertNotNull(parameters3);
@@ -766,6 +772,16 @@ public class XmlMetadataConsumerTest extends AbstractXmlConsumerTest
{
         assertNotNull(parameters4);
         assertEquals(0, parameters4.size());
         assertNull(functionImport4.getReturnType());
+
+        FunctionImport functionImport5 = container.getFunctionImports().get(4);
+        assertEquals("SingleRoomReturnType", functionImport5.getName());
+        List<FunctionImportParameter> parameters5 = functionImport5.getParameters();
+        assertNotNull(parameters5);
+        assertEquals(0, parameters5.size());
+        assertEquals(new FullQualifiedName("RefScenario", "Room"),
+            functionImport5.getReturnType().getTypeName());
+        assertEquals(EdmMultiplicity.ONE, functionImport5.getReturnType().getMultiplicity());
+
       }
     }
   }


Mime
View raw message