http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/b612b6bc/nifi/nifi-mock/src/main/java/org/apache/nifi/util/TestRunner.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/TestRunner.java b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/TestRunner.java index 177c889..c4fec35 100644 --- a/nifi/nifi-mock/src/main/java/org/apache/nifi/util/TestRunner.java +++ b/nifi/nifi-mock/src/main/java/org/apache/nifi/util/TestRunner.java @@ -38,29 +38,23 @@ import org.apache.nifi.reporting.InitializationException; public interface TestRunner { /** - * Returns the {@link Processor} for which this <code>TestRunner</code> is + * @return the {@link Processor} for which this <code>TestRunner</code> is * configured - * - * @return */ Processor getProcessor(); /** - * Returns the {@link ProcessSessionFactory} that this + * @return the {@link ProcessSessionFactory} that this * <code>TestRunner</code> will use to invoke the * {@link Processor#onTrigger(ProcessContext, ProcessSessionFactory)} method - * - * @return */ ProcessSessionFactory getProcessSessionFactory(); /** - * Returns the {@Link ProcessContext} that this <code>TestRunner</code> will + * @return the {@Link ProcessContext} that this <code>TestRunner</code> will * use to invoke the * {@link Processor#onTrigger(ProcessContext, ProcessSessionFactory) onTrigger} * method - * - * @return */ ProcessContext getProcessContext(); @@ -74,25 +68,26 @@ public interface TestRunner { * Performs the same operation as calling {@link #run(int, boolean)} with a * value of <code>true</code> * - * @param iterations + * @param iterations number of iterations */ void run(int iterations); /** - * performs the same operation as calling {@link #run(int, boolean, int)} with a value - * of {@code iterations}, {@code stopOnFinish}, {@code true} - * - * @param iterations - * @param stopOnFinish + * performs the same operation as calling {@link #run(int, boolean, int)} + * with a value of {@code iterations}, {@code stopOnFinish}, {@code true} + * + * @param iterations number of iterations + * @param stopOnFinish flag to stop when finished */ void run(int iterations, boolean stopOnFinish); - + /** * This method runs the {@link Processor} <code>iterations</code> times, * using the sequence of steps below: * <ul> * <li> - * If {@code initialize} is true, run all methods on the Processor that are annotated with the + * If {@code initialize} is true, run all methods on the Processor that are + * annotated with the * {@link nifi.processor.annotation.OnScheduled @OnScheduled} annotation. If * any of these methods throws an Exception, the Unit Test will fail. * </li> @@ -122,14 +117,13 @@ public interface TestRunner { * </li> * </ul> * - * @param iterations + * @param iterations number of iterations * @param stopOnFinish whether or not to run the Processor methods that are * annotated with {@link nifi.processor.annotation.OnStopped @OnStopped} + * @param initialize true if must initialize */ void run(int iterations, boolean stopOnFinish, final boolean initialize); - - /** * Invokes all methods on the Processor that are annotated with the * {@link nifi.processor.annotation.OnShutdown @OnShutdown} annotation. If @@ -141,16 +135,14 @@ public interface TestRunner { * Updates the number of threads that will be used to run the Processor when * calling the {@link #run()} or {@link #run(int)} methods. * - * @param threadCount + * @param threadCount num threads */ void setThreadCount(int threadCount); /** - * Returns the currently configured number of threads that will be used to + * @return the currently configured number of threads that will be used to * runt he Processor when calling the {@link #run()} or {@link #run(int)} - * methods. - * - * @return + * methods */ int getThreadCount(); @@ -160,9 +152,9 @@ public interface TestRunner { * descriptor's validator. Otherwise, Assert.fail() is called, causing the * unit test to fail * - * @param propertyName - * @param propertyValue - * @return + * @param propertyName name + * @param propertyValue value + * @return result */ ValidationResult setProperty(String propertyName, String propertyValue); @@ -172,9 +164,9 @@ public interface TestRunner { * descriptor's validator. Otherwise, Assert.fail() is called, causing the * unit test to fail * - * @param descriptor - * @param value - * @return + * @param descriptor descriptor + * @param value value + * @return result */ ValidationResult setProperty(PropertyDescriptor descriptor, String value); @@ -184,16 +176,16 @@ public interface TestRunner { * descriptor's validator. Otherwise, Assert.fail() is called, causing the * unit test to fail * - * @param descriptor - * @param value - * @return + * @param descriptor descriptor + * @param value allowable valu + * @return result */ ValidationResult setProperty(PropertyDescriptor descriptor, AllowableValue value); /** - * Sets the annontation data. + * Sets the annotation data. * - * @param annotationData + * @param annotationData data */ void setAnnotationData(String annotationData); @@ -201,7 +193,7 @@ public interface TestRunner { * Asserts that all FlowFiles that were transferred were transferred to the * given relationship * - * @param relationship + * @param relationship to verify */ void assertAllFlowFilesTransferred(String relationship); @@ -209,7 +201,7 @@ public interface TestRunner { * Asserts that all FlowFiles that were transferred were transferred to the * given relationship * - * @param relationship + * @param relationship to verify */ void assertAllFlowFilesTransferred(Relationship relationship); @@ -218,8 +210,8 @@ public interface TestRunner { * given relationship and that the number of FlowFiles transferred is equal * to <code>count</code> * - * @param relationship - * @param count + * @param relationship to verify + * @param count number of expected transfers */ void assertAllFlowFilesTransferred(String relationship, int count); @@ -228,8 +220,8 @@ public interface TestRunner { * given relationship and that the number of FlowFiles transferred is equal * to <code>count</code> * - * @param relationship - * @param count + * @param relationship to verify + * @param count number of expected transfers */ void assertAllFlowFilesTransferred(Relationship relationship, int count); @@ -237,8 +229,8 @@ public interface TestRunner { * Assert that the number of FlowFiles transferred to the given relationship * is equal to the given count * - * @param relationship - * @param count + * @param relationship to verify + * @param count number of expected transfers */ void assertTransferCount(Relationship relationship, int count); @@ -246,8 +238,8 @@ public interface TestRunner { * Assert that the number of FlowFiles transferred to the given relationship * is equal to the given count * - * @param relationship - * @param count + * @param relationship to verify + * @param count number of expected transfers */ void assertTransferCount(String relationship, int count); @@ -257,10 +249,8 @@ public interface TestRunner { void assertQueueEmpty(); /** - * Returns <code>true</code> if the Input Queue to the Processor is empty, + * @return <code>true</code> if the Input Queue to the Processor is empty, * <code>false</code> otherwise - * - * @return */ boolean isQueueEmpty(); @@ -293,7 +283,7 @@ public interface TestRunner { /** * Enqueues the given FlowFiles into the Processor's input queue * - * @param flowFiles + * @param flowFiles to enqueue */ void enqueue(FlowFile... flowFiles); @@ -302,8 +292,8 @@ public interface TestRunner { * FlowFile from this content with no attributes and adds this FlowFile to * the Processor's Input Queue * - * @param path - * @throws IOException + * @param path to read content from + * @throws IOException if unable to read content */ void enqueue(Path path) throws IOException; @@ -312,9 +302,9 @@ public interface TestRunner { * FlowFile from this content with the given attributes and adds this * FlowFile to the Processor's Input Queue * - * @param path - * @param attributes - * @throws IOException + * @param path to read content from + * @param attributes attributes to use for new flow file + * @throws IOException if unable to read content */ void enqueue(Path path, Map<String, String> attributes) throws IOException; @@ -323,7 +313,7 @@ public interface TestRunner { * FlowFile from this content with no attributes and adds this FlowFile to * the Processor's Input Queue * - * @param data + * @param data to enqueue */ void enqueue(byte[] data); @@ -332,8 +322,8 @@ public interface TestRunner { * FlowFile from this content with the given attributes and adds this * FlowFile to the Processor's Input Queue * - * @param data - * @param attributes + * @param data to enqueue + * @param attributes to use for enqueued items */ void enqueue(byte[] data, Map<String, String> attributes); @@ -342,7 +332,7 @@ public interface TestRunner { * creates a FlowFile from this content with no attributes and adds this * FlowFile to the Processor's Input Queue * - * @param data + * @param data to source data from */ void enqueue(InputStream data); @@ -351,8 +341,8 @@ public interface TestRunner { * creates a FlowFile from this content with the given attributes and adds * this FlowFile to the Processor's Input Queue * - * @param data - * @param attributes + * @param data source of data + * @param attributes to use for flow files */ void enqueue(InputStream data, Map<String, String> attributes); @@ -360,8 +350,8 @@ public interface TestRunner { * Copies the contents of the given {@link MockFlowFile} into a byte array * and returns that byte array. * - * @param flowFile - * @return + * @param flowFile to get content for + * @return byte array of flowfile content */ byte[] getContentAsByteArray(MockFlowFile flowFile); @@ -369,8 +359,8 @@ public interface TestRunner { * Returns a List of FlowFiles in the order in which they were transferred * to the given relationship * - * @param relationship - * @return + * @param relationship to get flowfiles for + * @return flowfiles transfered to given relationship */ List<MockFlowFile> getFlowFilesForRelationship(String relationship); @@ -378,39 +368,31 @@ public interface TestRunner { * Returns a List of FlowFiles in the order in which they were transferred * to the given relationship * - * @param relationship - * @return + * @param relationship to get flowfiles for + * @return flowfiles transfered to given relationship */ List<MockFlowFile> getFlowFilesForRelationship(Relationship relationship); /** - * Returns the {@link ProvenanceReporter} that will be used by the - * configured {@link Processor} for reporting Provenance Events. - * - * @return + * @return the {@link ProvenanceReporter} that will be used by the + * configured {@link Processor} for reporting Provenance Events */ ProvenanceReporter getProvenanceReporter(); /** - * Returns the current size of the Processor's Input Queue - * - * @return + * @return the current size of the Processor's Input Queue */ QueueSize getQueueSize(); /** - * Returns the current value of the counter with the specified name, or null + * @param name of counter + * @return the current value of the counter with the specified name, or null * if no counter exists with the specified name - * - * @param name - * @return */ Long getCounterValue(String name); /** - * Returns the number of FlowFiles that have been removed from the system - * - * @return + * @return the number of FlowFiles that have been removed from the system */ int getRemovedCount(); @@ -418,10 +400,11 @@ public interface TestRunner { * Indicates to the Framework that the given Relationship should be * considered "available", meaning that the queues of all Connections that * contain this Relationship are not full. This is generally used only when - * dealing with Processors that use the {@link nifi.processor.annotation.TriggerWhenAnyDestinationAvailable - * @TriggerWhenAnyDestinationAvailable} annotation. + * dealing with Processors that use the + * {@link nifi.processor.annotation.TriggerWhenAnyDestinationAvailable} + * annotation. * - * @param relationship + * @param relationship to mark as available */ void setRelationshipAvailable(Relationship relationship); @@ -429,9 +412,10 @@ public interface TestRunner { * Indicates to the Framework that the given Relationship with the given * name should be considered "available", meaning that the queues of all * Connections that contain this Relationship are not full. This is - * generally used only when dealing with Processors that use the {@link nifi.processor.annotation.TriggerWhenAnyDestinationAvailable - * @param relationshipName - * @TriggerWhenAnyDestinationAvailable} annotation. + * generally used only when dealing with Processors that use the + * {@link nifi.processor.annotation.TriggerWhenAnyDestinationAvailable} + * + * @param relationshipName relationship name */ void setRelationshipAvailable(String relationshipName); @@ -439,10 +423,11 @@ public interface TestRunner { * Indicates to the Framework that the given Relationship should NOT be * considered "available", meaning that the queue of at least one Connection * that contain this Relationship is full. This is generally used only when - * dealing with Processors that use the {@link nifi.processor.annotation.TriggerWhenAnyDestinationAvailable - * @TriggerWhenAnyDestinationAvailable} annotation. + * dealing with Processors that use the + * {@link nifi.processor.annotation.TriggerWhenAnyDestinationAvailable} + * annotation. * - * @param relationship + * @param relationship to mark as unavailable */ void setRelationshipUnavailable(Relationship relationship); @@ -450,9 +435,10 @@ public interface TestRunner { * Indicates to the Framework that the Relationship with the given name * should NOT be considered "available", meaning that the queue of at least * one Connection that contain this Relationship is full. This is generally - * used only when dealing with Processors that use the {@link nifi.processor.annotation.TriggerWhenAnyDestinationAvailable - * @param relationshipName - * @TriggerWhenAnyDestinationAvailable} annotation. + * used only when dealing with Processors that use the + * {@link nifi.processor.annotation.TriggerWhenAnyDestinationAvailable} + * + * @param relationshipName name of relationship. */ void setRelationshipUnavailable(String relationshipName); @@ -464,12 +450,13 @@ public interface TestRunner { * {@link nifi.controller.ControllerServiceInitializationContext ControllerServiceInitializationContext} * and initialize the ControllerService with no specified properties. * - * This will call any method on the given Controller Service that is annotated with - * the {@link org.apache.nifi.annotation.lifecycle.OnAdded @OnAdded} annotation. + * This will call any method on the given Controller Service that is + * annotated with the + * {@link org.apache.nifi.annotation.lifecycle.OnAdded @OnAdded} annotation. * - * @param identifier - * @param service - * @throws InitializationException + * @param identifier of service + * @param service the service + * @throws InitializationException ie */ void addControllerService(String identifier, ControllerService service) throws InitializationException; @@ -481,185 +468,206 @@ public interface TestRunner { * {@link nifi.controller.ControllerServiceInitializationContext ControllerServiceInitializationContext} * and initialize the ControllerService with the given properties. * - * This will call any method on the given Controller Service that is annotated with - * the {@link org.apache.nifi.annotation.lifecycle.OnAdded @OnAdded} annotation. - * - * @param identifier - * @param service - * @param properties - * @throws InitializationException + * This will call any method on the given Controller Service that is + * annotated with the + * {@link org.apache.nifi.annotation.lifecycle.OnAdded @OnAdded} annotation. + * + * @param identifier of service + * @param service the service + * @param properties service properties + * @throws InitializationException ie */ void addControllerService(String identifier, ControllerService service, Map<String, String> properties) throws InitializationException; /** * <p> - * Marks the Controller Service as enabled so that it can be used by other components. + * Marks the Controller Service as enabled so that it can be used by other + * components. * </p> - * + * * <p> - * This method will result in calling any method in the Controller Service that is - * annotated with the {@link org.apache.nifi.annotation.lifecycle.OnEnabled @OnEnabled} annotation. + * This method will result in calling any method in the Controller Service + * that is annotated with the + * {@link org.apache.nifi.annotation.lifecycle.OnEnabled @OnEnabled} + * annotation. * </p> - * - * @param service + * + * @param service the service to enable */ void enableControllerService(ControllerService service); - + /** * <p> - * Marks the Controller Service as disabled so that it cannot be used by other components. + * Marks the Controller Service as disabled so that it cannot be used by + * other components. * </p> - * + * * <p> - * This method will result in calling any method in the Controller Service that is - * annotated with the {@link org.apache.nifi.annotation.lifecycle.OnDisabled @OnDisabled} annotation. + * This method will result in calling any method in the Controller Service + * that is annotated with the + * {@link org.apache.nifi.annotation.lifecycle.OnDisabled @OnDisabled} + * annotation. * </p> - * - * @param service + * + * @param service the service to disable */ void disableControllerService(ControllerService service); - + /** - * <p> - * Returns {@code true} if the given Controller Service is enabled, {@code false} if it is disabled. - * </p> - * - * @param service - * @return - * - * @throws IllegalArgumentException if the given ControllerService is not known by this TestRunner - * (i.e., it has not been added via the {@link #addControllerService(String, ControllerService)} or - * {@link #addControllerService(String, ControllerService, Map)} method or if the Controller Service - * has been removed via the {@link #removeControllerService(ControllerService)} method. + * @param service the service + * @return {@code true} if the given Controller Service is enabled, + * {@code false} if it is disabled + * + * @throws IllegalArgumentException if the given ControllerService is not + * known by this TestRunner (i.e., it has not been added via the + * {@link #addControllerService(String, ControllerService)} or + * {@link #addControllerService(String, ControllerService, Map)} method or + * if the Controller Service has been removed via the + * {@link #removeControllerService(ControllerService)} method. */ boolean isControllerServiceEnabled(ControllerService service); - + /** * <p> - * Removes the Controller Service from the TestRunner. This will call any method on the ControllerService - * that is annotated with the {@link org.apache.nifi.annotation.lifecycle.OnRemoved @OnRemoved} annotation. + * Removes the Controller Service from the TestRunner. This will call any + * method on the ControllerService that is annotated with the + * {@link org.apache.nifi.annotation.lifecycle.OnRemoved @OnRemoved} + * annotation. * </p> - * - * @param service - * + * + * @param service the service + * * @throws IllegalStateException if the ControllerService is not disabled - * @throws IllegalArgumentException if the given ControllerService is not known by this TestRunner - * (i.e., it has not been added via the {@link #addControllerService(String, ControllerService)} or - * {@link #addControllerService(String, ControllerService, Map)} method or if the Controller Service - * has been removed via the {@link #removeControllerService(ControllerService)} method. - * + * @throws IllegalArgumentException if the given ControllerService is not + * known by this TestRunner (i.e., it has not been added via the + * {@link #addControllerService(String, ControllerService)} or + * {@link #addControllerService(String, ControllerService, Map)} method or + * if the Controller Service has been removed via the + * {@link #removeControllerService(ControllerService)} method. + * */ void removeControllerService(ControllerService service); - + /** * Sets the given property on the given ControllerService - * - * @param service - * @param property - * @param value - * + * + * @param service to modify + * @param property to modify + * @param value value to use + * @return result + * * @throws IllegalStateException if the ControllerService is not disabled - * @throws IllegalArgumentException if the given ControllerService is not known by this TestRunner - * (i.e., it has not been added via the {@link #addControllerService(String, ControllerService)} or - * {@link #addControllerService(String, ControllerService, Map)} method or if the Controller Service - * has been removed via the {@link #removeControllerService(ControllerService)} method. - * + * @throws IllegalArgumentException if the given ControllerService is not + * known by this TestRunner (i.e., it has not been added via the + * {@link #addControllerService(String, ControllerService)} or + * {@link #addControllerService(String, ControllerService, Map)} method or + * if the Controller Service has been removed via the + * {@link #removeControllerService(ControllerService)} method. + * */ ValidationResult setProperty(ControllerService service, PropertyDescriptor property, String value); - - + /** * Sets the given property on the given ControllerService - * - * @param service - * @param property - * @param value - * + * + * @param service to modify + * @param property to modify + * @param value value to use + * @return result + * * @throws IllegalStateException if the ControllerService is not disabled - * @throws IllegalArgumentException if the given ControllerService is not known by this TestRunner - * (i.e., it has not been added via the {@link #addControllerService(String, ControllerService)} or - * {@link #addControllerService(String, ControllerService, Map)} method or if the Controller Service - * has been removed via the {@link #removeControllerService(ControllerService)} method. - * + * @throws IllegalArgumentException if the given ControllerService is not + * known by this TestRunner (i.e., it has not been added via the + * {@link #addControllerService(String, ControllerService)} or + * {@link #addControllerService(String, ControllerService, Map)} method or + * if the Controller Service has been removed via the + * {@link #removeControllerService(ControllerService)} method. + * */ ValidationResult setProperty(ControllerService service, PropertyDescriptor property, AllowableValue value); - - + /** * Sets the property with the given name on the given ControllerService - * - * @param service - * @param property - * @param value - * + * + * @param service to modify + * @param propertyName to modify + * @param value value to use + * @return result + * * @throws IllegalStateException if the ControllerService is not disabled - * @throws IllegalArgumentException if the given ControllerService is not known by this TestRunner - * (i.e., it has not been added via the {@link #addControllerService(String, ControllerService)} or - * {@link #addControllerService(String, ControllerService, Map)} method or if the Controller Service - * has been removed via the {@link #removeControllerService(ControllerService)} method. - * + * @throws IllegalArgumentException if the given ControllerService is not + * known by this TestRunner (i.e., it has not been added via the + * {@link #addControllerService(String, ControllerService)} or + * {@link #addControllerService(String, ControllerService, Map)} method or + * if the Controller Service has been removed via the + * {@link #removeControllerService(ControllerService)} method. + * */ ValidationResult setProperty(ControllerService service, String propertyName, String value); - + /** - * Sets the annontation data of the given service to the provided annotation data. + * Sets the annontation data of the given service to the provided annotation + * data. + * + * @param service to modify + * @param annotationData the data * - * @param service - * @param annotationData - * * @throws IllegalStateException if the Controller Service is not disabled * - * @throws IllegalArgumentException if the given ControllerService is not known by this TestRunner - * (i.e., it has not been added via the {@link #addControllerService(String, ControllerService)} or - * {@link #addControllerService(String, ControllerService, Map)} method or if the Controller Service - * has been removed via the {@link #removeControllerService(ControllerService)} method. + * @throws IllegalArgumentException if the given ControllerService is not + * known by this TestRunner (i.e., it has not been added via the + * {@link #addControllerService(String, ControllerService)} or + * {@link #addControllerService(String, ControllerService, Map)} method or + * if the Controller Service has been removed via the + * {@link #removeControllerService(ControllerService)} method. */ void setAnnotationData(ControllerService service, String annotationData); - /** - * Returns the {@link ControllerService} that is registered with the given + * @param identifier of controller service + * @return the {@link ControllerService} that is registered with the given * identifier, or <code>null</code> if no Controller Service exists with the * given identifier - * - * @param identifier - * @return */ ControllerService getControllerService(String identifier); /** * Assert that the currently configured set of properties/annotation data * are valid for the given Controller Service. - * - * @throws IllegalArgumentException if the given ControllerService is not known by this TestRunner - * (i.e., it has not been added via the {@link #addControllerService(String, ControllerService)} or - * {@link #addControllerService(String, ControllerService, Map)} method or if the Controller Service - * has been removed via the {@link #removeControllerService(ControllerService)} method. + * + * @param service the service to validate + * @throws IllegalArgumentException if the given ControllerService is not + * known by this TestRunner (i.e., it has not been added via the + * {@link #addControllerService(String, ControllerService)} or + * {@link #addControllerService(String, ControllerService, Map)} method or + * if the Controller Service has been removed via the + * {@link #removeControllerService(ControllerService)} method. */ void assertValid(ControllerService service); /** * Assert that the currently configured set of properties/annotation data * are NOT valid for the given Controller Service. - * - * @throws IllegalArgumentException if the given ControllerService is not known by this TestRunner - * (i.e., it has not been added via the {@link #addControllerService(String, ControllerService)} or - * {@link #addControllerService(String, ControllerService, Map)} method or if the Controller Service - * has been removed via the {@link #removeControllerService(ControllerService)} method. - * + * + * @param service the service to validate + * @throws IllegalArgumentException if the given ControllerService is not + * known by this TestRunner (i.e., it has not been added via the + * {@link #addControllerService(String, ControllerService)} or + * {@link #addControllerService(String, ControllerService, Map)} method or + * if the Controller Service has been removed via the + * {@link #removeControllerService(ControllerService)} method. + * */ void assertNotValid(ControllerService service); /** - * Returns the {@link ControllerService} that is registered with the given + * @param <T> type of service + * @param identifier identifier of service + * @param serviceType type of service + * @return the {@link ControllerService} that is registered with the given * identifier, cast as the provided service type, or <code>null</code> if no * Controller Service exists with the given identifier * - * @param <T> - * @param identifier - * @param serviceType - * @return - * * @throws ClassCastException if the identifier given is registered for a * Controller Service but that Controller Service is not of the type * specified @@ -682,7 +690,7 @@ public interface TestRunner { * </b>{@link PropertyDescriptor.Builder#expressionLanguageSupported(boolean)} * </p> * - * @param validate + * @param validate whether there is any need to validate the EL was used */ void setValidateExpressionUsage(boolean validate); @@ -690,8 +698,8 @@ public interface TestRunner { * Removes the {@link PropertyDescriptor} from the {@link ProcessContext}, * effectively setting its value to null. * - * @param descriptor - * @return + * @param descriptor of property to remove + * @return true if removed */ boolean removeProperty(PropertyDescriptor descriptor); }
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/b612b6bc/nifi/nifi-mock/src/test/java/org/apache/nifi/util/TestStandardProcessorTestRunner.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-mock/src/test/java/org/apache/nifi/util/TestStandardProcessorTestRunner.java b/nifi/nifi-mock/src/test/java/org/apache/nifi/util/TestStandardProcessorTestRunner.java index a561982..323a357 100644 --- a/nifi/nifi-mock/src/test/java/org/apache/nifi/util/TestStandardProcessorTestRunner.java +++ b/nifi/nifi-mock/src/test/java/org/apache/nifi/util/TestStandardProcessorTestRunner.java @@ -26,61 +26,63 @@ import org.junit.Test; @Ignore("This should not be enabled until we actually fail processor unit tests for using deprecated methods, which should happen in 0.1.0") public class TestStandardProcessorTestRunner { - @Test(expected=AssertionError.class) + @Test(expected = AssertionError.class) public void testFailOnDeprecatedTypeAnnotation() { new StandardProcessorTestRunner(new DeprecatedAnnotation()); } - + @Test public void testDoesNotFailOnNonDeprecatedTypeAnnotation() { new StandardProcessorTestRunner(new NewAnnotation()); } - - @Test(expected=AssertionError.class) + + @Test(expected = AssertionError.class) public void testFailOnDeprecatedMethodAnnotation() { new StandardProcessorTestRunner(new DeprecatedMethodAnnotation()); } - + @Test public void testDoesNotFailOnNonDeprecatedMethodAnnotation() { new StandardProcessorTestRunner(new NewMethodAnnotation()); } - - @SuppressWarnings("deprecation") @org.apache.nifi.processor.annotation.Tags({"deprecated"}) private static class DeprecatedAnnotation extends AbstractProcessor { + @Override public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { } } - + @org.apache.nifi.annotation.documentation.Tags({"deprecated"}) private static class NewAnnotation extends AbstractProcessor { + @Override public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { } } - + private static class NewMethodAnnotation extends AbstractProcessor { + @org.apache.nifi.annotation.lifecycle.OnScheduled public void dummy() { - + } - + @Override public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { } } - + private static class DeprecatedMethodAnnotation extends AbstractProcessor { + @SuppressWarnings("deprecation") @org.apache.nifi.processor.annotation.OnScheduled public void dummy() { - + } - + @Override public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/b612b6bc/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/DocGenerator.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/DocGenerator.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/DocGenerator.java index 8a53f00..ea033c5 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/DocGenerator.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/DocGenerator.java @@ -54,7 +54,7 @@ public class DocGenerator { * Generates documentation into the work/docs dir specified by * NiFiProperties. * - * @param properties + * @param properties to lookup nifi properties */ public static void generate(final NiFiProperties properties) { @SuppressWarnings("rawtypes") @@ -90,10 +90,10 @@ public class DocGenerator { * @param docsDir the work\docs\components dir to stick component * documentation in * @param componentClass the class to document - * @throws InstantiationException - * @throws IllegalAccessException - * @throws IOException - * @throws InitializationException + * @throws InstantiationException ie + * @throws IllegalAccessException iae + * @throws IOException ioe + * @throws InitializationException ie */ private static void document(final File docsDir, final Class<? extends ConfigurableComponent> componentClass) throws InstantiationException, IllegalAccessException, IOException, InitializationException { @@ -163,7 +163,7 @@ public class DocGenerator { * Checks to see if a directory to write to has an additionalDetails.html in * it already. * - * @param directory + * @param directory to check * @return true if additionalDetails.html exists, false otherwise. */ private static boolean hasAdditionalInfo(File directory) { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/b612b6bc/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java index 243aaa3..a86a416 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java @@ -72,13 +72,11 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * Writes the head portion of the HTML documentation. - * - * @param configurableComponent - * the component to describe - * @param xmlStreamWriter - * the stream to write to - * @throws XMLStreamException - * thrown if there was a problem writing to the stream + * + * @param configurableComponent the component to describe + * @param xmlStreamWriter the stream to write to + * @throws XMLStreamException thrown if there was a problem writing to the + * stream */ protected void writeHead(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { @@ -99,9 +97,8 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * Gets the class name of the component. - * - * @param configurableComponent - * the component to describe + * + * @param configurableComponent the component to describe * @return the class name of the component */ protected String getTitle(final ConfigurableComponent configurableComponent) { @@ -111,15 +108,13 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * Writes the body section of the documentation, this consists of the * component description, the tags, and the PropertyDescriptors. - * - * @param configurableComponent - * the component to describe - * @param xmlStreamWriter - * the stream writer - * @param hasAdditionalDetails - * whether there are additional details present or not - * @throws XMLStreamException - * thrown if there was a problem writing to the XML stream + * + * @param configurableComponent the component to describe + * @param xmlStreamWriter the stream writer + * @param hasAdditionalDetails whether there are additional details present + * or not + * @throws XMLStreamException thrown if there was a problem writing to the + * XML stream */ private void writeBody(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter, final boolean hasAdditionalDetails) @@ -136,13 +131,10 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * Writes the list of components that may be linked from this component. - * - * @param configurableComponent - * the component to describe - * @param xmlStreamWriter - * the stream writer to use - * @throws XMLStreamException - * thrown if there was a problem writing the XML + * + * @param configurableComponent the component to describe + * @param xmlStreamWriter the stream writer to use + * @throws XMLStreamException thrown if there was a problem writing the XML */ private void writeSeeAlso(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter) throws XMLStreamException { @@ -162,7 +154,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter { ++index; } - + for (final String linkedComponent : seeAlso.classNames()) { if (index != 0) { xmlStreamWriter.writeCharacters(", "); @@ -171,7 +163,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter { final String link = "../" + linkedComponent + "/index.html"; final int indexOfLastPeriod = linkedComponent.lastIndexOf(".") + 1; - + writeLink(xmlStreamWriter, linkedComponent.substring(indexOfLastPeriod), link); ++index; @@ -183,26 +175,17 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * This method may be overridden by sub classes to write additional * information to the body of the documentation. - * - * @param configurableComponent - * the component to describe - * @param xmlStreamWriter - * the stream writer - * @throws XMLStreamException - * thrown if there was a problem writing to the XML stream + * + * @param configurableComponent the component to describe + * @param xmlStreamWriter the stream writer + * @throws XMLStreamException thrown if there was a problem writing to the + * XML stream */ protected void writeAdditionalBodyInfo(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { } - /** - * Writes the tags attached to a ConfigurableComponent. - * - * @param configurableComponent - * @param xmlStreamWriter - * @throws XMLStreamException - */ private void writeTags(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { final Tags tags = configurableComponent.getClass().getAnnotation(Tags.class); @@ -218,30 +201,27 @@ public class HtmlDocumentationWriter implements DocumentationWriter { } xmlStreamWriter.writeEndElement(); } - + static String join(final String[] toJoin, final String delimiter) { - final StringBuilder sb = new StringBuilder(); - for (int i=0; i < toJoin.length; i++) { - sb.append(toJoin[i]); - if ( i < toJoin.length - 1 ) { - sb.append(delimiter); - } - } - return sb.toString(); + final StringBuilder sb = new StringBuilder(); + for (int i = 0; i < toJoin.length; i++) { + sb.append(toJoin[i]); + if (i < toJoin.length - 1) { + sb.append(delimiter); + } + } + return sb.toString(); } /** * Writes a description of the configurable component. - * - * @param configurableComponent - * the component to describe - * @param xmlStreamWriter - * the stream writer - * @param hasAdditionalDetails - * whether there are additional details available as - * 'additionalDetails.html' - * @throws XMLStreamException - * thrown if there was a problem writing to the XML stream + * + * @param configurableComponent the component to describe + * @param xmlStreamWriter the stream writer + * @param hasAdditionalDetails whether there are additional details + * available as 'additionalDetails.html' + * @throws XMLStreamException thrown if there was a problem writing to the + * XML stream */ protected void writeDescription(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter, final boolean hasAdditionalDetails) @@ -260,9 +240,8 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * Gets a description of the ConfigurableComponent using the * CapabilityDescription annotation. - * - * @param configurableComponent - * the component to describe + * + * @param configurableComponent the component to describe * @return a description of the configurableComponent */ protected String getDescription(final ConfigurableComponent configurableComponent) { @@ -281,13 +260,11 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * Writes the PropertyDescriptors out as a table. - * - * @param configurableComponent - * the component to describe - * @param xmlStreamWriter - * the stream writer - * @throws XMLStreamException - * thrown if there was a problem writing to the XML Stream + * + * @param configurableComponent the component to describe + * @param xmlStreamWriter the stream writer + * @throws XMLStreamException thrown if there was a problem writing to the + * XML Stream */ protected void writeProperties(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { @@ -367,13 +344,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter { writeSimpleElement(xmlStreamWriter, "p", "This component has no required or optional properties."); } } - - /** - * Writes a list of the dynamic properties that a processor supports - * @param configurableComponent - * @param xmlStreamWriter - * @throws XMLStreamException - */ + private void writeDynamicProperties(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { @@ -392,7 +363,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter { writeSimpleElement(xmlStreamWriter, "th", "Description"); xmlStreamWriter.writeEndElement(); for (final DynamicProperty dynamicProperty : dynamicProperties) { - xmlStreamWriter.writeStartElement("tr"); + xmlStreamWriter.writeStartElement("tr"); writeSimpleElement(xmlStreamWriter, "td", dynamicProperty.name(), false, "name"); writeSimpleElement(xmlStreamWriter, "td", dynamicProperty.value(), false, "value"); xmlStreamWriter.writeStartElement("td"); @@ -404,17 +375,12 @@ public class HtmlDocumentationWriter implements DocumentationWriter { xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); } - + xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); } } - /** - * Gets the dynamic properties for a configurable component - * @param configurableComponent - * @return - */ private List<DynamicProperty> getDynamicProperties(ConfigurableComponent configurableComponent) { final List<DynamicProperty> dynamicProperties = new ArrayList<>(); final DynamicProperties dynProps = configurableComponent.getClass().getAnnotation(DynamicProperties.class); @@ -423,22 +389,15 @@ public class HtmlDocumentationWriter implements DocumentationWriter { dynamicProperties.add(dynProp); } } - + final DynamicProperty dynProp = configurableComponent.getClass().getAnnotation(DynamicProperty.class); if (dynProp != null) { dynamicProperties.add(dynProp); } - + return dynamicProperties; } - /** - * Writes an info icon with a description. - * - * @param xmlStreamWriter - * @param description the description of the item - * @throws XMLStreamException - */ private void writeValidValueDescription(XMLStreamWriter xmlStreamWriter, String description) throws XMLStreamException { xmlStreamWriter.writeCharacters(" "); @@ -453,13 +412,11 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * Interrogates a PropertyDescriptor to get a list of AllowableValues, if * there are none, nothing is written to the stream. - * - * @param xmlStreamWriter - * the stream writer to use - * @param property - * the property to describe - * @throws XMLStreamException - * thrown if there was a problem writing to the XML Stream + * + * @param xmlStreamWriter the stream writer to use + * @param property the property to describe + * @throws XMLStreamException thrown if there was a problem writing to the + * XML Stream */ protected void writeValidValues(XMLStreamWriter xmlStreamWriter, PropertyDescriptor property) throws XMLStreamException { @@ -489,40 +446,38 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * Writes a begin element, then text, then end element for the element of a * users choosing. Example: <p>text</p> - * - * @param writer - * the stream writer to use - * @param elementName - * the name of the element - * @param characters - * the characters to insert into the element - * @param strong - * whether the characters should be strong or not. - * @throws XMLStreamException - * thrown if there was a problem writing to the stream. + * + * @param writer the stream writer to use + * @param elementName the name of the element + * @param characters the characters to insert into the element + * @param strong whether the characters should be strong or not. + * @throws XMLStreamException thrown if there was a problem writing to the + * stream. */ protected final static void writeSimpleElement(final XMLStreamWriter writer, final String elementName, final String characters, boolean strong) throws XMLStreamException { - writeSimpleElement(writer, elementName, characters, strong, null); + writeSimpleElement(writer, elementName, characters, strong, null); } - + /** - * Writes a begin element, an id attribute(if specified), then text, then end element for - * element of the users choosing. Example: <p id="p-id">text</p> - * + * Writes a begin element, an id attribute(if specified), then text, then + * end element for element of the users choosing. Example: <p + * id="p-id">text</p> + * * @param writer the stream writer to use * @param elementName the name of the element * @param characters the text of the element * @param strong whether to bold the text of the element or not - * @param id the id of the element. specifying null will cause no element to be written. - * @throws XMLStreamException + * @param id the id of the element. specifying null will cause no element to + * be written. + * @throws XMLStreamException xse */ protected final static void writeSimpleElement(final XMLStreamWriter writer, final String elementName, final String characters, boolean strong, String id) throws XMLStreamException { - writer.writeStartElement(elementName); - if (id != null) { - writer.writeAttribute("id", id); - } + writer.writeStartElement(elementName); + if (id != null) { + writer.writeAttribute("id", id); + } if (strong) { writer.writeStartElement("strong"); } @@ -536,15 +491,12 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * Writes a begin element, then text, then end element for the element of a * users choosing. Example: <p>text</p> - * - * @param writer - * the stream writer to use - * @param elementName - * the name of the element - * @param characters - * the characters to insert into the element - * @throws XMLStreamException - * thrown if there was a problem writing to the stream + * + * @param writer the stream writer to use + * @param elementName the name of the element + * @param characters the characters to insert into the element + * @throws XMLStreamException thrown if there was a problem writing to the + * stream */ protected final static void writeSimpleElement(final XMLStreamWriter writer, final String elementName, final String characters) throws XMLStreamException { @@ -553,15 +505,12 @@ public class HtmlDocumentationWriter implements DocumentationWriter { /** * A helper method to write a link - * - * @param xmlStreamWriter - * the stream to write to - * @param text - * the text of the link - * @param location - * the location of the link - * @throws XMLStreamException - * thrown if there was a problem writing to the stream + * + * @param xmlStreamWriter the stream to write to + * @param text the text of the link + * @param location the location of the link + * @throws XMLStreamException thrown if there was a problem writing to the + * stream */ protected void writeLink(final XMLStreamWriter xmlStreamWriter, final String text, final String location) throws XMLStreamException { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/b612b6bc/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java index c253a4d..4a15b50 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java @@ -51,13 +51,10 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { /** * Writes all the attributes that a processor says it reads and writes - * - * @param processor - * the processor to describe - * @param xmlStreamWriter - * the xml stream writer to use - * @throws XMLStreamException - * thrown if there was a problem writing the XML + * + * @param processor the processor to describe + * @param xmlStreamWriter the xml stream writer to use + * @throws XMLStreamException thrown if there was a problem writing the XML */ private void writeAttributeInfo(Processor processor, XMLStreamWriter xmlStreamWriter) throws XMLStreamException { @@ -67,20 +64,18 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { } private String defaultIfBlank(final String test, final String defaultValue) { - if ( test == null || test.trim().isEmpty() ) { - return defaultValue; - } - return test; + if (test == null || test.trim().isEmpty()) { + return defaultValue; + } + return test; } - + /** * Writes out just the attributes that are being read in a table form. - * - * @param xmlStreamWriter - * the xml stream writer to use - * @param processor - * the processor to describe - * @throws XMLStreamException + * + * @param xmlStreamWriter the xml stream writer to use + * @param processor the processor to describe + * @throws XMLStreamException xse */ private void handleReadsAttributes(XMLStreamWriter xmlStreamWriter, final Processor processor) throws XMLStreamException { @@ -102,7 +97,7 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { writeSimpleElement(xmlStreamWriter, "td", defaultIfBlank(attribute.description(), "Not Specified")); xmlStreamWriter.writeEndElement(); - + } xmlStreamWriter.writeEndElement(); @@ -113,12 +108,10 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { /** * Writes out just the attributes that are being written to in a table form. - * - * @param xmlStreamWriter - * the xml stream writer to use - * @param processor - * the processor to describe - * @throws XMLStreamException + * + * @param xmlStreamWriter the xml stream writer to use + * @param processor the processor to describe + * @throws XMLStreamException xse */ private void handleWritesAttributes(XMLStreamWriter xmlStreamWriter, final Processor processor) throws XMLStreamException { @@ -150,9 +143,8 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { /** * Collects the attributes that a processor is reading from. - * - * @param processor - * the processor to describe + * + * @param processor the processor to describe * @return the list of attributes that processor is reading */ private List<ReadsAttribute> getReadsAttributes(Processor processor) { @@ -173,9 +165,8 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { /** * Collects the attributes that a processor is writing to. - * - * @param processor - * the processor to describe + * + * @param processor the processor to describe * @return the list of attributes the processor is writing */ private List<WritesAttribute> getWritesAttributes(Processor processor) { @@ -196,13 +187,10 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { /** * Writes a table describing the relations a processor has. - * - * @param processor - * the processor to describe - * @param xmlStreamWriter - * the stream writer to use - * @throws XMLStreamException - * thrown if there was a problem writing the xml + * + * @param processor the processor to describe + * @param xmlStreamWriter the stream writer to use + * @throws XMLStreamException thrown if there was a problem writing the xml */ private void writeRelationships(final Processor processor, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { @@ -229,15 +217,8 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { } } - /** - * Writes dynamic relationship information - * - * @param processor - * @param xmlStreamWriter - * @throws XMLStreamException - */ private void writeDynamicRelationships(final Processor processor, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { - + List<DynamicRelationship> dynamicRelationships = getDynamicRelationships(processor); if (dynamicRelationships.size() > 0) { @@ -264,12 +245,12 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter { private List<DynamicRelationship> getDynamicRelationships(Processor processor) { List<DynamicRelationship> results = new ArrayList<>(); - + DynamicRelationship dynamicRelationships = processor.getClass().getAnnotation(DynamicRelationship.class); if (dynamicRelationships != null) { results.add(dynamicRelationships); } - + return results; } } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/b612b6bc/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedControllerService.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedControllerService.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedControllerService.java index c27f3ba..4320c6e 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedControllerService.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedControllerService.java @@ -27,31 +27,32 @@ import org.apache.nifi.controller.AbstractControllerService; import org.apache.nifi.processor.util.StandardValidators; @CapabilityDescription("A documented controller service that can help you do things") -@Tags({ "one", "two", "three" }) +@Tags({"one", "two", "three"}) public class FullyDocumentedControllerService extends AbstractControllerService { - public static final PropertyDescriptor KEYSTORE = new PropertyDescriptor.Builder().name("Keystore Filename") - .description("The fully-qualified filename of the Keystore").defaultValue(null) - .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR).sensitive(false).build(); - public static final PropertyDescriptor KEYSTORE_TYPE = new PropertyDescriptor.Builder().name("Keystore Type") - .description("The Type of the Keystore").allowableValues("JKS", "PKCS12") - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).defaultValue("JKS").sensitive(false).build(); - public static final PropertyDescriptor KEYSTORE_PASSWORD = new PropertyDescriptor.Builder() - .name("Keystore Password").defaultValue(null).description("The password for the Keystore") - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).sensitive(true).build(); - - private static final List<PropertyDescriptor> properties; - - static { - List<PropertyDescriptor> props = new ArrayList<>(); - props.add(KEYSTORE); - props.add(KEYSTORE_PASSWORD); - props.add(KEYSTORE_TYPE); - properties = Collections.unmodifiableList(props); - } - - @Override - protected List<PropertyDescriptor> getSupportedPropertyDescriptors() { - return properties; - } + + public static final PropertyDescriptor KEYSTORE = new PropertyDescriptor.Builder().name("Keystore Filename") + .description("The fully-qualified filename of the Keystore").defaultValue(null) + .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR).sensitive(false).build(); + public static final PropertyDescriptor KEYSTORE_TYPE = new PropertyDescriptor.Builder().name("Keystore Type") + .description("The Type of the Keystore").allowableValues("JKS", "PKCS12") + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).defaultValue("JKS").sensitive(false).build(); + public static final PropertyDescriptor KEYSTORE_PASSWORD = new PropertyDescriptor.Builder() + .name("Keystore Password").defaultValue(null).description("The password for the Keystore") + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).sensitive(true).build(); + + private static final List<PropertyDescriptor> properties; + + static { + List<PropertyDescriptor> props = new ArrayList<>(); + props.add(KEYSTORE); + props.add(KEYSTORE_PASSWORD); + props.add(KEYSTORE_TYPE); + properties = Collections.unmodifiableList(props); + } + + @Override + protected List<PropertyDescriptor> getSupportedPropertyDescriptors() { + return properties; + } } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/b612b6bc/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java index cc59733..178a144 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java @@ -40,82 +40,90 @@ import org.apache.nifi.processor.Relationship; import org.apache.nifi.processor.exception.ProcessException; import org.apache.nifi.processor.util.StandardValidators; -@Tags({ "one", "two", "three" }) +@Tags({"one", "two", "three"}) @CapabilityDescription("This is a processor that is used to test documentation.") -@WritesAttributes({@WritesAttribute(attribute="first", description="this is the first attribute i write"), @WritesAttribute(attribute="second")}) -@ReadsAttribute(attribute = "incoming", description="this specifies the format of the thing") -@SeeAlso(value={FullyDocumentedControllerService.class, FullyDocumentedReportingTask.class}, classNames={"org.apache.nifi.processor.ExampleProcessor"}) -@DynamicProperty(name="Relationship Name", supportsExpressionLanguage=true, value="some XPath", description="Routes FlowFiles to relationships based on XPath") -@DynamicRelationship(name="name from dynamic property", description="all files that match the properties XPath") +@WritesAttributes({ + @WritesAttribute(attribute = "first", description = "this is the first attribute i write"), + @WritesAttribute(attribute = "second")}) +@ReadsAttribute(attribute = "incoming", description = "this specifies the format of the thing") +@SeeAlso(value = {FullyDocumentedControllerService.class, FullyDocumentedReportingTask.class}, classNames = {"org.apache.nifi.processor.ExampleProcessor"}) +@DynamicProperty(name = "Relationship Name", supportsExpressionLanguage = true, value = "some XPath", description = "Routes FlowFiles to relationships based on XPath") +@DynamicRelationship(name = "name from dynamic property", description = "all files that match the properties XPath") public class FullyDocumentedProcessor extends AbstractProcessor { - public static final PropertyDescriptor DIRECTORY = new PropertyDescriptor.Builder().name("Input Directory") - .description("The input directory from which to pull files").required(true) - .addValidator(StandardValidators.createDirectoryExistsValidator(true, false)) - .expressionLanguageSupported(true).build(); - - public static final PropertyDescriptor RECURSE = new PropertyDescriptor.Builder().name("Recurse Subdirectories") - .description("Indicates whether or not to pull files from subdirectories").required(true) - .allowableValues(new AllowableValue("true", "true", "Should pull from sub directories"), new AllowableValue("false", "false", "Should not pull from sub directories")).defaultValue("true").build(); - - public static final PropertyDescriptor POLLING_INTERVAL = new PropertyDescriptor.Builder().name("Polling Interval") - .description("Indicates how long to wait before performing a directory listing").required(true) - .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).defaultValue("0 sec").build(); - - public static final PropertyDescriptor OPTIONAL_PROPERTY = new PropertyDescriptor.Builder() - .name("Optional Property").description("This is a property you can use or not").required(false).build(); - - public static final PropertyDescriptor TYPE_PROPERTY = new PropertyDescriptor.Builder() - .name("Type").description("This is the type of something that you can choose. It has several possible values").allowableValues("yes", "no", "maybe", "possibly", "not likely", "longer option name").required(true).build(); - - public static final PropertyDescriptor SERVICE_PROPERTY = new PropertyDescriptor.Builder() - .name("Controller Service").description("This is the controller service to use to do things") - .identifiesControllerService(SampleService.class).required(true).build(); - - public static final Relationship REL_SUCCESS = new Relationship.Builder().name("success") - .description("Successful files").build(); - public static final Relationship REL_FAILURE = new Relationship.Builder().name("failure") - .description("Failing files").build(); - - private List<PropertyDescriptor> properties; - private Set<Relationship> relationships; - - @Override - protected void init(ProcessorInitializationContext context) { - final List<PropertyDescriptor> properties = new ArrayList<>(); - properties.add(DIRECTORY); - properties.add(RECURSE); - properties.add(POLLING_INTERVAL); - properties.add(OPTIONAL_PROPERTY); - properties.add(TYPE_PROPERTY); - properties.add(SERVICE_PROPERTY); - this.properties = Collections.unmodifiableList(properties); - - final Set<Relationship> relationships = new HashSet<>(); - relationships.add(REL_SUCCESS); - relationships.add(REL_FAILURE); - this.relationships = Collections.unmodifiableSet(relationships); - } - - @Override - protected List<PropertyDescriptor> getSupportedPropertyDescriptors() { - return properties; - } - - @Override - public Set<Relationship> getRelationships() { - return relationships; - } - - @Override - public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { - - } - - @Override - protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) { - return new PropertyDescriptor.Builder().name(propertyDescriptorName) - .description("This is a property you can use or not").dynamic(true).build(); - } + public static final PropertyDescriptor DIRECTORY = new PropertyDescriptor.Builder().name("Input Directory") + .description("The input directory from which to pull files").required(true) + .addValidator(StandardValidators.createDirectoryExistsValidator(true, false)) + .expressionLanguageSupported(true).build(); + + public static final PropertyDescriptor RECURSE = new PropertyDescriptor.Builder().name("Recurse Subdirectories") + .description("Indicates whether or not to pull files from subdirectories").required(true) + .allowableValues( + new AllowableValue("true", "true", "Should pull from sub directories"), + new AllowableValue("false", "false", "Should not pull from sub directories") + ).defaultValue("true").build(); + + public static final PropertyDescriptor POLLING_INTERVAL = new PropertyDescriptor.Builder().name("Polling Interval") + .description("Indicates how long to wait before performing a directory listing").required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR).defaultValue("0 sec").build(); + + public static final PropertyDescriptor OPTIONAL_PROPERTY = new PropertyDescriptor.Builder() + .name("Optional Property").description("This is a property you can use or not").required(false).build(); + + public static final PropertyDescriptor TYPE_PROPERTY = new PropertyDescriptor.Builder() + .name("Type") + .description("This is the type of something that you can choose. It has several possible values") + .allowableValues("yes", "no", "maybe", "possibly", "not likely", "longer option name") + .required(true).build(); + + public static final PropertyDescriptor SERVICE_PROPERTY = new PropertyDescriptor.Builder() + .name("Controller Service").description("This is the controller service to use to do things") + .identifiesControllerService(SampleService.class).required(true).build(); + + public static final Relationship REL_SUCCESS = new Relationship.Builder().name("success") + .description("Successful files").build(); + public static final Relationship REL_FAILURE = new Relationship.Builder().name("failure") + .description("Failing files").build(); + + private List<PropertyDescriptor> properties; + private Set<Relationship> relationships; + + @Override + protected void init(ProcessorInitializationContext context) { + final List<PropertyDescriptor> properties = new ArrayList<>(); + properties.add(DIRECTORY); + properties.add(RECURSE); + properties.add(POLLING_INTERVAL); + properties.add(OPTIONAL_PROPERTY); + properties.add(TYPE_PROPERTY); + properties.add(SERVICE_PROPERTY); + this.properties = Collections.unmodifiableList(properties); + + final Set<Relationship> relationships = new HashSet<>(); + relationships.add(REL_SUCCESS); + relationships.add(REL_FAILURE); + this.relationships = Collections.unmodifiableSet(relationships); + } + + @Override + protected List<PropertyDescriptor> getSupportedPropertyDescriptors() { + return properties; + } + + @Override + public Set<Relationship> getRelationships() { + return relationships; + } + + @Override + public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { + + } + + @Override + protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) { + return new PropertyDescriptor.Builder().name(propertyDescriptorName) + .description("This is a property you can use or not").dynamic(true).build(); + } } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/b612b6bc/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedReportingTask.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedReportingTask.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedReportingTask.java index 275905b..17e446a 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedReportingTask.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedReportingTask.java @@ -26,25 +26,25 @@ import org.apache.nifi.reporting.AbstractReportingTask; import org.apache.nifi.reporting.ReportingContext; @CapabilityDescription("A helper reporting task to do...") -@Tags({ "first", "second", "third" }) +@Tags({"first", "second", "third"}) public class FullyDocumentedReportingTask extends AbstractReportingTask { - public static final PropertyDescriptor SHOW_DELTAS = new PropertyDescriptor.Builder() - .name("Show Deltas") - .description( - "Specifies whether or not to show the difference in values between the current status and the previous status") - .required(true).allowableValues("true", "false").defaultValue("true").build(); + public static final PropertyDescriptor SHOW_DELTAS = new PropertyDescriptor.Builder() + .name("Show Deltas") + .description( + "Specifies whether or not to show the difference in values between the current status and the previous status") + .required(true).allowableValues("true", "false").defaultValue("true").build(); - @Override - public final List<PropertyDescriptor> getSupportedPropertyDescriptors() { - final List<PropertyDescriptor> descriptors = new ArrayList<>(); - descriptors.add(SHOW_DELTAS); - return descriptors; - } + @Override + public final List<PropertyDescriptor> getSupportedPropertyDescriptors() { + final List<PropertyDescriptor> descriptors = new ArrayList<>(); + descriptors.add(SHOW_DELTAS); + return descriptors; + } - @Override - public void onTrigger(ReportingContext context) { - // TODO Auto-generated method stub + @Override + public void onTrigger(ReportingContext context) { + // TODO Auto-generated method stub - } + } } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/b612b6bc/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/NakedProcessor.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/NakedProcessor.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/NakedProcessor.java index ee7f315..e288f0a 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/NakedProcessor.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/NakedProcessor.java @@ -23,9 +23,9 @@ import org.apache.nifi.processor.exception.ProcessException; public class NakedProcessor extends AbstractProcessor { - @Override - public void onTrigger(ProcessContext arg0, ProcessSession arg1) throws ProcessException { - - } + @Override + public void onTrigger(ProcessContext arg0, ProcessSession arg1) throws ProcessException { + + } } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/b612b6bc/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/SampleService.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/SampleService.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/SampleService.java index 6224364..6f84c15 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/SampleService.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/SampleService.java @@ -20,6 +20,6 @@ import org.apache.nifi.controller.ControllerService; public interface SampleService extends ControllerService { - public void doSomething(); + public void doSomething(); } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/b612b6bc/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java index 90ff09f..e897262 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/html/HtmlDocumentationWriterTest.java @@ -34,68 +34,68 @@ import static org.junit.Assert.assertEquals; public class HtmlDocumentationWriterTest { - @Test - public void testJoin() { - assertEquals("a, b, c", HtmlDocumentationWriter.join(new String[] {"a", "b", "c"}, ", ")); - assertEquals("a, b", HtmlDocumentationWriter.join(new String[] {"a", "b"}, ", ")); - assertEquals("a", HtmlDocumentationWriter.join(new String[] {"a"}, ", ")); - } - - @Test - public void testDocumentControllerService() throws InitializationException, IOException { + @Test + public void testJoin() { + assertEquals("a, b, c", HtmlDocumentationWriter.join(new String[]{"a", "b", "c"}, ", ")); + assertEquals("a, b", HtmlDocumentationWriter.join(new String[]{"a", "b"}, ", ")); + assertEquals("a", HtmlDocumentationWriter.join(new String[]{"a"}, ", ")); + } - ControllerService controllerService = new FullyDocumentedControllerService(); - controllerService.initialize(new MockControllerServiceInitializationContext()); + @Test + public void testDocumentControllerService() throws InitializationException, IOException { - DocumentationWriter writer = new HtmlDocumentationWriter(); + ControllerService controllerService = new FullyDocumentedControllerService(); + controllerService.initialize(new MockControllerServiceInitializationContext()); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DocumentationWriter writer = new HtmlDocumentationWriter(); - writer.write(controllerService, baos, false); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); - String results = new String(baos.toByteArray()); - XmlValidator.assertXmlValid(results); + writer.write(controllerService, baos, false); - // description - assertContains(results, "A documented controller service that can help you do things"); + String results = new String(baos.toByteArray()); + XmlValidator.assertXmlValid(results); - // tags - assertContains(results, "one, two, three"); + // description + assertContains(results, "A documented controller service that can help you do things"); - // 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"); - } + // tags + assertContains(results, "one, two, three"); - @Test - public void testDocumentReportingTask() throws InitializationException, IOException { + // 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"); + } - ReportingTask reportingTask = new FullyDocumentedReportingTask(); - reportingTask.initialize(new MockReportingInitializationContext()); + @Test + public void testDocumentReportingTask() throws InitializationException, IOException { - DocumentationWriter writer = new HtmlDocumentationWriter(); + ReportingTask reportingTask = new FullyDocumentedReportingTask(); + reportingTask.initialize(new MockReportingInitializationContext()); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DocumentationWriter writer = new HtmlDocumentationWriter(); - writer.write(reportingTask, baos, false); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); - String results = new String(baos.toByteArray()); - XmlValidator.assertXmlValid(results); + writer.write(reportingTask, baos, false); - // description - assertContains(results, "A helper reporting task to do..."); + String results = new String(baos.toByteArray()); + XmlValidator.assertXmlValid(results); - // tags - assertContains(results, "first, second, third"); + // description + assertContains(results, "A helper reporting task to do..."); - // 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"); - } + // 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"); + } }