Package com.persequor.saga.componenttest
Class DatesTestHelper
java.lang.Object
com.persequor.saga.componenttest.DatesTestHelper
Setup like this:
@Mock
Dates dates;
DatesTestHelper datesTestHelper;
@Before
public void before() {
datesTestHelper = new DatesTestHelper(dates);
}
Then use like this:
datesTestHelper.setNow(Instant.now().minus(5, ChronoUnit.DAYS));
... do something ...
datesTestHelper.setOffset(Duration.ofMinutes(43));
... do something ...
datesTestHelper.addToOffset(Duration.ofMinutes(5));
... etc ...
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToOffset(Duration changeOfOffsetFromRealNow) protected longcurrentTimeMillis(org.mockito.invocation.InvocationOnMock invocation) protected ZonedDateTimenow(org.mockito.invocation.InvocationOnMock invocation) protected DatenowDate(org.mockito.invocation.InvocationOnMock invocation) protected InstantnowInstant(org.mockito.invocation.InvocationOnMock invocation) protected ZonedDateTimenowTruncatedToSeconds(org.mockito.invocation.InvocationOnMock invocation) voidvoidvoidprotected voidstep()
-
Field Details
-
realDates
-
nowOverride
-
offset
-
step
-
-
Constructor Details
-
DatesTestHelper
- Parameters:
mockDates- the mock of the Dates class that will be manipulated
-
-
Method Details
-
setNow
- Parameters:
newNow- all "now" methods will return this value (possibly truncated)
-
setOffset
- Parameters:
offsetFromRealNow- all "now" methods will return the real now plus this offset
-
addToOffset
- Parameters:
changeOfOffsetFromRealNow- all "now" methods will return the real now plus an offset that is incremented by this amount
-
setStep
- Parameters:
step- before every "now" call, the override/offset will be increased by this amount
-
step
protected void step() -
now
-
nowTruncatedToSeconds
-
nowInstant
-
nowDate
-
currentTimeMillis
protected long currentTimeMillis(org.mockito.invocation.InvocationOnMock invocation)
-