개요
아파치 Atlas에서 REST API를 JAVA API로 수행할 수 있는 AtlasClientV2를 이용하여 TC를 작성해보고 공유해둔다.
코드
package org.apache.atlas;
import org.apache.atlas.model.discovery.AtlasSearchResult;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.commons.configuration.Configuration;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class AtlasClientV2Test {
public static final String ATLAS_ENDPOINT = "atlas.rest.address";
AtlasClientV2 atlasClientV2;
@BeforeClass
public void before() throws AtlasException {
Configuration configuration = ApplicationProperties.get();
String[] atlasEndPoint = configuration.getStringArray(ATLAS_ENDPOINT);
atlasClientV2 = new AtlasClientV2(atlasEndPoint, new String[]{"admin", "admin"});
}
@Test
public void testIsServerReady() throws AtlasServiceException {
Assert.assertTrue(atlasClientV2.isServerReady());
}
@Test
public void testGetEntityDefByName() throws AtlasServiceException {
AtlasEntityDef info = atlasClientV2.getEntityDefByName("hive_db");
AtlasEntityDef def = atlasClientV2.getEntityDefByGuid(info.getGuid());
}
@Test
public void testGetEntityByGuid() throws AtlasServiceException {
AtlasEntity.AtlasEntityWithExtInfo info = atlasClientV2.getEntityByGuid("53b4f45d-5c84-4984-b818-05607b9bf6d7");
}
@Test
public void testSearch() throws AtlasServiceException {
AtlasSearchResult result = atlasClientV2.basicSearch("hive_db", null, null, true, 10, 0);
}
}