org.apache.atlas.AtlasServiceException Java Examples

The following examples show how to use org.apache.atlas.AtlasServiceException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BulkFetchAndUpdate.java    From atlas with Apache License 2.0 6 votes vote down vote up
private void readEntityUpdates(String basePath, String fileName) throws IOException {
    BufferedReader bufferedReader = null;
    try {
        bufferedReader = getBufferedReader(basePath, fileName);
        String json = bufferedReader.readLine();
        if (StringUtils.isEmpty(json)) {
            displayCrLf("Empty file encountered: %s", fileName);
            return;
        }

        AtlasEntityHeaders response = AtlasType.fromJson(json, AtlasEntityHeaders.class);
        displayCrLf("Found :" + response.getGuidHeaderMap().size());
        String output = atlasClientV2.setClassifications(response);
        displayCrLf(output);
    } catch (AtlasServiceException e) {
        displayCrLf("Error updating. Please see log for details.");
        LOG.error("Error updating. {}", e);
    } finally {
        closeReader(bufferedReader);
    }
}
 
Example #2
Source File: NotificationHookConsumerTest.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
@Test
public void testCommitIsNotCalledEvenWhenMessageProcessingFails() throws AtlasServiceException, AtlasException, AtlasBaseException {
    NotificationHookConsumer notificationHookConsumer =
            new NotificationHookConsumer(notificationInterface, atlasEntityStore, serviceState, instanceConverter, typeRegistry);
    NotificationConsumer consumer = mock(NotificationConsumer.class);
    NotificationHookConsumer.HookConsumer hookConsumer =
            notificationHookConsumer.new HookConsumer(consumer);
    HookNotification.EntityCreateRequest message = new HookNotification.EntityCreateRequest("user",
            new ArrayList<Referenceable>() {
        { add(mock(Referenceable.class)); }
    });
    when(atlasEntityStore.createOrUpdate(any(EntityStream.class), anyBoolean())).thenThrow(new RuntimeException("Simulating exception in processing message"));
    hookConsumer.handleMessage(new AtlasKafkaMessage(message, -1, -1));

    verifyZeroInteractions(consumer);
}
 
