Search in sources :

Example 16 with MultivaluedMapImpl

use of com.sun.jersey.core.util.MultivaluedMapImpl in project incubator-atlas by apache.

the class EntityJerseyResourceIT method testGetEntityListForNoInstances.

@Test
public void testGetEntityListForNoInstances() throws Exception {
    String typeName = addNewType();
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add("type", typeName);
    JSONObject response = atlasClientV1.callAPIWithQueryParams(AtlasClient.API.GET_ENTITY, queryParams);
    assertNotNull(response);
    Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
    final JSONArray list = response.getJSONArray(AtlasClient.RESULTS);
    Assert.assertEquals(list.length(), 0);
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) JSONArray(org.codehaus.jettison.json.JSONArray) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Test(org.testng.annotations.Test)

Example 17 with MultivaluedMapImpl

use of com.sun.jersey.core.util.MultivaluedMapImpl in project incubator-atlas by apache.

the class EntityLineageJerseyResourceIT method testInputLineageInfo.

@Test
public void testInputLineageInfo() throws Exception {
    String tableId = atlasClientV1.getEntity(HIVE_TABLE_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesMonthlyTable).getId()._getId();
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add(DIRECTION_PARAM, INPUT_DIRECTION);
    queryParams.add(DEPTH_PARAM, "5");
    JSONObject response = atlasClientV1.callAPI(LINEAGE_V2_API, JSONObject.class, queryParams, tableId);
    Assert.assertNotNull(response);
    System.out.println("input lineage info = " + response);
    AtlasLineageInfo inputLineageInfo = gson.fromJson(response.toString(), AtlasLineageInfo.class);
    Map<String, AtlasEntityHeader> entities = inputLineageInfo.getGuidEntityMap();
    Assert.assertNotNull(entities);
    Set<AtlasLineageInfo.LineageRelation> relations = inputLineageInfo.getRelations();
    Assert.assertNotNull(relations);
    Assert.assertEquals(entities.size(), 6);
    Assert.assertEquals(relations.size(), 5);
    Assert.assertEquals(inputLineageInfo.getLineageDirection(), AtlasLineageInfo.LineageDirection.INPUT);
    Assert.assertEquals(inputLineageInfo.getLineageDepth(), 5);
    Assert.assertEquals(inputLineageInfo.getBaseEntityGuid(), tableId);
}
Also used : AtlasLineageInfo(org.apache.atlas.model.lineage.AtlasLineageInfo) JSONObject(org.codehaus.jettison.json.JSONObject) AtlasEntityHeader(org.apache.atlas.model.instance.AtlasEntityHeader) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Test(org.testng.annotations.Test)

Example 18 with MultivaluedMapImpl

use of com.sun.jersey.core.util.MultivaluedMapImpl in project incubator-atlas by apache.

the class MetadataDiscoveryJerseyResourceIT method testSearchUsingDSL.

@Test
public void testSearchUsingDSL() throws Exception {
    //String query = "from dsl_test_type";
    String query = "from " + DATABASE_TYPE + " name=\"" + dbName + "\"";
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add("query", query);
    JSONObject response = atlasClientV1.callAPIWithQueryParams(AtlasClient.API.SEARCH, queryParams);
    Assert.assertNotNull(response);
    Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
    assertEquals(response.getString("query"), query);
    assertEquals(response.getString("queryType"), "dsl");
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Test(org.testng.annotations.Test)

Example 19 with MultivaluedMapImpl

use of com.sun.jersey.core.util.MultivaluedMapImpl in project incubator-atlas by apache.

the class MetadataDiscoveryJerseyResourceIT method testSearchUsingGremlin.

@Test
public void testSearchUsingGremlin() throws Exception {
    String query = "g.V.has('type', '" + BaseResourceIT.HIVE_TABLE_TYPE + "').toList()";
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add("query", query);
    JSONObject response = atlasClientV1.callAPIWithQueryParams(AtlasClient.API.GREMLIN_SEARCH, queryParams);
    assertNotNull(response);
    assertNotNull(response.get(AtlasClient.REQUEST_ID));
    assertEquals(response.getString("query"), query);
    assertEquals(response.getString("queryType"), "gremlin");
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Test(org.testng.annotations.Test)

Example 20 with MultivaluedMapImpl

use of com.sun.jersey.core.util.MultivaluedMapImpl in project incubator-atlas by apache.

the class MetadataDiscoveryJerseyResourceIT method testSearchByDSL.

@Test
public void testSearchByDSL() throws Exception {
    String dslQuery = "from " + DATABASE_TYPE + " name=\"" + dbName + "\"";
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add("query", dslQuery);
    JSONObject response = atlasClientV1.callAPIWithQueryParams(AtlasClient.API.SEARCH_DSL, queryParams);
    Assert.assertNotNull(response);
    Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
    assertEquals(response.getString("query"), dslQuery);
    assertEquals(response.getString("queryType"), "dsl");
    JSONArray results = response.getJSONArray(AtlasClient.RESULTS);
    assertNotNull(results);
    assertEquals(results.length(), 1);
    int numRows = response.getInt(AtlasClient.COUNT);
    assertEquals(numRows, 1);
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) JSONArray(org.codehaus.jettison.json.JSONArray) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Test(org.testng.annotations.Test)

Aggregations

MultivaluedMapImpl (com.sun.jersey.core.util.MultivaluedMapImpl)72 JSONObject (org.codehaus.jettison.json.JSONObject)33 Test (org.junit.Test)32 ClientResponse (com.sun.jersey.api.client.ClientResponse)29 WebResource (com.sun.jersey.api.client.WebResource)21 Test (org.testng.annotations.Test)19 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)12 MockNM (org.apache.hadoop.yarn.server.resourcemanager.MockNM)11 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)9 JSONArray (org.codehaus.jettison.json.JSONArray)9 MockAM (org.apache.hadoop.yarn.server.resourcemanager.MockAM)7 Response (javax.ws.rs.core.Response)6 BridgePort (org.midonet.client.resource.BridgePort)5 Router (org.midonet.client.resource.Router)5 Bridge (org.midonet.client.resource.Bridge)4 Route (org.midonet.client.resource.Route)4 OAuthServiceException (com.sun.identity.oauth.service.OAuthServiceException)3 Client (com.sun.jersey.api.client.Client)3 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)3 ArrayList (java.util.ArrayList)3