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());
}
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);
}
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());
}
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());
}
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);
}
Aggregations