Example #3
Source File: TypedefsJerseyResourceIT.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Test
public void testDuplicateCreate() throws Exception {
    AtlasEntityDef type = createClassTypeDef(randomString(),
            Collections.<String>emptySet(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"));
    AtlasTypesDef typesDef = new AtlasTypesDef();
    typesDef.getEntityDefs().add(type);

    AtlasTypesDef created = clientV2.createAtlasTypeDefs(typesDef);
    assertNotNull(created);

    try {
        created = clientV2.createAtlasTypeDefs(typesDef);
        fail("Expected 409");
    } catch (AtlasServiceException e) {
        assertEquals(e.getStatus().getStatusCode(), Response.Status.CONFLICT.getStatusCode());
    }
}
 
Example #4
Source File: QuickStartIT.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Test
public void testProcessIsAdded() throws AtlasServiceException {
    Referenceable loadProcess = atlasClientV1.getEntity(QuickStart.LOAD_PROCESS_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
            QuickStart.LOAD_SALES_DAILY_PROCESS);

    assertEquals(QuickStart.LOAD_SALES_DAILY_PROCESS, loadProcess.get(AtlasClient.NAME));
    assertEquals(QuickStart.LOAD_SALES_DAILY_PROCESS_DESCRIPTION, loadProcess.get("description"));

    List<Id> inputs = (List<Id>)loadProcess.get(QuickStart.INPUTS_ATTRIBUTE);
    List<Id> outputs = (List<Id>)loadProcess.get(QuickStart.OUTPUTS_ATTRIBUTE);
    assertEquals(2, inputs.size());
    String salesFactTableId = getTableId(QuickStart.SALES_FACT_TABLE);
    String timeDimTableId = getTableId(QuickStart.TIME_DIM_TABLE);
    String salesFactDailyMVId = getTableId(QuickStart.SALES_FACT_DAILY_MV_TABLE);

    assertEquals(salesFactTableId, inputs.get(0)._getId());
    assertEquals(timeDimTableId, inputs.get(1)._getId());
    assertEquals(salesFactDailyMVId, outputs.get(0)._getId());
}
 
Example #5
Source File: EntityV2JerseyResourceIT.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Test(dependsOnMethods = "testSubmitEntity")
public void testDeleteExistentTraitNonExistentForEntity() throws Exception {

    final String guid = createHiveTable().getGuid();
    final String traitName = "PII_Trait" + randomString();
    AtlasClassificationDef piiTrait = AtlasTypeUtil
            .createTraitTypeDef(traitName, Collections.<String>emptySet(),
                    AtlasTypeUtil.createRequiredAttrDef("type", "string"));
    AtlasTypesDef typesDef = new AtlasTypesDef();
    typesDef.getClassificationDefs().add(piiTrait);
    createType(typesDef);

    try {
        atlasClientV2.deleteClassification(guid, traitName);
        fail("Deletion should've failed for non-existent trait association");
    } catch (AtlasServiceException ex) {
        Assert.assertNotNull(ex.getStatus());
        assertEquals(ex.getStatus(), ClientResponse.Status.BAD_REQUEST);
    }
}
 
Example #6
Source File: HiveITBase.java    From atlas with Apache License 2.0 6 votes vote down vote up
protected void assertEntityIsNotRegistered(final String typeName, final String property, final String value) throws Exception {
    // wait for sufficient time before checking if entity is not available.
    long waitTime = 10000;
    LOG.debug("Waiting for {} msecs, before asserting entity is not registered.", waitTime);
    Thread.sleep(waitTime);

    try {
        atlasClientV2.getEntityByAttribute(typeName, Collections.singletonMap(property, value));

        fail(String.format("Entity was not supposed to exist for typeName = %s, attributeName = %s, attributeValue = %s", typeName, property, value));
    } catch (AtlasServiceException e) {
        if (e.getStatus() == NOT_FOUND) {
            return;
        }
    }
}
 
Example #7
Source File: TypedefsJerseyResourceIT.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
@Test
public void testDuplicateCreate() throws Exception {
    AtlasEntityDef type = createClassTypeDef(randomString(),
            ImmutableSet.<String>of(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"));
    AtlasTypesDef typesDef = new AtlasTypesDef();
    typesDef.getEntityDefs().add(type);

    AtlasTypesDef created = clientV2.createAtlasTypeDefs(typesDef);
    assertNotNull(created);

    try {
        created = clientV2.createAtlasTypeDefs(typesDef);
        fail("Expected 409");
    } catch (AtlasServiceException e) {
        assertEquals(e.getStatus().getStatusCode(), Response.Status.CONFLICT.getStatusCode());
    }
}
 
Example #8
Source File: BulkFetchAndUpdate.java    From atlas with Apache License 2.0 6 votes vote down vote up
private void createOrUpdateClassification(AtlasClassificationDef classificationDef) {
    String name = classificationDef.getName();
    AtlasTypesDef typesDef = new AtlasTypesDef(null, null, Collections.singletonList(classificationDef), null, null);
    try {
        display("%s -> ", name);
        atlasClientV2.createAtlasTypeDefs(typesDef);
        displayCrLf(" [Done]");
    } catch (AtlasServiceException e) {
        LOG.error("{} skipped!", name, e);
        displayCrLf(" [Skipped]", name);
        updateClassification(classificationDef);
        displayCrLf(" [Done!]");
    } catch (Exception ex) {
        LOG.error("{} skipped!", name, ex);
        displayCrLf(" [Skipped]", name);
    }
}
 
Example #9
Source File: EntityJerseyResourceIT.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
@Test(expectedExceptions = AtlasServiceException.class)
public void testDeleteTraitNonExistent() throws Exception {
    String dbName = "db" + randomString();
    String tableName = "table" + randomString();
    Referenceable hiveDBInstance = createHiveDBInstanceBuiltIn(dbName);
    Id dbId = createInstance(hiveDBInstance);
    Referenceable hiveTableInstance = createHiveTableInstanceBuiltIn(dbName, tableName, dbId);
    Id id = createInstance(hiveTableInstance);

    final String guid = id._getId();
    try {
        Assert.assertNotNull(UUID.fromString(guid));
    } catch (IllegalArgumentException e) {
        Assert.fail("Response is not a guid, " + guid);
    }

    final String traitName = "blah_trait";
    atlasClientV1.deleteTrait(guid, traitName);
    fail("trait=" + traitName + " should be defined in type system before it can be deleted");
}
 
Example #10
Source File: QuickStartV2IT.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Test
public void testProcessIsAdded() throws AtlasServiceException {
    Map<String, String> attributes         = Collections.singletonMap(REFERENCEABLE_ATTRIBUTE_NAME, LOAD_SALES_DAILY_PROCESS + CLUSTER_SUFFIX);
    AtlasEntity         loadProcess        = atlasClientV2.getEntityByAttribute(LOAD_PROCESS_TYPE, attributes).getEntity();
    Map                 loadProcessAttribs = loadProcess.getAttributes();

    assertEquals(LOAD_SALES_DAILY_PROCESS, loadProcessAttribs.get(NAME));
    assertEquals("hive query for daily summary", loadProcessAttribs.get("description"));

    List inputs = (List) loadProcessAttribs.get("inputs");
    List outputs = (List) loadProcessAttribs.get("outputs");

    assertEquals(2, inputs.size());

    String salesFactTableId   = getTableId(SALES_FACT_TABLE);
    String timeDimTableId     = getTableId(TIME_DIM_TABLE);
    String salesFactDailyMVId = getTableId(SALES_FACT_DAILY_MV_TABLE);

    assertEquals(salesFactTableId, ((Map) inputs.get(0)).get("guid"));
    assertEquals(timeDimTableId, ((Map) inputs.get(1)).get("guid"));
    assertEquals(salesFactDailyMVId, ((Map) outputs.get(0)).get("guid"));
}
 
Example #11
Source File: BaseResourceIT.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
protected AtlasEntityHeader modifyEntity(AtlasEntity atlasEntity, boolean update) {
    EntityMutationResponse entity = null;
    try {
        if (!update) {
            entity = atlasClientV2.createEntity(new AtlasEntityWithExtInfo(atlasEntity));
            assertNotNull(entity);
            assertNotNull(entity.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE));
            assertTrue(entity.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE).size() > 0);
            return entity.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE).get(0);
        } else {
            entity = atlasClientV2.updateEntity(new AtlasEntityWithExtInfo(atlasEntity));
            assertNotNull(entity);
            assertNotNull(entity.getEntitiesByOperation(EntityMutations.EntityOperation.UPDATE));
            assertTrue(entity.getEntitiesByOperation(EntityMutations.EntityOperation.UPDATE).size() > 0);
            return entity.getEntitiesByOperation(EntityMutations.EntityOperation.UPDATE).get(0);
        }

    } catch (AtlasServiceException e) {
        LOG.error("Entity {} failed", update ? "update" : "creation", entity);
    }
    return null;
}
 
Example #12
Source File: TypesJerseyResourceIT.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Test
public void testDuplicateSubmit() throws Exception {
    ClassTypeDefinition type = TypesUtil.createClassTypeDef(randomString(), null,
            Collections.<String>emptySet(), TypesUtil.createUniqueRequiredAttrDef(NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING));
    TypesDef typesDef =
            new TypesDef(Collections.<EnumTypeDefinition>emptyList(), Collections.<StructTypeDefinition>emptyList(),
                    Collections.<TraitTypeDefinition>emptyList(), Collections.singletonList(type));
    atlasClientV1.createType(typesDef);

    try {
        atlasClientV1.createType(typesDef);
        fail("Expected 409");
    } catch (AtlasServiceException e) {
        assertEquals(e.getStatus().getStatusCode(), Response.Status.CONFLICT.getStatusCode());
    }
}
 
Example #13
Source File: QuickStartV2IT.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
@Test
public void testProcessIsAdded() throws AtlasServiceException, JSONException {
    Map<String, String> attributes = new HashMap<>();
    attributes.put(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, QuickStartV2.LOAD_SALES_DAILY_PROCESS);
    AtlasEntity loadProcess = atlasClientV2.getEntityByAttribute(QuickStartV2.LOAD_PROCESS_TYPE, attributes).getEntity();

    Map loadProcessAttribs = loadProcess.getAttributes();
    assertEquals(QuickStartV2.LOAD_SALES_DAILY_PROCESS, loadProcessAttribs.get(AtlasClient.NAME));
    assertEquals("hive query for daily summary", loadProcessAttribs.get("description"));

    List inputs = (List) loadProcessAttribs.get("inputs");
    List outputs = (List) loadProcessAttribs.get("outputs");
    assertEquals(2, inputs.size());

    String salesFactTableId = getTableId(QuickStartV2.SALES_FACT_TABLE);
    String timeDimTableId = getTableId(QuickStartV2.TIME_DIM_TABLE);
    String salesFactDailyMVId = getTableId(QuickStartV2.SALES_FACT_DAILY_MV_TABLE);

    assertEquals(salesFactTableId, ((Map) inputs.get(0)).get("guid"));
    assertEquals(timeDimTableId, ((Map) inputs.get(1)).get("guid"));
    assertEquals(salesFactDailyMVId, ((Map) outputs.get(0)).get("guid"));
}
 
Example #14
Source File: QuickStartV2IT.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Test
public void testLineageIsMaintained() throws AtlasServiceException {
    String salesFactTableId      = getTableId(SALES_FACT_TABLE);
    String timeDimTableId        = getTableId(TIME_DIM_TABLE);
    String salesFactDailyMVId    = getTableId(SALES_FACT_DAILY_MV_TABLE);
    String salesFactMonthlyMvId  = getTableId(SALES_FACT_MONTHLY_MV_TABLE);
    String salesDailyProcessId   = getProcessId(LOAD_SALES_DAILY_PROCESS);
    String salesMonthlyProcessId = getProcessId(LOAD_SALES_MONTHLY_PROCESS);

    AtlasLineageInfo               inputLineage = atlasClientV2.getLineageInfo(salesFactDailyMVId, LineageDirection.BOTH, 0);
    List<LineageRelation>          relations    = new ArrayList<>(inputLineage.getRelations());
    Map<String, AtlasEntityHeader> entityMap    = inputLineage.getGuidEntityMap();

    assertEquals(relations.size(), 5);
    assertEquals(entityMap.size(), 6);

    assertTrue(entityMap.containsKey(salesFactTableId));
    assertTrue(entityMap.containsKey(timeDimTableId));
    assertTrue(entityMap.containsKey(salesFactDailyMVId));
    assertTrue(entityMap.containsKey(salesDailyProcessId));
    assertTrue(entityMap.containsKey(salesFactMonthlyMvId));
    assertTrue(entityMap.containsKey(salesMonthlyProcessId));
}
 
Example #15
Source File: EntityJerseyResourceIT.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
@Test
public void testSubmitEntityWithBadDateFormat() throws Exception {
    try {
        String dbName = "db" + randomString();
        String tableName = "table" + randomString();
        Referenceable hiveDBInstance = createHiveDBInstanceBuiltIn(dbName);
        Id dbId = createInstance(hiveDBInstance);
        Referenceable hiveTableInstance = createHiveTableInstanceBuiltIn(dbName, tableName, dbId);
        hiveTableInstance.set("lastAccessTime", "2014-07-11");
        Id tableId = createInstance(hiveTableInstance);
        Assert.fail("Was expecting an  exception here ");
    } catch (AtlasServiceException e) {
        Assert.assertTrue(
                e.getMessage().contains("\"error\":\"Cannot convert value '2014-07-11' to datatype date\""));
    }
}
 
Example #16
Source File: BulkFetchAndUpdate.java    From atlas with Apache License 2.0 6 votes vote down vote up
private String getUniqueAttribute(String typeName) {
    try {
        if (typeNameUniqueAttributeNameMap.containsKey(typeName)) {
            return typeNameUniqueAttributeNameMap.get(typeName);
        }

        AtlasEntityDef entityDef = atlasClientV2.getEntityDefByName(typeName);
        for (AtlasStructDef.AtlasAttributeDef ad : entityDef.getAttributeDefs()) {
            if (ad.getIsUnique()) {
                typeNameUniqueAttributeNameMap.put(typeName, ad.getName());
                return ad.getName();
            }
        }
    } catch (AtlasServiceException e) {
        LOG.error("Error fetching type: {}", typeName, e);
        return null;
    }

    return null;
}
 
Example #17
Source File: MetadataDiscoveryJerseyResourceIT.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = AtlasServiceException.class)
public void testSearchByDSLForUnknownType() throws Exception {
    String dslQuery = "from blah";
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add("query", dslQuery);
    atlasClientV1.callAPIWithQueryParams(AtlasClient.API.SEARCH_DSL, queryParams);
}
 
