Search in sources :

Example 11 with TableExportResult

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

the class GraphQLTableExportOperationTest method testProcessBadQuery.

@Test
public void testProcessBadQuery() 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("Bad Request Body'Can't parse query: { tableExport { edges { node { id principalName}  } }'", 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 12 with TableExportResult

use of com.yahoo.elide.async.models.TableExportResult 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 13 with TableExportResult

use of com.yahoo.elide.async.models.TableExportResult 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)

Aggregations

TableExport (com.yahoo.elide.async.models.TableExport)13 TableExportResult (com.yahoo.elide.async.models.TableExportResult)13 JSONExportFormatter (com.yahoo.elide.async.export.formatter.JSONExportFormatter)10 Test (org.junit.jupiter.api.Test)10 FileExtensionType (com.yahoo.elide.async.models.FileExtensionType)3 Observable (io.reactivex.Observable)3 Getter (lombok.Getter)3 Slf4j (lombok.extern.slf4j.Slf4j)3 IOException (java.io.IOException)2 Iterator (java.util.Iterator)2 Singleton (javax.inject.Singleton)2 Setter (lombok.Setter)2 Elide (com.yahoo.elide.Elide)1 TableExportFormatter (com.yahoo.elide.async.export.formatter.TableExportFormatter)1 SingleRootProjectionValidator (com.yahoo.elide.async.export.validator.SingleRootProjectionValidator)1 Validator (com.yahoo.elide.async.export.validator.Validator)1 AsyncAPI (com.yahoo.elide.async.models.AsyncAPI)1 AsyncAPIResult (com.yahoo.elide.async.models.AsyncAPIResult)1 AsyncExecutorService (com.yahoo.elide.async.service.AsyncExecutorService)1 ResultStorageEngine (com.yahoo.elide.async.service.storageengine.ResultStorageEngine)1