Search in sources :

Example 1 with ProcessorInitializer

use of org.apache.nifi.init.ProcessorInitializer 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)

Example 2 with ProcessorInitializer

use of org.apache.nifi.init.ProcessorInitializer in project nifi by apache.

the class ProcessorDocumentationWriterTest method testProcessorWithLoggerInitialization.

@Test
public void testProcessorWithLoggerInitialization() throws IOException {
    ProcessorWithLogger processor = new ProcessorWithLogger();
    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);
}
Also used : ProcessorInitializer(org.apache.nifi.init.ProcessorInitializer) DocumentationWriter(org.apache.nifi.documentation.DocumentationWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ProcessorWithLogger(org.apache.nifi.documentation.example.ProcessorWithLogger) Test(org.junit.Test)

Example 3 with ProcessorInitializer

use of org.apache.nifi.init.ProcessorInitializer in project nifi by apache.

the class ProcessorDocumentationWriterTest method testNakedProcessor.

@Test
public void testNakedProcessor() throws IOException {
    NakedProcessor processor = new NakedProcessor();
    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);
    // no description
    assertContains(results, "No description provided.");
    // no tags
    assertContains(results, "No tags provided.");
    // properties
    assertContains(results, "This component has no required or optional properties.");
    // relationships
    assertContains(results, "This processor has no relationships.");
    // state management
    assertContains(results, "This component does not store state.");
    // state management
    assertContains(results, "This component is not restricted.");
    // input requirement
    assertNotContains(results, "Input requirement:");
}
Also used : ProcessorInitializer(org.apache.nifi.init.ProcessorInitializer) DocumentationWriter(org.apache.nifi.documentation.DocumentationWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) NakedProcessor(org.apache.nifi.documentation.example.NakedProcessor) Test(org.junit.Test)

Example 4 with ProcessorInitializer

use of org.apache.nifi.init.ProcessorInitializer in project nifi by apache.

the class ProcessorDocumentationWriterTest method testDeprecatedProcessor.

@Test
public void testDeprecatedProcessor() throws IOException {
    DeprecatedProcessor processor = new DeprecatedProcessor();
    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, DeprecatedProcessor.DIRECTORY.getDisplayName());
    assertContains(results, DeprecatedProcessor.DIRECTORY.getDescription());
    assertContains(results, DeprecatedProcessor.OPTIONAL_PROPERTY.getDisplayName());
    assertContains(results, DeprecatedProcessor.OPTIONAL_PROPERTY.getDescription());
    assertContains(results, DeprecatedProcessor.POLLING_INTERVAL.getDisplayName());
    assertContains(results, DeprecatedProcessor.POLLING_INTERVAL.getDescription());
    assertContains(results, DeprecatedProcessor.POLLING_INTERVAL.getDefaultValue());
    assertContains(results, DeprecatedProcessor.RECURSE.getDisplayName());
    assertContains(results, DeprecatedProcessor.RECURSE.getDescription());
    assertContains(results, DeprecatedProcessor.REL_SUCCESS.getName());
    assertContains(results, DeprecatedProcessor.REL_SUCCESS.getDescription());
    assertContains(results, DeprecatedProcessor.REL_FAILURE.getName());
    assertContains(results, DeprecatedProcessor.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");
    assertNotContains(results, "iconSecure.png");
    assertContains(results, DeprecatedProcessor.class.getAnnotation(CapabilityDescription.class).value());
    // Check for the existence of deprecation notice
    assertContains(results, "Deprecation notice: ");
    // assertContains(results, DeprecatedProcessor.class.getAnnotation(DeprecationNotice.class.));
    assertNotContains(results, "This component has no required or optional properties.");
    assertNotContains(results, "No description provided.");
    assertNotContains(results, "No tags provided.");
    assertNotContains(results, "Additional Details...");
    // 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 : DeprecatedProcessor(org.apache.nifi.documentation.example.DeprecatedProcessor) 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)4 DocumentationWriter (org.apache.nifi.documentation.DocumentationWriter)4 ProcessorInitializer (org.apache.nifi.init.ProcessorInitializer)4 Test (org.junit.Test)4 DeprecatedProcessor (org.apache.nifi.documentation.example.DeprecatedProcessor)1 FullyDocumentedProcessor (org.apache.nifi.documentation.example.FullyDocumentedProcessor)1 NakedProcessor (org.apache.nifi.documentation.example.NakedProcessor)1 ProcessorWithLogger (org.apache.nifi.documentation.example.ProcessorWithLogger)1