Example #18
Source File: BulkFetchAndUpdate.java    From atlas with Apache License 2.0 5 votes vote down vote up
private void updateClassification(AtlasClassificationDef classificationDef) {
    String name = classificationDef.getName();
    AtlasTypesDef typesDef = new AtlasTypesDef(null, null, Collections.singletonList(classificationDef), null, null);
    try {
        display("Update: %s -> ", name);
        atlasClientV2.updateAtlasTypeDefs(typesDef);
        displayCrLf(" [Done]");
    } catch (AtlasServiceException e) {
        LOG.error("{} skipped!", name, e);
        displayCrLf(" [Skipped]", name);
    } catch (Exception ex) {
        LOG.error("{} skipped!", name, ex);
        displayCrLf(" [Skipped]", name);
    }
}
 
Example #19
Source File: QuickStartIT.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void testTablesAreAdded() throws AtlasServiceException {
    Referenceable table = getTable(QuickStart.SALES_FACT_TABLE);
    verifySimpleTableAttributes(table);

    verifyDBIsLinkedToTable(table);

    verifyColumnsAreAddedToTable(table);

    verifyTrait(table);
}
 
Example #20
Source File: KafkaBridgeTest.java    From atlas with Apache License 2.0 5 votes vote down vote up
private void returnExistingTopic(String topicName, AtlasClientV2 atlasClientV2, String clusterName)
        throws AtlasServiceException {

    when(atlasClientV2.getEntityByAttribute(KafkaDataTypes.KAFKA_TOPIC.getName(),
            Collections.singletonMap(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
                    getTopicQualifiedName(TEST_TOPIC_NAME,CLUSTER_NAME))))
            .thenReturn((new AtlasEntity.AtlasEntityWithExtInfo(
                    getTopicEntityWithGuid("0dd466a4-3838-4537-8969-6abb8b9e9185"))));

}
 
