@Test(expected = IllegalArgumentException.class) public void scanWithNoClassesWithBadPackageFound() { AnnotationScanPropertyDefinitionsProvider provider = new AnnotationScanPropertyDefinitionsProvider( ConquesoConfig.class, Collections.singletonList("com.bad.package")); Map<String, PropertyDefinition> results = Maps.newHashMap(); provider.addPropertyDefinitions(results); }
@Test(expected = IllegalArgumentException.class) public void scanWithNoClassesWithAnnotationFound() { AnnotationScanPropertyDefinitionsProvider provider = new AnnotationScanPropertyDefinitionsProvider( DummyAnnotation.class, Collections.singletonList("com.rapid7.conqueso")); Map<String, PropertyDefinition> results = Maps.newHashMap(); provider.addPropertyDefinitions(results); }
@Test public void standardSuccessfulScan() { // This test relies on the fact that the ExampleConfigClass is annotated with @ConquesoConfig AnnotationScanPropertyDefinitionsProvider provider = new AnnotationScanPropertyDefinitionsProvider( ConquesoConfig.class, Collections.singletonList("com.rapid7.conqueso")); Map<String, PropertyDefinition> results = Maps.newHashMap(); provider.addPropertyDefinitions(results); ConquesoTestHelper.assertExampleConfigProperties(results); }
@Test public void scanWithCustomDelimiter() { // This test relies on the fact that the ExampleConfigClass is annotated with @ConquesoConfig AnnotationScanPropertyDefinitionsProvider provider = new AnnotationScanPropertyDefinitionsProvider( ConquesoConfig.class, Collections.singletonList("com.rapid7.conqueso"), ";;"); Map<String, PropertyDefinition> results = Maps.newHashMap(); provider.addPropertyDefinitions(results); assertContainsProperty( "stringList1", PropertyType.STRING_LIST, "foo;;bar;;baz", "This is stringList1", results); assertContainsProperty("stringSet1", PropertyType.STRING_SET, "baz;;foo;;bar", null, results); assertContainsProperty( "stringMap1", PropertyType.STRING_MAP, "k3=v3;;k1=v1;;k2=v2", null, results); }