Search in sources :

Example 1 with SparkShellRestClient

use of com.thinkbiganalytics.spark.shell.SparkShellRestClient in project kylo by Teradata.

the class SparkFileSchemaParserServiceTest method parseQueryResult.

private Schema parseQueryResult(List<QueryResultColumn> columns, SparkFileSchemaParserService.SparkFileType sparkFileType, TableSchemaType tableSchemaType) throws Exception {
    final SparkShellRestClient restClient = Mockito.mock(SparkShellRestClient.class);
    final SparkShellProcessManager sparkShellProcessManager = Mockito.mock(SparkShellProcessManager.class);
    SparkFileSchemaParserService service = Mockito.mock(SparkFileSchemaParserService.class);
    Whitebox.setInternalState(service, "shellProcessManager", sparkShellProcessManager);
    Whitebox.setInternalState(service, "restClient", restClient);
    Mockito.when(service.doParse(Mockito.any(InputStream.class), Mockito.any(), Mockito.any())).thenCallRealMethod();
    Mockito.when(sparkShellProcessManager.getSystemProcess()).thenReturn(null);
    Mockito.when(restClient.transform(Mockito.any(), Mockito.any())).thenReturn(transformResponse(columns));
    byte[] b = new byte[] {};
    InputStream inputStream = new ByteArrayInputStream(b);
    Schema schema = service.doParse(inputStream, sparkFileType, tableSchemaType);
    return schema;
}
Also used : SparkShellProcessManager(com.thinkbiganalytics.spark.shell.SparkShellProcessManager) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Schema(com.thinkbiganalytics.discovery.schema.Schema) SparkShellRestClient(com.thinkbiganalytics.spark.shell.SparkShellRestClient)

Aggregations

Schema (com.thinkbiganalytics.discovery.schema.Schema)1 SparkShellProcessManager (com.thinkbiganalytics.spark.shell.SparkShellProcessManager)1 SparkShellRestClient (com.thinkbiganalytics.spark.shell.SparkShellRestClient)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1