Search in sources :

Example 6 with DocumentationWriter

use of org.apache.nifi.documentation.DocumentationWriter 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 7 with DocumentationWriter

use of org.apache.nifi.documentation.DocumentationWriter 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)

Example 8 with DocumentationWriter

use of org.apache.nifi.documentation.DocumentationWriter in project nifi by apache.

the class HtmlDocumentationWriterTest method testControllerServiceWithLogger.

@Test
public void testControllerServiceWithLogger() throws InitializationException, IOException {
    ControllerService controllerService = new ControllerServiceWithLogger();
    controllerService.initialize(new MockControllerServiceInitializationContext());
    DocumentationWriter writer = new HtmlDocumentationWriter();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    writer.write(controllerService, baos, false);
    String results = new String(baos.toByteArray());
    XmlValidator.assertXmlValid(results);
}
Also used : MockControllerServiceInitializationContext(org.apache.nifi.mock.MockControllerServiceInitializationContext) ControllerServiceWithLogger(org.apache.nifi.documentation.example.ControllerServiceWithLogger) DocumentationWriter(org.apache.nifi.documentation.DocumentationWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ControllerService(org.apache.nifi.controller.ControllerService) FullyDocumentedControllerService(org.apache.nifi.documentation.example.FullyDocumentedControllerService) Test(org.junit.Test)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 DocumentationWriter (org.apache.nifi.documentation.DocumentationWriter)8 Test (org.junit.Test)8 ProcessorInitializer (org.apache.nifi.init.ProcessorInitializer)4 FullyDocumentedControllerService (org.apache.nifi.documentation.example.FullyDocumentedControllerService)2 FullyDocumentedReportingTask (org.apache.nifi.documentation.example.FullyDocumentedReportingTask)2 ControllerService (org.apache.nifi.controller.ControllerService)1 ControllerServiceWithLogger (org.apache.nifi.documentation.example.ControllerServiceWithLogger)1 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 ReportingTaskWithLogger (org.apache.nifi.documentation.example.ReportingTaskWithLogger)1 ControllerServiceInitializer (org.apache.nifi.init.ControllerServiceInitializer)1 ReportingTaskingInitializer (org.apache.nifi.init.ReportingTaskingInitializer)1 MockControllerServiceInitializationContext (org.apache.nifi.mock.MockControllerServiceInitializationContext)1 MockReportingInitializationContext (org.apache.nifi.mock.MockReportingInitializationContext)1 ReportingTask (org.apache.nifi.reporting.ReportingTask)1