public class StandardProcessorTestRunner extends Object implements TestRunner
Modifier and Type | Class and Description |
---|---|
private class |
StandardProcessorTestRunner.RunProcessor |
Modifier and Type | Field and Description |
---|---|
private MockProcessContext |
context |
private Map<String,MockComponentLog> |
controllerServiceLoggers |
private Map<String,MockStateManager> |
controllerServiceStateManagers |
private boolean |
enforceReadStreamsClosed |
private MockFlowFileQueue |
flowFileQueue |
private AtomicLong |
idGenerator |
private AtomicInteger |
invocations |
private MockComponentLog |
logger |
private int |
numThreads |
private Processor |
processor |
private MockStateManager |
processorStateManager |
private long |
runSchedule |
private MockSessionFactory |
sessionFactory |
private SharedSessionState |
sharedState |
private boolean |
triggerSerially |
private MockVariableRegistry |
variableRegistry |
Constructor and Description |
---|
StandardProcessorTestRunner(Processor processor) |
StandardProcessorTestRunner(Processor processor,
String processorName) |
StandardProcessorTestRunner(Processor processor,
String processorName,
MockComponentLog logger) |
Modifier and Type | Method and Description |
---|---|
void |
addConnection(Relationship relationship)
Indicates to the Framework that the configured processor has a connection for the given Relationship.
|
void |
addConnection(String relationshipName)
Indicates to the Framework that the configured processor has a connection for the
Relationship with the given name.
|
void |
addControllerService(String identifier,
ControllerService service)
Adds the given
ControllerService to this TestRunner so that the
configured Processor can access it using the given
identifier . |
void |
addControllerService(String identifier,
ControllerService service,
Map<String,String> properties)
Adds the given
ControllerService to this TestRunner so that the
configured Processor can access it using the given
identifier . |
void |
assertAllConditionsMet(Relationship relationship,
Predicate<MockFlowFile> predicate)
Asserts that all FlowFiles meet all conditions.
|
void |
assertAllConditionsMet(String relationshipName,
Predicate<MockFlowFile> predicate)
Asserts that all FlowFiles meet all conditions.
|
void |
assertAllFlowFiles(FlowFileValidator validator)
Asserts that all FlowFiles that were transferred are compliant with the
given validator.
|
void |
assertAllFlowFiles(Relationship relationship,
FlowFileValidator validator)
Asserts that all FlowFiles that were transferred in the given relationship
are compliant with the given validator.
|
void |
assertAllFlowFilesContainAttribute(Relationship relationship,
String attributeName)
Asserts that all FlowFiles that were transferred to the given
relationship contain the given attribute.
|
void |
assertAllFlowFilesContainAttribute(String attributeName)
Asserts that all FlowFiles that were transferred contain the given
attribute.
|
void |
assertAllFlowFilesTransferred(Relationship relationship)
Asserts that all FlowFiles that were transferred were transferred to the
given relationship
|
void |
assertAllFlowFilesTransferred(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
to
count |
void |
assertAllFlowFilesTransferred(String relationship)
Asserts that all FlowFiles that were transferred were transferred to the
given relationship
|
void |
assertAllFlowFilesTransferred(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
to
count |
void |
assertNotValid()
Assert that the currently configured set of properties/annotation data
are NOT valid
|
void |
assertNotValid(ControllerService service)
Assert that the currently configured set of properties/annotation data
are NOT valid for the given Controller Service.
|
void |
assertPenalizeCount(int count)
Assert that the number of FlowFiles that were penalized is equal to the given count
|
void |
assertQueueEmpty()
Assert that there are no FlowFiles left on the input queue.
|
void |
assertQueueNotEmpty()
Assert that there is at least one FlowFile left on the input queue.
|
void |
assertTransferCount(Relationship relationship,
int count)
Assert that the number of FlowFiles transferred to the given relationship
is equal to the given count
|
void |
assertTransferCount(String relationship,
int count)
Assert that the number of FlowFiles transferred to the given relationship
is equal to the given count
|
void |
assertValid()
Assert that the currently configured set of properties/annotation data
are valid
|
void |
assertValid(ControllerService service)
Assert that the currently configured set of properties/annotation data
are valid for the given Controller Service.
|
void |
clearProperties()
Clears all set properties from the
ProcessContext . |
void |
clearProvenanceEvents()
Clears the Provenance Events that have been emitted by the Processor
|
void |
clearQueue() |
void |
clearTransferState()
Resets 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.
|
void |
disableControllerService(ControllerService service)
Marks the Controller Service as disabled so that it cannot be used by
other components.
|
void |
enableControllerService(ControllerService service)
Marks the Controller Service as enabled so that it can be used by other
components.
|
void |
enforceReadStreamsClosed(boolean enforce)
By default, if
ProcessSession.read(FlowFile) is called, the InputStream that is returned MUST be closed by
the processor under test or calls to ProcessSession.commit() will throw an Exception. |
MockFlowFile |
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 Queue
|
MockFlowFile |
enqueue(byte[] data,
Map<String,String> attributes)
Copies 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
|
void |
enqueue(FlowFile... flowFiles)
Enqueues the given FlowFiles into the Processor's input queue
|
MockFlowFile |
enqueue(InputStream data)
Reads the content from the given
InputStream into memory and
creates a FlowFile from this content with no attributes and adds this
FlowFile to the Processor's Input Queue |
MockFlowFile |
enqueue(InputStream data,
Map<String,String> attributes)
Reads the content from the given
InputStream into memory and
creates a FlowFile from this content with the given attributes and adds
this FlowFile to the Processor's Input Queue |
MockFlowFile |
enqueue(Path path)
Reads the content from the given
Path into memory and creates a
FlowFile from this content with no attributes and adds this FlowFile to
the Processor's Input Queue |
MockFlowFile |
enqueue(Path path,
Map<String,String> attributes)
Reads the content from the given
Path into memory and creates a
FlowFile from this content with the given attributes and adds this
FlowFile to the Processor's Input Queue |
MockFlowFile |
enqueue(String data)
Creates 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
|
MockFlowFile |
enqueue(String data,
Map<String,String> attributes)
Creates 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
|
private ControllerServiceConfiguration |
getConfigToUpdate(ControllerService service) |
byte[] |
getContentAsByteArray(MockFlowFile flowFile)
Copies the contents of the given
MockFlowFile into a byte array
and returns that byte array. |
ControllerService |
getControllerService(String identifier) |
<T extends ControllerService> |
getControllerService(String identifier,
Class<T> serviceType) |
MockComponentLog |
getControllerServiceLogger(String identifier)
Returns the
MockComponentLog that is used by the specified controller service. |
Long |
getCounterValue(String name) |
List<MockFlowFile> |
getFlowFilesForRelationship(Relationship relationship)
Returns a List of FlowFiles in the order in which they were transferred
to the given relationship
|
List<MockFlowFile> |
getFlowFilesForRelationship(String relationship)
Returns a List of FlowFiles in the order in which they were transferred
to the given relationship
|
MockComponentLog |
getLogger()
Returns the
MockComponentLog that is used by the Processor under test. |
List<MockFlowFile> |
getPenalizedFlowFiles()
Returns a List of FlowFiles in the order in which they were transferred that were penalized
|
MockProcessContext |
getProcessContext() |
Processor |
getProcessor() |
ProcessSessionFactory |
getProcessSessionFactory() |
List<ProvenanceEventRecord> |
getProvenanceEvents()
Returns a
List of all ProvenanceEventRecord s that were
emitted by the Processor |
QueueSize |
getQueueSize() |
int |
getRemovedCount() |
MockStateManager |
getStateManager() |
MockStateManager |
getStateManager(ControllerService controllerService)
Returns the State Manager for the given Controller Service.
|
int |
getThreadCount() |
String |
getVariableValue(String name)
Returns the current value of the variable with the given name
|
boolean |
isControllerServiceEnabled(ControllerService service) |
boolean |
isQueueEmpty() |
void |
removeConnection(Relationship relationship)
Removes the connection for the given Relationship from the configured processor.
|
void |
removeConnection(String relationshipName)
Removes the connection for the relationship with the given name from the configured processor.
|
void |
removeControllerService(ControllerService service)
Removes the Controller Service from the TestRunner.
|
boolean |
removeProperty(PropertyDescriptor descriptor)
Removes the
PropertyDescriptor from the ProcessContext ,
effectively setting its value to null, or the property's default value, if it has one. |
boolean |
removeProperty(String property)
Removes the property from the
ProcessContext ,
effectively setting its value to null, or the property's default value, if it has one. |
String |
removeVariable(String name)
Removes the variable with the given name from this Test Runner, if it is set.
|
void |
run()
Performs exactly the same operation as calling
TestRunner.run(int) with a
value of 1. |
void |
run(int iterations)
Performs the same operation as calling
TestRunner.run(int, boolean) with a
value of true |
void |
run(int iterations,
boolean stopOnFinish)
performs the same operation as calling
TestRunner.run(int, boolean, boolean)
with a value of iterations , stopOnFinish , true |
void |
run(int iterations,
boolean stopOnFinish,
boolean initialize)
This method runs the
Processor iterations times,
using the sequence of steps below:
If initialize is true, run all methods on the Processor that are
annotated with the
@OnScheduled annotation. |
void |
run(int iterations,
boolean stopOnFinish,
boolean initialize,
long runWait)
This method runs the
Processor iterations times,
using the sequence of steps below:
If initialize is true, run all methods on the Processor that are
annotated with the
@OnScheduled annotation. |
void |
setAnnotationData(ControllerService service,
String annotationData)
Sets the annotation data of the given service to the provided annotation
data.
|
void |
setAnnotationData(String annotationData)
Sets the annotation data.
|
void |
setClustered(boolean clustered) |
void |
setIncomingConnection(boolean hasIncomingConnection)
Indicates to the framework that the configured processor has one or more
incoming connections.
|
void |
setNonLoopConnection(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.
|
void |
setPrimaryNode(boolean primaryNode) |
ValidationResult |
setProperty(ControllerService service,
PropertyDescriptor property,
AllowableValue value)
Sets the given property on the given ControllerService
|
ValidationResult |
setProperty(ControllerService service,
PropertyDescriptor property,
String value)
Sets the given property on the given ControllerService
|
ValidationResult |
setProperty(ControllerService service,
String propertyName,
String value)
Sets the property with the given name on the given ControllerService
|
ValidationResult |
setProperty(PropertyDescriptor descriptor,
AllowableValue 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.
|
ValidationResult |
setProperty(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.
|
ValidationResult |
setProperty(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.
|
void |
setRelationshipAvailable(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.
|
void |
setRelationshipAvailable(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.
|
void |
setRelationshipUnavailable(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.
|
void |
setRelationshipUnavailable(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.
|
void |
setRunSchedule(long runSchedule)
Set the Run Schedule parameter (in milliseconds).
|
void |
setThreadCount(int threadCount)
Updates the number of threads that will be used to run the Processor when
calling the
TestRunner.run() or TestRunner.run(int) methods. |
void |
setValidateExpressionUsage(boolean validate)
Specifies whether or not the TestRunner will validate the use of
Expression Language.
|
void |
setVariable(String name,
String value)
Sets the value of the variable with the given name to be the given value.
|
void |
shutdown()
Invokes all methods on the Processor that are annotated with the
@OnShutdown annotation. |
private final Processor processor
private final MockProcessContext context
private final MockFlowFileQueue flowFileQueue
private final SharedSessionState sharedState
private final AtomicLong idGenerator
private final boolean triggerSerially
private final MockStateManager processorStateManager
private final Map<String,MockStateManager> controllerServiceStateManagers
private final MockVariableRegistry variableRegistry
private int numThreads
private MockSessionFactory sessionFactory
private long runSchedule
private final AtomicInteger invocations
private final Map<String,MockComponentLog> controllerServiceLoggers
private final MockComponentLog logger
private boolean enforceReadStreamsClosed
StandardProcessorTestRunner(Processor processor)
StandardProcessorTestRunner(Processor processor, String processorName, MockComponentLog logger)
public void enforceReadStreamsClosed(boolean enforce)
TestRunner
ProcessSession.read(FlowFile)
is called, the InputStream that is returned MUST be closed by
the processor under test or calls to ProcessSession.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.enforceReadStreamsClosed
in interface TestRunner
enforce
- true
if calls to session.commit() should fail if the read streams are not properly closed.public void setValidateExpressionUsage(boolean validate)
TestRunner
true
, which
means that an Exception will be thrown if the Processor attempts to
obtain the configured value of a Property without calling
evaluateAttributeExpressions
on the Property Value or if
evaluateAttributeExpressions
is called but the PropertyDescriptor indicates that the Expression
Language is not supported.
See Also:
PropertyDescriptor.Builder#expressionLanguageSupported(boolean)
setValidateExpressionUsage
in interface TestRunner
validate
- whether there is any need to validate the EL was usedpublic Processor getProcessor()
getProcessor
in interface TestRunner
Processor
for which this TestRunner
is
configuredpublic MockProcessContext getProcessContext()
getProcessContext
in interface TestRunner
TestRunner
will
use to invoke the
onTrigger
methodpublic void run()
TestRunner
TestRunner.run(int)
with a
value of 1.run
in interface TestRunner
public void run(int iterations)
TestRunner
TestRunner.run(int, boolean)
with a
value of true
run
in interface TestRunner
iterations
- number of iterationspublic void run(int iterations, boolean stopOnFinish)
TestRunner
TestRunner.run(int, boolean, boolean)
with a value of iterations
, stopOnFinish
, true
run
in interface TestRunner
iterations
- number of iterationsstopOnFinish
- flag to stop when finishedpublic void run(int iterations, boolean stopOnFinish, boolean initialize)
TestRunner
Processor
iterations
times,
using the sequence of steps below:
initialize
is true, run all methods on the Processor that are
annotated with the
@OnScheduled
annotation. If
any of these methods throws an Exception, the Unit Test will fail.
onTrigger
method to be invoked iterations
times. The number of threads
used to run these iterations is determined by the ThreadCount of this
TestRunner
. By default, the value is set to 1, but it can be
modified by calling the TestRunner.setThreadCount(int)
method.
onTrigger
,
all methods on the Processor that are annotated with the
@OnUnscheduled
annotation
are invoked. If any of these methods throws an Exception, the Unit Test
will fail.
shutdown
is true: Call all
methods on the Processor that is annotated with the
@OnStopped
annotation.
run
in interface TestRunner
iterations
- number of iterationsstopOnFinish
- whether or not to run the Processor methods that are
annotated with @OnStopped
initialize
- true if must initializepublic void run(int iterations, boolean stopOnFinish, boolean initialize, long runWait)
TestRunner
Processor
iterations
times,
using the sequence of steps below:
initialize
is true, run all methods on the Processor that are
annotated with the
@OnScheduled
annotation. If
any of these methods throws an Exception, the Unit Test will fail.
onTrigger
method to be invoked iterations
times. The number of threads
used to run these iterations is determined by the ThreadCount of this
TestRunner
. By default, the value is set to 1, but it can be
modified by calling the TestRunner.setThreadCount(int)
method.
onTrigger
,
all methods on the Processor that are annotated with the
@OnUnscheduled
annotation
are invoked. If any of these methods throws an Exception, the Unit Test
will fail.
shutdown
is true: Call all
methods on the Processor that is annotated with the
@OnStopped
annotation.
run
in interface TestRunner
iterations
- number of iterationsstopOnFinish
- whether or not to run the Processor methods that are
annotated with @OnStopped
initialize
- true if must initializerunWait
- indicates the amount of time in milliseconds that the framework should wait for
processors to stop running before calling the @OnUnscheduled
annotationpublic void shutdown()
TestRunner
@OnShutdown
annotation. If
any of these methods throws an Exception, the Unit Test will failshutdown
in interface TestRunner
public ProcessSessionFactory getProcessSessionFactory()
getProcessSessionFactory
in interface TestRunner
ProcessSessionFactory
that this
TestRunner
will use to invoke the
Processor.onTrigger(ProcessContext, ProcessSessionFactory)
methodpublic void assertAllFlowFilesTransferred(String relationship)
TestRunner
assertAllFlowFilesTransferred
in interface TestRunner
relationship
- to verifypublic void assertAllFlowFilesTransferred(Relationship relationship)
TestRunner
assertAllFlowFilesTransferred
in interface TestRunner
relationship
- to verifypublic void assertAllFlowFilesTransferred(String relationship, int count)
TestRunner
count
assertAllFlowFilesTransferred
in interface TestRunner
relationship
- to verifycount
- number of expected transferspublic void assertAllFlowFilesContainAttribute(String attributeName)
TestRunner
assertAllFlowFilesContainAttribute
in interface TestRunner
attributeName
- attribute to look forpublic void assertAllFlowFilesContainAttribute(Relationship relationship, String attributeName)
TestRunner
assertAllFlowFilesContainAttribute
in interface TestRunner
relationship
- relationship to checkattributeName
- attribute to look forpublic void assertAllFlowFiles(FlowFileValidator validator)
TestRunner
assertAllFlowFiles
in interface TestRunner
validator
- validator to usepublic void assertAllFlowFiles(Relationship relationship, FlowFileValidator validator)
TestRunner
assertAllFlowFiles
in interface TestRunner
validator
- validator to usepublic void assertAllFlowFilesTransferred(Relationship relationship, int count)
TestRunner
count
assertAllFlowFilesTransferred
in interface TestRunner
relationship
- to verifycount
- number of expected transferspublic void assertTransferCount(Relationship relationship, int count)
TestRunner
assertTransferCount
in interface TestRunner
relationship
- to verifycount
- number of expected transferspublic void assertTransferCount(String relationship, int count)
TestRunner
assertTransferCount
in interface TestRunner
relationship
- to verifycount
- number of expected transferspublic void assertPenalizeCount(int count)
TestRunner
assertPenalizeCount
in interface TestRunner
count
- number of expected penalizedpublic void assertValid()
TestRunner
assertValid
in interface TestRunner
public void assertNotValid()
TestRunner
assertNotValid
in interface TestRunner
public boolean isQueueEmpty()
isQueueEmpty
in interface TestRunner
true
if the Input Queue to the Processor is empty,
false
otherwisepublic void assertQueueEmpty()
TestRunner
assertQueueEmpty
in interface TestRunner
public void assertQueueNotEmpty()
TestRunner
assertQueueNotEmpty
in interface TestRunner
public void clearTransferState()
TestRunner
run
if the output is
to be examined after each run.clearTransferState
in interface TestRunner
public void enqueue(FlowFile... flowFiles)
TestRunner
enqueue
in interface TestRunner
flowFiles
- to enqueuepublic MockFlowFile enqueue(Path path) throws IOException
TestRunner
Path
into memory and creates a
FlowFile from this content with no attributes and adds this FlowFile to
the Processor's Input Queueenqueue
in interface TestRunner
path
- to read content fromIOException
- if unable to read contentpublic MockFlowFile enqueue(Path path, Map<String,String> attributes) throws IOException
TestRunner
Path
into memory and creates a
FlowFile from this content with the given attributes and adds this
FlowFile to the Processor's Input Queueenqueue
in interface TestRunner
path
- to read content fromattributes
- attributes to use for new flow fileIOException
- if unable to read contentpublic MockFlowFile enqueue(byte[] data)
TestRunner
enqueue
in interface TestRunner
data
- to enqueuepublic MockFlowFile enqueue(String data)
TestRunner
enqueue
in interface TestRunner
data
- to enqueuepublic MockFlowFile enqueue(byte[] data, Map<String,String> attributes)
TestRunner
enqueue
in interface TestRunner
data
- to enqueueattributes
- to use for enqueued itempublic MockFlowFile enqueue(String data, Map<String,String> attributes)
TestRunner
enqueue
in interface TestRunner
data
- to enqueueattributes
- to use for enqueued itempublic MockFlowFile enqueue(InputStream data)
TestRunner
InputStream
into memory and
creates a FlowFile from this content with no attributes and adds this
FlowFile to the Processor's Input Queueenqueue
in interface TestRunner
data
- to source data frompublic MockFlowFile enqueue(InputStream data, Map<String,String> attributes)
TestRunner
InputStream
into memory and
creates a FlowFile from this content with the given attributes and adds
this FlowFile to the Processor's Input Queueenqueue
in interface TestRunner
data
- source of dataattributes
- to use for flow filespublic byte[] getContentAsByteArray(MockFlowFile flowFile)
TestRunner
MockFlowFile
into a byte array
and returns that byte array.getContentAsByteArray
in interface TestRunner
flowFile
- to get content forpublic List<MockFlowFile> getFlowFilesForRelationship(String relationship)
TestRunner
getFlowFilesForRelationship
in interface TestRunner
relationship
- to get flowfiles forpublic List<MockFlowFile> getFlowFilesForRelationship(Relationship relationship)
TestRunner
getFlowFilesForRelationship
in interface TestRunner
relationship
- to get flowfiles forpublic List<MockFlowFile> getPenalizedFlowFiles()
TestRunner
getPenalizedFlowFiles
in interface TestRunner
public QueueSize getQueueSize()
getQueueSize
in interface TestRunner
public void clearQueue()
public Long getCounterValue(String name)
getCounterValue
in interface TestRunner
name
- of counterpublic int getRemovedCount()
getRemovedCount
in interface TestRunner
public void setAnnotationData(String annotationData)
TestRunner
setAnnotationData
in interface TestRunner
annotationData
- datapublic ValidationResult setProperty(String propertyName, String propertyValue)
TestRunner
setProperty
in interface TestRunner
propertyName
- namepropertyValue
- valuepublic ValidationResult setProperty(PropertyDescriptor descriptor, String value)
TestRunner
setProperty
in interface TestRunner
descriptor
- descriptorvalue
- valuepublic ValidationResult setProperty(PropertyDescriptor descriptor, AllowableValue value)
TestRunner
setProperty
in interface TestRunner
descriptor
- descriptorvalue
- allowable valupublic void setThreadCount(int threadCount)
TestRunner
TestRunner.run()
or TestRunner.run(int)
methods.setThreadCount
in interface TestRunner
threadCount
- num threadspublic int getThreadCount()
getThreadCount
in interface TestRunner
TestRunner.run()
or TestRunner.run(int)
methodspublic void setRelationshipAvailable(Relationship relationship)
TestRunner
annotation.TriggerWhenAnyDestinationAvailable
annotation.setRelationshipAvailable
in interface TestRunner
relationship
- to mark as availablepublic void setRelationshipAvailable(String relationshipName)
TestRunner
annotation.TriggerWhenAnyDestinationAvailable
setRelationshipAvailable
in interface TestRunner
relationshipName
- relationship namepublic void setRelationshipUnavailable(Relationship relationship)
TestRunner
annotation.TriggerWhenAnyDestinationAvailable
annotation.setRelationshipUnavailable
in interface TestRunner
relationship
- to mark as unavailablepublic void setRelationshipUnavailable(String relationshipName)
TestRunner
annotation.TriggerWhenAnyDestinationAvailable
setRelationshipUnavailable
in interface TestRunner
relationshipName
- name of relationship.public void setIncomingConnection(boolean hasIncomingConnection)
TestRunner
setIncomingConnection
in interface TestRunner
hasIncomingConnection
- whether or not the configured processor should behave as though it has an incoming connectionpublic void setNonLoopConnection(boolean hasNonLoopConnection)
TestRunner
setNonLoopConnection
in interface TestRunner
hasNonLoopConnection
- whether or not the configured processor should behave as though it has a non-looping incoming connectionpublic void addConnection(Relationship relationship)
TestRunner
addConnection
in interface TestRunner
relationship
- that has a connectionpublic void addConnection(String relationshipName)
TestRunner
addConnection
in interface TestRunner
relationshipName
- name of relationship that has a connectionpublic void removeConnection(Relationship relationship)
TestRunner
removeConnection
in interface TestRunner
relationship
- to removepublic void removeConnection(String relationshipName)
TestRunner
removeConnection
in interface TestRunner
relationshipName
- name of the relationship to removepublic void addControllerService(String identifier, ControllerService service) throws InitializationException
TestRunner
ControllerService
to this TestRunner so that the
configured Processor can access it using the given
identifier
. The ControllerService is not expected to be
initialized, as the framework will create the appropriate
ControllerServiceInitializationContext
and initialize the ControllerService with no specified properties.
This will call any method on the given Controller Service that is
annotated with the
@OnAdded
annotation.addControllerService
in interface TestRunner
identifier
- of serviceservice
- the serviceInitializationException
- iepublic void addControllerService(String identifier, ControllerService service, Map<String,String> properties) throws InitializationException
TestRunner
ControllerService
to this TestRunner so that the
configured Processor can access it using the given
identifier
. The ControllerService is not expected to be
initialized, as the framework will create the appropriate
ControllerServiceInitializationContext
and initialize the ControllerService with the given properties.
This will call any method on the given Controller Service that is
annotated with the
@OnAdded
annotation.addControllerService
in interface TestRunner
identifier
- of serviceservice
- the serviceproperties
- service propertiesInitializationException
- iepublic void assertNotValid(ControllerService service)
TestRunner
assertNotValid
in interface TestRunner
service
- the service to validatepublic void assertValid(ControllerService service)
TestRunner
assertValid
in interface TestRunner
service
- the service to validatepublic void disableControllerService(ControllerService service)
TestRunner
Marks 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
@OnDisabled
annotation.
disableControllerService
in interface TestRunner
service
- the service to disablepublic void enableControllerService(ControllerService service)
TestRunner
Marks 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
@OnEnabled
annotation.
enableControllerService
in interface TestRunner
service
- the service to enablepublic boolean isControllerServiceEnabled(ControllerService service)
isControllerServiceEnabled
in interface TestRunner
service
- the servicetrue
if the given Controller Service is enabled,
false
if it is disabledpublic void removeControllerService(ControllerService service)
TestRunner
Removes the Controller Service from the TestRunner. This will call any
method on the ControllerService that is annotated with the
@OnRemoved
annotation.
removeControllerService
in interface TestRunner
service
- the servicepublic void setAnnotationData(ControllerService service, String annotationData)
TestRunner
setAnnotationData
in interface TestRunner
service
- to modifyannotationData
- the dataprivate ControllerServiceConfiguration getConfigToUpdate(ControllerService service)
public ValidationResult setProperty(ControllerService service, PropertyDescriptor property, AllowableValue value)
TestRunner
setProperty
in interface TestRunner
service
- to modifyproperty
- to modifyvalue
- value to usepublic ValidationResult setProperty(ControllerService service, PropertyDescriptor property, String value)
TestRunner
setProperty
in interface TestRunner
service
- to modifyproperty
- to modifyvalue
- value to usepublic ValidationResult setProperty(ControllerService service, String propertyName, String value)
TestRunner
setProperty
in interface TestRunner
service
- to modifypropertyName
- to modifyvalue
- value to usepublic ControllerService getControllerService(String identifier)
getControllerService
in interface TestRunner
identifier
- of controller serviceControllerService
that is registered with the given
identifier, or null
if no Controller Service exists with the
given identifierpublic <T extends ControllerService> T getControllerService(String identifier, Class<T> serviceType)
getControllerService
in interface TestRunner
T
- type of serviceidentifier
- identifier of serviceserviceType
- type of serviceControllerService
that is registered with the given
identifier, cast as the provided service type, or null
if no
Controller Service exists with the given identifierpublic boolean removeProperty(PropertyDescriptor descriptor)
TestRunner
PropertyDescriptor
from the ProcessContext
,
effectively setting its value to null, or the property's default value, if it has one.removeProperty
in interface TestRunner
descriptor
- of property to removetrue
if removed, false
if the property was not setpublic boolean removeProperty(String property)
TestRunner
ProcessContext
,
effectively setting its value to null, or the property's default value, if it has one.removeProperty
in interface TestRunner
property
- name of the property to removetrue
if removed, false
if the property was not setpublic void clearProperties()
TestRunner
ProcessContext
.clearProperties
in interface TestRunner
public List<ProvenanceEventRecord> getProvenanceEvents()
TestRunner
List
of all ProvenanceEventRecord
s that were
emitted by the ProcessorgetProvenanceEvents
in interface TestRunner
public void clearProvenanceEvents()
TestRunner
clearProvenanceEvents
in interface TestRunner
public MockStateManager getStateManager()
getStateManager
in interface TestRunner
public MockStateManager getStateManager(ControllerService controllerService)
getStateManager
in interface TestRunner
controllerService
- the Controller Service whose State Manager should be returnedpublic MockComponentLog getLogger()
TestRunner
MockComponentLog
that is used by the Processor under test.getLogger
in interface TestRunner
public MockComponentLog getControllerServiceLogger(String identifier)
TestRunner
MockComponentLog
that is used by the specified controller service.getControllerServiceLogger
in interface TestRunner
identifier
- a controller service identifierpublic void setClustered(boolean clustered)
setClustered
in interface TestRunner
clustered
- Specify if this test emulates running in a clustered environmentpublic void setPrimaryNode(boolean primaryNode)
setPrimaryNode
in interface TestRunner
primaryNode
- Specify if this test emulates running as a primary nodepublic String getVariableValue(String name)
TestRunner
getVariableValue
in interface TestRunner
name
- the name of the variable whose value should be returned.null
if no value is currently setpublic void setVariable(String name, String value)
TestRunner
setVariable
in interface TestRunner
name
- the name of the variable to setvalue
- the value of the variablepublic String removeVariable(String name)
TestRunner
removeVariable
in interface TestRunner
name
- the name of the variable to removenull
if the variable was not setpublic void assertAllConditionsMet(String relationshipName, Predicate<MockFlowFile> predicate)
assertAllConditionsMet
in interface TestRunner
relationshipName
- relationship namepredicate
- conditionspublic void assertAllConditionsMet(Relationship relationship, Predicate<MockFlowFile> predicate)
assertAllConditionsMet
in interface TestRunner
relationship
- relationshippredicate
- conditionspublic void setRunSchedule(long runSchedule)
setRunSchedule
in interface TestRunner
runSchedule
- Run schedule duration in milliseconds.Copyright © 2020 Apache NiFi Project. All rights reserved.