Package org.apache.nifi.util
Class MockProcessContext
java.lang.Object
org.apache.nifi.util.MockControllerServiceLookup
org.apache.nifi.util.MockProcessContext
- All Implemented Interfaces:
ClusterContext
,PropertyContext
,ControllerServiceLookup
,NodeTypeProvider
,ProcessContext
public class MockProcessContext
extends MockControllerServiceLookup
implements ProcessContext, ControllerServiceLookup, NodeTypeProvider
-
Field Summary
Modifier and TypeFieldDescriptionprivate boolean
private String
private final ConfigurableComponent
private final String
private Set
<Relationship> private boolean
private boolean
private InputRequirement
private boolean
private boolean
private boolean
private boolean
private int
private boolean
private final Map
<PropertyDescriptor, String> private final StateManager
private Set
<Relationship> private boolean
-
Constructor Summary
ConstructorDescriptionMockProcessContext
(ConfigurableComponent component) MockProcessContext
(ConfigurableComponent component, String componentName) MockProcessContext
(ConfigurableComponent component, String componentName, StateManager stateManager, Map<String, String> environmentVariables) Creates a new MockProcessContext for the given Processor with given nameMockProcessContext
(ConfigurableComponent component, StateManager stateManager) Creates a new MockProcessContext for the given ProcessorMockProcessContext
(ControllerService component, String componentName, MockProcessContext context, StateManager stateManager, Map<String, String> environmentVariables) MockProcessContext
(ControllerService component, MockProcessContext context, StateManager stateManager, Map<String, String> environmentVariables) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConnection
(Relationship relationship) void
addControllerService
(String serviceIdentifier, ControllerService controllerService, Map<PropertyDescriptor, String> properties, String annotationData) void
void
void
void
(package private) String
getControllerServiceAnnotationData
(ControllerService controllerService) (package private) Map
<PropertyDescriptor, String> getControllerServiceProperties
(ControllerService controllerService) int
getName()
getProperty
(String propertyName) getProperty
(PropertyDescriptor descriptor) getPropertyDescriptor
(String propertyName) getPropertyWithoutValidatingExpressions
(PropertyDescriptor propertyDescriptor) int
boolean
hasConnection
(Relationship relationship) boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
isRelationshipRetried
(Relationship relationship) boolean
isValid()
boolean
newPropertyValue
(String rawValue) void
removeConnection
(Relationship relationship) boolean
removeProperty
(String property) boolean
removeProperty
(PropertyDescriptor descriptor) void
setAnnotationData
(String annotationData) void
setClustered
(boolean clustered) void
setConnected
(boolean connected) void
setConnections
(Set<Relationship> connections) void
setIncomingConnection
(boolean hasIncomingConnection) void
setIsConfiguredForClustering
(boolean isConfiguredForClustering) void
setMaxConcurrentTasks
(int maxConcurrentTasks) void
setNonLoopConnection
(boolean hasNonLoopConnection) void
setPrimaryNode
(boolean primaryNode) setProperty
(String propertyName, String propertyValue) 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.void
setUnavailableRelationships
(Set<Relationship> relationships) void
setValidateExpressionUsage
(boolean validate) validate()
Validates the current properties, returning ValidationResults for any invalid properties.protected final Collection
<ValidationResult> validateReferencedControllerServices
(ValidationContext validationContext) void
yield()
Methods inherited from class org.apache.nifi.util.MockControllerServiceLookup
addControllerService, addControllerService, addControllerServices, getConfiguration, getControllerService, getControllerServiceIdentifiers, getControllerServiceName, getControllerServices, isControllerServiceEnabled, isControllerServiceEnabled, isControllerServiceEnabling, removeControllerService
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.nifi.controller.ControllerServiceLookup
getControllerService, getControllerServiceIdentifiers, getControllerServiceName, isControllerServiceEnabled, isControllerServiceEnabled, isControllerServiceEnabling
Methods inherited from interface org.apache.nifi.controller.NodeTypeProvider
getClusterMembers, getCurrentNode, isConnected
-
Field Details
-
component
-
componentName
-
properties
-
stateManager
-
annotationData
-
yieldCalled
private boolean yieldCalled -
enableExpressionValidation
private boolean enableExpressionValidation -
allowExpressionValidation
private boolean allowExpressionValidation -
incomingConnection
private volatile boolean incomingConnection -
nonLoopConnection
private volatile boolean nonLoopConnection -
inputRequirement
-
maxConcurrentTasks
private int maxConcurrentTasks -
connections
-
isClustered
private volatile boolean isClustered -
isConfiguredForClustering
private volatile boolean isConfiguredForClustering -
isPrimaryNode
private volatile boolean isPrimaryNode -
isConnected
private volatile boolean isConnected -
environmentVariables
-
-
Constructor Details
-
MockProcessContext
-
MockProcessContext
-
MockProcessContext
Creates a new MockProcessContext for the given Processor- Parameters:
component
- being mockedstateManager
- state manager
-
MockProcessContext
public MockProcessContext(ControllerService component, MockProcessContext context, StateManager stateManager, Map<String, String> environmentVariables) -
MockProcessContext
public MockProcessContext(ControllerService component, String componentName, MockProcessContext context, StateManager stateManager, Map<String, String> environmentVariables) -
MockProcessContext
public MockProcessContext(ConfigurableComponent component, String componentName, StateManager stateManager, Map<String, String> environmentVariables) Creates a new MockProcessContext for the given Processor with given name- Parameters:
component
- being mockedcomponentName
- the name to be given the component;stateManager
- state manager
-
-
Method Details
-
getProperty
- Specified by:
getProperty
in interfacePropertyContext
-
getPropertyWithoutValidatingExpressions
-
getProperty
- Specified by:
getProperty
in interfaceProcessContext
-
newPropertyValue
- Specified by:
newPropertyValue
in interfaceProcessContext
-
setProperty
-
getPropertyDescriptor
-
setProperty
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, the property value is not updated. In either case, the ValidationResult is returned, indicating whether or not the property is valid- Parameters:
descriptor
- of property to modifyvalue
- new value- Returns:
- result
-
removeProperty
-
removeProperty
-
clearProperties
public void clearProperties() -
yield
public void yield()- Specified by:
yield
in interfaceProcessContext
-
isYieldCalled
public boolean isYieldCalled() -
addControllerService
public void addControllerService(String serviceIdentifier, ControllerService controllerService, Map<PropertyDescriptor, String> properties, String annotationData) -
getMaxConcurrentTasks
public int getMaxConcurrentTasks()- Specified by:
getMaxConcurrentTasks
in interfaceProcessContext
-
getExecutionNode
- Specified by:
getExecutionNode
in interfaceProcessContext
-
setAnnotationData
-
getAnnotationData
- Specified by:
getAnnotationData
in interfaceProcessContext
-
getProperties
- Specified by:
getProperties
in interfaceProcessContext
-
getAllProperties
- Specified by:
getAllProperties
in interfacePropertyContext
-
validate
Validates the current properties, returning ValidationResults for any invalid properties. All processor defined properties will be validated. If they are not included in the in the purposed configuration, the default value will be used.- Returns:
- Collection of validation result objects for any invalid findings only. If the collection is empty then the processor is valid. Guaranteed non-null
-
validateReferencedControllerServices
protected final Collection<ValidationResult> validateReferencedControllerServices(ValidationContext validationContext) -
isValid
public boolean isValid() -
assertValid
public void assertValid() -
setValidateExpressionUsage
public void setValidateExpressionUsage(boolean validate) -
enableExpressionValidation
public void enableExpressionValidation() -
disableExpressionValidation
public void disableExpressionValidation() -
getControllerServiceProperties
-
getControllerServiceAnnotationData
-
getControllerServiceLookup
- Specified by:
getControllerServiceLookup
in interfaceProcessContext
-
getAvailableRelationships
- Specified by:
getAvailableRelationships
in interfaceProcessContext
-
hasIncomingConnection
public boolean hasIncomingConnection()- Specified by:
hasIncomingConnection
in interfaceProcessContext
-
setIncomingConnection
public void setIncomingConnection(boolean hasIncomingConnection) -
hasConnection
- Specified by:
hasConnection
in interfaceProcessContext
-
setNonLoopConnection
public void setNonLoopConnection(boolean hasNonLoopConnection) -
hasNonLoopConnection
public boolean hasNonLoopConnection()- Specified by:
hasNonLoopConnection
in interfaceProcessContext
-
addConnection
-
removeConnection
-
setConnections
-
isExpressionLanguagePresent
- Specified by:
isExpressionLanguagePresent
in interfaceProcessContext
-
getStateManager
- Specified by:
getStateManager
in interfaceProcessContext
-
getName
- Specified by:
getName
in interfaceProcessContext
-
setMaxConcurrentTasks
public void setMaxConcurrentTasks(int maxConcurrentTasks) -
isClustered
public boolean isClustered()- Specified by:
isClustered
in interfaceNodeTypeProvider
-
isConfiguredForClustering
public boolean isConfiguredForClustering()- Specified by:
isConfiguredForClustering
in interfaceNodeTypeProvider
-
isPrimary
public boolean isPrimary()- Specified by:
isPrimary
in interfaceNodeTypeProvider
-
setClustered
public void setClustered(boolean clustered) -
setIsConfiguredForClustering
public void setIsConfiguredForClustering(boolean isConfiguredForClustering) -
setPrimaryNode
public void setPrimaryNode(boolean primaryNode) -
getInputRequirement
- Overrides:
getInputRequirement
in classMockControllerServiceLookup
-
setConnected
public void setConnected(boolean connected) -
isConnectedToCluster
public boolean isConnectedToCluster()- Specified by:
isConnectedToCluster
in interfaceClusterContext
-
getRetryCount
public int getRetryCount()- Specified by:
getRetryCount
in interfaceProcessContext
-
isRelationshipRetried
- Specified by:
isRelationshipRetried
in interfaceProcessContext
-
getEnvironmentVariables
-