use of org.apache.nifi.init.ReportingTaskingInitializer in project nifi by apache.
the class HtmlDocumentationWriterTest method testDocumentReportingTask.
@Test
public void testDocumentReportingTask() throws InitializationException, IOException {
FullyDocumentedReportingTask reportingTask = new FullyDocumentedReportingTask();
ReportingTaskingInitializer initializer = new ReportingTaskingInitializer();
initializer.initialize(reportingTask);
DocumentationWriter writer = new HtmlDocumentationWriter();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
writer.write(reportingTask, baos, false);
initializer.teardown(reportingTask);
String results = new String(baos.toByteArray());
XmlValidator.assertXmlValid(results);
// description
assertContains(results, "A helper reporting task to do...");
// tags
assertContains(results, "first, second, third");
// properties
assertContains(results, "Show Deltas");
assertContains(results, "Specifies whether or not to show the difference in values between the current status and the previous status");
assertContains(results, "true");
assertContains(results, "false");
// restricted
assertContains(results, "reporting task restriction description");
// verify system resource considerations
assertContains(results, SystemResource.CPU.name());
assertContains(results, SystemResourceConsideration.DEFAULT_DESCRIPTION);
assertContains(results, SystemResource.DISK.name());
assertContains(results, "Customized disk usage description");
assertContains(results, SystemResource.MEMORY.name());
assertContains(results, "Not Specified");
// verify the right OnRemoved and OnShutdown methods were called
Assert.assertEquals(0, reportingTask.getOnRemovedArgs());
Assert.assertEquals(0, reportingTask.getOnRemovedNoArgs());
Assert.assertEquals(1, reportingTask.getOnShutdownArgs());
Assert.assertEquals(1, reportingTask.getOnShutdownNoArgs());
}
Aggregations