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 TypeMethodDescriptionvoid
addToOffset
(Duration changeOfOffsetFromRealNow) protected long
currentTimeMillis
(org.mockito.invocation.InvocationOnMock invocation) protected ZonedDateTime
now
(org.mockito.invocation.InvocationOnMock invocation) protected Date
nowDate
(org.mockito.invocation.InvocationOnMock invocation) protected Instant
nowInstant
(org.mockito.invocation.InvocationOnMock invocation) protected ZonedDateTime
nowTruncatedToSeconds
(org.mockito.invocation.InvocationOnMock invocation) void
void
void
protected void
step()
-
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)
-