Class TestProcessingUnitRunner

  • All Implemented Interfaces:
    java.io.Serializable

    public class TestProcessingUnitRunner
    extends java.lang.Object
    implements java.io.Serializable
    Implements a simple processing unit runner. It's made to use in unit tests.
    See Also:
    Serialized Form
    • Constructor Detail

      • TestProcessingUnitRunner

        protected TestProcessingUnitRunner()
        Constructor
    • Method Detail

      • runAndAbort

        public long runAndAbort​(java.lang.Class<? extends IProcessingUnit> processingUnitClass,
                                java.util.List<Parameter> parameterList,
                                java.lang.Integer numberOfCyclesBeforeStop)
                         throws ValidationException,
                                ProcessingException
        Run processing unit and abort after some cycles
        Parameters:
        processingUnitClass - the processing unit class
        parameterList - the parameter list
        numberOfCyclesBeforeStop - the number of cycles before stop
        Returns:
        the number of cycles
        Throws:
        ValidationException - In case the processing can not be initilized
        ProcessingException - In case of an error in a processing
      • runWithThrottling

        public long runWithThrottling​(java.lang.Class<? extends IProcessingUnit> processingUnitClass,
                                      java.util.List<Parameter> parameterList,
                                      java.lang.Long maxNumberOfProcessingUnitCallsPerSecond)
                               throws ValidationException,
                                      ProcessingException
        Run processing unit and abort after some cycles
        Parameters:
        processingUnitClass - the processing unit class
        parameterList - the parameter list
        maxNumberOfProcessingUnitCallsPerSecond - the max number of calls per second of the processing unit
        Returns:
        the number of cycles
        Throws:
        ValidationException - In case the processing can not be initilized
        ProcessingException - In case of an error in a processing
      • runWithSuspendAndResume

        public long runWithSuspendAndResume​(java.lang.Class<? extends IProcessingUnit> processingUnitClass,
                                            java.util.List<Parameter> parameterList,
                                            long suspendAfterCycles,
                                            long suspendSleepTime,
                                            int maxNumberOfSuspends)
                                     throws ValidationException,
                                            ProcessingException
        Run processing unit
        Parameters:
        processingUnitClass - the processing unit class
        parameterList - the parameter list
        suspendAfterCycles - after the number of cycles it will suspended
        suspendSleepTime - the sleep time after suspending or null
        maxNumberOfSuspends - the max number of suspends
        Returns:
        the number of cycles
        Throws:
        ValidationException - In case the processing can not be initilized
        ProcessingException - In case of an error in a processing
      • runWithSuspendAndResume

        public long runWithSuspendAndResume​(java.lang.Class<? extends IProcessingUnit> processingUnitClass,
                                            java.util.List<Parameter> parameterList,
                                            long suspendAfterCycles,
                                            long suspendSleepTime,
                                            int maxNumberOfSuspends,
                                            java.lang.Long maxNumberOfProcessingUnitCallsPerSecond)
                                     throws ValidationException,
                                            ProcessingException
        Run processing unit
        Parameters:
        processingUnitClass - the processing unit class
        parameterList - the parameter list
        suspendAfterCycles - after the number of cycles it will suspended
        suspendSleepTime - the sleep time after suspending or null
        maxNumberOfSuspends - the max number of suspends
        maxNumberOfProcessingUnitCallsPerSecond - the max number of calls per second of the processing unit
        Returns:
        the number of cycles
        Throws:
        ValidationException - In case the processing can not be initilized
        ProcessingException - In case of an error in a processing
      • processingUnitContext

        public TestProcessingUnitRunner processingUnitContext​(IProcessingUnitContext processingUnitContext)
        Set the processing context
        Parameters:
        processingUnitContext - the processing unit context
        Returns:
        this instance
      • getSuspendCounter

        public int getSuspendCounter()
        Gets the suspend counter
        Returns:
        the suspend counter
      • getId

        public java.lang.String getId()
        Get the runnable id
        Returns:
        the runnable id
      • getName

        public java.lang.String getName()
        Get the runnable name or null
        Returns:
        the name or null
      • getProcessingActionStatus

        public ProcessingActionStatus getProcessingActionStatus()
        Get the processing action status
        Returns:
        the processing action status
      • getProcessingUnitProgress

        public IProcessingUnitProgress getProcessingUnitProgress()
        Gets the processing unit progress
        Returns:
        the processing unit progress
      • getProcessingRuntimeStatus

        public ProcessingRuntimeStatus getProcessingRuntimeStatus()
        Get the processing runtime status
        Returns:
        the processing runtime status
      • getStatusMessageList

        public java.util.List<java.lang.String> getStatusMessageList()
        Get the status message list
        Returns:
        the status message list
      • getProcesingUnit

        public <T extends IProcessingUnit> T getProcesingUnit()
        Get the processing unit. IMPORTANT: Only to verify some results
        Type Parameters:
        T - the processing unit type
        Returns:
        the processing unit
      • getParameterList

        public java.util.List<Parameter> getParameterList()
        Get the processing parameter list.
        Returns:
        the processing parameter list
      • getProcessingUnitThrottling

        public com.github.toolarium.common.bandwidth.IBandwidthThrottling getProcessingUnitThrottling()
        Get the processing unit throttling
        Returns:
        the processing unit throttling
      • getEmptyProcessingUnitHandler

        public IEmptyProcessingUnitHandler getEmptyProcessingUnitHandler()
        Get the empty processing unit handler
        Returns:
        the empty processing unit handler
      • setEmptyProcessingUnitHandler

        public void setEmptyProcessingUnitHandler​(IEmptyProcessingUnitHandler emptyProcessingUnitHandler)
        Set the empty processing unit handler
        Parameters:
        emptyProcessingUnitHandler - the empty processing unit handler
      • getProcessingUnitContext

        public IProcessingUnitContext getProcessingUnitContext()
        Get the processing unit context
        Returns:
        the processing unit context
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()