Search in sources :

Example 1 with FullyDocumentedProcessor

use of org.apache.nifi.documentation.example.FullyDocumentedProcessor in project nifi by apache.

the class ProcessorDocumentationWriterTest method testFullyDocumentedProcessor.

@Test
public void testFullyDocumentedProcessor() throws IOException {
    FullyDocumentedProcessor processor = new FullyDocumentedProcessor();
    ProcessorInitializer initializer = new ProcessorInitializer();
    initializer.initialize(processor);
    DocumentationWriter writer = new HtmlProcessorDocumentationWriter();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    writer.write(processor, baos, false);
    initializer.teardown(processor);
    String results = new String(baos.toByteArray());
    XmlValidator.assertXmlValid(results);
    assertContains(results, FullyDocumentedProcessor.DIRECTORY.getDisplayName());
    assertContains(results, FullyDocumentedProcessor.DIRECTORY.getDescription());
    assertContains(results, FullyDocumentedProcessor.OPTIONAL_PROPERTY.getDisplayName());
    assertContains(results, FullyDocumentedProcessor.OPTIONAL_PROPERTY.getDescription());
    assertContains(results, FullyDocumentedProcessor.POLLING_INTERVAL.getDisplayName());
    assertContains(results, FullyDocumentedProcessor.POLLING_INTERVAL.getDescription());
    assertContains(results, FullyDocumentedProcessor.POLLING_INTERVAL.getDefaultValue());
    assertContains(results, FullyDocumentedProcessor.RECURSE.getDisplayName());
    assertContains(results, FullyDocumentedProcessor.RECURSE.getDescription());
    assertContains(results, FullyDocumentedProcessor.REL_SUCCESS.getName());
    assertContains(results, FullyDocumentedProcessor.REL_SUCCESS.getDescription());
    assertContains(results, FullyDocumentedProcessor.REL_FAILURE.getName());
    assertContains(results, FullyDocumentedProcessor.REL_FAILURE.getDescription());
    assertContains(results, "Controller Service API: ");
    assertContains(results, "SampleService");
    assertContains(results, "CLUSTER, LOCAL");
    assertContains(results, "state management description");
    assertContains(results, "processor restriction description");
    assertContains(results, RequiredPermission.READ_FILESYSTEM.getPermissionLabel());
    assertContains(results, "Requires read filesystem permission");
    assertNotContains(results, "iconSecure.png");
    assertContains(results, FullyDocumentedProcessor.class.getAnnotation(CapabilityDescription.class).value());
    assertNotContains(results, "This component has no required or optional properties.");
    assertNotContains(results, "No description provided.");
    assertNotContains(results, "No tags provided.");
    assertNotContains(results, "Additional Details...");
    // input requirement
    assertContains(results, "This component does not allow an incoming relationship.");
    // 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, processor.getOnRemovedArgs());
    Assert.assertEquals(0, processor.getOnRemovedNoArgs());
    Assert.assertEquals(1, processor.getOnShutdownArgs());
    Assert.assertEquals(1, processor.getOnShutdownNoArgs());
}
Also used : FullyDocumentedProcessor(org.apache.nifi.documentation.example.FullyDocumentedProcessor) ProcessorInitializer(org.apache.nifi.init.ProcessorInitializer) 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 FullyDocumentedProcessor (org.apache.nifi.documentation.example.FullyDocumentedProcessor)1 ProcessorInitializer (org.apache.nifi.init.ProcessorInitializer)1 Test (org.junit.Test)1