Example #21
Source File: FalconHookIT.java    From atlas with Apache License 2.0 5 votes vote down vote up
private boolean isDataModelAlreadyRegistered() throws Exception {
    try {
        atlasClient.getType(FalconDataTypes.FALCON_PROCESS.getName());
        LOG.info("Hive data model is already registered!");
        return true;
    } catch(AtlasServiceException ase) {
        if (ase.getStatus() == ClientResponse.Status.NOT_FOUND) {
            return false;
        }
        throw ase;
    }
}
 
Example #22
Source File: QuickStartIT.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void testViewIsAdded() throws AtlasServiceException {

    Referenceable view = atlasClientV1.getEntity(QuickStart.VIEW_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, QuickStart.PRODUCT_DIM_VIEW);

    assertEquals(QuickStart.PRODUCT_DIM_VIEW, view.get(AtlasClient.NAME));

    Id productDimId = getTable(QuickStart.PRODUCT_DIM_TABLE).getId();
    Id inputTableId = ((List<Id>) view.get(QuickStart.INPUT_TABLES_ATTRIBUTE)).get(0);
    assertEquals(productDimId, inputTableId);
}
 
Example #23
Source File: HiveMetaStoreBridgeTest.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
private void returnExistingDatabase(String databaseName, AtlasClient atlasClient, String clusterName)
        throws AtlasServiceException, JSONException {
    when(atlasClient.getEntity(
        HiveDataTypes.HIVE_DB.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
        HiveMetaStoreBridge.getDBQualifiedName(clusterName, databaseName))).thenReturn(
        getEntityReference(HiveDataTypes.HIVE_DB.getName(), "72e06b34-9151-4023-aa9d-b82103a50e76"));
}
 
