You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2017/09/24 22:09:30 UTC

atlas git commit: ATLAS-2158: ZipFileResourceTestUtils: Improved failure scenario.

Repository: atlas
Updated Branches:
  refs/heads/master 6a64cd9c2 -> 40666d181


ATLAS-2158: ZipFileResourceTestUtils: Improved failure scenario.

Signed-off-by: Madhan Neethiraj <ma...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/40666d18
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/40666d18
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/40666d18

Branch: refs/heads/master
Commit: 40666d181853f752f2cd4e010104962129369a42
Parents: 6a64cd9
Author: ashutoshm <am...@hortonworks.com>
Authored: Thu Sep 21 17:03:56 2017 -0700
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Sun Sep 24 14:45:57 2017 -0700

----------------------------------------------------------------------
 .../impexp/ZipFileResourceTestUtils.java        | 38 +++++++++++---------
 1 file changed, 22 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/40666d18/repository/src/test/java/org/apache/atlas/repository/impexp/ZipFileResourceTestUtils.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/impexp/ZipFileResourceTestUtils.java b/repository/src/test/java/org/apache/atlas/repository/impexp/ZipFileResourceTestUtils.java
index 8abbb9f..cc1d2b3 100644
--- a/repository/src/test/java/org/apache/atlas/repository/impexp/ZipFileResourceTestUtils.java
+++ b/repository/src/test/java/org/apache/atlas/repository/impexp/ZipFileResourceTestUtils.java
@@ -76,24 +76,26 @@ public class ZipFileResourceTestUtils {
         File[] topModelsDirContents = topModelsDir.exists() ? topModelsDir.listFiles() : null;
 
         assertTrue(topModelsDirContents != null, topModelsDir.getAbsolutePath() + ": unable to find/read directory");
-
-        Arrays.sort(topModelsDirContents);
-
-        for (File modelDir : topModelsDirContents) {
-            if (modelDir.exists() && modelDir.isDirectory()) {
-                ret = getFileContents(modelDir, fileName);
-
-                if (ret != null) {
-                    break;
+        if(topModelsDirContents != null) {
+            Arrays.sort(topModelsDirContents);
+            for (File modelDir : topModelsDirContents) {
+                if (modelDir.exists() && modelDir.isDirectory()) {
+                    ret = getFileContents(modelDir, fileName);
+
+                    if (ret != null) {
+                        break;
+                    }
                 }
             }
-        }
 
-        if (ret == null) {
-            ret = getFileContents(topModelsDir, fileName);
-        }
+            if (ret == null) {
+                ret = getFileContents(topModelsDir, fileName);
+            }
 
-        assertTrue(ret != null, fileName + ": unable to find model file");
+            assertTrue(ret != null, fileName + ": unable to find model file");
+        } else {
+            throw new IOException("Unable to retrieve model contents.");
+        }
 
         return ret;
     }
@@ -169,15 +171,19 @@ public class ZipFileResourceTestUtils {
     }
 
     private static void createTypesAsNeeded(AtlasTypesDef typesFromJson, AtlasTypeDefStore typeDefStore, AtlasTypeRegistry typeRegistry) throws AtlasBaseException {
-        AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesFromJson, typeRegistry);
+        if(typesFromJson == null) {
+            return;
+        }
 
-        if (!typesToCreate.isEmpty()) {
+        AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesFromJson, typeRegistry);
+        if (typesToCreate != null && !typesToCreate.isEmpty()) {
             typeDefStore.createTypesDef(typesToCreate);
         }
     }
 
     private static AtlasTypesDef getAtlasTypesDefFromFile(String fileName) throws IOException {
         String sampleTypes = ZipFileResourceTestUtils.getModelJson(fileName);
+        if(sampleTypes == null) return null;
         return AtlasType.fromJson(sampleTypes, AtlasTypesDef.class);
     }