From 37d94efb0febf8c5ffcc2ea1389617649b03fe02 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 16 Aug 2024 15:51:13 +0200 Subject: [PATCH] test for values instead of objects --- .../CollectionLSPSchedulingTest.java | 10 ++++++++-- .../CompleteLSPSchedulingTest.java | 6 ++++-- .../FirstReloadLSPSchedulingTest.java | 6 ++++-- .../MainRunLSPSchedulingTest.java | 6 ++++-- ...leShipmentsCollectionLSPSchedulingTest.java | 6 ++++-- ...ipleShipmentsCompleteLSPSchedulingTest.java | 6 ++++-- ...eShipmentsFirstReloadLSPSchedulingTest.java | 6 ++++-- ...tipleShipmentsMainRunLSPSchedulingTest.java | 6 ++++-- ...ShipmentsSecondReloadLSPSchedulingTest.java | 17 ++++++++++++----- .../SecondReloadLSPSchedulingTest.java | 18 ++++++++++++------ 10 files changed, 60 insertions(+), 27 deletions(-) diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java index 4064ef67..400ab067 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java @@ -192,29 +192,35 @@ public void testCollectionLSPScheduling() { assertEquals(2, shipment.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(shipment.getSimulationTrackers()); + { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(endHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), collectionLSP.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(endHandler.getLspShipment(), shipment); assertSame(endHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(endHandler.getResourceId(), collectionLSP.getResources().iterator().next().getId()); + } + { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(serviceHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(serviceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(serviceHandler.getElement(), collectionLSP.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(serviceHandler.getLspShipment(), shipment); assertSame(serviceHandler.getResourceId(), planElements.get(1).getResourceId()); assertSame(serviceHandler.getResourceId(), collectionLSP.getResources().iterator().next().getId()); + } } for (LogisticChain solution : collectionLSP.getSelectedPlan().getLogisticChains()) { diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java index e4227cbd..885a2d4f 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java @@ -488,7 +488,8 @@ public void testCompletedLSPScheduling() { assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(endHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(endHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); @@ -505,7 +506,8 @@ public void testCompletedLSPScheduling() { assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(serviceHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(serviceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(2).getLogisticChainElement()); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java index 8ad0b1c4..90254732 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java @@ -285,7 +285,8 @@ public void testFirstReloadLSPScheduling() { assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(endHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(endHandler.getLspShipment(), shipment); @@ -297,7 +298,8 @@ public void testFirstReloadLSPScheduling() { assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(serviceHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(serviceHandler.getElement(), planElements.getFirst().getLogisticChainElement()); assertSame(serviceHandler.getElement(), lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(serviceHandler.getLspShipment(), shipment); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java index 7f6900e6..de0c1643 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java @@ -353,7 +353,8 @@ public void testMainRunLSPScheduling() { assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(endHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(endHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); @@ -370,7 +371,8 @@ public void testMainRunLSPScheduling() { assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(serviceHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(serviceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(2).getLogisticChainElement()); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java index 458a833b..173fa089 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java @@ -200,7 +200,8 @@ public void testCollectionLSPScheduling() { assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(endHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), collectionLSP.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(endHandler.getLspShipment(), shipment); @@ -212,7 +213,8 @@ public void testCollectionLSPScheduling() { assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(serviceHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(serviceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(serviceHandler.getElement(), collectionLSP.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(serviceHandler.getLspShipment(), shipment); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java index 8b09edd0..6994d171 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java @@ -491,7 +491,8 @@ public void testCompletedLSPScheduling() { assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(endHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(endHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); @@ -508,7 +509,8 @@ public void testCompletedLSPScheduling() { assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(serviceHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(serviceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(2).getLogisticChainElement()); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java index d101b4c9..2b6a2e60 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java @@ -284,7 +284,8 @@ public void testFirstReloadLSPScheduling() { assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(endHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(endHandler.getLspShipment(), shipment); @@ -296,7 +297,8 @@ public void testFirstReloadLSPScheduling() { assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(serviceHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(serviceHandler.getElement(), planElements.getFirst().getLogisticChainElement()); assertSame(serviceHandler.getElement(), lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(serviceHandler.getLspShipment(), shipment); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java index 4f0605cf..6c8bd2fe 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java @@ -353,7 +353,8 @@ public void testMainRunLSPScheduling() { assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(endHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(endHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); @@ -370,7 +371,8 @@ public void testMainRunLSPScheduling() { assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(serviceHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(serviceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(2).getLogisticChainElement()); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java index 4766d616..236e1dd2 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java @@ -427,12 +427,14 @@ public void testSecondReloadLSPScheduling() { ArrayList resources = new ArrayList<>(lsp.getResources()); //CollectionTourEnd + { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(collectionEndHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(collectionEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(collectionEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(collectionEndHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); @@ -442,14 +444,16 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionEndHandler.getResourceId(), planElements.get(1).getResourceId()); assertSame(collectionEndHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(collectionEndHandler.getResourceId(), resources.getFirst().getId()); + } - //CollectionServiceEnd + {//CollectionServiceEnd assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler collectionServiceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(collectionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(collectionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(collectionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(collectionServiceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(collectionServiceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(collectionServiceHandler.getElement(), planElements.get(2).getLogisticChainElement()); @@ -459,8 +463,9 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionServiceHandler.getResourceId(), planElements.get(1).getResourceId()); assertSame(collectionServiceHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(collectionServiceHandler.getResourceId(), resources.getFirst().getId()); + } - //MainRunStart + {//MainRunStart assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); @@ -477,8 +482,9 @@ public void testSecondReloadLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), planElements.get(5).getResourceId()); assertSame(mainRunStartHandler.getResourceId(), planElements.get(6).getResourceId()); assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); + } - //MainRunEnd + {//MainRunEnd assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); @@ -495,6 +501,7 @@ public void testSecondReloadLSPScheduling() { assertSame(mainRunEndHandler.getResourceId(), planElements.get(5).getResourceId()); assertSame(mainRunEndHandler.getResourceId(), planElements.get(6).getResourceId()); assertSame(mainRunEndHandler.getResourceId(), resources.get(2).getId()); + } } for (LogisticChain solution : lsp.getSelectedPlan().getLogisticChains()) { diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java index f7a32ede..e158884b 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java @@ -434,13 +434,14 @@ public void testSecondReloadLSPScheduling() { ArrayList solutionElements = new ArrayList<>(lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements()); ArrayList resources = new ArrayList<>(lsp.getResources()); - //CollectionTourEnd + {//CollectionTourEnd assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(collectionEndHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(collectionEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(collectionEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(collectionEndHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); @@ -450,14 +451,16 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionEndHandler.getResourceId(), planElements.get(1).getResourceId()); assertSame(collectionEndHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(collectionEndHandler.getResourceId(), resources.getFirst().getId()); + } - //CollectionServiceEnd + {//CollectionServiceEnd assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler collectionServiceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(collectionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(collectionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(collectionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertSame(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); + assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(collectionServiceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(collectionServiceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(collectionServiceHandler.getElement(), planElements.get(2).getLogisticChainElement()); @@ -467,8 +470,9 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionServiceHandler.getResourceId(), planElements.get(1).getResourceId()); assertSame(collectionServiceHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(collectionServiceHandler.getResourceId(), resources.getFirst().getId()); + } - //MainRunStart + {//MainRunStart assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); @@ -485,8 +489,9 @@ public void testSecondReloadLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), planElements.get(5).getResourceId()); assertSame(mainRunStartHandler.getResourceId(), planElements.get(6).getResourceId()); assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); + } - //MainRunEnd + {//MainRunEnd assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); @@ -503,6 +508,7 @@ public void testSecondReloadLSPScheduling() { assertSame(mainRunEndHandler.getResourceId(), planElements.get(5).getResourceId()); assertSame(mainRunEndHandler.getResourceId(), planElements.get(6).getResourceId()); assertSame(mainRunEndHandler.getResourceId(), resources.get(2).getId()); + } } for (LogisticChain solution : lsp.getSelectedPlan().getLogisticChains()) {