Package de.gebit.integrity.runner.time

## Class SimpleTestTimeAdapter

- java.lang.Object
- - de.gebit.integrity.runner.time.SimpleTestTimeAdapter

- All Implemented Interfaces:
    `TestTimeAdapter`

      public class SimpleTestTimeAdapter
      extends Object
      implements TestTimeAdapter

  A simple default implementation of a `TestTimeAdapter`, which just tries to instantiate the "real" adapter implemented by the system-under-test by resolving the class name of a system property. The adapter shall then forward the parameters to the actual time proxy implementation.
  You can either use this mechanism to inject your adapter or, if you think it's a little bit dirty to use a system property, you can also override this adapter directly by specifying a different one in a custom subclass of the `IntegrityRunnerModule` (the same class where you can basically customize the entire service set of internal Integrity services).
  Author:
    Rene Schneider - initial API and implementation

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected Method` | `accessorMethod` | The method used to access the adapter.
    `protected ClassLoader` | `classLoader` | The classloader to use when resolving `SUT_TIME_ADAPTER_CLASS_PROPERTY`.
    `static String` | `SUT_TIME_ADAPTER_CLASS_PROPERTY` | The system property used by this adapter to instantiate the actual adapter supplied by the system-under-test, which has the purpose to forward the fake time parameters to the test time provider in the application.
    `protected Object` | `systemUnderTestAdapter` | The adapter provided by the system-under-test.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `SimpleTestTimeAdapter()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `setInternalState​(long aRealtimeOffset, long aRealtimeDecouplingTime, double aProgressionFactor)` | Sets the internal state of an entity that can use this state to calculate a "fake" current date and time that is to be used for the system under test.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SUT_TIME_ADAPTER_CLASS_PROPERTY

          public static final String SUT_TIME_ADAPTER_CLASS_PROPERTY

      The system property used by this adapter to instantiate the actual adapter supplied by the system-under-test, which has the purpose to forward the fake time parameters to the test time provider in the application.
      See Also:
        Constant Field Values

    - #### systemUnderTestAdapter

          protected Object systemUnderTestAdapter

      The adapter provided by the system-under-test.

    - #### accessorMethod

          protected Method accessorMethod

      The method used to access the adapter. If this is null, the `systemUnderTestAdapter` was found to be an implementation of `TestTimeAdapter` and thus can be called directly without Reflection.

    - #### classLoader

          @Inject
          protected ClassLoader classLoader

      The classloader to use when resolving `SUT_TIME_ADAPTER_CLASS_PROPERTY`.

  - ### Constructor Detail

    - #### SimpleTestTimeAdapter

          public SimpleTestTimeAdapter()

  - ### Method Detail

    - #### setInternalState

          public void setInternalState​(long aRealtimeOffset,
                                       long aRealtimeDecouplingTime,
                                       double aProgressionFactor)

      Description copied from interface: `TestTimeAdapter`
      Sets the internal state of an entity that can use this state to calculate a "fake" current date and time that is to be used for the system under test. Depending on the parameters, the time is intended to be frozen (if no progression factor or one of 0.0 is provided) or to progress at a certain speed relative to real-time. From the provided parameters, an accurate test time can be calculated. For an example how this can be done, see `TimeAndDateSingleton`.
      If the realtime offset is zero and the progression factor is exactly 1.0, this means that the "fake test time" is reverted to actual realtime.
      Specified by:
        `setInternalState` in interface `TestTimeAdapter`
      Parameters:
        `aRealtimeOffset` - the offset of our test time from real system time (wall clock)
        `aRealtimeDecouplingTime` - the point in real time at which our test time was decoupled from system time
        `aProgressionFactor` - the speed at which the test time should progress (1.0 is normal speed, progression factor may be negative too, or 0.0, which means time is frozen)