org.apache.nifi.annotation.documentation.CapabilityDescription Java Examples

The following examples show how to use org.apache.nifi.annotation.documentation.CapabilityDescription. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HtmlDocumentationWriter.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Gets a description of the ConfigurableComponent using the
 * CapabilityDescription annotation.
 *
 * @param configurableComponent the component to describe
 * @return a description of the configurableComponent
 */
protected String getDescription(final ConfigurableComponent configurableComponent) {
    final CapabilityDescription capabilityDescription = configurableComponent.getClass().getAnnotation(
            CapabilityDescription.class);

    final String description;
    if (capabilityDescription != null) {
        description = capabilityDescription.value();
    } else {
        description = "No description provided.";
    }

    return description;
}
 
Example #2
Source File: StandardProcessorNode.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * @return the value of the processor's {@link CapabilityDescription}
 *         annotation, if one exists, else <code>null</code>.
 */
public String getProcessorDescription() {
    final CapabilityDescription capDesc = processor.getClass().getAnnotation(CapabilityDescription.class);
    String description = null;
    if (capDesc != null) {
        description = capDesc.value();
    }
    return description;
}
 
Example #3
Source File: AbstractDocumentationWriter.java    From nifi with Apache License 2.0 5 votes vote down vote up
protected String getDescription(final ConfigurableComponent component) {
    final CapabilityDescription capabilityDescription = component.getClass().getAnnotation(CapabilityDescription.class);
    if (capabilityDescription == null) {
        return null;
    }

    return capabilityDescription.value();
}
 
Example #4
Source File: HtmlDocumentationWriter.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Gets a description of the ConfigurableComponent using the
 * CapabilityDescription annotation.
 *
 * @param configurableComponent the component to describe
 * @return a description of the configurableComponent
 */
protected String getDescription(final ConfigurableComponent configurableComponent) {
    final CapabilityDescription capabilityDescription = configurableComponent.getClass().getAnnotation(
            CapabilityDescription.class);

    final String description;
    if (capabilityDescription != null) {
        description = capabilityDescription.value();
    } else {
        description = "No description provided.";
    }

    return description;
}
 
Example #5
Source File: StandardProcessorNode.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * @return the value of the processor's {@link CapabilityDescription}
 *         annotation, if one exists, else <code>null</code>.
 */
public String getProcessorDescription() {
    final Processor processor = processorRef.get().getProcessor();
    final CapabilityDescription capDesc = processor.getClass().getAnnotation(CapabilityDescription.class);
    String description = null;
    if (capDesc != null) {
        description = capDesc.value();
    }
    return description;
}
 
Example #6
Source File: ProcessorDocumentationWriterTest.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@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");

    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...");

    // 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());
}
 
Example #7
Source File: DtoFactory.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Gets the capability description from the specified class.
 */
private String getCapabilityDescription(final Class<?> cls) {
    final CapabilityDescription capabilityDesc = cls.getAnnotation(CapabilityDescription.class);
    return capabilityDesc == null ? null : capabilityDesc.value();
}
 
Example #8
Source File: ProcessorDocumentationWriterTest.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Test
public void testFullyDocumentedProcessor() throws IOException {
    ExtensionManager extensionManager = new StandardExtensionDiscoveringManager();

    FullyDocumentedProcessor processor = new FullyDocumentedProcessor();
    ProcessorInitializer initializer = new ProcessorInitializer(extensionManager);
    initializer.initialize(processor);

    DocumentationWriter writer = new HtmlProcessorDocumentationWriter(extensionManager);

    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...");

    // check expression language scope
    assertContains(results, "Supports Expression Language: true (will be evaluated using variable registry only)");
    assertContains(results, "Supports Expression Language: true (undefined scope)");

    // verify dynamic properties
    assertContains(results, "Routes FlowFiles to relationships based on XPath");

    // 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());
}
 
Example #9
Source File: ProcessorDocumentationWriterTest.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Test
public void testDeprecatedProcessor() throws IOException {
    ExtensionManager extensionManager = new StandardExtensionDiscoveringManager();

    DeprecatedProcessor processor = new DeprecatedProcessor();
    ProcessorInitializer initializer = new ProcessorInitializer(extensionManager);
    initializer.initialize(processor);

    DocumentationWriter writer = new HtmlProcessorDocumentationWriter(extensionManager);

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