use of com.yahoo.elide.async.models.TableExport in project elide by yahoo.
the class CSVExportFormatterTest method testHeaderWithNonmatchingAlias.
@Test
public void testHeaderWithNonmatchingAlias() {
CSVExportFormatter formatter = new CSVExportFormatter(elide, false);
TableExport queryObj = new TableExport();
String query = "{ tableExport { edges { node { query queryType } } } }";
String id = "edc4a871-dff2-4054-804e-d80075cf827d";
queryObj.setId(id);
queryObj.setQuery(query);
queryObj.setQueryType(QueryType.GRAPHQL_V1_0);
queryObj.setResultType(ResultType.CSV);
// Prepare EntityProjection
Set<Attribute> attributes = new LinkedHashSet<>();
attributes.add(Attribute.builder().type(TableExport.class).name("query").alias("foo").build());
attributes.add(Attribute.builder().type(TableExport.class).name("queryType").build());
EntityProjection projection = EntityProjection.builder().type(TableExport.class).attributes(attributes).build();
String output = formatter.preFormat(projection, queryObj);
assertEquals("\"query\",\"queryType\"", output);
}
use of com.yahoo.elide.async.models.TableExport in project elide by yahoo.
the class CSVExportFormatterTest method testHeaderSkip.
@Test
public void testHeaderSkip() {
CSVExportFormatter formatter = new CSVExportFormatter(elide, true);
TableExport queryObj = new TableExport();
String query = "{ tableExport { edges { node { query queryType } } } }";
String id = "edc4a871-dff2-4054-804e-d80075cf827d";
queryObj.setId(id);
queryObj.setQuery(query);
queryObj.setQueryType(QueryType.GRAPHQL_V1_0);
queryObj.setResultType(ResultType.CSV);
// Prepare EntityProjection
Set<Attribute> attributes = new LinkedHashSet<>();
attributes.add(Attribute.builder().type(TableExport.class).name("query").alias("query").build());
attributes.add(Attribute.builder().type(TableExport.class).name("queryType").build());
EntityProjection projection = EntityProjection.builder().type(TableExport.class).attributes(attributes).build();
String output = formatter.preFormat(projection, queryObj);
assertNull(output);
}
use of com.yahoo.elide.async.models.TableExport in project elide by yahoo.
the class TableExportHook method getOperation.
@Override
public Callable<AsyncAPIResult> getOperation(AsyncAPI export, RequestScope requestScope) {
Callable<AsyncAPIResult> operation = null;
TableExport exportObj = (TableExport) export;
ResultType resultType = exportObj.getResultType();
QueryType queryType = exportObj.getQueryType();
com.yahoo.elide.core.RequestScope scope = (com.yahoo.elide.core.RequestScope) requestScope;
TableExportFormatter formatter = supportedFormatters.get(resultType);
if (formatter == null) {
throw new InvalidOperationException("Formatter unavailable for " + resultType);
}
if (queryType.equals(QueryType.GRAPHQL_V1_0)) {
operation = new GraphQLTableExportOperation(formatter, getAsyncExecutorService(), export, scope, engine);
} else if (queryType.equals(QueryType.JSONAPI_V1_0)) {
operation = new JSONAPITableExportOperation(formatter, getAsyncExecutorService(), export, scope, engine);
} else {
throw new InvalidOperationException(queryType + "is not supported");
}
return operation;
}
Aggregations