leesf commented on a change in pull request #1851: URL: https://github.com/apache/hudi/pull/1851#discussion_r459200519
########## File path: hudi-client/src/test/java/org/apache/hudi/metrics/TestMetricsReporterFactory.java ########## @@ -45,4 +52,53 @@ public void metricsReporterFactoryShouldReturnReporter() { MetricsReporter reporter = MetricsReporterFactory.createReporter(config, registry); assertTrue(reporter instanceof InMemoryMetricsReporter); } + + @Test + public void metricsReporterFactoryShouldReturnUserDefinedReporter() { + when(config.getMetricReporterClassName()).thenReturn(TestMetricReporter.class.getName()); + + Properties props = new Properties(); + props.setProperty("testKey", "testValue"); + + when(config.getProps()).thenReturn(props); + MetricsReporter reporter = MetricsReporterFactory.createReporter(config, registry); + assertTrue(reporter instanceof AbstractUserDefinedMetricsReporter); + assertEquals(props, ((TestMetricReporter) reporter).getProps()); + assertEquals(registry, ((TestMetricReporter) reporter).getRegistry()); + } + + @Test + public void metricsReporterFactoryShouldThrowExceptionWhenMetricsReporterClassIsIllegal() { + when(config.getMetricReporterClassName()).thenReturn(TestIllegalMetricReporter.class.getName()); + when(config.getProps()).thenReturn(new Properties()); + assertThrows(HoodieException.class, () -> MetricsReporterFactory.createReporter(config, registry)); + } + + public static class TestMetricReporter extends AbstractUserDefinedMetricsReporter { Review comment: would rename to `DummyMetricsReporter` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org