Search in sources :

Example 16 with AtlasSearchResult

use of org.apache.atlas.model.discovery.AtlasSearchResult in project atlas by apache.

the class EntityDiscoveryJerseyResourceIT method testSearchUsingDSL.

@Test(enabled = false)
public void testSearchUsingDSL() throws Exception {
    String query = "from " + DATABASE_TYPE_BUILTIN + " " + QUALIFIED_NAME + "=\"" + dbName + "\"";
    AtlasSearchResult searchResult = atlasClientV2.dslSearch(query);
    assertNotNull(searchResult);
    assertEquals(searchResult.getQueryText(), query);
    assertEquals(searchResult.getQueryType(), AtlasQueryType.DSL);
    List<AtlasEntityHeader> entities = searchResult.getEntities();
    assertNotNull(entities);
    assertEquals(entities.size(), 1);
    AtlasEntityHeader dbEntity = entities.get(0);
    assertEquals(dbEntity.getTypeName(), DATABASE_TYPE_BUILTIN);
    assertEquals(dbEntity.getDisplayText(), dbName);
    assertEquals(dbEntity.getStatus(), Status.ACTIVE);
    assertNotNull(dbEntity.getGuid());
    assertNull(searchResult.getAttributes());
    assertNull(searchResult.getFullTextResult());
}
Also used : AtlasEntityHeader(org.apache.atlas.model.instance.AtlasEntityHeader) AtlasSearchResult(org.apache.atlas.model.discovery.AtlasSearchResult) Test(org.testng.annotations.Test)

Example 17 with AtlasSearchResult

use of org.apache.atlas.model.discovery.AtlasSearchResult in project atlas by apache.

the class EntityDiscoveryJerseyResourceIT method testSearchDSLLimits.

@Test(enabled = false)
public void testSearchDSLLimits() throws Exception {
    String dslQuery = "from " + DATABASE_TYPE_BUILTIN + " " + QUALIFIED_NAME + "=\"" + dbName + "\"";
    AtlasSearchResult searchResult = atlasClientV2.dslSearch(dslQuery);
    assertNotNull(searchResult);
    // higher limit, all results returned
    searchResult = atlasClientV2.dslSearchWithParams(dslQuery, 10, 0);
    assertEquals(searchResult.getEntities().size(), 1);
    // default limit and offset -1, all results returned
    searchResult = atlasClientV2.dslSearchWithParams(dslQuery, -1, -1);
    assertEquals(searchResult.getEntities().size(), 1);
    // uses the limit parameter passed
    searchResult = atlasClientV2.dslSearchWithParams(dslQuery, 1, 0);
    assertEquals(searchResult.getEntities().size(), 1);
    // uses the offset parameter passed
    searchResult = atlasClientV2.dslSearchWithParams(dslQuery, 10, 1);
    assertNull(searchResult.getEntities());
    // limit > 0
    searchResult = atlasClientV2.dslSearchWithParams(dslQuery, 0, 10);
    assertNull(searchResult.getEntities());
    // limit > maxlimit
    searchResult = atlasClientV2.dslSearchWithParams(dslQuery, Integer.MAX_VALUE, 10);
    assertNull(searchResult.getEntities());
    // offset >= 0
    searchResult = atlasClientV2.dslSearchWithParams(dslQuery, 10, -2);
    assertEquals(searchResult.getEntities().size(), 1);
}
Also used : AtlasSearchResult(org.apache.atlas.model.discovery.AtlasSearchResult) Test(org.testng.annotations.Test)

Example 18 with AtlasSearchResult

use of org.apache.atlas.model.discovery.AtlasSearchResult in project atlas by apache.

the class EntityDiscoveryJerseyResourceIT method testSearchByDSLForUnknownType.

@Test(expectedExceptions = AtlasServiceException.class)
public void testSearchByDSLForUnknownType() throws Exception {
    String dslQuery = "from blah";
    AtlasSearchResult searchResult = atlasClientV2.dslSearch(dslQuery);
}
Also used : AtlasSearchResult(org.apache.atlas.model.discovery.AtlasSearchResult) Test(org.testng.annotations.Test)

Example 19 with AtlasSearchResult

use of org.apache.atlas.model.discovery.AtlasSearchResult in project atlas by apache.

the class EntityDiscoveryJerseyResourceIT method testSearchFullTextOnDSLFailure.

@Test
public void testSearchFullTextOnDSLFailure() throws Exception {
    String query = "*";
    AtlasSearchResult searchResult = atlasClientV2.fullTextSearch(query);
    assertNotNull(searchResult);
    assertEquals(searchResult.getQueryText(), query);
    assertEquals(searchResult.getQueryType(), AtlasQueryType.FULL_TEXT);
}
Also used : AtlasSearchResult(org.apache.atlas.model.discovery.AtlasSearchResult) Test(org.testng.annotations.Test)

Example 20 with AtlasSearchResult

use of org.apache.atlas.model.discovery.AtlasSearchResult in project atlas by apache.

the class DSLQueriesTest method queryAssert.

private void queryAssert(String query, FieldValueValidator fv) throws AtlasBaseException {
    AtlasSearchResult searchResult = discoveryService.searchUsingDslQuery(query, DEFAULT_LIMIT, 0);
    assertSearchResult(searchResult, fv);
}
Also used : AtlasSearchResult(org.apache.atlas.model.discovery.AtlasSearchResult)

Aggregations

AtlasSearchResult (org.apache.atlas.model.discovery.AtlasSearchResult)30 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)13 Test (org.testng.annotations.Test)13 GraphTransaction (org.apache.atlas.annotation.GraphTransaction)9 QueryParams (org.apache.atlas.query.QueryParams)8 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)7 AtlasFullTextResult (org.apache.atlas.model.discovery.AtlasSearchResult.AtlasFullTextResult)6 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)5 AtlasAttribute (org.apache.atlas.type.AtlasStructType.AtlasAttribute)5 AttributeSearchResult (org.apache.atlas.model.discovery.AtlasSearchResult.AttributeSearchResult)4 ScriptEngine (javax.script.ScriptEngine)3 ScriptException (javax.script.ScriptException)3 AtlasServiceException (org.apache.atlas.AtlasServiceException)3 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)3 MultivaluedMapImpl (com.sun.jersey.core.util.MultivaluedMapImpl)2 IOException (java.io.IOException)2 Consumes (javax.ws.rs.Consumes)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2