Search in sources :

Example 1 with FullyDocumentedControllerService

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

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DocumentationWriter (org.apache.nifi.documentation.DocumentationWriter)1 FullyDocumentedControllerService (org.apache.nifi.documentation.example.FullyDocumentedControllerService)1 ControllerServiceInitializer (org.apache.nifi.init.ControllerServiceInitializer)1 Test (org.junit.Test)1