Unit Tests
NiFi's Mock Framework provides an extensive collection of tools to perform unit testing of Processors. Processor unit tests typically begin with the TestRunner
class. As a result, the TestRunner
class contains a getStateManager
method of its own. The StateManager that is returned, however, is of a specific type: MockStateManager
. This implementation provides several methods in addition to those defined by the StateManager
interface, that help developers to more easily develop unit tests.
First, the MockStateManager
implements the StateManager
interface, so all of the state can be examined from within a unit test. Additionally, the MockStateManager
exposes a handful of assert*
methods to perform assertions that the State is set as expected. The MockStateManager
also provides the ability to indicate that the unit test should immediately fail if state is updated for a particular Scope
.