Search in sources :

Example 1 with AtlasImportRequest

use of org.apache.atlas.model.impexp.AtlasImportRequest in project incubator-atlas by apache.

the class AtlasImportRequestTest method serializeAtlasImportRequstFromJsonWithEmptyTransforms.

@Test
public void serializeAtlasImportRequstFromJsonWithEmptyTransforms() {
    String jsonData = "{ \"options\": { \"transforms\": \"{ }\" } }";
    AtlasImportRequest request = AtlasType.fromJson(jsonData, AtlasImportRequest.class);
    assertNotNull(request);
    assertNotNull(request.getOptions());
    assertNotNull(request.getOptions().get(AtlasImportRequest.TRANSFORMS_KEY));
    ImportTransforms tr = ImportTransforms.fromJson(request.getOptions().get(AtlasImportRequest.TRANSFORMS_KEY));
    assertNotNull(tr);
    assertNotNull(tr.getTransforms());
    assertEquals(tr.getTransforms().size(), 0);
}
Also used : AtlasImportRequest(org.apache.atlas.model.impexp.AtlasImportRequest) Test(org.testng.annotations.Test)

Example 2 with AtlasImportRequest

use of org.apache.atlas.model.impexp.AtlasImportRequest in project incubator-atlas by apache.

the class AtlasImportRequestTest method serializeAtlasImportRequstFromJson.

@Test
public void serializeAtlasImportRequstFromJson() {
    String jsonData = "{ \"options\": { \"transforms\": \"{ \\\"hive_db\\\": { \\\"qualifiedName\\\": [ \\\"replace:@cl1:@cl2\\\" ] }, \\\"hive_table\\\": { \\\"qualifiedName\\\": [ \\\"lowercase\\\", \\\"replace:@cl1:@cl2\\\" ] } }\" } } }";
    AtlasImportRequest request = AtlasType.fromJson(jsonData, AtlasImportRequest.class);
    assertNotNull(request);
    assertNotNull(request.getOptions());
    assertNotNull(request.getOptions().get(AtlasImportRequest.TRANSFORMS_KEY));
    ImportTransforms tr = ImportTransforms.fromJson(request.getOptions().get(AtlasImportRequest.TRANSFORMS_KEY));
    assertNotNull(tr);
    assertNotNull(tr.getTransforms());
    assertEquals(tr.getTransforms().size(), 2);
    assertTrue(tr.getTransforms().containsKey("hive_db"));
    assertEquals(tr.getTransforms("hive_db").entrySet().size(), 1);
    assertTrue(tr.getTransforms("hive_db").containsKey("qualifiedName"));
    assertEquals(tr.getTransforms("hive_db").get("qualifiedName").size(), 1);
    assertTrue(tr.getTransforms().containsKey("hive_table"));
    assertEquals(tr.getTransforms("hive_table").entrySet().size(), 1);
    assertTrue(tr.getTransforms("hive_table").containsKey("qualifiedName"));
    assertEquals(tr.getTransforms("hive_table").get("qualifiedName").size(), 2);
}
Also used : AtlasImportRequest(org.apache.atlas.model.impexp.AtlasImportRequest) Test(org.testng.annotations.Test)

Example 3 with AtlasImportRequest

use of org.apache.atlas.model.impexp.AtlasImportRequest in project incubator-atlas by apache.

the class ZipFileResourceTestUtils method runAndVerifyQuickStart_v1_Import.

public static void runAndVerifyQuickStart_v1_Import(ImportService importService, ZipSource zipSource) throws AtlasBaseException, IOException {
    AtlasExportResult exportResult = zipSource.getExportResult();
    List<String> creationOrder = zipSource.getCreationOrder();
    AtlasImportRequest request = getDefaultImportRequest();
    AtlasImportResult result = runImportWithParameters(importService, request, zipSource);
    Assert.assertNotNull(result);
    verifyImportedMetrics(exportResult, result);
    verifyImportedEntities(creationOrder, result.getProcessedEntities());
}
Also used : AtlasExportResult(org.apache.atlas.model.impexp.AtlasExportResult) AtlasImportResult(org.apache.atlas.model.impexp.AtlasImportResult) AtlasImportRequest(org.apache.atlas.model.impexp.AtlasImportRequest)

Example 4 with AtlasImportRequest

use of org.apache.atlas.model.impexp.AtlasImportRequest in project incubator-atlas by apache.

the class AtlasImportRequestTest method serializeAtlasImportRequstFromJsonWith1Transform.

@Test
public void serializeAtlasImportRequstFromJsonWith1Transform() {
    String jsonData = "{ \"options\": { \"transforms\": \"{ \\\"hive_db\\\": { \\\"qualifiedName\\\": [ \\\"replace:@cl1:@cl2\\\" ] } }\" } }";
    AtlasImportRequest request = AtlasType.fromJson(jsonData, AtlasImportRequest.class);
    assertNotNull(request);
    assertNotNull(request.getOptions());
    assertNotNull(request.getOptions().get(AtlasImportRequest.TRANSFORMS_KEY));
    ImportTransforms tr = ImportTransforms.fromJson(request.getOptions().get(AtlasImportRequest.TRANSFORMS_KEY));
    assertNotNull(tr);
    assertNotNull(tr.getTransforms());
    assertEquals(tr.getTransforms().size(), 1);
    assertTrue(tr.getTransforms().containsKey("hive_db"));
    assertEquals(tr.getTransforms("hive_db").entrySet().size(), 1);
    assertTrue(tr.getTransforms("hive_db").containsKey("qualifiedName"));
    assertEquals(tr.getTransforms("hive_db").get("qualifiedName").size(), 1);
}
Also used : AtlasImportRequest(org.apache.atlas.model.impexp.AtlasImportRequest) Test(org.testng.annotations.Test)

Example 5 with AtlasImportRequest

use of org.apache.atlas.model.impexp.AtlasImportRequest in project incubator-atlas by apache.

the class AtlasImportRequestTest method serializeAtlasImportRequstFromJsonWithEmptyOptions.

@Test
public void serializeAtlasImportRequstFromJsonWithEmptyOptions() {
    String jsonData = "{ \"options\": {} }";
    AtlasImportRequest request = AtlasType.fromJson(jsonData, AtlasImportRequest.class);
    assertNotNull(request);
    assertNotNull(request.getOptions());
    assertNull(request.getOptions().get(AtlasImportRequest.TRANSFORMS_KEY));
    ImportTransforms tr = ImportTransforms.fromJson(request.getOptions().get(AtlasImportRequest.TRANSFORMS_KEY));
    assertNull(tr);
}
Also used : AtlasImportRequest(org.apache.atlas.model.impexp.AtlasImportRequest) Test(org.testng.annotations.Test)

Aggregations

AtlasImportRequest (org.apache.atlas.model.impexp.AtlasImportRequest)7 Test (org.testng.annotations.Test)4 AtlasImportResult (org.apache.atlas.model.impexp.AtlasImportResult)3 IOException (java.io.IOException)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)2 ImportService (org.apache.atlas.repository.impexp.ImportService)2 ConfigurationException (org.apache.commons.configuration.ConfigurationException)2 JSONException (org.codehaus.jettison.json.JSONException)2 Consumes (javax.ws.rs.Consumes)1 AtlasExportResult (org.apache.atlas.model.impexp.AtlasExportResult)1 ZipSource (org.apache.atlas.repository.impexp.ZipSource)1