Repository: atlas
Updated Branches:
  refs/heads/master 97e131a58 -> 2068d7ddc


ATLAS-2969: Addressed UniformInterfaceException from earlier commit.


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

Branch: refs/heads/master
Commit: 2068d7ddc08c66307a90a6a925d131fe19ce3756
Parents: 97e131a
Author: Ashutosh Mestry <ames...@hortonworks.com>
Authored: Mon Dec 10 11:08:43 2018 -0800
Committer: Ashutosh Mestry <ames...@hortonworks.com>
Committed: Mon Dec 10 11:36:29 2018 -0800

----------------------------------------------------------------------
 .../atlas/web/resources/AdminResource.java      |   2 ++
 .../web/resources/AdminExportImportTestIT.java  |  23 +++++++++++++++----
 webapp/src/test/resources/empty-1.zip           | Bin 0 -> 22 bytes
 3 files changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/2068d7dd/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
----------------------------------------------------------------------
diff --git 
a/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java 
b/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
index b62c90c..9659a38 100755
--- a/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
@@ -408,10 +408,12 @@ public class AdminResource {
         } catch (AtlasBaseException excp) {
             if 
(excp.getAtlasErrorCode().equals(AtlasErrorCode.IMPORT_ATTEMPTING_EMPTY_ZIP)) {
                 LOG.info(excp.getMessage());
+                return new AtlasImportResult();
             } else {
                 LOG.error("importData(binary) failed", excp);
                 throw excp;
             }
+
         } catch (Exception excp) {
             LOG.error("importData(binary) failed", excp);
 

http://git-wip-us.apache.org/repos/asf/atlas/blob/2068d7dd/webapp/src/test/java/org/apache/atlas/web/resources/AdminExportImportTestIT.java
----------------------------------------------------------------------
diff --git 
a/webapp/src/test/java/org/apache/atlas/web/resources/AdminExportImportTestIT.java
 
b/webapp/src/test/java/org/apache/atlas/web/resources/AdminExportImportTestIT.java
index babf275..d5ff423 100644
--- 
a/webapp/src/test/java/org/apache/atlas/web/resources/AdminExportImportTestIT.java
+++ 
b/webapp/src/test/java/org/apache/atlas/web/resources/AdminExportImportTestIT.java
@@ -21,6 +21,7 @@ package org.apache.atlas.web.resources;
 
 import org.apache.atlas.AtlasServiceException;
 import org.apache.atlas.exception.AtlasBaseException;
+import org.apache.atlas.model.impexp.AtlasExportResult;
 import org.apache.atlas.model.impexp.AtlasServer;
 import org.apache.atlas.model.impexp.AtlasExportRequest;
 import org.apache.atlas.model.impexp.AtlasImportRequest;
@@ -43,6 +44,7 @@ import static org.testng.Assert.assertTrue;
 
 public class AdminExportImportTestIT extends BaseResourceIT {
     private final String FILE_TO_IMPORT = "stocks-base.zip";
+    private final String FILE_TO_IMPORT_EMPTY = "empty-1.zip";
     private final String EXPORT_REQUEST_FILE = "export-incremental";
     private final String SOURCE_SERVER_NAME = "cl1";
 
@@ -62,6 +64,13 @@ public class AdminExportImportTestIT extends BaseResourceIT {
         assertReplicationData("cl1");
     }
 
+    @Test(dependsOnMethods = "isActive")
+    public void importEmptyData() throws AtlasServiceException {
+        AtlasImportResult result = performImportUsing(FILE_TO_IMPORT_EMPTY, 
new AtlasImportRequest());
+        assertNotNull(result);
+        assertEquals(AtlasExportResult.OperationStatus.FAIL.toString(), 
result.getOperationStatus().toString());
+    }
+
     @Test(dependsOnMethods = "importData")
     public void exportData() throws AtlasServiceException, IOException, 
AtlasBaseException {
         final int EXPECTED_CREATION_ORDER_SIZE = 10;
@@ -85,6 +94,14 @@ public class AdminExportImportTestIT extends BaseResourceIT {
 
     private void performImport(String fileToImport, AtlasImportRequest 
request) throws AtlasServiceException {
 
+        AtlasImportResult result = performImportUsing(fileToImport, request);
+        assertNotNull(result);
+        assertEquals(result.getOperationStatus(), 
AtlasImportResult.OperationStatus.SUCCESS);
+        assertNotNull(result.getMetrics());
+        assertEquals(result.getProcessedEntities().size(), 37);
+    }
+
+    private AtlasImportResult performImportUsing(String fileToImport, 
AtlasImportRequest request) throws AtlasServiceException {
         FileInputStream fileInputStream = null;
 
         try {
@@ -93,11 +110,7 @@ public class AdminExportImportTestIT extends BaseResourceIT 
{
             assertFalse(true, "Exception: " + e.getMessage());
         }
 
-        AtlasImportResult result = atlasClientV2.importData(request, 
fileInputStream);
-        assertNotNull(result);
-        assertEquals(result.getOperationStatus(), 
AtlasImportResult.OperationStatus.SUCCESS);
-        assertNotNull(result.getMetrics());
-        assertEquals(result.getProcessedEntities().size(), 37);
+        return atlasClientV2.importData(request, fileInputStream);
     }
 
     private void assertReplicationData(String serverName) throws 
AtlasServiceException {

http://git-wip-us.apache.org/repos/asf/atlas/blob/2068d7dd/webapp/src/test/resources/empty-1.zip
----------------------------------------------------------------------
diff --git a/webapp/src/test/resources/empty-1.zip 
b/webapp/src/test/resources/empty-1.zip
new file mode 100644
index 0000000..15cb0ec
Binary files /dev/null and b/webapp/src/test/resources/empty-1.zip differ

Reply via email to