// Path: src/main/java/org/trustedanalytics/servicebroker/hdfs/config/Application.java
// @EnableAutoConfiguration
// @EnableServiceBrokerConfig
// @EnableZookeeperBrokerStore
// @ComponentScan
// public class Application {
// 
//   public Application() {}
// 
//   public static void main(String[] args) {
//     SpringApplication.run(Application.class, args);
//   }
// }
// 
// Path: src/main/java/org/trustedanalytics/servicebroker/hdfs/config/ExternalConfiguration.java
// @Configuration
// public class ExternalConfiguration {
// 
//   @Value("${store.user}")
//   @NotNull
//   @Getter @Setter
//   private String user;
// 
//   @Value("${store.password}")
//   @NotNull
//   @Getter @Setter
//   private String password;
// 
//   @Value("${hdfs.userspace.chroot}")
//   @NotNull
//   @Getter @Setter
//   private String userspaceChroot;
// 
//   @Value("${hdfs.provided.zip}")
//   @NotNull
//   @Getter @Setter
//   private String hdfsProvidedZip;
// 
//   @Value("${hdfs.superuser}")
//   @NotNull
//   @Getter @Setter
//   private String hdfsSuperuser;
// 
//   @Value("${hdfs.keytab}")
//   @NotNull
//   @Getter @Setter
//   private String hdfsSuperuserKeytab;
// 
// }
// 
// Path: src/test/java/org/trustedanalytics/servicebroker/hdfs/integration/config/HdfsLocalConfiguration.java
// @Configuration
// @Profile("integration-test")
// public class HdfsLocalConfiguration {
// 
//   @Autowired
//   private ExternalConfiguration externalConfiguration;
// 
//   @Bean
//   @Qualifier("user")
//   public FileSystem getUserFileSystem() throws InterruptedException, IOException,
//       URISyntaxException {
//     return FileSystemFactory.getFileSystem(externalConfiguration.getUserspaceChroot());
//   }
// 
//   @Bean
//   @Qualifier("superUser")
//   public FileSystem getSuperUserFileSystem() throws InterruptedException, IOException,
//       URISyntaxException {
//     return FileSystemFactory.getFileSystem(externalConfiguration.getUserspaceChroot());
//   }
// 
//   static class FileSystemFactory {
//     private static FileSystem fileSystem;
// 
//     public static FileSystem getFileSystem(String userspace) throws IOException,
//         InterruptedException, URISyntaxException {
//       if (fileSystem == null) {
//         File baseDir = new File("./target/hdfs/" + "testName").getAbsoluteFile();
//         FileUtil.fullyDelete(baseDir);
//         org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration(false);
//         conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, baseDir.getAbsolutePath());
//         MiniDFSCluster.Builder builder = new MiniDFSCluster.Builder(conf);
//         MiniDFSCluster cluster = builder.build();
//         fileSystem = cluster.getFileSystem();
// 
//         tryMkdirOrThrowException(fileSystem, userspace);
//       }
//       return fileSystem;
//     }
// 
//     private static void tryMkdirOrThrowException(FileSystem fs, String path) throws IOException {
//       if (!fs.mkdirs(new Path(path))) {
//         throw new RuntimeException("Failure when try to create test root dir: " + path);
//       }
//     }
//   }
// }


