Pārlūkot izejas kodu

Tests adapted to changes in HandlingEvent and CarrierMovement

peter_backlund 18 gadus atpakaļ
vecāks
revīzija
3f7a97641f

+ 2
- 2
dddsample/src/test/java/se/citerus/dddsample/application/persistence/CargoRepositoryTest.java Parādīt failu

51
     assertHandlingEvent(cargo, firstEvent, RECEIVE, HONGKONG, 100, 160, null);
51
     assertHandlingEvent(cargo, firstEvent, RECEIVE, HONGKONG, 100, 160, null);
52
 
52
 
53
     HandlingEvent secondEvent = events.get(1);
53
     HandlingEvent secondEvent = events.get(1);
54
-    CarrierMovement expectedCm = new CarrierMovement(new CarrierMovementId("CAR_010"), HONGKONG, MELBOURNE);
54
+    CarrierMovement expectedCm = new CarrierMovement(new CarrierMovementId("CAR_010"), HONGKONG, MELBOURNE, new Date(), new Date());
55
     assertHandlingEvent(cargo,  secondEvent, LOAD, HONGKONG, 150, 110, expectedCm);
55
     assertHandlingEvent(cargo,  secondEvent, LOAD, HONGKONG, 150, 110, expectedCm);
56
 
56
 
57
     List<Leg> legs = cargo.itinerary().legs();
57
     List<Leg> legs = cargo.itinerary().legs();
163
 
163
 
164
     Location origin = locationRepository.find(STOCKHOLM.unLocode());
164
     Location origin = locationRepository.find(STOCKHOLM.unLocode());
165
 
165
 
166
-    HandlingEvent event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.RECEIVE, origin, null);
166
+    HandlingEvent event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.RECEIVE, origin);
167
     assertFalse(cargo.deliveryHistory().eventsOrderedByCompletionTime().contains(event));
167
     assertFalse(cargo.deliveryHistory().eventsOrderedByCompletionTime().contains(event));
168
 
168
 
169
     CargoTestHelper.setDeliveryHistory(cargo, Arrays.asList(event));
169
     CargoTestHelper.setDeliveryHistory(cargo, Arrays.asList(event));

+ 2
- 30
dddsample/src/test/java/se/citerus/dddsample/application/persistence/CarrierMovementRepositoryInMem.java Parādīt failu

3
 import se.citerus.dddsample.domain.model.carrier.CarrierMovement;
3
 import se.citerus.dddsample.domain.model.carrier.CarrierMovement;
4
 import se.citerus.dddsample.domain.model.carrier.CarrierMovementId;
4
 import se.citerus.dddsample.domain.model.carrier.CarrierMovementId;
5
 import se.citerus.dddsample.domain.model.carrier.CarrierMovementRepository;
5
 import se.citerus.dddsample.domain.model.carrier.CarrierMovementRepository;
6
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
7
-
8
-import java.util.HashMap;
9
-import java.util.Map;
6
+import se.citerus.dddsample.domain.model.carrier.SampleCarrierMovements;
10
 
7
 
11
 public final class CarrierMovementRepositoryInMem implements CarrierMovementRepository {
8
 public final class CarrierMovementRepositoryInMem implements CarrierMovementRepository {
12
 
9
 
13
-  private Map<CarrierMovementId, CarrierMovement> carriers;
14
-
15
-  public CarrierMovementRepositoryInMem() {
16
-    carriers = new HashMap<CarrierMovementId, CarrierMovement>();
17
-  }
18
-
19
-  private void setup() {
20
-    final CarrierMovement stockholmToHamburg = new CarrierMovement(
21
-            new CarrierMovementId("CAR_001"), STOCKHOLM, HAMBURG);
22
-    final CarrierMovement hamburgToHongKong = new CarrierMovement(
23
-            new CarrierMovementId("CAR_002"), HAMBURG, HONGKONG);
24
-    final CarrierMovement melbourneToTokyo = new CarrierMovement(
25
-            new CarrierMovementId("CAR_003"), MELBOURNE, TOKYO);
26
-    final CarrierMovement tokyoToChicago = new CarrierMovement(
27
-            new CarrierMovementId("CAR_004"), TOKYO, CHICAGO);
28
-    final CarrierMovement stockholmToHelsinki = new CarrierMovement(
29
-            new CarrierMovementId("CAR_005"), STOCKHOLM, HELSINKI);
30
-    
31
-    carriers.put(new CarrierMovementId("SESTO_DEHAM"), stockholmToHamburg);
32
-    carriers.put(new CarrierMovementId("DEHAM_CNHKG"), hamburgToHongKong);
33
-    carriers.put(new CarrierMovementId("AUMEL_JPTOK"), melbourneToTokyo);
34
-    carriers.put(new CarrierMovementId("JPTOK_USCHI"), tokyoToChicago);
35
-    carriers.put(new CarrierMovementId("SESTO_FIHEL"), stockholmToHelsinki);
36
-  }
37
-
38
   public CarrierMovement find(final CarrierMovementId carrierMovementId) {
10
   public CarrierMovement find(final CarrierMovementId carrierMovementId) {
39
-    return carriers.get(carrierMovementId);
11
+    return SampleCarrierMovements.lookup(carrierMovementId);
40
   }
12
   }
41
 
13
 
42
 }
14
 }

