|
|
@@ -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
|
}
|