### Question:
ReportPublisherFactory { public ReportPublisher getPublisherFor( Class<? extends GeneratedMessage> report) { Class<? extends ReportPublisher> publisherClass = report2publisher.get(report); if (publisherClass == null) { throw new RuntimeException("No publisher found for report " + report); } try { ReportPublisher reportPublisher = publisherClass.newInstance(); reportPublisher.setConf(conf); return reportPublisher; } catch (Exception e) { throw new RuntimeException(e); } } ReportPublisherFactory(ConfigurationSource conf); ReportPublisher getPublisherFor(
      Class<? extends GeneratedMessage> report);  }### Answer:
@Test public void testGetContainerReportPublisher() { OzoneConfiguration conf = new OzoneConfiguration(); ReportPublisherFactory factory = new ReportPublisherFactory(conf); ReportPublisher publisher = factory .getPublisherFor(ContainerReportsProto.class); Assert.assertEquals(ContainerReportPublisher.class, publisher.getClass()); Assert.assertEquals(conf, publisher.getConf()); }
@Test public void testGetNodeReportPublisher() { OzoneConfiguration conf = new OzoneConfiguration(); ReportPublisherFactory factory = new ReportPublisherFactory(conf); ReportPublisher publisher = factory .getPublisherFor(NodeReportProto.class); Assert.assertEquals(NodeReportPublisher.class, publisher.getClass()); Assert.assertEquals(conf, publisher.getConf()); }
@Test public void testInvalidReportPublisher() { OzoneConfiguration conf = new OzoneConfiguration(); ReportPublisherFactory factory = new ReportPublisherFactory(conf); exception.expect(RuntimeException.class); exception.expectMessage("No publisher found for report"); factory.getPublisherFor(HddsProtos.DatanodeDetailsProto.class); }