@Test public void testIsMethodMultipleSettersClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(IsMethodMultipleSettersClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); expectedAttributes.put("Value", ImmutableSet.of("value")); verifyMetaData(metadata, IsMethodMultipleSettersClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(0); monitor.assertNumberOfWarnings(0); }
@Test public void testCurrentAndLegacyConfigOnSetterClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(CurrentAndLegacyConfigOnSetterClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); expectedAttributes.put("Value", ImmutableSet.of("value", "replacedValue")); verifyMetaData(metadata, CurrentAndLegacyConfigOnSetterClass.class, "description", false, expectedAttributes); monitor.assertNumberOfErrors(0); monitor.assertNumberOfWarnings(0); }
@Test public void testGetterMultipleSettersClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(GetterMultipleSettersClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); expectedAttributes.put("Value", ImmutableSet.of("value")); verifyMetaData(metadata, GetterMultipleSettersClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(0); monitor.assertNumberOfWarnings(0); }
@Test public void testCurrentAndLegacyConfigOnSetterClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(CurrentAndLegacyConfigOnSetterClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); expectedAttributes.put("Value", ImmutableSet.of("value", "replacedValue")); verifyMetaData(metadata, CurrentAndLegacyConfigOnSetterClass.class, "description", false, expectedAttributes); monitor.assertNumberOfErrors(0); monitor.assertNumberOfWarnings(0); }
@Test public void testSetterConfigClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(SetterConfigClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); expectedAttributes.put("Value", ImmutableSet.of("value")); verifyMetaData(metadata, SetterConfigClass.class, "description", false, expectedAttributes); monitor.assertNumberOfErrors(0); monitor.assertNumberOfWarnings(0); }
@Test public void testSubSetterConfigClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(SetterSubConfigClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); expectedAttributes.put("Value", ImmutableSet.of("value")); verifyMetaData(metadata, SetterSubConfigClass.class, "description", false, expectedAttributes); monitor.assertNumberOfErrors(0); monitor.assertNumberOfWarnings(0); }
@Test public void testGetterMultipleSettersClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(GetterMultipleSettersClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); expectedAttributes.put("Value", ImmutableSet.of("value")); verifyMetaData(metadata, GetterMultipleSettersClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(0); monitor.assertNumberOfWarnings(0); }
@Test public void testDefunctConfigClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(DefunctConfigClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); expectedAttributes.put("Value", ImmutableSet.of("value")); verifyMetaData(metadata, DefunctConfigClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(0); monitor.assertNumberOfWarnings(0); }
@Test public void testSetterSensitiveClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(SetterSensitiveClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap(); expectedAttributes.put("Value", ImmutableSet.of("value")); verifyMetaData(metadata, SetterSensitiveClass.class, "description", true, expectedAttributes); monitor.assertNumberOfErrors(0); monitor.assertNumberOfWarnings(0); }
@Test public void testDefunctConfigClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(DefunctConfigClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); expectedAttributes.put("Value", ImmutableSet.of("value")); verifyMetaData(metadata, DefunctConfigClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(0); monitor.assertNumberOfWarnings(0); }
@Test public void testMultipleLegacyConfigClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(MultipleLegacyConfigClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); expectedAttributes.put("Value", ImmutableSet.of("legacy1", "legacy2", "value")); verifyMetaData(metadata, MultipleLegacyConfigClass.class, "description", false, expectedAttributes); monitor.assertNumberOfErrors(0); monitor.assertNumberOfWarnings(0); }
@Test public void testMultipleLegacyConfigClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(MultipleLegacyConfigClass.class, monitor); Map<String, Set<String>> expectedAttributes = Maps.newHashMap(); expectedAttributes.put("Value", ImmutableSet.of("legacy1", "legacy2", "value")); verifyMetaData(metadata, MultipleLegacyConfigClass.class, "description", expectedAttributes); monitor.assertNumberOfErrors(0); monitor.assertNumberOfWarnings(0); }
@Test public void testIsMethodNoSetterClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(IsMethodNoSetterClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); verifyMetaData(metadata, IsMethodNoSetterClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded(IsMethodNoSetterClass.class.getName(), "isValue", "is not a valid setter"); }
@Test public void testNoConfigMethodsClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(NoConfigMethodsClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); verifyMetaData(metadata, NoConfigMethodsClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("does not have any @Config annotations", NoConfigMethodsClass.class.getName()); }
@Test public void testSetterWithNoParameterClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(SetterWithNoParameterClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); verifyMetaData(metadata, SetterWithNoParameterClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("does not have exactly one parameter", SetterWithNoParameterClass.class.getName(), "setValue"); }
@Test public void testGetterNoSetterClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(GetterNoSetterClass.class, monitor); Map<String, Set<String>> expectedAttributes = Maps.newHashMap(); verifyMetaData(metadata, GetterNoSetterClass.class, null, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("is not a valid setter", GetterNoSetterClass.class.getName(), "getValue"); }
@Test public void testSetterWithNoParameterClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(SetterWithNoParameterClass.class, monitor); Map<String, Set<String>> expectedAttributes = Maps.newHashMap(); verifyMetaData(metadata, SetterWithNoParameterClass.class, null, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("does not have exactly one parameter", SetterWithNoParameterClass.class.getName(), "setValue"); }
@Test public void testEmptyStringInArrayLegacyConfigClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(EmptyStringInArrayLegacyConfigClass.class, monitor); Map<String, Set<String>> expectedAttributes = Maps.newHashMap(); verifyMetaData(metadata, EmptyStringInArrayLegacyConfigClass.class, null, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("@LegacyConfig method", EmptyStringInArrayLegacyConfigClass.class.getName(), "setValue", "null or empty value"); }
@Test public void testEmptyArrayLegacyConfigClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(EmptyArrayLegacyConfigClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); verifyMetaData(metadata, EmptyArrayLegacyConfigClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("@LegacyConfig method", EmptyArrayLegacyConfigClass.class.getName(), "setValue", "empty list"); }
@Test public void testStaticAttributeClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(StaticAttributeClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); verifyMetaData(metadata, StaticAttributeClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded(StaticAttributeClass.class.getName(), "setValue", "is static"); }