import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.trustedanalytics.servicebroker.test.cloudfoundry.CfModelsFactory.getCreateBindingRequest;
import static org.trustedanalytics.servicebroker.test.cloudfoundry.CfModelsFactory.getCreateInstanceRequest;
import static org.trustedanalytics.servicebroker.test.cloudfoundry.CfModelsFactory.getDeleteBindingRequest;
import static org.trustedanalytics.servicebroker.test.cloudfoundry.CfModelsFactory.getDeleteInstanceRequest;
import static org.trustedanalytics.servicebroker.test.cloudfoundry.CfModelsFactory.getServiceInstance;
import java.io.IOException;
import java.util.UUID;
import org.cloudfoundry.community.servicebroker.model.CreateServiceInstanceBindingRequest;
import org.cloudfoundry.community.servicebroker.model.CreateServiceInstanceRequest;
import org.cloudfoundry.community.servicebroker.model.DeleteServiceInstanceBindingRequest;
import org.cloudfoundry.community.servicebroker.model.DeleteServiceInstanceRequest;
import org.cloudfoundry.community.servicebroker.model.ServiceInstance;
import org.cloudfoundry.community.servicebroker.service.ServiceInstanceBindingService;
import org.cloudfoundry.community.servicebroker.service.ServiceInstanceService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.trustedanalytics.cfbroker.store.zookeeper.service.ZookeeperClient;
import org.trustedanalytics.servicebroker.hdfs.config.Application;
import org.trustedanalytics.servicebroker.hdfs.config.ExternalConfiguration;
import org.trustedanalytics.servicebroker.hdfs.integration.config.HdfsLocalConfiguration;
/**
 * Copyright (c) 2015 Intel Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.trustedanalytics.servicebroker.hdfs.integration;





@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = {Application.class, HdfsLocalConfiguration.class})
@WebAppConfiguration
@IntegrationTest("server.port=0")
@ActiveProfiles("integration-test")
public class CreateDeleteThenGetTest {

  @Autowired
  private ZookeeperClient zkClient;

  @Autowired
// Path: src/main/java/org/trustedanalytics/servicebroker/hdfs/config/Application.java
// @EnableAutoConfiguration
// @EnableServiceBrokerConfig
// @EnableZookeeperBrokerStore
// @ComponentScan
// public class Application {
// 
//   public Application() {}
// 
//   public static void main(String[] args) {
//     SpringApplication.run(Application.class, args);
//   }
// }
// 
// Path: src/main/java/org/trustedanalytics/servicebroker/hdfs/config/ExternalConfiguration.java
// @Configuration
// public class ExternalConfiguration {
// 
//   @Value("${store.user}")
//   @NotNull
//   @Getter @Setter
//   private String user;
// 
//   @Value("${store.password}")
//   @NotNull
//   @Getter @Setter
//   private String password;
// 
//   @Value("${hdfs.userspace.chroot}")
//   @NotNull
//   @Getter @Setter
//   private String userspaceChroot;
// 
//   @Value("${hdfs.provided.zip}")
//   @NotNull
//   @Getter @Setter
//   private String hdfsProvidedZip;
// 
//   @Value("${hdfs.superuser}")
//   @NotNull
//   @Getter @Setter
//   private String hdfsSuperuser;
// 
//   @Value("${hdfs.keytab}")
//   @NotNull
//   @Getter @Setter
//   private String hdfsSuperuserKeytab;
// 
// }
// 
// Path: src/test/java/org/trustedanalytics/servicebroker/hdfs/integration/config/HdfsLocalConfiguration.java
// @Configuration
// @Profile("integration-test")
// public class HdfsLocalConfiguration {
// 
//   @Autowired
//   private ExternalConfiguration externalConfiguration;
// 
//   @Bean
//   @Qualifier("user")
//   public FileSystem getUserFileSystem() throws InterruptedException, IOException,
//       URISyntaxException {
//     return FileSystemFactory.getFileSystem(externalConfiguration.getUserspaceChroot());
//   }
// 
//   @Bean
//   @Qualifier("superUser")
//   public FileSystem getSuperUserFileSystem() throws InterruptedException, IOException,
//       URISyntaxException {
//     return FileSystemFactory.getFileSystem(externalConfiguration.getUserspaceChroot());
//   }
// 
//   static class FileSystemFactory {
//     private static FileSystem fileSystem;
// 
//     public static FileSystem getFileSystem(String userspace) throws IOException,
//         InterruptedException, URISyntaxException {
//       if (fileSystem == null) {
//         File baseDir = new File("./target/hdfs/" + "testName").getAbsoluteFile();
//         FileUtil.fullyDelete(baseDir);
//         org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration(false);
//         conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, baseDir.getAbsolutePath());
//         MiniDFSCluster.Builder builder = new MiniDFSCluster.Builder(conf);
//         MiniDFSCluster cluster = builder.build();
//         fileSystem = cluster.getFileSystem();
// 
//         tryMkdirOrThrowException(fileSystem, userspace);
//       }
//       return fileSystem;
//     }
// 
//     private static void tryMkdirOrThrowException(FileSystem fs, String path) throws IOException {
//       if (!fs.mkdirs(new Path(path))) {
//         throw new RuntimeException("Failure when try to create test root dir: " + path);
//       }
//     }
//   }
// }


// Path: src/test/java/org/trustedanalytics/servicebroker/hdfs/integration/CreateDeleteThenGetTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.trustedanalytics.servicebroker.test.cloudfoundry.CfModelsFactory.getCreateBindingRequest;
import static org.trustedanalytics.servicebroker.test.cloudfoundry.CfModelsFactory.getCreateInstanceRequest;
import static org.trustedanalytics.servicebroker.test.cloudfoundry.CfModelsFactory.getDeleteBindingRequest;
import static org.trustedanalytics.servicebroker.test.cloudfoundry.CfModelsFactory.getDeleteInstanceRequest;
import static org.trustedanalytics.servicebroker.test.cloudfoundry.CfModelsFactory.getServiceInstance;
import java.io.IOException;
import java.util.UUID;
import org.cloudfoundry.community.servicebroker.model.CreateServiceInstanceBindingRequest;
import org.cloudfoundry.community.servicebroker.model.CreateServiceInstanceRequest;
import org.cloudfoundry.community.servicebroker.model.DeleteServiceInstanceBindingRequest;
import org.cloudfoundry.community.servicebroker.model.DeleteServiceInstanceRequest;
import org.cloudfoundry.community.servicebroker.model.ServiceInstance;
import org.cloudfoundry.community.servicebroker.service.ServiceInstanceBindingService;
import org.cloudfoundry.community.servicebroker.service.ServiceInstanceService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.trustedanalytics.cfbroker.store.zookeeper.service.ZookeeperClient;
import org.trustedanalytics.servicebroker.hdfs.config.Application;
import org.trustedanalytics.servicebroker.hdfs.config.ExternalConfiguration;
import org.trustedanalytics.servicebroker.hdfs.integration.config.HdfsLocalConfiguration;

/**
 * Copyright (c) 2015 Intel Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.trustedanalytics.servicebroker.hdfs.integration;





@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = {Application.class, HdfsLocalConfiguration.class})
@WebAppConfiguration
@IntegrationTest("server.port=0")
@ActiveProfiles("integration-test")
public class CreateDeleteThenGetTest {

  @Autowired
  private ZookeeperClient zkClient;

  @Autowired
  private ExternalConfiguration conf;