Search in sources :

Example 1 with DocumentationWriter

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

Example 2 with DocumentationWriter

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

the class HtmlDocumentationWriterTest method testReportingTaskWithLogger.

@Test
public void testReportingTaskWithLogger() throws InitializationException, IOException {
    ReportingTask controllerService = new ReportingTaskWithLogger();
    controllerService.initialize(new MockReportingInitializationContext());
    DocumentationWriter writer = new HtmlDocumentationWriter();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    writer.write(controllerService, baos, false);
    String results = new String(baos.toByteArray());
    XmlValidator.assertXmlValid(results);
}
Also used : ReportingTaskWithLogger(org.apache.nifi.documentation.example.ReportingTaskWithLogger) MockReportingInitializationContext(org.apache.nifi.mock.MockReportingInitializationContext) DocumentationWriter(org.apache.nifi.documentation.DocumentationWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FullyDocumentedReportingTask(org.apache.nifi.documentation.example.FullyDocumentedReportingTask) ReportingTask(org.apache.nifi.reporting.ReportingTask) Test(org.junit.Test)

Example 3 with DocumentationWriter

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

the class HtmlDocumentationWriterTest method testDocumentControllerService.

@Test
public void testDocumentControllerService() throws InitializationException, IOException {
    FullyDocumentedControllerService controllerService = new FullyDocumentedControllerService();
    ControllerServiceInitializer initializer = new ControllerServiceInitializer();
    initializer.initialize(controllerService);
    DocumentationWriter writer = new HtmlDocumentationWriter();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    writer.write(controllerService, baos, false);
    initializer.teardown(controllerService);
    String results = new String(baos.toByteArray());
    XmlValidator.assertXmlValid(results);
    // description
    assertContains(results, "A documented controller service that can help you do things");
    // tags
    assertContains(results, "one, two, three");
    // properties
    assertContains(results, "Keystore Filename");
    assertContains(results, "The fully-qualified filename of the Keystore");
    assertContains(results, "Keystore Type");
    assertContains(results, "JKS");
    assertContains(results, "PKCS12");
    assertContains(results, "Sensitive Property: true");
    // restricted
    assertContains(results, "controller service 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, controllerService.getOnRemovedArgs());
    Assert.assertEquals(0, controllerService.getOnRemovedNoArgs());
    Assert.assertEquals(1, controllerService.getOnShutdownArgs());
    Assert.assertEquals(1, controllerService.getOnShutdownNoArgs());
}
Also used : DocumentationWriter(org.apache.nifi.documentation.DocumentationWriter) FullyDocumentedControllerService(org.apache.nifi.documentation.example.FullyDocumentedControllerService) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ControllerServiceInitializer(org.apache.nifi.init.ControllerServiceInitializer) Test(org.junit.Test)

Example 4 with DocumentationWriter

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

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

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