From 1df323c6b726222262194aecd6d23ed0da194458 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Thu, 22 Jul 2010 23:22:41 +0000 Subject: [PATCH] --- .../wamblee/wicket/model/DetachableEntityTest.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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(); -- 2.31.1