@Test public void testEmptyPropertyNameClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(EmptyPropertyNameClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); verifyMetaData(metadata, EmptyPropertyNameClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("empty value", "setValue"); }
@Test public void testNotJavaBeanClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(NotJavaBeanClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); verifyMetaData(metadata, NotJavaBeanClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("not a valid setter", "putValue"); }
@Test public void testNotPublicAttributeClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(NotPublicAttributeClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); verifyMetaData(metadata, NotPublicAttributeClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("No getter", "unusable", "getValue", "setValue"); }
@Test public void testIsMethodNoReturnClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(IsMethodNoReturnClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); verifyMetaData(metadata, IsMethodNoReturnClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("No getter", "setValue"); }
@Test public void testLegacyConfigDuplicatesConfigClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(LegacyConfigDuplicatesConfigClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); verifyMetaData(metadata, LegacyConfigDuplicatesConfigClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("@Config property", "'value'", "appears in @LegacyConfig", "setValue"); }
@Test public void testEmptyPropertyNameClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(EmptyPropertyNameClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); verifyMetaData(metadata, EmptyPropertyNameClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("empty value", "setValue"); }
@Test public void testIsMethodWithParameterClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(IsMethodWithParameterClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); verifyMetaData(metadata, IsMethodWithParameterClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("No getter", "unusable", "isValue", "setValue"); }
@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 testGetterWithParameterClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(GetterWithParameterClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); verifyMetaData(metadata, GetterWithParameterClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("No getter", "unusable", "getValue", "setValue"); }
@Test public void testGetterNoReturnClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(GetterNoReturnClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); verifyMetaData(metadata, GetterNoReturnClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("No getter", "unusable", "getValue", "setValue"); }
@Test public void testNotJavaBeanClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(NotJavaBeanClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); verifyMetaData(metadata, NotJavaBeanClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("not a valid setter", "putValue"); }
@Test public void testGetterPrivateSetterClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(GetterPrivateSetterClass.class, monitor); Map<String, Set<String>> expectedAttributes = Maps.newHashMap(); verifyMetaData(metadata, GetterPrivateSetterClass.class, null, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("@Config method", "setValue", "is not public"); }
@Test public void testLegacyConfigDuplicatesConfigClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(LegacyConfigDuplicatesConfigClass.class, monitor); Map<String, Set<String>> expectedAttributes = Maps.newHashMap(); verifyMetaData(metadata, LegacyConfigDuplicatesConfigClass.class, null, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("@Config property", "'value'", "appears in @LegacyConfig", "setValue"); }
@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 testIsMethodPrivateSetterClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(IsMethodPrivateSetterClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); verifyMetaData(metadata, IsMethodPrivateSetterClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("@Config method", IsMethodPrivateSetterClass.class.getName(), "setValue", "is not public"); }
@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 testEmptyStringLegacyConfigClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(EmptyStringLegacyConfigClass.class, monitor); Map<String, Set<String>> expectedAttributes = new HashMap<>(); verifyMetaData(metadata, EmptyStringLegacyConfigClass.class, null, false, expectedAttributes); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("@LegacyConfig method", EmptyStringLegacyConfigClass.class.getName(), "setValue", "null or empty value"); }
@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"); }