Search in sources :

Example 11 with DefaultDataSetTemplate

use of com.thinkbiganalytics.kylo.catalog.rest.model.DefaultDataSetTemplate in project kylo by Teradata.

the class DataSourceIT method testListFilesAzureNative.

/**
 * Verify listing files from the Azure Storage connector.
 */
@Test
public void testListFilesAzureNative() {
    Assume.assumeNotNull(azureAccountKey);
    // Create an Azure data source
    final Connector connector = new Connector();
    connector.setId("azure-storage");
    final DefaultDataSetTemplate template = new DefaultDataSetTemplate();
    template.setOptions(Collections.singletonMap("spark.hadoop.fs.azure.account.key.kylogreg1.blob.core.windows.net", azureAccountKey));
    final DataSource request = new DataSource();
    request.setConnector(connector);
    request.setTemplate(template);
    request.setTitle("test list files wasb");
    final DataSource dataSource = given(DataSourceController.BASE).when().body(request).post().then().statusCode(200).extract().as(DataSource.class);
    // Test listing containers
    final List<DataSetFile> containers = given(DataSourceController.BASE).when().pathParam("id", dataSource.getId()).queryParam("path", "wasb://kylogreg1.blob.core.windows.net/").get("{id}/files").then().statusCode(200).extract().as(DataSetFileList.class);
    Assert.assertThat(containers, CoreMatchers.hasItem(new CustomMatcher<DataSetFile>("DataSetFile name=blob123 directory=true") {

        @Override
        public boolean matches(final Object item) {
            return (item instanceof DataSetFile) && Objects.equals("blob123", ((DataSetFile) item).getName()) && Objects.equals("wasb://blob123@kylogreg1.blob.core.windows.net/", ((DataSetFile) item).getPath()) && ((DataSetFile) item).isDirectory();
        }
    }));
    // Test listing files
    final List<DataSetFile> files = given(DataSourceController.BASE).when().pathParam("id", dataSource.getId()).queryParam("path", "wasb://blob123@kylogreg1.blob.core.windows.net/").get("{id}/files").then().statusCode(200).extract().as(DataSetFileList.class);
    Assert.assertThat(files, CoreMatchers.hasItem(new CustomMatcher<DataSetFile>("DataSetFile name=books1.json directory=true") {

        @Override
        public boolean matches(final Object item) {
            return (item instanceof DataSetFile) && Objects.equals("books1.json", ((DataSetFile) item).getName()) && Objects.equals("wasb://blob123@kylogreg1.blob.core.windows.net/books1.json", ((DataSetFile) item).getPath()) && !((DataSetFile) item).isDirectory();
        }
    }));
}
Also used : Connector(com.thinkbiganalytics.kylo.catalog.rest.model.Connector) CustomMatcher(org.hamcrest.CustomMatcher) DataSetFile(com.thinkbiganalytics.kylo.catalog.rest.model.DataSetFile) DefaultDataSetTemplate(com.thinkbiganalytics.kylo.catalog.rest.model.DefaultDataSetTemplate) DataSource(com.thinkbiganalytics.kylo.catalog.rest.model.DataSource) Test(org.junit.Test)

Aggregations

DefaultDataSetTemplate (com.thinkbiganalytics.kylo.catalog.rest.model.DefaultDataSetTemplate)11 DataSource (com.thinkbiganalytics.kylo.catalog.rest.model.DataSource)9 Connector (com.thinkbiganalytics.kylo.catalog.rest.model.Connector)6 Test (org.junit.Test)5 DataSet (com.thinkbiganalytics.kylo.catalog.rest.model.DataSet)3 Nonnull (javax.annotation.Nonnull)3 CustomMatcher (org.hamcrest.CustomMatcher)3 DataSetFile (com.thinkbiganalytics.kylo.catalog.rest.model.DataSetFile)2 Nullable (javax.annotation.Nullable)2 CatalogTableSchema (com.thinkbiganalytics.discovery.model.CatalogTableSchema)1 ThriftConnectionException (com.thinkbiganalytics.hive.exceptions.ThriftConnectionException)1 CatalogException (com.thinkbiganalytics.kylo.catalog.CatalogException)1 PotentialControllerServiceConflictException (com.thinkbiganalytics.kylo.catalog.datasource.PotentialControllerServiceConflictException)1 DataSetWithTableSchema (com.thinkbiganalytics.kylo.catalog.rest.model.DataSetWithTableSchema)1 DataSourceAlreadyExistsException (com.thinkbiganalytics.metadata.api.catalog.DataSourceAlreadyExistsException)1 JdbcDatasource (com.thinkbiganalytics.metadata.rest.model.data.JdbcDatasource)1 RestResponseStatus (com.thinkbiganalytics.rest.model.RestResponseStatus)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 AccessDeniedException (java.nio.file.AccessDeniedException)1