+ 2
- 3
dddsample/src/test/java/se/citerus/dddsample/application/persistence/HandlingEventRepositoryInMem.java Parādīt failu

8
 import se.citerus.dddsample.domain.model.carrier.CarrierMovementId;
8
 import se.citerus.dddsample.domain.model.carrier.CarrierMovementId;
9
 import se.citerus.dddsample.domain.model.carrier.CarrierMovementRepository;
9
 import se.citerus.dddsample.domain.model.carrier.CarrierMovementRepository;
10
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
10
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
11
-import se.citerus.dddsample.domain.model.handling.HandlingEvent.Type;
12
 import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
11
 import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
13
 import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
12
 import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
14
 
13
 
61
     registerEvent(cargoABC, "2008-01-01", HandlingEvent.Type.RECEIVE, null);
60
     registerEvent(cargoABC, "2008-01-01", HandlingEvent.Type.RECEIVE, null);
62
     
61
     
63
     final CarrierMovement stockholmToHelsinki = new CarrierMovement(
62
     final CarrierMovement stockholmToHelsinki = new CarrierMovement(
64
-            new CarrierMovementId("CAR_001"), STOCKHOLM, HELSINKI);
63
+            new CarrierMovementId("CAR_001"), STOCKHOLM, HELSINKI, new Date(), new Date());
65
 
64
 
66
     registerEvent(cargoABC, "2008-01-02", HandlingEvent.Type.LOAD, stockholmToHelsinki);
65
     registerEvent(cargoABC, "2008-01-02", HandlingEvent.Type.LOAD, stockholmToHelsinki);
67
     registerEvent(cargoABC, "2008-01-03", HandlingEvent.Type.UNLOAD, stockholmToHelsinki);
66
     registerEvent(cargoABC, "2008-01-03", HandlingEvent.Type.UNLOAD, stockholmToHelsinki);
72
     registerEvent(cargoCBA, "2008-01-10", HandlingEvent.Type.RECEIVE, null);
71
     registerEvent(cargoCBA, "2008-01-10", HandlingEvent.Type.RECEIVE, null);
73
   }
72
   }
74
 
73
 
75
-  private void registerEvent(Cargo cargo, String date, Type type, CarrierMovement carrierMovement) throws ParseException {
74
+  private void registerEvent(Cargo cargo, String date, HandlingEvent.Type type, CarrierMovement carrierMovement) throws ParseException {
76
     HandlingEvent event = new HandlingEvent(cargo, getDate(date), new Date(), type, null, carrierMovement);
75
     HandlingEvent event = new HandlingEvent(cargo, getDate(date), new Date(), type, null, carrierMovement);
77
     String id = cargo.trackingId() + "_" + type + "_" + date;
76
     String id = cargo.trackingId() + "_" + type + "_" + date;
78
 
77
 

+ 1
- 1
dddsample/src/test/java/se/citerus/dddsample/application/persistence/HandlingEventRepositoryTest.java Parādīt failu

37
     Cargo cargo = cargoRepository.find(new TrackingId("XYZ"));
37
     Cargo cargo = cargoRepository.find(new TrackingId("XYZ"));
38
     Date completionTime = new Date(10);
38
     Date completionTime = new Date(10);
39
     Date registrationTime = new Date(20);
39
     Date registrationTime = new Date(20);
40
-    HandlingEvent event = new HandlingEvent(cargo, completionTime, registrationTime, HandlingEvent.Type.CLAIM, location, null);
40
+    HandlingEvent event = new HandlingEvent(cargo, completionTime, registrationTime, HandlingEvent.Type.CLAIM, location);
41
 
41
 
42
     handlingEventRepository.save(event);
42
     handlingEventRepository.save(event);
43
 
43