|
|
@@ -2,8 +2,7 @@ package se.citerus.dddsample.repository;
|
|
2
|
2
|
|
|
3
|
3
|
import org.springframework.dao.DataRetrievalFailureException;
|
|
4
|
4
|
import se.citerus.dddsample.domain.Cargo;
|
|
5
|
|
-import se.citerus.dddsample.domain.DeliveryHistory;
|
|
6
|
|
-import se.citerus.dddsample.domain.Itinerary;
|
|
|
5
|
+import se.citerus.dddsample.domain.CargoTestHelper;
|
|
7
|
6
|
import static se.citerus.dddsample.domain.SampleLocations.*;
|
|
8
|
7
|
import se.citerus.dddsample.domain.TrackingId;
|
|
9
|
8
|
|
|
|
@@ -49,34 +48,30 @@ public class CargoRepositoryInMem implements CargoRepository {
|
|
49
|
48
|
);
|
|
50
|
49
|
}
|
|
51
|
50
|
|
|
52
|
|
- public void deleteItinerary(Itinerary itinerary) {
|
|
53
|
|
- }
|
|
54
|
|
-
|
|
55
|
51
|
public List<Cargo> findAll() {
|
|
56
|
52
|
return new ArrayList(cargoDb.values());
|
|
57
|
53
|
}
|
|
58
|
54
|
|
|
59
|
55
|
public void init() throws Exception {
|
|
60
|
|
- String trackIdXYZ = "XYZ";
|
|
61
|
|
- final Cargo cargoXYZ = new Cargo(new TrackingId(trackIdXYZ), STOCKHOLM, MELBOURNE);
|
|
62
|
|
- cargoDb.put(trackIdXYZ, cargoXYZ);
|
|
63
|
|
-
|
|
64
|
|
- String trackIdZYX = "ZYX";
|
|
65
|
|
- final Cargo cargoZYX = new Cargo(new TrackingId(trackIdZYX), MELBOURNE, STOCKHOLM);
|
|
66
|
|
- cargoDb.put(trackIdZYX, cargoZYX);
|
|
67
|
|
-
|
|
68
|
|
- String trackIdABC = "ABC";
|
|
69
|
|
- final Cargo cargoABC = new Cargo(new TrackingId(trackIdABC), STOCKHOLM, HELSINKI);
|
|
70
|
|
- cargoDb.put(trackIdABC, cargoABC);
|
|
71
|
|
-
|
|
72
|
|
- String trackIdCBA = "CBA";
|
|
73
|
|
- final Cargo cargoCBA = new Cargo(new TrackingId(trackIdCBA), HELSINKI, STOCKHOLM);
|
|
74
|
|
- cargoDb.put(trackIdCBA, cargoCBA);
|
|
|
56
|
+ final TrackingId xyz = new TrackingId("XYZ");
|
|
|
57
|
+ final Cargo cargoXYZ = CargoTestHelper.createCargoWithDeliveryHistory(
|
|
|
58
|
+ xyz, STOCKHOLM, MELBOURNE, handlingEventRepository.findEventsForCargo(xyz));
|
|
|
59
|
+ cargoDb.put(xyz.idString(), cargoXYZ);
|
|
75
|
60
|
|
|
76
|
|
- for (Cargo cargo : cargoDb.values()) {
|
|
77
|
|
- DeliveryHistory dh = new DeliveryHistory(handlingEventRepository.findEventsForCargo(cargo.trackingId()));
|
|
78
|
|
- cargo.setDeliveryHistory(dh);
|
|
79
|
|
- }
|
|
|
61
|
+ final TrackingId zyx = new TrackingId("ZYX");
|
|
|
62
|
+ final Cargo cargoZYX = CargoTestHelper.createCargoWithDeliveryHistory(
|
|
|
63
|
+ zyx, MELBOURNE, STOCKHOLM, handlingEventRepository.findEventsForCargo(zyx));
|
|
|
64
|
+ cargoDb.put(zyx.idString(), cargoZYX);
|
|
|
65
|
+
|
|
|
66
|
+ final TrackingId abc = new TrackingId("ABC");
|
|
|
67
|
+ final Cargo cargoABC = CargoTestHelper.createCargoWithDeliveryHistory(
|
|
|
68
|
+ abc, STOCKHOLM, HELSINKI, handlingEventRepository.findEventsForCargo(abc));
|
|
|
69
|
+ cargoDb.put(abc.idString(), cargoABC);
|
|
|
70
|
+
|
|
|
71
|
+ final TrackingId cba = new TrackingId("CBA");
|
|
|
72
|
+ final Cargo cargoCBA = CargoTestHelper.createCargoWithDeliveryHistory(
|
|
|
73
|
+ cba, HELSINKI, STOCKHOLM, handlingEventRepository.findEventsForCargo(cba));
|
|
|
74
|
+ cargoDb.put(cba.idString(), cargoCBA);
|
|
80
|
75
|
}
|
|
81
|
76
|
|
|
82
|
77
|
public void setHandlingEventRepository(final HandlingEventRepository handlingEventRepository) {
|