Example #24
Source File: QuickStartV2IT.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void testViewIsAdded() throws AtlasServiceException {
    Map<String, String> attributes                 = Collections.singletonMap(REFERENCEABLE_ATTRIBUTE_NAME, PRODUCT_DIM_VIEW + CLUSTER_SUFFIX);
    AtlasEntity         view                       = atlasClientV2.getEntityByAttribute(VIEW_TYPE, attributes).getEntity();
    Map<String, Object> viewAttributes             = view.getAttributes();
    Map<String, Object> viewRelationshipAttributes = view.getRelationshipAttributes();

    assertEquals(PRODUCT_DIM_VIEW, viewAttributes.get(NAME));

    String productDimId   = getTable(PRODUCT_DIM_TABLE).getGuid();
    List   inputTables    = (List) viewRelationshipAttributes.get("inputTables");
    Map    inputTablesMap = (Map) inputTables.get(0);

    assertEquals(productDimId, inputTablesMap.get("guid"));
}
 
Example #25
Source File: EntityJerseyResourceIT.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = AtlasServiceException.class)
public void testGetEntityListForBadEntityType() throws Exception {
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add("type", "blah");

    JSONObject response = atlasClientV1.callAPIWithQueryParams(AtlasClient.API.GET_ENTITY, queryParams);
    assertNotNull(response);
    Assert.assertNotNull(response.get(AtlasClient.ERROR));
}
 
