You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by nb...@apache.org on 2021/08/25 14:08:32 UTC

[atlas] branch master updated: ATLAS-4376: AtlasClientV2 getRelationshipDefByName does not work

This is an automated email from the ASF dual-hosted git repository.

nbonte pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/master by this push:
     new d0d195c  ATLAS-4376: AtlasClientV2 getRelationshipDefByName does not work
d0d195c is described below

commit d0d195cc0204e6c4fb1e87c9d758318eefb849e7
Author: chaitali borole <ch...@cloudera.com>
AuthorDate: Wed Aug 4 17:04:16 2021 +0530

    ATLAS-4376: AtlasClientV2 getRelationshipDefByName does not work
    
    Signed-off-by: Nikhil Bonte <nb...@apache.org>
---
 .../main/java/org/apache/atlas/AtlasClientV2.java  |  6 +++---
 .../java/org/apache/atlas/AtlasClientV2Test.java   | 23 +++++++++++++++++++++-
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/client/client-v2/src/main/java/org/apache/atlas/AtlasClientV2.java b/client/client-v2/src/main/java/org/apache/atlas/AtlasClientV2.java
index eb0e630..85ca78b 100644
--- a/client/client-v2/src/main/java/org/apache/atlas/AtlasClientV2.java
+++ b/client/client-v2/src/main/java/org/apache/atlas/AtlasClientV2.java
@@ -1125,19 +1125,19 @@ public class AtlasClientV2 extends AtlasBaseClient {
         return callAPI(api, typeDefClass, null);
     }
 
-    private <T> String getPathForType(Class<T> typeDefClass) {
+    protected  <T> String getPathForType(Class<T> typeDefClass) {
         if (AtlasEnumDef.class.isAssignableFrom(typeDefClass)) {
             return "enumdef";
         } else if (AtlasEntityDef.class.isAssignableFrom(typeDefClass)) {
             return "entitydef";
         } else if (AtlasClassificationDef.class.isAssignableFrom(typeDefClass)) {
             return "classificationdef";
-        } else if (AtlasStructDef.class.isAssignableFrom(typeDefClass)) {
-            return "structdef";
         } else if (AtlasRelationshipDef.class.isAssignableFrom(typeDefClass)) {
             return "relationshipdef";
         } else if (AtlasBusinessMetadataDef.class.isAssignableFrom(typeDefClass)) {
             return "businessmetadatadef";
+        }else if (AtlasStructDef.class.isAssignableFrom(typeDefClass)) {
+            return "structdef";
         }
 
         // Code should never reach this point
diff --git a/client/client-v2/src/test/java/org/apache/atlas/AtlasClientV2Test.java b/client/client-v2/src/test/java/org/apache/atlas/AtlasClientV2Test.java
index 83a3391..26086be 100644
--- a/client/client-v2/src/test/java/org/apache/atlas/AtlasClientV2Test.java
+++ b/client/client-v2/src/test/java/org/apache/atlas/AtlasClientV2Test.java
@@ -22,6 +22,12 @@ package org.apache.atlas;
 import com.sun.jersey.api.client.ClientResponse;
 import com.sun.jersey.api.client.WebResource;
 import org.apache.atlas.model.instance.AtlasClassification;
+import org.apache.atlas.model.typedef.AtlasRelationshipDef;
+import org.apache.atlas.model.typedef.AtlasClassificationDef;
+import org.apache.atlas.model.typedef.AtlasEnumDef;
+import org.apache.atlas.model.typedef.AtlasBusinessMetadataDef;
+import org.apache.atlas.model.typedef.AtlasStructDef;
+import org.apache.atlas.model.typedef.AtlasEntityDef;
 import org.apache.commons.configuration.Configuration;
 import org.mockito.Matchers;
 import org.mockito.Mock;
@@ -124,6 +130,21 @@ public class AtlasClientV2Test {
 
     }
 
-
+    @Test
+    public void restRequestCheck() {
+        AtlasClientV2 atlasClient = new AtlasClientV2(service, configuration);
+        String pathForRelationshipTypeDef           = atlasClient.getPathForType(AtlasRelationshipDef.class);
+        Assert.assertEquals("relationshipdef", pathForRelationshipTypeDef);
+        String pathForStructTypeDef                 = atlasClient.getPathForType(AtlasStructDef.class);
+        Assert.assertEquals("structdef", pathForStructTypeDef);
+        String pathForBusinessMetadataTypeDef       = atlasClient.getPathForType(AtlasBusinessMetadataDef.class);
+        Assert.assertEquals("businessmetadatadef", pathForBusinessMetadataTypeDef);
+        String pathForEnumTypeDef                   = atlasClient.getPathForType(AtlasEnumDef.class);
+        Assert.assertEquals("enumdef", pathForEnumTypeDef);
+        String pathForClassificationTypeDef         = atlasClient.getPathForType(AtlasClassificationDef.class);
+        Assert.assertEquals("classificationdef", pathForClassificationTypeDef);
+        String pathForEntityTypeDef                 = atlasClient.getPathForType(AtlasEntityDef.class);
+        Assert.assertEquals("entitydef", pathForEntityTypeDef);
+    }
 }