Package org.apache.nifi.util
Class StandardProcessorTestRunner
java.lang.Object
org.apache.nifi.util.StandardProcessorTestRunner
- All Implemented Interfaces:
TestRunner
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate booleanprivate final MockProcessContextprivate final Map<String, MockComponentLog> private final Map<String, MockStateManager> private booleanprivate final MockFlowFileQueueprivate final AtomicLongprivate final AtomicIntegerprivate final org.apache.nifi.kerberos.KerberosContextprivate final MockComponentLogprivate intprivate final org.apache.nifi.processor.Processorprivate final MockStateManagerprivate longprivate MockSessionFactoryprivate final SharedSessionStateprivate final booleanprivate boolean -
Constructor Summary
ConstructorsConstructorDescriptionStandardProcessorTestRunner(org.apache.nifi.processor.Processor processor) StandardProcessorTestRunner(org.apache.nifi.processor.Processor processor, String processorName) StandardProcessorTestRunner(org.apache.nifi.processor.Processor processor, String processorName, org.apache.nifi.kerberos.KerberosContext kerberosContext) StandardProcessorTestRunner(org.apache.nifi.processor.Processor processor, String processorName, MockComponentLog logger) StandardProcessorTestRunner(org.apache.nifi.processor.Processor processor, String processorName, MockComponentLog logger, org.apache.nifi.kerberos.KerberosContext kerberosContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConnection(String relationshipName) Indicates to the Framework that the configured processor has a connection for the Relationship with the given name.voidaddConnection(org.apache.nifi.processor.Relationship relationship) Indicates to the Framework that the configured processor has a connection for the given Relationship.voidaddControllerService(String identifier, org.apache.nifi.controller.ControllerService service) Adds the givenControllerServiceto this TestRunner so that the configured Processor can access it using the givenidentifier.voidaddControllerService(String identifier, org.apache.nifi.controller.ControllerService service, Map<String, String> properties) Adds the givenControllerServiceto this TestRunner so that the configured Processor can access it using the givenidentifier.voidassertAllConditionsMet(String relationshipName, Predicate<MockFlowFile> predicate) Asserts that all FlowFiles meet all conditions.voidassertAllConditionsMet(org.apache.nifi.processor.Relationship relationship, Predicate<MockFlowFile> predicate) Asserts that all FlowFiles meet all conditions.voidassertAllFlowFiles(org.apache.nifi.processor.Relationship relationship, FlowFileValidator validator) Asserts that all FlowFiles that were transferred in the given relationship are compliant with the given validator.voidassertAllFlowFiles(FlowFileValidator validator) Asserts that all FlowFiles that were transferred are compliant with the given validator.voidassertAllFlowFilesContainAttribute(String attributeName) Asserts that all FlowFiles that were transferred contain the given attribute.voidassertAllFlowFilesContainAttribute(org.apache.nifi.processor.Relationship relationship, String attributeName) Asserts that all FlowFiles that were transferred to the given relationship contain the given attribute.voidassertAllFlowFilesTransferred(String relationship) Asserts that all FlowFiles that were transferred were transferred to the given relationshipvoidassertAllFlowFilesTransferred(String relationship, int count) Asserts that all FlowFiles that were transferred were transferred to the given relationship and that the number of FlowFiles transferred is equal tocountvoidassertAllFlowFilesTransferred(org.apache.nifi.processor.Relationship relationship) Asserts that all FlowFiles that were transferred were transferred to the given relationshipvoidassertAllFlowFilesTransferred(org.apache.nifi.processor.Relationship relationship, int count) Asserts that all FlowFiles that were transferred were transferred to the given relationship and that the number of FlowFiles transferred is equal tocountvoidassertAttributes(org.apache.nifi.processor.Relationship relationship, Set<String> checkedAttributeNames, Set<Map<String, String>> expectedAttributes) Asserts that flowfiles on a given relationship have a certain set of attributes.voidassertContents(org.apache.nifi.processor.Relationship relationship, List<String> expectedContent) Asserts that flowfiles on a given relationship have certain contents.voidAssert that the currently configured set of properties/annotation data are NOT validvoidassertNotValid(org.apache.nifi.controller.ControllerService service) Assert that the currently configured set of properties/annotation data are NOT valid for the given Controller Service.voidassertPenalizeCount(int count) Assert that the number of FlowFiles that were penalized is equal to the given countvoidassertProvenanceEvent(org.apache.nifi.provenance.ProvenanceEventType eventType) Assert that provenance event was created with the specified event type.voidAssert that there are no FlowFiles left on the input queue.voidAssert that there is at least one FlowFile left on the input queue.voidassertTransferCount(String relationship, int count) Assert that the number of FlowFiles transferred to the given relationship is equal to the given countvoidassertTransferCount(org.apache.nifi.processor.Relationship relationship, int count) Assert that the number of FlowFiles transferred to the given relationship is equal to the given countvoidAssert that the currently configured set of properties/annotation data are validvoidassertValid(org.apache.nifi.controller.ControllerService service) Assert that the currently configured set of properties/annotation data are valid for the given Controller Service.voidClears all set properties from theProcessContext.voidClears the Provenance Events that have been emitted by the ProcessorvoidAllow for clearing the queue from all remaining flow files.voidResets the Transfer Counts that indicate how many FlowFiles have been transferred to each Relationship and removes from memory any FlowFiles that have been transferred to this Relationships.voiddisableControllerService(org.apache.nifi.controller.ControllerService service) Marks the Controller Service as disabled so that it cannot be used by other components.voidenableControllerService(org.apache.nifi.controller.ControllerService service) Marks the Controller Service as enabled so that it can be used by other components.voidenforceReadStreamsClosed(boolean enforce) By default, ifProcessSession.read(FlowFile)is called, the InputStream that is returned MUST be closed by the processor under test or calls toProcessSession.commit()will throw an Exception.enqueue(byte[] data) Copies the content from the given byte array into memory and creates a FlowFile from this content with no attributes and adds this FlowFile to the Processor's Input QueueCopies the content from the given byte array into memory and creates a FlowFile from this content with the given attributes and adds this FlowFile to the Processor's Input Queueenqueue(InputStream data) Reads the content from the givenInputStreaminto memory and creates a FlowFile from this content with no attributes and adds this FlowFile to the Processor's Input Queueenqueue(InputStream data, Map<String, String> attributes) Reads the content from the givenInputStreaminto memory and creates a FlowFile from this content with the given attributes and adds this FlowFile to the Processor's Input QueueCreates a FlowFile with the content set to the given string (in UTF-8 format), with no attributes, and adds this FlowFile to the Processor's Input QueueCreates a FlowFile with the content set to the given string (in UTF-8 format), with the given attributes, and adds this FlowFile to the Processor's Input QueueReads the content from the givenPathinto memory and creates a FlowFile from this content with no attributes and adds this FlowFile to the Processor's Input QueueReads the content from the givenPathinto memory and creates a FlowFile from this content with the given attributes and adds this FlowFile to the Processor's Input Queuevoidenqueue(org.apache.nifi.flowfile.FlowFile... flowFiles) Enqueues the given FlowFiles into the Processor's input queueprivate ControllerServiceConfigurationgetConfigToUpdate(org.apache.nifi.controller.ControllerService service) byte[]getContentAsByteArray(MockFlowFile flowFile) Copies the contents of the givenMockFlowFileinto a byte array and returns that byte array.org.apache.nifi.controller.ControllerServicegetControllerService(String identifier) <T extends org.apache.nifi.controller.ControllerService>
TgetControllerService(String identifier, Class<T> serviceType) getControllerServiceLogger(String identifier) Returns theMockComponentLogthat is used by the specified controller service.getCounterValue(String name) Returns the current value of the variable with the given namegetFlowFilesForRelationship(String relationship) Returns a List of FlowFiles in the order in which they were transferred to the given relationshipgetFlowFilesForRelationship(org.apache.nifi.processor.Relationship relationship) Returns a List of FlowFiles in the order in which they were transferred to the given relationshipReturns theMockComponentLogthat is used by the Processor under test.Returns the current value for the given parameter name from the simulated Parameter ContextReturns a List of FlowFiles in the order in which they were transferred that were penalizedorg.apache.nifi.processor.Processororg.apache.nifi.processor.ProcessSessionFactoryList<org.apache.nifi.provenance.ProvenanceEventRecord> Returns aListof allProvenanceEventRecords that were emitted by the Processororg.apache.nifi.controller.queue.QueueSizeintgetStateManager(org.apache.nifi.controller.ControllerService controllerService) Returns the State Manager for the given Controller Service.intbooleanisControllerServiceEnabled(org.apache.nifi.controller.ControllerService service) booleanbooleanisValid()booleanCauses the TestRunner to call the Processor'sProcessor.migrateProperties(PropertyConfiguration)method.Causes the TestRunner to call the Processor'sProcessor.migrateRelationships(RelationshipConfiguration)method.voidremoveConnection(String relationshipName) Removes the connection for the relationship with the given name from the configured processor.voidremoveConnection(org.apache.nifi.processor.Relationship relationship) Removes the connection for the given Relationship from the configured processor.voidremoveControllerService(org.apache.nifi.controller.ControllerService service) Removes the Controller Service from the TestRunner.booleanremoveProperty(String property) Removes the property from theProcessContext, effectively setting its value to null, or the property's default value, if it has one.booleanremoveProperty(org.apache.nifi.components.PropertyDescriptor descriptor) Removes thePropertyDescriptorfrom theProcessContext, effectively setting its value to null, or the property's default value, if it has one.booleanremoveProperty(org.apache.nifi.controller.ControllerService service, String propertyName) Removes thePropertyDescriptorfrom the ControllerService, effectively setting its value to null, or the property's default value, if it has one.booleanremoveProperty(org.apache.nifi.controller.ControllerService service, org.apache.nifi.components.PropertyDescriptor property) Removes thePropertyDescriptorfrom the ControllerService, effectively setting its value to null, or the property's default value, if it has one.voidrun()Performs exactly the same operation as callingTestRunner.run(int)with a value of 1.voidrun(int iterations) Performs the same operation as callingTestRunner.run(int, boolean)with a value oftruevoidrun(int iterations, boolean stopOnFinish) performs the same operation as callingTestRunner.run(int, boolean, boolean)with a value ofiterations,stopOnFinish,truevoidrun(int iterations, boolean stopOnFinish, boolean initialize) This method runs theProcessoriterationstimes, using the sequence of steps below: Ifinitializeis true, run all methods on the Processor that are annotated with the@OnScheduledannotation.voidrun(int iterations, boolean stopOnFinish, boolean initialize, long runWait) This method runs theProcessoriterationstimes, using the sequence of steps below: Ifinitializeis true, run all methods on the Processor that are annotated with the@OnScheduledannotation.voidsetAllowRecursiveReads(boolean allowRecursiveReads) Specifies whether the TestRunner will allow ProcessSession.read() multiple times for the same FlowFile while an InputStream is already open.voidsetAllowSynchronousSessionCommits(boolean allowSynchronousSessionCommits) Specifies whether the TestRunner will allow ProcessSession.commit() to be called.voidsetAnnotationData(String annotationData) Sets the annotation data.voidsetAnnotationData(org.apache.nifi.controller.ControllerService service, String annotationData) Sets the annotation data of the given service to the provided annotation data.voidsetClustered(boolean clustered) voidsetConnected(boolean isConnected) voidsetEnvironmentVariableValue(String name, String value) Sets the value of the variable with the given name to be the given value.voidsetIncomingConnection(boolean hasIncomingConnection) Indicates to the framework that the configured processor has one or more incoming connections.voidsetIsConfiguredForClustering(boolean isConfiguredForClustering) voidsetNonLoopConnection(boolean hasNonLoopConnection) Indicates to the framework that the configured processor has one or more incoming connections for which the processor is not also the source.voidsetParameterContextValue(String name, String value) Sets a parameter with the given name and value into the simulated Parameter Context.voidsetPrimaryNode(boolean primaryNode) org.apache.nifi.components.ValidationResultsetProperty(String propertyName, String propertyValue) Updates the value of the property with the given PropertyDescriptor to the specified value IF and ONLY IF the value is valid according to the descriptor's validator.org.apache.nifi.components.ValidationResultsetProperty(org.apache.nifi.components.PropertyDescriptor descriptor, String value) Updates the value of the property with the given PropertyDescriptor to the specified value IF and ONLY IF the value is valid according to the descriptor's validator.org.apache.nifi.components.ValidationResultsetProperty(org.apache.nifi.components.PropertyDescriptor descriptor, org.apache.nifi.components.DescribedValue value) Updates the value of the property with the given PropertyDescriptor to the specified value IF and ONLY IF the value is valid according to the descriptor's validator.org.apache.nifi.components.ValidationResultsetProperty(org.apache.nifi.controller.ControllerService service, String propertyName, String value) Sets the property with the given name on the given ControllerServiceorg.apache.nifi.components.ValidationResultsetProperty(org.apache.nifi.controller.ControllerService service, org.apache.nifi.components.PropertyDescriptor property, String value) Sets the given property on the given ControllerServiceorg.apache.nifi.components.ValidationResultsetProperty(org.apache.nifi.controller.ControllerService service, org.apache.nifi.components.PropertyDescriptor property, org.apache.nifi.components.DescribedValue value) Sets the given property on the given ControllerServicevoidsetRelationshipAvailable(String relationshipName) 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.voidsetRelationshipAvailable(org.apache.nifi.processor.Relationship relationship) 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.voidsetRelationshipUnavailable(String relationshipName) 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.voidsetRelationshipUnavailable(org.apache.nifi.processor.Relationship relationship) 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.voidsetRunSchedule(long runSchedule) Set the Run Schedule parameter (in milliseconds).voidsetThreadCount(int threadCount) Updates the number of threads that will be used to run the Processor when calling theTestRunner.run()orTestRunner.run(int)methods.voidsetValidateExpressionUsage(boolean validate) Specifies whether or not the TestRunner will validate the use of Expression Language.voidshutdown()Invokes all methods on the Processor that are annotated with the@OnShutdownannotation.voidstop()Invokes all methods on the Processor that are annotated with the@OnStoppedannotation.voidInvokes all methods on the Processor that are annotated with the@OnUnscheduledannotation.Collection<org.apache.nifi.components.ValidationResult> validate()Validates the currently configured set of properties/annotation dataCollection<org.apache.nifi.components.ValidationResult> validate(org.apache.nifi.controller.ControllerService service) Validates the currently configured set of properties/annotation data for the given Controller Service.List<org.apache.nifi.components.ConfigVerificationResult> Verifies the currently configured set of properties/annotation dataList<org.apache.nifi.components.ConfigVerificationResult> Verifies the currently configured set of properties/annotation data for the given Controller Service.
-
Field Details
-
processor
private final org.apache.nifi.processor.Processor processor -
context
-
kerberosContext
private final org.apache.nifi.kerberos.KerberosContext kerberosContext -
flowFileQueue
-
idGenerator
-
triggerSerially
private final boolean triggerSerially -
processorStateManager
-
controllerServiceStateManagers
-
numThreads
private int numThreads -
sessionFactory
-
allowSynchronousSessionCommits
private boolean allowSynchronousSessionCommits -
allowRecursiveReads
private boolean allowRecursiveReads -
runSchedule
private long runSchedule -
invocations
-
controllerServiceLoggers
-
logger
-
enforceReadStreamsClosed
private boolean enforceReadStreamsClosed -
validateExpressionUsage
private boolean validateExpressionUsage -
environmentVariables
-
contextParameters
-
-
Constructor Details
-
StandardProcessorTestRunner
StandardProcessorTestRunner(org.apache.nifi.processor.Processor processor) -
StandardProcessorTestRunner
StandardProcessorTestRunner(org.apache.nifi.processor.Processor processor, String processorName) -
StandardProcessorTestRunner
StandardProcessorTestRunner(org.apache.nifi.processor.Processor processor, String processorName, org.apache.nifi.kerberos.KerberosContext kerberosContext) -
StandardProcessorTestRunner
StandardProcessorTestRunner(org.apache.nifi.processor.Processor processor, String processorName, MockComponentLog logger) -
StandardProcessorTestRunner
StandardProcessorTestRunner(org.apache.nifi.processor.Processor processor, String processorName, MockComponentLog logger, org.apache.nifi.kerberos.KerberosContext kerberosContext)
-
-
Method Details
-
enforceReadStreamsClosed
public void enforceReadStreamsClosed(boolean enforce) Description copied from interface:TestRunnerBy default, ifProcessSession.read(FlowFile)is called, the InputStream that is returned MUST be closed by the processor under test or calls toProcessSession.commit()will throw an Exception. This method allows the developer to indicate explicitly that they do or do not want this functionality. The ProcessSession that is used in the framework when running NiFi does not enforce this, as the framework itself tracks the InputStreams that it returns and ensures that they are properly closed on session commit or rollback. However, it is considered a best practice for Processors to close the streams themselves whenever they are no longer needed. There may be cases, however, where this is not feasible or easy and this method provides developers the ability to indicate that by disabling enforcement so that the framework will handle this.- Specified by:
enforceReadStreamsClosedin interfaceTestRunner- Parameters:
enforce-trueif calls to session.commit() should fail if the read streams are not properly closed.
-
setValidateExpressionUsage
public void setValidateExpressionUsage(boolean validate) Description copied from interface:TestRunnerSpecifies whether or not the TestRunner will validate the use of Expression Language. By default, the value istrue, which means that an Exception will be thrown if the Processor attempts to obtain the configured value of a Property without callingevaluateAttributeExpressionson the Property Value or ifevaluateAttributeExpressionsis called but the PropertyDescriptor indicates that the Expression Language is not supported.See Also:
PropertyDescriptor.Builder.expressionLanguageSupported(ExpressionLanguageScope)- Specified by:
setValidateExpressionUsagein interfaceTestRunner- Parameters:
validate- whether there is any need to validate the EL was used
-
setAllowSynchronousSessionCommits
public void setAllowSynchronousSessionCommits(boolean allowSynchronousSessionCommits) Description copied from interface:TestRunnerSpecifies whether the TestRunner will allow ProcessSession.commit() to be called. By default, the value isfalse, meaning that any call to ProcessSession.commit() will throw an Exception. See JavaDocs forProcessSession.commit()for more information- Specified by:
setAllowSynchronousSessionCommitsin interfaceTestRunner- Parameters:
allowSynchronousSessionCommits- whether to allow asynchronous session commits (i.e., calls to ProcessSession.commit())
-
setAllowRecursiveReads
public void setAllowRecursiveReads(boolean allowRecursiveReads) Description copied from interface:TestRunnerSpecifies whether the TestRunner will allow ProcessSession.read() multiple times for the same FlowFile while an InputStream is already open. By default, the value isfalse, meaning that any call to ProcessSession.read() for a FlowFile already being read will throw an Exception. See JavaDocs forProcessSession.read(FlowFile)for more information- Specified by:
setAllowRecursiveReadsin interfaceTestRunner- Parameters:
allowRecursiveReads- whether to allow recursive reads of a FlowFile (i.e., calls to ProcessSession.read())
-
getProcessor
public org.apache.nifi.processor.Processor getProcessor()- Specified by:
getProcessorin interfaceTestRunner- Returns:
- the
Processorfor which thisTestRunneris configured
-
getProcessContext
- Specified by:
getProcessContextin interfaceTestRunner- Returns:
- the
ProcessContextthat thisTestRunnerwill use to invoke theonTriggermethod
-
isYieldCalled
public boolean isYieldCalled()- Specified by:
isYieldCalledin interfaceTestRunner
-
run
public void run()Description copied from interface:TestRunnerPerforms exactly the same operation as callingTestRunner.run(int)with a value of 1.- Specified by:
runin interfaceTestRunner
-
run
public void run(int iterations) Description copied from interface:TestRunnerPerforms the same operation as callingTestRunner.run(int, boolean)with a value oftrue- Specified by:
runin interfaceTestRunner- Parameters:
iterations- number of iterations
-
run
public void run(int iterations, boolean stopOnFinish) Description copied from interface:TestRunnerperforms the same operation as callingTestRunner.run(int, boolean, boolean)with a value ofiterations,stopOnFinish,true- Specified by:
runin interfaceTestRunner- Parameters:
iterations- number of iterationsstopOnFinish- flag to stop when finished
-
run
public void run(int iterations, boolean stopOnFinish, boolean initialize) Description copied from interface:TestRunnerThis method runs theProcessoriterationstimes, using the sequence of steps below:-
If
initializeis true, run all methods on the Processor that are annotated with the@OnScheduledannotation. If any of these methods throws an Exception, the Unit Test will fail. -
Schedule the
onTriggermethod to be invokediterationstimes. The number of threads used to run these iterations is determined by the ThreadCount of thisTestRunner. By default, the value is set to 1, but it can be modified by calling theTestRunner.setThreadCount(int)method. -
As soon as the first thread finishes its execution of
onTrigger, all methods on the Processor that are annotated with the@OnUnscheduledannotation are invoked. If any of these methods throws an Exception, the Unit Test will fail. - Waits for all threads to finish execution.
-
If and only if the value of
shutdownis true: Call all methods on the Processor that is annotated with the@OnStoppedannotation.
- Specified by:
runin interfaceTestRunner- Parameters:
iterations- number of iterationsstopOnFinish- whether or not to run the Processor methods that are annotated with@OnStoppedinitialize- true if must initialize
-
If
-
run
public void run(int iterations, boolean stopOnFinish, boolean initialize, long runWait) Description copied from interface:TestRunnerThis method runs theProcessoriterationstimes, using the sequence of steps below:-
If
initializeis true, run all methods on the Processor that are annotated with the@OnScheduledannotation. If any of these methods throws an Exception, the Unit Test will fail. -
Schedule the
onTriggermethod to be invokediterationstimes. The number of threads used to run these iterations is determined by the ThreadCount of thisTestRunner. By default, the value is set to 1, but it can be modified by calling theTestRunner.setThreadCount(int)method. -
As soon as the first thread finishes its execution of
onTrigger, all methods on the Processor that are annotated with the@OnUnscheduledannotation are invoked. If any of these methods throws an Exception, the Unit Test will fail. - Waits for all threads to finish execution.
-
If and only if the value of
shutdownis true: Call all methods on the Processor that is annotated with the@OnStoppedannotation.
- Specified by:
runin interfaceTestRunner- Parameters:
iterations- number of iterationsstopOnFinish- whether or not to run the Processor methods that are annotated with@OnStoppedinitialize- true if must initializerunWait- indicates the amount of time in milliseconds that the framework should wait for processors to stop running before calling the@OnUnscheduledannotation
-
If
-
unSchedule
public void unSchedule()Description copied from interface:TestRunnerInvokes all methods on the Processor that are annotated with the@OnUnscheduledannotation. If any of these methods throws an Exception, the Unit Test will fail- Specified by:
unSchedulein interfaceTestRunner
-
stop
public void stop()Description copied from interface:TestRunnerInvokes all methods on the Processor that are annotated with the@OnStoppedannotation. If any of these methods throws an Exception, the Unit Test will fail- Specified by:
stopin interfaceTestRunner
-
shutdown
public void shutdown()Description copied from interface:TestRunnerInvokes all methods on the Processor that are annotated with the@OnShutdownannotation. If any of these methods throws an Exception, the Unit Test will fail- Specified by:
shutdownin interfaceTestRunner
-
getProcessSessionFactory
public org.apache.nifi.processor.ProcessSessionFactory getProcessSessionFactory()- Specified by:
getProcessSessionFactoryin interfaceTestRunner- Returns:
- the
ProcessSessionFactorythat thisTestRunnerwill use to invoke theProcessor.onTrigger(ProcessContext, ProcessSessionFactory)method
-
assertAllFlowFilesTransferred
Description copied from interface:TestRunnerAsserts that all FlowFiles that were transferred were transferred to the given relationship- Specified by:
assertAllFlowFilesTransferredin interfaceTestRunner- Parameters:
relationship- to verify
-
assertAllFlowFilesTransferred
public void assertAllFlowFilesTransferred(org.apache.nifi.processor.Relationship relationship) Description copied from interface:TestRunnerAsserts that all FlowFiles that were transferred were transferred to the given relationship- Specified by:
assertAllFlowFilesTransferredin interfaceTestRunner- Parameters:
relationship- to verify
-
assertAllFlowFilesTransferred
Description copied from interface:TestRunnerAsserts that all FlowFiles that were transferred were transferred to the given relationship and that the number of FlowFiles transferred is equal tocount- Specified by:
assertAllFlowFilesTransferredin interfaceTestRunner- Parameters:
relationship- to verifycount- number of expected transfers
-
assertAllFlowFilesContainAttribute
Description copied from interface:TestRunnerAsserts that all FlowFiles that were transferred contain the given attribute.- Specified by:
assertAllFlowFilesContainAttributein interfaceTestRunner- Parameters:
attributeName- attribute to look for
-
assertAllFlowFilesContainAttribute
public void assertAllFlowFilesContainAttribute(org.apache.nifi.processor.Relationship relationship, String attributeName) Description copied from interface:TestRunnerAsserts that all FlowFiles that were transferred to the given relationship contain the given attribute.- Specified by:
assertAllFlowFilesContainAttributein interfaceTestRunner- Parameters:
relationship- relationship to checkattributeName- attribute to look for
-
assertAllFlowFiles
Description copied from interface:TestRunnerAsserts that all FlowFiles that were transferred are compliant with the given validator.- Specified by:
assertAllFlowFilesin interfaceTestRunner- Parameters:
validator- validator to use
-
assertAllFlowFiles
public void assertAllFlowFiles(org.apache.nifi.processor.Relationship relationship, FlowFileValidator validator) Description copied from interface:TestRunnerAsserts that all FlowFiles that were transferred in the given relationship are compliant with the given validator.- Specified by:
assertAllFlowFilesin interfaceTestRunner- Parameters:
validator- validator to use
-
assertAttributes
public void assertAttributes(org.apache.nifi.processor.Relationship relationship, Set<String> checkedAttributeNames, Set<Map<String, String>> expectedAttributes) Description copied from interface:TestRunnerAsserts that flowfiles on a given relationship have a certain set of attributes.- Specified by:
assertAttributesin interfaceTestRunner- Parameters:
relationship- The relationship on which to check the attributes of flowfilescheckedAttributeNames- The names of attributes that should be checkedexpectedAttributes- The expected attributes of all flowfiles
-
assertContents
public void assertContents(org.apache.nifi.processor.Relationship relationship, List<String> expectedContent) Description copied from interface:TestRunnerAsserts that flowfiles on a given relationship have certain contents.- Specified by:
assertContentsin interfaceTestRunner- Parameters:
relationship- The relationship on which to check the contents of flowfilesexpectedContent- The expected contents of all flowfiles
-
assertAllFlowFilesTransferred
public void assertAllFlowFilesTransferred(org.apache.nifi.processor.Relationship relationship, int count) Description copied from interface:TestRunnerAsserts that all FlowFiles that were transferred were transferred to the given relationship and that the number of FlowFiles transferred is equal tocount- Specified by:
assertAllFlowFilesTransferredin interfaceTestRunner- Parameters:
relationship- to verifycount- number of expected transfers
-
assertTransferCount
public void assertTransferCount(org.apache.nifi.processor.Relationship relationship, int count) Description copied from interface:TestRunnerAssert that the number of FlowFiles transferred to the given relationship is equal to the given count- Specified by:
assertTransferCountin interfaceTestRunner- Parameters:
relationship- to verifycount- number of expected transfers
-
assertTransferCount
Description copied from interface:TestRunnerAssert that the number of FlowFiles transferred to the given relationship is equal to the given count- Specified by:
assertTransferCountin interfaceTestRunner- Parameters:
relationship- to verifycount- number of expected transfers
-
assertPenalizeCount
public void assertPenalizeCount(int count) Description copied from interface:TestRunnerAssert that the number of FlowFiles that were penalized is equal to the given count- Specified by:
assertPenalizeCountin interfaceTestRunner- Parameters:
count- number of expected penalized
-
assertValid
public void assertValid()Description copied from interface:TestRunnerAssert that the currently configured set of properties/annotation data are valid- Specified by:
assertValidin interfaceTestRunner
-
validate
Description copied from interface:TestRunnerValidates the currently configured set of properties/annotation data- Specified by:
validatein interfaceTestRunner- Returns:
- a Collection of ValidationResult
-
verify
public List<org.apache.nifi.components.ConfigVerificationResult> verify(Map<String, String> variables) Description copied from interface:TestRunnerVerifies the currently configured set of properties/annotation data- Specified by:
verifyin interfaceTestRunner- Parameters:
variables- the variables to use for verification- Returns:
- a Collection of ConfigVerificationResult
-
isValid
public boolean isValid()- Specified by:
isValidin interfaceTestRunner
-
assertNotValid
public void assertNotValid()Description copied from interface:TestRunnerAssert that the currently configured set of properties/annotation data are NOT valid- Specified by:
assertNotValidin interfaceTestRunner
-
isQueueEmpty
public boolean isQueueEmpty()- Specified by:
isQueueEmptyin interfaceTestRunner- Returns:
trueif the Input Queue to the Processor is empty,falseotherwise
-
assertQueueEmpty
public void assertQueueEmpty()Description copied from interface:TestRunnerAssert that there are no FlowFiles left on the input queue.- Specified by:
assertQueueEmptyin interfaceTestRunner
-
assertQueueNotEmpty
public void assertQueueNotEmpty()Description copied from interface:TestRunnerAssert that there is at least one FlowFile left on the input queue.- Specified by:
assertQueueNotEmptyin interfaceTestRunner
-
clearTransferState
public void clearTransferState()Description copied from interface:TestRunnerResets the Transfer Counts that indicate how many FlowFiles have been transferred to each Relationship and removes from memory any FlowFiles that have been transferred to this Relationships. This method should be called between successive calls torunif the output is to be examined after each run.- Specified by:
clearTransferStatein interfaceTestRunner
-
enqueue
public void enqueue(org.apache.nifi.flowfile.FlowFile... flowFiles) Description copied from interface:TestRunnerEnqueues the given FlowFiles into the Processor's input queue- Specified by:
enqueuein interfaceTestRunner- Parameters:
flowFiles- to enqueue
-
enqueue
Description copied from interface:TestRunnerReads the content from the givenPathinto memory and creates a FlowFile from this content with no attributes and adds this FlowFile to the Processor's Input Queue- Specified by:
enqueuein interfaceTestRunner- Parameters:
path- to read content from- Throws:
IOException- if unable to read content
-
enqueue
Description copied from interface:TestRunnerReads the content from the givenPathinto memory and creates a FlowFile from this content with the given attributes and adds this FlowFile to the Processor's Input Queue- Specified by:
enqueuein interfaceTestRunner- Parameters:
path- to read content fromattributes- attributes to use for new flow file- Throws:
IOException- if unable to read content
-
enqueue
Description copied from interface:TestRunnerCopies the content from the given byte array into memory and creates a FlowFile from this content with no attributes and adds this FlowFile to the Processor's Input Queue- Specified by:
enqueuein interfaceTestRunner- Parameters:
data- to enqueue
-
enqueue
Description copied from interface:TestRunnerCreates a FlowFile with the content set to the given string (in UTF-8 format), with no attributes, and adds this FlowFile to the Processor's Input Queue- Specified by:
enqueuein interfaceTestRunner- Parameters:
data- to enqueue
-
enqueue
Description copied from interface:TestRunnerCopies the content from the given byte array into memory and creates a FlowFile from this content with the given attributes and adds this FlowFile to the Processor's Input Queue- Specified by:
enqueuein interfaceTestRunner- Parameters:
data- to enqueueattributes- to use for enqueued item
-
enqueue
Description copied from interface:TestRunnerCreates a FlowFile with the content set to the given string (in UTF-8 format), with the given attributes, and adds this FlowFile to the Processor's Input Queue- Specified by:
enqueuein interfaceTestRunner- Parameters:
data- to enqueueattributes- to use for enqueued item
-
enqueue
Description copied from interface:TestRunnerReads the content from the givenInputStreaminto memory and creates a FlowFile from this content with no attributes and adds this FlowFile to the Processor's Input Queue- Specified by:
enqueuein interfaceTestRunner- Parameters:
data- to source data from
-
enqueue
Description copied from interface:TestRunnerReads the content from the givenInputStreaminto memory and creates a FlowFile from this content with the given attributes and adds this FlowFile to the Processor's Input Queue- Specified by:
enqueuein interfaceTestRunner- Parameters:
data- source of dataattributes- to use for flow files
-
getContentAsByteArray
Description copied from interface:TestRunnerCopies the contents of the givenMockFlowFileinto a byte array and returns that byte array.- Specified by:
getContentAsByteArrayin interfaceTestRunner- Parameters:
flowFile- to get content for- Returns:
- byte array of flowfile content
-
getFlowFilesForRelationship
Description copied from interface:TestRunnerReturns a List of FlowFiles in the order in which they were transferred to the given relationship- Specified by:
getFlowFilesForRelationshipin interfaceTestRunner- Parameters:
relationship- to get flowfiles for- Returns:
- flowfiles transferred to given relationship
-
getFlowFilesForRelationship
public List<MockFlowFile> getFlowFilesForRelationship(org.apache.nifi.processor.Relationship relationship) Description copied from interface:TestRunnerReturns a List of FlowFiles in the order in which they were transferred to the given relationship- Specified by:
getFlowFilesForRelationshipin interfaceTestRunner- Parameters:
relationship- to get flowfiles for- Returns:
- flowfiles transferred to given relationship
-
getPenalizedFlowFiles
Description copied from interface:TestRunnerReturns a List of FlowFiles in the order in which they were transferred that were penalized- Specified by:
getPenalizedFlowFilesin interfaceTestRunner- Returns:
- flowfiles that were penalized
-
getQueueSize
public org.apache.nifi.controller.queue.QueueSize getQueueSize()- Specified by:
getQueueSizein interfaceTestRunner- Returns:
- the current size of the Processor's Input Queue
-
clearQueue
public void clearQueue()Description copied from interface:TestRunnerAllow for clearing the queue from all remaining flow files.- Specified by:
clearQueuein interfaceTestRunner
-
getCounterValue
- Specified by:
getCounterValuein interfaceTestRunner- Parameters:
name- of counter- Returns:
- the current value of the counter with the specified name, or null if no counter exists with the specified name
-
getRemovedCount
public int getRemovedCount()- Specified by:
getRemovedCountin interfaceTestRunner- Returns:
- the number of FlowFiles that have been removed from the system
-
setAnnotationData
Description copied from interface:TestRunnerSets the annotation data.- Specified by:
setAnnotationDatain interfaceTestRunner- Parameters:
annotationData- data
-
setProperty
public org.apache.nifi.components.ValidationResult setProperty(String propertyName, String propertyValue) Description copied from interface:TestRunnerUpdates the value of the property with the given PropertyDescriptor to the specified value IF and ONLY IF the value is valid according to the descriptor's validator. Otherwise, Assertions.fail() is called, causing the unit test to fail- Specified by:
setPropertyin interfaceTestRunner- Parameters:
propertyName- namepropertyValue- value- Returns:
- result
-
setProperty
public org.apache.nifi.components.ValidationResult setProperty(org.apache.nifi.components.PropertyDescriptor descriptor, String value) Description copied from interface:TestRunnerUpdates the value of the property with the given PropertyDescriptor to the specified value IF and ONLY IF the value is valid according to the descriptor's validator. Otherwise, Assertions.fail() is called, causing the unit test to fail- Specified by:
setPropertyin interfaceTestRunner- Parameters:
descriptor- descriptorvalue- value- Returns:
- result
-
setProperty
public org.apache.nifi.components.ValidationResult setProperty(org.apache.nifi.components.PropertyDescriptor descriptor, org.apache.nifi.components.DescribedValue value) Description copied from interface:TestRunnerUpdates the value of the property with the given PropertyDescriptor to the specified value IF and ONLY IF the value is valid according to the descriptor's validator. Otherwise, Assertions.fail() is called, causing the unit test to fail- Specified by:
setPropertyin interfaceTestRunner- Parameters:
descriptor- descriptorvalue- allowable valu- Returns:
- result
-
setThreadCount
public void setThreadCount(int threadCount) Description copied from interface:TestRunnerUpdates the number of threads that will be used to run the Processor when calling theTestRunner.run()orTestRunner.run(int)methods.- Specified by:
setThreadCountin interfaceTestRunner- Parameters:
threadCount- num threads
-
getThreadCount
public int getThreadCount()- Specified by:
getThreadCountin interfaceTestRunner- Returns:
- the currently configured number of threads that will be used to
runt he Processor when calling the
TestRunner.run()orTestRunner.run(int)methods
-
setRelationshipAvailable
public void setRelationshipAvailable(org.apache.nifi.processor.Relationship relationship) Description copied from interface:TestRunnerIndicates 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 theTriggerWhenAnyDestinationAvailableannotation.- Specified by:
setRelationshipAvailablein interfaceTestRunner- Parameters:
relationship- to mark as available
-
setRelationshipAvailable
Description copied from interface:TestRunnerIndicates 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 theTriggerWhenAnyDestinationAvailable- Specified by:
setRelationshipAvailablein interfaceTestRunner- Parameters:
relationshipName- relationship name
-
setIncomingConnection
public void setIncomingConnection(boolean hasIncomingConnection) Description copied from interface:TestRunnerIndicates to the framework that the configured processor has one or more incoming connections.- Specified by:
setIncomingConnectionin interfaceTestRunner- Parameters:
hasIncomingConnection- whether or not the configured processor should behave as though it has an incoming connection
-
setNonLoopConnection
public void setNonLoopConnection(boolean hasNonLoopConnection) Description copied from interface:TestRunnerIndicates to the framework that the configured processor has one or more incoming connections for which the processor is not also the source.- Specified by:
setNonLoopConnectionin interfaceTestRunner- Parameters:
hasNonLoopConnection- whether or not the configured processor should behave as though it has a non-looping incoming connection
-
addConnection
public void addConnection(org.apache.nifi.processor.Relationship relationship) Description copied from interface:TestRunnerIndicates to the Framework that the configured processor has a connection for the given Relationship.- Specified by:
addConnectionin interfaceTestRunner- Parameters:
relationship- that has a connection
-
addConnection
Description copied from interface:TestRunnerIndicates to the Framework that the configured processor has a connection for the Relationship with the given name.- Specified by:
addConnectionin interfaceTestRunner- Parameters:
relationshipName- name of relationship that has a connection
-
removeConnection
public void removeConnection(org.apache.nifi.processor.Relationship relationship) Description copied from interface:TestRunnerRemoves the connection for the given Relationship from the configured processor.- Specified by:
removeConnectionin interfaceTestRunner- Parameters:
relationship- to remove
-
removeConnection
Description copied from interface:TestRunnerRemoves the connection for the relationship with the given name from the configured processor.- Specified by:
removeConnectionin interfaceTestRunner- Parameters:
relationshipName- name of the relationship to remove
-
addControllerService
public void addControllerService(String identifier, org.apache.nifi.controller.ControllerService service) throws org.apache.nifi.reporting.InitializationException Description copied from interface:TestRunnerAdds the givenControllerServiceto this TestRunner so that the configured Processor can access it using the givenidentifier. The ControllerService is not expected to be initialized, as the framework will create the appropriateControllerServiceInitializationContextand initialize the ControllerService with no specified properties. This will call any method on the given Controller Service that is annotated with the@OnAddedannotation.- Specified by:
addControllerServicein interfaceTestRunner- Parameters:
identifier- of serviceservice- the service- Throws:
org.apache.nifi.reporting.InitializationException- ie
-
addControllerService
public void addControllerService(String identifier, org.apache.nifi.controller.ControllerService service, Map<String, String> properties) throws org.apache.nifi.reporting.InitializationExceptionDescription copied from interface:TestRunnerAdds the givenControllerServiceto this TestRunner so that the configured Processor can access it using the givenidentifier. The ControllerService is not expected to be initialized, as the framework will create the appropriateControllerServiceInitializationContextand initialize the ControllerService with the given properties. This will call any method on the given Controller Service that is annotated with the@OnAddedannotation.- Specified by:
addControllerServicein interfaceTestRunner- Parameters:
identifier- of serviceservice- the serviceproperties- service properties- Throws:
org.apache.nifi.reporting.InitializationException- ie
-
assertNotValid
public void assertNotValid(org.apache.nifi.controller.ControllerService service) Description copied from interface:TestRunnerAssert that the currently configured set of properties/annotation data are NOT valid for the given Controller Service.- Specified by:
assertNotValidin interfaceTestRunner- Parameters:
service- the service to validate
-
assertValid
public void assertValid(org.apache.nifi.controller.ControllerService service) Description copied from interface:TestRunnerAssert that the currently configured set of properties/annotation data are valid for the given Controller Service.- Specified by:
assertValidin interfaceTestRunner- Parameters:
service- the service to validate
-
validate
public Collection<org.apache.nifi.components.ValidationResult> validate(org.apache.nifi.controller.ControllerService service) Description copied from interface:TestRunnerValidates the currently configured set of properties/annotation data for the given Controller Service.- Specified by:
validatein interfaceTestRunner- Parameters:
service- the service to validate- Returns:
- a Collection of ValidationResult
-
verify
public List<org.apache.nifi.components.ConfigVerificationResult> verify(org.apache.nifi.controller.ControllerService service, Map<String, String> variables) Description copied from interface:TestRunnerVerifies the currently configured set of properties/annotation data for the given Controller Service.- Specified by:
verifyin interfaceTestRunner- Parameters:
variables- the variables to use for verification- Returns:
- a Collection of ConfigVerificationResult
-
disableControllerService
public void disableControllerService(org.apache.nifi.controller.ControllerService service) Description copied from interface:TestRunnerMarks the Controller Service as disabled so that it cannot be used by other components.
This method will result in calling any method in the Controller Service that is annotated with the
@OnDisabledannotation.- Specified by:
disableControllerServicein interfaceTestRunner- Parameters:
service- the service to disable
-
enableControllerService
public void enableControllerService(org.apache.nifi.controller.ControllerService service) Description copied from interface:TestRunnerMarks the Controller Service as enabled so that it can be used by other components.
This method will result in calling any method in the Controller Service that is annotated with the
@OnEnabledannotation.- Specified by:
enableControllerServicein interfaceTestRunner- Parameters:
service- the service to enable
-
isControllerServiceEnabled
public boolean isControllerServiceEnabled(org.apache.nifi.controller.ControllerService service) - Specified by:
isControllerServiceEnabledin interfaceTestRunner- Parameters:
service- the service- Returns:
trueif the given Controller Service is enabled,falseif it is disabled
-
removeControllerService
public void removeControllerService(org.apache.nifi.controller.ControllerService service) Description copied from interface:TestRunnerRemoves the Controller Service from the TestRunner. This will call any method on the ControllerService that is annotated with the
@OnRemovedannotation.- Specified by:
removeControllerServicein interfaceTestRunner- Parameters:
service- the service
-
setAnnotationData
public void setAnnotationData(org.apache.nifi.controller.ControllerService service, String annotationData) Description copied from interface:TestRunnerSets the annotation data of the given service to the provided annotation data.- Specified by:
setAnnotationDatain interfaceTestRunner- Parameters:
service- to modifyannotationData- the data
-
getConfigToUpdate
private ControllerServiceConfiguration getConfigToUpdate(org.apache.nifi.controller.ControllerService service) -
setProperty
public org.apache.nifi.components.ValidationResult setProperty(org.apache.nifi.controller.ControllerService service, org.apache.nifi.components.PropertyDescriptor property, org.apache.nifi.components.DescribedValue value) Description copied from interface:TestRunnerSets the given property on the given ControllerService- Specified by:
setPropertyin interfaceTestRunner- Parameters:
service- to modifyproperty- to modifyvalue- value to use- Returns:
- result
-
setProperty
public org.apache.nifi.components.ValidationResult setProperty(org.apache.nifi.controller.ControllerService service, org.apache.nifi.components.PropertyDescriptor property, String value) Description copied from interface:TestRunnerSets the given property on the given ControllerService- Specified by:
setPropertyin interfaceTestRunner- Parameters:
service- to modifyproperty- to modifyvalue- value to use- Returns:
- result
-
setProperty
public org.apache.nifi.components.ValidationResult setProperty(org.apache.nifi.controller.ControllerService service, String propertyName, String value) Description copied from interface:TestRunnerSets the property with the given name on the given ControllerService- Specified by:
setPropertyin interfaceTestRunner- Parameters:
service- to modifypropertyName- to modifyvalue- value to use- Returns:
- result
-
getControllerService
- Specified by:
getControllerServicein interfaceTestRunner- Parameters:
identifier- of controller service- Returns:
- the
ControllerServicethat is registered with the given identifier, ornullif no Controller Service exists with the given identifier
-
getControllerService
public <T extends org.apache.nifi.controller.ControllerService> T getControllerService(String identifier, Class<T> serviceType) - Specified by:
getControllerServicein interfaceTestRunner- Type Parameters:
T- type of service- Parameters:
identifier- identifier of serviceserviceType- type of service- Returns:
- the
ControllerServicethat is registered with the given identifier, cast as the provided service type, ornullif no Controller Service exists with the given identifier
-
removeProperty
public boolean removeProperty(org.apache.nifi.components.PropertyDescriptor descriptor) Description copied from interface:TestRunnerRemoves thePropertyDescriptorfrom theProcessContext, effectively setting its value to null, or the property's default value, if it has one.- Specified by:
removePropertyin interfaceTestRunner- Parameters:
descriptor- of property to remove- Returns:
trueif removed,falseif the property was not set
-
removeProperty
Description copied from interface:TestRunnerRemoves the property from theProcessContext, effectively setting its value to null, or the property's default value, if it has one.- Specified by:
removePropertyin interfaceTestRunner- Parameters:
property- name of the property to remove- Returns:
trueif removed,falseif the property was not set
-
removeProperty
public boolean removeProperty(org.apache.nifi.controller.ControllerService service, org.apache.nifi.components.PropertyDescriptor property) Description copied from interface:TestRunnerRemoves thePropertyDescriptorfrom the ControllerService, effectively setting its value to null, or the property's default value, if it has one.- Specified by:
removePropertyin interfaceTestRunner- Parameters:
service- the controller service to remove the property fromproperty- of property to remove- Returns:
trueif removed,falseif the property was not set
-
removeProperty
public boolean removeProperty(org.apache.nifi.controller.ControllerService service, String propertyName) Description copied from interface:TestRunnerRemoves thePropertyDescriptorfrom the ControllerService, effectively setting its value to null, or the property's default value, if it has one.- Specified by:
removePropertyin interfaceTestRunner- Parameters:
service- the controller service to remove the property frompropertyName- name of the property to remove- Returns:
trueif removed,falseif the property was not set
-
clearProperties
public void clearProperties()Description copied from interface:TestRunnerClears all set properties from theProcessContext.- Specified by:
clearPropertiesin interfaceTestRunner
-
getProvenanceEvents
Description copied from interface:TestRunnerReturns aListof allProvenanceEventRecords that were emitted by the Processor- Specified by:
getProvenanceEventsin interfaceTestRunner- Returns:
- a List of all Provenance Events that were emitted by the Processor
-
clearProvenanceEvents
public void clearProvenanceEvents()Description copied from interface:TestRunnerClears the Provenance Events that have been emitted by the Processor- Specified by:
clearProvenanceEventsin interfaceTestRunner
-
getStateManager
- Specified by:
getStateManagerin interfaceTestRunner- Returns:
- the State Manager that is used to stored and retrieve state
-
getStateManager
public MockStateManager getStateManager(org.apache.nifi.controller.ControllerService controllerService) Returns the State Manager for the given Controller Service.- Specified by:
getStateManagerin interfaceTestRunner- Parameters:
controllerService- the Controller Service whose State Manager should be returned- Returns:
- the State Manager for the given Controller Service
-
getLogger
Description copied from interface:TestRunnerReturns theMockComponentLogthat is used by the Processor under test.- Specified by:
getLoggerin interfaceTestRunner- Returns:
- the logger
-
getControllerServiceLogger
Description copied from interface:TestRunnerReturns theMockComponentLogthat is used by the specified controller service.- Specified by:
getControllerServiceLoggerin interfaceTestRunner- Parameters:
identifier- a controller service identifier- Returns:
- the logger
-
setClustered
public void setClustered(boolean clustered) - Specified by:
setClusteredin interfaceTestRunner- Parameters:
clustered- Specify if this test emulates running in a clustered environment
-
setIsConfiguredForClustering
public void setIsConfiguredForClustering(boolean isConfiguredForClustering) - Specified by:
setIsConfiguredForClusteringin interfaceTestRunner- Parameters:
isConfiguredForClustering- Specify if this test emulates running in an environment where the expected cluster state equals with the argument.
-
setPrimaryNode
public void setPrimaryNode(boolean primaryNode) - Specified by:
setPrimaryNodein interfaceTestRunner- Parameters:
primaryNode- Specify if this test emulates running as a primary node
-
setConnected
public void setConnected(boolean isConnected) - Specified by:
setConnectedin interfaceTestRunner- Parameters:
isConnected- Specify if this test emulates ongoing cluster connection
-
getEnvironmentVariableValue
Description copied from interface:TestRunnerReturns the current value of the variable with the given name- Specified by:
getEnvironmentVariableValuein interfaceTestRunner- Parameters:
name- the name of the variable whose value should be returned.- Returns:
- the current value of the variable with the given name or
nullif no value is currently set
-
setEnvironmentVariableValue
Description copied from interface:TestRunnerSets the value of the variable with the given name to be the given value. This exposes the variable for use by the Expression Language. NOTE - this method is only for testing purposes as we only support variables coming from environment and system variables. This usage is to avoid the need to set env/sys variables in the tests.- Specified by:
setEnvironmentVariableValuein interfaceTestRunner- Parameters:
name- the name of the variable to setvalue- the value of the variable
-
getParameterContextValue
Description copied from interface:TestRunnerReturns the current value for the given parameter name from the simulated Parameter Context- Specified by:
getParameterContextValuein interfaceTestRunner- Parameters:
name- the name of the parameter from the Parameter Context whose value should be returned.- Returns:
- the current value for the given parameter name from the simulated Parameter Context or
nullif no value is currently set
-
setParameterContextValue
Description copied from interface:TestRunnerSets a parameter with the given name and value into the simulated Parameter Context. This makes available the parameter to the properties of the component being tested through parameter referencing such as#{name}.- Specified by:
setParameterContextValuein interfaceTestRunner- Parameters:
name- the name of the parameter to setvalue- the value of the parameter to set
-
assertAllConditionsMet
Asserts that all FlowFiles meet all conditions.- Specified by:
assertAllConditionsMetin interfaceTestRunner- Parameters:
relationshipName- relationship namepredicate- conditions
-
assertAllConditionsMet
public void assertAllConditionsMet(org.apache.nifi.processor.Relationship relationship, Predicate<MockFlowFile> predicate) Asserts that all FlowFiles meet all conditions.- Specified by:
assertAllConditionsMetin interfaceTestRunner- Parameters:
relationship- relationshippredicate- conditions
-
setRunSchedule
public void setRunSchedule(long runSchedule) Set the Run Schedule parameter (in milliseconds). If set, this will be the duration between two calls of the onTrigger method.- Specified by:
setRunSchedulein interfaceTestRunner- Parameters:
runSchedule- Run schedule duration in milliseconds.
-
assertProvenanceEvent
public void assertProvenanceEvent(org.apache.nifi.provenance.ProvenanceEventType eventType) Description copied from interface:TestRunnerAssert that provenance event was created with the specified event type.- Specified by:
assertProvenanceEventin interfaceTestRunner- Parameters:
eventType- Provenance event type
-
migrateProperties
Description copied from interface:TestRunnerCauses the TestRunner to call the Processor'sProcessor.migrateProperties(PropertyConfiguration)method. The effects that are caused by calling the method are applied, as they would be in a running NiFi instance. Unlike in a running NiFi instance, though, the operations that were performed are captured so that they can be examined and assertions made about the migration that occurred.- Specified by:
migratePropertiesin interfaceTestRunner- Returns:
- the results of migrating properties
-
migrateRelationships
Description copied from interface:TestRunnerCauses the TestRunner to call the Processor'sProcessor.migrateRelationships(RelationshipConfiguration)method. The effects that are caused by calling the method are applied, as they would be in a running NiFi instance. Unlike in a running NiFi instance, though, the operations that were performed are captured so that they can be examined and assertions made about the migration that occurred.- Specified by:
migrateRelationshipsin interfaceTestRunner- Returns:
- the results of migrating relationships
-