Bladeren bron

Moved ExternalRoutingService into impl subpackage and renamed it RoutingServiceImpl, for consistency. We probably should try to find use-case based package names below application though.

peter_backlund 18 jaren geleden
bovenliggende
commit
25f9251b4a

dddsample/src/main/java/se/citerus/dddsample/application/routing/ExternalRoutingService.java → dddsample/src/main/java/se/citerus/dddsample/application/impl/RoutingServiceImpl.java Bestand weergeven

@@ -1,4 +1,4 @@
1
-package se.citerus.dddsample.application.routing;
1
+package se.citerus.dddsample.application.impl;
2 2
 
3 3
 import org.springframework.transaction.annotation.Transactional;
4 4
 import se.citerus.dddsample.application.RoutingService;
@@ -24,7 +24,7 @@ import java.util.List;
24 24
  * by the routing team, which operates in a different context from us.
25 25
  *
26 26
  */
27
-public class ExternalRoutingService implements RoutingService {
27
+public class RoutingServiceImpl implements RoutingService {
28 28
 
29 29
   private GraphTraversalService graphTraversalService;
30 30
   private LocationRepository locationRepository;

dddsample/src/main/java/se/citerus/dddsample/application/routing/package.html → dddsample/src/main/java/se/citerus/dddsample/application/impl/package.html Bestand weergeven


+ 0
- 20
dddsample/src/main/java/se/citerus/dddsample/domain/service/RoutingService.java Bestand weergeven

@@ -1,20 +0,0 @@
1
-package se.citerus.dddsample.domain.service;
2
-
3
-import se.citerus.dddsample.domain.model.cargo.Itinerary;
4
-import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
5
-
6
-import java.util.List;
7
-
8
-/**
9
- * Routing service.
10
- *
11
- */
12
-public interface RoutingService {
13
-
14
-  /**
15
-   * @param routeSpecification route specification
16
-   * @return A list of itineraries that satisfy the specification. May be an empty list if no route is found.
17
-   */
18
-  List<Itinerary> fetchRoutesForSpecification(RouteSpecification routeSpecification);
19
-
20
-}

+ 1
- 1
dddsample/src/main/resources/context-service.xml Bestand weergeven

@@ -32,7 +32,7 @@
32 32
 
33 33
   <tx:annotation-driven transaction-manager="transactionManager"/>
34 34
 
35
-  <bean id="routingService" class="se.citerus.dddsample.application.routing.ExternalRoutingService">
35
+  <bean id="routingService" class="se.citerus.dddsample.application.impl.RoutingServiceImpl">
36 36
     <property name="locationRepository" ref="locationRepository"/>
37 37
     <property name="voyageRepository" ref="voyageRepository"/>
38 38
     <property name="graphTraversalService" ref="graphTraversalService"/>

+ 7
- 7
dddsample/src/test/java/se/citerus/dddsample/application/RoutingServiceTest.java Bestand weergeven

@@ -2,7 +2,7 @@ package se.citerus.dddsample.application;
2 2
 
3 3
 import junit.framework.TestCase;
4 4
 import static org.easymock.EasyMock.*;
5
-import se.citerus.dddsample.application.routing.ExternalRoutingService;
5
+import se.citerus.dddsample.application.impl.RoutingServiceImpl;
6 6
 import se.citerus.dddsample.domain.model.cargo.*;
7 7
 import se.citerus.dddsample.domain.model.carrier.SampleVoyages;
8 8
 import se.citerus.dddsample.domain.model.carrier.VoyageNumber;
@@ -22,16 +22,16 @@ import java.util.List;
22 22
 
23 23
 public class RoutingServiceTest extends TestCase {
24 24
 
25
-  private ExternalRoutingService routingService;
25
+  private RoutingServiceImpl routingServiceImpl;
26 26
   private VoyageRepository voyageRepository;
27 27
 
28 28
   protected void setUp() throws Exception {
29
-    routingService = new ExternalRoutingService();
29
+    routingServiceImpl = new RoutingServiceImpl();
30 30
     LocationRepository locationRepository = new LocationRepositoryInMem();
31
-    routingService.setLocationRepository(locationRepository);
31
+    routingServiceImpl.setLocationRepository(locationRepository);
32 32
 
33 33
     voyageRepository = createMock(VoyageRepository.class);
34
-    routingService.setVoyageRepository(voyageRepository);
34
+    routingServiceImpl.setVoyageRepository(voyageRepository);
35 35
 
36 36
     GraphTraversalService graphTraversalService = new GraphTraversalServiceImpl(new GraphDAO(createMock(DataSource.class)) {
37 37
       public List<String> listLocations() {
@@ -41,7 +41,7 @@ public class RoutingServiceTest extends TestCase {
41 41
       public void storeCarrierMovementId(String cmId, String from, String to) {
42 42
       }
43 43
     });
44
-    routingService.setGraphTraversalService(graphTraversalService);
44
+    routingServiceImpl.setGraphTraversalService(graphTraversalService);
45 45
   }
46 46
 
47 47
   public void testCalculatePossibleRoutes() {
@@ -53,7 +53,7 @@ public class RoutingServiceTest extends TestCase {
53 53
     
54 54
     replay(voyageRepository);
55 55
 
56
-    List<Itinerary> candidates = routingService.fetchRoutesForSpecification(routeSpecification);
56
+    List<Itinerary> candidates = routingServiceImpl.fetchRoutesForSpecification(routeSpecification);
57 57
     assertNotNull(candidates);
58 58
     
59 59
     for (Itinerary itinerary : candidates) {

dddsample/src/test/java/se/citerus/dddsample/domain/service/RoutingServiceTest.java → dddsample/src/test/java/se/citerus/dddsample/application/impl/ExternalRoutingServiceTest.java Bestand weergeven

@@ -1,8 +1,7 @@
1
-package se.citerus.dddsample.domain.service;
1
+package se.citerus.dddsample.application.impl;
2 2
 
3 3
 import junit.framework.TestCase;
4 4
 import static org.easymock.EasyMock.*;
5
-import se.citerus.dddsample.application.routing.ExternalRoutingService;
6 5
 import se.citerus.dddsample.domain.model.cargo.*;
7 6
 import se.citerus.dddsample.domain.model.carrier.SampleVoyages;
8 7
 import se.citerus.dddsample.domain.model.carrier.VoyageNumber;
@@ -20,18 +19,18 @@ import java.util.Arrays;
20 19
 import java.util.Date;
21 20
 import java.util.List;
22 21
 
23
-public class RoutingServiceTest extends TestCase {
22
+public class ExternalRoutingServiceTest extends TestCase {
24 23
 
25
-  private ExternalRoutingService routingService;
24
+  private RoutingServiceImpl routingServiceImpl;
26 25
   private VoyageRepository voyageRepository;
27 26
 
28 27
   protected void setUp() throws Exception {
29
-    routingService = new ExternalRoutingService();
28
+    routingServiceImpl = new RoutingServiceImpl();
30 29
     LocationRepository locationRepository = new LocationRepositoryInMem();
31
-    routingService.setLocationRepository(locationRepository);
30
+    routingServiceImpl.setLocationRepository(locationRepository);
32 31
 
33 32
     voyageRepository = createMock(VoyageRepository.class);
34
-    routingService.setVoyageRepository(voyageRepository);
33
+    routingServiceImpl.setVoyageRepository(voyageRepository);
35 34
 
36 35
     GraphTraversalService graphTraversalService = new GraphTraversalServiceImpl(new GraphDAO(createMock(DataSource.class)) {
37 36
       public List<String> listLocations() {
@@ -41,7 +40,7 @@ public class RoutingServiceTest extends TestCase {
41 40
       public void storeCarrierMovementId(String cmId, String from, String to) {
42 41
       }
43 42
     });
44
-    routingService.setGraphTraversalService(graphTraversalService);
43
+    routingServiceImpl.setGraphTraversalService(graphTraversalService);
45 44
   }
46 45
 
47 46
   public void testCalculatePossibleRoutes() {
@@ -53,7 +52,7 @@ public class RoutingServiceTest extends TestCase {
53 52
     
54 53
     replay(voyageRepository);
55 54
 
56
-    List<Itinerary> candidates = routingService.fetchRoutesForSpecification(routeSpecification);
55
+    List<Itinerary> candidates = routingServiceImpl.fetchRoutesForSpecification(routeSpecification);
57 56
     assertNotNull(candidates);
58 57
     
59 58
     for (Itinerary itinerary : candidates) {
@@ -69,7 +68,7 @@ public class RoutingServiceTest extends TestCase {
69 68
       assertEquals(cargo.destination(), lastLegStop);
70 69
 
71 70
       for (int i = 0; i < legs.size() - 1; i++) {
72
-        // Assert that all legs are conencted
71
+        // Assert that all legs are connected
73 72
         assertEquals(legs.get(i).unloadLocation(), legs.get(i + 1).loadLocation());
74 73
       }
75 74
     }