olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ram...@apache.org
Subject olingo-odata4 git commit: [OLINGO-1191] Code Improvements
Date Wed, 08 Nov 2017 05:06:11 GMT
Repository: olingo-odata4
Updated Branches:
  refs/heads/master dd992163b -> a3a84c9e8


[OLINGO-1191] Code Improvements


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

Branch: refs/heads/master
Commit: a3a84c9e86c65adcb388dc041c0b54f61604aac2
Parents: dd99216
Author: ramya vasanth <ramya.vasanth@sap.com>
Authored: Wed Nov 8 10:36:03 2017 +0530
Committer: ramya vasanth <ramya.vasanth@sap.com>
Committed: Wed Nov 8 10:36:03 2017 +0530

----------------------------------------------------------------------
 .../metadatavalidator/CsdlTypeValidator.java    | 30 +++++++++++---------
 .../apache/olingo/client/core/EntityTest.java   | 13 ---------
 .../serializer/json/ODataJsonSerializer.java    |  4 +--
 3 files changed, 19 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a3a84c9e/lib/client-core/src/main/java/org/apache/olingo/client/core/metadatavalidator/CsdlTypeValidator.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/metadatavalidator/CsdlTypeValidator.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/metadatavalidator/CsdlTypeValidator.java
index b85dfa6..fbb28d0 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/metadatavalidator/CsdlTypeValidator.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/metadatavalidator/CsdlTypeValidator.java
@@ -125,12 +125,14 @@ public class CsdlTypeValidator {
         baseTypeFQName = validateCsdlEntityTypeWithAlias(baseTypeFQName);
       }
       baseEntityType = csdlEntityTypesMap.get(baseTypeFQName);
-      if (baseEntityType.getKey() != null) {
-        break;
-      } else if (baseEntityType != null && baseEntityType.getBaseType() != null)
{
-        baseTypeFQName = baseEntityType.getBaseTypeFQN();
-      } else if (baseEntityType.getBaseType() == null) {
-        break;
+      if (baseEntityType != null) {
+        if (baseEntityType.getKey() != null) {
+          break;
+        } else if (baseEntityType.getBaseType() != null) {
+          baseTypeFQName = baseEntityType.getBaseTypeFQN();
+        } else if (baseEntityType.getBaseType() == null) {
+          break;
+        }
       }
     }
     return baseEntityType;
@@ -149,16 +151,18 @@ public class CsdlTypeValidator {
         baseTypeFQName = validateCsdlEntityTypeWithAlias(baseTypeFQName);
       }
       baseEntityType = csdlEntityTypesMap.get(baseTypeFQName);
-      if (baseEntityType.getNavigationProperty(navBindingProperty) != null) {
-        break;
-      } else if (baseEntityType != null && baseEntityType.getBaseType() != null)
{
-        baseTypeFQName = baseEntityType.getBaseTypeFQN();
-      } else if (baseEntityType.getBaseType() == null) {
-        break;
+      if (baseEntityType != null) {
+        if (baseEntityType.getNavigationProperty(navBindingProperty) != null) {
+          break;
+        } else if (baseEntityType.getBaseType() != null) {
+          baseTypeFQName = baseEntityType.getBaseTypeFQN();
+        } else if (baseEntityType.getBaseType() == null) {
+          break;
+        }
       }
     }
     if (baseEntityType == null) {
-      throw new RuntimeException("Entity TYpe is null with fully qualified name:" + baseTypeFQName);
+      throw new RuntimeException("Entity Type is null with fully qualified name:" + baseTypeFQName);
     }
     return baseEntityType.getNavigationProperty(navBindingProperty);
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a3a84c9e/lib/client-core/src/test/java/org/apache/olingo/client/core/EntityTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/EntityTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/EntityTest.java
index 52e8e70..d80846b 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/EntityTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/EntityTest.java
@@ -404,17 +404,4 @@ public class EntityTest extends AbstractTest {
     assertTrue(property.isPrimitive());
     assertEquals(property.getValueType(), ValueType.PRIMITIVE);
   }
-  
-  @Test
-  public void testFindTypeInEdmEnabledClient() throws Exception {
-    final Edm edm = client.getReader().readMetadata(getClass().getResourceAsStream("metadata_TripInService.xml"));
-    assertNotNull(edm);
-    final InputStream input = getClass().getResourceAsStream("tripinServEntity.json");
-    EdmEnabledODataClient edmClient = ODataClientFactory.getEdmEnabledClient(SERVICE_URI,
ContentType.APPLICATION_JSON);
-    ClientEntity entity = edmClient.getBinder().getODataEntity(
-        edmClient.getDeserializer(ContentType.APPLICATION_JSON).toEntity(input));
-    assertNotNull(entity);
-    assertEquals(entity.getTypeName().getFullQualifiedNameAsString(), 
-        "Microsoft.OData.SampleService.Models.TripPin.Person");
-  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a3a84c9e/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
index 249e821..9e4d74a 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
@@ -350,8 +350,8 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
    * @return ascii representation of the entity id
    */
   private String getEntityId(Entity entity, EdmEntityType entityType, String name) throws
SerializerException {
-    if(entity.getId() == null) {
-      if(entity == null || entityType == null || entityType.getKeyPredicateNames() == null

+    if(entity != null && entity.getId() == null) {
+      if(entityType == null || entityType.getKeyPredicateNames() == null 
           || name == null) {
         throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID);
       }else{


Mime
View raw message