// Path: src/main/java/com/cisco/cta/taxii/adapter/httpclient/ProxyAuthenticationType.java
// public enum ProxyAuthenticationType {
//     NONE,
//     BASIC,
//     NTLM
// 
// }


import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.NestedRuntimeException;
import org.springframework.core.env.PropertySource;
import org.springframework.mock.env.MockPropertySource;
import java.net.URL;
import java.util.List;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.fail;
import com.cisco.cta.taxii.adapter.httpclient.ProxyAuthenticationType;
import org.junit.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.context.properties.bind.validation.BindValidationException;
import org.springframework.context.ConfigurableApplicationContext;
        try (ConfigurableApplicationContext ctx = context(validProperties())) {
            assertThat(ctx.getBean(TaxiiServiceSettings.class).getFeeds().get(0), is("alpha-feed"));
        }
    }

    private ConfigurableApplicationContext context(PropertySource<?> source) {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
        ctx.register(SettingsConfiguration.class);
        ctx.getEnvironment().getPropertySources().addFirst(source);
        ctx.refresh();
        return ctx;
    }

    private MockPropertySource validProperties() {
        return new MockPropertySource()
            .withProperty("taxii-service.pollEndpoint", "http://taxii")
            .withProperty("taxii-service.username", "smith")
            .withProperty("taxii-service.password", "secret")
            .withProperty("taxii-service.feeds[0]", "alpha-feed")
            .withProperty("taxii-service.statusFile", "taxii-status.xml")
            .withProperty("schedule.cron", "* * * * * *")
            .withProperty("transform.stylesheet", "transform.xsl")
            .withProperty("proxy.url", "http://localhost:8001/")
            .withProperty("proxy.authenticationType", "NONE");
    }

    @Test
    public void typeConversion() throws Exception {
        try (ConfigurableApplicationContext ctx = context(validProperties())) {
            assertThat(ctx.getBean(ProxySettings.class).getUrl(), is(new URL("http://localhost:8001/")));
// Path: src/main/java/com/cisco/cta/taxii/adapter/httpclient/ProxyAuthenticationType.java
// public enum ProxyAuthenticationType {
//     NONE,
//     BASIC,
//     NTLM
// 
// }


// Path: src/test/java/com/cisco/cta/taxii/adapter/settings/SettingsConfigurationTest.java
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.NestedRuntimeException;
import org.springframework.core.env.PropertySource;
import org.springframework.mock.env.MockPropertySource;
import java.net.URL;
import java.util.List;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.fail;
import com.cisco.cta.taxii.adapter.httpclient.ProxyAuthenticationType;
import org.junit.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.context.properties.bind.validation.BindValidationException;
import org.springframework.context.ConfigurableApplicationContext;

        try (ConfigurableApplicationContext ctx = context(validProperties())) {
            assertThat(ctx.getBean(TaxiiServiceSettings.class).getFeeds().get(0), is("alpha-feed"));
        }
    }

    private ConfigurableApplicationContext context(PropertySource<?> source) {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
        ctx.register(SettingsConfiguration.class);
        ctx.getEnvironment().getPropertySources().addFirst(source);
        ctx.refresh();
        return ctx;
    }

    private MockPropertySource validProperties() {
        return new MockPropertySource()
            .withProperty("taxii-service.pollEndpoint", "http://taxii")
            .withProperty("taxii-service.username", "smith")
            .withProperty("taxii-service.password", "secret")
            .withProperty("taxii-service.feeds[0]", "alpha-feed")
            .withProperty("taxii-service.statusFile", "taxii-status.xml")
            .withProperty("schedule.cron", "* * * * * *")
            .withProperty("transform.stylesheet", "transform.xsl")
            .withProperty("proxy.url", "http://localhost:8001/")
            .withProperty("proxy.authenticationType", "NONE");
    }

    @Test
    public void typeConversion() throws Exception {
        try (ConfigurableApplicationContext ctx = context(validProperties())) {
            assertThat(ctx.getBean(ProxySettings.class).getUrl(), is(new URL("http://localhost:8001/")));
            assertThat(ctx.getBean(ProxySettings.class).getAuthenticationType(), is(ProxyAuthenticationType.NONE));