@Test public void testLegacyConfigOnGetterClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(LegacyConfigOnGetterClass.class, monitor); monitor.assertNumberOfErrors(2); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("not a valid setter", "getValue"); monitor.assertMatchingErrorRecorded("LegacyConfig", "getValue", "not associated with any valid @Config"); }
@Test public void testLegacyConfigOnNonDeprecatedSetterClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(LegacyConfigOnNonDeprecatedSetterClass.class, monitor); monitor.assertNumberOfErrors(0); monitor.assertNumberOfWarnings(1); monitor.assertMatchingWarningRecorded("Replaced @LegacyConfig method", "setValue(int)", "should be @Deprecated"); }
private String errorsString() { return messageListAsString(errors); }
public static void main( String args[] ) { final TestMonitor tm = new TestMonitor(); Thread thread1 = new Thread( new Runnable() { public void run() { tm.lockAndWait(); } } ); Thread thread2 = new Thread( new Runnable() { public void run() { tm.lockAndWait(); } } ); thread1.start(); thread2.start(); }
@Test public void testLegacyConfigOnDeprecatedSetterClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(LegacyConfigOnDeprecatedSetterClass.class, monitor); monitor.assertNumberOfErrors(0); monitor.assertNumberOfWarnings(0); }
public void assertNumberOfErrors(int expected) { assertEquals(errors.size(), expected, String.format("Number of errors is incorrect, actual errors: %s", errorsString())); }
public void assertNumberOfWarnings(int expected) { assertEquals(warnings.size(), expected, String.format("Number of warnings is incorrect, actual warnings: %s", warningsString())); }
@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); }
public void assertNumberOfErrors(int expected) { Assert.assertEquals(errors.size(), expected, String.format("Number of errors is incorrect, actual errors: %s", errorsString())); }
public void assertNumberOfWarnings(int expected) { Assert.assertEquals(warnings.size(), expected, String.format("Number of warnings is incorrect, actual warnings: %s", warningsString())); }
@Test public void testLegacyConfigOnGetterClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(LegacyConfigOnGetterClass.class, monitor); monitor.assertNumberOfErrors(2); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("not a valid setter", "getValue"); monitor.assertMatchingErrorRecorded("LegacyConfig", "getValue", "not associated with any valid @Config"); }
@Test public void testLegacyConfigOnNonDeprecatedSetterClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(LegacyConfigOnNonDeprecatedSetterClass.class, monitor); monitor.assertNumberOfErrors(0); monitor.assertNumberOfWarnings(1); monitor.assertMatchingWarningRecorded("Replaced @LegacyConfig method", "setValue(int)", "should be @Deprecated"); }
@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); }
private String warningsString() { return messageListAsString(warnings); }
public void assertNumberOfErrors(int expected) { assertEquals(errors.size(), expected, String.format("Number of errors is incorrect, actual errors: %s", errorsString())); }
public void assertNumberOfWarnings(int expected) { assertEquals(warnings.size(), expected, String.format("Number of warnings is incorrect, actual warnings: %s", warningsString())); }
@Test public void testLegacyConfigOnSetterClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(LegacyConfigOnSetterClass.class, monitor); monitor.assertNumberOfErrors(1); monitor.assertNumberOfWarnings(0); monitor.assertMatchingErrorRecorded("LegacyConfig", "setValue", "not associated with any valid @Config"); }
@Test public void testLegacyConfigOnNonDeprecatedSetterClass() throws Exception { TestMonitor monitor = new TestMonitor(); ConfigurationMetadata<?> metadata = ConfigurationMetadata.getConfigurationMetadata(LegacyConfigOnNonDeprecatedSetterClass.class, monitor); monitor.assertNumberOfErrors(0); monitor.assertNumberOfWarnings(1); monitor.assertMatchingWarningRecorded("Replaced @LegacyConfig method", "setValue(int)", "should be @Deprecated"); }
@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); }
private String errorsString() { return messageListAsString(errors); }