Search in sources :

Example 1 with ReportingTaskingInitializer

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());
}
Also used : ReportingTaskingInitializer(org.apache.nifi.init.ReportingTaskingInitializer) FullyDocumentedReportingTask(org.apache.nifi.documentation.example.FullyDocumentedReportingTask) DocumentationWriter(org.apache.nifi.documentation.DocumentationWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DocumentationWriter (org.apache.nifi.documentation.DocumentationWriter)1 FullyDocumentedReportingTask (org.apache.nifi.documentation.example.FullyDocumentedReportingTask)1 ReportingTaskingInitializer (org.apache.nifi.init.ReportingTaskingInitializer)1 Test (org.junit.Test)1