Search in sources :

Example 21 with TableExport

use of com.yahoo.elide.async.models.TableExport in project elide by yahoo.

the class JsonAPITableExportOperationTest method testProcessQueryWithRelationship.

@Test
public void testProcessQueryWithRelationship() {
    TableExport queryObj = new TableExport();
    String query = "/group?fields[group]=products";
    String id = "edc4a871-dff2-4194-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("Export is not supported for Query that requires traversing Relationships.", queryResultObj.getMessage());
    assertNull(queryResultObj.getRecordCount());
    assertNull(queryResultObj.getUrl());
}
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 22 with TableExport

use of com.yahoo.elide.async.models.TableExport in project elide by yahoo.

the class JsonAPITableExportOperationTest method testProcessBadQuery.

@Test
public void testProcessBadQuery() throws IOException {
    dataPrep();
    TableExport queryObj = new TableExport();
    String query = "tableExport/^IllegalCharacter^";
    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("Illegal character in path at index 12: tableExport/^IllegalCharacter^", 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 23 with TableExport

use of com.yahoo.elide.async.models.TableExport in project elide by yahoo.

the class FileResultStorageEngineTest method storeResultsFile.

private void storeResultsFile(String path, String queryId, Observable<String> storable) {
    FileResultStorageEngine engine = new FileResultStorageEngine(path, false);
    TableExport query = new TableExport();
    query.setId(queryId);
    engine.storeResults(query, storable);
}
Also used : TableExport(com.yahoo.elide.async.models.TableExport)

Example 24 with TableExport

use of com.yahoo.elide.async.models.TableExport in project elide by yahoo.

the class RedisResultStorageEngineTest method storeResults.

private void storeResults(String queryId, Observable<String> storable) {
    TableExport query = new TableExport();
    query.setId(queryId);
    engine.storeResults(query, storable);
}
Also used : TableExport(com.yahoo.elide.async.models.TableExport)

Example 25 with TableExport

use of com.yahoo.elide.async.models.TableExport in project elide by yahoo.

the class CSVExportFormatterTest method testNullProjectionHeader.

@Test
public void testNullProjectionHeader() {
    CSVExportFormatter formatter = new CSVExportFormatter(elide, false);
    TableExport queryObj = new TableExport();
    // Prepare EntityProjection
    EntityProjection projection = null;
    String output = formatter.preFormat(projection, queryObj);
    assertNull(output);
}
Also used : TableExport(com.yahoo.elide.async.models.TableExport) EntityProjection(com.yahoo.elide.core.request.EntityProjection) 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