MicroserverConfigurer implements Configurer { public Config buildConfig(Class class1) { Microserver microserver = (Microserver) class1.getAnnotation(Microserver.class); if (microserver == null){ microserver = Microserver.Instance.class.getAnnotation(Microserver.class); } String[] basePackages=microserver.basePackages(); if(basePackages.length==0){ String[] basePackagesFromClass ={class1.getPackage().getName()}; basePackages = basePackagesFromClass; } List<Class> classes = buildClasses(class1, microserver); Map<String, String> properties = buildProperties(microserver); return Config.instance().withBasePackages(basePackages).withEntityScan(microserver.entityScan()).withClasses(cyclops.data.HashSet.fromIterable(classes)) .withPropertiesName(microserver.propertiesName()).withInstancePropertiesName(microserver.instancePropertiesName()) .withServiceTypePropertiesName(microserver.serviceTypePropertiesName()) .withAllowCircularReferences(microserver.allowCircularDependencies()).withProperties(HashMap.fromMap(properties)).set(); }  Config buildConfig(Class class1);  }
@Test public void properties() { assertThat(configurer.buildConfig(MicroserverConfigurerTest.class).getProperties().stream().map(Tuple2::_1).toSet(), hasItem("hello")); assertThat(configurer.buildConfig(MicroserverConfigurerTest.class).getProperties().stream().map(Tuple2::_2).toSet(), hasItem("world")); }
@Test public void propertiesName() { assertThat(configurer.buildConfig(MicroserverConfigurerTest.class).getPropertiesName(), equalTo("test!")); }
@Test public void instancPpropertiesName() { assertThat(configurer.buildConfig(MicroserverConfigurerTest.class).getInstancePropertiesName(), equalTo("test2!")); }
@Test public void serviceTypePropertiesName() { assertThat(configurer.buildConfig(MicroserverConfigurerTest.class).getServiceTypePropertiesName(), equalTo("servicetType!")); }
@Test public void entityScan() { Config config = configurer.buildConfig(MicroserverConfigurerTest.class); assertThat(config.getDataSources().getOrElse(config.getDefaultDataSourceName(), Arrays.asList()), hasItem("packages")); }
@Test public void springClasses() { Config config = configurer.buildConfig(MicroserverConfigurerTest.class); System.out.println(config.getClasses()); assertThat(config.getClasses(), hasItem(Integer.class)); }
@Test public void selfClass() { Config config = configurer.buildConfig(MicroserverConfigurerTest.class); assertThat(config.getClasses(), hasItem(this.getClass())); }
@Test public void additionalClasses() { Config config = configurer.buildConfig(MicroserverConfigurerTest.class); assertThat(config.getClasses(), hasItem(Integer.class)); }
@Test public void circularReferences() { Config config = configurer.buildConfig(MicroserverConfigurerTest.class); assertFalse(config.isAllowCircularReferences()); config = configurer.buildConfig(MicroserverConfigurerTest.class).withAllowCircularReferences(true); assertTrue(config.isAllowCircularReferences()); }