// Path: graceland-platform/src/main/java/io/graceland/inject/Keys.java
// public final class Keys {
// 
//     protected Keys() {
//         // utility class
//     }
// 
//     // ===================
//     // Guice Injector Keys
//     // ===================
// 
//     // Managed Objects
//     public static final Key<Set<Managed>> ManagedObjects = Key.get(TypeLiterals.ManagedSet, Graceland.class);
//     public static final Key<Set<Class<? extends Managed>>> ManagedObjectClasses = Key.get(TypeLiterals.ManagedClassSet, Graceland.class);
// 
//     // Jersey Components
//     public static final Key<Set<Object>> JerseyComponents = Key.get(TypeLiterals.ObjectSet, Graceland.class);
// 
//     // Health Checks
//     public static final Key<Set<HealthCheck>> HealthChecks = Key.get(TypeLiterals.HealthCheckSet, Graceland.class);
//     public static final Key<Set<Class<? extends HealthCheck>>> HealthCheckClasses = Key.get(TypeLiterals.HealthCheckClassSet, Graceland.class);
// 
//     // Tasks
//     public static final Key<Set<Task>> Tasks = Key.get(TypeLiterals.TaskSet, Graceland.class);
//     public static final Key<Set<Class<? extends Task>>> TaskClasses = Key.get(TypeLiterals.TaskClassSet, Graceland.class);
// 
//     // Bundles
//     public static final Key<Set<Bundle>> Bundles = Key.get(TypeLiterals.BundleSet, Graceland.class);
//     public static final Key<Set<Class<? extends Bundle>>> BundleClasses = Key.get(TypeLiterals.BundleClassSet, Graceland.class);
// 
//     // Commands
//     public static final Key<Set<Command>> Commands = Key.get(TypeLiterals.CommandSet, Graceland.class);
//     public static final Key<Set<Class<? extends Command>>> CommandClasses = Key.get(TypeLiterals.CommandClassSet, Graceland.class);
// 
//     // Initializers
//     public static final Key<Set<Initializer>> Initializers = Key.get(TypeLiterals.InitializerSet, Graceland.class);
//     public static final Key<Set<Class<? extends Initializer>>> InitializerClasses = Key.get(TypeLiterals.InitializerClassSet, Graceland.class);
// 
//     // Configurators
//     public static final Key<Set<Configurator>> Configurators = Key.get(TypeLiterals.ConfiguratorSet, Graceland.class);
//     public static final Key<Set<Class<? extends Configurator>>> ConfiguratorClasses = Key.get(TypeLiterals.ConfiguratorClassSet, Graceland.class);
// 
//     // Filter Specs
//     public static final Key<Set<FilterSpec>> FilterSpecs = Key.get(TypeLiterals.FilterSpecSet, Graceland.class);
// }
// 
// Path: graceland-platform/src/test/java/io/graceland/testing/TestFilter.java
// public class TestFilter implements Filter {
//     @Override
//     public void init(FilterConfig filterConfig) throws ServletException {
//         // do nothing
//     }
// 
//     @Override
//     public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//         // do nothing
//     }
// 
//     @Override
//     public void destroy() {
//         // do nothing
//     }
// }


