private Computation<Integer> computation;
private ComputedValue<Integer> guard;
-
@Override
protected void setUp() throws Exception {
guard = new ComputedValue<Integer>(this, computation);
assertNull(guard.getCached());
-
+
when(computation.isOutOfDate()).thenReturn(true);
when(computation.compute()).thenReturn(10);
-
+
int value = guard.get();
assertEquals(10, value);
verify(computation).compute();
reset(computation);
}
-
- public void testGetCached() {
+
+ public void testGetCached() {
initGuard();
- assertEquals(10, (int)guard.getCached());
+ assertEquals(10, (int) guard.getCached());
verifyNoMoreInteractions(computation);
}