Search in sources :

Example 11 with TableExport

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());
}
Also used : TableExport(com.yahoo.elide.async.models.TableExport) JSONExportFormatter(com.yahoo.elide.async.export.formatter.JSONExportFormatter) TableExportResult(com.yahoo.elide.async.models.TableExportResult) Test(org.junit.jupiter.api.Test)

Example 12 with TableExport

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());
}
Also used : TableExport(com.yahoo.elide.async.models.TableExport) JSONExportFormatter(com.yahoo.elide.async.export.formatter.JSONExportFormatter) TableExportResult(com.yahoo.elide.async.models.TableExportResult) Test(org.junit.jupiter.api.Test)

Example 13 with TableExport

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();
}
Also used : TableExport(com.yahoo.elide.async.models.TableExport) DataStoreTransaction(com.yahoo.elide.core.datastore.DataStoreTransaction) RequestScope(com.yahoo.elide.core.RequestScope)

Example 14 with TableExport

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());
}
Also used : TableExport(com.yahoo.elide.async.models.TableExport) JSONExportFormatter(com.yahoo.elide.async.export.formatter.JSONExportFormatter) TableExportResult(com.yahoo.elide.async.models.TableExportResult) Test(org.junit.jupiter.api.Test)

Example 15 with TableExport

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());
}
Also used : TableExport(com.yahoo.elide.async.models.TableExport) JSONExportFormatter(com.yahoo.elide.async.export.formatter.JSONExportFormatter) TableExportResult(com.yahoo.elide.async.models.TableExportResult) Test(org.junit.jupiter.api.Test)

Aggregations

TableExport (com.yahoo.elide.async.models.TableExport)28 Test (org.junit.jupiter.api.Test)20 TableExportResult (com.yahoo.elide.async.models.TableExportResult)13 EntityProjection (com.yahoo.elide.core.request.EntityProjection)11 JSONExportFormatter (com.yahoo.elide.async.export.formatter.JSONExportFormatter)10 Attribute (com.yahoo.elide.core.request.Attribute)9 LinkedHashSet (java.util.LinkedHashSet)8 PersistentResource (com.yahoo.elide.core.PersistentResource)4 FileExtensionType (com.yahoo.elide.async.models.FileExtensionType)3 RequestScope (com.yahoo.elide.core.RequestScope)3 DataStoreTransaction (com.yahoo.elide.core.datastore.DataStoreTransaction)3 Resource (com.yahoo.elide.jsonapi.models.Resource)3 Observable (io.reactivex.Observable)3 LinkedHashMap (java.util.LinkedHashMap)3 TableExportFormatter (com.yahoo.elide.async.export.formatter.TableExportFormatter)2 AsyncAPIResult (com.yahoo.elide.async.models.AsyncAPIResult)2 IOException (java.io.IOException)2 Iterator (java.util.Iterator)2 Singleton (javax.inject.Singleton)2 Getter (lombok.Getter)2