Example #26
Source File: EntityV2JerseyResourceIT.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = "testAddTrait")
public void testDeleteTrait() throws Exception {
    final String guid = createHiveTable().getGuid();

    try {
        atlasClientV2.deleteClassification(guid, traitName);
    } catch (AtlasServiceException ex) {
        fail("Deletion should've succeeded");
    }
    assertEntityAudit(guid, EntityAuditEvent.EntityAuditAction.TAG_DELETE);
}
 
Example #27
Source File: QuickStartIT.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@Test
public void testViewIsAdded() throws AtlasServiceException, JSONException {

    Referenceable view = atlasClientV1.getEntity(QuickStart.VIEW_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, QuickStart.PRODUCT_DIM_VIEW);

    assertEquals(QuickStart.PRODUCT_DIM_VIEW, view.get(AtlasClient.NAME));

    Id productDimId = getTable(QuickStart.PRODUCT_DIM_TABLE).getId();
    Id inputTableId = ((List<Id>) view.get(QuickStart.INPUT_TABLES_ATTRIBUTE)).get(0);
    assertEquals(productDimId, inputTableId);
}
 
Example #28
Source File: EntityV2JerseyResourceIT.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = AtlasServiceException.class)
public void testAddTraitWithNoRegistration() throws Exception {
    final String traitName = "PII_Trait" + randomString();
    AtlasTypeUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of());

    AtlasClassification traitInstance = new AtlasClassification(traitName);

    atlasClientV2.addClassifications("random", ImmutableList.of(traitInstance));
}
 
Example #29
Source File: HiveHookIT.java    From atlas with Apache License 2.0 5 votes vote down vote up
private String createTrait(String guid) throws AtlasServiceException {
    //add trait
    //valid type names in v2 must consist of a letter followed by a sequence of letter, number, or _ characters
    String                 traitName = "PII_Trait" + random();
    AtlasClassificationDef piiTrait  =  AtlasTypeUtil.createTraitTypeDef(traitName, Collections.<String>emptySet());

    atlasClientV2.createAtlasTypeDefs(new AtlasTypesDef(Collections.emptyList(), Collections.emptyList(), Collections.singletonList(piiTrait), Collections.emptyList()));
    atlasClientV2.addClassifications(guid, Collections.singletonList(new AtlasClassification(piiTrait.getName())));

    return traitName;
}
 
Example #30
Source File: FalconHookIT.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
private boolean isDataModelAlreadyRegistered() throws Exception {
    try {
        atlasClient.getType(FalconDataTypes.FALCON_PROCESS.getName());
        LOG.info("Hive data model is already registered!");
        return true;
    } catch(AtlasServiceException ase) {
        if (ase.getStatus() == ClientResponse.Status.NOT_FOUND) {
            return false;
        }
        throw ase;
    }
}