git://wamblee.org
/
utils
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(no commit message)
[utils]
/
wicket
/
joe
/
src
/
test
/
java
/
org
/
wamblee
/
wicket
/
model
/
DetachableEntityTest.java
diff --git
a/wicket/joe/src/test/java/org/wamblee/wicket/model/DetachableEntityTest.java
b/wicket/joe/src/test/java/org/wamblee/wicket/model/DetachableEntityTest.java
index e4cf731711bc897dea589c919ae96a2ca9550ce5..3346be63e0ad23ef30ae1c49b13aaab5843d957d 100644
(file)
--- a/
wicket/joe/src/test/java/org/wamblee/wicket/model/DetachableEntityTest.java
+++ b/
wicket/joe/src/test/java/org/wamblee/wicket/model/DetachableEntityTest.java
@@
-28,22
+28,27
@@
public class DetachableEntityTest {
}
}
+ private X initialValue;
private Detachable<X> detachable;
private DetachableEntity<X> entity;
@Before
public void setUp() {
private Detachable<X> detachable;
private DetachableEntity<X> entity;
@Before
public void setUp() {
+ initialValue = mock(X.class);
detachable = mock(Detachable.class);
detachable = mock(Detachable.class);
+ when(detachable.get()).thenReturn(initialValue);
entity = new DetachableEntity<X>(detachable);
}
@Test
public void testGetObject() {
X x = new X();
entity = new DetachableEntity<X>(detachable);
}
@Test
public void testGetObject() {
X x = new X();
+ reset(detachable);
when(detachable.get()).thenReturn(x);
X value = entity.getObject();
when(detachable.get()).thenReturn(x);
X value = entity.getObject();
- assertSame(x, value);
- verify(detachable).get();
+ // we did not detach it yet so the old value should be returned.
+ assertSame(initialValue, value);
+ verifyNoMoreInteractions(detachable);
}
@Test
}
@Test
@@
-51,9
+56,12
@@
public class DetachableEntityTest {
X x = new X();
when(detachable.get()).thenReturn(x);
X x = new X();
when(detachable.get()).thenReturn(x);
- entity.
onD
etach();
+ entity.
d
etach();
verify(detachable).detach();
verify(detachable).detach();
+ reset(detachable);
+ when(detachable.get()).thenReturn(x);
+
X y = entity.getObject();
assertSame(x, y);
verify(detachable).get();
X y = entity.getObject();
assertSame(x, y);
verify(detachable).get();