import org.junit.Test;
import com.google.common.collect.Iterables;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import io.graceland.inject.Keys;
import io.graceland.testing.TestFilter;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;

    @Test
    public void can_add_more_than_one_patterns() {
        final FilterPattern pattern1 = mock(FilterPattern.class);
        final FilterPattern pattern2 = mock(FilterPattern.class);

        AbstractModule abstractModule = new AbstractModule() {
            @Override
            protected void configure() {
                FilterBinder
                        .forClass(binder(), TestFilter.class)
                        .withPriority(filterPriority)
                        .addPattern(pattern1)
                        .addPattern(pattern2)
                        .withName(filterName)
                        .bind();
            }
        };

        verifyInjectedValue(abstractModule, filterPriority, filterName, pattern1, pattern2);
    }

    private void verifyInjectedValue(
            AbstractModule abstractModule,
            int priority,
            String name,
            FilterPattern... patterns) {

        Injector injector = Guice.createInjector(abstractModule);

// Path: graceland-platform/src/main/java/io/graceland/inject/Keys.java
// public final class Keys {
// 
//     protected Keys() {
//         // utility class
//     }
// 
//     // ===================
//     // Guice Injector Keys
//     // ===================
// 
//     // Managed Objects
//     public static final Key<Set<Managed>> ManagedObjects = Key.get(TypeLiterals.ManagedSet, Graceland.class);
//     public static final Key<Set<Class<? extends Managed>>> ManagedObjectClasses = Key.get(TypeLiterals.ManagedClassSet, Graceland.class);
// 
//     // Jersey Components
//     public static final Key<Set<Object>> JerseyComponents = Key.get(TypeLiterals.ObjectSet, Graceland.class);
// 
//     // Health Checks
//     public static final Key<Set<HealthCheck>> HealthChecks = Key.get(TypeLiterals.HealthCheckSet, Graceland.class);
//     public static final Key<Set<Class<? extends HealthCheck>>> HealthCheckClasses = Key.get(TypeLiterals.HealthCheckClassSet, Graceland.class);
// 
//     // Tasks
//     public static final Key<Set<Task>> Tasks = Key.get(TypeLiterals.TaskSet, Graceland.class);
//     public static final Key<Set<Class<? extends Task>>> TaskClasses = Key.get(TypeLiterals.TaskClassSet, Graceland.class);
// 
//     // Bundles
//     public static final Key<Set<Bundle>> Bundles = Key.get(TypeLiterals.BundleSet, Graceland.class);
//     public static final Key<Set<Class<? extends Bundle>>> BundleClasses = Key.get(TypeLiterals.BundleClassSet, Graceland.class);
// 
//     // Commands
//     public static final Key<Set<Command>> Commands = Key.get(TypeLiterals.CommandSet, Graceland.class);
//     public static final Key<Set<Class<? extends Command>>> CommandClasses = Key.get(TypeLiterals.CommandClassSet, Graceland.class);
// 
//     // Initializers
//     public static final Key<Set<Initializer>> Initializers = Key.get(TypeLiterals.InitializerSet, Graceland.class);
//     public static final Key<Set<Class<? extends Initializer>>> InitializerClasses = Key.get(TypeLiterals.InitializerClassSet, Graceland.class);
// 
//     // Configurators
//     public static final Key<Set<Configurator>> Configurators = Key.get(TypeLiterals.ConfiguratorSet, Graceland.class);
//     public static final Key<Set<Class<? extends Configurator>>> ConfiguratorClasses = Key.get(TypeLiterals.ConfiguratorClassSet, Graceland.class);
// 
//     // Filter Specs
//     public static final Key<Set<FilterSpec>> FilterSpecs = Key.get(TypeLiterals.FilterSpecSet, Graceland.class);
// }
// 
// Path: graceland-platform/src/test/java/io/graceland/testing/TestFilter.java
// public class TestFilter implements Filter {
//     @Override
//     public void init(FilterConfig filterConfig) throws ServletException {
//         // do nothing
//     }
// 
//     @Override
//     public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//         // do nothing
//     }
// 
//     @Override
//     public void destroy() {
//         // do nothing
//     }
// }


// Path: graceland-platform/src/test/java/io/graceland/filter/FilterBinderTest.java
import org.junit.Test;
import com.google.common.collect.Iterables;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import io.graceland.inject.Keys;
import io.graceland.testing.TestFilter;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;


    @Test
    public void can_add_more_than_one_patterns() {
        final FilterPattern pattern1 = mock(FilterPattern.class);
        final FilterPattern pattern2 = mock(FilterPattern.class);

        AbstractModule abstractModule = new AbstractModule() {
            @Override
            protected void configure() {
                FilterBinder
                        .forClass(binder(), TestFilter.class)
                        .withPriority(filterPriority)
                        .addPattern(pattern1)
                        .addPattern(pattern2)
                        .withName(filterName)
                        .bind();
            }
        };

        verifyInjectedValue(abstractModule, filterPriority, filterName, pattern1, pattern2);
    }

    private void verifyInjectedValue(
            AbstractModule abstractModule,
            int priority,
            String name,
            FilterPattern... patterns) {

        Injector injector = Guice.createInjector(abstractModule);

        FilterSpec filterSpec = Iterables.getFirst(injector.getInstance(Keys.FilterSpecs), null);