Explorar el Código

Use UnLocode in CargoService.shippingLocations signature

peter_backlund hace 18 años
padre
commit
5e27b4d272

+ 1
- 1
dddsample/src/main/java/se/citerus/dddsample/service/CargoService.java Ver fichero

@@ -32,7 +32,7 @@ public interface CargoService {
32 32
   /**
33 33
    * @return A list of all locations where the company ships cargo to.
34 34
    */
35
-  List<String> shippingLocations();
35
+  List<UnLocode> shippingLocations();
36 36
 
37 37
   /**
38 38
    * Send relevant notifications to interested parties,

+ 5
- 4
dddsample/src/main/java/se/citerus/dddsample/service/CargoServiceImpl.java Ver fichero

@@ -39,11 +39,11 @@ public class CargoServiceImpl implements CargoService {
39 39
   }
40 40
 
41 41
   @Transactional(readOnly = true)
42
-  public List<String> shippingLocations() {
42
+  public List<UnLocode> shippingLocations() {
43 43
     List<Location> allLocations = locationRepository.findAll();
44
-    List<String> unlocodes = new ArrayList<String>(allLocations.size());
44
+    List<UnLocode> unlocodes = new ArrayList<UnLocode>(allLocations.size());
45 45
     for (Location location : allLocations) {
46
-      unlocodes.add(location.unLocode().idString());
46
+      unlocodes.add(location.unLocode());
47 47
     }
48 48
     return unlocodes;
49 49
   }
@@ -177,7 +177,8 @@ public class CargoServiceImpl implements CargoService {
177 177
         locationRepository.find(new UnLocode(legDTO.getTo())))
178 178
       );
179 179
     }
180
-
180
+    // TODO: delete orphaned itineraries manually.
181
+    // Can't cascade delete-orphan for many-to-one using mapping directives.
181 182
     cargo.setItinerary(new Itinerary(legs));
182 183
     cargoRepository.save(cargo);
183 184
   }

+ 6
- 1
dddsample/src/main/java/se/citerus/dddsample/web/CargoAdminController.java Ver fichero

@@ -29,7 +29,12 @@ public class CargoAdminController extends MultiActionController {
29 29
 
30 30
   public Map registrationForm(HttpServletRequest request, HttpServletResponse response) throws Exception {
31 31
     Map map = new HashMap();
32
-    map.put("unlocodes", cargoService.shippingLocations());
32
+    List<UnLocode> unLocodes = cargoService.shippingLocations();
33
+    List<String> unLocodeStrings = new ArrayList<String>();
34
+    for (UnLocode unLocode : unLocodes) {
35
+      unLocodeStrings.add(unLocode.idString());
36
+    }
37
+    map.put("unlocodes", unLocodeStrings);
33 38
     return map;
34 39
   }
35 40
 

+ 3
- 0
dddsample/src/test/java/se/citerus/dddsample/service/CargoServiceTest.java Ver fichero

@@ -51,6 +51,9 @@ public class CargoServiceTest extends AbstractDependencyInjectionSpringContextTe
51 51
     this.sessionFactory = sessionFactory;
52 52
   }
53 53
 
54
+  // TODO: scrap the mock-persistence-context altogether, don't bother verifying transactions.
55
+  // TODO: use mocks instead of stubs in this test
56
+
54 57
   protected void onSetUp() {
55 58
     Session session = createMock(Session.class);
56 59
     Connection connection = createMock(Connection.class);

+ 1
- 1
dddsample/src/test/java/se/citerus/dddsample/web/CargoTrackingControllerTest.java Ver fichero

@@ -123,7 +123,7 @@ public class CargoTrackingControllerTest extends TestCase {
123 123
       return null;
124 124
     }
125 125
 
126
-    public List<String> shippingLocations() {
126
+    public List<UnLocode> shippingLocations() {
127 127
       return null;
128 128
     }
129 129