I have a validation object that triggers input through a series of validations. If the input signal does not pass any tests, the completion of the test is completed.
Inputs that pass all checks are grouped based on a sliding time window. This window starts when the first part of the input arrives. So this is the thread:
1) The first entrance comes. 2) The entrance goes through all the checks. 3) Since there is no active timer, input is entered into a new bin. The timer window starts within N seconds. 4) Any subsequent input that passes all the checks in this timer window will be grouped into one basket. 5) As soon as the timer goes out, the basket is sent. 6) Any additional valid input starts a new timer, and the process repeats.
Right now, to make sure the correct inputs are grouped correctly, I use Thread.sleep in unit tests (i.e. as soon as I send multiple inputs, I sleep for a few seconds and then wake up and make sure that the basket that was sent, contains everything expected).
This starts to get annoying as I have over 700 unit tests, and this test collection is a bottleneck every time I run the full package.
The time window is just a ScheduledExecutorService. To test this functionality faster, do I have to create a custom time window object?
source
share