From: erik Date: Thu, 22 Jul 2010 23:22:41 +0000 (+0000) Subject: (no commit message) X-Git-Tag: wamblee-utils-0.4~29 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=9a7783d7d65f70d0ba971a92ead2f50a54c12711;p=utils --- 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 e4cf7317..3346be63 100644 --- 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 detachable; private DetachableEntity entity; @Before public void setUp() { + initialValue = mock(X.class); detachable = mock(Detachable.class); + when(detachable.get()).thenReturn(initialValue); entity = new DetachableEntity(detachable); } @Test public void testGetObject() { X x = new X(); + reset(detachable); 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 @@ -51,9 +56,12 @@ public class DetachableEntityTest { X x = new X(); when(detachable.get()).thenReturn(x); - entity.onDetach(); + entity.detach(); verify(detachable).detach(); + reset(detachable); + when(detachable.get()).thenReturn(x); + X y = entity.getObject(); assertSame(x, y); verify(detachable).get();