package org.apache.mesos.hdfs;

import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.name.Named;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.mesos.hdfs.config.SchedulerConf;
import org.apache.mesos.hdfs.state.ClusterState;
import org.apache.mesos.hdfs.state.State;
import org.apache.mesos.state.ZooKeeperState;

import java.util.Properties;

import static org.mockito.Mockito.mock;

public class TestConfigModule extends AbstractModule {
  private String dataDir;
  private String credentialsPath = "";
  private String backupBucket = "test";
  private String backupPrefix = "testprefix";

  public void setDataDir(String dataDir) {
    this.dataDir = dataDir;
  }

  public void setCredentialsPath(String credentialsPath) {
    this.credentialsPath = credentialsPath;
  }

  @Provides
  Properties providesProperties() {
    return new Properties();
  }

  @Provides
  @Named("ConfigPath")
  String providesConfigPath(Properties props) {
    String sitePath = props.getProperty("mesos.site.path", "etc/hadoop");
    return new Path(props.getProperty("mesos.conf.path", sitePath + "/mesos-site.xml")).toString();
  }

  @Provides
  ClusterState providesClusterState(SchedulerConf schedulerConf) {
    ZooKeeperState zkState = mock(ZooKeeperState.class);
    State state = mock(State.class);
    ClusterState clusterState = ClusterState.getInstance();
    clusterState.init(state);
    return clusterState;
  }

  @Override
  protected void configure() {
  }
}

@@ -1230,280 +1230,317 @@
 s%0A  
-ClusterState providesClusterState(SchedulerConf schedulerConf) %7B%0A    ZooKeeperState zkState = mock(ZooKeeperState.class);%0A    State state = mock(State.class);%0A    ClusterState clusterState = ClusterState.getInstance();%0A    clusterState.init(state);%0A    return clusterState
+SchedulerConf providesSchedulerConfig(Properties props, @Named(%22ConfigPath%22) String configPath) %7B%0A    Configuration conf = new Configuration();%0A    int configServerPort = Integer.valueOf(%0A        props.getProperty(%22mesos.hdfs.config.server.port%22, %228765%22));%0A    return new SchedulerConf(conf, configServerPort)
 ;%0A  

Test correct functionality in config