Bläddra i källkod

Migrated test to Mockito

peter_backlund 17 år sedan
förälder
incheckning
2e77c9c013

+ 7
- 11
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/application/event/CargoUpdaterTest.java Visa fil

@@ -1,10 +1,11 @@
1 1
 package se.citerus.dddsample.tracking.core.application.event;
2 2
 
3
-import static org.easymock.EasyMock.*;
4 3
 import static org.hamcrest.core.IsEqual.equalTo;
4
+import static org.hamcrest.core.IsNot.not;
5 5
 import static org.junit.Assert.assertThat;
6 6
 import org.junit.Before;
7 7
 import org.junit.Test;
8
+import static org.mockito.Mockito.*;
8 9
 import static se.citerus.dddsample.tracking.core.application.util.DateTestUtil.toDate;
9 10
 import se.citerus.dddsample.tracking.core.domain.model.cargo.Cargo;
10 11
 import se.citerus.dddsample.tracking.core.domain.model.cargo.CargoRepository;
@@ -28,11 +29,11 @@ public class CargoUpdaterTest {
28 29
   HandlingEventRepository handlingEventRepository;
29 30
   LocationRepository locationRepository;
30 31
   VoyageRepository voyageRepository;
31
-  private TrackingIdFactoryInMem trackingIdFactory;
32
+  TrackingIdFactoryInMem trackingIdFactory;
32 33
 
33 34
   @Before
34 35
   public void setUp() {
35
-    systemEvents = createMock(SystemEvents.class);
36
+    systemEvents = mock(SystemEvents.class);
36 37
     cargoRepository = new CargoRepositoryInMem();
37 38
     handlingEventRepository = new HandlingEventRepositoryInMem();
38 39
     locationRepository = new LocationRepositoryInMem();
@@ -59,24 +60,19 @@ public class CargoUpdaterTest {
59 60
     );
60 61
     handlingEventRepository.store(handlingEvent);
61 62
 
62
-    systemEvents.notifyOfCargoUpdate(cargo);
63
-    replay(systemEvents);
64
-
65 63
     assertThat(handlingEvent.activity(), not(equalTo(cargo.mostRecentHandlingActivity())));
66 64
 
67 65
     cargoUpdater.updateCargo(handlingEvent.sequenceNumber());
68 66
     
69 67
     assertThat(handlingEvent.activity(), equalTo(cargo.mostRecentHandlingActivity()));
70
-
71
-    verify(systemEvents);
68
+    verify(systemEvents).notifyOfCargoUpdate(cargo);
72 69
   }
73 70
 
74 71
   @Test
75 72
   public void handlingEventNotFound() {
76
-    replay(systemEvents);
77
-
78 73
     cargoUpdater.updateCargo(EventSequenceNumber.valueOf(999L));
79 74
     
80
-    verify(systemEvents);
75
+    verifyZeroInteractions(systemEvents);
81 76
   }
77
+  
82 78
 }