diff --git a/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java b/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java index 7a175216..a19ddce7 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java @@ -42,6 +42,7 @@ package org.matsim.freight.logistics.examples.requirementsChecking; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; @@ -203,11 +204,11 @@ public void initialize() { public void testAssignerRequirements() { for (Id shipmentId : blueChain.getLspShipmentIds()) { LspShipment shipment = LSPUtils.findLspShipment(blueChain.getLSP(), shipmentId); - assertTrue(shipment.getRequirements().iterator().next() instanceof BlueRequirement); + assertInstanceOf(BlueRequirement.class, shipment.getRequirements().iterator().next()); } for (Id shipmentId : redChain.getLspShipmentIds()) { LspShipment shipment = LSPUtils.findLspShipment(redChain.getLSP(), shipmentId); - assertTrue(shipment.getRequirements().iterator().next() instanceof RedRequirement); + assertInstanceOf(RedRequirement.class, shipment.getRequirements().iterator().next()); } } diff --git a/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java b/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java index 4b9945e5..76ec9466 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java @@ -21,9 +21,6 @@ package org.matsim.freight.logistics.examples.simulationTrackers; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - import java.util.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -58,6 +55,8 @@ import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import static org.junit.jupiter.api.Assertions.*; + public class CollectionTrackerTest { private static final Logger log = LogManager.getLogger(CollectionTrackerTest.class); @RegisterExtension @@ -209,7 +208,7 @@ public void testCollectionTracker() { assertEquals(1, logisticChain.getSimulationTrackers().size()); LSPSimulationTracker tracker = logisticChain.getSimulationTrackers().iterator().next(); - assertTrue(tracker instanceof LinearCostTracker); + assertInstanceOf(LinearCostTracker.class, tracker); LinearCostTracker linearTracker = (LinearCostTracker) tracker; double totalScheduledCosts = 0; double totalTrackedCosts = 0; 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 6b381d7e..41b00365 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java @@ -193,7 +193,7 @@ public void testCollectionLSPScheduling() { assertEquals(2, shipment.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(shipment.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -205,7 +205,7 @@ public void testCollectionLSPScheduling() { assertSame(endHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(endHandler.getResourceId(), collectionLSP.getResources().iterator().next().getId()); - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); 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 3593cae3..01ac0685 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java @@ -428,7 +428,7 @@ public void testCompletedLSPScheduling() { assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); Iterator> iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); @@ -455,7 +455,7 @@ public void testCompletedLSPScheduling() { assertEquals(1, secondTranshipmentHubResource.getSimulationTrackers().size()); eventHandlers = new ArrayList<>(secondTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); @@ -486,7 +486,7 @@ public void testCompletedLSPScheduling() { ArrayList planElements = new ArrayList<>(LspShipmentUtils.getOrCreateShipmentPlan(lsp.getSelectedPlan(), shipment.getId()).getPlanElements().values()); planElements.sort(LspShipmentUtils.createShipmentPlanElementComparator()); - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -503,7 +503,7 @@ public void testCompletedLSPScheduling() { assertSame(endHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -520,7 +520,7 @@ public void testCompletedLSPScheduling() { assertSame(serviceHandler.getResourceId(), resources.getFirst().getId()); //MainRunStart - assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -538,7 +538,7 @@ public void testCompletedLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); //MainRunEnd - assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -556,7 +556,7 @@ public void testCompletedLSPScheduling() { assertSame(mainRunEndHandler.getResourceId(), resources.get(2).getId()); //DistributionRunStart - assertTrue(eventHandlers.get(4) instanceof LSPTourStartEventHandler); + assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(4)); LSPTourStartEventHandler lspTourStartEventHandler = (LSPTourStartEventHandler) eventHandlers.get(4); assertSame(lspTourStartEventHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); assertEquals(lspTourStartEventHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -574,7 +574,7 @@ public void testCompletedLSPScheduling() { assertSame(lspTourStartEventHandler.getResourceId(), resources.get(4).getId()); //DistributionServiceStart - assertTrue(eventHandlers.get(5) instanceof DistributionServiceStartEventHandler); + assertInstanceOf(DistributionServiceStartEventHandler.class, eventHandlers.get(5)); DistributionServiceStartEventHandler distributionServiceHandler = (DistributionServiceStartEventHandler) eventHandlers.get(5); assertSame(distributionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); assertEquals(distributionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); 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 11caf4ab..d79f3141 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java @@ -252,7 +252,7 @@ public void testFirstReloadLSPScheduling() { assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); for (Entry entry : reloadEventHandler.getServicesWaitedFor().entrySet()) { @@ -281,7 +281,7 @@ public void testFirstReloadLSPScheduling() { eventHandlers = new ArrayList<>(shipment.getSimulationTrackers()); ArrayList planElements = new ArrayList<>(LspShipmentUtils.getOrCreateShipmentPlan(lsp.getSelectedPlan(), shipment.getId()).getPlanElements().values()); - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -293,7 +293,7 @@ public void testFirstReloadLSPScheduling() { assertSame(endHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(endHandler.getResourceId(), lsp.getResources().iterator().next().getId()); - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); 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 b604fc96..5909c999 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java @@ -319,7 +319,7 @@ public void testMainRunLSPScheduling() { assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); for (Entry entry : reloadEventHandler.getServicesWaitedFor().entrySet()) { @@ -350,7 +350,7 @@ public void testMainRunLSPScheduling() { ArrayList solutionElements = new ArrayList<>(lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements()); ArrayList resources = new ArrayList<>(lsp.getResources()); - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -367,7 +367,7 @@ public void testMainRunLSPScheduling() { assertSame(endHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -384,7 +384,7 @@ public void testMainRunLSPScheduling() { assertSame(serviceHandler.getResourceId(), resources.getFirst().getId()); //MainRunTourStart - assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -402,7 +402,7 @@ public void testMainRunLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); //MainRunTourEnd - assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); 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 3507e56a..e4f84cd4 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java @@ -196,7 +196,7 @@ public void testCollectionLSPScheduling() { assertEquals(2, shipment.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(shipment.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -208,7 +208,7 @@ public void testCollectionLSPScheduling() { assertSame(endHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(endHandler.getResourceId(), collectionLSP.getResources().iterator().next().getId()); - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); 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 14fd9f71..ec2ed677 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java @@ -431,7 +431,7 @@ public void testCompletedLSPScheduling() { assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); Iterator> iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); @@ -458,7 +458,7 @@ public void testCompletedLSPScheduling() { assertEquals(1, secondTranshipmentHubResource.getSimulationTrackers().size()); eventHandlers = new ArrayList<>(secondTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); @@ -489,7 +489,7 @@ public void testCompletedLSPScheduling() { ArrayList planElements = new ArrayList<>(LspShipmentUtils.getOrCreateShipmentPlan(lsp.getSelectedPlan(), shipment.getId()).getPlanElements().values()); planElements.sort(LspShipmentUtils.createShipmentPlanElementComparator()); - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -506,7 +506,7 @@ public void testCompletedLSPScheduling() { assertSame(endHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -523,7 +523,7 @@ public void testCompletedLSPScheduling() { assertSame(serviceHandler.getResourceId(), resources.getFirst().getId()); //MainRunTourStart - assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -541,7 +541,7 @@ public void testCompletedLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); //MainRunTourEnd - assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -559,7 +559,7 @@ public void testCompletedLSPScheduling() { assertSame(mainRunEndHandler.getResourceId(), resources.get(2).getId()); //DistributionTourStart - assertTrue(eventHandlers.get(4) instanceof LSPTourStartEventHandler); + assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(4)); LSPTourStartEventHandler lspTourStartEventHandler = (LSPTourStartEventHandler) eventHandlers.get(4); assertSame(lspTourStartEventHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); assertEquals(lspTourStartEventHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -577,7 +577,7 @@ public void testCompletedLSPScheduling() { assertSame(lspTourStartEventHandler.getResourceId(), resources.get(4).getId()); //DistributionServiceStart - assertTrue(eventHandlers.get(5) instanceof DistributionServiceStartEventHandler); + assertInstanceOf(DistributionServiceStartEventHandler.class, eventHandlers.get(5)); DistributionServiceStartEventHandler distributionServiceHandler = (DistributionServiceStartEventHandler) eventHandlers.get(5); assertSame(distributionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); assertEquals(distributionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); 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 cf01e31f..30507398 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java @@ -251,7 +251,7 @@ public void testFirstReloadLSPScheduling() { assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); for (Entry entry : reloadEventHandler.getServicesWaitedFor().entrySet()) { @@ -280,7 +280,7 @@ public void testFirstReloadLSPScheduling() { eventHandlers = new ArrayList<>(shipment.getSimulationTrackers()); ArrayList planElements = new ArrayList<>(LspShipmentUtils.getOrCreateShipmentPlan(lsp.getSelectedPlan(), shipment.getId()).getPlanElements().values()); - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -292,7 +292,7 @@ public void testFirstReloadLSPScheduling() { assertSame(endHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(endHandler.getResourceId(), lsp.getResources().iterator().next().getId()); - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); 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 dba0cc94..205d0022 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java @@ -319,7 +319,7 @@ public void testMainRunLSPScheduling() { assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); for (Entry entry : reloadEventHandler.getServicesWaitedFor().entrySet()) { @@ -350,7 +350,7 @@ public void testMainRunLSPScheduling() { ArrayList solutionElements = new ArrayList<>(lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements()); ArrayList resources = new ArrayList<>(lsp.getResources()); - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -367,7 +367,7 @@ public void testMainRunLSPScheduling() { assertSame(endHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -384,7 +384,7 @@ public void testMainRunLSPScheduling() { assertSame(serviceHandler.getResourceId(), resources.getFirst().getId()); //MainRunTourStart - assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -402,7 +402,7 @@ public void testMainRunLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); //MainRunEnd - assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); 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 f215df75..6fa3888e 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java @@ -358,7 +358,7 @@ public void testSecondReloadLSPScheduling() { assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); Iterator> iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); @@ -385,7 +385,7 @@ public void testSecondReloadLSPScheduling() { assertEquals(1, secondTranshipmentHubResource.getSimulationTrackers().size()); eventHandlers = new ArrayList<>(secondTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); @@ -419,7 +419,7 @@ public void testSecondReloadLSPScheduling() { ArrayList resources = new ArrayList<>(lsp.getResources()); //CollectionTourEnd - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(collectionEndHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(collectionEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -436,7 +436,7 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionEndHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler collectionServiceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(collectionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(collectionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -453,7 +453,7 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionServiceHandler.getResourceId(), resources.getFirst().getId()); //MainRunStart - assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -471,7 +471,7 @@ public void testSecondReloadLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); //MainRunEnd - assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); 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 92856a25..e1440539 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java @@ -358,7 +358,7 @@ public void testSecondReloadLSPScheduling() { assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); Iterator> iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); @@ -385,7 +385,7 @@ public void testSecondReloadLSPScheduling() { assertEquals(1, secondTranshipmentHubResource.getSimulationTrackers().size()); eventHandlers = new ArrayList<>(secondTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); @@ -419,7 +419,7 @@ public void testSecondReloadLSPScheduling() { ArrayList resources = new ArrayList<>(lsp.getResources()); //CollectionTourEnd - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(collectionEndHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(collectionEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -436,7 +436,7 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionEndHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler collectionServiceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(collectionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(collectionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -453,7 +453,7 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionServiceHandler.getResourceId(), resources.getFirst().getId()); //MainRunStart - assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -471,7 +471,7 @@ public void testSecondReloadLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); //MainRunEnd - assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0);