Interface TestRunner

All Known Implementing Classes:
StandardProcessorTestRunner

public interface TestRunner
  • Method Details

    • getProcessor

      Processor getProcessor()
      Returns:
      the Processor for which this TestRunner is configured
    • getProcessSessionFactory

      ProcessSessionFactory getProcessSessionFactory()
      Returns:
      the ProcessSessionFactory that this TestRunner will use to invoke the Processor.onTrigger(ProcessContext, ProcessSessionFactory) method
    • getProcessContext

      ProcessContext getProcessContext()
      Returns:
      the ProcessContext that this TestRunner will use to invoke the onTrigger method
    • isYieldCalled

      boolean isYieldCalled()
    • run

      void run()
      Performs exactly the same operation as calling run(int) with a value of 1.
    • run

      void run(int iterations)
      Performs the same operation as calling run(int, boolean) with a value of true
      Parameters:
      iterations - number of iterations
    • run

      void run(int iterations, boolean stopOnFinish)
      performs the same operation as calling run(int, boolean, boolean) with a value of iterations, stopOnFinish, true
      Parameters:
      iterations - number of iterations
      stopOnFinish - flag to stop when finished
    • run

      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. If any of these methods throws an Exception, the Unit Test will fail.
      • Schedule the 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.
      • As soon as the first thread finishes its execution of 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.
      • Waits for all threads to finish execution.
      • If and only if the value of shutdown is true: Call all methods on the Processor that is annotated with the @OnStopped annotation.
      Parameters:
      iterations - number of iterations
      stopOnFinish - whether or not to run the Processor methods that are annotated with @OnStopped
      initialize - true if must initialize
    • run

      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. If any of these methods throws an Exception, the Unit Test will fail.
      • Schedule the 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.
      • As soon as the first thread finishes its execution of 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.
      • Waits for all threads to finish execution.
      • If and only if the value of shutdown is true: Call all methods on the Processor that is annotated with the @OnStopped annotation.
      Parameters:
      iterations - number of iterations
      stopOnFinish - whether or not to run the Processor methods that are annotated with @OnStopped
      initialize - true if must initialize
      runWait - indicates the amount of time in milliseconds that the framework should wait for processors to stop running before calling the @OnUnscheduled annotation
    • unSchedule

      void unSchedule()
      Invokes all methods on the Processor that are annotated with the @OnUnscheduled annotation. If any of these methods throws an Exception, the Unit Test will fail
    • stop

      void stop()
      Invokes all methods on the Processor that are annotated with the @OnStopped annotation. If any of these methods throws an Exception, the Unit Test will fail
    • shutdown

      void shutdown()
      Invokes all methods on the Processor that are annotated with the @OnShutdown annotation. If any of these methods throws an Exception, the Unit Test will fail
    • setThreadCount

      void setThreadCount(int threadCount)
      Updates the number of threads that will be used to run the Processor when calling the run() or run(int) methods.
      Parameters:
      threadCount - num threads
    • getThreadCount

      int getThreadCount()
      Returns:
      the currently configured number of threads that will be used to runt he Processor when calling the run() or run(int) methods
    • setProperty

      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. Otherwise, Assertions.fail() is called, causing the unit test to fail
      Parameters:
      propertyName - name
      propertyValue - value
      Returns:
      result
    • setProperty

      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. Otherwise, Assertions.fail() is called, causing the unit test to fail
      Parameters:
      descriptor - descriptor
      value - value
      Returns:
      result
    • setProperty

      ValidationResult setProperty(PropertyDescriptor descriptor, 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. Otherwise, Assertions.fail() is called, causing the unit test to fail
      Parameters:
      descriptor - descriptor
      value - allowable valu
      Returns:
      result
    • setAnnotationData

      void setAnnotationData(String annotationData)
      Sets the annotation data.
      Parameters:
      annotationData - data
    • assertAllFlowFilesTransferred

      void assertAllFlowFilesTransferred(String relationship)
      Asserts that all FlowFiles that were transferred were transferred to the given relationship
      Parameters:
      relationship - to verify
    • assertAllFlowFilesTransferred

      void assertAllFlowFilesTransferred(Relationship relationship)
      Asserts that all FlowFiles that were transferred were transferred to the given relationship
      Parameters:
      relationship - to verify
    • assertAllFlowFilesTransferred

      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
      Parameters:
      relationship - to verify
      count - number of expected transfers
    • assertAllFlowFilesTransferred

      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
      Parameters:
      relationship - to verify
      count - number of expected transfers
    • assertAllFlowFilesContainAttribute

      void assertAllFlowFilesContainAttribute(String attributeName)
      Asserts that all FlowFiles that were transferred contain the given attribute.
      Parameters:
      attributeName - attribute to look for
    • assertAllFlowFilesContainAttribute

      void assertAllFlowFilesContainAttribute(Relationship relationship, String attributeName)
      Asserts that all FlowFiles that were transferred to the given relationship contain the given attribute.
      Parameters:
      relationship - relationship to check
      attributeName - attribute to look for
    • assertAllFlowFiles

      void assertAllFlowFiles(FlowFileValidator validator)
      Asserts that all FlowFiles that were transferred are compliant with the given validator.
      Parameters:
      validator - validator to use
    • assertAllFlowFiles

      void assertAllFlowFiles(Relationship relationship, FlowFileValidator validator)
      Asserts that all FlowFiles that were transferred in the given relationship are compliant with the given validator.
      Parameters:
      validator - validator to use
    • assertAttributes

      void assertAttributes(Relationship relationship, Set<String> checkedAttributeNames, Set<Map<String,String>> expectedAttributes)
      Asserts that flowfiles on a given relationship have a certain set of attributes.
      Parameters:
      relationship - The relationship on which to check the attributes of flowfiles
      checkedAttributeNames - The names of attributes that should be checked
      expectedAttributes - The expected attributes of all flowfiles
    • assertContents

      void assertContents(Relationship relationship, List<String> expectedContent)
      Asserts that flowfiles on a given relationship have certain contents.
      Parameters:
      relationship - The relationship on which to check the contents of flowfiles
      expectedContent - The expected contents of all flowfiles
    • assertTransferCount

      void assertTransferCount(Relationship relationship, int count)
      Assert that the number of FlowFiles transferred to the given relationship is equal to the given count
      Parameters:
      relationship - to verify
      count - number of expected transfers
    • assertTransferCount

      void assertTransferCount(String relationship, int count)
      Assert that the number of FlowFiles transferred to the given relationship is equal to the given count
      Parameters:
      relationship - to verify
      count - number of expected transfers
    • assertPenalizeCount

      void assertPenalizeCount(int count)
      Assert that the number of FlowFiles that were penalized is equal to the given count
      Parameters:
      count - number of expected penalized
    • assertQueueEmpty

      void assertQueueEmpty()
      Assert that there are no FlowFiles left on the input queue.
    • isQueueEmpty

      boolean isQueueEmpty()
      Returns:
      true if the Input Queue to the Processor is empty, false otherwise
    • assertQueueNotEmpty

      void assertQueueNotEmpty()
      Assert that there is at least one FlowFile left on the input queue.
    • assertValid

      void assertValid()
      Assert that the currently configured set of properties/annotation data are valid
    • isValid

      boolean isValid()
    • assertNotValid

      void assertNotValid()
      Assert that the currently configured set of properties/annotation data are NOT valid
    • clearTransferState

      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. This method should be called between successive calls to run if the output is to be examined after each run.
    • enqueue

      void enqueue(FlowFile... flowFiles)
      Enqueues the given FlowFiles into the Processor's input queue
      Parameters:
      flowFiles - to enqueue
    • enqueue

      MockFlowFile enqueue(Path path) throws IOException
      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
      Parameters:
      path - to read content from
      Throws:
      IOException - if unable to read content
    • enqueue

      MockFlowFile enqueue(Path path, Map<String,String> attributes) throws IOException
      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
      Parameters:
      path - to read content from
      attributes - attributes to use for new flow file
      Throws:
      IOException - if unable to read content
    • enqueue

      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
      Parameters:
      data - to enqueue
    • enqueue

      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
      Parameters:
      data - to enqueue
    • enqueue

      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
      Parameters:
      data - to enqueue
      attributes - to use for enqueued item
    • enqueue

      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
      Parameters:
      data - to enqueue
      attributes - to use for enqueued item
    • enqueue

      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
      Parameters:
      data - to source data from
    • enqueue

      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
      Parameters:
      data - source of data
      attributes - to use for flow files
    • getContentAsByteArray

      byte[] getContentAsByteArray(MockFlowFile flowFile)
      Copies the contents of the given MockFlowFile into a byte array and returns that byte array.
      Parameters:
      flowFile - to get content for
      Returns:
      byte array of flowfile content
    • getFlowFilesForRelationship

      List<MockFlowFile> getFlowFilesForRelationship(String relationship)
      Returns a List of FlowFiles in the order in which they were transferred to the given relationship
      Parameters:
      relationship - to get flowfiles for
      Returns:
      flowfiles transferred to given relationship
    • getFlowFilesForRelationship

      List<MockFlowFile> getFlowFilesForRelationship(Relationship relationship)
      Returns a List of FlowFiles in the order in which they were transferred to the given relationship
      Parameters:
      relationship - to get flowfiles for
      Returns:
      flowfiles transferred to given relationship
    • getPenalizedFlowFiles

      List<MockFlowFile> getPenalizedFlowFiles()
      Returns a List of FlowFiles in the order in which they were transferred that were penalized
      Returns:
      flowfiles that were penalized
    • getQueueSize

      QueueSize getQueueSize()
      Returns:
      the current size of the Processor's Input Queue
    • getCounterValue

      Long getCounterValue(String name)
      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

      int getRemovedCount()
      Returns:
      the number of FlowFiles that have been removed from the system
    • setRelationshipAvailable

      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. This is generally used only when dealing with Processors that use the TriggerWhenAnyDestinationAvailable annotation.
      Parameters:
      relationship - to mark as available
    • setRelationshipAvailable

      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. This is generally used only when dealing with Processors that use the TriggerWhenAnyDestinationAvailable
      Parameters:
      relationshipName - relationship name
    • setRelationshipUnavailable

      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. This is generally used only when dealing with Processors that use the TriggerWhenAnyDestinationAvailable annotation.
      Parameters:
      relationship - to mark as unavailable
    • setRelationshipUnavailable

      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. This is generally used only when dealing with Processors that use the TriggerWhenAnyDestinationAvailable
      Parameters:
      relationshipName - name of relationship.
    • setIncomingConnection

      void setIncomingConnection(boolean hasIncomingConnection)
      Indicates to the framework that the configured processor has one or more incoming connections.
      Parameters:
      hasIncomingConnection - whether or not the configured processor should behave as though it has an incoming connection
    • setNonLoopConnection

      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.
      Parameters:
      hasNonLoopConnection - whether or not the configured processor should behave as though it has a non-looping incoming connection
    • addConnection

      void addConnection(Relationship relationship)
      Indicates to the Framework that the configured processor has a connection for the given Relationship.
      Parameters:
      relationship - that has a connection
    • addConnection

      void addConnection(String relationshipName)
      Indicates to the Framework that the configured processor has a connection for the Relationship with the given name.
      Parameters:
      relationshipName - name of relationship that has a connection
    • removeConnection

      void removeConnection(Relationship relationship)
      Removes the connection for the given Relationship from the configured processor.
      Parameters:
      relationship - to remove
    • removeConnection

      void removeConnection(String relationshipName)
      Removes the connection for the relationship with the given name from the configured processor.
      Parameters:
      relationshipName - name of the relationship to remove
    • addControllerService

      void addControllerService(String identifier, ControllerService service) throws InitializationException
      Adds the given 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.
      Parameters:
      identifier - of service
      service - the service
      Throws:
      InitializationException - ie
    • addControllerService

      void addControllerService(String identifier, ControllerService service, Map<String,String> properties) throws InitializationException
      Adds the given 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.
      Parameters:
      identifier - of service
      service - the service
      properties - service properties
      Throws:
      InitializationException - ie
    • enableControllerService

      void 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.

      Parameters:
      service - the service to enable
    • disableControllerService

      void 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.

      Parameters:
      service - the service to disable
    • isControllerServiceEnabled

      boolean isControllerServiceEnabled(ControllerService service)
      Parameters:
      service - the service
      Returns:
      true if the given Controller Service is enabled, false if it is disabled
      Throws:
      IllegalArgumentException - if the given ControllerService is not known by this TestRunner (i.e., it has not been added via the addControllerService(String, ControllerService) or addControllerService(String, ControllerService, Map) method or if the Controller Service has been removed via the removeControllerService(ControllerService) method.
    • removeControllerService

      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.

      Parameters:
      service - the service
      Throws:
      IllegalStateException - if the ControllerService is not disabled
      IllegalArgumentException - 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.
    • setProperty

      ValidationResult setProperty(ControllerService service, PropertyDescriptor property, String value)
      Sets the given property on the given ControllerService
      Parameters:
      service - to modify
      property - to modify
      value - value to use
      Returns:
      result
      Throws:
      IllegalStateException - if the ControllerService is not disabled
      IllegalArgumentException - 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.
    • setProperty

      ValidationResult setProperty(ControllerService service, PropertyDescriptor property, DescribedValue value)
      Sets the given property on the given ControllerService
      Parameters:
      service - to modify
      property - to modify
      value - value to use
      Returns:
      result
      Throws:
      IllegalStateException - if the ControllerService is not disabled
      IllegalArgumentException - 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.
    • setProperty

      ValidationResult setProperty(ControllerService service, String propertyName, String value)
      Sets the property with the given name on the given ControllerService
      Parameters:
      service - to modify
      propertyName - to modify
      value - value to use
      Returns:
      result
      Throws:
      IllegalStateException - if the ControllerService is not disabled
      IllegalArgumentException - 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.
    • setAnnotationData

      void setAnnotationData(ControllerService service, String annotationData)
      Sets the annotation data of the given service to the provided annotation data.
      Parameters:
      service - to modify
      annotationData - the data
      Throws:
      IllegalStateException - if the Controller Service is not disabled
      IllegalArgumentException - 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.
    • getControllerService

      ControllerService getControllerService(String identifier)
      Parameters:
      identifier - of controller service
      Returns:
      the ControllerService that is registered with the given identifier, or null if no Controller Service exists with the given identifier
    • assertValid

      void assertValid(ControllerService service)
      Assert that the currently configured set of properties/annotation data are valid for the given Controller Service.
      Parameters:
      service - the service to validate
      Throws:
      IllegalArgumentException - if the given ControllerService is not known by this TestRunner (i.e., it has not been added via the addControllerService(String, ControllerService) or addControllerService(String, ControllerService, Map) method or if the Controller Service has been removed via the removeControllerService(ControllerService) method.
    • assertNotValid

      void assertNotValid(ControllerService service)
      Assert that the currently configured set of properties/annotation data are NOT valid for the given Controller Service.
      Parameters:
      service - the service to validate
      Throws:
      IllegalArgumentException - if the given ControllerService is not known by this TestRunner (i.e., it has not been added via the addControllerService(String, ControllerService) or addControllerService(String, ControllerService, Map) method or if the Controller Service has been removed via the removeControllerService(ControllerService) method.
    • getControllerService

      <T extends ControllerService> T getControllerService(String identifier, Class<T> serviceType)
      Type Parameters:
      T - type of service
      Parameters:
      identifier - identifier of service
      serviceType - type of service
      Returns:
      the ControllerService that is registered with the given identifier, cast as the provided service type, or null if no Controller Service exists with the given identifier
      Throws:
      ClassCastException - if the identifier given is registered for a Controller Service but that Controller Service is not of the type specified
    • setValidateExpressionUsage

      void setValidateExpressionUsage(boolean validate)
      Specifies whether or not the TestRunner will validate the use of Expression Language. By default, the value is 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(ExpressionLanguageScope)

      Parameters:
      validate - whether there is any need to validate the EL was used
    • setAllowSynchronousSessionCommits

      void setAllowSynchronousSessionCommits(boolean allow)
      Specifies whether or not the TestRunner will allow ProcessSession.commit() to be called. By default, the value is false, meaning that any call to ProcessSession.commit() will throw an Exception. See JavaDocs for ProcessSession.commit() for more information
      Parameters:
      allow - whethr or not to allow asynchronous session commits (i.e., calls to ProcessSession.commit())
    • removeProperty

      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.
      Parameters:
      descriptor - of property to remove
      Returns:
      true if removed, false if the property was not set
    • removeProperty

      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.
      Parameters:
      controllerService - the controller service to remove the property from
      descriptor - of property to remove
      Returns:
      true if removed, false if the property was not set
    • removeProperty

      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.
      Parameters:
      property - name of the property to remove
      Returns:
      true if removed, false if the property was not set
    • removeProperty

      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.
      Parameters:
      controllerService - the controller service to remove the property from
      property - name of the property to remove
      Returns:
      true if removed, false if the property was not set
    • clearProperties

      void clearProperties()
      Clears all set properties from the ProcessContext.
    • getProvenanceEvents

      List<ProvenanceEventRecord> getProvenanceEvents()
      Returns a List of all ProvenanceEventRecords that were emitted by the Processor
      Returns:
      a List of all Provenance Events that were emitted by the Processor
    • clearProvenanceEvents

      void clearProvenanceEvents()
      Clears the Provenance Events that have been emitted by the Processor
    • getLogger

      MockComponentLog getLogger()
      Returns the MockComponentLog that is used by the Processor under test.
      Returns:
      the logger
    • getControllerServiceLogger

      MockComponentLog getControllerServiceLogger(String identifier)
      Returns the MockComponentLog that is used by the specified controller service.
      Parameters:
      identifier - a controller service identifier
      Returns:
      the logger
    • getStateManager

      MockStateManager getStateManager()
      Returns:
      the State Manager that is used to stored and retrieve state
    • getStateManager

      MockStateManager getStateManager(ControllerService service)
      Parameters:
      service - the controller service of interest
      Returns:
      the State Manager that is used to store and retrieve state for the given controller service
    • setClustered

      void setClustered(boolean clustered)
      Parameters:
      clustered - Specify if this test emulates running in a clustered environment
    • setIsConfiguredForClustering

      void setIsConfiguredForClustering(boolean isConfiguredForClustering)
      Parameters:
      isConfiguredForClustering - Specify if this test emulates running in an environment where the expected cluster state equals with the argument.
    • setPrimaryNode

      void setPrimaryNode(boolean primaryNode)
      Parameters:
      primaryNode - Specify if this test emulates running as a primary node
    • setConnected

      void setConnected(boolean isConnected)
      Parameters:
      isConnected - Specify if this test emulates ongoing cluster connection
    • getEnvironmentVariableValue

      String getEnvironmentVariableValue(String name)
      Returns the current value of the variable with the given name
      Parameters:
      name - the name of the variable whose value should be returned.
      Returns:
      the current value of the variable with the given name or null if no value is currently set
      Throws:
      NullPointerException - if the name is null
    • setEnvironmentVariableValue

      void setEnvironmentVariableValue(String name, String value)
      Sets 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.
      Parameters:
      name - the name of the variable to set
      value - the value of the variable
      Throws:
      NullPointerException - if either the name or the value is null
    • assertAllConditionsMet

      void assertAllConditionsMet(String relationshipName, Predicate<MockFlowFile> predicate)
      Asserts that all FlowFiles meet all conditions.
      Parameters:
      relationshipName - relationship name
      predicate - conditions
    • assertAllConditionsMet

      void assertAllConditionsMet(Relationship relationship, Predicate<MockFlowFile> predicate)
      Asserts that all FlowFiles meet all conditions.
      Parameters:
      relationship - relationship
      predicate - conditions
    • enforceReadStreamsClosed

      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. 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.
      Parameters:
      enforce - true if calls to session.commit() should fail if the read streams are not properly closed.
    • setRunSchedule

      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.
      Parameters:
      runSchedule - Run schedule duration in milliseconds.
    • assertProvenanceEvent

      void assertProvenanceEvent(ProvenanceEventType eventType)
      Assert that provenance event was created with the specified event type.
      Parameters:
      eventType - Provenance event type
    • migrateProperties

      PropertyMigrationResult migrateProperties()
      Causes the TestRunner to call the Processor's Processor.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.
      Returns:
      the results of migrating properties
    • migrateRelationships

      RelationshipMigrationResult migrateRelationships()
      Causes the TestRunner to call the Processor's Processor.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.
      Returns:
      the results of migrating relationships