Class MockProcessContext

All Implemented Interfaces:
org.apache.nifi.context.ClusterContext, org.apache.nifi.context.PropertyContext, org.apache.nifi.controller.ControllerServiceLookup, org.apache.nifi.controller.NodeTypeProvider, org.apache.nifi.processor.ProcessContext

public class MockProcessContext extends MockControllerServiceLookup implements org.apache.nifi.processor.ProcessContext, org.apache.nifi.controller.ControllerServiceLookup, org.apache.nifi.controller.NodeTypeProvider
  • Field Details

    • component

      private final org.apache.nifi.components.ConfigurableComponent component
    • componentName

      private final String componentName
    • properties

      private final Map<org.apache.nifi.components.PropertyDescriptor,String> properties
    • stateManager

      private final org.apache.nifi.components.state.StateManager stateManager
    • annotationData

      private String annotationData
    • yieldCalled

      private boolean yieldCalled
    • allowExpressionValidation

      private boolean allowExpressionValidation
    • incomingConnection

      private volatile boolean incomingConnection
    • nonLoopConnection

      private volatile boolean nonLoopConnection
    • inputRequirement

      private volatile org.apache.nifi.annotation.behavior.InputRequirement inputRequirement
    • maxConcurrentTasks

      private int maxConcurrentTasks
    • connections

      private volatile Set<org.apache.nifi.processor.Relationship> connections
    • unavailableRelationships

      private volatile Set<org.apache.nifi.processor.Relationship> unavailableRelationships
    • isClustered

      private volatile boolean isClustered
    • isConfiguredForClustering

      private volatile boolean isConfiguredForClustering
    • isPrimaryNode

      private volatile boolean isPrimaryNode
    • isConnected

      private volatile boolean isConnected
    • environmentVariables

      private final Map<String,String> environmentVariables
    • parameterLookup

      private final ParameterLookup parameterLookup
  • Constructor Details

    • MockProcessContext

      public MockProcessContext(org.apache.nifi.components.ConfigurableComponent component)
    • MockProcessContext

      public MockProcessContext(org.apache.nifi.components.ConfigurableComponent component, String componentName)
    • MockProcessContext

      public MockProcessContext(org.apache.nifi.components.ConfigurableComponent component, org.apache.nifi.components.state.StateManager stateManager)
      Creates a new MockProcessContext for the given Processor
      Parameters:
      component - being mocked
      stateManager - state manager
    • MockProcessContext

      public MockProcessContext(org.apache.nifi.controller.ControllerService component, MockProcessContext context, org.apache.nifi.components.state.StateManager stateManager, Map<String,String> environmentVariables)
    • MockProcessContext

      public MockProcessContext(org.apache.nifi.controller.ControllerService component, String componentName, MockProcessContext context, org.apache.nifi.components.state.StateManager stateManager, Map<String,String> environmentVariables)
    • MockProcessContext

      public MockProcessContext(org.apache.nifi.components.ConfigurableComponent component, String componentName, org.apache.nifi.components.state.StateManager stateManager, Map<String,String> environmentVariables)
      Creates a new MockProcessContext for the given Processor with given name
      Parameters:
      component - being mocked
      componentName - the name to be given the component;
      stateManager - state manager
    • MockProcessContext

      public MockProcessContext(org.apache.nifi.components.ConfigurableComponent component, String componentName, org.apache.nifi.components.state.StateManager stateManager, Map<String,String> environmentVariables, Map<String,String> contextParameters)
      Creates a new MockProcessContext for the given Processor with given name
      Parameters:
      component - being mocked
      componentName - the name to be given the component;
      stateManager - state manager
      environmentVariables - the environment variables
      contextParameters - the context parameters
  • Method Details

    • getProperty

      public org.apache.nifi.components.PropertyValue getProperty(org.apache.nifi.components.PropertyDescriptor descriptor)
      Specified by:
      getProperty in interface org.apache.nifi.context.PropertyContext
    • getPropertyWithoutValidatingExpressions

      public org.apache.nifi.components.PropertyValue getPropertyWithoutValidatingExpressions(org.apache.nifi.components.PropertyDescriptor propertyDescriptor)
    • getProperty

      public org.apache.nifi.components.PropertyValue getProperty(String propertyName)
      Specified by:
      getProperty in interface org.apache.nifi.processor.ProcessContext
    • determineUnsatisfiedDependencies

      private List<MockProcessContext.ValidatedPropertyDependency> determineUnsatisfiedDependencies(org.apache.nifi.components.PropertyDescriptor descriptor)
    • validatedDependencies

      private List<MockProcessContext.ValidatedPropertyDependency> validatedDependencies(org.apache.nifi.components.PropertyDescriptor descriptor)
    • newPropertyValue

      public org.apache.nifi.components.PropertyValue newPropertyValue(String rawValue)
      Specified by:
      newPropertyValue in interface org.apache.nifi.processor.ProcessContext
    • setProperty

      public org.apache.nifi.components.ValidationResult setProperty(String propertyName, String propertyValue)
    • getPropertyDescriptor

      public org.apache.nifi.components.PropertyDescriptor getPropertyDescriptor(String propertyName)
    • setProperty

      public org.apache.nifi.components.ValidationResult setProperty(org.apache.nifi.components.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, 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 modify
      value - new value
      Returns:
      result
    • removeProperty

      public boolean removeProperty(org.apache.nifi.components.PropertyDescriptor descriptor)
    • removeProperty

      public boolean removeProperty(String property)
    • clearProperties

      public void clearProperties()
    • yield

      public void yield()
      Specified by:
      yield in interface org.apache.nifi.processor.ProcessContext
    • isYieldCalled

      public boolean isYieldCalled()
    • addControllerService

      public void addControllerService(org.apache.nifi.controller.ControllerService controllerService, Map<org.apache.nifi.components.PropertyDescriptor,String> properties, String annotationData)
    • getMaxConcurrentTasks

      public int getMaxConcurrentTasks()
      Specified by:
      getMaxConcurrentTasks in interface org.apache.nifi.processor.ProcessContext
    • getExecutionNode

      public org.apache.nifi.scheduling.ExecutionNode getExecutionNode()
      Specified by:
      getExecutionNode in interface org.apache.nifi.processor.ProcessContext
    • setAnnotationData

      public void setAnnotationData(String annotationData)
    • getAnnotationData

      public String getAnnotationData()
      Specified by:
      getAnnotationData in interface org.apache.nifi.processor.ProcessContext
    • getProperties

      public Map<org.apache.nifi.components.PropertyDescriptor,String> getProperties()
      Specified by:
      getProperties in interface org.apache.nifi.processor.ProcessContext
    • getAllProperties

      public Map<String,String> getAllProperties()
      Specified by:
      getAllProperties in interface org.apache.nifi.context.PropertyContext
    • validate

      public Collection<org.apache.nifi.components.ValidationResult> 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<org.apache.nifi.components.ValidationResult> validateReferencedControllerServices(org.apache.nifi.components.ValidationContext validationContext)
    • isValid

      public boolean isValid()
    • assertValid

      public void assertValid()
    • setValidateExpressionUsage

      public void setValidateExpressionUsage(boolean validate)
    • getControllerServiceProperties

      Map<org.apache.nifi.components.PropertyDescriptor,String> getControllerServiceProperties(org.apache.nifi.controller.ControllerService controllerService)
    • getControllerServiceAnnotationData

      String getControllerServiceAnnotationData(org.apache.nifi.controller.ControllerService controllerService)
    • getControllerServiceLookup

      public org.apache.nifi.controller.ControllerServiceLookup getControllerServiceLookup()
      Specified by:
      getControllerServiceLookup in interface org.apache.nifi.processor.ProcessContext
    • getAllRelationships

      public Set<org.apache.nifi.processor.Relationship> getAllRelationships()
    • getAvailableRelationships

      public Set<org.apache.nifi.processor.Relationship> getAvailableRelationships()
      Specified by:
      getAvailableRelationships in interface org.apache.nifi.processor.ProcessContext
    • isAutoTerminated

      public boolean isAutoTerminated(org.apache.nifi.processor.Relationship relationship)
      Specified by:
      isAutoTerminated in interface org.apache.nifi.processor.ProcessContext
    • setUnavailableRelationships

      public void setUnavailableRelationships(Set<org.apache.nifi.processor.Relationship> relationships)
    • getUnavailableRelationships

      public Set<org.apache.nifi.processor.Relationship> getUnavailableRelationships()
    • hasIncomingConnection

      public boolean hasIncomingConnection()
      Specified by:
      hasIncomingConnection in interface org.apache.nifi.processor.ProcessContext
    • setIncomingConnection

      public void setIncomingConnection(boolean hasIncomingConnection)
    • hasConnection

      public boolean hasConnection(org.apache.nifi.processor.Relationship relationship)
      Specified by:
      hasConnection in interface org.apache.nifi.processor.ProcessContext
    • setNonLoopConnection

      public void setNonLoopConnection(boolean hasNonLoopConnection)
    • hasNonLoopConnection

      public boolean hasNonLoopConnection()
      Specified by:
      hasNonLoopConnection in interface org.apache.nifi.processor.ProcessContext
    • addConnection

      public void addConnection(org.apache.nifi.processor.Relationship relationship)
    • removeConnection

      public void removeConnection(org.apache.nifi.processor.Relationship relationship)
    • clearConnections

      public void clearConnections()
    • setConnections

      public void setConnections(Set<org.apache.nifi.processor.Relationship> connections)
    • isExpressionLanguagePresent

      public boolean isExpressionLanguagePresent(org.apache.nifi.components.PropertyDescriptor property)
      Specified by:
      isExpressionLanguagePresent in interface org.apache.nifi.processor.ProcessContext
    • getStateManager

      public org.apache.nifi.components.state.StateManager getStateManager()
      Specified by:
      getStateManager in interface org.apache.nifi.processor.ProcessContext
    • getName

      public String getName()
      Specified by:
      getName in interface org.apache.nifi.processor.ProcessContext
    • setMaxConcurrentTasks

      public void setMaxConcurrentTasks(int maxConcurrentTasks)
    • isClustered

      public boolean isClustered()
      Specified by:
      isClustered in interface org.apache.nifi.controller.NodeTypeProvider
    • isConfiguredForClustering

      public boolean isConfiguredForClustering()
      Specified by:
      isConfiguredForClustering in interface org.apache.nifi.controller.NodeTypeProvider
    • isPrimary

      public boolean isPrimary()
      Specified by:
      isPrimary in interface org.apache.nifi.controller.NodeTypeProvider
    • setClustered

      public void setClustered(boolean clustered)
    • setIsConfiguredForClustering

      public void setIsConfiguredForClustering(boolean isConfiguredForClustering)
    • setPrimaryNode

      public void setPrimaryNode(boolean primaryNode)
    • getInputRequirement

      public org.apache.nifi.annotation.behavior.InputRequirement getInputRequirement()
      Overrides:
      getInputRequirement in class MockControllerServiceLookup
    • setConnected

      public void setConnected(boolean connected)
    • isConnectedToCluster

      public boolean isConnectedToCluster()
      Specified by:
      isConnectedToCluster in interface org.apache.nifi.context.ClusterContext
    • getRetryCount

      public int getRetryCount()
      Specified by:
      getRetryCount in interface org.apache.nifi.processor.ProcessContext
    • isRelationshipRetried

      public boolean isRelationshipRetried(org.apache.nifi.processor.Relationship relationship)
      Specified by:
      isRelationshipRetried in interface org.apache.nifi.processor.ProcessContext
    • getEnvironmentVariables

      public Map<String,String> getEnvironmentVariables()