Commit 2068d7dd by Ashutosh Mestry

ATLAS-2969: Addressed UniformInterfaceException from earlier commit.

parent 97e131a5
...@@ -408,10 +408,12 @@ public class AdminResource { ...@@ -408,10 +408,12 @@ public class AdminResource {
} catch (AtlasBaseException excp) { } catch (AtlasBaseException excp) {
if (excp.getAtlasErrorCode().equals(AtlasErrorCode.IMPORT_ATTEMPTING_EMPTY_ZIP)) { if (excp.getAtlasErrorCode().equals(AtlasErrorCode.IMPORT_ATTEMPTING_EMPTY_ZIP)) {
LOG.info(excp.getMessage()); LOG.info(excp.getMessage());
return new AtlasImportResult();
} else { } else {
LOG.error("importData(binary) failed", excp); LOG.error("importData(binary) failed", excp);
throw excp; throw excp;
} }
} catch (Exception excp) { } catch (Exception excp) {
LOG.error("importData(binary) failed", excp); LOG.error("importData(binary) failed", excp);
......
...@@ -21,6 +21,7 @@ package org.apache.atlas.web.resources; ...@@ -21,6 +21,7 @@ package org.apache.atlas.web.resources;
import org.apache.atlas.AtlasServiceException; import org.apache.atlas.AtlasServiceException;
import org.apache.atlas.exception.AtlasBaseException; 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.AtlasServer;
import org.apache.atlas.model.impexp.AtlasExportRequest; import org.apache.atlas.model.impexp.AtlasExportRequest;
import org.apache.atlas.model.impexp.AtlasImportRequest; import org.apache.atlas.model.impexp.AtlasImportRequest;
...@@ -43,6 +44,7 @@ import static org.testng.Assert.assertTrue; ...@@ -43,6 +44,7 @@ import static org.testng.Assert.assertTrue;
public class AdminExportImportTestIT extends BaseResourceIT { public class AdminExportImportTestIT extends BaseResourceIT {
private final String FILE_TO_IMPORT = "stocks-base.zip"; 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 EXPORT_REQUEST_FILE = "export-incremental";
private final String SOURCE_SERVER_NAME = "cl1"; private final String SOURCE_SERVER_NAME = "cl1";
...@@ -62,6 +64,13 @@ public class AdminExportImportTestIT extends BaseResourceIT { ...@@ -62,6 +64,13 @@ public class AdminExportImportTestIT extends BaseResourceIT {
assertReplicationData("cl1"); 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") @Test(dependsOnMethods = "importData")
public void exportData() throws AtlasServiceException, IOException, AtlasBaseException { public void exportData() throws AtlasServiceException, IOException, AtlasBaseException {
final int EXPECTED_CREATION_ORDER_SIZE = 10; final int EXPECTED_CREATION_ORDER_SIZE = 10;
...@@ -85,6 +94,14 @@ public class AdminExportImportTestIT extends BaseResourceIT { ...@@ -85,6 +94,14 @@ public class AdminExportImportTestIT extends BaseResourceIT {
private void performImport(String fileToImport, AtlasImportRequest request) throws AtlasServiceException { 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; FileInputStream fileInputStream = null;
try { try {
...@@ -93,11 +110,7 @@ public class AdminExportImportTestIT extends BaseResourceIT { ...@@ -93,11 +110,7 @@ public class AdminExportImportTestIT extends BaseResourceIT {
assertFalse(true, "Exception: " + e.getMessage()); assertFalse(true, "Exception: " + e.getMessage());
} }
AtlasImportResult result = atlasClientV2.importData(request, fileInputStream); return atlasClientV2.importData(request, fileInputStream);
assertNotNull(result);
assertEquals(result.getOperationStatus(), AtlasImportResult.OperationStatus.SUCCESS);
assertNotNull(result.getMetrics());
assertEquals(result.getProcessedEntities().size(), 37);
} }
private void assertReplicationData(String serverName) throws AtlasServiceException { private void assertReplicationData(String serverName) throws AtlasServiceException {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment