public interface TestRunner
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 |
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
|
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
|
ProcessContext |
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 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(ControllerService controllerService,
PropertyDescriptor descriptor)
Removes the
PropertyDescriptor from the ControllerService,
effectively setting its value to null, or the property's default value, if it has one. |
boolean |
removeProperty(ControllerService controllerService,
String property)
Removes the
PropertyDescriptor from the ControllerService,
effectively setting its value to null, or the property's default value, if it has one. |
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
run(int) with a
value of 1. |
void |
run(int iterations)
Performs the same operation as calling
run(int, boolean) with a
value of true |
void |
run(int iterations,
boolean stopOnFinish)
performs the same operation as calling
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 |
setAllowSynchronousSessionCommits(boolean allow)
Specifies whether or not the TestRunner will allow ProcessSession.commit() to be called.
|
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 |
setConnected(boolean isConnected) |
void |
setIncomingConnection(boolean hasIncomingConnection)
Indicates to the framework that the configured processor has one or more
incoming connections.
|
void |
setIsConfiguredForClustering(boolean isConfiguredForClustering) |
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)
|
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. |
void |
stop()
Invokes all methods on the Processor that are annotated with the
@OnStopped annotation. |
void |
unSchedule()
Invokes all methods on the Processor that are annotated with the
@OnUnscheduled annotation. |
Processor getProcessor()
Processor
for which this TestRunner
is
configuredProcessSessionFactory getProcessSessionFactory()
ProcessSessionFactory
that this
TestRunner
will use to invoke the
Processor.onTrigger(ProcessContext, ProcessSessionFactory)
methodProcessContext getProcessContext()
TestRunner
will
use to invoke the
onTrigger
methodvoid run()
run(int)
with a
value of 1.void run(int iterations)
run(int, boolean)
with a
value of true
iterations
- number of iterationsvoid run(int iterations, boolean stopOnFinish)
run(int, boolean, boolean)
with a value of iterations
, stopOnFinish
, true
iterations
- number of iterationsstopOnFinish
- flag to stop when finishedvoid run(int iterations, boolean stopOnFinish, boolean initialize)
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 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.
iterations
- number of iterationsstopOnFinish
- whether or not to run the Processor methods that are
annotated with @OnStopped
initialize
- true if must initializevoid run(int iterations, boolean stopOnFinish, boolean initialize, long runWait)
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 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.
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
annotationvoid unSchedule()
@OnUnscheduled
annotation. If
any of these methods throws an Exception, the Unit Test will failvoid stop()
@OnStopped
annotation. If
any of these methods throws an Exception, the Unit Test will failvoid shutdown()
@OnShutdown
annotation. If
any of these methods throws an Exception, the Unit Test will failvoid setThreadCount(int threadCount)
run()
or run(int)
methods.threadCount
- num threadsint getThreadCount()
ValidationResult setProperty(String propertyName, String propertyValue)
propertyName
- namepropertyValue
- valueValidationResult setProperty(PropertyDescriptor descriptor, String value)
descriptor
- descriptorvalue
- valueValidationResult setProperty(PropertyDescriptor descriptor, AllowableValue value)
descriptor
- descriptorvalue
- allowable valuvoid setAnnotationData(String annotationData)
annotationData
- datavoid assertAllFlowFilesTransferred(String relationship)
relationship
- to verifyvoid assertAllFlowFilesTransferred(Relationship relationship)
relationship
- to verifyvoid assertAllFlowFilesTransferred(String relationship, int count)
count
relationship
- to verifycount
- number of expected transfersvoid assertAllFlowFilesTransferred(Relationship relationship, int count)
count
relationship
- to verifycount
- number of expected transfersvoid assertAllFlowFilesContainAttribute(String attributeName)
attributeName
- attribute to look forvoid assertAllFlowFilesContainAttribute(Relationship relationship, String attributeName)
relationship
- relationship to checkattributeName
- attribute to look forvoid assertAllFlowFiles(FlowFileValidator validator)
validator
- validator to usevoid assertAllFlowFiles(Relationship relationship, FlowFileValidator validator)
validator
- validator to usevoid assertTransferCount(Relationship relationship, int count)
relationship
- to verifycount
- number of expected transfersvoid assertTransferCount(String relationship, int count)
relationship
- to verifycount
- number of expected transfersvoid assertPenalizeCount(int count)
count
- number of expected penalizedvoid assertQueueEmpty()
boolean isQueueEmpty()
true
if the Input Queue to the Processor is empty,
false
otherwisevoid assertQueueNotEmpty()
void assertValid()
void assertNotValid()
void clearTransferState()
run
if the output is
to be examined after each run.void enqueue(FlowFile... flowFiles)
flowFiles
- to enqueueMockFlowFile enqueue(Path path) throws IOException
Path
into memory and creates a
FlowFile from this content with no attributes and adds this FlowFile to
the Processor's Input Queuepath
- to read content fromIOException
- if unable to read contentMockFlowFile enqueue(Path path, Map<String,String> attributes) throws IOException
Path
into memory and creates a
FlowFile from this content with the given attributes and adds this
FlowFile to the Processor's Input Queuepath
- to read content fromattributes
- attributes to use for new flow fileIOException
- if unable to read contentMockFlowFile enqueue(byte[] data)
data
- to enqueueMockFlowFile enqueue(String data)
data
- to enqueueMockFlowFile enqueue(byte[] data, Map<String,String> attributes)
data
- to enqueueattributes
- to use for enqueued itemMockFlowFile enqueue(String data, Map<String,String> attributes)
data
- to enqueueattributes
- to use for enqueued itemMockFlowFile enqueue(InputStream data)
InputStream
into memory and
creates a FlowFile from this content with no attributes and adds this
FlowFile to the Processor's Input Queuedata
- to source data fromMockFlowFile enqueue(InputStream data, Map<String,String> attributes)
InputStream
into memory and
creates a FlowFile from this content with the given attributes and adds
this FlowFile to the Processor's Input Queuedata
- source of dataattributes
- to use for flow filesbyte[] getContentAsByteArray(MockFlowFile flowFile)
MockFlowFile
into a byte array
and returns that byte array.flowFile
- to get content forList<MockFlowFile> getFlowFilesForRelationship(String relationship)
relationship
- to get flowfiles forList<MockFlowFile> getFlowFilesForRelationship(Relationship relationship)
relationship
- to get flowfiles forList<MockFlowFile> getPenalizedFlowFiles()
QueueSize getQueueSize()
Long getCounterValue(String name)
name
- of counterint getRemovedCount()
void setRelationshipAvailable(Relationship relationship)
TriggerWhenAnyDestinationAvailable
annotation.relationship
- to mark as availablevoid setRelationshipAvailable(String relationshipName)
TriggerWhenAnyDestinationAvailable
relationshipName
- relationship namevoid setRelationshipUnavailable(Relationship relationship)
TriggerWhenAnyDestinationAvailable
annotation.relationship
- to mark as unavailablevoid setRelationshipUnavailable(String relationshipName)
TriggerWhenAnyDestinationAvailable
relationshipName
- name of relationship.void setIncomingConnection(boolean hasIncomingConnection)
hasIncomingConnection
- whether or not the configured processor should behave as though it has an incoming connectionvoid setNonLoopConnection(boolean hasNonLoopConnection)
hasNonLoopConnection
- whether or not the configured processor should behave as though it has a non-looping incoming connectionvoid addConnection(Relationship relationship)
relationship
- that has a connectionvoid addConnection(String relationshipName)
relationshipName
- name of relationship that has a connectionvoid removeConnection(Relationship relationship)
relationship
- to removevoid removeConnection(String relationshipName)
relationshipName
- name of the relationship to removevoid addControllerService(String identifier, ControllerService service) throws InitializationException
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.identifier
- of serviceservice
- the serviceInitializationException
- ievoid addControllerService(String identifier, ControllerService service, Map<String,String> properties) throws InitializationException
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.identifier
- of serviceservice
- the serviceproperties
- service propertiesInitializationException
- ievoid enableControllerService(ControllerService service)
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.
service
- the service to enablevoid disableControllerService(ControllerService service)
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.
service
- the service to disableboolean isControllerServiceEnabled(ControllerService service)
service
- the servicetrue
if the given Controller Service is enabled,
false
if it is disabledIllegalArgumentException
- if the given ControllerService is not
known by this TestRunner (i.e., it has not been added via the
addControllerService(String, ControllerService)
or
addControllerService(String, ControllerService, Map)
method or
if the Controller Service has been removed via the
removeControllerService(ControllerService)
method.void removeControllerService(ControllerService service)
Removes the Controller Service from the TestRunner. This will call any
method on the ControllerService that is annotated with the
@OnRemoved
annotation.
service
- the serviceIllegalStateException
- if the ControllerService is not disabledIllegalArgumentException
- if the given ControllerService is not
known by this TestRunner (i.e., it has not been added via the
addControllerService(String, ControllerService)
or
addControllerService(String, ControllerService, Map)
method or
if the Controller Service has been removed via the
removeControllerService(ControllerService)
method.ValidationResult setProperty(ControllerService service, PropertyDescriptor property, String value)
service
- to modifyproperty
- to modifyvalue
- value to useIllegalStateException
- if the ControllerService is not disabledIllegalArgumentException
- if the given ControllerService is not
known by this TestRunner (i.e., it has not been added via the
addControllerService(String, ControllerService)
or
addControllerService(String, ControllerService, Map)
method or
if the Controller Service has been removed via the
removeControllerService(ControllerService)
method.ValidationResult setProperty(ControllerService service, PropertyDescriptor property, AllowableValue value)
service
- to modifyproperty
- to modifyvalue
- value to useIllegalStateException
- if the ControllerService is not disabledIllegalArgumentException
- if the given ControllerService is not
known by this TestRunner (i.e., it has not been added via the
addControllerService(String, ControllerService)
or
addControllerService(String, ControllerService, Map)
method or
if the Controller Service has been removed via the
removeControllerService(ControllerService)
method.ValidationResult setProperty(ControllerService service, String propertyName, String value)
service
- to modifypropertyName
- to modifyvalue
- value to useIllegalStateException
- if the ControllerService is not disabledIllegalArgumentException
- if the given ControllerService is not
known by this TestRunner (i.e., it has not been added via the
addControllerService(String, ControllerService)
or
addControllerService(String, ControllerService, Map)
method or
if the Controller Service has been removed via the
removeControllerService(ControllerService)
method.void setAnnotationData(ControllerService service, String annotationData)
service
- to modifyannotationData
- the dataIllegalStateException
- if the Controller Service is not disabledIllegalArgumentException
- if the given ControllerService is not
known by this TestRunner (i.e., it has not been added via the
addControllerService(String, ControllerService)
or
addControllerService(String, ControllerService, Map)
method or
if the Controller Service has been removed via the
removeControllerService(ControllerService)
method.ControllerService getControllerService(String identifier)
identifier
- of controller serviceControllerService
that is registered with the given
identifier, or null
if no Controller Service exists with the
given identifiervoid assertValid(ControllerService service)
service
- the service to validateIllegalArgumentException
- if the given ControllerService is not
known by this TestRunner (i.e., it has not been added via the
addControllerService(String, ControllerService)
or
addControllerService(String, ControllerService, Map)
method or
if the Controller Service has been removed via the
removeControllerService(ControllerService)
method.void assertNotValid(ControllerService service)
service
- the service to validateIllegalArgumentException
- if the given ControllerService is not
known by this TestRunner (i.e., it has not been added via the
addControllerService(String, ControllerService)
or
addControllerService(String, ControllerService, Map)
method or
if the Controller Service has been removed via the
removeControllerService(ControllerService)
method.<T extends ControllerService> T getControllerService(String identifier, Class<T> serviceType)
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 identifierClassCastException
- if the identifier given is registered for a
Controller Service but that Controller Service is not of the type
specifiedvoid setValidateExpressionUsage(boolean validate)
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)
validate
- whether there is any need to validate the EL was usedvoid setAllowSynchronousSessionCommits(boolean allow)
false
, meaning that any call to ProcessSession.commit() will throw
an Exception. See JavaDocs for ProcessSession.commit()
for more informationallow
- whethr or not to allow asynchronous session commits (i.e., calls to ProcessSession.commit())boolean removeProperty(PropertyDescriptor descriptor)
PropertyDescriptor
from the ProcessContext
,
effectively setting its value to null, or the property's default value, if it has one.descriptor
- of property to removetrue
if removed, false
if the property was not setboolean removeProperty(ControllerService controllerService, PropertyDescriptor descriptor)
PropertyDescriptor
from the ControllerService,
effectively setting its value to null, or the property's default value, if it has one.controllerService
- the controller service to remove the property fromdescriptor
- of property to removetrue
if removed, false
if the property was not setboolean removeProperty(String property)
ProcessContext
,
effectively setting its value to null, or the property's default value, if it has one.property
- name of the property to removetrue
if removed, false
if the property was not setboolean removeProperty(ControllerService controllerService, String property)
PropertyDescriptor
from the ControllerService,
effectively setting its value to null, or the property's default value, if it has one.controllerService
- the controller service to remove the property fromproperty
- name of the property to removetrue
if removed, false
if the property was not setvoid clearProperties()
ProcessContext
.List<ProvenanceEventRecord> getProvenanceEvents()
List
of all ProvenanceEventRecord
s that were
emitted by the Processorvoid clearProvenanceEvents()
MockComponentLog getLogger()
MockComponentLog
that is used by the Processor under test.MockComponentLog getControllerServiceLogger(String identifier)
MockComponentLog
that is used by the specified controller service.identifier
- a controller service identifierMockStateManager getStateManager()
MockStateManager getStateManager(ControllerService service)
service
- the controller service of interestvoid setClustered(boolean clustered)
clustered
- Specify if this test emulates running in a clustered environmentvoid setIsConfiguredForClustering(boolean isConfiguredForClustering)
isConfiguredForClustering
- Specify if this test emulates running in an environment where the expected
cluster state equals with the argument.void setPrimaryNode(boolean primaryNode)
primaryNode
- Specify if this test emulates running as a primary nodevoid setConnected(boolean isConnected)
isConnected
- Specify if this test emulates ongoing cluster connectionvoid setVariable(String name, String value)
name
- the name of the variable to setvalue
- the value of the variableNullPointerException
- if either the name or the value is nullString getVariableValue(String name)
name
- the name of the variable whose value should be returned.null
if no value is currently setNullPointerException
- if the name is nullString removeVariable(String name)
name
- the name of the variable to removenull
if the variable was not setNullPointerException
- if the name is nullvoid assertAllConditionsMet(String relationshipName, Predicate<MockFlowFile> predicate)
relationshipName
- relationship namepredicate
- conditionsvoid assertAllConditionsMet(Relationship relationship, Predicate<MockFlowFile> predicate)
relationship
- relationshippredicate
- conditionsvoid enforceReadStreamsClosed(boolean enforce)
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.enforce
- true
if calls to session.commit() should fail if the read streams are not properly closed.void setRunSchedule(long runSchedule)
runSchedule
- Run schedule duration in milliseconds.Copyright © 2021 Apache NiFi Project. All rights reserved.