use of com.yahoo.elide.async.models.TableExport in project elide by yahoo.
the class GraphQLTableExportOperationTest method testProcessQuery.
@Test
public void testProcessQuery() throws IOException {
dataPrep();
TableExport queryObj = new TableExport();
String query = "{\"query\":\"{ tableExport { edges { node { id principalName} } } }\",\"variables\":null}";
String id = "edc4a871-dff2-4054-804e-d80075cf827d";
queryObj.setId(id);
queryObj.setQuery(query);
queryObj.setQueryType(QueryType.GRAPHQL_V1_0);
queryObj.setResultType(ResultType.CSV);
GraphQLTableExportOperation graphQLOperation = new GraphQLTableExportOperation(new JSONExportFormatter(elide), asyncExecutorService, queryObj, requestScope, engine);
TableExportResult queryResultObj = (TableExportResult) graphQLOperation.call();
assertEquals(200, queryResultObj.getHttpStatus());
assertEquals("https://elide.io/export/edc4a871-dff2-4054-804e-d80075cf827d", queryResultObj.getUrl().toString());
assertEquals(1, queryResultObj.getRecordCount());
}
use of com.yahoo.elide.async.models.TableExport in project elide by yahoo.
the class GraphQLTableExportOperationTest method testProcessBadEntityQuery.
@Test
public void testProcessBadEntityQuery() throws IOException {
dataPrep();
TableExport queryObj = new TableExport();
String query = "{\"query\":\"{ tableExportInvalid { edges { node { id principalName} } } }\",\"variables\":null}";
String id = "edc4a871-dff2-4054-804e-d80075cf827d";
queryObj.setId(id);
queryObj.setQuery(query);
queryObj.setQueryType(QueryType.GRAPHQL_V1_0);
queryObj.setResultType(ResultType.CSV);
GraphQLTableExportOperation graphQLOperation = new GraphQLTableExportOperation(new JSONExportFormatter(elide), asyncExecutorService, queryObj, requestScope, engine);
TableExportResult queryResultObj = (TableExportResult) graphQLOperation.call();
assertEquals(200, queryResultObj.getHttpStatus());
assertEquals("Bad Request Body'Unknown entity {tableExportInvalid}.'", queryResultObj.getMessage());
}
use of com.yahoo.elide.async.models.TableExport in project elide by yahoo.
the class GraphQLTableExportOperationTest method dataPrep.
/**
* Prepping and Storing an TableExport entry to be queried later on.
* @throws IOException IOException
*/
private void dataPrep() throws IOException {
TableExport temp = new TableExport();
DataStoreTransaction tx = dataStore.beginTransaction();
RequestScope scope = new RequestScope(null, null, NO_VERSION, null, tx, user, null, Collections.emptyMap(), UUID.randomUUID(), elide.getElideSettings());
tx.save(temp, scope);
tx.commit(scope);
tx.close();
}
use of com.yahoo.elide.async.models.TableExport in project elide by yahoo.
the class JsonAPITableExportOperationTest method testProcessQuery.
@Test
public void testProcessQuery() throws IOException {
dataPrep();
TableExport queryObj = new TableExport();
String query = "/tableExport?sort=principalName&fields=principalName";
String id = "edc4a871-dff2-4054-804e-d80075cf827d";
queryObj.setId(id);
queryObj.setQuery(query);
queryObj.setQueryType(QueryType.JSONAPI_V1_0);
queryObj.setResultType(ResultType.CSV);
JSONAPITableExportOperation jsonAPIOperation = new JSONAPITableExportOperation(new JSONExportFormatter(elide), asyncExecutorService, queryObj, requestScope, engine);
TableExportResult queryResultObj = (TableExportResult) jsonAPIOperation.call();
assertEquals(200, queryResultObj.getHttpStatus());
assertEquals("https://elide.io/export/edc4a871-dff2-4054-804e-d80075cf827d.csv", queryResultObj.getUrl().toString());
assertEquals(1, queryResultObj.getRecordCount());
assertNull(queryResultObj.getMessage());
}
use of com.yahoo.elide.async.models.TableExport in project elide by yahoo.
the class JsonAPITableExportOperationTest method testProcessBadEntityQuery.
@Test
public void testProcessBadEntityQuery() throws IOException {
dataPrep();
TableExport queryObj = new TableExport();
String query = "/tableExportInvalid?sort=principalName&fields=principalName";
String id = "edc4a871-dff2-4054-804e-d80075cf827d";
queryObj.setId(id);
queryObj.setQuery(query);
queryObj.setQueryType(QueryType.JSONAPI_V1_0);
queryObj.setResultType(ResultType.CSV);
JSONAPITableExportOperation jsonAPIOperation = new JSONAPITableExportOperation(new JSONExportFormatter(elide), asyncExecutorService, queryObj, requestScope, engine);
TableExportResult queryResultObj = (TableExportResult) jsonAPIOperation.call();
assertEquals(200, queryResultObj.getHttpStatus());
assertEquals("Unknown collection tableExportInvalid", queryResultObj.getMessage());
}
Aggregations