ConfigureBeans { @Bean public FilterConfiguration crossDomain(){ return new FilterConfiguration() { @Override public String getName() { return "simple-cors"; } @Override public String[] getMapping() { if(simple) return new String[] {mapping }; else return new String[0]; } @Override public Map<String, String> getInitParameters() { return Optional.ofNullable(initParameters).orElse(new HashMap<>()); } @Override public Either<Class<? extends Filter>, Filter> getFilter() { return Either.left(CrossDomainFilter.class); } }; }  @Bean FilterConfiguration crossDomain(); @Bean FilterConfiguration ebayCrossDomain();  }
@Test public void testCrossDomainOn() { ConfigureBeans config = new ConfigureBeans(true,"/*",new HashMap<>()); assertThat(config.crossDomain().getMapping().length,equalTo(1)); }
@Test public void testCrossDomainOff() { ConfigureBeans config = new ConfigureBeans(false,"/*",new HashMap<>()); assertThat(config.crossDomain().getMapping().length,equalTo(0)); }