Package org.apache.nifi.state
Class MockStateManager
java.lang.Object
org.apache.nifi.state.MockStateManager
- All Implemented Interfaces:
org.apache.nifi.components.state.StateManager
public class MockStateManager
extends Object
implements org.apache.nifi.components.state.StateManager
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicLongprivate org.apache.nifi.components.state.StateMapprivate MockStateManager.ExecutionModeprivate booleanprivate booleanprivate booleanprivate booleanprivate booleanprivate final AtomicLongprivate org.apache.nifi.components.state.StateMapprivate final booleanprivate final booleanprivate final AtomicInteger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidassertStateEquals(String key, String value, org.apache.nifi.components.state.Scope scope) Ensures that the state with the given key and scope is set to the given value, or else the test will failvoidassertStateEquals(Map<String, String> stateValues, org.apache.nifi.components.state.Scope scope) Ensures that the state is equal to the given valuesvoidassertStateNotEquals(String key, String value, org.apache.nifi.components.state.Scope scope) Ensures that the state with the given key and scope is not set to the given value, or else the test will failvoidassertStateNotEquals(Map<String, String> stateValues, org.apache.nifi.components.state.Scope scope) Ensures that the state is not equal to the given valuesvoidEnsures that state was not set for any scopevoidassertStateNotSet(String key, org.apache.nifi.components.state.Scope scope) Ensures that no value is set for the given key and scope, or else the test will failvoidassertStateNotSet(org.apache.nifi.components.state.Scope scope) Ensures that the state was not set for the given scopevoidassertStateSet(String key, org.apache.nifi.components.state.Scope scope) Ensures that some value is set for the given key and scope, or else the test will failvoidassertStateSet(org.apache.nifi.components.state.Scope scope) Ensures that the state was set for the given scope, regardless of what the value was.voidclear(org.apache.nifi.components.state.Scope scope) longgetRetrievalCount(org.apache.nifi.components.state.Scope scope) org.apache.nifi.components.state.StateMapgetState(org.apache.nifi.components.state.Scope scope) private Stringbooleanreplace(org.apache.nifi.components.state.StateMap oldValue, Map<String, String> newValue, org.apache.nifi.components.state.Scope scope) voidreset()private org.apache.nifi.components.state.StateMapretrieveState(org.apache.nifi.components.state.Scope scope) voidsetExecutionMode(MockStateManager.ExecutionMode executionMode) voidsetFailOnStateGet(org.apache.nifi.components.state.Scope scope, boolean fail) Specifies whether or not the State Manager should throw an IOException when state is retrieved for the given scope.voidsetFailOnStateSet(org.apache.nifi.components.state.Scope scope, boolean fail) Specifies whether or not the State Manager should throw an IOException when state is set for the given scope.voidsetIgnoreAnnotations(boolean ignore) voidprivate voidverifyAnnotation(org.apache.nifi.components.state.Scope scope) private voidverifyCanGet(org.apache.nifi.components.state.Scope scope) private voidverifyCanSet(org.apache.nifi.components.state.Scope scope) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.nifi.components.state.StateManager
isStateKeyDropSupported
-
Field Details
-
versionIndex
-
localStateMap
private org.apache.nifi.components.state.StateMap localStateMap -
clusterStateMap
private org.apache.nifi.components.state.StateMap clusterStateMap -
failToGetLocalState
private volatile boolean failToGetLocalState -
failToSetLocalState
private volatile boolean failToSetLocalState -
failToGetClusterState
private volatile boolean failToGetClusterState -
failToSetClusterState
private volatile boolean failToSetClusterState -
ignoreAnnotations
private volatile boolean ignoreAnnotations -
localRetrievedCount
-
clusterRetrievedCount
-
usesLocalState
private final boolean usesLocalState -
usesClusterState
private final boolean usesClusterState -
executionMode
-
-
Constructor Details
-
MockStateManager
-
-
Method Details
-
reset
public void reset() -
setExecutionMode
-
setState
public void setState(Map<String, String> state, org.apache.nifi.components.state.Scope scope) throws IOException- Specified by:
setStatein interfaceorg.apache.nifi.components.state.StateManager- Throws:
IOException
-
getState
public org.apache.nifi.components.state.StateMap getState(org.apache.nifi.components.state.Scope scope) throws IOException - Specified by:
getStatein interfaceorg.apache.nifi.components.state.StateManager- Throws:
IOException
-
retrieveState
private org.apache.nifi.components.state.StateMap retrieveState(org.apache.nifi.components.state.Scope scope) -
getRetrievalCount
public long getRetrievalCount(org.apache.nifi.components.state.Scope scope) -
replace
public boolean replace(org.apache.nifi.components.state.StateMap oldValue, Map<String, String> newValue, org.apache.nifi.components.state.Scope scope) throws IOException- Specified by:
replacein interfaceorg.apache.nifi.components.state.StateManager- Throws:
IOException
-
clear
- Specified by:
clearin interfaceorg.apache.nifi.components.state.StateManager- Throws:
IOException
-
verifyCanSet
- Throws:
IOException
-
verifyCanGet
- Throws:
IOException
-
setIgnoreAnnotations
public void setIgnoreAnnotations(boolean ignore) -
verifyAnnotation
private void verifyAnnotation(org.apache.nifi.components.state.Scope scope) -
getValue
-
assertStateEquals
public void assertStateEquals(String key, String value, org.apache.nifi.components.state.Scope scope) Ensures that the state with the given key and scope is set to the given value, or else the test will fail- Parameters:
key- the state keyvalue- the expected valuescope- the scope
-
assertStateEquals
public void assertStateEquals(Map<String, String> stateValues, org.apache.nifi.components.state.Scope scope) Ensures that the state is equal to the given values- Parameters:
stateValues- the values expectedscope- the scope to compare the stateValues against
-
assertStateNotEquals
public void assertStateNotEquals(Map<String, String> stateValues, org.apache.nifi.components.state.Scope scope) Ensures that the state is not equal to the given values- Parameters:
stateValues- the unexpected valuesscope- the scope to compare the stateValues against
-
assertStateNotEquals
public void assertStateNotEquals(String key, String value, org.apache.nifi.components.state.Scope scope) Ensures that the state with the given key and scope is not set to the given value, or else the test will fail- Parameters:
key- the state keyvalue- the unexpected valuescope- the scope
-
assertStateSet
Ensures that some value is set for the given key and scope, or else the test will fail- Parameters:
key- the state keyscope- the scope
-
assertStateNotSet
Ensures that no value is set for the given key and scope, or else the test will fail- Parameters:
key- the state keyscope- the scope
-
assertStateSet
public void assertStateSet(org.apache.nifi.components.state.Scope scope) Ensures that the state was set for the given scope, regardless of what the value was.- Parameters:
scope- the scope
-
assertStateNotSet
public void assertStateNotSet()Ensures that state was not set for any scope -
assertStateNotSet
public void assertStateNotSet(org.apache.nifi.components.state.Scope scope) Ensures that the state was not set for the given scope- Parameters:
scope- the scope
-
setFailOnStateSet
public void setFailOnStateSet(org.apache.nifi.components.state.Scope scope, boolean fail) Specifies whether or not the State Manager should throw an IOException when state is set for the given scope. Note that calls toreplace(StateMap, Map, Scope)will fail only if the state would be set (i.e., if we call replace and the StateMap does not match the old value, it will not fail). Also note that if setting state is set to fail, clearing will also fail, as clearing is thought of as setting the state to empty- Parameters:
scope- the scope that should (or should not) failfail- whether or not setting state should fail
-
setFailOnStateGet
public void setFailOnStateGet(org.apache.nifi.components.state.Scope scope, boolean fail) Specifies whether or not the State Manager should throw an IOException when state is retrieved for the given scope.- Parameters:
scope- the scope that should (or should not) failfail- whether or not retrieving state should fail
-