From 365aa9621e63c87b6ffe4cc0bf88bc6ca445554e Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Tue, 5 Dec 2023 16:41:05 +0100 Subject: [PATCH 01/21] add junit 5 dependency --- benchmark/pom.xml | 12 ++++++++++-- contribs/pom.xml | 12 ++++++++++-- matsim/pom.xml | 12 ++++++++++-- pom.xml | 25 +++++++++++++++++++------ 4 files changed, 49 insertions(+), 12 deletions(-) diff --git a/benchmark/pom.xml b/benchmark/pom.xml index 43ee7d820b2..dd8bbafda2c 100644 --- a/benchmark/pom.xml +++ b/benchmark/pom.xml @@ -41,8 +41,16 @@ 16.0-SNAPSHOT - junit - junit + org.junit.vintage + junit-vintage-engine + + + org.junit.jupiter + junit-jupiter-engine + + + org.junit.jupiter + junit-jupiter diff --git a/contribs/pom.xml b/contribs/pom.xml index 9ffc2dec10e..49124a6bd25 100644 --- a/contribs/pom.xml +++ b/contribs/pom.xml @@ -104,8 +104,16 @@ - junit - junit + org.junit.vintage + junit-vintage-engine + + + org.junit.jupiter + junit-jupiter-engine + + + org.junit.jupiter + junit-jupiter org.matsim diff --git a/matsim/pom.xml b/matsim/pom.xml index 6bf9a851f4d..5f88ffc874b 100644 --- a/matsim/pom.xml +++ b/matsim/pom.xml @@ -160,8 +160,16 @@ 1.5.4 - junit - junit + org.junit.vintage + junit-vintage-engine + + + org.junit.jupiter + junit-jupiter-engine + + + org.junit.jupiter + junit-jupiter org.matsim diff --git a/pom.xml b/pom.xml index be8af9131d3..23a9f29ff66 100644 --- a/pom.xml +++ b/pom.xml @@ -37,6 +37,7 @@ 7.0.0 2.16.0 2.5.0 + 5.10.1 @@ -215,12 +216,24 @@ 4.2.2 - - junit - junit - 4.13.2 - test - + + org.junit.vintage + junit-vintage-engine + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter + ${junit.version} + test + org.slf4j From 156164f270ff12ede7271420495449141caae84f Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Fri, 8 Dec 2023 11:13:52 +0100 Subject: [PATCH 02/21] implemented abstract parent class to replace MatsimTestUtils --- .../contrib/bicycle/run/BicycleTest.java | 211 +++++------ .../config/ReflectiveConfigGroupTest.java | 16 +- .../matsim/testcases/MatsimJunit5Test.java | 344 ++++++++++++++++++ 3 files changed, 452 insertions(+), 119 deletions(-) create mode 100644 matsim/src/test/java/org/matsim/testcases/MatsimJunit5Test.java diff --git a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java index 0f2dea83a91..a5a798ee9de 100644 --- a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java +++ b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java @@ -21,8 +21,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -51,6 +51,7 @@ import org.matsim.core.router.TripStructureUtils; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.collections.CollectionUtils; +import org.matsim.testcases.MatsimJunit5Test; import org.matsim.testcases.MatsimTestUtils; import org.matsim.utils.eventsfilecomparison.EventsFileComparator; import org.matsim.vehicles.Vehicle; @@ -63,23 +64,19 @@ import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import static org.matsim.utils.eventsfilecomparison.EventsFileComparator.Result.FILES_ARE_EQUAL; /** * @author dziemke */ -public class BicycleTest { +public class BicycleTest extends MatsimJunit5Test { private static final Logger LOG = LogManager.getLogger(BicycleTest.class); private static final String bicycleMode = "bicycle"; - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testNormal() { - Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -87,33 +84,32 @@ public void testNormal() { config.network().setInputFile("network_normal.xml"); config.plans().setInputFile("population_1200.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(getOutputDirectory()); config.controller().setLastIteration(0); config.controller().setCreateGraphs(false); new RunBicycleExample().run(config ); LOG.info("Checking MATSim events file ..."); - final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; - final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; - assertEquals("Different event files.", FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew)); + final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; + final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; + Assertions.assertEquals(FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew), "Different event files."); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); - new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); for (Id personId : scenarioReference.getPopulation().getPersons().keySet()) { double scoreReference = scenarioReference.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); double scoreCurrent = scenarioCurrent.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); - Assert.assertEquals("Scores of persons " + personId + " are different", scoreReference, scoreCurrent, MatsimTestUtils.EPSILON); + Assertions.assertEquals(scoreReference, scoreCurrent, MatsimTestUtils.EPSILON, "Scores of persons " + personId + " are different"); } - assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); + Assertions.assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); } @Test public void testCobblestone() { - Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -123,7 +119,7 @@ public void testCobblestone() { config.plans().setInputFile("population_1200.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(getOutputDirectory()); config.controller().setLastIteration(0); config.controller().setCreateGraphs(false); @@ -131,22 +127,21 @@ public void testCobblestone() { { Scenario scenarioReference = ScenarioUtils.createScenario( ConfigUtils.createConfig() ); Scenario scenarioCurrent = ScenarioUtils.createScenario( ConfigUtils.createConfig() ); - new PopulationReader( scenarioReference ).readFile( utils.getInputDirectory() + "output_plans.xml.gz" ); - new PopulationReader( scenarioCurrent ).readFile( utils.getOutputDirectory() + "output_plans.xml.gz" ); - assertTrue( "Populations are different", PopulationUtils.equalPopulation( scenarioReference.getPopulation(), scenarioCurrent.getPopulation() ) ); + new PopulationReader( scenarioReference ).readFile( getInputDirectory() + "output_plans.xml.gz" ); + new PopulationReader( scenarioCurrent ).readFile( getOutputDirectory() + "output_plans.xml.gz" ); + Assertions.assertTrue(PopulationUtils.equalPopulation( scenarioReference.getPopulation(), scenarioCurrent.getPopulation() ), "Populations are different"); } { LOG.info( "Checking MATSim events file ..." ); - final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; - final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; - assertEquals( "Different event files.", FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew )); + final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; + final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; + Assertions.assertEquals(FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew ), "Different event files."); } } @Test public void testPedestrian() { - Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -154,28 +149,27 @@ public void testPedestrian() { config.network().setInputFile("network_pedestrian.xml"); config.plans().setInputFile("population_1200.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(getOutputDirectory()); config.controller().setLastIteration(0); config.controller().setCreateGraphs(false); new RunBicycleExample().run(config ); LOG.info("Checking MATSim events file ..."); - final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; - final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; - assertEquals("Different event files.", FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew)); + final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; + final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; + Assertions.assertEquals(FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew), "Different event files."); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); - new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); - assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); + new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); + Assertions.assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); } @Test public void testLane() { - Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -183,28 +177,27 @@ public void testLane() { config.network().setInputFile("network_lane.xml"); config.plans().setInputFile("population_1200.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(getOutputDirectory()); config.controller().setLastIteration(0); config.controller().setCreateGraphs(false); new RunBicycleExample().run(config ); LOG.info("Checking MATSim events file ..."); - final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; - final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; - assertEquals("Different event files.", FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew)); + final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; + final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; + Assertions.assertEquals(FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew), "Different event files."); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); - new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); - assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); + new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); + Assertions.assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); } @Test public void testGradient() { - Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -212,28 +205,27 @@ public void testGradient() { config.network().setInputFile("network_gradient.xml"); config.plans().setInputFile("population_1200.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(getOutputDirectory()); config.controller().setLastIteration(0); config.controller().setCreateGraphs(false); new RunBicycleExample().run(config ); LOG.info("Checking MATSim events file ..."); - final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; - final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; - assertEquals("Different event files.", FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew)); + final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; + final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; + Assertions.assertEquals(FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew), "Different event files."); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); - new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); - assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); + new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); + Assertions.assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); } @Test public void testGradientLane() { - Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -242,28 +234,27 @@ public void testGradientLane() { config.network().setInputFile("network_gradient_lane.xml"); config.plans().setInputFile("population_1200.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(getOutputDirectory()); config.controller().setLastIteration(0); config.controller().setCreateGraphs(false); new RunBicycleExample().run(config ); LOG.info("Checking MATSim events file ..."); - final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; - final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; - assertEquals("Different event files.", FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew)); + final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; + final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; + Assertions.assertEquals(FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew), "Different event files."); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); - new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); - assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); + new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); + Assertions.assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); } @Test public void testNormal10It() { - Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -271,7 +262,7 @@ public void testNormal10It() { config.network().setInputFile("network_normal.xml"); config.plans().setInputFile("population_1200.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(getOutputDirectory()); // 10 iterations config.controller().setLastIteration(10); config.controller().setWriteEventsInterval(10); @@ -281,16 +272,15 @@ public void testNormal10It() { new RunBicycleExample().run(config ); LOG.info("Checking MATSim events file ..."); - final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; - final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; - assertEquals("Different event files.", FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew)); + final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; + final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; + Assertions.assertEquals(FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew), "Different event files."); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); - new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); - assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); + new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); + Assertions.assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); } @Test public void testLinkBasedScoring() { @@ -301,7 +291,7 @@ public void testNormal10It() { // new RunBicycleExample().run( config ); // } Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); { Config config2 = createConfig( 0 ); BicycleConfigGroup bicycleConfigGroup2 = (BicycleConfigGroup) config2.getModules().get( "bicycle" ); @@ -309,22 +299,23 @@ public void testNormal10It() { new RunBicycleExample().run( config2 ); } Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); // LOG.info("Checking MATSim events file ..."); -// final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; -// final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; -// assertEquals("Different event files.", FILES_ARE_EQUAL, +// final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; +// final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; +// Assert.assertEquals("Different event files.", FILES_ARE_EQUAL, // new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew)); for (Id personId : scenarioReference.getPopulation().getPersons().keySet()) { double scoreReference = scenarioReference.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); double scoreCurrent = scenarioCurrent.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); - Assert.assertEquals("Scores of persons " + personId + " are different", scoreReference, scoreCurrent, MatsimTestUtils.EPSILON); + Assertions.assertEquals(scoreReference, scoreCurrent, MatsimTestUtils.EPSILON, "Scores of persons " + personId + " are different"); } -// assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); +// Assert.assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); } - @Test public void testLinkVsLegMotorizedScoring() { + @Test + public void testLinkVsLegMotorizedScoring() { // --- withOUT additional car traffic: // { // Config config2 = createConfig( 0 ); @@ -334,7 +325,7 @@ public void testNormal10It() { // new RunBicycleExample().run( config2 ); // } Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); // --- // --- WITH additional car traffic: { @@ -393,22 +384,22 @@ public void testNormal10It() { controler.run(); } Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); // --- // --- // LOG.info("Checking MATSim events file ..."); -// final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; -// final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; -// assertEquals("Different event files.", FILES_ARE_EQUAL, +// final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; +// final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; +// Assert.assertEquals("Different event files.", FILES_ARE_EQUAL, // new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew)); for (Id personId : scenarioReference.getPopulation().getPersons().keySet()) { double scoreReference = scenarioReference.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); double scoreCurrent = scenarioCurrent.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); - Assert.assertEquals("Scores of person=" + personId + " are different", scoreReference, scoreCurrent, MatsimTestUtils.EPSILON); + Assertions.assertEquals(scoreReference, scoreCurrent, MatsimTestUtils.EPSILON, "Scores of person=" + personId + " are different"); } -// assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); +// Assert.assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); } // @Test public void testMotorizedInteraction() { //// Config config = ConfigUtils.createConfig("./src/main/resources/bicycle_example/"); @@ -422,26 +413,26 @@ public void testNormal10It() { // new RunBicycleExample().run(config ); // // LOG.info("Checking MATSim events file ..."); -// final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; -// final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; -// assertEquals("Different event files.", FILES_ARE_EQUAL, +// final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; +// final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; +// Assert.assertEquals("Different event files.", FILES_ARE_EQUAL, // new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew)); // // Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); // Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); -// new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); -// new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); +// new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); +// new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); // for (Id personId : scenarioReference.getPopulation().getPersons().keySet()) { // double scoreReference = scenarioReference.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); // double scoreCurrent = scenarioCurrent.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); -// Assert.assertEquals("Scores of persons " + personId + " are different", scoreReference, scoreCurrent, MatsimTestUtils.EPSILON); +// Assert.Assert.assertEquals("Scores of persons " + personId + " are different", scoreReference, scoreCurrent, MatsimTestUtils.EPSILON); // } -// assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); +// Assert.assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); // } @Test public void testInfrastructureSpeedFactor() { - Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); config.controller().setWriteEventsInterval(0); @@ -486,7 +477,7 @@ public void testInfrastructureSpeedFactor() { config.plans().setInputFile("population_4.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(getOutputDirectory()); config.controller().setLastIteration(0); config.global().setNumberOfThreads(1); @@ -523,20 +514,20 @@ public void install() { controler.run(); - Assert.assertEquals("All bicycle users should use the longest but fastest route where the bicycle infrastructur speed factor is set to 1.0", 3, linkHandler.getLinkId2demand().get(Id.createLinkId("2")), MatsimTestUtils.EPSILON); - Assert.assertEquals("Only the car user should use the shortest route", 1, linkHandler.getLinkId2demand().get(Id.createLinkId("6")), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, linkHandler.getLinkId2demand().get(Id.createLinkId("2")), MatsimTestUtils.EPSILON, "All bicycle users should use the longest but fastest route where the bicycle infrastructur speed factor is set to 1.0"); + Assertions.assertEquals(1, linkHandler.getLinkId2demand().get(Id.createLinkId("6")), MatsimTestUtils.EPSILON, "Only the car user should use the shortest route"); - Assert.assertEquals("Wrong travel time (bicycle user)", 1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(0), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time (bicycle user)", 1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(1), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time (bicycle user)", 1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(0), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); + Assertions.assertEquals(1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(1), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); + Assertions.assertEquals(1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(2), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); - Assert.assertEquals("Wrong travel time (car user)", Math.ceil( 10000 / (13.88) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(0), MatsimTestUtils.EPSILON); + Assertions.assertEquals(Math.ceil( 10000 / (13.88) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(0), MatsimTestUtils.EPSILON, "Wrong travel time (car user)"); } @Test public void testInfrastructureSpeedFactorDistanceMoreRelevantThanTravelTime() { - Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(getClassInputDirectory() ); BicycleConfigGroup bicycleConfigGroup = ConfigUtils.addOrGetModule( config, BicycleConfigGroup.class ); config.controller().setWriteEventsInterval(0); @@ -580,7 +571,7 @@ public void testInfrastructureSpeedFactorDistanceMoreRelevantThanTravelTime() { config.network().setInputFile("network_infrastructure-speed-factor.xml"); config.plans().setInputFile("population_4.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(getOutputDirectory()); config.controller().setLastIteration(0); config.global().setNumberOfThreads(1); @@ -610,16 +601,16 @@ public void testInfrastructureSpeedFactorDistanceMoreRelevantThanTravelTime() { controler.run(); - Assert.assertEquals("All bicycle users should use the shortest route even though the bicycle infrastructur speed factor is set to 0.1", 4, linkHandler.getLinkId2demand().get(Id.createLinkId("6")), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time (car user)", Math.ceil(10000 / 13.88 ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(0), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time (bicycle user)", Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(1), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time (bicycle user)", Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(2), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time (bicycle user)", Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(4, linkHandler.getLinkId2demand().get(Id.createLinkId("6")), MatsimTestUtils.EPSILON, "All bicycle users should use the shortest route even though the bicycle infrastructur speed factor is set to 0.1"); + Assertions.assertEquals(Math.ceil(10000 / 13.88 ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(0), MatsimTestUtils.EPSILON, "Wrong travel time (car user)"); + Assertions.assertEquals(Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(1), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); + Assertions.assertEquals(Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(2), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); + Assertions.assertEquals(Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(3), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); } private Config createConfig( int lastIteration ){ // Config config = ConfigUtils.createConfig("./src/main/resources/bicycle_example/"); - Config config = ConfigUtils.createConfig( utils.getClassInputDirectory() ); + Config config = ConfigUtils.createConfig( getClassInputDirectory() ); config.addModule( new BicycleConfigGroup() ); RunBicycleExample.fillConfigWithBicycleStandardValues( config ); @@ -627,7 +618,7 @@ private Config createConfig( int lastIteration ){ config.network().setInputFile( "network_normal.xml" ); config.plans().setInputFile( "population_1200.xml" ); config.controller().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ); - config.controller().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setOutputDirectory( getOutputDirectory() ); config.controller().setLastIteration( lastIteration ); config.controller().setLastIteration( lastIteration ); config.controller().setWriteEventsInterval( 10 ); diff --git a/matsim/src/test/java/org/matsim/core/config/ReflectiveConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/ReflectiveConfigGroupTest.java index a662f53d5ad..be71252c59f 100644 --- a/matsim/src/test/java/org/matsim/core/config/ReflectiveConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/ReflectiveConfigGroupTest.java @@ -32,13 +32,13 @@ import java.util.Map; import java.util.Set; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.ReflectiveConfigGroup.InconsistentModuleException; +import org.matsim.testcases.MatsimJunit5Test; import org.matsim.testcases.MatsimTestUtils; import com.google.common.collect.ImmutableSet; @@ -46,9 +46,7 @@ /** * @author thibautd */ -public class ReflectiveConfigGroupTest { - @Rule - public final MatsimTestUtils utils = new MatsimTestUtils(); +public class ReflectiveConfigGroupTest extends MatsimJunit5Test { @Test public void testDumpAndRead() { @@ -128,7 +126,7 @@ private void assertEqualAfterDumpAndRead(MyModule dumpedModule) { Config dumpedConfig = new Config(); dumpedConfig.addModule(dumpedModule); - String fileName = utils.getOutputDirectory() + "/dump.xml"; + String fileName = getOutputDirectory() + "/dump.xml"; new ConfigWriter(dumpedConfig).write(fileName); Config readConfig = ConfigUtils.loadConfig(fileName); @@ -141,7 +139,7 @@ private void assertEqualAfterDumpAndRead(MyModule dumpedModule) { @Test public void testReadCollectionsIncludingEmptyString() { - String fileName = utils.getInputDirectory() + "/config_with_blank_comma_separated_elements.xml"; + String fileName = getInputDirectory() + "/config_with_blank_comma_separated_elements.xml"; final Config readConfig = ConfigUtils.loadConfig(fileName); final MyModule readModule = new MyModule(); // as a side effect, this loads the information @@ -362,7 +360,7 @@ public Object getStuff() { final String param = "my unknown param"; final String value = "my val"; testee.addParam(param, value); - Assert.assertEquals("unexpected stored value", value, testee.getValue(param)); + Assertions.assertEquals(value, testee.getValue(param), "unexpected stored value"); } @Test diff --git a/matsim/src/test/java/org/matsim/testcases/MatsimJunit5Test.java b/matsim/src/test/java/org/matsim/testcases/MatsimJunit5Test.java new file mode 100644 index 00000000000..0581a3d58d0 --- /dev/null +++ b/matsim/src/test/java/org/matsim/testcases/MatsimJunit5Test.java @@ -0,0 +1,344 @@ +/* *********************************************************************** * + * project: org.matsim.* + * * + * *********************************************************************** * + * * + * copyright : (C) 2010 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ + +package org.matsim.testcases; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.Assert; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInfo; +import org.junit.rules.TestWatcher; +import org.junit.runner.Description; +import org.matsim.core.config.Config; +import org.matsim.core.config.ConfigGroup; +import org.matsim.core.config.ConfigUtils; +import org.matsim.core.gbl.MatsimRandom; +import org.matsim.core.utils.io.IOUtils; +import org.matsim.core.utils.misc.CRCChecksum; +import org.matsim.utils.eventsfilecomparison.EventsFileComparator; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static org.junit.Assert.assertEquals; + +/** + * //TODO + * + * @author pheinrich + */ +public abstract class MatsimJunit5Test { + private static final Logger log = LogManager.getLogger(MatsimJunit5Test.class); + + /** + * A constant for the exactness when comparing doubles. + */ + public static final double EPSILON = 1e-10; + + /** The default output directory, where files of this test should be written to. + * Includes the trailing '/' to denote a directory. */ + private String outputDirectory = null; + + /** The default input directory, where files of this test should be read from. + * Includes the trailing '/' to denote a directory. */ + private String inputDirectory = null; + + /** + * The input directory one level above the default input directory. If files are + * used by several test methods of a testcase they have to be stored in this directory. + */ + private String classInputDirectory = null; + /** + * The input directory two levels above the default input directory. If files are used + * by several test classes of a package they have to be stored in this directory. + */ + private String packageInputDirectory; + + private boolean outputDirCreated = false; + + private Class testClass = null; + private String testMethodName = null; + private String testParameterSetIndex = null; + + public MatsimJunit5Test() { + MatsimRandom.reset(); + } + + @BeforeEach + public void initEach(TestInfo testInfo) { + this.testClass = testInfo.getTestClass().orElseThrow(); + + Matcher matcher = METHOD_PARAMETERS_WITH_INDEX_PATTERN.matcher(testInfo.getTestMethod().orElseThrow().getName()); + if (!matcher.matches()) { + throw new RuntimeException("The name of the test parameter set must start with {index}"); + } + this.testMethodName = matcher.group(1); + this.testParameterSetIndex = matcher.group(2); // null for non-parametrised tests + } + + @AfterEach + public void finish() { + this.testClass = null; + this.testMethodName = null; + } + + public Config createConfigWithInputResourcePathAsContext() { + Config config = ConfigUtils.createConfig(); + config.setContext(inputResourcePath()); + this.outputDirectory = getOutputDirectory(); + config.controller().setOutputDirectory(this.outputDirectory); + return config; + } + + public Config createConfigWithClassInputResourcePathAsContext() { + Config config = ConfigUtils.createConfig(); + config.setContext(classInputResourcePath()); + this.outputDirectory = getOutputDirectory(); + config.controller().setOutputDirectory(this.outputDirectory); + return config; + } + + public Config createConfigWithPackageInputResourcePathAsContext() { + Config config = ConfigUtils.createConfig(); + config.setContext(packageInputResourcePath()); + this.outputDirectory = getOutputDirectory(); + config.controller().setOutputDirectory(this.outputDirectory); + return config; + } + + public URL inputResourcePath() { + return getResourceNotNull("/" + getClassInputDirectory() + getMethodName() + "/."); + } + + /** + * @return class input directory as URL + */ + public URL classInputResourcePath() { + return getResourceNotNull("/" + getClassInputDirectory() + "/."); + } + + public URL packageInputResourcePath() { + return getResourceNotNull("/" + getPackageInputDirectory() + "/."); + } + + private URL getResourceNotNull(String pathString) { + URL resource = this.testClass.getResource(pathString); + if (resource == null) { + throw new UncheckedIOException(new IOException("Not found: "+pathString)); + } + return resource; + } + + public Config createConfigWithTestInputFilePathAsContext() { + try { + Config config = ConfigUtils.createConfig(); + config.setContext(new File(this.getInputDirectory()).toURI().toURL()); + this.outputDirectory = getOutputDirectory(); + config.controller().setOutputDirectory(this.outputDirectory); + return config; + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + } + + public Config createConfig(URL context) { + Config config = ConfigUtils.createConfig(); + config.setContext(context); + this.outputDirectory = getOutputDirectory(); + config.controller().setOutputDirectory(this.outputDirectory); + return config; + } + + + /** + * Loads a configuration from file (or the default config if configfile is null). + * + * @param configfile The path/filename of a configuration file, or null to load the default configuration. + * @return The loaded configuration. + */ + public Config loadConfig(final String configfile, final ConfigGroup... customGroups) { + Config config; + if (configfile != null) { + config = ConfigUtils.loadConfig(configfile, customGroups); + } else { + config = ConfigUtils.createConfig( customGroups ); + } + this.outputDirectory = getOutputDirectory(); + config.controller().setOutputDirectory(this.outputDirectory); + return config; + } + + public Config loadConfig(final URL configfile, final ConfigGroup... customGroups) { + Config config; + if (configfile != null) { + config = ConfigUtils.loadConfig(configfile, customGroups); + } else { + config = ConfigUtils.createConfig( customGroups ); + } + this.outputDirectory = getOutputDirectory(); + config.controller().setOutputDirectory(this.outputDirectory); + return config; + } + + public Config createConfig(final ConfigGroup... customGroups) { + Config config = ConfigUtils.createConfig( customGroups ); + this.outputDirectory = getOutputDirectory(); + config.controller().setOutputDirectory(this.outputDirectory); + return config; + } + + private void createOutputDirectory() { + if ((!this.outputDirCreated) && (this.outputDirectory != null)) { + File directory = new File(this.outputDirectory); + if (directory.exists()) { + IOUtils.deleteDirectoryRecursively(directory.toPath()); + } + this.outputDirCreated = directory.mkdirs(); + Assert.assertTrue("Could not create the output directory " + this.outputDirectory, this.outputDirCreated); + } + } + + /** + * Returns the path to the output directory for this test including a trailing slash as directory delimiter. + * + * @return path to the output directory for this test + */ + public String getOutputDirectory() { + if (this.outputDirectory == null) { + String subDirectoryForParametrisedTests = testParameterSetIndex == null ? "" : testParameterSetIndex + "/"; + this.outputDirectory = "test/output/" + this.testClass.getCanonicalName().replace('.', '/') + "/" + getMethodName()+ "/" + + subDirectoryForParametrisedTests; + } + createOutputDirectory(); + return this.outputDirectory; + } + + /** + * Returns the path to the input directory for this test including a trailing slash as directory delimiter. + * + * @return path to the input directory for this test + */ + public String getInputDirectory() { + if (this.inputDirectory == null) { + this.inputDirectory = getClassInputDirectory() + getMethodName() + "/"; + } + return this.inputDirectory; + } + /** + * Returns the path to the input directory one level above the default input directory for this test including a trailing slash as directory delimiter. + * + * @return path to the input directory for this test + */ + public String getClassInputDirectory() { + if (this.classInputDirectory == null) { + + LogManager.getLogger(this.getClass()).info( "user.dir = " + System.getProperty("user.dir") ) ; + + this.classInputDirectory = "test/input/" + + this.testClass.getCanonicalName().replace('.', '/') + "/"; +// this.classInputDirectory = System.getProperty("user.dir") + "/test/input/" + +// this.testClass.getCanonicalName().replace('.', '/') + "/"; + // (this used to be relative, i.e. ... = "test/input/" + ... . Started failing when + // this was used in tests to read a second config file when I made the path of that + // relative to the root of the initial config file. Arghh. kai, feb'18) + // yyyyyy needs to be discussed, see MATSIM-776 and MATSIM-777. kai, feb'18 + } + return this.classInputDirectory; + } + /** + * Returns the path to the input directory two levels above the default input directory for this test including a trailing slash as directory delimiter. + * + * @return path to the input directory for this test + */ + public String getPackageInputDirectory() { + if (this.packageInputDirectory == null) { + String classDirectory = getClassInputDirectory(); + this.packageInputDirectory = classDirectory.substring(0, classDirectory.lastIndexOf('/')); + this.packageInputDirectory = this.packageInputDirectory.substring(0, this.packageInputDirectory.lastIndexOf('/') + 1); + } + return this.packageInputDirectory; + } + + /** + * @return the name of the currently-running test method + */ + public String getMethodName() { + if (this.testMethodName == null) { + throw new RuntimeException("MatsimTestUtils.getMethodName() can only be used in actual test, not in constructor or elsewhere!"); + } + return this.testMethodName; + } + + /** + * Initializes MatsimTestUtils without requiring the method of a class to be a JUnit test. + * This should be used for "fixtures" only that provide a scenario common to several + * test cases. + */ + public void initWithoutJUnitForFixture(Class fixture, Method method){ + this.testClass = fixture; + this.testMethodName = method.getName(); + } + + //captures the method name (group 1) and optionally the index of the parameter set (group 2; only if the test is parametrised) + //The matching may fail if the parameter set name does not start with {index} (at least one digit is required at the beginning) + private static final Pattern METHOD_PARAMETERS_WITH_INDEX_PATTERN = Pattern.compile( + "([\\S]*)(?:\\[(\\d+)[\\s\\S]*\\])?"); + + public static void assertEqualEventsFiles( String filename1, String filename2 ) { + Assert.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL ,EventsFileComparator.compare(filename1, filename2) ); + } + + public static void assertEqualFilesBasedOnCRC( String filename1, String filename2 ) { + long checksum1 = CRCChecksum.getCRCFromFile(filename1) ; + long checksum2 = CRCChecksum.getCRCFromFile(filename2) ; + Assert.assertEquals( "different file checksums", checksum1, checksum2 ); + } + + public static void assertEqualFilesLineByLine(String inputFilename, String outputFilename) { + try (BufferedReader readerV1Input = IOUtils.getBufferedReader(inputFilename); + BufferedReader readerV1Output = IOUtils.getBufferedReader(outputFilename)) { + + String lineInput; + String lineOutput; + + while( ((lineInput = readerV1Input.readLine()) != null) && ((lineOutput = readerV1Output.readLine()) != null) ){ + if ( !Objects.equals( lineInput.trim(), lineOutput.trim() ) ){ + log.info( "Reading line... " ); + log.info( lineInput ); + log.info( lineOutput ); + log.info( "" ); + } + assertEquals( "Lines have different content: ", lineInput.trim(), lineOutput.trim() ); + } + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + +} From 0fefc9f2970b336d296d8321d48270d7c7ff0430 Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Fri, 8 Dec 2023 13:14:12 +0100 Subject: [PATCH 03/21] implemented Test Extension --- .../contrib/ev/example/RunEvExampleTest.java | 23 +- .../matsim/core/config/ConfigV2IOTest.java | 41 +-- .../testcases/MatsimJunit5TestExtension.java | 344 ++++++++++++++++++ 3 files changed, 367 insertions(+), 41 deletions(-) create mode 100644 matsim/src/test/java/org/matsim/testcases/MatsimJunit5TestExtension.java diff --git a/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleTest.java b/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleTest.java index 8c26016e49a..c2d26638e04 100644 --- a/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleTest.java +++ b/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleTest.java @@ -2,21 +2,22 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; import org.matsim.core.events.EventsUtils; import org.matsim.core.population.PopulationUtils; -import org.matsim.testcases.MatsimTestUtils; +import org.matsim.testcases.MatsimJunit5TestExtension; import org.matsim.utils.eventsfilecomparison.EventsFileComparator; public class RunEvExampleTest{ private static final Logger log = LogManager.getLogger(RunEvExample.class ); - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension + public MatsimJunit5TestExtension utils = new MatsimJunit5TestExtension() ; @Test public void runTest(){ try { @@ -33,20 +34,20 @@ public class RunEvExampleTest{ PopulationUtils.readPopulation( actual, utils.getOutputDirectory() + "/output_plans.xml.gz" ); boolean result = PopulationUtils.comparePopulations( expected, actual ); - Assert.assertTrue( result ); + Assertions.assertTrue(result); } { String expected = utils.getInputDirectory() + "/output_events.xml.gz" ; String actual = utils.getOutputDirectory() + "/output_events.xml.gz" ; EventsFileComparator.Result result = EventsUtils.compareEventsFiles( expected, actual ); - Assert.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result ); + Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, result); } } catch ( Exception ee ) { log.fatal("there was an exception: \n" + ee ) ; // if one catches an exception, then one needs to explicitly fail the test: - Assert.fail(); + Assertions.fail(); } } @@ -66,20 +67,20 @@ public class RunEvExampleTest{ PopulationUtils.readPopulation( actual, utils.getOutputDirectory() + "/output_plans.xml.gz" ); boolean result = PopulationUtils.comparePopulations( expected, actual ); - Assert.assertTrue( result ); + Assertions.assertTrue(result); } { String expected = utils.getInputDirectory() + "/output_events.xml.gz" ; String actual = utils.getOutputDirectory() + "/output_events.xml.gz" ; EventsFileComparator.Result result = EventsUtils.compareEventsFiles( expected, actual ); - Assert.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result ); + Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, result); } } catch ( Exception ee ) { log.fatal("there was an exception: \n" + ee ) ; // if one catches an exception, then one needs to explicitly fail the test: - Assert.fail(); + Assertions.fail(); } } diff --git a/matsim/src/test/java/org/matsim/core/config/ConfigV2IOTest.java b/matsim/src/test/java/org/matsim/core/config/ConfigV2IOTest.java index f98a8e5603f..4ee31b42d7b 100644 --- a/matsim/src/test/java/org/matsim/core/config/ConfigV2IOTest.java +++ b/matsim/src/test/java/org/matsim/core/config/ConfigV2IOTest.java @@ -22,22 +22,18 @@ import java.util.Collection; import java.util.Iterator; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.matsim.core.config.Config; -import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.ConfigWriter; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.config.groups.ChangeLegModeConfigGroup; -import org.matsim.core.config.ConfigReaderMatsimV2; -import org.matsim.testcases.MatsimTestUtils; +import org.matsim.testcases.MatsimJunit5TestExtension; /** * @author thibautd */ public class ConfigV2IOTest { - @Rule - public final MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public final MatsimJunit5TestExtension utils = new MatsimJunit5TestExtension(); @Test public void testInputSameAsOutput() { @@ -56,10 +52,7 @@ public void testInputSameAsOutput() { private void assertTheSame( final Config outConfig, final Config inConfig) { - Assert.assertEquals( - "names of modules differ!", - outConfig.getModules().keySet(), - inConfig.getModules().keySet() ); + Assertions.assertEquals(outConfig.getModules().keySet(), inConfig.getModules().keySet(), "names of modules differ!"); for ( String name : outConfig.getModules().keySet() ) { if ( !name.equals( ChangeLegModeConfigGroup.CONFIG_MODULE ) ) { @@ -74,29 +67,17 @@ private void assertTheSame( private void assertTheSame( final ConfigGroup outModule, final ConfigGroup inModule) { - Assert.assertEquals( - "wrong module class", - outModule.getClass(), - inModule.getClass() ); + Assertions.assertEquals(outModule.getClass(), inModule.getClass(), "wrong module class"); - Assert.assertEquals( - "different parameters", - outModule.getParams(), - inModule.getParams() ); + Assertions.assertEquals(outModule.getParams(), inModule.getParams(), "different parameters"); - Assert.assertEquals( - "different parameterset types", - outModule.getParameterSets().keySet(), - inModule.getParameterSets().keySet() ); + Assertions.assertEquals(outModule.getParameterSets().keySet(), inModule.getParameterSets().keySet(), "different parameterset types"); for ( String type : outModule.getParameterSets().keySet() ) { final Collection outSets = outModule.getParameterSets( type ); final Collection inSets = inModule.getParameterSets( type ); - Assert.assertEquals( - "different number of sets for type "+type, - outSets.size(), - inSets.size() ); + Assertions.assertEquals(outSets.size(), inSets.size(), "different number of sets for type "+type); final Iterator outIter = outSets.iterator(); final Iterator inIter = inSets.iterator(); diff --git a/matsim/src/test/java/org/matsim/testcases/MatsimJunit5TestExtension.java b/matsim/src/test/java/org/matsim/testcases/MatsimJunit5TestExtension.java new file mode 100644 index 00000000000..1e4e87367c9 --- /dev/null +++ b/matsim/src/test/java/org/matsim/testcases/MatsimJunit5TestExtension.java @@ -0,0 +1,344 @@ +/* *********************************************************************** * + * project: org.matsim.* + * * + * *********************************************************************** * + * * + * copyright : (C) 2010 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ + +package org.matsim.testcases; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.Assert; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.matsim.core.config.Config; +import org.matsim.core.config.ConfigGroup; +import org.matsim.core.config.ConfigUtils; +import org.matsim.core.gbl.MatsimRandom; +import org.matsim.core.utils.io.IOUtils; +import org.matsim.core.utils.misc.CRCChecksum; +import org.matsim.utils.eventsfilecomparison.EventsFileComparator; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static org.junit.Assert.assertEquals; + +/** + * //TODO + * + * @author pheinrich + */ +public class MatsimJunit5TestExtension implements BeforeEachCallback, AfterEachCallback { + private static final Logger log = LogManager.getLogger(MatsimJunit5TestExtension.class); + + /** + * A constant for the exactness when comparing doubles. + */ + public static final double EPSILON = 1e-10; + + /** The default output directory, where files of this test should be written to. + * Includes the trailing '/' to denote a directory. */ + private String outputDirectory = null; + + /** The default input directory, where files of this test should be read from. + * Includes the trailing '/' to denote a directory. */ + private String inputDirectory = null; + + /** + * The input directory one level above the default input directory. If files are + * used by several test methods of a testcase they have to be stored in this directory. + */ + private String classInputDirectory = null; + /** + * The input directory two levels above the default input directory. If files are used + * by several test classes of a package they have to be stored in this directory. + */ + private String packageInputDirectory; + + private boolean outputDirCreated = false; + + private Class testClass = null; + private String testMethodName = null; + private String testParameterSetIndex = null; + + public MatsimJunit5TestExtension() { + MatsimRandom.reset(); + } + + @Override + public void beforeEach(ExtensionContext extensionContext) throws Exception { + this.testClass = extensionContext.getTestClass().orElseThrow(); + + Matcher matcher = METHOD_PARAMETERS_WITH_INDEX_PATTERN.matcher(extensionContext.getTestMethod().orElseThrow().getName()); + if (!matcher.matches()) { + throw new RuntimeException("The name of the test parameter set must start with {index}"); + } + this.testMethodName = matcher.group(1); + this.testParameterSetIndex = matcher.group(2); // null for non-parametrised tests + } + + @Override + public void afterEach(ExtensionContext extensionContext) throws Exception { + this.testClass = null; + this.testMethodName = null; + } + + public Config createConfigWithInputResourcePathAsContext() { + Config config = ConfigUtils.createConfig(); + config.setContext(inputResourcePath()); + this.outputDirectory = getOutputDirectory(); + config.controller().setOutputDirectory(this.outputDirectory); + return config; + } + + public Config createConfigWithClassInputResourcePathAsContext() { + Config config = ConfigUtils.createConfig(); + config.setContext(classInputResourcePath()); + this.outputDirectory = getOutputDirectory(); + config.controller().setOutputDirectory(this.outputDirectory); + return config; + } + + public Config createConfigWithPackageInputResourcePathAsContext() { + Config config = ConfigUtils.createConfig(); + config.setContext(packageInputResourcePath()); + this.outputDirectory = getOutputDirectory(); + config.controller().setOutputDirectory(this.outputDirectory); + return config; + } + + public URL inputResourcePath() { + return getResourceNotNull("/" + getClassInputDirectory() + getMethodName() + "/."); + } + + /** + * @return class input directory as URL + */ + public URL classInputResourcePath() { + return getResourceNotNull("/" + getClassInputDirectory() + "/."); + } + + public URL packageInputResourcePath() { + return getResourceNotNull("/" + getPackageInputDirectory() + "/."); + } + + private URL getResourceNotNull(String pathString) { + URL resource = this.testClass.getResource(pathString); + if (resource == null) { + throw new UncheckedIOException(new IOException("Not found: "+pathString)); + } + return resource; + } + + public Config createConfigWithTestInputFilePathAsContext() { + try { + Config config = ConfigUtils.createConfig(); + config.setContext(new File(this.getInputDirectory()).toURI().toURL()); + this.outputDirectory = getOutputDirectory(); + config.controller().setOutputDirectory(this.outputDirectory); + return config; + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + } + + public Config createConfig(URL context) { + Config config = ConfigUtils.createConfig(); + config.setContext(context); + this.outputDirectory = getOutputDirectory(); + config.controller().setOutputDirectory(this.outputDirectory); + return config; + } + + + /** + * Loads a configuration from file (or the default config if configfile is null). + * + * @param configfile The path/filename of a configuration file, or null to load the default configuration. + * @return The loaded configuration. + */ + public Config loadConfig(final String configfile, final ConfigGroup... customGroups) { + Config config; + if (configfile != null) { + config = ConfigUtils.loadConfig(configfile, customGroups); + } else { + config = ConfigUtils.createConfig( customGroups ); + } + this.outputDirectory = getOutputDirectory(); + config.controller().setOutputDirectory(this.outputDirectory); + return config; + } + + public Config loadConfig(final URL configfile, final ConfigGroup... customGroups) { + Config config; + if (configfile != null) { + config = ConfigUtils.loadConfig(configfile, customGroups); + } else { + config = ConfigUtils.createConfig( customGroups ); + } + this.outputDirectory = getOutputDirectory(); + config.controller().setOutputDirectory(this.outputDirectory); + return config; + } + + public Config createConfig(final ConfigGroup... customGroups) { + Config config = ConfigUtils.createConfig( customGroups ); + this.outputDirectory = getOutputDirectory(); + config.controller().setOutputDirectory(this.outputDirectory); + return config; + } + + private void createOutputDirectory() { + if ((!this.outputDirCreated) && (this.outputDirectory != null)) { + File directory = new File(this.outputDirectory); + if (directory.exists()) { + IOUtils.deleteDirectoryRecursively(directory.toPath()); + } + this.outputDirCreated = directory.mkdirs(); + Assert.assertTrue("Could not create the output directory " + this.outputDirectory, this.outputDirCreated); + } + } + + /** + * Returns the path to the output directory for this test including a trailing slash as directory delimiter. + * + * @return path to the output directory for this test + */ + public String getOutputDirectory() { + if (this.outputDirectory == null) { + String subDirectoryForParametrisedTests = testParameterSetIndex == null ? "" : testParameterSetIndex + "/"; + this.outputDirectory = "test/output/" + this.testClass.getCanonicalName().replace('.', '/') + "/" + getMethodName()+ "/" + + subDirectoryForParametrisedTests; + } + createOutputDirectory(); + return this.outputDirectory; + } + + /** + * Returns the path to the input directory for this test including a trailing slash as directory delimiter. + * + * @return path to the input directory for this test + */ + public String getInputDirectory() { + if (this.inputDirectory == null) { + this.inputDirectory = getClassInputDirectory() + getMethodName() + "/"; + } + return this.inputDirectory; + } + /** + * Returns the path to the input directory one level above the default input directory for this test including a trailing slash as directory delimiter. + * + * @return path to the input directory for this test + */ + public String getClassInputDirectory() { + if (this.classInputDirectory == null) { + + LogManager.getLogger(this.getClass()).info( "user.dir = " + System.getProperty("user.dir") ) ; + + this.classInputDirectory = "test/input/" + + this.testClass.getCanonicalName().replace('.', '/') + "/"; +// this.classInputDirectory = System.getProperty("user.dir") + "/test/input/" + +// this.testClass.getCanonicalName().replace('.', '/') + "/"; + // (this used to be relative, i.e. ... = "test/input/" + ... . Started failing when + // this was used in tests to read a second config file when I made the path of that + // relative to the root of the initial config file. Arghh. kai, feb'18) + // yyyyyy needs to be discussed, see MATSIM-776 and MATSIM-777. kai, feb'18 + } + return this.classInputDirectory; + } + /** + * Returns the path to the input directory two levels above the default input directory for this test including a trailing slash as directory delimiter. + * + * @return path to the input directory for this test + */ + public String getPackageInputDirectory() { + if (this.packageInputDirectory == null) { + String classDirectory = getClassInputDirectory(); + this.packageInputDirectory = classDirectory.substring(0, classDirectory.lastIndexOf('/')); + this.packageInputDirectory = this.packageInputDirectory.substring(0, this.packageInputDirectory.lastIndexOf('/') + 1); + } + return this.packageInputDirectory; + } + + /** + * @return the name of the currently-running test method + */ + public String getMethodName() { + if (this.testMethodName == null) { + throw new RuntimeException("MatsimTestUtils.getMethodName() can only be used in actual test, not in constructor or elsewhere!"); + } + return this.testMethodName; + } + + /** + * Initializes MatsimTestUtils without requiring the method of a class to be a JUnit test. + * This should be used for "fixtures" only that provide a scenario common to several + * test cases. + */ + public void initWithoutJUnitForFixture(Class fixture, Method method){ + this.testClass = fixture; + this.testMethodName = method.getName(); + } + + //captures the method name (group 1) and optionally the index of the parameter set (group 2; only if the test is parametrised) + //The matching may fail if the parameter set name does not start with {index} (at least one digit is required at the beginning) + private static final Pattern METHOD_PARAMETERS_WITH_INDEX_PATTERN = Pattern.compile( + "([\\S]*)(?:\\[(\\d+)[\\s\\S]*\\])?"); + + public static void assertEqualEventsFiles( String filename1, String filename2 ) { + Assert.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL ,EventsFileComparator.compare(filename1, filename2) ); + } + + public static void assertEqualFilesBasedOnCRC( String filename1, String filename2 ) { + long checksum1 = CRCChecksum.getCRCFromFile(filename1) ; + long checksum2 = CRCChecksum.getCRCFromFile(filename2) ; + Assert.assertEquals( "different file checksums", checksum1, checksum2 ); + } + + public static void assertEqualFilesLineByLine(String inputFilename, String outputFilename) { + try (BufferedReader readerV1Input = IOUtils.getBufferedReader(inputFilename); + BufferedReader readerV1Output = IOUtils.getBufferedReader(outputFilename)) { + + String lineInput; + String lineOutput; + + while( ((lineInput = readerV1Input.readLine()) != null) && ((lineOutput = readerV1Output.readLine()) != null) ){ + if ( !Objects.equals( lineInput.trim(), lineOutput.trim() ) ){ + log.info( "Reading line... " ); + log.info( lineInput ); + log.info( lineOutput ); + log.info( "" ); + } + assertEquals( "Lines have different content: ", lineInput.trim(), lineOutput.trim() ); + } + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } +} From ea99b55ff9e79ce89df1a1236ba58e1fa20eb0bc Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Mon, 11 Dec 2023 11:23:07 +0100 Subject: [PATCH 04/21] implemented HereMapsRouteValidatorTest --- .../HereMapsRouteValidator.java | 60 +++++++++++-------- .../HereMapsRouteValidatorTest.java | 41 +++++++++++++ .../GoogleMapRouteValidatorTest/route.json | 30 ++++++++++ .../HereMapsRouteValidatorTest/route.json | 49 +++++++++++++++ 4 files changed, 155 insertions(+), 25 deletions(-) create mode 100644 contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java create mode 100644 contribs/analysis/test/input/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest/route.json create mode 100644 contribs/analysis/test/input/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest/route.json diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidator.java b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidator.java index 9af9cff72c9..e78704027e8 100644 --- a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidator.java +++ b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidator.java @@ -28,6 +28,7 @@ import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Locale; +import java.util.Optional; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -41,6 +42,9 @@ import org.matsim.core.utils.io.IOUtils; import org.matsim.core.utils.misc.Time; +import javax.swing.*; +import javax.swing.text.html.Option; + /** * @author jbischoff this class requests travel times and distances between two * coordinates from HERE Maps. Please replace the API code with your own @@ -91,9 +95,6 @@ public Tuple getTravelTime(NetworkTrip trip) { @Override public Tuple getTravelTime(Coord fromCoord, Coord toCoord, double departureTime, String tripId) { - long travelTime = 0; - long distance = 0; - Coord from = transformation.transform(fromCoord); Coord to = transformation.transform(toCoord); @@ -110,36 +111,45 @@ public Tuple getTravelTime(Coord fromCoord, Coord toCoord, doubl log.info(urlString); + Optional> result; try { URL url = new URL(urlString); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); - JSONParser jp = new JSONParser(); - JSONObject jsonObject = (JSONObject) jp.parse(in); - JSONArray routes = (JSONArray) jsonObject.get("routes"); - - if (!routes.isEmpty()) { - JSONObject route = (JSONObject) routes.get(0); - JSONArray sections = (JSONArray) route.get("sections"); - JSONObject section = (JSONObject) sections.get(0); - JSONObject summary = (JSONObject) section.get("summary"); - travelTime = (long) summary.get("duration"); - distance = (long) summary.get("length"); - if (writeDetailedFiles) { - String filename = outputPath + "/" + tripId + ".json.gz"; - BufferedWriter bw = IOUtils.getBufferedWriter(filename); - bw.write(jsonObject.toString()); - bw.flush(); - bw.close(); - } - } - - in.close(); + result = readFromJson(in, tripId); } catch (MalformedURLException e) { log.error("URL is not working. Please check your API key", e); + result = Optional.empty(); } catch (IOException | ParseException e) { log.error("Cannot read the content on the URL properly. Please manually check the URL", e); + result = Optional.empty(); } - return new Tuple((double) travelTime, (double) distance); + return result.orElse(new Tuple<>(0.0, 0.0)); } + Optional> readFromJson(BufferedReader reader, String tripId) throws IOException, ParseException { + JSONParser jp = new JSONParser(); + JSONObject jsonObject = (JSONObject) jp.parse(reader); + JSONArray routes = (JSONArray) jsonObject.get("routes"); + + if(routes.isEmpty()){ + return Optional.empty(); + } + + JSONObject route = (JSONObject) routes.get(0); + JSONArray sections = (JSONArray) route.get("sections"); + JSONObject section = (JSONObject) sections.get(0); + JSONObject summary = (JSONObject) section.get("summary"); + long travelTime = (long) summary.get("duration"); + long distance = (long) summary.get("length"); + if (writeDetailedFiles) { + String filename = outputPath + "/" + tripId + ".json.gz"; + BufferedWriter bw = IOUtils.getBufferedWriter(filename); + bw.write(jsonObject.toString()); + bw.flush(); + bw.close(); + } + reader.close(); + return Optional.of(new Tuple<>((double) travelTime, (double) distance)); + } + } diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java new file mode 100644 index 00000000000..d4a8c0ce063 --- /dev/null +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java @@ -0,0 +1,41 @@ +package org.matsim.contrib.analysis.vsp.traveltimedistance; + +import org.jgrapht.alg.linkprediction.PreferentialAttachmentLinkPrediction; +import org.json.simple.parser.ParseException; +import org.junit.Rule; +import org.junit.Test; +import org.matsim.core.utils.collections.Tuple; +import org.matsim.testcases.MatsimTestUtils; + +import java.io.*; +import java.util.Optional; + +import static org.junit.Assert.*; + +public class HereMapsRouteValidatorTest { + @Rule + public MatsimTestUtils utils = new MatsimTestUtils(); + + @Test + public void testReadJson() throws IOException, ParseException { + HereMapsRouteValidator hereMapsRouteValidator = getDummyValidator(false); + BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(utils.getClassInputDirectory() + "route.json"))); + Optional> result = hereMapsRouteValidator.readFromJson(reader, null); + assertTrue(result.isPresent()); + assertEquals(394, result.get().getFirst(), MatsimTestUtils.EPSILON); + assertEquals(2745, result.get().getSecond(), MatsimTestUtils.EPSILON); + } + + @Test + public void testWriteFile() throws IOException, ParseException { + HereMapsRouteValidator hereMapsRouteValidator = getDummyValidator(true); + BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(utils.getClassInputDirectory() + "route.json"))); + hereMapsRouteValidator.readFromJson(reader, "tripId"); + assertTrue(new File(utils.getOutputDirectory() + "tripId.json.gz").isFile()); + } + + //All values with null filled are not necessary for this test + private HereMapsRouteValidator getDummyValidator(boolean writeDetailedFiles) { + return new HereMapsRouteValidator(utils.getOutputDirectory(), null, null, null, null, writeDetailedFiles); + } +} diff --git a/contribs/analysis/test/input/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest/route.json b/contribs/analysis/test/input/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest/route.json new file mode 100644 index 00000000000..14e61b35177 --- /dev/null +++ b/contribs/analysis/test/input/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest/route.json @@ -0,0 +1,30 @@ +{ + "destination_addresses": [ + "Kaiserin-Augusta-Allee 104, 10553 Berlin, Germany" + ], + "origin_addresses": [ + "B2 135, 10623 Berlin, Germany" + ], + "rows": [ + { + "elements": [ + { + "distance": { + "text": "2.5 km", + "value": 2464 + }, + "duration": { + "text": "7 mins", + "value": 400 + }, + "duration_in_traffic": { + "text": "7 mins", + "value": 413 + }, + "status": "OK" + } + ] + } + ], + "status": "OK" +} \ No newline at end of file diff --git a/contribs/analysis/test/input/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest/route.json b/contribs/analysis/test/input/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest/route.json new file mode 100644 index 00000000000..2dfdae5e032 --- /dev/null +++ b/contribs/analysis/test/input/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest/route.json @@ -0,0 +1,49 @@ +{ + "routes": [ + { + "id": "ed5396be-8f97-4c25-a373-a019da78b696", + "sections": [ + { + "id": "5f0ff311-d1d0-4a6a-a631-1c59fd5eaee4", + "type": "vehicle", + "departure": { + "time": "2023-12-11T10:00:00+01:00", + "place": { + "type": "place", + "location": { + "lat": 52.5127381, + "lng": 13.3268076 + }, + "originalLocation": { + "lat": 52.512638, + "lng": 13.326826 + } + } + }, + "arrival": { + "time": "2023-12-11T10:06:34+01:00", + "place": { + "type": "place", + "location": { + "lat": 52.5258281, + "lng": 13.3209817 + }, + "originalLocation": { + "lat": 52.5256489, + "lng": 13.320944 + } + } + }, + "summary": { + "duration": 394, + "length": 2745, + "baseDuration": 325 + }, + "transport": { + "mode": "car" + } + } + ] + } + ] +} \ No newline at end of file From 98a82e69b67cc80e2b4b9d21e5d3c23c27251122 Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Mon, 11 Dec 2023 11:33:33 +0100 Subject: [PATCH 05/21] implemented GoogleMapRouteValidatorTest --- .../GoogleMapRouteValidator.java | 57 ++++++++++++------- .../GoogleMapRouteValidatorTest.java | 33 +++++++++++ 2 files changed, 68 insertions(+), 22 deletions(-) create mode 100644 contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidator.java b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidator.java index b8aa76c34e1..171c5bc4469 100644 --- a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidator.java +++ b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidator.java @@ -9,8 +9,10 @@ import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.geometry.CoordinateTransformation; +import org.matsim.core.utils.io.IOUtils; import java.io.BufferedReader; +import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; @@ -20,6 +22,7 @@ import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.Locale; +import java.util.Optional; public class GoogleMapRouteValidator implements TravelTimeDistanceValidator { private static final Logger log = LogManager.getLogger(GoogleMapRouteValidator.class); @@ -51,9 +54,6 @@ public Tuple getTravelTime(NetworkTrip trip) { @Override public Tuple getTravelTime(Coord fromCoord, Coord toCoord, double departureTime, String tripId) { - long travelTime = 0; - long distance = 0; - double adjustedDepartureTime = calculateGoogleDepartureTime(departureTime); Coord from = ct.transform(fromCoord); Coord to = ct.transform(toCoord); @@ -71,32 +71,45 @@ public Tuple getTravelTime(Coord fromCoord, Coord toCoord, doubl "&origins=" + df.format(from.getY()) + "%2C" + df.format(from.getX()) + "&key=" + apiAccessKey; + log.info(urlString); + + Optional> result; try { - log.info(urlString); URL url = new URL(urlString); - try (BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()))) { - JSONParser jp = new JSONParser(); - JSONObject jsonObject = (JSONObject) jp.parse(in); - JSONArray rows = (JSONArray) jsonObject.get("rows"); - if (!rows.isEmpty()) { - JSONArray elements = (JSONArray) ((JSONObject) rows.get(0)).get("elements"); - JSONObject results = (JSONObject) elements.get(0); - if (results.containsKey("distance")) { - JSONObject distanceResults = (JSONObject) results.get("distance"); - distance = (long) distanceResults.get("value"); - } - if (results.containsKey("duration_in_traffic")) { - JSONObject timeResults = (JSONObject) results.get("duration_in_traffic"); - travelTime = (long) timeResults.get("value"); - } - } - } + BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); + result = readFromJson(in); } catch (IOException | ParseException e) { log.error("The contents on the URL cannot be read properly. Please check your API or check the contents on URL manually", e); + result = Optional.empty(); } - return new Tuple<>((double) travelTime, (double) distance); + return result.orElse(new Tuple<>(0.0, 0.0)); } + Optional> readFromJson(BufferedReader reader) throws IOException, ParseException { + JSONParser jp = new JSONParser(); + JSONObject jsonObject = (JSONObject) jp.parse(reader); + JSONArray rows = (JSONArray) jsonObject.get("rows"); + + if (rows.isEmpty()) { + return Optional.empty(); + } + + JSONArray elements = (JSONArray) ((JSONObject) rows.get(0)).get("elements"); + JSONObject results = (JSONObject) elements.get(0); + + + if (!results.containsKey("distance") && !results.containsKey("duration_in_traffic")) { + return Optional.empty(); + } + + JSONObject distanceResults = (JSONObject) results.get("distance"); + long distance = (long) distanceResults.get("value"); + JSONObject timeResults = (JSONObject) results.get("duration_in_traffic"); + long travelTime = (long) timeResults.get("value"); + + return Optional.of(new Tuple<>((double) travelTime, (double) distance)); + } + private double calculateGoogleDepartureTime(double departureTime) { DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDate googleDate0 = LocalDate.parse("1970-01-01", dateTimeFormatter); diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java new file mode 100644 index 00000000000..ee9d4dbb2f4 --- /dev/null +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java @@ -0,0 +1,33 @@ +package org.matsim.contrib.analysis.vsp.traveltimedistance; + +import org.json.simple.parser.ParseException; +import org.junit.Rule; +import org.junit.Test; +import org.matsim.core.utils.collections.Tuple; +import org.matsim.testcases.MatsimTestUtils; + +import java.io.*; +import java.util.Optional; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class GoogleMapRouteValidatorTest { + @Rule + public MatsimTestUtils utils = new MatsimTestUtils(); + + @Test + public void testReadJson() throws IOException, ParseException { + GoogleMapRouteValidator googleMapRouteValidator = getDummyValidator(); + BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(utils.getClassInputDirectory() + "route.json"))); + Optional> result = googleMapRouteValidator.readFromJson(reader); + assertTrue(result.isPresent()); + assertEquals(413, result.get().getFirst(), MatsimTestUtils.EPSILON); + assertEquals(2464, result.get().getSecond(), MatsimTestUtils.EPSILON); + } + + //All values with null filled are not necessary for this test + private GoogleMapRouteValidator getDummyValidator() { + return new GoogleMapRouteValidator(utils.getOutputDirectory(), null, null, null, null); + } +} From 11703e405ca4d700bbe81301d650271febd38a1d Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Mon, 11 Dec 2023 11:53:28 +0100 Subject: [PATCH 06/21] switched to gson --- contribs/analysis/pom.xml | 12 +++--- .../GoogleMapRouteValidator.java | 39 +++++++++---------- .../HereMapsRouteValidator.java | 38 +++++++++--------- .../GoogleMapRouteValidatorTest.java | 3 +- .../HereMapsRouteValidatorTest.java | 6 +-- 5 files changed, 47 insertions(+), 51 deletions(-) diff --git a/contribs/analysis/pom.xml b/contribs/analysis/pom.xml index 83989a7fcbf..6eccfbda0b1 100644 --- a/contribs/analysis/pom.xml +++ b/contribs/analysis/pom.xml @@ -20,12 +20,12 @@ proj4j 0.1.0 - - com.googlecode.json-simple - json-simple - 1.1.1 - - + + com.google.code.gson + gson + 2.10.1 + + org.apache.commons commons-math3 diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidator.java b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidator.java index 171c5bc4469..7d35886428d 100644 --- a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidator.java +++ b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidator.java @@ -1,18 +1,16 @@ package org.matsim.contrib.analysis.vsp.traveltimedistance; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.geometry.CoordinateTransformation; -import org.matsim.core.utils.io.IOUtils; import java.io.BufferedReader; -import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; @@ -78,36 +76,37 @@ public Tuple getTravelTime(Coord fromCoord, Coord toCoord, doubl URL url = new URL(urlString); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); result = readFromJson(in); - } catch (IOException | ParseException e) { + } catch (IOException e) { log.error("The contents on the URL cannot be read properly. Please check your API or check the contents on URL manually", e); result = Optional.empty(); } return result.orElse(new Tuple<>(0.0, 0.0)); } - Optional> readFromJson(BufferedReader reader) throws IOException, ParseException { - JSONParser jp = new JSONParser(); - JSONObject jsonObject = (JSONObject) jp.parse(reader); - JSONArray rows = (JSONArray) jsonObject.get("rows"); + Optional> readFromJson(BufferedReader reader) throws IOException { + JsonElement jsonElement = JsonParser.parseReader(reader); + if(!jsonElement.isJsonObject()){ + return Optional.empty(); + } + JsonObject jsonObject = jsonElement.getAsJsonObject(); + JsonArray rows = jsonObject.getAsJsonArray("rows"); if (rows.isEmpty()) { return Optional.empty(); } - JSONArray elements = (JSONArray) ((JSONObject) rows.get(0)).get("elements"); - JSONObject results = (JSONObject) elements.get(0); - + JsonObject results = rows.get(0).getAsJsonObject().get("elements").getAsJsonArray().get(0).getAsJsonObject(); - if (!results.containsKey("distance") && !results.containsKey("duration_in_traffic")) { + if (!results.has("distance") && !results.has("duration_in_traffic")) { return Optional.empty(); } - JSONObject distanceResults = (JSONObject) results.get("distance"); - long distance = (long) distanceResults.get("value"); - JSONObject timeResults = (JSONObject) results.get("duration_in_traffic"); - long travelTime = (long) timeResults.get("value"); + JsonObject distanceResults = results.get("distance").getAsJsonObject(); + double distance = distanceResults.get("value").getAsDouble(); + JsonObject timeResults = results.get("duration_in_traffic").getAsJsonObject(); + double travelTime = timeResults.get("value").getAsDouble(); - return Optional.of(new Tuple<>((double) travelTime, (double) distance)); + return Optional.of(new Tuple<>(travelTime, distance)); } private double calculateGoogleDepartureTime(double departureTime) { diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidator.java b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidator.java index e78704027e8..b437d7dffb8 100644 --- a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidator.java +++ b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidator.java @@ -30,21 +30,18 @@ import java.util.Locale; import java.util.Optional; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.core.utils.io.IOUtils; import org.matsim.core.utils.misc.Time; -import javax.swing.*; -import javax.swing.text.html.Option; - /** * @author jbischoff this class requests travel times and distances between two * coordinates from HERE Maps. Please replace the API code with your own @@ -119,28 +116,31 @@ public Tuple getTravelTime(Coord fromCoord, Coord toCoord, doubl } catch (MalformedURLException e) { log.error("URL is not working. Please check your API key", e); result = Optional.empty(); - } catch (IOException | ParseException e) { + } catch (IOException e) { log.error("Cannot read the content on the URL properly. Please manually check the URL", e); result = Optional.empty(); } return result.orElse(new Tuple<>(0.0, 0.0)); } - Optional> readFromJson(BufferedReader reader, String tripId) throws IOException, ParseException { - JSONParser jp = new JSONParser(); - JSONObject jsonObject = (JSONObject) jp.parse(reader); - JSONArray routes = (JSONArray) jsonObject.get("routes"); + Optional> readFromJson(BufferedReader reader, String tripId) throws IOException { + JsonElement jsonElement = JsonParser.parseReader(reader); + if(!jsonElement.isJsonObject()){ + return Optional.empty(); + } + JsonObject jsonObject = jsonElement.getAsJsonObject(); + JsonArray routes = jsonObject.getAsJsonArray("routes"); if(routes.isEmpty()){ return Optional.empty(); } - JSONObject route = (JSONObject) routes.get(0); - JSONArray sections = (JSONArray) route.get("sections"); - JSONObject section = (JSONObject) sections.get(0); - JSONObject summary = (JSONObject) section.get("summary"); - long travelTime = (long) summary.get("duration"); - long distance = (long) summary.get("length"); + JsonObject route = routes.get(0).getAsJsonObject(); + JsonArray sections = route.get("sections").getAsJsonArray(); + JsonObject section = sections.get(0).getAsJsonObject(); + JsonObject summary = section.get("summary").getAsJsonObject(); + double travelTime = summary.get("duration").getAsDouble(); + double distance = summary.get("length").getAsDouble(); if (writeDetailedFiles) { String filename = outputPath + "/" + tripId + ".json.gz"; BufferedWriter bw = IOUtils.getBufferedWriter(filename); @@ -149,7 +149,7 @@ Optional> readFromJson(BufferedReader reader, String tripI bw.close(); } reader.close(); - return Optional.of(new Tuple<>((double) travelTime, (double) distance)); + return Optional.of(new Tuple<>(travelTime, distance)); } } diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java index ee9d4dbb2f4..694b5039e8e 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java @@ -1,6 +1,5 @@ package org.matsim.contrib.analysis.vsp.traveltimedistance; -import org.json.simple.parser.ParseException; import org.junit.Rule; import org.junit.Test; import org.matsim.core.utils.collections.Tuple; @@ -17,7 +16,7 @@ public class GoogleMapRouteValidatorTest { public MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testReadJson() throws IOException, ParseException { + public void testReadJson() throws IOException { GoogleMapRouteValidator googleMapRouteValidator = getDummyValidator(); BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(utils.getClassInputDirectory() + "route.json"))); Optional> result = googleMapRouteValidator.readFromJson(reader); diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java index d4a8c0ce063..cdf03802384 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java @@ -1,7 +1,5 @@ package org.matsim.contrib.analysis.vsp.traveltimedistance; -import org.jgrapht.alg.linkprediction.PreferentialAttachmentLinkPrediction; -import org.json.simple.parser.ParseException; import org.junit.Rule; import org.junit.Test; import org.matsim.core.utils.collections.Tuple; @@ -17,7 +15,7 @@ public class HereMapsRouteValidatorTest { public MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testReadJson() throws IOException, ParseException { + public void testReadJson() throws IOException { HereMapsRouteValidator hereMapsRouteValidator = getDummyValidator(false); BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(utils.getClassInputDirectory() + "route.json"))); Optional> result = hereMapsRouteValidator.readFromJson(reader, null); @@ -27,7 +25,7 @@ public void testReadJson() throws IOException, ParseException { } @Test - public void testWriteFile() throws IOException, ParseException { + public void testWriteFile() throws IOException { HereMapsRouteValidator hereMapsRouteValidator = getDummyValidator(true); BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(utils.getClassInputDirectory() + "route.json"))); hereMapsRouteValidator.readFromJson(reader, "tripId"); From cc81f0ec97c4de41726240d242d1248a4ecc812f Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Mon, 11 Dec 2023 12:00:00 +0100 Subject: [PATCH 07/21] replace dependencies of simple json --- .../accessibility/utils/GeoJsonPolygonFeatureWriter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GeoJsonPolygonFeatureWriter.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GeoJsonPolygonFeatureWriter.java index c022be98067..f0e3dc08db3 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GeoJsonPolygonFeatureWriter.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GeoJsonPolygonFeatureWriter.java @@ -1,6 +1,6 @@ package org.matsim.contrib.accessibility.utils; -import org.json.simple.JSONValue; +import com.google.gson.Gson; import org.matsim.api.core.v01.Coord; import java.util.*; @@ -34,7 +34,7 @@ public String asGeoJson() { featureCollectionMap.put("features", featuresList); featureCollectionMap.put("crs", parseCRS()); featureCollectionMap.put("bbox", boundingBox.getBoundingBox()); - return JSONValue.toJSONString(featureCollectionMap); + return new Gson().toJson(featureCollectionMap); } private List> parseFeatureList() { From 30e7163cb4450a887e329b46891021b1b222351e Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Mon, 11 Dec 2023 14:05:18 +0100 Subject: [PATCH 08/21] replaced rules by extensions --- .../accessibility/grid/SpatialGridTest.java | 6 +- .../CompareLogsumFormulas2Test.java | 6 +- .../CompareLogsumFormulasTest.java | 6 +- .../ComputeLogsumFormulas3Test.java | 6 +- .../run/AccessibilityIntegrationTest.java | 4 +- .../accessibility/run/NetworkUtilTest.java | 92 +-- .../run/TinyAccessibilityTest.java | 4 +- .../run/TinyMultimodalAccessibilityTest.java | 4 +- .../org/matsim/contrib/accidents/RunTest.java | 4 +- .../contrib/accidents/RunTestEquil.java | 4 +- .../PersonIntersectAreaFilterTest.java | 6 +- .../population/RouteLinkFilterTest.java | 6 +- .../kai/KNAnalysisEventsHandlerTest.java | 10 +- .../GoogleMapRouteValidatorTest.java | 6 +- .../HereMapsRouteValidatorTest.java | 6 +- .../RunEventsToTravelDiariesIT.java | 6 +- .../matsim/application/CommandRunnerTest.java | 6 +- .../application/MATSimApplicationTest.java | 6 +- .../analysis/LogFileAnalysisTest.java | 6 +- .../application/options/CsvOptionsTest.java | 11 +- .../application/options/ShpOptionsTest.java | 8 +- .../prepare/CreateLandUseShpTest.java | 8 +- .../prepare/ShapeFileTextLookupTest.java | 8 +- .../counts/CreateCountsFromBAStDataTest.java | 6 +- .../population/CloseTrajectoriesTest.java | 8 +- .../SplitActivityTypesDurationTest.java | 6 +- .../pt/CreateTransitScheduleFromGtfsTest.java | 6 +- .../CarrierReaderFromCSVTest.java | 6 +- .../DemandReaderFromCSVTest.java | 6 +- .../FreightDemandGenerationTest.java | 6 +- .../FreightDemandGenerationUtilsTest.java | 8 +- .../LanduseBuildingAnalysisTest.java | 6 +- ...nerateSmallScaleCommercialTrafficTest.java | 6 +- .../SmallScaleCommercialTrafficUtilsTest.java | 6 +- .../TrafficVolumeGenerationTest.java | 6 +- .../TripDistributionMatrixTest.java | 6 +- .../contrib/av/flow/RunAvExampleIT.java | 6 +- .../contrib/av/flow/TestAvFlowFactor.java | 6 +- .../RunTaxiPTIntermodalExampleIT.java | 6 +- .../BicycleLinkSpeedCalculatorTest.java | 5 +- .../contrib/bicycle/run/BicycleTest.java | 212 ++--- .../contrib/cadyts/car/CadytsCarIT.java | 6 +- .../utils/CalibrationStatReaderTest.java | 6 +- .../runExample/RunCarsharingIT.java | 4 +- .../always/BetaTravelTest66IT.java | 6 +- .../integration/always/BetaTravelTest6IT.java | 6 +- .../DecongestionPricingTestIT.java | 6 +- .../modules/config/ConfigTest.java | 4 +- .../DrtWithExtensionsConfigGroupTest.java | 14 +- .../RunDrtWithCompanionExampleIT.java | 6 +- .../extension/dashboards/DashboardTests.java | 6 +- .../MultiModaFixedDrtLegEstimatorTest.java | 6 +- .../MultiModalDrtLegEstimatorTest.java | 6 +- .../insertion/DrtInsertionExtensionIT.java | 6 +- .../OperationFacilitiesIOTest.java | 6 +- .../operations/shifts/ShiftsIOTest.java | 6 +- .../drt/config/ConfigBehaviorTest.java | 4 +- .../DefaultUnplannedRequestInserterTest.java | 9 +- .../insertion/DrtPoolingParameterTest.java | 4 +- ...stRule.java => ForkJoinPoolExtension.java} | 20 +- .../ExtensiveInsertionProviderTest.java | 6 +- .../SelectiveInsertionProviderTest.java | 10 +- .../drt/prebooking/AbandonAndCancelTest.java | 26 +- .../prebooking/PersonStuckPrebookingTest.java | 6 +- .../drt/prebooking/PrebookingTest.java | 38 +- .../drt/routing/DrtRoutingModuleTest.java | 6 +- .../drt/run/examples/RunDrtExampleIT.java | 28 +- .../RunOneTaxiWithPrebookingExampleIT.java | 6 +- .../contrib/emissions/EmissionModuleTest.java | 8 +- .../emissions/TestPositionEmissionModule.java | 6 +- .../analysis/EmissionGridAnalyzerTest.java | 6 +- .../FastEmissionGridAnalyzerTest.java | 6 +- .../analysis/RawEmissionEventsReaderTest.java | 8 +- .../events/VehicleLeavesTrafficEventTest.java | 6 +- ...unAverageEmissionToolOfflineExampleIT.java | 4 +- ...nDetailedEmissionToolOfflineExampleIT.java | 4 +- ...EmissionToolOnlineExampleIT_vehTypeV1.java | 4 +- ...eExampleIT_vehTypeV1FallbackToAverage.java | 4 +- ...EmissionToolOnlineExampleIT_vehTypeV2.java | 4 +- ...eExampleIT_vehTypeV2FallbackToAverage.java | 4 +- .../contrib/ev/example/RunEvExampleTest.java | 4 +- ...nEvExampleWithLTHConsumptionModelTest.java | 4 +- ...emperatureChangeModuleIntegrationTest.java | 6 +- .../carriers/CarrierEventsReadersTest.java | 4 +- .../freight/carriers/CarrierModuleTest.java | 6 +- .../carriers/CarrierPlanReaderV1Test.java | 4 +- .../carriers/CarrierPlanXmlReaderV2Test.java | 4 +- .../CarrierPlanXmlReaderV2WithDtdTest.java | 2 +- .../carriers/CarrierPlanXmlWriterV1Test.java | 6 +- .../carriers/CarrierPlanXmlWriterV2Test.java | 6 +- .../CarrierPlanXmlWriterV2_1Test.java | 6 +- .../carriers/CarrierReadWriteV2_1Test.java | 6 +- .../CarrierVehicleTypeLoaderTest.java | 4 +- .../CarrierVehicleTypeReaderTest.java | 4 +- .../carriers/CarrierVehicleTypeTest.java | 4 +- .../CarrierVehicleTypeWriterTest.java | 6 +- .../freight/carriers/CarriersUtilsTest.java | 6 +- .../EquilWithCarrierWithPersonsIT.java | 4 +- .../EquilWithCarrierWithoutPersonsIT.java | 4 +- ...istanceConstraintFromVehiclesFileTest.java | 6 +- .../jsprit/DistanceConstraintTest.java | 6 +- .../carriers/jsprit/FixedCostsTest.java | 4 +- .../carriers/jsprit/IntegrationIT.java | 6 +- .../jsprit/MatsimTransformerTest.java | 6 +- .../NetworkBasedTransportCostsTest.java | 4 +- .../freight/carriers/jsprit/SkillsIT.java | 6 +- .../usecases/chessboard/RunChessboardIT.java | 4 +- .../RunPassengerAlongWithCarriersIT.java | 6 +- .../utils/CarrierControlerUtilsIT.java | 6 +- .../utils/CarrierControlerUtilsTest.java | 10 +- .../freightreceiver/ReceiversReaderTest.java | 4 +- .../freightreceiver/ReceiversTest.java | 6 +- .../freightreceiver/ReceiversWriterTest.java | 4 +- .../matsim/modechoice/EstimateRouterTest.java | 8 +- .../org/matsim/modechoice/ScenarioTest.java | 6 +- .../org/matsim/modechoice/TestScenario.java | 2 +- .../commands/GenerateChoiceSetTest.java | 6 +- .../estimators/ComplexEstimatorTest.java | 6 +- .../modechoice/search/TopKMinMaxTest.java | 6 +- .../CreateAutomatedFDTest.java | 66 +- ...stReplyLocationChoicePlanStrategyTest.java | 6 +- .../locationchoice/LocationChoiceIT.java | 6 +- .../frozenepsilons/BestReplyIT.java | 6 +- .../FrozenEpsilonLocaChoiceIT.java | 4 +- .../frozenepsilons/SamplerTest.java | 6 +- .../LocationMutatorwChoiceSetTest.java | 6 +- .../timegeography/ManageSubchainsTest.java | 6 +- .../RandomLocationMutatorTest.java | 6 +- .../timegeography/SubChainTest.java | 6 +- .../MatrixBasedPtRouterIT.java | 14 +- .../matrixbasedptrouter/PtMatrixTest.java | 14 +- .../minibus/integration/PControlerTestIT.java | 4 +- .../integration/SubsidyContextTestIT.java | 4 +- .../minibus/integration/SubsidyTestIT.java | 4 +- .../replanning/EndRouteExtensionTest.java | 98 +-- .../MaxRandomEndTimeAllocatorTest.java | 22 +- .../MaxRandomStartTimeAllocatorTest.java | 22 +- .../SidewaysRouteExtensionTest.java | 96 +-- .../minibus/replanning/TimeProviderTest.java | 44 +- .../WeightedEndTimeExtensionTest.java | 40 +- .../WeightedStartTimeExtensionTest.java | 40 +- .../ComplexCircleScheduleProviderTest.java | 104 +-- .../SimpleCircleScheduleProviderTest.java | 62 +- ...tionApproachesAndBetweenJunctionsTest.java | 74 +- .../CreateStopsForAllCarLinksTest.java | 26 +- .../RecursiveStatsApproxContainerTest.java | 12 +- .../stats/RecursiveStatsContainerTest.java | 12 +- .../MultiModalControlerListenerTest.java | 4 +- .../multimodal/RunMultimodalExampleTest.java | 4 +- .../pt/MultiModalPTCombinationTest.java | 6 +- .../router/util/BikeTravelTimeTest.java | 6 +- .../router/util/WalkTravelTimeTest.java | 6 +- .../multimodal/simengine/StuckAgentTest.java | 6 +- .../contrib/noise/NoiseConfigGroupIT.java | 6 +- .../org/matsim/contrib/noise/NoiseIT.java | 6 +- .../contrib/noise/NoiseOnlineExampleIT.java | 6 +- .../matsim/contrib/noise/NoiseRLS19IT.java | 6 +- .../osm/networkReader/OsmBicycleReaderIT.java | 6 +- .../networkReader/OsmBicycleReaderTest.java | 6 +- .../networkReader/OsmNetworkParserTest.java | 6 +- .../networkReader/OsmSignalsParserTest.java | 8 +- .../SupersonicOsmNetworkReaderIT.java | 6 +- .../SupersonicOsmNetworkReaderTest.java | 6 +- .../org/matsim/contrib/otfvis/OTFVisIT.java | 6 +- .../run/RunWithParkingProxyIT.java | 4 +- .../run/RunParkingChoiceExampleIT.java | 4 +- .../run/RunParkingSearchScenarioIT.java | 6 +- .../contrib/protobuf/EventWriterPBTest.java | 9 +- .../contrib/pseudosimulation/RunPSimTest.java | 6 +- .../integration/RailsimIntegrationTest.java | 6 +- .../railsim/qsimengine/RailsimEngineTest.java | 6 +- .../roadpricing/AvoidTolledRouteTest.java | 6 +- .../contrib/roadpricing/CalcPaidTollTest.java | 6 +- .../contrib/roadpricing/ModuleTest.java | 6 +- .../PlansCalcRouteWithTollOrNotTest.java | 6 +- .../RoadPricingConfigGroupTest.java | 8 +- .../roadpricing/RoadPricingControlerIT.java | 6 +- .../roadpricing/RoadPricingIOTest.java | 6 +- .../TollTravelCostCalculatorTest.java | 4 +- .../run/RoadPricingByConfigfileTest.java | 4 +- .../run/RunRoadPricingExampleIT.java | 4 +- .../matsim/mobsim/qsim/SBBQSimModuleTest.java | 4 +- .../SBBTransitQSimEngineIntegrationTest.java | 4 +- .../AdaptiveSignalsExampleTest.java | 10 +- .../CreateIntergreensExampleTest.java | 12 +- .../CreateSignalInputExampleTest.java | 12 +- ...CreateSignalInputExampleWithLanesTest.java | 20 +- .../RunSignalSystemsExampleTest.java | 4 +- .../FixResponsiveSignalResultsIT.java | 14 +- .../contrib/signals/CalculateAngleTest.java | 38 +- .../analysis/DelayAnalysisToolTest.java | 58 +- .../signals/builder/QSimSignalTest.java | 40 +- .../builder/TravelTimeFourWaysTest.java | 6 +- .../builder/TravelTimeOneWayTestIT.java | 6 +- ...aultPlanbasedSignalSystemControllerIT.java | 6 +- .../controller/laemmerFix/LaemmerIT.java | 6 +- .../signals/controller/sylvia/SylviaIT.java | 6 +- .../v10/AmberTimesData10ReaderWriterTest.java | 8 +- .../SignalConflictDataReaderWriterTest.java | 38 +- .../UnprotectedLeftTurnLogicTest.java | 6 +- ...IntergreenTimesData10ReaderWriterTest.java | 10 +- .../SignalControlData20ReaderWriterTest.java | 34 +- .../v20/SignalGroups20ReaderWriterTest.java | 38 +- .../SignalSystemsData20ReaderWriterTest.java | 38 +- .../signals/integration/SignalSystemsIT.java | 6 +- .../InvertedNetworksSignalsIT.java | 6 +- .../SignalsAndLanesOsmNetworkReaderTest.java | 6 +- .../signals/oneagent/ControlerTest.java | 6 +- .../SimulatedAnnealingConfigGroupTest.java | 12 +- .../SimulatedAnnealingIT.java | 6 +- .../simwrapper/SimWrapperConfigGroupTest.java | 6 +- .../simwrapper/SimWrapperModuleTest.java | 6 +- .../org/matsim/simwrapper/SimWrapperTest.java | 6 +- .../simwrapper/dashboard/DashboardTests.java | 6 +- .../dashboard/EmissionsDashboardTest.java | 6 +- .../dashboard/TrafficCountsDashboardTest.java | 6 +- .../simwrapper/viz/PlotlyExamplesTest.java | 6 +- .../org/matsim/simwrapper/viz/PlotlyTest.java | 6 +- .../framework/population/JointPlanIOTest.java | 4 +- .../population/SocialNetworkIOTest.java | 4 +- .../replanning/grouping/FixedGroupsIT.java | 4 +- .../FullExplorationVsCuttoffTest.java | 4 +- ...intTravelingSimulationIntegrationTest.java | 10 +- .../utils/JointScenarioUtilsTest.java | 10 +- .../etaxi/run/RunETaxiBenchmarkTest.java | 4 +- .../contrib/etaxi/run/RunETaxiScenarioIT.java | 6 +- .../assignment/AssignmentTaxiOptimizerIT.java | 4 +- .../optimizer/fifo/FifoTaxiOptimizerIT.java | 4 +- .../rules/RuleBasedTaxiOptimizerIT.java | 4 +- .../optimizer/zonal/ZonalTaxiOptimizerIT.java | 4 +- .../taxi/run/RunTaxiScenarioTestIT.java | 4 +- ...oringParametersFromPersonAttributesIT.java | 6 +- ...omPersonAttributesNoSubpopulationTest.java | 6 +- ...ingParametersFromPersonAttributesTest.java | 6 +- .../FreightAnalysisEventBasedTest.java | 6 +- .../analysis/RunFreightAnalysisIT.java | 4 +- .../RunFreightAnalysisWithShipmentTest.java | 6 +- .../drtAndPt/PtAlongALine2Test.java | 6 +- .../drtAndPt/PtAlongALineTest.java | 6 +- .../osmBB/PTCountsNetworkSimplifierTest.java | 6 +- .../ModalDistanceAndCountsCadytsIT.java | 6 +- ...odalDistanceCadytsMultipleDistancesIT.java | 6 +- .../ModalDistanceCadytsSingleDistanceIT.java | 6 +- .../marginals/TripEventHandlerTest.java | 6 +- .../AdvancedMarginalCongestionPricingIT.java | 6 +- .../CombinedFlowAndStorageDelayTest.java | 32 +- ...nalCongestionHandlerFlowQueueQsimTest.java | 776 +++++++++--------- ...tionHandlerFlowSpillbackQueueQsimTest.java | 6 +- .../MarginalCongestionHandlerV3Test.java | 6 +- .../MarginalCongestionPricingTest.java | 16 +- .../MultipleSpillbackCausingLinksTest.java | 18 +- .../vsp/congestion/TestForEmergenceTime.java | 16 +- .../ev/TransferFinalSocToNextIterTest.java | 6 +- .../java/playground/vsp/ev/UrbanEVIT.java | 4 +- ...rarchicalFLowEfficiencyCalculatorTest.java | 7 +- .../cemdap/input/SynPopCreatorTest.java | 12 +- .../PlanFileModifierTest.java | 4 +- .../vsp/pt/fare/PtTripFareEstimatorTest.java | 6 +- .../vsp/pt/ptdisturbances/EditTripsTest.java | 4 +- ...nScoringParametersNoSubpopulationTest.java | 6 +- ...ityOfMoneyPersonScoringParametersTest.java | 4 +- .../vsp/zzArchive/bvwpOld/BvwpTest.java | 6 +- .../pt/raptor/SwissRailRaptorModuleTest.java | 6 +- .../org/matsim/analysis/CalcLegTimesTest.java | 6 +- .../matsim/analysis/CalcLinkStatsTest.java | 76 +- ...ationTravelStatsControlerListenerTest.java | 6 +- .../org/matsim/analysis/LegHistogramTest.java | 6 +- .../LinkStatsControlerListenerTest.java | 6 +- ...deChoiceCoverageControlerListenerTest.java | 6 +- .../ModeStatsControlerListenerTest.java | 6 +- .../analysis/OutputTravelStatsTest.java | 6 +- .../analysis/PHbyModeCalculatorTest.java | 6 +- .../analysis/PKMbyModeCalculatorTest.java | 6 +- .../ScoreStatsControlerListenerTest.java | 6 +- ...ansportPlanningMainModeIdentifierTest.java | 8 +- .../analysis/TravelDistanceStatsTest.java | 6 +- .../org/matsim/analysis/TripsAnalysisIT.java | 6 +- .../analysis/TripsAndLegsCSVWriterTest.java | 6 +- .../matsim/analysis/VolumesAnalyzerTest.java | 50 +- .../LinkPaxVolumesAnalysisTest.java | 6 +- .../PersonMoneyEventAggregatorTest.java | 6 +- .../api/core/v01/DemandGenerationTest.java | 6 +- .../api/core/v01/NetworkCreationTest.java | 6 +- .../matsim/core/config/CommandLineTest.java | 4 +- .../matsim/core/config/ConfigV2IOTest.java | 4 +- .../core/config/MaterializeConfigTest.java | 8 +- .../config/ReflectiveConfigGroupTest.java | 17 +- .../groups/ReplanningConfigGroupTest.java | 4 +- .../config/groups/RoutingConfigGroupTest.java | 4 +- .../config/groups/ScoringConfigGroupTest.java | 4 +- .../VspExperimentalConfigGroupTest.java | 6 +- .../core/controler/AbstractModuleTest.java | 4 +- .../core/controler/ControlerEventsTest.java | 6 +- .../matsim/core/controler/ControlerIT.java | 4 +- .../ControlerMobsimIntegrationTest.java | 4 +- .../controler/MatsimServicesImplTest.java | 6 +- .../core/controler/MobsimListenerTest.java | 6 +- .../core/controler/NewControlerTest.java | 6 +- .../OutputDirectoryHierarchyTest.java | 4 +- .../core/controler/TerminationTest.java | 6 +- .../TransitControlerIntegrationTest.java | 6 +- .../corelisteners/ListenersInjectionTest.java | 4 +- .../corelisteners/PlansDumpingIT.java | 4 +- .../matsim/core/events/ActEndEventTest.java | 6 +- .../matsim/core/events/ActStartEventTest.java | 6 +- .../core/events/AgentMoneyEventTest.java | 6 +- .../events/AgentWaitingForPtEventTest.java | 4 +- .../core/events/BasicEventsHandlerTest.java | 6 +- .../events/EventsHandlerHierarchyTest.java | 6 +- .../matsim/core/events/EventsReadersTest.java | 6 +- .../matsim/core/events/GenericEventTest.java | 6 +- .../core/events/LinkEnterEventTest.java | 6 +- .../core/events/LinkLeaveEventTest.java | 6 +- .../core/events/PersonArrivalEventTest.java | 6 +- .../core/events/PersonDepartureEventTest.java | 6 +- .../events/PersonEntersVehicleEventTest.java | 6 +- .../events/PersonLeavesVehicleEventTest.java | 6 +- .../core/events/PersonStuckEventTest.java | 6 +- .../events/TransitDriverStartsEventTest.java | 14 +- .../core/events/VehicleAbortsEventTest.java | 6 +- ...VehicleArrivesAtFacilityEventImplTest.java | 6 +- ...VehicleDepartsAtFacilityEventImplTest.java | 6 +- .../events/VehicleEntersTrafficEventTest.java | 6 +- .../events/VehicleLeavesTrafficEventTest.java | 6 +- .../events/algorithms/EventWriterXMLTest.java | 14 +- .../org/matsim/core/gbl/MatsimRandomTest.java | 6 +- .../matsim/core/gbl/MatsimResourceTest.java | 6 +- .../mobsim/hermes/HermesRoundaboutTest.java | 6 +- .../mobsim/jdeqsim/AbstractJDEQSimTest.java | 4 +- .../mobsim/jdeqsim/ConfigParameterTest.java | 6 +- .../core/mobsim/jdeqsim/TestEventLog.java | 6 +- .../mobsim/jdeqsim/TestMessageFactory.java | 6 +- .../core/mobsim/jdeqsim/TestMessageQueue.java | 6 +- .../mobsim/jdeqsim/util/TestEventLibrary.java | 6 +- .../mobsim/qsim/FlowStorageSpillbackTest.java | 6 +- .../qsim/QSimEventsIntegrationTest.java | 12 +- ...TeleportationEngineWDistanceCheckTest.java | 4 +- .../core/mobsim/qsim/VehicleSourceTest.java | 4 +- .../qsim/jdeqsimengine/JDEQSimPluginTest.java | 6 +- .../core/mobsim/qsim/pt/UmlaufDriverTest.java | 6 +- .../LinkSpeedCalculatorIntegrationTest.java | 4 +- .../qsim/qnetsimengine/PassingTest.java | 4 +- .../qsim/qnetsimengine/QLinkLanesTest.java | 6 +- .../mobsim/qsim/qnetsimengine/QLinkTest.java | 6 +- .../qnetsimengine/QSimComponentsTest.java | 4 +- .../SimulatedLaneFlowCapacityTest.java | 6 +- .../qnetsimengine/SpeedCalculatorTest.java | 4 +- .../qnetsimengine/VehicleHandlerTest.java | 6 +- .../AbstractNetworkWriterReaderTest.java | 6 +- .../core/network/DisallowedNextLinksTest.java | 10 +- .../NetworkChangeEventsParserWriterTest.java | 8 +- .../matsim/core/network/NetworkUtilsTest.java | 34 +- .../matsim/core/network/NetworkV2IOTest.java | 6 +- .../core/network/TimeVariantLinkImplTest.java | 6 +- .../TravelTimeCalculatorIntegrationTest.java | 6 +- .../IntersectionSimplifierTest.java | 20 +- .../containers/ConcaveHullTest.java | 24 +- .../io/NetworkAttributeConversionTest.java | 4 +- .../network/io/NetworkReaderMatsimV1Test.java | 6 +- .../network/io/NetworkReprojectionIOTest.java | 4 +- .../core/population/PersonImplTest.java | 6 +- .../io/PopulationAttributeConversionTest.java | 4 +- .../io/PopulationReprojectionIOIT.java | 4 +- .../population/io/PopulationV6IOTest.java | 4 +- .../io/PopulationWriterHandlerImplV4Test.java | 6 +- .../io/PopulationWriterHandlerImplV5Test.java | 4 +- ...mingPopulationAttributeConversionTest.java | 4 +- .../population/routes/NetworkFactoryTest.java | 6 +- .../routes/RouteFactoryIntegrationTest.java | 4 +- .../core/replanning/PlanStrategyTest.java | 6 +- .../annealing/ReplanningAnnealerTest.java | 6 +- .../ReplanningWithConflictsTest.java | 16 +- .../modules/ExternalModuleTest.java | 6 +- .../planInheritance/PlanInheritanceTest.java | 23 +- .../selectors/AbstractPlanSelectorTest.java | 4 +- ...eterministicMultithreadedReplanningIT.java | 6 +- .../strategies/InnovationSwitchOffTest.java | 6 +- .../TimeAllocationMutatorModuleTest.java | 6 +- .../AbstractLeastCostPathCalculatorTest.java | 6 +- .../router/FallbackRoutingModuleTest.java | 4 +- ...workRoutingInclAccessEgressModuleTest.java | 6 +- .../PseudoTransitRoutingModuleTest.java | 6 +- .../org/matsim/core/router/RoutingIT.java | 4 +- .../core/router/TripRouterModuleTest.java | 6 +- .../core/router/old/PlanRouterTest.java | 6 +- .../ScenarioByConfigInjectionTest.java | 4 +- .../core/scenario/ScenarioLoaderImplTest.java | 4 +- .../core/scoring/EventsToScoreTest.java | 6 +- ...yparNagelOpenTimesScoringFunctionTest.java | 6 +- .../LinkToLinkTravelTimeCalculatorTest.java | 6 +- .../TravelTimeCalculatorModuleTest.java | 6 +- .../TravelTimeCalculatorTest.java | 6 +- .../TravelTimeDataArrayTest.java | 4 +- .../core/utils/charts/BarChartTest.java | 6 +- .../core/utils/charts/LineChartTest.java | 6 +- .../core/utils/charts/XYLineChartTest.java | 6 +- .../core/utils/charts/XYScatterChartTest.java | 6 +- .../utils/geometry/GeometryUtilsTest.java | 10 +- .../core/utils/geometry/geotools/MGCTest.java | 6 +- .../GeotoolsTransformationTest.java | 6 +- .../core/utils/gis/ShapeFileReaderTest.java | 6 +- .../core/utils/gis/ShapeFileWriterTest.java | 84 +- .../org/matsim/core/utils/io/IOUtilsTest.java | 4 +- .../core/utils/io/MatsimXmlParserTest.java | 11 +- .../core/utils/io/OsmNetworkReaderTest.java | 22 +- .../core/utils/misc/ArgumentParserTest.java | 6 +- .../core/utils/misc/ByteBufferUtilsTest.java | 6 +- .../core/utils/misc/ConfigUtilsTest.java | 6 +- .../core/utils/misc/PopulationUtilsTest.java | 36 +- .../core/utils/misc/StringUtilsTest.java | 6 +- .../utils/timing/TimeInterpretationTest.java | 6 +- .../java/org/matsim/counts/CountTest.java | 6 +- .../counts/CountsComparisonAlgorithmTest.java | 6 +- .../counts/CountsControlerListenerTest.java | 4 +- .../matsim/counts/CountsErrorGraphTest.java | 6 +- .../counts/CountsHtmlAndGraphsWriterTest.java | 6 +- .../counts/CountsLoadCurveGraphTest.java | 6 +- .../org/matsim/counts/CountsParserTest.java | 6 +- .../matsim/counts/CountsParserWriterTest.java | 4 +- .../counts/CountsReaderHandlerImplV1Test.java | 6 +- .../counts/CountsReprojectionIOTest.java | 4 +- .../counts/CountsSimRealPerHourGraphTest.java | 6 +- .../matsim/counts/CountsTableWriterTest.java | 6 +- .../java/org/matsim/counts/CountsTest.java | 6 +- .../java/org/matsim/counts/CountsV2Test.java | 6 +- .../org/matsim/counts/OutputDelegateTest.java | 6 +- .../java/org/matsim/examples/EquilTest.java | 4 +- .../examples/OnePercentBerlin10sIT.java | 6 +- .../org/matsim/examples/PtTutorialIT.java | 5 +- .../matsim/examples/simple/PtScoringTest.java | 4 +- .../ActivityFacilitiesSourceTest.java | 4 +- .../FacilitiesAttributeConvertionTest.java | 4 +- .../FacilitiesParserWriterTest.java | 4 +- .../FacilitiesReprojectionIOTest.java | 4 +- .../AbstractFacilityAlgorithmTest.java | 6 +- .../HouseholdAttributeConversionTest.java | 4 +- .../matsim/households/HouseholdImplTest.java | 6 +- .../matsim/households/HouseholdsIoTest.java | 6 +- .../integration/EquilTwoAgentsTest.java | 6 +- .../integration/SimulateAndScoreTest.java | 6 +- .../PersonMoneyEventIntegrationTest.java | 6 +- .../InvertedNetworkRoutingIT.java | 6 +- .../integration/invertednetworks/LanesIT.java | 6 +- .../NonAlternatingPlanElementsIT.java | 4 +- .../pt/TransitIntegrationTest.java | 4 +- .../ChangeTripModeIntegrationTest.java | 6 +- .../integration/replanning/ReRoutingIT.java | 6 +- .../replanning/ResumableRunsIT.java | 6 +- .../QSimIntegrationTest.java | 6 +- .../lanes/data/LanesReaderWriterTest.java | 6 +- .../matsim/modules/ScoreStatsModuleTest.java | 6 +- .../matsim/other/DownloadAndReadXmlTest.java | 34 +- .../ChooseRandomLegModeForSubtourTest.java | 40 +- .../algorithms/ChooseRandomLegModeTest.java | 6 +- .../analysis/TransitLoadIntegrationTest.java | 4 +- .../pt/router/TransitRouterModuleTest.java | 4 +- .../pt/transitSchedule/DepartureTest.java | 6 +- .../pt/transitSchedule/TransitLineTest.java | 6 +- .../transitSchedule/TransitRouteStopTest.java | 6 +- .../pt/transitSchedule/TransitRouteTest.java | 6 +- .../TransitScheduleFormatV1Test.java | 6 +- .../TransitScheduleReaderTest.java | 6 +- .../TransitScheduleReprojectionIOTest.java | 4 +- .../TransitScheduleWriterTest.java | 14 +- .../TransitStopFacilityTest.java | 6 +- .../org/matsim/run/CreateFullConfigTest.java | 4 +- .../java/org/matsim/run/InitRoutesTest.java | 6 +- .../java/org/matsim/run/XY2LinksTest.java | 6 +- .../matsim/testcases/MatsimJunit5Test.java | 344 -------- .../testcases/MatsimJunit5TestExtension.java | 344 -------- .../org/matsim/testcases/MatsimTestUtils.java | 104 ++- .../EventsFileComparatorTest.java | 6 +- .../network/Network2ESRIShapeTest.java | 6 +- .../plans/SelectedPlans2ESRIShapeTest.java | 6 +- .../ObjectAttributesXmlIOTest.java | 11 +- .../ObjectAttributesXmlReaderTest.java | 4 +- .../vehicles/MatsimVehicleWriterTest.java | 6 +- .../matsim/vehicles/VehicleReaderV1Test.java | 6 +- .../matsim/vehicles/VehicleReaderV2Test.java | 6 +- .../matsim/vehicles/VehicleWriteReadTest.java | 4 +- .../matsim/vehicles/VehicleWriterV1Test.java | 6 +- .../matsim/vehicles/VehicleWriterV2Test.java | 6 +- .../vis/snapshotwriters/PositionInfoTest.java | 6 +- .../ExampleWithinDayControllerTest.java | 6 +- .../ExperiencedPlansWriterTest.java | 6 +- .../tools/ActivityReplanningMapTest.java | 6 +- .../tools/LinkReplanningMapTest.java | 6 +- .../trafficmonitoring/TtmobsimListener.java | 28 +- .../WithinDayTravelTimeTest.java | 6 +- ...TravelTimeWithNetworkChangeEventsTest.java | 6 +- .../withinday/utils/EditRoutesTest.java | 6 +- .../utils/ReplacePlanElementsTest.java | 6 +- 492 files changed, 2750 insertions(+), 3434 deletions(-) rename contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/{ForkJoinPoolTestRule.java => ForkJoinPoolExtension.java} (78%) delete mode 100644 matsim/src/test/java/org/matsim/testcases/MatsimJunit5Test.java delete mode 100644 matsim/src/test/java/org/matsim/testcases/MatsimJunit5TestExtension.java diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/grid/SpatialGridTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/grid/SpatialGridTest.java index b9f82d4cfa1..3b1ea9c2c9b 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/grid/SpatialGridTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/grid/SpatialGridTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.accessibility.grid; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.network.Network; import org.matsim.contrib.accessibility.SpatialGrid; @@ -11,8 +11,8 @@ public class SpatialGridTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private double cellSize = 10.; diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulas2Test.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulas2Test.java index b561798a16d..046d187a965 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulas2Test.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulas2Test.java @@ -23,7 +23,7 @@ package org.matsim.contrib.accessibility.logsumComputations; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -33,8 +33,8 @@ */ public class CompareLogsumFormulas2Test { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulasTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulasTest.java index 8c85aabbe9f..3c25e7c59d0 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulasTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulasTest.java @@ -23,7 +23,7 @@ package org.matsim.contrib.accessibility.logsumComputations; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -33,8 +33,8 @@ */ public class CompareLogsumFormulasTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** * underlying network diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/ComputeLogsumFormulas3Test.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/ComputeLogsumFormulas3Test.java index 81eb7bc3254..0b358229465 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/ComputeLogsumFormulas3Test.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/ComputeLogsumFormulas3Test.java @@ -23,7 +23,7 @@ package org.matsim.contrib.accessibility.logsumComputations; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -33,8 +33,8 @@ */ public class ComputeLogsumFormulas3Test { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** * underlying network diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java index b843e1ae3b5..c4835291ee3 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java @@ -29,7 +29,7 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Ignore; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.locationtech.jts.geom.Envelope; import org.matsim.api.core.v01.Coord; @@ -74,7 +74,7 @@ public class AccessibilityIntegrationTest { private static final Logger LOG = LogManager.getLogger(AccessibilityIntegrationTest.class); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Ignore @Test diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/NetworkUtilTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/NetworkUtilTest.java index 405bc54c3e9..aa9360e8013 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/NetworkUtilTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/NetworkUtilTest.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -39,11 +39,11 @@ * @author dziemke */ public class NetworkUtilTest { - + private static final Logger log = LogManager.getLogger(NetworkUtilTest.class); - - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + @Test public void testNetworkUtil() { @@ -62,10 +62,10 @@ public void testNetworkUtil() { * * The network contains an exactly horizontal, an exactly vertical, an exactly diagonal * and another link with no special slope to also test possible special cases. - * + * * why is that a "special case"? in a normal network all sort of slopes are *normally* present. dz, feb'16 */ - + Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord((double) 0, (double) 0)); Node node2 = NetworkUtils.createAndAddNode(network, Id.create("2", Node.class), new Coord((double) 0, (double) 1000)); @@ -76,7 +76,7 @@ public void testNetworkUtil() { Link link2 = NetworkUtils.createAndAddLink(network, Id.create("2", Link.class), node2, node3, 1500, 1, 3600, 1); Link link3 = NetworkUtils.createAndAddLink(network, Id.create("3", Link.class), node3, node4, 1000, 1, 3600, 1); Link link4 = NetworkUtils.createAndAddLink(network, Id.create("4", Link.class), node4, node5, 2800, 1, 3600, 1); - + Coord a = new Coord(100., 0.); Coord b = new Coord(100., 100.); Coord c = new Coord(100., 1000.); @@ -86,89 +86,89 @@ public void testNetworkUtil() { Coord g = new Coord(2300., 2000.); Coord h = new Coord(1700., 1000.); Coord i = new Coord(0., 1200.); - - + + Distances distanceA11 = NetworkUtil.getDistances2NodeViaGivenLink(a, link1, node1); Assert.assertEquals("distanceA11.getDistancePoint2Road()", 100., distanceA11.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); Assert.assertEquals("distanceA11.getDistanceRoad2Node()", 0., distanceA11.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); - + Coord projectionA11 = CoordUtils.orthogonalProjectionOnLineSegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), a); Assert.assertEquals("projectionA11.getX()", 0., projectionA11.getX(), MatsimTestUtils.EPSILON); Assert.assertEquals("projectionA11.getY()", 0., projectionA11.getY(), MatsimTestUtils.EPSILON); - - + + Distances distanceB11 = NetworkUtil.getDistances2NodeViaGivenLink(b, link1, node1); Assert.assertEquals("distanceB11.getDistancePoint2Road()", 100., distanceB11.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); Assert.assertEquals("distanceB11.getDistanceRoad2Node()", 100., distanceB11.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); - + Coord projectionB11 = CoordUtils.orthogonalProjectionOnLineSegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), b); Assert.assertEquals("projectionB11.getX()", 0., projectionB11.getX(), MatsimTestUtils.EPSILON); Assert.assertEquals("projectionB11.getY()", 100., projectionB11.getY(), MatsimTestUtils.EPSILON); - - + + Distances distanceB12 = NetworkUtil.getDistances2NodeViaGivenLink(b, link1, node2); Assert.assertEquals("distanceB12.getDistancePoint2Road()", 100., distanceB12.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); Assert.assertEquals("distanceB12.getDistanceRoad2Node()", 900., distanceB12.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); - + Coord projectionB12 = CoordUtils.orthogonalProjectionOnLineSegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), b); Assert.assertEquals("projectionB12.getX()", 0., projectionB12.getX(), MatsimTestUtils.EPSILON); Assert.assertEquals("projectionB12.getY()", 100., projectionB12.getY(), MatsimTestUtils.EPSILON); - - + + Distances distanceC11 = NetworkUtil.getDistances2NodeViaGivenLink(c, link1, node1); Assert.assertEquals("distanceC11.getDistancePoint2Road()", 100., distanceC11.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); Assert.assertEquals("distanceC11.getDistanceRoad2Node()", 1000., distanceC11.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); - + Coord projectionC11 = CoordUtils.orthogonalProjectionOnLineSegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), c); Assert.assertEquals("projectionC11.getX()", 0., projectionC11.getX(), MatsimTestUtils.EPSILON); Assert.assertEquals("projectionC11.getY()", 1000., projectionC11.getY(), MatsimTestUtils.EPSILON); - - + + Distances distanceC12 = NetworkUtil.getDistances2NodeViaGivenLink(c, link1, node2); Assert.assertEquals("distanceC12.getDistancePoint2Road()", 100., distanceC12.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); Assert.assertEquals("distanceC12.getDistanceRoad2Node()", 0., distanceC12.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); - + Coord projectionC12 = CoordUtils.orthogonalProjectionOnLineSegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), c); Assert.assertEquals("projectionC12.getX()", 0., projectionC12.getX(), MatsimTestUtils.EPSILON); Assert.assertEquals("projectionC12.getY()", 1000., projectionC12.getY(), MatsimTestUtils.EPSILON); - - + + Distances distanceC22 = NetworkUtil.getDistances2NodeViaGivenLink(c, link2, node2); Assert.assertEquals("distanceC22.getDistancePoint2Road()", Math.sqrt(2.) / 2. * 100., distanceC22.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); Assert.assertEquals("distanceC22.getDistanceRoad2Node()", Math.sqrt(2.) / 2. * 100., distanceC22.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); - + Coord projectionC22 = CoordUtils.orthogonalProjectionOnLineSegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), c); Assert.assertEquals("projectionC22.getX()", 50., projectionC22.getX(), MatsimTestUtils.EPSILON); Assert.assertEquals("projectionC22.getY()", 1050., projectionC22.getY(), MatsimTestUtils.EPSILON); - - + + Distances distanceC23 = NetworkUtil.getDistances2NodeViaGivenLink(c, link2, node3); Assert.assertEquals("distanceC23.getDistancePoint2Road()", Math.sqrt(2.) / 2. * 100., distanceC23.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); Assert.assertEquals("distanceC23.getDistanceRoad2Node()", Math.sqrt(2) * 1000. - Math.sqrt(2.) / 2. * 100., distanceC23.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); - + Coord projectionC23 = CoordUtils.orthogonalProjectionOnLineSegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), c); Assert.assertEquals("projectionC23.getX()", 50., projectionC23.getX(), MatsimTestUtils.EPSILON); Assert.assertEquals("projectionC23.getY()", 1050., projectionC23.getY(), MatsimTestUtils.EPSILON); - - + + Distances distanceD22 = NetworkUtil.getDistances2NodeViaGivenLink(d, link2, node2); Assert.assertEquals("distanceD22.getDistancePoint2Road()", Math.sqrt(2.) / 2. * 100.0, distanceD22.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); Assert.assertEquals("distanceD22.getDistanceRoad2Node()", Math.sqrt(2.) / 2. * 100.0 + Math.sqrt(2) * 200., distanceD22.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); - + Coord projectionD22 = CoordUtils.orthogonalProjectionOnLineSegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), d); Assert.assertEquals("projectionD22.getX()", 250., projectionD22.getX(), MatsimTestUtils.EPSILON); Assert.assertEquals("projectionD22.getY()", 1250., projectionD22.getY(), MatsimTestUtils.EPSILON); - - + + Distances distanceD23 = NetworkUtil.getDistances2NodeViaGivenLink(d, link2, node3); Assert.assertEquals("distanceD23.getDistancePoint2Road()", Math.sqrt(2.)/2.*100.0, distanceD23.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); Assert.assertEquals("distanceD23.getDistanceRoad2Node()", Math.sqrt(2.)/2.*100.0 + Math.sqrt(2) * 700., distanceD23.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); - + Coord projectionD23 = CoordUtils.orthogonalProjectionOnLineSegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), d); Assert.assertEquals("projectionD23.getX()", 250., projectionD23.getX(), MatsimTestUtils.EPSILON); Assert.assertEquals("projectionD23.getY()", 1250., projectionD23.getY(), MatsimTestUtils.EPSILON); - - + + Distances distanceE33 = NetworkUtil.getDistances2NodeViaGivenLink(e, link3, node3); Assert.assertEquals("distanceE33.getDistancePoint2Road()", 100.0, distanceE33.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); Assert.assertEquals("distanceE33.getDistanceRoad2Node()", 300.0, distanceE33.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); @@ -176,8 +176,8 @@ public void testNetworkUtil() { Coord projectionE33 = CoordUtils.orthogonalProjectionOnLineSegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), e); Assert.assertEquals("projectionE33.getX()", 1300., projectionE33.getX(), MatsimTestUtils.EPSILON); Assert.assertEquals("projectionE33.getY()", 2000., projectionE33.getY(), MatsimTestUtils.EPSILON); - - + + Distances distanceE34 = NetworkUtil.getDistances2NodeViaGivenLink(e, link3, node4); Assert.assertEquals("distanceE34.getDistancePoint2Road()", 100.0, distanceE34.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); Assert.assertEquals("distanceE34.getDistanceRoad2Node()", 700.0, distanceE34.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); @@ -185,23 +185,23 @@ public void testNetworkUtil() { Coord projectionE34 = CoordUtils.orthogonalProjectionOnLineSegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), e); Assert.assertEquals("projectionE34.getX()", 1300., projectionE34.getX(), MatsimTestUtils.EPSILON); Assert.assertEquals("projectionE34.getY()", 2000., projectionE34.getY(), MatsimTestUtils.EPSILON); - - + + Distances distanceF33 = NetworkUtil.getDistances2NodeViaGivenLink(f, link3, node3); Assert.assertEquals("distanceF33.getDistancePoint2Road()", Math.sqrt(Math.pow(100, 2) + Math.pow(300, 2)), distanceF33.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); Assert.assertEquals("distanceF33.getDistanceRoad2Node()", 1000., distanceF33.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); - + Coord projectionF33 = CoordUtils.orthogonalProjectionOnLineSegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), e); Assert.assertEquals("projectionF33.getX()", 1300., projectionF33.getX(), MatsimTestUtils.EPSILON); Assert.assertEquals("projectionF33.getY()", 2000., projectionF33.getY(), MatsimTestUtils.EPSILON); - - + + Distances distanceF34 = NetworkUtil.getDistances2NodeViaGivenLink(f, link3, node4); Assert.assertEquals("distanceF34.getDistancePoint2Road()", Math.sqrt(Math.pow(100, 2) + Math.pow(300, 2)), distanceF34.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); Assert.assertEquals("distanceF34.getDistanceRoad2Node()", 0., distanceF34.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); - + Coord projectionF34 = CoordUtils.orthogonalProjectionOnLineSegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), f); Assert.assertEquals("projectionF34.getX()", 2000., projectionF34.getX(), MatsimTestUtils.EPSILON); Assert.assertEquals("projectionF34.getY()", 2000., projectionF34.getY(), MatsimTestUtils.EPSILON); } -} \ No newline at end of file +} diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyAccessibilityTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyAccessibilityTest.java index 29283b26ede..a0a2f6548f7 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyAccessibilityTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyAccessibilityTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -57,7 +57,7 @@ public class TinyAccessibilityTest { private static final Logger LOG = LogManager.getLogger(TinyAccessibilityTest.class); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void runFromEvents() { diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java index bde5a98c612..51081fd61b1 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Ignore; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -65,7 +65,7 @@ public class TinyMultimodalAccessibilityTest { private static final Logger LOG = LogManager.getLogger(TinyMultimodalAccessibilityTest.class); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test @Ignore // non-deterministic presumably because of multi-threading. kai, sep'19 diff --git a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTest.java b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTest.java index b98c144164f..bd0daad8082 100644 --- a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTest.java +++ b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTest.java @@ -4,7 +4,7 @@ import java.io.IOException; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -24,7 +24,7 @@ */ public class RunTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void test1() { diff --git a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTestEquil.java b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTestEquil.java index d537b8c40e4..de2a0923944 100644 --- a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTestEquil.java +++ b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTestEquil.java @@ -3,7 +3,7 @@ import java.io.BufferedReader; import java.io.IOException; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -19,7 +19,7 @@ public class RunTestEquil { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void test1() { diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/PersonIntersectAreaFilterTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/PersonIntersectAreaFilterTest.java index 2c856118e92..848a370fb01 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/PersonIntersectAreaFilterTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/PersonIntersectAreaFilterTest.java @@ -25,7 +25,7 @@ import java.util.HashMap; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -51,8 +51,8 @@ */ public class PersonIntersectAreaFilterTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testFilter() throws Exception { diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/RouteLinkFilterTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/RouteLinkFilterTest.java index 01f4b00a334..206f1a7c2a9 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/RouteLinkFilterTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/RouteLinkFilterTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -50,8 +50,8 @@ public class RouteLinkFilterTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testRouteLinkFilter() { diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java index 8d6e64b29f9..ee36629cfc1 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java @@ -26,7 +26,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -55,10 +55,10 @@ public class KNAnalysisEventsHandlerTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); - // yy this test is probably not doing anything with respect to some of the newer statistics, such as money. kai, mar'14 + // yy this test is probably not doing anything with respect to some of the newer statistics, such as money. kai, mar'14 public static final String BASE_FILE_NAME = "stats_"; public final Id DEFAULT_PERSON_ID = Id.create(123, Person.class); @@ -124,7 +124,7 @@ public void testNoEvents() { @Test @Ignore public void testAveraging() { - // yy this test is probably not doing anything with respect to some of the newer statistics, such as money. kai, mar'14 + // yy this test is probably not doing anything with respect to some of the newer statistics, such as money. kai, mar'14 KNAnalysisEventsHandler testee = new KNAnalysisEventsHandler(this.scenario); diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java index 694b5039e8e..0b8723a704b 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.analysis.vsp.traveltimedistance; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.utils.collections.Tuple; import org.matsim.testcases.MatsimTestUtils; @@ -12,8 +12,8 @@ import static org.junit.Assert.assertTrue; public class GoogleMapRouteValidatorTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testReadJson() throws IOException { diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java index cdf03802384..e08bf8c5b00 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.analysis.vsp.traveltimedistance; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.utils.collections.Tuple; import org.matsim.testcases.MatsimTestUtils; @@ -11,8 +11,8 @@ import static org.junit.Assert.*; public class HereMapsRouteValidatorTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testReadJson() throws IOException { diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/travelsummary/events2traveldiaries/RunEventsToTravelDiariesIT.java b/contribs/analysis/src/test/java/org/matsim/contrib/travelsummary/events2traveldiaries/RunEventsToTravelDiariesIT.java index 2fd76b243bd..58ee087e1fe 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/travelsummary/events2traveldiaries/RunEventsToTravelDiariesIT.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/travelsummary/events2traveldiaries/RunEventsToTravelDiariesIT.java @@ -18,7 +18,7 @@ * *********************************************************************** */ package org.matsim.contrib.travelsummary.events2traveldiaries; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -26,8 +26,8 @@ * @author nagel */ public class RunEventsToTravelDiariesIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); @SuppressWarnings("static-method") @Test diff --git a/contribs/application/src/test/java/org/matsim/application/CommandRunnerTest.java b/contribs/application/src/test/java/org/matsim/application/CommandRunnerTest.java index 67f566eb5ae..3f3cff914d1 100644 --- a/contribs/application/src/test/java/org/matsim/application/CommandRunnerTest.java +++ b/contribs/application/src/test/java/org/matsim/application/CommandRunnerTest.java @@ -1,7 +1,7 @@ package org.matsim.application; import org.assertj.core.api.Assertions; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.application.analysis.TestDependentAnalysis; import org.matsim.application.analysis.TestOtherAnalysis; @@ -12,8 +12,8 @@ public class CommandRunnerTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void runner() { diff --git a/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java b/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java index 9be98d76122..4decf8ec93b 100644 --- a/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java +++ b/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java @@ -2,7 +2,7 @@ import org.junit.Assume; import org.junit.Ignore; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.application.options.SampleOptions; import org.matsim.application.prepare.freight.tripExtraction.ExtractRelevantFreightTrips; @@ -28,8 +28,8 @@ public class MATSimApplicationTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void help() { diff --git a/contribs/application/src/test/java/org/matsim/application/analysis/LogFileAnalysisTest.java b/contribs/application/src/test/java/org/matsim/application/analysis/LogFileAnalysisTest.java index 4b1c121aa72..043845b921f 100644 --- a/contribs/application/src/test/java/org/matsim/application/analysis/LogFileAnalysisTest.java +++ b/contribs/application/src/test/java/org/matsim/application/analysis/LogFileAnalysisTest.java @@ -1,7 +1,7 @@ package org.matsim.application.analysis; import org.assertj.core.api.Assertions; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.application.ApplicationUtils; import org.matsim.application.MATSimApplication; @@ -16,8 +16,8 @@ public class LogFileAnalysisTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void output() throws IOException { diff --git a/contribs/application/src/test/java/org/matsim/application/options/CsvOptionsTest.java b/contribs/application/src/test/java/org/matsim/application/options/CsvOptionsTest.java index fff884efa77..8fd5097116a 100644 --- a/contribs/application/src/test/java/org/matsim/application/options/CsvOptionsTest.java +++ b/contribs/application/src/test/java/org/matsim/application/options/CsvOptionsTest.java @@ -2,8 +2,9 @@ import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVPrinter; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; +import org.junit.jupiter.api.io.TempDir; import org.junit.rules.TemporaryFolder; import java.io.IOException; @@ -14,15 +15,15 @@ public class CsvOptionsTest { - @Rule - public TemporaryFolder f = new TemporaryFolder(); + @TempDir + public Path f; @Test public void output() throws IOException { CsvOptions csv = new CsvOptions(CSVFormat.Predefined.TDF); - Path tmp = f.getRoot().toPath().resolve("test.csv"); + Path tmp = f.resolve("test.csv"); CSVPrinter printer = csv.createPrinter(tmp); @@ -34,4 +35,4 @@ public void output() throws IOException { .hasContent("header\tcolumn\n1\t2"); } -} \ No newline at end of file +} diff --git a/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java b/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java index 8874cfaf671..48c70be2e1b 100644 --- a/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java +++ b/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java @@ -2,7 +2,7 @@ import org.junit.Assert; import org.junit.Assume; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -19,8 +19,8 @@ public class ShpOptionsTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void readZip() { @@ -88,4 +88,4 @@ public void testGetGeometry() { Assert.assertTrue(geometry.equals(expectedGeometry)); } -} \ No newline at end of file +} diff --git a/contribs/application/src/test/java/org/matsim/application/prepare/CreateLandUseShpTest.java b/contribs/application/src/test/java/org/matsim/application/prepare/CreateLandUseShpTest.java index 7068b755e78..7830166223f 100644 --- a/contribs/application/src/test/java/org/matsim/application/prepare/CreateLandUseShpTest.java +++ b/contribs/application/src/test/java/org/matsim/application/prepare/CreateLandUseShpTest.java @@ -1,7 +1,7 @@ package org.matsim.application.prepare; import org.junit.Assume; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -12,8 +12,8 @@ public class CreateLandUseShpTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void convert() { @@ -34,4 +34,4 @@ public void convert() { .isRegularFile(); } -} \ No newline at end of file +} diff --git a/contribs/application/src/test/java/org/matsim/application/prepare/ShapeFileTextLookupTest.java b/contribs/application/src/test/java/org/matsim/application/prepare/ShapeFileTextLookupTest.java index 02f1892fc47..0fb5fe666c5 100644 --- a/contribs/application/src/test/java/org/matsim/application/prepare/ShapeFileTextLookupTest.java +++ b/contribs/application/src/test/java/org/matsim/application/prepare/ShapeFileTextLookupTest.java @@ -1,7 +1,7 @@ package org.matsim.application.prepare; import org.junit.Assume; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; import picocli.CommandLine; @@ -14,8 +14,8 @@ public class ShapeFileTextLookupTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); @Test public void main() { @@ -40,4 +40,4 @@ public void main() { .exists(); } -} \ No newline at end of file +} diff --git a/contribs/application/src/test/java/org/matsim/application/prepare/counts/CreateCountsFromBAStDataTest.java b/contribs/application/src/test/java/org/matsim/application/prepare/counts/CreateCountsFromBAStDataTest.java index 2bb18be2668..6706676043b 100644 --- a/contribs/application/src/test/java/org/matsim/application/prepare/counts/CreateCountsFromBAStDataTest.java +++ b/contribs/application/src/test/java/org/matsim/application/prepare/counts/CreateCountsFromBAStDataTest.java @@ -1,7 +1,7 @@ package org.matsim.application.prepare.counts; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -17,8 +17,8 @@ public class CreateCountsFromBAStDataTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); String countsOutput = "test-counts.xml.gz"; diff --git a/contribs/application/src/test/java/org/matsim/application/prepare/population/CloseTrajectoriesTest.java b/contribs/application/src/test/java/org/matsim/application/prepare/population/CloseTrajectoriesTest.java index d8fb62a6e30..b3db595cfb0 100644 --- a/contribs/application/src/test/java/org/matsim/application/prepare/population/CloseTrajectoriesTest.java +++ b/contribs/application/src/test/java/org/matsim/application/prepare/population/CloseTrajectoriesTest.java @@ -1,7 +1,7 @@ package org.matsim.application.prepare.population; import org.assertj.core.api.Condition; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Person; @@ -17,8 +17,8 @@ public class CloseTrajectoriesTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void main() { @@ -45,4 +45,4 @@ public void main() { } -} \ No newline at end of file +} diff --git a/contribs/application/src/test/java/org/matsim/application/prepare/population/SplitActivityTypesDurationTest.java b/contribs/application/src/test/java/org/matsim/application/prepare/population/SplitActivityTypesDurationTest.java index c88c1f977eb..0e3e98374a1 100644 --- a/contribs/application/src/test/java/org/matsim/application/prepare/population/SplitActivityTypesDurationTest.java +++ b/contribs/application/src/test/java/org/matsim/application/prepare/population/SplitActivityTypesDurationTest.java @@ -1,7 +1,7 @@ package org.matsim.application.prepare.population; import org.assertj.core.api.Assertions; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Person; @@ -17,8 +17,8 @@ public class SplitActivityTypesDurationTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void split() { diff --git a/contribs/application/src/test/java/org/matsim/application/prepare/pt/CreateTransitScheduleFromGtfsTest.java b/contribs/application/src/test/java/org/matsim/application/prepare/pt/CreateTransitScheduleFromGtfsTest.java index 9d0b2553537..89ce36a5691 100644 --- a/contribs/application/src/test/java/org/matsim/application/prepare/pt/CreateTransitScheduleFromGtfsTest.java +++ b/contribs/application/src/test/java/org/matsim/application/prepare/pt/CreateTransitScheduleFromGtfsTest.java @@ -1,7 +1,7 @@ package org.matsim.application.prepare.pt; import org.assertj.core.api.Assertions; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; @@ -12,8 +12,8 @@ public class CreateTransitScheduleFromGtfsTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void run() { diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/CarrierReaderFromCSVTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/CarrierReaderFromCSVTest.java index 9d2ec63b41c..b067e5e2a43 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/CarrierReaderFromCSVTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/CarrierReaderFromCSVTest.java @@ -10,7 +10,7 @@ import java.util.Set; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -39,8 +39,8 @@ */ public class CarrierReaderFromCSVTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void carrierCreation() throws IOException { diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java index d9ff39a695c..a8b19900587 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java @@ -9,7 +9,7 @@ import java.util.Set; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -37,8 +37,8 @@ * */ public class DemandReaderFromCSVTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testLinkForPerson() throws IOException { diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationTest.java index 82ee3fc674a..5d42bcd5ab3 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationTest.java @@ -2,7 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -15,8 +15,8 @@ */ public class FreightDemandGenerationTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testMain() { diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtilsTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtilsTest.java index c8dbaeff5df..ea14e21ad6b 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtilsTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtilsTest.java @@ -4,7 +4,7 @@ import java.util.Collection; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.locationtech.jts.geom.Point; import org.matsim.api.core.v01.Coord; @@ -26,9 +26,9 @@ */ public class FreightDemandGenerationUtilsTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); - + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); + @Test public void testPreparePopulation() { String populationLocation = utils.getPackageInputDirectory() + "testPopulation.xml"; diff --git a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/LanduseBuildingAnalysisTest.java b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/LanduseBuildingAnalysisTest.java index 9ba27596185..5ad5e0de362 100644 --- a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/LanduseBuildingAnalysisTest.java +++ b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/LanduseBuildingAnalysisTest.java @@ -21,7 +21,7 @@ import it.unimi.dsi.fastutil.objects.Object2DoubleMap; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.application.options.ShpOptions; import org.matsim.application.options.ShpOptions.Index; @@ -42,8 +42,8 @@ */ public class LanduseBuildingAnalysisTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testReadOfDataDistributionPerZoneAndBuildingAnalysis() throws IOException { diff --git a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/RunGenerateSmallScaleCommercialTrafficTest.java b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/RunGenerateSmallScaleCommercialTrafficTest.java index d0f4620ac71..a916ccae961 100644 --- a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/RunGenerateSmallScaleCommercialTrafficTest.java +++ b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/RunGenerateSmallScaleCommercialTrafficTest.java @@ -20,7 +20,7 @@ package org.matsim.smallScaleCommercialTrafficGeneration; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -43,8 +43,8 @@ */ public class RunGenerateSmallScaleCommercialTrafficTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testMainRunAndResults() { diff --git a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/SmallScaleCommercialTrafficUtilsTest.java b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/SmallScaleCommercialTrafficUtilsTest.java index 84c5e0bd188..fab0c22abc4 100644 --- a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/SmallScaleCommercialTrafficUtilsTest.java +++ b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/SmallScaleCommercialTrafficUtilsTest.java @@ -20,7 +20,7 @@ package org.matsim.smallScaleCommercialTrafficGeneration; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -46,8 +46,8 @@ */ public class SmallScaleCommercialTrafficUtilsTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void findZoneOfLinksTest() throws IOException, URISyntaxException { diff --git a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TrafficVolumeGenerationTest.java b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TrafficVolumeGenerationTest.java index fe522f7462d..05d4e824089 100644 --- a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TrafficVolumeGenerationTest.java +++ b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TrafficVolumeGenerationTest.java @@ -21,7 +21,7 @@ import it.unimi.dsi.fastutil.objects.Object2DoubleMap; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -49,8 +49,8 @@ */ public class TrafficVolumeGenerationTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testTrafficVolumeGenerationCommercialPersonTraffic() throws IOException { diff --git a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrixTest.java b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrixTest.java index 4392957d1c9..9694505cbf2 100644 --- a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrixTest.java +++ b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrixTest.java @@ -21,7 +21,7 @@ import it.unimi.dsi.fastutil.objects.Object2DoubleMap; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -43,8 +43,8 @@ */ public class TripDistributionMatrixTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testTripDistributionCommercialPersonTrafficTraffic() throws IOException { diff --git a/contribs/av/src/test/java/org/matsim/contrib/av/flow/RunAvExampleIT.java b/contribs/av/src/test/java/org/matsim/contrib/av/flow/RunAvExampleIT.java index 442047d0674..ed3476fc8ea 100644 --- a/contribs/av/src/test/java/org/matsim/contrib/av/flow/RunAvExampleIT.java +++ b/contribs/av/src/test/java/org/matsim/contrib/av/flow/RunAvExampleIT.java @@ -26,7 +26,7 @@ import java.net.MalformedURLException; import java.net.URL; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -34,8 +34,8 @@ * @author jbischoff */ public class RunAvExampleIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testAvFlowExample() throws MalformedURLException { diff --git a/contribs/av/src/test/java/org/matsim/contrib/av/flow/TestAvFlowFactor.java b/contribs/av/src/test/java/org/matsim/contrib/av/flow/TestAvFlowFactor.java index 67837840838..916bd3c9e12 100644 --- a/contribs/av/src/test/java/org/matsim/contrib/av/flow/TestAvFlowFactor.java +++ b/contribs/av/src/test/java/org/matsim/contrib/av/flow/TestAvFlowFactor.java @@ -27,7 +27,7 @@ import java.net.URL; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -44,8 +44,8 @@ import org.matsim.vis.otfvis.OTFVisConfigGroup; public class TestAvFlowFactor { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testAvFlowFactor() throws MalformedURLException { diff --git a/contribs/av/src/test/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExampleIT.java b/contribs/av/src/test/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExampleIT.java index 7fe1d1624c6..d9573384ef0 100644 --- a/contribs/av/src/test/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExampleIT.java +++ b/contribs/av/src/test/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExampleIT.java @@ -30,7 +30,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -48,8 +48,8 @@ * @author jbischoff */ public class RunTaxiPTIntermodalExampleIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testIntermodalExample() throws MalformedURLException { diff --git a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleLinkSpeedCalculatorTest.java b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleLinkSpeedCalculatorTest.java index 1af7f1aec93..8ee7bcdc13d 100644 --- a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleLinkSpeedCalculatorTest.java +++ b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleLinkSpeedCalculatorTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.bicycle; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -34,7 +34,8 @@ import static org.junit.Assert.assertTrue; public class BicycleLinkSpeedCalculatorTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); private static final double MAX_BICYCLE_SPEED = 15; private final Config config = ConfigUtils.createConfig(); diff --git a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java index a5a798ee9de..e3a50e711df 100644 --- a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java +++ b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java @@ -21,8 +21,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; +import org.junit.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -51,7 +51,6 @@ import org.matsim.core.router.TripStructureUtils; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.collections.CollectionUtils; -import org.matsim.testcases.MatsimJunit5Test; import org.matsim.testcases.MatsimTestUtils; import org.matsim.utils.eventsfilecomparison.EventsFileComparator; import org.matsim.vehicles.Vehicle; @@ -64,19 +63,24 @@ import java.util.List; import java.util.Map; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.matsim.utils.eventsfilecomparison.EventsFileComparator.Result.FILES_ARE_EQUAL; /** * @author dziemke */ -public class BicycleTest extends MatsimJunit5Test { +public class BicycleTest { private static final Logger LOG = LogManager.getLogger(BicycleTest.class); private static final String bicycleMode = "bicycle"; + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); + @Test public void testNormal() { - Config config = ConfigUtils.createConfig(getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -84,32 +88,33 @@ public void testNormal() { config.network().setInputFile("network_normal.xml"); config.plans().setInputFile("population_1200.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); config.controller().setLastIteration(0); config.controller().setCreateGraphs(false); new RunBicycleExample().run(config ); LOG.info("Checking MATSim events file ..."); - final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; - final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; - Assertions.assertEquals(FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew), "Different event files."); + final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; + final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; + assertEquals("Different event files.", FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew)); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); - new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); for (Id personId : scenarioReference.getPopulation().getPersons().keySet()) { double scoreReference = scenarioReference.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); double scoreCurrent = scenarioCurrent.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); - Assertions.assertEquals(scoreReference, scoreCurrent, MatsimTestUtils.EPSILON, "Scores of persons " + personId + " are different"); + Assert.assertEquals("Scores of persons " + personId + " are different", scoreReference, scoreCurrent, MatsimTestUtils.EPSILON); } - Assertions.assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); + assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); } @Test public void testCobblestone() { - Config config = ConfigUtils.createConfig(getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -119,7 +124,7 @@ public void testCobblestone() { config.plans().setInputFile("population_1200.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); config.controller().setLastIteration(0); config.controller().setCreateGraphs(false); @@ -127,21 +132,22 @@ public void testCobblestone() { { Scenario scenarioReference = ScenarioUtils.createScenario( ConfigUtils.createConfig() ); Scenario scenarioCurrent = ScenarioUtils.createScenario( ConfigUtils.createConfig() ); - new PopulationReader( scenarioReference ).readFile( getInputDirectory() + "output_plans.xml.gz" ); - new PopulationReader( scenarioCurrent ).readFile( getOutputDirectory() + "output_plans.xml.gz" ); - Assertions.assertTrue(PopulationUtils.equalPopulation( scenarioReference.getPopulation(), scenarioCurrent.getPopulation() ), "Populations are different"); + new PopulationReader( scenarioReference ).readFile( utils.getInputDirectory() + "output_plans.xml.gz" ); + new PopulationReader( scenarioCurrent ).readFile( utils.getOutputDirectory() + "output_plans.xml.gz" ); + assertTrue( "Populations are different", PopulationUtils.equalPopulation( scenarioReference.getPopulation(), scenarioCurrent.getPopulation() ) ); } { LOG.info( "Checking MATSim events file ..." ); - final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; - final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; - Assertions.assertEquals(FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew ), "Different event files."); + final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; + final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; + assertEquals( "Different event files.", FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew )); } } @Test public void testPedestrian() { - Config config = ConfigUtils.createConfig(getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -149,27 +155,28 @@ public void testPedestrian() { config.network().setInputFile("network_pedestrian.xml"); config.plans().setInputFile("population_1200.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); config.controller().setLastIteration(0); config.controller().setCreateGraphs(false); new RunBicycleExample().run(config ); LOG.info("Checking MATSim events file ..."); - final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; - final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; - Assertions.assertEquals(FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew), "Different event files."); + final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; + final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; + assertEquals("Different event files.", FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew)); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); - new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); - Assertions.assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); + new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); + assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); } @Test public void testLane() { - Config config = ConfigUtils.createConfig(getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -177,27 +184,28 @@ public void testLane() { config.network().setInputFile("network_lane.xml"); config.plans().setInputFile("population_1200.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); config.controller().setLastIteration(0); config.controller().setCreateGraphs(false); new RunBicycleExample().run(config ); LOG.info("Checking MATSim events file ..."); - final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; - final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; - Assertions.assertEquals(FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew), "Different event files."); + final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; + final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; + assertEquals("Different event files.", FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew)); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); - new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); - Assertions.assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); + new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); + assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); } @Test public void testGradient() { - Config config = ConfigUtils.createConfig(getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -205,27 +213,28 @@ public void testGradient() { config.network().setInputFile("network_gradient.xml"); config.plans().setInputFile("population_1200.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); config.controller().setLastIteration(0); config.controller().setCreateGraphs(false); new RunBicycleExample().run(config ); LOG.info("Checking MATSim events file ..."); - final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; - final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; - Assertions.assertEquals(FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew), "Different event files."); + final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; + final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; + assertEquals("Different event files.", FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew)); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); - new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); - Assertions.assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); + new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); + assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); } @Test public void testGradientLane() { - Config config = ConfigUtils.createConfig(getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -234,27 +243,28 @@ public void testGradientLane() { config.network().setInputFile("network_gradient_lane.xml"); config.plans().setInputFile("population_1200.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); config.controller().setLastIteration(0); config.controller().setCreateGraphs(false); new RunBicycleExample().run(config ); LOG.info("Checking MATSim events file ..."); - final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; - final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; - Assertions.assertEquals(FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew), "Different event files."); + final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; + final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; + assertEquals("Different event files.", FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew)); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); - new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); - Assertions.assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); + new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); + assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); } @Test public void testNormal10It() { - Config config = ConfigUtils.createConfig(getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -262,7 +272,7 @@ public void testNormal10It() { config.network().setInputFile("network_normal.xml"); config.plans().setInputFile("population_1200.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); // 10 iterations config.controller().setLastIteration(10); config.controller().setWriteEventsInterval(10); @@ -272,15 +282,16 @@ public void testNormal10It() { new RunBicycleExample().run(config ); LOG.info("Checking MATSim events file ..."); - final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; - final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; - Assertions.assertEquals(FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew), "Different event files."); + final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; + final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; + assertEquals("Different event files.", FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew)); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); - new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); - Assertions.assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); + new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); + assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); } @Test public void testLinkBasedScoring() { @@ -291,7 +302,7 @@ public void testNormal10It() { // new RunBicycleExample().run( config ); // } Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); { Config config2 = createConfig( 0 ); BicycleConfigGroup bicycleConfigGroup2 = (BicycleConfigGroup) config2.getModules().get( "bicycle" ); @@ -299,23 +310,22 @@ public void testNormal10It() { new RunBicycleExample().run( config2 ); } Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); // LOG.info("Checking MATSim events file ..."); -// final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; -// final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; -// Assert.assertEquals("Different event files.", FILES_ARE_EQUAL, +// final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; +// final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; +// assertEquals("Different event files.", FILES_ARE_EQUAL, // new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew)); for (Id personId : scenarioReference.getPopulation().getPersons().keySet()) { double scoreReference = scenarioReference.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); double scoreCurrent = scenarioCurrent.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); - Assertions.assertEquals(scoreReference, scoreCurrent, MatsimTestUtils.EPSILON, "Scores of persons " + personId + " are different"); + Assert.assertEquals("Scores of persons " + personId + " are different", scoreReference, scoreCurrent, MatsimTestUtils.EPSILON); } -// Assert.assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); +// assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); } - @Test - public void testLinkVsLegMotorizedScoring() { + @Test public void testLinkVsLegMotorizedScoring() { // --- withOUT additional car traffic: // { // Config config2 = createConfig( 0 ); @@ -325,7 +335,7 @@ public void testLinkVsLegMotorizedScoring() { // new RunBicycleExample().run( config2 ); // } Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); // --- // --- WITH additional car traffic: { @@ -384,22 +394,22 @@ public void testLinkVsLegMotorizedScoring() { controler.run(); } Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); + new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); // --- // --- // LOG.info("Checking MATSim events file ..."); -// final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; -// final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; -// Assert.assertEquals("Different event files.", FILES_ARE_EQUAL, +// final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; +// final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; +// assertEquals("Different event files.", FILES_ARE_EQUAL, // new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew)); for (Id personId : scenarioReference.getPopulation().getPersons().keySet()) { double scoreReference = scenarioReference.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); double scoreCurrent = scenarioCurrent.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); - Assertions.assertEquals(scoreReference, scoreCurrent, MatsimTestUtils.EPSILON, "Scores of person=" + personId + " are different"); + Assert.assertEquals("Scores of person=" + personId + " are different", scoreReference, scoreCurrent, MatsimTestUtils.EPSILON); } -// Assert.assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); +// assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); } // @Test public void testMotorizedInteraction() { //// Config config = ConfigUtils.createConfig("./src/main/resources/bicycle_example/"); @@ -413,26 +423,26 @@ public void testLinkVsLegMotorizedScoring() { // new RunBicycleExample().run(config ); // // LOG.info("Checking MATSim events file ..."); -// final String eventsFilenameReference = getInputDirectory() + "output_events.xml.gz"; -// final String eventsFilenameNew = getOutputDirectory() + "output_events.xml.gz"; -// Assert.assertEquals("Different event files.", FILES_ARE_EQUAL, +// final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; +// final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; +// assertEquals("Different event files.", FILES_ARE_EQUAL, // new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew)); // // Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); // Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); -// new PopulationReader(scenarioReference).readFile(getInputDirectory() + "output_plans.xml.gz"); -// new PopulationReader(scenarioCurrent).readFile(getOutputDirectory() + "output_plans.xml.gz"); +// new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); +// new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); // for (Id personId : scenarioReference.getPopulation().getPersons().keySet()) { // double scoreReference = scenarioReference.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); // double scoreCurrent = scenarioCurrent.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); -// Assert.Assert.assertEquals("Scores of persons " + personId + " are different", scoreReference, scoreCurrent, MatsimTestUtils.EPSILON); +// Assert.assertEquals("Scores of persons " + personId + " are different", scoreReference, scoreCurrent, MatsimTestUtils.EPSILON); // } -// Assert.assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); +// assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); // } @Test public void testInfrastructureSpeedFactor() { - Config config = ConfigUtils.createConfig(getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); config.controller().setWriteEventsInterval(0); @@ -477,7 +487,7 @@ public void testInfrastructureSpeedFactor() { config.plans().setInputFile("population_4.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); config.controller().setLastIteration(0); config.global().setNumberOfThreads(1); @@ -514,20 +524,20 @@ public void install() { controler.run(); - Assertions.assertEquals(3, linkHandler.getLinkId2demand().get(Id.createLinkId("2")), MatsimTestUtils.EPSILON, "All bicycle users should use the longest but fastest route where the bicycle infrastructur speed factor is set to 1.0"); - Assertions.assertEquals(1, linkHandler.getLinkId2demand().get(Id.createLinkId("6")), MatsimTestUtils.EPSILON, "Only the car user should use the shortest route"); + Assert.assertEquals("All bicycle users should use the longest but fastest route where the bicycle infrastructur speed factor is set to 1.0", 3, linkHandler.getLinkId2demand().get(Id.createLinkId("2")), MatsimTestUtils.EPSILON); + Assert.assertEquals("Only the car user should use the shortest route", 1, linkHandler.getLinkId2demand().get(Id.createLinkId("6")), MatsimTestUtils.EPSILON); - Assertions.assertEquals(1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(0), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); - Assertions.assertEquals(1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(1), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); - Assertions.assertEquals(1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(2), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); + Assert.assertEquals("Wrong travel time (bicycle user)", 1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(0), MatsimTestUtils.EPSILON); + Assert.assertEquals("Wrong travel time (bicycle user)", 1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(1), MatsimTestUtils.EPSILON); + Assert.assertEquals("Wrong travel time (bicycle user)", 1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(2), MatsimTestUtils.EPSILON); - Assertions.assertEquals(Math.ceil( 10000 / (13.88) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(0), MatsimTestUtils.EPSILON, "Wrong travel time (car user)"); + Assert.assertEquals("Wrong travel time (car user)", Math.ceil( 10000 / (13.88) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(0), MatsimTestUtils.EPSILON); } @Test public void testInfrastructureSpeedFactorDistanceMoreRelevantThanTravelTime() { - Config config = ConfigUtils.createConfig(getClassInputDirectory() ); + Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); BicycleConfigGroup bicycleConfigGroup = ConfigUtils.addOrGetModule( config, BicycleConfigGroup.class ); config.controller().setWriteEventsInterval(0); @@ -571,7 +581,7 @@ public void testInfrastructureSpeedFactorDistanceMoreRelevantThanTravelTime() { config.network().setInputFile("network_infrastructure-speed-factor.xml"); config.plans().setInputFile("population_4.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controller().setOutputDirectory(getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); config.controller().setLastIteration(0); config.global().setNumberOfThreads(1); @@ -601,16 +611,16 @@ public void testInfrastructureSpeedFactorDistanceMoreRelevantThanTravelTime() { controler.run(); - Assertions.assertEquals(4, linkHandler.getLinkId2demand().get(Id.createLinkId("6")), MatsimTestUtils.EPSILON, "All bicycle users should use the shortest route even though the bicycle infrastructur speed factor is set to 0.1"); - Assertions.assertEquals(Math.ceil(10000 / 13.88 ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(0), MatsimTestUtils.EPSILON, "Wrong travel time (car user)"); - Assertions.assertEquals(Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(1), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); - Assertions.assertEquals(Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(2), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); - Assertions.assertEquals(Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(3), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); + Assert.assertEquals("All bicycle users should use the shortest route even though the bicycle infrastructur speed factor is set to 0.1", 4, linkHandler.getLinkId2demand().get(Id.createLinkId("6")), MatsimTestUtils.EPSILON); + Assert.assertEquals("Wrong travel time (car user)", Math.ceil(10000 / 13.88 ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(0), MatsimTestUtils.EPSILON); + Assert.assertEquals("Wrong travel time (bicycle user)", Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(1), MatsimTestUtils.EPSILON); + Assert.assertEquals("Wrong travel time (bicycle user)", Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(2), MatsimTestUtils.EPSILON); + Assert.assertEquals("Wrong travel time (bicycle user)", Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(3), MatsimTestUtils.EPSILON); } private Config createConfig( int lastIteration ){ // Config config = ConfigUtils.createConfig("./src/main/resources/bicycle_example/"); - Config config = ConfigUtils.createConfig( getClassInputDirectory() ); + Config config = ConfigUtils.createConfig( utils.getClassInputDirectory() ); config.addModule( new BicycleConfigGroup() ); RunBicycleExample.fillConfigWithBicycleStandardValues( config ); @@ -618,7 +628,7 @@ private Config createConfig( int lastIteration ){ config.network().setInputFile( "network_normal.xml" ); config.plans().setInputFile( "population_1200.xml" ); config.controller().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ); - config.controller().setOutputDirectory( getOutputDirectory() ); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); config.controller().setLastIteration( lastIteration ); config.controller().setLastIteration( lastIteration ); config.controller().setWriteEventsInterval( 10 ); diff --git a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java index 6b72ab1b664..815fc250dc3 100644 --- a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java +++ b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java @@ -24,7 +24,7 @@ import cadyts.utilities.io.tabularFileParser.TabularFileParser; import cadyts.utilities.misc.DynamicData; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -78,8 +78,8 @@ */ public class CadytsCarIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public final void testInitialization() { diff --git a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/utils/CalibrationStatReaderTest.java b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/utils/CalibrationStatReaderTest.java index cf1c31b9126..f8512146bf5 100644 --- a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/utils/CalibrationStatReaderTest.java +++ b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/utils/CalibrationStatReaderTest.java @@ -22,7 +22,7 @@ import java.io.IOException; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -30,8 +30,8 @@ public class CalibrationStatReaderTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testReader() throws IOException { diff --git a/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java b/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java index 9431005a492..6b95a948fbe 100644 --- a/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java +++ b/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.analysis.LegHistogram; import org.matsim.api.core.v01.Scenario; @@ -55,7 +55,7 @@ public class RunCarsharingIT { private final static Logger log = LogManager.getLogger(RunCarsharingIT.class); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public final void test() { diff --git a/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest66IT.java b/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest66IT.java index 935e4c61fb8..4e6afb73afd 100644 --- a/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest66IT.java +++ b/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest66IT.java @@ -32,7 +32,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -90,8 +90,8 @@ */ public class BetaTravelTest66IT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /* This TestCase uses a custom Controler, named TestControler, to load diff --git a/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest6IT.java b/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest6IT.java index 9db009cbcf8..de0ecae4685 100644 --- a/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest6IT.java +++ b/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest6IT.java @@ -32,7 +32,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -91,8 +91,8 @@ */ public class BetaTravelTest6IT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /* This TestCase uses a custom Controler, named TestControler, to load diff --git a/contribs/decongestion/src/test/java/org/matsim/contrib/decongestion/DecongestionPricingTestIT.java b/contribs/decongestion/src/test/java/org/matsim/contrib/decongestion/DecongestionPricingTestIT.java index 58477477f23..a59cc8f2027 100644 --- a/contribs/decongestion/src/test/java/org/matsim/contrib/decongestion/DecongestionPricingTestIT.java +++ b/contribs/decongestion/src/test/java/org/matsim/contrib/decongestion/DecongestionPricingTestIT.java @@ -23,7 +23,7 @@ package org.matsim.contrib.decongestion; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.analysis.ScoreStatsControlerListener.ScoreItem; import org.matsim.api.core.v01.Id; @@ -54,8 +54,8 @@ */ public class DecongestionPricingTestIT { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); /** * Kp = 0.0123 diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/modules/config/ConfigTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/modules/config/ConfigTest.java index b212182d3bc..32697f90a8d 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/modules/config/ConfigTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/modules/config/ConfigTest.java @@ -11,7 +11,7 @@ import java.util.Arrays; import java.util.HashSet; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.contribs.discrete_mode_choice.modules.config.DiscreteModeChoiceConfigGroup; import org.matsim.core.config.Config; @@ -21,7 +21,7 @@ import org.matsim.testcases.MatsimTestUtils; public class ConfigTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtWithExtensionsConfigGroupTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtWithExtensionsConfigGroupTest.java index bc0f9e22ba3..8790d1a5341 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtWithExtensionsConfigGroupTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtWithExtensionsConfigGroupTest.java @@ -19,13 +19,15 @@ package org.matsim.contrib.drt.extension; +import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; +import org.junit.jupiter.api.io.TempDir; import org.junit.rules.TemporaryFolder; import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup; import org.matsim.contrib.drt.extension.companions.DrtCompanionParams; @@ -45,10 +47,8 @@ public class DrtWithExtensionsConfigGroupTest { private final static double WEIGHT_2 = 1337.; private final static double WEIGHT_3 = 911.; - - @Rule - public TemporaryFolder tempFolder = new TemporaryFolder(); - + @TempDir + public File tempFolder; private static Config createConfig(List values) { Config config = ConfigUtils.createConfig(); @@ -70,9 +70,9 @@ private static Config createConfig(List values) { return config; } - private static Path writeConfig(final TemporaryFolder tempFolder, List weights) throws IOException { + private static Path writeConfig(final File tempFolder, List weights) throws IOException { Config config = createConfig(weights); - Path configFile = tempFolder.newFile("config.xml").toPath(); + Path configFile = new File(tempFolder, "config.xml").toPath(); ConfigUtils.writeConfig(config, configFile.toString()); return configFile; } diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/companions/RunDrtWithCompanionExampleIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/companions/RunDrtWithCompanionExampleIT.java index 9ac24985fe4..749cc23e8ea 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/companions/RunDrtWithCompanionExampleIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/companions/RunDrtWithCompanionExampleIT.java @@ -28,7 +28,7 @@ import java.util.stream.Collectors; import org.assertj.core.api.Assertions; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup; @@ -48,8 +48,8 @@ */ public class RunDrtWithCompanionExampleIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testRunDrtWithCompanions() { diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/dashboards/DashboardTests.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/dashboards/DashboardTests.java index c26a623fec8..f078e00e07b 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/dashboards/DashboardTests.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/dashboards/DashboardTests.java @@ -1,7 +1,7 @@ package org.matsim.contrib.drt.extension.dashboards; import org.assertj.core.api.Assertions; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.application.MATSimApplication; import org.matsim.contrib.drt.extension.DrtTestScenario; @@ -17,8 +17,8 @@ public class DashboardTests { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private void run() { diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModaFixedDrtLegEstimatorTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModaFixedDrtLegEstimatorTest.java index de1c98e62d1..1a149837266 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModaFixedDrtLegEstimatorTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModaFixedDrtLegEstimatorTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.drt.extension.estimator; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.application.MATSimApplication; import org.matsim.contrib.drt.extension.DrtTestScenario; @@ -27,8 +27,8 @@ public class MultiModaFixedDrtLegEstimatorTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private Controler controler; diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModalDrtLegEstimatorTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModalDrtLegEstimatorTest.java index 8d61ef68123..c35ac36af49 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModalDrtLegEstimatorTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModalDrtLegEstimatorTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.drt.extension.estimator; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.application.MATSimApplication; import org.matsim.contrib.drt.extension.DrtTestScenario; @@ -26,8 +26,8 @@ public class MultiModalDrtLegEstimatorTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private Controler controler; diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/insertion/DrtInsertionExtensionIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/insertion/DrtInsertionExtensionIT.java index 001bae2a1e7..7f7f76fe71c 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/insertion/DrtInsertionExtensionIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/insertion/DrtInsertionExtensionIT.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.Set; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.IdMap; @@ -52,8 +52,8 @@ import org.matsim.vis.otfvis.OTFVisConfigGroup; public class DrtInsertionExtensionIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private Controler createController() { URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml"); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/operationFacilities/OperationFacilitiesIOTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/operationFacilities/OperationFacilitiesIOTest.java index d1e2e231a43..3afc583589b 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/operationFacilities/OperationFacilitiesIOTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/operationFacilities/OperationFacilitiesIOTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.drt.extension.operations.operationFacilities; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -13,8 +13,8 @@ public class OperationFacilitiesIOTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); @Test public void test() { diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/ShiftsIOTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/ShiftsIOTest.java index 37a86a85098..d7ff41c3846 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/ShiftsIOTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/ShiftsIOTest.java @@ -5,7 +5,7 @@ import java.io.File; import java.util.Optional; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacility; @@ -22,8 +22,8 @@ */ public class ShiftsIOTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final String TESTSHIFTSINPUT = "testShifts.xml"; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/config/ConfigBehaviorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/config/ConfigBehaviorTest.java index ff70b6e4808..38880db6bcb 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/config/ConfigBehaviorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/config/ConfigBehaviorTest.java @@ -3,7 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; @@ -16,7 +16,7 @@ public class ConfigBehaviorTest{ private static final Logger log = LogManager.getLogger(ConfigBehaviorTest.class ); - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; @Test diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DefaultUnplannedRequestInserterTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DefaultUnplannedRequestInserterTest.java index 5730c59ea46..2f33a567b87 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DefaultUnplannedRequestInserterTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DefaultUnplannedRequestInserterTest.java @@ -32,8 +32,9 @@ import java.util.*; import org.apache.commons.lang3.mutable.MutableInt; -import org.junit.Rule; +import org.junit.jupiter.api.extension.ExtendWith; import org.junit.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Identifiable; import org.matsim.api.core.v01.network.Link; @@ -69,8 +70,8 @@ public class DefaultUnplannedRequestInserterTest { private final EventsManager eventsManager = mock(EventsManager.class); - @Rule - public final ForkJoinPoolTestRule rule = new ForkJoinPoolTestRule(); + @RegisterExtension + public final ForkJoinPoolExtension forkJoinPoolExtension = new ForkJoinPoolExtension(); @Test public void nothingToSchedule() { @@ -285,7 +286,7 @@ private DefaultUnplannedRequestInserter newInserter(Fleet fleet, double now, DrtInsertionSearch insertionSearch, RequestInsertionScheduler insertionScheduler) { return new DefaultUnplannedRequestInserter(mode, fleet, () -> now, eventsManager, insertionScheduler, vehicleEntryFactory, insertionRetryQueue, insertionSearch, DrtOfferAcceptor.DEFAULT_ACCEPTOR, - rule.forkJoinPool, StaticPassengerStopDurationProvider.of(10.0, 0.0)); + forkJoinPoolExtension.forkJoinPool, StaticPassengerStopDurationProvider.of(10.0, 0.0)); } private Link link(String id) { diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java index c708e623de0..26c4c3f6f7d 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java @@ -4,7 +4,7 @@ import java.util.*; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -52,7 +52,7 @@ */ public class DrtPoolingParameterTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/ForkJoinPoolTestRule.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/ForkJoinPoolExtension.java similarity index 78% rename from contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/ForkJoinPoolTestRule.java rename to contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/ForkJoinPoolExtension.java index 548decd28b6..e6f204bdf58 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/ForkJoinPoolTestRule.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/ForkJoinPoolExtension.java @@ -22,27 +22,17 @@ import java.util.concurrent.ForkJoinPool; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; /** * @author Michal Maciejewski (michalm) */ -public class ForkJoinPoolTestRule implements TestRule { +public class ForkJoinPoolExtension implements AfterEachCallback { public final ForkJoinPool forkJoinPool = new ForkJoinPool(1); @Override - public Statement apply(Statement base, Description description) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - try { - base.evaluate(); - } finally { - forkJoinPool.shutdown(); - } - } - }; + public void afterEach(ExtensionContext extensionContext) throws Exception { + forkJoinPool.shutdown(); } } diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/ExtensiveInsertionProviderTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/ExtensiveInsertionProviderTest.java index 3e94e70dfd5..4d05fbc2397 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/ExtensiveInsertionProviderTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/ExtensiveInsertionProviderTest.java @@ -29,8 +29,8 @@ import java.util.List; -import org.junit.Rule; import org.junit.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.contrib.drt.optimizer.VehicleEntry; import org.matsim.contrib.drt.optimizer.Waypoint; import org.matsim.contrib.drt.optimizer.insertion.*; @@ -43,8 +43,8 @@ * @author Michal Maciejewski (michalm) */ public class ExtensiveInsertionProviderTest { - @Rule - public final ForkJoinPoolTestRule rule = new ForkJoinPoolTestRule(); + @RegisterExtension + public final ForkJoinPoolExtension rule = new ForkJoinPoolExtension(); @Test public void getInsertions_noInsertionsGenerated() { diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/selective/SelectiveInsertionProviderTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/selective/SelectiveInsertionProviderTest.java index a88df5ac539..d6ed2a51d7b 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/selective/SelectiveInsertionProviderTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/selective/SelectiveInsertionProviderTest.java @@ -31,11 +31,11 @@ import java.util.Optional; import java.util.Set; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.contrib.drt.optimizer.VehicleEntry; import org.matsim.contrib.drt.optimizer.insertion.BestInsertionFinder; -import org.matsim.contrib.drt.optimizer.insertion.ForkJoinPoolTestRule; +import org.matsim.contrib.drt.optimizer.insertion.ForkJoinPoolExtension; import org.matsim.contrib.drt.optimizer.insertion.InsertionGenerator; import org.matsim.contrib.drt.optimizer.insertion.InsertionGenerator.Insertion; import org.matsim.contrib.drt.optimizer.insertion.InsertionWithDetourData; @@ -47,8 +47,8 @@ * @author Michal Maciejewski (michalm) */ public class SelectiveInsertionProviderTest { - @Rule - public final ForkJoinPoolTestRule rule = new ForkJoinPoolTestRule(); + @RegisterExtension + public final ForkJoinPoolExtension rule = new ForkJoinPoolExtension(); private final BestInsertionFinder initialInsertionFinder = mock(BestInsertionFinder.class); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/AbandonAndCancelTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/AbandonAndCancelTest.java index c3dc7f546b0..ba9f10a787e 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/AbandonAndCancelTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/AbandonAndCancelTest.java @@ -3,7 +3,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Leg; @@ -21,9 +21,9 @@ * @author Sebastian Hörl (sebhoerl) / IRT SystemX */ public class AbandonAndCancelTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); - + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); + @Test public void noAbandonTest() { /* @@ -64,7 +64,7 @@ public void abandonTest() { * One person requests to depart at 2000 and also is there at 2000. Another * person asks also to depart at 2000, but only arrives at 4000, i.e. the person * has 1000s delay. - * + * * We configure that the vehicle should leave without the passenger if it waits * longer than 500s. The late request will be rejected! */ @@ -103,7 +103,7 @@ public void abandonThenImmediateTest() { * One person requests to depart at 2000 and also is there at 2000. Another * person asks also to depart at 2000, but only arrives at 4000, i.e. the person * has 1000s delay. - * + * * We configure that the vehicle should leave without the passenger if it waits * longer than 500s. The person will, however, send a new request when arriving * at the departure point and get an immediate vehicle. @@ -146,7 +146,7 @@ public void cancelEarlyTest() { * One person requests to depart at 2000 and also is there at 2000. Another * person asks also to depart at 2000, but only arrives at 4000, i.e. the person * has 1000s delay. - * + * * In this test we manually cancel the second request at 500.0 (so before * departure of any agent). */ @@ -174,9 +174,9 @@ public void notifyMobsimBeforeSimStep(MobsimBeforeSimStepEvent e) { if (e.getSimulationTime() == 500.0) { PlanAgent planAgent = (PlanAgent) qsim.getAgents() .get(Id.createPersonId("personLate")); - + Leg leg = TripStructureUtils.getLegs(planAgent.getCurrentPlan()).get(1); - + prebookingManager.cancel(leg); } } @@ -202,14 +202,14 @@ public void notifyMobsimBeforeSimStep(MobsimBeforeSimStepEvent e) { assertTrue(requestInfo.rejected); } } - + @Test public void cancelLateTest() { /* * One person requests to depart at 2000 and also is there at 2000. Another * person asks also to depart at 2000, but only arrives at 4000, i.e. the person * has 1000s delay. - * + * * In this test we manually cancel the second request at 3000.0 (so after * departure of the first agent). */ @@ -237,9 +237,9 @@ public void notifyMobsimBeforeSimStep(MobsimBeforeSimStepEvent e) { if (e.getSimulationTime() == 3000.0) { PlanAgent planAgent = (PlanAgent) qsim.getAgents() .get(Id.createPersonId("personLate")); - + Leg leg = TripStructureUtils.getLegs(planAgent.getCurrentPlan()).get(1); - + prebookingManager.cancel(leg); } } diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PersonStuckPrebookingTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PersonStuckPrebookingTest.java index 11d3951b632..1c017bc5f1a 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PersonStuckPrebookingTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PersonStuckPrebookingTest.java @@ -6,7 +6,7 @@ import java.util.Collections; import java.util.Set; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Activity; @@ -37,8 +37,8 @@ * @author Sebastian Hörl (sebhoerl) / IRT SystemX */ public class PersonStuckPrebookingTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void baselineTest() { diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTest.java index 35d9a0ef62b..2845a5d7af4 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTest.java @@ -2,7 +2,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.contrib.drt.prebooking.PrebookingTestEnvironment.RequestInfo; import org.matsim.contrib.drt.prebooking.logic.AttributeBasedPrebookingLogic; @@ -14,9 +14,9 @@ * @author Sebastian Hörl (sebhoerl) / IRT SystemX */ public class PrebookingTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); - + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); + @Test public void withoutPrebookedRequests() { /*- @@ -49,7 +49,7 @@ public void withoutPrebookedRequests() { assertEquals(2086.0, taskInfo.get(2).startTime, 1e-3); assertEquals(2146.0, taskInfo.get(2).endTime, 1e-3); } - + static PrebookingParams installPrebooking(Controler controller) { return installPrebooking(controller, true); } @@ -57,11 +57,11 @@ static PrebookingParams installPrebooking(Controler controller) { static PrebookingParams installPrebooking(Controler controller, boolean installLogic) { DrtConfigGroup drtConfig = DrtConfigGroup.getSingleModeDrtConfig(controller.getConfig()); drtConfig.addParameterSet(new PrebookingParams()); - + if (installLogic) { AttributeBasedPrebookingLogic.install(controller, drtConfig); } - + return drtConfig.getPrebookingParams().get(); } @@ -212,7 +212,7 @@ public void twoSequentialRequests_inverseSubmission() { @Test public void sameTrip_differentDepartureTime() { /*- - * Two requests with the same origin and destination, but distinct departure time. + * Two requests with the same origin and destination, but distinct departure time. * - First, early one is submitted, then late one. * - Vehicle picks up and drops off early one, then late one. * - In total four stops (P,D,P,D) @@ -250,7 +250,7 @@ public void sameTrip_differentDepartureTime() { @Test public void sameTrip_sameDepartureTime() { /*- - * Two requests with the same origin and destination, and same departure time. + * Two requests with the same origin and destination, and same departure time. * - First, A is submitted, then B. * - Vehicle picks up and A and B, then drops off A and B. * - In total two stops (P,D) @@ -382,26 +382,26 @@ public void sameTrip_inverseSubmission_noPrepending() { * Two requests with the same origin and destination, different departure times. * - First, A is submitted with departure time 2020 * - Then, B is submitted with departure time 2000 - * - * - This is inverse of sameTrip_extendPickupDuration above, the request with the earlier departure + * + * - This is inverse of sameTrip_extendPickupDuration above, the request with the earlier departure * time is submitted second. * - We would expect the requests to be merged, but this is not so trivial with the current code base: - * It would be necessary to shift the stop task to the past and extend it. Theoretically, this is + * It would be necessary to shift the stop task to the past and extend it. Theoretically, this is * possible but it would be nice to embed this in a more robust way in the code base. * - Plus, it may change the current DRT behavior because we have these situations also in non-prebooked * simulations: We may submit an immediate request and find an insertion for a stop task that starts - * in 5 seconds. This case is treated in standard DRT as any other request (extending the task but + * in 5 seconds. This case is treated in standard DRT as any other request (extending the task but * keeping the start time fixed). - * - We follow this default behaviour here: Instead of *prepending* the task with the new request, we + * - We follow this default behaviour here: Instead of *prepending* the task with the new request, we * *append* it as usual. If there is at least one pickup in the stop task with the standard stop * durations, there is no additional cost of adding the request, but the person experiences a wait * delay that could be minimized if we were able to prepend the task. * - (Then again, do we actually want to do this, it would reserve the vehicle a few seconds more than * necessary for a stop that is potentially prebooked in a long time). - * + * * - Expected behavior in current implementation: Merge new request with the later departing existing * one, which generates wait time for the customer. - * + * * - In total two stops (P, D) */ @@ -438,14 +438,14 @@ public void sameTrip_inverseSubmission_noPrepending() { public void sameTrip_inverseSubmission_splitPickup() { /*- * Two requests with the same origin and destination, different departure times. - * - First, A is submitted with departure time 2020 + * - First, A is submitted with departure time 2020 * - Then, B is submitted with departure time 1770 - * - B's departure is 250s before A, so appending it to A would lead to more than 300s + * - B's departure is 250s before A, so appending it to A would lead to more than 300s * of wait time, which is not a valid insertion * - Hence, the insertion *after* the pickup of A is not valid * - But the insertion *before* A is possible (it is usually evaluated but dominated by the insertion after) * - TODO: May think this through and eliminate these insertion upfront - * + * * - Expectation: Standard scheduling a prebooked request before another one (as if they had not the * same origin link). * - In total three stops (P,P,D) diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java index 365c5e04dff..2bf9646c17a 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java @@ -23,7 +23,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -66,8 +66,8 @@ * @author jbischoff */ public class DrtRoutingModuleTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testCottbusClosestAccessEgressStopFinder() { diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java index b95f6d8de61..7878dad8604 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java @@ -31,7 +31,7 @@ import java.util.Map; import java.util.stream.Collectors; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.drt.optimizer.DrtRequestInsertionRetryParams; @@ -72,8 +72,8 @@ */ public class RunDrtExampleIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testRunDrtExampleWithNoRejections_ExtensiveSearch() { @@ -319,30 +319,30 @@ public void install() { verifyDrtCustomerStatsCloseToExpectedStats(utils.getOutputDirectory(), expectedStats); } - + @Test public void testRunDrtWithPrebooking() { Id.resetCaches(); URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml"); - + Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), new OTFVisConfigGroup()); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); - + DrtConfigGroup drtConfig = DrtConfigGroup.getSingleModeDrtConfig(config); drtConfig.addParameterSet(new PrebookingParams()); - + Controler controller = DrtControlerCreator.createControler(config, false); ProbabilityBasedPrebookingLogic.install(controller, drtConfig, 0.5, 4.0 * 3600.0); - + PrebookingTracker tracker = new PrebookingTracker(); tracker.install(controller); - + controller.run(); - + assertEquals(157, tracker.immediateScheduled); assertEquals(205, tracker.prebookedScheduled); assertEquals(26, tracker.immediateRejected); @@ -467,13 +467,13 @@ public Stats build() { } } } - + static private class PrebookingTracker implements PassengerRequestRejectedEventHandler, PassengerRequestScheduledEventHandler { int immediateScheduled = 0; int prebookedScheduled = 0; int immediateRejected = 0; int prebookedRejected = 0; - + @Override public void handleEvent(PassengerRequestScheduledEvent event) { if (event.getRequestId().toString().contains("prebooked")) { @@ -491,10 +491,10 @@ public void handleEvent(PassengerRequestRejectedEvent event) { immediateRejected++; } } - + void install(Controler controller) { PrebookingTracker thisTracker = this; - + controller.addOverridingModule(new AbstractModule() { @Override public void install() { diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiWithPrebookingExampleIT.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiWithPrebookingExampleIT.java index b6c7e2ed828..55e0e574dac 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiWithPrebookingExampleIT.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiWithPrebookingExampleIT.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.Logger; import org.assertj.core.data.Offset; import org.junit.Ignore; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -68,8 +68,8 @@ public class RunOneTaxiWithPrebookingExampleIT { private static final Logger log = LogManager.getLogger(RunOneTaxiWithPrebookingExampleIT.class); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Ignore @Test diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/EmissionModuleTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/EmissionModuleTest.java index 5f61653ebc3..6af6c9b7abe 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/EmissionModuleTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/EmissionModuleTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.emissions; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; @@ -22,8 +22,8 @@ */ public class EmissionModuleTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils testUtils = new MatsimTestUtils(); @Test(expected = RuntimeException.class) public void testWithIncorrectNetwork() { @@ -63,4 +63,4 @@ public void install() { fail("Was expecting exception"); } -} \ No newline at end of file +} diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java index c48f5254b39..3e9d93e186a 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java @@ -1,7 +1,7 @@ package org.matsim.contrib.emissions; import org.junit.Ignore; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -55,8 +55,8 @@ public class TestPositionEmissionModule { private static final String configFile = IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "emissions-sampleScenario/testv2_Vehv2" ), "config_detailed.xml" ).toString(); // (I changed the above from veh v1 to veh v2 since veh v1 is deprecated, especially for emissions. kai, apr'21) - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils testUtils = new MatsimTestUtils(); @Test @Ignore diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionGridAnalyzerTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionGridAnalyzerTest.java index 3f764cd6b88..7cf055ff33e 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionGridAnalyzerTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionGridAnalyzerTest.java @@ -3,7 +3,7 @@ import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVPrinter; import org.apache.commons.csv.CSVRecord; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; @@ -37,8 +37,8 @@ public class EmissionGridAnalyzerTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils testUtils = new MatsimTestUtils(); private Geometry createRect(double maxX, double maxY) { return new GeometryFactory().createPolygon(new Coordinate[]{ diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/FastEmissionGridAnalyzerTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/FastEmissionGridAnalyzerTest.java index ceb4b2a093d..25c0a8b4122 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/FastEmissionGridAnalyzerTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/FastEmissionGridAnalyzerTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.emissions.analysis; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -20,8 +20,8 @@ public class FastEmissionGridAnalyzerTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); @Test public void rasterNetwork_singleLink() { diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RawEmissionEventsReaderTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RawEmissionEventsReaderTest.java index 3eda5f417e8..08678b9549f 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RawEmissionEventsReaderTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RawEmissionEventsReaderTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.emissions.analysis; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.emissions.Pollutant; @@ -16,8 +16,8 @@ public class RawEmissionEventsReaderTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); @Test public void handleNonEventNode() { @@ -95,4 +95,4 @@ public void handleWarmEmissionEvent() { assertEquals(expectedEventsCount, counter.get()); } -} \ No newline at end of file +} diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/VehicleLeavesTrafficEventTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/VehicleLeavesTrafficEventTest.java index e8a0513f36a..bc2a404634c 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/VehicleLeavesTrafficEventTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/VehicleLeavesTrafficEventTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.emissions.events; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.emissions.EmissionModule; @@ -36,7 +36,7 @@ */ public class VehicleLeavesTrafficEventTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public final void testRareEventsFromBerlinScenario (){ @@ -85,4 +85,4 @@ public void install(){ Assert.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result); } -} \ No newline at end of file +} diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExampleIT.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExampleIT.java index 5f231f96650..eb79ad597b5 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExampleIT.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExampleIT.java @@ -19,7 +19,7 @@ package org.matsim.contrib.emissions.example; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.contrib.emissions.EmissionUtils; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; @@ -39,7 +39,7 @@ * */ public class RunAverageEmissionToolOfflineExampleIT{ - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; @Test public final void testAverage_vehTypeV1() { diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExampleIT.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExampleIT.java index 35735730695..4a3edaf60dd 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExampleIT.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExampleIT.java @@ -19,7 +19,7 @@ package org.matsim.contrib.emissions.example; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup.DetailedVsAverageLookupBehavior; @@ -34,7 +34,7 @@ * */ public class RunDetailedEmissionToolOfflineExampleIT { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; /* * diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1.java index a762a196a4a..375cae0855b 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1.java @@ -20,7 +20,7 @@ import org.junit.Assert; import org.junit.Ignore; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; @@ -35,7 +35,7 @@ * */ public class RunDetailedEmissionToolOnlineExampleIT_vehTypeV1 { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; /** * Test method for {@link RunDetailedEmissionToolOnlineExample#main(String[])}. diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage.java index a046d363371..fc23f2cefbd 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage.java @@ -18,7 +18,7 @@ * *********************************************************************** */ package org.matsim.contrib.emissions.example; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; @@ -35,7 +35,7 @@ * */ public class RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; /** * Test method for {@link RunDetailedEmissionToolOnlineExample#main(java.lang.String[])}. diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java index 1a247d71217..213c933c504 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java @@ -20,7 +20,7 @@ import org.junit.Assert; import org.junit.Ignore; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; @@ -35,7 +35,7 @@ * */ public class RunDetailedEmissionToolOnlineExampleIT_vehTypeV2 { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; /** * Test method for {@link RunDetailedEmissionToolOnlineExample#main(String[])}. diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage.java index 42f65e0010b..1c387a47d73 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage.java @@ -18,7 +18,7 @@ * *********************************************************************** */ package org.matsim.contrib.emissions.example; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; @@ -36,7 +36,7 @@ * */ public class RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; /** * Test method for {@link RunDetailedEmissionToolOnlineExample#main(String[])}. diff --git a/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleTest.java b/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleTest.java index c2d26638e04..e8bb29fea1c 100644 --- a/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleTest.java +++ b/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleTest.java @@ -9,7 +9,7 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.events.EventsUtils; import org.matsim.core.population.PopulationUtils; -import org.matsim.testcases.MatsimJunit5TestExtension; +import org.matsim.testcases.MatsimTestUtils; import org.matsim.utils.eventsfilecomparison.EventsFileComparator; public class RunEvExampleTest{ @@ -17,7 +17,7 @@ public class RunEvExampleTest{ private static final Logger log = LogManager.getLogger(RunEvExample.class ); @RegisterExtension - public MatsimJunit5TestExtension utils = new MatsimJunit5TestExtension() ; + public MatsimTestUtils utils = new MatsimTestUtils() ; @Test public void runTest(){ try { diff --git a/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleWithLTHConsumptionModelTest.java b/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleWithLTHConsumptionModelTest.java index 0aedc60e902..543e1a643da 100644 --- a/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleWithLTHConsumptionModelTest.java +++ b/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleWithLTHConsumptionModelTest.java @@ -3,7 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; @@ -20,7 +20,7 @@ public class RunEvExampleWithLTHConsumptionModelTest{ private static final Logger log = LogManager.getLogger(RunEvExample.class ); - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; @Test public void runTest(){ try { diff --git a/contribs/ev/src/test/java/org/matsim/contrib/ev/temperature/TemperatureChangeModuleIntegrationTest.java b/contribs/ev/src/test/java/org/matsim/contrib/ev/temperature/TemperatureChangeModuleIntegrationTest.java index 7c39936e0b6..a7c51e597b1 100644 --- a/contribs/ev/src/test/java/org/matsim/contrib/ev/temperature/TemperatureChangeModuleIntegrationTest.java +++ b/contribs/ev/src/test/java/org/matsim/contrib/ev/temperature/TemperatureChangeModuleIntegrationTest.java @@ -22,7 +22,7 @@ import jakarta.inject.Inject; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -41,8 +41,8 @@ * created by jbischoff, 16.08.2018 */ public class TemperatureChangeModuleIntegrationTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testTemperatureChangeModule() { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java index 37a4cabaf82..60c0c236e32 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java @@ -21,7 +21,7 @@ package org.matsim.freight.carriers; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.Event; @@ -49,7 +49,7 @@ public class CarrierEventsReadersTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); private final Id linkId = Id.createLinkId("demoLink"); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierModuleTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierModuleTest.java index 69938d9c14d..6971e244003 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierModuleTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierModuleTest.java @@ -22,7 +22,7 @@ package org.matsim.freight.carriers; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; @@ -47,8 +47,8 @@ public class CarrierModuleTest { FreightCarriersConfigGroup freightCarriersConfigGroup; - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils testUtils = new MatsimTestUtils(); @Before public void setUp(){ diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanReaderV1Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanReaderV1Test.java index 10f95ad59cc..e99df84a363 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanReaderV1Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanReaderV1Test.java @@ -22,7 +22,7 @@ package org.matsim.freight.carriers; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.core.population.routes.NetworkRoute; @@ -38,7 +38,7 @@ */ public class CarrierPlanReaderV1Test { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2Test.java index 29887701aa4..1a491be3e95 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2Test.java @@ -23,7 +23,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -44,7 +44,7 @@ public class CarrierPlanXmlReaderV2Test { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); private Carrier testCarrier; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java index 64a078eecb5..1732949b629 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java @@ -33,7 +33,7 @@ public class CarrierPlanXmlReaderV2WithDtdTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); private Carrier testCarrier; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV1Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV1Test.java index 21b0ba0ed8f..4dd9a950d5a 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV1Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV1Test.java @@ -21,7 +21,7 @@ package org.matsim.freight.carriers; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.freight.carriers.*; @@ -33,8 +33,8 @@ */ public class CarrierPlanXmlWriterV1Test { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void testCarrierPlanWriterWrites() { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test.java index f8b84d04382..252254f9a24 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test.java @@ -22,7 +22,7 @@ package org.matsim.freight.carriers; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -37,8 +37,8 @@ public class CarrierPlanXmlWriterV2Test { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); private Carrier testCarrier; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1Test.java index 268bae2dd71..a122bae47cb 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1Test.java @@ -22,7 +22,7 @@ package org.matsim.freight.carriers; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -37,8 +37,8 @@ public class CarrierPlanXmlWriterV2_1Test { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); private Carrier testCarrier; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierReadWriteV2_1Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierReadWriteV2_1Test.java index 50453b95881..741d20cb168 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierReadWriteV2_1Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierReadWriteV2_1Test.java @@ -21,7 +21,7 @@ package org.matsim.freight.carriers; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.freight.carriers.*; import org.matsim.testcases.MatsimTestUtils; @@ -32,8 +32,8 @@ public class CarrierReadWriteV2_1Test { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void readWriteTest() throws FileNotFoundException, IOException { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest.java index aa0a0ec281a..06a24c9e6ee 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest.java @@ -23,7 +23,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.freight.carriers.*; @@ -33,7 +33,7 @@ public class CarrierVehicleTypeLoaderTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); private CarrierVehicleTypes types; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest.java index 43c73857e44..720dcb63c32 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.testcases.MatsimTestUtils; @@ -34,7 +34,7 @@ import static org.junit.Assert.assertTrue; public class CarrierVehicleTypeReaderTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; private static final Logger log = LogManager.getLogger(CarrierVehicleTypeReaderTest.class) ; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeTest.java index 6516c4933a8..a17f15744aa 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeTest.java @@ -23,7 +23,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.freight.carriers.CarrierVehicleTypes; @@ -33,7 +33,7 @@ public class CarrierVehicleTypeTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); CarrierVehicleTypes types; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeWriterTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeWriterTest.java index 551c5b6eac8..c47029826e6 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeWriterTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeWriterTest.java @@ -21,7 +21,7 @@ package org.matsim.freight.carriers; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.freight.carriers.CarrierVehicleTypeReader; import org.matsim.freight.carriers.CarrierVehicleTypeWriter; @@ -30,8 +30,8 @@ public class CarrierVehicleTypeWriterTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils() ; @Test public void testTypeWriter(){ diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java index e6224ced05c..b1a831f0763 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java @@ -22,7 +22,7 @@ package org.matsim.freight.carriers; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.freight.carriers.*; @@ -36,8 +36,8 @@ */ public class CarriersUtilsTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void testAddAndGetVehicleToCarrier() { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java index 648a61edff2..7a157805173 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java @@ -23,7 +23,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -43,7 +43,7 @@ public class EquilWithCarrierWithPersonsIT { private Controler controler; - @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); static Config commonConfig( MatsimTestUtils testUtils ) { Config config = ConfigUtils.createConfig(); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT.java index 51a28a88ed0..4de7e0d3267 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT.java @@ -22,7 +22,7 @@ package org.matsim.freight.carriers.controler; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -44,7 +44,7 @@ public class EquilWithCarrierWithoutPersonsIT { private Controler controler; - @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); public void setUp() { Config config = EquilWithCarrierWithPersonsIT.commonConfig( testUtils ); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java index 71b63d36035..99f0c7ebe80 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -63,8 +63,8 @@ */ public class DistanceConstraintFromVehiclesFileTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); static final Logger log = LogManager.getLogger(DistanceConstraintFromVehiclesFileTest.class); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java index cff10f42763..f55ccf201ed 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -64,8 +64,8 @@ */ public class DistanceConstraintTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); static final Logger log = LogManager.getLogger(DistanceConstraintTest.class); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java index a1811281682..1adec7e30a1 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java @@ -31,7 +31,7 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -56,7 +56,7 @@ */ public class FixedCostsTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); private final static Logger log = LogManager.getLogger(FixedCostsTest.class); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/IntegrationIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/IntegrationIT.java index 984bdd3e5e8..1e0988f6529 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/IntegrationIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/IntegrationIT.java @@ -28,7 +28,7 @@ import com.graphhopper.jsprit.core.reporting.SolutionPrinter; import com.graphhopper.jsprit.core.util.Solutions; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; @@ -44,8 +44,8 @@ public class IntegrationIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testJsprit() throws ExecutionException, InterruptedException { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java index 7b3060643a3..16cef601c1a 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java @@ -31,7 +31,7 @@ import com.graphhopper.jsprit.core.problem.vehicle.Vehicle; import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl; import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -54,8 +54,8 @@ public class MatsimTransformerTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void whenTransforming_jSpritType2matsimType_itIsMadeCorrectly() { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/NetworkBasedTransportCostsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/NetworkBasedTransportCostsTest.java index e85cb3ce9a1..bc8bc2d0e81 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/NetworkBasedTransportCostsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/NetworkBasedTransportCostsTest.java @@ -25,7 +25,7 @@ import com.graphhopper.jsprit.core.problem.driver.Driver; import com.graphhopper.jsprit.core.problem.vehicle.Vehicle; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -47,7 +47,7 @@ public class NetworkBasedTransportCostsTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java index 3201a4cd5c9..41f746ec87a 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java @@ -27,7 +27,7 @@ import com.graphhopper.jsprit.core.reporting.SolutionPrinter; import com.graphhopper.jsprit.core.util.Solutions; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -41,8 +41,8 @@ import org.matsim.vehicles.VehicleType; public class SkillsIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private final Id carrierLocation = Id.createLinkId("i(1,0)"); @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunChessboardIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunChessboardIT.java index 593b7786a62..eb884308c2c 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunChessboardIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunChessboardIT.java @@ -22,7 +22,7 @@ package org.matsim.freight.carriers.usecases.chessboard; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; @@ -36,7 +36,7 @@ public class RunChessboardIT { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; @Test public void runChessboard() { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunPassengerAlongWithCarriersIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunPassengerAlongWithCarriersIT.java index 0749341e978..4fdfd06b0fb 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunPassengerAlongWithCarriersIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunPassengerAlongWithCarriersIT.java @@ -22,15 +22,15 @@ package org.matsim.freight.carriers.usecases.chessboard; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.testcases.MatsimTestUtils; public class RunPassengerAlongWithCarriersIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils() ; @Test public void runChessboard() { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsIT.java index 05f0eeb244d..d297d904034 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsIT.java @@ -28,7 +28,7 @@ import com.graphhopper.jsprit.core.util.Solutions; import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -64,8 +64,8 @@ public class CarrierControlerUtilsIT { private Carrier carrierWShipmentsOnlyFromCarrierWServices; private Carrier carrierWShipmentsOnlyFromCarrierWShipments; - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Before public void setUp() { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java index 0f4354005b1..4253b81d269 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java @@ -30,7 +30,7 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -60,8 +60,8 @@ public class CarrierControlerUtilsTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final Logger log = LogManager.getLogger(CarrierControlerUtilsTest.class); @@ -74,8 +74,8 @@ public class CarrierControlerUtilsTest { private Carrier carrierWShipmentsOnlyFromCarrierWServices; private Carrier carrierWShipmentsOnlyFromCarrierWShipments; - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Before public void setUp() { diff --git a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversReaderTest.java b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversReaderTest.java index f5ba3475e0b..6568d0d0bdd 100644 --- a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversReaderTest.java +++ b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversReaderTest.java @@ -21,7 +21,7 @@ package org.matsim.contrib.freightreceiver; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.freight.carriers.Carrier; @@ -31,7 +31,7 @@ import org.matsim.testcases.MatsimTestUtils; public class ReceiversReaderTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); /** * This is just a simplified version of {@link #testV2()} with the main diff --git a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversTest.java b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversTest.java index f06e6dbe79a..9a1a34dd34a 100644 --- a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversTest.java +++ b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.freightreceiver; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -19,8 +19,8 @@ */ public class ReceiversTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testSetupReceivers() { diff --git a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversWriterTest.java b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversWriterTest.java index 2020662eca9..aba05df627e 100644 --- a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversWriterTest.java +++ b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversWriterTest.java @@ -21,7 +21,7 @@ package org.matsim.contrib.freightreceiver; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.freightreceiver.run.chessboard.ReceiverChessboardScenario; @@ -33,7 +33,7 @@ public class ReceiversWriterTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testV1() { diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/EstimateRouterTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/EstimateRouterTest.java index 5e509b0a02a..0b192d3bb83 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/EstimateRouterTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/EstimateRouterTest.java @@ -2,7 +2,7 @@ import com.google.inject.Injector; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -24,8 +24,8 @@ public class EstimateRouterTest { private InformedModeChoiceConfigGroup group; private Controler controler; - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Before public void setUp() throws Exception { @@ -57,4 +57,4 @@ public void routing() { } -} \ No newline at end of file +} diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ScenarioTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ScenarioTest.java index d52365dc081..4e38c743ab9 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ScenarioTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ScenarioTest.java @@ -2,7 +2,7 @@ import com.google.inject.Injector; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.application.MATSimApplication; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -15,8 +15,8 @@ public class ScenarioTest { protected Controler controler; protected Injector injector; - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Before public void setUp() throws Exception { diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/TestScenario.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/TestScenario.java index 98798263fad..f62d2ec7277 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/TestScenario.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/TestScenario.java @@ -59,7 +59,7 @@ public TestScenario(@Nullable Config config) { /** * Load scenario config. - * @param utils needed to set correct output directory {@code @Rule public MatsimTestUtils utils = new MatsimTestUtils();} + * @param utils needed to set correct output directory {@code @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils();} */ public static Config loadConfig(MatsimTestUtils utils) { diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/commands/GenerateChoiceSetTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/commands/GenerateChoiceSetTest.java index b1b0a619110..f166bae8767 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/commands/GenerateChoiceSetTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/commands/GenerateChoiceSetTest.java @@ -1,6 +1,6 @@ package org.matsim.modechoice.commands; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; @@ -13,8 +13,8 @@ public class GenerateChoiceSetTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void command() throws URISyntaxException { diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/estimators/ComplexEstimatorTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/estimators/ComplexEstimatorTest.java index 5d3dd6a7a36..497e69a631c 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/estimators/ComplexEstimatorTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/estimators/ComplexEstimatorTest.java @@ -1,6 +1,6 @@ package org.matsim.modechoice.estimators; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.application.MATSimApplication; import org.matsim.core.config.Config; @@ -13,8 +13,8 @@ public class ComplexEstimatorTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void bindings() { diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java index e57a6413116..166a19d9aac 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java @@ -6,7 +6,7 @@ import org.assertj.core.api.InstanceOfAssertFactories; import org.assertj.core.data.Offset; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.junit.runner.RunWith; import org.matsim.api.core.v01.Coord; @@ -47,8 +47,8 @@ @RunWith(MockitoJUnitRunner.class) public class TopKMinMaxTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private TopKChoicesGenerator generator; private Injector injector; diff --git a/contribs/integration/src/test/java/org/matsim/integration/weekly/fundamentaldiagram/CreateAutomatedFDTest.java b/contribs/integration/src/test/java/org/matsim/integration/weekly/fundamentaldiagram/CreateAutomatedFDTest.java index 072ff3bac05..0a99e7e8054 100644 --- a/contribs/integration/src/test/java/org/matsim/integration/weekly/fundamentaldiagram/CreateAutomatedFDTest.java +++ b/contribs/integration/src/test/java/org/matsim/integration/weekly/fundamentaldiagram/CreateAutomatedFDTest.java @@ -43,7 +43,7 @@ import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -121,7 +121,7 @@ public static Collection createFds() { } } return Arrays.asList(combos2run); - + } @Test @@ -135,18 +135,18 @@ public void fdsCarBike(){ run(false); } - @Test + @Test public void fdsCarBikeFastCapacityUpdate(){ run(true); } - + @Test public void fdsCarOnly(){ this.travelModes = new String [] {"car"}; run(false); } - @Rule public MatsimTestUtils helper = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils helper = new MatsimTestUtils(); private String [] travelModes; public final Id flowDynamicsMeasurementLinkId = Id.createLinkId(0); @@ -170,14 +170,14 @@ private void run(final boolean isUsingFastCapacityUpdate) { config.qsim().setSeepModeStorageFree(false); config.qsim().setRestrictingSeepage(true); } - + config.vspExperimental().setVspDefaultsCheckingLevel( VspDefaultsCheckingLevel.abort ); config.qsim().setTrafficDynamics(trafficDynamics); config.qsim().setUsingFastCapacityUpdate(isUsingFastCapacityUpdate); - + // --- - + Scenario scenario = ScenarioUtils.loadScenario(config); createNetwork(scenario); @@ -185,17 +185,17 @@ private void run(final boolean isUsingFastCapacityUpdate) { double networkDensity = 3.*(1000./7.5); - + double sumOfPCUInEachStep = 0.; - + //equal modal split run for (String mode : travelModes) { sumOfPCUInEachStep += modeVehicleTypes.get(mode).getPcuEquivalents() * getMinNumberOfAgentAtStart(mode) ; }; - + int reduceNoOfDataPointsInPlot = 4; // 1--> will generate all possible data points; if( sumOfPCUInEachStep >=3 ) reduceNoOfDataPointsInPlot = 1 ; - + int numberOfPoints = (int) Math.ceil( networkDensity/ (reduceNoOfDataPointsInPlot * sumOfPCUInEachStep) ) + 5; List> points2Run = new ArrayList<>(); @@ -237,7 +237,7 @@ private void run(final boolean isUsingFastCapacityUpdate) { EventsManager events = EventsUtils.createEventsManager(); globalFlowDynamicsUpdator = new GlobalFlowDynamicsUpdator(mode2FlowData); events.addHandler(globalFlowDynamicsUpdator); - + final QSim qSim = new QSimBuilder(config) // .useDefaults() .configureQSimComponents( components -> { @@ -263,11 +263,11 @@ public void insertAgentsIntoMobsim() { final Vehicle vehicle = VehicleUtils.getFactory().createVehicle(Id.create(agent.getId(), Vehicle.class), travelModesTypes.get(travelMode)); final Id linkId4VehicleInsertion = Id.createLinkId("home"); - + // qSim.createAndParkVehicleOnLink(vehicle, linkId4VehicleInsertion); QVehicle qVehicle = new QVehicleImpl( vehicle ) ; // yyyyyy should use factory. kai, nov'18 qSim.addParkedVehicle( qVehicle, linkId4VehicleInsertion ); - + } } }; @@ -279,7 +279,7 @@ public void insertAgentsIntoMobsim() { Map> mode2FlowSpeed = new HashMap<>(); for(int i=0; i < travelModes.length; i++){ - Tuple flowSpeed = + Tuple flowSpeed = new Tuple<>(this.mode2FlowData.get(Id.create(travelModes[i],VehicleType.class)).getPermanentFlow(), this.mode2FlowData.get(Id.create(travelModes[i],VehicleType.class)).getPermanentAverageVelocity()); mode2FlowSpeed.put(travelModes[i], flowSpeed); @@ -290,8 +290,8 @@ public void insertAgentsIntoMobsim() { /* * Basically overriding the helper.getOutputDirectory() method, such that, * if file directory does not exists or same file already exists, remove and re-creates the whole dir hierarchy so that - * all existing files are re-written - * else, just keep adding files in the directory. + * all existing files are re-written + * else, just keep adding files in the directory. * This is necessary in order to allow writing different tests results from JUnit parameterization. */ @@ -309,7 +309,7 @@ public void insertAgentsIntoMobsim() { //plotting data scatterPlot(outData,outFile); } - + static int getMinNumberOfAgentAtStart(final String mode) {//equal modal split run // only three different modes (and pcus) are used in this test ie -- car(1), truck(3), bike(0.25) switch (mode) { @@ -320,7 +320,7 @@ static int getMinNumberOfAgentAtStart(final String mode) {//equal modal split ru default : throw new RuntimeException("The test is not designed for this "+ mode + "yet."); } } - + class MySimplifiedRoundAndRoundAgent implements MobsimAgent, MobsimDriverAgent { private final Id ORIGIN_LINK_ID = Id.createLinkId("home"); @@ -364,8 +364,8 @@ public Id getId() { @Override public Id chooseNextLinkId() { - if (globalFlowDynamicsUpdator.isPermanent()){ - isArriving = true; + if (globalFlowDynamicsUpdator.isPermanent()){ + isArriving = true; } if( ORIGIN_LINK_ID.equals(this.currentLinkId ) ){ @@ -544,7 +544,7 @@ private void scatterPlot (Map>> inputD XYSeries bikeFlow = null; XYSeries bikeSpeed = null; - + if(travelModes.length==2) { bikeFlow = new XYSeries(travelModes[1]+" flow"); bikeSpeed = new XYSeries(travelModes[1]+" speed"); @@ -553,7 +553,7 @@ private void scatterPlot (Map>> inputD for(double d :inputData.keySet()){ carFlow.add(d, inputData.get(d).get(mode1).getFirst()); carSpeed.add(d, inputData.get(d).get(mode1).getSecond()); - + if(travelModes.length == 2) { bikeFlow.add(d, inputData.get(d).get(travelModes[1]).getFirst()); bikeSpeed.add(d, inputData.get(d).get(travelModes[1]).getSecond()); @@ -573,14 +573,14 @@ private void scatterPlot (Map>> inputD // speed vs density XYSeriesCollection speedDataset = new XYSeriesCollection(); speedDataset.addSeries(carSpeed); - + if ( travelModes.length==2 ) { flowDataset.addSeries(bikeFlow); speedDataset.addSeries(bikeSpeed); } NumberAxis speedAxis = new NumberAxis("Speed (m/s)"); - speedAxis.setRange(0.0, 17.0); + speedAxis.setRange(0.0, 17.0); XYPlot plot2 = new XYPlot(speedDataset, null, speedAxis, new XYLineAndShapeRenderer(false,true)); plot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); @@ -791,7 +791,7 @@ private void saveDynamicVariables(){ this.permanentAverageVelocity = this.getActualAverageVelocity(); LOG.info("Calculated permanent Speed from "+modeId+"'s lastXSpeeds : "+speedTable+"\nResult is : "+this.permanentAverageVelocity); this.permanentFlow = this.getSlidingAverageLastXFlows900(); - LOG.info("Calculated permanent Flow from "+modeId+"'s lastXFlows900 : "+lastXFlows900+"\nResult is :"+this.permanentFlow); + LOG.info("Calculated permanent Flow from "+modeId+"'s lastXFlows900 : "+lastXFlows900+"\nResult is :"+this.permanentFlow); } //Getters/Setters @@ -869,7 +869,7 @@ class GlobalFlowDynamicsUpdator implements LinkEnterEventHandler { private boolean permanentRegime; /** - * container to store static properties of vehicles and dynamic flow properties during simulation + * container to store static properties of vehicles and dynamic flow properties during simulation */ public GlobalFlowDynamicsUpdator(Map, TravelModesFlowDynamicsUpdator> travelModeFlowDataContainer){ this.travelModesFlowData = travelModeFlowDataContainer; @@ -883,7 +883,7 @@ public GlobalFlowDynamicsUpdator(Map, TravelModesFlowDynamicsUpd } @Override - public void reset(int iteration) { + public void reset(int iteration) { for (Id vehTyp : this.travelModesFlowData .keySet()){ this.travelModesFlowData.get(vehTyp).reset(); } @@ -905,16 +905,16 @@ public void handleEvent(LinkEnterEvent event) { //Aggregated data update double nowTime = event.getTime(); - if (event.getLinkId().equals(flowDynamicsMeasurementLinkId)){ + if (event.getLinkId().equals(flowDynamicsMeasurementLinkId)){ this.globalFlowData.updateFlow900(nowTime, pcuVeh); this.globalFlowData.updateSpeedTable(nowTime, event.getVehicleId()); //Waiting for all agents to be on the track before studying stability if ((this.globalFlowData.getNumberOfDrivingAgents() == this.globalFlowData.numberOfAgents) && (nowTime>1800)){ //TODO parametrize this correctly /*//Taking speed check out, as it is not reliable on the global speed table - * Maybe making a list of moving averages could be smart, + * Maybe making a list of moving averages could be smart, * but there is no reliable converging process even in that case. (ssix, 25.10.13) * if (!(this.globalData.isSpeedStable())){ - this.globalData.checkSpeedStability(); + this.globalData.checkSpeedStability(); System.out.println("Checking speed stability in global data for: "+this.globalData.getSpeedTable()); }*/ if (!(this.globalFlowData.isFlowStable())){ @@ -928,7 +928,7 @@ public void handleEvent(LinkEnterEvent event) { if (! this.travelModesFlowData.get(vehTyp).isSpeedStable() || !(this.travelModesFlowData.get(vehTyp).isFlowStable())) { modesStable = false; break; - } + } } } if (modesStable){ diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/BestReplyLocationChoicePlanStrategyTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/BestReplyLocationChoicePlanStrategyTest.java index 2309a1e4dbc..a22dd55b20a 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/BestReplyLocationChoicePlanStrategyTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/BestReplyLocationChoicePlanStrategyTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.locationchoice; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -37,8 +37,8 @@ public class BestReplyLocationChoicePlanStrategyTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testOne() { diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java index 82fbd9e7a0e..3ef0156f7dc 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java @@ -24,7 +24,7 @@ import jakarta.inject.Provider; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -73,8 +73,8 @@ public class LocationChoiceIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyIT.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyIT.java index 133a45fc886..e76efbcf390 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyIT.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyIT.java @@ -1,6 +1,6 @@ package org.matsim.contrib.locationchoice.frozenepsilons; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; @@ -14,8 +14,8 @@ public class BestReplyIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testRunControler() { diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java index 08af97c8a0c..a09f75758c9 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java @@ -15,7 +15,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -72,7 +72,7 @@ public class FrozenEpsilonLocaChoiceIT{ private static final Logger log = LogManager.getLogger( FrozenEpsilonLocaChoiceIT.class ) ; - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; /** * This one is, I think, testing the frozen epsilon location choice. kai, mar'19 diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/SamplerTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/SamplerTest.java index d969373ed86..eee860fb1a1 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/SamplerTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/SamplerTest.java @@ -23,7 +23,7 @@ package org.matsim.contrib.locationchoice.frozenepsilons; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -38,8 +38,8 @@ public class SamplerTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); private DestinationChoiceContext context; private Scenario scenario; diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/LocationMutatorwChoiceSetTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/LocationMutatorwChoiceSetTest.java index 7251ae4e31a..960cca8b706 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/LocationMutatorwChoiceSetTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/LocationMutatorwChoiceSetTest.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Random; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -37,8 +37,8 @@ public class LocationMutatorwChoiceSetTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private MutableScenario scenario; diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/ManageSubchainsTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/ManageSubchainsTest.java index 85d1a30def9..d1c4aa34efc 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/ManageSubchainsTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/ManageSubchainsTest.java @@ -21,7 +21,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Activity; @@ -34,8 +34,8 @@ public class ManageSubchainsTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testPrimarySecondaryActivityFound() { diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/RandomLocationMutatorTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/RandomLocationMutatorTest.java index 47846eaf550..351ca1c1da1 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/RandomLocationMutatorTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/RandomLocationMutatorTest.java @@ -21,7 +21,7 @@ import java.util.Random; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -32,8 +32,8 @@ public class RandomLocationMutatorTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private MutableScenario scenario; diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/SubChainTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/SubChainTest.java index 9b22f6f9e7d..16fccf1abd0 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/SubChainTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/SubChainTest.java @@ -2,14 +2,14 @@ import static org.junit.Assert.assertNotNull; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; public class SubChainTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testConstructorandGetSlActs() { diff --git a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java index 2e10edddfa8..b8529245eff 100644 --- a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java +++ b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java @@ -22,11 +22,13 @@ */ package org.matsim.contrib.matrixbasedptrouter; +import java.io.File; import java.io.IOException; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; +import org.junit.jupiter.api.io.TempDir; import org.junit.rules.TemporaryFolder; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Scenario; @@ -51,10 +53,10 @@ * */ public class MatrixBasedPtRouterIT { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Rule - public TemporaryFolder folder = new TemporaryFolder(); + @TempDir + public File folder; /** * This method tests the travel time computation with pseudo pt. @@ -79,8 +81,8 @@ public void testIntegration() throws IOException { new PopulationWriter(population, network).write(path+"plans.xml"); //dummy csv files for pt stops, travel times and travel distances fitting into the dummy network are created - String stopsLocation = CreateTestNetwork.createTestPtStationCSVFile(folder.newFile("ptStops.csv")); - String timesLocation = CreateTestNetwork.createTestPtTravelTimesAndDistancesCSVFile(folder.newFile("ptTravelInfo.csv")); + String stopsLocation = CreateTestNetwork.createTestPtStationCSVFile( new File(folder, "ptStops.csv")); + String timesLocation = CreateTestNetwork.createTestPtTravelTimesAndDistancesCSVFile(new File(folder, "ptTravelInfo.csv")); //add stops, travel times and travel distances file to the pseudo pt config group final MatrixBasedPtRouterConfigGroup matrixBasedPtRouterConfigGroup = new MatrixBasedPtRouterConfigGroup(); diff --git a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java index 0b029d1f749..9296f93e9ef 100644 --- a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java +++ b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java @@ -22,6 +22,7 @@ */ package org.matsim.contrib.matrixbasedptrouter; +import java.io.File; import java.io.IOException; import java.util.List; @@ -30,8 +31,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; +import org.junit.jupiter.api.io.TempDir; import org.junit.rules.TemporaryFolder; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.TransportMode; @@ -72,8 +74,8 @@ public class PtMatrixTest { private static final Logger log = LogManager.getLogger(PtMatrixTest.class); - @Rule - public TemporaryFolder folder = new TemporaryFolder(); + @TempDir + public File folder; @Before public void setUp() throws Exception { @@ -103,7 +105,7 @@ public void testPtMatrixStops() throws IOException{ config.routing().setTeleportedModeSpeed(TransportMode.pt, defaultPtSpeed ) ; Network network = CreateTestNetwork.createTestNetwork(); // creates a dummy network - String location = CreateTestNetwork.createTestPtStationCSVFile(folder.newFile("ptStops.csv")); // creates a dummy csv file with pt stops fitting into the dummy network + String location = CreateTestNetwork.createTestPtStationCSVFile(new File(folder, "ptStops.csv")); // creates a dummy csv file with pt stops fitting into the dummy network MatrixBasedPtRouterConfigGroup module = new MatrixBasedPtRouterConfigGroup(); module.setPtStopsInputFile(location); // this is to be compatible with real code @@ -207,8 +209,8 @@ public void testPtMatrixTimesAndDistances() throws IOException{ Network network = CreateTestNetwork.createTestNetwork(); // creates a dummy network - String stopsLocation = CreateTestNetwork.createTestPtStationCSVFile(folder.newFile("ptStops.csv")); // creates a dummy csv file with pt stops fitting into the dummy network - String timesLocation = CreateTestNetwork.createTestPtTravelTimesAndDistancesCSVFile(folder.newFile("ptTravelInfo.csv")); // creates a dummy csv file with pt travel times fitting into the dummy network + String stopsLocation = CreateTestNetwork.createTestPtStationCSVFile(new File(folder, "ptStops.csv")); // creates a dummy csv file with pt stops fitting into the dummy network + String timesLocation = CreateTestNetwork.createTestPtTravelTimesAndDistancesCSVFile(new File(folder, "ptTravelInfo.csv")); // creates a dummy csv file with pt travel times fitting into the dummy network MatrixBasedPtRouterConfigGroup module = new MatrixBasedPtRouterConfigGroup(); module.setUsingPtStops(true); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/PControlerTestIT.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/PControlerTestIT.java index 3429d672745..7ea50ed1e8e 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/PControlerTestIT.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/PControlerTestIT.java @@ -25,7 +25,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.minibus.PConfigGroup; @@ -47,7 +47,7 @@ */ public class PControlerTestIT implements TabularFileHandler{ - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); private final ArrayList pStatsResults = new ArrayList<>(); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java index f9881ed715e..3c22dcac81e 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java @@ -26,7 +26,7 @@ import org.junit.Assert; import org.junit.Ignore; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.minibus.PConfigGroup; @@ -51,7 +51,7 @@ public class SubsidyContextTestIT implements TabularFileHandler { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); private final ArrayList pStatsResults = new ArrayList<>(); private String gridScenarioDirectory ="../../example-scenario/input/"; diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyTestIT.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyTestIT.java index 5b84b9f964c..33af461049a 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyTestIT.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyTestIT.java @@ -25,7 +25,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.minibus.PConfigGroup; @@ -49,7 +49,7 @@ public class SubsidyTestIT implements TabularFileHandler { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); private final ArrayList pStatsResults = new ArrayList<>(); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/EndRouteExtensionTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/EndRouteExtensionTest.java index a6e905e1f55..d2a097f60bf 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/EndRouteExtensionTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/EndRouteExtensionTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.minibus.replanning; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.contrib.minibus.PConstants; import org.matsim.contrib.minibus.hook.Operator; @@ -33,160 +33,160 @@ public class EndRouteExtensionTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + @Test public final void testRun() { - + Operator coop = PScenarioHelper.createCoop2111to2333(); - + new File(utils.getOutputDirectory() + PConstants.statsOutputFolder).mkdir(); ArrayList parameter = new ArrayList<>(); parameter.add("1000.0"); parameter.add("0.0"); - + EndRouteExtension strat = new EndRouteExtension(parameter); - + PPlan testPlan = null; - + Assert.assertEquals("Compare number of vehicles", 1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start stop", "p_2111", coop.getBestPlan().getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare end stop", "p_2333", coop.getBestPlan().getStopsToBeServed().get(1).getId().toString()); Assert.assertNull("Test plan should be null", testPlan); - + // buffer too small testPlan = strat.run(coop); - + Assert.assertNull("Test plan should be null", testPlan); - + parameter = new ArrayList<>(); parameter.add("1000.0"); parameter.add("0.5"); - + strat = new EndRouteExtension(parameter); - + testPlan = strat.run(coop); - + Assert.assertNotNull("Test plan should not be null", testPlan); - + Assert.assertEquals("Compare start stop", "p_2111", testPlan.getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare start stop", "p_2333", testPlan.getStopsToBeServed().get(1).getId().toString()); Assert.assertEquals("Compare end stop", "p_3343", testPlan.getStopsToBeServed().get(2).getId().toString()); - - + + parameter = new ArrayList<>(); parameter.add("2000.0"); parameter.add("0.5"); - + strat = new EndRouteExtension(parameter); - + testPlan = strat.run(coop); - + Assert.assertNotNull("Test plan should not be null", testPlan); Assert.assertEquals("Compare start stop", "p_2111", testPlan.getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare start stop", "p_2333", testPlan.getStopsToBeServed().get(1).getId().toString()); Assert.assertEquals("Compare end stop", "p_3334", testPlan.getStopsToBeServed().get(2).getId().toString()); - + coop.getBestPlan().setStopsToBeServed(testPlan.getStopsToBeServed()); - + testPlan = strat.run(coop); - + // remaining stops are covered now by the buffer of the otherwise wiggly route Assert.assertNull("Test plan should be null", testPlan); } - + @Test public final void testRunVShapedRoute() { - + Operator coop = PScenarioHelper.createCoopRouteVShaped(); - + new File(utils.getOutputDirectory() + PConstants.statsOutputFolder).mkdir(); ArrayList parameter = new ArrayList<>(); parameter.add("1000.0"); parameter.add("0.0"); - + EndRouteExtension strat = new EndRouteExtension(parameter); - + PPlan testPlan = null; - + Assert.assertEquals("Compare number of vehicles", 1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start stop", "p_2111", coop.getBestPlan().getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare middle stop", "p_3141", coop.getBestPlan().getStopsToBeServed().get(1).getId().toString()); Assert.assertEquals("Compare end stop", "p_3222", coop.getBestPlan().getStopsToBeServed().get(2).getId().toString()); Assert.assertEquals("Compare middle stop", "p_3141", coop.getBestPlan().getStopsToBeServed().get(3).getId().toString()); Assert.assertNull("Test plan should be null", testPlan); - + // buffer too small testPlan = strat.run(coop); - + Assert.assertNull("Test plan should be null", testPlan); - + parameter = new ArrayList<>(); parameter.add("1000.0"); parameter.add("0.8"); parameter.add("true"); parameter.add("false"); - + strat = new EndRouteExtension(parameter); - + testPlan = strat.run(coop); - + Assert.assertNotNull("Test plan should not be null", testPlan); - + Assert.assertEquals("Compare start stop", "p_2111", testPlan.getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare most distant stop in between", "p_3141", testPlan.getStopsToBeServed().get(1).getId().toString()); Assert.assertEquals("Compare former end stop", "p_3222", testPlan.getStopsToBeServed().get(2).getId().toString()); Assert.assertEquals("Compare new end stop", "p_2223", testPlan.getStopsToBeServed().get(3).getId().toString()); Assert.assertEquals("Compare most distant stop in between", "p_3141", testPlan.getStopsToBeServed().get(4).getId().toString()); - + parameter = new ArrayList<>(); parameter.add("1000.0"); parameter.add("0.8"); parameter.add("true"); parameter.add("false"); - + strat = new EndRouteExtension(parameter); - + testPlan = strat.run(coop); - + Assert.assertNotNull("Test plan should not be null", testPlan); Assert.assertEquals("Compare start stop", "p_2111", testPlan.getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare most distant stop in between", "p_3141", testPlan.getStopsToBeServed().get(1).getId().toString()); Assert.assertEquals("Compare former end stop", "p_3222", testPlan.getStopsToBeServed().get(2).getId().toString()); Assert.assertEquals("Compare new end stop", "p_1323", testPlan.getStopsToBeServed().get(3).getId().toString()); Assert.assertEquals("Compare most distant stop in between", "p_3141", testPlan.getStopsToBeServed().get(4).getId().toString()); - + parameter = new ArrayList<>(); parameter.add("1500.0"); parameter.add("0.8"); parameter.add("true"); parameter.add("false"); - + strat = new EndRouteExtension(parameter); - + testPlan = strat.run(coop); - + Assert.assertNotNull("Test plan should not be null", testPlan); Assert.assertEquals("Compare start stop", "p_2111", testPlan.getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare most distant stop in between", "p_3141", testPlan.getStopsToBeServed().get(1).getId().toString()); Assert.assertEquals("Compare former end stop", "p_3222", testPlan.getStopsToBeServed().get(2).getId().toString()); Assert.assertEquals("Compare new end stop", "p_1413", testPlan.getStopsToBeServed().get(3).getId().toString()); Assert.assertEquals("Compare most distant stop in between", "p_3141", testPlan.getStopsToBeServed().get(4).getId().toString()); - + coop.getBestPlan().setStopsToBeServed(testPlan.getStopsToBeServed()); coop.getBestPlan().setLine(testPlan.getLine()); - + testPlan = strat.run(coop); - + // Adds stop 2414 Assert.assertEquals("Compare new end stop", "p_2414", testPlan.getStopsToBeServed().get(4).getId().toString()); - + coop.getBestPlan().setStopsToBeServed(testPlan.getStopsToBeServed()); coop.getBestPlan().setLine(testPlan.getLine()); testPlan = strat.run(coop); - + // remaining stops are covered now by the buffer of the otherwise wiggly route Assert.assertNull("Test plan should be null", testPlan); } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomEndTimeAllocatorTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomEndTimeAllocatorTest.java index a1e7e34f096..af6b404c1a2 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomEndTimeAllocatorTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomEndTimeAllocatorTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.minibus.replanning; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.contrib.minibus.hook.Operator; import org.matsim.contrib.minibus.hook.PPlan; @@ -31,11 +31,11 @@ public class MaxRandomEndTimeAllocatorTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + @Test public final void testRun() { - + Operator coop = PScenarioHelper.createTestCooperative(utils.getOutputDirectory()); ArrayList param = new ArrayList<>(); param.add("0"); @@ -43,33 +43,33 @@ public final void testRun() { param.add("false"); MaxRandomEndTimeAllocator strat = new MaxRandomEndTimeAllocator(param); PPlan testPlan = null; - + coop.getBestPlan().setEndTime(40000.0); Assert.assertEquals("Compare number of vehicles", 1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare end time", 40000.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON); Assert.assertNull("Test plan should be null", testPlan); - + coop.getBestPlan().setNVehicles(2); - + // enough vehicles for testing, but mutation range 0 testPlan = strat.run(coop); - + Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare end time", 40000.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON); Assert.assertNotNull("Test plan should be not null", testPlan); Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare end time", 40000.0, testPlan.getEndTime(), MatsimTestUtils.EPSILON); - + param = new ArrayList<>(); param.add("900"); param.add("10"); param.add("false"); strat = new MaxRandomEndTimeAllocator(param); - + // enough vehicles for testing testPlan = strat.run(coop); - + Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 40000.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON); Assert.assertNotNull("Test plan should be not null", testPlan); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomStartTimeAllocatorTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomStartTimeAllocatorTest.java index f3c4827ab06..d3086cf9ced 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomStartTimeAllocatorTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomStartTimeAllocatorTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.minibus.replanning; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.contrib.minibus.hook.Operator; import org.matsim.contrib.minibus.hook.PPlan; @@ -31,11 +31,11 @@ public class MaxRandomStartTimeAllocatorTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + @Test public final void testRun() { - + Operator coop = PScenarioHelper.createTestCooperative(utils.getOutputDirectory()); ArrayList param = new ArrayList<>(); param.add("0"); @@ -43,34 +43,34 @@ public final void testRun() { param.add("false"); MaxRandomStartTimeAllocator strat = new MaxRandomStartTimeAllocator(param); PPlan testPlan = null; - + coop.getBestPlan().setStartTime(12000.0); coop.getBestPlan().setEndTime(36000.0); Assert.assertEquals("Compare number of vehicles", 1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 12000.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON); Assert.assertNull("Test plan should be null", testPlan); - + coop.getBestPlan().setNVehicles(2); - + // run strategy - time mutation is zero, thus no change testPlan = strat.run(coop); - + Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 12000.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON); Assert.assertNotNull("Test plan should be not null", testPlan); Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 12000.0, testPlan.getStartTime(), MatsimTestUtils.EPSILON); - + param = new ArrayList<>(); param.add("900"); param.add("10"); param.add("false"); strat = new MaxRandomStartTimeAllocator(param); - + // enough vehicles for testing testPlan = strat.run(coop); - + Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 12000.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON); Assert.assertNotNull("Test plan should be not null", testPlan); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/SidewaysRouteExtensionTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/SidewaysRouteExtensionTest.java index cf21adf8319..615ef2f3412 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/SidewaysRouteExtensionTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/SidewaysRouteExtensionTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.minibus.replanning; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.contrib.minibus.PConstants; import org.matsim.contrib.minibus.hook.Operator; @@ -44,73 +44,73 @@ * -mrieser/2019Sept30 */ public class SidewaysRouteExtensionTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + @Test public final void testRun() { - + Operator coop = PScenarioHelper.createCoop2414to3444(); - + new File(utils.getOutputDirectory() + PConstants.statsOutputFolder).mkdir(); ArrayList parameter = new ArrayList<>(); parameter.add("0.0"); parameter.add("0.0"); parameter.add("true"); - + SidewaysRouteExtension strat = new SidewaysRouteExtension(parameter); - + PPlan testPlan = null; - + Assert.assertEquals("Compare number of vehicles", 1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start stop", "p_2414", coop.getBestPlan().getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare end stop", "p_3444", coop.getBestPlan().getStopsToBeServed().get(1).getId().toString()); Assert.assertNull("Test plan should be null", testPlan); - + // buffer too small testPlan = strat.run(coop); - + Assert.assertNull("Test plan should be null", testPlan); - + parameter = new ArrayList<>(); parameter.add("100.0"); parameter.add("0.0"); parameter.add("true"); - + strat = new SidewaysRouteExtension(parameter); - + testPlan = strat.run(coop); - + // enough buffer to add a stop located directly at the beeline Assert.assertNotNull("Test plan should not be null", testPlan); - + Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare start stop", "p_2324", testPlan.getStopsToBeServed().get(1).getId().toString()); Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); Assert.assertEquals("Compare end stop", "p_2324", testPlan.getStopsToBeServed().get(3).getId().toString()); - - + + parameter = new ArrayList<>(); parameter.add("100.0"); parameter.add("0.5"); parameter.add("true"); - + strat = new SidewaysRouteExtension(parameter); - + testPlan = strat.run(coop); - - // enough buffer 0.5 * 3000m = 1500m + + // enough buffer 0.5 * 3000m = 1500m Assert.assertNotNull("Test plan should not be null", testPlan); Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare start stop", "p_2223", testPlan.getStopsToBeServed().get(1).getId().toString()); Assert.assertEquals("Compare start stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); Assert.assertEquals("Compare end stop", "p_2223", testPlan.getStopsToBeServed().get(3).getId().toString()); - + coop.getBestPlan().setStopsToBeServed(testPlan.getStopsToBeServed()); coop.getBestPlan().setLine(coop.getRouteProvider().createTransitLineFromOperatorPlan(coop.getId(), testPlan)); - + testPlan = strat.run(coop); - + // and again stacking - therefore, enlarging the effective buffer Assert.assertNotNull("Test plan should not be null", testPlan); Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); @@ -119,106 +119,106 @@ public final void testRun() { Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(3).getId().toString()); Assert.assertEquals("Compare start stop", "p_2212", testPlan.getStopsToBeServed().get(4).getId().toString()); Assert.assertEquals("Compare end stop", "p_2223", testPlan.getStopsToBeServed().get(5).getId().toString()); - + parameter = new ArrayList<>(); parameter.add("4000.0"); parameter.add("0.5"); parameter.add("true"); - + strat = new SidewaysRouteExtension(parameter); coop = PScenarioHelper.createCoop2414to3444(); - + testPlan = strat.run(coop); - + // quite a lot buffer covering all nodes Assert.assertNotNull("Test plan should not be null", testPlan); Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare start stop", "p_2324", testPlan.getStopsToBeServed().get(1).getId().toString()); Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); Assert.assertEquals("Compare end stop", "p_2324", testPlan.getStopsToBeServed().get(3).getId().toString()); - + testPlan = strat.run(coop); - + // quite a lot buffer covering all nodes Assert.assertNotNull("Test plan should not be null", testPlan); Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare start stop", "p_2223", testPlan.getStopsToBeServed().get(1).getId().toString()); Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); Assert.assertEquals("Compare end stop", "p_2223", testPlan.getStopsToBeServed().get(3).getId().toString()); - + testPlan = strat.run(coop); - + // quite a lot buffer covering all nodes Assert.assertNotNull("Test plan should not be null", testPlan); Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare start stop", "p_2223", testPlan.getStopsToBeServed().get(1).getId().toString()); Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); Assert.assertEquals("Compare end stop", "p_2223", testPlan.getStopsToBeServed().get(3).getId().toString()); - + testPlan = strat.run(coop); - + // quite a lot buffer covering all nodes Assert.assertNotNull("Test plan should not be null", testPlan); Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare start stop", "p_3323", testPlan.getStopsToBeServed().get(1).getId().toString()); Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); Assert.assertEquals("Compare end stop", "p_3323", testPlan.getStopsToBeServed().get(3).getId().toString()); - + testPlan = strat.run(coop); - + // quite a lot buffer covering all nodes Assert.assertNotNull("Test plan should not be null", testPlan); Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare start stop", "p_3433", testPlan.getStopsToBeServed().get(1).getId().toString()); Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); Assert.assertEquals("Compare end stop", "p_3433", testPlan.getStopsToBeServed().get(3).getId().toString()); - + testPlan = strat.run(coop); - + // quite a lot buffer covering all nodes Assert.assertNotNull("Test plan should not be null", testPlan); Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare start stop", "p_2423", testPlan.getStopsToBeServed().get(1).getId().toString()); Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); Assert.assertEquals("Compare end stop", "p_2423", testPlan.getStopsToBeServed().get(3).getId().toString()); - + testPlan = strat.run(coop); - + // quite a lot buffer covering all nodes Assert.assertNotNull("Test plan should not be null", testPlan); Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare start stop", "p_2322", testPlan.getStopsToBeServed().get(1).getId().toString()); Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); Assert.assertEquals("Compare end stop", "p_2322", testPlan.getStopsToBeServed().get(3).getId().toString()); - + testPlan = strat.run(coop); - + // quite a lot buffer covering all nodes Assert.assertNotNull("Test plan should not be null", testPlan); Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare start stop", "p_2221", testPlan.getStopsToBeServed().get(1).getId().toString()); Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); Assert.assertEquals("Compare end stop", "p_2221", testPlan.getStopsToBeServed().get(3).getId().toString()); - + parameter = new ArrayList<>(); parameter.add("100.0"); parameter.add("0.0"); parameter.add("false"); - + strat = new SidewaysRouteExtension(parameter); coop = PScenarioHelper.createCoop2414to3444(); - + testPlan = strat.run(coop); - + // can now choose among stops at the outer edges Assert.assertNotNull("Test plan should not be null", testPlan); Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); Assert.assertEquals("Compare start stop", "p_2324", testPlan.getStopsToBeServed().get(1).getId().toString()); Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); Assert.assertEquals("Compare end stop", "p_2324", testPlan.getStopsToBeServed().get(3).getId().toString()); - + testPlan = strat.run(coop); - + // can now choose among stops at the outer edges Assert.assertNotNull("Test plan should not be null", testPlan); Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/TimeProviderTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/TimeProviderTest.java index 7284273616f..61744081b5d 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/TimeProviderTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/TimeProviderTest.java @@ -22,7 +22,7 @@ import java.io.File; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; @@ -36,66 +36,66 @@ public class TimeProviderTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + @Test public final void testGetRandomTimeInIntervalOneTimeSlot() { - + new File(utils.getOutputDirectory() + PConstants.statsOutputFolder).mkdir(); - + PConfigGroup pConfig = new PConfigGroup(); pConfig.addParam("timeSlotSize", "99999999"); - + TimeProvider tP = new TimeProvider(pConfig, utils.getOutputDirectory()); tP.reset(0); - + double startTime = 3600.0; double endTime = startTime; - + Assert.assertEquals("New time (There is only one slot, thus time is zero)", 0.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON); } - + @Test public final void testGetRandomTimeInIntervalOneSameStartEndTime() { - + new File(utils.getOutputDirectory() + PConstants.statsOutputFolder).mkdir(); - + PConfigGroup pConfig = new PConfigGroup(); pConfig.addParam("timeSlotSize", "900"); - + TimeProvider tP = new TimeProvider(pConfig, utils.getOutputDirectory()); tP.reset(0); - + double startTime = 3600.0; double endTime = startTime; - + Assert.assertEquals("Same start and end time. Should return start time", 3600.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON); } - + @Test public final void testGetRandomTimeInIntervalDifferentStartEndTime() { - + new File(utils.getOutputDirectory() + PConstants.statsOutputFolder).mkdir(); - + PConfigGroup pConfig = new PConfigGroup(); pConfig.addParam("timeSlotSize", "900"); - + TimeProvider tP = new TimeProvider(pConfig, utils.getOutputDirectory()); tP.reset(0); - + double startTime = 7500.0; double endTime = 19400.0; - + Assert.assertEquals("Check time", 7200.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON); Assert.assertEquals("Check time", 11700.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON); - + Id agentId = Id.create("id", Person.class); Id linkId = Id.create("id", Link.class); Id facilityId = Id.create("id", ActivityFacility.class); for (int i = 0; i < 100; i++) { tP.handleEvent(new ActivityEndEvent(500.0 * i, agentId, linkId, facilityId, "type")); } - + Assert.assertEquals("Check time", 9000.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON); Assert.assertEquals("Check time", 10800.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedEndTimeExtensionTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedEndTimeExtensionTest.java index 922bd2073a0..ba4fb39e8d8 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedEndTimeExtensionTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedEndTimeExtensionTest.java @@ -23,7 +23,7 @@ import java.util.ArrayList; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; @@ -40,52 +40,52 @@ public class WeightedEndTimeExtensionTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + @Test public final void testRun() { - + Operator coop = PScenarioHelper.createTestCooperative(utils.getOutputDirectory()); - + new File(utils.getOutputDirectory() + PConstants.statsOutputFolder).mkdir(); - + PConfigGroup pConfig = new PConfigGroup(); pConfig.addParam("timeSlotSize", "900"); - + TimeProvider tP = new TimeProvider(pConfig, utils.getOutputDirectory()); tP.reset(0); - + WeightedEndTimeExtension strat = new WeightedEndTimeExtension(new ArrayList()); strat.setTimeProvider(tP); - + PPlan testPlan = null; - + coop.getBestPlan().setEndTime(19500.0); Assert.assertEquals("Compare number of vehicles", 1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON); Assert.assertNull("Test plan should be null", testPlan); - + coop.getBestPlan().setNVehicles(2); - + // enough vehicles for testing testPlan = strat.run(coop); - + Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON); Assert.assertNotNull("Test plan should be not null", testPlan); Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 50400.0, testPlan.getEndTime(), MatsimTestUtils.EPSILON); - + // enough vehicles for testing testPlan = strat.run(coop); - + Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON); Assert.assertNotNull("Test plan should be not null", testPlan); Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 24300.0, testPlan.getEndTime(), MatsimTestUtils.EPSILON); - + // Now same with acts Id agentId = Id.create("id", Person.class); Id linkId = Id.create("id", Link.class); @@ -94,18 +94,18 @@ public final void testRun() { for (int i = 0; i < 100; i++) { tP.handleEvent(new ActivityEndEvent(36600.0, agentId, linkId, facilityId, "type")); } - + testPlan = strat.run(coop); - + Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON); Assert.assertNotNull("Test plan should be not null", testPlan); Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 36000.0, testPlan.getEndTime(), MatsimTestUtils.EPSILON); - + tP.reset(1); testPlan = strat.run(coop); - + Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON); Assert.assertNotNull("Test plan should be not null", testPlan); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedStartTimeExtensionTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedStartTimeExtensionTest.java index 104413f6dd7..8c2dd102cd7 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedStartTimeExtensionTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedStartTimeExtensionTest.java @@ -23,7 +23,7 @@ import java.util.ArrayList; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; @@ -40,52 +40,52 @@ public class WeightedStartTimeExtensionTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + @Test public final void testRun() { - + Operator coop = PScenarioHelper.createTestCooperative(utils.getOutputDirectory()); - + new File(utils.getOutputDirectory() + PConstants.statsOutputFolder).mkdir(); - + PConfigGroup pConfig = new PConfigGroup(); pConfig.addParam("timeSlotSize", "900"); - + TimeProvider tP = new TimeProvider(pConfig, utils.getOutputDirectory()); tP.reset(0); - + WeightedStartTimeExtension strat = new WeightedStartTimeExtension(new ArrayList()); strat.setTimeProvider(tP); - + PPlan testPlan = null; - + coop.getBestPlan().setStartTime(19500.0); Assert.assertEquals("Compare number of vehicles", 1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON); Assert.assertNull("Test plan should be null", testPlan); - + coop.getBestPlan().setNVehicles(2); - + // enough vehicles for testing testPlan = strat.run(coop); - + Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON); Assert.assertNotNull("Test plan should be not null", testPlan); Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 9000.0, testPlan.getStartTime(), MatsimTestUtils.EPSILON); - + // enough vehicles for testing testPlan = strat.run(coop); - + Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON); Assert.assertNotNull("Test plan should be not null", testPlan); Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 900.0, testPlan.getStartTime(), MatsimTestUtils.EPSILON); - + // Now same with acts Id agentId = Id.create("id", Person.class); Id linkId = Id.create("id", Link.class); @@ -94,18 +94,18 @@ public final void testRun() { for (int i = 0; i < 100; i++) { tP.handleEvent(new ActivityEndEvent(9600.0, agentId, linkId, facilityId, "type")); } - + testPlan = strat.run(coop); - + Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON); Assert.assertNotNull("Test plan should be not null", testPlan); Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 9000.0, testPlan.getStartTime(), MatsimTestUtils.EPSILON); - + tP.reset(1); testPlan = strat.run(coop); - + Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON); Assert.assertNotNull("Test plan should be not null", testPlan); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/ComplexCircleScheduleProviderTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/ComplexCircleScheduleProviderTest.java index e7f462d4211..70a363892ed 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/ComplexCircleScheduleProviderTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/ComplexCircleScheduleProviderTest.java @@ -22,7 +22,7 @@ import java.util.ArrayList; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -41,23 +41,23 @@ import org.matsim.testcases.MatsimTestUtils; public class ComplexCircleScheduleProviderTest { - -@Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + +@RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + @Test public final void testCreateTransitLineLikeSimpleCircleScheduleProvider() { - + Scenario scenario = PScenarioHelper.createTestNetwork(); PConfigGroup pC = new PConfigGroup(); - - + + TransitSchedule tS = CreateStopsForAllCarLinks.createStopsForAllCarLinks(scenario.getNetwork(), pC); - + ComplexCircleScheduleProvider prov = new ComplexCircleScheduleProvider(tS, scenario.getNetwork(), null, pC.getVehicleMaximumVelocity(), pC.getPlanningSpeedFactor(), pC.getDriverRestTime(), pC.getMode()); - + Id lineId = Id.create("line1", Operator.class); Id routeId = Id.create("route1", PPlan.class); - + PPlan plan = new PPlan(routeId, "noCreator", PConstants.founderPlanId); plan.setStartTime(7.0 * 3600.0); plan.setEndTime(9.0 * 3600.0); @@ -68,55 +68,55 @@ public final void testCreateTransitLineLikeSimpleCircleScheduleProvider() { stopsToBeServed.add(startStop); stopsToBeServed.add(endStop); plan.setStopsToBeServed(stopsToBeServed); - + ArrayList> refIds = new ArrayList<>(); refIds.add(Id.create("1424", Link.class)); refIds.add(Id.create("2434", Link.class)); refIds.add(Id.create("3444", Link.class)); refIds.add(Id.create("4434", Link.class)); refIds.add(Id.create("3424", Link.class)); refIds.add(Id.create("2414", Link.class)); refIds.add(Id.create("1424", Link.class)); - + TransitLine line = prov.createTransitLineFromOperatorPlan(lineId, plan); - + Assert.assertEquals("Transit line ids have to be the same", Id.create(lineId, TransitLine.class), line.getId()); - + for (TransitRoute route : line.getRoutes().values()) { Assert.assertEquals("Route id have to be the same", Id.create(lineId + "-" + routeId, TransitRoute.class), route.getId()); Assert.assertEquals("Number of departures", 14.0, route.getDepartures().size(), MatsimTestUtils.EPSILON); - - // check links + + // check links Assert.assertEquals("Start link id has to be the same", refIds.get(0), route.getRoute().getStartLinkId()); - + int i = 1; for (Id linkId : route.getRoute().getLinkIds()) { Assert.assertEquals("Route link ids have to be the same", refIds.get(i), linkId); i++; } - + Assert.assertEquals("End link id has to be the same", refIds.get(refIds.size() - 1), route.getRoute().getEndLinkId()); - + // check stops i = 0; for (TransitRouteStop stop : route.getStops()) { Assert.assertEquals("Route stop ids have to be the same", Id.create(pC.getPIdentifier() + refIds.get(i), TransitStopFacility.class), stop.getStopFacility().getId()); i++; - } - } + } + } } - + @Test public final void testCreateTransitLineWithMoreStops() { - + Scenario scenario = PScenarioHelper.createTestNetwork(); PConfigGroup pC = new PConfigGroup(); - - + + TransitSchedule tS = CreateStopsForAllCarLinks.createStopsForAllCarLinks(scenario.getNetwork(), pC); - + ComplexCircleScheduleProvider prov = new ComplexCircleScheduleProvider(tS, scenario.getNetwork(), null, pC.getVehicleMaximumVelocity(), pC.getPlanningSpeedFactor(), pC.getDriverRestTime(), pC.getMode()); - + Id lineId = Id.create("line1", Operator.class); Id routeId = Id.create("route1", PPlan.class); - + PPlan plan = new PPlan(routeId, "noCreator",PConstants.founderPlanId); plan.setStartTime(7.0 * 3600.0); plan.setEndTime(9.0 * 3600.0); @@ -132,72 +132,72 @@ public final void testCreateTransitLineWithMoreStops() { stopsToBeServed.add(stop3); stopsToBeServed.add(stop4); stopsToBeServed.add(stop5); - + plan.setStopsToBeServed(stopsToBeServed); - + ArrayList> refIds = new ArrayList<>(); refIds.add(Id.create("1424", Link.class)); refIds.add(Id.create("2423", Link.class)); refIds.add(Id.create("2333", Link.class)); refIds.add(Id.create("3334", Link.class)); refIds.add(Id.create("3433", Link.class)); refIds.add(Id.create("3334", Link.class)); refIds.add(Id.create("3424", Link.class)); refIds.add(Id.create("2414", Link.class)); refIds.add(Id.create("1424", Link.class)); - + TransitLine line = prov.createTransitLineFromOperatorPlan(lineId, plan); - + Assert.assertEquals("Transit line ids have to be the same", Id.create(lineId, TransitLine.class), line.getId()); - + for (TransitRoute route : line.getRoutes().values()) { Assert.assertEquals("Route id have to be the same", Id.create(lineId + "-" + routeId, TransitRoute.class), route.getId()); - - // check links + + // check links Assert.assertEquals("Start link id has to be the same", refIds.get(0), route.getRoute().getStartLinkId()); - + int i = 1; for (Id linkId : route.getRoute().getLinkIds()) { Assert.assertEquals("Route link ids have to be the same", refIds.get(i), linkId); i++; } - + Assert.assertEquals("End link id has to be the same", refIds.get(refIds.size() - 1), route.getRoute().getEndLinkId()); - + // check stops i = 0; for (TransitRouteStop stop : route.getStops()) { Assert.assertEquals("Route stop ids have to be the same", Id.create(pC.getPIdentifier() + refIds.get(i), TransitStopFacility.class), stop.getStopFacility().getId()); i++; } - - Assert.assertEquals("Number of departures", 11.0, route.getDepartures().size(), MatsimTestUtils.EPSILON); - } + + Assert.assertEquals("Number of departures", 11.0, route.getDepartures().size(), MatsimTestUtils.EPSILON); + } } - + @Test public final void testGetRandomTransitStop() { - + MutableScenario scenario = (MutableScenario) PScenarioHelper.createTestNetwork(); PConfigGroup pC = new PConfigGroup(); RandomStopProvider randomStopProvider = new RandomStopProvider(pC, scenario.getPopulation(), scenario.getTransitSchedule(), null); - + SimpleCircleScheduleProvider prov = new SimpleCircleScheduleProvider(pC.getPIdentifier(), scenario.getTransitSchedule(), scenario.getNetwork(), randomStopProvider, pC.getVehicleMaximumVelocity(), pC.getDriverRestTime(), pC.getMode()); - + for (int i = 0; i < 5; i++) { TransitStopFacility stop1 = prov.getRandomTransitStop(0); TransitStopFacility stop2 = prov.getRandomTransitStop(0); - Assert.assertNotSame("Stop should not be the same", stop1.getId(), stop2.getId()); + Assert.assertNotSame("Stop should not be the same", stop1.getId(), stop2.getId()); } - } - + } + @Test public final void testCreateEmptyLine() { - + MutableScenario scenario = (MutableScenario) PScenarioHelper.createTestNetwork(); PConfigGroup pC = new PConfigGroup(); - + Id lineId = Id.create("1", Operator.class); - + SimpleCircleScheduleProvider prov = new SimpleCircleScheduleProvider(pC.getPIdentifier(), scenario.getTransitSchedule(), scenario.getNetwork(), null, pC.getVehicleMaximumVelocity(), pC.getDriverRestTime(), pC.getMode()); TransitLine line = prov.createEmptyLineFromOperator(lineId); - + Assert.assertEquals("Transit line ids have to be the same", Id.create(lineId, TransitLine.class), line.getId()); } } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/SimpleCircleScheduleProviderTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/SimpleCircleScheduleProviderTest.java index 44875c05220..4b09480162c 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/SimpleCircleScheduleProviderTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/SimpleCircleScheduleProviderTest.java @@ -22,7 +22,7 @@ import java.util.ArrayList; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -41,23 +41,23 @@ import org.matsim.testcases.MatsimTestUtils; public class SimpleCircleScheduleProviderTest { - -@Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + +@RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + @Test public final void testCreateTransitLine() { - + Scenario scenario = PScenarioHelper.createTestNetwork(); PConfigGroup pC = new PConfigGroup(); - - + + TransitSchedule tS = CreateStopsForAllCarLinks.createStopsForAllCarLinks(scenario.getNetwork(), pC); - + SimpleCircleScheduleProvider prov = new SimpleCircleScheduleProvider(pC.getPIdentifier(), tS, scenario.getNetwork(), null, pC.getVehicleMaximumVelocity(), pC.getDriverRestTime(), pC.getMode()); - + Id lineId = Id.create("line1", PPlan.class); Id routeId = Id.create("route1", PPlan.class); - + PPlan plan = new PPlan(routeId, "noCreator", PConstants.founderPlanId); plan.setStartTime(7.0 * 3600.0); plan.setEndTime(9.0 * 3600.0); @@ -68,68 +68,68 @@ public final void testCreateTransitLine() { stopsToBeServed.add(startStop); stopsToBeServed.add(endStop); plan.setStopsToBeServed(stopsToBeServed); - + ArrayList> refIds = new ArrayList<>(); refIds.add(Id.create("1424", Link.class)); refIds.add(Id.create("2434", Link.class)); refIds.add(Id.create("3444", Link.class)); refIds.add(Id.create("4434", Link.class)); refIds.add(Id.create("3424", Link.class)); refIds.add(Id.create("2414", Link.class)); refIds.add(Id.create("1424", Link.class)); - + TransitLine line = prov.createTransitLineFromOperatorPlan(Id.create(lineId, Operator.class), plan); - + Assert.assertEquals("Transit line ids have to be the same", Id.create(lineId, TransitLine.class), line.getId()); - + for (TransitRoute route : line.getRoutes().values()) { Assert.assertEquals("Route id have to be the same", Id.create(lineId + "-" + routeId, TransitRoute.class), route.getId()); Assert.assertEquals("Number of departures", 14.0, route.getDepartures().size(), MatsimTestUtils.EPSILON); - + // check stops int i = 0; for (TransitRouteStop stop : route.getStops()) { Assert.assertEquals("Route stop ids have to be the same", Id.create(pC.getPIdentifier() + refIds.get(i), TransitStopFacility.class), stop.getStopFacility().getId()); i++; } - - // check links + + // check links Assert.assertEquals("Start link id has to be the same", refIds.get(0), route.getRoute().getStartLinkId()); - + i = 1; for (Id linkId : route.getRoute().getLinkIds()) { Assert.assertEquals("Route link ids have to be the same", refIds.get(i), linkId); i++; } - + Assert.assertEquals("End link id has to be the same", refIds.get(refIds.size() - 1), route.getRoute().getEndLinkId()); - } + } } - + @Test public final void testGetRandomTransitStop() { - + MutableScenario scenario = (MutableScenario) PScenarioHelper.createTestNetwork(); PConfigGroup pC = new PConfigGroup(); RandomStopProvider randomStopProvider = new RandomStopProvider(pC, scenario.getPopulation(), scenario.getTransitSchedule(), null); - + SimpleCircleScheduleProvider prov = new SimpleCircleScheduleProvider(pC.getPIdentifier(), scenario.getTransitSchedule(), scenario.getNetwork(), randomStopProvider, pC.getVehicleMaximumVelocity(), pC.getDriverRestTime(), pC.getMode()); - + for (int i = 0; i < 5; i++) { TransitStopFacility stop1 = prov.getRandomTransitStop(0); TransitStopFacility stop2 = prov.getRandomTransitStop(0); - Assert.assertNotSame("Stop should not be the same", stop1.getId(), stop2.getId()); + Assert.assertNotSame("Stop should not be the same", stop1.getId(), stop2.getId()); } - } - + } + @Test public final void testCreateEmptyLine() { - + MutableScenario scenario = (MutableScenario) PScenarioHelper.createTestNetwork(); PConfigGroup pC = new PConfigGroup(); - + Id lineId = Id.create("1", Operator.class); - + SimpleCircleScheduleProvider prov = new SimpleCircleScheduleProvider(pC.getPIdentifier(), scenario.getTransitSchedule(), scenario.getNetwork(), null, pC.getVehicleMaximumVelocity(), pC.getDriverRestTime(), pC.getMode()); TransitLine line = prov.createEmptyLineFromOperator(lineId); - + Assert.assertEquals("Transit line ids have to be the same", Id.create(lineId, TransitLine.class), line.getId()); } } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreatePStopsOnJunctionApproachesAndBetweenJunctionsTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreatePStopsOnJunctionApproachesAndBetweenJunctionsTest.java index 14bcd4e148c..260a6a7d7f1 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreatePStopsOnJunctionApproachesAndBetweenJunctionsTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreatePStopsOnJunctionApproachesAndBetweenJunctionsTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.minibus.schedule; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -39,18 +39,18 @@ public class CreatePStopsOnJunctionApproachesAndBetweenJunctionsTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + @Test public final void testPScenarioHelperTestNetwork() { - + Network net = PScenarioHelper.createTestNetwork().getNetwork(); PConfigGroup pC = new PConfigGroup(); pC.addParam("stopLocationSelector", "outsideJunctionAreas"); pC.addParam("stopLocationSelectorParameter", "50.0,2,Double.positiveInfinity"); - + String realPtStopLink = "3233"; - + /* Modify some link attributes to check whether these links are excluded as specified in the config */ String tooLowCapacityLink = "2122"; String tooHighFreespeedLink = "2223"; @@ -58,93 +58,93 @@ public final void testPScenarioHelperTestNetwork() { net.getLinks().get(Id.createLinkId(tooHighFreespeedLink)).setFreespeed(100); pC.addParam("minCapacityForStops", "0"); pC.addParam("speedLimitForStops", "1000"); - + TransitSchedule transitSchedule = CreatePStopsOnJunctionApproachesAndBetweenJunctions.createPStops(net, pC, new NetworkConfigGroup()); - + int numberOfParaStops = 0; for (TransitStopFacility stopFacility : transitSchedule.getFacilities().values()) { if (stopFacility.getId().toString().startsWith(pC.getPIdentifier())) { numberOfParaStops++; } } - + /* 4 inner junctions with 4 approaches + 8 outer junctions with 3 approaches + 4 corners without junctions = 40 approach links */ Assert.assertEquals("All 40 junction approach links got a paratransit stop", 40, numberOfParaStops, MatsimTestUtils.EPSILON); - + /* Check whether these links are included as specified in the config */ Assert.assertNotNull("Paratransit stop at link without real pt stop", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + realPtStopLink, TransitStopFacility.class))); Assert.assertNotNull("Paratransit stop at link with small capacity", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + tooLowCapacityLink, TransitStopFacility.class))); Assert.assertNotNull("Paratransit stop at link with high freespeed", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + tooHighFreespeedLink, TransitStopFacility.class))); TransitScheduleFactoryImpl tSF = new TransitScheduleFactoryImpl(); - + TransitSchedule realTransitSchedule = tSF.createTransitSchedule(); TransitStopFacility stop1 = tSF.createTransitStopFacility(Id.create(realPtStopLink, TransitStopFacility.class), new Coord(0.0, 0.0), false); stop1.setLinkId(Id.create(realPtStopLink, Link.class)); realTransitSchedule.addStopFacility(stop1); - + /* Modify config to exclude some links */ pC.addParam("minCapacityForStops", "800"); pC.addParam("speedLimitForStops", "20"); - + transitSchedule = CreatePStopsOnJunctionApproachesAndBetweenJunctions.createPStops(net, pC, realTransitSchedule, new NetworkConfigGroup()); - + numberOfParaStops = 0; for (TransitStopFacility stopFacility : transitSchedule.getFacilities().values()) { if (stopFacility.getId().toString().startsWith(pC.getPIdentifier())) { numberOfParaStops++; } } - + Assert.assertEquals("All car links minus one stop from formal transit got a paratransit stop", 40 - 3, numberOfParaStops, MatsimTestUtils.EPSILON); - + Assert.assertNull("No paratransit stop at link with real pt stop", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + realPtStopLink, TransitStopFacility.class))); Assert.assertNull("No paratransit stop at link with too small capacity", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + tooLowCapacityLink, TransitStopFacility.class))); Assert.assertNull("No paratransit stop at link with too high freespeed", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + tooHighFreespeedLink, TransitStopFacility.class))); - + } - - /** {@link org.matsim.core.network.algorithms.intersectionSimplifier.IntersectionSimplifierTest} */ + + /** {@link org.matsim.core.network.algorithms.intersectionSimplifier.IntersectionSimplifierTest} */ @Test public final void testComplexIntersection() { - + Network network = buildComplexIntersection(); PConfigGroup pC = new PConfigGroup(); pC.addParam("stopLocationSelector", "outsideJunctionAreas"); pC.addParam("stopLocationSelectorParameter", "30.0,2,500"); - + TransitSchedule transitSchedule = CreatePStopsOnJunctionApproachesAndBetweenJunctions.createPStops(network, pC, new NetworkConfigGroup()); - + int numberOfParaStops = 0; for (TransitStopFacility stopFacility : transitSchedule.getFacilities().values()) { if (stopFacility.getId().toString().startsWith(pC.getPIdentifier())) { numberOfParaStops++; } } - + Assert.assertEquals("Check number of paratransit stops", 16, numberOfParaStops, MatsimTestUtils.EPSILON); - + /* approaches to (unclustered) dead-ends */ Assert.assertNotNull("Should find paratransit stop 'p_2_1'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "2_1", TransitStopFacility.class))); Assert.assertNotNull("Should find paratransit stop 'p_4_3'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "4_3", TransitStopFacility.class))); Assert.assertNotNull("Should find paratransit stop 'p_9_10'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "9_10", TransitStopFacility.class))); Assert.assertNotNull("Should find paratransit stop 'p_30_31'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "30_31", TransitStopFacility.class))); - + /* left junction: clustered nodes 5-6-7-8 */ Assert.assertNotNull("Should find junction approach paratransit stop 'p_2_5'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "2_5", TransitStopFacility.class))); Assert.assertNotNull("Should find junction approach paratransit stop 'p_4_6'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "4_6", TransitStopFacility.class))); Assert.assertNotNull("Should find junction approach paratransit stop 'p_19_8'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "19_8", TransitStopFacility.class))); Assert.assertNotNull("Should find junction approach paratransit stop 'p_9_7'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "9_7", TransitStopFacility.class))); - + Assert.assertNull("Should NOT find paratransit stop at link in junction '5_6'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "5_6", TransitStopFacility.class))); Assert.assertNull("Should NOT find paratransit stop at link in junction '6_8'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "6_8", TransitStopFacility.class))); Assert.assertNull("Should NOT find paratransit stop at link in junction '8_7'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "8_7", TransitStopFacility.class))); Assert.assertNull("Should NOT find paratransit stop at link in junction '7_5'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "7_5", TransitStopFacility.class))); - + /* clustered nodes 11-12: dead-end, therefore only one stop approaching */ Assert.assertNotNull("Should find junction approach paratransit stop 'p_13_12'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "13_12", TransitStopFacility.class))); - + /* right junction: clustered nodes 13-14-15-16-17-18-19-20-21-22-23-24 */ Assert.assertNotNull("Should find junction approach paratransit stop 'p_6_15'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "6_15", TransitStopFacility.class))); Assert.assertNotNull("Should find junction approach paratransit stop 'p_12_14'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "12_14", TransitStopFacility.class))); @@ -174,29 +174,29 @@ public final void testComplexIntersection() { Assert.assertNull("Should NOT find paratransit stop at link in junction '20_17'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "20_17", TransitStopFacility.class))); Assert.assertNull("Should NOT find paratransit stop at link in junction '16_21'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "16_21", TransitStopFacility.class))); Assert.assertNull("Should NOT find paratransit stop at link in junction '21_16'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "21_16", TransitStopFacility.class))); - + /* clustered nodes 25-26: dead-end, therefore only one stop approaching */ Assert.assertNotNull("Should find junction approach paratransit stop 'p_24_25'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "24_25", TransitStopFacility.class))); - + /* links exiting junctions (towards dead-ends) */ Assert.assertNull("Should NOT find paratransit stop at link exiting junction '7_2'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "7_2", TransitStopFacility.class))); Assert.assertNull("Should NOT find paratransit stop at link exiting junction '5_4'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "5_4", TransitStopFacility.class))); Assert.assertNull("Should NOT find paratransit stop at link exiting junction '8_9'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "8_9", TransitStopFacility.class))); Assert.assertNull("Should NOT find paratransit stop at link exiting junction '18_19'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "7_2", TransitStopFacility.class))); - + /* Infill Stops between junctions / dead-ends */ Assert.assertNotNull("Should find infill paratransit stop 'p_30_29'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "30_29", TransitStopFacility.class))); Assert.assertNotNull("Should find infill paratransit stop 'p_27_28'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "27_28", TransitStopFacility.class))); - + /* Check whether CalcTopoTypes is considered (type 8 : intersections only) */ pC.addParam("TopoTypesForStops", "8"); - + transitSchedule = CreatePStopsOnJunctionApproachesAndBetweenJunctions.createPStops(network, pC, new NetworkConfigGroup()); Assert.assertNull("Should NOT find paratransit stop at link with wrong topo type (not an intersection) '30_31'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "30_31", TransitStopFacility.class))); } /** - * The following layout is not according to scale, but shows the structure + * The following layout is not according to scale, but shows the structure * of the two 'complex' intersections. * 11 * | @@ -204,7 +204,7 @@ public final void testComplexIntersection() { * 12 * 3 / \ * | / \ - * | .__ 13 14 __. + * | .__ 13 14 __. * 4 / | | \ * / \ | | | | * .____ 5 ___ 6 _____> 110m _____ 15 ___ 16 ___ 17 ___ 18 ___. @@ -309,12 +309,12 @@ private Network buildComplexIntersection() { /* Link the two clusters */ NetworkUtils.createAndAddLink(network, Id.createLinkId("6_15"), n06, n15, 50.0, 80.0/3.6, 1000.0, 2.0 ); NetworkUtils.createAndAddLink(network, Id.createLinkId("19_8"), n19, n08, 50.0, 80.0/3.6, 1000.0, 2.0 ); - + /* Eastern extension, note length different from beeline distance */ Node n29 = NetworkUtils.createAndAddNode(network, Id.createNodeId(29), CoordUtils.createCoord(700.0, 85.0)); Node n30 = NetworkUtils.createAndAddNode(network, Id.createNodeId(30), CoordUtils.createCoord(800.0, 85.0)); Node n31 = NetworkUtils.createAndAddNode(network, Id.createNodeId(31), CoordUtils.createCoord(900.0, 85.0)); - + NetworkUtils.createAndAddLink(network, Id.createLinkId("28_29"), n28, n29, 400.0, 80.0/3.6, 1000.0, 1.0 ); NetworkUtils.createAndAddLink(network, Id.createLinkId("29_28"), n29, n28, 400.0, 80.0/3.6, 1000.0, 1.0 ); NetworkUtils.createAndAddLink(network, Id.createLinkId("29_30"), n29, n30, 100.0, 80.0/3.6, 1000.0, 1.0 ); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreateStopsForAllCarLinksTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreateStopsForAllCarLinksTest.java index 74b1c64162c..50453286821 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreateStopsForAllCarLinksTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreateStopsForAllCarLinksTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.minibus.schedule; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -36,50 +36,50 @@ public class CreateStopsForAllCarLinksTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + @Test public final void testCreateStopsForAllCarLinks() { - + Network net = PScenarioHelper.createTestNetwork().getNetwork(); PConfigGroup pC = new PConfigGroup(); - + int numberOfCarLinks = 0; for (Link link : net.getLinks().values()) { if (link.getAllowedModes().contains(TransportMode.car)) { numberOfCarLinks++; } } - + TransitSchedule transitSchedule = CreateStopsForAllCarLinks.createStopsForAllCarLinks(net, pC); - + int numberOfParaStops = 0; for (TransitStopFacility stopFacility : transitSchedule.getFacilities().values()) { if (stopFacility.getId().toString().startsWith(pC.getPIdentifier())) { numberOfParaStops++; } } - + Assert.assertEquals("All car links got a paratransit stop", numberOfCarLinks, numberOfParaStops, MatsimTestUtils.EPSILON); TransitScheduleFactoryImpl tSF = new TransitScheduleFactoryImpl(); - + TransitSchedule realTransitSchedule = tSF.createTransitSchedule(); TransitStopFacility stop1 = tSF.createTransitStopFacility(Id.create("1314", TransitStopFacility.class), new Coord(0.0, 0.0), false); stop1.setLinkId(Id.create("1314", Link.class)); realTransitSchedule.addStopFacility(stop1); - + transitSchedule = CreateStopsForAllCarLinks.createStopsForAllCarLinks(net, pC, realTransitSchedule); - + numberOfParaStops = 0; for (TransitStopFacility stopFacility : transitSchedule.getFacilities().values()) { if (stopFacility.getId().toString().startsWith(pC.getPIdentifier())) { numberOfParaStops++; } } - + Assert.assertEquals("All car links minus one stop from formal transit got a paratransit stop", numberOfCarLinks - 1, numberOfParaStops, MatsimTestUtils.EPSILON); - + } } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsApproxContainerTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsApproxContainerTest.java index 6173890e187..fc160716cfb 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsApproxContainerTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsApproxContainerTest.java @@ -20,14 +20,14 @@ package org.matsim.contrib.minibus.stats; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.contrib.minibus.stats.RecursiveStatsApproxContainer; import org.matsim.testcases.MatsimTestUtils; public class RecursiveStatsApproxContainerTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public final void testRecursiveStatsContainer() { @@ -43,7 +43,7 @@ public final void testRecursiveStatsContainer() { Assert.assertEquals("std dev route", Double.NaN, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON); Assert.assertEquals("std dev pax", Double.NaN, stats.getStdDevPax(), MatsimTestUtils.EPSILON); Assert.assertEquals("std dev veh", Double.NaN, stats.getStdDevVeh(), MatsimTestUtils.EPSILON); - + stats.handleNewEntry(2.0, 3.0, 3.0, 1.0); Assert.assertEquals("mean coop", 1.5, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON); Assert.assertEquals("mean route", 3.5, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON); @@ -53,7 +53,7 @@ public final void testRecursiveStatsContainer() { Assert.assertEquals("std dev route", 0.7071067811865476, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON); Assert.assertEquals("std dev pax", 0.7071067811865476, stats.getStdDevPax(), MatsimTestUtils.EPSILON); Assert.assertEquals("std dev veh", 1.4142135623730951, stats.getStdDevVeh(), MatsimTestUtils.EPSILON); - + stats.handleNewEntry(3.0, 2.0, 1.0, 2.0); Assert.assertEquals("mean coop", 2.0, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON); Assert.assertEquals("mean route", 3.0, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON); @@ -63,7 +63,7 @@ public final void testRecursiveStatsContainer() { Assert.assertEquals("std dev route", 1.0, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON); Assert.assertEquals("std dev pax", 1.0, stats.getStdDevPax(), MatsimTestUtils.EPSILON); Assert.assertEquals("std dev veh", 1.0, stats.getStdDevVeh(), MatsimTestUtils.EPSILON); - + stats.handleNewEntry(1.0, 4.0, 2.0, 3.0); stats.handleNewEntry(2.0, 3.0, 3.0, 1.0); stats.handleNewEntry(12.0, 12345.0, 123.0, 1234.0); @@ -76,4 +76,4 @@ public final void testRecursiveStatsContainer() { Assert.assertEquals("std dev pax", 11.691, stats.getStdDevPax(), MatsimTestUtils.EPSILON); Assert.assertEquals("std dev veh", 111.7719, stats.getStdDevVeh(), MatsimTestUtils.EPSILON); } -} \ No newline at end of file +} diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsContainerTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsContainerTest.java index c51536689a4..5b51ce6808d 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsContainerTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsContainerTest.java @@ -20,14 +20,14 @@ package org.matsim.contrib.minibus.stats; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.contrib.minibus.stats.RecursiveStatsContainer; import org.matsim.testcases.MatsimTestUtils; public class RecursiveStatsContainerTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public final void testRecursiveStatsContainer() { @@ -43,7 +43,7 @@ public final void testRecursiveStatsContainer() { Assert.assertEquals("std dev route", Double.NaN, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON); Assert.assertEquals("std dev pax", Double.NaN, stats.getStdDevPax(), MatsimTestUtils.EPSILON); Assert.assertEquals("std dev veh", Double.NaN, stats.getStdDevVeh(), MatsimTestUtils.EPSILON); - + stats.handleNewEntry(2.0, 3.0, 3.0, 1.0); Assert.assertEquals("mean coop", 1.5, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON); Assert.assertEquals("mean route", 3.5, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON); @@ -53,7 +53,7 @@ public final void testRecursiveStatsContainer() { Assert.assertEquals("std dev route", 0.7071067811865476, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON); Assert.assertEquals("std dev pax", 0.7071067811865476, stats.getStdDevPax(), MatsimTestUtils.EPSILON); Assert.assertEquals("std dev veh", 1.4142135623730951, stats.getStdDevVeh(), MatsimTestUtils.EPSILON); - + stats.handleNewEntry(3.0, 2.0, 1.0, 2.0); Assert.assertEquals("mean coop", 2.0, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON); Assert.assertEquals("mean route", 3.0, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON); @@ -63,7 +63,7 @@ public final void testRecursiveStatsContainer() { Assert.assertEquals("std dev route", 1.0, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON); Assert.assertEquals("std dev pax", 1.0, stats.getStdDevPax(), MatsimTestUtils.EPSILON); Assert.assertEquals("std dev veh", 1.0, stats.getStdDevVeh(), MatsimTestUtils.EPSILON); - + stats.handleNewEntry(1.0, 4.0, 2.0, 3.0); stats.handleNewEntry(2.0, 3.0, 3.0, 1.0); stats.handleNewEntry(12.0, 12345.0, 123.0, 1234.0); @@ -76,4 +76,4 @@ public final void testRecursiveStatsContainer() { Assert.assertEquals("std dev pax", 49.32207078648124, stats.getStdDevPax(), MatsimTestUtils.EPSILON); Assert.assertEquals("std dev veh", 502.962689139728, stats.getStdDevVeh(), MatsimTestUtils.EPSILON); } -} \ No newline at end of file +} diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java index 28c96b9e39d..e94aeb5073c 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java @@ -69,8 +69,8 @@ public class MultiModalControlerListenerTest { private static final Logger log = LogManager.getLogger(MultiModalControlerListenerTest.class); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @SuppressWarnings("static-method") @Test diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/RunMultimodalExampleTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/RunMultimodalExampleTest.java index 77e61902f97..99407837927 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/RunMultimodalExampleTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/RunMultimodalExampleTest.java @@ -3,7 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; @@ -13,7 +13,7 @@ public class RunMultimodalExampleTest{ private static final Logger log = LogManager.getLogger( RunMultimodalExampleTest.class ) ; - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void main(){ diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java index c4bb7388e2c..52aa33e2fc2 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -60,8 +60,8 @@ public class MultiModalPTCombinationTest { private static final Logger log = LogManager.getLogger(MultiModalPTCombinationTest.class); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** * Two things are tested here: diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeTest.java index 7f95d342870..9f2cfda7ee0 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeTest.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -46,8 +46,8 @@ public class BikeTravelTimeTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final Logger log = LogManager.getLogger(BikeTravelTimeTest.class); diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeTest.java index ca66b5a25d5..2136ca6a756 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeTest.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -46,8 +46,8 @@ public class WalkTravelTimeTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final Logger log = LogManager.getLogger(WalkTravelTimeTest.class); diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java index ffb8924a15c..d7d87c67e8d 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -62,8 +62,8 @@ public class StuckAgentTest { private static final Logger log = LogManager.getLogger(StuckAgentTest.class); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testStuckEvents() { diff --git a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseConfigGroupIT.java b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseConfigGroupIT.java index 7e07654ace8..0862fe22736 100644 --- a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseConfigGroupIT.java +++ b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseConfigGroupIT.java @@ -23,7 +23,7 @@ package org.matsim.contrib.noise; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; @@ -40,8 +40,8 @@ public class NoiseConfigGroupIT { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public final void test0(){ diff --git a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java index aa179afd113..5d8569ad0e9 100644 --- a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java +++ b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java @@ -30,7 +30,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -72,8 +72,8 @@ public class NoiseIT { private static final Logger log = LogManager.getLogger( NoiseIT.class ); - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); // Tests the NoisSpatialInfo functionality separately for each function @Test diff --git a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseOnlineExampleIT.java b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseOnlineExampleIT.java index c03d5d04e57..fa0e8c0c1e5 100644 --- a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseOnlineExampleIT.java +++ b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseOnlineExampleIT.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.analysis.XYTRecord; import org.matsim.api.core.v01.Coord; @@ -54,8 +54,8 @@ public class NoiseOnlineExampleIT { private static final Logger log = LogManager.getLogger( NoiseOnlineExampleIT.class ) ; - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public final void test0(){ diff --git a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseRLS19IT.java b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseRLS19IT.java index 3c9b486bb7a..096250d46d4 100644 --- a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseRLS19IT.java +++ b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseRLS19IT.java @@ -23,7 +23,7 @@ package org.matsim.contrib.noise; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; @@ -50,8 +50,8 @@ */ public class NoiseRLS19IT { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void testShielding() { diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderIT.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderIT.java index 613776996ad..e5a9f4558e9 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderIT.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderIT.java @@ -1,6 +1,6 @@ package org.matsim.contrib.osm.networkReader; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.network.Network; import org.matsim.core.network.NetworkUtils; @@ -15,8 +15,8 @@ public class OsmBicycleReaderIT { private static final CoordinateTransformation coordinateTransformation = TransformationFactory.getCoordinateTransformation(TransformationFactory.WGS84, "EPSG:32631"); - @Rule - public MatsimTestUtils matsimTestUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils matsimTestUtils = new MatsimTestUtils(); @Test public void test_andorra() { diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderTest.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderTest.java index 9a00864be0b..bc7b8479342 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderTest.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderTest.java @@ -2,7 +2,7 @@ import de.topobyte.osm4j.core.model.iface.OsmTag; import de.topobyte.osm4j.core.model.impl.Tag; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -23,8 +23,8 @@ public class OsmBicycleReaderTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void test_singleLinkWithAttributes() { diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmNetworkParserTest.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmNetworkParserTest.java index ea2eef09583..03be0ed6ca9 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmNetworkParserTest.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmNetworkParserTest.java @@ -4,7 +4,7 @@ import de.topobyte.osm4j.core.model.iface.OsmWay; import org.junit.After; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.geometry.CoordinateTransformation; @@ -25,8 +25,8 @@ public class OsmNetworkParserTest { private final ExecutorService executor = Executors.newSingleThreadExecutor(); private static final CoordinateTransformation transformation = new IdentityTransformation(); - @Rule - public MatsimTestUtils matsimUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils matsimUtils = new MatsimTestUtils(); @After public void shutDownExecutor() { diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmSignalsParserTest.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmSignalsParserTest.java index cf47fdc1b91..c5ba94aab22 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmSignalsParserTest.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmSignalsParserTest.java @@ -7,7 +7,7 @@ import de.topobyte.osm4j.core.model.impl.Tag; import org.junit.After; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.core.utils.geometry.transformations.IdentityTransformation; @@ -30,8 +30,8 @@ public class OsmSignalsParserTest { private final ExecutorService executor = Executors.newSingleThreadExecutor(); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @After @@ -229,4 +229,4 @@ private OsmRelation createRestriction(long id, OsmWay from, OsmWay to, OsmNode v return new Relation(id, members, tags); } -} \ No newline at end of file +} diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderIT.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderIT.java index 999e26a0dbb..423233c2079 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderIT.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderIT.java @@ -2,7 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.network.Network; import org.matsim.core.network.NetworkUtils; @@ -17,8 +17,8 @@ public class SupersonicOsmNetworkReaderIT { private static final CoordinateTransformation coordinateTransformation = TransformationFactory.getCoordinateTransformation(TransformationFactory.WGS84, "EPSG:32631"); private static final Logger log = LogManager.getLogger(SupersonicOsmNetworkReaderIT.class); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void test_andorra() { diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderTest.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderTest.java index 35e73c6cd71..95f68fad504 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderTest.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderTest.java @@ -9,7 +9,7 @@ import de.topobyte.osm4j.pbf.seq.PbfWriter; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -39,8 +39,8 @@ public class SupersonicOsmNetworkReaderTest { private static final String MOTORWAY = "motorway"; private static final String TERTIARY = "tertiary"; - @Rule - public MatsimTestUtils matsimTestUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils matsimTestUtils = new MatsimTestUtils(); private static void writeOsmData(Collection nodes, Collection ways, Path file) { diff --git a/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java b/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java index d713edcd6ab..b16a6a5d01d 100644 --- a/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java +++ b/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java @@ -24,7 +24,7 @@ package org.matsim.contrib.otfvis; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -48,8 +48,8 @@ */ public class OTFVisIT { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void testConvert() { diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxyIT.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxyIT.java index 828685aec99..fcbc247bd76 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxyIT.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxyIT.java @@ -21,7 +21,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Ignore; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; @@ -34,7 +34,7 @@ public class RunWithParkingProxyIT { private static final Logger log = LogManager.getLogger(RunWithParkingProxyIT.class); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test @Ignore diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingChoiceExampleIT.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingChoiceExampleIT.java index 57792fb205d..483a118e22e 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingChoiceExampleIT.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingChoiceExampleIT.java @@ -18,7 +18,7 @@ * *********************************************************************** */ package org.matsim.contrib.parking.run; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.contrib.parking.parkingchoice.run.RunParkingChoiceExample; import org.matsim.core.config.Config; @@ -30,7 +30,7 @@ * */ public class RunParkingChoiceExampleIT { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; /** * Test method for {@link org.matsim.contrib.parking.parkingchoice.run.RunParkingChoiceExample#run(org.matsim.core.config.Config)}. diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingSearchScenarioIT.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingSearchScenarioIT.java index ef761cedee2..16f1a7f8525 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingSearchScenarioIT.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingSearchScenarioIT.java @@ -20,7 +20,7 @@ package org.matsim.contrib.parking.run; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -39,8 +39,8 @@ * @author jbischoff */ public class RunParkingSearchScenarioIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testRunParkingBenesonStrategy() { diff --git a/contribs/protobuf/src/test/java/org/matsim/contrib/protobuf/EventWriterPBTest.java b/contribs/protobuf/src/test/java/org/matsim/contrib/protobuf/EventWriterPBTest.java index b1c18d8ab07..5941d7c17dd 100644 --- a/contribs/protobuf/src/test/java/org/matsim/contrib/protobuf/EventWriterPBTest.java +++ b/contribs/protobuf/src/test/java/org/matsim/contrib/protobuf/EventWriterPBTest.java @@ -3,7 +3,7 @@ import com.google.protobuf.Descriptors; import org.assertj.core.api.Assertions; import org.assertj.core.api.Condition; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.matsim.api.core.v01.Id; @@ -27,11 +27,8 @@ public class EventWriterPBTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); - - @Rule - public TemporaryFolder tmp = new TemporaryFolder(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); @Test public void writer() throws IOException { diff --git a/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java b/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java index 2a82fc13096..9e7f626e248 100644 --- a/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java +++ b/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java @@ -5,7 +5,7 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.FixMethodOrder; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.junit.runners.MethodSorters; import org.matsim.analysis.ScoreStatsControlerListener; @@ -33,8 +33,8 @@ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class RunPSimTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private final Logger logger = LogManager.getLogger(RunPSimTest.class ); diff --git a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java index f49a5b0901c..3fe816aff64 100644 --- a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java +++ b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java @@ -23,7 +23,7 @@ import ch.sbb.matsim.contrib.railsim.events.RailsimTrainStateEvent; import ch.sbb.matsim.contrib.railsim.qsimengine.RailsimQSimModule; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -58,8 +58,8 @@ public class RailsimIntegrationTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testMicroSimpleBiDirectionalTrack() { diff --git a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimEngineTest.java b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimEngineTest.java index a993b46fd49..922fbb513e5 100644 --- a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimEngineTest.java +++ b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimEngineTest.java @@ -24,7 +24,7 @@ import ch.sbb.matsim.contrib.railsim.qsimengine.disposition.SimpleDisposition; import ch.sbb.matsim.contrib.railsim.qsimengine.router.TrainRouter; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -39,8 +39,8 @@ public class RailsimEngineTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private EventsManager eventsManager; private RailsimTestUtils.EventCollector collector; diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/AvoidTolledRouteTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/AvoidTolledRouteTest.java index 2f79155d1e4..e9877f905ca 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/AvoidTolledRouteTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/AvoidTolledRouteTest.java @@ -26,7 +26,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -51,8 +51,8 @@ */ public class AvoidTolledRouteTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public final void test1(){ diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/CalcPaidTollTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/CalcPaidTollTest.java index 6d8dabfc109..2ca1f243fff 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/CalcPaidTollTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/CalcPaidTollTest.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -50,8 +50,8 @@ * @author mrieser */ public class CalcPaidTollTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); static private final Logger log = LogManager.getLogger(CalcPaidTollTest.class); diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/ModuleTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/ModuleTest.java index 118dac01eb9..912a2cff00b 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/ModuleTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/ModuleTest.java @@ -22,7 +22,7 @@ package org.matsim.contrib.roadpricing; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; @@ -32,8 +32,8 @@ public class ModuleTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); @Test(expected = RuntimeException.class) public void testControlerWithoutRoadPricingDoesntWork() { diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/PlansCalcRouteWithTollOrNotTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/PlansCalcRouteWithTollOrNotTest.java index df6e547c898..339abde2d1e 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/PlansCalcRouteWithTollOrNotTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/PlansCalcRouteWithTollOrNotTest.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -64,8 +64,8 @@ public class PlansCalcRouteWithTollOrNotTest { private static final Logger log = LogManager.getLogger( PlansCalcRouteWithTollOrNotTest.class ); - @Rule - public MatsimTestUtils matsimTestUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils matsimTestUtils = new MatsimTestUtils(); /** * Tests a few cases where the router can decide if it is better to pay the diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingConfigGroupTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingConfigGroupTest.java index 3d852263e75..ca59e1d482f 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingConfigGroupTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingConfigGroupTest.java @@ -1,15 +1,15 @@ package org.matsim.contrib.roadpricing; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; public class RoadPricingConfigGroupTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void getTollLinksFile() { @@ -47,4 +47,4 @@ public void setEnforcementProbability() { cg.setEnforcementProbability(0.95); } -} \ No newline at end of file +} diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingControlerIT.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingControlerIT.java index e45608b4fbd..b4d8412ea5c 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingControlerIT.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingControlerIT.java @@ -21,7 +21,7 @@ package org.matsim.contrib.roadpricing; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -39,8 +39,8 @@ */ public class RoadPricingControlerIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testPaidTollsEndUpInScores() { diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingIOTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingIOTest.java index 7ce688e6671..a93960aeb94 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingIOTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingIOTest.java @@ -25,7 +25,7 @@ import java.io.File; import java.util.Iterator; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -41,8 +41,8 @@ */ public class RoadPricingIOTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java index b0c99aab041..6407bf1136d 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java @@ -27,7 +27,7 @@ import jakarta.inject.Provider; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -69,7 +69,7 @@ * @author mrieser */ public class TollTravelCostCalculatorTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RoadPricingByConfigfileTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RoadPricingByConfigfileTest.java index 077f9d88514..98ce6fec965 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RoadPricingByConfigfileTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RoadPricingByConfigfileTest.java @@ -21,7 +21,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; @@ -39,7 +39,7 @@ * */ public class RoadPricingByConfigfileTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; private static final Logger log = LogManager.getLogger( RoadPricingByConfigfileTest.class ); diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingExampleIT.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingExampleIT.java index e49a6410dfa..b73a1169381 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingExampleIT.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingExampleIT.java @@ -1,12 +1,12 @@ package org.matsim.contrib.roadpricing.run; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; public class RunRoadPricingExampleIT { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); private static final String TEST_CONFIG = "./test/input/org/matsim/contrib/roadpricing/AvoidTolledRouteTest/config.xml"; diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java index 59043264ed7..f40c02b6b02 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java @@ -26,7 +26,7 @@ import java.nio.charset.StandardCharsets; import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; @@ -44,7 +44,7 @@ */ public class SBBQSimModuleTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Before public void setUp() { diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java index 579f960e19b..54dcc62891c 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.controler.Controler; import org.matsim.core.mobsim.framework.Mobsim; @@ -40,7 +40,7 @@ public class SBBTransitQSimEngineIntegrationTest { private static final Logger log = LogManager.getLogger(SBBTransitQSimEngineIntegrationTest.class); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testIntegration() { diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/adaptiveSignals/AdaptiveSignalsExampleTest.java b/contribs/signals/src/test/java/org/matsim/codeexamples/adaptiveSignals/AdaptiveSignalsExampleTest.java index c351f323f17..a8f3454f627 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/adaptiveSignals/AdaptiveSignalsExampleTest.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/adaptiveSignals/AdaptiveSignalsExampleTest.java @@ -20,7 +20,7 @@ */ package org.matsim.codeexamples.adaptiveSignals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -29,13 +29,13 @@ */ public class AdaptiveSignalsExampleTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); - + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); + @Test public void testAdaptiveSignalsExample() { String configFileName = "./examples/tutorial/singleCrossingScenario/config.xml"; RunAdaptiveSignalsExample.run(configFileName, testUtils.getOutputDirectory() + "/", false); } - + } diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateIntergreensExampleTest.java b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateIntergreensExampleTest.java index 6ff30744d37..3068410bbba 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateIntergreensExampleTest.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateIntergreensExampleTest.java @@ -24,7 +24,7 @@ import java.io.IOException; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.utils.misc.CRCChecksum; import org.matsim.testcases.MatsimTestUtils; @@ -37,8 +37,8 @@ public class CreateIntergreensExampleTest { private static final String DIR_TO_COMPARE_WITH = "./examples/tutorial/example90TrafficLights/useSignalInput/"; - @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); - + @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); + @Test public void testIntergreenExample(){ try { @@ -49,9 +49,9 @@ public void testIntergreenExample(){ Assert.fail("something went wrong") ; } // compare intergreen output - Assert.assertEquals("different intergreen files", - CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "intergreens.xml"), + Assert.assertEquals("different intergreen files", + CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "intergreens.xml"), CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "intergreens.xml")); } - + } diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleTest.java b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleTest.java index 65a23d47da6..c52847d338b 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleTest.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleTest.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.utils.misc.CRCChecksum; import org.matsim.testcases.MatsimTestUtils; @@ -40,7 +40,7 @@ public class CreateSignalInputExampleTest { private static final String DIR_TO_COMPARE_WITH = "./examples/tutorial/example90TrafficLights/useSignalInput/woLanes/"; - @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void testCreateSignalInputExample(){ @@ -56,14 +56,14 @@ public void testCreateSignalInputExample(){ final String referenceFilename = DIR_TO_COMPARE_WITH + "signal_systems.xml"; log.info( "outputFilename=" + outputFilename ) ; log.info( "referenceFilename=" + referenceFilename ) ; - Assert.assertEquals("different signal system files", - CRCChecksum.getCRCFromFile(outputFilename), + Assert.assertEquals("different signal system files", + CRCChecksum.getCRCFromFile(outputFilename), CRCChecksum.getCRCFromFile(referenceFilename)); } - Assert.assertEquals("different signal group files", + Assert.assertEquals("different signal group files", CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "signal_groups.xml"), CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "signal_groups.xml")); - Assert.assertEquals("different signal control files", + Assert.assertEquals("different signal control files", CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "signal_groups.xml"), CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "signal_groups.xml")); } diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleWithLanesTest.java b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleWithLanesTest.java index 3aaeb001258..fd10d568b5c 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleWithLanesTest.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleWithLanesTest.java @@ -24,7 +24,7 @@ import java.io.IOException; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.utils.misc.CRCChecksum; import org.matsim.testcases.MatsimTestUtils; @@ -36,9 +36,9 @@ public class CreateSignalInputExampleWithLanesTest { private static final String DIR_TO_COMPARE_WITH = "./examples/tutorial/example90TrafficLights/useSignalInput/withLanes/"; - - @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); - + + @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); + @Test public void testCreateSignalInputExampleWithLanes(){ try { @@ -48,18 +48,18 @@ public void testCreateSignalInputExampleWithLanes(){ Assert.fail("something went wrong") ; } // compare signal output - Assert.assertEquals("different signal system files", - CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "signal_systems.xml"), + Assert.assertEquals("different signal system files", + CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "signal_systems.xml"), CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "signal_systems.xml")); - Assert.assertEquals("different signal group files", + Assert.assertEquals("different signal group files", CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "signal_groups.xml"), CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "signal_groups.xml")); - Assert.assertEquals("different signal control files", + Assert.assertEquals("different signal control files", CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "signal_groups.xml"), CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "signal_groups.xml")); - Assert.assertEquals("different lane files", + Assert.assertEquals("different lane files", CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "lane_definitions_v2.0.xml"), CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "lane_definitions_v2.0.xml")); } - + } diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleTest.java b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleTest.java index ee8adba17bf..0b63f1b71a0 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleTest.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleTest.java @@ -19,7 +19,7 @@ package org.matsim.codeexamples.fixedTimeSignals; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -32,7 +32,7 @@ */ public class RunSignalSystemsExampleTest { - @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public final void testExampleWithHoles() { diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/FixResponsiveSignalResultsIT.java b/contribs/signals/src/test/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/FixResponsiveSignalResultsIT.java index 159fbf0ee6b..486848880db 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/FixResponsiveSignalResultsIT.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/FixResponsiveSignalResultsIT.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.signals.data.SignalsData; @@ -46,16 +46,16 @@ public class FixResponsiveSignalResultsIT { private static final Logger LOG = LogManager.getLogger(FixResponsiveSignalResultsIT.class); - - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void testOneCrossingExample() { LOG.info("Fix the results from the simple one-crossing-example in RunSimpleResponsiveSignalExample."); RunSimpleResponsiveSignalExample responsiveSignal = new RunSimpleResponsiveSignalExample(); responsiveSignal.run(); - + SignalsData signalsData = (SignalsData) responsiveSignal.getControler().getScenario().getScenarioElement(SignalsData.ELEMENT_NAME); SignalSystemControllerData signalControlSystem1 = signalsData.getSignalControlData().getSignalSystemControllerDataBySystemId() .get(Id.create("SignalSystem1", SignalSystem.class)); @@ -63,7 +63,7 @@ public void testOneCrossingExample() { SortedMap, SignalGroupSettingsData> signalGroupSettings = signalPlan.getSignalGroupSettingsDataByGroupId(); SignalGroupSettingsData group1Setting = signalGroupSettings.get(Id.create("SignalGroup1", SignalGroup.class)); SignalGroupSettingsData group2Setting = signalGroupSettings.get(Id.create("SignalGroup2", SignalGroup.class)); - + LOG.info("SignalGroup1: onset " + group1Setting.getOnset() + ", dropping " + group1Setting.getDropping()); LOG.info("SignalGroup2: onset " + group2Setting.getOnset() + ", dropping " + group2Setting.getDropping()); Assert.assertEquals(0, group1Setting.getOnset()); @@ -71,5 +71,5 @@ public void testOneCrossingExample() { Assert.assertEquals(30, group2Setting.getOnset()); Assert.assertEquals(55, group2Setting.getDropping()); } - + } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/CalculateAngleTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/CalculateAngleTest.java index 5cde4a3e867..d8ffa385400 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/CalculateAngleTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/CalculateAngleTest.java @@ -6,7 +6,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -29,15 +29,15 @@ * @author dgrether */ public class CalculateAngleTest { - + private static final Logger log = LogManager.getLogger(CalculateAngleTest.class); - - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + /** * @author aneumann */ - @Test + @Test public void testGetLeftLane() { Config conf = utils.loadConfig(utils.getClassInputDirectory() + "config.xml"); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(conf); @@ -51,18 +51,18 @@ public void testGetLeftLane() { Assert.assertEquals( scenario.getNetwork().getLinks().get(Id.create("3", Link.class)), NetworkUtils.getLeftmostTurnExcludingU(scenario.getNetwork().getLinks().get(Id.create("22", Link.class)))); - + Assert.assertEquals( scenario.getNetwork().getLinks().get(Id.create("4", Link.class)), NetworkUtils.getLeftmostTurnExcludingU(scenario.getNetwork().getLinks().get(Id.create("33", Link.class)))); - + Assert.assertEquals( scenario.getNetwork().getLinks().get(Id.create("1", Link.class)), NetworkUtils.getLeftmostTurnExcludingU(scenario.getNetwork().getLinks().get(Id.create("44", Link.class)))); - + Assert.assertEquals( scenario.getNetwork().getLinks().get(Id.create("5", Link.class)), NetworkUtils.getLeftmostTurnExcludingU(scenario.getNetwork().getLinks().get(Id.create("3", Link.class)))); - + } - + /** * @author dgrether */ @@ -82,13 +82,13 @@ public void testGetOutLinksSortedByAngle(){ Assert.assertEquals("For angle " + angle + "CalculateAngle returns not the correct order of outlinks", Id.create(3, Link.class), entry.getValue().getId()); entry = m.higherEntry(entry.getKey()); Assert.assertEquals("For angle " + angle + "CalculateAngle returns not the correct order of outlinks", Id.create(4, Link.class), entry.getValue().getId()); - + Link leftLane = NetworkUtils.getLeftmostTurnExcludingU(net.getLinks().get(Id.create(1, Link.class))); Assert.assertEquals(Id.create(2, Link.class), leftLane.getId()); - + } } - + /** * creates a network with node 5 at 0,0 the other nodes build a cross spanning 200 m * coordinates: @@ -98,7 +98,7 @@ public void testGetOutLinksSortedByAngle(){ * | * 1 * @param sc - * @param ids + * @param ids */ private void createNetwork(Scenario sc, double alpha){ Network net = sc.getNetwork(); @@ -138,7 +138,7 @@ private void createNetwork(Scenario sc, double alpha){ link = netfac.createLink(Id.create(4, Link.class), node5, node4); net.addLink(link); } - - - -} \ No newline at end of file + + + +} diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/analysis/DelayAnalysisToolTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/analysis/DelayAnalysisToolTest.java index 6d053ad2930..468f9e7f376 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/analysis/DelayAnalysisToolTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/analysis/DelayAnalysisToolTest.java @@ -4,7 +4,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -36,52 +36,52 @@ import org.matsim.testcases.MatsimTestUtils; /** - * + * * @author tschlenther * this class tests the functionality of TtTotalDelay in playground.dgrether.koehlerstrehlersignal.analysis - * which calculates the total delay of all agents in a network - * + * which calculates the total delay of all agents in a network + * * having only one agent in a network, the total delay should be 0 (testGetTotalDelayOnePerson) * calculation of the delay of all persons in a network should be made in awareness of matsim's step logic * * the network generated in this tests basically consists of 4 links of 1000m with a free speed of 201 m/s * output is optionally written to outputDirectory of this testClass * -> set field writeOutput to do so - * + * * the number of persons to be set in the network for the test can be modified * they will get an insertion delay due to the capacity of the first link */ public class DelayAnalysisToolTest { - - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + private final Id LINK_ID1 = Id.create("Link1", Link.class); private final Id LINK_ID2 = Id.create("Link2", Link.class); private final Id LINK_ID3 = Id.create("Link3", Link.class); private final Id LINK_ID4 = Id.create("Link4", Link.class); - + //optionally to be modified private static final boolean WRITE_OUTPUT = false; private static final int NUMBER_OF_PERSONS = 5; - + @Test public void testGetTotalDelayOnePerson(){ Scenario scenario = prepareTest(1); - + EventsManager events = EventsUtils.createEventsManager(); DelayAnalysisTool handler = new DelayAnalysisTool(scenario.getNetwork(), events); - + final List eventslist = new ArrayList(); events.addHandler(new BasicEventHandler(){ @Override public void reset(int iteration) { - eventslist.clear(); + eventslist.clear(); } @Override public void handleEvent(Event event) { - eventslist.add(event); + eventslist.add(event); } }); @@ -97,19 +97,19 @@ public void handleEvent(Event event) { @Test public void testGetTotalDelaySeveralPerson(){ Scenario scenario = prepareTest(NUMBER_OF_PERSONS); - + EventsManager events = EventsUtils.createEventsManager(); DelayAnalysisTool handler = new DelayAnalysisTool(scenario.getNetwork(), events); - + final List eventslist = new ArrayList(); events.addHandler(new BasicEventHandler(){ @Override public void reset(int iteration) { - eventslist.clear(); + eventslist.clear(); } @Override public void handleEvent(Event event) { - eventslist.add(event); + eventslist.add(event); } }); @@ -119,7 +119,7 @@ public void handleEvent(Event event) { if(WRITE_OUTPUT){ generateOutput(scenario, eventslist); } - + //expectedDelay = inserting delay as a result of capacity of first link being 3600 vh/h int expectedDelay = 0; for(int i=0; i eventslist) { + private void generateOutput(Scenario scenario, final List eventslist) { EventWriterXML eventWriter = new EventWriterXML(utils.getOutputDirectory() + "events.xml"); for (Event e : eventslist) { eventWriter.handleEvent(e); @@ -145,7 +145,7 @@ private Scenario prepareTest(int numberOfPersons) { createPopulation(scenario, numberOfPersons); return scenario; } - + void createNetwork(Scenario scenario){ Network network = scenario.getNetwork(); NetworkFactory factory = network.getFactory(); @@ -167,26 +167,26 @@ void createNetwork(Scenario scenario){ link1.setLength(1000); link1.setFreespeed(201); network.addLink(link1); - - Link link2 = factory.createLink((LINK_ID2), node2, node3); + + Link link2 = factory.createLink((LINK_ID2), node2, node3); link2.setCapacity(3600); link2.setLength(1000); link2.setFreespeed(201); - network.addLink(link2); - + network.addLink(link2); + Link link3 = factory.createLink((LINK_ID3), node3 , node4); link3.setCapacity(3600); link3.setLength(1000); link3.setFreespeed(201); network.addLink(link3); - - Link link4 = factory.createLink((LINK_ID4), node4, node5); + + Link link4 = factory.createLink((LINK_ID4), node4, node5); link4.setCapacity(3600); link4.setLength(1000); link4.setFreespeed(201); - network.addLink(link4); + network.addLink(link4); } - + private void createPopulation(Scenario scenario, int numberOfPersons) { Population population = scenario.getPopulation(); PopulationFactory popFactory = (PopulationFactory) scenario.getPopulation().getFactory(); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/QSimSignalTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/QSimSignalTest.java index ef406e1aa02..62d0078f7c3 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/QSimSignalTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/QSimSignalTest.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.LinkEnterEvent; @@ -56,12 +56,12 @@ public class QSimSignalTest implements private double link2EnterTime = Double.NaN; - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); - + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); + private final Fixture fixture = new Fixture(); - - + + /** * Tests the setup with a traffic light that shows all the time green */ @@ -69,17 +69,17 @@ public class QSimSignalTest implements public void testTrafficLightIntersection2arms1AgentV20() { // configure and load standard scenario Scenario scenario = fixture.createAndLoadTestScenarioOneSignal(false ); - + this.link2EnterTime = 38.0; runQSimWithSignals(scenario, true); } /** - * Tests the setup with a traffic light that shows red up to second 99 then in sec 100 green. + * Tests the setup with a traffic light that shows red up to second 99 then in sec 100 green. */ @Test - public void testSignalSystems1AgentGreenAtSec100() { + public void testSignalSystems1AgentGreenAtSec100() { // configure and load standard scenario Scenario scenario = fixture.createAndLoadTestScenarioOneSignal(false ); // modify scenario @@ -97,7 +97,7 @@ public void testSignalSystems1AgentGreenAtSec100() { this.link2EnterTime = 100.0; runQSimWithSignals(scenario, true); } - + /** * Tests the setup with a traffic light that shows red less than the specified intergreen time of five seconds. */ @@ -115,14 +115,14 @@ public void testIntergreensAbortOneAgentDriving() { planData.setCycleTime(60); SignalGroupSettingsData groupData = planData.getSignalGroupSettingsDataByGroupId().get( fixture.signalGroupId100 ); groupData.setOnset(0); - groupData.setDropping(59); - + groupData.setDropping(59); + runQSimWithSignals(scenario, false); // if this code is reached, no exception has been thrown Assert.fail("The simulation should abort because of intergreens violation."); } - + /** * Tests the setup with a traffic light which red time corresponds to the specified intergreen time of five seconds. */ @@ -140,12 +140,12 @@ public void testIntergreensNoAbortOneAgentDriving() { planData.setCycleTime(60); SignalGroupSettingsData groupData = planData.getSignalGroupSettingsDataByGroupId().get( fixture.signalGroupId100 ); groupData.setOnset(30); - groupData.setDropping(25); - + groupData.setDropping(25); + this.link2EnterTime = 38.0; runQSimWithSignals(scenario, true); } - + /** * Tests the setup with two conflicting directions showing green together */ @@ -159,7 +159,7 @@ public void testConflictingDirectionsAbortOneAgentDriving() { // if this code is reached, no exception has been thrown Assert.fail("The simulation should abort because of intergreens violation."); } - + /** * Tests the setup with two conflicting directions not showing green together */ @@ -177,8 +177,8 @@ public void testConflictingDirectionsNoAbortOneAgentDriving() { runQSimWithSignals(scenario, false); } - - + + private void runQSimWithSignals(final Scenario scenario, boolean handleEvents) throws RuntimeException { // /* // * this is the old version how to build an injector without a controler and @@ -195,7 +195,7 @@ private void runQSimWithSignals(final Scenario scenario, boolean handleEvents) t // install(new ScenarioByInstanceModule(scenario)); // } // }), new SignalsModule())); -// +// // EventsManager events = injector.getInstance(EventsManager.class); // if (handleEvents){ // events.addHandler(this); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeFourWaysTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeFourWaysTest.java index da098163ddb..350093c5ec6 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeFourWaysTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeFourWaysTest.java @@ -21,7 +21,7 @@ package org.matsim.contrib.signals.builder; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.signals.SignalSystemsConfigGroup; @@ -49,8 +49,8 @@ public class TravelTimeFourWaysTest { private static final String EVENTSFILE = "events.xml.gz"; - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void testTrafficLightIntersection4arms() { diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeOneWayTestIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeOneWayTestIT.java index fde085e7b61..0dc9ba78923 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeOneWayTestIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeOneWayTestIT.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -66,8 +66,8 @@ public class TravelTimeOneWayTestIT { private static final Logger log = LogManager.getLogger(TravelTimeOneWayTestIT.class); - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void testSignalOutflow_withLanes() { diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java index 9e5a726548a..b7498921eae 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -81,8 +81,8 @@ public class DefaultPlanbasedSignalSystemControllerIT { private static final Logger log = LogManager.getLogger(DefaultPlanbasedSignalSystemControllerIT.class); - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void test2SequentialPlansCompleteDay(){ diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java index d5e9aaf88ca..570bb7374d4 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -64,8 +64,8 @@ public class LaemmerIT { private static final Logger log = LogManager.getLogger(LaemmerIT.class); - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); private static final int maxCycleTime = 90; private static final int cycleIntergreenTime = 10; diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java index 3954235366d..2d083c75e07 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -85,8 +85,8 @@ public class SylviaIT { private static final Logger log = LogManager.getLogger(SylviaIT.class); - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); /** * Test sylvia with two conflicting streams at a single intersection. A fixed diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/ambertimes/v10/AmberTimesData10ReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/ambertimes/v10/AmberTimesData10ReaderWriterTest.java index 30524b50342..5cccb0ced12 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/ambertimes/v10/AmberTimesData10ReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/ambertimes/v10/AmberTimesData10ReaderWriterTest.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.signals.model.Signal; @@ -37,7 +37,7 @@ /** * @author jbischoff * @author dgrether - * + * */ public class AmberTimesData10ReaderWriterTest { @@ -45,8 +45,8 @@ public class AmberTimesData10ReaderWriterTest { private static final String TESTXML = "testAmberTimes_v1.0.xml"; - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void testParser() throws IOException, JAXBException, SAXException, diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/SignalConflictDataReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/SignalConflictDataReaderWriterTest.java index 64bc0458e0d..6513066495f 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/SignalConflictDataReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/SignalConflictDataReaderWriterTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -37,31 +37,31 @@ * @author tthunig */ public class SignalConflictDataReaderWriterTest { - + private static final Logger LOG = LogManager.getLogger(SignalConflictDataReaderWriterTest.class); - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); - + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); + @Test public void testReaderAndWriter() { LOG.info("create conflict data"); ConflictData conflictData = createConflictDataForTestCase(); - + LOG.info("write conflict data"); ConflictingDirectionsWriter writer = new ConflictingDirectionsWriter(conflictData); String filename = this.testUtils.getOutputDirectory() + "signalConflictData.xml"; writer.write(filename); - + LOG.info("read conflict data"); ConflictData readConflictData = new ConflictDataImpl(); ConflictingDirectionsReader reader = new ConflictingDirectionsReader(readConflictData); reader.readFile(filename); - + LOG.info("compare written and read conflict data"); compare(conflictData, readConflictData); } - + private void compare(ConflictData conflictData1, ConflictData conflictData2) { Assert.assertEquals("not the same number of intersections", conflictData1.getConflictsPerNode().size(), conflictData2.getConflictsPerNode().size()); for (IntersectionDirections intersection1 : conflictData1.getConflictsPerSignalSystem().values()) { @@ -103,7 +103,7 @@ private void compare(ConflictData conflictData1, ConflictData conflictData2) { * < --- 1 --- > x < --- 3 --- > x < --- 4 --- > */ private ConflictData createConflictDataForTestCase() { - + Id signalSystemId1 = Id.create("sys1", SignalSystem.class); Id nodeId1 = Id.createNodeId("node1"); Id linkId1 = Id.createLinkId("link1"); @@ -118,46 +118,46 @@ private ConflictData createConflictDataForTestCase() { Id dirId23 = Id.create(linkId2 + "-" + linkId3, Direction.class); Id dirId34 = Id.create(linkId3 + "-" + linkId4, Direction.class); Id dirId43 = Id.create(linkId4 + "-" + linkId3, Direction.class); - + ConflictData conflictData = new ConflictDataImpl(); IntersectionDirections intersection1 = conflictData.getFactory().createConflictingDirectionsContainerForIntersection(signalSystemId1, nodeId1); conflictData.addConflictingDirectionsForIntersection(signalSystemId1, nodeId1, intersection1); - + Direction dir13 = conflictData.getFactory().createDirection(signalSystemId1, nodeId1, linkId1, linkId3, dirId13); intersection1.addDirection(dir13); dir13.addNonConflictingDirection(dirId31); dir13.addNonConflictingDirection(dirId12); dir13.addConflictingDirection(dirId23); - + Direction dir31 = conflictData.getFactory().createDirection(signalSystemId1, nodeId1, linkId3, linkId1, dirId31); intersection1.addDirection(dir31); dir31.addNonConflictingDirection(dirId13); dir31.addDirectionWhichMustYield(dirId12); dir31.addConflictingDirection(dirId23); - + Direction dir12 = conflictData.getFactory().createDirection(signalSystemId1, nodeId1, linkId1, linkId2, dirId12); intersection1.addDirection(dir12); dir12.addNonConflictingDirection(dirId13); dir12.addDirectionWithRightOfWay(dirId31); dir12.addConflictingDirection(dirId23); - + Direction dir23 = conflictData.getFactory().createDirection(signalSystemId1, nodeId1, linkId2, linkId3, dirId23); intersection1.addDirection(dir23); dir23.addConflictingDirection(dirId12); dir23.addConflictingDirection(dirId13); dir23.addConflictingDirection(dirId31); - + IntersectionDirections intersection2 = conflictData.getFactory().createConflictingDirectionsContainerForIntersection(signalSystemId2, nodeId2); conflictData.addConflictingDirectionsForIntersection(signalSystemId2, nodeId2, intersection2); - + Direction dir34 = conflictData.getFactory().createDirection(signalSystemId2, nodeId2, linkId3, linkId4, dirId34); intersection2.addDirection(dir34); dir34.addNonConflictingDirection(dirId43); - + Direction dir43 = conflictData.getFactory().createDirection(signalSystemId2, nodeId2, linkId4, linkId3, dirId43); intersection2.addDirection(dir43); dir43.addNonConflictingDirection(dirId43); - + return conflictData; } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/UnprotectedLeftTurnLogicTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/UnprotectedLeftTurnLogicTest.java index e33fed5dc46..92eef4f43c2 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/UnprotectedLeftTurnLogicTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/UnprotectedLeftTurnLogicTest.java @@ -21,7 +21,7 @@ package org.matsim.contrib.signals.data.conflicts; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.signals.SignalSystemsConfigGroup; @@ -41,8 +41,8 @@ */ public class UnprotectedLeftTurnLogicTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void testSingleIntersectionScenarioWithLeftTurns() { diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/intergreens/v10/IntergreenTimesData10ReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/intergreens/v10/IntergreenTimesData10ReaderWriterTest.java index 593cc5868da..794b36a3482 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/intergreens/v10/IntergreenTimesData10ReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/intergreens/v10/IntergreenTimesData10ReaderWriterTest.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.signals.model.SignalGroup; @@ -37,7 +37,7 @@ /** * @author dgrether - * + * */ public class IntergreenTimesData10ReaderWriterTest { @@ -45,8 +45,8 @@ public class IntergreenTimesData10ReaderWriterTest { private static final String TESTXML = "testIntergreenTimes_v1.0.xml"; - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); private Id groupId1 = Id.create("1", SignalGroup.class); private Id groupId2 = Id.create("2", SignalGroup.class); @@ -97,7 +97,7 @@ private void checkContent(IntergreenTimesData itd) { Assert.assertEquals(Integer.valueOf(3), ig23.getIntergreenTime(groupId1, groupId3)); Assert.assertEquals(Integer.valueOf(3), ig23.getIntergreenTime(groupId1, groupId4)); Assert.assertNull(ig23.getIntergreenTime(groupId2, groupId3)); - + IntergreensForSignalSystemData ig42 = itd.getIntergreensForSignalSystemDataMap().get(systemId42); Assert.assertNotNull(ig42); Assert.assertEquals(Integer.valueOf(5), ig42.getIntergreenTime(groupId1, groupId2)); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalcontrol/v20/SignalControlData20ReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalcontrol/v20/SignalControlData20ReaderWriterTest.java index 26956aa1cbe..7decd766c3a 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalcontrol/v20/SignalControlData20ReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalcontrol/v20/SignalControlData20ReaderWriterTest.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.signals.data.signalsystems.v20.SignalSystemControllerData; @@ -39,7 +39,7 @@ /** * @author dgrether - * + * */ public class SignalControlData20ReaderWriterTest { @@ -48,19 +48,19 @@ public class SignalControlData20ReaderWriterTest { private static final String TESTXML = "testSignalControl_v2.0.xml"; private Id systemId42 = Id.create("42", SignalSystem.class); - + private Id signalPlanId8 = Id.create("8", SignalPlan.class); - + private Id groupId23 = Id.create("23", SignalGroup.class); - + private Id systemId43 = Id.create("43", SignalSystem.class); - + // private Id id24 = new IdImpl("24"); // private Id id5 = new IdImpl("5"); - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void testReader() throws JAXBException, SAXException, ParserConfigurationException, IOException{ @@ -69,7 +69,7 @@ public void testReader() throws JAXBException, SAXException, ParserConfiguration reader.readFile(this.testUtils.getPackageInputDirectory() + TESTXML); checkContent(controlData); } - + @Test public void testWriter() throws JAXBException, SAXException, ParserConfigurationException, IOException { String testoutput = this.testUtils.getOutputDirectory() + "testSignalControlOutput.xml"; @@ -78,12 +78,12 @@ public void testWriter() throws JAXBException, SAXException, ParserConfiguration SignalControlData controlData = new SignalControlDataImpl(); SignalControlReader20 reader = new SignalControlReader20(controlData); reader.readFile(this.testUtils.getPackageInputDirectory() + TESTXML); - + //write the test file log.debug("write the test file..."); SignalControlWriter20 writer = new SignalControlWriter20(controlData); writer.write(testoutput); - + log.debug("and read it again"); controlData = new SignalControlDataImpl(); reader = new SignalControlReader20(controlData); @@ -91,13 +91,13 @@ public void testWriter() throws JAXBException, SAXException, ParserConfiguration checkContent(controlData); } - - - + + + private void checkContent(SignalControlData controlData) { Assert.assertNotNull(controlData); Assert.assertEquals(2, controlData.getSignalSystemControllerDataBySystemId().size()); - + //first controller SignalSystemControllerData systemController = controlData.getSignalSystemControllerDataBySystemId().get(systemId42); Assert.assertNotNull(systemController); @@ -114,7 +114,7 @@ private void checkContent(SignalControlData controlData) { Assert.assertNotNull(cycleTime); Assert.assertEquals(Integer.valueOf(60), cycleTime); Assert.assertEquals(3, plan.getOffset()); - + Assert.assertNotNull(plan.getSignalGroupSettingsDataByGroupId()); SignalGroupSettingsData signalGroupSettings = plan.getSignalGroupSettingsDataByGroupId().get(groupId23); Assert.assertNotNull(signalGroupSettings); @@ -123,7 +123,7 @@ private void checkContent(SignalControlData controlData) { Assert.assertEquals(0, signalGroupSettings.getOnset()); Assert.assertNotNull(signalGroupSettings.getDropping()); Assert.assertEquals(45, signalGroupSettings.getDropping()); - + //second controller systemController = controlData.getSignalSystemControllerDataBySystemId().get(systemId43); Assert.assertNotNull(systemController); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalgroups/v20/SignalGroups20ReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalgroups/v20/SignalGroups20ReaderWriterTest.java index 6b36fac7401..a6d27f26127 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalgroups/v20/SignalGroups20ReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalgroups/v20/SignalGroups20ReaderWriterTest.java @@ -30,7 +30,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.signals.model.Signal; @@ -42,15 +42,15 @@ /** * @author jbischoff * @author dgrether -* +* */ public class SignalGroups20ReaderWriterTest { private static final Logger log = LogManager.getLogger(SignalGroups20ReaderWriterTest.class); private static final String TESTXML = "testSignalGroups_v2.0.xml"; - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); private Id id23 = Id.create("23", SignalSystem.class); private Id id1 = Id.create("1", Signal.class); @@ -71,7 +71,7 @@ public void testParser() throws IOException, JAXBException, SAXException, checkContent(sgd); } - + @Test public void testWriter() throws JAXBException, SAXException, ParserConfigurationException, IOException { @@ -93,21 +93,21 @@ public void testWriter() throws JAXBException, SAXException, ParserConfiguration reader.readFile(testoutput); checkContent(sgd); } - - + + private void checkContent(SignalGroupsData sgd) { Assert.assertNotNull(sgd); Assert.assertNotNull(sgd.getSignalGroupDataBySignalSystemId()); Assert.assertNotNull(sgd.getSignalGroupDataBySystemId(id23)); - + //sg23 Map,SignalGroupData> ss23 = sgd.getSignalGroupDataBySystemId(id23); Assert.assertEquals(id23,ss23.get(idSg1).getSignalSystemId()); Set> sg = ss23.get(idSg1).getSignalIds(); Assert.assertTrue(sg.contains(id1)); - + //sg42 Assert.assertNotNull(sgd.getSignalGroupDataBySystemId(id42)); Map,SignalGroupData> ss42 = sgd.getSignalGroupDataBySystemId(id42); @@ -119,17 +119,17 @@ private void checkContent(SignalGroupsData sgd) { Assert.assertTrue(sg.contains(id1)); Assert.assertTrue(sg.contains(id4)); Assert.assertTrue(sg.contains(id5)); - - - - + + + + } - - + + } - - - - + + + + diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalsystems/v20/SignalSystemsData20ReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalsystems/v20/SignalSystemsData20ReaderWriterTest.java index 17ab6161634..88fa1c1e46d 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalsystems/v20/SignalSystemsData20ReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalsystems/v20/SignalSystemsData20ReaderWriterTest.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -44,37 +44,37 @@ * @author dgrether */ public class SignalSystemsData20ReaderWriterTest { - + private static final Logger log = LogManager.getLogger(SignalSystemsData20ReaderWriterTest.class); - + private static final String TESTXML = "testSignalSystems_v2.0.xml"; - - @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); - + + @RegisterExtension public MatsimTestUtils testUtils = new MatsimTestUtils(); + private Id systemId1 = Id.create("1", SignalSystem.class); private Id signalId1 = Id.create("1", Signal.class); private Id laneId1 = Id.create("1", Lane.class); private Id linkId1 = Id.create("1", Link.class); - + private Id systemId2 = Id.create("2", SignalSystem.class); private Id signalId2 = Id.create("2", Signal.class); private Id linkId2 = Id.create("2", Link.class); private Id laneId2 = Id.create("2", Lane.class); - + private Id signalId3 = Id.create("3", Signal.class); private Id linkId3 = Id.create("3", Link.class); - + private Id linkId4 = Id.create("4", Link.class); - + @Test public void testParser() throws IOException, JAXBException, SAXException, ParserConfigurationException { SignalSystemsData lss = new SignalSystemsDataImpl(); SignalSystemsReader20 reader = new SignalSystemsReader20(lss); reader.readFile(this.testUtils.getPackageInputDirectory() + TESTXML); - + checkContent(lss); } - + @Test public void testWriter() throws JAXBException, SAXException, ParserConfigurationException, IOException { String testoutput = this.testUtils.getOutputDirectory() + "testLssOutput.xml"; @@ -83,12 +83,12 @@ public void testWriter() throws JAXBException, SAXException, ParserConfiguration SignalSystemsData lss = new SignalSystemsDataImpl(); SignalSystemsReader20 reader = new SignalSystemsReader20(lss); reader.readFile(this.testUtils.getPackageInputDirectory() + TESTXML); - + //write the test file log.debug("write the test file..."); SignalSystemsWriter20 writer = new SignalSystemsWriter20(lss); writer.write(testoutput); - + log.debug("and read it again"); lss = new SignalSystemsDataImpl(); reader = new SignalSystemsReader20(lss); @@ -101,14 +101,14 @@ private void checkContent(SignalSystemsData ss) { SignalSystemData ssdata = ss.getSignalSystemData().get(systemId1); Assert.assertNotNull(ssdata); Assert.assertEquals(2, ssdata.getSignalData().size()); - + SignalData signaldata = ssdata.getSignalData().get(signalId1); Assert.assertNotNull(signaldata); Assert.assertEquals(signalId1, signaldata.getId()); Assert.assertEquals(linkId1, signaldata.getLinkId()); Assert.assertNull(signaldata.getLaneIds()); Assert.assertNull(signaldata.getTurningMoveRestrictions()); - + signaldata = ssdata.getSignalData().get(signalId2); Assert.assertNotNull(signaldata); Assert.assertEquals(signalId2, signaldata.getId()); @@ -117,8 +117,8 @@ private void checkContent(SignalSystemsData ss) { Assert.assertEquals(1, signaldata.getTurningMoveRestrictions().size()); Assert.assertEquals(linkId3, signaldata.getTurningMoveRestrictions().iterator().next()); Assert.assertNull(signaldata.getLaneIds()); - - //system id 2 + + //system id 2 ssdata = ss.getSignalSystemData().get(systemId2); Assert.assertNotNull(ssdata); @@ -141,7 +141,7 @@ private void checkContent(SignalSystemsData ss) { Assert.assertNotNull(signaldata.getTurningMoveRestrictions()); Assert.assertEquals(1, signaldata.getTurningMoveRestrictions().size()); Assert.assertTrue(signaldata.getTurningMoveRestrictions().contains(linkId3)); - + } } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/SignalSystemsIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/SignalSystemsIT.java index 96b73fa8a3d..c3be6656303 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/SignalSystemsIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/SignalSystemsIT.java @@ -20,7 +20,7 @@ package org.matsim.contrib.signals.integration; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.signals.builder.Signals; @@ -48,8 +48,8 @@ public class SignalSystemsIT { private final static String CONFIG_FILE_NAME = "signalSystemsIntegrationConfig.xml"; - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void testSignalSystems() { diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/invertednetworks/InvertedNetworksSignalsIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/invertednetworks/InvertedNetworksSignalsIT.java index 3515b7fba6e..643e89a87b8 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/invertednetworks/InvertedNetworksSignalsIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/invertednetworks/InvertedNetworksSignalsIT.java @@ -20,7 +20,7 @@ package org.matsim.contrib.signals.integration.invertednetworks; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -43,8 +43,8 @@ * */ public class InvertedNetworksSignalsIT { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public final void testSignalsInvertedNetworkRouting() { diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java index 7a8db642e1c..f2dd03ed0a0 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java @@ -14,7 +14,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -63,8 +63,8 @@ public class SignalsAndLanesOsmNetworkReaderTest { private static final Logger log = LogManager.getLogger(SignalsAndLanesOsmNetworkReaderTest.class); - @Rule - public MatsimTestUtils matsimTestUtils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils matsimTestUtils = new MatsimTestUtils(); @Parameterized.Parameters public static Collection data() { diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/ControlerTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/ControlerTest.java index 6b981e6ba59..8f1d630c363 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/ControlerTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/ControlerTest.java @@ -21,7 +21,7 @@ import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -50,8 +50,8 @@ */ public class ControlerTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); /** * Tests the setup with a traffic light that shows all the time green in the 0th iteration. diff --git a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingConfigGroupTest.java b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingConfigGroupTest.java index be3f8870410..f9fd687abc1 100644 --- a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingConfigGroupTest.java +++ b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingConfigGroupTest.java @@ -9,14 +9,16 @@ package org.matsim.contrib.simulatedannealing; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; +import org.junit.jupiter.api.io.TempDir; import org.junit.rules.TemporaryFolder; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.testcases.MatsimTestUtils; import org.matsim.contrib.simulatedannealing.temperature.TemperatureFunction; +import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.util.Map; @@ -26,8 +28,8 @@ */ public class SimulatedAnnealingConfigGroupTest { - @Rule - public TemporaryFolder tempFolder = new TemporaryFolder(); + @TempDir + public File tempFolder; private static Config createConfig() { Config config = ConfigUtils.createConfig(); @@ -42,9 +44,9 @@ private static Config createConfig() { } - private static Path writeConfig(final TemporaryFolder tempFolder) throws IOException { + private static Path writeConfig(final File tempFolder) throws IOException { Config config = createConfig(); - Path configFile = tempFolder.newFile("config.xml").toPath(); + Path configFile = new File(tempFolder,"config.xml").toPath(); ConfigUtils.writeConfig(config, configFile.toString()); return configFile; } diff --git a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingIT.java b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingIT.java index a8622e6ba36..87e9026ec3e 100644 --- a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingIT.java +++ b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingIT.java @@ -1,7 +1,7 @@ package org.matsim.contrib.simulatedannealing; import com.google.inject.TypeLiteral; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.LinkLeaveEvent; @@ -31,8 +31,8 @@ */ public class SimulatedAnnealingIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testIntegratedAnnealingInQSim() { diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperConfigGroupTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperConfigGroupTest.java index 76798aa58bb..9d3f59ae4e8 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperConfigGroupTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperConfigGroupTest.java @@ -1,7 +1,7 @@ package org.matsim.simwrapper; import org.assertj.core.api.Assertions; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -10,8 +10,8 @@ public class SimWrapperConfigGroupTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void config() { diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperModuleTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperModuleTest.java index 0e781bb830d..8a6cdeba974 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperModuleTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperModuleTest.java @@ -1,6 +1,6 @@ package org.matsim.simwrapper; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -13,8 +13,8 @@ public class SimWrapperModuleTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void runScenario() { diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperTest.java index 91ab0825970..b9e985f1fee 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperTest.java @@ -1,7 +1,7 @@ package org.matsim.simwrapper; import org.assertj.core.api.Assertions; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.simwrapper.viz.*; @@ -14,8 +14,8 @@ public class SimWrapperTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void vizElementsTest() throws IOException { diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/DashboardTests.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/DashboardTests.java index 394797cdea9..1b103bdd313 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/DashboardTests.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/DashboardTests.java @@ -1,7 +1,7 @@ package org.matsim.simwrapper.dashboard; import org.assertj.core.api.Assertions; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.application.MATSimApplication; import org.matsim.core.config.Config; @@ -16,8 +16,8 @@ import java.nio.file.Path; public class DashboardTests { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private void run(Dashboard... dashboards) { diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/EmissionsDashboardTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/EmissionsDashboardTest.java index 5fd6f285973..c14a93d3d82 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/EmissionsDashboardTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/EmissionsDashboardTest.java @@ -3,7 +3,7 @@ import com.google.common.collect.Iterables; import org.assertj.core.api.Assertions; import org.junit.Assume; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -33,8 +33,8 @@ public class EmissionsDashboardTest { private static final String HBEFA_FILE_COLD_AVERAGE = HBEFA_2020_PATH + "r9230ru2n209r30u2fn0c9rn20n2rujkhkjhoewt84202.enc"; private static final String HBEFA_FILE_WARM_AVERAGE = HBEFA_2020_PATH + "7eff8f308633df1b8ac4d06d05180dd0c5fdf577.enc"; - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void generate() { diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/TrafficCountsDashboardTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/TrafficCountsDashboardTest.java index 876e5d01552..8078e9c6e44 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/TrafficCountsDashboardTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/TrafficCountsDashboardTest.java @@ -1,7 +1,7 @@ package org.matsim.simwrapper.dashboard; import org.assertj.core.api.Assertions; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -28,8 +28,8 @@ public class TrafficCountsDashboardTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void generate() { diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyExamplesTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyExamplesTest.java index 1bbd1c1e631..6fc28108a5b 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyExamplesTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyExamplesTest.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.ObjectWriter; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; import tech.tablesaw.api.IntColumn; @@ -27,8 +27,8 @@ */ public class PlotlyExamplesTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private ObjectWriter writer; diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyTest.java index 8009eb1d981..987f1464e0b 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyTest.java @@ -11,7 +11,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.assertj.core.api.Assertions; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.simwrapper.ComponentMixin; import org.matsim.testcases.MatsimTestUtils; @@ -28,8 +28,8 @@ public class PlotlyTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private ObjectWriter writer; diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanIOTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanIOTest.java index 95c103aa9c7..56cf258be11 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanIOTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanIOTest.java @@ -27,7 +27,7 @@ import java.util.Random; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -46,7 +46,7 @@ * @author thibautd */ public class JointPlanIOTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkIOTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkIOTest.java index 86d755078b6..9bc61d77eee 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkIOTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkIOTest.java @@ -25,7 +25,7 @@ import java.util.Set; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -39,7 +39,7 @@ * @author thibautd */ public class SocialNetworkIOTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/FixedGroupsIT.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/FixedGroupsIT.java index 08b2ba9c53f..80a234c05fe 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/FixedGroupsIT.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/FixedGroupsIT.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -46,7 +46,7 @@ * @author thibautd */ public class FixedGroupsIT { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/FullExplorationVsCuttoffTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/FullExplorationVsCuttoffTest.java index e3e19d4dba3..5bc566bb884 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/FullExplorationVsCuttoffTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/FullExplorationVsCuttoffTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Ignore; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.population.Plan; import org.matsim.core.utils.collections.Tuple; @@ -44,7 +44,7 @@ public class FullExplorationVsCuttoffTest { private static final Logger log = LogManager.getLogger(FullExplorationVsCuttoffTest.class); - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/qsim/JointTravelingSimulationIntegrationTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/qsim/JointTravelingSimulationIntegrationTest.java index 5aadbb30477..9a86bd3f1bb 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/qsim/JointTravelingSimulationIntegrationTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/qsim/JointTravelingSimulationIntegrationTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -79,7 +79,7 @@ public class JointTravelingSimulationIntegrationTest { private static final Logger log = LogManager.getLogger(JointTravelingSimulationIntegrationTest.class); - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); private static enum RouteType { @@ -87,7 +87,7 @@ private static enum RouteType { puAtDo, puAtDoFullCycle, everythingAtOrigin - }; + }; // helps to understand test failures, but makes the test more expensive. // => to set to true when fixing tests only @@ -454,7 +454,7 @@ private Scenario createTestScenario( fixture.puLink, fixture.doLink ); dRoute.setLinkIds( - fixture.puLink , + fixture.puLink , fixture.puToDoRoute, fixture.doLink); dRoute.addPassenger( passengerId1 ); @@ -489,7 +489,7 @@ private Scenario createTestScenario( driverPlan.addActivity( act ); } - // passengers + // passengers for (Id passengerId : new Id[]{ passengerId1 , passengerId2 }) { final Person p1 = factory.createPerson( passengerId ); final Plan p1Plan = factory.createPlan(); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/JointScenarioUtilsTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/JointScenarioUtilsTest.java index 99da384c041..ceeca695ac9 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/JointScenarioUtilsTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/JointScenarioUtilsTest.java @@ -23,7 +23,7 @@ import java.util.Collection; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -47,7 +47,7 @@ * @author thibautd */ public class JointScenarioUtilsTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test @@ -80,7 +80,7 @@ public void testJointTripsImport() throws Exception { final Leg dumpedLeg = (Leg) dumpedPlan.getPlanElements().get( 1 ); final Leg loadedLeg = (Leg) loadedPlan.getPlanElements().get( 1 ); - + if (dumpedLeg.getMode().equals( JointActingTypes.DRIVER )) { assertEquals( "wrong route class", @@ -121,7 +121,7 @@ private static Population createPopulation() { final Plan driverPlan = population.getFactory().createPlan(); driverPlan.setPerson( driver ); driver.addPlan( driverPlan ); - + driverPlan.addActivity( population.getFactory().createActivityFromLinkId( "h" , Id.create( 1 , Link.class ) ) ); final Leg driverLeg = population.getFactory().createLeg( JointActingTypes.DRIVER ); final DriverRoute dRoute = new DriverRoute( Id.create( 1 , Link.class ) , Id.create( 1 , Link.class ) ); @@ -137,7 +137,7 @@ private static Population createPopulation() { final Plan passengerPlan = population.getFactory().createPlan(); passengerPlan.setPerson( passenger ); passenger.addPlan( passengerPlan ); - + passengerPlan.addActivity( population.getFactory().createActivityFromLinkId( "h" , Id.create( 1 , Link.class ) ) ); final Leg passengerLeg = population.getFactory().createLeg( JointActingTypes.PASSENGER ); final PassengerRoute pRoute = new PassengerRoute( Id.create( 1 , Link.class ) , Id.create( 1 , Link.class ) ); diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiBenchmarkTest.java b/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiBenchmarkTest.java index 9d1febf7f0e..364bbb5a39a 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiBenchmarkTest.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiBenchmarkTest.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; @@ -34,7 +34,7 @@ public class RunETaxiBenchmarkTest { private static final Logger log = LogManager.getLogger(RunETaxiBenchmarkTest.class); - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiScenarioIT.java b/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiScenarioIT.java index b3a755f34bb..218ca340f49 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiScenarioIT.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiScenarioIT.java @@ -19,7 +19,7 @@ package org.matsim.contrib.etaxi.run; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Population; @@ -35,8 +35,8 @@ * @author michalm */ public class RunETaxiScenarioIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testOneTaxi() { diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/assignment/AssignmentTaxiOptimizerIT.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/assignment/AssignmentTaxiOptimizerIT.java index 515c8e718ad..baae47ffdb2 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/assignment/AssignmentTaxiOptimizerIT.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/assignment/AssignmentTaxiOptimizerIT.java @@ -21,13 +21,13 @@ import static org.matsim.contrib.taxi.optimizer.TaxiOptimizerTests.runBenchmark; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.contrib.taxi.optimizer.assignment.TaxiToRequestAssignmentCostProvider.Mode; import org.matsim.testcases.MatsimTestUtils; public class AssignmentTaxiOptimizerIT { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/fifo/FifoTaxiOptimizerIT.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/fifo/FifoTaxiOptimizerIT.java index e3b68f9c374..3e4b0ebefdf 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/fifo/FifoTaxiOptimizerIT.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/fifo/FifoTaxiOptimizerIT.java @@ -21,12 +21,12 @@ import static org.matsim.contrib.taxi.optimizer.TaxiOptimizerTests.runBenchmark; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; public class FifoTaxiOptimizerIT { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/rules/RuleBasedTaxiOptimizerIT.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/rules/RuleBasedTaxiOptimizerIT.java index 41259b9828e..2d58410b364 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/rules/RuleBasedTaxiOptimizerIT.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/rules/RuleBasedTaxiOptimizerIT.java @@ -21,13 +21,13 @@ import static org.matsim.contrib.taxi.optimizer.TaxiOptimizerTests.runBenchmark; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.contrib.taxi.optimizer.rules.RuleBasedRequestInserter.Goal; import org.matsim.testcases.MatsimTestUtils; public class RuleBasedTaxiOptimizerIT { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/zonal/ZonalTaxiOptimizerIT.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/zonal/ZonalTaxiOptimizerIT.java index 648b36a8da7..370a7f37e3a 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/zonal/ZonalTaxiOptimizerIT.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/zonal/ZonalTaxiOptimizerIT.java @@ -22,7 +22,7 @@ import static org.matsim.contrib.taxi.optimizer.TaxiOptimizerTests.runBenchmark; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.contrib.taxi.optimizer.rules.RuleBasedRequestInserter.Goal; import org.matsim.contrib.taxi.optimizer.rules.RuleBasedTaxiOptimizerParams; @@ -30,7 +30,7 @@ import org.matsim.testcases.MatsimTestUtils; public class ZonalTaxiOptimizerIT { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/RunTaxiScenarioTestIT.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/RunTaxiScenarioTestIT.java index 7e991fdfebe..714104455e7 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/RunTaxiScenarioTestIT.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/RunTaxiScenarioTestIT.java @@ -21,7 +21,7 @@ import java.net.URL; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.contrib.dvrp.run.DvrpConfigGroup; import org.matsim.core.config.Config; @@ -32,7 +32,7 @@ import org.matsim.vis.otfvis.OTFVisConfigGroup; public class RunTaxiScenarioTestIT { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesIT.java b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesIT.java index 7d838d4178a..3ed9158cf9f 100644 --- a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesIT.java +++ b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesIT.java @@ -20,7 +20,7 @@ package org.matsim.core.scoring.functions; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -41,8 +41,8 @@ public class PersonScoringParametersFromPersonAttributesIT { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils testUtils = new MatsimTestUtils(); @SuppressWarnings("unchecked") @Test diff --git a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java index bb9ca23ac4a..2db28b64006 100644 --- a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java +++ b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java @@ -21,7 +21,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -50,8 +50,8 @@ */ public class PersonScoringParametersFromPersonAttributesNoSubpopulationTest { - @Rule - public MatsimTestUtils utils; + @RegisterExtension + private MatsimTestUtils utils; private PersonScoringParametersFromPersonAttributes personScoringParams; private Population population; diff --git a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java index cb7da7c9069..f7cd61abd9c 100644 --- a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java +++ b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java @@ -21,7 +21,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -50,8 +50,8 @@ */ public class PersonScoringParametersFromPersonAttributesTest { - @Rule - public MatsimTestUtils utils; + @RegisterExtension + private MatsimTestUtils utils; private PersonScoringParametersFromPersonAttributes personScoringParams; private Population population; diff --git a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest.java b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest.java index b34c72ac10b..da7035be7e5 100644 --- a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest.java +++ b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest.java @@ -21,7 +21,7 @@ package org.matsim.freight.carriers.analysis; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -29,8 +29,8 @@ public class FreightAnalysisEventBasedTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void runFreightAnalysisEventBasedTest() throws IOException { diff --git a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java index 8dec71ea7f9..54d9471758b 100644 --- a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java +++ b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java @@ -38,8 +38,8 @@ public class RunFreightAnalysisIT { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Before public void runAnalysis(){ diff --git a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisWithShipmentTest.java b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisWithShipmentTest.java index 358b79d8ad4..6a60941db1f 100644 --- a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisWithShipmentTest.java +++ b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisWithShipmentTest.java @@ -22,7 +22,7 @@ package org.matsim.freight.carriers.analysis; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -44,8 +44,8 @@ public class RunFreightAnalysisWithShipmentTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void runShipmentTrackerTest(){ diff --git a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java index f9daad794d9..c42b548f626 100644 --- a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java +++ b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java @@ -11,7 +11,7 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Ignore; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -68,8 +68,8 @@ public class PtAlongALine2Test { private static final Logger log = LogManager.getLogger(PtAlongALine2Test.class); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); enum DrtMode {none, teleportBeeline, teleportBasedOnNetworkRoute, full, withPrebooking} diff --git a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java index 67534b4b205..d8736f176fc 100644 --- a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java +++ b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java @@ -4,7 +4,7 @@ import java.util.Set; import org.junit.Ignore; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -48,8 +48,8 @@ public class PtAlongALineTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Ignore @Test diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/osmBB/PTCountsNetworkSimplifierTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/osmBB/PTCountsNetworkSimplifierTest.java index 4e787e84544..d549920130b 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/osmBB/PTCountsNetworkSimplifierTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/osmBB/PTCountsNetworkSimplifierTest.java @@ -24,7 +24,7 @@ import java.util.TreeSet; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -38,8 +38,8 @@ public class PTCountsNetworkSimplifierTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** * Test simple network diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java index 0974c7e40da..db7023afb6a 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java @@ -1,6 +1,6 @@ package playground.vsp.cadyts.marginals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -54,8 +54,8 @@ public static Collection parameterObjects() { }); } - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private double countsWeight; private double modalDistanceWeight; diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java index c1a5a6a1e74..ad2500ce36f 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java @@ -1,6 +1,6 @@ package playground.vsp.cadyts.marginals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -43,8 +43,8 @@ import static org.junit.Assert.assertEquals; public class ModalDistanceCadytsMultipleDistancesIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** * This test runs a population of 1000 agents which have the same home and work place. All agents start with two plans. diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java index cbd93316434..94c68a9d5bd 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java @@ -19,7 +19,7 @@ package playground.vsp.cadyts.marginals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -58,8 +58,8 @@ public class ModalDistanceCadytsSingleDistanceIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); /** * This test runs a population of 1000 agents which have the same home and work place. All agents start with two plans. diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java index 83439dd2480..e0c7d42e18a 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java @@ -1,6 +1,6 @@ package playground.vsp.cadyts.marginals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -28,8 +28,8 @@ public class TripEventHandlerTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** * This test takes the pt-tutorial from the scenarios module and performs one iteration. Afterwards it is tested diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java b/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java index 78942907bdf..22b9e50abc3 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java @@ -29,7 +29,7 @@ import jakarta.inject.Provider; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -71,8 +71,8 @@ */ public class AdvancedMarginalCongestionPricingIT { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); // test normal activities @Test diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/CombinedFlowAndStorageDelayTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/CombinedFlowAndStorageDelayTest.java index 1a9ea4b22fe..792eb498409 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/CombinedFlowAndStorageDelayTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/CombinedFlowAndStorageDelayTest.java @@ -22,7 +22,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -57,16 +57,16 @@ /** * Accounting for flow delays even if leaving agents list is empty. - * + * * @author amit */ public class CombinedFlowAndStorageDelayTest { - + private final boolean usingOTFVis = false; - - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); /** * Basically agent first delay due to flow cap and then when agent can leave the link, it is delayed due to storage cap @@ -77,40 +77,40 @@ public class CombinedFlowAndStorageDelayTest { @Test public final void implV4Test(){ /* - * In the test, two routes (1-2-3-4 and 5-3-4) are assigned to agents. First two agents (1,2) start on first route and next two (3,4) on + * In the test, two routes (1-2-3-4 and 5-3-4) are assigned to agents. First two agents (1,2) start on first route and next two (3,4) on * other route. After agent 1 leave the link 2 (marginal flow delay =100), agent 2 is delayed. Mean while, before agent 2 can move to next link, * link 3 is blocked by agent 3 (departed on link 5). Thus, agent 2 on link 2 is delayed. Causing agents should be 1 (flow cap), 4 (storage cap). */ List congestionEvents = getAffectedPersonId2Delays("v4"); - + for(CongestionEvent e : congestionEvents){ if(e.getAffectedAgentId().equals(Id.createPersonId("2")) && e.getCausingAgentId().equals(Id.createPersonId("1"))){ Assert.assertEquals("Delay caused by agent 2 is not correct.", 100, e.getDelay(), MatsimTestUtils.EPSILON); // this is not captured by only leaving agents list. - } + } } - + Assert.assertEquals("Number of congestion events are not correct.", 4, congestionEvents.size(), MatsimTestUtils.EPSILON); } // @Test public final void implV6Test(){ /* - * In the test, two routes (1-2-3-4 and 5-3-4) are assigned to agents. First two agents (1,2) start on first route and next two (3,4) on + * In the test, two routes (1-2-3-4 and 5-3-4) are assigned to agents. First two agents (1,2) start on first route and next two (3,4) on * other route. After agent 1 leave the link 2 (marginal flow delay =100), agent 2 is delayed. Mean while, before agent 2 can move to next link, * link 3 is blocked by agent 3 (departed on link 5). Thus, agent 2 on link 2 is delayed. Causing agents should be 1 (flow cap), 4 (storage cap). */ List congestionEvents = getAffectedPersonId2Delays("v6"); - + for(CongestionEvent e : congestionEvents){ if(e.getAffectedAgentId().equals(Id.createPersonId("2")) && e.getLinkId().equals(Id.createLinkId("2"))){ Assert.assertEquals("Wrong causing agent", Id.createPersonId("1"), e.getCausingAgentId()); // this is not captured by only leaving agents list. - } + } } Assert.assertEquals("Number of congestion events are not correct.", 3, congestionEvents.size(), MatsimTestUtils.EPSILON); } - + private List getAffectedPersonId2Delays(String congestionPricingImpl){ createPseudoInputs pseudoInputs = new createPseudoInputs(); @@ -132,7 +132,7 @@ private List getAffectedPersonId2Delays(String congestionPricin events.addHandler( new CongestionEventHandler() { @Override - public void reset(int iteration) { + public void reset(int iteration) { } @Override @@ -190,7 +190,7 @@ private void createNetwork(){ link4 = NetworkUtils.createAndAddLink(network,Id.createLinkId(String.valueOf("4")), fromNode3, toNode3, 100.0, 20.0, (double) 3600, (double) 1, null, (String) "7"); final Node fromNode4 = node1; final Node toNode4 = node3; - + link5 = NetworkUtils.createAndAddLink(network,Id.createLinkId(String.valueOf("5")), fromNode4, toNode4, 100.0, 20.0, (double) 3600, (double) 1, null, (String) "7"); } diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowQueueQsimTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowQueueQsimTest.java index 3e8bb3f8909..06b51cf1a47 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowQueueQsimTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowQueueQsimTest.java @@ -1,388 +1,388 @@ -/* *********************************************************************** * - * project: org.matsim.* - * * - * *********************************************************************** * - * * - * copyright : (C) 2013 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -/** - * - */ -package playground.vsp.congestion; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.matsim.api.core.v01.Coord; -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.Scenario; -import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; -import org.matsim.api.core.v01.network.Node; -import org.matsim.api.core.v01.population.Activity; -import org.matsim.api.core.v01.population.Leg; -import org.matsim.api.core.v01.population.Person; -import org.matsim.api.core.v01.population.Plan; -import org.matsim.api.core.v01.population.Population; -import org.matsim.api.core.v01.population.PopulationFactory; -import org.matsim.core.api.experimental.events.EventsManager; -import org.matsim.core.config.Config; -import org.matsim.core.config.groups.QSimConfigGroup; -import org.matsim.core.controler.PrepareForSimUtils; -import org.matsim.core.events.EventsUtils; -import org.matsim.core.mobsim.qsim.QSim; -import org.matsim.core.mobsim.qsim.QSimBuilder; -import org.matsim.core.population.PopulationUtils; -import org.matsim.core.population.routes.LinkNetworkRouteFactory; -import org.matsim.core.population.routes.NetworkRoute; -import org.matsim.core.scenario.ScenarioUtils; -import org.matsim.testcases.MatsimTestUtils; - -import playground.vsp.congestion.events.CongestionEvent; -import playground.vsp.congestion.handlers.CongestionEventHandler; -import playground.vsp.congestion.handlers.CongestionHandlerImplV3; -import playground.vsp.congestion.handlers.CongestionHandlerImplV7; -import playground.vsp.congestion.handlers.CongestionHandlerImplV8; - -/** - * Simple scenario setup: - * Three agents moving along a corridor with unlimited storage capacity; arriving simultaneously at the bottleneck. - * - * @author ikaddoura , lkroeger - * - */ - -public class MarginalCongestionHandlerFlowQueueQsimTest { - - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); - - private EventsManager events; - - private Id testAgent1 = Id.create("agentA", Person.class); - private Id testAgent2 = Id.create("agentB", Person.class); - private Id testAgent3 = Id.create("agentC", Person.class); - - private Id linkId1 = Id.create("link1", Link.class); - private Id linkId2 = Id.create("link2", Link.class); - private Id linkId3 = Id.create("link3", Link.class); - private Id linkId4 = Id.create("link4", Link.class); - private Id linkId5 = Id.create("link5", Link.class); - - double avgValue1 = 0.0; - double avgValue2 = 0.0; - double avgOldValue1 = 0.0; - double avgOldValue2 = 0.0; - double avgValue3 = 0.0; - double avgValue4 = 0.0; - double avgOldValue3 = 0.0; - double avgOldValue4 = 0.0; - - //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - /** - * V3 - */ - @Test - public final void testFlowCongestion_3agents_V3(){ - - Scenario sc = loadScenario1(); - setPopulation1(sc); - - final List congestionEvents = new ArrayList(); - final CongestionHandlerImplV3 congestionHandler = new CongestionHandlerImplV3(events, sc); - - events.addHandler( new CongestionEventHandler() { - - @Override - public void reset(int iteration) { - } - - @Override - public void handleEvent(CongestionEvent event) { - congestionEvents.add(event); - } - }); - - events.addHandler(congestionHandler); - - PrepareForSimUtils.createDefaultPrepareForSim(sc).run(); - QSim sim = createQSim(sc, events); - sim.run(); - - for (CongestionEvent event : congestionEvents) { - Assert.assertEquals("here the delay should be equal to the inverse of the flow capacity", 3., event.getDelay(), MatsimTestUtils.EPSILON); - } - - Assert.assertEquals("wrong total delay", 9., congestionHandler.getTotalDelay(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong total internalized delay", 9., congestionHandler.getTotalInternalizedDelay(), MatsimTestUtils.EPSILON); - - } - - /** - * V7 - */ - @Test - public final void testFlowCongestion_3agents_V7(){ - - Scenario sc = loadScenario1(); - setPopulation1(sc); - - final List congestionEvents = new ArrayList(); - final CongestionHandlerImplV7 congestionHandler = new CongestionHandlerImplV7(events, sc); - - events.addHandler( new CongestionEventHandler() { - - @Override - public void reset(int iteration) { - } - - @Override - public void handleEvent(CongestionEvent event) { - congestionEvents.add(event); - } - }); - - events.addHandler(congestionHandler); - - PrepareForSimUtils.createDefaultPrepareForSim(sc).run(); - QSim sim = createQSim(sc, events); - sim.run(); - - for (CongestionEvent event : congestionEvents) { - if (event.getCausingAgentId().toString().equals("agentC") && event.getAffectedAgentId().toString().equals("agentB")) { - Assert.assertEquals("wrong delay", 3., event.getDelay(), MatsimTestUtils.EPSILON); - } - - if (event.getCausingAgentId().toString().equals("agentC") && event.getAffectedAgentId().toString().equals("agentA")) { - Assert.assertEquals("wrong delay", 6., event.getDelay(), MatsimTestUtils.EPSILON); - } - - if (event.getCausingAgentId().toString().equals("agentB") && event.getAffectedAgentId().toString().equals("agentA")) { - Assert.assertEquals("wrong delay", 6., event.getDelay(), MatsimTestUtils.EPSILON); - } - } - - Assert.assertEquals("wrong total delay", 9., congestionHandler.getTotalDelay(), MatsimTestUtils.EPSILON); - - // the second agent is 3 sec delayed and charges the first agent with these 3 sec - // the third agent is 6 sec delayed and charges the first and the second agent with each 6 sec - Assert.assertEquals("wrong total internalized delay", 15., congestionHandler.getTotalInternalizedDelay(), MatsimTestUtils.EPSILON); - } - - /** - * V8 - */ - @Test - public final void testFlowCongestion_3agents_V8(){ - - Scenario sc = loadScenario1(); - setPopulation1(sc); - - final List congestionEvents = new ArrayList(); - final CongestionHandlerImplV8 congestionHandler = new CongestionHandlerImplV8(events, sc); - - events.addHandler( new CongestionEventHandler() { - - @Override - public void reset(int iteration) { - } - - @Override - public void handleEvent(CongestionEvent event) { - congestionEvents.add(event); - } - }); - - events.addHandler(congestionHandler); - - PrepareForSimUtils.createDefaultPrepareForSim(sc).run(); - QSim sim = createQSim(sc, events); - sim.run(); - - for (CongestionEvent event : congestionEvents) { - if (event.getCausingAgentId().toString().equals("agentC") && event.getAffectedAgentId().toString().equals("agentB")) { - Assert.assertEquals("wrong delay", 3., event.getDelay(), MatsimTestUtils.EPSILON); - } - - if (event.getCausingAgentId().toString().equals("agentC") && event.getAffectedAgentId().toString().equals("agentA")) { - Assert.assertEquals("wrong delay", 3., event.getDelay(), MatsimTestUtils.EPSILON); - } - - if (event.getCausingAgentId().toString().equals("agentB") && event.getAffectedAgentId().toString().equals("agentA")) { - Assert.assertEquals("wrong delay", 3., event.getDelay(), MatsimTestUtils.EPSILON); - } - } - - Assert.assertEquals("wrong total delay", 9., congestionHandler.getTotalDelay(), MatsimTestUtils.EPSILON); - - // the second agent is 3 sec delayed and charges the first agent with these 3 sec - // the third agent is 6 sec delayed and charges the first and the second agent with each 6 sec - Assert.assertEquals("wrong total internalized delay", 9., congestionHandler.getTotalInternalizedDelay(), MatsimTestUtils.EPSILON); - } - - private void setPopulation1(Scenario scenario) { - - Population population = scenario.getPopulation(); - PopulationFactory popFactory = (PopulationFactory) scenario.getPopulation().getFactory(); - LinkNetworkRouteFactory routeFactory = new LinkNetworkRouteFactory(); - - Activity workActLink5 = popFactory.createActivityFromLinkId("work", linkId5); - - // leg: 1,2,3,4,5 - Leg leg_1_5 = popFactory.createLeg("car"); - List> linkIds234 = new ArrayList>(); - linkIds234.add(linkId2); - linkIds234.add(linkId3); - linkIds234.add(linkId4); - NetworkRoute route1_5 = (NetworkRoute) routeFactory.createRoute(linkId1, linkId5); - route1_5.setLinkIds(linkId1, linkIds234, linkId5); - leg_1_5.setRoute(route1_5); - - Person person1 = popFactory.createPerson(testAgent1); - Plan plan1 = popFactory.createPlan(); - Activity homeActLink1_1 = popFactory.createActivityFromLinkId("home", linkId1); - homeActLink1_1.setEndTime(100); - plan1.addActivity(homeActLink1_1); - plan1.addLeg(leg_1_5); - plan1.addActivity(workActLink5); - person1.addPlan(plan1); - population.addPerson(person1); - - Person person2 = popFactory.createPerson(testAgent2); - Plan plan2 = popFactory.createPlan(); - Activity homeActLink1_2 = popFactory.createActivityFromLinkId("home", linkId1); - homeActLink1_2.setEndTime(100); - plan2.addActivity(homeActLink1_2); - { - Leg leg = popFactory.createLeg(leg_1_5.getMode()); - PopulationUtils.copyFromTo(leg_1_5, leg); - plan2.addLeg(leg); - } - plan2.addActivity(workActLink5); - person2.addPlan(plan2); - population.addPerson(person2); - - Person person3 = popFactory.createPerson(testAgent3); - Plan plan3 = popFactory.createPlan(); - Activity homeActLink1_3 = popFactory.createActivityFromLinkId("home", linkId1); - homeActLink1_3.setEndTime(100); - plan3.addActivity(homeActLink1_3); - { - Leg leg = popFactory.createLeg(leg_1_5.getMode()); - PopulationUtils.copyFromTo(leg_1_5, leg); - plan3.addLeg(leg); - } - plan3.addActivity(workActLink5); - person3.addPlan(plan3); - population.addPerson(person3); -} - - private Scenario loadScenario1() { - - // (0) (1) (2) (3) (4) (5) - // -----link1---- ----link2---- ----link3---- ----link4---- ----link5---- - - Config config = testUtils.createConfig(); - QSimConfigGroup qSimConfigGroup = config.qsim(); - qSimConfigGroup.setFlowCapFactor(1.0); - qSimConfigGroup.setStorageCapFactor(1.0); - qSimConfigGroup.setInsertingWaitingVehiclesBeforeDrivingVehicles(true); - qSimConfigGroup.setRemoveStuckVehicles(true); - qSimConfigGroup.setStuckTime(3600.0); - Scenario scenario = (ScenarioUtils.createScenario(config)); - - Network network = (Network) scenario.getNetwork(); - network.setEffectiveCellSize(7.5); - network.setCapacityPeriod(3600.); - - Node node0 = network.getFactory().createNode(Id.create("0", Node.class), new Coord(0., 0.)); - Node node1 = network.getFactory().createNode(Id.create("1", Node.class), new Coord(100., 0.)); - Node node2 = network.getFactory().createNode(Id.create("2", Node.class), new Coord(200., 0.)); - Node node3 = network.getFactory().createNode(Id.create("3", Node.class), new Coord(300., 0.)); - Node node4 = network.getFactory().createNode(Id.create("4", Node.class), new Coord(400., 0.)); - Node node5 = network.getFactory().createNode(Id.create("5", Node.class), new Coord(500., 0.)); - - Link link1 = network.getFactory().createLink(this.linkId1, node0, node1); - Link link2 = network.getFactory().createLink(this.linkId2, node1, node2); - Link link3 = network.getFactory().createLink(this.linkId3, node2, node3); - Link link4 = network.getFactory().createLink(this.linkId4, node3, node4); - Link link5 = network.getFactory().createLink(this.linkId5, node4, node5); - - Set modes = new HashSet(); - modes.add("car"); - - // link without capacity restrictions - link1.setAllowedModes(modes); - link1.setCapacity(999999); - link1.setFreespeed(250); // one time step - link1.setNumberOfLanes(100); - link1.setLength(500); - - // link without capacity restrictions - link2.setAllowedModes(modes); - link2.setCapacity(999999); - link2.setFreespeed(166.66666667); // two time steps - link2.setNumberOfLanes(100); - link2.setLength(500); - - // capacity: one car every 3 sec - link3.setAllowedModes(modes); - link3.setCapacity(1200); - link3.setFreespeed(250); // one time step - link3.setNumberOfLanes(100); - link3.setLength(7.5); - - // link without capacity restrictions - link4.setAllowedModes(modes); - link4.setCapacity(999999); - link4.setFreespeed(166.66666667); // two time steps - link4.setNumberOfLanes(100); - link4.setLength(500); - - // link without capacity restrictions - link5.setAllowedModes(modes); - link5.setCapacity(999999); - link5.setFreespeed(250); // one time step - link5.setNumberOfLanes(100); - link5.setLength(500); - - network.addNode(node0); - network.addNode(node1); - network.addNode(node2); - network.addNode(node3); - network.addNode(node4); - network.addNode(node5); - - network.addLink(link1); - network.addLink(link2); - network.addLink(link3); - network.addLink(link4); - network.addLink(link5); - - this.events = EventsUtils.createEventsManager(); - return scenario; - } - - private QSim createQSim(Scenario sc, EventsManager events) { - return new QSimBuilder(sc.getConfig()).useDefaults().build(sc, events); - } - -} \ No newline at end of file +/* *********************************************************************** * + * project: org.matsim.* + * * + * *********************************************************************** * + * * + * copyright : (C) 2013 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ + +/** + * + */ +package playground.vsp.congestion; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.junit.Assert; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.Test; +import org.matsim.api.core.v01.Coord; +import org.matsim.api.core.v01.Id; +import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.network.Link; +import org.matsim.api.core.v01.network.Network; +import org.matsim.api.core.v01.network.Node; +import org.matsim.api.core.v01.population.Activity; +import org.matsim.api.core.v01.population.Leg; +import org.matsim.api.core.v01.population.Person; +import org.matsim.api.core.v01.population.Plan; +import org.matsim.api.core.v01.population.Population; +import org.matsim.api.core.v01.population.PopulationFactory; +import org.matsim.core.api.experimental.events.EventsManager; +import org.matsim.core.config.Config; +import org.matsim.core.config.groups.QSimConfigGroup; +import org.matsim.core.controler.PrepareForSimUtils; +import org.matsim.core.events.EventsUtils; +import org.matsim.core.mobsim.qsim.QSim; +import org.matsim.core.mobsim.qsim.QSimBuilder; +import org.matsim.core.population.PopulationUtils; +import org.matsim.core.population.routes.LinkNetworkRouteFactory; +import org.matsim.core.population.routes.NetworkRoute; +import org.matsim.core.scenario.ScenarioUtils; +import org.matsim.testcases.MatsimTestUtils; + +import playground.vsp.congestion.events.CongestionEvent; +import playground.vsp.congestion.handlers.CongestionEventHandler; +import playground.vsp.congestion.handlers.CongestionHandlerImplV3; +import playground.vsp.congestion.handlers.CongestionHandlerImplV7; +import playground.vsp.congestion.handlers.CongestionHandlerImplV8; + +/** + * Simple scenario setup: + * Three agents moving along a corridor with unlimited storage capacity; arriving simultaneously at the bottleneck. + * + * @author ikaddoura , lkroeger + * + */ + +public class MarginalCongestionHandlerFlowQueueQsimTest { + + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); + + private EventsManager events; + + private Id testAgent1 = Id.create("agentA", Person.class); + private Id testAgent2 = Id.create("agentB", Person.class); + private Id testAgent3 = Id.create("agentC", Person.class); + + private Id linkId1 = Id.create("link1", Link.class); + private Id linkId2 = Id.create("link2", Link.class); + private Id linkId3 = Id.create("link3", Link.class); + private Id linkId4 = Id.create("link4", Link.class); + private Id linkId5 = Id.create("link5", Link.class); + + double avgValue1 = 0.0; + double avgValue2 = 0.0; + double avgOldValue1 = 0.0; + double avgOldValue2 = 0.0; + double avgValue3 = 0.0; + double avgValue4 = 0.0; + double avgOldValue3 = 0.0; + double avgOldValue4 = 0.0; + + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + /** + * V3 + */ + @Test + public final void testFlowCongestion_3agents_V3(){ + + Scenario sc = loadScenario1(); + setPopulation1(sc); + + final List congestionEvents = new ArrayList(); + final CongestionHandlerImplV3 congestionHandler = new CongestionHandlerImplV3(events, sc); + + events.addHandler( new CongestionEventHandler() { + + @Override + public void reset(int iteration) { + } + + @Override + public void handleEvent(CongestionEvent event) { + congestionEvents.add(event); + } + }); + + events.addHandler(congestionHandler); + + PrepareForSimUtils.createDefaultPrepareForSim(sc).run(); + QSim sim = createQSim(sc, events); + sim.run(); + + for (CongestionEvent event : congestionEvents) { + Assert.assertEquals("here the delay should be equal to the inverse of the flow capacity", 3., event.getDelay(), MatsimTestUtils.EPSILON); + } + + Assert.assertEquals("wrong total delay", 9., congestionHandler.getTotalDelay(), MatsimTestUtils.EPSILON); + Assert.assertEquals("wrong total internalized delay", 9., congestionHandler.getTotalInternalizedDelay(), MatsimTestUtils.EPSILON); + + } + + /** + * V7 + */ + @Test + public final void testFlowCongestion_3agents_V7(){ + + Scenario sc = loadScenario1(); + setPopulation1(sc); + + final List congestionEvents = new ArrayList(); + final CongestionHandlerImplV7 congestionHandler = new CongestionHandlerImplV7(events, sc); + + events.addHandler( new CongestionEventHandler() { + + @Override + public void reset(int iteration) { + } + + @Override + public void handleEvent(CongestionEvent event) { + congestionEvents.add(event); + } + }); + + events.addHandler(congestionHandler); + + PrepareForSimUtils.createDefaultPrepareForSim(sc).run(); + QSim sim = createQSim(sc, events); + sim.run(); + + for (CongestionEvent event : congestionEvents) { + if (event.getCausingAgentId().toString().equals("agentC") && event.getAffectedAgentId().toString().equals("agentB")) { + Assert.assertEquals("wrong delay", 3., event.getDelay(), MatsimTestUtils.EPSILON); + } + + if (event.getCausingAgentId().toString().equals("agentC") && event.getAffectedAgentId().toString().equals("agentA")) { + Assert.assertEquals("wrong delay", 6., event.getDelay(), MatsimTestUtils.EPSILON); + } + + if (event.getCausingAgentId().toString().equals("agentB") && event.getAffectedAgentId().toString().equals("agentA")) { + Assert.assertEquals("wrong delay", 6., event.getDelay(), MatsimTestUtils.EPSILON); + } + } + + Assert.assertEquals("wrong total delay", 9., congestionHandler.getTotalDelay(), MatsimTestUtils.EPSILON); + + // the second agent is 3 sec delayed and charges the first agent with these 3 sec + // the third agent is 6 sec delayed and charges the first and the second agent with each 6 sec + Assert.assertEquals("wrong total internalized delay", 15., congestionHandler.getTotalInternalizedDelay(), MatsimTestUtils.EPSILON); + } + + /** + * V8 + */ + @Test + public final void testFlowCongestion_3agents_V8(){ + + Scenario sc = loadScenario1(); + setPopulation1(sc); + + final List congestionEvents = new ArrayList(); + final CongestionHandlerImplV8 congestionHandler = new CongestionHandlerImplV8(events, sc); + + events.addHandler( new CongestionEventHandler() { + + @Override + public void reset(int iteration) { + } + + @Override + public void handleEvent(CongestionEvent event) { + congestionEvents.add(event); + } + }); + + events.addHandler(congestionHandler); + + PrepareForSimUtils.createDefaultPrepareForSim(sc).run(); + QSim sim = createQSim(sc, events); + sim.run(); + + for (CongestionEvent event : congestionEvents) { + if (event.getCausingAgentId().toString().equals("agentC") && event.getAffectedAgentId().toString().equals("agentB")) { + Assert.assertEquals("wrong delay", 3., event.getDelay(), MatsimTestUtils.EPSILON); + } + + if (event.getCausingAgentId().toString().equals("agentC") && event.getAffectedAgentId().toString().equals("agentA")) { + Assert.assertEquals("wrong delay", 3., event.getDelay(), MatsimTestUtils.EPSILON); + } + + if (event.getCausingAgentId().toString().equals("agentB") && event.getAffectedAgentId().toString().equals("agentA")) { + Assert.assertEquals("wrong delay", 3., event.getDelay(), MatsimTestUtils.EPSILON); + } + } + + Assert.assertEquals("wrong total delay", 9., congestionHandler.getTotalDelay(), MatsimTestUtils.EPSILON); + + // the second agent is 3 sec delayed and charges the first agent with these 3 sec + // the third agent is 6 sec delayed and charges the first and the second agent with each 6 sec + Assert.assertEquals("wrong total internalized delay", 9., congestionHandler.getTotalInternalizedDelay(), MatsimTestUtils.EPSILON); + } + + private void setPopulation1(Scenario scenario) { + + Population population = scenario.getPopulation(); + PopulationFactory popFactory = (PopulationFactory) scenario.getPopulation().getFactory(); + LinkNetworkRouteFactory routeFactory = new LinkNetworkRouteFactory(); + + Activity workActLink5 = popFactory.createActivityFromLinkId("work", linkId5); + + // leg: 1,2,3,4,5 + Leg leg_1_5 = popFactory.createLeg("car"); + List> linkIds234 = new ArrayList>(); + linkIds234.add(linkId2); + linkIds234.add(linkId3); + linkIds234.add(linkId4); + NetworkRoute route1_5 = (NetworkRoute) routeFactory.createRoute(linkId1, linkId5); + route1_5.setLinkIds(linkId1, linkIds234, linkId5); + leg_1_5.setRoute(route1_5); + + Person person1 = popFactory.createPerson(testAgent1); + Plan plan1 = popFactory.createPlan(); + Activity homeActLink1_1 = popFactory.createActivityFromLinkId("home", linkId1); + homeActLink1_1.setEndTime(100); + plan1.addActivity(homeActLink1_1); + plan1.addLeg(leg_1_5); + plan1.addActivity(workActLink5); + person1.addPlan(plan1); + population.addPerson(person1); + + Person person2 = popFactory.createPerson(testAgent2); + Plan plan2 = popFactory.createPlan(); + Activity homeActLink1_2 = popFactory.createActivityFromLinkId("home", linkId1); + homeActLink1_2.setEndTime(100); + plan2.addActivity(homeActLink1_2); + { + Leg leg = popFactory.createLeg(leg_1_5.getMode()); + PopulationUtils.copyFromTo(leg_1_5, leg); + plan2.addLeg(leg); + } + plan2.addActivity(workActLink5); + person2.addPlan(plan2); + population.addPerson(person2); + + Person person3 = popFactory.createPerson(testAgent3); + Plan plan3 = popFactory.createPlan(); + Activity homeActLink1_3 = popFactory.createActivityFromLinkId("home", linkId1); + homeActLink1_3.setEndTime(100); + plan3.addActivity(homeActLink1_3); + { + Leg leg = popFactory.createLeg(leg_1_5.getMode()); + PopulationUtils.copyFromTo(leg_1_5, leg); + plan3.addLeg(leg); + } + plan3.addActivity(workActLink5); + person3.addPlan(plan3); + population.addPerson(person3); +} + + private Scenario loadScenario1() { + + // (0) (1) (2) (3) (4) (5) + // -----link1---- ----link2---- ----link3---- ----link4---- ----link5---- + + Config config = testUtils.createConfig(); + QSimConfigGroup qSimConfigGroup = config.qsim(); + qSimConfigGroup.setFlowCapFactor(1.0); + qSimConfigGroup.setStorageCapFactor(1.0); + qSimConfigGroup.setInsertingWaitingVehiclesBeforeDrivingVehicles(true); + qSimConfigGroup.setRemoveStuckVehicles(true); + qSimConfigGroup.setStuckTime(3600.0); + Scenario scenario = (ScenarioUtils.createScenario(config)); + + Network network = (Network) scenario.getNetwork(); + network.setEffectiveCellSize(7.5); + network.setCapacityPeriod(3600.); + + Node node0 = network.getFactory().createNode(Id.create("0", Node.class), new Coord(0., 0.)); + Node node1 = network.getFactory().createNode(Id.create("1", Node.class), new Coord(100., 0.)); + Node node2 = network.getFactory().createNode(Id.create("2", Node.class), new Coord(200., 0.)); + Node node3 = network.getFactory().createNode(Id.create("3", Node.class), new Coord(300., 0.)); + Node node4 = network.getFactory().createNode(Id.create("4", Node.class), new Coord(400., 0.)); + Node node5 = network.getFactory().createNode(Id.create("5", Node.class), new Coord(500., 0.)); + + Link link1 = network.getFactory().createLink(this.linkId1, node0, node1); + Link link2 = network.getFactory().createLink(this.linkId2, node1, node2); + Link link3 = network.getFactory().createLink(this.linkId3, node2, node3); + Link link4 = network.getFactory().createLink(this.linkId4, node3, node4); + Link link5 = network.getFactory().createLink(this.linkId5, node4, node5); + + Set modes = new HashSet(); + modes.add("car"); + + // link without capacity restrictions + link1.setAllowedModes(modes); + link1.setCapacity(999999); + link1.setFreespeed(250); // one time step + link1.setNumberOfLanes(100); + link1.setLength(500); + + // link without capacity restrictions + link2.setAllowedModes(modes); + link2.setCapacity(999999); + link2.setFreespeed(166.66666667); // two time steps + link2.setNumberOfLanes(100); + link2.setLength(500); + + // capacity: one car every 3 sec + link3.setAllowedModes(modes); + link3.setCapacity(1200); + link3.setFreespeed(250); // one time step + link3.setNumberOfLanes(100); + link3.setLength(7.5); + + // link without capacity restrictions + link4.setAllowedModes(modes); + link4.setCapacity(999999); + link4.setFreespeed(166.66666667); // two time steps + link4.setNumberOfLanes(100); + link4.setLength(500); + + // link without capacity restrictions + link5.setAllowedModes(modes); + link5.setCapacity(999999); + link5.setFreespeed(250); // one time step + link5.setNumberOfLanes(100); + link5.setLength(500); + + network.addNode(node0); + network.addNode(node1); + network.addNode(node2); + network.addNode(node3); + network.addNode(node4); + network.addNode(node5); + + network.addLink(link1); + network.addLink(link2); + network.addLink(link3); + network.addLink(link4); + network.addLink(link5); + + this.events = EventsUtils.createEventsManager(); + return scenario; + } + + private QSim createQSim(Scenario sc, EventsManager events) { + return new QSimBuilder(sc.getConfig()).useDefaults().build(sc, events); + } + +} diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java index 0a5aae8bb70..6a545ed494e 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java @@ -34,7 +34,7 @@ import org.junit.Assert; import org.junit.Ignore; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -99,8 +99,8 @@ public class MarginalCongestionHandlerFlowSpillbackQueueQsimTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); private EventsManager events; diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java index 2c040502c4d..52ba06a0f54 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java @@ -31,7 +31,7 @@ import jakarta.inject.Provider; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -60,8 +60,8 @@ public class MarginalCongestionHandlerV3Test { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public final void testCongestionExample(){ diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionPricingTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionPricingTest.java index 377c35e92d8..b3633c5a13b 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionPricingTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionPricingTest.java @@ -24,7 +24,7 @@ import java.util.Set; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -63,8 +63,8 @@ */ public class MarginalCongestionPricingTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public final void implV4Test(){ @@ -89,7 +89,7 @@ public final void implV4Test(){ events.addHandler( new CongestionEventHandler() { @Override - public void reset(int iteration) { + public void reset(int iteration) { } @Override @@ -114,7 +114,7 @@ public void handleEvent(CongestionEvent event) { double person6Delay=0; double person8_6Delay=0; double person8_4Delay=0; - + int repetationPerson6Count=0; int repetationPerson8_6Count=0; int repetationPerson8_4Count=0; @@ -153,7 +153,7 @@ public void handleEvent(CongestionEvent event) { // delays are 10, 10 person8_6Delay+=event.getDelay(); if(repetationPerson8_6Count>0){ - Assert.assertEquals("wrong delay.", 20, person8_6Delay, MatsimTestUtils.EPSILON); + Assert.assertEquals("wrong delay.", 20, person8_6Delay, MatsimTestUtils.EPSILON); } repetationPerson8_6Count++; link3Delays++; @@ -187,7 +187,7 @@ public void handleEvent(CongestionEvent event) { } else if (event.getCausingAgentId().toString().equals("8") && event.getAffectedAgentId().toString().equals("9")) { Assert.assertEquals("wrong delay.", 1, event.getDelay(), MatsimTestUtils.EPSILON); link2Delays++; - } + } } else throw new RuntimeException("Delay can not occur on link id - "+event.getLinkId().toString()); } @@ -208,7 +208,7 @@ public void handleEvent(CongestionEvent event) { * generates network with 6 links. Even persons will go on one branch (up) and odd persons will go on other (down). *

o----4----o *

| - *

3 + *

3 *

| *

| *

o--1---o---2---o diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MultipleSpillbackCausingLinksTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MultipleSpillbackCausingLinksTest.java index 5ec75a5ce3b..c6ae3343755 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MultipleSpillbackCausingLinksTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MultipleSpillbackCausingLinksTest.java @@ -22,7 +22,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -60,13 +60,13 @@ public class MultipleSpillbackCausingLinksTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); /** - * This test shows that (1) an agent can have spill back delays due to more than one link and + * This test shows that (1) an agent can have spill back delays due to more than one link and * therefore, need to iterate through all spill back causing links. - * (2) an agent may have two different links as next link in the route and therefore correct one should be adopted. + * (2) an agent may have two different links as next link in the route and therefore correct one should be adopted. */ @Test public final void multipleSpillBackTest(){ @@ -97,7 +97,7 @@ public final void multipleSpillBackTest(){ // second next link in the // route is link 6 // agent 3 and 4 leave prior to agent 2 during home work (trip3) - if(e.getCausingAgentId().equals(Id.createPersonId("3"))){ + if(e.getCausingAgentId().equals(Id.createPersonId("3"))){ Assert.assertEquals("Delay on second next link in the route is not correct.", 10.0, e.getDelay(), MatsimTestUtils.EPSILON); } else if (e.getCausingAgentId().equals(Id.createPersonId("4"))){ Assert.assertEquals("Delay on second next link in the route is not correct.", 10.0, e.getDelay(), MatsimTestUtils.EPSILON); @@ -116,7 +116,7 @@ public final void multipleSpillBackTest(){ } } - // now check, for agent 2, first link in the route (trip1) is occur first and rest later time i.e. during index ==1. + // now check, for agent 2, first link in the route (trip1) is occur first and rest later time i.e. during index ==1. Assert.assertFalse("Congestion event for first next link in the route should occur first.", eventTimes.get(0) > eventTimes.get(1)); // all other congestion event for agent 2 while leaving link 1 should occur at the same time. @@ -144,7 +144,7 @@ private List getAffectedPersonId2Delays(){ events.addHandler( new CongestionEventHandler() { @Override - public void reset(int iteration) { + public void reset(int iteration) { } @Override @@ -270,7 +270,7 @@ private void createPopulation(){ Activity a4 = population.getFactory().createActivityFromLinkId("w", link4.getId()); plan.addActivity(a4); } - population.addPerson(p); + population.addPerson(p); } } } diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/TestForEmergenceTime.java b/contribs/vsp/src/test/java/playground/vsp/congestion/TestForEmergenceTime.java index 840c08836d4..7b4be2a2cf1 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/TestForEmergenceTime.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/TestForEmergenceTime.java @@ -22,7 +22,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -60,8 +60,8 @@ */ public class TestForEmergenceTime { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public final void emergenceTimeTest_v4(){ @@ -94,7 +94,7 @@ public final void emergenceTimeTest_v4(){ // } // } // } - + private List getAffectedPersonId2Delays(String congestionPricingImpl){ int numberOfPersonInPlan = 10; @@ -117,7 +117,7 @@ private List getAffectedPersonId2Delays(String congestionPricin events.addHandler( new CongestionEventHandler() { @Override - public void reset(int iteration) { + public void reset(int iteration) { } @Override @@ -137,8 +137,8 @@ public void handleEvent(CongestionEvent event) { } /** - * generates network with 8 links. Even persons will go on one branch (down) and odd persons will go on other (up). A person come from top. - *

+ * generates network with 8 links. Even persons will go on one branch (down) and odd persons will go on other (up). A person come from top. + *

*

o *

| *

8 @@ -146,7 +146,7 @@ public void handleEvent(CongestionEvent event) { *

| *

o *

| - *

7 + *

7 *

| *

| *

o--1---o---2---o----3----o----4----o diff --git a/contribs/vsp/src/test/java/playground/vsp/ev/TransferFinalSocToNextIterTest.java b/contribs/vsp/src/test/java/playground/vsp/ev/TransferFinalSocToNextIterTest.java index 172fc201ad2..330e4bff5ad 100644 --- a/contribs/vsp/src/test/java/playground/vsp/ev/TransferFinalSocToNextIterTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/ev/TransferFinalSocToNextIterTest.java @@ -24,7 +24,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -45,8 +45,8 @@ public class TransferFinalSocToNextIterTest { private static final Integer LAST_ITERATION = 1; private static final double INITIAL_SOC = 0.95; - @Rule - public MatsimTestUtils matsimTestUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils matsimTestUtils = new MatsimTestUtils(); @Test public void test() { diff --git a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVIT.java b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVIT.java index 9a94e91d15c..b35592a42ca 100644 --- a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVIT.java @@ -2,7 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; @@ -16,7 +16,7 @@ import java.net.URL; public class UrbanEVIT { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void run() { diff --git a/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java b/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java index d8033195348..dc6fc153dbc 100644 --- a/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java @@ -3,7 +3,7 @@ import com.google.inject.Provides; import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -61,9 +61,8 @@ */ public class HierarchicalFLowEfficiencyCalculatorTest { - - public @Rule - MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); private FlowEfficiencyHandler handler; @Test diff --git a/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreatorTest.java b/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreatorTest.java index 2e77d5aa867..524f1f3816e 100644 --- a/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreatorTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreatorTest.java @@ -1,7 +1,7 @@ package playground.vsp.openberlinscenario.cemdap.input; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; @@ -19,8 +19,8 @@ */ public class SynPopCreatorTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void TestGenerateDemand() { @@ -39,13 +39,13 @@ public void TestGenerateDemand() { SynPopCreator demandGeneratorCensus = new SynPopCreator(commuterFilesOutgoing, censusFile, utils.getOutputDirectory(), numberOfPlansPerPerson, idsOfFederalStatesIncluded, defaultAdultsToEmployeesRatio, defaultEmployeesToCommutersRatio); - + demandGeneratorCensus.setShapeFileForSpatialRefinement(utils.getInputDirectory() + "Bezirksregion_EPSG_25833.shp"); demandGeneratorCensus.setIdsOfMunicipalitiesForSpatialRefinement(Arrays.asList("11000000")); demandGeneratorCensus.setRefinementFeatureKeyInShapefile("SCHLUESSEL"); demandGeneratorCensus.generateDemand(); - + String municipal = "Breydin"; ArrayList possibleLocationsOfWork = readPossibleLocationsOfWork(commuterFileOutgoingTest, municipal); @@ -172,4 +172,4 @@ private String[] getCensusDataLine(String censusFile, String municipal) { } return line; } -} \ No newline at end of file +} diff --git a/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java b/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java index 9952e81b744..594390f486c 100644 --- a/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java @@ -19,8 +19,8 @@ public class PlanFileModifierTest { private final static Logger LOG = LogManager.getLogger(PlanFileModifierTest.class); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); private final static double SELECTION_PROBABILITY = 0.70; private final CoordinateTransformation ct = new IdentityTransformation(); diff --git a/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java b/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java index e4b686fc810..2d5797dc1b8 100644 --- a/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java @@ -5,7 +5,7 @@ import org.assertj.core.api.InstanceOfAssertFactories; import org.assertj.core.data.Offset; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -33,8 +33,8 @@ public class PtTripFareEstimatorTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); protected InformedModeChoiceConfigGroup group; protected Controler controler; diff --git a/contribs/vsp/src/test/java/playground/vsp/pt/ptdisturbances/EditTripsTest.java b/contribs/vsp/src/test/java/playground/vsp/pt/ptdisturbances/EditTripsTest.java index c9e063abf12..341ad741a91 100644 --- a/contribs/vsp/src/test/java/playground/vsp/pt/ptdisturbances/EditTripsTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/pt/ptdisturbances/EditTripsTest.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -102,7 +102,7 @@ public class EditTripsTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); private static final Logger log = LogManager.getLogger(EditTripsTest.class); // this is messy, but DisturbanceAndReplanningEngine needs to be static and there is no // constructor or similar to pass the replanning time diff --git a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java index f7a08b4ea4b..42fd52d8119 100644 --- a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java @@ -2,7 +2,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -28,8 +28,8 @@ */ public class IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest { - @Rule - public MatsimTestUtils utils; + @RegisterExtension + private MatsimTestUtils utils; private IncomeDependentUtilityOfMoneyPersonScoringParameters personScoringParams; private Population population; diff --git a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java index daa410350d4..247e54a45e5 100644 --- a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java @@ -25,8 +25,8 @@ */ public class IncomeDependentUtilityOfMoneyPersonScoringParametersTest { - @Rule - public MatsimTestUtils utils; + @RegisterExtension + private MatsimTestUtils utils; private IncomeDependentUtilityOfMoneyPersonScoringParameters personScoringParams; private Population population; diff --git a/contribs/vsp/src/test/java/playground/vsp/zzArchive/bvwpOld/BvwpTest.java b/contribs/vsp/src/test/java/playground/vsp/zzArchive/bvwpOld/BvwpTest.java index f9a06f7ec15..fe8cee1a096 100644 --- a/contribs/vsp/src/test/java/playground/vsp/zzArchive/bvwpOld/BvwpTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/zzArchive/bvwpOld/BvwpTest.java @@ -20,7 +20,7 @@ package playground.vsp.zzArchive.bvwpOld; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -28,8 +28,8 @@ public class BvwpTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testOne() { diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java index a5fc49cfefe..13ab81099e8 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java @@ -25,7 +25,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -82,8 +82,8 @@ */ public class SwissRailRaptorModuleTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); @Before public void setUp() { diff --git a/matsim/src/test/java/org/matsim/analysis/CalcLegTimesTest.java b/matsim/src/test/java/org/matsim/analysis/CalcLegTimesTest.java index caf7ae06c75..f04fdbd7ffc 100644 --- a/matsim/src/test/java/org/matsim/analysis/CalcLegTimesTest.java +++ b/matsim/src/test/java/org/matsim/analysis/CalcLegTimesTest.java @@ -26,7 +26,7 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -56,8 +56,8 @@ public class CalcLegTimesTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); public static final String BASE_FILE_NAME = "legdurations.txt"; diff --git a/matsim/src/test/java/org/matsim/analysis/CalcLinkStatsTest.java b/matsim/src/test/java/org/matsim/analysis/CalcLinkStatsTest.java index 2ee9d5fddb0..72eaa88a2bb 100644 --- a/matsim/src/test/java/org/matsim/analysis/CalcLinkStatsTest.java +++ b/matsim/src/test/java/org/matsim/analysis/CalcLinkStatsTest.java @@ -22,7 +22,7 @@ import java.io.File; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -47,8 +47,8 @@ */ public class CalcLinkStatsTest { - @Rule public MatsimTestUtils util = new MatsimTestUtils(); - + @RegisterExtension private MatsimTestUtils util = new MatsimTestUtils(); + @Test public void testAddData() { Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); @@ -65,32 +65,32 @@ public void testAddData() { Link link2 = nf.createLink(Id.create("102", Link.class), node2, node3); network.addLink(link1); network.addLink(link2); - + VolumesAnalyzer analyzer = new VolumesAnalyzer(3600, 86400, network); TravelTime ttimes = new FreeSpeedTravelTime(); CalcLinkStats cls = new CalcLinkStats(network); - + Id vehId = Id.create("1001", Vehicle.class); // generate some pseudo traffic for hour 0: 3 veh on link 1; 1 veh on link 2 analyzer.handleEvent(new LinkLeaveEvent(1000, vehId, link1.getId())); analyzer.handleEvent(new LinkLeaveEvent(1010, vehId, link1.getId())); analyzer.handleEvent(new LinkLeaveEvent(1020, vehId, link1.getId())); analyzer.handleEvent(new LinkLeaveEvent(1030, vehId, link2.getId())); - + // generate some pseudo traffic for hour 0: 1 veh on link 1; 4 veh on link 2 analyzer.handleEvent(new LinkLeaveEvent(4000, vehId, link1.getId())); analyzer.handleEvent(new LinkLeaveEvent(4010, vehId, link2.getId())); analyzer.handleEvent(new LinkLeaveEvent(4020, vehId, link2.getId())); analyzer.handleEvent(new LinkLeaveEvent(4030, vehId, link2.getId())); analyzer.handleEvent(new LinkLeaveEvent(4040, vehId, link2.getId())); - + cls.addData(analyzer, ttimes); - + Assert.assertEquals(3.0, cls.getAvgLinkVolumes(link1.getId())[0], 1e-8); Assert.assertEquals(1.0, cls.getAvgLinkVolumes(link2.getId())[0], 1e-8); Assert.assertEquals(1.0, cls.getAvgLinkVolumes(link1.getId())[1], 1e-8); Assert.assertEquals(4.0, cls.getAvgLinkVolumes(link2.getId())[1], 1e-8); - + analyzer.reset(1); // generate some pseudo traffic for hour 0: 4 veh on link 1; 3 veh on link 2 analyzer.handleEvent(new LinkLeaveEvent(1000, vehId, link1.getId())); @@ -100,7 +100,7 @@ public void testAddData() { analyzer.handleEvent(new LinkLeaveEvent(1040, vehId, link2.getId())); analyzer.handleEvent(new LinkLeaveEvent(1050, vehId, link2.getId())); analyzer.handleEvent(new LinkLeaveEvent(1060, vehId, link2.getId())); - + // generate some pseudo traffic for hour 0: 4 veh on link 1; 2 veh on link 2 analyzer.handleEvent(new LinkLeaveEvent(4000, vehId, link1.getId())); analyzer.handleEvent(new LinkLeaveEvent(4010, vehId, link1.getId())); @@ -108,26 +108,26 @@ public void testAddData() { analyzer.handleEvent(new LinkLeaveEvent(4030, vehId, link1.getId())); analyzer.handleEvent(new LinkLeaveEvent(4040, vehId, link2.getId())); analyzer.handleEvent(new LinkLeaveEvent(4040, vehId, link2.getId())); - + cls.addData(analyzer, ttimes); - + Assert.assertEquals(3.5, cls.getAvgLinkVolumes(link1.getId())[0], 1e-8); Assert.assertEquals(2.0, cls.getAvgLinkVolumes(link2.getId())[0], 1e-8); Assert.assertEquals(2.5, cls.getAvgLinkVolumes(link1.getId())[1], 1e-8); Assert.assertEquals(3.0, cls.getAvgLinkVolumes(link2.getId())[1], 1e-8); - + cls.reset(); Assert.assertEquals(0, cls.getAvgLinkVolumes(link1.getId()).length); Assert.assertEquals(0, cls.getAvgLinkVolumes(link2.getId()).length); } - + /** * Tests the travel times that are written out by {@link CalcLinkStats}. - * + * * Currently, the travel times are only correct if the time bin size in {@link TravelTimeCalculatorConfigGroup} is set to 3600. * If the time bin size is set to the default (900, see TODO below), {@link CalcLinkStats} wrongly assumes hourly time bins resulting in wrong travel times. - * + * * @author ikaddoura */ @Test @@ -146,16 +146,16 @@ public void testAddDataObservedTravelTime() { Link link2 = nf.createLink(Id.create("102", Link.class), node2, node3); network.addLink(link1); network.addLink(link2); - + VolumesAnalyzer analyzer = new VolumesAnalyzer(3600, 86400, network); TravelTimeCalculatorConfigGroup ttcalcConfig = new TravelTimeCalculatorConfigGroup(); - + ttcalcConfig.setTraveltimeBinSize(3600); // ttcalcConfig.setTraveltimeBinSize(900); // TODO - + TravelTimeCalculator ttimeCalculator = new TravelTimeCalculator(network, ttcalcConfig); CalcLinkStats cls = new CalcLinkStats(network); - + Id vehId1 = Id.create("1001", Vehicle.class); Id vehId2 = Id.create("1002", Vehicle.class); Id vehId3 = Id.create("1003", Vehicle.class); @@ -172,9 +172,9 @@ public void testAddDataObservedTravelTime() { analyzer.handleEvent(new LinkLeaveEvent(1010, vehId2, link1.getId())); ttimeCalculator.handleEvent(new LinkLeaveEvent(1020, vehId3, link1.getId())); analyzer.handleEvent(new LinkLeaveEvent(1020, vehId3, link1.getId())); - ttimeCalculator.handleEvent(new LinkLeaveEvent(1030, vehId1, link2.getId())); + ttimeCalculator.handleEvent(new LinkLeaveEvent(1030, vehId1, link2.getId())); analyzer.handleEvent(new LinkLeaveEvent(1030, vehId1, link2.getId())); - + // generate some pseudo traffic for hour 1: 1 veh on link 1; 4 veh on link 2 ttimeCalculator.handleEvent(new LinkEnterEvent(3800, vehId1, link1.getId())); ttimeCalculator.handleEvent(new LinkLeaveEvent(4000, vehId1, link1.getId())); @@ -182,37 +182,37 @@ public void testAddDataObservedTravelTime() { ttimeCalculator.handleEvent(new LinkEnterEvent(4000, vehId1, link2.getId())); ttimeCalculator.handleEvent(new LinkEnterEvent(4000, vehId2, link2.getId())); ttimeCalculator.handleEvent(new LinkEnterEvent(4000, vehId3, link2.getId())); - ttimeCalculator.handleEvent(new LinkEnterEvent(4000, vehId4, link2.getId())); - ttimeCalculator.handleEvent(new LinkLeaveEvent(4010, vehId1, link2.getId())); - analyzer.handleEvent(new LinkLeaveEvent(4010, vehId1, link2.getId())); + ttimeCalculator.handleEvent(new LinkEnterEvent(4000, vehId4, link2.getId())); + ttimeCalculator.handleEvent(new LinkLeaveEvent(4010, vehId1, link2.getId())); + analyzer.handleEvent(new LinkLeaveEvent(4010, vehId1, link2.getId())); ttimeCalculator.handleEvent(new LinkLeaveEvent(4020, vehId2, link2.getId())); analyzer.handleEvent(new LinkLeaveEvent(4020, vehId2, link2.getId())); ttimeCalculator.handleEvent(new LinkLeaveEvent(4030, vehId3, link2.getId())); analyzer.handleEvent(new LinkLeaveEvent(4030, vehId3, link2.getId())); ttimeCalculator.handleEvent(new LinkLeaveEvent(4040, vehId4, link2.getId())); analyzer.handleEvent(new LinkLeaveEvent(4040, vehId4, link2.getId())); - + TravelTime ttimes = ttimeCalculator.getLinkTravelTimes(); cls.addData(analyzer, ttimes); - + // volumes Assert.assertEquals(3.0, cls.getAvgLinkVolumes(link1.getId())[0], 1e-8); Assert.assertEquals(1.0, cls.getAvgLinkVolumes(link2.getId())[0], 1e-8); Assert.assertEquals(1.0, cls.getAvgLinkVolumes(link1.getId())[1], 1e-8); Assert.assertEquals(4.0, cls.getAvgLinkVolumes(link2.getId())[1], 1e-8); - + // travel times Assert.assertEquals( 1530/3., cls.getAvgTravelTimes(link1.getId())[0], 1e-8 ); Assert.assertEquals( 30./1., cls.getAvgTravelTimes(link2.getId())[0], 1e-8 ); Assert.assertEquals( 200./1., cls.getAvgTravelTimes(link1.getId())[1], 1e-8 ); Assert.assertEquals( 100./4., cls.getAvgTravelTimes(link2.getId())[1], 1e-8 ); Assert.assertEquals( link2.getLength() / link2.getFreespeed(), cls.getAvgTravelTimes(link2.getId())[3], 1e-8 ); - + cls.reset(); Assert.assertEquals(0, cls.getAvgLinkVolumes(link1.getId()).length); Assert.assertEquals(0, cls.getAvgLinkVolumes(link2.getId()).length); - } + } @Test public void testWriteRead() { @@ -230,27 +230,27 @@ public void testWriteRead() { Link link2 = nf.createLink(Id.create("102", Link.class), node2, node3); network.addLink(link1); network.addLink(link2); - + VolumesAnalyzer analyzer = new VolumesAnalyzer(3600, 86400, network); TravelTime ttimes = new FreeSpeedTravelTime(); CalcLinkStats cls = new CalcLinkStats(network); - + Id vehId = Id.create("1001", Vehicle.class); // generate some pseudo traffic for hour 0: 3 veh on link 1; 1 veh on link 2 analyzer.handleEvent(new LinkLeaveEvent(1000, vehId, link1.getId())); analyzer.handleEvent(new LinkLeaveEvent(1010, vehId, link1.getId())); analyzer.handleEvent(new LinkLeaveEvent(1020, vehId, link1.getId())); analyzer.handleEvent(new LinkLeaveEvent(1030, vehId, link2.getId())); - + // generate some pseudo traffic for hour 0: 1 veh on link 1; 4 veh on link 2 analyzer.handleEvent(new LinkLeaveEvent(4000, vehId, link1.getId())); analyzer.handleEvent(new LinkLeaveEvent(4010, vehId, link2.getId())); analyzer.handleEvent(new LinkLeaveEvent(4020, vehId, link2.getId())); analyzer.handleEvent(new LinkLeaveEvent(4030, vehId, link2.getId())); analyzer.handleEvent(new LinkLeaveEvent(4040, vehId, link2.getId())); - + cls.addData(analyzer, ttimes); - + analyzer.reset(1); // generate some pseudo traffic for hour 0: 4 veh on link 1; 3 veh on link 2 analyzer.handleEvent(new LinkLeaveEvent(1000, vehId, link1.getId())); @@ -260,7 +260,7 @@ public void testWriteRead() { analyzer.handleEvent(new LinkLeaveEvent(1040, vehId, link2.getId())); analyzer.handleEvent(new LinkLeaveEvent(1050, vehId, link2.getId())); analyzer.handleEvent(new LinkLeaveEvent(1060, vehId, link2.getId())); - + // generate some pseudo traffic for hour 0: 4 veh on link 1; 2 veh on link 2 analyzer.handleEvent(new LinkLeaveEvent(4000, vehId, link1.getId())); analyzer.handleEvent(new LinkLeaveEvent(4010, vehId, link1.getId())); @@ -268,9 +268,9 @@ public void testWriteRead() { analyzer.handleEvent(new LinkLeaveEvent(4030, vehId, link1.getId())); analyzer.handleEvent(new LinkLeaveEvent(4040, vehId, link2.getId())); analyzer.handleEvent(new LinkLeaveEvent(4040, vehId, link2.getId())); - + cls.addData(analyzer, ttimes); - + String filename = this.util.getOutputDirectory() + "linkstats.txt"; cls.writeFile(filename); Assert.assertTrue(new File(filename).exists()); diff --git a/matsim/src/test/java/org/matsim/analysis/IterationTravelStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/IterationTravelStatsControlerListenerTest.java index d665683747a..10c333db369 100644 --- a/matsim/src/test/java/org/matsim/analysis/IterationTravelStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/IterationTravelStatsControlerListenerTest.java @@ -11,7 +11,7 @@ import java.util.zip.GZIPInputStream; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.IdMap; @@ -50,8 +50,8 @@ public class IterationTravelStatsControlerListenerTest { private int first_act_y; private int first_act_type; - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testIterationTravelStatsControlerListener() { diff --git a/matsim/src/test/java/org/matsim/analysis/LegHistogramTest.java b/matsim/src/test/java/org/matsim/analysis/LegHistogramTest.java index 72456c9cdac..9146970dde1 100644 --- a/matsim/src/test/java/org/matsim/analysis/LegHistogramTest.java +++ b/matsim/src/test/java/org/matsim/analysis/LegHistogramTest.java @@ -24,7 +24,7 @@ import java.util.Set; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -45,8 +45,8 @@ */ public class LegHistogramTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/analysis/LinkStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/LinkStatsControlerListenerTest.java index e72013364c3..17538d237d8 100644 --- a/matsim/src/test/java/org/matsim/analysis/LinkStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/LinkStatsControlerListenerTest.java @@ -21,7 +21,7 @@ import com.google.inject.*; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -57,8 +57,8 @@ */ public class LinkStatsControlerListenerTest { - @Rule - public MatsimTestUtils util = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils util = new MatsimTestUtils(); @Test public void testlinksOutputCSV() throws IOException { diff --git a/matsim/src/test/java/org/matsim/analysis/ModeChoiceCoverageControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/ModeChoiceCoverageControlerListenerTest.java index 051f1485cf6..76927ec7a57 100644 --- a/matsim/src/test/java/org/matsim/analysis/ModeChoiceCoverageControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/ModeChoiceCoverageControlerListenerTest.java @@ -1,7 +1,7 @@ package org.matsim.analysis; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -30,8 +30,8 @@ */ public class ModeChoiceCoverageControlerListenerTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java index daf5a8cd90d..ab15ea48c94 100644 --- a/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java @@ -11,7 +11,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -52,8 +52,8 @@ public class ModeStatsControlerListenerTest { HashMap person1modes = new HashMap<>(); HashMap person2modes = new HashMap<>(); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testModeStatsControlerListener() { diff --git a/matsim/src/test/java/org/matsim/analysis/OutputTravelStatsTest.java b/matsim/src/test/java/org/matsim/analysis/OutputTravelStatsTest.java index 2ed4392921c..da31465d1c5 100644 --- a/matsim/src/test/java/org/matsim/analysis/OutputTravelStatsTest.java +++ b/matsim/src/test/java/org/matsim/analysis/OutputTravelStatsTest.java @@ -19,7 +19,7 @@ package org.matsim.analysis; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.controler.Controler; @@ -36,8 +36,8 @@ public class OutputTravelStatsTest { - @Rule - public MatsimTestUtils util = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils util = new MatsimTestUtils(); @Test public void testActivitiesOutputCSV() throws IOException { diff --git a/matsim/src/test/java/org/matsim/analysis/PHbyModeCalculatorTest.java b/matsim/src/test/java/org/matsim/analysis/PHbyModeCalculatorTest.java index e123bfceea9..4622a31b6b9 100644 --- a/matsim/src/test/java/org/matsim/analysis/PHbyModeCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/analysis/PHbyModeCalculatorTest.java @@ -10,7 +10,7 @@ import java.util.Iterator; import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.IdMap; @@ -46,8 +46,8 @@ public class PHbyModeCalculatorTest { Id person3 = Id.create("person3", Person.class); Id person4 = Id.create("person4", Person.class); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); final IdMap map = new IdMap<>(Person.class); diff --git a/matsim/src/test/java/org/matsim/analysis/PKMbyModeCalculatorTest.java b/matsim/src/test/java/org/matsim/analysis/PKMbyModeCalculatorTest.java index ba62f04f994..8af9981fb13 100644 --- a/matsim/src/test/java/org/matsim/analysis/PKMbyModeCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/analysis/PKMbyModeCalculatorTest.java @@ -9,7 +9,7 @@ import java.util.HashMap; import java.util.stream.Collectors; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.IdMap; @@ -40,8 +40,8 @@ public class PKMbyModeCalculatorTest { Person person3 = PopulationUtils.getFactory().createPerson(Id.create(3, Person.class)); Person person4 = PopulationUtils.getFactory().createPerson(Id.create(4, Person.class)); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testPKMbyModeCalculator() { diff --git a/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java index 33345fdfb2b..9c6d251a048 100644 --- a/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java @@ -7,7 +7,7 @@ import org.assertj.core.api.Assertions; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -40,8 +40,8 @@ */ public class ScoreStatsControlerListenerTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private int avgexecuted; private int avgworst; diff --git a/matsim/src/test/java/org/matsim/analysis/TransportPlanningMainModeIdentifierTest.java b/matsim/src/test/java/org/matsim/analysis/TransportPlanningMainModeIdentifierTest.java index ada9b7872a0..d2141c89b78 100644 --- a/matsim/src/test/java/org/matsim/analysis/TransportPlanningMainModeIdentifierTest.java +++ b/matsim/src/test/java/org/matsim/analysis/TransportPlanningMainModeIdentifierTest.java @@ -1,5 +1,5 @@ /** - * + * */ package org.matsim.analysis; @@ -7,7 +7,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.Leg; @@ -23,8 +23,8 @@ public class TransportPlanningMainModeIdentifierTest { private final List modeHierarchy = new ArrayList<>(); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testIterationTravelStatsControlerListener() { diff --git a/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java b/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java index e1e0a8fb0d2..4836dbb1e1c 100644 --- a/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java +++ b/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java @@ -10,7 +10,7 @@ import java.util.stream.Collectors; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.IdMap; @@ -51,8 +51,8 @@ public class TravelDistanceStatsTest { Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Person person2 = PopulationUtils.getFactory().createPerson(Id.create(2, Person.class)); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testTravelDistanceStats() { diff --git a/matsim/src/test/java/org/matsim/analysis/TripsAnalysisIT.java b/matsim/src/test/java/org/matsim/analysis/TripsAnalysisIT.java index 7abdeff8aea..e0a372d519b 100644 --- a/matsim/src/test/java/org/matsim/analysis/TripsAnalysisIT.java +++ b/matsim/src/test/java/org/matsim/analysis/TripsAnalysisIT.java @@ -23,7 +23,7 @@ import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; import org.assertj.core.api.Assertions; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; @@ -42,8 +42,8 @@ public class TripsAnalysisIT { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void testMainMode() { diff --git a/matsim/src/test/java/org/matsim/analysis/TripsAndLegsCSVWriterTest.java b/matsim/src/test/java/org/matsim/analysis/TripsAndLegsCSVWriterTest.java index 788452ea7bb..cfb58800664 100644 --- a/matsim/src/test/java/org/matsim/analysis/TripsAndLegsCSVWriterTest.java +++ b/matsim/src/test/java/org/matsim/analysis/TripsAndLegsCSVWriterTest.java @@ -21,7 +21,7 @@ package org.matsim.analysis; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.analysis.TripsAndLegsCSVWriter.NoLegsWriterExtension; import org.matsim.analysis.TripsAndLegsCSVWriter.NoTripWriterExtension; @@ -112,8 +112,8 @@ public class TripsAndLegsCSVWriterTest { ArrayList legsfromplan = new ArrayList<>(); Map persontrips = new HashMap<>(); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testTripsAndLegsCSVWriter() { diff --git a/matsim/src/test/java/org/matsim/analysis/VolumesAnalyzerTest.java b/matsim/src/test/java/org/matsim/analysis/VolumesAnalyzerTest.java index 54a18fd2047..01ade096cca 100644 --- a/matsim/src/test/java/org/matsim/analysis/VolumesAnalyzerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/VolumesAnalyzerTest.java @@ -1,10 +1,10 @@ /** - * + * */ package org.matsim.analysis; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -28,26 +28,26 @@ */ public class VolumesAnalyzerTest { - @Rule - public MatsimTestUtils util = new MatsimTestUtils(); - + @RegisterExtension + private MatsimTestUtils util = new MatsimTestUtils(); + @Test public void performTest() { - + final Id link1 = Id.create(10723, Link.class); final Id link2 = Id.create(123160, Link.class); final Id link3 = Id.create(130181, Link.class); - + Id person1 = Id.create("1", Person.class); Id person2 = Id.create("2", Person.class); Id person3 = Id.create("3", Person.class); Id person4 = Id.create("4", Person.class); Id person5 = Id.create("5", Person.class); - + Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network = scenario.getNetwork(); NetworkFactory factory = network.getFactory(); - + Node n0, n1, n2, n3; network.addNode(n0 = factory.createNode(Id.createNodeId(0), new Coord(30.0, 50.0))); network.addNode(n1 = factory.createNode(Id.createNodeId(1), new Coord(1800.0, 2500.0))); @@ -56,50 +56,50 @@ public void performTest() { Link LinkOne = factory.createLink(link1, n0, n1); Link LinkTwo = factory.createLink(link2, n1, n2); Link LinkThree = factory.createLink(link3, n2, n3); - + network.addLink(LinkOne); network.addLink(LinkTwo); network.addLink(LinkThree); - + VolumesAnalyzer analyzer = new VolumesAnalyzer(3600, 86400, network); Id veh1 = Id.create("1001", Vehicle.class); Id veh2 = Id.create("1002", Vehicle.class); Id veh3 = Id.create("1003", Vehicle.class); Id veh4 = Id.create("1004", Vehicle.class); Id veh5 = Id.create("1005", Vehicle.class); - + analyzer.handleEvent(new VehicleEntersTrafficEvent(3600.0, person4, link1, veh4, TransportMode.car, 1.0)); analyzer.handleEvent(new VehicleEntersTrafficEvent(3610.0, person1, link1, veh1, TransportMode.car, 2.0)); - + analyzer.handleEvent(new LinkLeaveEvent(5100, veh4, link1)); analyzer.handleEvent(new LinkLeaveEvent(5410, veh1, link1)); - + analyzer.handleEvent(new VehicleEntersTrafficEvent(7200.0, person2, link1, veh2, TransportMode.car, 1.0)); analyzer.handleEvent(new VehicleEntersTrafficEvent(7210.0, person5, link1, veh5, TransportMode.car, 2.0)); analyzer.handleEvent(new VehicleEntersTrafficEvent(7215.0, person4, link1, veh4, TransportMode.car, 3.0)); - + analyzer.handleEvent(new LinkLeaveEvent(9000, veh2, link1)); analyzer.handleEvent(new LinkLeaveEvent(8710, veh5, link1)); analyzer.handleEvent(new LinkLeaveEvent(8895, veh4, link1)); - + analyzer.handleEvent(new VehicleEntersTrafficEvent(10800.0, person1, link1, veh1, TransportMode.car, 1.0)); analyzer.handleEvent(new VehicleEntersTrafficEvent(10810.0, person3, link1, veh3, TransportMode.car, 2.0)); - + analyzer.handleEvent(new LinkLeaveEvent(12600, veh1, link1)); analyzer.handleEvent(new LinkLeaveEvent(12370, veh3, link1)); - + analyzer.handleEvent(new VehicleEntersTrafficEvent(21600.0, person1, link1, veh1, TransportMode.car, 1.0)); analyzer.handleEvent(new VehicleEntersTrafficEvent(21650.0, person2, link1, veh2, TransportMode.car, 2.0)); analyzer.handleEvent(new VehicleEntersTrafficEvent(21700.0, person3, link1, veh3, TransportMode.car, 3.0)); analyzer.handleEvent(new VehicleEntersTrafficEvent(21750.0, person4, link1, veh4, TransportMode.car, 4.0)); analyzer.handleEvent(new VehicleEntersTrafficEvent(21800.0, person5, link1, veh5, TransportMode.car, 5.0)); - + analyzer.handleEvent(new LinkLeaveEvent(22800, veh1, link1)); analyzer.handleEvent(new LinkLeaveEvent(23450, veh2, link1)); analyzer.handleEvent(new LinkLeaveEvent(22800, veh3, link1)); analyzer.handleEvent(new LinkLeaveEvent(22800, veh4, link1)); analyzer.handleEvent(new LinkLeaveEvent(22800, veh5, link1)); - + double[] volume = analyzer.getVolumesPerHourForLink(link1); int[] volumeForLink = analyzer.getVolumesForLink(link1); @@ -111,25 +111,25 @@ public void performTest() { Assert.assertEquals(volumeForLink[2], 3, 0); Assert.assertEquals(volumeForLink[3], 2, 0); Assert.assertEquals(volumeForLink[6], 5, 0); - + VolumesAnalyzer analyzerBike = new VolumesAnalyzer(3600, 86400, network, true); - + analyzerBike.handleEvent(new VehicleEntersTrafficEvent(21600.0, person1, link2, veh1, TransportMode.bike, 1.0)); analyzerBike.handleEvent(new VehicleEntersTrafficEvent(21650.0, person2, link2, veh2, TransportMode.bike, 2.0)); analyzerBike.handleEvent(new VehicleEntersTrafficEvent(21700.0, person3, link2, veh3, TransportMode.bike, 3.0)); analyzerBike.handleEvent(new VehicleEntersTrafficEvent(21750.0, person4, link2, veh4, TransportMode.car, 4.0)); analyzerBike.handleEvent(new VehicleEntersTrafficEvent(21800.0, person5, link2, veh5, TransportMode.car, 5.0)); - + analyzerBike.handleEvent(new LinkLeaveEvent(22800, veh1, link2)); analyzerBike.handleEvent(new LinkLeaveEvent(23450, veh2, link2)); analyzerBike.handleEvent(new LinkLeaveEvent(22800, veh3, link2)); analyzerBike.handleEvent(new LinkLeaveEvent(22800, veh4, link2)); analyzerBike.handleEvent(new LinkLeaveEvent(22800, veh5, link2)); - + double[] volumeBike = analyzerBike.getVolumesPerHourForLink(link2, TransportMode.bike); int[] volumeForLinkBike = analyzerBike.getVolumesForLink(link2, TransportMode.bike); Assert.assertEquals(volumeBike[6], 3.0, 0); Assert.assertEquals(volumeForLinkBike[6], 3, 0); - + } } diff --git a/matsim/src/test/java/org/matsim/analysis/linkPaxVolumes/LinkPaxVolumesAnalysisTest.java b/matsim/src/test/java/org/matsim/analysis/linkPaxVolumes/LinkPaxVolumesAnalysisTest.java index bbcb71c47b7..126b90c8dcf 100644 --- a/matsim/src/test/java/org/matsim/analysis/linkPaxVolumes/LinkPaxVolumesAnalysisTest.java +++ b/matsim/src/test/java/org/matsim/analysis/linkPaxVolumes/LinkPaxVolumesAnalysisTest.java @@ -23,7 +23,7 @@ import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.analysis.linkpaxvolumes.LinkPaxVolumesAnalysis; import org.matsim.analysis.linkpaxvolumes.LinkPaxVolumesWriter; @@ -52,8 +52,8 @@ public class LinkPaxVolumesAnalysisTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); /** * Test method for {@link LinkPaxVolumesAnalysis}. diff --git a/matsim/src/test/java/org/matsim/analysis/personMoney/PersonMoneyEventAggregatorTest.java b/matsim/src/test/java/org/matsim/analysis/personMoney/PersonMoneyEventAggregatorTest.java index b892032ccf9..542b72deb15 100644 --- a/matsim/src/test/java/org/matsim/analysis/personMoney/PersonMoneyEventAggregatorTest.java +++ b/matsim/src/test/java/org/matsim/analysis/personMoney/PersonMoneyEventAggregatorTest.java @@ -23,7 +23,7 @@ import org.apache.commons.csv.CSVRecord; import org.apache.commons.lang3.mutable.MutableDouble; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonMoneyEvent; @@ -39,8 +39,8 @@ public class PersonMoneyEventAggregatorTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** * Test method for {@link org.matsim.analysis.personMoney.PersonMoneyEventsCollector}. diff --git a/matsim/src/test/java/org/matsim/api/core/v01/DemandGenerationTest.java b/matsim/src/test/java/org/matsim/api/core/v01/DemandGenerationTest.java index f03feb96de7..254e8a05703 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/DemandGenerationTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/DemandGenerationTest.java @@ -25,7 +25,7 @@ import org.junit.After; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -49,8 +49,8 @@ */ public class DemandGenerationTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final String populationFile = "population.xml"; diff --git a/matsim/src/test/java/org/matsim/api/core/v01/NetworkCreationTest.java b/matsim/src/test/java/org/matsim/api/core/v01/NetworkCreationTest.java index 203a7000a36..ce259d996c2 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/NetworkCreationTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/NetworkCreationTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -39,8 +39,8 @@ */ public class NetworkCreationTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testCreateNetwork() { diff --git a/matsim/src/test/java/org/matsim/core/config/CommandLineTest.java b/matsim/src/test/java/org/matsim/core/config/CommandLineTest.java index e9f32150370..4d623e74764 100644 --- a/matsim/src/test/java/org/matsim/core/config/CommandLineTest.java +++ b/matsim/src/test/java/org/matsim/core/config/CommandLineTest.java @@ -1,7 +1,7 @@ package org.matsim.core.config; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -9,7 +9,7 @@ public class CommandLineTest{ - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; @Test public void testStandardUsage() { diff --git a/matsim/src/test/java/org/matsim/core/config/ConfigV2IOTest.java b/matsim/src/test/java/org/matsim/core/config/ConfigV2IOTest.java index 4ee31b42d7b..2ed89e288fd 100644 --- a/matsim/src/test/java/org/matsim/core/config/ConfigV2IOTest.java +++ b/matsim/src/test/java/org/matsim/core/config/ConfigV2IOTest.java @@ -26,14 +26,14 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.config.groups.ChangeLegModeConfigGroup; -import org.matsim.testcases.MatsimJunit5TestExtension; +import org.matsim.testcases.MatsimTestUtils; /** * @author thibautd */ public class ConfigV2IOTest { @RegisterExtension - public final MatsimJunit5TestExtension utils = new MatsimJunit5TestExtension(); + public final MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testInputSameAsOutput() { diff --git a/matsim/src/test/java/org/matsim/core/config/MaterializeConfigTest.java b/matsim/src/test/java/org/matsim/core/config/MaterializeConfigTest.java index cdf645c7141..57f77ab8bca 100644 --- a/matsim/src/test/java/org/matsim/core/config/MaterializeConfigTest.java +++ b/matsim/src/test/java/org/matsim/core/config/MaterializeConfigTest.java @@ -3,15 +3,15 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; public class MaterializeConfigTest { private static final Logger log = LogManager.getLogger(MaterializeConfigTest.class); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public final void testMaterializeAfterReadParameterSets() { @@ -107,4 +107,4 @@ public String getParameter() { public void setParameter(String parameter) { this.parameter = parameter; } -} \ No newline at end of file +} diff --git a/matsim/src/test/java/org/matsim/core/config/ReflectiveConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/ReflectiveConfigGroupTest.java index be71252c59f..a0302aea465 100644 --- a/matsim/src/test/java/org/matsim/core/config/ReflectiveConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/ReflectiveConfigGroupTest.java @@ -32,13 +32,14 @@ import java.util.Map; import java.util.Set; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; +import org.junit.Assert; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.ReflectiveConfigGroup.InconsistentModuleException; -import org.matsim.testcases.MatsimJunit5Test; import org.matsim.testcases.MatsimTestUtils; import com.google.common.collect.ImmutableSet; @@ -46,7 +47,9 @@ /** * @author thibautd */ -public class ReflectiveConfigGroupTest extends MatsimJunit5Test { +public class ReflectiveConfigGroupTest { + @RegisterExtension + public final MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testDumpAndRead() { @@ -126,7 +129,7 @@ private void assertEqualAfterDumpAndRead(MyModule dumpedModule) { Config dumpedConfig = new Config(); dumpedConfig.addModule(dumpedModule); - String fileName = getOutputDirectory() + "/dump.xml"; + String fileName = utils.getOutputDirectory() + "/dump.xml"; new ConfigWriter(dumpedConfig).write(fileName); Config readConfig = ConfigUtils.loadConfig(fileName); @@ -139,7 +142,7 @@ private void assertEqualAfterDumpAndRead(MyModule dumpedModule) { @Test public void testReadCollectionsIncludingEmptyString() { - String fileName = getInputDirectory() + "/config_with_blank_comma_separated_elements.xml"; + String fileName = utils.getInputDirectory() + "/config_with_blank_comma_separated_elements.xml"; final Config readConfig = ConfigUtils.loadConfig(fileName); final MyModule readModule = new MyModule(); // as a side effect, this loads the information @@ -360,7 +363,7 @@ public Object getStuff() { final String param = "my unknown param"; final String value = "my val"; testee.addParam(param, value); - Assertions.assertEquals(value, testee.getValue(param), "unexpected stored value"); + Assert.assertEquals("unexpected stored value", value, testee.getValue(param)); } @Test diff --git a/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java index 17409e3ec33..ba0fae597fa 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.core.config.Config; @@ -46,7 +46,7 @@ public class ReplanningConfigGroupTest { private static final Logger log = LogManager.getLogger(ReplanningConfigGroupTest.class); - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java index 7b765cd84bb..5b04311c78f 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.core.config.Config; @@ -40,7 +40,7 @@ public class RoutingConfigGroupTest { private final static Logger log = LogManager.getLogger(RoutingConfigGroupTest.class); private final static int N_MODE_ROUTING_PARAMS_DEFAULT = 5 ; - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java index 16e7f336a44..d75ee413732 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java @@ -29,7 +29,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.core.config.Config; @@ -45,7 +45,7 @@ public class ScoringConfigGroupTest { private static final Logger log = LogManager.getLogger(ScoringConfigGroupTest.class); - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); private void testResultsBeforeCheckConsistency( Config config, boolean fullyHierarchical ) { diff --git a/matsim/src/test/java/org/matsim/core/config/groups/VspExperimentalConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/VspExperimentalConfigGroupTest.java index 74a908bbbdd..088d486fea7 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/VspExperimentalConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/VspExperimentalConfigGroupTest.java @@ -22,14 +22,14 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; public class VspExperimentalConfigGroupTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final Logger log = LogManager.getLogger(VspExperimentalConfigGroupTest.class); diff --git a/matsim/src/test/java/org/matsim/core/controler/AbstractModuleTest.java b/matsim/src/test/java/org/matsim/core/controler/AbstractModuleTest.java index ae3c97c0a8e..5651097897f 100644 --- a/matsim/src/test/java/org/matsim/core/controler/AbstractModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/AbstractModuleTest.java @@ -5,7 +5,7 @@ import com.google.inject.name.Named; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -22,7 +22,7 @@ public class AbstractModuleTest{ private static final Logger log = LogManager.getLogger( AbstractModuleTest.class ); - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; @Test public void test1() { diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java b/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java index 4a696e4e606..a1739b52361 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java @@ -28,7 +28,7 @@ import org.junit.After; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.controler.events.IterationEndsEvent; @@ -42,8 +42,8 @@ */ public class ControlerEventsTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private List calledStartupListener = null; diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java b/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java index a0c6bc24154..3f49cbf2b46 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java @@ -34,7 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -79,7 +79,7 @@ public class ControlerIT { private final static Logger log = LogManager.getLogger(ControlerIT.class); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); private final boolean isUsingFastCapacityUpdate; diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerMobsimIntegrationTest.java b/matsim/src/test/java/org/matsim/core/controler/ControlerMobsimIntegrationTest.java index a66fc10c46c..d20bc0a6222 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerMobsimIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerMobsimIntegrationTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.api.experimental.events.EventsManager; @@ -40,7 +40,7 @@ public class ControlerMobsimIntegrationTest { private final static Logger log = LogManager.getLogger(ControlerMobsimIntegrationTest.class); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testRunMobsim_customMobsim() { diff --git a/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java b/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java index b4ad53a30d1..9c7e303230d 100644 --- a/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java @@ -23,7 +23,7 @@ import org.junit.Assert; import org.junit.Ignore; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -33,8 +33,8 @@ public class MatsimServicesImplTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); @Ignore @Test diff --git a/matsim/src/test/java/org/matsim/core/controler/MobsimListenerTest.java b/matsim/src/test/java/org/matsim/core/controler/MobsimListenerTest.java index 099e07ca091..8818f2b63b6 100644 --- a/matsim/src/test/java/org/matsim/core/controler/MobsimListenerTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/MobsimListenerTest.java @@ -22,7 +22,7 @@ package org.matsim.core.controler; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.mobsim.framework.events.MobsimInitializedEvent; @@ -33,8 +33,8 @@ public class MobsimListenerTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testRunMobsim_listenerTransient() { diff --git a/matsim/src/test/java/org/matsim/core/controler/NewControlerTest.java b/matsim/src/test/java/org/matsim/core/controler/NewControlerTest.java index cbb1eabbe43..b10a0509487 100644 --- a/matsim/src/test/java/org/matsim/core/controler/NewControlerTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/NewControlerTest.java @@ -21,7 +21,7 @@ package org.matsim.core.controler; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; @@ -35,8 +35,8 @@ public class NewControlerTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void testInjectionBeforeControler() { diff --git a/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java b/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java index 0431939f972..9f9e788218e 100644 --- a/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java @@ -19,7 +19,7 @@ package org.matsim.core.controler; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.utils.io.IOUtils; @@ -34,7 +34,7 @@ * @author thibautd */ public class OutputDirectoryHierarchyTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java b/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java index 65de1dea5b9..6bfbc27f763 100644 --- a/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java @@ -3,7 +3,7 @@ import java.io.File; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.PersonDepartureEvent; @@ -30,8 +30,8 @@ * TerminationCriterion. */ public class TerminationTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testSimulationEndsOnInterval() { diff --git a/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java b/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java index 3d2999caa20..b02ba76fbe4 100644 --- a/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java @@ -25,7 +25,7 @@ import java.util.ArrayList; import java.util.Collections; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -61,8 +61,8 @@ public class TransitControlerIntegrationTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testTransitRouteCopy() { diff --git a/matsim/src/test/java/org/matsim/core/controler/corelisteners/ListenersInjectionTest.java b/matsim/src/test/java/org/matsim/core/controler/corelisteners/ListenersInjectionTest.java index ca53da64631..300296fbc27 100644 --- a/matsim/src/test/java/org/matsim/core/controler/corelisteners/ListenersInjectionTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/corelisteners/ListenersInjectionTest.java @@ -20,7 +20,7 @@ package org.matsim.core.controler.corelisteners; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.analysis.IterationStopWatch; import org.matsim.core.config.Config; @@ -42,7 +42,7 @@ * @author thibautd */ public class ListenersInjectionTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/matsim/src/test/java/org/matsim/core/controler/corelisteners/PlansDumpingIT.java b/matsim/src/test/java/org/matsim/core/controler/corelisteners/PlansDumpingIT.java index ee429308a3a..68e67547cb2 100644 --- a/matsim/src/test/java/org/matsim/core/controler/corelisteners/PlansDumpingIT.java +++ b/matsim/src/test/java/org/matsim/core/controler/corelisteners/PlansDumpingIT.java @@ -19,7 +19,7 @@ package org.matsim.core.controler.corelisteners; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.controler.Controler; @@ -35,7 +35,7 @@ */ public class PlansDumpingIT { - @Rule public MatsimTestUtils util = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils util = new MatsimTestUtils(); @Test public void testPlansDump_Interval() { diff --git a/matsim/src/test/java/org/matsim/core/events/ActEndEventTest.java b/matsim/src/test/java/org/matsim/core/events/ActEndEventTest.java index d4319c90c12..aee383139ab 100644 --- a/matsim/src/test/java/org/matsim/core/events/ActEndEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/ActEndEventTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -37,8 +37,8 @@ */ public class ActEndEventTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteReadXml() { diff --git a/matsim/src/test/java/org/matsim/core/events/ActStartEventTest.java b/matsim/src/test/java/org/matsim/core/events/ActStartEventTest.java index baa4b067f6a..7a57d2334e3 100644 --- a/matsim/src/test/java/org/matsim/core/events/ActStartEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/ActStartEventTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -37,8 +37,8 @@ */ public class ActStartEventTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteReadXml() { diff --git a/matsim/src/test/java/org/matsim/core/events/AgentMoneyEventTest.java b/matsim/src/test/java/org/matsim/core/events/AgentMoneyEventTest.java index df91a68fa3a..0a40dc47137 100644 --- a/matsim/src/test/java/org/matsim/core/events/AgentMoneyEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/AgentMoneyEventTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonMoneyEvent; @@ -34,8 +34,8 @@ */ public class AgentMoneyEventTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteReadXml() { diff --git a/matsim/src/test/java/org/matsim/core/events/AgentWaitingForPtEventTest.java b/matsim/src/test/java/org/matsim/core/events/AgentWaitingForPtEventTest.java index 827470698d8..08e5667ce31 100644 --- a/matsim/src/test/java/org/matsim/core/events/AgentWaitingForPtEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/AgentWaitingForPtEventTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -34,7 +34,7 @@ */ public class AgentWaitingForPtEventTest { - @Rule public MatsimTestUtils helper = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils helper = new MatsimTestUtils(); @Test public void testReadWriteXml() { diff --git a/matsim/src/test/java/org/matsim/core/events/BasicEventsHandlerTest.java b/matsim/src/test/java/org/matsim/core/events/BasicEventsHandlerTest.java index e2f24659ea1..d8c25c4eaa5 100644 --- a/matsim/src/test/java/org/matsim/core/events/BasicEventsHandlerTest.java +++ b/matsim/src/test/java/org/matsim/core/events/BasicEventsHandlerTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -39,8 +39,8 @@ public class BasicEventsHandlerTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testLinkEnterEventHandler() { diff --git a/matsim/src/test/java/org/matsim/core/events/EventsHandlerHierarchyTest.java b/matsim/src/test/java/org/matsim/core/events/EventsHandlerHierarchyTest.java index 5dedc88f8b3..6c09b3bd184 100644 --- a/matsim/src/test/java/org/matsim/core/events/EventsHandlerHierarchyTest.java +++ b/matsim/src/test/java/org/matsim/core/events/EventsHandlerHierarchyTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.Event; @@ -37,8 +37,8 @@ public class EventsHandlerHierarchyTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); int eventHandled = 0; diff --git a/matsim/src/test/java/org/matsim/core/events/EventsReadersTest.java b/matsim/src/test/java/org/matsim/core/events/EventsReadersTest.java index 4dd891c976c..24f43377b2d 100644 --- a/matsim/src/test/java/org/matsim/core/events/EventsReadersTest.java +++ b/matsim/src/test/java/org/matsim/core/events/EventsReadersTest.java @@ -26,7 +26,7 @@ import javax.xml.parsers.ParserConfigurationException; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; @@ -53,8 +53,8 @@ public class EventsReadersTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); diff --git a/matsim/src/test/java/org/matsim/core/events/GenericEventTest.java b/matsim/src/test/java/org/matsim/core/events/GenericEventTest.java index e46bc1ac1ed..b24edda5020 100644 --- a/matsim/src/test/java/org/matsim/core/events/GenericEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/GenericEventTest.java @@ -21,7 +21,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.events.GenericEvent; import org.matsim.testcases.MatsimTestUtils; @@ -32,8 +32,8 @@ */ public class GenericEventTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteReadXml() { diff --git a/matsim/src/test/java/org/matsim/core/events/LinkEnterEventTest.java b/matsim/src/test/java/org/matsim/core/events/LinkEnterEventTest.java index a057273b468..c098d01d14a 100644 --- a/matsim/src/test/java/org/matsim/core/events/LinkEnterEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/LinkEnterEventTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.LinkEnterEvent; @@ -35,8 +35,8 @@ */ public class LinkEnterEventTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteReadXml() { diff --git a/matsim/src/test/java/org/matsim/core/events/LinkLeaveEventTest.java b/matsim/src/test/java/org/matsim/core/events/LinkLeaveEventTest.java index 7608932471d..10c7c168aee 100644 --- a/matsim/src/test/java/org/matsim/core/events/LinkLeaveEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/LinkLeaveEventTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.LinkLeaveEvent; @@ -35,8 +35,8 @@ */ public class LinkLeaveEventTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteReadXml() { diff --git a/matsim/src/test/java/org/matsim/core/events/PersonArrivalEventTest.java b/matsim/src/test/java/org/matsim/core/events/PersonArrivalEventTest.java index 08d6192f944..b5a2e03edca 100644 --- a/matsim/src/test/java/org/matsim/core/events/PersonArrivalEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/PersonArrivalEventTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -36,8 +36,8 @@ */ public class PersonArrivalEventTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteReadXml() { diff --git a/matsim/src/test/java/org/matsim/core/events/PersonDepartureEventTest.java b/matsim/src/test/java/org/matsim/core/events/PersonDepartureEventTest.java index 95e8fda3a8b..7f42ea5a472 100644 --- a/matsim/src/test/java/org/matsim/core/events/PersonDepartureEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/PersonDepartureEventTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -36,8 +36,8 @@ */ public class PersonDepartureEventTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteReadXml() { diff --git a/matsim/src/test/java/org/matsim/core/events/PersonEntersVehicleEventTest.java b/matsim/src/test/java/org/matsim/core/events/PersonEntersVehicleEventTest.java index 04f74f23db9..bb554d35908 100644 --- a/matsim/src/test/java/org/matsim/core/events/PersonEntersVehicleEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/PersonEntersVehicleEventTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonEntersVehicleEvent; @@ -38,8 +38,8 @@ */ public class PersonEntersVehicleEventTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testReadWriteXml() { diff --git a/matsim/src/test/java/org/matsim/core/events/PersonLeavesVehicleEventTest.java b/matsim/src/test/java/org/matsim/core/events/PersonLeavesVehicleEventTest.java index ffaf19b3c30..bd0c7ac42c6 100644 --- a/matsim/src/test/java/org/matsim/core/events/PersonLeavesVehicleEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/PersonLeavesVehicleEventTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonLeavesVehicleEvent; @@ -38,8 +38,8 @@ */ public class PersonLeavesVehicleEventTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteReadXml() { diff --git a/matsim/src/test/java/org/matsim/core/events/PersonStuckEventTest.java b/matsim/src/test/java/org/matsim/core/events/PersonStuckEventTest.java index 0f3a062a0bb..090c2512aa5 100644 --- a/matsim/src/test/java/org/matsim/core/events/PersonStuckEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/PersonStuckEventTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -36,8 +36,8 @@ */ public class PersonStuckEventTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteReadXml() { diff --git a/matsim/src/test/java/org/matsim/core/events/TransitDriverStartsEventTest.java b/matsim/src/test/java/org/matsim/core/events/TransitDriverStartsEventTest.java index 7b81c9a31ea..4f9076d4f51 100644 --- a/matsim/src/test/java/org/matsim/core/events/TransitDriverStartsEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/TransitDriverStartsEventTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.TransitDriverStartsEvent; @@ -36,15 +36,15 @@ */ public class TransitDriverStartsEventTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteReadXml() { - final TransitDriverStartsEvent event1 = new TransitDriverStartsEvent(36095.2, - Id.create("ptDrvr-1", Person.class), - Id.create("vehicle-bus5", Vehicle.class), - Id.create("line L-1", TransitLine.class), - Id.create("route-R1", TransitRoute.class), + final TransitDriverStartsEvent event1 = new TransitDriverStartsEvent(36095.2, + Id.create("ptDrvr-1", Person.class), + Id.create("vehicle-bus5", Vehicle.class), + Id.create("line L-1", TransitLine.class), + Id.create("route-R1", TransitRoute.class), Id.create("departure-D-1", Departure.class)); final TransitDriverStartsEvent event2 = XmlEventsTester.testWriteReadXml(this.utils.getOutputDirectory() + "events.xml", event1); Assert.assertEquals(event1.getTime(), event2.getTime(), 1.0e-9); diff --git a/matsim/src/test/java/org/matsim/core/events/VehicleAbortsEventTest.java b/matsim/src/test/java/org/matsim/core/events/VehicleAbortsEventTest.java index 77b154c4282..274cb9b762a 100644 --- a/matsim/src/test/java/org/matsim/core/events/VehicleAbortsEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/VehicleAbortsEventTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.VehicleAbortsEvent; @@ -35,8 +35,8 @@ */ public class VehicleAbortsEventTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteReadXml() { diff --git a/matsim/src/test/java/org/matsim/core/events/VehicleArrivesAtFacilityEventImplTest.java b/matsim/src/test/java/org/matsim/core/events/VehicleArrivesAtFacilityEventImplTest.java index 644f47ca99c..05929edf7e8 100644 --- a/matsim/src/test/java/org/matsim/core/events/VehicleArrivesAtFacilityEventImplTest.java +++ b/matsim/src/test/java/org/matsim/core/events/VehicleArrivesAtFacilityEventImplTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent; @@ -33,8 +33,8 @@ public class VehicleArrivesAtFacilityEventImplTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteReadXml() { diff --git a/matsim/src/test/java/org/matsim/core/events/VehicleDepartsAtFacilityEventImplTest.java b/matsim/src/test/java/org/matsim/core/events/VehicleDepartsAtFacilityEventImplTest.java index a425d4118a0..99b3396177a 100644 --- a/matsim/src/test/java/org/matsim/core/events/VehicleDepartsAtFacilityEventImplTest.java +++ b/matsim/src/test/java/org/matsim/core/events/VehicleDepartsAtFacilityEventImplTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.core.api.experimental.events.VehicleDepartsAtFacilityEvent; @@ -33,8 +33,8 @@ public class VehicleDepartsAtFacilityEventImplTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteReadXml() { diff --git a/matsim/src/test/java/org/matsim/core/events/VehicleEntersTrafficEventTest.java b/matsim/src/test/java/org/matsim/core/events/VehicleEntersTrafficEventTest.java index 420f8de3ad7..45f4676e80b 100644 --- a/matsim/src/test/java/org/matsim/core/events/VehicleEntersTrafficEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/VehicleEntersTrafficEventTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -37,8 +37,8 @@ */ public class VehicleEntersTrafficEventTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteReadXml() { diff --git a/matsim/src/test/java/org/matsim/core/events/VehicleLeavesTrafficEventTest.java b/matsim/src/test/java/org/matsim/core/events/VehicleLeavesTrafficEventTest.java index b577e4d0afc..241e0b9f382 100644 --- a/matsim/src/test/java/org/matsim/core/events/VehicleLeavesTrafficEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/VehicleLeavesTrafficEventTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -37,8 +37,8 @@ */ public class VehicleLeavesTrafficEventTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteReadXml() { diff --git a/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterXMLTest.java b/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterXMLTest.java index cf510a4e60f..a84b21baf2d 100644 --- a/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterXMLTest.java +++ b/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterXMLTest.java @@ -22,7 +22,7 @@ import java.io.File; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.GenericEvent; @@ -40,8 +40,8 @@ */ public class EventWriterXMLTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + /** * Some people use the ids as names, including special characters in there... so make sure attribute * values are correctly encoded when written to a file. @@ -50,7 +50,7 @@ public class EventWriterXMLTest { public void testSpecialCharacters() { String filename = this.utils.getOutputDirectory() + "testEvents.xml"; EventWriterXML writer = new EventWriterXML(filename); - + writer.handleEvent(new LinkLeaveEvent(3600.0, Id.create("vehicle>3", Vehicle.class), Id.create("link<2", Link.class))); writer.handleEvent(new LinkLeaveEvent(3601.0, Id.create("vehicle\"4", Vehicle.class), Id.create("link'3", Link.class))); writer.closeFile(); @@ -79,20 +79,20 @@ public void testSpecialCharacters() { public void testNullAttribute() { String filename = this.utils.getOutputDirectory() + "testEvents.xml"; EventWriterXML writer = new EventWriterXML(filename); - + GenericEvent event = new GenericEvent("TEST", 3600.0); event.getAttributes().put("dummy", null); writer.handleEvent(event); writer.closeFile(); Assert.assertTrue(new File(filename).exists()); - + EventsManager events = EventsUtils.createEventsManager(); EventsCollector collector = new EventsCollector(); events.addHandler(collector); events.initProcessing(); // this is already a test: is the XML valid so it can be parsed again? new MatsimEventsReader(events).readFile(filename); - + events.finishProcessing(); Assert.assertEquals("there must be 1 event.", 1, collector.getEvents().size()); } diff --git a/matsim/src/test/java/org/matsim/core/gbl/MatsimRandomTest.java b/matsim/src/test/java/org/matsim/core/gbl/MatsimRandomTest.java index cfc7b4ba1bb..c9e1aa8c73c 100644 --- a/matsim/src/test/java/org/matsim/core/gbl/MatsimRandomTest.java +++ b/matsim/src/test/java/org/matsim/core/gbl/MatsimRandomTest.java @@ -25,7 +25,7 @@ import java.util.Random; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -34,8 +34,8 @@ */ public class MatsimRandomTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/core/gbl/MatsimResourceTest.java b/matsim/src/test/java/org/matsim/core/gbl/MatsimResourceTest.java index 4058168db0c..40394904b1f 100644 --- a/matsim/src/test/java/org/matsim/core/gbl/MatsimResourceTest.java +++ b/matsim/src/test/java/org/matsim/core/gbl/MatsimResourceTest.java @@ -24,7 +24,7 @@ import java.awt.Image; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -33,8 +33,8 @@ */ public class MatsimResourceTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public final void testGetAsImage() { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesRoundaboutTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesRoundaboutTest.java index ff2e28c9e31..e8dcd098d1b 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesRoundaboutTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesRoundaboutTest.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.Map; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.locationtech.jts.util.Assert; import org.matsim.api.core.v01.Coord; @@ -60,8 +60,8 @@ public class HermesRoundaboutTest { public static final Coord A_START = new Coord(0, -60); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/AbstractJDEQSimTest.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/AbstractJDEQSimTest.java index 6017b868bed..cd7c0b8a0da 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/AbstractJDEQSimTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/AbstractJDEQSimTest.java @@ -32,7 +32,7 @@ import org.junit.After; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -69,7 +69,7 @@ public abstract class AbstractJDEQSimTest { - @Rule + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); protected Map, Id> vehicleToDriver = null; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/ConfigParameterTest.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/ConfigParameterTest.java index 3e14d2281e8..f95aa9149da 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/ConfigParameterTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/ConfigParameterTest.java @@ -21,7 +21,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -29,8 +29,8 @@ public class ConfigParameterTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testParametersSetCorrectly() { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestEventLog.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestEventLog.java index 8fe15767525..fb8231a0859 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestEventLog.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestEventLog.java @@ -23,15 +23,15 @@ import java.util.ArrayList; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.mobsim.jdeqsim.util.CppEventFileParser; import org.matsim.testcases.MatsimTestUtils; public class TestEventLog { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testGetTravelTime(){ diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestMessageFactory.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestMessageFactory.java index cdac5815578..0906d2c8814 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestMessageFactory.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestMessageFactory.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -35,8 +35,8 @@ public class TestMessageFactory { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); // check if gc turned on @Test public void testMessageFactory1(){ diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestMessageQueue.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestMessageQueue.java index bda50e8a94a..23bc2712123 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestMessageQueue.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestMessageQueue.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.mobsim.jdeqsim.util.DummyMessage; import org.matsim.testcases.MatsimTestUtils; @@ -31,8 +31,8 @@ public class TestMessageQueue { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testPutMessage1(){ MessageQueue mq=new MessageQueue(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/util/TestEventLibrary.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/util/TestEventLibrary.java index 88554925a0e..314faf79eb5 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/util/TestEventLibrary.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/util/TestEventLibrary.java @@ -25,7 +25,7 @@ import java.util.LinkedList; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -38,8 +38,8 @@ public class TestEventLibrary { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testGetTravelTime(){ diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/FlowStorageSpillbackTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/FlowStorageSpillbackTest.java index 2ac3bee129f..0b5d2e4d65c 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/FlowStorageSpillbackTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/FlowStorageSpillbackTest.java @@ -24,7 +24,7 @@ import java.util.*; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -61,8 +61,8 @@ @RunWith(Parameterized.class) public class FlowStorageSpillbackTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); private final boolean isUsingFastCapacityUpdate; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimEventsIntegrationTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimEventsIntegrationTest.java index 09c873c3f2c..e7ec111bd4b 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimEventsIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimEventsIntegrationTest.java @@ -22,9 +22,9 @@ package org.matsim.core.mobsim.qsim; import org.assertj.core.api.Assertions; -import org.junit.Rule; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; -import org.junit.rules.Timeout; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.handler.LinkLeaveEventHandler; import org.matsim.core.api.experimental.events.EventsManager; @@ -35,12 +35,10 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.testcases.MatsimTestUtils; +@Timeout(10) public class QSimEventsIntegrationTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); - - @Rule - public Timeout globalTimeout = new Timeout(10000); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void netsimEngineHandlesExceptionCorrectly() { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/TeleportationEngineWDistanceCheckTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/TeleportationEngineWDistanceCheckTest.java index 9e722b5eaa6..0af1d61514c 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/TeleportationEngineWDistanceCheckTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/TeleportationEngineWDistanceCheckTest.java @@ -20,7 +20,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -56,7 +56,7 @@ public class TeleportationEngineWDistanceCheckTest { private static final Logger log = LogManager.getLogger( TeleportationEngineWDistanceCheckTest.class ) ; - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; @Test public final void test() { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java index 069f22b616b..5ffc5e3b6af 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java @@ -19,7 +19,7 @@ package org.matsim.core.mobsim.qsim; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -100,7 +100,7 @@ public static Collection parameterObjects () { ); } - @Rule public MatsimTestUtils helper = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils helper = new MatsimTestUtils(); private Scenario scenario ; private final String[] transportModes = new String[]{"bike", "car"}; private Link link1; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/jdeqsimengine/JDEQSimPluginTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/jdeqsimengine/JDEQSimPluginTest.java index 8be6ddce8a9..af6cfbc3aa3 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/jdeqsimengine/JDEQSimPluginTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/jdeqsimengine/JDEQSimPluginTest.java @@ -21,7 +21,7 @@ package org.matsim.core.mobsim.qsim.jdeqsimengine; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.api.experimental.events.EventsManager; @@ -38,8 +38,8 @@ */ public class JDEQSimPluginTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private QSim prepareQSim(Scenario scenario, EventsManager eventsManager) { return new QSimBuilder(scenario.getConfig()) // diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/UmlaufDriverTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/UmlaufDriverTest.java index b7bd85628a1..a30dfcc609f 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/UmlaufDriverTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/UmlaufDriverTest.java @@ -29,7 +29,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -74,8 +74,8 @@ */ public class UmlaufDriverTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final Logger log = LogManager.getLogger(UmlaufDriverTest.class); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/LinkSpeedCalculatorIntegrationTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/LinkSpeedCalculatorIntegrationTest.java index a73e82a5b3e..7f1d04bc347 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/LinkSpeedCalculatorIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/LinkSpeedCalculatorIntegrationTest.java @@ -23,7 +23,7 @@ import jakarta.inject.Inject; import jakarta.inject.Provider; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -58,7 +58,7 @@ */ public class LinkSpeedCalculatorIntegrationTest { - @Rule public MatsimTestUtils helper = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils helper = new MatsimTestUtils(); @Test public void testIntegration_Default() { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/PassingTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/PassingTest.java index 78f85f000a2..554b88b3059 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/PassingTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/PassingTest.java @@ -21,7 +21,7 @@ import java.util.*; import jakarta.inject.Inject; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -63,7 +63,7 @@ */ public class PassingTest { - @Rule public MatsimTestUtils helper = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils helper = new MatsimTestUtils(); /** * A bike enters at t=0; and a car at t=5sec link length = 1000m diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkLanesTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkLanesTest.java index 0577d703827..064025f4fe1 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkLanesTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkLanesTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -53,8 +53,8 @@ */ public class QLinkLanesTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static void initNetwork(Network network) { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkTest.java index 63e11d2c30d..bb83c11c1d8 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkTest.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -88,8 +88,8 @@ @RunWith(Parameterized.class) public final class QLinkTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final Logger logger = LogManager.getLogger( QLinkTest.class ); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QSimComponentsTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QSimComponentsTest.java index 8915e730af2..28f2c1bd0dd 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QSimComponentsTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QSimComponentsTest.java @@ -4,7 +4,7 @@ import com.google.inject.ProvisionException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -30,7 +30,7 @@ public class QSimComponentsTest{ private final static String MY_NETSIM_ENGINE = "MyNetsimEngine"; private static final Logger log = LogManager.getLogger( QSimComponentsTest.class ); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test(expected = RuntimeException.class) public void testRemoveNetsimEngine() { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java index 62966d8493f..01ee89e122e 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java @@ -27,7 +27,7 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -69,8 +69,8 @@ */ public class SimulatedLaneFlowCapacityTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** * create this network: diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SpeedCalculatorTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SpeedCalculatorTest.java index cea3d9d7d25..dcef567b287 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SpeedCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SpeedCalculatorTest.java @@ -1,7 +1,7 @@ package org.matsim.core.mobsim.qsim.qnetsimengine; import com.google.inject.Singleton; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -33,7 +33,7 @@ public class SpeedCalculatorTest{ // This originally comes from the bicycle contrib. One now needs access to AbstractQLink to properly test this functionality. In contrast, the // specific bicycle material should not be necessary. kai, jun'23 - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); private final Config config = ConfigUtils.createConfig(); private final Network unusedNetwork = NetworkUtils.createNetwork(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java index 48bf9fbc37a..6919f8f020c 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java @@ -24,7 +24,7 @@ import java.util.Arrays; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -57,8 +57,8 @@ public class VehicleHandlerTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testVehicleHandler() { diff --git a/matsim/src/test/java/org/matsim/core/network/AbstractNetworkWriterReaderTest.java b/matsim/src/test/java/org/matsim/core/network/AbstractNetworkWriterReaderTest.java index 90b73184eee..7391d0b4d2f 100644 --- a/matsim/src/test/java/org/matsim/core/network/AbstractNetworkWriterReaderTest.java +++ b/matsim/src/test/java/org/matsim/core/network/AbstractNetworkWriterReaderTest.java @@ -34,7 +34,7 @@ import java.util.Set; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -57,8 +57,8 @@ */ public abstract class AbstractNetworkWriterReaderTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksTest.java b/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksTest.java index 1cb653a1421..f48d85ecc6b 100644 --- a/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksTest.java +++ b/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksTest.java @@ -2,13 +2,15 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.Collections; import java.util.List; import java.util.Map; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; +import org.junit.jupiter.api.io.TempDir; import org.junit.rules.TemporaryFolder; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -21,8 +23,8 @@ public class DisallowedNextLinksTest { - @Rule - public TemporaryFolder tempFolder = new TemporaryFolder(); + @TempDir + public File tempFolder; @Test public void testEquals() { @@ -135,7 +137,7 @@ public void testNetworkWritingAndReading() throws IOException { DisallowedNextLinks dnl0 = NetworkUtils.getOrCreateDisallowedNextLinks(l1); dnl0.addDisallowedLinkSequence("car", List.of(l1.getId(), Id.createLinkId("2"))); - File tempFile = tempFolder.newFile("network.xml"); + File tempFile = new File(tempFolder, "network.xml"); new NetworkWriter(n).write(tempFile.toString()); Network network = NetworkUtils.createNetwork(); new MatsimNetworkReader(network).readFile(tempFile.toString()); diff --git a/matsim/src/test/java/org/matsim/core/network/NetworkChangeEventsParserWriterTest.java b/matsim/src/test/java/org/matsim/core/network/NetworkChangeEventsParserWriterTest.java index f02fcc531dc..44479f38383 100644 --- a/matsim/src/test/java/org/matsim/core/network/NetworkChangeEventsParserWriterTest.java +++ b/matsim/src/test/java/org/matsim/core/network/NetworkChangeEventsParserWriterTest.java @@ -21,7 +21,7 @@ package org.matsim.core.network; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -43,8 +43,8 @@ public class NetworkChangeEventsParserWriterTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils() ; @Test public void testChangeEventsParserWriter() { @@ -227,4 +227,4 @@ public void testNegativeOffsetChangeEvents() { Assert.assertEquals(event.getFreespeedChange().getValue(), event2.getFreespeedChange().getValue(), 1e-10); } -} \ No newline at end of file +} diff --git a/matsim/src/test/java/org/matsim/core/network/NetworkUtilsTest.java b/matsim/src/test/java/org/matsim/core/network/NetworkUtilsTest.java index 1b54bdee4ce..28008eaa50c 100644 --- a/matsim/src/test/java/org/matsim/core/network/NetworkUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/network/NetworkUtilsTest.java @@ -21,7 +21,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -46,9 +46,9 @@ */ public class NetworkUtilsTest { private static final Logger log = LogManager.getLogger( NetworkUtilsTest.class ) ; - - @Rule - public MatsimTestUtils utils = new MatsimTestUtils() ; + + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils() ; /** * Test method for {@link org.matsim.core.network.NetworkUtils#isMultimodal(org.matsim.api.core.v01.network.Network)}. @@ -58,13 +58,13 @@ public final void testIsMultimodal() { Config config = utils.createConfigWithInputResourcePathAsContext(); config.network().setInputFile("network.xml" ); - + Scenario scenario = ScenarioUtils.loadScenario(config) ; - + Network network = scenario.getNetwork() ; - + Assert.assertTrue( NetworkUtils.isMultimodal( network ) ); - + } @@ -73,11 +73,11 @@ public final void testIsMultimodal() { public final void getOutLinksSortedByAngleTest() { final Network network = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getNetwork(); // (we need the network to properly connect the links) - + NetworkFactory nf = network.getFactory() ; - + // a number of potentially outgoing links: - + Node nd0 = nf.createNode(Id.createNodeId("0"), new Coord(0.,0.) ) ; Node ndN = nf.createNode(Id.createNodeId("N"), new Coord(0.,100.) ) ; Node ndNE = nf.createNode(Id.createNodeId("NE"), new Coord(100.,100.) ) ; @@ -87,7 +87,7 @@ public final void getOutLinksSortedByAngleTest() { Node ndSW = nf.createNode(Id.createNodeId("SW"), new Coord(-100.,-100.) ) ; Node ndW = nf.createNode(Id.createNodeId("W"), new Coord(-100.,0.) ) ; Node ndNW = nf.createNode(Id.createNodeId("NW"), new Coord(-100.,+100.) ) ; - + network.addNode( nd0 ); network.addNode( ndN ); network.addNode( ndNE ); @@ -97,7 +97,7 @@ public final void getOutLinksSortedByAngleTest() { network.addNode( ndSW ); network.addNode( ndW ); network.addNode( ndNW ); - + Link liN = nf.createLink( Id.createLinkId("N"), nd0, ndN ) ; Link liNE = nf.createLink( Id.createLinkId("NE"), nd0, ndNE ) ; Link liE = nf.createLink( Id.createLinkId("E"), nd0, ndE ) ; @@ -106,7 +106,7 @@ public final void getOutLinksSortedByAngleTest() { Link liSW = nf.createLink( Id.createLinkId("SW"), nd0, ndSW ) ; Link liW = nf.createLink( Id.createLinkId("W"), nd0, ndW ) ; Link liNW = nf.createLink( Id.createLinkId("NW"), nd0, ndNW ) ; - + network.addLink( liN ); network.addLink( liNE ); network.addLink( liE ); @@ -115,7 +115,7 @@ public final void getOutLinksSortedByAngleTest() { network.addLink( liSW ); network.addLink( liW ); network.addLink( liNW ); - + log.info("==="); // a link coming north to south: { @@ -124,11 +124,11 @@ public final void getOutLinksSortedByAngleTest() { for ( Link outLink : result.values() ) { log.info( outLink ); } - + Link[] actuals = result.values().toArray( new Link[result.size()] ) ; Link[] expecteds = {liNE,liE,liSE,liS,liSW,liW,liNW} ; Assert.assertArrayEquals(expecteds, actuals); - + } log.info("==="); // a link coming south to north: diff --git a/matsim/src/test/java/org/matsim/core/network/NetworkV2IOTest.java b/matsim/src/test/java/org/matsim/core/network/NetworkV2IOTest.java index ed49b59785d..589ec99ba16 100644 --- a/matsim/src/test/java/org/matsim/core/network/NetworkV2IOTest.java +++ b/matsim/src/test/java/org/matsim/core/network/NetworkV2IOTest.java @@ -22,7 +22,7 @@ package org.matsim.core.network; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -37,8 +37,8 @@ * @author thibautd */ public class NetworkV2IOTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testNetworkAttributes() { diff --git a/matsim/src/test/java/org/matsim/core/network/TimeVariantLinkImplTest.java b/matsim/src/test/java/org/matsim/core/network/TimeVariantLinkImplTest.java index 9b6c6f109d9..5b84ddb4263 100644 --- a/matsim/src/test/java/org/matsim/core/network/TimeVariantLinkImplTest.java +++ b/matsim/src/test/java/org/matsim/core/network/TimeVariantLinkImplTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -39,8 +39,8 @@ */ public class TimeVariantLinkImplTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final double TIME_BEFORE_FIRST_CHANGE_EVENTS = -99999;//when base (default) link properties are used diff --git a/matsim/src/test/java/org/matsim/core/network/TravelTimeCalculatorIntegrationTest.java b/matsim/src/test/java/org/matsim/core/network/TravelTimeCalculatorIntegrationTest.java index 3ab5af3cff8..8a886da7975 100644 --- a/matsim/src/test/java/org/matsim/core/network/TravelTimeCalculatorIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/network/TravelTimeCalculatorIntegrationTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -43,8 +43,8 @@ */ public class TravelTimeCalculatorIntegrationTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testTravelTimeCalculatorArray() { diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/IntersectionSimplifierTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/IntersectionSimplifierTest.java index 733a8ed14cf..8d8e0f6639c 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/IntersectionSimplifierTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/IntersectionSimplifierTest.java @@ -25,7 +25,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -41,7 +41,7 @@ import org.matsim.testcases.MatsimTestUtils; public class IntersectionSimplifierTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testComplexIntersection() { @@ -116,7 +116,7 @@ public void testSimplifyOne() { Cluster c2 = findCluster(clusters, CoordUtils.createCoord(225.0, 85.0)); Assert.assertNotNull("Could not find cluster with centroid (225.0,85.0)", c2); Assert.assertEquals("Wrong number of points", 4, c2.getPoints().size()); - + /* Write the cleaned network to file. */ new NetworkWriter(simpleNetwork).write(utils.getOutputDirectory() + "cleanNetwork.xml"); } @@ -138,13 +138,13 @@ public void testSimplifyTwo() { Cluster c2 = findCluster(clusters, CoordUtils.createCoord(225.0, 85.0)); Assert.assertNotNull("Could not find cluster with centroid (225.0,85.0)", c2); Assert.assertEquals("Wrong number of points", 12, c2.getPoints().size()); - + /* Write the cleaned network to file. */ new NetworkWriter(simpleNetwork).write(utils.getOutputDirectory() + "cleanNetwork.xml"); } /** - * The network cleaner will/should ensure that full connectivity remains. + * The network cleaner will/should ensure that full connectivity remains. */ @Test public void testNetworkCleaner() { @@ -194,7 +194,7 @@ public void testNetworkSimplifier() { ns.run(simpleNetwork); new NetworkCleaner().run(simpleNetwork); new NetworkWriter(simpleNetwork).write(utils.getOutputDirectory() + "network.xml"); - + Assert.assertEquals("Wrong number of nodes.", 12l, simpleNetwork.getNodes().size()); Assert.assertNotNull("Should find node '1'", simpleNetwork.getNodes().get(Id.createNodeId("1"))); @@ -219,7 +219,7 @@ public void testNetworkSimplifier() { Assert.assertNotNull("Should find simplified node '23-24'", simpleNetwork.getNodes().get(Id.createNodeId("23-24"))); } - + private Cluster findCluster(List clusters, Coord c) { Cluster cluster = null; Iterator iterator = clusters.iterator(); @@ -234,7 +234,7 @@ private Cluster findCluster(List clusters, Coord c) { /** - * The following layout is not according to scale, but shows the structure + * The following layout is not according to scale, but shows the structure * of the two 'complex' intersections. * 11 * | @@ -242,7 +242,7 @@ private Cluster findCluster(List clusters, Coord c) { * 12 * 3 / \ * | / \ - * | .__ 13 14 __. + * | .__ 13 14 __. * 4 / | | \ * / \ | | | | * .____ 5 ___ 6 _____________> 110m ______________ 15 ___ 16 ___ 17 ___ 18 ___. @@ -352,4 +352,4 @@ private Network buildComplexIntersection() { return network; } -} \ No newline at end of file +} diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/containers/ConcaveHullTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/containers/ConcaveHullTest.java index 2a8be041b68..8fdde25b9eb 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/containers/ConcaveHullTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/containers/ConcaveHullTest.java @@ -20,7 +20,7 @@ package org.matsim.core.network.algorithms.intersectionSimplifier.containers; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; @@ -30,33 +30,33 @@ import org.matsim.testcases.MatsimTestUtils; public class ConcaveHullTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + - /** Test whether duplicate input points are removed. **/ @Test public void testConstructor(){ GeometryCollection gcIncorrect = setupWithDuplicates(); ConcaveHull ch1 = new ConcaveHull(gcIncorrect, 2); Assert.assertEquals("Duplicates not removed.", 8, ch1.getInputPoints()); - + GeometryCollection gcCorrect = setup(); ConcaveHull ch2 = new ConcaveHull(gcCorrect, 2); Assert.assertEquals("Wrong number of input points.", 8, ch2.getInputPoints()); } - - + + public void testGetConcaveHull(){ GeometryCollection gc = setup(); ConcaveHull ch = new ConcaveHull(gc, 1.0); Geometry g = ch.getConcaveHull(); Assert.assertTrue("Wrong geometry created.", g instanceof Polygon); } - + /** * Set up a small test case: - * + * * ^ * | * 3 4 @@ -64,7 +64,7 @@ public void testGetConcaveHull(){ * | 8 6 * | 5 * 1_________2___> - * + * */ private GeometryCollection setup(){ GeometryFactory gf = new GeometryFactory(); @@ -79,7 +79,7 @@ private GeometryCollection setup(){ ga[7] = gf.createPoint(new Coordinate(1, 2)); return new GeometryCollection(ga, gf); } - + /** * Creates a similar {@link GeometryCollection} as in setup() but have * triplicates of points 7 & 8. @@ -96,10 +96,10 @@ private GeometryCollection setupWithDuplicates(){ ga[5] = gf.createPoint(new Coordinate(3, 2)); // 6 ga[6] = gf.createPoint(new Coordinate(2, 3)); // 7 ga[7] = gf.createPoint(new Coordinate(1, 2)); // 8 - + ga[8] = gf.createPoint(new Coordinate(2, 3)); // 7 ga[9] = gf.createPoint(new Coordinate(2, 3)); // 7 - + ga[10] = gf.createPoint(new Coordinate(1, 2)); // 8 ga[11] = gf.createPoint(new Coordinate(1, 2)); // 8 return new GeometryCollection(ga, gf); diff --git a/matsim/src/test/java/org/matsim/core/network/io/NetworkAttributeConversionTest.java b/matsim/src/test/java/org/matsim/core/network/io/NetworkAttributeConversionTest.java index cdb701228af..e122adda402 100644 --- a/matsim/src/test/java/org/matsim/core/network/io/NetworkAttributeConversionTest.java +++ b/matsim/src/test/java/org/matsim/core/network/io/NetworkAttributeConversionTest.java @@ -22,7 +22,7 @@ package org.matsim.core.network.io; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; @@ -35,7 +35,7 @@ import java.util.function.Consumer; public class NetworkAttributeConversionTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/matsim/src/test/java/org/matsim/core/network/io/NetworkReaderMatsimV1Test.java b/matsim/src/test/java/org/matsim/core/network/io/NetworkReaderMatsimV1Test.java index f69ec1a456b..33517747af2 100644 --- a/matsim/src/test/java/org/matsim/core/network/io/NetworkReaderMatsimV1Test.java +++ b/matsim/src/test/java/org/matsim/core/network/io/NetworkReaderMatsimV1Test.java @@ -25,7 +25,7 @@ import java.util.Set; import java.util.Stack; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -42,8 +42,8 @@ public class NetworkReaderMatsimV1Test { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/core/network/io/NetworkReprojectionIOTest.java b/matsim/src/test/java/org/matsim/core/network/io/NetworkReprojectionIOTest.java index 3fe86ebe824..980cddcc1eb 100644 --- a/matsim/src/test/java/org/matsim/core/network/io/NetworkReprojectionIOTest.java +++ b/matsim/src/test/java/org/matsim/core/network/io/NetworkReprojectionIOTest.java @@ -22,7 +22,7 @@ package org.matsim.core.network.io; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -51,7 +51,7 @@ public class NetworkReprojectionIOTest { INITIAL_CRS, TARGET_CRS); - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/matsim/src/test/java/org/matsim/core/population/PersonImplTest.java b/matsim/src/test/java/org/matsim/core/population/PersonImplTest.java index b8a84df5797..732657460e2 100644 --- a/matsim/src/test/java/org/matsim/core/population/PersonImplTest.java +++ b/matsim/src/test/java/org/matsim/core/population/PersonImplTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -41,8 +41,8 @@ */ public class PersonImplTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private final static Logger log = LogManager.getLogger(PersonImplTest.class); diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationAttributeConversionTest.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationAttributeConversionTest.java index c418f5179a2..8fe0bef6f34 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationAttributeConversionTest.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationAttributeConversionTest.java @@ -22,7 +22,7 @@ package org.matsim.core.population.io; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -39,7 +39,7 @@ import java.util.function.Consumer; public class PopulationAttributeConversionTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationReprojectionIOIT.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationReprojectionIOIT.java index 853af4157eb..7518db2c084 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationReprojectionIOIT.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationReprojectionIOIT.java @@ -28,7 +28,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -66,7 +66,7 @@ public class PopulationReprojectionIOIT { private static final String NET_FILE = "network.xml.gz"; private static final String BASE_FILE = "plans_hwh_1pct.xml.gz"; - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationV6IOTest.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationV6IOTest.java index 1228ac4736a..07e7629c7cb 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationV6IOTest.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationV6IOTest.java @@ -22,7 +22,7 @@ package org.matsim.core.population.io; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -58,7 +58,7 @@ * @author thibautd */ public class PopulationV6IOTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV4Test.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV4Test.java index 32feb12bf34..7a242e6ab54 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV4Test.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV4Test.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -45,8 +45,8 @@ public class PopulationWriterHandlerImplV4Test { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteGenericRoute() { diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV5Test.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV5Test.java index 0853ed74581..a0e79a87e89 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV5Test.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV5Test.java @@ -24,7 +24,7 @@ import java.util.Stack; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -52,7 +52,7 @@ */ public class PopulationWriterHandlerImplV5Test { - @Rule public MatsimTestUtils util = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils util = new MatsimTestUtils(); @Test public void test_writeNetworkRoute_sameStartEndLink() { diff --git a/matsim/src/test/java/org/matsim/core/population/io/StreamingPopulationAttributeConversionTest.java b/matsim/src/test/java/org/matsim/core/population/io/StreamingPopulationAttributeConversionTest.java index b66d311c8b8..de959287f47 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/StreamingPopulationAttributeConversionTest.java +++ b/matsim/src/test/java/org/matsim/core/population/io/StreamingPopulationAttributeConversionTest.java @@ -26,7 +26,7 @@ import java.util.function.Consumer; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -40,7 +40,7 @@ public class StreamingPopulationAttributeConversionTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/matsim/src/test/java/org/matsim/core/population/routes/NetworkFactoryTest.java b/matsim/src/test/java/org/matsim/core/population/routes/NetworkFactoryTest.java index 6b50d8c8ea8..d0025c9bb74 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/NetworkFactoryTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/NetworkFactoryTest.java @@ -21,7 +21,7 @@ package org.matsim.core.population.routes; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -36,8 +36,8 @@ */ public class NetworkFactoryTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /*package*/ static class CarRouteMock extends AbstractRoute implements Cloneable { diff --git a/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java b/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java index bcecf3f052a..e72eb1ecde7 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java @@ -21,7 +21,7 @@ package org.matsim.core.population.routes; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.*; @@ -43,7 +43,7 @@ */ public class RouteFactoryIntegrationTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/core/replanning/PlanStrategyTest.java b/matsim/src/test/java/org/matsim/core/replanning/PlanStrategyTest.java index 3e3afa3ca65..8e4407f56e8 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/PlanStrategyTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/PlanStrategyTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.replanning.PlanStrategyModule; @@ -31,8 +31,8 @@ public class PlanStrategyTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java b/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java index 1a04ffdf6cb..e741f3d3066 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java @@ -5,7 +5,7 @@ import java.util.List; import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; @@ -20,8 +20,8 @@ public class ReplanningAnnealerTest { private static final String FILENAME_ANNEAL = "annealingRates.txt"; - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); private Scenario scenario; private Config config; private ReplanningAnnealerConfigGroup saConfig; diff --git a/matsim/src/test/java/org/matsim/core/replanning/conflicts/ReplanningWithConflictsTest.java b/matsim/src/test/java/org/matsim/core/replanning/conflicts/ReplanningWithConflictsTest.java index d7dcef44001..66db3fd7806 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/conflicts/ReplanningWithConflictsTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/conflicts/ReplanningWithConflictsTest.java @@ -2,7 +2,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -38,8 +38,8 @@ * @author Sebastian Hörl (sebhoerl), IRT SystemX */ public class ReplanningWithConflictsTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testModeRestriction() { @@ -52,10 +52,10 @@ public void testModeRestriction() { * BestScore, so if selection is chosen, a plan with "restricted" will be chosen * if it exists in the agent memory. For innovation, we use ChangeTripMode, so * we choose a new random mode. - * + * * Without conflicts, this will lead to all agents choosing the "restricted" * mode eventually, only 10% will choose "unrestricted" because they innovate. - * + * * However, we introduce a conflict logic that ensures that we never have more * than 40 agents using the "restricted" mode. In our simple logic, we iterate * through the agents and "accept" plans as long as we don't go over this @@ -63,10 +63,10 @@ public void testModeRestriction() { * and let our ConflictResolver return their IDs. The conflict logic will then * *reject* the plans generated by replanning and switch the agents back to a * non-conflicting plan (in that case the ones with the "unrestricted" mode). - * + * * To make sure that every agent always has a non-conflicting plan in memory, we * use WorstPlanForRemovalSelectorWithConflicts as the planRemovalSelector. - * + * * Running the simulation will make the agents replan and soon we hit the mark * of 40 agents using the "restricted" mode. After that, the conflict logic will * start rejecting plans. Note that in this particular logic as a side effect, @@ -75,7 +75,7 @@ public void testModeRestriction() { * logic we would make sure that, for instance, agents that didn't change their * plan or were already using initially the restricted mode are treated with * priority. - * + * * This is the most simple set-up of a conflict resolution process. It can be * adapted to all kind of use cases, for instance, managing parking space, * matching agents for car-pooling or implementing peer-to-peer car-sharing. diff --git a/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java b/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java index d7a8f260215..6612877c0f1 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java @@ -24,7 +24,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -41,8 +41,8 @@ public class ExternalModuleTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); private Scenario scenario; private OutputDirectoryHierarchy outputDirectoryHierarchy; diff --git a/matsim/src/test/java/org/matsim/core/replanning/planInheritance/PlanInheritanceTest.java b/matsim/src/test/java/org/matsim/core/replanning/planInheritance/PlanInheritanceTest.java index c15436d3391..e6ca4326678 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/planInheritance/PlanInheritanceTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/planInheritance/PlanInheritanceTest.java @@ -7,7 +7,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -30,8 +30,7 @@ public class PlanInheritanceTest { * @author alex94263 */ - - @Rule + @RegisterExtension public MatsimTestUtils util = new MatsimTestUtils(); @Test @@ -48,7 +47,7 @@ public void testPlanInheritanceEnabled() throws IOException { File csv = new File(outputDirectory, "planInheritanceRecords.csv.gz"); assertThat(csv).exists(); - + List personList = new ArrayList(); final Scenario scenario = ScenarioUtils.createScenario(config); @@ -66,9 +65,9 @@ public void run(Person person) { assert(p.getAttributes().getAsMap().keySet().contains(PlanInheritanceModule.ITERATION_CREATED)); assert(p.getAttributes().getAsMap().keySet().contains(PlanInheritanceModule.PLAN_ID)); } - + } - + PlanInheritanceRecordReader reader = new PlanInheritanceRecordReader(outputDirectory+"planInheritanceRecords.csv.gz"); List records = reader.read(); assert(records.size()==2); @@ -79,7 +78,7 @@ public void run(Person person) { assert( ((PlanInheritanceRecord) records.get(0)).getIterationRemoved() == -1); assert( ((PlanInheritanceRecord) records.get(0)).getPlanId().equals(Id.create("1",Plan.class))); assert( ((PlanInheritanceRecord) records.get(0)).getIterationsSelected().equals(Arrays.asList(0, 1, 2, 3, 4, 6, 7, 8, 9, 10))); - + assert( ((PlanInheritanceRecord) records.get(1)).getAgentId().equals(Id.createPersonId("1"))); assert( ((PlanInheritanceRecord) records.get(1)).getAncestorId().equals(Id.create("1",Plan.class))); assert( ((PlanInheritanceRecord) records.get(1)).getMutatedBy().equals("RandomPlanSelector_ReRoute")); @@ -87,11 +86,11 @@ public void run(Person person) { assert( ((PlanInheritanceRecord) records.get(1)).getIterationRemoved() == -1); assert( ((PlanInheritanceRecord) records.get(1)).getPlanId().equals(Id.create("2",Plan.class))); assert( ((PlanInheritanceRecord) records.get(1)).getIterationsSelected().equals(Arrays.asList(5))); - - + + } - + @Test public void testPlanInheritanceDisabled() throws IOException { String outputDirectory = util.getOutputDirectory(); @@ -106,7 +105,7 @@ public void testPlanInheritanceDisabled() throws IOException { File csv = new File(outputDirectory, "planInheritanceRecords.csv.gz"); assertThat(csv).doesNotExist(); - + List personList = new ArrayList(); final Scenario scenario = ScenarioUtils.createScenario(config); StreamingPopulationReader spr = new StreamingPopulationReader(scenario); @@ -123,7 +122,7 @@ public void run(Person person) { assert(!p.getAttributes().getAsMap().keySet().contains(PlanInheritanceModule.ITERATION_CREATED)); assert(!p.getAttributes().getAsMap().keySet().contains(PlanInheritanceModule.PLAN_ID)); } - + } } } diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/AbstractPlanSelectorTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/AbstractPlanSelectorTest.java index 30e576431ff..d6c414c47ee 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/AbstractPlanSelectorTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/AbstractPlanSelectorTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.HasPlansAndId; @@ -43,7 +43,7 @@ */ public abstract class AbstractPlanSelectorTest { - @Rule + @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); diff --git a/matsim/src/test/java/org/matsim/core/replanning/strategies/DeterministicMultithreadedReplanningIT.java b/matsim/src/test/java/org/matsim/core/replanning/strategies/DeterministicMultithreadedReplanningIT.java index 122f9acc428..bbf1f35fa4f 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/strategies/DeterministicMultithreadedReplanningIT.java +++ b/matsim/src/test/java/org/matsim/core/replanning/strategies/DeterministicMultithreadedReplanningIT.java @@ -23,7 +23,7 @@ import com.google.inject.Singleton; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; @@ -58,8 +58,8 @@ */ public class DeterministicMultithreadedReplanningIT { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); /** * Tests that the {@link TimeAllocationMutatorModule} generates always the same results diff --git a/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java b/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java index 9c81aee55f2..62aa5944e92 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java @@ -26,7 +26,7 @@ import org.junit.Assert; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.core.config.Config; @@ -55,8 +55,8 @@ public class InnovationSwitchOffTest { private static final Logger log = LogManager.getLogger(InnovationSwitchOffTest.class); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** * Integration test for testing if switching off of innovative strategies works. diff --git a/matsim/src/test/java/org/matsim/core/replanning/strategies/TimeAllocationMutatorModuleTest.java b/matsim/src/test/java/org/matsim/core/replanning/strategies/TimeAllocationMutatorModuleTest.java index 00e5fa6b164..c27cf25f777 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/strategies/TimeAllocationMutatorModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/strategies/TimeAllocationMutatorModuleTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertTrue; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -52,8 +52,8 @@ */ public class TimeAllocationMutatorModuleTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testSimplifiedMutation() { diff --git a/matsim/src/test/java/org/matsim/core/router/AbstractLeastCostPathCalculatorTest.java b/matsim/src/test/java/org/matsim/core/router/AbstractLeastCostPathCalculatorTest.java index f87838e068b..ecad20f4e9b 100644 --- a/matsim/src/test/java/org/matsim/core/router/AbstractLeastCostPathCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/router/AbstractLeastCostPathCalculatorTest.java @@ -26,7 +26,7 @@ import javax.xml.parsers.ParserConfigurationException; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -46,8 +46,8 @@ */ public abstract class AbstractLeastCostPathCalculatorTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); protected abstract LeastCostPathCalculator getLeastCostPathCalculator(final Network network); diff --git a/matsim/src/test/java/org/matsim/core/router/FallbackRoutingModuleTest.java b/matsim/src/test/java/org/matsim/core/router/FallbackRoutingModuleTest.java index 2357da20138..97d039dd334 100644 --- a/matsim/src/test/java/org/matsim/core/router/FallbackRoutingModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/FallbackRoutingModuleTest.java @@ -2,7 +2,7 @@ import java.util.List; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -27,7 +27,7 @@ import org.matsim.testcases.MatsimTestUtils; public class FallbackRoutingModuleTest{ - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void calcRoute(){ diff --git a/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java b/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java index 6f53a8f7363..4883342c79d 100644 --- a/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java @@ -1,6 +1,6 @@ package org.matsim.core.router; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.locationtech.jts.util.Assert; import org.matsim.api.core.v01.Coord; @@ -49,8 +49,8 @@ public class NetworkRoutingInclAccessEgressModuleTest { private static final String SLOW_BUT_DIRECT_LINK = "slow-but-direct-link"; private static final String FAST_BUT_LONGER_LINK = "fast-but-longer-link"; - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); private static Scenario createScenario(Config config) { diff --git a/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java b/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java index eeb366c2f68..9061316cef6 100644 --- a/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java @@ -22,7 +22,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -57,8 +57,8 @@ public class PseudoTransitRoutingModuleTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testRouteLeg() { diff --git a/matsim/src/test/java/org/matsim/core/router/RoutingIT.java b/matsim/src/test/java/org/matsim/core/router/RoutingIT.java index 0d1fc62702e..33bf594d4c5 100644 --- a/matsim/src/test/java/org/matsim/core/router/RoutingIT.java +++ b/matsim/src/test/java/org/matsim/core/router/RoutingIT.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; @@ -55,7 +55,7 @@ public class RoutingIT { /*package*/ static final Logger log = LogManager.getLogger(RoutingIT.class); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); private interface RouterProvider { public String getName(); diff --git a/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java b/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java index 4bb4c1df8ed..20447170bcd 100644 --- a/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java @@ -23,7 +23,7 @@ package org.matsim.core.router; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; @@ -38,8 +38,8 @@ public class TripRouterModuleTest { - @Rule - public MatsimTestUtils matsimTestUtils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils matsimTestUtils = new MatsimTestUtils(); @Test public void testRouterCreation() { diff --git a/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java b/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java index 511a141c8a2..395299f5f62 100644 --- a/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java +++ b/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java @@ -23,7 +23,7 @@ package org.matsim.core.router.old; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -55,8 +55,8 @@ public class PlanRouterTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); @Test public void passesVehicleFromOldPlan() { diff --git a/matsim/src/test/java/org/matsim/core/scenario/ScenarioByConfigInjectionTest.java b/matsim/src/test/java/org/matsim/core/scenario/ScenarioByConfigInjectionTest.java index d77d2dfe4f1..bc7cc4793ed 100644 --- a/matsim/src/test/java/org/matsim/core/scenario/ScenarioByConfigInjectionTest.java +++ b/matsim/src/test/java/org/matsim/core/scenario/ScenarioByConfigInjectionTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -47,7 +47,7 @@ */ public class ScenarioByConfigInjectionTest { private static final Logger log = LogManager.getLogger( ScenarioByConfigInjectionTest.class ); - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/matsim/src/test/java/org/matsim/core/scenario/ScenarioLoaderImplTest.java b/matsim/src/test/java/org/matsim/core/scenario/ScenarioLoaderImplTest.java index ed651429022..bca2d701757 100644 --- a/matsim/src/test/java/org/matsim/core/scenario/ScenarioLoaderImplTest.java +++ b/matsim/src/test/java/org/matsim/core/scenario/ScenarioLoaderImplTest.java @@ -21,7 +21,7 @@ import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -46,7 +46,7 @@ */ public class ScenarioLoaderImplTest { - @Rule public MatsimTestUtils util = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils util = new MatsimTestUtils(); @Test public void testLoadScenario_loadTransitData() { diff --git a/matsim/src/test/java/org/matsim/core/scoring/EventsToScoreTest.java b/matsim/src/test/java/org/matsim/core/scoring/EventsToScoreTest.java index 48fabecebed..4873a3759ec 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/EventsToScoreTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/EventsToScoreTest.java @@ -21,7 +21,7 @@ package org.matsim.core.scoring; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -44,8 +44,8 @@ */ public class EventsToScoreTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelOpenTimesScoringFunctionTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelOpenTimesScoringFunctionTest.java index 336f4dc2273..5e87ef5bf27 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelOpenTimesScoringFunctionTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelOpenTimesScoringFunctionTest.java @@ -24,7 +24,7 @@ import org.junit.After; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -46,8 +46,8 @@ public class CharyparNagelOpenTimesScoringFunctionTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private Person person = null; diff --git a/matsim/src/test/java/org/matsim/core/trafficmonitoring/LinkToLinkTravelTimeCalculatorTest.java b/matsim/src/test/java/org/matsim/core/trafficmonitoring/LinkToLinkTravelTimeCalculatorTest.java index 2b5e3db5a5a..179a9254981 100644 --- a/matsim/src/test/java/org/matsim/core/trafficmonitoring/LinkToLinkTravelTimeCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/trafficmonitoring/LinkToLinkTravelTimeCalculatorTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -40,8 +40,8 @@ public class LinkToLinkTravelTimeCalculatorTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModuleTest.java b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModuleTest.java index 7a1b22936cc..00654aa914e 100644 --- a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModuleTest.java @@ -24,7 +24,7 @@ import com.google.inject.Key; import com.google.inject.Singleton; import com.google.inject.name.Names; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -54,8 +54,8 @@ public class TravelTimeCalculatorModuleTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testOneTravelTimeCalculatorForAll() { diff --git a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorTest.java b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorTest.java index a7bc3c003af..45c0595a509 100644 --- a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorTest.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -70,8 +70,8 @@ */ public class TravelTimeCalculatorTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private final static Logger log = LogManager.getLogger(TravelTimeCalculatorTest.class); diff --git a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeDataArrayTest.java b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeDataArrayTest.java index 1e0e4e3dca7..e56a8cb3a51 100644 --- a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeDataArrayTest.java +++ b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeDataArrayTest.java @@ -2,7 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -13,7 +13,7 @@ public class TravelTimeDataArrayTest{ private static final Logger log = LogManager.getLogger( TravelTimeDataArrayTest.class ); - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void test() { diff --git a/matsim/src/test/java/org/matsim/core/utils/charts/BarChartTest.java b/matsim/src/test/java/org/matsim/core/utils/charts/BarChartTest.java index dd069338304..b13c9fd28a8 100644 --- a/matsim/src/test/java/org/matsim/core/utils/charts/BarChartTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/charts/BarChartTest.java @@ -29,7 +29,7 @@ import javax.imageio.ImageIO; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -40,8 +40,8 @@ */ public class BarChartTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/core/utils/charts/LineChartTest.java b/matsim/src/test/java/org/matsim/core/utils/charts/LineChartTest.java index 91a272f1b37..4c70f43a26d 100644 --- a/matsim/src/test/java/org/matsim/core/utils/charts/LineChartTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/charts/LineChartTest.java @@ -29,7 +29,7 @@ import javax.imageio.ImageIO; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -40,8 +40,8 @@ */ public class LineChartTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/core/utils/charts/XYLineChartTest.java b/matsim/src/test/java/org/matsim/core/utils/charts/XYLineChartTest.java index 69379559860..1410b27b202 100644 --- a/matsim/src/test/java/org/matsim/core/utils/charts/XYLineChartTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/charts/XYLineChartTest.java @@ -29,7 +29,7 @@ import javax.imageio.ImageIO; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -40,8 +40,8 @@ */ public class XYLineChartTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/core/utils/charts/XYScatterChartTest.java b/matsim/src/test/java/org/matsim/core/utils/charts/XYScatterChartTest.java index cfda39f43b5..03c60398659 100644 --- a/matsim/src/test/java/org/matsim/core/utils/charts/XYScatterChartTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/charts/XYScatterChartTest.java @@ -29,7 +29,7 @@ import javax.imageio.ImageIO; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -40,8 +40,8 @@ */ public class XYScatterChartTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/GeometryUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/GeometryUtilsTest.java index dbb81fd3c2d..4e4a7495248 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/GeometryUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/GeometryUtilsTest.java @@ -21,7 +21,7 @@ package org.matsim.core.utils.geometry; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.GeometryFactory; @@ -46,13 +46,13 @@ */ public class GeometryUtilsTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; @Test public final void testIntersectingLinks() { - + Config config = ConfigUtils.loadConfig( IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL("equil"), "config.xml" ) ) ; - + final Network network = ScenarioUtils.loadScenario(config).getNetwork(); { @@ -86,7 +86,7 @@ public final void testIntersectingLinks() { Assert.assertTrue("expected link " + id, intersectingLinkIds.contains(id)); } } - + } } diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/geotools/MGCTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/geotools/MGCTest.java index 64666c2fa55..65265390b9f 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/geotools/MGCTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/geotools/MGCTest.java @@ -21,7 +21,7 @@ package org.matsim.core.utils.geometry.geotools; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Point; @@ -35,8 +35,8 @@ */ public class MGCTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testCoord2CoordinateAndViceVersa(){ diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/GeotoolsTransformationTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/GeotoolsTransformationTest.java index 41a7275bb2a..7fd2cacc8df 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/GeotoolsTransformationTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/GeotoolsTransformationTest.java @@ -20,7 +20,7 @@ package org.matsim.core.utils.geometry.transformations; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.geometry.CoordinateTransformation; @@ -32,8 +32,8 @@ */ public class GeotoolsTransformationTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testTransform(){ diff --git a/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileReaderTest.java b/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileReaderTest.java index 30c9f350ffc..155a9f62128 100644 --- a/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileReaderTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileReaderTest.java @@ -25,7 +25,7 @@ import org.geotools.data.FeatureSource; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -34,8 +34,8 @@ */ public class ShapeFileReaderTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + /** * Based on message on users-mailing list from 20Dec2012) * @throws IOException diff --git a/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileWriterTest.java b/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileWriterTest.java index b20f713473e..bf9b3ee2a90 100644 --- a/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileWriterTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileWriterTest.java @@ -33,7 +33,7 @@ import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.geotools.referencing.crs.DefaultGeographicCRS; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; @@ -46,15 +46,15 @@ import org.opengis.feature.simple.SimpleFeatureType; public class ShapeFileWriterTest { - - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testShapeFileWriter() throws IOException{ - + String inFile = "src/test/resources/" + utils.getInputDirectory() + "test.shp"; - - String outFile = utils.getOutputDirectory() + "/test.shp"; + + String outFile = utils.getOutputDirectory() + "/test.shp"; SimpleFeatureSource s = ShapeFileReader.readDataFile(inFile); SimpleFeatureCollection fts = s.getFeatures(); SimpleFeatureIterator it = fts.features(); @@ -63,133 +63,133 @@ public void testShapeFileWriter() throws IOException{ List fc = new ArrayList<>(); fc.add(ft); ShapeFileWriter.writeGeometries(fc, outFile); - + SimpleFeatureSource s1 = ShapeFileReader.readDataFile(outFile); SimpleFeatureCollection fts1 = s1.getFeatures(); SimpleFeatureIterator it1 = fts1.features(); SimpleFeature ft1 = it1.next(); Geometry g1 = (Geometry) ft1.getDefaultGeometry(); - + Assert.assertEquals(g.getCoordinates().length, g1.getCoordinates().length); - + } - + @Test public void testShapeFileWriterWithSelfCreatedContent() throws IOException { - String outFile = utils.getOutputDirectory() + "/test.shp"; + String outFile = utils.getOutputDirectory() + "/test.shp"; SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setName("EvacuationArea"); b.setCRS(DefaultGeographicCRS.WGS84); b.add("the_geom", MultiPolygon.class); b.add("name", String.class); SimpleFeatureType ft = b.buildFeatureType(); - + GeometryFactory geofac = new GeometryFactory(); LinearRing lr = geofac.createLinearRing(new Coordinate[]{new Coordinate(0,0),new Coordinate(0,1),new Coordinate(1,1),new Coordinate(0,0)}); Polygon p = geofac.createPolygon(lr,null); - MultiPolygon mp = geofac.createMultiPolygon(new Polygon[]{p}); + MultiPolygon mp = geofac.createMultiPolygon(new Polygon[]{p}); Collection features = new ArrayList(); features.add(SimpleFeatureBuilder.build(ft, new Object[]{mp,"test_name"},"fid")); - - + + Geometry g0 = (Geometry) features.iterator().next().getDefaultGeometry(); - + ShapeFileWriter.writeGeometries(features, outFile); - + SimpleFeatureSource s1 = ShapeFileReader.readDataFile(outFile); SimpleFeatureCollection fts1 = s1.getFeatures(); SimpleFeatureIterator it1 = fts1.features(); SimpleFeature ft1 = it1.next(); Geometry g1 = (Geometry) ft1.getDefaultGeometry(); - + Assert.assertEquals(g0.getCoordinates().length, g1.getCoordinates().length); - - + + } - + @Test public void testShapeFileWriterWithSelfCreatedContent_withMatsimFactory_Polygon() throws IOException { String outFile = utils.getOutputDirectory() + "test.shp"; - + PolygonFeatureFactory ff = new PolygonFeatureFactory.Builder() .setName("EvacuationArea") .setCrs(DefaultGeographicCRS.WGS84) .addAttribute("name", String.class) .create(); - + Coordinate[] coordinates = new Coordinate[]{new Coordinate(0,0),new Coordinate(0,1),new Coordinate(1,1),new Coordinate(0,0)}; SimpleFeature f = ff.createPolygon(coordinates); - + Collection features = new ArrayList(); features.add(f); - + Geometry g0 = (Geometry) f.getDefaultGeometry(); - + ShapeFileWriter.writeGeometries(features, outFile); - + SimpleFeatureSource s1 = ShapeFileReader.readDataFile(outFile); SimpleFeatureCollection fts1 = s1.getFeatures(); SimpleFeatureIterator it1 = fts1.features(); SimpleFeature ft1 = it1.next(); Geometry g1 = (Geometry) ft1.getDefaultGeometry(); - + Assert.assertEquals(g0.getCoordinates().length, g1.getCoordinates().length); } @Test public void testShapeFileWriterWithSelfCreatedContent_withMatsimFactory_Polyline() throws IOException { String outFile = utils.getOutputDirectory() + "test.shp"; - + PolylineFeatureFactory ff = new PolylineFeatureFactory.Builder() .setName("EvacuationArea") .setCrs(DefaultGeographicCRS.WGS84) .addAttribute("name", String.class) .create(); - + Coordinate[] coordinates = new Coordinate[]{new Coordinate(0,0),new Coordinate(0,1),new Coordinate(1,1),new Coordinate(0,0)}; SimpleFeature f = ff.createPolyline(coordinates); - + Collection features = new ArrayList(); features.add(f); - + Geometry g0 = (Geometry) f.getDefaultGeometry(); - + ShapeFileWriter.writeGeometries(features, outFile); - + SimpleFeatureSource s1 = ShapeFileReader.readDataFile(outFile); SimpleFeatureCollection fts1 = s1.getFeatures(); SimpleFeatureIterator it1 = fts1.features(); SimpleFeature ft1 = it1.next(); Geometry g1 = (Geometry) ft1.getDefaultGeometry(); - + Assert.assertEquals(g0.getCoordinates().length, g1.getCoordinates().length); } @Test public void testShapeFileWriterWithSelfCreatedContent_withMatsimFactory_Point() throws IOException { String outFile = utils.getOutputDirectory() + "test.shp"; - + PointFeatureFactory ff = new PointFeatureFactory.Builder() .setName("EvacuationArea") .setCrs(DefaultGeographicCRS.WGS84) .addAttribute("name", String.class) .create(); - + SimpleFeature f = ff.createPoint(new Coordinate(10, 20)); - + Collection features = new ArrayList(); features.add(f); - + Geometry g0 = (Geometry) f.getDefaultGeometry(); - + ShapeFileWriter.writeGeometries(features, outFile); - + SimpleFeatureSource s1 = ShapeFileReader.readDataFile(outFile); SimpleFeatureCollection fts1 = s1.getFeatures(); SimpleFeatureIterator it1 = fts1.features(); SimpleFeature ft1 = it1.next(); Geometry g1 = (Geometry) ft1.getDefaultGeometry(); - + Assert.assertEquals(g0.getCoordinates().length, g1.getCoordinates().length); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/io/IOUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/io/IOUtilsTest.java index 58c03dc4f5e..db3784f59e6 100644 --- a/matsim/src/test/java/org/matsim/core/utils/io/IOUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/io/IOUtilsTest.java @@ -20,7 +20,7 @@ package org.matsim.core.utils.io; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.controler.OutputDirectoryLogging; import org.matsim.core.utils.misc.CRCChecksum; @@ -39,7 +39,7 @@ */ public class IOUtilsTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testInitOutputDirLogging() throws IOException { diff --git a/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlParserTest.java b/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlParserTest.java index d7006b7ce1d..972b0a99be4 100644 --- a/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlParserTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlParserTest.java @@ -20,8 +20,9 @@ package org.matsim.core.utils.io; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; +import org.junit.jupiter.api.io.TempDir; import org.junit.rules.TemporaryFolder; import org.xml.sax.Attributes; import org.xml.sax.SAXParseException; @@ -43,8 +44,8 @@ */ public class MatsimXmlParserTest { - @Rule - public TemporaryFolder tempFolder = new TemporaryFolder(); + @TempDir + public File tempFolder; @Test public void testParsingReservedEntities_AttributeValue() { @@ -302,7 +303,7 @@ public void testParse_preventXEEattack_woodstox() throws IOException { String secretValue = "S3CR3T"; - File secretsFile = this.tempFolder.newFile("file-with-secrets.txt"); + File secretsFile = new File(this.tempFolder,"file-with-secrets.txt"); try (OutputStream out = new FileOutputStream(secretsFile)) { out.write(secretValue.getBytes(StandardCharsets.UTF_8)); } @@ -349,7 +350,7 @@ public void testParse_preventXEEattack_xerces() throws IOException { String secretValue = "S3CR3T"; - File secretsFile = this.tempFolder.newFile("file-with-secrets.txt"); + File secretsFile = new File(this.tempFolder, "file-with-secrets.txt"); try (OutputStream out = new FileOutputStream(secretsFile)) { out.write(secretValue.getBytes(StandardCharsets.UTF_8)); } diff --git a/matsim/src/test/java/org/matsim/core/utils/io/OsmNetworkReaderTest.java b/matsim/src/test/java/org/matsim/core/utils/io/OsmNetworkReaderTest.java index aa0f362a2a4..a43441e5c8f 100644 --- a/matsim/src/test/java/org/matsim/core/utils/io/OsmNetworkReaderTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/io/OsmNetworkReaderTest.java @@ -20,7 +20,7 @@ package org.matsim.core.utils.io; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -41,7 +41,7 @@ */ public class OsmNetworkReaderTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testConversion() { @@ -198,13 +198,13 @@ public void testConversion_MissingNodeRef() { Assert.assertEquals("incomplete ways should not be converted.", 0, net.getNodes().size()); Assert.assertEquals("incomplete ways should not be converted.", 0, net.getLinks().size()); } - + @Test public void testConversion_maxspeeds() { Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network net = sc.getNetwork(); CoordinateTransformation ct = new IdentityTransformation(); - + OsmNetworkReader reader = new OsmNetworkReader(net, ct); reader.setKeepPaths(true); reader.setHighwayDefaults(1, "motorway", 1, 50.0/3.6, 1.0, 2000.0); @@ -242,7 +242,7 @@ public void testConversion_maxspeeds() { * - links 3 & 4: for way 2, in both directions * - links 5 & 6: for way 3, in both directions */ - + Link link1 = net.getLinks().get(Id.create("1", Link.class)); Link link3 = net.getLinks().get(Id.create("3", Link.class)); Link link5 = net.getLinks().get(Id.create("5", Link.class)); @@ -256,20 +256,20 @@ public void testConversion_maxspeeds() { /** * Tests that the conversion does not fail if a way does not contain any node. This might - * happen if the osm-file was edited, e.g. with JOSM, and a link was deleted. Then, the way + * happen if the osm-file was edited, e.g. with JOSM, and a link was deleted. Then, the way * still exists, but marked as deleted, and all nodes removed from it. - * Reported by jjoubert,15nov2012. + * Reported by jjoubert,15nov2012. */ @Test public void testConversion_emptyWay() { Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network net = sc.getNetwork(); CoordinateTransformation ct = new IdentityTransformation(); - + OsmNetworkReader reader = new OsmNetworkReader(net, ct); reader.setKeepPaths(true); reader.setHighwayDefaults(1, "motorway", 1, 50.0/3.6, 1.0, 2000.0); - + String str = "\n" + "\n" + " \n" + @@ -293,12 +293,12 @@ public void testConversion_emptyWay() { " \n" + ""; reader.parse(() -> new ByteArrayInputStream(str.getBytes())); - + /* this creates 4 links: * - links 1 & 2: for way 1, in both directions * - links 3 & 4: for way 2, in both directions */ - + Link link1 = net.getLinks().get(Id.create("1", Link.class)); Link link3 = net.getLinks().get(Id.create("3", Link.class)); Assert.assertNotNull("Could not find converted link 1.", link1); diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/ArgumentParserTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/ArgumentParserTest.java index 5d322e5fd0e..8b30ecbdf30 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/ArgumentParserTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/ArgumentParserTest.java @@ -26,7 +26,7 @@ import java.util.Iterator; import java.util.NoSuchElementException; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -37,8 +37,8 @@ */ public class ArgumentParserTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/ByteBufferUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/ByteBufferUtilsTest.java index 70ff5573005..8741b572cd5 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/ByteBufferUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/ByteBufferUtilsTest.java @@ -26,7 +26,7 @@ import java.io.Serializable; import java.nio.ByteBuffer; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -35,8 +35,8 @@ */ public class ByteBufferUtilsTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java index 2b0e176d0bb..cf2e00940eb 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -40,8 +40,8 @@ public class ConfigUtilsTest { private static final Logger log = LogManager.getLogger( ConfigUtilsTest.class ) ; - @Rule - public MatsimTestUtils util = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils util = new MatsimTestUtils(); @Test public void testLoadConfig_filenameOnly() throws IOException { diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/PopulationUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/PopulationUtilsTest.java index dc35c4d2bf9..6e5a02f746e 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/PopulationUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/PopulationUtilsTest.java @@ -21,7 +21,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -47,8 +47,8 @@ * */ public class PopulationUtilsTest { - - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; @Test public void testLegOverlap() { @@ -56,28 +56,28 @@ public void testLegOverlap() { List legs1 = PopulationUtils.getLegs(f.plan1) ; List legs2 = PopulationUtils.getLegs(f.plan2); List legs3 = PopulationUtils.getLegs(f.plan3); - + // Assert.assertEquals( 2., PopulationUtils.calculateSimilarity( legs1, legs2, null, 1., 1. ) , 0.001 ) ; Assert.assertEquals( 4., PopulationUtils.calculateSimilarity( legs1, legs2, null, 1., 1. ) , 0.001 ) ; // (no route is now counted as "same route" and thus reaps the reward. kai, jul'18) - + // Assert.assertEquals( 1., PopulationUtils.calculateSimilarity( legs1, legs3, null, 1., 1. ) , 0.001 ) ; Assert.assertEquals( 2., PopulationUtils.calculateSimilarity( legs1, legs3, null, 1., 1. ) , 0.001 ) ; // (no route is now counted as "same route" and thus reaps the reward. kai, jul'18) } - + @Test public void testActivityOverlap() { Fixture f = new Fixture() ; List acts1 = PopulationUtils.getActivities(f.plan1, StageActivityHandling.StagesAsNormalActivities ) ; List acts2 = PopulationUtils.getActivities(f.plan2, StageActivityHandling.StagesAsNormalActivities ) ; List acts3 = PopulationUtils.getActivities(f.plan3, StageActivityHandling.StagesAsNormalActivities ) ; - + Assert.assertEquals( 6., PopulationUtils.calculateSimilarity( acts1, acts2 , 1., 1., 0. ) , 0.001 ) ; Assert.assertEquals( 5., PopulationUtils.calculateSimilarity( acts1, acts3 , 1., 1., 0. ) , 0.001 ) ; } - + private static class Fixture { Plan plan1, plan2, plan3 ; Fixture() { @@ -85,13 +85,13 @@ private static class Fixture { Scenario scenario = ScenarioUtils.createScenario(config) ; Population pop = scenario.getPopulation() ; PopulationFactory pf = pop.getFactory() ; - + { Plan plan = pf.createPlan() ; Activity act1 = pf.createActivityFromCoord("h", new Coord(0., 0.)) ; plan.addActivity(act1); - + Leg leg1 = pf.createLeg( TransportMode.car ) ; plan.addLeg( leg1 ) ; @@ -103,7 +103,7 @@ private static class Fixture { Activity act3 = pf.createActivityFromCoord("h", new Coord(0., 0.)) ; plan.addActivity(act3) ; - + plan1 = plan ; } { @@ -111,7 +111,7 @@ private static class Fixture { Activity act1 = pf.createActivityFromCoord("h", new Coord(0., 0.)) ; plan.addActivity(act1); - + Leg leg1 = pf.createLeg( TransportMode.car ) ; plan.addLeg( leg1 ) ; @@ -123,7 +123,7 @@ private static class Fixture { Activity act3 = pf.createActivityFromCoord("h", new Coord(0., 0.)) ; plan.addActivity(act3) ; - + plan2 = plan ; } { @@ -131,7 +131,7 @@ private static class Fixture { Activity act1 = pf.createActivityFromCoord("h", new Coord(0., 0.)) ; plan.addActivity(act1); - + Leg leg1 = pf.createLeg( TransportMode.car ) ; plan.addLeg( leg1 ) ; @@ -143,19 +143,19 @@ private static class Fixture { Activity act3 = pf.createActivityFromCoord("h", new Coord(0., 0.)) ; plan.addActivity(act3) ; - + plan3 = plan ; } } } - + @Test public void testEmptyPopulation() { Scenario s1 = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario s2 = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Assert.assertTrue(PopulationUtils.equalPopulation(s1.getPopulation(), s2.getPopulation())); } - + @Test public void testEmptyPopulationVsOnePerson() { Scenario s1 = ScenarioUtils.createScenario(ConfigUtils.createConfig()); @@ -165,7 +165,7 @@ public void testEmptyPopulationVsOnePerson() { Assert.assertFalse(PopulationUtils.equalPopulation(s1.getPopulation(), s2.getPopulation())); Assert.assertFalse(PopulationUtils.equalPopulation(s2.getPopulation(), s1.getPopulation())); } - + @Test public void testCompareBigPopulationWithItself() { Scenario s1 = ScenarioUtils.createScenario(ConfigUtils.createConfig()); diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/StringUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/StringUtilsTest.java index c5c19f6a232..873fad98d90 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/StringUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/StringUtilsTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -33,8 +33,8 @@ */ public class StringUtilsTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java b/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java index e8ef70e3ccd..58e06bfdf21 100644 --- a/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java @@ -24,7 +24,7 @@ import java.util.List; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -48,8 +48,8 @@ public class TimeInterpretationTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testIgnoreDelays() { diff --git a/matsim/src/test/java/org/matsim/counts/CountTest.java b/matsim/src/test/java/org/matsim/counts/CountTest.java index 3ea7868ec61..7575c4bd529 100644 --- a/matsim/src/test/java/org/matsim/counts/CountTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountTest.java @@ -25,7 +25,7 @@ import java.util.Iterator; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -33,8 +33,8 @@ public class CountTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private Counts counts; diff --git a/matsim/src/test/java/org/matsim/counts/CountsComparisonAlgorithmTest.java b/matsim/src/test/java/org/matsim/counts/CountsComparisonAlgorithmTest.java index 07f36ef8d6f..ecefd40d4b1 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsComparisonAlgorithmTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsComparisonAlgorithmTest.java @@ -24,15 +24,15 @@ import java.util.List; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.counts.algorithms.CountsComparisonAlgorithm; import org.matsim.testcases.MatsimTestUtils; public class CountsComparisonAlgorithmTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testCompare() { diff --git a/matsim/src/test/java/org/matsim/counts/CountsControlerListenerTest.java b/matsim/src/test/java/org/matsim/counts/CountsControlerListenerTest.java index 45f5d661b93..21b0939f3d8 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsControlerListenerTest.java @@ -27,7 +27,7 @@ import jakarta.inject.Singleton; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -59,7 +59,7 @@ */ public class CountsControlerListenerTest { - @Rule public MatsimTestUtils util = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils util = new MatsimTestUtils(); @Test public void testUseVolumesOfIteration() { diff --git a/matsim/src/test/java/org/matsim/counts/CountsErrorGraphTest.java b/matsim/src/test/java/org/matsim/counts/CountsErrorGraphTest.java index 6320634482c..dd1627a5c0e 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsErrorGraphTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsErrorGraphTest.java @@ -22,15 +22,15 @@ import static org.junit.Assert.assertNotNull; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.counts.algorithms.graphs.BoxPlotErrorGraph; import org.matsim.testcases.MatsimTestUtils; public class CountsErrorGraphTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testCreateChart() { diff --git a/matsim/src/test/java/org/matsim/counts/CountsHtmlAndGraphsWriterTest.java b/matsim/src/test/java/org/matsim/counts/CountsHtmlAndGraphsWriterTest.java index 5a1d0617691..50dac9c7a41 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsHtmlAndGraphsWriterTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsHtmlAndGraphsWriterTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertTrue; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.counts.algorithms.CountsComparisonAlgorithm; import org.matsim.counts.algorithms.CountsHtmlAndGraphsWriter; @@ -38,8 +38,8 @@ */ public class CountsHtmlAndGraphsWriterTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testGraphCreation() { diff --git a/matsim/src/test/java/org/matsim/counts/CountsLoadCurveGraphTest.java b/matsim/src/test/java/org/matsim/counts/CountsLoadCurveGraphTest.java index 376c36a1732..63a2002b7af 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsLoadCurveGraphTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsLoadCurveGraphTest.java @@ -22,15 +22,15 @@ import static org.junit.Assert.assertNotNull; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.counts.algorithms.graphs.CountsLoadCurveGraph; import org.matsim.testcases.MatsimTestUtils; public class CountsLoadCurveGraphTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testCreateChart() { diff --git a/matsim/src/test/java/org/matsim/counts/CountsParserTest.java b/matsim/src/test/java/org/matsim/counts/CountsParserTest.java index 1f3f4201cd8..804c0be2f33 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsParserTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsParserTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.*; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -31,8 +31,8 @@ public class CountsParserTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testSEElementCounts() throws SAXException { diff --git a/matsim/src/test/java/org/matsim/counts/CountsParserWriterTest.java b/matsim/src/test/java/org/matsim/counts/CountsParserWriterTest.java index 0d9c6b0dd34..e548ece2bd0 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsParserWriterTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsParserWriterTest.java @@ -27,7 +27,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; import org.xml.sax.SAXException; @@ -39,7 +39,7 @@ */ public class CountsParserWriterTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); /** * @author ahorni diff --git a/matsim/src/test/java/org/matsim/counts/CountsReaderHandlerImplV1Test.java b/matsim/src/test/java/org/matsim/counts/CountsReaderHandlerImplV1Test.java index cee54eff284..70f99f38dd9 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsReaderHandlerImplV1Test.java +++ b/matsim/src/test/java/org/matsim/counts/CountsReaderHandlerImplV1Test.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -30,8 +30,8 @@ public class CountsReaderHandlerImplV1Test { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testSECounts() { diff --git a/matsim/src/test/java/org/matsim/counts/CountsReprojectionIOTest.java b/matsim/src/test/java/org/matsim/counts/CountsReprojectionIOTest.java index 55e42f43d49..627d918b98d 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsReprojectionIOTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsReprojectionIOTest.java @@ -24,7 +24,7 @@ import com.google.inject.Key; import com.google.inject.TypeLiteral; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -42,7 +42,7 @@ * @author thibautd */ public class CountsReprojectionIOTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/matsim/src/test/java/org/matsim/counts/CountsSimRealPerHourGraphTest.java b/matsim/src/test/java/org/matsim/counts/CountsSimRealPerHourGraphTest.java index 624940acd73..93d404cbe68 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsSimRealPerHourGraphTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsSimRealPerHourGraphTest.java @@ -22,15 +22,15 @@ import static org.junit.Assert.assertNotNull; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.counts.algorithms.graphs.CountsSimRealPerHourGraph; import org.matsim.testcases.MatsimTestUtils; public class CountsSimRealPerHourGraphTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testCreateChart() { diff --git a/matsim/src/test/java/org/matsim/counts/CountsTableWriterTest.java b/matsim/src/test/java/org/matsim/counts/CountsTableWriterTest.java index 320df997d40..f869f6edaa3 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsTableWriterTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsTableWriterTest.java @@ -25,7 +25,7 @@ import java.io.File; import java.util.Locale; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.counts.algorithms.CountSimComparisonTableWriter; import org.matsim.counts.algorithms.CountsComparisonAlgorithm; @@ -34,8 +34,8 @@ public class CountsTableWriterTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testTableCreation() { diff --git a/matsim/src/test/java/org/matsim/counts/CountsTest.java b/matsim/src/test/java/org/matsim/counts/CountsTest.java index 28e76bfcaf0..af9ae2d6249 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -30,8 +30,8 @@ public class CountsTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testGetCounts() { diff --git a/matsim/src/test/java/org/matsim/counts/CountsV2Test.java b/matsim/src/test/java/org/matsim/counts/CountsV2Test.java index 696aa521795..46e306ae4d5 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsV2Test.java +++ b/matsim/src/test/java/org/matsim/counts/CountsV2Test.java @@ -2,7 +2,7 @@ import org.assertj.core.api.Assertions; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -26,8 +26,8 @@ public class CountsV2Test { private final SplittableRandom random = new SplittableRandom(1234); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void test_general_handling() throws IOException { diff --git a/matsim/src/test/java/org/matsim/counts/OutputDelegateTest.java b/matsim/src/test/java/org/matsim/counts/OutputDelegateTest.java index b8fb853dce1..7928c29c482 100644 --- a/matsim/src/test/java/org/matsim/counts/OutputDelegateTest.java +++ b/matsim/src/test/java/org/matsim/counts/OutputDelegateTest.java @@ -27,7 +27,7 @@ import java.util.List; import java.util.Vector; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -38,8 +38,8 @@ public class OutputDelegateTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testOutputHtml() { diff --git a/matsim/src/test/java/org/matsim/examples/EquilTest.java b/matsim/src/test/java/org/matsim/examples/EquilTest.java index c884bf4b3a5..64e3bcdc062 100644 --- a/matsim/src/test/java/org/matsim/examples/EquilTest.java +++ b/matsim/src/test/java/org/matsim/examples/EquilTest.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -51,7 +51,7 @@ public class EquilTest { private static final Logger log = LogManager.getLogger( EquilTest.class ) ; - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); private final boolean isUsingFastCapacityUpdate; diff --git a/matsim/src/test/java/org/matsim/examples/OnePercentBerlin10sIT.java b/matsim/src/test/java/org/matsim/examples/OnePercentBerlin10sIT.java index 92e9431f0c5..48c7bb036f8 100644 --- a/matsim/src/test/java/org/matsim/examples/OnePercentBerlin10sIT.java +++ b/matsim/src/test/java/org/matsim/examples/OnePercentBerlin10sIT.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.api.experimental.events.EventsManager; @@ -44,8 +44,8 @@ public class OnePercentBerlin10sIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final Logger log = LogManager.getLogger(OnePercentBerlin10sIT.class); diff --git a/matsim/src/test/java/org/matsim/examples/PtTutorialIT.java b/matsim/src/test/java/org/matsim/examples/PtTutorialIT.java index 43c8378d326..781f3587b01 100644 --- a/matsim/src/test/java/org/matsim/examples/PtTutorialIT.java +++ b/matsim/src/test/java/org/matsim/examples/PtTutorialIT.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; @@ -52,7 +52,8 @@ public class PtTutorialIT { private final static Logger log = LogManager.getLogger(PtTutorialIT.class); - public @Rule MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); @Test public void ensure_tutorial_runs() throws MalformedURLException { diff --git a/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java b/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java index 3789e469a25..0c63dacd949 100644 --- a/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java +++ b/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java @@ -22,7 +22,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -61,7 +61,7 @@ public static Object[] testParameters() { return new Object[] {TypicalDurationScoreComputation.relative, TypicalDurationScoreComputation.uniform}; } - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void test_PtScoringLineswitch() { diff --git a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java index 30d0e5a0a6e..25b4d5a96ed 100644 --- a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java +++ b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java @@ -20,7 +20,7 @@ package org.matsim.facilities; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -53,7 +53,7 @@ @RunWith(Parameterized.class) public class ActivityFacilitiesSourceTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; // private static final String outDir = "test/output/"+ActivityFacilitiesSourceTest.class.getCanonicalName().replace('.','/')+"/"; diff --git a/matsim/src/test/java/org/matsim/facilities/FacilitiesAttributeConvertionTest.java b/matsim/src/test/java/org/matsim/facilities/FacilitiesAttributeConvertionTest.java index 04225385284..9120b176773 100644 --- a/matsim/src/test/java/org/matsim/facilities/FacilitiesAttributeConvertionTest.java +++ b/matsim/src/test/java/org/matsim/facilities/FacilitiesAttributeConvertionTest.java @@ -22,7 +22,7 @@ package org.matsim.facilities; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.ConfigUtils; @@ -35,7 +35,7 @@ import java.util.function.Consumer; public class FacilitiesAttributeConvertionTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/matsim/src/test/java/org/matsim/facilities/FacilitiesParserWriterTest.java b/matsim/src/test/java/org/matsim/facilities/FacilitiesParserWriterTest.java index 65fca6d624d..90bde039ca5 100644 --- a/matsim/src/test/java/org/matsim/facilities/FacilitiesParserWriterTest.java +++ b/matsim/src/test/java/org/matsim/facilities/FacilitiesParserWriterTest.java @@ -21,7 +21,7 @@ package org.matsim.facilities; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -42,7 +42,7 @@ */ public class FacilitiesParserWriterTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testParserWriter1() { diff --git a/matsim/src/test/java/org/matsim/facilities/FacilitiesReprojectionIOTest.java b/matsim/src/test/java/org/matsim/facilities/FacilitiesReprojectionIOTest.java index e3ad1e04478..f4154bb23d4 100644 --- a/matsim/src/test/java/org/matsim/facilities/FacilitiesReprojectionIOTest.java +++ b/matsim/src/test/java/org/matsim/facilities/FacilitiesReprojectionIOTest.java @@ -22,7 +22,7 @@ package org.matsim.facilities; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -50,7 +50,7 @@ public class FacilitiesReprojectionIOTest { INITIAL_CRS, TARGET_CRS); - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/matsim/src/test/java/org/matsim/facilities/algorithms/AbstractFacilityAlgorithmTest.java b/matsim/src/test/java/org/matsim/facilities/algorithms/AbstractFacilityAlgorithmTest.java index 5296c8c4440..99083e55eb7 100644 --- a/matsim/src/test/java/org/matsim/facilities/algorithms/AbstractFacilityAlgorithmTest.java +++ b/matsim/src/test/java/org/matsim/facilities/algorithms/AbstractFacilityAlgorithmTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -32,8 +32,8 @@ public class AbstractFacilityAlgorithmTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testRunAlgorithms() { diff --git a/matsim/src/test/java/org/matsim/households/HouseholdAttributeConversionTest.java b/matsim/src/test/java/org/matsim/households/HouseholdAttributeConversionTest.java index 10257ac5867..14d81eb0be3 100644 --- a/matsim/src/test/java/org/matsim/households/HouseholdAttributeConversionTest.java +++ b/matsim/src/test/java/org/matsim/households/HouseholdAttributeConversionTest.java @@ -24,7 +24,7 @@ import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -40,7 +40,7 @@ import java.util.function.Consumer; public class HouseholdAttributeConversionTest { - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/matsim/src/test/java/org/matsim/households/HouseholdImplTest.java b/matsim/src/test/java/org/matsim/households/HouseholdImplTest.java index e5137aa72cb..83f7d596c35 100644 --- a/matsim/src/test/java/org/matsim/households/HouseholdImplTest.java +++ b/matsim/src/test/java/org/matsim/households/HouseholdImplTest.java @@ -22,15 +22,15 @@ import static org.junit.Assert.*; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.testcases.MatsimTestUtils; public class HouseholdImplTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/households/HouseholdsIoTest.java b/matsim/src/test/java/org/matsim/households/HouseholdsIoTest.java index 0f158b4494e..28f68261192 100644 --- a/matsim/src/test/java/org/matsim/households/HouseholdsIoTest.java +++ b/matsim/src/test/java/org/matsim/households/HouseholdsIoTest.java @@ -27,7 +27,7 @@ import java.util.Collections; import java.util.List; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -41,8 +41,8 @@ */ public class HouseholdsIoTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final String TESTHOUSEHOLDSINPUT = "testHouseholds.xml"; diff --git a/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java b/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java index 3d2df7affd6..d458b8af9a5 100644 --- a/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java +++ b/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java @@ -21,7 +21,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; @@ -69,8 +69,8 @@ */ public class EquilTwoAgentsTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /*package*/ final static Logger log = LogManager.getLogger(EquilTwoAgentsTest.class); diff --git a/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java b/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java index 9d70490fc42..a7235c552d9 100644 --- a/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java +++ b/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java @@ -24,7 +24,7 @@ import java.util.Arrays; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -82,8 +82,8 @@ public class SimulateAndScoreTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testRealPtScore() { diff --git a/matsim/src/test/java/org/matsim/integration/events/PersonMoneyEventIntegrationTest.java b/matsim/src/test/java/org/matsim/integration/events/PersonMoneyEventIntegrationTest.java index 6236bd93fbb..d255daabe55 100644 --- a/matsim/src/test/java/org/matsim/integration/events/PersonMoneyEventIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/integration/events/PersonMoneyEventIntegrationTest.java @@ -26,7 +26,7 @@ import java.io.BufferedWriter; import java.io.IOException; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonMoneyEvent; @@ -44,8 +44,8 @@ */ public class PersonMoneyEventIntegrationTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteReadXxml() { diff --git a/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingIT.java b/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingIT.java index 7373f84c106..acf0bf75e71 100644 --- a/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingIT.java +++ b/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingIT.java @@ -21,7 +21,7 @@ import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.controler.Controler; import org.matsim.core.controler.events.StartupEvent; @@ -30,8 +30,8 @@ public class InvertedNetworkRoutingIT { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public final void testLanesInvertedNetworkRouting() { diff --git a/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java b/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java index f31ec3a810e..e3f49875139 100644 --- a/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java +++ b/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.LinkEnterEvent; @@ -56,8 +56,8 @@ public class LanesIT { private static final Logger log = LogManager.getLogger(LanesIT.class); - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test public void testLanes(){ diff --git a/matsim/src/test/java/org/matsim/integration/population/NonAlternatingPlanElementsIT.java b/matsim/src/test/java/org/matsim/integration/population/NonAlternatingPlanElementsIT.java index 5c317f24862..9e4952cb95a 100644 --- a/matsim/src/test/java/org/matsim/integration/population/NonAlternatingPlanElementsIT.java +++ b/matsim/src/test/java/org/matsim/integration/population/NonAlternatingPlanElementsIT.java @@ -23,7 +23,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -60,7 +60,7 @@ */ public class NonAlternatingPlanElementsIT { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void test_Controler_QSim_Routechoice_acts() { diff --git a/matsim/src/test/java/org/matsim/integration/pt/TransitIntegrationTest.java b/matsim/src/test/java/org/matsim/integration/pt/TransitIntegrationTest.java index b6caa9f2372..7f957b6bf4e 100644 --- a/matsim/src/test/java/org/matsim/integration/pt/TransitIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/integration/pt/TransitIntegrationTest.java @@ -19,7 +19,7 @@ package org.matsim.integration.pt; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -31,7 +31,7 @@ public class TransitIntegrationTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test(expected = RuntimeException.class) public void testPtInteractionParams() { diff --git a/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java b/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java index 7672fd7769b..8dc31bb2b98 100644 --- a/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -70,8 +70,8 @@ */ public class ChangeTripModeIntegrationTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testStrategyManagerConfigLoaderIntegration() { diff --git a/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java b/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java index 19a67fdd437..eeba73759b9 100644 --- a/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java +++ b/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.PopulationWriter; @@ -44,8 +44,8 @@ public class ReRoutingIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private Scenario loadScenario() { Config config = utils.loadConfig(utils.getClassInputDirectory() +"config.xml"); diff --git a/matsim/src/test/java/org/matsim/integration/replanning/ResumableRunsIT.java b/matsim/src/test/java/org/matsim/integration/replanning/ResumableRunsIT.java index ee859ca7b41..feb4b69ff3c 100644 --- a/matsim/src/test/java/org/matsim/integration/replanning/ResumableRunsIT.java +++ b/matsim/src/test/java/org/matsim/integration/replanning/ResumableRunsIT.java @@ -21,7 +21,7 @@ package org.matsim.integration.replanning; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; @@ -46,8 +46,8 @@ */ public class ResumableRunsIT { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** * Runs a first simulation for 11 iteration, then restarts at iteration 10. diff --git a/matsim/src/test/java/org/matsim/integration/timevariantnetworks/QSimIntegrationTest.java b/matsim/src/test/java/org/matsim/integration/timevariantnetworks/QSimIntegrationTest.java index 32c05ba9629..9808f4b5f2c 100644 --- a/matsim/src/test/java/org/matsim/integration/timevariantnetworks/QSimIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/integration/timevariantnetworks/QSimIntegrationTest.java @@ -26,7 +26,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -75,8 +75,8 @@ */ public class QSimIntegrationTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testFreespeed() { diff --git a/matsim/src/test/java/org/matsim/lanes/data/LanesReaderWriterTest.java b/matsim/src/test/java/org/matsim/lanes/data/LanesReaderWriterTest.java index 9ba9fcade74..c032d3409c9 100644 --- a/matsim/src/test/java/org/matsim/lanes/data/LanesReaderWriterTest.java +++ b/matsim/src/test/java/org/matsim/lanes/data/LanesReaderWriterTest.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -49,8 +49,8 @@ */ public class LanesReaderWriterTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final Logger log = LogManager.getLogger(LanesReaderWriterTest.class); diff --git a/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java b/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java index 4951ffdf3c7..caf4baac619 100644 --- a/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java +++ b/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java @@ -29,7 +29,7 @@ import jakarta.inject.Inject; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -48,8 +48,8 @@ public class ScoreStatsModuleTest { public static final double DELTA = 0.0000000001; - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private final boolean isUsingFastCapacityUpdate; private final boolean isInsertingAccessEgressWalk; diff --git a/matsim/src/test/java/org/matsim/other/DownloadAndReadXmlTest.java b/matsim/src/test/java/org/matsim/other/DownloadAndReadXmlTest.java index 9508314fd5c..883aa930f3a 100644 --- a/matsim/src/test/java/org/matsim/other/DownloadAndReadXmlTest.java +++ b/matsim/src/test/java/org/matsim/other/DownloadAndReadXmlTest.java @@ -21,7 +21,7 @@ import org.junit.Assert; import org.junit.Ignore; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; @@ -31,15 +31,15 @@ import org.matsim.testcases.MatsimTestUtils; /** - * + * * Tests downloading and reading in xml files from our public svn. - * + * * @author gleich */ public class DownloadAndReadXmlTest { - - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Ignore @Test @@ -47,43 +47,43 @@ public class DownloadAndReadXmlTest { * Http downloads from the SVN server will be forbidden soon, according to jwilk. */ public final void testHttpFromSvn() { - + Config config = ConfigUtils.createConfig(); System.out.println(utils.getInputDirectory() + "../../"); config.network().setInputFile("http://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/atlantis/minibus/input/network.xml"); - + // See whether the file can be downloaded and read Scenario scenario = ScenarioUtils.loadScenario(config); - + // Check whether all nodes and links were read Network network = scenario.getNetwork(); - + // 3 pt nodes and 4 x 4 car nodes Assert.assertEquals(3 + 4 * 4, network.getNodes().size()); - + // 6 pt links and 3 links * 2 directions * 4 times in parallel * 2 (horizontally and vertically) Assert.assertEquals(6 + 3 * 2 * 4 * 2, network.getLinks().size()); } - + @Test public final void testHttpsFromSvn() { - + Config config = ConfigUtils.createConfig(); System.out.println(utils.getInputDirectory() + "../../"); config.network().setInputFile("https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/atlantis/minibus/input/network.xml"); - + // See whether the file can be downloaded and read Scenario scenario = ScenarioUtils.loadScenario(config); - + // Check whether all nodes and links were read Network network = scenario.getNetwork(); - + // 3 pt nodes and 4 x 4 car nodes Assert.assertEquals(3 + 4 * 4, network.getNodes().size()); - + // 6 pt links and 3 links * 2 directions * 4 times in parallel * 2 (horizontally and vertically) Assert.assertEquals(6 + 3 * 2 * 4 * 2, network.getLinks().size()); } - + } diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourTest.java index 8511013b329..68c8df6fd01 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourTest.java @@ -30,7 +30,7 @@ import java.util.List; import java.util.Random; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -65,9 +65,9 @@ */ @RunWith(Parameterized.class) public class ChooseRandomLegModeForSubtourTest { - + private double probaForRandomSingleTripMode; - + private static class AllowTheseModesForEveryone implements PermissibleModesCalculator { @@ -79,18 +79,18 @@ public AllowTheseModesForEveryone(String[] availableModes) { @Override public Collection getPermissibleModes(Plan plan) { - return availableModes; + return availableModes; } } - - @Rule + + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); public static enum TripStructureAnalysisLayerOption {facility,link} private static final String CONFIGFILE = "test/scenarios/equil/config.xml"; - private static final String[] CHAIN_BASED_MODES = new String[] { TransportMode.car }; + private static final String[] CHAIN_BASED_MODES = new String[] { TransportMode.car }; private static final Collection activityChainStrings = Arrays.asList( "1 2 1", "1 2 20 1", @@ -108,7 +108,7 @@ public static enum TripStructureAnalysisLayerOption {facility,link} "1 2 1 1", "1 2 2 3 2 2 2 1 4 1", "1 2 3 4 3 1"); - + @Parameterized.Parameters(name = "{index}: probaForRandomSingleTripMode == {0}") public static Collection createTests() { return Arrays.asList(0., 0.5); @@ -116,8 +116,8 @@ public static Collection createTests() { public ChooseRandomLegModeForSubtourTest( double proba ) { this.probaForRandomSingleTripMode = proba ; } - - + + @Test public void testHandleEmptyPlan() { String[] modes = new String[] {TransportMode.car, TransportMode.pt, TransportMode.walk}; @@ -175,7 +175,7 @@ public void testCarDoesntTeleportFromHome() { @Test public void testSingleTripSubtourHandling() { String[] modes = new String[] {"car", "pt", "walk"}; - + ChooseRandomLegModeForSubtour testee = new ChooseRandomLegModeForSubtour( new MainModeIdentifierImpl() ,new AllowTheseModesForEveryone(modes), modes, CHAIN_BASED_MODES, new Random(15102011), SubtourModeChoice.Behavior.fromSpecifiedModesToSpecifiedModes, probaForRandomSingleTripMode); Person person = PopulationUtils.getFactory().createPerson(Id.create("1000", Person.class)); Plan plan = PopulationUtils.createPlan(); @@ -187,12 +187,12 @@ public void testSingleTripSubtourHandling() { plan.addActivity(home1); plan.addLeg(leg); plan.addActivity(home2); - + { // test default boolean hasCar = false; boolean hasPt = false; boolean hasWalk = false; - + for (int i = 0; i < 50; i++) { testee.run(plan); @@ -225,7 +225,7 @@ public void testSingleTripSubtourHandling() { boolean hasCar = false; boolean hasPt = false; boolean hasWalk = false; - + for (int i = 0; i < 50; i++) { testee.run(plan); @@ -302,7 +302,7 @@ private void testSubTourMutationToCar(Network network) { assertSubTourMutated(plan, originalPlan, expectedMode, false); } } - + private void testSubTourMutationToCar(ActivityFacilities facilities) { String expectedMode = TransportMode.car; String originalMode = TransportMode.pt; @@ -318,7 +318,7 @@ private void testSubTourMutationToCar(ActivityFacilities facilities) { assertSubTourMutated(plan, originalPlan, expectedMode, true); } } - + private void testUnknownModeDoesntMutate(Network network) { String originalMode = TransportMode.walk; String[] modes = new String[] {TransportMode.car, TransportMode.pt}; @@ -333,7 +333,7 @@ private void testUnknownModeDoesntMutate(Network network) { assertTrue(TestsUtil.equals(plan.getPlanElements(), originalPlan.getPlanElements())); } } - + private void testUnknownModeDoesntMutate(ActivityFacilities facilities) { String originalMode = TransportMode.walk; String[] modes = new String[] {TransportMode.car, TransportMode.pt}; @@ -364,7 +364,7 @@ private void testSubTourMutationToPt(ActivityFacilities facilities) { assertSubTourMutated(plan, originalPlan, expectedMode, true); } } - + private void testSubTourMutationToPt(Network network) { String expectedMode = TransportMode.pt; String originalMode = TransportMode.car; @@ -380,7 +380,7 @@ private void testSubTourMutationToPt(Network network) { assertSubTourMutated(plan, originalPlan, expectedMode, false); } } - + private void testCarDoesntTeleport(Network network, String originalMode, String otherMode) { String[] modes = new String[] {originalMode, otherMode}; ChooseRandomLegModeForSubtour testee = new ChooseRandomLegModeForSubtour( new MainModeIdentifierImpl() ,new AllowTheseModesForEveryone(modes), modes, CHAIN_BASED_MODES, MatsimRandom.getRandom(), SubtourModeChoice.Behavior.fromSpecifiedModesToSpecifiedModes, probaForRandomSingleTripMode); @@ -414,7 +414,7 @@ private void testCarDoesntTeleport(Network network, String originalMode, String carLocation); } } - + private void testCarDoesntTeleport(ActivityFacilities facilities, String originalMode, String otherMode) { String[] modes = new String[] {originalMode, otherMode}; ChooseRandomLegModeForSubtour testee = new ChooseRandomLegModeForSubtour( new MainModeIdentifierImpl() ,new AllowTheseModesForEveryone(modes), modes, CHAIN_BASED_MODES, MatsimRandom.getRandom(), SubtourModeChoice.Behavior.fromSpecifiedModesToSpecifiedModes, probaForRandomSingleTripMode); diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeTest.java index dce12c298ec..e52d56eca60 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeTest.java @@ -24,7 +24,7 @@ import java.util.Random; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -43,8 +43,8 @@ */ public class ChooseRandomLegModeTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testRandomChoice() { diff --git a/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadIntegrationTest.java b/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadIntegrationTest.java index 298664f0f7f..8e43b745d0a 100644 --- a/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadIntegrationTest.java @@ -20,7 +20,7 @@ package org.matsim.pt.analysis; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -41,7 +41,7 @@ */ public class TransitLoadIntegrationTest { - @Rule public MatsimTestUtils util = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils util = new MatsimTestUtils(); @Test public void testIntegration() { diff --git a/matsim/src/test/java/org/matsim/pt/router/TransitRouterModuleTest.java b/matsim/src/test/java/org/matsim/pt/router/TransitRouterModuleTest.java index 196ff84dc0c..7d573d29ed8 100644 --- a/matsim/src/test/java/org/matsim/pt/router/TransitRouterModuleTest.java +++ b/matsim/src/test/java/org/matsim/pt/router/TransitRouterModuleTest.java @@ -3,7 +3,7 @@ import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptor; import com.google.inject.Injector; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; @@ -16,7 +16,7 @@ */ public class TransitRouterModuleTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testTransitRoutingAlgorithm_DependencyInjection_Raptor() { diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/DepartureTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/DepartureTest.java index a178e71fc8b..d79bcd590e4 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/DepartureTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/DepartureTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.pt.transitSchedule.api.Departure; @@ -35,8 +35,8 @@ */ public class DepartureTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitLineTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitLineTest.java index b4a9c097c47..05c4b721b6d 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitLineTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitLineTest.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.pt.transitSchedule.api.TransitLine; @@ -39,8 +39,8 @@ */ public class TransitLineTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final Logger log = LogManager.getLogger(TransitLineTest.class); diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteStopTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteStopTest.java index 1bc7999d263..176ac89d5c3 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteStopTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteStopTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.*; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -35,8 +35,8 @@ */ public class TransitRouteStopTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); protected TransitRouteStop createTransitRouteStop(final TransitStopFacility stop, final double arrivalDelay, final double departureDelay) { diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteTest.java index ac7d811dd0f..d55881a2542 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteTest.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -46,8 +46,8 @@ */ public class TransitRouteTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final Logger log = LogManager.getLogger(TransitRouteTest.class); diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFormatV1Test.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFormatV1Test.java index b4f4c0afe95..665f560b7db 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFormatV1Test.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFormatV1Test.java @@ -28,7 +28,7 @@ import javax.xml.parsers.ParserConfigurationException; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -61,8 +61,8 @@ */ public class TransitScheduleFormatV1Test { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteRead() throws IOException, SAXException, ParserConfigurationException { diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderTest.java index 305de6e3cec..a634df0d228 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderTest.java @@ -29,7 +29,7 @@ import javax.xml.parsers.ParserConfigurationException; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -56,8 +56,8 @@ */ public class TransitScheduleReaderTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final String INPUT_TEST_FILE_TRANSITSCHEDULE = "transitSchedule.xml"; diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReprojectionIOTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReprojectionIOTest.java index 526fefcb1d2..460bb4930b3 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReprojectionIOTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReprojectionIOTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -62,7 +62,7 @@ public class TransitScheduleReprojectionIOTest { INITIAL_CRS, TARGET_CRS); - @Rule + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @Test diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleWriterTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleWriterTest.java index 2bd2ef73e58..c628d33117e 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleWriterTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleWriterTest.java @@ -25,7 +25,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.core.population.routes.RouteFactories; @@ -41,8 +41,8 @@ */ public class TransitScheduleWriterTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + /** * Tests that the default format written is in v2 format. * @@ -67,20 +67,20 @@ public void testDefaultV2() throws IOException, SAXException, ParserConfiguratio new TransitScheduleReaderV2(schedule2, new RouteFactories()).readFile(filename); Assert.assertEquals(1, schedule2.getTransitLines().size()); } - + @Test public void testTransitLineName() { String filename = this.utils.getOutputDirectory() + "schedule.xml"; - + TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitSchedule schedule = builder.createTransitSchedule(); TransitLine line = builder.createTransitLine(Id.create(1, TransitLine.class)); line.setName("Blue line"); schedule.addTransitLine(line); - + TransitScheduleWriter writer = new TransitScheduleWriter(schedule); writer.writeFile(filename); - + TransitScheduleFactory builder2 = new TransitScheduleFactoryImpl(); TransitSchedule schedule2 = builder2.createTransitSchedule(); new TransitScheduleReaderV1(schedule2, new RouteFactories()).readFile(filename); diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitStopFacilityTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitStopFacilityTest.java index dd2889e872f..5f8cd61b7b1 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitStopFacilityTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitStopFacilityTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.*; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -36,8 +36,8 @@ */ public class TransitStopFacilityTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** diff --git a/matsim/src/test/java/org/matsim/run/CreateFullConfigTest.java b/matsim/src/test/java/org/matsim/run/CreateFullConfigTest.java index fba104c3f3d..cf324a220c0 100644 --- a/matsim/src/test/java/org/matsim/run/CreateFullConfigTest.java +++ b/matsim/src/test/java/org/matsim/run/CreateFullConfigTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -35,7 +35,7 @@ public class CreateFullConfigTest { private final static Logger log = LogManager.getLogger(CreateFullConfigTest.class); - @Rule public MatsimTestUtils helper = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils helper = new MatsimTestUtils(); @Test public void testMain() { diff --git a/matsim/src/test/java/org/matsim/run/InitRoutesTest.java b/matsim/src/test/java/org/matsim/run/InitRoutesTest.java index ecc5c4b1d8b..b44932b7cf4 100644 --- a/matsim/src/test/java/org/matsim/run/InitRoutesTest.java +++ b/matsim/src/test/java/org/matsim/run/InitRoutesTest.java @@ -24,7 +24,7 @@ import java.io.File; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -57,8 +57,8 @@ */ public class InitRoutesTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testMain() throws Exception { diff --git a/matsim/src/test/java/org/matsim/run/XY2LinksTest.java b/matsim/src/test/java/org/matsim/run/XY2LinksTest.java index bab46ae2286..b403682c30a 100644 --- a/matsim/src/test/java/org/matsim/run/XY2LinksTest.java +++ b/matsim/src/test/java/org/matsim/run/XY2LinksTest.java @@ -24,7 +24,7 @@ import java.io.File; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -54,8 +54,8 @@ */ public class XY2LinksTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testMain() throws Exception { diff --git a/matsim/src/test/java/org/matsim/testcases/MatsimJunit5Test.java b/matsim/src/test/java/org/matsim/testcases/MatsimJunit5Test.java deleted file mode 100644 index 0581a3d58d0..00000000000 --- a/matsim/src/test/java/org/matsim/testcases/MatsimJunit5Test.java +++ /dev/null @@ -1,344 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * * - * *********************************************************************** * - * * - * copyright : (C) 2010 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.testcases; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.junit.Assert; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.TestInfo; -import org.junit.rules.TestWatcher; -import org.junit.runner.Description; -import org.matsim.core.config.Config; -import org.matsim.core.config.ConfigGroup; -import org.matsim.core.config.ConfigUtils; -import org.matsim.core.gbl.MatsimRandom; -import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.misc.CRCChecksum; -import org.matsim.utils.eventsfilecomparison.EventsFileComparator; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.lang.reflect.Method; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Objects; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static org.junit.Assert.assertEquals; - -/** - * //TODO - * - * @author pheinrich - */ -public abstract class MatsimJunit5Test { - private static final Logger log = LogManager.getLogger(MatsimJunit5Test.class); - - /** - * A constant for the exactness when comparing doubles. - */ - public static final double EPSILON = 1e-10; - - /** The default output directory, where files of this test should be written to. - * Includes the trailing '/' to denote a directory. */ - private String outputDirectory = null; - - /** The default input directory, where files of this test should be read from. - * Includes the trailing '/' to denote a directory. */ - private String inputDirectory = null; - - /** - * The input directory one level above the default input directory. If files are - * used by several test methods of a testcase they have to be stored in this directory. - */ - private String classInputDirectory = null; - /** - * The input directory two levels above the default input directory. If files are used - * by several test classes of a package they have to be stored in this directory. - */ - private String packageInputDirectory; - - private boolean outputDirCreated = false; - - private Class testClass = null; - private String testMethodName = null; - private String testParameterSetIndex = null; - - public MatsimJunit5Test() { - MatsimRandom.reset(); - } - - @BeforeEach - public void initEach(TestInfo testInfo) { - this.testClass = testInfo.getTestClass().orElseThrow(); - - Matcher matcher = METHOD_PARAMETERS_WITH_INDEX_PATTERN.matcher(testInfo.getTestMethod().orElseThrow().getName()); - if (!matcher.matches()) { - throw new RuntimeException("The name of the test parameter set must start with {index}"); - } - this.testMethodName = matcher.group(1); - this.testParameterSetIndex = matcher.group(2); // null for non-parametrised tests - } - - @AfterEach - public void finish() { - this.testClass = null; - this.testMethodName = null; - } - - public Config createConfigWithInputResourcePathAsContext() { - Config config = ConfigUtils.createConfig(); - config.setContext(inputResourcePath()); - this.outputDirectory = getOutputDirectory(); - config.controller().setOutputDirectory(this.outputDirectory); - return config; - } - - public Config createConfigWithClassInputResourcePathAsContext() { - Config config = ConfigUtils.createConfig(); - config.setContext(classInputResourcePath()); - this.outputDirectory = getOutputDirectory(); - config.controller().setOutputDirectory(this.outputDirectory); - return config; - } - - public Config createConfigWithPackageInputResourcePathAsContext() { - Config config = ConfigUtils.createConfig(); - config.setContext(packageInputResourcePath()); - this.outputDirectory = getOutputDirectory(); - config.controller().setOutputDirectory(this.outputDirectory); - return config; - } - - public URL inputResourcePath() { - return getResourceNotNull("/" + getClassInputDirectory() + getMethodName() + "/."); - } - - /** - * @return class input directory as URL - */ - public URL classInputResourcePath() { - return getResourceNotNull("/" + getClassInputDirectory() + "/."); - } - - public URL packageInputResourcePath() { - return getResourceNotNull("/" + getPackageInputDirectory() + "/."); - } - - private URL getResourceNotNull(String pathString) { - URL resource = this.testClass.getResource(pathString); - if (resource == null) { - throw new UncheckedIOException(new IOException("Not found: "+pathString)); - } - return resource; - } - - public Config createConfigWithTestInputFilePathAsContext() { - try { - Config config = ConfigUtils.createConfig(); - config.setContext(new File(this.getInputDirectory()).toURI().toURL()); - this.outputDirectory = getOutputDirectory(); - config.controller().setOutputDirectory(this.outputDirectory); - return config; - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - - public Config createConfig(URL context) { - Config config = ConfigUtils.createConfig(); - config.setContext(context); - this.outputDirectory = getOutputDirectory(); - config.controller().setOutputDirectory(this.outputDirectory); - return config; - } - - - /** - * Loads a configuration from file (or the default config if configfile is null). - * - * @param configfile The path/filename of a configuration file, or null to load the default configuration. - * @return The loaded configuration. - */ - public Config loadConfig(final String configfile, final ConfigGroup... customGroups) { - Config config; - if (configfile != null) { - config = ConfigUtils.loadConfig(configfile, customGroups); - } else { - config = ConfigUtils.createConfig( customGroups ); - } - this.outputDirectory = getOutputDirectory(); - config.controller().setOutputDirectory(this.outputDirectory); - return config; - } - - public Config loadConfig(final URL configfile, final ConfigGroup... customGroups) { - Config config; - if (configfile != null) { - config = ConfigUtils.loadConfig(configfile, customGroups); - } else { - config = ConfigUtils.createConfig( customGroups ); - } - this.outputDirectory = getOutputDirectory(); - config.controller().setOutputDirectory(this.outputDirectory); - return config; - } - - public Config createConfig(final ConfigGroup... customGroups) { - Config config = ConfigUtils.createConfig( customGroups ); - this.outputDirectory = getOutputDirectory(); - config.controller().setOutputDirectory(this.outputDirectory); - return config; - } - - private void createOutputDirectory() { - if ((!this.outputDirCreated) && (this.outputDirectory != null)) { - File directory = new File(this.outputDirectory); - if (directory.exists()) { - IOUtils.deleteDirectoryRecursively(directory.toPath()); - } - this.outputDirCreated = directory.mkdirs(); - Assert.assertTrue("Could not create the output directory " + this.outputDirectory, this.outputDirCreated); - } - } - - /** - * Returns the path to the output directory for this test including a trailing slash as directory delimiter. - * - * @return path to the output directory for this test - */ - public String getOutputDirectory() { - if (this.outputDirectory == null) { - String subDirectoryForParametrisedTests = testParameterSetIndex == null ? "" : testParameterSetIndex + "/"; - this.outputDirectory = "test/output/" + this.testClass.getCanonicalName().replace('.', '/') + "/" + getMethodName()+ "/" - + subDirectoryForParametrisedTests; - } - createOutputDirectory(); - return this.outputDirectory; - } - - /** - * Returns the path to the input directory for this test including a trailing slash as directory delimiter. - * - * @return path to the input directory for this test - */ - public String getInputDirectory() { - if (this.inputDirectory == null) { - this.inputDirectory = getClassInputDirectory() + getMethodName() + "/"; - } - return this.inputDirectory; - } - /** - * Returns the path to the input directory one level above the default input directory for this test including a trailing slash as directory delimiter. - * - * @return path to the input directory for this test - */ - public String getClassInputDirectory() { - if (this.classInputDirectory == null) { - - LogManager.getLogger(this.getClass()).info( "user.dir = " + System.getProperty("user.dir") ) ; - - this.classInputDirectory = "test/input/" + - this.testClass.getCanonicalName().replace('.', '/') + "/"; -// this.classInputDirectory = System.getProperty("user.dir") + "/test/input/" + -// this.testClass.getCanonicalName().replace('.', '/') + "/"; - // (this used to be relative, i.e. ... = "test/input/" + ... . Started failing when - // this was used in tests to read a second config file when I made the path of that - // relative to the root of the initial config file. Arghh. kai, feb'18) - // yyyyyy needs to be discussed, see MATSIM-776 and MATSIM-777. kai, feb'18 - } - return this.classInputDirectory; - } - /** - * Returns the path to the input directory two levels above the default input directory for this test including a trailing slash as directory delimiter. - * - * @return path to the input directory for this test - */ - public String getPackageInputDirectory() { - if (this.packageInputDirectory == null) { - String classDirectory = getClassInputDirectory(); - this.packageInputDirectory = classDirectory.substring(0, classDirectory.lastIndexOf('/')); - this.packageInputDirectory = this.packageInputDirectory.substring(0, this.packageInputDirectory.lastIndexOf('/') + 1); - } - return this.packageInputDirectory; - } - - /** - * @return the name of the currently-running test method - */ - public String getMethodName() { - if (this.testMethodName == null) { - throw new RuntimeException("MatsimTestUtils.getMethodName() can only be used in actual test, not in constructor or elsewhere!"); - } - return this.testMethodName; - } - - /** - * Initializes MatsimTestUtils without requiring the method of a class to be a JUnit test. - * This should be used for "fixtures" only that provide a scenario common to several - * test cases. - */ - public void initWithoutJUnitForFixture(Class fixture, Method method){ - this.testClass = fixture; - this.testMethodName = method.getName(); - } - - //captures the method name (group 1) and optionally the index of the parameter set (group 2; only if the test is parametrised) - //The matching may fail if the parameter set name does not start with {index} (at least one digit is required at the beginning) - private static final Pattern METHOD_PARAMETERS_WITH_INDEX_PATTERN = Pattern.compile( - "([\\S]*)(?:\\[(\\d+)[\\s\\S]*\\])?"); - - public static void assertEqualEventsFiles( String filename1, String filename2 ) { - Assert.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL ,EventsFileComparator.compare(filename1, filename2) ); - } - - public static void assertEqualFilesBasedOnCRC( String filename1, String filename2 ) { - long checksum1 = CRCChecksum.getCRCFromFile(filename1) ; - long checksum2 = CRCChecksum.getCRCFromFile(filename2) ; - Assert.assertEquals( "different file checksums", checksum1, checksum2 ); - } - - public static void assertEqualFilesLineByLine(String inputFilename, String outputFilename) { - try (BufferedReader readerV1Input = IOUtils.getBufferedReader(inputFilename); - BufferedReader readerV1Output = IOUtils.getBufferedReader(outputFilename)) { - - String lineInput; - String lineOutput; - - while( ((lineInput = readerV1Input.readLine()) != null) && ((lineOutput = readerV1Output.readLine()) != null) ){ - if ( !Objects.equals( lineInput.trim(), lineOutput.trim() ) ){ - log.info( "Reading line... " ); - log.info( lineInput ); - log.info( lineOutput ); - log.info( "" ); - } - assertEquals( "Lines have different content: ", lineInput.trim(), lineOutput.trim() ); - } - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - -} diff --git a/matsim/src/test/java/org/matsim/testcases/MatsimJunit5TestExtension.java b/matsim/src/test/java/org/matsim/testcases/MatsimJunit5TestExtension.java deleted file mode 100644 index 1e4e87367c9..00000000000 --- a/matsim/src/test/java/org/matsim/testcases/MatsimJunit5TestExtension.java +++ /dev/null @@ -1,344 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * * - * *********************************************************************** * - * * - * copyright : (C) 2010 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.testcases; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.junit.Assert; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.TestInfo; -import org.junit.jupiter.api.extension.AfterEachCallback; -import org.junit.jupiter.api.extension.BeforeEachCallback; -import org.junit.jupiter.api.extension.ExtensionContext; -import org.matsim.core.config.Config; -import org.matsim.core.config.ConfigGroup; -import org.matsim.core.config.ConfigUtils; -import org.matsim.core.gbl.MatsimRandom; -import org.matsim.core.utils.io.IOUtils; -import org.matsim.core.utils.misc.CRCChecksum; -import org.matsim.utils.eventsfilecomparison.EventsFileComparator; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.lang.reflect.Method; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Objects; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static org.junit.Assert.assertEquals; - -/** - * //TODO - * - * @author pheinrich - */ -public class MatsimJunit5TestExtension implements BeforeEachCallback, AfterEachCallback { - private static final Logger log = LogManager.getLogger(MatsimJunit5TestExtension.class); - - /** - * A constant for the exactness when comparing doubles. - */ - public static final double EPSILON = 1e-10; - - /** The default output directory, where files of this test should be written to. - * Includes the trailing '/' to denote a directory. */ - private String outputDirectory = null; - - /** The default input directory, where files of this test should be read from. - * Includes the trailing '/' to denote a directory. */ - private String inputDirectory = null; - - /** - * The input directory one level above the default input directory. If files are - * used by several test methods of a testcase they have to be stored in this directory. - */ - private String classInputDirectory = null; - /** - * The input directory two levels above the default input directory. If files are used - * by several test classes of a package they have to be stored in this directory. - */ - private String packageInputDirectory; - - private boolean outputDirCreated = false; - - private Class testClass = null; - private String testMethodName = null; - private String testParameterSetIndex = null; - - public MatsimJunit5TestExtension() { - MatsimRandom.reset(); - } - - @Override - public void beforeEach(ExtensionContext extensionContext) throws Exception { - this.testClass = extensionContext.getTestClass().orElseThrow(); - - Matcher matcher = METHOD_PARAMETERS_WITH_INDEX_PATTERN.matcher(extensionContext.getTestMethod().orElseThrow().getName()); - if (!matcher.matches()) { - throw new RuntimeException("The name of the test parameter set must start with {index}"); - } - this.testMethodName = matcher.group(1); - this.testParameterSetIndex = matcher.group(2); // null for non-parametrised tests - } - - @Override - public void afterEach(ExtensionContext extensionContext) throws Exception { - this.testClass = null; - this.testMethodName = null; - } - - public Config createConfigWithInputResourcePathAsContext() { - Config config = ConfigUtils.createConfig(); - config.setContext(inputResourcePath()); - this.outputDirectory = getOutputDirectory(); - config.controller().setOutputDirectory(this.outputDirectory); - return config; - } - - public Config createConfigWithClassInputResourcePathAsContext() { - Config config = ConfigUtils.createConfig(); - config.setContext(classInputResourcePath()); - this.outputDirectory = getOutputDirectory(); - config.controller().setOutputDirectory(this.outputDirectory); - return config; - } - - public Config createConfigWithPackageInputResourcePathAsContext() { - Config config = ConfigUtils.createConfig(); - config.setContext(packageInputResourcePath()); - this.outputDirectory = getOutputDirectory(); - config.controller().setOutputDirectory(this.outputDirectory); - return config; - } - - public URL inputResourcePath() { - return getResourceNotNull("/" + getClassInputDirectory() + getMethodName() + "/."); - } - - /** - * @return class input directory as URL - */ - public URL classInputResourcePath() { - return getResourceNotNull("/" + getClassInputDirectory() + "/."); - } - - public URL packageInputResourcePath() { - return getResourceNotNull("/" + getPackageInputDirectory() + "/."); - } - - private URL getResourceNotNull(String pathString) { - URL resource = this.testClass.getResource(pathString); - if (resource == null) { - throw new UncheckedIOException(new IOException("Not found: "+pathString)); - } - return resource; - } - - public Config createConfigWithTestInputFilePathAsContext() { - try { - Config config = ConfigUtils.createConfig(); - config.setContext(new File(this.getInputDirectory()).toURI().toURL()); - this.outputDirectory = getOutputDirectory(); - config.controller().setOutputDirectory(this.outputDirectory); - return config; - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - - public Config createConfig(URL context) { - Config config = ConfigUtils.createConfig(); - config.setContext(context); - this.outputDirectory = getOutputDirectory(); - config.controller().setOutputDirectory(this.outputDirectory); - return config; - } - - - /** - * Loads a configuration from file (or the default config if configfile is null). - * - * @param configfile The path/filename of a configuration file, or null to load the default configuration. - * @return The loaded configuration. - */ - public Config loadConfig(final String configfile, final ConfigGroup... customGroups) { - Config config; - if (configfile != null) { - config = ConfigUtils.loadConfig(configfile, customGroups); - } else { - config = ConfigUtils.createConfig( customGroups ); - } - this.outputDirectory = getOutputDirectory(); - config.controller().setOutputDirectory(this.outputDirectory); - return config; - } - - public Config loadConfig(final URL configfile, final ConfigGroup... customGroups) { - Config config; - if (configfile != null) { - config = ConfigUtils.loadConfig(configfile, customGroups); - } else { - config = ConfigUtils.createConfig( customGroups ); - } - this.outputDirectory = getOutputDirectory(); - config.controller().setOutputDirectory(this.outputDirectory); - return config; - } - - public Config createConfig(final ConfigGroup... customGroups) { - Config config = ConfigUtils.createConfig( customGroups ); - this.outputDirectory = getOutputDirectory(); - config.controller().setOutputDirectory(this.outputDirectory); - return config; - } - - private void createOutputDirectory() { - if ((!this.outputDirCreated) && (this.outputDirectory != null)) { - File directory = new File(this.outputDirectory); - if (directory.exists()) { - IOUtils.deleteDirectoryRecursively(directory.toPath()); - } - this.outputDirCreated = directory.mkdirs(); - Assert.assertTrue("Could not create the output directory " + this.outputDirectory, this.outputDirCreated); - } - } - - /** - * Returns the path to the output directory for this test including a trailing slash as directory delimiter. - * - * @return path to the output directory for this test - */ - public String getOutputDirectory() { - if (this.outputDirectory == null) { - String subDirectoryForParametrisedTests = testParameterSetIndex == null ? "" : testParameterSetIndex + "/"; - this.outputDirectory = "test/output/" + this.testClass.getCanonicalName().replace('.', '/') + "/" + getMethodName()+ "/" - + subDirectoryForParametrisedTests; - } - createOutputDirectory(); - return this.outputDirectory; - } - - /** - * Returns the path to the input directory for this test including a trailing slash as directory delimiter. - * - * @return path to the input directory for this test - */ - public String getInputDirectory() { - if (this.inputDirectory == null) { - this.inputDirectory = getClassInputDirectory() + getMethodName() + "/"; - } - return this.inputDirectory; - } - /** - * Returns the path to the input directory one level above the default input directory for this test including a trailing slash as directory delimiter. - * - * @return path to the input directory for this test - */ - public String getClassInputDirectory() { - if (this.classInputDirectory == null) { - - LogManager.getLogger(this.getClass()).info( "user.dir = " + System.getProperty("user.dir") ) ; - - this.classInputDirectory = "test/input/" + - this.testClass.getCanonicalName().replace('.', '/') + "/"; -// this.classInputDirectory = System.getProperty("user.dir") + "/test/input/" + -// this.testClass.getCanonicalName().replace('.', '/') + "/"; - // (this used to be relative, i.e. ... = "test/input/" + ... . Started failing when - // this was used in tests to read a second config file when I made the path of that - // relative to the root of the initial config file. Arghh. kai, feb'18) - // yyyyyy needs to be discussed, see MATSIM-776 and MATSIM-777. kai, feb'18 - } - return this.classInputDirectory; - } - /** - * Returns the path to the input directory two levels above the default input directory for this test including a trailing slash as directory delimiter. - * - * @return path to the input directory for this test - */ - public String getPackageInputDirectory() { - if (this.packageInputDirectory == null) { - String classDirectory = getClassInputDirectory(); - this.packageInputDirectory = classDirectory.substring(0, classDirectory.lastIndexOf('/')); - this.packageInputDirectory = this.packageInputDirectory.substring(0, this.packageInputDirectory.lastIndexOf('/') + 1); - } - return this.packageInputDirectory; - } - - /** - * @return the name of the currently-running test method - */ - public String getMethodName() { - if (this.testMethodName == null) { - throw new RuntimeException("MatsimTestUtils.getMethodName() can only be used in actual test, not in constructor or elsewhere!"); - } - return this.testMethodName; - } - - /** - * Initializes MatsimTestUtils without requiring the method of a class to be a JUnit test. - * This should be used for "fixtures" only that provide a scenario common to several - * test cases. - */ - public void initWithoutJUnitForFixture(Class fixture, Method method){ - this.testClass = fixture; - this.testMethodName = method.getName(); - } - - //captures the method name (group 1) and optionally the index of the parameter set (group 2; only if the test is parametrised) - //The matching may fail if the parameter set name does not start with {index} (at least one digit is required at the beginning) - private static final Pattern METHOD_PARAMETERS_WITH_INDEX_PATTERN = Pattern.compile( - "([\\S]*)(?:\\[(\\d+)[\\s\\S]*\\])?"); - - public static void assertEqualEventsFiles( String filename1, String filename2 ) { - Assert.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL ,EventsFileComparator.compare(filename1, filename2) ); - } - - public static void assertEqualFilesBasedOnCRC( String filename1, String filename2 ) { - long checksum1 = CRCChecksum.getCRCFromFile(filename1) ; - long checksum2 = CRCChecksum.getCRCFromFile(filename2) ; - Assert.assertEquals( "different file checksums", checksum1, checksum2 ); - } - - public static void assertEqualFilesLineByLine(String inputFilename, String outputFilename) { - try (BufferedReader readerV1Input = IOUtils.getBufferedReader(inputFilename); - BufferedReader readerV1Output = IOUtils.getBufferedReader(outputFilename)) { - - String lineInput; - String lineOutput; - - while( ((lineInput = readerV1Input.readLine()) != null) && ((lineOutput = readerV1Output.readLine()) != null) ){ - if ( !Objects.equals( lineInput.trim(), lineOutput.trim() ) ){ - log.info( "Reading line... " ); - log.info( lineInput ); - log.info( lineOutput ); - log.info( "" ); - } - assertEquals( "Lines have different content: ", lineInput.trim(), lineOutput.trim() ); - } - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } -} diff --git a/matsim/src/test/java/org/matsim/testcases/MatsimTestUtils.java b/matsim/src/test/java/org/matsim/testcases/MatsimTestUtils.java index b568268cbae..8b34bea7c10 100644 --- a/matsim/src/test/java/org/matsim/testcases/MatsimTestUtils.java +++ b/matsim/src/test/java/org/matsim/testcases/MatsimTestUtils.java @@ -21,9 +21,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; -import org.junit.rules.TestWatcher; -import org.junit.runner.Description; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigGroup; import org.matsim.core.config.ConfigUtils; @@ -43,15 +44,12 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import static org.junit.Assert.assertEquals; - /** - * Some helper methods for writing JUnit 4 tests in MATSim. - * Inspired by JUnit's rule TestName + * Some helper methods for writing JUnit 5 tests in MATSim. * * @author mrieser */ -public final class MatsimTestUtils extends TestWatcher { +public final class MatsimTestUtils implements BeforeEachCallback, AfterEachCallback { private static final Logger log = LogManager.getLogger(MatsimTestUtils.class); /** @@ -59,27 +57,6 @@ public final class MatsimTestUtils extends TestWatcher { */ public static final double EPSILON = 1e-10; - public static void assertEqualFilesLineByLine(String inputFilename, String outputFilename) { - try (BufferedReader readerV1Input = IOUtils.getBufferedReader(inputFilename); - BufferedReader readerV1Output = IOUtils.getBufferedReader(outputFilename)) { - - String lineInput; - String lineOutput; - - while( ((lineInput = readerV1Input.readLine()) != null) && ((lineOutput = readerV1Output.readLine()) != null) ){ - if ( !Objects.equals( lineInput.trim(), lineOutput.trim() ) ){ - log.info( "Reading line... " ); - log.info( lineInput ); - log.info( lineOutput ); - log.info( "" ); - } - assertEquals( "Lines have different content: ", lineInput.trim(), lineOutput.trim() ); - } - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - /** The default output directory, where files of this test should be written to. * Includes the trailing '/' to denote a directory. */ private String outputDirectory = null; @@ -105,10 +82,34 @@ public static void assertEqualFilesLineByLine(String inputFilename, String outpu private String testMethodName = null; private String testParameterSetIndex = null; + //captures the method name (group 1) and optionally the index of the parameter set (group 2; only if the test is parametrised) + //The matching may fail if the parameter set name does not start with {index} (at least one digit is required at the beginning) + private static final Pattern METHOD_PARAMETERS_WITH_INDEX_PATTERN = Pattern.compile( + "([\\S]*)(?:\\[(\\d+)[\\s\\S]*\\])?"); + + public MatsimTestUtils() { MatsimRandom.reset(); } + @Override + public void beforeEach(ExtensionContext extensionContext) { + this.testClass = extensionContext.getTestClass().orElseThrow(); + + Matcher matcher = METHOD_PARAMETERS_WITH_INDEX_PATTERN.matcher(extensionContext.getTestMethod().orElseThrow().getName()); + if (!matcher.matches()) { + throw new RuntimeException("The name of the test parameter set must start with {index}"); + } + this.testMethodName = matcher.group(1); + this.testParameterSetIndex = matcher.group(2); // null for non-parametrised tests + } + + @Override + public void afterEach(ExtensionContext extensionContext) { + this.testClass = null; + this.testMethodName = null; + } + public Config createConfigWithInputResourcePathAsContext() { Config config = ConfigUtils.createConfig(); config.setContext(inputResourcePath()); @@ -221,7 +222,7 @@ private void createOutputDirectory() { IOUtils.deleteDirectoryRecursively(directory.toPath()); } this.outputDirCreated = directory.mkdirs(); - Assert.assertTrue("Could not create the output directory " + this.outputDirectory, this.outputDirCreated); + Assertions.assertTrue(this.outputDirCreated, "Could not create the output directory " + this.outputDirectory); } } @@ -306,41 +307,34 @@ public void initWithoutJUnitForFixture(Class fixture, Method method){ this.testMethodName = method.getName(); } - //captures the method name (group 1) and optionally the index of the parameter set (group 2; only if the test is parametrised) - //The matching may fail if the parameter set name does not start with {index} (at least one digit is required at the beginning) - private static final Pattern METHOD_PARAMETERS_WITH_INDEX_PATTERN = Pattern.compile( - "([\\S]*)(?:\\[(\\d+)[\\s\\S]*\\])?"); + public static void assertEqualFilesLineByLine(String inputFilename, String outputFilename) { + try (BufferedReader readerV1Input = IOUtils.getBufferedReader(inputFilename); + BufferedReader readerV1Output = IOUtils.getBufferedReader(outputFilename)) { - /* inspired by - * @see org.junit.rules.TestName#starting(org.junit.runners.model.FrameworkMethod) - */ - @Override - public void starting(Description description) { - super.starting(description); - this.testClass = description.getTestClass(); + String lineInput; + String lineOutput; - Matcher matcher = METHOD_PARAMETERS_WITH_INDEX_PATTERN.matcher(description.getMethodName()); - if (!matcher.matches()) { - throw new RuntimeException("The name of the test parameter set must start with {index}"); + while( ((lineInput = readerV1Input.readLine()) != null) && ((lineOutput = readerV1Output.readLine()) != null) ){ + if ( !Objects.equals( lineInput.trim(), lineOutput.trim() ) ){ + log.info( "Reading line... " ); + log.info( lineInput ); + log.info( lineOutput ); + log.info( "" ); + } + Assertions.assertEquals(lineInput.trim(), lineOutput.trim(), "Lines have different content: " ); + } + } catch (IOException e) { + throw new UncheckedIOException(e); } - this.testMethodName = matcher.group(1); - this.testParameterSetIndex = matcher.group(2); // null for non-parametrised tests - } - - @Override - public void finished(Description description) { - super.finished(description); - this.testClass = null; - this.testMethodName = null; } public static void assertEqualEventsFiles( String filename1, String filename2 ) { - Assert.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL ,EventsFileComparator.compare(filename1, filename2) ); + Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL ,EventsFileComparator.compare(filename1, filename2) ); } public static void assertEqualFilesBasedOnCRC( String filename1, String filename2 ) { long checksum1 = CRCChecksum.getCRCFromFile(filename1) ; long checksum2 = CRCChecksum.getCRCFromFile(filename2) ; - Assert.assertEquals( "different file checksums", checksum1, checksum2 ); + Assertions.assertEquals( checksum1, checksum2, "different file checksums" ); } } diff --git a/matsim/src/test/java/org/matsim/utils/eventsfilecomparison/EventsFileComparatorTest.java b/matsim/src/test/java/org/matsim/utils/eventsfilecomparison/EventsFileComparatorTest.java index b11f3b6128f..76c4b86140b 100644 --- a/matsim/src/test/java/org/matsim/utils/eventsfilecomparison/EventsFileComparatorTest.java +++ b/matsim/src/test/java/org/matsim/utils/eventsfilecomparison/EventsFileComparatorTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; import static org.matsim.utils.eventsfilecomparison.EventsFileComparator.Result.*; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -32,8 +32,8 @@ */ public class EventsFileComparatorTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testRetCode0() { diff --git a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/Network2ESRIShapeTest.java b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/Network2ESRIShapeTest.java index 93d111619ea..298f06bcbb0 100755 --- a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/Network2ESRIShapeTest.java +++ b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/Network2ESRIShapeTest.java @@ -23,7 +23,7 @@ import java.util.Collection; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; @@ -38,8 +38,8 @@ public class Network2ESRIShapeTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testPolygonCapacityShape() { String netFileName = "test/scenarios/equil/network.xml"; diff --git a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShapeTest.java b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShapeTest.java index 10db54d1fef..eb8441dce27 100755 --- a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShapeTest.java +++ b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShapeTest.java @@ -25,7 +25,7 @@ import java.util.zip.GZIPInputStream; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; @@ -41,8 +41,8 @@ public class SelectedPlans2ESRIShapeTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testSelectedPlansActsShape() throws IOException { diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlIOTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlIOTest.java index ce57926282c..8cbc027a81b 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlIOTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlIOTest.java @@ -24,7 +24,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; import org.xml.sax.SAXException; @@ -34,7 +34,8 @@ */ public class ObjectAttributesXmlIOTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + public MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testReadWrite() throws IOException, SAXException, ParserConfigurationException { @@ -52,7 +53,7 @@ public void testReadWrite() throws IOException, SAXException, ParserConfiguratio Assert.assertEquals(Double.valueOf(1.5), oa2.getAttribute("two", "c")); Assert.assertEquals(Boolean.TRUE, oa2.getAttribute("two", "d")); } - + @Test public void testReadWrite_CustomAttribute() { ObjectAttributes oa1 = new ObjectAttributes(); @@ -62,14 +63,14 @@ public void testReadWrite_CustomAttribute() { MyTuple.MyTupleConverter converter = new MyTuple.MyTupleConverter(); writer.putAttributeConverter(MyTuple.class, converter); writer.writeFile(this.utils.getOutputDirectory() + "oa.xml"); - + Assert.assertFalse("toString() should return something different from converter to test functionality.", t.toString().equals(converter.convertToString(t))); ObjectAttributes oa2 = new ObjectAttributes(); ObjectAttributesXmlReader reader = new ObjectAttributesXmlReader(oa2); reader.putAttributeConverter(MyTuple.class, new MyTuple.MyTupleConverter()); reader.readFile(this.utils.getOutputDirectory() + "oa.xml"); - + Object o = oa2.getAttribute("1", "A"); Assert.assertNotNull(o); Assert.assertEquals(MyTuple.class, o.getClass()); diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlReaderTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlReaderTest.java index d0c298be179..b02914eaada 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlReaderTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlReaderTest.java @@ -25,7 +25,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; import org.xml.sax.SAXException; @@ -35,7 +35,7 @@ */ public class ObjectAttributesXmlReaderTest { - @Rule public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testParse_customConverter() throws SAXException, ParserConfigurationException, IOException { diff --git a/matsim/src/test/java/org/matsim/vehicles/MatsimVehicleWriterTest.java b/matsim/src/test/java/org/matsim/vehicles/MatsimVehicleWriterTest.java index 2357c18ec49..6c0b4d9858e 100644 --- a/matsim/src/test/java/org/matsim/vehicles/MatsimVehicleWriterTest.java +++ b/matsim/src/test/java/org/matsim/vehicles/MatsimVehicleWriterTest.java @@ -29,7 +29,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.testcases.MatsimTestUtils; @@ -39,8 +39,8 @@ */ public class MatsimVehicleWriterTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final Logger log = LogManager.getLogger(MatsimVehicleWriterTest.class); diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV1Test.java b/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV1Test.java index deaecd70c10..4ff191bfbfc 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV1Test.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV1Test.java @@ -24,7 +24,7 @@ import java.util.Map; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.testcases.MatsimTestUtils; @@ -34,8 +34,8 @@ */ public class VehicleReaderV1Test { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final String TESTXML = "testVehicles_v1.xml"; diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV2Test.java b/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV2Test.java index fa989c663d1..5e2208a4a88 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV2Test.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV2Test.java @@ -24,7 +24,7 @@ import java.util.Map; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.testcases.MatsimTestUtils; @@ -34,8 +34,8 @@ */ public class VehicleReaderV2Test { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final String TESTXML2 = "testVehicles_v2.xml"; diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleWriteReadTest.java b/matsim/src/test/java/org/matsim/vehicles/VehicleWriteReadTest.java index c31cbd923c9..ea13e5dd1b4 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleWriteReadTest.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleWriteReadTest.java @@ -6,14 +6,14 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; public class VehicleWriteReadTest{ private static final Logger log = LogManager.getLogger( VehicleWriteReadTest.class ) ; - @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; private static final String TESTXML_v1 = "testVehicles_v1_withDefaultValues.xml"; diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV1Test.java b/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV1Test.java index cc87af6eacd..7625ba85319 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV1Test.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV1Test.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.testcases.MatsimTestUtils; @@ -38,8 +38,8 @@ */ public class VehicleWriterV1Test { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final Logger log = LogManager.getLogger(VehicleWriterV1Test.class); diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV2Test.java b/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV2Test.java index e4a4818a335..d7242617d79 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV2Test.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV2Test.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.testcases.MatsimTestUtils; @@ -38,8 +38,8 @@ */ public class VehicleWriterV2Test { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final Logger log = LogManager.getLogger(VehicleWriterV2Test.class); diff --git a/matsim/src/test/java/org/matsim/vis/snapshotwriters/PositionInfoTest.java b/matsim/src/test/java/org/matsim/vis/snapshotwriters/PositionInfoTest.java index dea73c1d5b7..84d11f60338 100644 --- a/matsim/src/test/java/org/matsim/vis/snapshotwriters/PositionInfoTest.java +++ b/matsim/src/test/java/org/matsim/vis/snapshotwriters/PositionInfoTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -34,8 +34,8 @@ public class PositionInfoTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); private static final double epsilon = 1e-8; // accuracy of double-comparisons diff --git a/matsim/src/test/java/org/matsim/withinday/controller/ExampleWithinDayControllerTest.java b/matsim/src/test/java/org/matsim/withinday/controller/ExampleWithinDayControllerTest.java index 01a9e44a166..4512cfea7e0 100644 --- a/matsim/src/test/java/org/matsim/withinday/controller/ExampleWithinDayControllerTest.java +++ b/matsim/src/test/java/org/matsim/withinday/controller/ExampleWithinDayControllerTest.java @@ -22,7 +22,7 @@ package org.matsim.withinday.controller; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Leg; @@ -39,8 +39,8 @@ public class ExampleWithinDayControllerTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testRun() { diff --git a/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java b/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java index a9290886cb9..c1b95aa5670 100644 --- a/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java +++ b/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -73,8 +73,8 @@ public class ExperiencedPlansWriterTest { private static final Logger log = LogManager.getLogger(ExperiencedPlansWriterTest.class); - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testWriteFile() { diff --git a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java index 4aebdd6bb91..59c2ed7e244 100644 --- a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java +++ b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java @@ -27,7 +27,7 @@ import jakarta.inject.Inject; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Activity; @@ -54,8 +54,8 @@ public class ActivityReplanningMapTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testGetTimeBin() { diff --git a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java index 7dddab430db..4f5157fb784 100644 --- a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java +++ b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java @@ -24,7 +24,7 @@ import jakarta.inject.Inject; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.groups.ControllerConfigGroup; @@ -45,8 +45,8 @@ */ public class LinkReplanningMapTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); diff --git a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/TtmobsimListener.java b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/TtmobsimListener.java index 61a87f4d6cc..7d8dab36738 100644 --- a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/TtmobsimListener.java +++ b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/TtmobsimListener.java @@ -20,7 +20,7 @@ package org.matsim.withinday.trafficmonitoring; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.network.Link; import org.matsim.core.mobsim.framework.events.MobsimAfterSimStepEvent; import org.matsim.core.mobsim.framework.listeners.MobsimAfterSimStepListener; @@ -35,22 +35,22 @@ */ public class TtmobsimListener implements MobsimAfterSimStepListener { - - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); @Inject private TravelTime travelTime; - + private boolean case1 = false; private boolean case2 = false; - + private Link link; private double networkChangeEventTime; private double reducedFreespeed; public TtmobsimListener(NetworkChangeEvent nce) { - + if (nce.getLinks().size() > 1) { throw new RuntimeException("Expecting only one network change event for a single link. Aborting..."); } else { @@ -58,22 +58,22 @@ public TtmobsimListener(NetworkChangeEvent nce) { this.link = link; this.networkChangeEventTime = nce.getStartTime(); this.reducedFreespeed = nce.getFreespeedChange().getValue(); - + Assert.assertEquals(true, this.reducedFreespeed < this.link.getFreespeed()); } - } + } } @Override public void notifyMobsimAfterSimStep(MobsimAfterSimStepEvent e) { - + if (e.getSimulationTime() <= networkChangeEventTime) { - + Assert.assertEquals("Wrong travel time at time step " + e.getSimulationTime() + ". Should be the freespeed travel time.", Math.ceil(link.getLength()/link.getFreespeed()), Math.ceil(travelTime.getLinkTravelTime(link, e.getSimulationTime(), null, null)), testUtils.EPSILON); - + case1 = true; } else { @@ -81,10 +81,10 @@ public void notifyMobsimAfterSimStep(MobsimAfterSimStepEvent e) { Math.ceil(link.getLength() / reducedFreespeed), Math.ceil(travelTime.getLinkTravelTime(link, e.getSimulationTime(), null, null)), testUtils.EPSILON); - + case2 = true; } - + } public boolean isCase1() { diff --git a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java index 8a1e15db1f4..7af481f6af8 100644 --- a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java +++ b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -55,8 +55,8 @@ */ public class WithinDayTravelTimeTest { - @Rule - public MatsimTestUtils helper = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils helper = new MatsimTestUtils(); private Link link22; private double originalFreeSpeed22; diff --git a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java index ef68744005b..25f5076e8b9 100644 --- a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java +++ b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java @@ -25,7 +25,7 @@ import java.util.Set; import org.junit.Assert; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -64,8 +64,8 @@ */ public class WithinDayTravelTimeWithNetworkChangeEventsTest { - @Rule - public MatsimTestUtils testUtils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils testUtils = new MatsimTestUtils(); private Id link01 = Id.createLinkId("link_0_1"); private Id link12 = Id.createLinkId("link_1_2"); diff --git a/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java b/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java index d6d29521b27..8c87bda545e 100644 --- a/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java +++ b/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -68,8 +68,8 @@ public class EditRoutesTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); // yyyy This test relies heavily on position counting in plans. With the introduction of intermediate walk legs the positions changed. // I tried to guess the correct indices, but it would be more honest to change this to TripStructureUtils. kai, feb'16 diff --git a/matsim/src/test/java/org/matsim/withinday/utils/ReplacePlanElementsTest.java b/matsim/src/test/java/org/matsim/withinday/utils/ReplacePlanElementsTest.java index f938263629a..23c69bdc66d 100644 --- a/matsim/src/test/java/org/matsim/withinday/utils/ReplacePlanElementsTest.java +++ b/matsim/src/test/java/org/matsim/withinday/utils/ReplacePlanElementsTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -37,8 +37,8 @@ public class ReplacePlanElementsTest { - @Rule - public MatsimTestUtils utils = new MatsimTestUtils(); + @RegisterExtension + private MatsimTestUtils utils = new MatsimTestUtils(); /** From cc1c2b59cf8a71ec54294b3150be070efa59b08e Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Mon, 11 Dec 2023 16:46:40 +0100 Subject: [PATCH 09/21] removed build failures --- .../freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java | 1 + .../src/test/java/org/matsim/modechoice/ScenarioTest.java | 2 +- .../contrib/multimodal/MultiModalControlerListenerTest.java | 1 + .../matsim/freight/carriers/analysis/RunFreightAnalysisIT.java | 1 + .../planmodification/PlanFileModifierTest.java | 1 + ...ncomeDependentUtilityOfMoneyPersonScoringParametersTest.java | 1 + 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java index 1732949b629..00d92714dc3 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java @@ -22,6 +22,7 @@ package org.matsim.freight.carriers; import org.junit.*; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.core.gbl.Gbl; import org.matsim.freight.carriers.*; diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ScenarioTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ScenarioTest.java index 4e38c743ab9..2042b6c03a0 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ScenarioTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ScenarioTest.java @@ -16,7 +16,7 @@ public class ScenarioTest { protected Injector injector; @RegisterExtension - private MatsimTestUtils utils = new MatsimTestUtils(); + public MatsimTestUtils utils = new MatsimTestUtils(); @Before public void setUp() throws Exception { diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java index e94aeb5073c..f64a3d0d57c 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java @@ -26,6 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.*; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; diff --git a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java index 54d9471758b..6ef803c9a77 100644 --- a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java +++ b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java @@ -22,6 +22,7 @@ package org.matsim.freight.carriers.analysis; import org.junit.*; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.population.Person; diff --git a/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java b/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java index 594390f486c..f8dedea8aa3 100644 --- a/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java @@ -3,6 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.*; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.*; diff --git a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java index 247e54a45e5..d94fa19d64d 100644 --- a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java @@ -1,6 +1,7 @@ package playground.vsp.scoring; import org.junit.*; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; From 429ffdf6895971fb0b15e138a67295ee14ba017d Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Mon, 11 Dec 2023 19:25:17 +0100 Subject: [PATCH 10/21] Migrate JUnit 4 @Test annotations to JUnit 5 --- .../accessibility/LeastCostPathTreeTest.java | 6 +- .../accessibility/grid/SpatialGridTest.java | 5 +- .../CompareLogsumFormulas2Test.java | 6 +- .../CompareLogsumFormulasTest.java | 5 +- .../ComputeLogsumFormulas3Test.java | 5 +- .../run/AccessibilityIntegrationTest.java | 18 +- .../accessibility/run/NetworkUtilTest.java | 4 +- .../run/TinyAccessibilityTest.java | 6 +- .../run/TinyMultimodalAccessibilityTest.java | 7 +- .../BvwpAccidentsCostComputationTest.java | 16 +- .../org/matsim/contrib/accidents/RunTest.java | 4 +- .../contrib/accidents/RunTestEquil.java | 16 +- .../PersonIntersectAreaFilterTest.java | 5 +- .../population/RouteLinkFilterTest.java | 5 +- .../kai/KNAnalysisEventsHandlerTest.java | 14 +- .../contrib/analysis/spatial/GridTest.java | 34 +- .../spatial/SpatialInterpolationTest.java | 49 +-- .../contrib/analysis/time/TimeBinMapTest.java | 45 ++- .../GoogleMapRouteValidatorTest.java | 4 +- .../HereMapsRouteValidatorTest.java | 6 +- .../RunEventsToTravelDiariesIT.java | 8 +- .../application/ApplicationUtilsTest.java | 4 +- .../matsim/application/CommandRunnerTest.java | 4 +- .../application/MATSimApplicationTest.java | 16 +- .../analysis/LogFileAnalysisTest.java | 4 +- .../application/options/CsvOptionsTest.java | 4 +- .../options/SampleOptionsTest.java | 6 +- .../application/options/ShpOptionsTest.java | 8 +- .../prepare/CreateLandUseShpTest.java | 4 +- .../prepare/ShapeFileTextLookupTest.java | 6 +- .../counts/CreateCountsFromBAStDataTest.java | 10 +- .../prepare/counts/NetworkIndexTest.java | 4 +- .../population/CloseTrajectoriesTest.java | 4 +- .../population/FixSubtourModesTest.java | 8 +- .../SplitActivityTypesDurationTest.java | 4 +- .../pt/CreateTransitScheduleFromGtfsTest.java | 4 +- .../CarrierReaderFromCSVTest.java | 6 +- .../DemandReaderFromCSVTest.java | 8 +- .../FreightDemandGenerationTest.java | 4 +- .../FreightDemandGenerationUtilsTest.java | 44 ++- .../LanduseBuildingAnalysisTest.java | 6 +- ...nerateSmallScaleCommercialTrafficTest.java | 4 +- .../SmallScaleCommercialTrafficUtilsTest.java | 4 +- .../TrafficVolumeGenerationTest.java | 17 +- .../TripDistributionMatrixTest.java | 6 +- .../contrib/av/flow/RunAvExampleIT.java | 4 +- .../contrib/av/flow/TestAvFlowFactor.java | 4 +- .../RunTaxiPTIntermodalExampleIT.java | 4 +- .../run/RunDrtAndTaxiExampleTest.java | 4 +- .../av/robotaxi/run/RunRobotaxiExampleIT.java | 4 +- .../BicycleLinkSpeedCalculatorTest.java | 34 +- .../bicycle/BicycleUtilityUtilsTest.java | 12 +- .../contrib/bicycle/run/BicycleTest.java | 28 +- .../contrib/cadyts/car/CadytsCarIT.java | 6 +- .../cadyts/car/CadytsCarWithPtScenarioIT.java | 7 +- .../utils/CalibrationStatReaderTest.java | 4 +- .../runExample/RunCarsharingIT.java | 4 +- .../ChangeCommercialJobOperatorTest.java | 6 +- .../CommercialTrafficIntegrationTest.java | 6 +- .../DefaultCommercialServiceScoreTest.java | 6 +- .../IsTheRightCustomerScoredTest.java | 6 +- ...unJointDemandCarExampleSkipIntervalIT.java | 4 +- .../examples/RunJointDemandCarExampleIT.java | 4 +- .../examples/RunJointDemandDRTExampleIT.java | 4 +- .../common/collections/PartialSortTest.java | 16 +- .../DiversityGeneratingPlansRemoverTest.java | 10 +- .../util/WeightedRandomSelectionTest.java | 12 +- .../always/BetaTravelTest66IT.java | 7 +- .../integration/always/BetaTravelTest6IT.java | 7 +- .../DecongestionPricingTestIT.java | 16 +- .../SubtourModeChoiceReplacementTest.java | 8 +- .../VehicleTourConstraintTest.java | 8 +- .../components/readers/ApolloTest.java | 4 +- .../tour_finder/ActivityTourFinderTest.java | 6 +- .../ScheduleWaitingTimeEstimatorTest.java | 12 +- .../examples/TestSiouxFalls.java | 4 +- .../models/MaximumUtilityTest.java | 4 +- .../models/MultinomialLogitTest.java | 4 +- .../models/NestedLogitTest.java | 4 +- .../models/RandomUtilityTest.java | 4 +- .../models/nested/NestCalculatorTest.java | 10 +- .../modules/config/ConfigTest.java | 8 +- .../replanning/TestDepartureTimes.java | 8 +- .../DrtWithExtensionsConfigGroupTest.java | 6 +- .../RunDrtWithCompanionExampleIT.java | 4 +- .../extension/dashboards/DashboardTests.java | 4 +- .../extension/edrt/run/RunEDrtScenarioIT.java | 8 +- .../MultiModaFixedDrtLegEstimatorTest.java | 4 +- .../MultiModalDrtLegEstimatorTest.java | 4 +- .../extension/fiss/RunFissDrtScenarioIT.java | 4 +- .../insertion/DrtInsertionExtensionIT.java | 22 +- .../eshifts/run/RunEShiftDrtScenarioIT.java | 4 +- .../OperationFacilitiesIOTest.java | 6 +- .../operations/shifts/ShiftsIOTest.java | 5 +- .../efficiency/ShiftEfficiencyTest.java | 4 +- .../run/RunMultiHubShiftDrtScenarioIT.java | 4 +- .../shifts/run/RunShiftDrtScenarioIT.java | 4 +- .../optimizer/RunPreplannedDrtExampleIT.java | 4 +- .../drt/analysis/zonal/DrtGridUtilsTest.java | 4 +- .../analysis/zonal/DrtZonalSystemTest.java | 10 +- .../RandomDrtZoneTargetLinkSelectorTest.java | 4 +- .../drt/config/ConfigBehaviorTest.java | 10 +- .../contrib/drt/fare/DrtFareHandlerTest.java | 4 +- .../DrtRequestInsertionRetryQueueTest.java | 12 +- .../VehicleDataEntryFactoryImplTest.java | 14 +- .../insertion/BestInsertionFinderTest.java | 16 +- .../CostCalculationStrategyTest.java | 14 +- .../DefaultUnplannedRequestInserterTest.java | 12 +- .../insertion/DetourTimeEstimatorTest.java | 6 +- .../insertion/DrtPoolingParameterTest.java | 22 +- .../InsertionCostCalculatorTest.java | 4 +- .../InsertionDetourTimeCalculatorTest.java | 19 +- ...imeCalculatorWithVariableDurationTest.java | 19 +- .../insertion/InsertionGeneratorTest.java | 42 +- .../extensive/DetourPathDataCacheTest.java | 15 +- .../ExtensiveInsertionProviderTest.java | 8 +- .../KNearestInsertionsAtEndFilterTest.java | 15 +- ...ultiInsertionDetourPathCalculatorTest.java | 8 +- ...ngleInsertionDetourPathCalculatorTest.java | 8 +- ...eviousIterationDrtDemandEstimatorTest.java | 14 +- ...ualVehicleDensityTargetCalculatorTest.java | 8 +- ...ToPopulationRatioTargetCalculatorTest.java | 10 +- .../drt/prebooking/AbandonAndCancelTest.java | 12 +- .../prebooking/ComplexUnschedulerTest.java | 18 +- .../prebooking/PersonStuckPrebookingTest.java | 6 +- .../drt/prebooking/PrebookingTest.java | 24 +- .../drt/routing/DrtRoutingModuleTest.java | 6 +- .../MultiModeDrtMainModeIdentifierTest.java | 4 +- .../drt/run/examples/RunDrtExampleIT.java | 21 +- .../examples/RunMultiModeDrtExampleIT.java | 4 +- .../examples/RunOneSharedTaxiExampleIT.java | 4 +- .../contrib/drt/speedup/DrtSpeedUpTest.java | 13 +- .../drt/util/DrtEventsReadersTest.java | 4 +- .../DvrpBenchmarkQSimModuleTest.java | 4 +- .../examples/onetaxi/RunOneTaxiExampleIT.java | 4 +- .../RunOneTaxiWithPrebookingExampleIT.java | 4 +- .../RunOneTaxiOneTruckExampleIT.java | 4 +- .../onetruck/RunOneTruckExampleIT.java | 4 +- .../passenger/DefaultPassengerEngineTest.java | 9 +- .../passenger/GroupPassengerEngineTest.java | 4 +- .../TeleportingPassengerEngineTest.java | 6 +- .../LeastCostPathTreeStopCriteriaTest.java | 24 +- .../path/OneToManyPathCalculatorTest.java | 24 +- .../contrib/dvrp/router/DiversionTest.java | 10 +- .../dvrp/router/RoutingTimeStructureTest.java | 6 +- .../DvrpOfflineTravelTimeEstimatorTest.java | 9 +- .../DvrpOfflineTravelTimesTest.java | 11 +- .../dvrp/util/DvrpEventsReadersTest.java | 4 +- .../dvrp/vrpagent/VrpAgentLogicTest.java | 16 +- .../random/RunRandomDynAgentExampleTest.java | 4 +- .../matsim/contrib/zone/SquareGridTest.java | 12 +- .../skims/FreeSpeedTravelTimeMatrixTest.java | 6 +- .../matsim/contrib/zone/skims/MatrixTest.java | 12 +- .../contrib/zone/skims/SparseMatrixTest.java | 9 +- .../zone/skims/TravelTimeMatricesTest.java | 8 +- .../SpeedyMultiSourceALTBackwardTest.java | 10 +- .../SpeedyMultiSourceALTForwardTest.java | 10 +- .../contrib/emissions/EmissionModuleTest.java | 63 +-- .../emissions/OsmHbefaMappingTest.java | 47 +-- .../TestColdEmissionAnalysisModule.java | 6 +- .../TestColdEmissionAnalysisModuleCase1.java | 4 +- .../TestColdEmissionAnalysisModuleCase2.java | 4 +- .../TestColdEmissionAnalysisModuleCase3.java | 4 +- .../TestColdEmissionAnalysisModuleCase4.java | 6 +- .../TestColdEmissionAnalysisModuleCase6.java | 6 +- .../TestColdEmissionsFallbackBehaviour.java | 64 ++-- .../TestHbefaColdEmissionFactorKey.java | 16 +- .../emissions/TestHbefaVehicleAttributes.java | 16 +- .../TestHbefaWarmEmissionFactorKey.java | 28 +- .../emissions/TestPositionEmissionModule.java | 12 +- .../TestWarmEmissionAnalysisModule.java | 15 +- .../TestWarmEmissionAnalysisModuleCase1.java | 21 +- .../TestWarmEmissionAnalysisModuleCase2.java | 6 +- .../TestWarmEmissionAnalysisModuleCase3.java | 6 +- .../TestWarmEmissionAnalysisModuleCase4.java | 6 +- .../TestWarmEmissionAnalysisModuleCase5.java | 4 +- .../TestWarmEmissionsFallbackBehaviour.java | 54 +-- .../VspHbefaRoadTypeMappingTest.java | 6 +- .../analysis/EmissionGridAnalyzerTest.java | 61 +-- .../analysis/EmissionsByPollutantTest.java | 26 +- .../EmissionsOnLinkEventHandlerTest.java | 22 +- .../FastEmissionGridAnalyzerTest.java | 26 +- .../emissions/analysis/RasterTest.java | 20 +- .../analysis/RawEmissionEventsReaderTest.java | 18 +- .../events/TestColdEmissionEventImpl.java | 8 +- .../events/TestWarmEmissionEventImpl.java | 6 +- .../events/VehicleLeavesTrafficEventTest.java | 6 +- ...unAverageEmissionToolOfflineExampleIT.java | 10 +- ...nDetailedEmissionToolOfflineExampleIT.java | 14 +- ...EmissionToolOnlineExampleIT_vehTypeV1.java | 4 +- ...eExampleIT_vehTypeV1FallbackToAverage.java | 4 +- ...EmissionToolOnlineExampleIT_vehTypeV2.java | 4 +- ...eExampleIT_vehTypeV2FallbackToAverage.java | 4 +- .../emissions/utils/EmissionUtilsTest.java | 46 ++- .../ev/charging/FastThenSlowChargingTest.java | 16 +- .../charging/VariableSpeedChargingTest.java | 4 +- ...nEvExampleWithLTHConsumptionModelTest.java | 5 +- ...emperatureChangeModuleIntegrationTest.java | 4 +- .../carriers/CarrierEventsReadersTest.java | 12 +- .../freight/carriers/CarrierModuleTest.java | 12 +- .../carriers/CarrierPlanReaderV1Test.java | 10 +- .../carriers/CarrierPlanXmlReaderV2Test.java | 32 +- .../CarrierPlanXmlReaderV2WithDtdTest.java | 56 +-- .../carriers/CarrierPlanXmlWriterV1Test.java | 4 +- .../carriers/CarrierPlanXmlWriterV2Test.java | 28 +- .../CarrierPlanXmlWriterV2_1Test.java | 37 +- .../carriers/CarrierReadWriteV2_1Test.java | 6 +- .../CarrierVehicleTypeLoaderTest.java | 6 +- .../CarrierVehicleTypeReaderTest.java | 18 +- .../carriers/CarrierVehicleTypeTest.java | 32 +- .../CarrierVehicleTypeWriterTest.java | 4 +- .../freight/carriers/CarriersUtilsTest.java | 10 +- .../FreightCarriersConfigGroupTest.java | 6 +- .../EquilWithCarrierWithPersonsIT.java | 4 +- .../EquilWithCarrierWithoutPersonsIT.java | 66 ++-- ...istanceConstraintFromVehiclesFileTest.java | 10 +- .../jsprit/DistanceConstraintTest.java | 14 +- .../carriers/jsprit/FixedCostsTest.java | 8 +- .../carriers/jsprit/IntegrationIT.java | 4 +- .../jsprit/MatsimTransformerTest.java | 48 +-- .../NetworkBasedTransportCostsTest.java | 8 +- .../freight/carriers/jsprit/SkillsIT.java | 6 +- .../usecases/chessboard/RunChessboardIT.java | 4 +- .../RunPassengerAlongWithCarriersIT.java | 6 +- .../utils/CarrierControlerUtilsIT.java | 12 +- .../utils/CarrierControlerUtilsTest.java | 92 +++-- .../ReceiverCostAllocationFixedTest.java | 4 +- .../freightreceiver/ReceiverPlanTest.java | 5 +- .../freightreceiver/ReceiversReaderTest.java | 6 +- .../freightreceiver/ReceiversTest.java | 42 +- .../freightreceiver/ReceiversWriterTest.java | 6 +- .../freightreceiver/SSReorderPolicyTest.java | 4 +- .../hybridsim/utils/IdIntMapperTest.java | 26 +- .../matsim/modechoice/EstimateRouterTest.java | 4 +- .../ModeChoiceWeightSchedulerTest.java | 6 +- .../commands/GenerateChoiceSetTest.java | 4 +- ...RelaxedMassConservationConstraintTest.java | 8 +- .../RelaxedSubtourConstraintTest.java | 8 +- .../estimators/ComplexEstimatorTest.java | 4 +- .../DefaultActivityEstimatorTest.java | 4 +- .../MultinomialLogitSelectorTest.java | 18 +- .../RandomSubtourModeStrategyTest.java | 4 +- .../SelectSingleTripModeStrategyTest.java | 6 +- .../SelectSubtourModeStrategyTest.java | 8 +- .../search/BestChoiceGeneratorTest.java | 4 +- .../modechoice/search/DifferentModesTest.java | 4 +- .../search/ModeChoiceSearchTest.java | 8 +- .../SingleTripChoicesGeneratorTest.java | 8 +- .../search/TopKChoicesGeneratorTest.java | 12 +- .../modechoice/search/TopKMinMaxTest.java | 6 +- .../search/TopKSubtourGeneratorTest.java | 4 +- .../integration/daily/SomeDailyTest.java | 4 +- .../integration/weekly/SomeWeeklyTest.java | 4 +- .../CreateAutomatedFDTest.java | 10 +- ...stReplyLocationChoicePlanStrategyTest.java | 5 +- .../locationchoice/LocationChoiceIT.java | 7 +- .../frozenepsilons/BestReplyIT.java | 4 +- .../frozenepsilons/FacilityPenaltyTest.java | 8 +- .../FrozenEpsilonLocaChoiceIT.java | 9 +- .../frozenepsilons/SamplerTest.java | 6 +- .../frozenepsilons/ScoringPenaltyTest.java | 4 +- .../LocationMutatorwChoiceSetTest.java | 11 +- .../timegeography/ManageSubchainsTest.java | 5 +- .../RandomLocationMutatorTest.java | 5 +- .../timegeography/SubChainTest.java | 5 +- .../router/BackwardFastMultiNodeTest.java | 8 +- .../matsim/core/router/FastMultiNodeTest.java | 8 +- .../core/router/MultiNodeDijkstraTest.java | 28 +- .../MatrixBasedPtRouterIT.java | 4 +- .../matrixbasedptrouter/PtMatrixTest.java | 6 +- .../matrixbasedptrouter/TestQuadTree.java | 5 +- .../genericUtils/TerminusStopFinderTest.java | 7 +- .../minibus/integration/PControlerTestIT.java | 4 +- .../integration/SubsidyContextTestIT.java | 6 +- .../minibus/integration/SubsidyTestIT.java | 4 +- .../replanning/EndRouteExtensionTest.java | 6 +- .../MaxRandomEndTimeAllocatorTest.java | 4 +- .../MaxRandomStartTimeAllocatorTest.java | 4 +- .../SidewaysRouteExtensionTest.java | 4 +- .../minibus/replanning/TimeProviderTest.java | 8 +- .../WeightedEndTimeExtensionTest.java | 4 +- .../WeightedStartTimeExtensionTest.java | 4 +- .../ComplexCircleScheduleProviderTest.java | 10 +- .../SimpleCircleScheduleProviderTest.java | 8 +- ...tionApproachesAndBetweenJunctionsTest.java | 6 +- .../CreateStopsForAllCarLinksTest.java | 4 +- ...eaBtwLinksVsTerminiBeelinePenaltyTest.java | 6 +- .../RouteDesignScoringManagerTest.java | 6 +- .../StopServedMultipleTimesPenaltyTest.java | 6 +- .../RecursiveStatsApproxContainerTest.java | 4 +- .../stats/RecursiveStatsContainerTest.java | 4 +- .../MultiModalControlerListenerTest.java | 16 +- .../multimodal/MultiModalTripRouterTest.java | 4 +- .../multimodal/RunMultimodalExampleTest.java | 4 +- .../pt/MultiModalPTCombinationTest.java | 4 +- .../router/util/BikeTravelTimeTest.java | 8 +- .../router/util/WalkTravelTimeTest.java | 8 +- .../multimodal/simengine/StuckAgentTest.java | 4 +- .../contrib/noise/NoiseConfigGroupIT.java | 24 +- .../org/matsim/contrib/noise/NoiseIT.java | 19 +- .../contrib/noise/NoiseOnlineExampleIT.java | 8 +- .../matsim/contrib/noise/NoiseRLS19IT.java | 12 +- .../osm/networkReader/LinkPropertiesTest.java | 30 +- .../osm/networkReader/OsmBicycleReaderIT.java | 4 +- .../networkReader/OsmBicycleReaderTest.java | 18 +- .../networkReader/OsmNetworkParserTest.java | 10 +- .../networkReader/OsmSignalsParserTest.java | 14 +- .../SupersonicOsmNetworkReaderIT.java | 4 +- .../SupersonicOsmNetworkReaderTest.java | 44 +-- ...SupersonicOsmNetworkReaderBuilderTest.java | 4 +- .../org/matsim/contrib/otfvis/OTFVisIT.java | 6 +- .../contrib/parking/lib/GeneralLibTest.java | 8 +- .../lib/obj/DoubleValueHashMapTest.java | 5 +- .../lib/obj/LinkedListValueHashMapTest.java | 11 +- .../ParkingCostVehicleTrackerTest.java | 4 +- .../RideParkingCostTrackerTest.java | 4 +- .../RunParkingCostsExampleTest.java | 4 +- .../run/RunWithParkingProxyIT.java | 8 +- .../run/RunParkingChoiceExampleIT.java | 4 +- .../run/RunParkingSearchScenarioIT.java | 10 +- .../contrib/protobuf/EventWriterPBTest.java | 14 +- .../contrib/pseudosimulation/RunPSimTest.java | 6 +- .../integration/RailsimIntegrationTest.java | 48 +-- .../railsim/qsimengine/RailsimCalcTest.java | 14 +- .../railsim/qsimengine/RailsimEngineTest.java | 18 +- .../roadpricing/AvoidTolledRouteTest.java | 16 +- .../contrib/roadpricing/CalcPaidTollTest.java | 8 +- .../contrib/roadpricing/ModuleTest.java | 36 +- .../PlansCalcRouteWithTollOrNotTest.java | 10 +- .../RoadPricingConfigGroupTest.java | 10 +- .../roadpricing/RoadPricingControlerIT.java | 4 +- .../roadpricing/RoadPricingIOTest.java | 5 +- .../TollTravelCostCalculatorTest.java | 11 +- .../run/RoadPricingByConfigfileTest.java | 4 +- .../run/RunRoadPricingExampleIT.java | 4 +- .../run/RunRoadPricingFromCodeIT.java | 4 +- ...unRoadPricingUsingTollFactorExampleIT.java | 4 +- .../analysis/skims/FloatMatrixIOTest.java | 6 +- .../analysis/skims/RooftopUtilsTest.java | 70 ++-- .../config/SBBTransitConfigGroupTest.java | 6 +- .../matsim/mobsim/qsim/SBBQSimModuleTest.java | 8 +- .../SBBTransitQSimEngineIntegrationTest.java | 10 +- .../qsim/pt/SBBTransitQSimEngineTest.java | 76 ++-- .../matsim/contrib/shared_mobility/RunIT.java | 4 +- .../AdaptiveSignalsExampleTest.java | 4 +- .../CreateIntergreensExampleTest.java | 16 +- .../CreateSignalInputExampleTest.java | 16 +- ...CreateSignalInputExampleWithLanesTest.java | 16 +- .../RunSignalSystemsExampleTest.java | 6 +- ...sualizeSignalScenarioWithLanesGUITest.java | 10 +- .../FixResponsiveSignalResultsIT.java | 18 +- .../io/MatsimFileTypeGuesserSignalsTest.java | 12 +- .../contrib/signals/CalculateAngleTest.java | 38 +- .../contrib/signals/SignalUtilsTest.java | 19 +- .../analysis/DelayAnalysisToolTest.java | 6 +- .../signals/builder/QSimSignalTest.java | 70 ++-- .../builder/TravelTimeFourWaysTest.java | 6 +- .../builder/TravelTimeOneWayTestIT.java | 10 +- ...aultPlanbasedSignalSystemControllerIT.java | 40 +- .../controller/laemmerFix/LaemmerIT.java | 18 +- .../signals/controller/sylvia/SylviaIT.java | 8 +- .../v10/AmberTimesData10ReaderWriterTest.java | 6 +- .../SignalConflictDataReaderWriterTest.java | 4 +- .../UnprotectedLeftTurnLogicTest.java | 4 +- ...IntergreenTimesData10ReaderWriterTest.java | 6 +- .../SignalControlData20ReaderWriterTest.java | 8 +- .../v20/SignalGroups20ReaderWriterTest.java | 6 +- .../SignalSystemsData20ReaderWriterTest.java | 11 +- .../signals/integration/SignalSystemsIT.java | 6 +- .../InvertedNetworksSignalsIT.java | 6 +- .../SignalsAndLanesOsmNetworkReaderTest.java | 19 +- .../signals/oneagent/ControlerTest.java | 5 +- .../signals/sensor/LaneSensorTest.java | 20 +- .../signals/sensor/LinkSensorTest.java | 30 +- .../DefaultAnnealingAcceptorTest.java | 4 +- .../SimulatedAnnealingConfigGroupTest.java | 6 +- .../SimulatedAnnealingIT.java | 4 +- .../SimulatedAnnealingTest.java | 4 +- .../simwrapper/SimWrapperConfigGroupTest.java | 4 +- .../simwrapper/SimWrapperModuleTest.java | 4 +- .../org/matsim/simwrapper/SimWrapperTest.java | 4 +- .../simwrapper/dashboard/DashboardTests.java | 14 +- .../dashboard/EmissionsDashboardTest.java | 4 +- .../dashboard/TrafficCountsDashboardTest.java | 4 +- .../simwrapper/viz/PlotlyExamplesTest.java | 12 +- .../org/matsim/simwrapper/viz/PlotlyTest.java | 8 +- .../framework/events/CourtesyEventsTest.java | 12 +- .../population/JointPlanFactoryTest.java | 6 +- .../framework/population/JointPlanIOTest.java | 6 +- .../framework/population/JointPlansTest.java | 18 +- .../population/SocialNetworkIOTest.java | 6 +- .../population/SocialNetworkTest.java | 20 +- .../grouping/DynamicGroupIdentifierTest.java | 10 +- .../replanning/grouping/FixedGroupsIT.java | 4 +- .../replanning/grouping/GroupPlansTest.java | 8 +- .../ActivitySequenceMutatorAlgorithmTest.java | 10 +- .../replanning/modules/MergingTest.java | 6 +- .../modules/TourModeUnifierAlgorithmTest.java | 8 +- .../removers/LexicographicRemoverTest.java | 8 +- .../FullExplorationVsCuttoffTest.java | 10 +- .../selectors/HighestWeightSelectorTest.java | 10 +- .../selectors/RandomSelectorsTest.java | 9 +- .../CoalitionSelectorTest.java | 4 +- ...ghtJointPlanPruningConflictSolverTest.java | 4 +- ...tPointedPlanPruningConflictSolverTest.java | 5 +- .../WhoIsTheBossSelectorTest.java | 8 +- .../GroupCompositionPenalizerTest.java | 14 +- .../RecomposeJointPlanAlgorithmTest.java | 10 +- .../RandomJointLocationChoiceTest.java | 6 +- .../jointtrips/JointTravelUtilsTest.java | 6 +- ...intTravelingSimulationIntegrationTest.java | 26 +- ...InsertionRemovalIgnoranceBehaviorTest.java | 6 +- .../InsertionRemovalIterativeActionTest.java | 10 +- ...intTripInsertionWithSocialNetworkTest.java | 4 +- .../JointTripRemoverAlgorithmTest.java | 4 +- ...nchronizeCoTravelerPlansAlgorithmTest.java | 4 +- .../router/JointPlanRouterTest.java | 6 +- .../router/JointTripRouterFactoryTest.java | 6 +- .../HouseholdBasedVehicleRessourcesTest.java | 4 +- .../PlanRouterWithVehicleRessourcesTest.java | 4 +- ...PopulationAgentSourceWithVehiclesTest.java | 8 +- ...ehicleToPlansInGroupPlanAlgorithmTest.java | 10 +- ...imizeVehicleAllocationAtTourLevelTest.java | 8 +- .../replanning/GroupPlanStrategyTest.java | 10 +- ...nableActivitiesPlanLinkIdentifierTest.java | 24 +- .../VehicularPlanLinkIdentifierTest.java | 8 +- .../utils/JointScenarioUtilsTest.java | 4 +- .../socnetsim/utils/ObjectPoolTest.java | 6 +- .../utils/QuadTreeRebuilderTest.java | 4 +- .../sumo/SumoNetworkConverterTest.java | 6 +- .../contrib/sumo/SumoNetworkHandlerTest.java | 6 +- .../etaxi/run/RunETaxiBenchmarkTest.java | 4 +- .../contrib/etaxi/run/RunETaxiScenarioIT.java | 8 +- .../taxi/benchmark/RunTaxiBenchmarkTest.java | 4 +- .../assignment/AssignmentTaxiOptimizerIT.java | 10 +- .../optimizer/fifo/FifoTaxiOptimizerIT.java | 4 +- .../rules/RuleBasedTaxiOptimizerIT.java | 8 +- .../optimizer/zonal/ZonalTaxiOptimizerIT.java | 6 +- .../contrib/taxi/run/RunTaxiScenarioTest.java | 4 +- .../taxi/run/RunTaxiScenarioTestIT.java | 6 +- .../RunMultiModeTaxiExampleTestIT.java | 4 +- .../run/examples/RunTaxiExampleTestIT.java | 4 +- .../taxi/util/TaxiEventsReadersTest.java | 4 +- .../taxi/util/stats/DurationStatsTest.java | 8 +- .../taxi/util/stats/TimeBinSamplesTest.java | 10 +- ...oringParametersFromPersonAttributesIT.java | 8 +- ...omPersonAttributesNoSubpopulationTest.java | 16 +- ...ingParametersFromPersonAttributesTest.java | 20 +- .../FreightAnalysisEventBasedTest.java | 4 +- .../analysis/RunFreightAnalysisIT.java | 10 +- .../RunFreightAnalysisWithShipmentTest.java | 6 +- .../drtAndPt/PtAlongALine2Test.java | 11 +- .../drtAndPt/PtAlongALineTest.java | 10 +- .../EmissionCostFactorsTest.java | 17 +- .../emissions/TestColdEmissionHandler.java | 4 +- .../emissions/TestWarmEmissionHandler.java | 4 +- ...entId2DepartureDelayAtStopMapDataTest.java | 7 +- .../AgentId2DepartureDelayAtStopMapTest.java | 4 +- ...tId2EnterLeaveVehicleEventHandlerTest.java | 13 +- .../AgentId2PtTripTravelTimeMapDataTest.java | 4 +- .../AgentId2PtTripTravelTimeMapTest.java | 5 +- .../level1/StopId2LineId2PulkDataTest.java | 6 +- .../bvgAna/level1/StopId2LineId2PulkTest.java | 7 +- .../StopId2RouteId2DelayAtStopMapTest.java | 4 +- .../level1/VehId2DelayAtStopMapDataTest.java | 4 +- .../level1/VehId2DelayAtStopMapTest.java | 4 +- .../level1/VehId2OccupancyHandlerTest.java | 5 +- .../VehId2PersonEnterLeaveVehicleMapTest.java | 4 +- .../osmBB/PTCountsNetworkSimplifierTest.java | 20 +- .../ModalDistanceAndCountsCadytsIT.java | 5 +- ...odalDistanceCadytsMultipleDistancesIT.java | 5 +- .../ModalDistanceCadytsSingleDistanceIT.java | 17 +- .../marginals/TripEventHandlerTest.java | 4 +- .../AdvancedMarginalCongestionPricingIT.java | 16 +- .../CombinedFlowAndStorageDelayTest.java | 4 +- .../vsp/congestion/CorridorNetworkTest.java | 6 +- ...nalCongestionHandlerFlowQueueQsimTest.java | 8 +- ...tionHandlerFlowSpillbackQueueQsimTest.java | 36 +- .../MarginalCongestionHandlerV3Test.java | 4 +- .../MarginalCongestionPricingTest.java | 4 +- .../MultipleSpillbackCausingLinksTest.java | 4 +- .../vsp/congestion/TestForEmergenceTime.java | 4 +- .../ev/TransferFinalSocToNextIterTest.java | 4 +- .../java/playground/vsp/ev/UrbanEVIT.java | 5 +- .../java/playground/vsp/ev/UrbanEVTests.java | 26 +- ...rarchicalFLowEfficiencyCalculatorTest.java | 4 +- .../cemdap/input/SynPopCreatorTest.java | 4 +- .../PlanFileModifierTest.java | 52 +-- .../vsp/pt/fare/PtTripFareEstimatorTest.java | 8 +- .../vsp/pt/ptdisturbances/EditTripsTest.java | 19 +- .../TransitRouteTrimmerTest.java | 360 +++++++++--------- ...nScoringParametersNoSubpopulationTest.java | 14 +- ...ityOfMoneyPersonScoringParametersTest.java | 20 +- .../vsp/zzArchive/bvwpOld/BvwpTest.java | 6 +- .../SwissRailRaptorConfigGroupTest.java | 22 +- .../raptor/CapacityDependentScoringTest.java | 4 +- .../pt/raptor/OccupancyTrackerTest.java | 6 +- .../pt/raptor/RaptorStopFinderTest.java | 134 ++++--- .../routing/pt/raptor/RaptorUtilsTest.java | 6 +- .../raptor/SwissRailRaptorCapacitiesTest.java | 4 +- .../pt/raptor/SwissRailRaptorDataTest.java | 6 +- .../SwissRailRaptorInVehicleCostTest.java | 14 +- .../raptor/SwissRailRaptorIntermodalTest.java | 150 ++++---- .../pt/raptor/SwissRailRaptorModuleTest.java | 30 +- .../pt/raptor/SwissRailRaptorTest.java | 165 ++++---- .../pt/raptor/SwissRailRaptorTreeTest.java | 34 +- .../analysis/CalcAverageTripLengthTest.java | 17 +- .../org/matsim/analysis/CalcLegTimesTest.java | 8 +- .../matsim/analysis/CalcLinkStatsTest.java | 8 +- ...ationTravelStatsControlerListenerTest.java | 4 +- .../org/matsim/analysis/LegHistogramTest.java | 11 +- .../LinkStatsControlerListenerTest.java | 10 +- ...deChoiceCoverageControlerListenerTest.java | 14 +- .../ModeStatsControlerListenerTest.java | 4 +- .../analysis/OutputTravelStatsTest.java | 4 +- .../analysis/PHbyModeCalculatorTest.java | 16 +- .../analysis/PKMbyModeCalculatorTest.java | 4 +- .../ScoreStatsControlerListenerTest.java | 4 +- ...ansportPlanningMainModeIdentifierTest.java | 16 +- .../analysis/TravelDistanceStatsTest.java | 4 +- .../org/matsim/analysis/TripsAnalysisIT.java | 4 +- .../analysis/TripsAndLegsCSVWriterTest.java | 4 +- .../matsim/analysis/VolumesAnalyzerTest.java | 16 +- .../LinkPaxVolumesAnalysisTest.java | 12 +- .../PersonMoneyEventAggregatorTest.java | 4 +- .../pt/stop2stop/PtStop2StopAnalysisTest.java | 16 +- .../org/matsim/api/core/v01/CoordTest.java | 16 +- .../api/core/v01/DemandGenerationTest.java | 5 +- .../api/core/v01/IdAnnotationsTest.java | 10 +- .../matsim/api/core/v01/IdCollectorsTest.java | 10 +- .../core/v01/IdDeSerializationModuleTest.java | 6 +- .../org/matsim/api/core/v01/IdMapTest.java | 32 +- .../org/matsim/api/core/v01/IdSetTest.java | 20 +- .../java/org/matsim/api/core/v01/IdTest.java | 44 +-- .../api/core/v01/NetworkCreationTest.java | 5 +- .../core/v01/network/AbstractNetworkTest.java | 6 +- .../matsim/core/config/CommandLineTest.java | 61 +-- .../core/config/ConfigReaderMatsimV2Test.java | 22 +- .../org/matsim/core/config/ConfigTest.java | 6 +- .../core/config/MaterializeConfigTest.java | 4 +- .../config/ReflectiveConfigGroupTest.java | 46 +-- .../java/org/matsim/core/config/URLTest.java | 8 +- ...alidationConfigConsistencyCheckerTest.java | 12 +- .../ConfigConsistencyCheckerImplTest.java | 16 +- .../groups/ControllerConfigGroupTest.java | 12 +- .../config/groups/CountsConfigGroupTest.java | 14 +- .../groups/LinkStatsConfigGroupTest.java | 14 +- .../groups/ReplanningConfigGroupTest.java | 8 +- .../config/groups/RoutingConfigGroupTest.java | 77 ++-- .../config/groups/ScoringConfigGroupTest.java | 21 +- .../SubtourModeChoiceConfigGroupTest.java | 8 +- .../VspExperimentalConfigGroupTest.java | 5 +- .../core/controler/AbstractModuleTest.java | 4 +- .../core/controler/ControlerEventsTest.java | 8 +- .../matsim/core/controler/ControlerIT.java | 121 +++--- .../ControlerListenerManagerImplTest.java | 12 +- .../ControlerMobsimIntegrationTest.java | 30 +- .../controler/MatsimServicesImplTest.java | 10 +- .../core/controler/MobsimListenerTest.java | 45 ++- .../core/controler/NewControlerTest.java | 8 +- .../OutputDirectoryHierarchyTest.java | 8 +- .../core/controler/PrepareForSimImplTest.java | 16 +- .../core/controler/TerminationTest.java | 14 +- .../TransitControlerIntegrationTest.java | 5 +- .../corelisteners/ListenersInjectionTest.java | 12 +- .../corelisteners/PlansDumpingIT.java | 8 +- .../matsim/core/events/ActEndEventTest.java | 5 +- .../matsim/core/events/ActStartEventTest.java | 5 +- .../core/events/AgentMoneyEventTest.java | 5 +- .../events/AgentWaitingForPtEventTest.java | 4 +- .../core/events/BasicEventsHandlerTest.java | 5 +- .../matsim/core/events/CustomEventTest.java | 6 +- .../events/EventsHandlerHierarchyTest.java | 8 +- .../core/events/EventsManagerImplTest.java | 6 +- .../matsim/core/events/EventsReadersTest.java | 8 +- .../matsim/core/events/GenericEventTest.java | 5 +- .../core/events/LinkEnterEventTest.java | 5 +- .../core/events/LinkLeaveEventTest.java | 5 +- .../events/MobsimScopeEventHandlingTest.java | 8 +- .../events/ParallelEventsManagerTest.java | 10 +- .../core/events/PersonArrivalEventTest.java | 5 +- .../core/events/PersonDepartureEventTest.java | 5 +- .../events/PersonEntersVehicleEventTest.java | 5 +- .../events/PersonLeavesVehicleEventTest.java | 5 +- .../core/events/PersonStuckEventTest.java | 8 +- .../SimStepParallelEventsManagerImplTest.java | 8 +- .../events/TransitDriverStartsEventTest.java | 4 +- .../core/events/VehicleAbortsEventTest.java | 5 +- ...VehicleArrivesAtFacilityEventImplTest.java | 5 +- ...VehicleDepartsAtFacilityEventImplTest.java | 5 +- .../events/VehicleEntersTrafficEventTest.java | 5 +- .../events/VehicleLeavesTrafficEventTest.java | 5 +- .../algorithms/EventWriterJsonTest.java | 6 +- .../events/algorithms/EventWriterXMLTest.java | 6 +- .../org/matsim/core/gbl/MatsimRandomTest.java | 17 +- .../matsim/core/gbl/MatsimResourceTest.java | 5 +- .../core/mobsim/AbstractMobsimModuleTest.java | 8 +- .../matsim/core/mobsim/hermes/AgentTest.java | 24 +- .../core/mobsim/hermes/FlowCapacityTest.java | 14 +- .../mobsim/hermes/HermesRoundaboutTest.java | 5 +- .../matsim/core/mobsim/hermes/HermesTest.java | 32 +- .../core/mobsim/hermes/HermesTransitTest.java | 20 +- .../mobsim/hermes/StorageCapacityTest.java | 12 +- .../core/mobsim/hermes/TravelTimeTest.java | 10 +- .../mobsim/jdeqsim/ConfigParameterTest.java | 5 +- .../core/mobsim/jdeqsim/EmptyCarLegTest.java | 18 +- .../core/mobsim/jdeqsim/EquilPlans1Test.java | 18 +- .../core/mobsim/jdeqsim/NonCarLegTest.java | 18 +- .../mobsim/jdeqsim/TestDESStarter_Berlin.java | 20 +- ...tarter_EquilPopulationPlans1Modified1.java | 18 +- .../jdeqsim/TestDESStarter_equilPlans100.java | 18 +- .../core/mobsim/jdeqsim/TestEventLog.java | 8 +- .../mobsim/jdeqsim/TestMessageFactory.java | 29 +- .../core/mobsim/jdeqsim/TestMessageQueue.java | 29 +- .../core/mobsim/jdeqsim/TestScheduler.java | 42 +- .../mobsim/jdeqsim/util/TestEventLibrary.java | 10 +- .../mobsim/qsim/AbstractQSimModuleTest.java | 20 +- .../mobsim/qsim/AgentNotificationTest.java | 10 +- .../mobsim/qsim/FlowStorageSpillbackTest.java | 4 +- .../qsim/MobsimListenerManagerTest.java | 6 +- .../qsim/NetsimRoutingConsistencyTest.java | 128 +++---- .../core/mobsim/qsim/NodeTransitionTest.java | 16 +- .../qsim/QSimEventsIntegrationTest.java | 8 +- .../org/matsim/core/mobsim/qsim/QSimTest.java | 62 +-- ...TeleportationEngineWDistanceCheckTest.java | 4 +- .../mobsim/qsim/TransitQueueNetworkTest.java | 151 ++++---- .../core/mobsim/qsim/TravelTimeTest.java | 12 +- .../core/mobsim/qsim/VehicleSourceTest.java | 4 +- .../NetworkChangeEventsEngineTest.java | 16 +- .../qsim/components/QSimComponentsTest.java | 135 +++---- .../guice/ExplicitBindingsRequiredTest.java | 9 +- .../guice/MultipleBindingsTest.java | 9 +- .../qsim/jdeqsimengine/JDEQSimPluginTest.java | 10 +- .../mobsim/qsim/pt/QSimIntegrationTest.java | 12 +- .../core/mobsim/qsim/pt/TransitAgentTest.java | 8 +- .../mobsim/qsim/pt/TransitDriverTest.java | 20 +- .../qsim/pt/TransitQueueSimulationTest.java | 187 ++++----- .../qsim/pt/TransitStopAgentTrackerTest.java | 11 +- .../mobsim/qsim/pt/TransitVehicleTest.java | 20 +- .../core/mobsim/qsim/pt/UmlaufDriverTest.java | 29 +- .../DeparturesOnSameLinkSameTimeTest.java | 4 +- .../EquiDistAgentSnapshotInfoBuilderTest.java | 10 +- .../FlowCapacityVariationTest.java | 16 +- .../FlowEfficiencyCalculatorTest.java | 4 +- .../JavaRoundingErrorInQsimTest.java | 8 +- .../LinkSpeedCalculatorIntegrationTest.java | 8 +- .../qsim/qnetsimengine/PassingTest.java | 4 +- .../qsim/qnetsimengine/QLinkLanesTest.java | 15 +- .../mobsim/qsim/qnetsimengine/QLinkTest.java | 26 +- .../qnetsimengine/QSimComponentsTest.java | 96 ++--- .../QueueAgentSnapshotInfoBuilderTest.java | 26 +- ...onfigurableQNetworkFactoryExampleTest.java | 4 +- .../qsim/qnetsimengine/SeepageTest.java | 8 +- .../SimulatedLaneFlowCapacityTest.java | 14 +- .../qnetsimengine/SpeedCalculatorTest.java | 17 +- .../qnetsimengine/VehVsLinkSpeedTest.java | 8 +- .../qnetsimengine/VehicleHandlerTest.java | 4 +- .../qnetsimengine/VehicleWaitingTest.java | 10 +- .../AbstractNetworkWriterReaderTest.java | 29 +- .../core/network/DisallowedNextLinksTest.java | 22 +- .../network/DisallowedNextLinksUtilsTest.java | 10 +- .../org/matsim/core/network/LinkImplTest.java | 18 +- .../matsim/core/network/LinkQuadTreeTest.java | 36 +- .../NetworkChangeEventsParserWriterTest.java | 40 +- .../core/network/NetworkCollectorTest.java | 14 +- .../matsim/core/network/NetworkImplTest.java | 28 +- .../matsim/core/network/NetworkUtilsTest.java | 14 +- .../matsim/core/network/NetworkV2IOTest.java | 24 +- .../matsim/core/network/ReadFromURLIT.java | 4 +- .../core/network/TimeVariantLinkImplTest.java | 20 +- .../TravelTimeCalculatorIntegrationTest.java | 8 +- .../algorithms/CalcBoundingBoxTest.java | 7 +- .../MultimodalNetworkCleanerTest.java | 45 ++- .../algorithms/NetworkCleanerTest.java | 14 +- .../algorithms/NetworkExpandNodeTest.java | 17 +- .../NetworkMergeDoubleLinksTest.java | 9 +- .../NetworkSimplifierPass2WayTest.java | 7 +- .../algorithms/NetworkSimplifierTest.java | 12 +- .../TransportModeNetworkFilterTest.java | 21 +- .../DensityClusterTest.java | 8 +- .../HullConverterTest.java | 12 +- .../IntersectionSimplifierTest.java | 16 +- .../containers/ConcaveHullTest.java | 4 +- .../filter/NetworkFilterManagerTest.java | 4 +- .../io/NetworkAttributeConversionTest.java | 12 +- .../network/io/NetworkReaderMatsimV1Test.java | 11 +- .../network/io/NetworkReprojectionIOTest.java | 20 +- .../core/population/PersonImplTest.java | 26 +- .../matsim/core/population/PlanImplTest.java | 30 +- .../core/population/PopulationUtilsTest.java | 8 +- .../io/CompressedRoutesIntegrationTest.java | 4 +- .../io/MatsimPopulationReaderTest.java | 18 +- .../io/ParallelPopulationReaderTest.java | 6 +- .../io/PopulationAttributeConversionTest.java | 20 +- .../io/PopulationReaderMatsimV4Test.java | 16 +- .../io/PopulationReaderMatsimV5Test.java | 22 +- .../io/PopulationReprojectionIOIT.java | 28 +- .../population/io/PopulationV6IOTest.java | 56 +-- .../io/PopulationWriterHandlerImplV4Test.java | 5 +- .../io/PopulationWriterHandlerImplV5Test.java | 10 +- ...mingPopulationAttributeConversionTest.java | 4 +- .../routes/AbstractNetworkRouteTest.java | 48 +-- .../routes/LinkNetworkRouteTest.java | 4 +- .../population/routes/NetworkFactoryTest.java | 5 +- .../routes/RouteFactoryImplTest.java | 11 +- .../routes/RouteFactoryIntegrationTest.java | 4 +- .../HeavyCompressedNetworkRouteTest.java | 20 +- .../MediumCompressedNetworkRouteTest.java | 20 +- .../core/replanning/PlanStrategyTest.java | 5 +- .../StrategyManagerSubpopulationsTest.java | 4 +- .../core/replanning/StrategyManagerTest.java | 35 +- .../annealing/ReplanningAnnealerTest.java | 42 +- .../ForceInnovationStrategyChooserTest.java | 6 +- .../ReplanningWithConflictsTest.java | 4 +- .../AbstractMultithreadedModuleTest.java | 6 +- .../replanning/modules/ChangeLegModeTest.java | 14 +- .../modules/ChangeSingleLegModeTest.java | 12 +- .../modules/ExternalModuleTest.java | 10 +- .../planInheritance/PlanInheritanceTest.java | 12 +- .../selectors/AbstractPlanSelectorTest.java | 14 +- .../selectors/BestPlanSelectorTest.java | 5 +- .../selectors/ExpBetaPlanSelectorTest.java | 11 +- .../selectors/KeepSelectedTest.java | 5 +- .../selectors/PathSizeLogitSelectorTest.java | 5 +- .../selectors/RandomPlanSelectorTest.java | 5 +- .../WorstPlanForRemovalSelectorTest.java | 8 +- ...eterministicMultithreadedReplanningIT.java | 10 +- .../strategies/InnovationSwitchOffTest.java | 4 +- .../TimeAllocationMutatorModuleTest.java | 12 +- .../AbstractLeastCostPathCalculatorTest.java | 8 +- ...DefaultAnalysisMainModeIdentifierTest.java | 8 +- .../router/FallbackRoutingModuleTest.java | 4 +- .../router/InvertertedNetworkRoutingTest.java | 5 +- .../router/MultimodalLinkChooserTest.java | 6 +- ...workRoutingInclAccessEgressModuleTest.java | 93 ++--- .../core/router/NetworkRoutingModuleTest.java | 6 +- ...rsonalizableDisutilityIntegrationTest.java | 8 +- .../PseudoTransitRoutingModuleTest.java | 4 +- .../org/matsim/core/router/RoutingIT.java | 18 +- .../TeleportationRoutingModuleTest.java | 4 +- .../router/TestActivityWrapperFacility.java | 4 +- .../router/TripRouterFactoryImplTest.java | 6 +- .../core/router/TripRouterModuleTest.java | 6 +- .../matsim/core/router/TripRouterTest.java | 8 +- .../TripStructureUtilsSubtoursTest.java | 26 +- .../core/router/TripStructureUtilsTest.java | 57 +-- ...izingTimeDistanceTravelDisutilityTest.java | 4 +- .../core/router/old/PlanRouterTest.java | 10 +- .../priorityqueue/BinaryMinHeapTest.java | 48 +-- .../core/router/speedy/DAryMinHeapTest.java | 8 +- .../core/router/speedy/SpeedyGraphTest.java | 6 +- .../core/scenario/LoadScenarioByHTTPIT.java | 4 +- .../ScenarioByConfigInjectionTest.java | 8 +- .../core/scenario/ScenarioImplTest.java | 8 +- .../core/scenario/ScenarioLoaderImplTest.java | 12 +- .../core/scenario/ScenarioUtilsTest.java | 4 +- .../core/scoring/EventsToActivitiesTest.java | 10 +- .../matsim/core/scoring/EventsToLegsTest.java | 16 +- .../core/scoring/EventsToScoreTest.java | 8 +- ...ScoringFunctionsForPopulationStressIT.java | 76 ++-- .../ScoringFunctionsForPopulationTest.java | 12 +- ...yparNagelLegScoringDailyConstantsTest.java | 4 +- .../CharyparNagelLegScoringPtChangeTest.java | 4 +- ...yparNagelOpenTimesScoringFunctionTest.java | 5 +- .../CharyparNagelScoringFunctionTest.java | 46 +-- .../CharyparNagelWithSubpopulationsTest.java | 6 +- .../LinkToLinkTravelTimeCalculatorTest.java | 5 +- .../TravelTimeCalculatorModuleTest.java | 28 +- .../TravelTimeCalculatorTest.java | 38 +- .../TravelTimeDataArrayTest.java | 4 +- .../core/utils/charts/BarChartTest.java | 5 +- .../core/utils/charts/LineChartTest.java | 5 +- .../core/utils/charts/XYLineChartTest.java | 5 +- .../core/utils/charts/XYScatterChartTest.java | 5 +- .../core/utils/collections/ArrayMapTest.java | 36 +- .../collections/CollectionUtilsTest.java | 16 +- .../collections/IdentifiableArrayMapTest.java | 68 ++-- .../utils/collections/IntArrayMapTest.java | 34 +- .../PseudoRemovePriorityQueueTest.java | 38 +- .../core/utils/collections/QuadTreeTest.java | 44 +-- .../core/utils/collections/TupleTest.java | 14 +- .../core/utils/geometry/CoordImplTest.java | 4 +- .../core/utils/geometry/CoordUtilsTest.java | 37 +- .../utils/geometry/GeometryUtilsTest.java | 4 +- .../core/utils/geometry/geotools/MGCTest.java | 16 +- .../CH1903LV03PlustoWGS84Test.java | 4 +- .../CH1903LV03PlustofromCH1903LV03Test.java | 6 +- .../CH1903LV03toWGS84Test.java | 5 +- .../GeotoolsTransformationTest.java | 5 +- .../TransformationFactoryTest.java | 32 +- .../WGS84toCH1903LV03PlusTest.java | 4 +- .../WGS84toCH1903LV03Test.java | 5 +- .../core/utils/gis/ShapeFileReaderTest.java | 4 +- .../core/utils/gis/ShapeFileWriterTest.java | 12 +- .../org/matsim/core/utils/io/IOUtilsTest.java | 140 +++---- .../utils/io/MatsimFileTypeGuesserTest.java | 30 +- .../core/utils/io/MatsimXmlParserTest.java | 22 +- .../core/utils/io/MatsimXmlWriterTest.java | 6 +- .../core/utils/io/OsmNetworkReaderTest.java | 20 +- .../matsim/core/utils/io/XmlUtilsTest.java | 6 +- .../core/utils/misc/ArgumentParserTest.java | 14 +- .../core/utils/misc/ByteBufferUtilsTest.java | 8 +- .../core/utils/misc/ClassUtilsTest.java | 24 +- .../core/utils/misc/ConfigUtilsTest.java | 17 +- .../core/utils/misc/NetworkUtilsTest.java | 45 ++- .../core/utils/misc/OptionalTimeTest.java | 32 +- .../core/utils/misc/OptionalTimesTest.java | 4 +- .../core/utils/misc/PopulationUtilsTest.java | 12 +- .../core/utils/misc/RouteUtilsTest.java | 32 +- .../core/utils/misc/StringUtilsTest.java | 8 +- .../org/matsim/core/utils/misc/TimeTest.java | 23 +- .../utils/timing/TimeInterpretationTest.java | 8 +- .../java/org/matsim/counts/CountTest.java | 11 +- .../counts/CountsComparisonAlgorithmTest.java | 8 +- .../counts/CountsControlerListenerTest.java | 10 +- .../matsim/counts/CountsErrorGraphTest.java | 5 +- .../counts/CountsHtmlAndGraphsWriterTest.java | 5 +- .../counts/CountsLoadCurveGraphTest.java | 5 +- .../org/matsim/counts/CountsParserTest.java | 14 +- .../matsim/counts/CountsParserWriterTest.java | 6 +- .../counts/CountsReaderHandlerImplV1Test.java | 11 +- .../counts/CountsReprojectionIOTest.java | 16 +- .../counts/CountsSimRealPerHourGraphTest.java | 5 +- .../matsim/counts/CountsTableWriterTest.java | 5 +- .../java/org/matsim/counts/CountsTest.java | 5 +- .../java/org/matsim/counts/CountsV2Test.java | 24 +- .../org/matsim/counts/MatsimCountsIOTest.java | 32 +- .../org/matsim/counts/OutputDelegateTest.java | 5 +- .../java/org/matsim/examples/EquilTest.java | 4 +- .../examples/OnePercentBerlin10sIT.java | 8 +- .../org/matsim/examples/PtTutorialIT.java | 4 +- .../matsim/examples/simple/PtScoringTest.java | 12 +- .../ActivityFacilitiesFactoryImplTest.java | 6 +- .../ActivityFacilitiesImplTest.java | 10 +- .../ActivityFacilitiesSourceTest.java | 4 +- .../ActivityWithOnlyFacilityIdTest.java | 18 +- .../FacilitiesAttributeConvertionTest.java | 16 +- .../FacilitiesFromPopulationTest.java | 8 +- .../FacilitiesParserWriterTest.java | 10 +- .../FacilitiesReprojectionIOTest.java | 20 +- .../facilities/FacilitiesWriterTest.java | 24 +- .../MatsimFacilitiesReaderTest.java | 12 +- .../StreamingActivityFacilitiesTest.java | 4 +- .../AbstractFacilityAlgorithmTest.java | 5 +- .../HouseholdAttributeConversionTest.java | 8 +- .../matsim/households/HouseholdImplTest.java | 8 +- .../matsim/households/HouseholdsIoTest.java | 5 +- .../integration/EquilTwoAgentsTest.java | 4 +- .../integration/SimulateAndScoreTest.java | 8 +- .../PersonMoneyEventIntegrationTest.java | 8 +- .../events/PersonScoreEventTest.java | 8 +- ...iverStartsEventHandlerIntegrationTest.java | 4 +- .../InvertedNetworkRoutingIT.java | 9 +- .../integration/invertednetworks/LanesIT.java | 4 +- .../NonAlternatingPlanElementsIT.java | 6 +- .../pt/TransitIntegrationTest.java | 66 ++-- .../ChangeTripModeIntegrationTest.java | 5 +- .../integration/replanning/ReRoutingIT.java | 8 +- .../replanning/ResumableRunsIT.java | 4 +- .../QSimIntegrationTest.java | 11 +- .../java/org/matsim/lanes/LanesUtilsTest.java | 6 +- .../lanes/data/LanesReaderWriterTest.java | 8 +- .../matsim/modules/ScoreStatsModuleTest.java | 4 +- .../matsim/other/DownloadAndReadXmlTest.java | 9 +- ...ndomLegModeForSubtourComplexTripsTest.java | 8 +- ...eRandomLegModeForSubtourDiffModesTest.java | 6 +- .../ChooseRandomLegModeForSubtourTest.java | 16 +- .../algorithms/ChooseRandomLegModeTest.java | 30 +- .../ChooseRandomSingleLegModeTest.java | 23 +- .../ParallelPersonAlgorithmRunnerTest.java | 8 +- .../PermissibleModesCalculatorImplTest.java | 6 +- .../algorithms/PersonPrepareForSimTest.java | 24 +- .../algorithms/TripsToLegsAlgorithmTest.java | 10 +- .../analysis/TransitLoadIntegrationTest.java | 4 +- .../matsim/pt/analysis/TransitLoadTest.java | 4 +- .../pt/config/TransitConfigGroupTest.java | 11 +- .../pt/router/TransitActsRemoverTest.java | 17 +- .../pt/router/TransitRouterConfigTest.java | 5 +- .../pt/router/TransitRouterModuleTest.java | 4 +- .../DefaultTransitPassengerRouteTest.java | 26 +- .../routes/ExperimentalTransitRouteTest.java | 23 +- .../pt/transitSchedule/DepartureTest.java | 8 +- .../MinimalTransferTimesImplTest.java | 18 +- .../pt/transitSchedule/TransitLineTest.java | 17 +- .../transitSchedule/TransitRouteStopTest.java | 14 +- .../pt/transitSchedule/TransitRouteTest.java | 32 +- .../TransitScheduleFactoryTest.java | 14 +- .../TransitScheduleFormatV1Test.java | 5 +- .../TransitScheduleIOTest.java | 4 +- .../TransitScheduleReaderTest.java | 8 +- .../TransitScheduleReaderV1Test.java | 46 +-- .../TransitScheduleReprojectionIOTest.java | 20 +- .../transitSchedule/TransitScheduleTest.java | 22 +- .../TransitScheduleWriterTest.java | 6 +- .../TransitStopFacilityTest.java | 14 +- .../utils/TransitScheduleValidatorTest.java | 10 +- .../org/matsim/run/CreateFullConfigTest.java | 4 +- .../java/org/matsim/run/InitRoutesTest.java | 5 +- .../java/org/matsim/run/XY2LinksTest.java | 5 +- .../testcases/utils/LogCounterTest.java | 6 +- .../EventsFileComparatorTest.java | 17 +- .../matsim/utils/geometry/CoordUtilsTest.java | 12 +- .../LanesBasedWidthCalculatorTest.java | 4 +- .../network/Network2ESRIShapeTest.java | 17 +- .../plans/SelectedPlans2ESRIShapeTest.java | 8 +- .../ObjectAttributesConverterTest.java | 32 +- .../ObjectAttributesTest.java | 4 +- .../ObjectAttributesUtilsTest.java | 8 +- .../ObjectAttributesXmlIOTest.java | 6 +- .../ObjectAttributesXmlReaderTest.java | 10 +- .../attributable/AttributesTest.java | 20 +- .../attributable/AttributesUtilsTest.java | 6 +- .../CoordArrayConverterTest.java | 7 +- .../CoordConverterTest.java | 6 +- .../DoubleArrayConverterTest.java | 8 +- .../EnumConverterTest.java | 12 +- .../StringCollectionConverterTest.java | 6 +- .../StringStringMapConverterTest.java | 6 +- .../vehicles/MatsimVehicleWriterTest.java | 5 +- .../matsim/vehicles/VehicleReaderV1Test.java | 17 +- .../matsim/vehicles/VehicleReaderV2Test.java | 23 +- .../matsim/vehicles/VehicleWriteReadTest.java | 6 +- .../matsim/vehicles/VehicleWriterV1Test.java | 5 +- .../matsim/vehicles/VehicleWriterV2Test.java | 24 +- .../org/matsim/vehicles/VehiclesImplTest.java | 14 +- .../vis/snapshotwriters/PositionInfoTest.java | 8 +- .../ExampleWithinDayControllerTest.java | 4 +- .../ExperiencedPlansWriterTest.java | 4 +- .../tools/ActivityReplanningMapTest.java | 9 +- .../tools/LinkReplanningMapTest.java | 7 +- .../WithinDayTravelTimeTest.java | 6 +- ...TravelTimeWithNetworkChangeEventsTest.java | 4 +- .../withinday/utils/EditRoutesTest.java | 47 ++- .../utils/ReplacePlanElementsTest.java | 8 +- 934 files changed, 6756 insertions(+), 6186 deletions(-) diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/LeastCostPathTreeTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/LeastCostPathTreeTest.java index fcd995bd7b7..0de803d1434 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/LeastCostPathTreeTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/LeastCostPathTreeTest.java @@ -6,7 +6,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Node; @@ -24,9 +24,9 @@ public class LeastCostPathTreeTest { Scenario scenario; - + @Test - public void testRouteChoiceTestSpanningTree(){ + void testRouteChoiceTestSpanningTree(){ this.scenario = new ScenarioBuilder(ConfigUtils.createConfig()).setNetwork(CreateTestNetwork.createTriangularNetwork()).build() ; compareRouteChoices(); } diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/grid/SpatialGridTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/grid/SpatialGridTest.java index 3b1ea9c2c9b..0a43df9c1b6 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/grid/SpatialGridTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/grid/SpatialGridTest.java @@ -1,8 +1,8 @@ package org.matsim.contrib.accessibility.grid; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.network.Network; import org.matsim.contrib.accessibility.SpatialGrid; import org.matsim.contrib.matrixbasedptrouter.utils.BoundingBox; @@ -17,7 +17,8 @@ public class SpatialGridTest { private double cellSize = 10.; - @Test public void testSpatialGrid() { + @Test + void testSpatialGrid() { // get network Network network = CreateTestNetwork.createTestNetwork(); diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulas2Test.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulas2Test.java index 046d187a965..8d4c324a49a 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulas2Test.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulas2Test.java @@ -23,8 +23,8 @@ package org.matsim.contrib.accessibility.logsumComputations; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -37,8 +37,8 @@ public class CompareLogsumFormulas2Test { private MatsimTestUtils utils = new MatsimTestUtils(); - - @Test public void testLogsumFormulas(){ + @Test + void testLogsumFormulas(){ double walkTravelTime2Network = 2.; // 2min double travelTimeOnNetwork = 6.; // 6min diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulasTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulasTest.java index 3c25e7c59d0..95517505f79 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulasTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulasTest.java @@ -23,8 +23,8 @@ package org.matsim.contrib.accessibility.logsumComputations; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -47,7 +47,8 @@ public class CompareLogsumFormulasTest { * cjk3 */ - @Test public void testLogsumFormulas(){ + @Test + void testLogsumFormulas(){ double betaWalkTT = -2.; double betaWalkTD = -1.; diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/ComputeLogsumFormulas3Test.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/ComputeLogsumFormulas3Test.java index 0b358229465..a746fd57137 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/ComputeLogsumFormulas3Test.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/ComputeLogsumFormulas3Test.java @@ -23,8 +23,8 @@ package org.matsim.contrib.accessibility.logsumComputations; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -48,7 +48,8 @@ public class ComputeLogsumFormulas3Test { */ @SuppressWarnings("static-method") - @Test public void testLogsumFormulas(){ + @Test + void testLogsumFormulas(){ double betaWalkTT = -10. / 3600.0; // [util/sec] double betaWalkTD = -10.; // [util/meter] diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java index c4835291ee3..0b3aa1ebf8c 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java @@ -29,8 +29,8 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.locationtech.jts.geom.Envelope; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -78,7 +78,7 @@ public class AccessibilityIntegrationTest { @Ignore @Test - public void testRunAccessibilityExample() { + void testRunAccessibilityExample() { Config config = ConfigUtils.loadConfig("./examples/RunAccessibilityExample/config.xml"); AccessibilityConfigGroup accConfig = ConfigUtils.addOrGetModule(config, AccessibilityConfigGroup.class); @@ -119,7 +119,7 @@ public void startRow(String[] row) { @Test - public void testWithBoundingBoxConfigFile() { + void testWithBoundingBoxConfigFile() { Config config = ConfigUtils.loadConfig(utils.getInputDirectory() + "config.xml"); AccessibilityConfigGroup acg = ConfigUtils.addOrGetModule(config, AccessibilityConfigGroup.class) ; @@ -159,7 +159,7 @@ public void install() { @Test - public void testWithBoundingBox() { + void testWithBoundingBox() { final Config config = createTestConfig(); double min = 0.; // Values for bounding box usually come from a config file @@ -197,7 +197,7 @@ public void install() { @Test - public void testWithBoundingBoxUsingOpportunityWeights() { + void testWithBoundingBoxUsingOpportunityWeights() { final Config config = createTestConfig(); double min = 0.; // Values for bounding box usually come from a config file @@ -237,7 +237,7 @@ public void install() { @Test - public void testWithExtentDeterminedByNetwork() { + void testWithExtentDeterminedByNetwork() { final Config config = createTestConfig() ; config.routing().setRoutingRandomness(0.); @@ -264,7 +264,7 @@ public void install() { @Test - public void testWithExtentDeterminedShapeFile() { + void testWithExtentDeterminedShapeFile() { Config config = createTestConfig() ; File f = new File(this.utils.getInputDirectory() + "shapefile.shp"); // shape file completely covers the road network @@ -304,7 +304,7 @@ public void install() { @Test - public void testWithPredefinedMeasuringPoints() { + void testWithPredefinedMeasuringPoints() { Config config = createTestConfig() ; File f = new File(this.utils.getInputDirectory() + "measuringPoints.xml"); @@ -352,7 +352,7 @@ public void install() { @Ignore @Test - public void testWithFile(){ + void testWithFile(){ /*TODO Complete - JWJ, Dec'16 */ Config config = createTestConfig(); diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/NetworkUtilTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/NetworkUtilTest.java index aa9360e8013..e131507e5ad 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/NetworkUtilTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/NetworkUtilTest.java @@ -22,8 +22,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -46,7 +46,7 @@ public class NetworkUtilTest { @Test - public void testNetworkUtil() { + void testNetworkUtil() { /* create a sample network: * * (e) (f) diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyAccessibilityTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyAccessibilityTest.java index a0a2f6548f7..9e7a6eb30f1 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyAccessibilityTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyAccessibilityTest.java @@ -24,8 +24,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -60,7 +60,7 @@ public class TinyAccessibilityTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void runFromEvents() { + void runFromEvents() { final Config config = createTestConfig(); double min = 0.; // Values for bounding box usually come from a config file @@ -86,7 +86,7 @@ public void runFromEvents() { } @Test - public void testWithBoundingBox() { + void testWithBoundingBox() { final Config config = createTestConfig(); double min = 0.; // Values for bounding box usually come from a config file diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java index 51081fd61b1..3f407b42ffb 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java @@ -23,8 +23,8 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -67,9 +67,10 @@ public class TinyMultimodalAccessibilityTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + // non-deterministic presumably because of multi-threading. kai, sep'19 @Test - @Ignore // non-deterministic presumably because of multi-threading. kai, sep'19 - public void testWithBoundingBox() { + @Ignore + void testWithBoundingBox() { final Config config = createTestConfig(); double min = 0.; // Values for bounding box usually come from a config file diff --git a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/BvwpAccidentsCostComputationTest.java b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/BvwpAccidentsCostComputationTest.java index 9acd427bef7..5e6bd4a91d0 100644 --- a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/BvwpAccidentsCostComputationTest.java +++ b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/BvwpAccidentsCostComputationTest.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -12,7 +12,7 @@ import org.matsim.api.core.v01.network.Node; import org.matsim.core.network.NetworkUtils; import org.matsim.testcases.MatsimTestUtils; -; + /** * @author ikaddoura, mmayobre @@ -20,9 +20,9 @@ * */ public class BvwpAccidentsCostComputationTest { - + @Test - public void test1() { + void test1() { Network network = NetworkUtils.createNetwork(); NetworkFactory factory = network.getFactory(); @@ -42,9 +42,9 @@ public void test1() { double costs = AccidentCostComputationBVWP.computeAccidentCosts(4820, link1, list); Assert.assertEquals("wrong cost", 1772.13863066011, costs, MatsimTestUtils.EPSILON); } - + @Test - public void test2() { + void test2() { Network network = NetworkUtils.createNetwork(); NetworkFactory factory = network.getFactory(); @@ -64,9 +64,9 @@ public void test2() { double costs = AccidentCostComputationBVWP.computeAccidentCosts(1000, link1, list); Assert.assertEquals("wrong cost", 23.165, costs, MatsimTestUtils.EPSILON); } - + @Test - public void test3() { + void test3() { Network network = NetworkUtils.createNetwork(); NetworkFactory factory = network.getFactory(); diff --git a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTest.java b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTest.java index bd0daad8082..b087e316b5b 100644 --- a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTest.java +++ b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTest.java @@ -4,8 +4,8 @@ import java.io.IOException; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.accidents.AccidentsConfigGroup.AccidentsComputationMethod; @@ -27,7 +27,7 @@ public class RunTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void test1() { + void test1() { String configFile = utils.getPackageInputDirectory() + "/trial_scenario/trial_scenario_config.xml"; String outputDirectory = utils.getOutputDirectory(); diff --git a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTestEquil.java b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTestEquil.java index de2a0923944..94e8df01123 100644 --- a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTestEquil.java +++ b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTestEquil.java @@ -2,9 +2,9 @@ import java.io.BufferedReader; import java.io.IOException; -import org.junit.Assert; +import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -15,14 +15,14 @@ import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.io.IOUtils; -import org.matsim.testcases.MatsimTestUtils; - +import org.matsim.testcases.MatsimTestUtils; + public class RunTestEquil { - @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - - @Test - public void test1() { + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + + @Test + void test1() { String configFile = utils.getPackageInputDirectory() + "/equil_scenario/config.xml"; String outputDirectory = utils.getOutputDirectory(); String runId = "run1"; diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/PersonIntersectAreaFilterTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/PersonIntersectAreaFilterTest.java index 848a370fb01..53501436d54 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/PersonIntersectAreaFilterTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/PersonIntersectAreaFilterTest.java @@ -25,8 +25,8 @@ import java.util.HashMap; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -55,7 +55,8 @@ public class PersonIntersectAreaFilterTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testFilter() throws Exception { + @Test + void testFilter() throws Exception { /* create a simple network where agents can drive from the lower left * to the upper right */ Network network = NetworkUtils.createNetwork(); diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/RouteLinkFilterTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/RouteLinkFilterTest.java index 206f1a7c2a9..4f5b186f055 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/RouteLinkFilterTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/RouteLinkFilterTest.java @@ -23,8 +23,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -54,7 +54,8 @@ public class RouteLinkFilterTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testRouteLinkFilter() { + @Test + void testRouteLinkFilter() { // used to set the default dtd-location utils.loadConfig((String)null); Population population = getTestPopulation(); diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java index ee36629cfc1..f474729f527 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java @@ -26,8 +26,8 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -107,9 +107,9 @@ public void tearDown() throws Exception { this.network = null; } - @Test - @Ignore - public void testNoEvents() { + @Test + @Ignore + void testNoEvents() { KNAnalysisEventsHandler testee = new KNAnalysisEventsHandler(this.scenario); @@ -121,9 +121,9 @@ public void testNoEvents() { this.runTest(testee); } - @Test - @Ignore - public void testAveraging() { + @Test + @Ignore + void testAveraging() { // yy this test is probably not doing anything with respect to some of the newer statistics, such as money. kai, mar'14 KNAnalysisEventsHandler testee = new KNAnalysisEventsHandler(this.scenario); diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/GridTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/GridTest.java index a3253515666..1b223b21821 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/GridTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/GridTest.java @@ -4,14 +4,14 @@ import java.util.Collection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.GeometryFactory; public class GridTest { - @Test - public void initializeSquareGrid() { + @Test + void initializeSquareGrid() { final String testValue = "Test-value"; Grid grid = new SquareGrid<>(2, () -> testValue, SpatialTestUtils.createRect(10, 10)); @@ -23,8 +23,8 @@ public void initializeSquareGrid() { values.forEach(value -> assertEquals(testValue, value.getValue())); } - @Test - public void initializeHexagonalGrid() { + @Test + void initializeHexagonalGrid() { final String testValue = "test-value"; Grid grid = new HexagonalGrid<>(2, () -> testValue, SpatialTestUtils.createRect(10, 10)); @@ -38,8 +38,8 @@ public void initializeHexagonalGrid() { values.forEach(value -> assertEquals(testValue, value.getValue())); } - @Test - public void getArea_squareGrid() { + @Test + void getArea_squareGrid() { final double horizontalDistance = 2; final double expected = 2 * 2; // area of square is d^2 @@ -49,8 +49,8 @@ public void getArea_squareGrid() { assertEquals(expected, grid.getCellArea(), 0.0001); } - @Test - public void getArea_HexagonalGrid() { + @Test + void getArea_HexagonalGrid() { // actually area of hexagon is r^2 * sqrt(3)/2 final double horizontalDistance = 2; @@ -65,8 +65,8 @@ public void getArea_HexagonalGrid() { assertEquals(expected5, grid5.getCellArea(), 0.0001); } - @Test - public void getValue_withExactCoord() { + @Test + void getValue_withExactCoord() { final String testValue = "initialValue"; final Coordinate expectedCoordinate = new Coordinate(2, 1+Math.sqrt(3)); @@ -77,8 +77,8 @@ public void getValue_withExactCoord() { assertEquals(expectedCoordinate, result.getCoordinate()); } - @Test - public void getValue_closeCoordinate() { + @Test + void getValue_closeCoordinate() { final String testValue = "initialValue"; Grid grid = new HexagonalGrid<>(2, () -> testValue, SpatialTestUtils.createRect(10, 10)); @@ -89,8 +89,8 @@ public void getValue_closeCoordinate() { assertEquals(new Coordinate(2, 1+Math.sqrt(3)), result.getCoordinate()); } - @Test - public void getValue_coordOutsideOfGrid() { + @Test + void getValue_coordOutsideOfGrid() { final String testValue = "initialValue"; Grid grid = new HexagonalGrid<>(2, () -> testValue, SpatialTestUtils.createRect(10, 10)); @@ -100,8 +100,8 @@ public void getValue_coordOutsideOfGrid() { assertEquals(new Coordinate(8, 1 + 5*Math.sqrt(3)), result.getCoordinate()); } - @Test - public void getValues() { + @Test + void getValues() { final String testValue = "initialValue"; Grid grid = new HexagonalGrid<>(2, () -> testValue, SpatialTestUtils.createRect(10, 10)); diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/SpatialInterpolationTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/SpatialInterpolationTest.java index 49e3f8e4a8a..e739ab2b847 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/SpatialInterpolationTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/SpatialInterpolationTest.java @@ -2,14 +2,15 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.locationtech.jts.geom.Coordinate; public class SpatialInterpolationTest { - @Test - public void calculateWeightFromLine() { + @Test + void calculateWeightFromLine() { final Coordinate from = new Coordinate(1, 1); final Coordinate to = new Coordinate(4, 5); @@ -22,33 +23,37 @@ public void calculateWeightFromLine() { assertEquals(0.0011109434390476694, weight, 0.001); } - @Test(expected = IllegalArgumentException.class) - public void calculateWeightFromLine_invalidSmoothingRadius() { + @Test + void calculateWeightFromLine_invalidSmoothingRadius() { + assertThrows(IllegalArgumentException.class, () -> { - final Coordinate from = new Coordinate(0, 1); - final Coordinate to = new Coordinate(10, 1); - final Coordinate cellCentroid = new Coordinate(5, 1); - final double smoothingRadius = 0; + final Coordinate from = new Coordinate(0, 1); + final Coordinate to = new Coordinate(10, 1); + final Coordinate cellCentroid = new Coordinate(5, 1); + final double smoothingRadius = 0; - double weight = SpatialInterpolation.calculateWeightFromLine(from, to, cellCentroid, smoothingRadius); + double weight = SpatialInterpolation.calculateWeightFromLine(from, to, cellCentroid, smoothingRadius); - fail("smoothing radius <= 0 should cause exception"); - } + fail("smoothing radius <= 0 should cause exception"); + }); + } - @Test(expected = IllegalArgumentException.class) - public void calculateWeightFromPoint_invalidSmoothingRadius() { + @Test + void calculateWeightFromPoint_invalidSmoothingRadius() { + assertThrows(IllegalArgumentException.class, () -> { - final Coordinate source = new Coordinate(10, 10); - final Coordinate centroid = new Coordinate(10, 10); - final double smoothingRadius = 0; + final Coordinate source = new Coordinate(10, 10); + final Coordinate centroid = new Coordinate(10, 10); + final double smoothingRadius = 0; - double weight = SpatialInterpolation.calculateWeightFromPoint(source, centroid, smoothingRadius); + double weight = SpatialInterpolation.calculateWeightFromPoint(source, centroid, smoothingRadius); - fail("smoothing radius <= 0 should cause exception"); - } + fail("smoothing radius <= 0 should cause exception"); + }); + } - @Test - public void calculateWeightFromPoint() { + @Test + void calculateWeightFromPoint() { final Coordinate point = new Coordinate(5, 5); final Coordinate cell = new Coordinate (9, 5); diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/time/TimeBinMapTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/time/TimeBinMapTest.java index a15b076f567..3acb0feeec5 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/time/TimeBinMapTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/time/TimeBinMapTest.java @@ -1,15 +1,16 @@ package org.matsim.contrib.analysis.time; -import org.junit.Test; - import java.util.Map; import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; public class TimeBinMapTest { - @Test - public void getTimeBin() { + @Test + void getTimeBin() { TimeBinMap> map = new TimeBinMap<>(10); @@ -18,8 +19,8 @@ public void getTimeBin() { assertEquals(10, bin.getStartTime(), 0.001); } - @Test - public void getTimeBinWithStartTime() { + @Test + void getTimeBinWithStartTime() { TimeBinMap> map = new TimeBinMap<>(10, 20); @@ -28,18 +29,20 @@ public void getTimeBinWithStartTime() { assertEquals(20, bin.getStartTime(), 0.001); } - @Test(expected = IllegalArgumentException.class) - public void getTimeInvalidTime_exception() { + @Test + void getTimeInvalidTime_exception() { + assertThrows(IllegalArgumentException.class, () -> { - TimeBinMap> map = new TimeBinMap<>(10, 20); + TimeBinMap> map = new TimeBinMap<>(10, 20); - TimeBinMap.TimeBin> bin = map.getTimeBin(19); + TimeBinMap.TimeBin> bin = map.getTimeBin(19); - assertEquals(20, bin.getStartTime(), 0.001); - } + assertEquals(20, bin.getStartTime(), 0.001); + }); + } - @Test - public void getMultipleTimeBins() { + @Test + void getMultipleTimeBins() { TimeBinMap> map = new TimeBinMap<>(10); @@ -55,8 +58,8 @@ public void getMultipleTimeBins() { assertEquals(30, fourth.getStartTime(), 0.001); } - @Test - public void getEndOfLastTimeBucket() { + @Test + void getEndOfLastTimeBucket() { TimeBinMap> map = new TimeBinMap<>(10); @@ -68,8 +71,8 @@ public void getEndOfLastTimeBucket() { assertEquals(120, map.getEndTimeOfLastBin(), 0.0001); } - @Test - public void getAllTimeBins() { + @Test + void getAllTimeBins() { TimeBinMap> map = new TimeBinMap<>(10); @@ -81,8 +84,8 @@ public void getAllTimeBins() { assertEquals(4, map.getTimeBins().size()); } - @Test - public void timeBin_setEntry() { + @Test + void timeBin_setEntry() { final String testValue = "some-value"; @@ -97,7 +100,7 @@ public void timeBin_setEntry() { } @Test - public void timeBin_getValue() { + void timeBin_getValue() { final String testValue = "some-value"; diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java index 0b8723a704b..3d322dec849 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.analysis.vsp.traveltimedistance; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.utils.collections.Tuple; import org.matsim.testcases.MatsimTestUtils; @@ -16,7 +16,7 @@ public class GoogleMapRouteValidatorTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testReadJson() throws IOException { + void testReadJson() throws IOException { GoogleMapRouteValidator googleMapRouteValidator = getDummyValidator(); BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(utils.getClassInputDirectory() + "route.json"))); Optional> result = googleMapRouteValidator.readFromJson(reader); diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java index e08bf8c5b00..72ec7f44e30 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.analysis.vsp.traveltimedistance; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.utils.collections.Tuple; import org.matsim.testcases.MatsimTestUtils; @@ -15,7 +15,7 @@ public class HereMapsRouteValidatorTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testReadJson() throws IOException { + void testReadJson() throws IOException { HereMapsRouteValidator hereMapsRouteValidator = getDummyValidator(false); BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(utils.getClassInputDirectory() + "route.json"))); Optional> result = hereMapsRouteValidator.readFromJson(reader, null); @@ -25,7 +25,7 @@ public void testReadJson() throws IOException { } @Test - public void testWriteFile() throws IOException { + void testWriteFile() throws IOException { HereMapsRouteValidator hereMapsRouteValidator = getDummyValidator(true); BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(utils.getClassInputDirectory() + "route.json"))); hereMapsRouteValidator.readFromJson(reader, "tripId"); diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/travelsummary/events2traveldiaries/RunEventsToTravelDiariesIT.java b/contribs/analysis/src/test/java/org/matsim/contrib/travelsummary/events2traveldiaries/RunEventsToTravelDiariesIT.java index 58ee087e1fe..c3a4f24d7fd 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/travelsummary/events2traveldiaries/RunEventsToTravelDiariesIT.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/travelsummary/events2traveldiaries/RunEventsToTravelDiariesIT.java @@ -18,8 +18,8 @@ * *********************************************************************** */ package org.matsim.contrib.travelsummary.events2traveldiaries; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -29,9 +29,9 @@ public class RunEventsToTravelDiariesIT { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); - @SuppressWarnings("static-method") - @Test - public final void test() { + @SuppressWarnings("static-method") + @Test + final void test() { String[] str = {"../../examples/scenarios/equil/config.xml", "../../examples/scenarios/equil/output_events.xml.gz", "_test", utils.getOutputDirectory()}; // This goes through the file system (nothing to do with resource paths etc.) diff --git a/contribs/application/src/test/java/org/matsim/application/ApplicationUtilsTest.java b/contribs/application/src/test/java/org/matsim/application/ApplicationUtilsTest.java index edb2bcdbba6..85a1f820674 100644 --- a/contribs/application/src/test/java/org/matsim/application/ApplicationUtilsTest.java +++ b/contribs/application/src/test/java/org/matsim/application/ApplicationUtilsTest.java @@ -1,6 +1,6 @@ package org.matsim.application; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.application.analysis.TestAnalysis; import org.matsim.application.analysis.TestDependentAnalysis; import org.matsim.application.options.ShpOptions; @@ -10,7 +10,7 @@ public class ApplicationUtilsTest { @Test - public void shp() { + void shp() { assertTrue(ApplicationUtils.acceptsOptions(TestAnalysis.class, ShpOptions.class)); diff --git a/contribs/application/src/test/java/org/matsim/application/CommandRunnerTest.java b/contribs/application/src/test/java/org/matsim/application/CommandRunnerTest.java index 3f3cff914d1..bd7f228964f 100644 --- a/contribs/application/src/test/java/org/matsim/application/CommandRunnerTest.java +++ b/contribs/application/src/test/java/org/matsim/application/CommandRunnerTest.java @@ -1,8 +1,8 @@ package org.matsim.application; import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.application.analysis.TestDependentAnalysis; import org.matsim.application.analysis.TestOtherAnalysis; import org.matsim.application.analysis.TestOtherDependentAnalysis; @@ -16,7 +16,7 @@ public class CommandRunnerTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void runner() { + void runner() { Path path = Path.of(utils.getOutputDirectory()); diff --git a/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java b/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java index 4decf8ec93b..1abf0991cf0 100644 --- a/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java +++ b/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java @@ -2,8 +2,8 @@ import org.junit.Assume; import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.application.options.SampleOptions; import org.matsim.application.prepare.freight.tripExtraction.ExtractRelevantFreightTrips; import org.matsim.application.prepare.population.GenerateShortDistanceTrips; @@ -32,7 +32,7 @@ public class MATSimApplicationTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void help() { + void help() { int ret = MATSimApplication.execute(TestScenario.class, "--help"); @@ -40,7 +40,7 @@ public void help() { } @Test - public void config() { + void config() { Controler controler = MATSimApplication.prepare(TestScenario.class, ConfigUtils.createConfig(), "-c:controler.runId=Test123", "--config:global.numberOfThreads=4", "--config:plans.inputCRS", "EPSG:1234"); @@ -54,7 +54,7 @@ public void config() { } @Test - public void yaml() { + void yaml() { Path yml = Path.of(utils.getClassInputDirectory(), "specs.yml"); @@ -76,7 +76,7 @@ public void yaml() { } @Test - public void sample() { + void sample() { Controler controler = MATSimApplication.prepare(TestScenario.class, ConfigUtils.createConfig(), "--10pct"); @@ -92,7 +92,7 @@ public void sample() { } @Test - public void population() throws MalformedURLException { + void population() throws MalformedURLException { Path input = Path.of(utils.getClassInputDirectory()); Path output = Path.of(utils.getOutputDirectory()); @@ -128,7 +128,7 @@ public void population() throws MalformedURLException { @Test @Ignore("Class is deprecated") - public void freight() { + void freight() { Path input = Path.of("..", "..", "..", "..", "shared-svn", "komodnext", "data", "freight", "original_data").toAbsolutePath().normalize(); @@ -161,7 +161,7 @@ public void freight() { } @Test - public void run() { + void run() { Config config = ConfigUtils.createConfig(); Path out = Path.of(utils.getOutputDirectory()).resolve("out"); diff --git a/contribs/application/src/test/java/org/matsim/application/analysis/LogFileAnalysisTest.java b/contribs/application/src/test/java/org/matsim/application/analysis/LogFileAnalysisTest.java index 043845b921f..5309e1585b5 100644 --- a/contribs/application/src/test/java/org/matsim/application/analysis/LogFileAnalysisTest.java +++ b/contribs/application/src/test/java/org/matsim/application/analysis/LogFileAnalysisTest.java @@ -1,8 +1,8 @@ package org.matsim.application.analysis; import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.application.ApplicationUtils; import org.matsim.application.MATSimApplication; import org.matsim.application.MATSimApplicationTest; @@ -20,7 +20,7 @@ public class LogFileAnalysisTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void output() throws IOException { + void output() throws IOException { Config config = ConfigUtils.createConfig(); diff --git a/contribs/application/src/test/java/org/matsim/application/options/CsvOptionsTest.java b/contribs/application/src/test/java/org/matsim/application/options/CsvOptionsTest.java index 8fd5097116a..da166a7ea88 100644 --- a/contribs/application/src/test/java/org/matsim/application/options/CsvOptionsTest.java +++ b/contribs/application/src/test/java/org/matsim/application/options/CsvOptionsTest.java @@ -2,8 +2,8 @@ import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVPrinter; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.jupiter.api.io.TempDir; import org.junit.rules.TemporaryFolder; @@ -19,7 +19,7 @@ public class CsvOptionsTest { public Path f; @Test - public void output() throws IOException { + void output() throws IOException { CsvOptions csv = new CsvOptions(CSVFormat.Predefined.TDF); diff --git a/contribs/application/src/test/java/org/matsim/application/options/SampleOptionsTest.java b/contribs/application/src/test/java/org/matsim/application/options/SampleOptionsTest.java index 545e30560a2..cc7f4469b2b 100644 --- a/contribs/application/src/test/java/org/matsim/application/options/SampleOptionsTest.java +++ b/contribs/application/src/test/java/org/matsim/application/options/SampleOptionsTest.java @@ -2,7 +2,7 @@ import com.google.common.util.concurrent.AtomicDouble; import org.assertj.core.api.Assertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.application.MATSimAppCommand; import picocli.CommandLine; @@ -11,7 +11,7 @@ public class SampleOptionsTest { @Test - public void flexible() { + void flexible() { AtomicInteger size = new AtomicInteger(); AtomicDouble dSize = new AtomicDouble(); @@ -39,7 +39,7 @@ public Integer call() throws Exception { } @Test - public void fixed() { + void fixed() { AtomicInteger size = new AtomicInteger(); diff --git a/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java b/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java index 48c70be2e1b..ca5a7785d4b 100644 --- a/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java +++ b/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java @@ -2,8 +2,8 @@ import org.junit.Assert; import org.junit.Assume; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; import org.matsim.testcases.MatsimTestUtils; @@ -23,7 +23,7 @@ public class ShpOptionsTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void readZip() { + void readZip() { // use same shape file as for land-use Path input = Path.of(utils.getClassInputDirectory() @@ -43,7 +43,7 @@ public void readZip() { } @Test - public void all() { + void all() { // use same shape file as for land-use Path input = Path.of(utils.getClassInputDirectory() @@ -66,7 +66,7 @@ public void all() { } @Test - public void testGetGeometry() { + void testGetGeometry() { Path input = Path.of(utils.getClassInputDirectory() .replace("ShpOptionsTest", "CreateLandUseShpTest") diff --git a/contribs/application/src/test/java/org/matsim/application/prepare/CreateLandUseShpTest.java b/contribs/application/src/test/java/org/matsim/application/prepare/CreateLandUseShpTest.java index 7830166223f..38747c0fbc7 100644 --- a/contribs/application/src/test/java/org/matsim/application/prepare/CreateLandUseShpTest.java +++ b/contribs/application/src/test/java/org/matsim/application/prepare/CreateLandUseShpTest.java @@ -1,8 +1,8 @@ package org.matsim.application.prepare; import org.junit.Assume; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; import java.nio.file.Files; @@ -16,7 +16,7 @@ public class CreateLandUseShpTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void convert() { + void convert() { Path input = Path.of(utils.getClassInputDirectory(), "andorra-latest-free.shp.zip"); diff --git a/contribs/application/src/test/java/org/matsim/application/prepare/ShapeFileTextLookupTest.java b/contribs/application/src/test/java/org/matsim/application/prepare/ShapeFileTextLookupTest.java index 0fb5fe666c5..0ff988f14cf 100644 --- a/contribs/application/src/test/java/org/matsim/application/prepare/ShapeFileTextLookupTest.java +++ b/contribs/application/src/test/java/org/matsim/application/prepare/ShapeFileTextLookupTest.java @@ -1,8 +1,8 @@ package org.matsim.application.prepare; import org.junit.Assume; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; import picocli.CommandLine; @@ -17,8 +17,8 @@ public class ShapeFileTextLookupTest { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void main() { + @Test + void main() { Path input = Path.of(utils.getClassInputDirectory(), "verkehrszellen.csv"); Path output = Path.of(utils.getOutputDirectory(), "output.csv"); diff --git a/contribs/application/src/test/java/org/matsim/application/prepare/counts/CreateCountsFromBAStDataTest.java b/contribs/application/src/test/java/org/matsim/application/prepare/counts/CreateCountsFromBAStDataTest.java index 6706676043b..4c35b94c282 100644 --- a/contribs/application/src/test/java/org/matsim/application/prepare/counts/CreateCountsFromBAStDataTest.java +++ b/contribs/application/src/test/java/org/matsim/application/prepare/counts/CreateCountsFromBAStDataTest.java @@ -1,8 +1,8 @@ package org.matsim.application.prepare.counts; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -36,7 +36,7 @@ public class CreateCountsFromBAStDataTest { String shpCrs = "EPSG:3857"; @Test - public void testCreateCountsFromBAStData() { + void testCreateCountsFromBAStData() { String version = "normal-"; String out = utils.getOutputDirectory() + version + countsOutput; @@ -74,7 +74,7 @@ public void testCreateCountsFromBAStData() { } @Test - public void testWithIgnoredStations() { + void testWithIgnoredStations() { String version = "with-ignored-"; String out1 = utils.getOutputDirectory() + version + countsOutput; @@ -123,7 +123,7 @@ public void testWithIgnoredStations() { } @Test - public void testManualMatchedCounts() { + void testManualMatchedCounts() { String out = utils.getOutputDirectory() + "manual-matched-" + countsOutput; @@ -164,7 +164,7 @@ public void testManualMatchedCounts() { } @Test - public void testManualMatchingWithWrongInput() { + void testManualMatchingWithWrongInput() { String out = utils.getOutputDirectory() + "manual-matched-" + countsOutput; diff --git a/contribs/application/src/test/java/org/matsim/application/prepare/counts/NetworkIndexTest.java b/contribs/application/src/test/java/org/matsim/application/prepare/counts/NetworkIndexTest.java index a342fbac29c..74d0a5e356a 100644 --- a/contribs/application/src/test/java/org/matsim/application/prepare/counts/NetworkIndexTest.java +++ b/contribs/application/src/test/java/org/matsim/application/prepare/counts/NetworkIndexTest.java @@ -2,7 +2,7 @@ import org.assertj.core.data.Offset; import org.geotools.geometry.jts.JTSFactoryFinder; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.GeometryFactory; @@ -11,7 +11,7 @@ public class NetworkIndexTest { @Test - public void angle() { + void angle() { GeometryFactory f = JTSFactoryFinder.getGeometryFactory(); diff --git a/contribs/application/src/test/java/org/matsim/application/prepare/population/CloseTrajectoriesTest.java b/contribs/application/src/test/java/org/matsim/application/prepare/population/CloseTrajectoriesTest.java index b3db595cfb0..5c45ddefdb3 100644 --- a/contribs/application/src/test/java/org/matsim/application/prepare/population/CloseTrajectoriesTest.java +++ b/contribs/application/src/test/java/org/matsim/application/prepare/population/CloseTrajectoriesTest.java @@ -1,8 +1,8 @@ package org.matsim.application.prepare.population; import org.assertj.core.api.Condition; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; @@ -21,7 +21,7 @@ public class CloseTrajectoriesTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void main() { + void main() { Path input = Path.of(utils.getPackageInputDirectory(), "persons.xml"); diff --git a/contribs/application/src/test/java/org/matsim/application/prepare/population/FixSubtourModesTest.java b/contribs/application/src/test/java/org/matsim/application/prepare/population/FixSubtourModesTest.java index cbd4d0bd400..6f65537c5bf 100644 --- a/contribs/application/src/test/java/org/matsim/application/prepare/population/FixSubtourModesTest.java +++ b/contribs/application/src/test/java/org/matsim/application/prepare/population/FixSubtourModesTest.java @@ -1,6 +1,6 @@ package org.matsim.application.prepare.population; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -19,7 +19,7 @@ public class FixSubtourModesTest { private PopulationFactory fact = PopulationUtils.getFactory(); @Test - public void unclosed() { + void unclosed() { Person person = fact.createPerson(Id.create("1000", Person.class)); final Plan plan = fact.createPlan(); @@ -43,7 +43,7 @@ public void unclosed() { } @Test - public void complex() { + void complex() { Person person = fact.createPerson(Id.create("1000", Person.class)); final Plan plan = fact.createPlan(); @@ -72,7 +72,7 @@ public void complex() { @Test - public void correct() { + void correct() { Person person = fact.createPerson(Id.create("1000", Person.class)); final Plan plan = fact.createPlan(); diff --git a/contribs/application/src/test/java/org/matsim/application/prepare/population/SplitActivityTypesDurationTest.java b/contribs/application/src/test/java/org/matsim/application/prepare/population/SplitActivityTypesDurationTest.java index 0e3e98374a1..3c87f29a3c8 100644 --- a/contribs/application/src/test/java/org/matsim/application/prepare/population/SplitActivityTypesDurationTest.java +++ b/contribs/application/src/test/java/org/matsim/application/prepare/population/SplitActivityTypesDurationTest.java @@ -1,8 +1,8 @@ package org.matsim.application.prepare.population; import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; @@ -21,7 +21,7 @@ public class SplitActivityTypesDurationTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void split() { + void split() { Path input = Path.of(utils.getPackageInputDirectory(), "persons.xml"); diff --git a/contribs/application/src/test/java/org/matsim/application/prepare/pt/CreateTransitScheduleFromGtfsTest.java b/contribs/application/src/test/java/org/matsim/application/prepare/pt/CreateTransitScheduleFromGtfsTest.java index 89ce36a5691..5b3732f6347 100644 --- a/contribs/application/src/test/java/org/matsim/application/prepare/pt/CreateTransitScheduleFromGtfsTest.java +++ b/contribs/application/src/test/java/org/matsim/application/prepare/pt/CreateTransitScheduleFromGtfsTest.java @@ -1,8 +1,8 @@ package org.matsim.application.prepare.pt; import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; @@ -16,7 +16,7 @@ public class CreateTransitScheduleFromGtfsTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void run() { + void run() { String input = utils.getClassInputDirectory(); String output = utils.getOutputDirectory(); diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/CarrierReaderFromCSVTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/CarrierReaderFromCSVTest.java index b067e5e2a43..e66b63d3dd1 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/CarrierReaderFromCSVTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/CarrierReaderFromCSVTest.java @@ -10,8 +10,8 @@ import java.util.Set; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -43,7 +43,7 @@ public class CarrierReaderFromCSVTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void carrierCreation() throws IOException { + void carrierCreation() throws IOException { Config config = ConfigUtils.createConfig(); config.network().setInputFile( "https://raw.githubusercontent.com/matsim-org/matsim/master/examples/scenarios/freight-chessboard-9x9/grid9x9.xml"); @@ -160,7 +160,7 @@ public void carrierCreation() throws IOException { } @Test - public void csvCarrierReader() throws IOException { + void csvCarrierReader() throws IOException { Path carrierCSVLocation = Path.of(utils.getPackageInputDirectory() + "testCarrierCSV.csv"); Set allNewCarrierInformation = CarrierReaderFromCSV diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java index a8b19900587..7db97056e79 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java @@ -9,8 +9,8 @@ import java.util.Set; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -41,7 +41,7 @@ public class DemandReaderFromCSVTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testLinkForPerson() throws IOException { + void testLinkForPerson() throws IOException { Config config = ConfigUtils.createConfig(); config.network().setInputFile( "https://raw.githubusercontent.com/matsim-org/matsim-libs/master/examples/scenarios/freight-chessboard-9x9/grid9x9.xml"); @@ -67,7 +67,7 @@ public void testLinkForPerson() throws IOException { } @Test - public void demandCreation() throws IOException { + void demandCreation() throws IOException { // read inputs Config config = ConfigUtils.createConfig(); config.network().setInputFile( @@ -239,7 +239,7 @@ public void demandCreation() throws IOException { } @Test - public void csvDemandReader() throws IOException { + void csvDemandReader() throws IOException { Path demandCSVLocation = Path.of(utils.getPackageInputDirectory() + "testDemandCSV.csv"); Set demandInformation = DemandReaderFromCSV.readDemandInformation(demandCSVLocation); diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationTest.java index 5d42bcd5ab3..f1285ff809a 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationTest.java @@ -2,8 +2,8 @@ import org.apache.logging.log4j.LogManager; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; import java.nio.file.Path; @@ -19,7 +19,7 @@ public class FreightDemandGenerationTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testMain() { + void testMain() { try { Path output = Path.of(utils.getOutputDirectory()); Path vehicleFilePath = Path.of(utils.getPackageInputDirectory() + "testVehicleTypes.xml"); diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtilsTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtilsTest.java index ea14e21ad6b..cedeccd9dfb 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtilsTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtilsTest.java @@ -3,9 +3,9 @@ import java.nio.file.Path; import java.util.Collection; -import org.junit.Assert; +import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.locationtech.jts.geom.Point; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -18,8 +18,8 @@ import org.matsim.core.population.PopulationUtils; import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.testcases.MatsimTestUtils; -import org.opengis.feature.simple.SimpleFeature; - +import org.opengis.feature.simple.SimpleFeature; + /** * @author Ricardo Ewert * @@ -27,10 +27,10 @@ public class FreightDemandGenerationUtilsTest { @RegisterExtension - private MatsimTestUtils utils = new MatsimTestUtils(); - - @Test - public void testPreparePopulation() { + private MatsimTestUtils utils = new MatsimTestUtils(); + + @Test + void testPreparePopulation() { String populationLocation = utils.getPackageInputDirectory() + "testPopulation.xml"; Population population = PopulationUtils.readPopulation(populationLocation); FreightDemandGenerationUtils.preparePopulation(population, 1.0, 1.0, "changeNumberOfLocationsWithDemand"); @@ -78,9 +78,10 @@ public void testPreparePopulation() { Assert.assertEquals(5200.0,person.getAttributes().getAttribute("homeY")); Assert.assertEquals(0, person.getPlans().size()); Assert.assertNull(person.getSelectedPlan()); - } - @Test - public void testCoordOfMiddlePointOfLink() { + } + + @Test + void testCoordOfMiddlePointOfLink() { Network network = NetworkUtils.readNetwork("https://raw.githubusercontent.com/matsim-org/matsim-libs/master/examples/scenarios/freight-chessboard-9x9/grid9x9.xml"); Link link = network.getLinks().get(Id.createLinkId("i(8,8)")); Coord middlePoint = FreightDemandGenerationUtils.getCoordOfMiddlePointOfLink(link); @@ -90,9 +91,10 @@ public void testCoordOfMiddlePointOfLink() { Coord middlePoint2 = FreightDemandGenerationUtils.getCoordOfMiddlePointOfLink(link2); Assert.assertEquals(5000, middlePoint2.getX(), MatsimTestUtils.EPSILON); Assert.assertEquals(7500, middlePoint2.getY(), MatsimTestUtils.EPSILON); - } - @Test - public void testReducePopulationToShapeArea() { + } + + @Test + void testReducePopulationToShapeArea() { String populationLocation = utils.getPackageInputDirectory() + "testPopulation.xml"; Population population = PopulationUtils.readPopulation(populationLocation); FreightDemandGenerationUtils.preparePopulation(population, 1.0, 1.0, "changeNumberOfLocationsWithDemand"); @@ -103,9 +105,10 @@ public void testReducePopulationToShapeArea() { Assert.assertEquals(6, population.getPersons().size()); Assert.assertFalse(population.getPersons().containsKey(Id.createPersonId("person2"))); Assert.assertFalse(population.getPersons().containsKey(Id.createPersonId("person4"))); - } - @Test - public void testCheckPositionInShape_link() { + } + + @Test + void testCheckPositionInShape_link() { Network network = NetworkUtils.readNetwork("https://raw.githubusercontent.com/matsim-org/matsim-libs/master/examples/scenarios/freight-chessboard-9x9/grid9x9.xml"); Link link = network.getLinks().get(Id.createLinkId("i(8,8)")); Path shapeFilePath = Path.of(utils.getPackageInputDirectory() + "testShape/testShape.shp"); @@ -119,9 +122,10 @@ public void testCheckPositionInShape_link() { Assert.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[]{"area1"}, null)); Assert.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[]{"area2"}, null)); - } - @Test - public void testCheckPositionInShape_point() { + } + + @Test + void testCheckPositionInShape_point() { Path shapeFilePath = Path.of(utils.getPackageInputDirectory() + "testShape/testShape.shp"); ShpOptions shp = new ShpOptions(shapeFilePath,"WGS84", null); Collection polygonsInShape = shp.readFeatures(); diff --git a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/LanduseBuildingAnalysisTest.java b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/LanduseBuildingAnalysisTest.java index 5ad5e0de362..4255b694d0e 100644 --- a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/LanduseBuildingAnalysisTest.java +++ b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/LanduseBuildingAnalysisTest.java @@ -21,8 +21,8 @@ import it.unimi.dsi.fastutil.objects.Object2DoubleMap; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.application.options.ShpOptions; import org.matsim.application.options.ShpOptions.Index; import org.matsim.testcases.MatsimTestUtils; @@ -46,7 +46,7 @@ public class LanduseBuildingAnalysisTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testReadOfDataDistributionPerZoneAndBuildingAnalysis() throws IOException { + void testReadOfDataDistributionPerZoneAndBuildingAnalysis() throws IOException { HashMap> landuseCategoriesAndDataConnection = new HashMap>(); HashMap>> buildingsPerZone = new HashMap<>(); @@ -239,7 +239,7 @@ public void testReadOfDataDistributionPerZoneAndBuildingAnalysis() throws IOExce } @Test - public void testLanduseDistribution() throws IOException { + void testLanduseDistribution() throws IOException { HashMap> landuseCategoriesAndDataConnection = new HashMap>(); HashMap>> buildingsPerZone = new HashMap<>(); diff --git a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/RunGenerateSmallScaleCommercialTrafficTest.java b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/RunGenerateSmallScaleCommercialTrafficTest.java index a916ccae961..43fa34e8a5d 100644 --- a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/RunGenerateSmallScaleCommercialTrafficTest.java +++ b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/RunGenerateSmallScaleCommercialTrafficTest.java @@ -20,8 +20,8 @@ package org.matsim.smallScaleCommercialTrafficGeneration; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; @@ -47,7 +47,7 @@ public class RunGenerateSmallScaleCommercialTrafficTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testMainRunAndResults() { + void testMainRunAndResults() { String inputDataDirectory = utils.getPackageInputDirectory() + "config_demand.xml"; String output = utils.getOutputDirectory(); String sample = "0.1"; diff --git a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/SmallScaleCommercialTrafficUtilsTest.java b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/SmallScaleCommercialTrafficUtilsTest.java index fab0c22abc4..f73b0698099 100644 --- a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/SmallScaleCommercialTrafficUtilsTest.java +++ b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/SmallScaleCommercialTrafficUtilsTest.java @@ -20,8 +20,8 @@ package org.matsim.smallScaleCommercialTrafficGeneration; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -50,7 +50,7 @@ public class SmallScaleCommercialTrafficUtilsTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void findZoneOfLinksTest() throws IOException, URISyntaxException { + void findZoneOfLinksTest() throws IOException, URISyntaxException { Path inputDataDirectory = Path.of(utils.getPackageInputDirectory()); Path shapeFileZonePath = inputDataDirectory.resolve("shp/testZones.shp"); diff --git a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TrafficVolumeGenerationTest.java b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TrafficVolumeGenerationTest.java index 05d4e824089..c2e7ff89bd0 100644 --- a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TrafficVolumeGenerationTest.java +++ b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TrafficVolumeGenerationTest.java @@ -21,8 +21,8 @@ import it.unimi.dsi.fastutil.objects.Object2DoubleMap; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -53,7 +53,7 @@ public class TrafficVolumeGenerationTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testTrafficVolumeGenerationCommercialPersonTraffic() throws IOException { + void testTrafficVolumeGenerationCommercialPersonTraffic() throws IOException { HashMap> landuseCategoriesAndDataConnection = new HashMap<>(); HashMap>> buildingsPerZone = new HashMap<>(); @@ -183,7 +183,7 @@ public void testTrafficVolumeGenerationCommercialPersonTraffic() throws IOExcept } @Test - public void testTrafficVolumeGenerationGoodsTraffic() throws IOException { + void testTrafficVolumeGenerationGoodsTraffic() throws IOException { HashMap> landuseCategoriesAndDataConnection = new HashMap<>(); HashMap>> buildingsPerZone = new HashMap<>(); @@ -386,7 +386,7 @@ public void testTrafficVolumeGenerationGoodsTraffic() throws IOException { } @Test - public void testAddingExistingScenarios() throws Exception { + void testAddingExistingScenarios() throws Exception { Path inputDataDirectory = Path.of(utils.getPackageInputDirectory()); Path shapeFileZonePath = inputDataDirectory.resolve("shp/testZones.shp"); @@ -452,7 +452,7 @@ public void testAddingExistingScenarios() throws Exception { } @Test - public void testAddingExistingScenariosWithSample() throws Exception { + void testAddingExistingScenariosWithSample() throws Exception { Path inputDataDirectory = Path.of(utils.getPackageInputDirectory()); Path shapeFileZonePath = inputDataDirectory.resolve("shp/testZones.shp"); @@ -503,7 +503,7 @@ public void testAddingExistingScenariosWithSample() throws Exception { } @Test - public void testReducingDemandAfterAddingExistingScenarios_goods() throws Exception { + void testReducingDemandAfterAddingExistingScenarios_goods() throws Exception { HashMap> landuseCategoriesAndDataConnection = new HashMap<>(); HashMap>> buildingsPerZone = new HashMap<>(); @@ -663,7 +663,7 @@ public void testReducingDemandAfterAddingExistingScenarios_goods() throws Except } @Test - public void testReducingDemandAfterAddingExistingScenarios_commercialPersonTraffic() throws Exception { + void testReducingDemandAfterAddingExistingScenarios_commercialPersonTraffic() throws Exception { HashMap> landuseCategoriesAndDataConnection = new HashMap<>(); HashMap>> buildingsPerZone = new HashMap<>(); @@ -754,9 +754,8 @@ public void testReducingDemandAfterAddingExistingScenarios_commercialPersonTraff } - @Test - public void testTrafficVolumeKeyGeneration() { + void testTrafficVolumeKeyGeneration() { String zone = "zone1"; String mode = "modeA"; diff --git a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrixTest.java b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrixTest.java index 9694505cbf2..5d439e96bc9 100644 --- a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrixTest.java +++ b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrixTest.java @@ -21,8 +21,8 @@ import it.unimi.dsi.fastutil.objects.Object2DoubleMap; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -47,7 +47,7 @@ public class TripDistributionMatrixTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testTripDistributionCommercialPersonTrafficTraffic() throws IOException { + void testTripDistributionCommercialPersonTrafficTraffic() throws IOException { HashMap> landuseCategoriesAndDataConnection = new HashMap>(); HashMap>> buildingsPerZone = new HashMap<>(); @@ -137,7 +137,7 @@ public void testTripDistributionCommercialPersonTrafficTraffic() throws IOExcept } @Test - public void testTripDistributionGoodsTraffic() throws IOException { + void testTripDistributionGoodsTraffic() throws IOException { HashMap> landuseCategoriesAndDataConnection = new HashMap>(); HashMap>> buildingsPerZone = new HashMap<>(); diff --git a/contribs/av/src/test/java/org/matsim/contrib/av/flow/RunAvExampleIT.java b/contribs/av/src/test/java/org/matsim/contrib/av/flow/RunAvExampleIT.java index ed3476fc8ea..ddc697ee825 100644 --- a/contribs/av/src/test/java/org/matsim/contrib/av/flow/RunAvExampleIT.java +++ b/contribs/av/src/test/java/org/matsim/contrib/av/flow/RunAvExampleIT.java @@ -26,8 +26,8 @@ import java.net.MalformedURLException; import java.net.URL; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -38,7 +38,7 @@ public class RunAvExampleIT { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testAvFlowExample() throws MalformedURLException { + void testAvFlowExample() throws MalformedURLException { URL configUrl = new File(utils.getPackageInputDirectory() + "config.xml").toURI().toURL(); new RunAvExample().run(configUrl, false); } diff --git a/contribs/av/src/test/java/org/matsim/contrib/av/flow/TestAvFlowFactor.java b/contribs/av/src/test/java/org/matsim/contrib/av/flow/TestAvFlowFactor.java index 916bd3c9e12..2fe06af31f4 100644 --- a/contribs/av/src/test/java/org/matsim/contrib/av/flow/TestAvFlowFactor.java +++ b/contribs/av/src/test/java/org/matsim/contrib/av/flow/TestAvFlowFactor.java @@ -27,8 +27,8 @@ import java.net.URL; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.LinkEnterEvent; @@ -48,7 +48,7 @@ public class TestAvFlowFactor { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testAvFlowFactor() throws MalformedURLException { + void testAvFlowFactor() throws MalformedURLException { URL configUrl = new File(utils.getPackageInputDirectory() + "config.xml").toURI().toURL(); Config config = ConfigUtils.loadConfig(configUrl, new OTFVisConfigGroup()); Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/contribs/av/src/test/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExampleIT.java b/contribs/av/src/test/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExampleIT.java index d9573384ef0..5d7aae5a4e5 100644 --- a/contribs/av/src/test/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExampleIT.java +++ b/contribs/av/src/test/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExampleIT.java @@ -30,8 +30,8 @@ import java.util.Map; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.Leg; @@ -52,7 +52,7 @@ public class RunTaxiPTIntermodalExampleIT { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testIntermodalExample() throws MalformedURLException { + void testIntermodalExample() throws MalformedURLException { URL configUrl = new File(utils.getClassInputDirectory() + "config.xml").toURI().toURL(); new RunTaxiPTIntermodalExample().run(configUrl, false); diff --git a/contribs/av/src/test/java/org/matsim/contrib/av/robotaxi/run/RunDrtAndTaxiExampleTest.java b/contribs/av/src/test/java/org/matsim/contrib/av/robotaxi/run/RunDrtAndTaxiExampleTest.java index 2a85956ae3f..aa513d2a9e5 100644 --- a/contribs/av/src/test/java/org/matsim/contrib/av/robotaxi/run/RunDrtAndTaxiExampleTest.java +++ b/contribs/av/src/test/java/org/matsim/contrib/av/robotaxi/run/RunDrtAndTaxiExampleTest.java @@ -22,13 +22,13 @@ import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; public class RunDrtAndTaxiExampleTest { @Test - public void run() { + void run() { URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("dvrp-grid"), "one_taxi_and_one_shared_taxi_config.xml"); RunDrtAndTaxiExample.run(configUrl, false); diff --git a/contribs/av/src/test/java/org/matsim/contrib/av/robotaxi/run/RunRobotaxiExampleIT.java b/contribs/av/src/test/java/org/matsim/contrib/av/robotaxi/run/RunRobotaxiExampleIT.java index 9c56af75336..a256bd46e52 100644 --- a/contribs/av/src/test/java/org/matsim/contrib/av/robotaxi/run/RunRobotaxiExampleIT.java +++ b/contribs/av/src/test/java/org/matsim/contrib/av/robotaxi/run/RunRobotaxiExampleIT.java @@ -22,7 +22,7 @@ import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; @@ -31,7 +31,7 @@ */ public class RunRobotaxiExampleIT { @Test - public void testRun() { + void testRun() { URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_taxi_config.xml"); RunRobotaxiExample.run(configUrl, false); } diff --git a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleLinkSpeedCalculatorTest.java b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleLinkSpeedCalculatorTest.java index 8ee7bcdc13d..9bba0878b85 100644 --- a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleLinkSpeedCalculatorTest.java +++ b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleLinkSpeedCalculatorTest.java @@ -1,8 +1,8 @@ package org.matsim.contrib.bicycle; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -59,8 +59,8 @@ private static Vehicle createVehicle(double maxVelocity, long id) { return VehicleUtils.createVehicle(Id.createVehicleId(id), type); } - @Test - public void getMaximumVelocity_bike() { + @Test + void getMaximumVelocity_bike() { Link link = createLinkWithNoGradientAndNoSpecialSurface(); QVehicle vehicle = new QVehicleImpl(createVehicle(link.getFreespeed() * 0.5, 1)); // higher speed than the default @@ -71,8 +71,8 @@ public void getMaximumVelocity_bike() { assertEquals(vehicle.getMaximumVelocity(), speed, 0.0); } - @Test - public void getMaximumVelocity_bike_fasterThanFreespeed() { + @Test + void getMaximumVelocity_bike_fasterThanFreespeed() { Link link = createLinkWithNoGradientAndNoSpecialSurface(); QVehicle vehicle = new QVehicleImpl(createVehicle(link.getFreespeed() * 2, 1)); @@ -83,8 +83,8 @@ public void getMaximumVelocity_bike_fasterThanFreespeed() { assertEquals(link.getFreespeed(), speed, 0.0); } - @Test - public void getMaximumVelocityForLink_bikeIsNull() { + @Test + void getMaximumVelocityForLink_bikeIsNull() { Link link = createLinkWithNoGradientAndNoSpecialSurface(); BicycleLinkSpeedCalculatorDefaultImpl calculator = new BicycleLinkSpeedCalculatorDefaultImpl(config); @@ -94,8 +94,8 @@ public void getMaximumVelocityForLink_bikeIsNull() { assertEquals(configGroup.getMaxBicycleSpeedForRouting(), speed, 0.001); } - @Test - public void getMaximumVelocityForLink_withGradient() { + @Test + void getMaximumVelocityForLink_withGradient() { Link linkForComparison = createLinkWithNoGradientAndNoSpecialSurface(); Link linkWithGradient = createLink(100, "paved", "not-a-cycle-way", 1.0); @@ -109,8 +109,8 @@ public void getMaximumVelocityForLink_withGradient() { assertTrue(comparisonSpeed > gradientSpeed); } - @Test - public void getMaximumVelocityForLink_withReducedSpeedFactor() { + @Test + void getMaximumVelocityForLink_withReducedSpeedFactor() { Link linkForComparison = createLinkWithNoGradientAndNoSpecialSurface(); Link linkWithReducedSpeed = createLink(0, "paved", "not-a-cycle-way", 0.5); @@ -124,8 +124,8 @@ public void getMaximumVelocityForLink_withReducedSpeedFactor() { assertTrue(comparisonSpeed > gradientSpeed); } - @Test - public void getMaximumVelocityForLink_noSpeedFactor() { + @Test + void getMaximumVelocityForLink_noSpeedFactor() { var link = createLinkWithNoGradientAndNoSpecialSurface(); var vehicle = createVehicle(link.getFreespeed() + 1, 1); @@ -136,8 +136,8 @@ public void getMaximumVelocityForLink_noSpeedFactor() { assertEquals(link.getFreespeed(), speed, 0.001); } - @Test - public void getMaximumVelocityForLink_withRoughSurface() { + @Test + void getMaximumVelocityForLink_withRoughSurface() { Link linkForComparison = createLinkWithNoGradientAndNoSpecialSurface(); Link linkWithCobbleStone = createLink(0, "cobblestone", "not-a-cycle-way", 1.0); @@ -178,8 +178,8 @@ private Link createLink(double elevation, String surfaceType, String wayType, do return link; } - @Test - public void getMaximumVelocityForLink_withCycleWay() { + @Test + void getMaximumVelocityForLink_withCycleWay() { Link linkForComparison = createLinkWithNoGradientAndNoSpecialSurface(); Link linkWithCobbleStone = createLink(0, "some-surface", BicycleUtils.CYCLEWAY, 1.0); diff --git a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleUtilityUtilsTest.java b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleUtilityUtilsTest.java index 19697a3afaf..5e8ebb2f5d9 100644 --- a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleUtilityUtilsTest.java +++ b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleUtilityUtilsTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.bicycle; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -11,31 +11,31 @@ public class BicycleUtilityUtilsTest { @Test - public void getGradientNoFromZ() { + void getGradientNoFromZ() { var link = createLink(new Coord(0, 0), new Coord(100, 0, 100)); assertEquals(0., BicycleUtils.getGradient(link ), 0.00001 ); } @Test - public void getGradientNoToZ() { + void getGradientNoToZ() { var link = createLink(new Coord(0, 0, 100), new Coord(100, 0)); assertEquals(0., BicycleUtils.getGradient(link ), 0.00001 ); } @Test - public void getGradientFlat() { + void getGradientFlat() { var link = createLink(new Coord(0, 0, 100), new Coord(100, 0, 100)); assertEquals(0., BicycleUtils.getGradient(link ), 0.00001 ); } @Test - public void getGradientUphill() { + void getGradientUphill() { var link = createLink(new Coord(0, 0, 0), new Coord(100, 0, 100)); assertEquals(1., BicycleUtils.getGradient(link ), 0.00001 ); } @Test - public void getGradientDownhill() { + void getGradientDownhill() { var link = createLink(new Coord(0, 0, 100), new Coord(100, 0, 0)); assertEquals(0., BicycleUtils.getGradient(link ), 0.00001 ); } diff --git a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java index e3a50e711df..e14c9e48b76 100644 --- a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java +++ b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java @@ -21,7 +21,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -79,7 +79,7 @@ public class BicycleTest { public MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testNormal() { + void testNormal() { Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -113,7 +113,7 @@ public void testNormal() { } @Test - public void testCobblestone() { + void testCobblestone() { Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -146,7 +146,7 @@ public void testCobblestone() { } @Test - public void testPedestrian() { + void testPedestrian() { Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -175,7 +175,7 @@ public void testPedestrian() { } @Test - public void testLane() { + void testLane() { Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -204,7 +204,7 @@ public void testLane() { } @Test - public void testGradient() { + void testGradient() { Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -233,7 +233,7 @@ public void testGradient() { } @Test - public void testGradientLane() { + void testGradientLane() { Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -263,7 +263,7 @@ public void testGradientLane() { } @Test - public void testNormal10It() { + void testNormal10It() { Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); RunBicycleExample.fillConfigWithBicycleStandardValues(config); @@ -294,7 +294,8 @@ public void testNormal10It() { assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); } - @Test public void testLinkBasedScoring() { + @Test + void testLinkBasedScoring() { // { // Config config = createConfig( 0 ); // BicycleConfigGroup bicycleConfigGroup = (BicycleConfigGroup) config.getModules().get( "bicycle" ); @@ -325,7 +326,9 @@ public void testNormal10It() { } // assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); } - @Test public void testLinkVsLegMotorizedScoring() { + + @Test + void testLinkVsLegMotorizedScoring() { // --- withOUT additional car traffic: // { // Config config2 = createConfig( 0 ); @@ -411,6 +414,7 @@ public void testNormal10It() { } // assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); } + // @Test public void testMotorizedInteraction() { //// Config config = ConfigUtils.createConfig("./src/main/resources/bicycle_example/"); // Config config = createConfig( 10 ); @@ -441,7 +445,7 @@ public void testNormal10It() { // } @Test - public void testInfrastructureSpeedFactor() { + void testInfrastructureSpeedFactor() { Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); @@ -536,7 +540,7 @@ public void install() { } @Test - public void testInfrastructureSpeedFactorDistanceMoreRelevantThanTravelTime() { + void testInfrastructureSpeedFactorDistanceMoreRelevantThanTravelTime() { Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); BicycleConfigGroup bicycleConfigGroup = ConfigUtils.addOrGetModule( config, BicycleConfigGroup.class ); diff --git a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java index 815fc250dc3..85c1d6f6e88 100644 --- a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java +++ b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java @@ -24,8 +24,8 @@ import cadyts.utilities.io.tabularFileParser.TabularFileParser; import cadyts.utilities.misc.DynamicData; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -82,7 +82,7 @@ public class CadytsCarIT { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public final void testInitialization() { + final void testInitialization() { final String CADYTS_STRATEGY_NAME = "ccc"; String inputDir = this.utils.getClassInputDirectory(); @@ -154,7 +154,7 @@ public PlanStrategy get() { //-------------------------------------------------------------- @Test - public final void testCalibrationAsScoring() throws IOException { + final void testCalibrationAsScoring() throws IOException { final double beta=30. ; final int lastIteration = 20 ; diff --git a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarWithPtScenarioIT.java b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarWithPtScenarioIT.java index 58f3b81fb2f..08ccf453ef9 100644 --- a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarWithPtScenarioIT.java +++ b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarWithPtScenarioIT.java @@ -5,7 +5,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.handler.LinkLeaveEventHandler; @@ -22,8 +22,9 @@ public class CadytsCarWithPtScenarioIT { - @Test @Ignore - public void testCadytsWithPtVehicles() { + @Test + @Ignore + void testCadytsWithPtVehicles() { final Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("siouxfalls-2014"), "config_default.xml")); config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); config.controller().setLastIteration(0); diff --git a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/utils/CalibrationStatReaderTest.java b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/utils/CalibrationStatReaderTest.java index f8512146bf5..1da4d65881a 100644 --- a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/utils/CalibrationStatReaderTest.java +++ b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/utils/CalibrationStatReaderTest.java @@ -22,8 +22,8 @@ import java.io.IOException; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; import cadyts.utilities.io.tabularFileParser.TabularFileParser; @@ -34,7 +34,7 @@ public class CalibrationStatReaderTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testReader() throws IOException { + void testReader() throws IOException { TabularFileParser tabularFileParser = new TabularFileParser(); String calibStatFile = this.utils.getInputDirectory() + "calibration-stats.txt"; CalibrationStatReader calibrationStatReader = new CalibrationStatReader(); diff --git a/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java b/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java index 6b95a948fbe..4f862921469 100644 --- a/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java +++ b/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java @@ -26,8 +26,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.analysis.LegHistogram; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -58,7 +58,7 @@ public class RunCarsharingIT { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public final void test() { + final void test() { Config config = ConfigUtils.loadConfig(utils.getClassInputDirectory() + "/config.xml", new FreeFloatingConfigGroup(), new OneWayCarsharingConfigGroup(), diff --git a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/ChangeCommercialJobOperatorTest.java b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/ChangeCommercialJobOperatorTest.java index 18de26d446d..6fb30f6b0b7 100644 --- a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/ChangeCommercialJobOperatorTest.java +++ b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/ChangeCommercialJobOperatorTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.commercialTrafficApplications.jointDemand; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -17,8 +17,8 @@ public class ChangeCommercialJobOperatorTest { - @Test - public void getPlanAlgoInstance() { + @Test + void getPlanAlgoInstance() { Carriers carriers = TestScenarioGeneration.generateCarriers(); diff --git a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/CommercialTrafficIntegrationTest.java b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/CommercialTrafficIntegrationTest.java index 27b59b0d621..c0132d8903c 100644 --- a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/CommercialTrafficIntegrationTest.java +++ b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/CommercialTrafficIntegrationTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.commercialTrafficApplications.jointDemand; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.freight.carriers.FreightCarriersConfigGroup; import org.matsim.freight.carriers.CarriersUtils; @@ -12,8 +12,8 @@ public class CommercialTrafficIntegrationTest { - @Test - public void runCommercialTrafficIT() { + @Test + void runCommercialTrafficIT() { Config config = ConfigUtils.loadConfig("./scenarios/grid/jointDemand_config.xml"); config.controller().setLastIteration(5); ConfigUtils.addOrGetModule(config, JointDemandConfigGroup.class); diff --git a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialServiceScoreTest.java b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialServiceScoreTest.java index b96b3e5ca86..051e97829e9 100644 --- a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialServiceScoreTest.java +++ b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialServiceScoreTest.java @@ -1,13 +1,13 @@ package org.matsim.contrib.commercialTrafficApplications.jointDemand; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contrib.commercialTrafficApplications.jointDemand.DefaultCommercialServiceScore; public class DefaultCommercialServiceScoreTest { - @Test - public void calcScore() { + @Test + void calcScore() { DefaultCommercialServiceScore serviceScore = new DefaultCommercialServiceScore(6, -6, 1800); Assert.assertEquals(serviceScore.calcScore(0), 6., 0.001); diff --git a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/IsTheRightCustomerScoredTest.java b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/IsTheRightCustomerScoredTest.java index b9f40a81c5d..f71e9a3a3ed 100644 --- a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/IsTheRightCustomerScoredTest.java +++ b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/IsTheRightCustomerScoredTest.java @@ -20,7 +20,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Activity; @@ -98,8 +98,8 @@ private void preparePopulation(Scenario scenario) { } - @Test - public void testIfTheRightPersonIsScoredForReceivingAJob() { + @Test + void testIfTheRightPersonIsScoredForReceivingAJob() { Plan partyPizzaPlan = scenario.getPopulation().getPersons().get(Id.createPersonId("customerOrderingForParty")).getSelectedPlan(); Plan lonelyPizzaPlan = scenario.getPopulation().getPersons().get(Id.createPersonId("customerOrderingJustForItself")).getSelectedPlan(); Plan nonCustomerPlan = scenario.getPopulation().getPersons().get(Id.createPersonId("nonCustomer")).getSelectedPlan(); diff --git a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/RunJointDemandCarExampleSkipIntervalIT.java b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/RunJointDemandCarExampleSkipIntervalIT.java index 5ec00c316dc..884319ca6ef 100644 --- a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/RunJointDemandCarExampleSkipIntervalIT.java +++ b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/RunJointDemandCarExampleSkipIntervalIT.java @@ -1,13 +1,13 @@ package org.matsim.contrib.commercialTrafficApplications.jointDemand; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; public class RunJointDemandCarExampleSkipIntervalIT { @Test - public void main() throws IOException { + void main() throws IOException { RunJointDemandCarToggleJspritExample.main(new String[0]); } } \ No newline at end of file diff --git a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandCarExampleIT.java b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandCarExampleIT.java index 5d07acb7686..663f68d69e2 100644 --- a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandCarExampleIT.java +++ b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandCarExampleIT.java @@ -1,6 +1,6 @@ package org.matsim.contrib.commercialTrafficApplications.jointDemand.examples; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contrib.commercialTrafficApplications.jointDemand.examples.RunJointDemandCarExample; import java.io.IOException; @@ -8,7 +8,7 @@ public class RunJointDemandCarExampleIT { @Test - public void main() throws IOException { + void main() throws IOException { RunJointDemandCarExample.main(new String[0]); } } \ No newline at end of file diff --git a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExampleIT.java b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExampleIT.java index 30fbe9ef2c0..e62b15cc0ba 100644 --- a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExampleIT.java +++ b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExampleIT.java @@ -1,6 +1,6 @@ package org.matsim.contrib.commercialTrafficApplications.jointDemand.examples; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contrib.commercialTrafficApplications.jointDemand.examples.RunJointDemandDRTExample; import java.io.IOException; @@ -8,7 +8,7 @@ public class RunJointDemandDRTExampleIT { @Test - public void main() throws IOException { + void main() throws IOException { RunJointDemandDRTExample.main(new String[0]); } } \ No newline at end of file diff --git a/contribs/common/src/test/java/org/matsim/contrib/common/collections/PartialSortTest.java b/contribs/common/src/test/java/org/matsim/contrib/common/collections/PartialSortTest.java index 84371963d61..2609969dd8c 100644 --- a/contribs/common/src/test/java/org/matsim/contrib/common/collections/PartialSortTest.java +++ b/contribs/common/src/test/java/org/matsim/contrib/common/collections/PartialSortTest.java @@ -24,9 +24,9 @@ import static org.matsim.contrib.common.collections.PartialSort.kSmallestElements; import java.util.Comparator; -import java.util.stream.Stream; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import java.util.stream.Stream; /** * @author Michal Maciejewski (michalm) @@ -35,36 +35,36 @@ public class PartialSortTest { private final Comparator comparator = Integer::compareTo; @Test - public void k0_noneSelected() { + void k0_noneSelected() { assertThat(kSmallestElements(0, Stream.of(), comparator)).isEmpty(); assertThat(kSmallestElements(0, Stream.of(7, 1, 4, 9, 8), comparator)).isEmpty(); } @Test - public void reversedComparator_largestElementsSelected() { + void reversedComparator_largestElementsSelected() { assertThat(kSmallestElements(1, Stream.of(7, 1, 4, 9, 8), comparator.reversed())).containsExactly(9); assertThat(kSmallestElements(3, Stream.of(7, 1, 4, 9, 8), comparator.reversed())).containsExactly(9, 8, 7); } @Test - public void allElementsPairwiseNonEqual_inputOrderNotImportant() { + void allElementsPairwiseNonEqual_inputOrderNotImportant() { assertThat(kSmallestElements(3, Stream.of(1, 7, 9, 8), comparator)).containsExactly(1, 7, 8); assertThat(kSmallestElements(3, Stream.of(9, 8, 7, 1), comparator)).containsExactly(1, 7, 8); } @Test - public void exactlyKElementsProvided() { + void exactlyKElementsProvided() { assertThat(kSmallestElements(3, Stream.of(7, 1, 4), comparator)).containsExactly(1, 4, 7); } @Test - public void moreThenKElementsProvided() { + void moreThenKElementsProvided() { assertThat(kSmallestElements(3, Stream.of(7, 1, 4, 9, 8), comparator)).containsExactly(1, 4, 7); assertThat(kSmallestElements(3, Stream.of(13, 7, 1, 55, 4, 9, 8, 11), comparator)).containsExactly(1, 4, 7); } @Test - public void lessThenKElementsProvided() { + void lessThenKElementsProvided() { assertThat(kSmallestElements(3, Stream.of(7, 1), comparator)).containsExactly(1, 7); assertThat(kSmallestElements(3, Stream.of(13), comparator)).containsExactly(13); assertThat(kSmallestElements(3, Stream.of(), comparator)).isEmpty(); diff --git a/contribs/common/src/test/java/org/matsim/contrib/common/diversitygeneration/planselectors/DiversityGeneratingPlansRemoverTest.java b/contribs/common/src/test/java/org/matsim/contrib/common/diversitygeneration/planselectors/DiversityGeneratingPlansRemoverTest.java index a0025ce5638..a2b73e1657d 100644 --- a/contribs/common/src/test/java/org/matsim/contrib/common/diversitygeneration/planselectors/DiversityGeneratingPlansRemoverTest.java +++ b/contribs/common/src/test/java/org/matsim/contrib/common/diversitygeneration/planselectors/DiversityGeneratingPlansRemoverTest.java @@ -5,7 +5,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -45,9 +45,9 @@ public class DiversityGeneratingPlansRemoverTest { private final Id link0_1 = Id.createLinkId( "dummy0-1" ); private final Id link1_2 = Id.createLinkId( "dummy1-2" ); private final Id link2_3 = Id.createLinkId( "dummyN" ); - + @Test - public void calcWeights() { + void calcWeights() { // yy This is not really a strong test. Rather something I wrote for debugging. Would be a good // starting point for a fuller test. kai, jul'18 @@ -221,8 +221,8 @@ private Plan createHwhPlan( final PopulationFactory pf ) { plan.setScore(90.) ; return plan; } - + @Test - public void selectPlan() { + void selectPlan() { } } diff --git a/contribs/common/src/test/java/org/matsim/contrib/common/util/WeightedRandomSelectionTest.java b/contribs/common/src/test/java/org/matsim/contrib/common/util/WeightedRandomSelectionTest.java index f96b4468202..fb30100ab83 100644 --- a/contribs/common/src/test/java/org/matsim/contrib/common/util/WeightedRandomSelectionTest.java +++ b/contribs/common/src/test/java/org/matsim/contrib/common/util/WeightedRandomSelectionTest.java @@ -27,7 +27,7 @@ import org.apache.commons.lang3.mutable.MutableDouble; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author michalm @@ -48,7 +48,7 @@ public double nextDouble(double from, double to) { } @Test - public void testIncorrectInput() { + void testIncorrectInput() { assertIncorrectWeight(-Double.MIN_VALUE); assertIncorrectWeight(-1); assertIncorrectWeight(-Double.MAX_VALUE); @@ -71,7 +71,7 @@ private void assertIncorrectWeight(double weight) { } @Test - public void testEmptyList() { + void testEmptyList() { assertThat(weightedRandomSelection.size()).isEqualTo(0); assertThatThrownBy(() -> weightedRandomSelection.select())// .isExactlyInstanceOf(IllegalStateException.class)// @@ -79,7 +79,7 @@ public void testEmptyList() { } @Test - public void testZeroTotalWeight() { + void testZeroTotalWeight() { weightedRandomSelection.add("A", 0.); weightedRandomSelection.add("B", 0.); assertThatThrownBy(() -> weightedRandomSelection.select())// @@ -88,7 +88,7 @@ public void testZeroTotalWeight() { } @Test - public void testSingleValueList() { + void testSingleValueList() { weightedRandomSelection.add("A", 1); assertThat(weightedRandomSelection.size()).isEqualTo(1); @@ -100,7 +100,7 @@ public void testSingleValueList() { } @Test - public void testThreeValuesList() { + void testThreeValuesList() { weightedRandomSelection.add("A", 1); weightedRandomSelection.add("B", 0.5); weightedRandomSelection.add("C", 1.5); diff --git a/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest66IT.java b/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest66IT.java index 4e6afb73afd..09772d843d3 100644 --- a/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest66IT.java +++ b/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest66IT.java @@ -32,8 +32,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -94,7 +94,7 @@ public class BetaTravelTest66IT { private MatsimTestUtils utils = new MatsimTestUtils(); - /* This TestCase uses a custom Controler, named TestControler, to load + /*This TestCase uses a custom Controler, named TestControler, to load * specific strategies. The strategies make use of a test-specific * TimeAllocationMutator, the TimeAllocationMutatorBottleneck. * LinkAnalyzer, an event handler, collects some statistics on the @@ -130,7 +130,8 @@ public class BetaTravelTest66IT { * * @author mrieser */ - @Test public void testBetaTravel_66() { + @Test + void testBetaTravel_66() { Config config = utils.loadConfig("../../examples/scenarios/equil/config.xml"); ConfigUtils.loadConfig(config, utils.getInputDirectory() + "config.xml"); config.controller().setWritePlansInterval(0); diff --git a/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest6IT.java b/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest6IT.java index de0ecae4685..da2037aa8cd 100644 --- a/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest6IT.java +++ b/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest6IT.java @@ -32,8 +32,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -95,7 +95,7 @@ public class BetaTravelTest6IT { private MatsimTestUtils utils = new MatsimTestUtils(); - /* This TestCase uses a custom Controler, named TestControler, to load + /*This TestCase uses a custom Controler, named TestControler, to load * specific strategies. The strategies make use of a test-specific * TimeAllocationMutator, the TimeAllocationMutatorBottleneck. * LinkAnalyzer, an event handler, collects some statistics on the @@ -130,7 +130,8 @@ public class BetaTravelTest6IT { * * @author mrieser */ - @Test public void testBetaTravel_6() { + @Test + void testBetaTravel_6() { Config config = utils.loadConfig("../../examples/scenarios/equil/config.xml"); // default config ConfigUtils.loadConfig(config, utils.getInputDirectory() + "config.xml"); // specific setting for this test config.controller().setWritePlansInterval(0); diff --git a/contribs/decongestion/src/test/java/org/matsim/contrib/decongestion/DecongestionPricingTestIT.java b/contribs/decongestion/src/test/java/org/matsim/contrib/decongestion/DecongestionPricingTestIT.java index a59cc8f2027..7ff2403f49b 100644 --- a/contribs/decongestion/src/test/java/org/matsim/contrib/decongestion/DecongestionPricingTestIT.java +++ b/contribs/decongestion/src/test/java/org/matsim/contrib/decongestion/DecongestionPricingTestIT.java @@ -23,8 +23,8 @@ package org.matsim.contrib.decongestion; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.analysis.ScoreStatsControlerListener.ScoreItem; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -62,7 +62,7 @@ public class DecongestionPricingTestIT { * */ @Test - public final void test0a() { + final void test0a() { System.out.println(testUtils.getPackageInputDirectory()); @@ -151,7 +151,7 @@ public void install() { * */ @Test - public final void test0amodified() { + final void test0amodified() { System.out.println(testUtils.getPackageInputDirectory()); @@ -211,7 +211,7 @@ public void install() { * */ @Test - public final void test0b() { + final void test0b() { System.out.println(testUtils.getPackageInputDirectory()); @@ -299,7 +299,7 @@ public void install() { * */ @Test - public final void test0bmodified() { + final void test0bmodified() { System.out.println(testUtils.getPackageInputDirectory()); @@ -359,7 +359,7 @@ public void install() { * */ @Test - public final void test0c() { + final void test0c() { System.out.println(testUtils.getPackageInputDirectory()); @@ -440,7 +440,7 @@ public void install() { * */ @Test - public final void test1() { + final void test1() { System.out.println(testUtils.getPackageInputDirectory()); @@ -501,7 +501,7 @@ public void install() { * */ @Test - public final void test2() { + final void test2() { System.out.println(testUtils.getPackageInputDirectory()); diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/SubtourModeChoiceReplacementTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/SubtourModeChoiceReplacementTest.java index 2abbf28777c..b9cab362620 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/SubtourModeChoiceReplacementTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/SubtourModeChoiceReplacementTest.java @@ -9,7 +9,7 @@ import java.util.Random; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.population.Plan; import org.matsim.contrib.discrete_mode_choice.test_utils.PlanBuilder; import org.matsim.contrib.discrete_mode_choice.test_utils.PlanTester; @@ -51,7 +51,7 @@ public class SubtourModeChoiceReplacementTest { @Test - public void testChoiceSet() throws NoFeasibleChoiceException { + void testChoiceSet() throws NoFeasibleChoiceException { List modes = Arrays.asList("walk", "pt"); List constrainedModes = Arrays.asList(); boolean considerCarAvailability = true; @@ -140,7 +140,7 @@ public void testChoiceSet() throws NoFeasibleChoiceException { } @Test - public void testConstrainedChoiceSet() throws NoFeasibleChoiceException { + void testConstrainedChoiceSet() throws NoFeasibleChoiceException { List modes = Arrays.asList("walk", "car"); List constrainedModes = Arrays.asList("car"); boolean considerCarAvailability = true; @@ -229,7 +229,7 @@ public void testConstrainedChoiceSet() throws NoFeasibleChoiceException { } @Test - public void testLargerCase() throws NoFeasibleChoiceException { + void testLargerCase() throws NoFeasibleChoiceException { List modes = Arrays.asList("walk", "car", "pt", "bike"); List constrainedModes = Arrays.asList("car", "bike"); boolean considerCarAvailability = true; diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/constraints/VehicleTourConstraintTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/constraints/VehicleTourConstraintTest.java index 24bc7e6ceb5..a95458ffdf4 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/constraints/VehicleTourConstraintTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/constraints/VehicleTourConstraintTest.java @@ -7,7 +7,7 @@ import java.util.Collection; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.contrib.discrete_mode_choice.test_utils.PlanBuilder; @@ -20,7 +20,7 @@ public class VehicleTourConstraintTest { @Test - public void testWithHome() { + void testWithHome() { // PREPARATION HomeFinder homeFinder = (List trips) -> Id.create("A", ActivityFacility.class); Collection availableModes = Arrays.asList("car", "walk"); @@ -69,7 +69,7 @@ public void testWithHome() { } @Test - public void testWithoutHome() { + void testWithoutHome() { // PREPARATION HomeFinder homeFinder = (List trips) -> null; Collection availableModes = Arrays.asList("car", "walk"); @@ -107,7 +107,7 @@ public void testWithoutHome() { } @Test - public void testTour() { + void testTour() { // PREPARATION HomeFinder homeFinder = (List trips) -> Id.create("A", ActivityFacility.class); Collection availableModes = Arrays.asList("car", "walk"); diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/readers/ApolloTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/readers/ApolloTest.java index b58abaf6f80..3e396542e5f 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/readers/ApolloTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/readers/ApolloTest.java @@ -5,13 +5,13 @@ import java.io.IOException; import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contribs.discrete_mode_choice.components.readers.ApolloParameterReader; import org.matsim.contribs.discrete_mode_choice.components.readers.ApolloParameters; public class ApolloTest { @Test - public void testApolloReader() throws IOException { + void testApolloReader() throws IOException { URL fixtureUrl = getClass().getClassLoader().getResource("Model_13_12_Zurich_output.txt"); ApolloParameters parameters = new ApolloParameterReader().read(fixtureUrl); diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/tour_finder/ActivityTourFinderTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/tour_finder/ActivityTourFinderTest.java index af9610761ca..8fd14c7f09a 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/tour_finder/ActivityTourFinderTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/tour_finder/ActivityTourFinderTest.java @@ -6,7 +6,7 @@ import java.util.LinkedList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.population.Plan; import org.matsim.contribs.discrete_mode_choice.components.tour_finder.ActivityTourFinder; import org.matsim.contribs.discrete_mode_choice.model.DiscreteModeChoiceTrip; @@ -42,7 +42,7 @@ private List createFixture(String... activityTypes) { } @Test - public void testActivityTourFinder() { + void testActivityTourFinder() { ActivityTourFinder finder = new ActivityTourFinder(Arrays.asList("home")); List trips; @@ -84,7 +84,7 @@ public void testActivityTourFinder() { } @Test - public void testActivityTourFinderMultiple() { + void testActivityTourFinderMultiple() { ActivityTourFinder finder = new ActivityTourFinder(Arrays.asList("home1", "home2", "home3", "home4")); List trips; diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/utils/ScheduleWaitingTimeEstimatorTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/utils/ScheduleWaitingTimeEstimatorTest.java index 4d19508ad24..2e69210fff1 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/utils/ScheduleWaitingTimeEstimatorTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/utils/ScheduleWaitingTimeEstimatorTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.discrete_mode_choice.components.utils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Activity; @@ -29,7 +29,7 @@ public class ScheduleWaitingTimeEstimatorTest { @Test - public void testValidSingleCase() throws IOException { + void testValidSingleCase() throws IOException { TransitSchedule schedule = createSchedule(); ScheduleWaitingTimeEstimator estimator = new ScheduleWaitingTimeEstimator(schedule); @@ -53,9 +53,9 @@ public void testValidSingleCase() throws IOException { waitingTime = estimator.estimateWaitingTime(elements); assertEquals(995.0, waitingTime, 1e-6); } - + @Test - public void testValidMultiCase() throws IOException { + void testValidMultiCase() throws IOException { TransitSchedule schedule = createSchedule(); ScheduleWaitingTimeEstimator estimator = new ScheduleWaitingTimeEstimator(schedule); @@ -72,10 +72,10 @@ public void testValidMultiCase() throws IOException { waitingTime = estimator.estimateWaitingTime(elements); assertEquals(20.0 + 995.0, waitingTime, 1e-6); } - + @Test - public void testInvalidCase() throws IOException { + void testInvalidCase() throws IOException { TransitSchedule schedule = createSchedule(); ScheduleWaitingTimeEstimator estimator = new ScheduleWaitingTimeEstimator(schedule); diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/examples/TestSiouxFalls.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/examples/TestSiouxFalls.java index 1780065a3fe..5a1edb6623e 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/examples/TestSiouxFalls.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/examples/TestSiouxFalls.java @@ -6,7 +6,7 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.PersonArrivalEvent; import org.matsim.api.core.v01.events.handler.PersonArrivalEventHandler; @@ -24,7 +24,7 @@ public class TestSiouxFalls { @Test - public void testSiouxFallsWithSubtourModeChoiceReplacement() { + void testSiouxFallsWithSubtourModeChoiceReplacement() { URL scenarioURL = ExamplesUtils.getTestScenarioURL("siouxfalls-2014"); Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(scenarioURL, "config_default.xml")); diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/MaximumUtilityTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/MaximumUtilityTest.java index 347139ac155..31bff842634 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/MaximumUtilityTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/MaximumUtilityTest.java @@ -7,7 +7,7 @@ import java.util.List; import java.util.Random; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.population.Activity; import org.matsim.contribs.discrete_mode_choice.model.DiscreteModeChoiceModel.FallbackBehaviour; @@ -31,7 +31,7 @@ public class MaximumUtilityTest { @Test - public void testMaximumUtility() throws NoFeasibleChoiceException { + void testMaximumUtility() throws NoFeasibleChoiceException { TripFilter tripFilter = new CompositeTripFilter(Collections.emptySet()); ModeAvailability modeAvailability = new DefaultModeAvailability(Arrays.asList("car", "pt", "walk")); TripConstraintFactory constraintFactory = new CompositeTripConstraintFactory(); diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/MultinomialLogitTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/MultinomialLogitTest.java index 71bcf10e76b..dbe32f1e8a3 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/MultinomialLogitTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/MultinomialLogitTest.java @@ -9,7 +9,7 @@ import java.util.Map; import java.util.Random; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.population.Activity; import org.matsim.contribs.discrete_mode_choice.model.DiscreteModeChoiceModel.FallbackBehaviour; @@ -33,7 +33,7 @@ public class MultinomialLogitTest { @Test - public void testMultinomialLogit() throws NoFeasibleChoiceException { + void testMultinomialLogit() throws NoFeasibleChoiceException { TripFilter tripFilter = new CompositeTripFilter(Collections.emptySet()); ModeAvailability modeAvailability = new DefaultModeAvailability(Arrays.asList("car", "pt", "walk")); TripConstraintFactory constraintFactory = new CompositeTripConstraintFactory(); diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/NestedLogitTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/NestedLogitTest.java index 84489c34c7c..38e7b54df7d 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/NestedLogitTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/NestedLogitTest.java @@ -9,7 +9,7 @@ import java.util.Map; import java.util.Random; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.population.Activity; import org.matsim.contribs.discrete_mode_choice.model.DiscreteModeChoiceModel.FallbackBehaviour; @@ -35,7 +35,7 @@ public class NestedLogitTest { @Test - public void testRedBusBlueBus() throws NoFeasibleChoiceException { + void testRedBusBlueBus() throws NoFeasibleChoiceException { TripFilter tripFilter = new CompositeTripFilter(Collections.emptySet()); ModeAvailability modeAvailability = new DefaultModeAvailability(Arrays.asList("car", "redbus", "bluebus")); TripConstraintFactory constraintFactory = new CompositeTripConstraintFactory(); diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/RandomUtilityTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/RandomUtilityTest.java index e0f3e7dd619..e69eae5ee23 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/RandomUtilityTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/RandomUtilityTest.java @@ -9,7 +9,7 @@ import java.util.Map; import java.util.Random; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.population.Activity; import org.matsim.contribs.discrete_mode_choice.components.estimators.UniformTripEstimator; @@ -35,7 +35,7 @@ public class RandomUtilityTest { @Test - public void testRandomUtility() throws NoFeasibleChoiceException { + void testRandomUtility() throws NoFeasibleChoiceException { TripFilter tripFilter = new CompositeTripFilter(Collections.emptySet()); ModeAvailability modeAvailability = new DefaultModeAvailability(Arrays.asList("car", "pt", "walk")); TripConstraintFactory constraintFactory = new CompositeTripConstraintFactory(); diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/nested/NestCalculatorTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/nested/NestCalculatorTest.java index 499a955392a..5c344aabd51 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/nested/NestCalculatorTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/nested/NestCalculatorTest.java @@ -2,7 +2,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contribs.discrete_mode_choice.model.DiscreteModeChoiceModel.NoFeasibleChoiceException; import org.matsim.contribs.discrete_mode_choice.model.nested.DefaultNest; import org.matsim.contribs.discrete_mode_choice.model.nested.DefaultNestStructure; @@ -12,7 +12,7 @@ public class NestCalculatorTest { @Test - public void testNoNesting() throws NoFeasibleChoiceException { + void testNoNesting() throws NoFeasibleChoiceException { DefaultNestStructure structure = new DefaultNestStructure(); NestCalculator calculator = new NestCalculator(structure); @@ -28,7 +28,7 @@ public void testNoNesting() throws NoFeasibleChoiceException { } @Test - public void testNoNestingRedBlue() throws NoFeasibleChoiceException { + void testNoNestingRedBlue() throws NoFeasibleChoiceException { DefaultNestStructure structure = new DefaultNestStructure(); NestCalculator calculator = new NestCalculator(structure); @@ -49,7 +49,7 @@ public void testNoNestingRedBlue() throws NoFeasibleChoiceException { } @Test - public void testNestedBalancedRedBlue() throws NoFeasibleChoiceException { + void testNestedBalancedRedBlue() throws NoFeasibleChoiceException { DefaultNestStructure structure = new DefaultNestStructure(); DefaultNest busNest = new DefaultNest("bus", 1.0); structure.addNest(structure.getRoot(), busNest); @@ -96,7 +96,7 @@ public void testNestedBalancedRedBlue() throws NoFeasibleChoiceException { } @Test - public void testNestedUnbalancedRedBlue() throws NoFeasibleChoiceException { + void testNestedUnbalancedRedBlue() throws NoFeasibleChoiceException { DefaultNestStructure structure = new DefaultNestStructure(); DefaultNest busNest = new DefaultNest("bus", 1.0); structure.addNest(structure.getRoot(), busNest); diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/modules/config/ConfigTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/modules/config/ConfigTest.java index 32697f90a8d..4090739bcd5 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/modules/config/ConfigTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/modules/config/ConfigTest.java @@ -11,8 +11,8 @@ import java.util.Arrays; import java.util.HashSet; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.contribs.discrete_mode_choice.modules.config.DiscreteModeChoiceConfigGroup; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigReader; @@ -25,7 +25,7 @@ public class ConfigTest { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testReadWriteConfig() { + void testReadWriteConfig() { // Create config DiscreteModeChoiceConfigGroup dmcConfig = new DiscreteModeChoiceConfigGroup(); Config config = ConfigUtils.createConfig(dmcConfig); @@ -46,7 +46,7 @@ public void testReadWriteConfig() { } @Test - public void testReadWriteConfigMultipleTimes() throws IOException { + void testReadWriteConfigMultipleTimes() throws IOException { DiscreteModeChoiceConfigGroup dmcConfig = new DiscreteModeChoiceConfigGroup(); Config config1 = ConfigUtils.createConfig(dmcConfig); @@ -85,7 +85,7 @@ public void testReadWriteConfigMultipleTimes() throws IOException { } @Test - public void testSetTripConstraints() { + void testSetTripConstraints() { DiscreteModeChoiceConfigGroup dmcConfig1 = new DiscreteModeChoiceConfigGroup(); dmcConfig1.setTripConstraints(Arrays.asList("A", "B", "C")); diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/replanning/TestDepartureTimes.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/replanning/TestDepartureTimes.java index cfdef620689..c3e744e0880 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/replanning/TestDepartureTimes.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/replanning/TestDepartureTimes.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.Random; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.population.Leg; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -49,7 +49,7 @@ public class TestDepartureTimes { @Test - public void testTripBasedModelDepartureTimes() throws NoFeasibleChoiceException { + void testTripBasedModelDepartureTimes() throws NoFeasibleChoiceException { TripBasedModel model = createTripBasedModel(); // Case 1: Only activity end times, and trips fall well between the end times @@ -130,7 +130,7 @@ public void testTripBasedModelDepartureTimes() throws NoFeasibleChoiceException } @Test - public void testPushDepartureTimeToNextTour() throws NoFeasibleChoiceException { + void testPushDepartureTimeToNextTour() throws NoFeasibleChoiceException { TourBasedModel model = createTourBasedModel(); Plan plan = new PlanBuilder() // @@ -150,7 +150,7 @@ public void testPushDepartureTimeToNextTour() throws NoFeasibleChoiceException { } @Test - public void testAccumulateAndPushDepartureTimeToNextTour() throws NoFeasibleChoiceException { + void testAccumulateAndPushDepartureTimeToNextTour() throws NoFeasibleChoiceException { TourBasedModel model = createTourBasedModel(); Plan plan = new PlanBuilder() // diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtWithExtensionsConfigGroupTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtWithExtensionsConfigGroupTest.java index 8790d1a5341..8ca27490ae3 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtWithExtensionsConfigGroupTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtWithExtensionsConfigGroupTest.java @@ -25,8 +25,8 @@ import java.util.List; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.jupiter.api.io.TempDir; import org.junit.rules.TemporaryFolder; import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup; @@ -77,8 +77,8 @@ private static Path writeConfig(final File tempFolder, List weights) thr return configFile; } - @Test - public void loadConfigGroupTest() throws IOException { + @Test + void loadConfigGroupTest() throws IOException { /* Test that exported values are correct imported again */ Path configFile = writeConfig(tempFolder, List.of(WEIGHT_1,WEIGHT_2,WEIGHT_3)); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/companions/RunDrtWithCompanionExampleIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/companions/RunDrtWithCompanionExampleIT.java index 749cc23e8ea..3529d2fcd04 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/companions/RunDrtWithCompanionExampleIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/companions/RunDrtWithCompanionExampleIT.java @@ -28,8 +28,8 @@ import java.util.stream.Collectors; import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; @@ -52,7 +52,7 @@ public class RunDrtWithCompanionExampleIT { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testRunDrtWithCompanions() { + void testRunDrtWithCompanions() { Id.resetCaches(); URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml"); Config config = ConfigUtils.loadConfig(configUrl, new OTFVisConfigGroup(), new MultiModeDrtConfigGroup(DrtWithExtensionsConfigGroup::new), new DvrpConfigGroup()); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/dashboards/DashboardTests.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/dashboards/DashboardTests.java index f078e00e07b..78e7ccbeb5e 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/dashboards/DashboardTests.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/dashboards/DashboardTests.java @@ -1,8 +1,8 @@ package org.matsim.contrib.drt.extension.dashboards; import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.application.MATSimApplication; import org.matsim.contrib.drt.extension.DrtTestScenario; import org.matsim.contrib.drt.run.DrtConfigGroup; @@ -45,7 +45,7 @@ private void run() { } @Test - public void drtDefaults() { + void drtDefaults() { run(); // TODO: add test headers!? diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/edrt/run/RunEDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/edrt/run/RunEDrtScenarioIT.java index 3a3471007fd..370304d1bdb 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/edrt/run/RunEDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/edrt/run/RunEDrtScenarioIT.java @@ -22,7 +22,7 @@ import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contrib.drt.prebooking.PrebookingParams; import org.matsim.contrib.drt.prebooking.logic.ProbabilityBasedPrebookingLogic; import org.matsim.contrib.drt.run.DrtConfigGroup; @@ -46,13 +46,13 @@ */ public class RunEDrtScenarioIT { @Test - public void test() { + void test() { URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_edrt_config.xml"); RunEDrtScenario.run(configUrl, false); } - + @Test - public void testWithPrebooking() { + void testWithPrebooking() { URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_edrt_config.xml"); Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModaFixedDrtLegEstimatorTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModaFixedDrtLegEstimatorTest.java index 1a149837266..cb93757590c 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModaFixedDrtLegEstimatorTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModaFixedDrtLegEstimatorTest.java @@ -1,8 +1,8 @@ package org.matsim.contrib.drt.extension.estimator; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.application.MATSimApplication; import org.matsim.contrib.drt.extension.DrtTestScenario; import org.matsim.contrib.drt.extension.estimator.impl.ConstantDrtEstimator; @@ -78,7 +78,7 @@ public void setUp() throws Exception { } @Test - public void run() { + void run() { String out = utils.getOutputDirectory(); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModalDrtLegEstimatorTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModalDrtLegEstimatorTest.java index c35ac36af49..4f57b22744e 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModalDrtLegEstimatorTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModalDrtLegEstimatorTest.java @@ -1,8 +1,8 @@ package org.matsim.contrib.drt.extension.estimator; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.application.MATSimApplication; import org.matsim.contrib.drt.extension.DrtTestScenario; import org.matsim.contrib.drt.extension.estimator.run.DrtEstimatorConfigGroup; @@ -75,7 +75,7 @@ private static void prepare(Config config) { } @Test - public void run() { + void run() { String out = utils.getOutputDirectory(); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java index c5ea83cbce9..52da0c3199a 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java @@ -1,7 +1,7 @@ package org.matsim.contrib.drt.extension.fiss; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.events.LinkLeaveEvent; import org.matsim.api.core.v01.events.handler.LinkLeaveEventHandler; @@ -37,7 +37,7 @@ public class RunFissDrtScenarioIT { @Test - public void test() { + void test() { MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup(DrtWithOperationsConfigGroup::new); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/insertion/DrtInsertionExtensionIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/insertion/DrtInsertionExtensionIT.java index 7f7f76fe71c..91d5699623d 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/insertion/DrtInsertionExtensionIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/insertion/DrtInsertionExtensionIT.java @@ -9,8 +9,8 @@ import java.util.List; import java.util.Set; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.IdMap; import org.matsim.api.core.v01.IdSet; @@ -68,7 +68,7 @@ private Controler createController() { } @Test - public void testExclusivityContraint() { + void testExclusivityContraint() { IdSet exclusiveRequestIds = new IdSet<>(Request.class); for (int i = 100; i <= 200; i++) { @@ -173,7 +173,7 @@ public void install() { } @Test - public void testSkillsConstraint() { + void testSkillsConstraint() { IdSet restrictedRequestIds = new IdSet<>(Request.class); for (int i = 100; i <= 200; i++) { restrictedRequestIds.add(Id.create("drt_" + i, Request.class)); @@ -239,7 +239,7 @@ public void install() { } @Test - public void testRangeConstraint() { + void testRangeConstraint() { Controler controller = createController(); DrtConfigGroup drtConfig = DrtConfigGroup.getSingleModeDrtConfig(controller.getConfig()); @@ -259,7 +259,7 @@ public void testRangeConstraint() { } @Test - public void testRangeConstraintWithCustomInstances() { + void testRangeConstraintWithCustomInstances() { Controler controller = createController(); DrtConfigGroup drtConfig = DrtConfigGroup.getSingleModeDrtConfig(controller.getConfig()); @@ -287,7 +287,7 @@ public void testRangeConstraintWithCustomInstances() { } @Test - public void testRangeConstraintWithCustomInjection() { + void testRangeConstraintWithCustomInjection() { Controler controller = createController(); DrtConfigGroup drtConfig = DrtConfigGroup.getSingleModeDrtConfig(controller.getConfig()); @@ -365,7 +365,7 @@ public void install() { } @Test - public void testCustomConstraint() { + void testCustomConstraint() { Controler controller = createController(); DrtConfigGroup drtConfig = DrtConfigGroup.getSingleModeDrtConfig(controller.getConfig()); @@ -409,7 +409,7 @@ public void install() { } @Test - public void testDefaults() { + void testDefaults() { Controler controller = createController(); DrtConfigGroup drtConfig = DrtConfigGroup.getSingleModeDrtConfig(controller.getConfig()); @@ -428,7 +428,7 @@ public void testDefaults() { } @Test - public void testVehicleActiveTimeObjective() { + void testVehicleActiveTimeObjective() { Controler controller = createController(); DrtConfigGroup drtConfig = DrtConfigGroup.getSingleModeDrtConfig(controller.getConfig()); @@ -449,7 +449,7 @@ public void testVehicleActiveTimeObjective() { } @Test - public void testVehicleDistanceObjective() { + void testVehicleDistanceObjective() { Controler controller = createController(); DrtConfigGroup drtConfig = DrtConfigGroup.getSingleModeDrtConfig(controller.getConfig()); @@ -470,7 +470,7 @@ public void testVehicleDistanceObjective() { } @Test - public void testPassengerPassengerDelayObjective() { + void testPassengerPassengerDelayObjective() { Controler controller = createController(); DrtConfigGroup drtConfig = DrtConfigGroup.getSingleModeDrtConfig(controller.getConfig()); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java index 4abe57ba415..05e08557722 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java @@ -1,6 +1,6 @@ package org.matsim.contrib.drt.extension.operations.eshifts.run; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.contrib.drt.analysis.zonal.DrtZonalSystemParams; import org.matsim.contrib.drt.extension.operations.DrtOperationsParams; @@ -38,7 +38,7 @@ public class RunEShiftDrtScenarioIT { private static final double TEMPERATURE = 20;// oC @Test - public void test() { + void test() { MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup(DrtWithOperationsConfigGroup::new); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/operationFacilities/OperationFacilitiesIOTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/operationFacilities/OperationFacilitiesIOTest.java index 3afc583589b..427416b3b4b 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/operationFacilities/OperationFacilitiesIOTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/operationFacilities/OperationFacilitiesIOTest.java @@ -1,8 +1,8 @@ package org.matsim.contrib.drt.extension.operations.operationFacilities; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -16,8 +16,8 @@ public class OperationFacilitiesIOTest { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void test() { + @Test + void test() { OperationFacilitiesSpecification operationFacilities = new OperationFacilitiesSpecificationImpl(); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/ShiftsIOTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/ShiftsIOTest.java index d7ff41c3846..d2f4c3e27f2 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/ShiftsIOTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/ShiftsIOTest.java @@ -5,8 +5,8 @@ import java.io.File; import java.util.Optional; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacility; import org.matsim.contrib.drt.extension.operations.shifts.io.DrtShiftsReader; @@ -36,7 +36,8 @@ public class ShiftsIOTest { private final Id oid2 = Id.create("op2", OperationFacility.class); - @Test public void testBasicReaderWriter() { + @Test + void testBasicReaderWriter() { DrtShiftsSpecification shiftsSpecification = new DrtShiftsSpecificationImpl(); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/efficiency/ShiftEfficiencyTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/efficiency/ShiftEfficiencyTest.java index e40e1331388..d3b4dfb001c 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/efficiency/ShiftEfficiencyTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/efficiency/ShiftEfficiencyTest.java @@ -10,7 +10,7 @@ package org.matsim.contrib.drt.extension.operations.shifts.analysis.efficiency; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonMoneyEvent; import org.matsim.api.core.v01.network.Link; @@ -38,7 +38,7 @@ public class ShiftEfficiencyTest { * Test method for {@link ShiftEfficiencyTracker}. */ @Test - public void testDrtShiftEfficiency() { + void testDrtShiftEfficiency() { EventsManager events = new EventsManagerImpl(); ShiftEfficiencyTracker shiftEfficiencyTracker = new ShiftEfficiencyTracker(); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java index 91c2dd16be9..5b3f79ea7dd 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java @@ -1,6 +1,6 @@ package org.matsim.contrib.drt.extension.operations.shifts.run; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.contrib.drt.analysis.zonal.DrtZonalSystemParams; import org.matsim.contrib.drt.extension.operations.DrtOperationsControlerCreator; @@ -29,7 +29,7 @@ public class RunMultiHubShiftDrtScenarioIT { @Test - public void test() { + void test() { MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup(DrtWithOperationsConfigGroup::new); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java index e6b9caf51af..28034b937c6 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java @@ -1,6 +1,6 @@ package org.matsim.contrib.drt.extension.operations.shifts.run; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.contrib.drt.analysis.zonal.DrtZonalSystemParams; import org.matsim.contrib.drt.extension.operations.DrtOperationsControlerCreator; @@ -30,7 +30,7 @@ public class RunShiftDrtScenarioIT { @Test - public void test() { + void test() { MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup(DrtWithOperationsConfigGroup::new); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/preplanned/optimizer/RunPreplannedDrtExampleIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/preplanned/optimizer/RunPreplannedDrtExampleIT.java index cd0b743f9f2..e5477142a92 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/preplanned/optimizer/RunPreplannedDrtExampleIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/preplanned/optimizer/RunPreplannedDrtExampleIT.java @@ -29,7 +29,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.drt.extension.preplanned.optimizer.PreplannedDrtOptimizer.PreplannedRequestKey; import org.matsim.contrib.drt.extension.preplanned.optimizer.PreplannedDrtOptimizer.PreplannedSchedules; @@ -43,7 +43,7 @@ */ public class RunPreplannedDrtExampleIT { @Test - public void testRun() { + void testRun() { // scenario with 1 shared taxi (max 2 pax) and 10 requests URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("dvrp-grid"), "one_shared_taxi_config.xml"); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/analysis/zonal/DrtGridUtilsTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/analysis/zonal/DrtGridUtilsTest.java index 110d6bc9852..0d73adba5c6 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/analysis/zonal/DrtGridUtilsTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/analysis/zonal/DrtGridUtilsTest.java @@ -4,7 +4,7 @@ import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.prep.PreparedGeometry; @@ -18,7 +18,7 @@ public class DrtGridUtilsTest { @Test - public void test() { + void test() { Network network = createNetwork(); Map grid = DrtGridUtils.createGridFromNetwork(network, 100); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/analysis/zonal/DrtZonalSystemTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/analysis/zonal/DrtZonalSystemTest.java index af5b0be555e..6e58adfdbe5 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/analysis/zonal/DrtZonalSystemTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/analysis/zonal/DrtZonalSystemTest.java @@ -25,7 +25,7 @@ import static org.matsim.contrib.drt.analysis.zonal.DrtGridUtilsTest.createNetwork; import static org.matsim.contrib.drt.analysis.zonal.DrtZonalSystem.createFromPreparedGeometries; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.Polygon; @@ -44,21 +44,21 @@ public class DrtZonalSystemTest { @Test - public void test_cellSize100() { + void test_cellSize100() { DrtZonalSystem drtZonalSystem = createFromPreparedGeometries(createNetwork(), DrtGridUtils.createGridFromNetwork(createNetwork(), 100)); assertThat(drtZonalSystem.getZoneForLinkId(Id.createLinkId("ab")).getId()).isEqualTo("10"); } @Test - public void test_cellSize700() { + void test_cellSize700() { DrtZonalSystem drtZonalSystem = createFromPreparedGeometries(createNetwork(), DrtGridUtils.createGridFromNetwork(createNetwork(), 700)); assertThat(drtZonalSystem.getZoneForLinkId(Id.createLinkId("ab")).getId()).isEqualTo("2"); } @Test - public void test_gridWithinServiceArea(){ + void test_gridWithinServiceArea(){ Coordinate min = new Coordinate(-500, 500); Coordinate max = new Coordinate(1500, 1500); List serviceArea = createServiceArea(min,max); @@ -74,7 +74,7 @@ public void test_gridWithinServiceArea(){ } @Test - public void test_noZonesWithoutLinks(){ + void test_noZonesWithoutLinks(){ Coordinate min = new Coordinate(1500, 1500); Coordinate max = new Coordinate(2500, 2500); List serviceArea = createServiceArea(min,max); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/analysis/zonal/RandomDrtZoneTargetLinkSelectorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/analysis/zonal/RandomDrtZoneTargetLinkSelectorTest.java index 3251579a09e..fa38b72749b 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/analysis/zonal/RandomDrtZoneTargetLinkSelectorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/analysis/zonal/RandomDrtZoneTargetLinkSelectorTest.java @@ -27,7 +27,7 @@ import java.util.List; import java.util.function.IntUnaryOperator; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.testcases.fakes.FakeLink; @@ -44,7 +44,7 @@ public class RandomDrtZoneTargetLinkSelectorTest { private final Link link3 = new FakeLink(Id.createLinkId("3")); @Test - public void testSelectTargetLink_fourLinks() { + void testSelectTargetLink_fourLinks() { DrtZone zone = DrtZone.createDummyZone("zone", List.of(link0, link1, link2, link3), null); //fake random sequence diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/config/ConfigBehaviorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/config/ConfigBehaviorTest.java index 38880db6bcb..791902fbf14 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/config/ConfigBehaviorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/config/ConfigBehaviorTest.java @@ -3,8 +3,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; import org.matsim.contrib.dvrp.run.DvrpConfigGroup; @@ -19,8 +19,8 @@ public class ConfigBehaviorTest{ @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; - @Test - public final void testMaterializeAfterReadParameterSets() { + @Test + final void testMaterializeAfterReadParameterSets() { { // generate a test config that sets two values away from their defaults, and write it to file: Config config = ConfigUtils.createConfig(); @@ -60,8 +60,8 @@ public final void testMaterializeAfterReadParameterSets() { } } - @Test - public final void testMaterializeAfterReadStandardParams() { + @Test + final void testMaterializeAfterReadStandardParams() { { // generate a test config that sets two values away from their defaults, and write it to file: Config config = ConfigUtils.createConfig(); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/fare/DrtFareHandlerTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/fare/DrtFareHandlerTest.java index e586e1a9dda..fc3c85c6c57 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/fare/DrtFareHandlerTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/fare/DrtFareHandlerTest.java @@ -22,7 +22,7 @@ import org.apache.commons.lang3.mutable.MutableDouble; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonMoneyEvent; import org.matsim.api.core.v01.events.handler.PersonMoneyEventHandler; @@ -42,7 +42,7 @@ public class DrtFareHandlerTest { * Test method for {@link DrtFareHandler}. */ @Test - public void testDrtFareHandler() { + void testDrtFareHandler() { String mode = "mode_0"; DrtFareParams fareParams = new DrtFareParams(); fareParams.baseFare = 1; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/DrtRequestInsertionRetryQueueTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/DrtRequestInsertionRetryQueueTest.java index 208e652d1dc..8989aa90855 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/DrtRequestInsertionRetryQueueTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/DrtRequestInsertionRetryQueueTest.java @@ -22,7 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.drt.passenger.DrtRequest; import org.matsim.contrib.dvrp.optimizer.Request; @@ -43,21 +43,21 @@ public class DrtRequestInsertionRetryQueueTest { .build(); @Test - public void maxRequestAgeZero_noRetry() { + void maxRequestAgeZero_noRetry() { var queue = new DrtRequestInsertionRetryQueue(params(10, 0)); assertThat(queue.tryAddFailedRequest(request, SUBMISSION_TIME)).isFalse(); assertThat(queue.getRequestsToRetryNow(9999)).isEmpty(); } @Test - public void requestMaxAgeExceeded_noRetry() { + void requestMaxAgeExceeded_noRetry() { var queue = new DrtRequestInsertionRetryQueue(params(2, 10)); assertThat(queue.tryAddFailedRequest(request, SUBMISSION_TIME + 10)).isFalse(); assertThat(queue.getRequestsToRetryNow(9999)).isEmpty(); } @Test - public void requestMaxAgeNotExceeded_retry() { + void requestMaxAgeNotExceeded_retry() { var queue = new DrtRequestInsertionRetryQueue(params(2, 10)); assertThat(queue.tryAddFailedRequest(request, SUBMISSION_TIME)).isTrue(); @@ -77,7 +77,7 @@ public void requestMaxAgeNotExceeded_retry() { } @Test - public void requestMaxAgeNotExceeded_lateRetry() { + void requestMaxAgeNotExceeded_lateRetry() { var queue = new DrtRequestInsertionRetryQueue(params(2, 10)); assertThat(queue.tryAddFailedRequest(request, SUBMISSION_TIME)).isTrue(); @@ -91,7 +91,7 @@ public void requestMaxAgeNotExceeded_lateRetry() { } @Test - public void queueOrderMaintained() { + void queueOrderMaintained() { var queue = new DrtRequestInsertionRetryQueue(params(2, 10)); assertThat(queue.tryAddFailedRequest(DrtRequest.newBuilder(request).id(Id.create("a", Request.class)).build(), SUBMISSION_TIME)).isTrue(); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/VehicleDataEntryFactoryImplTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/VehicleDataEntryFactoryImplTest.java index 035367e15fc..e74e3334a71 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/VehicleDataEntryFactoryImplTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/VehicleDataEntryFactoryImplTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.drt.optimizer.Waypoint.Stop; @@ -50,7 +50,7 @@ public class VehicleDataEntryFactoryImplTest { private final Stop stop1 = stop(300, 340, 400, 430); @Test - public void computeSlackTimes_withStops() { + void computeSlackTimes_withStops() { final List precedingStayTimes = Arrays.asList(0.0, 0.0); //final stay task not started - vehicle slack time is 50 @@ -64,7 +64,7 @@ public void computeSlackTimes_withStops() { } @Test - public void computeSlackTimes_withoutStops() { + void computeSlackTimes_withoutStops() { final List precedingStayTimes = Arrays.asList(); //final stay task not started yet - vehicle slack time is 10 @@ -85,9 +85,9 @@ public void computeSlackTimes_withoutStops() { //final stay task planned after vehicle end time - vehicle slack time is 0s assertThat(computeSlackTimes(vehicle(500, 510), 300, new Stop[] {}, null, precedingStayTimes)).containsExactly(0, 0); } - + @Test - public void computeSlackTimes_withStart() { + void computeSlackTimes_withStart() { final List noPrecedingStayTimes = Arrays.asList(); final List onePrecedingStayTime = Arrays.asList(0.0); @@ -100,9 +100,9 @@ public void computeSlackTimes_withStart() { //start with stop assertThat(computeSlackTimes(vehicle(500, 450), 100, new Stop[] { stop1 }, stop0, onePrecedingStayTime)).containsExactly(30, 30, 50); } - + @Test - public void computeSlackTimes_withPrecedingStayTimes() { + void computeSlackTimes_withPrecedingStayTimes() { final List precedingStayTimes = Arrays.asList( // 0.0, // 33.0 // second stop is a prebooked pickup, so slack for insertion after first stop is longer diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/BestInsertionFinderTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/BestInsertionFinderTest.java index 32b44c82f2f..bf42ede62a7 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/BestInsertionFinderTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/BestInsertionFinderTest.java @@ -30,7 +30,7 @@ import java.util.Arrays; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.drt.optimizer.VehicleEntry; import org.matsim.contrib.drt.passenger.DrtRequest; @@ -48,19 +48,19 @@ public class BestInsertionFinderTest { private final BestInsertionFinder bestInsertionFinder = new BestInsertionFinder(insertionCostCalculator); @Test - public void noInsertions_empty() { + void noInsertions_empty() { assertThat(findBestInsertion()).isEmpty(); } @Test - public void noFeasibleInsertions_empty() { + void noFeasibleInsertions_empty() { when(insertionCostCalculator.calculate(eq(request), any(), any())).thenReturn(INFEASIBLE_SOLUTION_COST); assertThat(findBestInsertion(insertion("v1", 0, 0), insertion("v1", 0, 1))).isEmpty(); } @Test - public void oneFeasibleInsertion_oneInfeasibleInsertion_chooseFeasible() { + void oneFeasibleInsertion_oneInfeasibleInsertion_chooseFeasible() { var feasibleInsertion = insertion("v1", 0, 0); whenInsertionThenCost(feasibleInsertion, 12345); @@ -72,7 +72,7 @@ public void oneFeasibleInsertion_oneInfeasibleInsertion_chooseFeasible() { } @Test - public void twoFeasibleInsertions_chooseBetter() { + void twoFeasibleInsertions_chooseBetter() { var insertion1 = insertion("v1", 0, 0); whenInsertionThenCost(insertion1, 123); @@ -84,7 +84,7 @@ public void twoFeasibleInsertions_chooseBetter() { } @Test - public void twoEqualInsertions_chooseLowerVehicleId() { + void twoEqualInsertions_chooseLowerVehicleId() { var insertion1 = insertion("v1", 0, 0); whenInsertionThenCost(insertion1, 123); @@ -96,7 +96,7 @@ public void twoEqualInsertions_chooseLowerVehicleId() { } @Test - public void twoEqualInsertions_sameVehicle_chooseLowerPickupIdx() { + void twoEqualInsertions_sameVehicle_chooseLowerPickupIdx() { var insertion1 = insertion("v1", 0, 1); whenInsertionThenCost(insertion1, 123); @@ -108,7 +108,7 @@ public void twoEqualInsertions_sameVehicle_chooseLowerPickupIdx() { } @Test - public void twoEqualInsertions_sameVehicle_samePickupIdx_chooseLowerDropoffIdx() { + void twoEqualInsertions_sameVehicle_samePickupIdx_chooseLowerDropoffIdx() { var insertion1 = insertion("v1", 0, 0); whenInsertionThenCost(insertion1, 123); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/CostCalculationStrategyTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/CostCalculationStrategyTest.java index 569f4e7d708..cc52e2a3dbf 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/CostCalculationStrategyTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/CostCalculationStrategyTest.java @@ -27,7 +27,7 @@ import static org.matsim.contrib.drt.optimizer.insertion.InsertionDetourTimeCalculator.DropoffDetourInfo; import static org.matsim.contrib.drt.optimizer.insertion.InsertionDetourTimeCalculator.PickupDetourInfo; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contrib.drt.optimizer.insertion.InsertionDetourTimeCalculator.DetourTimeInfo; import org.matsim.contrib.drt.passenger.DrtRequest; @@ -36,20 +36,20 @@ */ public class CostCalculationStrategyTest { @Test - public void RejectSoftConstraintViolations_tooLongWaitTime() { + void RejectSoftConstraintViolations_tooLongWaitTime() { assertRejectSoftConstraintViolations(10, 9999, new DetourTimeInfo(new PickupDetourInfo(11, 0), new DropoffDetourInfo(22, 0)), INFEASIBLE_SOLUTION_COST); } @Test - public void RejectSoftConstraintViolations_tooLongTravelTime() { + void RejectSoftConstraintViolations_tooLongTravelTime() { assertRejectSoftConstraintViolations(9999, 10, new DetourTimeInfo(new PickupDetourInfo(0, 0), new DropoffDetourInfo(11, 0)), INFEASIBLE_SOLUTION_COST); } @Test - public void RejectSoftConstraintViolations_allConstraintSatisfied() { + void RejectSoftConstraintViolations_allConstraintSatisfied() { assertRejectSoftConstraintViolations(9999, 9999, new DetourTimeInfo(new PickupDetourInfo(11, 33), new DropoffDetourInfo(22, 44)), 33 + 44); } @@ -65,21 +65,21 @@ private void assertRejectSoftConstraintViolations(double latestStartTime, double } @Test - public void DiscourageSoftConstraintViolations_tooLongWaitTime() { + void DiscourageSoftConstraintViolations_tooLongWaitTime() { assertDiscourageSoftConstraintViolations(10, 9999, new DetourTimeInfo(new PickupDetourInfo(11, 0), new DropoffDetourInfo(22, 0)), MAX_WAIT_TIME_VIOLATION_PENALTY); } @Test - public void DiscourageSoftConstraintViolations_tooLongTravelTime() { + void DiscourageSoftConstraintViolations_tooLongTravelTime() { assertDiscourageSoftConstraintViolations(9999, 10, new DetourTimeInfo(new PickupDetourInfo(0, 0), new DropoffDetourInfo(11, 0)), MAX_TRAVEL_TIME_VIOLATION_PENALTY); } @Test - public void DiscourageSoftConstraintViolations_allConstraintSatisfied() { + void DiscourageSoftConstraintViolations_allConstraintSatisfied() { assertDiscourageSoftConstraintViolations(9999, 9999, new DetourTimeInfo(new PickupDetourInfo(11, 33), new DropoffDetourInfo(22, 44)), 33 + 44); } diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DefaultUnplannedRequestInserterTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DefaultUnplannedRequestInserterTest.java index 2f33a567b87..58637acaddc 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DefaultUnplannedRequestInserterTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DefaultUnplannedRequestInserterTest.java @@ -32,8 +32,8 @@ import java.util.*; import org.apache.commons.lang3.mutable.MutableInt; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Identifiable; @@ -74,7 +74,7 @@ public class DefaultUnplannedRequestInserterTest { public final ForkJoinPoolExtension forkJoinPoolExtension = new ForkJoinPoolExtension(); @Test - public void nothingToSchedule() { + void nothingToSchedule() { var fleet = fleet(vehicle("1")); var unplannedRequests = requests(); double now = 15; @@ -89,7 +89,7 @@ public void nothingToSchedule() { } @Test - public void notScheduled_rejected() { + void notScheduled_rejected() { var fleet = fleet();//no vehicles -> impossible to schedule var unplannedRequests = requests(request1); double now = 15; @@ -122,7 +122,7 @@ public void notScheduled_rejected() { } @Test - public void notScheduled_addedToRetry() { + void notScheduled_addedToRetry() { var fleet = fleet();//no vehicles -> impossible to schedule var unplannedRequests = requests(request1); double now = 15; @@ -159,7 +159,7 @@ public void notScheduled_addedToRetry() { } @Test - public void firstRetryOldRequest_thenHandleNewRequest() { + void firstRetryOldRequest_thenHandleNewRequest() { var fleet = fleet();//no vehicles -> impossible to schedule var unplannedRequests = requests(request1); double now = 15; @@ -194,7 +194,7 @@ public void firstRetryOldRequest_thenHandleNewRequest() { } @Test - public void acceptedRequest() { + void acceptedRequest() { var vehicle1 = vehicle("1"); var fleet = fleet(vehicle1); var unplannedRequests = requests(request1); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DetourTimeEstimatorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DetourTimeEstimatorTest.java index 85caff1ca6c..d11094a9fd1 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DetourTimeEstimatorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DetourTimeEstimatorTest.java @@ -25,7 +25,7 @@ import static org.mockito.Mockito.when; import org.assertj.core.api.Assertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contrib.dvrp.trafficmonitoring.QSimFreeSpeedTravelTime; import org.matsim.contrib.zone.skims.TravelTimeMatrix; import org.matsim.testcases.fakes.FakeLink; @@ -37,14 +37,14 @@ public class DetourTimeEstimatorTest { @Test - public void freeSpeedZonalTimeEstimator_fromLinkToLinkSame() { + void freeSpeedZonalTimeEstimator_fromLinkToLinkSame() { var link = new FakeLink(null); var estimator = DetourTimeEstimator.createMatrixBasedEstimator(1, null, null); Assertions.assertThat(estimator.estimateTime(link, link, 345)).isZero(); } @Test - public void freeSpeedZonalTimeEstimator_fromLinkToLinkDifferent() { + void freeSpeedZonalTimeEstimator_fromLinkToLinkDifferent() { var linkA = new FakeLink(null, null, new FakeNode(null)); var linkB = new FakeLink(null, new FakeNode(null), null); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java index 26c4c3f6f7d..6b01f318098 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java @@ -4,8 +4,8 @@ import java.util.*; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.*; @@ -64,7 +64,7 @@ public class DrtPoolingParameterTest { * With a low maxWaitTime of 100s, no DRT vehicle should have time to any agents. */ @Test - public void testMaxWaitTimeNoVehicles() { + void testMaxWaitTimeNoVehicles() { PersonEnterDrtVehicleEventHandler handler = setupAndRunScenario(50, 10.0, 10000.); Assert.assertEquals("There should be no vehicle used", 0, handler.getVehRequestCount().size()); @@ -76,7 +76,7 @@ public void testMaxWaitTimeNoVehicles() { * too far away to reach those agents. */ @Test - public void testMaxWaitTimeTwoVehiclesForTwoAgents() { + void testMaxWaitTimeTwoVehiclesForTwoAgents() { PersonEnterDrtVehicleEventHandler handler = setupAndRunScenario(121, 10.0, 10000.); Assert.assertEquals("There should two vehicle used", 2, handler.getVehRequestCount().size()); @@ -97,7 +97,7 @@ public void testMaxWaitTimeTwoVehiclesForTwoAgents() { * With a maxWaitTime of 250s, both drt vehicles should have time to each pick up two passengers. */ @Test - public void testMaxWaitTimeTwoVehiclesForFourAgents() { + void testMaxWaitTimeTwoVehiclesForFourAgents() { PersonEnterDrtVehicleEventHandler handler = setupAndRunScenario(250, 10.0, 10000.); Assert.assertEquals("There should two vehicle used", 2, handler.getVehRequestCount().size()); @@ -118,7 +118,7 @@ public void testMaxWaitTimeTwoVehiclesForFourAgents() { * With a high maxWaitTime of 500s, a single DRT vehicle should be able to pick up all four agents. */ @Test - public void testMaxWaitTimeOneVehicleForFourAgents() { + void testMaxWaitTimeOneVehicleForFourAgents() { PersonEnterDrtVehicleEventHandler handler = setupAndRunScenario(500, 10.0, 10000.); System.out.println(handler.getVehRequestCount()); @@ -132,15 +132,15 @@ public void testMaxWaitTimeOneVehicleForFourAgents() { } /* - The following tests vary the maxTravelTimeBeta parameter. maxTravelTimeAlpha is fixed to 1.0, while maxWaitTime is - fixed to a high value: 5000s. + e following tests vary the maxTravelTimeBeta parameter. maxTravelTimeAlpha is fixed to 1.0, while maxWaitTime is + ixed to a high value: 5000s. */ /** * With a low Beta of 0s, no DRT vehicles should be assigned to the agents. */ @Test - public void testBetaNoVehicles() { + void testBetaNoVehicles() { PersonEnterDrtVehicleEventHandler handler = setupAndRunScenario(5000, 1.0, 0.); Assert.assertEquals("There should only be zero vehicles used", 0, handler.getVehRequestCount().size()); @@ -152,7 +152,7 @@ public void testBetaNoVehicles() { * the remaining two agents will be left stranded */ @Test - public void testBetaTwoVehiclesForTwoAgents() { + void testBetaTwoVehiclesForTwoAgents() { PersonEnterDrtVehicleEventHandler handler = setupAndRunScenario(5000, 1.0, 150); Assert.assertEquals("There should two vehicle used", 2, handler.getVehRequestCount().size()); @@ -173,7 +173,7 @@ public void testBetaTwoVehiclesForTwoAgents() { * With a Beta value of 250s, two DRT vehicles should have enough time to pick up two passengers each. */ @Test - public void testBetaTwoVehiclesForFourAgents() { + void testBetaTwoVehiclesForFourAgents() { PersonEnterDrtVehicleEventHandler handler = setupAndRunScenario(5000, 1.0, 250); Assert.assertEquals("There should two vehicle used", 2, handler.getVehRequestCount().size()); @@ -193,7 +193,7 @@ public void testBetaTwoVehiclesForFourAgents() { * With a high Beta of 400s, one DRT vehicle should be used to pick up all four agents */ @Test - public void testBetaOneVehicleForFourAgents() { + void testBetaOneVehicleForFourAgents() { PersonEnterDrtVehicleEventHandler handler = setupAndRunScenario(5000, 1.0, 400); Assert.assertEquals("There should only be one vehicle used", 1, handler.getVehRequestCount().size()); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionCostCalculatorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionCostCalculatorTest.java index 563788c0f5c..0d617d9fc9f 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionCostCalculatorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionCostCalculatorTest.java @@ -24,7 +24,7 @@ import static org.matsim.contrib.drt.optimizer.insertion.InsertionCostCalculator.INFEASIBLE_SOLUTION_COST; import static org.matsim.contrib.drt.optimizer.insertion.InsertionDetourTimeCalculator.*; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.drt.optimizer.VehicleEntry; @@ -41,7 +41,7 @@ public class InsertionCostCalculatorTest { private final DrtRequest drtRequest = DrtRequest.newBuilder().fromLink(fromLink).toLink(toLink).build(); @Test - public void testCalculate() { + void testCalculate() { VehicleEntry entry = entry(new double[] { 20, 20, 50 }); var insertion = insertion(entry, 0, 1); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionDetourTimeCalculatorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionDetourTimeCalculatorTest.java index 3489c5ee854..756682854b0 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionDetourTimeCalculatorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionDetourTimeCalculatorTest.java @@ -24,8 +24,7 @@ import java.util.Collections; import java.util.List; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.drt.optimizer.VehicleEntry; @@ -57,7 +56,7 @@ public class InsertionDetourTimeCalculatorTest { private final DrtRequest drtRequest = DrtRequest.newBuilder().fromLink(fromLink).toLink(toLink).build(); @Test - public void detourTimeLoss_start_pickup_dropoff() { + void detourTimeLoss_start_pickup_dropoff() { Waypoint.Start start = start(null, 10, link("start")); VehicleEntry entry = entry(start); var detour = detourData(100., 15., Double.NaN, 0.); @@ -74,7 +73,7 @@ public void detourTimeLoss_start_pickup_dropoff() { } @Test - public void detourTimeLoss_ongoingStopAsStart_pickup_dropoff() { + void detourTimeLoss_ongoingStopAsStart_pickup_dropoff() { //similar to detourTmeLoss_start_pickup_dropoff(), but the pickup is appended to the ongoing STOP task // sh 03/08/23: Changed this test, according to VehicleDataEntryFactoryImpl the start time should be end time of stop task Waypoint.Start start = start(new DefaultDrtStopTask(20, 20 + STOP_DURATION, fromLink), 20 + STOP_DURATION, fromLink); @@ -91,7 +90,7 @@ public void detourTimeLoss_ongoingStopAsStart_pickup_dropoff() { } @Test - public void detourTimeLoss_start_pickup_dropoff_stop() { + void detourTimeLoss_start_pickup_dropoff_stop() { Waypoint.Start start = start(null, 5, link("start")); Waypoint.Stop stop0 = stop(10, link("stop0")); VehicleEntry entry = entry(start, stop0); @@ -109,7 +108,7 @@ public void detourTimeLoss_start_pickup_dropoff_stop() { } @Test - public void calculatePickupDetourTimeLoss_start_pickup_stop_dropoff() { + void calculatePickupDetourTimeLoss_start_pickup_stop_dropoff() { Waypoint.Start start = start(null, 5, link("start")); Waypoint.Stop stop0 = stop(10, link("stop0")); VehicleEntry entry = entry(start, stop0); @@ -127,7 +126,7 @@ public void calculatePickupDetourTimeLoss_start_pickup_stop_dropoff() { } @Test - public void calculatePickupDetourTimeLoss_start_pickup_stop_dropoff_stop() { + void calculatePickupDetourTimeLoss_start_pickup_stop_dropoff_stop() { Waypoint.Start start = start(null, 5, link("start")); Waypoint.Stop stop0 = stop(10, link("stop0")); Waypoint.Stop stop1 = stop(200, link("stop1")); @@ -148,7 +147,7 @@ public void calculatePickupDetourTimeLoss_start_pickup_stop_dropoff_stop() { } @Test - public void calculatePickupDetourTimeLoss_start_pickupNotAppended_stop_dropoffAppended_stop() { + void calculatePickupDetourTimeLoss_start_pickupNotAppended_stop_dropoffAppended_stop() { Waypoint.Start start = start(null, 5, fromLink);//not a STOP -> pickup cannot be appended Waypoint.Stop stop0 = stop(10, toLink); Waypoint.Stop stop1 = stop(200, link("stop1")); @@ -165,7 +164,7 @@ public void calculatePickupDetourTimeLoss_start_pickupNotAppended_stop_dropoffAp } @Test - public void calculatePickupDetourTimeLoss_start_stop_pickupAppended_stop_dropoffAppended() { + void calculatePickupDetourTimeLoss_start_stop_pickupAppended_stop_dropoffAppended() { Waypoint.Start start = start(null, 5, link("start")); Waypoint.Stop stop0 = stop(10, fromLink); Waypoint.Stop stop1 = stop(200, toLink); @@ -182,7 +181,7 @@ public void calculatePickupDetourTimeLoss_start_stop_pickupAppended_stop_dropoff } @Test - public void replacedDriveTimeEstimator() { + void replacedDriveTimeEstimator() { Waypoint.Start start = start(null, 0, link("start")); Waypoint.Stop stop0 = stop(10, link("stop0")); Waypoint.Stop stop1 = stop(200, link("stop1")); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionDetourTimeCalculatorWithVariableDurationTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionDetourTimeCalculatorWithVariableDurationTest.java index 461a598d874..fcfa03962bd 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionDetourTimeCalculatorWithVariableDurationTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionDetourTimeCalculatorWithVariableDurationTest.java @@ -24,8 +24,7 @@ import java.util.Collections; import java.util.List; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.drt.optimizer.VehicleEntry; @@ -91,7 +90,7 @@ public double calcDropoffDuration(DvrpVehicle vehicle, DrtRequest request) { new CumulativeStopTimeCalculator(STOP_DURATION_PROVIDER); @Test - public void detourTimeLoss_start_pickup_dropoff() { + void detourTimeLoss_start_pickup_dropoff() { Waypoint.Start start = start(null, 10, link("start")); VehicleEntry entry = entry(start); var detour = new Detour(100., 15., 0., 0.); @@ -109,7 +108,7 @@ public void detourTimeLoss_start_pickup_dropoff() { } @Test - public void detourTimeLoss_ongoingStopAsStart_pickup_dropoff() { + void detourTimeLoss_ongoingStopAsStart_pickup_dropoff() { //similar to detourTmeLoss_start_pickup_dropoff(), but the pickup is appended to the ongoing STOP task DrtStopTask stopTask = new DefaultDrtStopTask(20, 20 + STOP_DURATION_INITIAL, fromLink); stopTask.addDropoffRequest(AcceptedDrtRequest.createFromOriginalRequest(drtRequestInitial)); @@ -129,7 +128,7 @@ public void detourTimeLoss_ongoingStopAsStart_pickup_dropoff() { } @Test - public void detourTimeLoss_start_pickup_dropoff_stop() { + void detourTimeLoss_start_pickup_dropoff_stop() { Waypoint.Start start = start(null, 5, link("start")); Waypoint.Stop stop0 = stop(10, link("stop0")); VehicleEntry entry = entry(start, stop0); @@ -146,7 +145,7 @@ public void detourTimeLoss_start_pickup_dropoff_stop() { } @Test - public void calculatePickupDetourTimeLoss_start_pickup_stop_dropoff() { + void calculatePickupDetourTimeLoss_start_pickup_stop_dropoff() { Waypoint.Start start = start(null, 5, link("start")); Waypoint.Stop stop0 = stop(10, link("stop0")); VehicleEntry entry = entry(start, stop0); @@ -163,7 +162,7 @@ public void calculatePickupDetourTimeLoss_start_pickup_stop_dropoff() { } @Test - public void calculatePickupDetourTimeLoss_start_pickup_stop_dropoff_stop() { + void calculatePickupDetourTimeLoss_start_pickup_stop_dropoff_stop() { Waypoint.Start start = start(null, 5, link("start")); Waypoint.Stop stop0 = stop(10, link("stop0")); Waypoint.Stop stop1 = stop(200, link("stop1")); @@ -181,7 +180,7 @@ public void calculatePickupDetourTimeLoss_start_pickup_stop_dropoff_stop() { } @Test - public void calculatePickupDetourTimeLoss_start_pickupNotAppended_stop_dropoffAppended_stop() { + void calculatePickupDetourTimeLoss_start_pickupNotAppended_stop_dropoffAppended_stop() { Waypoint.Start start = start(null, 5, fromLink);//not a STOP -> pickup cannot be appended Waypoint.Stop stop0 = stop(10, toLink); Waypoint.Stop stop1 = stop(200, link("stop1")); @@ -199,7 +198,7 @@ public void calculatePickupDetourTimeLoss_start_pickupNotAppended_stop_dropoffAp } @Test - public void calculatePickupDetourTimeLoss_start_stop_pickupAppended_stop_dropoffAppended() { + void calculatePickupDetourTimeLoss_start_stop_pickupAppended_stop_dropoffAppended() { Waypoint.Start start = start(null, 5, link("start")); Waypoint.Stop stop0 = stop(10, fromLink); Waypoint.Stop stop1 = stop(200, toLink); @@ -217,7 +216,7 @@ public void calculatePickupDetourTimeLoss_start_stop_pickupAppended_stop_dropoff } @Test - public void replacedDriveTimeEstimator() { + void replacedDriveTimeEstimator() { Waypoint.Start start = start(null, 0, link("start")); Waypoint.Stop stop0 = stop(10, link("stop0")); Waypoint.Stop stop1 = stop(200, link("stop1")); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionGeneratorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionGeneratorTest.java index 18bb57661f2..53c6aa2d5ae 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionGeneratorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/InsertionGeneratorTest.java @@ -28,7 +28,7 @@ import java.util.List; import com.google.common.collect.Sets; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.drt.optimizer.VehicleEntry; @@ -94,7 +94,7 @@ public class InsertionGeneratorTest { private final DvrpVehicle vehicle = new DvrpVehicleImpl(vehicleSpecification, depotLink); @Test - public void startEmpty_noStops() { + void startEmpty_noStops() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, 0); //no stops => must be empty VehicleEntry entry = entry(start); @@ -110,7 +110,7 @@ public void startEmpty_noStops() { } @Test - public void startNotFull_oneStop() { + void startNotFull_oneStop() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, 1); // 1 pax aboard Waypoint.Stop stop0 = stop(start.time + TIME_REPLACED_DRIVE, link("stop0"), 0);//drop off 1 pax VehicleEntry entry = entry(start, stop0); @@ -143,7 +143,7 @@ public void startNotFull_oneStop() { } @Test - public void startFull_oneStop() { + void startFull_oneStop() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, CAPACITY); //full Waypoint.Stop stop0 = stop(start.time + TIME_REPLACED_DRIVE, link("stop0"), 0);//drop off 4 pax VehicleEntry entry = entry(start, stop0); @@ -160,7 +160,7 @@ public void startFull_oneStop() { } @Test - public void startEmpty_twoStops_notFullBetweenStops() { + void startEmpty_twoStops_notFullBetweenStops() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, 0); //empty Waypoint.Stop stop0 = stop(start.time + TIME_REPLACED_DRIVE, link("stop0"), 1);//pick up 1 pax Waypoint.Stop stop1 = stop(stop0.getDepartureTime() + TIME_REPLACED_DRIVE, link("stop1"), 0);//drop off 1 pax @@ -218,7 +218,7 @@ public void startEmpty_twoStops_notFullBetweenStops() { } @Test - public void startEmpty_twoStops_notFullBetweenStops_tightSlackTimes() { + void startEmpty_twoStops_notFullBetweenStops_tightSlackTimes() { //same as startEmpty_twoStops_notFullBetweenStops() but with different slack times Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, 0); //empty Waypoint.Stop stop0 = stop(start.time + TIME_REPLACED_DRIVE, link("stop0"), 1);//pick up 1 pax @@ -252,7 +252,7 @@ public void startEmpty_twoStops_notFullBetweenStops_tightSlackTimes() { } @Test - public void startEmpty_twoStops_fullBetweenStops() { + void startEmpty_twoStops_fullBetweenStops() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, 0); //empty Waypoint.Stop stop0 = stop(0, link("stop0"), CAPACITY);//pick up 4 pax (full) Waypoint.Stop stop1 = stop(0, link("stop1"), 0);//drop off 4 pax @@ -266,7 +266,7 @@ public void startEmpty_twoStops_fullBetweenStops() { } @Test - public void startFull_twoStops_notFullBetweenStops() { + void startFull_twoStops_notFullBetweenStops() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, CAPACITY); //full Waypoint.Stop stop0 = stop(0, link("stop0"), 2);//drop off 2 pax Waypoint.Stop stop1 = stop(0, link("stop1"), 0);//drop off 2 pax @@ -281,7 +281,7 @@ public void startFull_twoStops_notFullBetweenStops() { } @Test - public void startFull_twoStops_fullBetweenStops() { + void startFull_twoStops_fullBetweenStops() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, CAPACITY); //full Waypoint.Stop stop0 = stop(0, link("stop0"), CAPACITY);//drop off 1 pax, pickup 1 pax (full) Waypoint.Stop stop1 = stop(0, link("stop1"), 0);//drop off 4 pax @@ -294,7 +294,7 @@ public void startFull_twoStops_fullBetweenStops() { } @Test - public void startNotFull_threeStops_emptyBetweenStops01_fullBetweenStops12() { + void startNotFull_threeStops_emptyBetweenStops01_fullBetweenStops12() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, 1); //empty Waypoint.Stop stop0 = stop(0, link("stop0"), 0);// dropoff 1 pax Waypoint.Stop stop1 = stop(0, link("stop1"), CAPACITY);// pickup 4 pax @@ -312,7 +312,7 @@ public void startNotFull_threeStops_emptyBetweenStops01_fullBetweenStops12() { } @Test - public void startFull_threeStops_emptyBetweenStops01_fullBetweenStops12() { + void startFull_threeStops_emptyBetweenStops01_fullBetweenStops12() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, CAPACITY); //full Waypoint.Stop stop0 = stop(0, link("stop0"), 0);// dropoff 4 pax Waypoint.Stop stop1 = stop(0, link("stop1"), CAPACITY);// pickup 4 pax @@ -328,7 +328,7 @@ public void startFull_threeStops_emptyBetweenStops01_fullBetweenStops12() { } @Test - public void noDetourForPickup_noDuplicatedInsertions() { + void noDetourForPickup_noDuplicatedInsertions() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, 1); // 1 pax Waypoint.Stop stop0 = stop(0, fromLink, 0);//dropoff 1 pax VehicleEntry entry = entry(start, stop0); @@ -339,7 +339,7 @@ public void noDetourForPickup_noDuplicatedInsertions() { } @Test - public void noDetourForDropoff_noDuplicatedInsertions() { + void noDetourForDropoff_noDuplicatedInsertions() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, 1); // 1 pax Waypoint.Stop stop0 = stop(0, toLink, 0);//dropoff 1 pax VehicleEntry entry = entry(start, stop0); @@ -351,7 +351,7 @@ public void noDetourForDropoff_noDuplicatedInsertions() { } @Test - public void noDetourForDropoff_vehicleOutgoingFullAfterDropoff_insertionPossible() { + void noDetourForDropoff_vehicleOutgoingFullAfterDropoff_insertionPossible() { // a special case where we allow inserting the dropoff after a stop despite outgoingOccupancy == maxCapacity // this is only because the the dropoff happens exactly at (not after) the stop Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, 1); // 1 pax @@ -366,7 +366,7 @@ public void noDetourForDropoff_vehicleOutgoingFullAfterDropoff_insertionPossible } @Test - public void startEmpty_prebookedRequest() { + void startEmpty_prebookedRequest() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, 0); VehicleEntry entry = entry(start); assertInsertionsOnly(prebookedRequest, entry, @@ -374,7 +374,7 @@ public void startEmpty_prebookedRequest() { } @Test - public void startEmpty_onlineRequest_beforeAlreadyPrebookedOtherRequest() { + void startEmpty_onlineRequest_beforeAlreadyPrebookedOtherRequest() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, 0); Waypoint.Stop stop0 = stop(200, fromLink, 1); Waypoint.Stop stop1 = stop(400, link("stop"), 0); @@ -390,7 +390,7 @@ public void startEmpty_onlineRequest_beforeAlreadyPrebookedOtherRequest() { } @Test - public void startEmpty_prebookedRequest_inMiddleOfAlreadyPrebookedOtherRequest() { + void startEmpty_prebookedRequest_inMiddleOfAlreadyPrebookedOtherRequest() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, 0); Waypoint.Stop stop0 = stop(50, fromLink, 1); Waypoint.Stop stop1 = stop(300, link("stop"), 0); @@ -402,7 +402,7 @@ public void startEmpty_prebookedRequest_inMiddleOfAlreadyPrebookedOtherRequest() } @Test - public void startEmpty_prebookedRequest_afterAlreadyPrebookedOtherRequest() { + void startEmpty_prebookedRequest_afterAlreadyPrebookedOtherRequest() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, 0); Waypoint.Stop stop0 = stop(20, fromLink, 1); Waypoint.Stop stop1 = stop(70, link("stop"), 0); @@ -413,7 +413,7 @@ public void startEmpty_prebookedRequest_afterAlreadyPrebookedOtherRequest() { @Test - public void startEmpty_smallGroup() { + void startEmpty_smallGroup() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, 0); //empty VehicleEntry entry = entry(start); assertInsertionsOnly(drtRequest2Pax, entry, @@ -422,7 +422,7 @@ public void startEmpty_smallGroup() { } @Test - public void startEmpty_groupExceedsCapacity() { + void startEmpty_groupExceedsCapacity() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, 0); //empty VehicleEntry entry = entry(start); assertInsertionsOnly(drtRequest5Pax, entry @@ -431,7 +431,7 @@ public void startEmpty_groupExceedsCapacity() { } @Test - public void startEmpty_twoStops_groupExceedsCapacityAtFirstStop() { + void startEmpty_twoStops_groupExceedsCapacityAtFirstStop() { Waypoint.Start start = new Waypoint.Start(null, link("start"), 0, 0); //empty Waypoint.Stop stop0 = stop(0, toLink, 3);//dropoff 1 pax Waypoint.Stop stop1 = stop(0, link("stop1"), 0);//dropoff 1 pax diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/DetourPathDataCacheTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/DetourPathDataCacheTest.java index af7c0c331f2..fcc8928de9c 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/DetourPathDataCacheTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/DetourPathDataCacheTest.java @@ -24,8 +24,7 @@ import static org.mockito.Mockito.mock; import java.util.Arrays; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.drt.optimizer.VehicleEntry; @@ -86,32 +85,32 @@ public class DetourPathDataCacheTest { pathToDropoffMap, pathFromDropoffMap, ZERO_DETOUR); @Test - public void insertion_0_0() { + void insertion_0_0() { assertInsertion(0, 0, start_pickup, pickup_dropoff, null, dropoff_stop0); } @Test - public void insertion_0_1() { + void insertion_0_1() { assertInsertion(0, 1, start_pickup, pickup_stop0, stop0_dropoff, dropoff_stop1); } @Test - public void insertion_0_2() { + void insertion_0_2() { assertInsertion(0, 2, start_pickup, pickup_stop0, stop1_dropoff, ZERO_DETOUR); } @Test - public void insertion_1_1() { + void insertion_1_1() { assertInsertion(1, 1, stop0_pickup, pickup_dropoff, null, dropoff_stop1); } @Test - public void insertion_1_2() { + void insertion_1_2() { assertInsertion(1, 2, stop0_pickup, pickup_stop1, stop1_dropoff, ZERO_DETOUR); } @Test - public void insertion_2_2() { + void insertion_2_2() { assertInsertion(2, 2, stop1_pickup, pickup_dropoff, null, ZERO_DETOUR); } diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/ExtensiveInsertionProviderTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/ExtensiveInsertionProviderTest.java index 4d05fbc2397..c6dc35ebdf6 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/ExtensiveInsertionProviderTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/ExtensiveInsertionProviderTest.java @@ -29,7 +29,7 @@ import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.contrib.drt.optimizer.VehicleEntry; import org.matsim.contrib.drt.optimizer.Waypoint; @@ -47,21 +47,21 @@ public class ExtensiveInsertionProviderTest { public final ForkJoinPoolExtension rule = new ForkJoinPoolExtension(); @Test - public void getInsertions_noInsertionsGenerated() { + void getInsertions_noInsertionsGenerated() { var insertionProvider = new ExtensiveInsertionProvider(null, null, new InsertionGenerator(new DefaultStopTimeCalculator(120), null), rule.forkJoinPool); assertThat(insertionProvider.getInsertions(null, List.of())).isEmpty(); } @Test - public void getInsertions_twoAtEndInsertionsGenerated_zeroNearestInsertionsAtEndLimit() { + void getInsertions_twoAtEndInsertionsGenerated_zeroNearestInsertionsAtEndLimit() { //the infeasible solution gets discarded in the first stage //the feasible solution gets discarded in the second stage (KNearestInsertionsAtEndFilter) getInsertions_twoInsertionsGenerated(0); } @Test - public void getInsertions_twoAtEndInsertionsGenerated_tenNearestInsertionsAtEndLimit() { + void getInsertions_twoAtEndInsertionsGenerated_tenNearestInsertionsAtEndLimit() { //the infeasible solution gets discarded in the first stage //the feasible solution is NOT discarded in the second stage (KNearestInsertionsAtEndFilter) getInsertions_twoInsertionsGenerated(10); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/KNearestInsertionsAtEndFilterTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/KNearestInsertionsAtEndFilterTest.java index 77fc80cf388..02a92a9588b 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/KNearestInsertionsAtEndFilterTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/KNearestInsertionsAtEndFilterTest.java @@ -25,8 +25,7 @@ import static org.mockito.Mockito.when; import java.util.List; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.drt.optimizer.VehicleEntry; import org.matsim.contrib.drt.optimizer.Waypoint; @@ -46,7 +45,7 @@ public class KNearestInsertionsAtEndFilterTest { @Test - public void k0_atEndInsertionsNotReturned() { + void k0_atEndInsertionsNotReturned() { var vehicleEntry = vehicleEntry("v1", start(0), stop(100)); var insertion = insertion(vehicleEntry, 1, 10); var filteredInsertions = KNearestInsertionsAtEndFilter.filterInsertionsAtEnd(0, List.of(insertion)); @@ -54,13 +53,13 @@ public void k0_atEndInsertionsNotReturned() { } @Test - public void noInsertions_emptyList() { + void noInsertions_emptyList() { var filteredInsertions = filterOneInsertionAtEnd(); assertThat(filteredInsertions).isEmpty(); } @Test - public void noAtEndInsertions_allReturned() { + void noAtEndInsertions_allReturned() { var vehicleEntry = vehicleEntry("v1", start(0), stop(100)); var insertion1 = insertion(vehicleEntry, 0, 11); var insertion2 = insertion(vehicleEntry, 0, 22); @@ -70,7 +69,7 @@ public void noAtEndInsertions_allReturned() { } @Test - public void onlyAtEndInsertions_theEarliestReturned() { + void onlyAtEndInsertions_theEarliestReturned() { var vehicleEntry1 = vehicleEntry("v1", start(0), stop(100)); var insertion1 = insertion(vehicleEntry1, 1, 110); @@ -83,7 +82,7 @@ public void onlyAtEndInsertions_theEarliestReturned() { } @Test - public void onlyAtEndInsertions_equalArrivalTime_useVehicleIdAsTieBreaker() { + void onlyAtEndInsertions_equalArrivalTime_useVehicleIdAsTieBreaker() { var vehicleEntry1 = vehicleEntry("v1", start(0), stop(100)); var insertion1 = insertion(vehicleEntry1, 1, 110); @@ -96,7 +95,7 @@ public void onlyAtEndInsertions_equalArrivalTime_useVehicleIdAsTieBreaker() { } @Test - public void mixedTypeInsertions_bothReturned() { + void mixedTypeInsertions_bothReturned() { var vehicleEntry = vehicleEntry("v1", start(0), stop(100)); var insertionAfterStart = insertion(vehicleEntry, 0, 11); var insertionAtEnd = insertion(vehicleEntry, 1, 10); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/MultiInsertionDetourPathCalculatorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/MultiInsertionDetourPathCalculatorTest.java index 83ad6959ffe..9c604cb7acd 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/MultiInsertionDetourPathCalculatorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/MultiInsertionDetourPathCalculatorTest.java @@ -32,7 +32,7 @@ import java.util.Map; import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Node; @@ -76,7 +76,7 @@ public void after() { } @Test - public void calculatePaths() { + void calculatePaths() { var pathToPickup = mockCalcPathData(pickupLink, beforePickupLink, request.getEarliestStartTime(), false, 11); var pathFromPickup = mockCalcPathData(pickupLink, afterPickupLink, request.getEarliestStartTime(), true, 22); var pathToDropoff = mockCalcPathData(dropoffLink, beforeDropoffLink, request.getLatestArrivalTime(), false, 33); @@ -96,7 +96,7 @@ public void calculatePaths() { } @Test - public void calculatePaths_dropoffAfterPickup_dropoffAtEnd() { + void calculatePaths_dropoffAfterPickup_dropoffAtEnd() { //compute only 2 paths (instead of 4) var pathToPickup = mockCalcPathData(pickupLink, beforePickupLink, request.getEarliestStartTime(), false, 11); var pathFromPickup = mockCalcPathData(pickupLink, dropoffLink, request.getEarliestStartTime(), true, 22); @@ -117,7 +117,7 @@ public void calculatePaths_dropoffAfterPickup_dropoffAtEnd() { } @Test - public void calculatePaths_noDetours() { + void calculatePaths_noDetours() { // OneToManyPathSearch.calcPathDataMap() returns a map that contains entries for all toLinks // (unless the stop criterion terminates computations earlier) // If fromLink is in toLinks than PathData.EMPTY is mapped for such a link diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/selective/SingleInsertionDetourPathCalculatorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/selective/SingleInsertionDetourPathCalculatorTest.java index 95d69fe11c4..62a8f56f9e6 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/selective/SingleInsertionDetourPathCalculatorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/selective/SingleInsertionDetourPathCalculatorTest.java @@ -31,7 +31,7 @@ import java.util.List; import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Node; @@ -80,7 +80,7 @@ public void after() { } @Test - public void calculatePaths() { + void calculatePaths() { var pathToPickup = mockCalcLeastCostPath(beforePickupLink, pickupLink, request.getEarliestStartTime(), 11); var pathFromPickup = mockCalcLeastCostPath(pickupLink, afterPickupLink, request.getEarliestStartTime(), 22); var pathToDropoff = mockCalcLeastCostPath(beforeDropoffLink, dropoffLink, request.getLatestArrivalTime(), 33); @@ -99,7 +99,7 @@ public void calculatePaths() { } @Test - public void calculatePaths_dropoffAfterPickup_dropoffAtEnd() { + void calculatePaths_dropoffAfterPickup_dropoffAtEnd() { //compute only 2 paths (instead of 4) var pathToPickup = mockCalcLeastCostPath(beforePickupLink, pickupLink, request.getEarliestStartTime(), 11); var pathFromPickup = mockCalcLeastCostPath(pickupLink, dropoffLink, request.getEarliestStartTime(), 22); @@ -120,7 +120,7 @@ public void calculatePaths_dropoffAfterPickup_dropoffAtEnd() { } @Test - public void calculatePaths_noDetours() { + void calculatePaths_noDetours() { var pickup = insertionPoint(waypoint(pickupLink), waypoint(pickupLink)); var dropoff = insertionPoint(waypoint(dropoffLink), waypoint(dropoffLink)); var insertion = new Insertion(null, pickup, dropoff); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/demandestimator/PreviousIterationDrtDemandEstimatorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/demandestimator/PreviousIterationDrtDemandEstimatorTest.java index 7a155267da4..954959480ba 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/demandestimator/PreviousIterationDrtDemandEstimatorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/demandestimator/PreviousIterationDrtDemandEstimatorTest.java @@ -24,7 +24,7 @@ import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -51,7 +51,7 @@ public class PreviousIterationDrtDemandEstimatorTest { private final DrtZonalSystem zonalSystem = new DrtZonalSystem(List.of(zone1, zone2)); @Test - public void noDepartures() { + void noDepartures() { PreviousIterationDrtDemandEstimator estimator = createEstimator(); //no events in previous iterations @@ -66,7 +66,7 @@ public void noDepartures() { } @Test - public void drtDepartures() { + void drtDepartures() { PreviousIterationDrtDemandEstimator estimator = createEstimator(); //time bin 0-1800 @@ -101,7 +101,7 @@ public void drtDepartures() { } @Test - public void nonDrtDepartures() { + void nonDrtDepartures() { PreviousIterationDrtDemandEstimator estimator = createEstimator(); estimator.handleEvent(departureEvent(100, link1, "mode X")); @@ -113,7 +113,7 @@ public void nonDrtDepartures() { } @Test - public void currentCountsAreCopiedToPreviousAfterReset() { + void currentCountsAreCopiedToPreviousAfterReset() { PreviousIterationDrtDemandEstimator estimator = createEstimator(); estimator.handleEvent(departureEvent(100, link1, TransportMode.drt)); @@ -129,7 +129,7 @@ public void currentCountsAreCopiedToPreviousAfterReset() { } @Test - public void timeBinsAreRespected() { + void timeBinsAreRespected() { PreviousIterationDrtDemandEstimator estimator = createEstimator(); estimator.handleEvent(departureEvent(100, link1, TransportMode.drt)); @@ -147,7 +147,7 @@ public void timeBinsAreRespected() { } @Test - public void noTimeLimitIsImposed() { + void noTimeLimitIsImposed() { PreviousIterationDrtDemandEstimator estimator = createEstimator(); estimator.handleEvent(departureEvent(10000000, link1, TransportMode.drt)); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/targetcalculator/EqualVehicleDensityTargetCalculatorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/targetcalculator/EqualVehicleDensityTargetCalculatorTest.java index b37ef0d10f1..4f51cb334a5 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/targetcalculator/EqualVehicleDensityTargetCalculatorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/targetcalculator/EqualVehicleDensityTargetCalculatorTest.java @@ -25,7 +25,7 @@ import java.util.Map; import java.util.function.ToDoubleFunction; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Network; import org.matsim.contrib.drt.analysis.zonal.DrtGridUtils; @@ -57,21 +57,21 @@ public class EqualVehicleDensityTargetCalculatorTest { DrtGridUtils.createGridFromNetwork(network, 500.)); @Test - public void calculate_oneVehiclePerZone() { + void calculate_oneVehiclePerZone() { var targetFunction = new EqualVehicleDensityTargetCalculator(zonalSystem, createFleetSpecification(8)).calculate(0, Map.of()); zonalSystem.getZones().keySet().forEach(id -> assertTarget(targetFunction, zonalSystem, id, 1)); } @Test - public void calculate_lessVehiclesThanZones() { + void calculate_lessVehiclesThanZones() { var targetFunction = new EqualVehicleDensityTargetCalculator(zonalSystem, createFleetSpecification(7)).calculate(0, Map.of()); zonalSystem.getZones().keySet().forEach(id -> assertTarget(targetFunction, zonalSystem, id, 7. / 8)); } @Test - public void calculate_moreVehiclesThanZones() { + void calculate_moreVehiclesThanZones() { var targetFunction = new EqualVehicleDensityTargetCalculator(zonalSystem, createFleetSpecification(9)).calculate(0, Map.of()); zonalSystem.getZones().keySet().forEach(id -> assertTarget(targetFunction, zonalSystem, id, 9. / 8)); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/targetcalculator/EqualVehiclesToPopulationRatioTargetCalculatorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/targetcalculator/EqualVehiclesToPopulationRatioTargetCalculatorTest.java index e27e9850b96..7d1044fcd6e 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/targetcalculator/EqualVehiclesToPopulationRatioTargetCalculatorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/targetcalculator/EqualVehiclesToPopulationRatioTargetCalculatorTest.java @@ -25,7 +25,7 @@ import java.util.Map; import java.util.function.ToDoubleFunction; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -66,7 +66,7 @@ public class EqualVehiclesToPopulationRatioTargetCalculatorTest { private final PopulationFactory factory = population.getFactory(); @Test - public void testCalculate_oneVehiclePerZone() { + void testCalculate_oneVehiclePerZone() { initPopulation(Map.of("2", 1, "4", 1, "8", 1)); var targetFunction = new EqualVehiclesToPopulationRatioTargetCalculator(zonalSystem, population, createFleetSpecification(8)).calculate(0, Map.of()); @@ -82,7 +82,7 @@ public void testCalculate_oneVehiclePerZone() { } @Test - public void testCalculate_twoVehiclesPerZone() { + void testCalculate_twoVehiclesPerZone() { initPopulation(Map.of("2", 1, "4", 1, "8", 1)); var targetFunction = new EqualVehiclesToPopulationRatioTargetCalculator(zonalSystem, population, createFleetSpecification(16)).calculate(0, Map.of()); @@ -98,7 +98,7 @@ public void testCalculate_twoVehiclesPerZone() { } @Test - public void testCalculate_noPopulation() { + void testCalculate_noPopulation() { initPopulation(Map.of()); var targetFunction = new EqualVehiclesToPopulationRatioTargetCalculator(zonalSystem, population, createFleetSpecification(16)).calculate(0, Map.of()); @@ -114,7 +114,7 @@ public void testCalculate_noPopulation() { } @Test - public void testCalculate_unevenDistributionOfActivitiesInPopulatedZones() { + void testCalculate_unevenDistributionOfActivitiesInPopulatedZones() { initPopulation(Map.of("2", 2, "4", 4, "8", 8)); var targetFunction = new EqualVehiclesToPopulationRatioTargetCalculator(zonalSystem, population, createFleetSpecification(16)).calculate(0, Map.of()); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/AbandonAndCancelTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/AbandonAndCancelTest.java index ba9f10a787e..692657020d8 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/AbandonAndCancelTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/AbandonAndCancelTest.java @@ -3,8 +3,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Leg; import org.matsim.contrib.drt.prebooking.PrebookingTestEnvironment.RequestInfo; @@ -25,7 +25,7 @@ public class AbandonAndCancelTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void noAbandonTest() { + void noAbandonTest() { /* * One person requests to depart at 2000 and also is there at 2000. Another * person asks also to depart at 2000, but only arrives at 4000, i.e. the person @@ -59,7 +59,7 @@ public void noAbandonTest() { } @Test - public void abandonTest() { + void abandonTest() { /* * One person requests to depart at 2000 and also is there at 2000. Another * person asks also to depart at 2000, but only arrives at 4000, i.e. the person @@ -98,7 +98,7 @@ public void abandonTest() { } @Test - public void abandonThenImmediateTest() { + void abandonThenImmediateTest() { /* * One person requests to depart at 2000 and also is there at 2000. Another * person asks also to depart at 2000, but only arrives at 4000, i.e. the person @@ -141,7 +141,7 @@ public void abandonThenImmediateTest() { } @Test - public void cancelEarlyTest() { + void cancelEarlyTest() { /* * One person requests to depart at 2000 and also is there at 2000. Another * person asks also to depart at 2000, but only arrives at 4000, i.e. the person @@ -204,7 +204,7 @@ public void notifyMobsimBeforeSimStep(MobsimBeforeSimStepEvent e) { } @Test - public void cancelLateTest() { + void cancelLateTest() { /* * One person requests to depart at 2000 and also is there at 2000. Another * person asks also to depart at 2000, but only arrives at 4000, i.e. the person diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/ComplexUnschedulerTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/ComplexUnschedulerTest.java index 84c3ada7791..f6155aceec8 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/ComplexUnschedulerTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/ComplexUnschedulerTest.java @@ -8,7 +8,7 @@ import java.util.LinkedList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -55,7 +55,7 @@ */ public class ComplexUnschedulerTest { @Test - public void testDirectDropoffAfterPickup() { + void testDirectDropoffAfterPickup() { Fixture fixture = new Fixture(); Schedule schedule = fixture.schedule; @@ -115,7 +115,7 @@ public void testDirectDropoffAfterPickup() { } @Test - public void testStandardSituation() { + void testStandardSituation() { Fixture fixture = new Fixture(); Schedule schedule = fixture.schedule; @@ -179,7 +179,7 @@ public void testStandardSituation() { } @Test - public void testRemoveAtEnd() { + void testRemoveAtEnd() { Fixture fixture = new Fixture(); Schedule schedule = fixture.schedule; @@ -244,7 +244,7 @@ public void testRemoveAtEnd() { } @Test - public void testRemoveAtBeginningWithWaitSecond() { + void testRemoveAtBeginningWithWaitSecond() { Fixture fixture = new Fixture(); Schedule schedule = fixture.schedule; @@ -310,7 +310,7 @@ public void testRemoveAtBeginningWithWaitSecond() { } @Test - public void testRemoveAtBeginningWithWaitFirst() { + void testRemoveAtBeginningWithWaitFirst() { Fixture fixture = new Fixture(); Schedule schedule = fixture.schedule; @@ -374,7 +374,7 @@ public void testRemoveAtBeginningWithWaitFirst() { } @Test - public void testRemoveAtBeginningWithDriveDiversion() { + void testRemoveAtBeginningWithDriveDiversion() { Fixture fixture = new Fixture(); Schedule schedule = fixture.schedule; @@ -451,7 +451,7 @@ public void testRemoveAtBeginningWithDriveDiversion() { } @Test - public void testRemoveAllStartWithWait() { + void testRemoveAllStartWithWait() { Fixture fixture = new Fixture(); Schedule schedule = fixture.schedule; @@ -484,7 +484,7 @@ public void testRemoveAllStartWithWait() { } @Test - public void testRemoveAllStartWithDrive() { + void testRemoveAllStartWithDrive() { Fixture fixture = new Fixture(); Schedule schedule = fixture.schedule; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PersonStuckPrebookingTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PersonStuckPrebookingTest.java index 1c017bc5f1a..35605aac125 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PersonStuckPrebookingTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PersonStuckPrebookingTest.java @@ -6,8 +6,8 @@ import java.util.Collections; import java.util.Set; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Leg; @@ -41,7 +41,7 @@ public class PersonStuckPrebookingTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void baselineTest() { + void baselineTest() { /* * Agent personA is performing three drt legs during the day. Agent personB does * exactly the same in parallel, both prebook their requests. @@ -72,7 +72,7 @@ public void baselineTest() { } @Test - public void cancelTest() { + void cancelTest() { /* * Agent personA is performing three drt legs during the day. Agent personB does * exactly the same in parallel, both prebook there requests. diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTest.java index 2845a5d7af4..05f5eeb2eb8 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTest.java @@ -2,8 +2,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.contrib.drt.prebooking.PrebookingTestEnvironment.RequestInfo; import org.matsim.contrib.drt.prebooking.logic.AttributeBasedPrebookingLogic; import org.matsim.contrib.drt.run.DrtConfigGroup; @@ -18,7 +18,7 @@ public class PrebookingTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void withoutPrebookedRequests() { + void withoutPrebookedRequests() { /*- * Standard test running with prebooking but without any prebooked requests */ @@ -66,7 +66,7 @@ static PrebookingParams installPrebooking(Controler controller, boolean installL } @Test - public void oneRequestArrivingLate() { + void oneRequestArrivingLate() { /*- * One request arriving after the requested departure time. Vehicle should wait * and depart with appropriate delay (taking into account a fixed duration for @@ -105,7 +105,7 @@ public void oneRequestArrivingLate() { } @Test - public void oneRequestArrivingEarly() { + void oneRequestArrivingEarly() { /*- * One request arriving in advance before the requested departure time. Vehicle * will pickup up agent and then depart after the duration to enter the vehicle. @@ -143,7 +143,7 @@ public void oneRequestArrivingEarly() { } @Test - public void twoSequentialRequests() { + void twoSequentialRequests() { /*- * Two requests that are scheduled in advance. * - First the early one is submitted, then the late one @@ -176,7 +176,7 @@ public void twoSequentialRequests() { } @Test - public void twoSequentialRequests_inverseSubmission() { + void twoSequentialRequests_inverseSubmission() { /*- * Two requests that are scheduled in advance. * - First the late one is submitted, then the early one (inverse of above test). @@ -210,7 +210,7 @@ public void twoSequentialRequests_inverseSubmission() { } @Test - public void sameTrip_differentDepartureTime() { + void sameTrip_differentDepartureTime() { /*- * Two requests with the same origin and destination, but distinct departure time. * - First, early one is submitted, then late one. @@ -248,7 +248,7 @@ public void sameTrip_differentDepartureTime() { } @Test - public void sameTrip_sameDepartureTime() { + void sameTrip_sameDepartureTime() { /*- * Two requests with the same origin and destination, and same departure time. * - First, A is submitted, then B. @@ -286,7 +286,7 @@ public void sameTrip_sameDepartureTime() { } @Test - public void sameTrip_extendPickupDuration() { + void sameTrip_extendPickupDuration() { /*- * Two requests with the same origin and destination, different departure times. * - First, A is submitted with departure time 2000 @@ -330,7 +330,7 @@ public void sameTrip_extendPickupDuration() { } @Test - public void sameTrip_splitPickup() { + void sameTrip_splitPickup() { /*- * Two requests with the same origin and destination, different departure times. * - First, A is submitted with departure time 2000 @@ -377,7 +377,7 @@ public void sameTrip_splitPickup() { } @Test - public void sameTrip_inverseSubmission_noPrepending() { + void sameTrip_inverseSubmission_noPrepending() { /*- * Two requests with the same origin and destination, different departure times. * - First, A is submitted with departure time 2020 @@ -435,7 +435,7 @@ public void sameTrip_inverseSubmission_noPrepending() { } @Test - public void sameTrip_inverseSubmission_splitPickup() { + void sameTrip_inverseSubmission_splitPickup() { /*- * Two requests with the same origin and destination, different departure times. * - First, A is submitted with departure time 2020 diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java index 2bf9646c17a..71dc3a222b8 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java @@ -23,8 +23,8 @@ import java.util.List; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -70,7 +70,7 @@ public class DrtRoutingModuleTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testCottbusClosestAccessEgressStopFinder() { + void testCottbusClosestAccessEgressStopFinder() { Scenario scenario = createTestScenario(); ActivityFacilities facilities = scenario.getActivityFacilities(); final double networkTravelSpeed = 0.83333; @@ -226,7 +226,7 @@ public void testCottbusClosestAccessEgressStopFinder() { } @Test - public void testRouteDescriptionHandling() { + void testRouteDescriptionHandling() { String oldRouteFormat = "600 400"; String newRouteFormat = "{\"maxWaitTime\":600.0,\"directRideTime\":400.0,\"unsharedPath\":[\"a\",\"b\",\"c\"]}"; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/MultiModeDrtMainModeIdentifierTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/MultiModeDrtMainModeIdentifierTest.java index d9af16f9896..517321d1305 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/MultiModeDrtMainModeIdentifierTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/MultiModeDrtMainModeIdentifierTest.java @@ -4,7 +4,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.Activity; @@ -21,7 +21,7 @@ public class MultiModeDrtMainModeIdentifierTest { @Test - public void test() { + void test() { DrtConfigGroup drtConfigGroup = new DrtConfigGroup(); String drtMode = "drt"; drtConfigGroup.mode = drtMode; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java index 7878dad8604..04bd15fa5c8 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java @@ -30,9 +30,8 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; - +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.drt.optimizer.DrtRequestInsertionRetryParams; import org.matsim.contrib.drt.optimizer.insertion.repeatedselective.RepeatedSelectiveInsertionSearchParams; @@ -76,7 +75,7 @@ public class RunDrtExampleIT { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testRunDrtExampleWithNoRejections_ExtensiveSearch() { + void testRunDrtExampleWithNoRejections_ExtensiveSearch() { Id.resetCaches(); URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml"); Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), @@ -103,7 +102,7 @@ public void testRunDrtExampleWithNoRejections_ExtensiveSearch() { } @Test - public void testRunDrtExampleWithNoRejections_SelectiveSearch() { + void testRunDrtExampleWithNoRejections_SelectiveSearch() { Id.resetCaches(); URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml"); Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), @@ -137,7 +136,7 @@ public void testRunDrtExampleWithNoRejections_SelectiveSearch() { } @Test - public void testRunDrtExampleWithNoRejections_RepeatedSelectiveSearch() { + void testRunDrtExampleWithNoRejections_RepeatedSelectiveSearch() { Id.resetCaches(); URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml"); Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), @@ -172,7 +171,7 @@ public void testRunDrtExampleWithNoRejections_RepeatedSelectiveSearch() { } @Test - public void testRunDrtExampleWithRequestRetry() { + void testRunDrtExampleWithRequestRetry() { Id.resetCaches(); URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml"); Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), @@ -201,7 +200,7 @@ public void testRunDrtExampleWithRequestRetry() { } @Test - public void testRunDrtStopbasedExample() { + void testRunDrtStopbasedExample() { Id.resetCaches(); URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_stop_based_drt_config.xml"); @@ -224,7 +223,7 @@ public void testRunDrtStopbasedExample() { } @Test - public void testRunDrtStopbasedExampleWithFlexibleStopDuration() { + void testRunDrtStopbasedExampleWithFlexibleStopDuration() { Id.resetCaches(); URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_stop_based_drt_config.xml"); @@ -259,7 +258,7 @@ public void install() { } @Test - public void testRunServiceAreabasedExampleWithSpeedUp() { + void testRunServiceAreabasedExampleWithSpeedUp() { Id.resetCaches(); URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_serviceArea_based_drt_config.xml"); @@ -282,7 +281,7 @@ public void testRunServiceAreabasedExampleWithSpeedUp() { } @Test - public void testRunDrtExampleWithIncrementalStopDuration() { + void testRunDrtExampleWithIncrementalStopDuration() { Id.resetCaches(); URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml"); Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), @@ -321,7 +320,7 @@ public void install() { } @Test - public void testRunDrtWithPrebooking() { + void testRunDrtWithPrebooking() { Id.resetCaches(); URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml"); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunMultiModeDrtExampleIT.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunMultiModeDrtExampleIT.java index 88aae448e87..b5bdb9ca19a 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunMultiModeDrtExampleIT.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunMultiModeDrtExampleIT.java @@ -22,13 +22,13 @@ import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; public class RunMultiModeDrtExampleIT { @Test - public void testRun() { + void testRun() { URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("dvrp-grid"), "multi_mode_one_shared_taxi_config.xml"); RunMultiModeDrtExample.run(configUrl, false, 0); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunOneSharedTaxiExampleIT.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunOneSharedTaxiExampleIT.java index db6373e49be..eaa173d1466 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunOneSharedTaxiExampleIT.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunOneSharedTaxiExampleIT.java @@ -20,7 +20,7 @@ import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; @@ -29,7 +29,7 @@ */ public class RunOneSharedTaxiExampleIT { @Test - public void testRun() { + void testRun() { URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("dvrp-grid"), "one_shared_taxi_config.xml"); RunOneSharedTaxiExample.run(configUrl, false, 1); } diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/speedup/DrtSpeedUpTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/speedup/DrtSpeedUpTest.java index af92306b69e..1f08cf7c993 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/speedup/DrtSpeedUpTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/speedup/DrtSpeedUpTest.java @@ -30,8 +30,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -72,7 +71,7 @@ public class DrtSpeedUpTest { private final ControllerConfigGroup controlerConfig = new ControllerConfigGroup(); @Test - public final void test_computeMovingAverage() { + final void test_computeMovingAverage() { List list = List.of(2., 5., 22.); assertThat(computeMovingAverage(2, list)).isEqualTo(27. / 2); assertThat(computeMovingAverage(3, list)).isEqualTo(29. / 3); @@ -80,7 +79,7 @@ public final void test_computeMovingAverage() { } @Test - public void test_isTeleportDrtUsers() { + void test_isTeleportDrtUsers() { drtSpeedUpParams.fractionOfIterationsSwitchOn = 0.1; drtSpeedUpParams.fractionOfIterationsSwitchOff = 0.9; drtSpeedUpParams.intervalDetailedIteration = 10; @@ -124,7 +123,7 @@ public void test_isTeleportDrtUsers() { private final DrtEventSequenceCollector requestAnalyzer = mock(DrtEventSequenceCollector.class); @Test - public void test_useOnlyInitialEstimates_noRegression() { + void test_useOnlyInitialEstimates_noRegression() { //iters 0 & 100 - simulated, iters 1...99 - teleported drtSpeedUpParams.fractionOfIterationsSwitchOn = 0.0; drtSpeedUpParams.fractionOfIterationsSwitchOff = 1.0; @@ -161,7 +160,7 @@ public void test_useOnlyInitialEstimates_noRegression() { } @Test - public void test_useAveragesFromLastTwoSimulations_noRegression() { + void test_useAveragesFromLastTwoSimulations_noRegression() { //iters 0, 2, 4 - simulated, iters 1, 3 - teleported drtSpeedUpParams.fractionOfIterationsSwitchOn = 0.0; drtSpeedUpParams.fractionOfIterationsSwitchOff = 1.0; @@ -209,7 +208,7 @@ public void test_useAveragesFromLastTwoSimulations_noRegression() { } @Test - public void test_linearRegression() { + void test_linearRegression() { //iters 0, 2, 4 - simulated, iters 1, 3 - teleported drtSpeedUpParams.fractionOfIterationsSwitchOn = 0.0; drtSpeedUpParams.fractionOfIterationsSwitchOff = 1.0; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/util/DrtEventsReadersTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/util/DrtEventsReadersTest.java index 27fcefc3b52..6ba4b41e0c8 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/util/DrtEventsReadersTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/util/DrtEventsReadersTest.java @@ -28,7 +28,7 @@ import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.Event; import org.matsim.api.core.v01.network.Link; @@ -72,7 +72,7 @@ public class DrtEventsReadersTest { taskEnded(70, EmptyVehicleRelocator.RELOCATE_VEHICLE_TASK_TYPE, 3, link2)); @Test - public void testReader() { + void testReader() { var outputStream = new ByteArrayOutputStream(); EventWriterXML writer = new EventWriterXML(outputStream); drtEvents.forEach(writer::handleEvent); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/benchmark/DvrpBenchmarkQSimModuleTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/benchmark/DvrpBenchmarkQSimModuleTest.java index 1571faf0e43..da9b96c0036 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/benchmark/DvrpBenchmarkQSimModuleTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/benchmark/DvrpBenchmarkQSimModuleTest.java @@ -25,7 +25,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.core.network.NetworkUtils; import org.matsim.core.router.util.TravelTime; @@ -36,7 +36,7 @@ */ public class DvrpBenchmarkQSimModuleTest { @Test - public void calcLinkSpeed() { + void calcLinkSpeed() { var link = NetworkUtils.createLink(Id.createLinkId("id"), null, null, null, 150, 15, 10, 1); var vehicle = mock(Vehicle.class); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiExampleIT.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiExampleIT.java index 0e509daca53..cb490c13c13 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiExampleIT.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiExampleIT.java @@ -21,13 +21,13 @@ import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; public class RunOneTaxiExampleIT { @Test - public void testRun() { + void testRun() { URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("dvrp-grid"), "generic_dvrp_one_taxi_config.xml"); RunOneTaxiExample.run(configUrl, "one_taxi_vehicles.xml", false, 0); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiWithPrebookingExampleIT.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiWithPrebookingExampleIT.java index 55e0e574dac..fc8deb6874c 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiWithPrebookingExampleIT.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiWithPrebookingExampleIT.java @@ -33,8 +33,8 @@ import org.apache.logging.log4j.Logger; import org.assertj.core.data.Offset; import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -73,7 +73,7 @@ public class RunOneTaxiWithPrebookingExampleIT { @Ignore @Test - public void testRun() { + void testRun() { // load config URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("dvrp-grid"), "generic_dvrp_one_taxi_config.xml"); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxionetruck/RunOneTaxiOneTruckExampleIT.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxionetruck/RunOneTaxiOneTruckExampleIT.java index 8f9ec937f63..10c9373563d 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxionetruck/RunOneTaxiOneTruckExampleIT.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxionetruck/RunOneTaxiOneTruckExampleIT.java @@ -22,13 +22,13 @@ import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; public class RunOneTaxiOneTruckExampleIT { @Test - public void testRun() { + void testRun() { URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("dvrp-grid"), "one_taxi_one_truck_config.xml"); RunOneTaxiOneTruckExample.run(configUrl, "one_taxi_vehicles.xml", "one_truck_vehicles.xml", false, 0); } diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetruck/RunOneTruckExampleIT.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetruck/RunOneTruckExampleIT.java index 1363005eb93..b43bcac98b5 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetruck/RunOneTruckExampleIT.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetruck/RunOneTruckExampleIT.java @@ -21,13 +21,13 @@ import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; public class RunOneTruckExampleIT { @Test - public void testRun() { + void testRun() { URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("dvrp-grid"), "one_truck_config.xml"); RunOneTruckExample.run(configUrl, "one_truck_vehicles.xml", false, 0); } diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/passenger/DefaultPassengerEngineTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/passenger/DefaultPassengerEngineTest.java index db4efe8d602..97579d14517 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/passenger/DefaultPassengerEngineTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/passenger/DefaultPassengerEngineTest.java @@ -25,8 +25,7 @@ import java.util.Collections; import java.util.List; import java.util.Set; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; import org.matsim.api.core.v01.events.ActivityStartEvent; @@ -80,7 +79,7 @@ public class DefaultPassengerEngineTest { private final Fleet fleet = () -> ImmutableMap.of(oneTaxi.getId(), oneTaxi); @Test - public void test_valid_served() { + void test_valid_served() { double departureTime = 0; fixture.addPersonWithLeg(fixture.linkAB, fixture.linkBA, departureTime, fixture.PERSON_ID); @@ -114,7 +113,7 @@ public void test_valid_served() { } @Test - public void test_invalid_rejected() { + void test_invalid_rejected() { double departureTime = 0; fixture.addPersonWithLeg(fixture.linkAB, fixture.linkBA, departureTime, fixture.PERSON_ID); @@ -132,7 +131,7 @@ public void test_invalid_rejected() { } @Test - public void test_valid_rejected() { + void test_valid_rejected() { double departureTime = 0; fixture.addPersonWithLeg(fixture.linkAB, fixture.linkBA, departureTime, fixture.PERSON_ID); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/passenger/GroupPassengerEngineTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/passenger/GroupPassengerEngineTest.java index 2f34014ca2f..9630efb9374 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/passenger/GroupPassengerEngineTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/passenger/GroupPassengerEngineTest.java @@ -2,7 +2,7 @@ import com.google.common.collect.ImmutableMap; import org.apache.commons.compress.utils.Sets; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.*; import org.matsim.api.core.v01.network.Network; @@ -49,7 +49,7 @@ public class GroupPassengerEngineTest { private final Fleet fleet = () -> ImmutableMap.of(oneTaxi.getId(), oneTaxi); @Test - public void test_group() { + void test_group() { double departureTime = 0; Id person1 = Id.createPersonId("1"); Id person2 = Id.createPersonId("2"); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/passenger/TeleportingPassengerEngineTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/passenger/TeleportingPassengerEngineTest.java index 6d1c3edd7d1..e26364800ab 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/passenger/TeleportingPassengerEngineTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/passenger/TeleportingPassengerEngineTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.dvrp.passenger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.*; import org.matsim.api.core.v01.network.Network; @@ -50,7 +50,7 @@ public class TeleportingPassengerEngineTest { private final PassengerEngineTestFixture fixture = new PassengerEngineTestFixture(); @Test - public void test_valid_teleported() { + void test_valid_teleported() { double departureTime = 0; fixture.addPersonWithLeg(fixture.linkAB, fixture.linkBA, departureTime, fixture.PERSON_ID); @@ -81,7 +81,7 @@ public void test_valid_teleported() { } @Test - public void test_invalid_rejected() { + void test_invalid_rejected() { double departureTime = 0; fixture.addPersonWithLeg(fixture.linkAB, fixture.linkBA, departureTime, fixture.PERSON_ID); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/path/LeastCostPathTreeStopCriteriaTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/path/LeastCostPathTreeStopCriteriaTest.java index 9b83de3356f..b10829bc365 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/path/LeastCostPathTreeStopCriteriaTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/path/LeastCostPathTreeStopCriteriaTest.java @@ -28,7 +28,7 @@ import java.util.Map; import java.util.function.IntToDoubleFunction; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.core.router.speedy.LeastCostPathTree.StopCriterion; import org.matsim.testcases.fakes.FakeNode; @@ -39,7 +39,7 @@ public class LeastCostPathTreeStopCriteriaTest { @Test - public void testAnd() { + void testAnd() { StopCriterion scTrue = (nodeIndex, arrivalTime, travelCost, distance, departureTime) -> true; StopCriterion scFalse = (nodeIndex, arrivalTime, travelCost, distance, departureTime) -> false; @@ -51,7 +51,7 @@ public void testAnd() { } @Test - public void testOr() { + void testOr() { StopCriterion scTrue = (nodeIndex, arrivalTime, travelCost, distance, departureTime) -> true; StopCriterion scFalse = (nodeIndex, arrivalTime, travelCost, distance, departureTime) -> false; @@ -63,7 +63,7 @@ public void testOr() { } @Test - public void testMaxTravelTime() { + void testMaxTravelTime() { StopCriterion sc = maxTravelTime(100); //TT is 100 - continue @@ -74,13 +74,13 @@ public void testMaxTravelTime() { } @Test - public void testAllEndNodesReached_noEndNodes() { + void testAllEndNodesReached_noEndNodes() { assertThatThrownBy(() -> allEndNodesReached(List.of())).isExactlyInstanceOf(IllegalArgumentException.class) .hasMessage("At least one end node must be provided."); } @Test - public void testAllEndNodesReached_oneEndNode() { + void testAllEndNodesReached_oneEndNode() { var endNode = new FakeNode(Id.createNodeId("end_node")); var otherNode = new FakeNode(Id.createNodeId("other_node")); StopCriterion sc = allEndNodesReached(List.of(endNode)); @@ -96,7 +96,7 @@ public void testAllEndNodesReached_oneEndNode() { } @Test - public void testAllEndNodesReached_twoEndNodes() { + void testAllEndNodesReached_twoEndNodes() { var endNode1 = new FakeNode(Id.createNodeId("end_node_1")); var endNode2 = new FakeNode(Id.createNodeId("end_node_2")); var otherNode = new FakeNode(Id.createNodeId("other_node")); @@ -119,13 +119,13 @@ public void testAllEndNodesReached_twoEndNodes() { } @Test - public void testLeastCostEndNodeReached_noEndNodes() { + void testLeastCostEndNodeReached_noEndNodes() { assertThatThrownBy(() -> new LeastCostEndNodeReached(List.of(), value -> 0)).isExactlyInstanceOf( IllegalArgumentException.class).hasMessage("At least one end node must be provided."); } @Test - public void testLeastCostEndNodeReached_oneEndNode() { + void testLeastCostEndNodeReached_oneEndNode() { var endNodeId = Id.createNodeId("end_node"); var otherNodeId = Id.createNodeId("other_node"); @@ -152,7 +152,7 @@ public void testLeastCostEndNodeReached_oneEndNode() { } @Test - public void testLeastCostEndNodeReached_twoEndNodes_stopBeforeReachingTheOtherEndNode() { + void testLeastCostEndNodeReached_twoEndNodes_stopBeforeReachingTheOtherEndNode() { var endNodeId1 = Id.createNodeId("end_node"); var endNodeId2 = Id.createNodeId("end_node_2"); var otherNodeId = Id.createNodeId("other_node"); @@ -172,7 +172,7 @@ public void testLeastCostEndNodeReached_twoEndNodes_stopBeforeReachingTheOtherEn } @Test - public void testLeastCostEndNodeReached_twoEndNodes_bothVisited_fartherEndNodeWithLowerTotalCost() { + void testLeastCostEndNodeReached_twoEndNodes_bothVisited_fartherEndNodeWithLowerTotalCost() { var endNodeId1 = Id.createNodeId("end_node"); var endNodeId2 = Id.createNodeId("end_node_2"); @@ -192,7 +192,7 @@ public void testLeastCostEndNodeReached_twoEndNodes_bothVisited_fartherEndNodeWi } @Test - public void testLeastCostEndNodeReached_twoEndNodes_noAdditionalCost_stopAfterVisitingFirstEndNode() { + void testLeastCostEndNodeReached_twoEndNodes_noAdditionalCost_stopAfterVisitingFirstEndNode() { var endNodeId1 = Id.createNodeId("end_node"); var endNodeId2 = Id.createNodeId("end_node_2"); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/path/OneToManyPathCalculatorTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/path/OneToManyPathCalculatorTest.java index d042fb3c814..8730f17dcb9 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/path/OneToManyPathCalculatorTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/path/OneToManyPathCalculatorTest.java @@ -27,7 +27,7 @@ import java.util.List; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.IdMap; @@ -76,7 +76,7 @@ public void init() { } @Test - public void forward_fromNodeB_toNodeB() { + void forward_fromNodeB_toNodeB() { //forward search starting from nodeB at time 0 var pathCalculator = new OneToManyPathCalculator(nodeMap, dijkstraTree, travelTime, true, linkAB, 0); @@ -94,7 +94,7 @@ public void forward_fromNodeB_toNodeB() { } @Test - public void forward_fromNodeB_toNodesBD() { + void forward_fromNodeB_toNodesBD() { //forward search starting from nodeB at time 0 var pathCalculator = new OneToManyPathCalculator(nodeMap, dijkstraTree, travelTime, true, linkAB, 0); @@ -109,7 +109,7 @@ public void forward_fromNodeB_toNodesBD() { } @Test - public void forward_fromNodeB_toNodesBD_maxTravelTime() { + void forward_fromNodeB_toNodesBD_maxTravelTime() { //forward search starting from nodeB at time 0 var pathCalculator = new OneToManyPathCalculator(nodeMap, dijkstraTree, travelTime, true, linkAB, 0); @@ -124,7 +124,7 @@ public void forward_fromNodeB_toNodesBD_maxTravelTime() { } @Test - public void backward_fromNodeD_toNodeD() { + void backward_fromNodeD_toNodeD() { //backward search starting from nodeD at time 0 var pathCalculator = new OneToManyPathCalculator(nodeMap, dijkstraTree, travelTime, false, linkDE, 0); @@ -142,7 +142,7 @@ public void backward_fromNodeD_toNodeD() { } @Test - public void backward_fromNodeD_toNodesBD() { + void backward_fromNodeD_toNodesBD() { //backward search starting from nodeD at time 0 var pathCalculator = new OneToManyPathCalculator(nodeMap, dijkstraTree, travelTime, false, linkDE, 0); @@ -157,7 +157,7 @@ public void backward_fromNodeD_toNodesBD() { } @Test - public void backward_fromNodeD_toNodesBD_maxTravelTime() { + void backward_fromNodeD_toNodesBD_maxTravelTime() { //backward search starting from nodeD at time 0 var pathCalculator = new OneToManyPathCalculator(nodeMap, dijkstraTree, travelTime, false, linkDE, 0); @@ -172,7 +172,7 @@ public void backward_fromNodeD_toNodesBD_maxTravelTime() { } @Test - public void equalFromLinkAndToLink() { + void equalFromLinkAndToLink() { LeastCostPathTree mockedTree = mock(LeastCostPathTree.class); for (boolean forward : List.of(true, false)) { @@ -186,7 +186,7 @@ public void equalFromLinkAndToLink() { } @Test - public void pathData_forward() { + void pathData_forward() { //forward search starting from linkAB at time 0 var pathCalculator = new OneToManyPathCalculator(nodeMap, dijkstraTree, travelTime, true, linkAB, 0); @@ -198,7 +198,7 @@ public void pathData_forward() { } @Test - public void pathData_backward() { + void pathData_backward() { //backward search starting from linkDE at time 0 var pathCalculator = new OneToManyPathCalculator(nodeMap, dijkstraTree, travelTime, false, linkDE, 0); @@ -210,7 +210,7 @@ public void pathData_backward() { } @Test - public void pathData_fromLinkEqualsToLink() { + void pathData_fromLinkEqualsToLink() { for (boolean forward : List.of(true, false)) { var pathCalculator = new OneToManyPathCalculator(nodeMap, dijkstraTree, travelTime, forward, linkAB, 0); pathCalculator.calculateDijkstraTree(List.of(linkAB)); @@ -219,7 +219,7 @@ public void pathData_fromLinkEqualsToLink() { } @Test - public void pathData_nodeNotReached() { + void pathData_nodeNotReached() { for (boolean forward : List.of(true, false)) { var pathCalculator = new OneToManyPathCalculator(nodeMap, dijkstraTree, travelTime, forward, linkAB, 0); pathCalculator.calculateDijkstraTree(List.of(linkBC)); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/router/DiversionTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/router/DiversionTest.java index adf44ba57ac..822f23b36c9 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/router/DiversionTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/router/DiversionTest.java @@ -6,7 +6,7 @@ import java.util.Set; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -75,7 +75,6 @@ public class DiversionTest { static public final String MODE = "testmode"; static public final int DIVERSION_FREQUENCY = 10; - @Test /** * This is a relatively complex test to the the diversion behaviour. The * experiment is constructed as folows: We have one DVRP vehicle which moves @@ -120,7 +119,8 @@ public class DiversionTest { * current one. * */ - public void testRepeatedSameDestinationDiversions() { + @Test + void testRepeatedSameDestinationDiversions() { Config config = ConfigUtils.createConfig(); { @@ -423,7 +423,6 @@ static private class TestTracker { private List taskEndTimes = new LinkedList<>(); } - @Test /** * This test is similar as the one above. However, there is another catch when * diverting, which is not covered on top. In fact, following the QSim and @@ -447,7 +446,8 @@ static private class TestTracker { * get a reduced arrival time estimate by one second. * */ - public void testRepeatedDiversionToDifferentDestinationRightBeforeLastLink() { + @Test + void testRepeatedDiversionToDifferentDestinationRightBeforeLastLink() { Config config = ConfigUtils.createConfig(); { diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/router/RoutingTimeStructureTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/router/RoutingTimeStructureTest.java index 41760878b96..f670f83a405 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/router/RoutingTimeStructureTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/router/RoutingTimeStructureTest.java @@ -28,7 +28,7 @@ import java.util.Optional; import org.apache.commons.lang3.tuple.Pair; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Activity; @@ -49,7 +49,7 @@ */ public class RoutingTimeStructureTest { @Test - public void testTimingWithSimpleAccess() { + void testTimingWithSimpleAccess() { TimeInterpretation timeInterpretation = TimeInterpretation.create(ConfigUtils.createConfig()); Facility fromFacility = mock(Facility.class); @@ -109,7 +109,7 @@ public void testTimingWithSimpleAccess() { } @Test - public void testTimingWithComplexAccess() { + void testTimingWithComplexAccess() { TimeInterpretation timeInterpretation = TimeInterpretation.create(ConfigUtils.createConfig()); Facility fromFacility = mock(Facility.class); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/trafficmonitoring/DvrpOfflineTravelTimeEstimatorTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/trafficmonitoring/DvrpOfflineTravelTimeEstimatorTest.java index 229738c16ce..808df1ff835 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/trafficmonitoring/DvrpOfflineTravelTimeEstimatorTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/trafficmonitoring/DvrpOfflineTravelTimeEstimatorTest.java @@ -22,8 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -61,7 +60,7 @@ public class DvrpOfflineTravelTimeEstimatorTest { private final TimeDiscretizer timeDiscretizer = new TimeDiscretizer(200, 100); @Test - public void getLinkTravelTime_timeAreCorrectlyBinned() { + void getLinkTravelTime_timeAreCorrectlyBinned() { var estimator = new DvrpOfflineTravelTimeEstimator(initialTT, null, network, timeDiscretizer, 0.25, null); //bin 0 @@ -79,7 +78,7 @@ public void getLinkTravelTime_timeAreCorrectlyBinned() { } @Test - public void getLinkTravelTime_exponentialAveragingOverIterations() { + void getLinkTravelTime_exponentialAveragingOverIterations() { double alpha = 0.25; //observed TTs for each time bin @@ -124,7 +123,7 @@ public void getLinkTravelTime_exponentialAveragingOverIterations() { } @Test - public void getLinkTravelTime_linkOutsideNetwork_fail() { + void getLinkTravelTime_linkOutsideNetwork_fail() { var linkOutsideNetwork = new FakeLink(Id.createLinkId("some-link")); var estimator = new DvrpOfflineTravelTimeEstimator(initialTT, null, network, timeDiscretizer, 0.25, null); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/trafficmonitoring/DvrpOfflineTravelTimesTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/trafficmonitoring/DvrpOfflineTravelTimesTest.java index efaa83bac7b..e3b904d4084 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/trafficmonitoring/DvrpOfflineTravelTimesTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/trafficmonitoring/DvrpOfflineTravelTimesTest.java @@ -34,8 +34,7 @@ import java.util.Arrays; import java.util.List; import java.util.Objects; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.common.timeprofile.TimeDiscretizer; @@ -52,7 +51,7 @@ public class DvrpOfflineTravelTimesTest { private final Id linkIdB = Id.createLinkId("B"); @Test - public void saveLinkTravelTimes() throws IOException { + void saveLinkTravelTimes() throws IOException { //the matrix may have more than 2 rows (depends on how many link ids are cached) var linkTTs = new double[Id.getNumberOfIds(Link.class)][]; @@ -70,7 +69,7 @@ public void saveLinkTravelTimes() throws IOException { } @Test - public void loadLinkTravelTimes() throws IOException { + void loadLinkTravelTimes() throws IOException { var line0 = String.join(";", "linkId", "0.0", "900.0", "1800.0", "2700.0", "3600.0"); var line1 = String.join(";", "A", 0.1 + "", 1.1 + "", 2.2 + "", 3.3 + "", 4.4 + ""); var line2 = String.join(";", "B", 5.5 + "", 6.6 + "", 7.7 + "", 8.8 + "", 9.9 + ""); @@ -89,7 +88,7 @@ public void loadLinkTravelTimes() throws IOException { } @Test - public void convertToLinkTravelTimes() { + void convertToLinkTravelTimes() { var link = new FakeLink(Id.createLinkId("link_A")); var timeDiscretizer = new TimeDiscretizer(100, 100); @@ -105,7 +104,7 @@ public void convertToLinkTravelTimes() { } @Test - public void asTravelTime() { + void asTravelTime() { var linkA = new FakeLink(Id.createLinkId("link_A")); var linkB = new FakeLink(Id.createLinkId("link_B")); var timeDiscretizer = new TimeDiscretizer(100, 100); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/util/DvrpEventsReadersTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/util/DvrpEventsReadersTest.java index b9452d7c495..3f8cbc2594e 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/util/DvrpEventsReadersTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/util/DvrpEventsReadersTest.java @@ -29,7 +29,7 @@ import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.Event; import org.matsim.api.core.v01.network.Link; @@ -81,7 +81,7 @@ private enum TestTaskType implements Task.TaskType { new TaskEndedEvent(333, mode, vehicle, driver, TestTaskType.DRIVE_TASK, 0, toLink)); @Test - public void testReader() { + void testReader() { var outputStream = new ByteArrayOutputStream(); EventWriterXML writer = new EventWriterXML(outputStream); dvrpEvents.forEach(writer::handleEvent); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/vrpagent/VrpAgentLogicTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/vrpagent/VrpAgentLogicTest.java index 89958aed641..9546a1ce4e4 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/vrpagent/VrpAgentLogicTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/vrpagent/VrpAgentLogicTest.java @@ -26,7 +26,7 @@ import static org.matsim.contrib.dvrp.vrpagent.VrpAgentLogic.BEFORE_SCHEDULE_ACTIVITY_TYPE; import static org.mockito.Mockito.*; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.dvrp.fleet.DvrpVehicle; @@ -86,7 +86,7 @@ public void nextTask(DvrpVehicle vehicle) { null, dynAgentLogic); @Test - public void testInitialActivity_unplanned() { + void testInitialActivity_unplanned() { DynActivity initialActivity = dynAgentLogic.computeInitialActivity(dynAgent); assertThat(initialActivity.getActivityType()).isEqualTo(BEFORE_SCHEDULE_ACTIVITY_TYPE); @@ -95,7 +95,7 @@ public void testInitialActivity_unplanned() { } @Test - public void testInitialActivity_planned() { + void testInitialActivity_planned() { DynActivity initialActivity = dynAgentLogic.computeInitialActivity(dynAgent); StayTask task0 = new DefaultStayTask(TestTaskType.TYPE, 10, 90, startLink); @@ -107,7 +107,7 @@ public void testInitialActivity_planned() { } @Test - public void testInitialActivity_started_failure() { + void testInitialActivity_started_failure() { DynActivity initialActivity = dynAgentLogic.computeInitialActivity(dynAgent); StayTask task0 = new DefaultStayTask(TestTaskType.TYPE, 10, 90, startLink); @@ -121,7 +121,7 @@ public void testInitialActivity_started_failure() { } @Test - public void testNextAction_unplanned_completed() { + void testNextAction_unplanned_completed() { IdleDynActivity nextAction = (IdleDynActivity)dynAgentLogic.computeNextAction(null, vehicle.getServiceEndTime()); @@ -131,7 +131,7 @@ public void testNextAction_unplanned_completed() { } @Test - public void testNextAction_planned_started() { + void testNextAction_planned_started() { double time = 10; StayTask task0 = new DefaultStayTask(TestTaskType.TYPE, time, 90, startLink); vehicle.getSchedule().addTask(task0); @@ -142,7 +142,7 @@ public void testNextAction_planned_started() { } @Test - public void testNextAction_started_started() { + void testNextAction_started_started() { double time = 50; StayTask task0 = new DefaultStayTask(TestTaskType.TYPE, 10, time, startLink); vehicle.getSchedule().addTask(task0); @@ -156,7 +156,7 @@ public void testNextAction_started_started() { } @Test - public void testNextAction_started_completed() { + void testNextAction_started_completed() { double time = 90; StayTask task0 = new DefaultStayTask(TestTaskType.TYPE, 10, time, startLink); vehicle.getSchedule().addTask(task0); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dynagent/examples/random/RunRandomDynAgentExampleTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dynagent/examples/random/RunRandomDynAgentExampleTest.java index 7076c71a804..78db1598058 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dynagent/examples/random/RunRandomDynAgentExampleTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dynagent/examples/random/RunRandomDynAgentExampleTest.java @@ -21,13 +21,13 @@ import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; public class RunRandomDynAgentExampleTest { @Test - public void testRun() { + void testRun() { URL networkUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("dvrp-grid"), "config.xml"); RunRandomDynAgentExample.run(networkUrl, "grid_network.xml", false); } diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/zone/SquareGridTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/zone/SquareGridTest.java index 697585b3ff6..dc09184888e 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/zone/SquareGridTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/zone/SquareGridTest.java @@ -25,7 +25,7 @@ import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Node; @@ -36,20 +36,20 @@ */ public class SquareGridTest { @Test - public void emptyNodes_fail() { + void emptyNodes_fail() { assertThatThrownBy(() -> new SquareGrid(List.of(), 100)).isExactlyInstanceOf(IllegalArgumentException.class) .hasMessage("Cannot create SquareGrid if no nodes"); } @Test - public void outsideBoundaries_withinEpsilon_success() { + void outsideBoundaries_withinEpsilon_success() { Node node_0_0 = node(0, 0); SquareGrid grid = new SquareGrid(List.of(node_0_0), 100); assertThatCode(() -> grid.getZone(new Coord(-EPSILON, EPSILON))).doesNotThrowAnyException(); } @Test - public void outsideBoundaries_outsideEpsilon_fail() { + void outsideBoundaries_outsideEpsilon_fail() { Node node_0_0 = node(0, 0); SquareGrid grid = new SquareGrid(List.of(node_0_0), 100); assertThatThrownBy(() -> grid.getZone(new Coord(-2 * EPSILON, 0))).isExactlyInstanceOf( @@ -57,7 +57,7 @@ public void outsideBoundaries_outsideEpsilon_fail() { } @Test - public void testLazyZoneCreation() { + void testLazyZoneCreation() { Node node_0_0 = node(0, 0); SquareGrid grid = new SquareGrid(List.of(node_0_0), 100); @@ -69,7 +69,7 @@ public void testLazyZoneCreation() { } @Test - public void testGrid() { + void testGrid() { Node node_0_0 = node(0, 0); Node node_150_150 = node(150, 150); SquareGrid grid = new SquareGrid(List.of(node_0_0, node_150_150), 100); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/zone/skims/FreeSpeedTravelTimeMatrixTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/zone/skims/FreeSpeedTravelTimeMatrixTest.java index e5522c47942..c5743ffaafb 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/zone/skims/FreeSpeedTravelTimeMatrixTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/zone/skims/FreeSpeedTravelTimeMatrixTest.java @@ -22,7 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Network; @@ -47,7 +47,7 @@ public FreeSpeedTravelTimeMatrixTest() { } @Test - public void matrix() { + void matrix() { DvrpTravelTimeMatrixParams params = new DvrpTravelTimeMatrixParams(); params.cellSize = 100; params.maxNeighborDistance = 0; @@ -67,7 +67,7 @@ public void matrix() { } @Test - public void sparseMatrix() { + void sparseMatrix() { DvrpTravelTimeMatrixParams params = new DvrpTravelTimeMatrixParams(); params.cellSize = 100; params.maxNeighborDistance = 9999; diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/zone/skims/MatrixTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/zone/skims/MatrixTest.java index 18f59308d00..02e6f9fc5dd 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/zone/skims/MatrixTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/zone/skims/MatrixTest.java @@ -26,7 +26,7 @@ import java.util.NoSuchElementException; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.zone.Zone; @@ -46,7 +46,7 @@ public class MatrixTest { private final static int MAX_ALLOWED_VALUE = (1 << 16) - 2; @Test - public void get_unsetValue() { + void get_unsetValue() { for (Zone from : zones) { for (Zone to : zones) { assertThatThrownBy(() -> matrix.get(from, to)).isExactlyInstanceOf(NoSuchElementException.class) @@ -56,7 +56,7 @@ public void get_unsetValue() { } @Test - public void get_validValue() { + void get_validValue() { matrix.set(zoneA, zoneB, 0); assertThat(matrix.get(zoneA, zoneB)).isEqualTo(0); @@ -65,7 +65,7 @@ public void get_validValue() { } @Test - public void set_invalidValue() { + void set_invalidValue() { assertThatThrownBy(() -> matrix.set(zoneA, zoneB, Double.POSITIVE_INFINITY)).isExactlyInstanceOf( IllegalArgumentException.class); assertThatThrownBy(() -> matrix.set(zoneA, zoneC, -1)).isExactlyInstanceOf(IllegalArgumentException.class); @@ -74,13 +74,13 @@ public void set_invalidValue() { } @Test - public void get_unknownZone() { + void get_unknownZone() { assertThatThrownBy(() -> matrix.get(zoneA, unknownZone)).isExactlyInstanceOf(IllegalArgumentException.class); assertThatThrownBy(() -> matrix.get(unknownZone, zoneC)).isExactlyInstanceOf(IllegalArgumentException.class); } @Test - public void set_unknownZone() { + void set_unknownZone() { assertThatThrownBy(() -> matrix.set(zoneA, unknownZone, 1)).isExactlyInstanceOf(IllegalArgumentException.class); assertThatThrownBy(() -> matrix.set(unknownZone, zoneC, 1)).isExactlyInstanceOf(IllegalArgumentException.class); } diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/zone/skims/SparseMatrixTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/zone/skims/SparseMatrixTest.java index 808730fea7c..a277900e956 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/zone/skims/SparseMatrixTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/zone/skims/SparseMatrixTest.java @@ -24,8 +24,7 @@ import static org.matsim.contrib.zone.skims.SparseMatrix.SparseRow; import java.util.List; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Node; import org.matsim.contrib.zone.skims.SparseMatrix.NodeAndTime; @@ -44,7 +43,7 @@ public class SparseMatrixTest { private final List allNodes = List.of(nodeA, nodeB, nodeC); @Test - public void emptyMatrix() { + void emptyMatrix() { var matrix = new SparseMatrix(); for (Node from : allNodes) { for (Node to : allNodes) { @@ -54,7 +53,7 @@ public void emptyMatrix() { } @Test - public void triangularMatrix() { + void triangularMatrix() { var matrix = new SparseMatrix(); //A -> A, B, C matrix.setRow(nodeA, @@ -76,7 +75,7 @@ public void triangularMatrix() { } @Test - public void nodeAndTimeOrderNotImportant() { + void nodeAndTimeOrderNotImportant() { //A -> A, B, C var nodeAndTimes = List.of(nodeAndTime(nodeA, 0), nodeAndTime(nodeB, 1), nodeAndTime(nodeC, 2)); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/zone/skims/TravelTimeMatricesTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/zone/skims/TravelTimeMatricesTest.java index d60f34f7fa2..02d7b7bd241 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/zone/skims/TravelTimeMatricesTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/zone/skims/TravelTimeMatricesTest.java @@ -24,7 +24,7 @@ import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Network; @@ -39,7 +39,7 @@ */ public class TravelTimeMatricesTest { @Test - public void travelTimeMatrix() { + void travelTimeMatrix() { Network network = NetworkUtils.createNetwork(); Node nodeA = NetworkUtils.createAndAddNode(network, Id.createNodeId("A"), new Coord(0, 0)); Node nodeB = NetworkUtils.createAndAddNode(network, Id.createNodeId("B"), new Coord(150, 150)); @@ -58,7 +58,7 @@ public void travelTimeMatrix() { } @Test - public void travelTimeSparseMatrix_maxDistance() { + void travelTimeSparseMatrix_maxDistance() { Network network = NetworkUtils.createNetwork(); Node nodeA = NetworkUtils.createAndAddNode(network, Id.createNodeId("A"), new Coord(0, 0)); Node nodeB = NetworkUtils.createAndAddNode(network, Id.createNodeId("B"), new Coord(150, 150)); @@ -85,7 +85,7 @@ public void travelTimeSparseMatrix_maxDistance() { } @Test - public void travelTimeSparseMatrix_maxTravelTime() { + void travelTimeSparseMatrix_maxTravelTime() { Network network = NetworkUtils.createNetwork(); Node nodeA = NetworkUtils.createAndAddNode(network, Id.createNodeId("A"), new Coord(0, 0)); Node nodeB = NetworkUtils.createAndAddNode(network, Id.createNodeId("B"), new Coord(150, 150)); diff --git a/contribs/dvrp/src/test/java/org/matsim/core/router/speedy/SpeedyMultiSourceALTBackwardTest.java b/contribs/dvrp/src/test/java/org/matsim/core/router/speedy/SpeedyMultiSourceALTBackwardTest.java index 7377d2c7ba0..828831db27b 100644 --- a/contribs/dvrp/src/test/java/org/matsim/core/router/speedy/SpeedyMultiSourceALTBackwardTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/core/router/speedy/SpeedyMultiSourceALTBackwardTest.java @@ -24,7 +24,7 @@ import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -80,7 +80,7 @@ public class SpeedyMultiSourceALTBackwardTest { travelDisutility); @Test - public void testOneSource_backward() { + void testOneSource_backward() { var startNode = new StartNode(nodeB, 9999, 7777); var path = multiSourceALT.calcLeastCostPath(List.of(startNode), nodeA, null, null, true); assertThat(path.nodes).containsExactly(nodeA, nodeE, nodeD, nodeB); @@ -90,7 +90,7 @@ public void testOneSource_backward() { } @Test - public void testManySources_backward_sameStartCost() { + void testManySources_backward_sameStartCost() { var startNodeB = new StartNode(nodeB, 9999, 7777); var startNodeC = new StartNode(nodeC, 9999, 7777); var path = multiSourceALT.calcLeastCostPath(List.of(startNodeB, startNodeC), nodeA, null, null, true); @@ -101,7 +101,7 @@ public void testManySources_backward_sameStartCost() { } @Test - public void testManySources_backward_selectFartherNodeWithLowerCost() { + void testManySources_backward_selectFartherNodeWithLowerCost() { var startNodeB = new StartNode(nodeB, 100, 7777); var startNodeC = new StartNode(nodeC, 111, 1111); var path = multiSourceALT.calcLeastCostPath(List.of(startNodeB, startNodeC), nodeA, null, null, true); @@ -112,7 +112,7 @@ public void testManySources_backward_selectFartherNodeWithLowerCost() { } @Test - public void testManySources_backward_selectNearestNodeWithHigherCost() { + void testManySources_backward_selectNearestNodeWithHigherCost() { var startNodeB = new StartNode(nodeB, 100, 7777); var startNodeC = new StartNode(nodeC, 109, 1111); var path = multiSourceALT.calcLeastCostPath(List.of(startNodeB, startNodeC), nodeA, null, null, true); diff --git a/contribs/dvrp/src/test/java/org/matsim/core/router/speedy/SpeedyMultiSourceALTForwardTest.java b/contribs/dvrp/src/test/java/org/matsim/core/router/speedy/SpeedyMultiSourceALTForwardTest.java index 35158e0b0c1..45287f7b776 100644 --- a/contribs/dvrp/src/test/java/org/matsim/core/router/speedy/SpeedyMultiSourceALTForwardTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/core/router/speedy/SpeedyMultiSourceALTForwardTest.java @@ -24,7 +24,7 @@ import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -78,7 +78,7 @@ public class SpeedyMultiSourceALTForwardTest { travelDisutility); @Test - public void testOneSource_forward() { + void testOneSource_forward() { var startNode = new StartNode(nodeB, 9999, 7777); var path = multiSourceALT.calcLeastCostPath(List.of(startNode), nodeA, null, null, false); assertThat(path.nodes).containsExactly(nodeB, nodeD, nodeE, nodeA); @@ -88,7 +88,7 @@ public void testOneSource_forward() { } @Test - public void testManySources_forward_sameStartCost() { + void testManySources_forward_sameStartCost() { var startNodeB = new StartNode(nodeB, 9999, 7777); var startNodeC = new StartNode(nodeC, 9999, 7777); var path = multiSourceALT.calcLeastCostPath(List.of(startNodeB, startNodeC), nodeA, null, null, false); @@ -99,7 +99,7 @@ public void testManySources_forward_sameStartCost() { } @Test - public void testManySources_forward_selectFartherNodeWithLowerCost() { + void testManySources_forward_selectFartherNodeWithLowerCost() { var startNodeB = new StartNode(nodeB, 100, 7777); var startNodeC = new StartNode(nodeC, 111, 1111); var path = multiSourceALT.calcLeastCostPath(List.of(startNodeB, startNodeC), nodeA, null, null, false); @@ -110,7 +110,7 @@ public void testManySources_forward_selectFartherNodeWithLowerCost() { } @Test - public void testManySources_forward_selectNearestNodeWithHigherCost() { + void testManySources_forward_selectNearestNodeWithHigherCost() { var startNodeB = new StartNode(nodeB, 100, 7777); var startNodeC = new StartNode(nodeC, 109, 1111); var path = multiSourceALT.calcLeastCostPath(List.of(startNodeB, startNodeC), nodeA, null, null, false); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/EmissionModuleTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/EmissionModuleTest.java index 6af6c9b7abe..ea2bb982d8e 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/EmissionModuleTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/EmissionModuleTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.emissions; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; import org.matsim.contrib.emissions.utils.TestUtils; @@ -16,6 +16,7 @@ import org.matsim.testcases.MatsimTestUtils; import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Most of the other test implicitly test the EmissionModule as well. Still, I guess it makes sense to have this here @@ -25,42 +26,44 @@ public class EmissionModuleTest { @RegisterExtension public MatsimTestUtils testUtils = new MatsimTestUtils(); - @Test(expected = RuntimeException.class) - public void testWithIncorrectNetwork() { + @Test + void testWithIncorrectNetwork() { + assertThrows(RuntimeException.class, () -> { - var scenarioURL = ExamplesUtils.getTestScenarioURL("emissions-sampleScenario"); + var scenarioURL = ExamplesUtils.getTestScenarioURL("emissions-sampleScenario"); - var emissionConfig = new EmissionsConfigGroup(); - emissionConfig.setHbefaTableConsistencyCheckingLevel(EmissionsConfigGroup.HbefaTableConsistencyCheckingLevel.none); - emissionConfig.setAverageColdEmissionFactorsFile(IOUtils.extendUrl(scenarioURL, "sample_41_EFA_ColdStart_SubSegm_2020detailed.csv").toString()); - emissionConfig.setAverageWarmEmissionFactorsFile(IOUtils.extendUrl(scenarioURL, "sample_41_EFA_HOT_vehcat_2020average.csv").toString()); - emissionConfig.setDetailedVsAverageLookupBehavior(EmissionsConfigGroup.DetailedVsAverageLookupBehavior.directlyTryAverageTable); + var emissionConfig = new EmissionsConfigGroup(); + emissionConfig.setHbefaTableConsistencyCheckingLevel(EmissionsConfigGroup.HbefaTableConsistencyCheckingLevel.none); + emissionConfig.setAverageColdEmissionFactorsFile(IOUtils.extendUrl(scenarioURL, "sample_41_EFA_ColdStart_SubSegm_2020detailed.csv").toString()); + emissionConfig.setAverageWarmEmissionFactorsFile(IOUtils.extendUrl(scenarioURL, "sample_41_EFA_HOT_vehcat_2020average.csv").toString()); + emissionConfig.setDetailedVsAverageLookupBehavior(EmissionsConfigGroup.DetailedVsAverageLookupBehavior.directlyTryAverageTable); - var config = ConfigUtils.createConfig(emissionConfig); + var config = ConfigUtils.createConfig(emissionConfig); - // create a scenario with a random network where every link has a hbefa road type except one link. - var scenario = ScenarioUtils.createMutableScenario(config); - var network = TestUtils.createRandomNetwork(1000, 10000, 10000); - new VspHbefaRoadTypeMapping().addHbefaMappings(network); - network.getLinks().values().iterator().next().getAttributes().removeAttribute(EmissionUtils.HBEFA_ROAD_TYPE); - scenario.setNetwork(network); + // create a scenario with a random network where every link has a hbefa road type except one link. + var scenario = ScenarioUtils.createMutableScenario(config); + var network = TestUtils.createRandomNetwork(1000, 10000, 10000); + new VspHbefaRoadTypeMapping().addHbefaMappings(network); + network.getLinks().values().iterator().next().getAttributes().removeAttribute(EmissionUtils.HBEFA_ROAD_TYPE); + scenario.setNetwork(network); - var eventsManager = EventsUtils.createEventsManager(); + var eventsManager = EventsUtils.createEventsManager(); - var module = new AbstractModule() { - @Override - public void install() { - bind(Scenario.class).toInstance(scenario); - bind(EventsManager.class).toInstance(eventsManager); - bind(EmissionModule.class); - } - }; + var module = new AbstractModule() { + @Override + public void install() { + bind(Scenario.class).toInstance(scenario); + bind(EventsManager.class).toInstance(eventsManager); + bind(EmissionModule.class); + } + }; - com.google.inject.Injector injector = Injector.createInjector(config, module); - // this call should cause an exception when the consistency check in the constructor of the emission module fails - injector.getInstance(EmissionModule.class); + com.google.inject.Injector injector = Injector.createInjector(config, module); + // this call should cause an exception when the consistency check in the constructor of the emission module fails + injector.getInstance(EmissionModule.class); - fail("Was expecting exception"); - } + fail("Was expecting exception"); + }); + } } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/OsmHbefaMappingTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/OsmHbefaMappingTest.java index d0bf9433dfa..af88ae935a2 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/OsmHbefaMappingTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/OsmHbefaMappingTest.java @@ -1,17 +1,18 @@ package org.matsim.contrib.emissions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.core.network.NetworkUtils; import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertThrows; public class OsmHbefaMappingTest { - @Test - public void testRegularMapping() { + @Test + void testRegularMapping() { var mapping = OsmHbefaMapping.build(); var link = getTestLink("primary", 70 / 3.6); @@ -22,7 +23,7 @@ public void testRegularMapping() { } @Test - public void testMergedLinkTypeMapping() { + void testMergedLinkTypeMapping() { var mapping = OsmHbefaMapping.build(); var link = getTestLink("primary|railway.tram", 70 / 3.6); @@ -32,19 +33,21 @@ public void testMergedLinkTypeMapping() { assertEquals("URB/Trunk-City/70", hbefaType); } - @Test(expected = RuntimeException.class) - public void testUnknownType() { + @Test + void testUnknownType() { + assertThrows(RuntimeException.class, () -> { - var mapping = OsmHbefaMapping.build(); - var link = getTestLink("unknown-tag", 100 / 3.6); + var mapping = OsmHbefaMapping.build(); + var link = getTestLink("unknown-tag", 100 / 3.6); - mapping.determineHebfaType(link); + mapping.determineHebfaType(link); - fail("Expected Runtime Exception."); - } + fail("Expected Runtime Exception."); + }); + } - @Test - public void testFastMotorway() { + @Test + void testFastMotorway() { var mapping = OsmHbefaMapping.build(); var link = getTestLink("motorway", 100 / 3.6); @@ -55,7 +58,7 @@ public void testFastMotorway() { } @Test - public void testMotorwayWithNoExactSpeedTag() { + void testMotorwayWithNoExactSpeedTag() { var mapping = OsmHbefaMapping.build(); @@ -70,7 +73,7 @@ public void testMotorwayWithNoExactSpeedTag() { } @Test - public void testFastMotorwayLink() { + void testFastMotorwayLink() { var mapping = OsmHbefaMapping.build(); var link = getTestLink("motorway_link", 100 / 3.6); @@ -81,7 +84,7 @@ public void testFastMotorwayLink() { } @Test - public void testLivingStreet() { + void testLivingStreet() { var mapping = OsmHbefaMapping.build(); var link = getTestLink("living_street", 50 / 3.6); @@ -90,8 +93,8 @@ public void testLivingStreet() { assertEquals("URB/Access/50", hbefaType); } - @Test - public void testUnclassified() { + @Test + void testUnclassified() { var mapping = OsmHbefaMapping.build(); var link = getTestLink("unclassified", 50 / 3.6); @@ -101,8 +104,8 @@ public void testUnclassified() { assertEquals("URB/Access/50", hbefaType); } - @Test - public void testNoHighwayType() { + @Test + void testNoHighwayType() { var mapping = OsmHbefaMapping.build(); var link = getTestLink(" ", 60 / 3.6); @@ -112,8 +115,8 @@ public void testNoHighwayType() { assertEquals("URB/Local/60", hbefaType); } - @Test - public void testNoAllowedSpeedTag() { + @Test + void testNoAllowedSpeedTag() { var mapping = OsmHbefaMapping.build(); var link = getTestLink("residential", 40 / 3.6); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModule.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModule.java index 57c8636221a..5f39db1437a 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModule.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModule.java @@ -22,7 +22,7 @@ import org.junit.Assert; import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; @@ -104,7 +104,7 @@ public class TestColdEmissionAnalysisModule { * all of them should throw exceptions */ @Test - public void calculateColdEmissionsAndThrowEventTest_Exceptions() { + void calculateColdEmissionsAndThrowEventTest_Exceptions() { ColdEmissionAnalysisModule coldEmissionAnalysisModule = setUp(); List> testCasesExceptions = new ArrayList<>(); @@ -135,7 +135,7 @@ public void calculateColdEmissionsAndThrowEventTest_Exceptions() { } @Test - public void calculateColdEmissionsAndThrowEventTest_minimalVehicleInformation() { + void calculateColdEmissionsAndThrowEventTest_minimalVehicleInformation() { ColdEmissionAnalysisModule coldEmissionAnalysisModule = setUp(); excep = false; diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase1.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase1.java index fc4d54bb0cf..a5785997e66 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase1.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase1.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; @@ -101,7 +101,7 @@ public class TestColdEmissionAnalysisModuleCase1 { private static final double fakeFactor = -1.; @Test - public void calculateColdEmissionsAndThrowEventTest_completeData() { + void calculateColdEmissionsAndThrowEventTest_completeData() { ColdEmissionAnalysisModule coldEmissionAnalysisModule = setUp(); ArrayList testCase1 = new ArrayList<>(); // first case: complete data diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase2.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase2.java index feed9108fb3..d975c75f447 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase2.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase2.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; @@ -93,7 +93,7 @@ public class TestColdEmissionAnalysisModuleCase2 { private static final double fakeFactor = -1.; @Test - public void calculateColdEmissionsAndThrowEventTest_completeData() { + void calculateColdEmissionsAndThrowEventTest_completeData() { ColdEmissionAnalysisModule coldEmissionAnalysisModule = setUp(); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase3.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase3.java index 861850165d5..e925e1df1d6 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase3.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase3.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; @@ -94,7 +94,7 @@ public class TestColdEmissionAnalysisModuleCase3 { private static final double fakeFactor = -1.; @Test - public void calculateColdEmissionsAndThrowEventTest_completeData() { + void calculateColdEmissionsAndThrowEventTest_completeData() { ColdEmissionAnalysisModule coldEmissionAnalysisModule = setUp(); ArrayList testCase3 = new ArrayList<>(); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase4.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase4.java index 8664f465e36..06a4298fb58 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase4.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase4.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; @@ -97,9 +97,9 @@ public class TestColdEmissionAnalysisModuleCase4 { private static final double fakeFactor = -1.; - + @Test - public void calculateColdEmissionsAndThrowEventTest_completeData() { + void calculateColdEmissionsAndThrowEventTest_completeData() { /* * test cases with complete input data or input that should be assigned to average/default cases diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase6.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase6.java index 2901ffba8c9..735adde0f16 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase6.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase6.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; @@ -91,9 +91,9 @@ public class TestColdEmissionAnalysisModuleCase6 { private static final double heavyGoodsFactor = -1.; - + @Test - public void calculateColdEmissionsAndThrowEventTest_completeData() { + void calculateColdEmissionsAndThrowEventTest_completeData() { /* * six test cases with complete input data diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionsFallbackBehaviour.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionsFallbackBehaviour.java index 4022a553a46..6c81637cc12 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionsFallbackBehaviour.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionsFallbackBehaviour.java @@ -21,8 +21,10 @@ package org.matsim.contrib.emissions; +import static org.junit.jupiter.api.Assertions.assertThrows; + import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -80,7 +82,7 @@ public class TestColdEmissionsFallbackBehaviour { * -> should calculate value */ @Test - public void testColdDetailedValueOnlyDetailed() { + void testColdDetailedValueOnlyDetailed() { EmissionModule emissionModule = setUpScenario( DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort ); Map coldEmissions = emissionModule.getColdEmissionAnalysisModule() @@ -98,13 +100,15 @@ public void testColdDetailedValueOnlyDetailed() { * * -> should abort --> RuntimeException */ - @Test(expected=RuntimeException.class) - public void testCold_DetailedElseAbort_ShouldAbort1() { - EmissionModule emissionModule = setUpScenario( DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort ); - - emissionModule.getColdEmissionAnalysisModule() - .checkVehicleInfoAndCalculateWColdEmissions(vehicleFallbackToTechnologyAverage.getType(), - vehicleFallbackToTechnologyAverage.getId(), link.getId(), startTime, parkingDuration, distance); + @Test + void testCold_DetailedElseAbort_ShouldAbort1() { + assertThrows(RuntimeException.class, () -> { + EmissionModule emissionModule = setUpScenario(DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort); + + emissionModule.getColdEmissionAnalysisModule() + .checkVehicleInfoAndCalculateWColdEmissions(vehicleFallbackToTechnologyAverage.getType(), + vehicleFallbackToTechnologyAverage.getId(), link.getId(), startTime, parkingDuration, distance); + }); } /** @@ -115,13 +119,15 @@ public void testCold_DetailedElseAbort_ShouldAbort1() { * * -> should abort --> RuntimeException */ - @Test(expected=RuntimeException.class) - public void testCold_DetailedElseAbort_ShouldAbort2() { - EmissionModule emissionModule = setUpScenario( DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort ); - - emissionModule.getColdEmissionAnalysisModule() - .checkVehicleInfoAndCalculateWColdEmissions(vehicleFallbackToTechnologyAverage.getType(), - vehicleFallbackToAverageTable.getId(), link.getId(), startTime, parkingDuration, distance); + @Test + void testCold_DetailedElseAbort_ShouldAbort2() { + assertThrows(RuntimeException.class, () -> { + EmissionModule emissionModule = setUpScenario(DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort); + + emissionModule.getColdEmissionAnalysisModule() + .checkVehicleInfoAndCalculateWColdEmissions(vehicleFallbackToTechnologyAverage.getType(), + vehicleFallbackToAverageTable.getId(), link.getId(), startTime, parkingDuration, distance); + }); } @@ -134,7 +140,7 @@ public void testCold_DetailedElseAbort_ShouldAbort2() { * ---> should calculate value from detailed value */ @Test - public void testCold_DetailedThenTechnologyAverageElseAbort_FallbackNotNeeded() { + void testCold_DetailedThenTechnologyAverageElseAbort_FallbackNotNeeded() { EmissionModule emissionModule = setUpScenario( DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageElseAbort ); Map coldEmissions = emissionModule.getColdEmissionAnalysisModule() @@ -153,7 +159,7 @@ public void testCold_DetailedThenTechnologyAverageElseAbort_FallbackNotNeeded() * ---> should calculate value from technology average */ @Test - public void testCold_DetailedThenTechnologyAverageElseAbort_FallbackToTechnologyAverage() { + void testCold_DetailedThenTechnologyAverageElseAbort_FallbackToTechnologyAverage() { EmissionModule emissionModule = setUpScenario( DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageElseAbort ); Map coldEmissions = emissionModule.getColdEmissionAnalysisModule() @@ -172,13 +178,15 @@ public void testCold_DetailedThenTechnologyAverageElseAbort_FallbackToTechnology * * -> should abort --> RuntimeException */ - @Test(expected=RuntimeException.class) - public void testCold_DetailedThenTechnologyAverageElseAbort_ShouldAbort() { - EmissionModule emissionModule = setUpScenario( DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort ); - - emissionModule.getColdEmissionAnalysisModule() - .checkVehicleInfoAndCalculateWColdEmissions(vehicleFallbackToAverageTable.getType(), - vehicleFallbackToAverageTable.getId(), link.getId(), startTime, parkingDuration, distance); + @Test + void testCold_DetailedThenTechnologyAverageElseAbort_ShouldAbort() { + assertThrows(RuntimeException.class, () -> { + EmissionModule emissionModule = setUpScenario(DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort); + + emissionModule.getColdEmissionAnalysisModule() + .checkVehicleInfoAndCalculateWColdEmissions(vehicleFallbackToAverageTable.getType(), + vehicleFallbackToAverageTable.getId(), link.getId(), startTime, parkingDuration, distance); + }); } // --------- DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable ----------- @@ -190,7 +198,7 @@ public void testCold_DetailedThenTechnologyAverageElseAbort_ShouldAbort() { * ---> should calculate value from detailed value */ @Test - public void testCold_DetailedThenTechnologyAverageThenAverageTable_FallbackNotNeeded() { + void testCold_DetailedThenTechnologyAverageThenAverageTable_FallbackNotNeeded() { EmissionModule emissionModule = setUpScenario( DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable ); Map coldEmissions = emissionModule.getColdEmissionAnalysisModule() @@ -209,7 +217,7 @@ public void testCold_DetailedThenTechnologyAverageThenAverageTable_FallbackNotNe * ---> should calculate value from technology average */ @Test - public void testCold_DetailedThenTechnologyAverageThenAverageTable_FallbackToTechnology() { + void testCold_DetailedThenTechnologyAverageThenAverageTable_FallbackToTechnology() { EmissionModule emissionModule = setUpScenario( DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable ); Map coldEmissions = emissionModule.getColdEmissionAnalysisModule() @@ -229,7 +237,7 @@ public void testCold_DetailedThenTechnologyAverageThenAverageTable_FallbackToTec * ---> should calculate value from average table */ @Test - public void testCold_DetailedThenTechnologyAverageThenAverageTable_FallbackToAverageTable() { + void testCold_DetailedThenTechnologyAverageThenAverageTable_FallbackToAverageTable() { EmissionModule emissionModule = setUpScenario( DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable ); Map coldEmissions = emissionModule.getColdEmissionAnalysisModule() diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaColdEmissionFactorKey.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaColdEmissionFactorKey.java index 861d12b5b2b..e3bbaecef8f 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaColdEmissionFactorKey.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaColdEmissionFactorKey.java @@ -21,7 +21,7 @@ package org.matsim.contrib.emissions; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.junit.Assert.*; import static org.matsim.contrib.emissions.Pollutant.CO; @@ -61,7 +61,7 @@ private void setUp(){ @Test - public final void testEqualsForCompleteKeys() { + final void testEqualsForCompleteKeys() { setUp(); @@ -113,7 +113,7 @@ public final void testEqualsForCompleteKeys() { //exception: if the vehicleAttributes are set to 'average' by default @Test - public final void testEqualsForIncompleteKeys_vehicleCategory(){ + final void testEqualsForIncompleteKeys_vehicleCategory(){ setUp(); //normal HbefaColdEmissionFactorKey @@ -132,7 +132,7 @@ public final void testEqualsForIncompleteKeys_vehicleCategory(){ } @Test - public final void testEqualsForIncompleteKeys_pollutant(){ + final void testEqualsForIncompleteKeys_pollutant(){ // generate a complete HbefaColdEmissionFactorKey: 'normal' // and set some parameters @@ -151,7 +151,7 @@ public final void testEqualsForIncompleteKeys_pollutant(){ } @Test - public final void testEqualsForIncompleteKeys_parkingTime() { + final void testEqualsForIncompleteKeys_parkingTime() { // generate a complete HbefaColdEmissionFactorKey: 'normal' // and set some parameters @@ -170,7 +170,7 @@ public final void testEqualsForIncompleteKeys_parkingTime() { } @Test - public final void testEqualsForIncompleteKeys_distance() { + final void testEqualsForIncompleteKeys_distance() { // generate a complete HbefaColdEmissionFactorKey: 'normal' // and set some parameters @@ -189,7 +189,7 @@ public final void testEqualsForIncompleteKeys_distance() { } @Test - public final void testEqualsForIncompleteKeys_emptyKey() { + final void testEqualsForIncompleteKeys_emptyKey() { // generate a complete HbefaColdEmissionFactorKey: 'normal' // and set some parameters @@ -204,7 +204,7 @@ public final void testEqualsForIncompleteKeys_emptyKey() { } @Test - public final void testEqualsForIncompleteKeys_VehicleAttributes(){ + final void testEqualsForIncompleteKeys_VehicleAttributes(){ //if no vehicle attributes are set manually they are set to 'average' by default // thus, the equals method should not throw nullpointer exceptions but return false or respectively true diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaVehicleAttributes.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaVehicleAttributes.java index 1709424db79..49a3e04e8cd 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaVehicleAttributes.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaVehicleAttributes.java @@ -21,7 +21,7 @@ package org.matsim.contrib.emissions; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /* @@ -41,7 +41,7 @@ public class TestHbefaVehicleAttributes { private HbefaVehicleAttributes differentValues; @Test - public final void testEqualsForCompleteAttributes(){ + final void testEqualsForCompleteAttributes(){ //two equal objects - no default values normal = new HbefaVehicleAttributes(); @@ -60,7 +60,7 @@ public final void testEqualsForCompleteAttributes(){ } @Test - public final void testEqualsForCompleteAttributes_emConcept(){ + final void testEqualsForCompleteAttributes_emConcept(){ //two unequal but complete objects normal = new HbefaVehicleAttributes(); @@ -79,7 +79,7 @@ public final void testEqualsForCompleteAttributes_emConcept(){ } @Test - public final void testEqualsForCompleteAttributes_sizeClass(){ + final void testEqualsForCompleteAttributes_sizeClass(){ //two unequal but complete objects normal = new HbefaVehicleAttributes(); @@ -98,7 +98,7 @@ public final void testEqualsForCompleteAttributes_sizeClass(){ } @Test - public final void testEqualsForCompleteAttributes_technologies(){ + final void testEqualsForCompleteAttributes_technologies(){ //two unequal but complete objects normal = new HbefaVehicleAttributes(); @@ -121,7 +121,7 @@ public final void testEqualsForCompleteAttributes_technologies(){ // thus, the equals method should not throw nullpointer exceptions but return false or respectively true @Test - public final void testEqualsForIncompleteAttributes_emConcept(){ + final void testEqualsForIncompleteAttributes_emConcept(){ //generate a complete key and set its parameters normal = new HbefaVehicleAttributes(); setToNormal(normal); @@ -142,7 +142,7 @@ public final void testEqualsForIncompleteAttributes_emConcept(){ @Test - public final void testEqualsForIncompleteAttributes_technology() { + final void testEqualsForIncompleteAttributes_technology() { // generate a complete key and set its parameters normal = new HbefaVehicleAttributes(); @@ -166,7 +166,7 @@ public final void testEqualsForIncompleteAttributes_technology() { } @Test - public final void testEqualsForIncompleteAttributes_sizeClass(){ + final void testEqualsForIncompleteAttributes_sizeClass(){ //generate a complete key and set its parameters normal = new HbefaVehicleAttributes(); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaWarmEmissionFactorKey.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaWarmEmissionFactorKey.java index 74eb698f206..c8c60aeaee3 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaWarmEmissionFactorKey.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaWarmEmissionFactorKey.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.junit.Assert.assertFalse; import static org.matsim.contrib.emissions.Pollutant.CO; @@ -64,7 +64,7 @@ private void setUp(){ } @Test - public final void testEqualsForCompleteKeys(){ + final void testEqualsForCompleteKeys(){ // generate a complete HbefaWarmEmissionFactorKey: 'normal' // and set some parameters @@ -100,7 +100,7 @@ public final void testEqualsForCompleteKeys(){ assertFalse(message, different.equals(normal)); assertFalse(message, normal.equals(different)); } - + // the following tests each compare a incomplete key to a complete key // wanted result: // completeData.equals(partialData) -> return false @@ -108,7 +108,7 @@ public final void testEqualsForCompleteKeys(){ // exception: if the vehicleAttributes are set to 'average' by default @Test - public final void testEqualsForIncompleteKeys_vehicleCategory() { + final void testEqualsForIncompleteKeys_vehicleCategory() { // generate a complete HbefaWarmEmissionFactorKey: 'normal' // and set some parameters setUp(); @@ -128,9 +128,9 @@ public final void testEqualsForIncompleteKeys_vehicleCategory() { assertFalse(result); } - + @Test - public final void testEqualsForIncompleteKeys_pollutant() { + final void testEqualsForIncompleteKeys_pollutant() { // generate a complete HbefaWarmEmissionFactorKey: 'normal' // and set some parameters setUp(); @@ -145,9 +145,9 @@ public final void testEqualsForIncompleteKeys_pollutant() { var result = noPollutant.equals(normal); } - + @Test - public final void testEqualsForIncompleteKeys_roadCategory() { + final void testEqualsForIncompleteKeys_roadCategory() { // generate a complete HbefaWarmEmissionFactorKey: 'normal' // and set some parameters setUp(); @@ -172,9 +172,9 @@ public final void testEqualsForIncompleteKeys_roadCategory() { Assert.assertTrue(message2, equalErr); assertFalse(message, normal.equals(noRoadCat)); } - + @Test - public final void testEqualsForIncompleteKeys_trafficSituation() { + final void testEqualsForIncompleteKeys_trafficSituation() { // generate a complete HbefaWarmEmissionFactorKey: 'normal' // and set some parameters setUp(); @@ -191,9 +191,9 @@ public final void testEqualsForIncompleteKeys_trafficSituation() { assertFalse(result); } - + @Test - public final void testEqualsForIncompleteKeys_emptyKey() { + final void testEqualsForIncompleteKeys_emptyKey() { // generate a complete HbefaWarmEmissionFactorKey: 'normal' // and set some parameters setUp(); @@ -206,9 +206,9 @@ public final void testEqualsForIncompleteKeys_emptyKey() { assertFalse(result); } - + @Test - public final void testEqualsForIncompleteKeys_vehicleAttributes(){ + final void testEqualsForIncompleteKeys_vehicleAttributes(){ // if no vehicle attributes are set manually they are set to 'average' by default // thus, the equals method should not throw nullpointer exceptions but return false or respectively true diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java index 3e9d93e186a..03d6e88cbbf 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java @@ -1,8 +1,8 @@ package org.matsim.contrib.emissions; import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -58,9 +58,9 @@ public class TestPositionEmissionModule { @RegisterExtension public MatsimTestUtils testUtils = new MatsimTestUtils(); - @Test - @Ignore - public void simpleTest() { + @Test + @Ignore + void simpleTest() { var emissionConfig = new EmissionsConfigGroup(); emissionConfig.setHbefaVehicleDescriptionSource(EmissionsConfigGroup.HbefaVehicleDescriptionSource.fromVehicleTypeDescription); @@ -81,8 +81,8 @@ public void simpleTest() { controler.run(); } - @Test - public void compareToOtherModule_singleVehicleSingleLink() { + @Test + void compareToOtherModule_singleVehicleSingleLink() { var emissionConfig = new EmissionsConfigGroup(); emissionConfig.setHbefaVehicleDescriptionSource(EmissionsConfigGroup.HbefaVehicleDescriptionSource.fromVehicleTypeDescription); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModule.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModule.java index c65dd54fd27..fd437883c91 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModule.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModule.java @@ -21,7 +21,7 @@ package org.matsim.contrib.emissions; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.matsim.api.core.v01.Id; @@ -127,9 +127,8 @@ public TestWarmEmissionAnalysisModule( EmissionsConfigGroup.EmissionsComputation } - @Test - public void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent6(){ + void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent6(){ //-- set up tables, event handler, parameters, module setUp(); @@ -166,7 +165,7 @@ public void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionE } @Test - public void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions1(){ + void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions1(){ //-- set up tables, event handler, parameters, module setUp(); @@ -198,7 +197,7 @@ public void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionE } @Test - public void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions2(){ + void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions2(){ //-- set up tables, event handler, parameters, module setUp(); @@ -223,7 +222,7 @@ public void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionE } @Test - public void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions3(){ + void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions3(){ //-- set up tables, event handler, parameters, module setUp(); @@ -247,7 +246,7 @@ public void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionE } @Test - public void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions4(){ + void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions4(){ //-- set up tables, event handler, parameters, module setUp(); // vehicle information string is 'null' @@ -270,7 +269,7 @@ public void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionE } @Test - public void testCounters7(){ + void testCounters7(){ setUp(); emissionsModule.reset(); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase1.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase1.java index ae5a6ed5d28..ed4a1e7322a 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase1.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase1.java @@ -21,7 +21,7 @@ package org.matsim.contrib.emissions; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.matsim.api.core.v01.Id; @@ -133,12 +133,12 @@ private WarmEmissionAnalysisModule setUp() { return new WarmEmissionAnalysisModule( avgHbefaWarmTable, detailedHbefaWarmTable, hbefaRoadTrafficSpeeds, pollutants, emissionEventManager, ecg ); } - + //this test method creates a mock link and mock vehicle with a complete vehicleTypId --> detailed values are used //the CO2_TOTAL warm Emissions are compared to a given value --> computed by using detailed Petrol and traffic state freeflow //the "Sum" of all emissions is tested @Test - public void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent1(){ + void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent1(){ //-- set up tables, event handler, parameters, module WarmEmissionAnalysisModule warmEmissionAnalysisModule = setUp(); // case 1 - data in both tables -> use detailed @@ -160,15 +160,15 @@ public void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionE emissionEventManager.reset(); warmEmissions.clear(); } - - + + /* * this test method creates a mock link and mock vehicle (petrol technology) with a complete vehicleTypId --> detailed values are used * the counters for all possible combinations of avg, stop go and free flow speed are tested * for the cases: > s&g speed, use average table diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase5.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase5.java index 8196789c523..3fd040f0950 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase5.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase5.java @@ -21,7 +21,7 @@ package org.matsim.contrib.emissions; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.matsim.api.core.v01.Id; @@ -119,7 +119,7 @@ public TestWarmEmissionAnalysisModuleCase5( EmissionsConfigGroup.EmissionsComput * detailed values are used */ @Test - public void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent5(){ + void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent5(){ //-- set up tables, event handler, parameters, module WarmEmissionAnalysisModule emissionsModule = setUp(); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionsFallbackBehaviour.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionsFallbackBehaviour.java index 3b7ec8f09e8..ee7ccc6eeee 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionsFallbackBehaviour.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionsFallbackBehaviour.java @@ -21,8 +21,10 @@ package org.matsim.contrib.emissions; +import static org.junit.jupiter.api.Assertions.assertThrows; + import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -67,7 +69,7 @@ public class TestWarmEmissionsFallbackBehaviour { * -> should calculate value */ @Test - public void testWarmDetailedValueOnlyDetailed() { + void testWarmDetailedValueOnlyDetailed() { EmissionModule emissionModule = setUpScenario(EmissionsConfigGroup.DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort); double travelTimeOnLink = 21; //sec. approx freeSpeed of link12 is : (200 m) / (9.72.. m/s) approx 20.57 s @@ -85,12 +87,14 @@ public void testWarmDetailedValueOnlyDetailed() { * * -> should abort --> RuntimeException */ - @Test(expected=RuntimeException.class) - public void testWarm_DetailedElseAbort_ShouldAbort1() { - EmissionModule emissionModule = setUpScenario(EmissionsConfigGroup.DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort); + @Test + void testWarm_DetailedElseAbort_ShouldAbort1() { + assertThrows(RuntimeException.class, () -> { + EmissionModule emissionModule = setUpScenario(EmissionsConfigGroup.DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort); - double travelTimeOnLink = 21; //sec. approx freeSpeed of link12 is : (200 m) / (9.72.. m/s) approx 20.57 s - emissionModule.getWarmEmissionAnalysisModule().checkVehicleInfoAndCalculateWarmEmissions(vehicleFallbackToTechnologyAverage, link, travelTimeOnLink); + double travelTimeOnLink = 21; //sec. approx freeSpeed of link12 is : (200 m) / (9.72.. m/s) approx 20.57 s + emissionModule.getWarmEmissionAnalysisModule().checkVehicleInfoAndCalculateWarmEmissions(vehicleFallbackToTechnologyAverage, link, travelTimeOnLink); + }); } /** @@ -101,15 +105,17 @@ public void testWarm_DetailedElseAbort_ShouldAbort1() { * * -> should abort --> RuntimeException */ - @Test(expected=RuntimeException.class) - public void testWarm_DetailedElseAbort_ShouldAbort2() { - EmissionModule emissionModule = setUpScenario(EmissionsConfigGroup.DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort); + @Test + void testWarm_DetailedElseAbort_ShouldAbort2() { + assertThrows(RuntimeException.class, () -> { + EmissionModule emissionModule = setUpScenario(EmissionsConfigGroup.DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort); - double travelTimeOnLink = 21; //sec. approx freeSpeed of link12 is : (200 m) / (9.72.. m/s) approx 20.57 s - emissionModule.getWarmEmissionAnalysisModule().checkVehicleInfoAndCalculateWarmEmissions(vehicleFallbackToAverageTable, link, travelTimeOnLink); + double travelTimeOnLink = 21; //sec. approx freeSpeed of link12 is : (200 m) / (9.72.. m/s) approx 20.57 s + emissionModule.getWarmEmissionAnalysisModule().checkVehicleInfoAndCalculateWarmEmissions(vehicleFallbackToAverageTable, link, travelTimeOnLink); + }); } - + // --------- DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageElseAbort) ----------- /** * vehicles information is complete @@ -119,7 +125,7 @@ public void testWarm_DetailedElseAbort_ShouldAbort2() { * ---> should calculate value from detailed value */ @Test - public void testWarm_DetailedThenTechnologyAverageElseAbort_FallbackNotNeeded() { + void testWarm_DetailedThenTechnologyAverageElseAbort_FallbackNotNeeded() { EmissionModule emissionModule = setUpScenario(EmissionsConfigGroup.DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageElseAbort); double travelTimeOnLink = 21; //sec. approx freeSpeed of link12 is : (200 m) / (9.72.. m/s) approx 20.57 s @@ -138,7 +144,7 @@ public void testWarm_DetailedThenTechnologyAverageElseAbort_FallbackNotNeeded() * ---> should calculate value from technology average */ @Test - public void testWarm_DetailedThenTechnologyAverageElseAbort_FallbackToTechnologyAverage() { + void testWarm_DetailedThenTechnologyAverageElseAbort_FallbackToTechnologyAverage() { EmissionModule emissionModule = setUpScenario(EmissionsConfigGroup.DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageElseAbort); double travelTimeOnLink = 21; //sec. approx freeSpeed of link12 is : (200 m) / (9.72.. m/s) approx 20.57 s @@ -156,12 +162,14 @@ public void testWarm_DetailedThenTechnologyAverageElseAbort_FallbackToTechnology * * -> should abort --> RuntimeException */ - @Test(expected=RuntimeException.class) - public void testWarm_DetailedThenTechnologyAverageElseAbort_ShouldAbort() { - EmissionModule emissionModule = setUpScenario(EmissionsConfigGroup.DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort); + @Test + void testWarm_DetailedThenTechnologyAverageElseAbort_ShouldAbort() { + assertThrows(RuntimeException.class, () -> { + EmissionModule emissionModule = setUpScenario(EmissionsConfigGroup.DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort); - double travelTimeOnLink = 21; //sec. approx freeSpeed of link12 is : (200 m) / (9.72.. m/s) approx 20.57 s - emissionModule.getWarmEmissionAnalysisModule().checkVehicleInfoAndCalculateWarmEmissions(vehicleFallbackToAverageTable, link, travelTimeOnLink); + double travelTimeOnLink = 21; //sec. approx freeSpeed of link12 is : (200 m) / (9.72.. m/s) approx 20.57 s + emissionModule.getWarmEmissionAnalysisModule().checkVehicleInfoAndCalculateWarmEmissions(vehicleFallbackToAverageTable, link, travelTimeOnLink); + }); } // --------- DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable ----------- @@ -173,7 +181,7 @@ public void testWarm_DetailedThenTechnologyAverageElseAbort_ShouldAbort() { * ---> should calculate value from detailed value */ @Test - public void testWarm_DetailedThenTechnologyAverageThenAverageTable_FallbackNotNeeded() { + void testWarm_DetailedThenTechnologyAverageThenAverageTable_FallbackNotNeeded() { EmissionModule emissionModule = setUpScenario(EmissionsConfigGroup.DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable); double travelTimeOnLink = 21; //sec. approx freeSpeed of link12 is : (200 m) / (9.72.. m/s) approx 20.57 s @@ -192,7 +200,7 @@ public void testWarm_DetailedThenTechnologyAverageThenAverageTable_FallbackNotNe * ---> should calculate value from technology average */ @Test - public void testWarm_DetailedThenTechnologyAverageThenAverageTable_FallbackToTechnology() { + void testWarm_DetailedThenTechnologyAverageThenAverageTable_FallbackToTechnology() { EmissionModule emissionModule = setUpScenario(EmissionsConfigGroup.DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable); double travelTimeOnLink = 21; //sec. approx freeSpeed of link12 is : (200 m) / (9.72.. m/s) approx 20.57 s @@ -212,7 +220,7 @@ public void testWarm_DetailedThenTechnologyAverageThenAverageTable_FallbackToTec * ---> should calculate value from average table */ @Test - public void testWarm_DetailedThenTechnologyAverageThenAverageTable_FallbackToAverageTable() { + void testWarm_DetailedThenTechnologyAverageThenAverageTable_FallbackToAverageTable() { EmissionModule emissionModule = setUpScenario(EmissionsConfigGroup.DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable); double travelTimeOnLink = 21; //sec. approx freeSpeed of link12 is : (200 m) / (9.72.. m/s) approx 20.57 s diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/VspHbefaRoadTypeMappingTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/VspHbefaRoadTypeMappingTest.java index c46b4a65ac6..7caf57a3bc9 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/VspHbefaRoadTypeMappingTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/VspHbefaRoadTypeMappingTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.emissions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -10,8 +10,8 @@ public class VspHbefaRoadTypeMappingTest { - @Test - public void testSimpleMapping() { + @Test + void testSimpleMapping() { var mapper = new VspHbefaRoadTypeMapping(); var link = getTestLink("", 70 / 3.6); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionGridAnalyzerTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionGridAnalyzerTest.java index 7cf055ff33e..df4bd3474a3 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionGridAnalyzerTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionGridAnalyzerTest.java @@ -3,8 +3,8 @@ import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVPrinter; import org.apache.commons.csv.CSVRecord; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -33,6 +33,7 @@ import java.util.UUID; import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.matsim.contrib.emissions.Pollutant.*; public class EmissionGridAnalyzerTest { @@ -49,21 +50,23 @@ private Geometry createRect(double maxX, double maxY) { new Coordinate(0, 0)}); } - @Test(expected = IllegalArgumentException.class) - public void initialize_invalidGridSizeToSmoothingRadiusRatio_exception() { + @Test + void initialize_invalidGridSizeToSmoothingRadiusRatio_exception() { + assertThrows(IllegalArgumentException.class, () -> { - new EmissionGridAnalyzer.Builder() - .withSmoothingRadius(1) - .withGridSize(1000) - .withNetwork(NetworkUtils.createNetwork()) - .withTimeBinSize(1) - .build(); + new EmissionGridAnalyzer.Builder() + .withSmoothingRadius(1) + .withGridSize(1000) + .withNetwork(NetworkUtils.createNetwork()) + .withTimeBinSize(1) + .build(); - fail("invalid grid size to smoothing radius ratio should cause exception"); - } + fail("invalid grid size to smoothing radius ratio should cause exception"); + }); + } - @Test - public void process() { + @Test + void process() { final Pollutant pollutant = HC; final double pollutionPerEvent = 1; @@ -87,8 +90,8 @@ public void process() { }); } - @Test - public void process_singleLinkWithOneEvent() { + @Test + void process_singleLinkWithOneEvent() { final Pollutant pollutant = CO; final double pollutionPerEvent = 1000; @@ -126,8 +129,8 @@ public void process_singleLinkWithOneEvent() { bin.getValue().getCells().forEach(cell -> assertTrue(cell.getValue().get(pollutant) <= valueOfCellWithLink)); } - @Test - public void process_singleLinkWithTwoEvents() { + @Test + void process_singleLinkWithTwoEvents() { final Pollutant pollutant = CO; final double pollutionPerEvent = 1000; @@ -165,8 +168,8 @@ public void process_singleLinkWithTwoEvents() { bin.getValue().getCells().forEach(cell -> assertTrue(cell.getValue().get(pollutant) <= valueOfCellWithLink)); } - @Test - public void process_twoLinksWithOneEventEach() { + @Test + void process_twoLinksWithOneEventEach() { final Pollutant pollutant = CO; final double pollutionPerEvent = 1000; @@ -207,8 +210,8 @@ public void process_twoLinksWithOneEventEach() { bin.getValue().getCells().forEach(cell -> assertTrue(cell.getValue().get(pollutant) <= valueOfCellWithLink + 0.1)); } - @Test - public void process_twoLinksWithTwoEventsEach() { + @Test + void process_twoLinksWithTwoEventsEach() { final Pollutant pollutant = NOx; final double pollutionPerEvent = 1000; @@ -249,8 +252,8 @@ public void process_twoLinksWithTwoEventsEach() { bin.getValue().getCells().forEach(cell -> assertTrue(cell.getValue().get(pollutant) <= valueOfCellWithLink + 0.1)); } - @Test - public void process_withBoundaries() { + @Test + void process_withBoundaries() { final double pollutionPerEvent = 1; Path eventsFile = Paths.get(testUtils.getOutputDirectory()).resolve(UUID.randomUUID().toString() + ".xml"); @@ -274,8 +277,8 @@ public void process_withBoundaries() { assertEquals(25, bin.getValue().getCells().size()); } - @Test - public void processToJson() { + @Test + void processToJson() { final double pollutionPerEvent = 1; final int time = 1; @@ -295,8 +298,8 @@ public void processToJson() { assertNotNull(json); } - @Test - public void processToJsonFile() throws IOException { + @Test + void processToJsonFile() throws IOException { final double pollutionPerEvent = 1; final int time = 1; @@ -319,8 +322,8 @@ public void processToJsonFile() throws IOException { assertTrue(jsonFileData.length > 0); } - @Test - public void process_regression() throws IOException { + @Test + void process_regression() throws IOException { var scenarioUrl = ExamplesUtils.getTestScenarioURL( "emissions-sampleScenario" ); var configUrl = IOUtils.extendUrl( scenarioUrl, "config_empty.xml" ); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionsByPollutantTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionsByPollutantTest.java index f4a970526ad..2575ebf4470 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionsByPollutantTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionsByPollutantTest.java @@ -9,19 +9,19 @@ import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contrib.emissions.Pollutant; import org.matsim.contrib.emissions.utils.EmissionUtilsTest; public class EmissionsByPollutantTest { - // The EmissionsByPollutant potentially adds up the same emissions coming from cold and warm. Thus, this cannot be combined into the enum approach - // without some thinking. kai, jan'20 - // Quite possibly, should just combine them into an enum "pollutant"?! There is, anyways, the JM map of those emissions that are actually present in the - // input file. kai, jan'20 + // The EmissionsByPollutant potentially adds up the same emissions coming from cold and warm. Thus, this cannot be combined into the enum approach + // without some thinking. kai, jan'20 + // Quite possibly, should just combine them into an enum "pollutant"?! There is, anyways, the JM map of those emissions that are actually present in the + // input file. kai, jan'20 - @Test - public void initialize() { + @Test + void initialize() { Map emissions = EmissionUtilsTest.createEmissions(); @@ -38,8 +38,8 @@ public void initialize() { }); } - @Test - public void addEmission() { + @Test + void addEmission() { Map emissions = EmissionUtilsTest.createEmissions(); final double valueToAdd = 5; @@ -58,8 +58,8 @@ public void addEmission() { assertEquals(expectedValue, retrievedResult, 0); } - @Test - public void addEmission_PollutantNotPresentYet() { + @Test + void addEmission_PollutantNotPresentYet() { Map initialPollutants = new HashMap<>(); initialPollutants.put(CO, Math.random()); @@ -74,8 +74,8 @@ public void addEmission_PollutantNotPresentYet() { assertEquals(valueToAdd, retrievedResult, 0); } - @Test - public void addEmissions() { + @Test + void addEmissions() { Map emissions = EmissionUtilsTest.createEmissions(); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionsOnLinkEventHandlerTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionsOnLinkEventHandlerTest.java index 9013c08e763..cc7b9df638c 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionsOnLinkEventHandlerTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionsOnLinkEventHandlerTest.java @@ -10,7 +10,7 @@ import java.util.UUID; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.analysis.time.TimeBinMap; @@ -37,8 +37,8 @@ private static Collection createWarmEmissionEvents(Id l return result; } - @Test - public void handleWarmEmissionsEvent() { + @Test + void handleWarmEmissionsEvent() { Id linkId = Id.createLinkId(UUID.randomUUID().toString()); Id vehicleId = Id.createVehicleId(UUID.randomUUID().toString()); @@ -66,8 +66,8 @@ public void handleWarmEmissionsEvent() { emissions.forEach((key, value) -> assertEquals(value, link2pollutantsMap.get(linkId).get(key), 0.0001)); } - @Test - public void handleColdEmissionEvent() { + @Test + void handleColdEmissionEvent() { Id linkId = Id.createLinkId(UUID.randomUUID().toString()); Id vehicleId = Id.createVehicleId(UUID.randomUUID().toString()); @@ -89,8 +89,8 @@ public void handleColdEmissionEvent() { emissions.forEach((key, value) -> assertEquals(value, link2pollutantsMap.get(linkId).get(key), 0.0001)); } - @Test - public void handleMultipleEvents() { + @Test + void handleMultipleEvents() { final Id linkId = Id.createLinkId(UUID.randomUUID().toString()); final int numberOfEvents = 1000; @@ -121,8 +121,8 @@ public void handleMultipleEvents() { assertEquals(3 * numberOfEvents * emissionValue, value, 0.0001)); } - @Test - public void handleSingleLinkWithSingleEvent() { + @Test + void handleSingleLinkWithSingleEvent() { Id linkId = Id.createLinkId(UUID.randomUUID().toString()); Id vehicleId = Id.createVehicleId(UUID.randomUUID().toString()); @@ -144,8 +144,8 @@ public void handleSingleLinkWithSingleEvent() { link2pollutantsMap.get(linkId).forEach((pollutant, value) -> assertEquals(emissionValue, value, 0.0001)); } - @Test - public void handleSingleLinkWithMultipleEvents() { + @Test + void handleSingleLinkWithMultipleEvents() { Id linkId = Id.createLinkId(UUID.randomUUID().toString()); Id vehicleId = Id.createVehicleId(UUID.randomUUID().toString()); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/FastEmissionGridAnalyzerTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/FastEmissionGridAnalyzerTest.java index 25c0a8b4122..0ea0f7b3f9b 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/FastEmissionGridAnalyzerTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/FastEmissionGridAnalyzerTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.emissions.analysis; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.contrib.emissions.Pollutant; @@ -23,8 +23,8 @@ public class FastEmissionGridAnalyzerTest { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void rasterNetwork_singleLink() { + @Test + void rasterNetwork_singleLink() { final var cellSize = 10.; final var cellArea = cellSize * cellSize; @@ -50,8 +50,8 @@ public void rasterNetwork_singleLink() { raster.forEachIndex((xi, yi, value) -> assertEquals(emissionPerLink / expectedCellNumber / cellArea, value, 0.00000001)); } - @Test - public void rasterNetwork_singleLinkWithBackwardsOrientation() { + @Test + void rasterNetwork_singleLinkWithBackwardsOrientation() { final var cellSize = 10.; final var cellArea = cellSize * cellSize; @@ -77,8 +77,8 @@ public void rasterNetwork_singleLinkWithBackwardsOrientation() { raster.forEachIndex((xi, yi, value) -> assertEquals(emissionPerLink / expectedCellNumber / cellArea, value, 0.00000001)); } - @Test - public void rasterNetwork_twoLinks() { + @Test + void rasterNetwork_twoLinks() { final var cellSize = 10.; final var cellArea = cellSize * cellSize; @@ -121,8 +121,8 @@ public void rasterNetwork_twoLinks() { } - @Test - public void blur_rasterWithSingleValue() { + @Test + void blur_rasterWithSingleValue() { final var initialValue = 10.; final var EPSILON = 0.000000001; @@ -150,8 +150,8 @@ public void blur_rasterWithSingleValue() { }); } - @Test - public void processLinkEmissions_twoLinks() { + @Test + void processLinkEmissions_twoLinks() { var network = NetworkUtils.createNetwork(new NetworkConfigGroup()); var node1 = network.getFactory().createNode(Id.createNodeId("node1"), new Coord(0, 49)); @@ -182,8 +182,8 @@ public void processLinkEmissions_twoLinks() { }); } - @Test - public void processEventsFile() { + @Test + void processEventsFile() { final var networkUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "network.xml"); final var emissionEvents = Paths.get(utils.getOutputDirectory()).resolve("emission.events.xml.gz"); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RasterTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RasterTest.java index ee57b97cb2d..2bcc4d639db 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RasterTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RasterTest.java @@ -1,14 +1,14 @@ package org.matsim.contrib.emissions.analysis; -import org.junit.Test; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; + public class RasterTest { - @Test - public void test() { + @Test + void test() { var bounds = new Raster.Bounds(10, 10, 100, 100); var raster = new Raster(bounds, 10); @@ -38,8 +38,8 @@ public void test() { } } - @Test - public void testInsertion() { + @Test + void testInsertion() { var bounds = new Raster.Bounds(4, 5, 123, 244); var raster = new Raster(bounds, 10); @@ -50,8 +50,8 @@ public void testInsertion() { raster.forEachIndex((x, y, value) -> assertEquals(10, value, 0.000001)); } - @Test - public void testIterationByIndex() { + @Test + void testIterationByIndex() { var bounds = new Raster.Bounds(4, 5, 123, 244); var raster = new Raster(bounds, 10); @@ -68,8 +68,8 @@ public void testIterationByIndex() { }); } - @Test - public void testIterationByCoord() { + @Test + void testIterationByCoord() { var bounds = new Raster.Bounds(4, 5, 123, 244); var raster = new Raster(bounds, 10); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RawEmissionEventsReaderTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RawEmissionEventsReaderTest.java index 08678b9549f..307667309b6 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RawEmissionEventsReaderTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RawEmissionEventsReaderTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.emissions.analysis; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.emissions.Pollutant; import org.matsim.contrib.emissions.utils.TestUtils; @@ -19,8 +19,8 @@ public class RawEmissionEventsReaderTest { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void handleNonEventNode() { + @Test + void handleNonEventNode() { // read in an xml file which doesn't have events. It will parse the whole file but will not handle any of the // parsed nodes @@ -33,8 +33,8 @@ public void handleNonEventNode() { // this test passes if the in the callback 'fail()' is not reached. } - @Test - public void handleNonEmissionEvent() { + @Test + void handleNonEmissionEvent() { // read in events file wihtout emission events. Those events should be ignored var eventsUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "output_events.xml.gz"); @@ -46,8 +46,8 @@ public void handleNonEmissionEvent() { // this test passes if the in the callback 'fail()' is not reached. } - @Test - public void handleColdEmissionEvent() { + @Test + void handleColdEmissionEvent() { final double expectedValue = 10; final int expectedTime = 1; @@ -71,8 +71,8 @@ public void handleColdEmissionEvent() { assertEquals(expectedEventsCount, counter.get()); } - @Test - public void handleWarmEmissionEvent() { + @Test + void handleWarmEmissionEvent() { final double expectedValue = 10; final int expectedTime = 1; diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/TestColdEmissionEventImpl.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/TestColdEmissionEventImpl.java index 5be0e9e9ca6..c4dff777494 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/TestColdEmissionEventImpl.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/TestColdEmissionEventImpl.java @@ -22,7 +22,7 @@ package org.matsim.contrib.emissions.events; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.emissions.Pollutant; @@ -55,7 +55,7 @@ public class TestColdEmissionEventImpl { private final Set coldPollutants = new HashSet<>(Arrays.asList(CO, FC, HC, NMHC, NOx, NO2,PM)); @Test - public final void testGetAttributesForCompleteEmissionMaps(){ + final void testGetAttributesForCompleteEmissionMaps(){ //test normal functionality //create a normal event impl @@ -91,9 +91,9 @@ private void setColdEmissions( Map coldEmissionsMap ) { coldEmissionsMap.put(PM, pm); } - + @Test - public final void testGetAttributesForIncompleteMaps(){ + final void testGetAttributesForIncompleteMaps(){ //the getAttributesMethod should // - return null if the emission map is empty // - throw NullPointerExceptions if the emission values are not set diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/TestWarmEmissionEventImpl.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/TestWarmEmissionEventImpl.java index c1ca71ad628..b10f7129d27 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/TestWarmEmissionEventImpl.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/TestWarmEmissionEventImpl.java @@ -29,7 +29,7 @@ */ import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.emissions.Pollutant; @@ -59,7 +59,7 @@ public class TestWarmEmissionEventImpl { @Test - public final void testGetAttributesForCompleteEmissionMaps(){ + final void testGetAttributesForCompleteEmissionMaps(){ //test normal functionality //create a normal event impl @@ -103,7 +103,7 @@ public final void testGetAttributesForCompleteEmissionMaps(){ } @Test - public final void testGetAttributesForIncompleteMaps(){ + final void testGetAttributesForIncompleteMaps(){ //the getAttributesMethod should // - return null if the emission map is empty // - throw NullPointerExceptions if the emission values are not set diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/VehicleLeavesTrafficEventTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/VehicleLeavesTrafficEventTest.java index bc2a404634c..28c1b9ab2a6 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/VehicleLeavesTrafficEventTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/VehicleLeavesTrafficEventTest.java @@ -1,8 +1,8 @@ package org.matsim.contrib.emissions.events; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.emissions.EmissionModule; import org.matsim.contrib.emissions.VspHbefaRoadTypeMapping; @@ -38,8 +38,8 @@ public class VehicleLeavesTrafficEventTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public final void testRareEventsFromBerlinScenario (){ + @Test + final void testRareEventsFromBerlinScenario(){ final String emissionEventsFileName = "smallBerlinSample.emissions.events.offline.xml.gz"; final String resultingEvents = utils.getOutputDirectory() + emissionEventsFileName; diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExampleIT.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExampleIT.java index eb79ad597b5..ede97411a51 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExampleIT.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExampleIT.java @@ -19,8 +19,8 @@ package org.matsim.contrib.emissions.example; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.contrib.emissions.EmissionUtils; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup.HbefaVehicleDescriptionSource; @@ -42,7 +42,7 @@ public class RunAverageEmissionToolOfflineExampleIT{ @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public final void testAverage_vehTypeV1() { + final void testAverage_vehTypeV1() { RunAverageEmissionToolOfflineExample offlineExample = new RunAverageEmissionToolOfflineExample(); // Config config = offlineExample.prepareConfig("./scenarios/sampleScenario/testv2_Vehv1/config_average.xml"); @@ -63,7 +63,7 @@ public final void testAverage_vehTypeV1() { } @Test - public final void testAverage_vehTypeV2() { + final void testAverage_vehTypeV2() { RunAverageEmissionToolOfflineExample offlineExample = new RunAverageEmissionToolOfflineExample(); // Config config = offlineExample.prepareConfig("./scenarios/sampleScenario/testv2_Vehv2/config_average.xml"); @@ -90,7 +90,7 @@ public final void testAverage_vehTypeV2() { * where this is used, has no way to know which file format was originally read. See some discussion there. :-( */ @Test - public final void testAverage_vehTypeV2b() { + final void testAverage_vehTypeV2b() { RunAverageEmissionToolOfflineExample offlineExample = new RunAverageEmissionToolOfflineExample(); // Config config = offlineExample.prepareConfig("./scenarios/sampleScenario/testv2_Vehv2/config_average.xml"); @@ -112,7 +112,7 @@ public final void testAverage_vehTypeV2b() { } @Test - public final void testAverage_vehTypeV2_HBEFA4() { + final void testAverage_vehTypeV2_HBEFA4() { RunAverageEmissionToolOfflineExample offlineExample = new RunAverageEmissionToolOfflineExample(); // Config config = offlineExample.prepareConfig("./scenarios/sampleScenario/testv2_Vehv2/config_average.xml"); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExampleIT.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExampleIT.java index 4a3edaf60dd..26a96f651e4 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExampleIT.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExampleIT.java @@ -19,8 +19,8 @@ package org.matsim.contrib.emissions.example; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup.DetailedVsAverageLookupBehavior; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup.HbefaVehicleDescriptionSource; @@ -45,7 +45,7 @@ public class RunDetailedEmissionToolOfflineExampleIT { // Expecting RuntimeException, because requested values are only in average file. Without fallback it has to fail! // @Test(expected=RuntimeException.class) @Test - public final void testDetailed_vehTypeV1() { + final void testDetailed_vehTypeV1() { boolean gotAnException = false ; try { RunDetailedEmissionToolOfflineExample offlineExample = new RunDetailedEmissionToolOfflineExample(); @@ -70,7 +70,7 @@ public final void testDetailed_vehTypeV1() { // Expecting RuntimeException, because requested values are only in average file. Without fallback it has to fail! // @Test(expected=RuntimeException.class) @Test - public final void testDetailed_vehTypeV2() { + final void testDetailed_vehTypeV2() { boolean gotAnException = false ; try { RunDetailedEmissionToolOfflineExample offlineExample = new RunDetailedEmissionToolOfflineExample(); @@ -94,7 +94,7 @@ public final void testDetailed_vehTypeV2() { // Expecting RuntimeException, because requested values are only in average file. Without fallback it has to fail! // @Test(expected=RuntimeException.class) @Test - public final void testDetailed_vehTypeV2_HBEFA4() { + final void testDetailed_vehTypeV2_HBEFA4() { boolean gotAnException = false ; try { RunDetailedEmissionToolOfflineExample offlineExample = new RunDetailedEmissionToolOfflineExample(); @@ -126,7 +126,7 @@ public final void testDetailed_vehTypeV2_HBEFA4() { * */ @Test - public final void testDetailed_vehTypeV1_FallbackToAverage() { + final void testDetailed_vehTypeV1_FallbackToAverage() { RunDetailedEmissionToolOfflineExample offlineExample = new RunDetailedEmissionToolOfflineExample(); // Config config = offlineExample.prepareConfig("./scenarios/sampleScenario/testv2_Vehv1/config_detailed.xml"); @@ -147,7 +147,7 @@ public final void testDetailed_vehTypeV1_FallbackToAverage() { } @Test - public final void testDetailed_vehTypeV2_FallbackToAverage() { + final void testDetailed_vehTypeV2_FallbackToAverage() { RunDetailedEmissionToolOfflineExample offlineExample = new RunDetailedEmissionToolOfflineExample(); // Config config = offlineExample.prepareConfig("./scenarios/sampleScenario/testv2_Vehv2/config_detailed.xml"); @@ -167,7 +167,7 @@ public final void testDetailed_vehTypeV2_FallbackToAverage() { } @Test - public final void testDetailed_vehTypeV2_HBEFA4_FallbackToAverage() { + final void testDetailed_vehTypeV2_HBEFA4_FallbackToAverage() { RunDetailedEmissionToolOfflineExample offlineExample = new RunDetailedEmissionToolOfflineExample(); // Config config = offlineExample.prepareConfig("./scenarios/sampleScenario/testv2_Vehv2/config_detailed.xml"); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1.java index 375cae0855b..ad7e875891a 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1.java @@ -20,8 +20,8 @@ import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; import org.matsim.core.config.Config; @@ -50,7 +50,7 @@ public class RunDetailedEmissionToolOnlineExampleIT_vehTypeV1 { // @Test(expected=RuntimeException.class) // Expecting RuntimeException, because requested values are only in average file. Without fallback it has to fail! @Ignore //Ignore this test, because the thrown exception during events handling does not always leads to an abort of the Simulation ->> Maybe a problem in @link{ParallelEventsManagerImpl.class}? @Test - public final void testDetailed_vehTypeV1() { + final void testDetailed_vehTypeV1() { boolean gotAnException = false ; try { RunDetailedEmissionToolOnlineExample onlineExample = new RunDetailedEmissionToolOnlineExample(); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage.java index fc23f2cefbd..2ba07507548 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage.java @@ -18,8 +18,8 @@ * *********************************************************************** */ package org.matsim.contrib.emissions.example; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; import org.matsim.core.config.Config; @@ -48,7 +48,7 @@ public class RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage { * * */ @Test - public final void testDetailed_vehTypeV1_FallbackToAverage() { + final void testDetailed_vehTypeV1_FallbackToAverage() { try { // Config config = onlineExample.prepareConfig( new String[]{"./scenarios/sampleScenario/testv2_Vehv1/config_detailed.xml"} ) ; var scenarioUrl = ExamplesUtils.getTestScenarioURL( "emissions-sampleScenario/testv2_Vehv1" ); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java index 213c933c504..8ebcee11237 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java @@ -20,8 +20,8 @@ import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; import org.matsim.core.config.Config; @@ -44,7 +44,7 @@ public class RunDetailedEmissionToolOnlineExampleIT_vehTypeV2 { // @Test(expected=RuntimeException.class) // Expecting RuntimeException, because requested values are only in average file. Without fallback it has to fail! @Ignore //Ignore this test, because the thrown exception during events handling does not always leads to an abort of the Simulation ->> Maybe a problem in @link{ParallelEventsManagerImpl.class}? @Test - public final void testDetailed_vehTypeV2() { + final void testDetailed_vehTypeV2() { boolean gotAnException = false ; try { RunDetailedEmissionToolOnlineExample onlineExample = new RunDetailedEmissionToolOnlineExample(); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage.java index 1c387a47d73..346f29f433c 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage.java @@ -18,8 +18,8 @@ * *********************************************************************** */ package org.matsim.contrib.emissions.example; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup.DetailedVsAverageLookupBehavior; @@ -42,7 +42,7 @@ public class RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage { * Test method for {@link RunDetailedEmissionToolOnlineExample#main(String[])}. */ @Test - public final void testDetailed_vehTypeV2_FallbackToAverage() { + final void testDetailed_vehTypeV2_FallbackToAverage() { try { // RunDetailedEmissionToolOnlineExample onlineExample = new RunDetailedEmissionToolOnlineExample(); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/utils/EmissionUtilsTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/utils/EmissionUtilsTest.java index 77aca8075f1..6fdf91cdb46 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/utils/EmissionUtilsTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/utils/EmissionUtilsTest.java @@ -21,7 +21,7 @@ package org.matsim.contrib.emissions.utils; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -43,6 +43,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.matsim.contrib.emissions.Pollutant.*; @@ -80,7 +81,7 @@ public static Map createUntypedEmissions() { } @Test - public final void testSumUpEmissions() { + final void testSumUpEmissions() { // test the method EmissionUtils.sumUpEmissions for a complete list of pollutants // missing data is not tested here @@ -135,7 +136,7 @@ public final void testSumUpEmissions() { } @Test - public final void testSumUpEmissionsPerId() { + final void testSumUpEmissionsPerId() { Map, Map> warmEmissions = new HashMap<>(); Map, Map> coldEmissions = new HashMap<>(); @@ -256,17 +257,20 @@ public final void testSumUpEmissionsPerId() { } - @Test(expected = NullPointerException.class) - public final void testGetTotalEmissions_nullInput() { + @Test + final void testGetTotalEmissions_nullInput() { + assertThrows(NullPointerException.class, () -> { + + @SuppressWarnings("ConstantConditions") + SortedMap totalEmissions = EmissionUtils.getTotalEmissions(null); + Assert.fail("Expected NullPointerException, got none."); - @SuppressWarnings("ConstantConditions") - SortedMap totalEmissions = EmissionUtils.getTotalEmissions(null); - Assert.fail("Expected NullPointerException, got none."); + }); } @Test - public final void testGetTotalEmissions_emptyList() { + final void testGetTotalEmissions_emptyList() { //test an empty list as input SortedMap totalEmissions; @@ -278,7 +282,7 @@ public final void testGetTotalEmissions_emptyList() { } @Test - public final void testGetTotalEmissions_completeData() { + final void testGetTotalEmissions_completeData() { //test getTotalEmissions for complete data Set pollsFromEU = new HashSet<>(Arrays.asList(CO, CO2_TOTAL, FC, HC, NMHC, NOx, NO2, PM, SO2)); @@ -356,9 +360,9 @@ public final void testGetTotalEmissions_completeData() { Assert.assertEquals("this list should be as long as number of pollutants", totalEmissions.keySet().size(), pollsFromEU.size()); } - + @Test - public final void testSetNonCalculatedEmissionsForPopulation_completeData(){ + final void testSetNonCalculatedEmissionsForPopulation_completeData(){ //test setNonCalculatedEmissionsForPopulation for three persons with complete lists of emissions //check values @@ -465,9 +469,9 @@ public final void testSetNonCalculatedEmissionsForPopulation_completeData(){ Assert.assertEquals("SO value for person 2 is not correct", sov2, finalMap.get(idp2).get( SO2 ), MatsimTestUtils.EPSILON ); } - + @Test - public final void testSetNonCalculatedEmissionsForPopulation_missingMap() { + final void testSetNonCalculatedEmissionsForPopulation_missingMap() { setUpForNonCaculatedEmissions(); @@ -512,7 +516,7 @@ private void setUpForNonCaculatedEmissions() { } @Test - public final void testSetNonCalculatedEmissionsForPopulation_missingPerson() { + final void testSetNonCalculatedEmissionsForPopulation_missingPerson() { setUpForNonCaculatedEmissions(); @@ -544,9 +548,9 @@ public final void testSetNonCalculatedEmissionsForPopulation_missingPerson() { Assert.assertEquals(message, pop.getPersons().keySet().size(), finalMap.keySet().size()); } - + @Test - public final void testSetNonCalculatedEmissionsForPopulation_nullEmissions(){ + final void testSetNonCalculatedEmissionsForPopulation_nullEmissions(){ //test setNonCalculatedEmissionsForPopulation with 'null' // throw nullpointer exception setUpForNonCaculatedEmissions(); @@ -566,9 +570,9 @@ public final void testSetNonCalculatedEmissionsForPopulation_nullEmissions(){ } Assert.assertTrue(nullPointerEx); } - + @Test - public final void testSetNonCalculatedEmissionsForPopulation_emptyPopulation(){ + final void testSetNonCalculatedEmissionsForPopulation_emptyPopulation(){ // test setNonCalculatedEmissionsForPopulation with an empty population // empty list should be returned setUpForNonCaculatedEmissions(); @@ -599,7 +603,7 @@ public final void testSetNonCalculatedEmissionsForPopulation_emptyPopulation(){ } @Test - public final void testSetNonCalculatedEmissionsForPopulation_emptyEmissionMap() { + final void testSetNonCalculatedEmissionsForPopulation_emptyEmissionMap() { //test setNonCalculatedEmissionsForPopulation with an empty emission map setUpForNonCaculatedEmissions(); @@ -643,7 +647,7 @@ public final void testSetNonCalculatedEmissionsForPopulation_emptyEmissionMap() } @Test - public final void testSetNonCalculatedEmissionsForNetwork() { + final void testSetNonCalculatedEmissionsForNetwork() { //test setNonCalculatedEmissionsForNetwork // network consists of four nodes 1,2,3,4 // and six links 12, 13, 14, 23, 24, 34 diff --git a/contribs/ev/src/test/java/org/matsim/contrib/ev/charging/FastThenSlowChargingTest.java b/contribs/ev/src/test/java/org/matsim/contrib/ev/charging/FastThenSlowChargingTest.java index 08eed4fe613..62e2013f14c 100644 --- a/contribs/ev/src/test/java/org/matsim/contrib/ev/charging/FastThenSlowChargingTest.java +++ b/contribs/ev/src/test/java/org/matsim/contrib/ev/charging/FastThenSlowChargingTest.java @@ -22,7 +22,7 @@ import org.assertj.core.api.Assertions; import org.assertj.core.data.Percentage; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.ev.EvUnits; import org.matsim.contrib.ev.fleet.ElectricFleetUtils; @@ -41,7 +41,7 @@ public class FastThenSlowChargingTest { @Test - public void calcChargingPower() { + void calcChargingPower() { //fast charger (2 c) assertCalcChargingPower(100, 0, 200, 175); assertCalcChargingPower(100, 50, 200, 175); @@ -76,7 +76,7 @@ private void assertCalcChargingPower(double capacity_kWh, double charge_kWh, dou } @Test - public void calcChargingTime_singleSection() { + void calcChargingTime_singleSection() { //fast charger (2 c) assertCalcChargingTime(100, 0, 0, 200, 0); assertCalcChargingTime(100, 0, 17.5, 200, 360); @@ -106,7 +106,7 @@ public void calcChargingTime_singleSection() { } @Test - public void calcChargingTime_crossSection() { + void calcChargingTime_crossSection() { //fast charger (2 c) assertCalcChargingTime(100, 32.5, 17.5 + 12.5, 200, 2 * 360); assertCalcChargingTime(100, 62.5, 12.5 + 5, 200, 2 * 360); @@ -124,7 +124,7 @@ public void calcChargingTime_crossSection() { } @Test - public void calcChargingTime_exceptions() { + void calcChargingTime_exceptions() { Assertions.assertThatThrownBy(() -> assertCalcChargingTime(100, 0, -1, 200, 2 * 360)) .isExactlyInstanceOf(IllegalArgumentException.class) .hasMessageStartingWith("Energy is negative: "); @@ -168,7 +168,7 @@ record TestEvSpecification(Id getId, Vehicle getMatsimVehicle, String g } @Test - public void calcEnergyCharge() { + void calcEnergyCharge() { assertCalcEnergyCharge(100, 100, 200, 10, 0); assertCalcEnergyCharge(100, 76, 200, 10, 500000); assertCalcEnergyCharge(100, 51, 200, 10, 1250000); @@ -186,14 +186,14 @@ private void assertCalcEnergyCharge(double capacity_kWh, double charge_kWh, doub } @Test - public void calcEnergyCharged_exceptions() { + void calcEnergyCharged_exceptions() { Assertions.assertThatThrownBy(() -> assertCalcEnergyCharge(100, 100, 10, -1, 0)) .isExactlyInstanceOf(IllegalArgumentException.class) .hasMessageStartingWith("Charging period is negative: "); } @Test - public void calcEnergyChargeAndVerifyWithDuration() { + void calcEnergyChargeAndVerifyWithDuration() { assertEnergyAndDurationCalcCompliance(100, 76, 200, 100); assertEnergyAndDurationCalcCompliance(100, 51, 200, 100); assertEnergyAndDurationCalcCompliance(100, 50, 200, 100); diff --git a/contribs/ev/src/test/java/org/matsim/contrib/ev/charging/VariableSpeedChargingTest.java b/contribs/ev/src/test/java/org/matsim/contrib/ev/charging/VariableSpeedChargingTest.java index 1f0c78ffab9..4178854fa93 100644 --- a/contribs/ev/src/test/java/org/matsim/contrib/ev/charging/VariableSpeedChargingTest.java +++ b/contribs/ev/src/test/java/org/matsim/contrib/ev/charging/VariableSpeedChargingTest.java @@ -22,7 +22,7 @@ import org.assertj.core.api.Assertions; import org.assertj.core.data.Percentage; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.ev.EvUnits; import org.matsim.contrib.ev.fleet.ElectricFleetUtils; @@ -40,7 +40,7 @@ public class VariableSpeedChargingTest { @Test - public void testCalcEnergyCharge() { + void testCalcEnergyCharge() { //fast charger (2 c) assertCalcChargingPower(100, 0, 200, 75); assertCalcChargingPower(100, 5, 200, 100); diff --git a/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleWithLTHConsumptionModelTest.java b/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleWithLTHConsumptionModelTest.java index 543e1a643da..0fe8353c9d8 100644 --- a/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleWithLTHConsumptionModelTest.java +++ b/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleWithLTHConsumptionModelTest.java @@ -3,8 +3,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; import org.matsim.core.events.EventsUtils; @@ -22,7 +22,8 @@ public class RunEvExampleWithLTHConsumptionModelTest{ @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; - @Test public void runTest(){ + @Test + void runTest(){ try { String [] args = { RunEvExampleWithLTHConsumptionModel.DEFAULT_CONFIG_FILE ,"--config:controler.outputDirectory", utils.getOutputDirectory() diff --git a/contribs/ev/src/test/java/org/matsim/contrib/ev/temperature/TemperatureChangeModuleIntegrationTest.java b/contribs/ev/src/test/java/org/matsim/contrib/ev/temperature/TemperatureChangeModuleIntegrationTest.java index a7c51e597b1..dbd13c7a8b6 100644 --- a/contribs/ev/src/test/java/org/matsim/contrib/ev/temperature/TemperatureChangeModuleIntegrationTest.java +++ b/contribs/ev/src/test/java/org/matsim/contrib/ev/temperature/TemperatureChangeModuleIntegrationTest.java @@ -22,8 +22,8 @@ import jakarta.inject.Inject; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.PersonDepartureEvent; @@ -45,7 +45,7 @@ public class TemperatureChangeModuleIntegrationTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testTemperatureChangeModule() { + void testTemperatureChangeModule() { Config config = ConfigUtils.loadConfig(utils.getClassInputDirectory() + "/config.xml", new TemperatureChangeConfigGroup()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java index 60c0c236e32..89a1108290d 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java @@ -21,8 +21,8 @@ package org.matsim.freight.carriers; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.Event; import org.matsim.api.core.v01.network.Link; @@ -73,7 +73,7 @@ public class CarrierEventsReadersTest { ); @Test - public void testWriteReadServiceBasedEvents() { + void testWriteReadServiceBasedEvents() { EventsManager eventsManager1 = EventsUtils.createEventsManager(); EventsManager eventsManager2 = EventsUtils.createEventsManager(); EventsCollector collector1 = new EventsCollector(); @@ -101,7 +101,7 @@ public void testWriteReadServiceBasedEvents() { @Test - public void testReadServiceBasedEvents() { + void testReadServiceBasedEvents() { EventsManager eventsManager = EventsUtils.createEventsManager(); TestEventHandlerTours eventHandlerTours = new TestEventHandlerTours(); @@ -119,7 +119,7 @@ public void testReadServiceBasedEvents() { } @Test - public void testWriteReadShipmentBasedEvents() { + void testWriteReadShipmentBasedEvents() { EventsManager eventsManager1 = EventsUtils.createEventsManager(); EventsManager eventsManager2 = EventsUtils.createEventsManager(); EventsCollector collector1 = new EventsCollector(); @@ -146,7 +146,7 @@ public void testWriteReadShipmentBasedEvents() { } @Test - public void testReadShipmentBasedEvents() { + void testReadShipmentBasedEvents() { EventsManager eventsManager = EventsUtils.createEventsManager(); TestEventHandlerTours eventHandlerTours = new TestEventHandlerTours(); @@ -169,7 +169,7 @@ public void testReadShipmentBasedEvents() { * This test is inspired by the DrtEventsReaderTest from michalm. */ @Test - public void testReader() { + void testReader() { var outputStream = new ByteArrayOutputStream(); EventWriterXML writer = new EventWriterXML(outputStream); carrierEvents.forEach(writer::handleEvent); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierModuleTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierModuleTest.java index 6971e244003..b9794b3aeed 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierModuleTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierModuleTest.java @@ -22,8 +22,8 @@ package org.matsim.freight.carriers; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -80,10 +80,10 @@ public void setUp(){ } + //using this constructor does not work at the moment, as the module would need to derive the carriers out of the scenario. + // to me, it is currently not clear how to do that, tschlenther oct 10 '19 @Test - //using this constructor does not work at the moment, as the module would need to derive the carriers out of the scenario. - // to me, it is currently not clear how to do that, tschlenther oct 10 '19 - public void test_ConstructorWOParameters(){ + void test_ConstructorWOParameters(){ // note setUp method! controler.addOverridingModule(new CarrierModule()); controler.addOverridingModule(new AbstractModule() { @@ -96,8 +96,8 @@ public void install() { controler.run(); } - @Test - public void test_ConstructorWithOneParameter(){ + @Test + void test_ConstructorWithOneParameter(){ // note setUp method! controler.addOverridingModule(new CarrierModule()); controler.addOverridingModule(new AbstractModule() { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanReaderV1Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanReaderV1Test.java index e99df84a363..9a8bfba14f9 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanReaderV1Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanReaderV1Test.java @@ -22,8 +22,8 @@ package org.matsim.freight.carriers; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.core.population.routes.NetworkRoute; import org.matsim.freight.carriers.*; @@ -42,7 +42,7 @@ public class CarrierPlanReaderV1Test { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testCarrierPlanReaderDoesSomething() { + void testCarrierPlanReaderDoesSomething() { CarrierVehicleTypes carrierVehicleTypes = new CarrierVehicleTypes(); new CarrierVehicleTypeReader( carrierVehicleTypes ).readFile( utils.getPackageInputDirectory() + "vehicleTypes_v2.xml" ); @@ -56,7 +56,7 @@ public void testCarrierPlanReaderDoesSomething() { } @Test - public void testReaderReadsCorrectly() { + void testReaderReadsCorrectly() { CarrierVehicleTypes carrierVehicleTypes = new CarrierVehicleTypes(); new CarrierVehicleTypeReader( carrierVehicleTypes ).readFile( utils.getPackageInputDirectory() + "vehicleTypes_v2.xml" ); @@ -81,7 +81,7 @@ public void testReaderReadsCorrectly() { } @Test - public void testReaderReadsScoreAndSelectedPlanCorrectly() { + void testReaderReadsScoreAndSelectedPlanCorrectly() { CarrierVehicleTypes carrierVehicleTypes = new CarrierVehicleTypes(); new CarrierVehicleTypeReader( carrierVehicleTypes ).readFile( utils.getPackageInputDirectory() + "vehicleTypes_v2.xml" ); @@ -98,7 +98,7 @@ public void testReaderReadsScoreAndSelectedPlanCorrectly() { } @Test - public void testReaderReadsUnScoredAndUnselectedPlanCorrectly() { + void testReaderReadsUnScoredAndUnselectedPlanCorrectly() { CarrierVehicleTypes carrierVehicleTypes = new CarrierVehicleTypes(); new CarrierVehicleTypeReader( carrierVehicleTypes ).readFile( utils.getPackageInputDirectory() + "vehicleTypes_v2.xml" ); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2Test.java index 1a491be3e95..8d2c910226d 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2Test.java @@ -23,8 +23,8 @@ import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -61,12 +61,12 @@ public void setUp() throws Exception{ } @Test - public void test_whenReadingServices_nuOfServicesIsCorrect(){ + void test_whenReadingServices_nuOfServicesIsCorrect(){ Assert.assertEquals(3,testCarrier.getServices().size()); } @Test - public void test_whenReadingCarrier_itReadsTypeIdsCorrectly(){ + void test_whenReadingCarrier_itReadsTypeIdsCorrectly(){ CarrierVehicle light = CarriersUtils.getCarrierVehicle(testCarrier, Id.createVehicleId("lightVehicle")); Gbl.assertNotNull(light); @@ -82,7 +82,7 @@ public void test_whenReadingCarrier_itReadsTypeIdsCorrectly(){ } @Test - public void test_whenReadingCarrier_itReadsVehiclesCorrectly(){ + void test_whenReadingCarrier_itReadsVehiclesCorrectly(){ Map, CarrierVehicle> carrierVehicles = testCarrier.getCarrierCapabilities().getCarrierVehicles(); Assert.assertEquals(3,carrierVehicles.size()); Assert.assertTrue(exactlyTheseVehiclesAreInVehicleCollection(Arrays.asList(Id.create("lightVehicle", Vehicle.class), @@ -90,27 +90,27 @@ public void test_whenReadingCarrier_itReadsVehiclesCorrectly(){ } @Test - public void test_whenReadingCarrier_itReadsFleetSizeCorrectly(){ + void test_whenReadingCarrier_itReadsFleetSizeCorrectly(){ Assert.assertEquals(FleetSize.INFINITE, testCarrier.getCarrierCapabilities().getFleetSize()); } @Test - public void test_whenReadingCarrier_itReadsShipmentsCorrectly(){ + void test_whenReadingCarrier_itReadsShipmentsCorrectly(){ Assert.assertEquals(2, testCarrier.getShipments().size()); } @Test - public void test_whenReadingCarrier_itReadsPlansCorrectly(){ + void test_whenReadingCarrier_itReadsPlansCorrectly(){ Assert.assertEquals(3, testCarrier.getPlans().size()); } @Test - public void test_whenReadingCarrier_itSelectsPlansCorrectly(){ + void test_whenReadingCarrier_itSelectsPlansCorrectly(){ Assert.assertNotNull(testCarrier.getSelectedPlan()); } @Test - public void test_whenReadingCarrierWithFiniteFleet_itSetsFleetSizeCorrectly(){ + void test_whenReadingCarrierWithFiniteFleet_itSetsFleetSizeCorrectly(){ CarrierVehicleTypes carrierVehicleTypes = new CarrierVehicleTypes(); new CarrierVehicleTypeReader( carrierVehicleTypes ).readFile( utils.getPackageInputDirectory() + "vehicleTypes_v2.xml" ); @@ -122,7 +122,7 @@ public void test_whenReadingCarrierWithFiniteFleet_itSetsFleetSizeCorrectly(){ } @Test - public void test_whenReadingPlans_nuOfToursIsCorrect(){ + void test_whenReadingPlans_nuOfToursIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); Assert.assertEquals(1, plans.get(0).getScheduledTours().size()); Assert.assertEquals(1, plans.get(1).getScheduledTours().size()); @@ -130,7 +130,7 @@ public void test_whenReadingPlans_nuOfToursIsCorrect(){ } @Test - public void test_whenReadingToursOfPlan1_nuOfActivitiesIsCorrect(){ + void test_whenReadingToursOfPlan1_nuOfActivitiesIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); CarrierPlan plan1 = plans.get(0); ScheduledTour tour1 = plan1.getScheduledTours().iterator().next(); @@ -138,7 +138,7 @@ public void test_whenReadingToursOfPlan1_nuOfActivitiesIsCorrect(){ } @Test - public void test_whenReadingToursOfPlan2_nuOfActivitiesIsCorrect(){ + void test_whenReadingToursOfPlan2_nuOfActivitiesIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); CarrierPlan plan2 = plans.get(1); ScheduledTour tour1 = plan2.getScheduledTours().iterator().next(); @@ -146,7 +146,7 @@ public void test_whenReadingToursOfPlan2_nuOfActivitiesIsCorrect(){ } @Test - public void test_whenReadingToursOfPlan3_nuOfActivitiesIsCorrect(){ + void test_whenReadingToursOfPlan3_nuOfActivitiesIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); CarrierPlan plan3 = plans.get(2); ScheduledTour tour1 = plan3.getScheduledTours().iterator().next(); @@ -162,13 +162,13 @@ private boolean exactlyTheseVehiclesAreInVehicleCollection(List> asL @Test - public void test_CarrierHasAttributes(){ + void test_CarrierHasAttributes(){ Assert.assertEquals((TransportMode.drt), CarriersUtils.getCarrierMode(testCarrier)); Assert.assertEquals(50, CarriersUtils.getJspritIterations(testCarrier)); } @Test - public void test_ServicesAndShipmentsHaveAttributes(){ + void test_ServicesAndShipmentsHaveAttributes(){ Object serviceCustomerAtt = testCarrier.getServices().get(Id.create("serv1", CarrierService.class)).getAttributes().getAttribute("customer"); Assert.assertNotNull(serviceCustomerAtt); Assert.assertEquals("someRandomCustomer", serviceCustomerAtt); @@ -178,7 +178,7 @@ public void test_ServicesAndShipmentsHaveAttributes(){ } @Test - public void test_readStream() { + void test_readStream() { Config config = ConfigUtils.createConfig(); Scenario scenario = ScenarioUtils.createScenario(config); Carriers carriers = CarriersUtils.addOrGetCarriers(scenario); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java index 00d92714dc3..32b3dd45307 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java @@ -21,7 +21,10 @@ package org.matsim.freight.carriers; -import org.junit.*; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.core.gbl.Gbl; @@ -51,13 +54,14 @@ public void setUp() throws Exception{ testCarrier = carriers.getCarriers().get(Id.create("testCarrier", Carrier.class)); } - @Test @Ignore - public void test_whenReadingServices_nuOfServicesIsCorrect(){ + @Test + @Ignore + void test_whenReadingServices_nuOfServicesIsCorrect(){ Assert.assertEquals(3,testCarrier.getServices().size()); } @Test - public void test_whenReadingCarrier_itReadsTypeIdsCorrectly(){ + void test_whenReadingCarrier_itReadsTypeIdsCorrectly(){ CarrierVehicle light = CarriersUtils.getCarrierVehicle(testCarrier, Id.createVehicleId("lightVehicle")); Gbl.assertNotNull(light); @@ -72,36 +76,41 @@ public void test_whenReadingCarrier_itReadsTypeIdsCorrectly(){ Assert.assertEquals("heavy",heavy.getVehicleTypeId().toString()); } - @Test @Ignore - public void test_whenReadingCarrier_itReadsVehiclesCorrectly(){ + @Test + @Ignore + void test_whenReadingCarrier_itReadsVehiclesCorrectly(){ Map, CarrierVehicle> carrierVehicles = testCarrier.getCarrierCapabilities().getCarrierVehicles(); Assert.assertEquals(3,carrierVehicles.size()); Assert.assertTrue(exactlyTheseVehiclesAreInVehicleCollection(Arrays.asList(Id.create("lightVehicle", Vehicle.class), Id.create("mediumVehicle", Vehicle.class),Id.create("heavyVehicle", Vehicle.class)),carrierVehicles.values())); } - @Test @Ignore - public void test_whenReadingCarrier_itReadsFleetSizeCorrectly(){ + @Test + @Ignore + void test_whenReadingCarrier_itReadsFleetSizeCorrectly(){ Assert.assertEquals(FleetSize.INFINITE, testCarrier.getCarrierCapabilities().getFleetSize()); } - @Test @Ignore - public void test_whenReadingCarrier_itReadsShipmentsCorrectly(){ + @Test + @Ignore + void test_whenReadingCarrier_itReadsShipmentsCorrectly(){ Assert.assertEquals(2, testCarrier.getShipments().size()); } - @Test @Ignore - public void test_whenReadingCarrier_itReadsPlansCorrectly(){ + @Test + @Ignore + void test_whenReadingCarrier_itReadsPlansCorrectly(){ Assert.assertEquals(3, testCarrier.getPlans().size()); } - @Test @Ignore - public void test_whenReadingCarrier_itSelectsPlansCorrectly(){ + @Test + @Ignore + void test_whenReadingCarrier_itSelectsPlansCorrectly(){ Assert.assertNotNull(testCarrier.getSelectedPlan()); } @Test - public void test_whenReadingCarrierWithFiniteFleet_itSetsFleetSizeCorrectly(){ + void test_whenReadingCarrierWithFiniteFleet_itSetsFleetSizeCorrectly(){ CarrierVehicleTypes carrierVehicleTypes = new CarrierVehicleTypes(); new CarrierVehicleTypeReader( carrierVehicleTypes ).readFile( utils.getPackageInputDirectory() + "vehicleTypes_v2.xml" ); @@ -112,16 +121,18 @@ public void test_whenReadingCarrierWithFiniteFleet_itSetsFleetSizeCorrectly(){ Assert.assertEquals(FleetSize.FINITE, carriers.getCarriers().get(Id.create("testCarrier", Carrier.class)).getCarrierCapabilities().getFleetSize()); } - @Test @Ignore - public void test_whenReadingPlans_nuOfToursIsCorrect(){ + @Test + @Ignore + void test_whenReadingPlans_nuOfToursIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); Assert.assertEquals(1, plans.get(0).getScheduledTours().size()); Assert.assertEquals(1, plans.get(1).getScheduledTours().size()); Assert.assertEquals(1, plans.get(2).getScheduledTours().size()); } - @Test @Ignore - public void test_whenReadingToursOfPlan1_nuOfActivitiesIsCorrect(){ + @Test + @Ignore + void test_whenReadingToursOfPlan1_nuOfActivitiesIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); CarrierPlan plan1 = plans.get(0); ScheduledTour tour1 = plan1.getScheduledTours().iterator().next(); @@ -129,15 +140,16 @@ public void test_whenReadingToursOfPlan1_nuOfActivitiesIsCorrect(){ } @Test - public void test_whenReadingToursOfPlan2_nuOfActivitiesIsCorrect(){ + void test_whenReadingToursOfPlan2_nuOfActivitiesIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); CarrierPlan plan2 = plans.get(1); ScheduledTour tour1 = plan2.getScheduledTours().iterator().next(); Assert.assertEquals(9,tour1.getTour().getTourElements().size()); } - @Test @Ignore - public void test_whenReadingToursOfPlan3_nuOfActivitiesIsCorrect(){ + @Test + @Ignore + void test_whenReadingToursOfPlan3_nuOfActivitiesIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); CarrierPlan plan3 = plans.get(2); ScheduledTour tour1 = plan3.getScheduledTours().iterator().next(); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV1Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV1Test.java index 4dd9a950d5a..f4840b577ae 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV1Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV1Test.java @@ -21,8 +21,8 @@ package org.matsim.freight.carriers; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.freight.carriers.*; import org.matsim.testcases.MatsimTestUtils; @@ -37,7 +37,7 @@ public class CarrierPlanXmlWriterV1Test { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void testCarrierPlanWriterWrites() { + void testCarrierPlanWriterWrites() { CarrierVehicleTypes carrierVehicleTypes = new CarrierVehicleTypes(); new CarrierVehicleTypeReader( carrierVehicleTypes ).readFile( testUtils.getPackageInputDirectory() + "vehicleTypes_v2.xml" ); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test.java index 252254f9a24..c6a5c2f42b1 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test.java @@ -22,8 +22,8 @@ package org.matsim.freight.carriers; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.freight.carriers.*; @@ -57,12 +57,12 @@ public void setUp() throws Exception{ } @Test - public void test_whenReadingServices_nuOfServicesIsCorrect(){ + void test_whenReadingServices_nuOfServicesIsCorrect(){ assertEquals(3,testCarrier.getServices().size()); } @Test - public void test_whenReadingCarrier_itReadsTypeIdsCorrectly(){ + void test_whenReadingCarrier_itReadsTypeIdsCorrectly(){ CarrierVehicle light = CarriersUtils.getCarrierVehicle(testCarrier, Id.createVehicleId("lightVehicle")); assertEquals("light",light.getVehicleTypeId().toString()); @@ -75,7 +75,7 @@ public void test_whenReadingCarrier_itReadsTypeIdsCorrectly(){ } @Test - public void test_whenReadingCarrier_itReadsVehiclesCorrectly(){ + void test_whenReadingCarrier_itReadsVehiclesCorrectly(){ Map, CarrierVehicle> carrierVehicles = testCarrier.getCarrierCapabilities().getCarrierVehicles(); assertEquals(3,carrierVehicles.size()); assertTrue(exactlyTheseVehiclesAreInVehicleCollection(Arrays.asList(Id.create("lightVehicle", Vehicle.class), @@ -83,27 +83,27 @@ public void test_whenReadingCarrier_itReadsVehiclesCorrectly(){ } @Test - public void test_whenReadingCarrier_itReadsFleetSizeCorrectly(){ + void test_whenReadingCarrier_itReadsFleetSizeCorrectly(){ assertEquals(FleetSize.INFINITE, testCarrier.getCarrierCapabilities().getFleetSize()); } @Test - public void test_whenReadingCarrier_itReadsShipmentsCorrectly(){ + void test_whenReadingCarrier_itReadsShipmentsCorrectly(){ assertEquals(2, testCarrier.getShipments().size()); } @Test - public void test_whenReadingCarrier_itReadsPlansCorrectly(){ + void test_whenReadingCarrier_itReadsPlansCorrectly(){ assertEquals(3, testCarrier.getPlans().size()); } @Test - public void test_whenReadingCarrier_itSelectsPlansCorrectly(){ + void test_whenReadingCarrier_itSelectsPlansCorrectly(){ assertNotNull(testCarrier.getSelectedPlan()); } @Test - public void test_whenReadingPlans_nuOfToursIsCorrect(){ + void test_whenReadingPlans_nuOfToursIsCorrect(){ List plans = new ArrayList(testCarrier.getPlans()); assertEquals(1, plans.get(0).getScheduledTours().size()); assertEquals(1, plans.get(1).getScheduledTours().size()); @@ -111,7 +111,7 @@ public void test_whenReadingPlans_nuOfToursIsCorrect(){ } @Test - public void test_whenReadingToursOfPlan1_nuOfActivitiesIsCorrect(){ + void test_whenReadingToursOfPlan1_nuOfActivitiesIsCorrect(){ List plans = new ArrayList(testCarrier.getPlans()); CarrierPlan plan1 = plans.get(0); ScheduledTour tour1 = plan1.getScheduledTours().iterator().next(); @@ -119,7 +119,7 @@ public void test_whenReadingToursOfPlan1_nuOfActivitiesIsCorrect(){ } @Test - public void test_whenReadingToursOfPlan2_nuOfActivitiesIsCorrect(){ + void test_whenReadingToursOfPlan2_nuOfActivitiesIsCorrect(){ List plans = new ArrayList(testCarrier.getPlans()); CarrierPlan plan2 = plans.get(1); ScheduledTour tour1 = plan2.getScheduledTours().iterator().next(); @@ -127,7 +127,7 @@ public void test_whenReadingToursOfPlan2_nuOfActivitiesIsCorrect(){ } @Test - public void test_whenReadingToursOfPlan3_nuOfActivitiesIsCorrect(){ + void test_whenReadingToursOfPlan3_nuOfActivitiesIsCorrect(){ List plans = new ArrayList(testCarrier.getPlans()); CarrierPlan plan3 = plans.get(2); ScheduledTour tour1 = plan3.getScheduledTours().iterator().next(); @@ -142,13 +142,13 @@ private boolean exactlyTheseVehiclesAreInVehicleCollection(List> asL } @Test - public void test_CarrierHasAttributes(){ + void test_CarrierHasAttributes(){ assertEquals((TransportMode.drt), CarriersUtils.getCarrierMode(testCarrier)); assertEquals(50, CarriersUtils.getJspritIterations(testCarrier)); } @Test - public void test_ServicesAndShipmentsHaveAttributes(){ + void test_ServicesAndShipmentsHaveAttributes(){ Object serviceCustomerAtt = testCarrier.getServices().get(Id.create("serv1",CarrierService.class)).getAttributes().getAttribute("customer"); assertNotNull(serviceCustomerAtt); assertEquals("someRandomCustomer", (String) serviceCustomerAtt); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1Test.java index a122bae47cb..315570c91a2 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1Test.java @@ -22,8 +22,8 @@ package org.matsim.freight.carriers; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.freight.carriers.*; @@ -57,12 +57,12 @@ public void setUp() throws Exception{ } @Test - public void test_whenReadingServices_nuOfServicesIsCorrect(){ + void test_whenReadingServices_nuOfServicesIsCorrect(){ assertEquals(3,testCarrier.getServices().size()); } @Test - public void test_whenReadingCarrier_itReadsTypeIdsCorrectly(){ + void test_whenReadingCarrier_itReadsTypeIdsCorrectly(){ CarrierVehicle light = CarriersUtils.getCarrierVehicle(testCarrier, Id.createVehicleId("lightVehicle")); assertEquals("light",light.getVehicleTypeId().toString()); @@ -75,7 +75,7 @@ public void test_whenReadingCarrier_itReadsTypeIdsCorrectly(){ } @Test - public void test_whenReadingCarrier_itReadsVehiclesCorrectly(){ + void test_whenReadingCarrier_itReadsVehiclesCorrectly(){ Map, CarrierVehicle> carrierVehicles = testCarrier.getCarrierCapabilities().getCarrierVehicles(); assertEquals(3,carrierVehicles.size()); assertTrue(exactlyTheseVehiclesAreInVehicleCollection(Arrays.asList(Id.create("lightVehicle", Vehicle.class), @@ -83,27 +83,27 @@ public void test_whenReadingCarrier_itReadsVehiclesCorrectly(){ } @Test - public void test_whenReadingCarrier_itReadsFleetSizeCorrectly(){ + void test_whenReadingCarrier_itReadsFleetSizeCorrectly(){ assertEquals(FleetSize.INFINITE, testCarrier.getCarrierCapabilities().getFleetSize()); } @Test - public void test_whenReadingCarrier_itReadsShipmentsCorrectly(){ + void test_whenReadingCarrier_itReadsShipmentsCorrectly(){ assertEquals(2, testCarrier.getShipments().size()); } @Test - public void test_whenReadingCarrier_itReadsPlansCorrectly(){ + void test_whenReadingCarrier_itReadsPlansCorrectly(){ assertEquals(3, testCarrier.getPlans().size()); } @Test - public void test_whenReadingCarrier_itSelectsPlansCorrectly(){ + void test_whenReadingCarrier_itSelectsPlansCorrectly(){ assertNotNull(testCarrier.getSelectedPlan()); } @Test - public void test_whenReadingPlans_nuOfToursIsCorrect(){ + void test_whenReadingPlans_nuOfToursIsCorrect(){ List plans = new ArrayList(testCarrier.getPlans()); assertEquals(1, plans.get(0).getScheduledTours().size()); assertEquals(1, plans.get(1).getScheduledTours().size()); @@ -111,7 +111,7 @@ public void test_whenReadingPlans_nuOfToursIsCorrect(){ } @Test - public void test_whenReadingToursOfPlan1_nuOfActivitiesIsCorrect(){ + void test_whenReadingToursOfPlan1_nuOfActivitiesIsCorrect(){ List plans = new ArrayList(testCarrier.getPlans()); CarrierPlan plan1 = plans.get(0); ScheduledTour tour1 = plan1.getScheduledTours().iterator().next(); @@ -119,7 +119,7 @@ public void test_whenReadingToursOfPlan1_nuOfActivitiesIsCorrect(){ } @Test - public void test_whenReadingToursOfPlan2_nuOfActivitiesIsCorrect(){ + void test_whenReadingToursOfPlan2_nuOfActivitiesIsCorrect(){ List plans = new ArrayList(testCarrier.getPlans()); CarrierPlan plan2 = plans.get(1); ScheduledTour tour1 = plan2.getScheduledTours().iterator().next(); @@ -127,7 +127,7 @@ public void test_whenReadingToursOfPlan2_nuOfActivitiesIsCorrect(){ } @Test - public void test_whenReadingToursOfPlan3_nuOfActivitiesIsCorrect(){ + void test_whenReadingToursOfPlan3_nuOfActivitiesIsCorrect(){ List plans = new ArrayList(testCarrier.getPlans()); CarrierPlan plan3 = plans.get(2); ScheduledTour tour1 = plan3.getScheduledTours().iterator().next(); @@ -135,7 +135,7 @@ public void test_whenReadingToursOfPlan3_nuOfActivitiesIsCorrect(){ } @Test - public void test_whenReadingToursOfPlan1_SpritScoreIsCorrect(){ + void test_whenReadingToursOfPlan1_SpritScoreIsCorrect(){ List plans = new ArrayList(testCarrier.getPlans()); CarrierPlan plan1 = plans.get(0); plan1.getAttributes().getAttribute("jspritScore"); @@ -143,7 +143,7 @@ public void test_whenReadingToursOfPlan1_SpritScoreIsCorrect(){ } @Test - public void test_whenReadingToursOfPlan2_jSpritScoreIsCorrect(){ + void test_whenReadingToursOfPlan2_jSpritScoreIsCorrect(){ List plans = new ArrayList(testCarrier.getPlans()); CarrierPlan plan2 = plans.get(1); plan2.getAttributes().getAttribute("jspritScore"); @@ -151,7 +151,7 @@ public void test_whenReadingToursOfPlan2_jSpritScoreIsCorrect(){ } @Test - public void test_whenReadingToursOfPlan3_jSpritIsCorrect(){ + void test_whenReadingToursOfPlan3_jSpritIsCorrect(){ List plans = new ArrayList(testCarrier.getPlans()); CarrierPlan plan3 = plans.get(2); plan3.getAttributes().getAttribute("jspritScore"); @@ -166,13 +166,13 @@ private boolean exactlyTheseVehiclesAreInVehicleCollection(List> asL } @Test - public void test_CarrierHasAttributes(){ + void test_CarrierHasAttributes(){ assertEquals((TransportMode.drt), CarriersUtils.getCarrierMode(testCarrier)); assertEquals(50, CarriersUtils.getJspritIterations(testCarrier)); } @Test - public void test_ServicesAndShipmentsHaveAttributes(){ + void test_ServicesAndShipmentsHaveAttributes(){ Object serviceCustomerAtt = testCarrier.getServices().get(Id.create("serv1",CarrierService.class)).getAttributes().getAttribute("customer"); assertNotNull(serviceCustomerAtt); assertEquals("someRandomCustomer", (String) serviceCustomerAtt); @@ -180,8 +180,9 @@ public void test_ServicesAndShipmentsHaveAttributes(){ assertNotNull(shipmentCustomerAtt); assertEquals("someRandomCustomer", (String) shipmentCustomerAtt); } + @Test - public void test_ReadWriteFilesAreEqual(){ + void test_ReadWriteFilesAreEqual(){ MatsimTestUtils.assertEqualFilesLineByLine(this.testUtils.getClassInputDirectory() + "carrierPlansEquils.xml", this.testUtils.getClassInputDirectory() + "carrierPlansEquilsWritten.xml"); } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierReadWriteV2_1Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierReadWriteV2_1Test.java index 741d20cb168..be71e48b2ca 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierReadWriteV2_1Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierReadWriteV2_1Test.java @@ -21,8 +21,8 @@ package org.matsim.freight.carriers; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.freight.carriers.*; import org.matsim.testcases.MatsimTestUtils; @@ -36,7 +36,7 @@ public class CarrierReadWriteV2_1Test { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void readWriteTest() throws FileNotFoundException, IOException { + void readWriteTest() throws FileNotFoundException, IOException { Carriers carriers = new Carriers(Collections.emptyList()); CarrierVehicleTypes carrierVehicleTypes = new CarrierVehicleTypes(); @@ -57,7 +57,7 @@ public void readWriteTest() throws FileNotFoundException, IOException { @Test - public void readWriteReadTest() throws FileNotFoundException, IOException { + void readWriteReadTest() throws FileNotFoundException, IOException { Carriers carriers = new Carriers(Collections.emptyList()); CarrierVehicleTypes carrierVehicleTypes = new CarrierVehicleTypes(); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest.java index 06a24c9e6ee..6f6a002f19c 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest.java @@ -23,8 +23,8 @@ import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.freight.carriers.*; import org.matsim.testcases.MatsimTestUtils; @@ -48,7 +48,7 @@ public void setUp() throws Exception{ } @Test - public void test_whenLoadingTypes_allAssignmentsInLightVehicleAreCorrectly(){ + void test_whenLoadingTypes_allAssignmentsInLightVehicleAreCorrectly(){ new CarrierVehicleTypeLoader(carriers).loadVehicleTypes(types); Carrier testCarrier = carriers.getCarriers().get(Id.create("testCarrier", Carrier.class)); CarrierVehicle v = CarriersUtils.getCarrierVehicle(testCarrier,Id.createVehicleId("lightVehicle")); @@ -67,7 +67,7 @@ public void test_whenLoadingTypes_allAssignmentsInLightVehicleAreCorrectly(){ } @Test - public void test_whenLoadingTypes_allAssignmentsInMediumVehicleAreCorrectly(){ + void test_whenLoadingTypes_allAssignmentsInMediumVehicleAreCorrectly(){ new CarrierVehicleTypeLoader(carriers).loadVehicleTypes(types); Carrier testCarrier = carriers.getCarriers().get(Id.create("testCarrier", Carrier.class)); CarrierVehicle v = CarriersUtils.getCarrierVehicle(testCarrier,Id.createVehicleId("mediumVehicle")); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest.java index 720dcb63c32..5801d07e523 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest.java @@ -24,8 +24,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.VehicleType; @@ -49,31 +49,31 @@ public void setUp() { } @Test - public void test_whenReadingTypes_nuOfTypesIsReadCorrectly(){ + void test_whenReadingTypes_nuOfTypesIsReadCorrectly(){ assertEquals(2, types.getVehicleTypes().size()); } @Test - public void test_whenReadingTypes_itReadyExactlyTheTypesFromFile(){ + void test_whenReadingTypes_itReadyExactlyTheTypesFromFile(){ assertTrue(types.getVehicleTypes().containsKey(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ) ); assertTrue(types.getVehicleTypes().containsKey(Id.create("light", org.matsim.vehicles.VehicleType.class ) ) ); assertEquals(2, types.getVehicleTypes().size()); } @Test - public void test_whenReadingTypeMedium_itReadsDescriptionCorrectly(){ + void test_whenReadingTypeMedium_itReadsDescriptionCorrectly(){ VehicleType medium = types.getVehicleTypes().get(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ); assertEquals("Medium Vehicle", medium.getDescription()); } @Test - public void test_whenReadingTypeMedium_itReadsCapacityCorrectly(){ + void test_whenReadingTypeMedium_itReadsCapacityCorrectly(){ VehicleType medium = types.getVehicleTypes().get(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ); assertEquals(30., (double) medium.getCapacity().getOther(), Double.MIN_VALUE ); } @Test - public void test_whenReadingTypeMedium_itReadsCostInfoCorrectly(){ + void test_whenReadingTypeMedium_itReadsCostInfoCorrectly(){ VehicleType medium = types.getVehicleTypes().get(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ); assertEquals(50.0, medium.getCostInformation().getFixedCosts(),0.01 ); assertEquals(0.4, medium.getCostInformation().getCostsPerMeter(),0.01 ); @@ -81,14 +81,14 @@ public void test_whenReadingTypeMedium_itReadsCostInfoCorrectly(){ } @Test - public void test_whenReadingTypeMedium_itReadsEngineInfoCorrectly(){ + void test_whenReadingTypeMedium_itReadsEngineInfoCorrectly(){ VehicleType medium = types.getVehicleTypes().get(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ); assertEquals(0.02, medium.getEngineInformation().getFuelConsumption(),0.01); assertEquals("gasoline", medium.getEngineInformation().getFuelType().toString()); } @Test - public void readV1andWriteV2(){ + void readV1andWriteV2(){ final String outFilename = utils.getOutputDirectory() + "/vehicleTypes_v2.xml"; new CarrierVehicleTypeWriter( types ).write( outFilename ) ; final String referenceFilename = utils.getClassInputDirectory() + "/vehicleTypes_v2.xml" ; @@ -96,7 +96,7 @@ public void readV1andWriteV2(){ } @Test - public void readV2andWriteV2() { + void readV2andWriteV2() { // yyyyyy FIXME because of "setUp" this will be doing an irrelevant read first. log.info("") ; log.info("") ; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeTest.java index a17f15744aa..080ea93de26 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeTest.java @@ -23,8 +23,8 @@ import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.freight.carriers.CarrierVehicleTypes; import org.matsim.testcases.MatsimTestUtils; @@ -84,19 +84,19 @@ public void setUp() throws Exception{ } @Test - public void test_whenCreatingTypeMedium_itCreatesDescriptionCorrectly(){ + void test_whenCreatingTypeMedium_itCreatesDescriptionCorrectly(){ VehicleType medium = types.getVehicleTypes().get(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ); Assert.assertEquals("Medium Vehicle", medium.getDescription()); } @Test - public void test_whenCreatingTypeMedium_itCreatesCapacityCorrectly(){ + void test_whenCreatingTypeMedium_itCreatesCapacityCorrectly(){ VehicleType medium = types.getVehicleTypes().get(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ); Assert.assertEquals(30., medium.getCapacity().getWeightInTons(), MatsimTestUtils.EPSILON ); } @Test - public void test_whenCreatingTypeMedium_itCreatesCostInfoCorrectly(){ + void test_whenCreatingTypeMedium_itCreatesCostInfoCorrectly(){ VehicleType medium = types.getVehicleTypes().get(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ); Assert.assertEquals(50.0, medium.getCostInformation().getFixedCosts(),0.01 ); Assert.assertEquals(1.0, medium.getCostInformation().getCostsPerMeter(),0.01 ); @@ -104,33 +104,33 @@ public void test_whenCreatingTypeMedium_itCreatesCostInfoCorrectly(){ } @Test - public void test_whenCreatingTypeMedium_itCreatesEngineInfoCorrectly(){ + void test_whenCreatingTypeMedium_itCreatesEngineInfoCorrectly(){ VehicleType medium = types.getVehicleTypes().get(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ); Assert.assertEquals(0.02, medium.getEngineInformation().getFuelConsumption(),0.001); Assert.assertEquals(FuelType.diesel, medium.getEngineInformation().getFuelType()); } @Test - public void test_whenCreatingTypeMedium_itCreatesMaxVelocityCorrectly(){ + void test_whenCreatingTypeMedium_itCreatesMaxVelocityCorrectly(){ VehicleType medium = types.getVehicleTypes().get(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ); Assert.assertEquals(13.89, medium.getMaximumVelocity(), 0.01); } //Now testing the copy @Test - public void test_whenCopyingTypeMedium_itCopiesDescriptionCorrectly(){ + void test_whenCopyingTypeMedium_itCopiesDescriptionCorrectly(){ VehicleType medium2 = types.getVehicleTypes().get(Id.create("medium2", org.matsim.vehicles.VehicleType.class ) ); Assert.assertEquals("Medium Vehicle", medium2.getDescription()); } @Test - public void test_whenCopyingTypeMedium_itCopiesCapacityCorrectly(){ + void test_whenCopyingTypeMedium_itCopiesCapacityCorrectly(){ VehicleType medium2 = types.getVehicleTypes().get(Id.create("medium2", org.matsim.vehicles.VehicleType.class ) ); Assert.assertEquals(30., medium2.getCapacity().getWeightInTons(), MatsimTestUtils.EPSILON ); } @Test - public void test_whenCopyingTypeMedium_itCopiesCostInfoCorrectly(){ + void test_whenCopyingTypeMedium_itCopiesCostInfoCorrectly(){ VehicleType medium2 = types.getVehicleTypes().get(Id.create("medium2", org.matsim.vehicles.VehicleType.class ) ); Assert.assertEquals(50.0, medium2.getCostInformation().getFixedCosts(),0.01 ); Assert.assertEquals(1.0, medium2.getCostInformation().getCostsPerMeter(),0.01 ); @@ -138,33 +138,33 @@ public void test_whenCopyingTypeMedium_itCopiesCostInfoCorrectly(){ } @Test - public void test_whenCopyingTypeMedium_itCopiesEngineInfoCorrectly(){ + void test_whenCopyingTypeMedium_itCopiesEngineInfoCorrectly(){ VehicleType medium2 = types.getVehicleTypes().get(Id.create("medium2", org.matsim.vehicles.VehicleType.class ) ); Assert.assertEquals(0.02, medium2.getEngineInformation().getFuelConsumption(),0.001); Assert.assertEquals(FuelType.diesel, medium2.getEngineInformation().getFuelType()); } @Test - public void test_whenCopyingTypeMedium_itCopiesMaxVelocityCorrectly(){ + void test_whenCopyingTypeMedium_itCopiesMaxVelocityCorrectly(){ VehicleType medium2 = types.getVehicleTypes().get(Id.create("medium2", org.matsim.vehicles.VehicleType.class ) ); Assert.assertEquals(13.89, medium2.getMaximumVelocity(), 0.01); } //Now testing the modified type. @Test - public void test_whenModifyingTypeSmall_itModifiesDescriptionCorrectly(){ + void test_whenModifyingTypeSmall_itModifiesDescriptionCorrectly(){ VehicleType small = types.getVehicleTypes().get(Id.create("small", org.matsim.vehicles.VehicleType.class ) ); Assert.assertEquals("Small Vehicle", small.getDescription()); } @Test - public void test_whenModifyingTypeSmall_itModifiesCapacityCorrectly(){ + void test_whenModifyingTypeSmall_itModifiesCapacityCorrectly(){ VehicleType small = types.getVehicleTypes().get(Id.create("small", org.matsim.vehicles.VehicleType.class ) ); Assert.assertEquals(16., small.getCapacity().getWeightInTons(), MatsimTestUtils.EPSILON ); } @Test - public void test_whenModifyingTypeSmall_itModifiesCostInfoCorrectly(){ + void test_whenModifyingTypeSmall_itModifiesCostInfoCorrectly(){ VehicleType small = types.getVehicleTypes().get(Id.create("small", org.matsim.vehicles.VehicleType.class ) ); Assert.assertEquals(25.0, small.getCostInformation().getFixedCosts(),0.01 ); Assert.assertEquals(0.75, small.getCostInformation().getCostsPerMeter(),0.01 ); @@ -172,14 +172,14 @@ public void test_whenModifyingTypeSmall_itModifiesCostInfoCorrectly(){ } @Test - public void test_whenModifyingTypeSmall_itModifiesEngineInfoCorrectly(){ + void test_whenModifyingTypeSmall_itModifiesEngineInfoCorrectly(){ VehicleType small = types.getVehicleTypes().get(Id.create("small", org.matsim.vehicles.VehicleType.class ) ); Assert.assertEquals(0.015, small.getEngineInformation().getFuelConsumption(),0.001); Assert.assertEquals(FuelType.gasoline, small.getEngineInformation().getFuelType()); } @Test - public void test_whenModifyingTypeSmall_itModifiesMaxVelocityCorrectly(){ + void test_whenModifyingTypeSmall_itModifiesMaxVelocityCorrectly(){ VehicleType small = types.getVehicleTypes().get(Id.create("small", org.matsim.vehicles.VehicleType.class ) ); Assert.assertEquals(10.0, small.getMaximumVelocity(), 0.01); } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeWriterTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeWriterTest.java index c47029826e6..307408885a6 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeWriterTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeWriterTest.java @@ -21,8 +21,8 @@ package org.matsim.freight.carriers; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.freight.carriers.CarrierVehicleTypeReader; import org.matsim.freight.carriers.CarrierVehicleTypeWriter; import org.matsim.freight.carriers.CarrierVehicleTypes; @@ -34,7 +34,7 @@ public class CarrierVehicleTypeWriterTest { private MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public void testTypeWriter(){ + void testTypeWriter(){ CarrierVehicleTypes types = new CarrierVehicleTypes(); new CarrierVehicleTypeReader(types).readFile(utils.getClassInputDirectory()+ "vehicleTypes.xml"); final String outputVehTypeFile = utils.getOutputDirectory()+ "vehicleTypesWritten.xml"; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java index b1a831f0763..a70e13239eb 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java @@ -22,8 +22,8 @@ package org.matsim.freight.carriers; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.freight.carriers.*; import org.matsim.testcases.MatsimTestUtils; @@ -40,7 +40,7 @@ public class CarriersUtilsTest { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void testAddAndGetVehicleToCarrier() { + void testAddAndGetVehicleToCarrier() { Carrier carrier = new CarrierImpl(Id.create("carrier", Carrier.class)); Id testVehicleId = Id.createVehicleId("testVehicle"); CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(testVehicleId, Id.createLinkId("link0"),VehicleUtils.getDefaultVehicleType()); @@ -61,7 +61,7 @@ public void testAddAndGetVehicleToCarrier() { } @Test - public void testAddAndGetServiceToCarrier() { + void testAddAndGetServiceToCarrier() { Carrier carrier = new CarrierImpl(Id.create("carrier", Carrier.class)); Id serviceId = Id.create("testVehicle", CarrierService.class); CarrierService service1 = CarrierService.Builder.newInstance(serviceId,Id.createLinkId("link0") ) @@ -83,7 +83,7 @@ public void testAddAndGetServiceToCarrier() { } @Test - public void testAddAndGetShipmentToCarrier() { + void testAddAndGetShipmentToCarrier() { Carrier carrier = new CarrierImpl(Id.create("carrier", Carrier.class)); Id shipmentId = Id.create("testVehicle", CarrierShipment.class); CarrierShipment service1 = CarrierShipment.Builder.newInstance(shipmentId,Id.createLinkId("link0"), Id.createLinkId("link1"), 20 ).build(); @@ -104,7 +104,7 @@ public void testAddAndGetShipmentToCarrier() { } @Test - public void testGetSetJspritIteration(){ + void testGetSetJspritIteration(){ Carrier carrier = new CarrierImpl(Id.create("carrier", Carrier.class)); //jspirtIterations is not set. should return Integer.Min_Value (null is not possible because returning (int) Assert.assertEquals(Integer.MIN_VALUE, CarriersUtils.getJspritIterations(carrier) ); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/FreightCarriersConfigGroupTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/FreightCarriersConfigGroupTest.java index 9310bf5716c..a56f1fce3aa 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/FreightCarriersConfigGroupTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/FreightCarriersConfigGroupTest.java @@ -22,7 +22,7 @@ package org.matsim.freight.carriers; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigReader; import org.matsim.core.config.ConfigUtils; @@ -39,7 +39,7 @@ public class FreightCarriersConfigGroupTest { @Test - public void test_allParametersAreWrittenToXml() { + void test_allParametersAreWrittenToXml() { FreightCarriersConfigGroup freight = new FreightCarriersConfigGroup(); Map params = freight.getParams(); @@ -51,7 +51,7 @@ public void test_allParametersAreWrittenToXml() { } @Test - public void test_configXmlCanBeParsed() { + void test_configXmlCanBeParsed() { FreightCarriersConfigGroup freight = new FreightCarriersConfigGroup(); Config config = ConfigUtils.createConfig(freight); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java index 7a157805173..c073356e1f0 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java @@ -23,8 +23,8 @@ import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; @@ -86,7 +86,7 @@ static Scenario commonScenario( Config config, MatsimTestUtils testUtils ){ } @Test - public void testScoringInMeters(){ + void testScoringInMeters(){ controler.addOverridingModule(new CarrierModule()); controler.addOverridingModule(new AbstractModule() { @Override diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT.java index 4de7e0d3267..e82e956b9da 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT.java @@ -21,9 +21,11 @@ package org.matsim.freight.carriers.controler; +import static org.junit.jupiter.api.Assertions.assertThrows; + import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; @@ -53,7 +55,7 @@ public void setUp() { } @Test - public void testMobsimWithCarrierRunsWithoutException() { + void testMobsimWithCarrierRunsWithoutException() { setUp(); controler.addOverridingModule(new CarrierModule()); controler.addOverridingModule(new AbstractModule() { @@ -66,39 +68,41 @@ public void install() { controler.run(); } - @Test(expected = IllegalStateException.class ) - public void testWithoutCarrierRoutes() { - Config config = EquilWithCarrierWithPersonsIT.commonConfig( testUtils ); - Scenario scenario = EquilWithCarrierWithPersonsIT.commonScenario( config, testUtils ); - - // set the routes to null: - for( Carrier carrier : CarriersUtils.getCarriers( scenario ).getCarriers().values() ){ - for( ScheduledTour tour : carrier.getSelectedPlan().getScheduledTours() ){ - for( Tour.TourElement tourElement : tour.getTour().getTourElements() ){ - if ( tourElement instanceof Tour.Leg ) { - ((Tour.Leg) tourElement).setRoute( null ); + @Test + void testWithoutCarrierRoutes() { + assertThrows(IllegalStateException.class, () -> { + Config config = EquilWithCarrierWithPersonsIT.commonConfig(testUtils); + Scenario scenario = EquilWithCarrierWithPersonsIT.commonScenario(config, testUtils); + + // set the routes to null: + for (Carrier carrier : CarriersUtils.getCarriers(scenario).getCarriers().values()) { + for (ScheduledTour tour : carrier.getSelectedPlan().getScheduledTours()) { + for (Tour.TourElement tourElement : tour.getTour().getTourElements()) { + if (tourElement instanceof Tour.Leg) { + ((Tour.Leg) tourElement).setRoute(null); + } } } } - } - controler = new Controler(scenario); - controler.addOverridingModule(new CarrierModule()); - controler.addOverridingModule(new AbstractModule() { - @Override - public void install() { - bind( CarrierStrategyManager.class ).toProvider(StrategyManagerFactoryForTests.class ).asEagerSingleton(); - bind(CarrierScoringFunctionFactory.class).to(DistanceScoringFunctionFactoryForTests.class).asEagerSingleton(); - } - }); + controler = new Controler(scenario); + controler.addOverridingModule(new CarrierModule()); + controler.addOverridingModule(new AbstractModule() { + @Override + public void install() { + bind(CarrierStrategyManager.class).toProvider(StrategyManagerFactoryForTests.class).asEagerSingleton(); + bind(CarrierScoringFunctionFactory.class).to(DistanceScoringFunctionFactoryForTests.class).asEagerSingleton(); + } + }); - // this fails in CarrierAgent#createDriverPlans(...). Could be made pass there, but then does not seem to drive on network. Would - // need carrier equivalent to PersonPrepareForSim. Could then adapt this test accordingly. kai, jul'22 - controler.run(); + // this fails in CarrierAgent#createDriverPlans(...). Could be made pass there, but then does not seem to drive on network. Would + // need carrier equivalent to PersonPrepareForSim. Could then adapt this test accordingly. kai, jul'22 + controler.run(); + }); } @Test - public void testScoringInMeters(){ + void testScoringInMeters(){ setUp(); controler.addOverridingModule(new CarrierModule()); controler.addOverridingModule(new AbstractModule() { @@ -118,7 +122,7 @@ public void install() { } @Test - public void testScoringInSecondsWoTimeWindowEnforcement(){ + void testScoringInSecondsWoTimeWindowEnforcement(){ setUp(); FreightCarriersConfigGroup freightCarriersConfigGroup = ConfigUtils.addOrGetModule( controler.getConfig(), FreightCarriersConfigGroup.class ); if ( false ){ @@ -145,7 +149,7 @@ public void install() { } @Test - public void testScoringInSecondsWTimeWindowEnforcement(){ + void testScoringInSecondsWTimeWindowEnforcement(){ setUp(); FreightCarriersConfigGroup freightCarriersConfigGroup = ConfigUtils.addOrGetModule( controler.getConfig(), FreightCarriersConfigGroup.class ); if ( true ){ @@ -173,7 +177,7 @@ public void install() { } @Test - public void testScoringInSecondsWithWithinDayRescheduling(){ + void testScoringInSecondsWithWithinDayRescheduling(){ setUp(); FreightCarriersConfigGroup freightCarriersConfigGroup = ConfigUtils.addOrGetModule( controler.getConfig(), FreightCarriersConfigGroup.class ); if ( true ){ @@ -197,7 +201,7 @@ public void install() { } @Test - public void testEventFilessAreEqual(){ + void testEventFilessAreEqual(){ setUp(); controler.addOverridingModule(new CarrierModule()); controler.addOverridingModule(new AbstractModule() { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java index 99f0c7ebe80..7879f26e03d 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java @@ -24,8 +24,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; @@ -76,7 +76,7 @@ public class DistanceConstraintFromVehiclesFileTest { * */ @Test - public final void CarrierSmallBatteryTest_Version1() throws ExecutionException, InterruptedException { + final void CarrierSmallBatteryTest_Version1() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); config.controller().setOutputDirectory(testUtils.getOutputDirectory()); @@ -150,7 +150,7 @@ public final void CarrierSmallBatteryTest_Version1() throws ExecutionException, * */ @Test - public final void CarrierLargeBatteryTest_Version2() throws ExecutionException, InterruptedException { + final void CarrierLargeBatteryTest_Version2() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); @@ -226,7 +226,7 @@ public final void CarrierLargeBatteryTest_Version2() throws ExecutionException, */ @Test - public final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, InterruptedException { + final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); @@ -307,7 +307,7 @@ public final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, */ @Test - public final void CarrierWithAdditionalDieselVehicleTest_Version4() throws ExecutionException, InterruptedException { + final void CarrierWithAdditionalDieselVehicleTest_Version4() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java index f55ccf201ed..f84e547bb14 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java @@ -24,8 +24,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; @@ -78,7 +78,7 @@ public class DistanceConstraintTest { * @throws ExecutionException, InterruptedException */ @Test - public final void CarrierSmallBatteryTest_Version1() throws ExecutionException, InterruptedException { + final void CarrierSmallBatteryTest_Version1() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); config.controller().setOutputDirectory(testUtils.getOutputDirectory()); @@ -157,7 +157,7 @@ public final void CarrierSmallBatteryTest_Version1() throws ExecutionException, * */ @Test - public final void CarrierLargeBatteryTest_Version2() throws ExecutionException, InterruptedException { + final void CarrierLargeBatteryTest_Version2() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); @@ -239,7 +239,7 @@ public final void CarrierLargeBatteryTest_Version2() throws ExecutionException, */ @Test - public final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, InterruptedException { + final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); @@ -329,7 +329,7 @@ public final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, */ @Test - public final void CarrierWithAdditionalDieselVehicleTest_Version4() throws ExecutionException, InterruptedException { + final void CarrierWithAdditionalDieselVehicleTest_Version4() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); @@ -428,7 +428,7 @@ else if (thisTypeId.equals("DieselVehicle")) */ @Test - public final void CarrierWithShipmentsMidSizeBatteryTest_Version5() throws ExecutionException, InterruptedException { + final void CarrierWithShipmentsMidSizeBatteryTest_Version5() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); @@ -507,7 +507,7 @@ public final void CarrierWithShipmentsMidSizeBatteryTest_Version5() throws Execu */ @Test - public final void CarrierWithShipmentsLargeBatteryTest_Version6() throws ExecutionException, InterruptedException { + final void CarrierWithShipmentsLargeBatteryTest_Version6() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java index 1adec7e30a1..a0001daba4b 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java @@ -31,8 +31,8 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -186,7 +186,7 @@ public void setUp() throws Exception { * nearby service1: 8km -> 8 EUR; service2: 36km -> 36 EUR --> total 44EUR -> score = -44 */ @Test - public final void test_carrier1CostsAreCorrectly() { + final void test_carrier1CostsAreCorrectly() { Assert.assertEquals(-44, carriersPlannedAndRouted.getCarriers().get(Id.create("carrier1", Carrier.class)).getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); } @@ -195,7 +195,7 @@ public final void test_carrier1CostsAreCorrectly() { * carrier2: only vehicles of Type B (fixed costs of 10 EUR/vehicle, no variable costs) */ @Test - public final void test_carrier2CostsAreCorrectly() { + final void test_carrier2CostsAreCorrectly() { Assert.assertEquals(-20.44, carriersPlannedAndRouted.getCarriers().get(Id.create("carrier2", Carrier.class)).getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); } @@ -204,7 +204,7 @@ public final void test_carrier2CostsAreCorrectly() { * should use A for short trip (8 EUR) and B for the long trip (10.36 EUR) */ @Test - public final void test_carrier3CostsAreCorrectly() { + final void test_carrier3CostsAreCorrectly() { Assert.assertEquals(-18.36, carriersPlannedAndRouted.getCarriers().get(Id.create("carrier3", Carrier.class)).getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/IntegrationIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/IntegrationIT.java index 1e0988f6529..5131d83904d 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/IntegrationIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/IntegrationIT.java @@ -28,8 +28,8 @@ import com.graphhopper.jsprit.core.reporting.SolutionPrinter; import com.graphhopper.jsprit.core.util.Solutions; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -48,7 +48,7 @@ public class IntegrationIT { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testJsprit() throws ExecutionException, InterruptedException { + void testJsprit() throws ExecutionException, InterruptedException { final String networkFilename = utils.getClassInputDirectory() + "/merged-network-simplified.xml.gz"; final String vehicleTypeFilename = utils.getClassInputDirectory() + "/vehicleTypes.xml"; final String carrierFilename = utils.getClassInputDirectory() + "/carrier.xml"; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java index 16cef601c1a..ec82034c573 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java @@ -31,8 +31,8 @@ import com.graphhopper.jsprit.core.problem.vehicle.Vehicle; import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl; import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -58,7 +58,7 @@ public class MatsimTransformerTest { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void whenTransforming_jSpritType2matsimType_itIsMadeCorrectly() { + void whenTransforming_jSpritType2matsimType_itIsMadeCorrectly() { com.graphhopper.jsprit.core.problem.vehicle.VehicleType jspritType = VehicleTypeImpl.Builder .newInstance("myType").addCapacityDimension(0, 50).setCostPerDistance(10.0).setCostPerTransportTime(5.0) .setFixedCost(100.0).build(); @@ -72,7 +72,7 @@ public void whenTransforming_jSpritType2matsimType_itIsMadeCorrectly() { } @Test - public void whenTransforming_jSpritType2matsimType_withCaching_itIsNotCached() { + void whenTransforming_jSpritType2matsimType_withCaching_itIsNotCached() { com.graphhopper.jsprit.core.problem.vehicle.VehicleType jspritType = VehicleTypeImpl.Builder .newInstance("myType").addCapacityDimension(0, 50).setCostPerDistance(10.0).setCostPerTransportTime(5.0) .setFixedCost(100.0).build(); @@ -81,7 +81,7 @@ public void whenTransforming_jSpritType2matsimType_withCaching_itIsNotCached() { } @Test - public void whenTransforming_matsimType2jSpritType_itIsMadeCorrectly() { + void whenTransforming_matsimType2jSpritType_itIsMadeCorrectly() { VehicleType matsimType = getMatsimVehicleType(); com.graphhopper.jsprit.core.problem.vehicle.VehicleType jspritType = MatsimJspritFactory .createJspritVehicleType(matsimType); @@ -93,7 +93,7 @@ public void whenTransforming_matsimType2jSpritType_itIsMadeCorrectly() { } @Test - public void whenTransforming_jspritVehicle2matsimVehicle_itIsMadeCorrectly() { + void whenTransforming_jspritVehicle2matsimVehicle_itIsMadeCorrectly() { com.graphhopper.jsprit.core.problem.vehicle.VehicleType jspritType = VehicleTypeImpl.Builder .newInstance("myType").addCapacityDimension(0, 50).setCostPerDistance(10.0).setCostPerTransportTime(5.0) .setFixedCost(100.0).build(); @@ -109,7 +109,7 @@ public void whenTransforming_jspritVehicle2matsimVehicle_itIsMadeCorrectly() { } @Test - public void whenTransforming_matsimVehicle2jspritVehicle_itIsMadeCorrectly() { + void whenTransforming_matsimVehicle2jspritVehicle_itIsMadeCorrectly() { VehicleType matsimType = getMatsimVehicleType(); CarrierVehicle matsimVehicle = getMatsimVehicle("matsimVehicle", "loc", matsimType); Vehicle jspritVehicle = MatsimJspritFactory.createJspritVehicle(matsimVehicle, null); @@ -122,7 +122,7 @@ public void whenTransforming_matsimVehicle2jspritVehicle_itIsMadeCorrectly() { } @Test - public void whenTransforming_matsimService2jspritService_isMadeCorrectly() { + void whenTransforming_matsimService2jspritService_isMadeCorrectly() { CarrierService carrierService = CarrierService.Builder .newInstance(Id.create("serviceId", CarrierService.class), Id.create("locationId", Link.class)) .setCapacityDemand(50).setServiceDuration(30.0) @@ -140,7 +140,7 @@ public void whenTransforming_matsimService2jspritService_isMadeCorrectly() { } @Test - public void whenTransforming_jspritService2matsimService_isMadeCorrectly() { + void whenTransforming_jspritService2matsimService_isMadeCorrectly() { Service carrierService = Service.Builder.newInstance("serviceId").addSizeDimension(0, 50) .setLocation(Location.newInstance("locationId")).setServiceTime(30.0) .setTimeWindow( @@ -160,7 +160,7 @@ public void whenTransforming_jspritService2matsimService_isMadeCorrectly() { } @Test - public void whenTransforming_matsimShipment2jspritShipment_isMadeCorrectly() { + void whenTransforming_matsimShipment2jspritShipment_isMadeCorrectly() { CarrierShipment carrierShipment = CarrierShipment.Builder .newInstance(Id.create("ShipmentId", CarrierShipment.class), Id.createLinkId("PickupLocationId"), Id.createLinkId("DeliveryLocationId"), 50) @@ -184,7 +184,7 @@ public void whenTransforming_matsimShipment2jspritShipment_isMadeCorrectly() { } @Test - public void whenTransforming_jspritShipment2matsimShipment_isMadeCorrectly() { + void whenTransforming_jspritShipment2matsimShipment_isMadeCorrectly() { Shipment shipment = Shipment.Builder.newInstance("shipmentId").addSizeDimension(0, 50) .setPickupLocation(Location.newInstance("PickupLocationId")).setPickupServiceTime(30.0) .setPickupTimeWindow( @@ -212,7 +212,7 @@ public void whenTransforming_jspritShipment2matsimShipment_isMadeCorrectly() { } @Test - public void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_routeStartMustBe15() { + void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_routeStartMustBe15() { ScheduledTour sTour = getMatsimServiceTour(); VehicleRoutingProblem vrp = getVehicleRoutingProblem(sTour); @@ -252,7 +252,7 @@ private VehicleImpl createJspritVehicle(CarrierVehicle vehicle) { } @Test - public void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_routeAndVehicleMustNotBeNull() { + void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_routeAndVehicleMustNotBeNull() { ScheduledTour sTour = getMatsimServiceTour(); VehicleRoutingProblem vehicleRoutingProblem = getVehicleRoutingProblem(sTour); VehicleRoute route = MatsimJspritFactory.createRoute(sTour, vehicleRoutingProblem); @@ -261,7 +261,7 @@ public void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_rout } @Test - public void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_vehicleMustHaveTheCorrectId() { + void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_vehicleMustHaveTheCorrectId() { ScheduledTour sTour = getMatsimServiceTour(); VehicleRoutingProblem vehicleRoutingProblem = getVehicleRoutingProblem(sTour); VehicleRoute route = MatsimJspritFactory.createRoute(sTour, vehicleRoutingProblem); @@ -269,7 +269,7 @@ public void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_vehi } @Test - public void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_earliestStartMustBe10() { + void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_earliestStartMustBe10() { ScheduledTour sTour = getMatsimServiceTour(); VehicleRoutingProblem vehicleRoutingProblem = getVehicleRoutingProblem(sTour); VehicleRoute route = MatsimJspritFactory.createRoute(sTour, vehicleRoutingProblem); @@ -277,7 +277,7 @@ public void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_earl } @Test - public void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_latestEndMustBe20() { + void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_latestEndMustBe20() { ScheduledTour sTour = getMatsimServiceTour(); VehicleRoutingProblem vehicleRoutingProblem = getVehicleRoutingProblem(sTour); VehicleRoute route = MatsimJspritFactory.createRoute(sTour, vehicleRoutingProblem); @@ -285,7 +285,7 @@ public void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_late } @Test - public void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_sizeOfTourMustBe2() { + void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_sizeOfTourMustBe2() { ScheduledTour sTour = getMatsimServiceTour(); VehicleRoutingProblem vehicleRoutingProblem = getVehicleRoutingProblem(sTour); VehicleRoute route = MatsimJspritFactory.createRoute(sTour, vehicleRoutingProblem); @@ -293,7 +293,7 @@ public void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_size } @Test - public void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_firstActIdMustBeCorrect() { + void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_firstActIdMustBeCorrect() { ScheduledTour sTour = getMatsimServiceTour(); VehicleRoutingProblem vehicleRoutingProblem = getVehicleRoutingProblem(sTour); VehicleRoute route = MatsimJspritFactory.createRoute(sTour, vehicleRoutingProblem); @@ -301,7 +301,7 @@ public void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_firs } @Test - public void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_secondActIdMustBeCorrect() { + void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_secondActIdMustBeCorrect() { ScheduledTour sTour = getMatsimServiceTour(); VehicleRoutingProblem vehicleRoutingProblem = getVehicleRoutingProblem(sTour); VehicleRoute route = MatsimJspritFactory.createRoute(sTour, vehicleRoutingProblem); @@ -309,7 +309,7 @@ public void whenTransforming_matsimScheduledTourWithServiceAct2vehicleRoute_seco } @Test - public void whenTransforming_matsimPlan2vehicleRouteSolution_itIsMadeCorrectly() { + void whenTransforming_matsimPlan2vehicleRouteSolution_itIsMadeCorrectly() { List sTours = new ArrayList(); ScheduledTour matsimTour = getMatsimTour("matsimVehicle"); sTours.add(matsimTour); @@ -404,12 +404,12 @@ private CarrierShipment getMatsimShipment(String id, String from, String to, int } @Test - public void createVehicleRoutingProblemWithServices_isMadeCorrectly() { + void createVehicleRoutingProblemWithServices_isMadeCorrectly() { // TODO create } @Test - public void createVehicleRoutingProblemBuilderWithServices_isMadeCorrectly() { + void createVehicleRoutingProblemBuilderWithServices_isMadeCorrectly() { Carrier carrier = createCarrierWithServices(); Network network = NetworkUtils.createNetwork(); new MatsimNetworkReader(network).readFile(testUtils.getClassInputDirectory() + "grid-network.xml"); @@ -456,13 +456,13 @@ public void createVehicleRoutingProblemBuilderWithServices_isMadeCorrectly() { } @Test - public void createVehicleRoutingProblemWithShipments_isMadeCorrectly() { + void createVehicleRoutingProblemWithShipments_isMadeCorrectly() { // TODO create } + // @Ignore //Set to ignore due to not implemented functionality of Shipments in MatsimJspritFactory @Test -// @Ignore //Set to ignore due to not implemented functionality of Shipments in MatsimJspritFactory - public void createVehicleRoutingProblemBuilderWithShipments_isMadeCorrectly() { + void createVehicleRoutingProblemBuilderWithShipments_isMadeCorrectly() { Carrier carrier = createCarrierWithShipments(); Network network = NetworkUtils.createNetwork(); new MatsimNetworkReader(network).readFile(testUtils.getClassInputDirectory() + "grid-network.xml"); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/NetworkBasedTransportCostsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/NetworkBasedTransportCostsTest.java index bc8bc2d0e81..b1c1e3a83f5 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/NetworkBasedTransportCostsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/NetworkBasedTransportCostsTest.java @@ -25,8 +25,8 @@ import com.graphhopper.jsprit.core.problem.driver.Driver; import com.graphhopper.jsprit.core.problem.vehicle.Vehicle; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; @@ -51,7 +51,7 @@ public class NetworkBasedTransportCostsTest { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void test_whenAddingTwoDifferentVehicleTypes_itMustAccountForThem(){ + void test_whenAddingTwoDifferentVehicleTypes_itMustAccountForThem(){ Config config = new Config(); config.addCoreModules(); Scenario scenario = ScenarioUtils.createScenario(config); @@ -85,7 +85,7 @@ public void test_whenAddingTwoDifferentVehicleTypes_itMustAccountForThem(){ } @Test - public void test_whenVehicleTypeNotKnow_throwException(){ + void test_whenVehicleTypeNotKnow_throwException(){ Config config = new Config(); config.addCoreModules(); Scenario scenario = ScenarioUtils.createScenario(config); @@ -113,7 +113,7 @@ public void test_whenVehicleTypeNotKnow_throwException(){ } @Test - public void test_whenAddingTwoVehicleTypesViaConstructor_itMustAccountForThat(){ + void test_whenAddingTwoVehicleTypesViaConstructor_itMustAccountForThat(){ Config config = new Config(); config.addCoreModules(); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java index 41f746ec87a..ed4ab348dd4 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java @@ -27,8 +27,8 @@ import com.graphhopper.jsprit.core.reporting.SolutionPrinter; import com.graphhopper.jsprit.core.util.Solutions; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -46,7 +46,7 @@ public class SkillsIT { private final Id carrierLocation = Id.createLinkId("i(1,0)"); @Test - public void testJspritWithDifferentSkillsRequired() { + void testJspritWithDifferentSkillsRequired() { /* First test with different skills. */ Scenario scenario = setupTestScenario(); addShipmentsRequiringDifferentSkills(scenario); @@ -62,7 +62,7 @@ public void testJspritWithDifferentSkillsRequired() { } @Test - public void testJspritWithSameSkillsRequired(){ + void testJspritWithSameSkillsRequired(){ /* Test with same skills. */ Scenario scenario = setupTestScenario(); addShipmentsRequiringSameSkills(scenario); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunChessboardIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunChessboardIT.java index eb884308c2c..f93f457f58e 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunChessboardIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunChessboardIT.java @@ -22,8 +22,8 @@ package org.matsim.freight.carriers.usecases.chessboard; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; import org.matsim.core.events.EventsUtils; @@ -39,7 +39,7 @@ public class RunChessboardIT { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public void runChessboard() { + void runChessboard() { String [] args = { IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "freight-chessboard-9x9" ), "config.xml" ).toString() , "--config:controler.outputDirectory", utils.getOutputDirectory() , "--config:controler.lastIteration", "1" diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunPassengerAlongWithCarriersIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunPassengerAlongWithCarriersIT.java index 4fdfd06b0fb..82e0f4a99e6 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunPassengerAlongWithCarriersIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunPassengerAlongWithCarriersIT.java @@ -22,8 +22,8 @@ package org.matsim.freight.carriers.usecases.chessboard; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.testcases.MatsimTestUtils; @@ -32,8 +32,8 @@ public class RunPassengerAlongWithCarriersIT { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils() ; - @Test - public void runChessboard() { + @Test + void runChessboard() { try{ RunPassengerAlongWithCarriers abc = new RunPassengerAlongWithCarriers(); // --- diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsIT.java index d297d904034..1c19c0cde0d 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsIT.java @@ -28,8 +28,8 @@ import com.graphhopper.jsprit.core.util.Solutions; import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -178,7 +178,7 @@ public void setUp() { @Test - public void numberOfToursIsCorrect() { + void numberOfToursIsCorrect() { Assert.assertEquals(2, carrierWServices.getSelectedPlan().getScheduledTours().size()); Assert.assertEquals(1, carrierWShipments.getSelectedPlan().getScheduledTours().size()); Assert.assertEquals(1, carrierWShipmentsOnlyFromCarrierWServices.getSelectedPlan().getScheduledTours().size()); @@ -190,7 +190,7 @@ public void numberOfToursIsCorrect() { * TODO Calculation of tour distance and duration are commented out, because ...tour.getEnd() has no values -> need for fixing in NetworkRouter or somewhere else kmt/okt18 */ @Test - public void toursInitialCarrierWServicesIsCorrect() { + void toursInitialCarrierWServicesIsCorrect() { Assert.assertEquals(-270.462, carrierWServices.getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); //Note: In score waiting and serviceDurationTime are not includes by now -> May fail, when fixed. KMT Okt/18 // double tourDurationSum = 0; // for (ScheduledTour scheduledTour: carrierWServices.getSelectedPlan().getScheduledTours()){ @@ -212,7 +212,7 @@ public void toursInitialCarrierWServicesIsCorrect() { * TODO Calculation of tour distance and duration are commented out, because ...tour.getEnd() has no values -> need for fixing in NetworkRouter or somewhere else kmt/okt18 */ @Test - public void toursInitialCarrierWShipmentsIsCorrect() { + void toursInitialCarrierWShipmentsIsCorrect() { Assert.assertEquals(-136.87, carrierWShipments.getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); //Note: In score waiting and serviceDurationTime are not includes by now -> May fail, when fixed. KMT Okt/18 // double tourDurationSum = 0; @@ -236,7 +236,7 @@ public void toursInitialCarrierWShipmentsIsCorrect() { * TODO Calculation of tour distance and duration are commented out, because ...tour.getEnd() has no values -> need for fixing in NetworkRouter or somewhere else kmt/okt18 */ @Test - public void toursCarrierWShipmentsOnlyFromCarrierWServicesIsCorrect() { + void toursCarrierWShipmentsOnlyFromCarrierWServicesIsCorrect() { Assert.assertEquals(-140.462, carrierWShipmentsOnlyFromCarrierWServices.getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); //Note: In score waiting and serviceDurationTime are not includes by now -> May fail, when fixed. KMT Okt/18 // double tourDurationSum = 0; @@ -262,7 +262,7 @@ public void toursCarrierWShipmentsOnlyFromCarrierWServicesIsCorrect() { * TODO Calculation of tour distance and duration are commented out, because ...tour.getEnd() has no values -> need for fixing in NetworkRouter or somewhere else kmt/okt18 */ @Test - public void toursCarrierWShipmentsOnlyFromCarrierWShipmentsIsCorrect() { + void toursCarrierWShipmentsOnlyFromCarrierWShipmentsIsCorrect() { Assert.assertEquals(-136.87, carrierWShipmentsOnlyFromCarrierWShipments.getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); //Note: In score waiting and serviceDurationTime are not includes by now -> May fail, when fixed. KMT Okt/18 // double tourDurationSum = 0; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java index 4253b81d269..7465db5d3d8 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java @@ -21,6 +21,8 @@ package org.matsim.freight.carriers.utils; +import static org.junit.jupiter.api.Assertions.assertThrows; + import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm; import com.graphhopper.jsprit.core.algorithm.box.SchrimpfFactory; import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; @@ -30,8 +32,8 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -164,8 +166,9 @@ public void setUp() { } - @Test //Should only have Services - public void numberOfInitalServicesIsCorrect() { + //Should only have Services + @Test + void numberOfInitalServicesIsCorrect() { Assert.assertEquals(2, carrierWServices.getServices().size()); int demandServices = 0; @@ -177,8 +180,9 @@ public void numberOfInitalServicesIsCorrect() { Assert.assertEquals(0, carrierWServices.getShipments().size()); } - @Test //Should only have Shipments - public void numberOfInitialShipmentsIsCorrect() { + //Should only have Shipments + @Test + void numberOfInitialShipmentsIsCorrect() { Assert.assertEquals(0, carrierWShipments.getServices().size()); Assert.assertEquals(2, carrierWShipments.getShipments().size()); @@ -190,7 +194,7 @@ public void numberOfInitialShipmentsIsCorrect() { } @Test - public void numberOfShipmentsFromCopiedShipmentsIsCorrect() { + void numberOfShipmentsFromCopiedShipmentsIsCorrect() { Assert.assertEquals(0, carrierWShipmentsOnlyFromCarrierWShipments.getServices().size()); Assert.assertEquals(2, carrierWShipmentsOnlyFromCarrierWShipments.getShipments().size()); @@ -202,7 +206,7 @@ public void numberOfShipmentsFromCopiedShipmentsIsCorrect() { } @Test - public void numberOfShipmentsFromConvertedServicesIsCorrect() { + void numberOfShipmentsFromConvertedServicesIsCorrect() { Assert.assertEquals(0, carrierWShipmentsOnlyFromCarrierWServices.getServices().size()); Assert.assertEquals(2, carrierWShipmentsOnlyFromCarrierWServices.getShipments().size()); @@ -214,7 +218,7 @@ public void numberOfShipmentsFromConvertedServicesIsCorrect() { } @Test - public void fleetAvailableAfterConvertingIsCorrect() { + void fleetAvailableAfterConvertingIsCorrect() { Assert.assertEquals(FleetSize.INFINITE, carrierWShipmentsOnlyFromCarrierWServices.getCarrierCapabilities().getFleetSize()); Assert.assertEquals(1, carrierWShipmentsOnlyFromCarrierWServices.getCarrierCapabilities().getVehicleTypes().size()); for ( VehicleType carrierVehicleType : carrierWShipmentsOnlyFromCarrierWServices.getCarrierCapabilities().getVehicleTypes()){ @@ -240,7 +244,7 @@ public void fleetAvailableAfterConvertingIsCorrect() { } @Test - public void copiingOfShipmentsIsDoneCorrectly() { + void copiingOfShipmentsIsDoneCorrectly() { boolean foundShipment1 = false; boolean foundShipment2 = false; CarrierShipment carrierShipment1 = CarriersUtils.getShipment(carrierWShipmentsOnlyFromCarrierWShipments, Id.create("shipment1", CarrierShipment.class)); @@ -279,7 +283,7 @@ public void copiingOfShipmentsIsDoneCorrectly() { @Test - public void convertionOfServicesIsDoneCorrectly() { + void convertionOfServicesIsDoneCorrectly() { boolean foundSercice1 = false; boolean foundService2 = false; CarrierShipment carrierShipment1 = CarriersUtils.getShipment(carrierWShipmentsOnlyFromCarrierWServices, Id.create("Service1", CarrierShipment.class)); @@ -314,22 +318,24 @@ public void convertionOfServicesIsDoneCorrectly() { Assert.assertTrue("Not found converted Service2 after converting", foundService2); } - /* Note: This test can be removed / modified when jsprit works properly with a combined Service and Shipment VRP. + /*Note: This test can be removed / modified when jsprit works properly with a combined Service and Shipment VRP. * Currently the capacity of the vehicle seems to be "ignored" in a way that the load within the tour is larger than the capacity; * Maybe it is because of the misunderstanding, that a Service is modeled as "Pickup" and not as thought before as "Delivery". KMT sep18 */ - @Test(expected=UnsupportedOperationException.class) - public void exceptionIsThrownWhenUsingMixedShipmentsAndServices() { - Carrier carrierMixedWServicesAndShipments = CarriersUtils.createCarrier(Id.create("CarrierMixed", Carrier.class ) ); - CarrierService service1 = createMatsimService("Service1", "i(3,9)", 2); - CarriersUtils.addService(carrierMixedWServicesAndShipments, service1); - CarrierShipment shipment1 = createMatsimShipment("shipment1", "i(1,0)", "i(7,6)R", 1); - CarriersUtils.addShipment(carrierMixedWServicesAndShipments, shipment1); - - Network network = NetworkUtils.createNetwork(); - new MatsimNetworkReader(network).readFile(testUtils.getPackageInputDirectory() + "grid-network.xml"); - - MatsimJspritFactory.createRoutingProblemBuilder(carrierMixedWServicesAndShipments, network); + @Test + void exceptionIsThrownWhenUsingMixedShipmentsAndServices() { + assertThrows(UnsupportedOperationException.class, () -> { + Carrier carrierMixedWServicesAndShipments = CarriersUtils.createCarrier(Id.create("CarrierMixed", Carrier.class)); + CarrierService service1 = createMatsimService("Service1", "i(3,9)", 2); + CarriersUtils.addService(carrierMixedWServicesAndShipments, service1); + CarrierShipment shipment1 = createMatsimShipment("shipment1", "i(1,0)", "i(7,6)R", 1); + CarriersUtils.addShipment(carrierMixedWServicesAndShipments, shipment1); + + Network network = NetworkUtils.createNetwork(); + new MatsimNetworkReader(network).readFile(testUtils.getPackageInputDirectory() + "grid-network.xml"); + + MatsimJspritFactory.createRoutingProblemBuilder(carrierMixedWServicesAndShipments, network); + }); } private static CarrierShipment createMatsimShipment(String id, String from, String to, int size) { @@ -361,7 +367,7 @@ private static CarrierService createMatsimService(String id, String to, int size } @Test - public void testAddVehicleTypeSkill(){ + void testAddVehicleTypeSkill(){ VehiclesFactory factory = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getVehicles().getFactory(); VehicleType type = factory.createVehicleType(Id.create("test", VehicleType.class)); Assert.assertFalse("Should not have skill.", CarriersUtils.hasSkill(type, "testSkill")); @@ -376,7 +382,7 @@ public void testAddVehicleTypeSkill(){ } @Test - public void testAddShipmentSkill(){ + void testAddShipmentSkill(){ CarrierShipment shipment = CarrierShipment.Builder.newInstance( Id.create("testShipment", CarrierShipment.class), Id.createLinkId("1"), Id.createLinkId("2"), 1) .build(); @@ -392,7 +398,7 @@ public void testAddShipmentSkill(){ } @Test - public void testAddServiceSkill(){ + void testAddServiceSkill(){ CarrierService service = CarrierService.Builder.newInstance( Id.create("testShipment", CarrierService.class), Id.createLinkId("2")) .build(); @@ -408,7 +414,7 @@ public void testAddServiceSkill(){ } @Test - public void testRunJsprit_allInformationGiven(){ + void testRunJsprit_allInformationGiven(){ Config config = prepareConfig(); config.controller().setOutputDirectory(utils.getOutputDirectory()); @@ -436,28 +442,30 @@ public void testRunJsprit_allInformationGiven(){ /** * This test should lead to an exception, because the NumberOfJspritIterations is not set for carriers. */ - @Test(expected = java.util.concurrent.ExecutionException.class) - public void testRunJsprit_NoOfJspritIterationsMissing() throws ExecutionException, InterruptedException { - Config config = prepareConfig(); - config.controller().setOutputDirectory(utils.getOutputDirectory()); - Scenario scenario = ScenarioUtils.loadScenario(config); - - CarriersUtils.loadCarriersAccordingToFreightConfig(scenario); - - //remove all attributes --> remove the NumberOfJspritIterations attribute to trigger exception - Carriers carriers = CarriersUtils.getCarriers(scenario); - for (Carrier carrier : carriers.getCarriers().values()) { - carrier.getAttributes().clear(); - } + @Test + void testRunJsprit_NoOfJspritIterationsMissing() throws ExecutionException, InterruptedException { + assertThrows(java.util.concurrent.ExecutionException.class, () -> { + Config config = prepareConfig(); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + Scenario scenario = ScenarioUtils.loadScenario(config); + + CarriersUtils.loadCarriersAccordingToFreightConfig(scenario); + + //remove all attributes --> remove the NumberOfJspritIterations attribute to trigger exception + Carriers carriers = CarriersUtils.getCarriers(scenario); + for (Carrier carrier : carriers.getCarriers().values()) { + carrier.getAttributes().clear(); + } - CarriersUtils.runJsprit(scenario); + CarriersUtils.runJsprit(scenario); + }); } /** * Don't crash even if there is no algortihm file specified. */ @Test - public void testRunJsprit_NoAlgortihmFileGiven(){ + void testRunJsprit_NoAlgortihmFileGiven(){ Config config = prepareConfig(); config.controller().setOutputDirectory(utils.getOutputDirectory()); Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiverCostAllocationFixedTest.java b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiverCostAllocationFixedTest.java index 6d9cbae17cb..bdb2f256853 100644 --- a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiverCostAllocationFixedTest.java +++ b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiverCostAllocationFixedTest.java @@ -1,13 +1,13 @@ package org.matsim.contrib.freightreceiver; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.testcases.MatsimTestUtils; public class ReceiverCostAllocationFixedTest { @Test - public void getScore() { + void getScore() { Assert.assertEquals("Wrong cost.", -20.0, new ReceiverCostAllocationFixed(20.0).getScore(null, null), MatsimTestUtils.EPSILON); } } diff --git a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiverPlanTest.java b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiverPlanTest.java index 7a7107f1ca0..7c3a1691412 100644 --- a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiverPlanTest.java +++ b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiverPlanTest.java @@ -17,17 +17,16 @@ * *********************************************************************** */ package org.matsim.contrib.freightreceiver; - +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.junit.Assert; -import org.junit.Test; public class ReceiverPlanTest { @Test - public void testBuilderTwo() { + void testBuilderTwo() { Receiver receiver = ReceiverUtils.newInstance( Id.create( "1", Receiver.class ) ); ReceiverPlan.Builder builder = ReceiverPlan.Builder.newInstance(receiver, true); ReceiverPlan plan = builder.build(); diff --git a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversReaderTest.java b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversReaderTest.java index 6568d0d0bdd..70112f0895f 100644 --- a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversReaderTest.java +++ b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversReaderTest.java @@ -21,8 +21,8 @@ package org.matsim.contrib.freightreceiver; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.freight.carriers.Carrier; import org.matsim.freight.carriers.TimeWindow; @@ -41,7 +41,7 @@ public class ReceiversReaderTest { * from the original DFG code. */ @Test - public void testBasicV2(){ + void testBasicV2(){ Receivers receivers = new Receivers(); try { new ReceiversReader(receivers).readFile(utils.getClassInputDirectory() + "receivers_v2_basic.xml"); @@ -59,7 +59,7 @@ public void testBasicV2(){ } @Test - public void testV2() { + void testV2() { Receivers receivers = new Receivers(); try { new ReceiversReader(receivers).readFile(utils.getClassInputDirectory() + "receivers_v2_full.xml"); diff --git a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversTest.java b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversTest.java index 9a1a34dd34a..ca5a5f02009 100644 --- a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversTest.java +++ b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversTest.java @@ -1,8 +1,8 @@ package org.matsim.contrib.freightreceiver; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.freightreceiver.run.chessboard.ReceiverChessboardScenario; @@ -22,8 +22,8 @@ public class ReceiversTest { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void testSetupReceivers() { + @Test + void testSetupReceivers() { try { @SuppressWarnings("unused") Receivers receivers = setupReceivers(); @@ -33,8 +33,8 @@ public void testSetupReceivers() { } } - @Test - public void getReceivers() { + @Test + void getReceivers() { Receivers receivers = setupReceivers(); Map, Receiver> map = receivers.getReceivers(); Assert.assertNotNull("Map must exist.", map); @@ -50,8 +50,8 @@ public void getReceivers() { } } - @Test - public void getReceiver() { + @Test + void getReceiver() { Receivers receivers = setupReceivers(); Receiver receiverExists = receivers.getReceiver(Id.create("1", Receiver.class)); Assert.assertNotNull("Should find receiver.", receiverExists); @@ -59,8 +59,8 @@ public void getReceiver() { Assert.assertNull("Should not find receiver.", receiverDoesNotExist); } - @Test - public void addReceiver() { + @Test + void addReceiver() { Receivers receivers = setupReceivers(); Assert.assertEquals("Wrong number of receivers.", 5, receivers.getReceivers().size()); @@ -74,8 +74,8 @@ public void addReceiver() { /*TODO Should we maybe check if a receiver is NOT overwritten? */ } - @Test - public void createAndAddProductType() { + @Test + void createAndAddProductType() { Receivers receivers = setupReceivers(); Assert.assertEquals("Wrong number of product types.", 2, receivers.getAllProductTypes().size()); @@ -84,8 +84,8 @@ public void createAndAddProductType() { Assert.assertTrue("Should contain new product types", receivers.getAllProductTypes().contains(test)); } - @Test - public void getProductType() { + @Test + void getProductType() { Receivers receivers = setupReceivers(); try { ProductType p1 = receivers.getProductType(Id.create("P1", ProductType.class)); @@ -103,8 +103,8 @@ public void getProductType() { } } - @Test - public void getAllProductTypes() { + @Test + void getAllProductTypes() { Receivers receivers = setupReceivers(); Collection types = receivers.getAllProductTypes(); Assert.assertNotNull("Must have product types.", types); @@ -124,8 +124,8 @@ public void getAllProductTypes() { Assert.assertEquals("Wrong capacity", 2.0, p2.getRequiredCapacity(), MatsimTestUtils.EPSILON); } - @Test - public void getAttributes() { + @Test + void getAttributes() { Receivers receivers = setupReceivers(); Assert.assertNotNull("Should find attributed.", receivers.getAttributes()); Assert.assertEquals("Wrong number of attributes.", 0, receivers.getAttributes().size()); @@ -134,16 +134,16 @@ public void getAttributes() { Assert.assertEquals("Wrong number of attributes.", 1, receivers.getAttributes().size()); } - @Test - public void setDescription() { + @Test + void setDescription() { Receivers receivers = setupReceivers(); Assert.assertEquals("Wrong description.", "Chessboard", receivers.getDescription()); receivers.setDescription("Dummy"); Assert.assertEquals("Wrong description.", "Dummy", receivers.getDescription()); } - @Test - public void getDescription() { + @Test + void getDescription() { Receivers receivers = setupReceivers(); Assert.assertEquals("Wrong description.", "Chessboard", receivers.getDescription()); } diff --git a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversWriterTest.java b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversWriterTest.java index aba05df627e..972ebf6e200 100644 --- a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversWriterTest.java +++ b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversWriterTest.java @@ -21,8 +21,8 @@ package org.matsim.contrib.freightreceiver; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.freightreceiver.run.chessboard.ReceiverChessboardScenario; import org.matsim.testcases.MatsimTestUtils; @@ -36,7 +36,7 @@ public class ReceiversWriterTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testV1() { + void testV1() { Scenario sc = ReceiverChessboardScenario.createChessboardScenario(1L, 5, utils.getOutputDirectory(), false ); ReceiverUtils.getReceivers(sc).getAttributes().putAttribute("date", new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format( Calendar.getInstance().getTime())); @@ -53,7 +53,7 @@ public void testV1() { } @Test - public void testV2() { + void testV2() { Scenario sc = ReceiverChessboardScenario.createChessboardScenario(1L, 5, utils.getOutputDirectory(), false ); ReceiverUtils.getReceivers(sc).getAttributes().putAttribute("date", new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format( Calendar.getInstance().getTime())); diff --git a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/SSReorderPolicyTest.java b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/SSReorderPolicyTest.java index 681b4f28777..9f51534e124 100644 --- a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/SSReorderPolicyTest.java +++ b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/SSReorderPolicyTest.java @@ -22,13 +22,13 @@ import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.testcases.MatsimTestUtils; public class SSReorderPolicyTest { @Test - public void testCalculateOrderQuantity() { + void testCalculateOrderQuantity() { ReorderPolicy policy = ReceiverUtils.createSSReorderPolicy(5.0, 10.0); Assert.assertEquals("Wrong reorder quantity", 0.0, policy.calculateOrderQuantity(6.0), MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong reorder quantity", 5.0, policy.calculateOrderQuantity(5.0), MatsimTestUtils.EPSILON); diff --git a/contribs/hybridsim/src/test/java/org/matsim/contrib/hybridsim/utils/IdIntMapperTest.java b/contribs/hybridsim/src/test/java/org/matsim/contrib/hybridsim/utils/IdIntMapperTest.java index 42bc58a0635..fad773395d3 100644 --- a/contribs/hybridsim/src/test/java/org/matsim/contrib/hybridsim/utils/IdIntMapperTest.java +++ b/contribs/hybridsim/src/test/java/org/matsim/contrib/hybridsim/utils/IdIntMapperTest.java @@ -15,7 +15,7 @@ import org.junit.After; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Node; @@ -43,8 +43,8 @@ public void tearDown() { this.mapper = null; } - @Test - public void testLinkIdIntMapper() { + @Test + void testLinkIdIntMapper() { int id1 = mapper.getIntLink(Id.createLinkId("l1")); assertThat(id1, is(0)); mapper.getIntLink(Id.createLinkId("l2")); @@ -55,8 +55,8 @@ public void testLinkIdIntMapper() { assertThat(id3, is(2)); } - @Test - public void testIntLinkIdMapper() { + @Test + void testIntLinkIdMapper() { Id linkId1 = mapper.getLinkId(10); assertThat(linkId1, is(nullValue())); mapper.getIntLink(Id.createLinkId("l1")); @@ -65,8 +65,8 @@ public void testIntLinkIdMapper() { } - @Test - public void testNodeIdIntMapper() { + @Test + void testNodeIdIntMapper() { int id1 = mapper.getIntNode(Id.createNodeId("l1")); assertThat(id1, is(0)); mapper.getIntNode(Id.createNodeId("l2")); @@ -77,8 +77,8 @@ public void testNodeIdIntMapper() { assertThat(id3, is(2)); } - @Test - public void testIntNodeIdMapper() { + @Test + void testIntNodeIdMapper() { Id nodeId1 = mapper.getNodeId(10); assertThat(nodeId1, is(nullValue())); mapper.getIntNode(Id.createNodeId("l1")); @@ -88,8 +88,8 @@ public void testIntNodeIdMapper() { } - @Test - public void testPersonIdIntMapper() throws Exception { + @Test + void testPersonIdIntMapper() throws Exception { int id1 = mapper.getIntPerson(Id.createPersonId("l1")); assertThat(id1, is(0)); mapper.getIntPerson(Id.createPersonId("l2")); @@ -100,8 +100,8 @@ public void testPersonIdIntMapper() throws Exception { assertThat(id3, is(2)); } - @Test - public void testIntPersonIdMapper() throws Exception { + @Test + void testIntPersonIdMapper() throws Exception { Id personId1 = mapper.getPersonId(10); assertThat(personId1, is(nullValue())); mapper.getIntPerson(Id.createPersonId("l1")); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/EstimateRouterTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/EstimateRouterTest.java index 0b192d3bb83..fae4abb3ab1 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/EstimateRouterTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/EstimateRouterTest.java @@ -2,8 +2,8 @@ import com.google.inject.Injector; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -42,7 +42,7 @@ public void setUp() throws Exception { } @Test - public void routing() { + void routing() { Map, ? extends Person> persons = controler.getScenario().getPopulation().getPersons(); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ModeChoiceWeightSchedulerTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ModeChoiceWeightSchedulerTest.java index b7a4d6cd386..4d9910b96bf 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ModeChoiceWeightSchedulerTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ModeChoiceWeightSchedulerTest.java @@ -1,7 +1,7 @@ package org.matsim.modechoice; import org.assertj.core.data.Offset; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.config.ConfigUtils; import org.matsim.core.controler.MatsimServices; import org.matsim.core.controler.events.IterationStartsEvent; @@ -12,7 +12,7 @@ public class ModeChoiceWeightSchedulerTest extends ScenarioTest { @Test - public void linear() { + void linear() { controler.getConfig().controller().setLastIteration(100); InformedModeChoiceConfigGroup imc = ConfigUtils.addOrGetModule(controler.getConfig(), InformedModeChoiceConfigGroup.class); @@ -38,7 +38,7 @@ public void linear() { } @Test - public void quadratic() { + void quadratic() { controler.getConfig().controller().setLastIteration(101); InformedModeChoiceConfigGroup imc = ConfigUtils.addOrGetModule(controler.getConfig(), InformedModeChoiceConfigGroup.class); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/commands/GenerateChoiceSetTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/commands/GenerateChoiceSetTest.java index f166bae8767..f94cd3f0c2d 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/commands/GenerateChoiceSetTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/commands/GenerateChoiceSetTest.java @@ -1,7 +1,7 @@ package org.matsim.modechoice.commands; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; import org.matsim.modechoice.TestScenario; @@ -17,7 +17,7 @@ public class GenerateChoiceSetTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void command() throws URISyntaxException { + void command() throws URISyntaxException { Path out = Path.of(utils.getOutputDirectory()); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedMassConservationConstraintTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedMassConservationConstraintTest.java index ea1120653c7..abd2614acbb 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedMassConservationConstraintTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedMassConservationConstraintTest.java @@ -1,7 +1,7 @@ package org.matsim.modechoice.constraints; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -30,7 +30,7 @@ public void setUp() throws Exception { @Test - public void cycle() { + void cycle() { Person person = f.createPerson(Id.createPersonId(0)); @@ -75,7 +75,7 @@ public void cycle() { } @Test - public void open() { + void open() { Person person = f.createPerson(Id.createPersonId(0)); @@ -101,7 +101,7 @@ public void open() { } @Test - public void openEnd() { + void openEnd() { Person person = f.createPerson(Id.createPersonId(0)); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedSubtourConstraintTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedSubtourConstraintTest.java index 04e889ca2ed..30153229e58 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedSubtourConstraintTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedSubtourConstraintTest.java @@ -1,7 +1,7 @@ package org.matsim.modechoice.constraints; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -33,7 +33,7 @@ public void setUp() throws Exception { } @Test - public void cycle() { + void cycle() { Person person = f.createPerson(Id.createPersonId(0)); @@ -75,7 +75,7 @@ public void cycle() { } @Test - public void open() { + void open() { Person person = f.createPerson(Id.createPersonId(0)); @@ -101,7 +101,7 @@ public void open() { } @Test - public void openEnd() { + void openEnd() { Person person = f.createPerson(Id.createPersonId(0)); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/estimators/ComplexEstimatorTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/estimators/ComplexEstimatorTest.java index 497e69a631c..ae9bcfc238e 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/estimators/ComplexEstimatorTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/estimators/ComplexEstimatorTest.java @@ -1,7 +1,7 @@ package org.matsim.modechoice.estimators; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.application.MATSimApplication; import org.matsim.core.config.Config; import org.matsim.core.controler.Controler; @@ -17,7 +17,7 @@ public class ComplexEstimatorTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void bindings() { + void bindings() { Config config = TestScenario.loadConfig(utils); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/estimators/DefaultActivityEstimatorTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/estimators/DefaultActivityEstimatorTest.java index 5ca25cf9a3d..53ba481d56c 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/estimators/DefaultActivityEstimatorTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/estimators/DefaultActivityEstimatorTest.java @@ -1,7 +1,7 @@ package org.matsim.modechoice.estimators; import org.assertj.core.data.Offset; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Person; import org.matsim.core.router.TripStructureUtils; @@ -19,7 +19,7 @@ public class DefaultActivityEstimatorTest extends ScenarioTest { @Test - public void person() { + void person() { ScoringParametersForPerson p = injector.getInstance(ScoringParametersForPerson.class); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/MultinomialLogitSelectorTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/MultinomialLogitSelectorTest.java index 2cc40d188ce..44658a957bb 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/MultinomialLogitSelectorTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/MultinomialLogitSelectorTest.java @@ -2,7 +2,7 @@ import org.assertj.core.data.Offset; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.modechoice.PlanCandidate; import java.util.List; @@ -22,7 +22,7 @@ public void setUp() throws Exception { } @Test - public void selection() { + void selection() { List candidates = List.of( new PlanCandidate(new String[]{"car"}, -1), @@ -62,7 +62,7 @@ public void selection() { } @Test - public void invariance() { + void invariance() { List candidates = List.of( new PlanCandidate(new String[]{"car"}, -1), @@ -99,7 +99,7 @@ public void invariance() { } @Test - public void best() { + void best() { selector = new MultinomialLogitSelector(0, new Random(0)); @@ -116,7 +116,7 @@ public void best() { } @Test - public void sameScore() { + void sameScore() { selector = new MultinomialLogitSelector(0.01, new Random(0)); @@ -132,7 +132,7 @@ public void sameScore() { } @Test - public void single() { + void single() { selector = new MultinomialLogitSelector(1, new Random(0)); @@ -148,7 +148,7 @@ public void single() { } @Test - public void precision() { + void precision() { selector = new MultinomialLogitSelector(0.01, new Random(0)); @@ -165,7 +165,7 @@ public void precision() { } @Test - public void inf() { + void inf() { selector = new MultinomialLogitSelector(10000, new Random(0)); @@ -184,7 +184,7 @@ public void inf() { } @Test - public void random() { + void random() { selector = new MultinomialLogitSelector(Double.POSITIVE_INFINITY, new Random(0)); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/RandomSubtourModeStrategyTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/RandomSubtourModeStrategyTest.java index 02ccaff9008..7103598e1a8 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/RandomSubtourModeStrategyTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/RandomSubtourModeStrategyTest.java @@ -2,7 +2,7 @@ import com.google.inject.Key; import com.google.inject.name.Names; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.population.Person; import org.matsim.core.controler.PrepareForMobsim; import org.matsim.core.replanning.PlanStrategy; @@ -18,7 +18,7 @@ protected String[] getArgs() { } @Test - public void person() { + void person() { PrepareForMobsim prepare = injector.getInstance(PrepareForMobsim.class); prepare.run(); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/SelectSingleTripModeStrategyTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/SelectSingleTripModeStrategyTest.java index 7ae3ffca08f..a421036bb16 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/SelectSingleTripModeStrategyTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/SelectSingleTripModeStrategyTest.java @@ -2,7 +2,7 @@ import com.google.inject.Key; import com.google.inject.name.Names; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.population.Person; import org.matsim.application.MATSimApplication; import org.matsim.core.config.Config; @@ -20,7 +20,7 @@ public class SelectSingleTripModeStrategyTest extends ScenarioTest { @Test - public void selectSingleTrip() { + void selectSingleTrip() { Config config = TestScenario.loadConfig(utils); @@ -42,7 +42,7 @@ public void selectSingleTrip() { } @Test - public void person() { + void person() { PlanStrategy strategy = injector.getInstance(Key.get(PlanStrategy.class, Names.named(InformedModeChoiceModule.SELECT_SINGLE_TRIP_MODE_STRATEGY))); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/SelectSubtourModeStrategyTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/SelectSubtourModeStrategyTest.java index d201dae0cfa..7536fe5f8de 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/SelectSubtourModeStrategyTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/SelectSubtourModeStrategyTest.java @@ -3,7 +3,7 @@ import com.google.inject.Key; import com.google.inject.name.Names; import org.assertj.core.data.Offset; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.Person; import org.matsim.core.controler.PrepareForMobsim; @@ -25,7 +25,7 @@ protected String[] getArgs() { } @Test - public void person() { + void person() { PrepareForMobsim prepare = injector.getInstance(PrepareForMobsim.class); prepare.run(); @@ -44,7 +44,7 @@ public void person() { } @Test - public void constraint() { + void constraint() { TopKChoicesGenerator generator = injector.getInstance(TopKChoicesGenerator.class); @@ -68,7 +68,7 @@ public void constraint() { } @Test - public void allowedModes() { + void allowedModes() { TopKChoicesGenerator generator = injector.getInstance(TopKChoicesGenerator.class); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/BestChoiceGeneratorTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/BestChoiceGeneratorTest.java index a1180f40a0a..1ea195cd8ad 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/BestChoiceGeneratorTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/BestChoiceGeneratorTest.java @@ -1,6 +1,6 @@ package org.matsim.modechoice.search; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.population.Person; import org.matsim.modechoice.PlanCandidate; import org.matsim.modechoice.PlanModel; @@ -14,7 +14,7 @@ public class BestChoiceGeneratorTest extends ScenarioTest { @Test - public void choices() { + void choices() { BestChoiceGenerator generator = injector.getInstance(BestChoiceGenerator.class); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/DifferentModesTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/DifferentModesTest.java index 6e363136228..d4ec3a62f36 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/DifferentModesTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/DifferentModesTest.java @@ -1,6 +1,6 @@ package org.matsim.modechoice.search; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.population.Person; import org.matsim.core.config.Config; import org.matsim.modechoice.PlanCandidate; @@ -17,7 +17,7 @@ public class DifferentModesTest extends ScenarioTest { @Test - public void topK() { + void topK() { group.setTopK(1024); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/ModeChoiceSearchTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/ModeChoiceSearchTest.java index 485d0535aaf..6c1ab6e7a7e 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/ModeChoiceSearchTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/ModeChoiceSearchTest.java @@ -1,7 +1,7 @@ package org.matsim.modechoice.search; import it.unimi.dsi.fastutil.doubles.DoubleIterator; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -9,7 +9,7 @@ public class ModeChoiceSearchTest { @Test - public void order() { + void order() { ModeChoiceSearch search = new ModeChoiceSearch(3, 3); @@ -43,7 +43,7 @@ public void order() { @Test - public void negative() { + void negative() { ModeChoiceSearch search = new ModeChoiceSearch(3, 3); @@ -68,7 +68,7 @@ public void negative() { @Test - public void nullValues() { + void nullValues() { ModeChoiceSearch search = new ModeChoiceSearch(3, 3); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/SingleTripChoicesGeneratorTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/SingleTripChoicesGeneratorTest.java index d10942e71f4..f9896ac0c2f 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/SingleTripChoicesGeneratorTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/SingleTripChoicesGeneratorTest.java @@ -1,6 +1,6 @@ package org.matsim.modechoice.search; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.Person; import org.matsim.modechoice.PlanCandidate; @@ -17,7 +17,7 @@ public class SingleTripChoicesGeneratorTest extends ScenarioTest { @Test - public void choices() { + void choices() { SingleTripChoicesGenerator generator = injector.getInstance(SingleTripChoicesGenerator.class); @@ -37,7 +37,7 @@ public void choices() { @Test - public void unavailable() { + void unavailable() { SingleTripChoicesGenerator generator = injector.getInstance(SingleTripChoicesGenerator.class); @@ -55,7 +55,7 @@ public void unavailable() { } @Test - public void subset() { + void subset() { SingleTripChoicesGenerator generator = injector.getInstance(SingleTripChoicesGenerator.class); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKChoicesGeneratorTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKChoicesGeneratorTest.java index 3a1ba610aea..e2a750f4214 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKChoicesGeneratorTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKChoicesGeneratorTest.java @@ -1,6 +1,6 @@ package org.matsim.modechoice.search; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Leg; import org.matsim.api.core.v01.population.Person; @@ -20,7 +20,7 @@ public class TopKChoicesGeneratorTest extends ScenarioTest { @Test - public void choices() { + void choices() { TopKChoicesGenerator generator = injector.getInstance(TopKChoicesGenerator.class); @@ -44,7 +44,7 @@ public void choices() { } @Test - public void person() { + void person() { TopKChoicesGenerator generator = injector.getInstance(TopKChoicesGenerator.class); @@ -59,7 +59,7 @@ public void person() { @Test - public void invariance() { + void invariance() { TopKChoicesGenerator generator = injector.getInstance(TopKChoicesGenerator.class); @@ -87,7 +87,7 @@ public void invariance() { } @Test - public void predefined() { + void predefined() { TopKChoicesGenerator generator = injector.getInstance(TopKChoicesGenerator.class); @@ -122,7 +122,7 @@ public void predefined() { } @Test - public void threshold() { + void threshold() { TopKChoicesGenerator generator = injector.getInstance(TopKChoicesGenerator.class); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java index 166a19d9aac..a32fc12df0c 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java @@ -6,8 +6,8 @@ import org.assertj.core.api.InstanceOfAssertFactories; import org.assertj.core.data.Offset; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.runner.RunWith; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -78,7 +78,7 @@ public void setUp() throws Exception { } @Test - public void minmax() { + void minmax() { Person person = create(); @@ -115,7 +115,7 @@ public void minmax() { } @Test - public void subset() { + void subset() { Person person = create(); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKSubtourGeneratorTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKSubtourGeneratorTest.java index cdb71445fb1..904fc57a7e9 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKSubtourGeneratorTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKSubtourGeneratorTest.java @@ -1,6 +1,6 @@ package org.matsim.modechoice.search; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.Person; import org.matsim.core.controler.PrepareForMobsim; @@ -18,7 +18,7 @@ public class TopKSubtourGeneratorTest extends ScenarioTest { @Test - public void subtours() { + void subtours() { // Subtours need mapped locations PrepareForMobsim prepare = injector.getInstance(PrepareForMobsim.class); diff --git a/contribs/integration/src/test/java/org/matsim/integration/daily/SomeDailyTest.java b/contribs/integration/src/test/java/org/matsim/integration/daily/SomeDailyTest.java index c37fca96283..2cf8b0c6d75 100644 --- a/contribs/integration/src/test/java/org/matsim/integration/daily/SomeDailyTest.java +++ b/contribs/integration/src/test/java/org/matsim/integration/daily/SomeDailyTest.java @@ -1,12 +1,12 @@ package org.matsim.integration.daily; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SomeDailyTest { @Test - public void doTest() { + void doTest() { System.out.println("RUN TEST DAILY"); System.out.println("available ram: " + (Runtime.getRuntime().maxMemory() / 1024/1024)); diff --git a/contribs/integration/src/test/java/org/matsim/integration/weekly/SomeWeeklyTest.java b/contribs/integration/src/test/java/org/matsim/integration/weekly/SomeWeeklyTest.java index 61d0673e8ed..87c4be20dac 100644 --- a/contribs/integration/src/test/java/org/matsim/integration/weekly/SomeWeeklyTest.java +++ b/contribs/integration/src/test/java/org/matsim/integration/weekly/SomeWeeklyTest.java @@ -1,11 +1,11 @@ package org.matsim.integration.weekly; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SomeWeeklyTest { @Test - public void doTest() { + void doTest() { System.out.println("RUN TEST WEEKLY"); System.out.println("available ram: " + (Runtime.getRuntime().maxMemory() / 1024/1024)); Assert.assertTrue(true); diff --git a/contribs/integration/src/test/java/org/matsim/integration/weekly/fundamentaldiagram/CreateAutomatedFDTest.java b/contribs/integration/src/test/java/org/matsim/integration/weekly/fundamentaldiagram/CreateAutomatedFDTest.java index 0a99e7e8054..a2bcc7ed20b 100644 --- a/contribs/integration/src/test/java/org/matsim/integration/weekly/fundamentaldiagram/CreateAutomatedFDTest.java +++ b/contribs/integration/src/test/java/org/matsim/integration/weekly/fundamentaldiagram/CreateAutomatedFDTest.java @@ -43,8 +43,8 @@ import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @@ -125,23 +125,23 @@ public static Collection createFds() { } @Test - public void fdsCarTruck(){ + void fdsCarTruck(){ this.travelModes = new String [] {"car","truck"}; run(false); } @Test - public void fdsCarBike(){ + void fdsCarBike(){ run(false); } @Test - public void fdsCarBikeFastCapacityUpdate(){ + void fdsCarBikeFastCapacityUpdate(){ run(true); } @Test - public void fdsCarOnly(){ + void fdsCarOnly(){ this.travelModes = new String [] {"car"}; run(false); } diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/BestReplyLocationChoicePlanStrategyTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/BestReplyLocationChoicePlanStrategyTest.java index a22dd55b20a..6a299b6d62d 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/BestReplyLocationChoicePlanStrategyTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/BestReplyLocationChoicePlanStrategyTest.java @@ -19,9 +19,8 @@ * *********************************************************************** */ package org.matsim.contrib.locationchoice; - +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; import org.matsim.core.replanning.ReplanningContext; @@ -41,7 +40,7 @@ public class BestReplyLocationChoicePlanStrategyTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testOne() { + void testOne() { // Config config = ConfigUtils.loadConfig(this.utils.getPackageInputDirectory() + "config.xml"); // Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java index 3ef0156f7dc..3ea1d36e21b 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java @@ -23,9 +23,8 @@ import static org.junit.Assert.*; import jakarta.inject.Provider; - +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -77,12 +76,12 @@ public class LocationChoiceIT { private MatsimTestUtils utils = new MatsimTestUtils(); - /** * This is, as far as I can see, testing the {@link LocationChoicePlanStrategy}. It will use the algo from the config, which is "random". It is thus not using the frozen * epsilon approach. kai, mar'19 */ - @Test public void testLocationChoice() { + @Test + void testLocationChoice() { final Config config = localCreateConfig( utils.getPackageInputDirectory() + "config2.xml"); diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyIT.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyIT.java index e76efbcf390..b08315560aa 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyIT.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyIT.java @@ -1,7 +1,7 @@ package org.matsim.contrib.locationchoice.frozenepsilons; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -18,7 +18,7 @@ public class BestReplyIT { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testRunControler() { + void testRunControler() { // load chessboard scenario config: Config config = utils.loadConfig( IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("chessboard"), "config.xml"), diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FacilityPenaltyTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FacilityPenaltyTest.java index 6e89db73e30..eac967476eb 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FacilityPenaltyTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FacilityPenaltyTest.java @@ -4,21 +4,21 @@ import java.lang.reflect.Method; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contrib.locationchoice.DestinationChoiceConfigGroup; import org.matsim.testcases.MatsimTestUtils; public class FacilityPenaltyTest { @Test - public void testGetPenalty() { + void testGetPenalty() { FacilityPenalty facilitypenalty = new FacilityPenalty(0.0, new DestinationChoiceConfigGroup()); Assert.assertEquals(facilitypenalty.getCapacityPenaltyFactor(0.0, 1.0), 0.0, MatsimTestUtils.EPSILON); } @Test - public void testcalculateCapPenaltyFactor() throws SecurityException, NoSuchMethodException, IllegalArgumentException, - IllegalAccessException, InvocationTargetException { + void testcalculateCapPenaltyFactor() throws SecurityException, NoSuchMethodException, IllegalArgumentException, + IllegalAccessException, InvocationTargetException { FacilityPenalty facilitypenalty = new FacilityPenalty(0.0, new DestinationChoiceConfigGroup()); diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java index a09f75758c9..dbbac69569f 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java @@ -15,8 +15,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -91,7 +91,7 @@ public class FrozenEpsilonLocaChoiceIT{ * Confirmed: This tests fails when called AFTER BestReplyIT, michalm/mar'20 */ @Test - public void testLocationChoiceJan2013() { + void testLocationChoiceJan2013() { // CONFIG: final Config config = localCreateConfig( this.utils.getPackageInputDirectory() + "../config2.xml"); @@ -169,7 +169,7 @@ public void install() { } @Test - public void testLocationChoiceFeb2013NegativeScores() { + void testLocationChoiceFeb2013NegativeScores() { // config: final Config config = localCreateConfig( utils.getPackageInputDirectory() + "../config2.xml"); @@ -231,7 +231,8 @@ public void install() { enum RunType { shortRun, medRun, longRun } - @Test public void testFacilitiesAlongALine() { + @Test + void testFacilitiesAlongALine() { RunType runType = RunType.shortRun ; Config config = ConfigUtils.createConfig() ; switch( runType ) { diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/SamplerTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/SamplerTest.java index eee860fb1a1..268466e0215 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/SamplerTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/SamplerTest.java @@ -23,8 +23,8 @@ package org.matsim.contrib.locationchoice.frozenepsilons; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -53,8 +53,8 @@ public void setUp() throws Exception { this.context.init(); } - @Test - public void testSampler() { + @Test + void testSampler() { DestinationSampler sampler = new DestinationSampler( context.getPersonsKValuesArray(), context.getFacilitiesKValuesArray(), ConfigUtils.addOrGetModule( scenario.getConfig(), FrozenTastesConfigGroup.class ) ) ; assertTrue(sampler.sample(context.getFacilityIndex(Id.create(1, ActivityFacility.class)), context.getPersonIndex(Id.create(1, Person.class)))); diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/ScoringPenaltyTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/ScoringPenaltyTest.java index 43c0182c5fb..5a4ce413fb9 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/ScoringPenaltyTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/ScoringPenaltyTest.java @@ -1,14 +1,14 @@ package org.matsim.contrib.locationchoice.frozenepsilons; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contrib.locationchoice.DestinationChoiceConfigGroup; import org.matsim.testcases.MatsimTestUtils; public class ScoringPenaltyTest { @Test - public void testGetPenalty() { + void testGetPenalty() { FacilityPenalty facilityPenalty = new FacilityPenalty(0.0, new DestinationChoiceConfigGroup()); ScoringPenalty scoringpenalty = new ScoringPenalty(0.0, 1.0, facilityPenalty, 1.0); Assert.assertEquals(scoringpenalty.getPenalty(), 0.0, MatsimTestUtils.EPSILON); diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/LocationMutatorwChoiceSetTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/LocationMutatorwChoiceSetTest.java index 960cca8b706..c17601dbc4b 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/LocationMutatorwChoiceSetTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/LocationMutatorwChoiceSetTest.java @@ -24,8 +24,8 @@ import java.util.List; import java.util.Random; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -50,14 +50,16 @@ private RecursiveLocationMutator initialize() { return new RecursiveLocationMutator(scenario, initializer.getControler().getTripRouterProvider().get(), TimeInterpretation.create(initializer.getControler().getScenario().getConfig()), new Random(4711)); } - @Test public void testConstructor() { + @Test + void testConstructor() { RecursiveLocationMutator locationmutator = this.initialize(); assertEquals(locationmutator.getMaxRecursions(), 10); assertEquals(locationmutator.getRecursionTravelSpeedChange(), 0.1, MatsimTestUtils.EPSILON); } - @Test public void testHandlePlan() { + @Test + void testHandlePlan() { RecursiveLocationMutator locationmutator = this.initialize(); Plan plan = scenario.getPopulation().getPersons().get(Id.create("1", Person.class)).getSelectedPlan(); locationmutator.run(plan); @@ -65,7 +67,8 @@ private RecursiveLocationMutator initialize() { assertEquals(PopulationUtils.getNextLeg(((Plan) plan), PopulationUtils.getFirstActivity( ((Plan) plan) )).getRoute(), null); } - @Test public void testCalcActChains() { + @Test + void testCalcActChains() { RecursiveLocationMutator locationmutator = this.initialize(); Plan plan = scenario.getPopulation().getPersons().get(Id.create("1", Person.class)).getSelectedPlan(); List list = locationmutator.calcActChains(plan); diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/ManageSubchainsTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/ManageSubchainsTest.java index d1c4aa34efc..1085935abf6 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/ManageSubchainsTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/ManageSubchainsTest.java @@ -21,8 +21,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Leg; @@ -38,7 +38,8 @@ public class ManageSubchainsTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testPrimarySecondaryActivityFound() { + @Test + void testPrimarySecondaryActivityFound() { Initializer initializer = new Initializer(); initializer.init(utils); ManageSubchains manager = new ManageSubchains(); diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/RandomLocationMutatorTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/RandomLocationMutatorTest.java index 351ca1c1da1..0a19814e847 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/RandomLocationMutatorTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/RandomLocationMutatorTest.java @@ -21,8 +21,8 @@ import java.util.Random; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.contrib.locationchoice.Initializer; @@ -48,7 +48,8 @@ private RandomLocationMutator initialize() { /* * TODO: Construct scenario with knowledge to compare plans before and after loc. choice */ - @Test public void testHandlePlan() { + @Test + void testHandlePlan() { RandomLocationMutator randomlocationmutator = this.initialize(); randomlocationmutator.run(scenario.getPopulation().getPersons().get(Id.create("1", Person.class)).getSelectedPlan()); } diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/SubChainTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/SubChainTest.java index 16fccf1abd0..c13f5995a67 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/SubChainTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/SubChainTest.java @@ -2,8 +2,8 @@ import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; public class SubChainTest { @@ -12,7 +12,8 @@ public class SubChainTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testConstructorandGetSlActs() { + @Test + void testConstructorandGetSlActs() { SubChain subchain = new SubChain(); assertNotNull(subchain.getSlActs()); } diff --git a/contribs/locationchoice/src/test/java/org/matsim/core/router/BackwardFastMultiNodeTest.java b/contribs/locationchoice/src/test/java/org/matsim/core/router/BackwardFastMultiNodeTest.java index 844fdbe02ef..beb768be82e 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/core/router/BackwardFastMultiNodeTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/core/router/BackwardFastMultiNodeTest.java @@ -21,7 +21,7 @@ package org.matsim.core.router; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -48,7 +48,7 @@ public class BackwardFastMultiNodeTest { @Test - public void testBackwardsFastMultiNodeDijkstra_OneToOne() { + void testBackwardsFastMultiNodeDijkstra_OneToOne() { runTestBackwardsFastMultiNodeDijkstra_OneToOne(true); runTestBackwardsFastMultiNodeDijkstra_OneToOne(false); } @@ -113,7 +113,7 @@ private void runTestBackwardsFastMultiNodeDijkstra_OneToOne(boolean searchAllEnd * Search only cheapest to node. n5 should not be found. */ @Test - public void testBackwardsFastMultiNodeDijkstra_OneToMany() { + void testBackwardsFastMultiNodeDijkstra_OneToMany() { Config config = ConfigUtils.createConfig(); config.routing().setRoutingRandomness(0.); @@ -203,7 +203,7 @@ public void testBackwardsFastMultiNodeDijkstra_OneToMany() { } @Test - public void testBackwardsFastMultiNodeDijkstra_OneToMany_SearchAllNodes() { + void testBackwardsFastMultiNodeDijkstra_OneToMany_SearchAllNodes() { Config config = ConfigUtils.createConfig(); config.routing().setRoutingRandomness(0.); diff --git a/contribs/locationchoice/src/test/java/org/matsim/core/router/FastMultiNodeTest.java b/contribs/locationchoice/src/test/java/org/matsim/core/router/FastMultiNodeTest.java index 1dc5a2a4650..56c804c9cc9 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/core/router/FastMultiNodeTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/core/router/FastMultiNodeTest.java @@ -21,7 +21,7 @@ package org.matsim.core.router; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -50,7 +50,7 @@ public class FastMultiNodeTest { @Test - public void testFastMultiNodeDijkstra_OneToOne() { + void testFastMultiNodeDijkstra_OneToOne() { Config config = ConfigUtils.createConfig(); config.routing().setRoutingRandomness( 0. ); @@ -108,7 +108,7 @@ public void testFastMultiNodeDijkstra_OneToOne() { } @Test - public void testFastMultiNodeDijkstra_OneToMany() { + void testFastMultiNodeDijkstra_OneToMany() { Config config = ConfigUtils.createConfig(); config.routing().setRoutingRandomness( 0. ); @@ -199,7 +199,7 @@ public void testFastMultiNodeDijkstra_OneToMany() { } @Test - public void testFastMultiNodeDijkstra_OneToMany_SearchAllNodes() { + void testFastMultiNodeDijkstra_OneToMany_SearchAllNodes() { Config config = ConfigUtils.createConfig(); config.routing().setRoutingRandomness( 0. ); diff --git a/contribs/locationchoice/src/test/java/org/matsim/core/router/MultiNodeDijkstraTest.java b/contribs/locationchoice/src/test/java/org/matsim/core/router/MultiNodeDijkstraTest.java index 4dc03887cdd..283b90b0218 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/core/router/MultiNodeDijkstraTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/core/router/MultiNodeDijkstraTest.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -56,9 +56,9 @@ private MultiNodeDijkstra makeMultiNodeDikstra(Network network, TravelDisutility return (MultiNodeDijkstra) new FastMultiNodeDijkstraFactory().createPathCalculator(network, travelDisutility, travelTime); } else return (MultiNodeDijkstra) new MultiNodeDijkstraFactory().createPathCalculator(network, travelDisutility, travelTime); } - + @Test - public void testMultipleStarts() { + void testMultipleStarts() { testMultipleStarts(true); testMultipleStarts(false); } @@ -116,7 +116,7 @@ public void testMultipleStarts(boolean fastRouter) { } @Test - public void testMultipleEnds() { + void testMultipleEnds() { testMultipleEnds(true); testMultipleEnds(false); } @@ -174,7 +174,7 @@ public void testMultipleEnds(boolean fastRouter) { } @Test - public void testMultipleStartsAndEnds() { + void testMultipleStartsAndEnds() { testMultipleStartsAndEnds(true); testMultipleStartsAndEnds(false); } @@ -235,7 +235,7 @@ public void testMultipleStartsAndEnds(boolean fastRouter) { } @Test - public void testStartViaFaster() { + void testStartViaFaster() { testStartViaFaster(true); testStartViaFaster(false); } @@ -278,7 +278,7 @@ public void testStartViaFaster(boolean fastRouter) { } @Test - public void testEndViaFaster() { + void testEndViaFaster() { testEndViaFaster(true); testEndViaFaster(false); } @@ -323,7 +323,7 @@ public void testEndViaFaster(boolean fastRouter) { } @Test - public void testOnlyFromToSameNode() { + void testOnlyFromToSameNode() { testOnlyFromToSameNode(true); testOnlyFromToSameNode(false); } @@ -358,7 +358,7 @@ public void testOnlyFromToSameNode(boolean fastRouter) { } @Test - public void testSameNodeInFromToSetCheapest() { + void testSameNodeInFromToSetCheapest() { testSameNodeInFromToSetCheapest(true); testSameNodeInFromToSetCheapest(false); } @@ -400,7 +400,7 @@ public void testSameNodeInFromToSetCheapest(boolean fastRouter) { } @Test - public void testSameNodeInFromToSetNotCheapest() { + void testSameNodeInFromToSetNotCheapest() { testSameNodeInFromToSetNotCheapest(true); testSameNodeInFromToSetNotCheapest(false); } @@ -443,7 +443,7 @@ public void testSameNodeInFromToSetNotCheapest(boolean fastRouter) { } @Test - public void testSomeEndNodesNotReachable() { + void testSomeEndNodesNotReachable() { testSomeEndNodesNotReachable(true); testSomeEndNodesNotReachable(false); } @@ -484,7 +484,7 @@ public void testSomeEndNodesNotReachable(boolean fastRouter) { } @Test - public void testSomeStartNodesNotUseable() { + void testSomeStartNodesNotUseable() { testSomeStartNodesNotUseable(true); testSomeStartNodesNotUseable(false); } @@ -525,7 +525,7 @@ public void testSomeStartNodesNotUseable(boolean fastRouter) { } @Test - public void testImpossibleRoute() { + void testImpossibleRoute() { testImpossibleRoute(true); testImpossibleRoute(false); } @@ -561,7 +561,7 @@ public void testImpossibleRoute(boolean fastRouter) { * account in the path. */ @Test - public void testInitialValuesCorrection() { + void testInitialValuesCorrection() { testInitialValuesCorrection(true); testInitialValuesCorrection(false); } diff --git a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java index b8529245eff..9f56650dc64 100644 --- a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java +++ b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java @@ -26,8 +26,8 @@ import java.io.IOException; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.jupiter.api.io.TempDir; import org.junit.rules.TemporaryFolder; import org.matsim.api.core.v01.Coord; @@ -66,7 +66,7 @@ public class MatrixBasedPtRouterIT { * the travel time computed by the PtMatrix are compared (should be equal). */ @Test - public void testIntegration() throws IOException { + void testIntegration() throws IOException { String path = utils.getOutputDirectory(); diff --git a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java index 9296f93e9ef..39a0ba2fa6c 100644 --- a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java +++ b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java @@ -31,8 +31,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.jupiter.api.io.TempDir; import org.junit.rules.TemporaryFolder; import org.matsim.api.core.v01.Coord; @@ -89,7 +89,7 @@ public void setUp() throws Exception { * @throws IOException */ @Test - public void testPtMatrixStops() throws IOException{ + void testPtMatrixStops() throws IOException{ log.info("Start testing the pt matrix with information about the pt stops."); long start = System.currentTimeMillis(); @@ -192,7 +192,7 @@ else if( (origin + 1) % 4 == destination || (origin + 3) % 4 == destination){ * @throws IOException */ @Test - public void testPtMatrixTimesAndDistances() throws IOException{ + void testPtMatrixTimesAndDistances() throws IOException{ log.info("Start testing the pt matrix with information about the pt stops, pt travel times and distances."); long start = System.currentTimeMillis(); diff --git a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/TestQuadTree.java b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/TestQuadTree.java index c9fc807c0de..fb284ae2911 100644 --- a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/TestQuadTree.java +++ b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/TestQuadTree.java @@ -26,8 +26,7 @@ import java.util.Iterator; import org.junit.Assert; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.collections.QuadTree; @@ -124,7 +123,7 @@ private void determineNearestPtStation(){ } @Test - public void test() { + void test() { TestQuadTree tc = new TestQuadTree(); tc.determineNearestPtStation(); } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/genericUtils/TerminusStopFinderTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/genericUtils/TerminusStopFinderTest.java index 4436fb790ae..9e13c9d134d 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/genericUtils/TerminusStopFinderTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/genericUtils/TerminusStopFinderTest.java @@ -20,8 +20,7 @@ package org.matsim.contrib.minibus.genericUtils; import java.util.ArrayList; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.core.config.ConfigUtils; import org.matsim.core.scenario.ScenarioUtils; @@ -42,9 +41,9 @@ public class TerminusStopFinderTest { TransitSchedule schedule; TransitScheduleFactory stopFactory; - + @Test - public void testFindSecondTerminusStop() { + void testFindSecondTerminusStop() { /* * straight line * diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/PControlerTestIT.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/PControlerTestIT.java index 7ea50ed1e8e..85b2ae5dc77 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/PControlerTestIT.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/PControlerTestIT.java @@ -25,8 +25,8 @@ import java.util.List; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.minibus.PConfigGroup; import org.matsim.contrib.minibus.hook.PModule; @@ -53,7 +53,7 @@ public class PControlerTestIT implements TabularFileHandler{ @Test - public final void testPControler() { + final void testPControler() { final String scenarioName = "corr_s1_0"; final int numberOfIterations = 10; diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java index 3c22dcac81e..e83d57955aa 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java @@ -26,8 +26,8 @@ import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.minibus.PConfigGroup; import org.matsim.contrib.minibus.hook.PModule; @@ -58,7 +58,7 @@ public class SubsidyContextTestIT implements TabularFileHandler { @Ignore @Test - public final void testDefaultPControler() { + final void testDefaultPControler() { Config config1 = ConfigUtils.loadConfig( utils.getClassInputDirectory() + "config.xml", new PConfigGroup() ) ; @@ -117,7 +117,7 @@ public final void testDefaultPControler() { @Ignore @Test - public final void testSubsidyPControler() { + final void testSubsidyPControler() { Config config2 = ConfigUtils.loadConfig( utils.getClassInputDirectory() + "config.xml", new PConfigGroup() ) ; diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyTestIT.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyTestIT.java index 33af461049a..07e2e05c0e7 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyTestIT.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyTestIT.java @@ -25,8 +25,8 @@ import java.util.List; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.minibus.PConfigGroup; import org.matsim.contrib.minibus.hook.PModule; @@ -54,7 +54,7 @@ public class SubsidyTestIT implements TabularFileHandler { private final ArrayList pStatsResults = new ArrayList<>(); @Test - public final void testSubsidyPControler() { + final void testSubsidyPControler() { Config config = ConfigUtils.loadConfig( utils.getClassInputDirectory() + "config.xml", new PConfigGroup() ) ; diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/EndRouteExtensionTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/EndRouteExtensionTest.java index d2a097f60bf..f0d42a75dd7 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/EndRouteExtensionTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/EndRouteExtensionTest.java @@ -20,8 +20,8 @@ package org.matsim.contrib.minibus.replanning; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.contrib.minibus.PConstants; import org.matsim.contrib.minibus.hook.Operator; import org.matsim.contrib.minibus.hook.PPlan; @@ -36,7 +36,7 @@ public class EndRouteExtensionTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public final void testRun() { + final void testRun() { Operator coop = PScenarioHelper.createCoop2111to2333(); @@ -98,7 +98,7 @@ public final void testRun() { } @Test - public final void testRunVShapedRoute() { + final void testRunVShapedRoute() { Operator coop = PScenarioHelper.createCoopRouteVShaped(); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomEndTimeAllocatorTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomEndTimeAllocatorTest.java index af6b404c1a2..dfae9e35570 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomEndTimeAllocatorTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomEndTimeAllocatorTest.java @@ -20,8 +20,8 @@ package org.matsim.contrib.minibus.replanning; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.contrib.minibus.hook.Operator; import org.matsim.contrib.minibus.hook.PPlan; import org.matsim.contrib.minibus.routeProvider.PScenarioHelper; @@ -34,7 +34,7 @@ public class MaxRandomEndTimeAllocatorTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public final void testRun() { + final void testRun() { Operator coop = PScenarioHelper.createTestCooperative(utils.getOutputDirectory()); ArrayList param = new ArrayList<>(); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomStartTimeAllocatorTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomStartTimeAllocatorTest.java index d3086cf9ced..0c51695020c 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomStartTimeAllocatorTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomStartTimeAllocatorTest.java @@ -20,8 +20,8 @@ package org.matsim.contrib.minibus.replanning; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.contrib.minibus.hook.Operator; import org.matsim.contrib.minibus.hook.PPlan; import org.matsim.contrib.minibus.routeProvider.PScenarioHelper; @@ -34,7 +34,7 @@ public class MaxRandomStartTimeAllocatorTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public final void testRun() { + final void testRun() { Operator coop = PScenarioHelper.createTestCooperative(utils.getOutputDirectory()); ArrayList param = new ArrayList<>(); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/SidewaysRouteExtensionTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/SidewaysRouteExtensionTest.java index 615ef2f3412..d9a58f4ce0b 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/SidewaysRouteExtensionTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/SidewaysRouteExtensionTest.java @@ -20,8 +20,8 @@ package org.matsim.contrib.minibus.replanning; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.contrib.minibus.PConstants; import org.matsim.contrib.minibus.hook.Operator; import org.matsim.contrib.minibus.hook.PPlan; @@ -47,7 +47,7 @@ public class SidewaysRouteExtensionTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public final void testRun() { + final void testRun() { Operator coop = PScenarioHelper.createCoop2414to3444(); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/TimeProviderTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/TimeProviderTest.java index 61744081b5d..d4cda9b24d9 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/TimeProviderTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/TimeProviderTest.java @@ -22,8 +22,8 @@ import java.io.File; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; import org.matsim.api.core.v01.network.Link; @@ -39,7 +39,7 @@ public class TimeProviderTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public final void testGetRandomTimeInIntervalOneTimeSlot() { + final void testGetRandomTimeInIntervalOneTimeSlot() { new File(utils.getOutputDirectory() + PConstants.statsOutputFolder).mkdir(); @@ -56,7 +56,7 @@ public final void testGetRandomTimeInIntervalOneTimeSlot() { } @Test - public final void testGetRandomTimeInIntervalOneSameStartEndTime() { + final void testGetRandomTimeInIntervalOneSameStartEndTime() { new File(utils.getOutputDirectory() + PConstants.statsOutputFolder).mkdir(); @@ -73,7 +73,7 @@ public final void testGetRandomTimeInIntervalOneSameStartEndTime() { } @Test - public final void testGetRandomTimeInIntervalDifferentStartEndTime() { + final void testGetRandomTimeInIntervalDifferentStartEndTime() { new File(utils.getOutputDirectory() + PConstants.statsOutputFolder).mkdir(); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedEndTimeExtensionTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedEndTimeExtensionTest.java index ba4fb39e8d8..9ece4bc8d4a 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedEndTimeExtensionTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedEndTimeExtensionTest.java @@ -23,8 +23,8 @@ import java.util.ArrayList; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; import org.matsim.api.core.v01.network.Link; @@ -43,7 +43,7 @@ public class WeightedEndTimeExtensionTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public final void testRun() { + final void testRun() { Operator coop = PScenarioHelper.createTestCooperative(utils.getOutputDirectory()); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedStartTimeExtensionTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedStartTimeExtensionTest.java index 8c2dd102cd7..38505c684cc 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedStartTimeExtensionTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedStartTimeExtensionTest.java @@ -23,8 +23,8 @@ import java.util.ArrayList; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; import org.matsim.api.core.v01.network.Link; @@ -43,7 +43,7 @@ public class WeightedStartTimeExtensionTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public final void testRun() { + final void testRun() { Operator coop = PScenarioHelper.createTestCooperative(utils.getOutputDirectory()); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/ComplexCircleScheduleProviderTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/ComplexCircleScheduleProviderTest.java index 70a363892ed..173983379c2 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/ComplexCircleScheduleProviderTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/ComplexCircleScheduleProviderTest.java @@ -22,8 +22,8 @@ import java.util.ArrayList; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -45,7 +45,7 @@ public class ComplexCircleScheduleProviderTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public final void testCreateTransitLineLikeSimpleCircleScheduleProvider() { + final void testCreateTransitLineLikeSimpleCircleScheduleProvider() { Scenario scenario = PScenarioHelper.createTestNetwork(); PConfigGroup pC = new PConfigGroup(); @@ -104,7 +104,7 @@ public final void testCreateTransitLineLikeSimpleCircleScheduleProvider() { } @Test - public final void testCreateTransitLineWithMoreStops() { + final void testCreateTransitLineWithMoreStops() { Scenario scenario = PScenarioHelper.createTestNetwork(); PConfigGroup pC = new PConfigGroup(); @@ -172,7 +172,7 @@ public final void testCreateTransitLineWithMoreStops() { } @Test - public final void testGetRandomTransitStop() { + final void testGetRandomTransitStop() { MutableScenario scenario = (MutableScenario) PScenarioHelper.createTestNetwork(); PConfigGroup pC = new PConfigGroup(); @@ -188,7 +188,7 @@ public final void testGetRandomTransitStop() { } @Test - public final void testCreateEmptyLine() { + final void testCreateEmptyLine() { MutableScenario scenario = (MutableScenario) PScenarioHelper.createTestNetwork(); PConfigGroup pC = new PConfigGroup(); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/SimpleCircleScheduleProviderTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/SimpleCircleScheduleProviderTest.java index 4b09480162c..5d73e3a7e8d 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/SimpleCircleScheduleProviderTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/SimpleCircleScheduleProviderTest.java @@ -22,8 +22,8 @@ import java.util.ArrayList; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -45,7 +45,7 @@ public class SimpleCircleScheduleProviderTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public final void testCreateTransitLine() { + final void testCreateTransitLine() { Scenario scenario = PScenarioHelper.createTestNetwork(); PConfigGroup pC = new PConfigGroup(); @@ -104,7 +104,7 @@ public final void testCreateTransitLine() { } @Test - public final void testGetRandomTransitStop() { + final void testGetRandomTransitStop() { MutableScenario scenario = (MutableScenario) PScenarioHelper.createTestNetwork(); PConfigGroup pC = new PConfigGroup(); @@ -120,7 +120,7 @@ public final void testGetRandomTransitStop() { } @Test - public final void testCreateEmptyLine() { + final void testCreateEmptyLine() { MutableScenario scenario = (MutableScenario) PScenarioHelper.createTestNetwork(); PConfigGroup pC = new PConfigGroup(); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreatePStopsOnJunctionApproachesAndBetweenJunctionsTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreatePStopsOnJunctionApproachesAndBetweenJunctionsTest.java index 260a6a7d7f1..8c174734f6f 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreatePStopsOnJunctionApproachesAndBetweenJunctionsTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreatePStopsOnJunctionApproachesAndBetweenJunctionsTest.java @@ -20,8 +20,8 @@ package org.matsim.contrib.minibus.schedule; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -42,7 +42,7 @@ public class CreatePStopsOnJunctionApproachesAndBetweenJunctionsTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public final void testPScenarioHelperTestNetwork() { + final void testPScenarioHelperTestNetwork() { Network net = PScenarioHelper.createTestNetwork().getNetwork(); PConfigGroup pC = new PConfigGroup(); @@ -107,7 +107,7 @@ public final void testPScenarioHelperTestNetwork() { /** {@link org.matsim.core.network.algorithms.intersectionSimplifier.IntersectionSimplifierTest} */ @Test - public final void testComplexIntersection() { + final void testComplexIntersection() { Network network = buildComplexIntersection(); PConfigGroup pC = new PConfigGroup(); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreateStopsForAllCarLinksTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreateStopsForAllCarLinksTest.java index 50453286821..38a447f0a74 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreateStopsForAllCarLinksTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreateStopsForAllCarLinksTest.java @@ -20,8 +20,8 @@ package org.matsim.contrib.minibus.schedule; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -39,7 +39,7 @@ public class CreateStopsForAllCarLinksTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public final void testCreateStopsForAllCarLinks() { + final void testCreateStopsForAllCarLinks() { Network net = PScenarioHelper.createTestNetwork().getNetwork(); PConfigGroup pC = new PConfigGroup(); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/AreaBtwLinksVsTerminiBeelinePenaltyTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/AreaBtwLinksVsTerminiBeelinePenaltyTest.java index 8693c46df4f..8c4e676cfeb 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/AreaBtwLinksVsTerminiBeelinePenaltyTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/AreaBtwLinksVsTerminiBeelinePenaltyTest.java @@ -24,7 +24,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -63,9 +63,9 @@ public void setUp() { scenario = ScenarioUtils.loadScenario(ConfigUtils.createConfig()); factory = scenario.getTransitSchedule().getFactory(); } - + @Test - public void testRectangularLine() { + void testRectangularLine() { ArrayList stopsToBeServed = new ArrayList<>(); ArrayList stops = new ArrayList<>(); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/RouteDesignScoringManagerTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/RouteDesignScoringManagerTest.java index efcd8818e98..1cd63090a0e 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/RouteDesignScoringManagerTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/RouteDesignScoringManagerTest.java @@ -24,7 +24,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.minibus.PConfigGroup; @@ -65,9 +65,9 @@ public void setUp() { scenario = ScenarioUtils.loadScenario(ConfigUtils.createConfig()); factory = scenario.getTransitSchedule().getFactory(); } - + @Test - public void testRectangularLine() { + void testRectangularLine() { ArrayList stopsToBeServed = new ArrayList<>(); ArrayList stops = new ArrayList<>(); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/StopServedMultipleTimesPenaltyTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/StopServedMultipleTimesPenaltyTest.java index dfd86935ab5..88c2217c9a6 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/StopServedMultipleTimesPenaltyTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/StopServedMultipleTimesPenaltyTest.java @@ -23,7 +23,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.minibus.PConfigGroup; @@ -59,9 +59,9 @@ public void setUp() { scenario = ScenarioUtils.loadScenario(ConfigUtils.createConfig()); factory = scenario.getTransitSchedule().getFactory(); } - + @Test - public void testRouteServingSameStopTwice() { + void testRouteServingSameStopTwice() { ArrayList stopsToBeServed = new ArrayList<>(); ArrayList stops = new ArrayList<>(); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsApproxContainerTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsApproxContainerTest.java index fc160716cfb..5d7d6647979 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsApproxContainerTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsApproxContainerTest.java @@ -20,8 +20,8 @@ package org.matsim.contrib.minibus.stats; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.contrib.minibus.stats.RecursiveStatsApproxContainer; import org.matsim.testcases.MatsimTestUtils; @@ -30,7 +30,7 @@ public class RecursiveStatsApproxContainerTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public final void testRecursiveStatsContainer() { + final void testRecursiveStatsContainer() { RecursiveStatsApproxContainer stats = new RecursiveStatsApproxContainer(0.1, 3); diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsContainerTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsContainerTest.java index 5b51ce6808d..60afd38171d 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsContainerTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsContainerTest.java @@ -20,8 +20,8 @@ package org.matsim.contrib.minibus.stats; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.contrib.minibus.stats.RecursiveStatsContainer; import org.matsim.testcases.MatsimTestUtils; @@ -30,7 +30,7 @@ public class RecursiveStatsContainerTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public final void testRecursiveStatsContainer() { + final void testRecursiveStatsContainer() { RecursiveStatsContainer stats = new RecursiveStatsContainer(); diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java index f64a3d0d57c..158a897f8d9 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java @@ -25,7 +25,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.*; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -75,7 +77,7 @@ public class MultiModalControlerListenerTest { @SuppressWarnings("static-method") @Test - public void testSimpleScenario() { + void testSimpleScenario() { log.info("Run test single threaded..."); runSimpleScenario(1); @@ -185,23 +187,23 @@ static void runSimpleScenario(int numberOfThreads) { Assert.assertEquals(8, linkModeChecker.linkLeftCount); } - @Ignore("Due to bugfixes in slow flowCap accumulation in QueueWithBuffer")//by michalm + @Ignore("Due to bugfixes in slow flowCap accumulation in QueueWithBuffer")//by michalm @Test - public void testBerlinScenario_singleThreaded() { + void testBerlinScenario_singleThreaded() { log.info("Run test single threaded..."); runBerlinScenario(1); } @Ignore("Due to bugfixes in slow flowCap accumulation in QueueWithBuffer")//by michalm @Test - public void testBerlinScenario_multiThreaded_2() { + void testBerlinScenario_multiThreaded_2() { log.info("Run test multi threaded with 2 threads..."); runBerlinScenario(2); } - @Ignore("Due to bugfixes in slow flowCap accumulation in QueueWithBuffer")//by michalm + @Ignore("Due to bugfixes in slow flowCap accumulation in QueueWithBuffer")//by michalm @Test - public void testBerlinScenario_multiThreaded_4() { + void testBerlinScenario_multiThreaded_4() { log.info("Run test multi threaded with 4 threads..."); runBerlinScenario(4); } diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalTripRouterTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalTripRouterTest.java index 45c6e6ece37..f7edb1a21c8 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalTripRouterTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalTripRouterTest.java @@ -22,7 +22,7 @@ import com.google.inject.name.Names; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -65,7 +65,7 @@ public class MultiModalTripRouterTest { @Test - public void testRouteLeg() { + void testRouteLeg() { final Config config = ConfigUtils.createConfig(); config.routing().addParam("teleportedModeSpeed_bike", "6.01"); diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/RunMultimodalExampleTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/RunMultimodalExampleTest.java index 99407837927..7e2f7edc25f 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/RunMultimodalExampleTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/RunMultimodalExampleTest.java @@ -3,8 +3,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; @@ -16,7 +16,7 @@ public class RunMultimodalExampleTest{ @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void main(){ + void main(){ URL url = IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "berlin" ), "config_multimodal.xml" );; String [] args = { url.toString(), diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java index 52aa33e2fc2..3b224c976f0 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java @@ -26,8 +26,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -73,7 +73,7 @@ public class MultiModalPTCombinationTest { * probably no longer very useful, there is no more special walk mode for pt agents - gl-nov'19 */ @Test - public void testMultiModalPtCombination() { + void testMultiModalPtCombination() { Fixture f = new Fixture(); f.init(); diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeTest.java index 9f2cfda7ee0..a8d88a3b193 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeTest.java @@ -28,8 +28,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -52,7 +52,8 @@ public class BikeTravelTimeTest { private static final Logger log = LogManager.getLogger(BikeTravelTimeTest.class); - @Test public void testLinkTravelTimeCalculation() { + @Test + void testLinkTravelTimeCalculation() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Node node1 = scenario.getNetwork().getFactory().createNode(Id.create("n1", Node.class), new Coord(0.0, 0.0)); @@ -185,7 +186,8 @@ private void printInfo(Person p, double expected, double calculated, double slop log.info(sb.toString()); } - @Test public void testThreadLocals() { + @Test + void testThreadLocals() { Config config = ConfigUtils.createConfig(); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeTest.java index 2136ca6a756..b5ec67bb8a5 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeTest.java @@ -28,8 +28,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -52,7 +52,8 @@ public class WalkTravelTimeTest { private static final Logger log = LogManager.getLogger(WalkTravelTimeTest.class); - @Test public void testLinkTravelTimeCalculation() { + @Test + void testLinkTravelTimeCalculation() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Node node1 = scenario.getNetwork().getFactory().createNode(Id.create("n1", Node.class), new Coord(0.0, 0.0)); @@ -166,7 +167,8 @@ private void printInfo(Person p, double expected, double calculated, double slop log.info(sb.toString()); } - @Test public void testThreadLocals() { + @Test + void testThreadLocals() { Config config = ConfigUtils.createConfig(); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java index d7d87c67e8d..082b470276f 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java @@ -27,8 +27,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -66,7 +66,7 @@ public class StuckAgentTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testStuckEvents() { + void testStuckEvents() { Config config = ConfigUtils.createConfig(); config.controller().setOutputDirectory(utils.getOutputDirectory()); diff --git a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseConfigGroupIT.java b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseConfigGroupIT.java index 0862fe22736..2e28c957bdb 100644 --- a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseConfigGroupIT.java +++ b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseConfigGroupIT.java @@ -22,17 +22,17 @@ */ package org.matsim.contrib.noise; -import org.junit.Assert; +import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.scenario.ScenarioUtils; -import org.matsim.testcases.MatsimTestUtils; - +import org.matsim.testcases.MatsimTestUtils; + /** * @author ikaddoura * @@ -41,10 +41,10 @@ public class NoiseConfigGroupIT { @RegisterExtension - private MatsimTestUtils testUtils = new MatsimTestUtils(); - - @Test - public final void test0(){ + private MatsimTestUtils testUtils = new MatsimTestUtils(); + + @Test + final void test0(){ String configFile = testUtils.getPackageInputDirectory() + "NoiseConfigGroupTest/config0.xml"; Config config = ConfigUtils.loadConfig(configFile, new NoiseConfigGroup()); @@ -69,10 +69,10 @@ public final void test0(){ String tunnelLinkIds = noiseParameters.getTunnelLinkIDsSet().toArray()[0] + "," + noiseParameters.getTunnelLinkIDsSet().toArray()[1]; Assert.assertEquals("wrong config parameter", "link1,link2", tunnelLinkIds); - } - - @Test - public final void test1(){ + } + + @Test + final void test1(){ String configFile = testUtils.getPackageInputDirectory() + "NoiseConfigGroupTest/config1.xml"; Config config = ConfigUtils.loadConfig(configFile, new NoiseConfigGroup()); diff --git a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java index 5d8569ad0e9..50b7321388a 100644 --- a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java +++ b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java @@ -30,8 +30,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -77,7 +77,7 @@ public class NoiseIT { // Tests the NoisSpatialInfo functionality separately for each function @Test - public final void test1(){ + final void test1(){ String configFile = testUtils.getPackageInputDirectory() + "NoiseTest/config1.xml"; @@ -150,7 +150,7 @@ public final void test1(){ // tests the noise emissions, immissions, considered agent units, damages (receiver points), damages (per link), damages (per vehicle) based on the generated *.csv output // tests the noise events applying the average cost allocation approach @Test - public final void test2a(){ + final void test2a(){ // start a simple MATSim run with a single iteration String configFile = testUtils.getPackageInputDirectory() + "NoiseTest/config2.xml"; Config config = ConfigUtils.loadConfig(configFile ) ; @@ -158,8 +158,9 @@ public final void test2a(){ config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.none); runTest2a( config ) ; } + @Test - public final void test2aWAccessEgress(){ + final void test2aWAccessEgress(){ // start a simple MATSim run with a single iteration String configFile = testUtils.getPackageInputDirectory() + "NoiseTest/config2.xml"; Config config = ConfigUtils.loadConfig(configFile ) ; @@ -948,7 +949,7 @@ else if(event.getActType().equals("work")){ // same test as before, but using the marginal cost approach @Test - public final void test2b(){ + final void test2b(){ String runDirectory = null; int lastIteration = -1; @@ -1047,7 +1048,7 @@ public final void test2b(){ // same test as 2a, but using the actual speed level @Test - public final void test2c(){ + final void test2c(){ // start a simple MATSim run with a single iteration String configFile = testUtils.getPackageInputDirectory() + "NoiseTest/config2.xml"; @@ -1174,7 +1175,7 @@ public void handleEvent(ActivityEndEvent event) { // tests the static methods within class "noiseEquations" @Test - public final void test3(){ + final void test3(){ double p = 0; double pInPercent = 0; @@ -1369,7 +1370,7 @@ else if( nHgvs == 2){ // tests the static methods within class "noiseEquations" @Test - public final void test4(){ + final void test4(){ double vCar = 0.0496757749985181; double vHGV = 0.0478758773550055; @@ -1417,7 +1418,7 @@ public final void test4(){ // tests the static methods within class "noiseEquations" - other speed levels @Test - public final void test5(){ + final void test5(){ double vCar = 30; double vHGV = 30; diff --git a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseOnlineExampleIT.java b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseOnlineExampleIT.java index fa0e8c0c1e5..969ec85aef0 100644 --- a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseOnlineExampleIT.java +++ b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseOnlineExampleIT.java @@ -26,8 +26,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.analysis.XYTRecord; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -58,7 +58,7 @@ public class NoiseOnlineExampleIT { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public final void test0(){ + final void test0(){ String configFile = testUtils.getPackageInputDirectory() + "config.xml"; Config config = ConfigUtils.loadConfig(configFile, new NoiseConfigGroup()); @@ -80,7 +80,7 @@ public final void test0(){ } @Test - public final void testOnTheFlyAggregationTerms() { + final void testOnTheFlyAggregationTerms() { String configFile = testUtils.getPackageInputDirectory() + "config.xml"; Config config = ConfigUtils.loadConfig(configFile, new NoiseConfigGroup()); config.controller().setLastIteration(1); @@ -180,7 +180,7 @@ public final void testOnTheFlyAggregationTerms() { } @Test - public final void testNoiseListener(){ + final void testNoiseListener(){ Config config = ConfigUtils.loadConfig( testUtils.getPackageInputDirectory() + "config.xml", new NoiseConfigGroup() ); config.controller().setLastIteration(1); diff --git a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseRLS19IT.java b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseRLS19IT.java index 096250d46d4..41c3ebb8836 100644 --- a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseRLS19IT.java +++ b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseRLS19IT.java @@ -23,8 +23,8 @@ package org.matsim.contrib.noise; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -54,7 +54,7 @@ public class NoiseRLS19IT { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void testShielding() { + void testShielding() { final RLS19ShieldingCorrection shieldingCorrection = new RLS19ShieldingCorrection(); @@ -94,8 +94,8 @@ public void testShielding() { } - @Test - public void testEmission() { + @Test + void testEmission() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network = scenario.getNetwork(); Node from = NetworkUtils.createAndAddNode(network, Id.createNodeId("from"), new Coord(0, 0)); @@ -127,8 +127,8 @@ public void testEmission() { Assert.assertEquals("Wrong final noise link emission!", 84.23546653306667, noiseLink.getEmission(), MatsimTestUtils.EPSILON); } - @Test - public void testImmission() { + @Test + void testImmission() { final RLS19ShieldingCorrection shieldingCorrection = new RLS19ShieldingCorrection(); diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/LinkPropertiesTest.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/LinkPropertiesTest.java index 2f8c4c442bb..30e886f88d8 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/LinkPropertiesTest.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/LinkPropertiesTest.java @@ -1,14 +1,14 @@ package org.matsim.contrib.osm.networkReader; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.network.Link; import static org.junit.Assert.assertEquals; public class LinkPropertiesTest { - @Test - public void calculateSpeedIfNoTag_excludedHierarchy() { + @Test + void calculateSpeedIfNoTag_excludedHierarchy() { var motorwayProperties = new LinkProperties(LinkProperties.LEVEL_MOTORWAY, 1, 50 / 3.6, 1000, false); var residentialProperties = new LinkProperties(LinkProperties.LEVEL_RESIDENTIAL, 1, 50 / 3.6, 1000, false); @@ -17,8 +17,8 @@ public void calculateSpeedIfNoTag_excludedHierarchy() { assertEquals(residentialProperties.freespeed, LinkProperties.calculateSpeedIfNoSpeedTag(200, residentialProperties), 0.0); } - @Test - public void calculateSpeedIfNoTag_longLink() { + @Test + void calculateSpeedIfNoTag_longLink() { var properties = new LinkProperties(LinkProperties.LEVEL_PRIMARY, 1, 50 / 3.6, 1000, false); var linkLength = 350; // longer than the threshold @@ -28,8 +28,8 @@ public void calculateSpeedIfNoTag_longLink() { assertEquals(properties.freespeed, result, 0.0); } - @Test - public void calculateSpeedIfNoTag_shortLink() { + @Test + void calculateSpeedIfNoTag_shortLink() { var properties = new LinkProperties(LinkProperties.LEVEL_PRIMARY, 1, 50 / 3.6, 1000, false); var linkLength = 1; // very shor link @@ -39,22 +39,22 @@ public void calculateSpeedIfNoTag_shortLink() { assertEquals(10 / 3.6, result, 0.1); // should be pretty much 10 km/h } - @Test - public void calculateSpeedIfSpeedTag_withoutUrbanFactor() { + @Test + void calculateSpeedIfSpeedTag_withoutUrbanFactor() { var maxSpeed = 100 / 3.6; assertEquals(maxSpeed, LinkProperties.calculateSpeedIfSpeedTag(maxSpeed), 0.0); } - @Test - public void calculateSpeedIfSpeedTag_withUrbanFactor() { + @Test + void calculateSpeedIfSpeedTag_withUrbanFactor() { var maxSpeed = 50 / 3.6; assertEquals(maxSpeed * 0.9, LinkProperties.calculateSpeedIfSpeedTag(maxSpeed), Double.MIN_VALUE); } - @Test - public void getLaneCapacity_withIncrease() { + @Test + void getLaneCapacity_withIncrease() { var linkLength = 40; var properties = new LinkProperties(LinkProperties.LEVEL_PRIMARY, 1, 50 / 3.6, 1000, false); @@ -62,8 +62,8 @@ public void getLaneCapacity_withIncrease() { assertEquals(properties.laneCapacity * 2, LinkProperties.getLaneCapacity(linkLength, properties), Double.MIN_VALUE); } - @Test - public void getLaneCapacity_withoutIncrease() { + @Test + void getLaneCapacity_withoutIncrease() { var linkLength = 101; var properties = new LinkProperties(LinkProperties.LEVEL_PRIMARY, 1, 50 / 3.6, 1000, false); diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderIT.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderIT.java index e5a9f4558e9..5e023e1fff0 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderIT.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderIT.java @@ -1,7 +1,7 @@ package org.matsim.contrib.osm.networkReader; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.network.Network; import org.matsim.core.network.NetworkUtils; import org.matsim.core.utils.geometry.CoordinateTransformation; @@ -19,7 +19,7 @@ public class OsmBicycleReaderIT { private MatsimTestUtils matsimTestUtils = new MatsimTestUtils(); @Test - public void test_andorra() { + void test_andorra() { final Path inputFile = Paths.get(matsimTestUtils.getPackageInputDirectory()).resolve("andorra-latest.osm.pbf"); diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderTest.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderTest.java index bc7b8479342..788c58bf779 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderTest.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderTest.java @@ -2,8 +2,8 @@ import de.topobyte.osm4j.core.model.iface.OsmTag; import de.topobyte.osm4j.core.model.impl.Tag; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -27,7 +27,7 @@ public class OsmBicycleReaderTest { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void test_singleLinkWithAttributes() { + void test_singleLinkWithAttributes() { final String surface = "surface-value"; final String smoothness = "smoothness-value"; @@ -62,7 +62,7 @@ public void test_singleLinkWithAttributes() { } @Test - public void test_singleLinkPrimaryWithSurfaceAsphalt() { + void test_singleLinkPrimaryWithSurfaceAsphalt() { List tags = Collections.singletonList( new Tag(OsmTags.HIGHWAY, OsmTags.PRIMARY)); @@ -85,7 +85,7 @@ public void test_singleLinkPrimaryWithSurfaceAsphalt() { } @Test - public void test_singleLinkWithBicycleNotAllowed() { + void test_singleLinkWithBicycleNotAllowed() { List tags = Collections.singletonList( new Tag(OsmTags.HIGHWAY, OsmTags.MOTORWAY)); @@ -109,7 +109,7 @@ public void test_singleLinkWithBicycleNotAllowed() { } @Test - public void test_singleLinkWithOnlyBicycleAllowed() { + void test_singleLinkWithOnlyBicycleAllowed() { List tags = Collections.singletonList( new Tag(OsmTags.HIGHWAY, OsmTags.PEDESTRIAN)); @@ -133,7 +133,7 @@ public void test_singleLinkWithOnlyBicycleAllowed() { } @Test - public void test_singleOnewayLinkOneWayBikeNo() { + void test_singleOnewayLinkOneWayBikeNo() { final String surface = "surface-value"; @@ -166,7 +166,7 @@ public void test_singleOnewayLinkOneWayBikeNo() { } @Test - public void test_singleOnewayLinkOppositeBike() { + void test_singleOnewayLinkOppositeBike() { final String surface = "surface-value"; @@ -199,7 +199,7 @@ public void test_singleOnewayLinkOppositeBike() { } @Test - public void test_singleReverseOnewayLinkOneWayBikeNo() { + void test_singleReverseOnewayLinkOneWayBikeNo() { final String surface = "surface-value"; @@ -233,7 +233,7 @@ public void test_singleReverseOnewayLinkOneWayBikeNo() { } @Test - public void test_builderDoesntOverrideLinkProperties() { + void test_builderDoesntOverrideLinkProperties() { var osmFile = Paths.get(testUtils.getOutputDirectory()).resolve("osm-data.osm.pbf"); diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmNetworkParserTest.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmNetworkParserTest.java index 03be0ed6ca9..ec2aadb4cc5 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmNetworkParserTest.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmNetworkParserTest.java @@ -4,8 +4,8 @@ import de.topobyte.osm4j.core.model.iface.OsmWay; import org.junit.After; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.core.utils.geometry.transformations.AtlantisToWGS84; @@ -34,7 +34,7 @@ public void shutDownExecutor() { } @Test - public void parse_singleLink() { + void parse_singleLink() { Utils.OsmData singleLink = Utils.createSingleLink(); Path file = Paths.get(matsimUtils.getOutputDirectory(), "parser_single-link.pbf"); @@ -66,7 +66,7 @@ public void parse_singleLink() { } @Test - public void parse_twoIntersectingWays() { + void parse_twoIntersectingWays() { Utils.OsmData twoIntersectingLinks = Utils.createTwoIntersectingLinksWithDifferentLevels(); Path file = Paths.get(matsimUtils.getOutputDirectory(), "parser_two-intersecting-ways.pbf"); @@ -92,7 +92,7 @@ else if (node.getId() == 9L || node.getId() == 1L || node.getId() == 10L || node } @Test - public void parse_intersectingLinksOneDoesNotMatchFilter() { + void parse_intersectingLinksOneDoesNotMatchFilter() { Utils.OsmData twoIntersectingLinks = Utils.createTwoIntersectingLinksWithDifferentLevels(); @@ -121,7 +121,7 @@ public void parse_intersectingLinksOneDoesNotMatchFilter() { } @Test - public void parse_singleLink_withTransformation() { + void parse_singleLink_withTransformation() { final CoordinateTransformation atlantis = new AtlantisToWGS84(); diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmSignalsParserTest.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmSignalsParserTest.java index c5ba94aab22..9aed196716b 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmSignalsParserTest.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmSignalsParserTest.java @@ -7,8 +7,8 @@ import de.topobyte.osm4j.core.model.impl.Tag; import org.junit.After; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.core.utils.geometry.transformations.IdentityTransformation; import org.matsim.core.utils.geometry.transformations.TransformationFactory; @@ -40,7 +40,7 @@ public void shutDownExecutor() { } @Test - public void parse_singleLinkWithCrossing() { + void parse_singleLinkWithCrossing() { Path file = Paths.get(utils.getOutputDirectory()).resolve("tmp.pbf"); Utils.OsmData data = Utils.createSingleLink(); @@ -74,7 +74,7 @@ public void parse_singleLinkWithCrossing() { } @Test - public void parse_singleLinkWithTrafficSignals() { + void parse_singleLinkWithTrafficSignals() { Path file = Paths.get(utils.getOutputDirectory()).resolve("tmp.pbf"); Utils.OsmData data = Utils.createSingleLink(); @@ -108,7 +108,7 @@ public void parse_singleLinkWithTrafficSignals() { } @Test - public void parse_singleLinkWithNonHighwayNode() { + void parse_singleLinkWithNonHighwayNode() { Path file = Paths.get(utils.getOutputDirectory()).resolve("tmp.pbf"); Utils.OsmData data = Utils.createSingleLink(); @@ -138,7 +138,7 @@ public void parse_singleLinkWithNonHighwayNode() { } @Test - public void parse_singleLinkWithNodeNotReferencedByWay() { + void parse_singleLinkWithNodeNotReferencedByWay() { Path file = Paths.get(utils.getOutputDirectory()).resolve("tmp.pbf"); Utils.OsmData data = Utils.createSingleLink(); @@ -158,7 +158,7 @@ public void parse_singleLinkWithNodeNotReferencedByWay() { } @Test - public void parse_intersectingWaysWithProhibitiveRestriction() { + void parse_intersectingWaysWithProhibitiveRestriction() { Path file = Paths.get(utils.getOutputDirectory()).resolve("tmp.pbf"); Utils.OsmData data = Utils.createTwoIntersectingLinksWithDifferentLevels(); @@ -185,7 +185,7 @@ public void parse_intersectingWaysWithProhibitiveRestriction() { } @Test - public void parse_intersectingWaysWithImperativeRestriction() { + void parse_intersectingWaysWithImperativeRestriction() { Path file = Paths.get(utils.getOutputDirectory()).resolve("tmp.pbf"); Utils.OsmData data = Utils.createTwoIntersectingLinksWithDifferentLevels(); diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderIT.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderIT.java index 423233c2079..be2996b5c08 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderIT.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderIT.java @@ -2,8 +2,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.network.Network; import org.matsim.core.network.NetworkUtils; import org.matsim.core.utils.geometry.CoordinateTransformation; @@ -21,7 +21,7 @@ public class SupersonicOsmNetworkReaderIT { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void test_andorra() { + void test_andorra() { Network network = new SupersonicOsmNetworkReader.Builder() .setCoordinateTransformation(coordinateTransformation) diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderTest.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderTest.java index 95f68fad504..0a8771b6649 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderTest.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderTest.java @@ -9,8 +9,8 @@ import de.topobyte.osm4j.pbf.seq.PbfWriter; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -62,7 +62,7 @@ private static void writeOsmData(Collection nodes, Collection w @SuppressWarnings("ConstantConditions") @Test - public void singleLink() { + void singleLink() { Utils.OsmData singleLink = Utils.createSingleLink(); @@ -108,7 +108,7 @@ public void singleLink() { @SuppressWarnings("ConstantConditions") @Test - public void singleLinkPreserveMiddleNodes() { + void singleLinkPreserveMiddleNodes() { Utils.OsmData singleLink = Utils.createSingleLink(); @@ -144,7 +144,7 @@ public void singleLinkPreserveMiddleNodes() { } @Test - public void singleLink_withMaxSpeedTag() { + void singleLink_withMaxSpeedTag() { Node node1 = new Node(1, 0, 0); Node node2 = new Node(2, 10, 10); @@ -170,7 +170,7 @@ public void singleLink_withMaxSpeedTag() { } @Test - public void singleLink_withMaxSpeedTag_milesPerHour() { + void singleLink_withMaxSpeedTag_milesPerHour() { Node node1 = new Node(1, 0, 0); Node node2 = new Node(2, 10, 10); TLongArrayList nodeReference = new TLongArrayList(new long[]{node1.getId(), node2.getId()}); @@ -194,7 +194,7 @@ public void singleLink_withMaxSpeedTag_milesPerHour() { } @Test - public void singleLink_withMaxSpeedTag_urbanLink() { + void singleLink_withMaxSpeedTag_urbanLink() { Node node1 = new Node(1, 0, 0); Node node2 = new Node(2, 10, 10); TLongArrayList nodeReference = new TLongArrayList(new long[]{node1.getId(), node2.getId()}); @@ -221,7 +221,7 @@ public void singleLink_withMaxSpeedTag_urbanLink() { } @Test - public void singleLink_withMaxSpeedTag_cantParseMaxSpeed() { + void singleLink_withMaxSpeedTag_cantParseMaxSpeed() { Node node1 = new Node(1, 0, 0); Node node2 = new Node(2, 10, 10); TLongArrayList nodeReference = new TLongArrayList(new long[]{node1.getId(), node2.getId()}); @@ -246,7 +246,7 @@ public void singleLink_withMaxSpeedTag_cantParseMaxSpeed() { } @Test - public void singleLink_noMaxSpeedTag_ruralLink() { + void singleLink_noMaxSpeedTag_ruralLink() { Node node1 = new Node(1, 0, 0); Node node2 = new Node(2, 1000, 1000); @@ -272,7 +272,7 @@ public void singleLink_noMaxSpeedTag_ruralLink() { } @Test - public void singleLink_noMaxSpeedTag_urbanLink() { + void singleLink_noMaxSpeedTag_urbanLink() { Node node1 = new Node(1, 0, 0); Node node2 = new Node(2, 10, 10); @@ -300,7 +300,7 @@ public void singleLink_noMaxSpeedTag_urbanLink() { } @Test - public void singleLink_noLanesTag() { + void singleLink_noLanesTag() { Node node1 = new Node(1, 0, 0); Node node2 = new Node(2, 10, 10); @@ -325,7 +325,7 @@ public void singleLink_noLanesTag() { } @Test - public void singleLink_withLanesTag() { + void singleLink_withLanesTag() { Node node1 = new Node(1, 0, 0); Node node2 = new Node(2, 10, 10); @@ -351,7 +351,7 @@ public void singleLink_withLanesTag() { } @Test - public void singleLink_lanesTagOneWay() { + void singleLink_lanesTagOneWay() { Node node1 = new Node(1, 0, 0); Node node2 = new Node(2, 10, 10); TLongArrayList nodeReference = new TLongArrayList(new long[]{node1.getId(), node2.getId()}); @@ -376,7 +376,7 @@ public void singleLink_lanesTagOneWay() { } @Test - public void singleLink_lanesForwardAndBackwardTag() { + void singleLink_lanesForwardAndBackwardTag() { Node node1 = new Node(1, 0, 0); Node node2 = new Node(2, 10, 10); TLongArrayList nodeReference = new TLongArrayList(new long[]{node1.getId(), node2.getId()}); @@ -403,7 +403,7 @@ public void singleLink_lanesForwardAndBackwardTag() { } @Test - public void singleLink_capacityLongLink() { + void singleLink_capacityLongLink() { Node node1 = new Node(1, 0, 0); Node node2 = new Node(2, 100, 100); @@ -427,7 +427,7 @@ public void singleLink_capacityLongLink() { } @Test - public void singleLink_capacityShortLink() { + void singleLink_capacityShortLink() { Node node1 = new Node(1, 0, 0); Node node2 = new Node(2, 10, 10); @@ -451,7 +451,7 @@ public void singleLink_capacityShortLink() { } @Test - public void singleLink_overridingLinkProperties() { + void singleLink_overridingLinkProperties() { Node node1 = new Node(1, 0, 0); Node node2 = new Node(2, 100, 100); @@ -480,7 +480,7 @@ public void singleLink_overridingLinkProperties() { } @Test - public void twoIntersectingLinks() { + void twoIntersectingLinks() { var twoLinks = Utils.createTwoIntersectingLinksWithDifferentLevels(); var file = Paths.get(matsimTestUtils.getOutputDirectory(), "two-intersecting-links.pbf"); @@ -527,7 +527,7 @@ public void twoIntersectingLinks() { } @Test - public void twoIntersectingLinks_withAfterLinkCreatedHook() { + void twoIntersectingLinks_withAfterLinkCreatedHook() { final List tags = Collections.singletonList(new Tag("highway", MOTORWAY)); final List nodes = Arrays.asList(new Node(1, 0, 0), new Node(2, 1, 1), new Node(3, 2, 2), @@ -574,7 +574,7 @@ public void twoIntersectingLinks_withAfterLinkCreatedHook() { } @Test - public void twoIntersectingLinks_oneShouldBeSimplified() { + void twoIntersectingLinks_oneShouldBeSimplified() { final List tags = Collections.singletonList(new Tag("highway", MOTORWAY)); final List nodes = Arrays.asList(new Node(1, 0, 0), @@ -601,7 +601,7 @@ public void twoIntersectingLinks_oneShouldBeSimplified() { } @Test - public void linkGrid_oneWayNotInFilter() { + void linkGrid_oneWayNotInFilter() { Utils.OsmData grid = Utils.createGridWithDifferentLevels(); final Path file = Paths.get(matsimTestUtils.getOutputDirectory(), "grid-with-filter.pbf"); @@ -632,7 +632,7 @@ public void linkGrid_oneWayNotInFilter() { } @Test - public void twoIntersectingLinks_oneWithLoop() { + void twoIntersectingLinks_oneWithLoop() { final List tags = Collections.singletonList(new Tag("highway", MOTORWAY)); final List nodes = Arrays.asList(new Node(1, 0, 0), new Node(2, 1, 1), new Node(3, 2, 2), @@ -667,7 +667,7 @@ public void twoIntersectingLinks_oneWithLoop() { } @Test - public void simplifiedLinksWithPreservedOriginalGeometry() { + void simplifiedLinksWithPreservedOriginalGeometry() { var file = Paths.get(matsimTestUtils.getOutputDirectory() + "file.osm.bbf"); var osmData = Utils.createSingleLink(List.of(new Tag(OsmTags.HIGHWAY, OsmTags.LIVING_STREET))); diff --git a/contribs/osm/src/test/java/otherPackage/SupersonicOsmNetworkReaderBuilderTest.java b/contribs/osm/src/test/java/otherPackage/SupersonicOsmNetworkReaderBuilderTest.java index 410c7e47756..e408f441573 100644 --- a/contribs/osm/src/test/java/otherPackage/SupersonicOsmNetworkReaderBuilderTest.java +++ b/contribs/osm/src/test/java/otherPackage/SupersonicOsmNetworkReaderBuilderTest.java @@ -1,6 +1,6 @@ package otherPackage; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contrib.osm.networkReader.SupersonicOsmNetworkReader; import org.matsim.core.utils.geometry.transformations.IdentityTransformation; @@ -9,7 +9,7 @@ public class SupersonicOsmNetworkReaderBuilderTest { @Test - public void testPublicApi() { + void testPublicApi() { SupersonicOsmNetworkReader reader = new SupersonicOsmNetworkReader.Builder() .setCoordinateTransformation(new IdentityTransformation()) diff --git a/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java b/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java index b16a6a5d01d..d54fb3ef32e 100644 --- a/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java +++ b/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java @@ -24,8 +24,8 @@ package org.matsim.contrib.otfvis; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.QSimConfigGroup; @@ -52,7 +52,7 @@ public class OTFVisIT { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void testConvert() { + void testConvert() { String networkFilename = "test/scenarios/equil/network.xml"; String eventsFilename = "test/scenarios/equil/events.xml"; String mviFilename = testUtils.getOutputDirectory()+"/events.mvi"; @@ -65,7 +65,7 @@ public void testConvert() { } @Test - public void testOTFVisSnapshotWriterOnQSim() { + void testOTFVisSnapshotWriterOnQSim() { final Config config = ConfigUtils.loadConfig("test/scenarios/equil/config_plans1.xml"); config.controller().setLastIteration(2); config.controller().setWriteEventsInterval(0); diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/GeneralLibTest.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/GeneralLibTest.java index 0ba50eed4c5..23663b17e77 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/GeneralLibTest.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/GeneralLibTest.java @@ -2,13 +2,13 @@ import static org.junit.Assert.*; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contrib.parking.parkingchoice.lib.GeneralLib; public class GeneralLibTest { @Test - public void testProjectTimeWithin24Hours() { + void testProjectTimeWithin24Hours() { assertEquals(10.0, GeneralLib.projectTimeWithin24Hours(10.0), 0); assertEquals(0.0, GeneralLib.projectTimeWithin24Hours(60 * 60 * 24.0), 0); assertEquals(1.0, GeneralLib.projectTimeWithin24Hours(60 * 60 * 24.0 + 1), 0.1); @@ -16,13 +16,13 @@ public void testProjectTimeWithin24Hours() { } @Test - public void testGetIntervalDuration() { + void testGetIntervalDuration() { assertEquals(10.0, GeneralLib.getIntervalDuration(0.0, 10.0), 0); assertEquals(11.0, GeneralLib.getIntervalDuration(60 * 60 * 24.0 - 1.0, 10.0), 0); } @Test - public void testIsIn24HourInterval() { + void testIsIn24HourInterval() { assertTrue(GeneralLib.isIn24HourInterval(0.0, 10.0, 9.0)); assertFalse(GeneralLib.isIn24HourInterval(0.0, 10.0, 11.0)); assertTrue(GeneralLib.isIn24HourInterval(0.0, 10.0, 0.0)); diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/obj/DoubleValueHashMapTest.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/obj/DoubleValueHashMapTest.java index d87fef93398..896c5cd8849 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/obj/DoubleValueHashMapTest.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/obj/DoubleValueHashMapTest.java @@ -2,12 +2,13 @@ import static org.junit.Assert.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contrib.parking.parkingchoice.lib.obj.DoubleValueHashMap; public class DoubleValueHashMapTest { - @Test public void testBasic(){ + @Test + void testBasic(){ DoubleValueHashMap dhm=new DoubleValueHashMap(); dhm.put(0, 5.2); diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/obj/LinkedListValueHashMapTest.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/obj/LinkedListValueHashMapTest.java index ddaf58a845b..99f18824563 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/obj/LinkedListValueHashMapTest.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/obj/LinkedListValueHashMapTest.java @@ -4,13 +4,14 @@ import java.util.HashMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contrib.parking.parkingchoice.lib.obj.HashMapInverter; import org.matsim.contrib.parking.parkingchoice.lib.obj.LinkedListValueHashMap; public class LinkedListValueHashMapTest { - @Test public void testInteger(){ + @Test + void testInteger(){ LinkedListValueHashMap hm1=new LinkedListValueHashMap(); hm1.put(1, 1); @@ -19,7 +20,8 @@ public class LinkedListValueHashMapTest { assertEquals(1, (int) hm1.get(1).get(0)); } - @Test public void testStrings(){ + @Test + void testStrings(){ LinkedListValueHashMap hm1=new LinkedListValueHashMap(); hm1.put("1", "1"); @@ -28,7 +30,8 @@ public class LinkedListValueHashMapTest { assertEquals("1", hm1.get("1").get(0)); } - @Test public void testHashMapInverter(){ + @Test + void testHashMapInverter(){ HashMap hashMap=new HashMap(); hashMap.put("0", "1"); diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/ParkingCostVehicleTrackerTest.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/ParkingCostVehicleTrackerTest.java index b186334bb59..ba933fa274b 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/ParkingCostVehicleTrackerTest.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/ParkingCostVehicleTrackerTest.java @@ -21,7 +21,7 @@ import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -52,7 +52,7 @@ public class ParkingCostVehicleTrackerTest { @Test - public void testParkingCostEvents() { + void testParkingCostEvents() { Fixture f = new Fixture(); f.events.addHandler(new EventsLogger()); diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/RideParkingCostTrackerTest.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/RideParkingCostTrackerTest.java index b51b9996f21..98e4f56a9b7 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/RideParkingCostTrackerTest.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/RideParkingCostTrackerTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.parking.parkingcost.eventhandling; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -50,7 +50,7 @@ public class RideParkingCostTrackerTest { @Test - public void testPersonMoneyEvents() { + void testPersonMoneyEvents() { Fixture f = new Fixture(); f.events.addHandler(new EventsLogger()); diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/RunParkingCostsExampleTest.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/RunParkingCostsExampleTest.java index f4ea4e0db2b..7e65a26f421 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/RunParkingCostsExampleTest.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/RunParkingCostsExampleTest.java @@ -19,13 +19,13 @@ package org.matsim.contrib.parking.parkingcost.eventhandling; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contrib.parking.parkingcost.RunParkingCostExample; public class RunParkingCostsExampleTest { @Test - public void testRunParkingCostsExample() { + void testRunParkingCostsExample() { RunParkingCostExample.main(new String[]{}); } } diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxyIT.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxyIT.java index fcbc247bd76..abd3e9a34d0 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxyIT.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxyIT.java @@ -21,8 +21,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; import org.matsim.core.events.EventsUtils; @@ -36,9 +36,9 @@ public class RunWithParkingProxyIT { private static final Logger log = LogManager.getLogger(RunWithParkingProxyIT.class); @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Test - @Ignore - public void testMain(){ + @Test + @Ignore + void testMain(){ RunWithParkingProxy.main( new String []{ IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "chessboard" ), "config.xml" ).toString() , "--config:controler.outputDirectory=" + utils.getOutputDirectory() , "--config:controler.lastIteration=2" diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingChoiceExampleIT.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingChoiceExampleIT.java index 483a118e22e..c084bf7a434 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingChoiceExampleIT.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingChoiceExampleIT.java @@ -18,8 +18,8 @@ * *********************************************************************** */ package org.matsim.contrib.parking.run; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.contrib.parking.parkingchoice.run.RunParkingChoiceExample; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -36,7 +36,7 @@ public class RunParkingChoiceExampleIT { * Test method for {@link org.matsim.contrib.parking.parkingchoice.run.RunParkingChoiceExample#run(org.matsim.core.config.Config)}. */ @Test - public final void testRun() { + final void testRun() { Config config = ConfigUtils.loadConfig("./src/main/resources/parkingchoice/config.xml"); config.controller().setOutputDirectory( utils.getOutputDirectory() ); config.controller().setLastIteration(0); diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingSearchScenarioIT.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingSearchScenarioIT.java index 16f1a7f8525..d614a1edd4c 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingSearchScenarioIT.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingSearchScenarioIT.java @@ -20,8 +20,8 @@ package org.matsim.contrib.parking.run; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; @@ -43,7 +43,7 @@ public class RunParkingSearchScenarioIT { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testRunParkingBenesonStrategy() { + void testRunParkingBenesonStrategy() { try { String configFile = "./src/main/resources/parkingsearch/config.xml"; Config config = ConfigUtils.loadConfig(configFile, new ParkingSearchConfigGroup()); @@ -62,7 +62,7 @@ public void testRunParkingBenesonStrategy() { } @Test - public void testRunParkingRandomStrategy() { + void testRunParkingRandomStrategy() { String configFile = "./src/main/resources/parkingsearch/config.xml"; Config config = ConfigUtils.loadConfig(configFile, new ParkingSearchConfigGroup()); config.controller().setLastIteration(0); @@ -80,7 +80,7 @@ public void testRunParkingRandomStrategy() { } @Test - public void testRunParkingDistanceMemoryStrategy() { + void testRunParkingDistanceMemoryStrategy() { try { String configFile = "./src/main/resources/parkingsearch/config.xml"; Config config = ConfigUtils.loadConfig(configFile, new ParkingSearchConfigGroup()); @@ -118,7 +118,7 @@ public void testRunParkingDistanceMemoryStrategy() { } @Test - public void testRunParkingNearestParkingSpotStrategy() { + void testRunParkingNearestParkingSpotStrategy() { try { String configFile = "./src/main/resources/parkingsearch/config.xml"; Config config = ConfigUtils.loadConfig(configFile, new ParkingSearchConfigGroup()); diff --git a/contribs/protobuf/src/test/java/org/matsim/contrib/protobuf/EventWriterPBTest.java b/contribs/protobuf/src/test/java/org/matsim/contrib/protobuf/EventWriterPBTest.java index 5941d7c17dd..6c90bffb6cd 100644 --- a/contribs/protobuf/src/test/java/org/matsim/contrib/protobuf/EventWriterPBTest.java +++ b/contribs/protobuf/src/test/java/org/matsim/contrib/protobuf/EventWriterPBTest.java @@ -3,8 +3,8 @@ import com.google.protobuf.Descriptors; import org.assertj.core.api.Assertions; import org.assertj.core.api.Condition; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.Event; @@ -30,8 +30,8 @@ public class EventWriterPBTest { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void writer() throws IOException { + @Test + void writer() throws IOException { // File file = tmp.newFile("output.pb"); File file = new File( utils.getOutputDirectory() + "events.pb" ); @@ -85,8 +85,8 @@ public void writer() throws IOException { } - @Test - public void convertEvent() { + @Test + void convertEvent() { // test few sample events GenericEvent event = new GenericEvent("test", 10.0); @@ -107,8 +107,8 @@ public void convertEvent() { .has(new Condition<>(e -> e.getPersonId().getId().equals("15") && e.getLinkId().getId().equals("20"), "Ids correct")); } - @Test - public void convertId() { + @Test + void convertId() { Id id = Id.createVehicleId(123); diff --git a/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java b/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java index 9e7f626e248..98b6c1fa889 100644 --- a/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java +++ b/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java @@ -5,8 +5,8 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.FixMethodOrder; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.runners.MethodSorters; import org.matsim.analysis.ScoreStatsControlerListener; import org.matsim.api.core.v01.population.Population; @@ -44,7 +44,7 @@ public class RunPSimTest { * Run 1 normal qsim iteration, a couple of psim iterations and a final 2nd qsim iteration. */ @Test - public void testA() { + void testA() { config.controller().setCreateGraphs(false); PSimConfigGroup pSimConfigGroup = new PSimConfigGroup(); @@ -115,7 +115,7 @@ public void install() { * in testA() was 134.52369453719413 and qsim score in testB was 131.84309487251033). */ @Test - public void testB() { + void testB() { config.controller().setOutputDirectory(utils.getOutputDirectory()); config.controller().setLastIteration(2); config.controller().setCreateGraphs(false); diff --git a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java index 3fe816aff64..ec938145c09 100644 --- a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java +++ b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java @@ -23,8 +23,8 @@ import ch.sbb.matsim.contrib.railsim.events.RailsimTrainStateEvent; import ch.sbb.matsim.contrib.railsim.qsimengine.RailsimQSimModule; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -62,12 +62,12 @@ public class RailsimIntegrationTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testMicroSimpleBiDirectionalTrack() { + void testMicroSimpleBiDirectionalTrack() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "microSimpleBiDirectionalTrack")); } @Test - public void testMesoUniDirectionalVaryingCapacities() { + void testMesoUniDirectionalVaryingCapacities() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "mesoUniDirectionalVaryingCapacities")); // print events of train1 for debugging @@ -174,33 +174,33 @@ public void testMesoUniDirectionalVaryingCapacities() { } @Test - public void testMicroTrackOppositeTraffic() { + void testMicroTrackOppositeTraffic() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "microTrackOppositeTraffic")); } @Test - public void testMicroTrackOppositeTrafficMany() { + void testMicroTrackOppositeTrafficMany() { // multiple trains, one slow train EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "microTrackOppositeTrafficMany")); } @Test - public void testMesoTwoSources() { + void testMesoTwoSources() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "mesoTwoSources")); } @Test - public void testMesoTwoSourcesComplex() { + void testMesoTwoSourcesComplex() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "mesoTwoSourcesComplex")); } @Test - public void testScenarioMesoGenfBernAllTrains() { + void testScenarioMesoGenfBernAllTrains() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "scenarioMesoGenfBern")); } @Test - public void testScenarioMesoGenfBernOneTrain() { + void testScenarioMesoGenfBernOneTrain() { // Remove vehicles except the first one Consumer filter = scenario -> { @@ -228,58 +228,58 @@ public void testScenarioMesoGenfBernOneTrain() { } @Test - public void testMicroThreeUniDirectionalTracks() { + void testMicroThreeUniDirectionalTracks() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "microThreeUniDirectionalTracks")); } @Test - public void testMicroTrainFollowingConstantSpeed() { + void testMicroTrainFollowingConstantSpeed() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "microTrainFollowingConstantSpeed")); } // This test is similar to testMicroTrainFollowingConstantSpeed but with varying speed levels along the corridor. @Test - public void testMicroTrainFollowingVaryingSpeed() { + void testMicroTrainFollowingVaryingSpeed() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "microTrainFollowingVaryingSpeed")); } @Test - public void testMicroStationSameLink() { + void testMicroStationSameLink() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "microStationSameLink")); } @Test - public void testMicroStationDifferentLink() { + void testMicroStationDifferentLink() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "microStationDifferentLink")); } @Test - public void testMicroJunctionCross() { + void testMicroJunctionCross() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "microJunctionCross")); } @Test - public void testMicroJunctionY() { + void testMicroJunctionY() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "microJunctionY")); } @Test - public void testMesoStationCapacityOne() { + void testMesoStationCapacityOne() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "mesoStationCapacityOne")); } @Test - public void testMesoStationCapacityTwo() { + void testMesoStationCapacityTwo() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "mesoStationCapacityTwo")); } @Test - public void testMesoStations() { + void testMesoStations() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "mesoStations")); } @Test - public void testMicroSimpleUniDirectionalTrack() { + void testMicroSimpleUniDirectionalTrack() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "microSimpleUniDirectionalTrack")); for (Event event : collector.getEvents()) { @@ -296,7 +296,7 @@ public void testMicroSimpleUniDirectionalTrack() { } @Test - public void testMicroStationRerouting() { + void testMicroStationRerouting() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "microStationRerouting")); collector.getEvents().forEach(System.out::println); // Checks end times @@ -309,7 +309,7 @@ public void testMicroStationRerouting() { } @Test - public void testMicroStationReroutingConcurrent() { + void testMicroStationReroutingConcurrent() { Consumer filter = scenario -> { TransitScheduleFactory f = scenario.getTransitSchedule().getFactory(); @@ -335,7 +335,7 @@ public void testMicroStationReroutingConcurrent() { } @Test - public void testScenarioKelheim() { + void testScenarioKelheim() { URL base = ExamplesUtils.getTestScenarioURL("kelheim"); @@ -373,7 +373,7 @@ public void testScenarioKelheim() { } @Test - public void testScenarioMicroMesoCombination() { + void testScenarioMicroMesoCombination() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "scenarioMicroMesoCombination")); } diff --git a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimCalcTest.java b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimCalcTest.java index e969aa3cb2c..bf7b63411e9 100644 --- a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimCalcTest.java +++ b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimCalcTest.java @@ -20,14 +20,14 @@ package ch.sbb.matsim.contrib.railsim.qsimengine; import org.assertj.core.data.Offset; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; public class RailsimCalcTest { @Test - public void testCalcAndSolveTraveledDist() { + void testCalcAndSolveTraveledDist() { assertThat(RailsimCalc.calcTraveledDist(5, 2, 0)) .isEqualTo(10); @@ -47,7 +47,7 @@ public void testCalcAndSolveTraveledDist() { } @Test - public void testCalcAndSolveTraveledDistNegative() { + void testCalcAndSolveTraveledDistNegative() { double d = RailsimCalc.calcTraveledDist(5, 5, -1); @@ -64,7 +64,7 @@ public void testCalcAndSolveTraveledDistNegative() { } @Test - public void testMaxSpeed() { + void testMaxSpeed() { double dist = 1000; @@ -86,7 +86,7 @@ public void testMaxSpeed() { } @Test - public void testCalcTargetDecel() { + void testCalcTargetDecel() { double d = RailsimCalc.calcTargetDecel(1000, 0, 10); @@ -101,7 +101,7 @@ public void testCalcTargetDecel() { } @Test - public void testCalcTargetSpeed() { + void testCalcTargetSpeed() { RailsimCalc.SpeedTarget target = RailsimCalc.calcTargetSpeed(100, 0.5, 0.5, 0, 23, 0); @@ -134,7 +134,7 @@ public void testCalcTargetSpeed() { } @Test - public void testCalcTargetSpeedForStop() { + void testCalcTargetSpeedForStop() { double v = RailsimCalc.calcTargetSpeedForStop(1000, 0.5, 0.5, 0); diff --git a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimEngineTest.java b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimEngineTest.java index 922fbb513e5..c2bb085c360 100644 --- a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimEngineTest.java +++ b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimEngineTest.java @@ -24,8 +24,8 @@ import ch.sbb.matsim.contrib.railsim.qsimengine.disposition.SimpleDisposition; import ch.sbb.matsim.contrib.railsim.qsimengine.router.TrainRouter; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.api.experimental.events.EventsManager; @@ -76,7 +76,7 @@ private RailsimTestUtils.Holder getTestEngine(String network) { } @Test - public void testSimple() { + void testSimple() { RailsimTestUtils.Holder test = getTestEngine("networkMicroBi.xml"); RailsimTestUtils.createDeparture(test, TestVehicle.Regio, "train", 0, "l1-2", "l5-6"); @@ -101,7 +101,7 @@ public void testSimple() { } @Test - public void testCongested() { + void testCongested() { RailsimTestUtils.Holder test = getTestEngine("networkMicroBi.xml"); @@ -117,7 +117,7 @@ public void testCongested() { } @Test - public void testCongestedWithHeadway() { + void testCongestedWithHeadway() { RailsimTestUtils.Holder test = getTestEngine("networkMicroBi.xml", l -> RailsimUtils.setMinimumHeadwayTime(l, 60)); @@ -134,7 +134,7 @@ public void testCongestedWithHeadway() { @Test - public void testOpposite() { + void testOpposite() { RailsimTestUtils.Holder test = getTestEngine("networkMicroBi.xml"); @@ -162,7 +162,7 @@ public void testOpposite() { } @Test - public void testVaryingSpeedOne() { + void testVaryingSpeedOne() { RailsimTestUtils.Holder test = getTestEngine("networkMesoUni.xml"); @@ -187,7 +187,7 @@ public void testVaryingSpeedOne() { } @Test - public void testVaryingSpeedMany() { + void testVaryingSpeedMany() { RailsimTestUtils.Holder test = getTestEngine("networkMesoUni.xml"); @@ -220,7 +220,7 @@ public void testVaryingSpeedMany() { } @Test - public void testTrainFollowing() { + void testTrainFollowing() { RailsimTestUtils.Holder test = getTestEngine("networkMicroUni.xml"); RailsimTestUtils.createDeparture(test, TestVehicle.Regio, "regio1", 0, "1-2", "20-21"); @@ -244,7 +244,7 @@ public void testTrainFollowing() { } @Test - public void testMicroTrainFollowingVaryingSpeed() { + void testMicroTrainFollowingVaryingSpeed() { RailsimTestUtils.Holder test = getTestEngine("networkMicroVaryingSpeed.xml"); diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/AvoidTolledRouteTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/AvoidTolledRouteTest.java index e9877f905ca..d7661de699c 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/AvoidTolledRouteTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/AvoidTolledRouteTest.java @@ -25,9 +25,9 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Assert; +import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.LinkLeaveEvent; @@ -37,8 +37,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.controler.Controler; import org.matsim.core.scenario.ScenarioUtils; -import org.matsim.testcases.MatsimTestUtils; - +import org.matsim.testcases.MatsimTestUtils; + /** * * Tests the integration of the roadpricing-package into the Controler. @@ -52,10 +52,10 @@ public class AvoidTolledRouteTest { @RegisterExtension - private MatsimTestUtils testUtils = new MatsimTestUtils(); - - @Test - public final void test1(){ + private MatsimTestUtils testUtils = new MatsimTestUtils(); + + @Test + final void test1(){ String configFile = testUtils.getClassInputDirectory() + "/config.xml"; diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/CalcPaidTollTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/CalcPaidTollTest.java index 2ca1f243fff..63ac002412e 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/CalcPaidTollTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/CalcPaidTollTest.java @@ -25,8 +25,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -56,7 +56,7 @@ public class CalcPaidTollTest { static private final Logger log = LogManager.getLogger(CalcPaidTollTest.class); @Test - public void testDistanceToll() { + void testDistanceToll() { Config config = ConfigUtils.loadConfig(utils.getClassInputDirectory() + "config.xml"); final String tollFile = utils.getClassInputDirectory() + "/roadpricing1.xml"; @@ -92,7 +92,7 @@ public void testDistanceToll() { } @Test - public void testAreaToll() { + void testAreaToll() { Config config = ConfigUtils.loadConfig(utils.getClassInputDirectory() + "config.xml"); final String tollFile = utils.getClassInputDirectory() + "/roadpricing2.xml"; @@ -143,7 +143,7 @@ public void testAreaToll() { } @Test - public void testCordonToll() { + void testCordonToll() { Config config = ConfigUtils.loadConfig(utils.getClassInputDirectory() + "config.xml"); final String tollFile = utils.getClassInputDirectory() + "/roadpricing3.xml"; diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/ModuleTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/ModuleTest.java index 912a2cff00b..2bbe59e82d8 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/ModuleTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/ModuleTest.java @@ -22,8 +22,10 @@ package org.matsim.contrib.roadpricing; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.controler.Controler; @@ -35,17 +37,21 @@ public class ModuleTest { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); - @Test(expected = RuntimeException.class) - public void testControlerWithoutRoadPricingDoesntWork() { - Config config = utils.loadConfig(utils.getClassInputDirectory() + "/config.xml"); - Controler controler = new Controler(config); - controler.run(); - // config has a roadpricing config group, but controler does not know about - // road pricing. - } + @Test + void testControlerWithoutRoadPricingDoesntWork() { + assertThrows(RuntimeException.class, () -> { + Config config = utils.loadConfig(utils.getClassInputDirectory() + "/config.xml"); + Controler controler = new Controler(config); + controler.run(); + // config has a roadpricing config group, but controler does not know about + // road pricing. + }); + // config has a roadpricing config group, but controler does not know about + // road pricing. + } - @Test - public void testControlerWithRoadPricingWorks() { + @Test + void testControlerWithRoadPricingWorks() { Config config = utils.loadConfig(utils.getClassInputDirectory() + "/config.xml"); Controler controler = new Controler(config); // controler.setModules(new RoadPricingModuleDefaults()); @@ -53,8 +59,8 @@ public void testControlerWithRoadPricingWorks() { controler.run(); } - @Test - public void testControlerWithRoadPricingByScenarioWorks() { + @Test + void testControlerWithRoadPricingByScenarioWorks() { Config config = utils.loadConfig(utils.getClassInputDirectory() + "/config.xml"); Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler = new Controler(scenario); @@ -64,8 +70,8 @@ public void testControlerWithRoadPricingByScenarioWorks() { } - @Test - public void testControlerWithRoadPricingByScenarioWorksTwice() { + @Test + void testControlerWithRoadPricingByScenarioWorksTwice() { Config config = utils.loadConfig(utils.getClassInputDirectory() + "/config.xml"); config.controller().setOutputDirectory(utils.getOutputDirectory()+"/1"); Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/PlansCalcRouteWithTollOrNotTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/PlansCalcRouteWithTollOrNotTest.java index 339abde2d1e..e75ed598afa 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/PlansCalcRouteWithTollOrNotTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/PlansCalcRouteWithTollOrNotTest.java @@ -26,8 +26,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -72,7 +72,7 @@ public class PlansCalcRouteWithTollOrNotTest { * toll or not. */ @Test - public void testBestAlternatives() { + void testBestAlternatives() { Config config = matsimTestUtils.createConfig(); config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); @@ -178,7 +178,7 @@ private PlansCalcRouteWithTollOrNot testee(final Scenario scenario, final RoadPr * Tests cases where the agent must pay the toll because one of its activities is on a tolled link */ @Test - public void testTolledActLink() { + void testTolledActLink() { Config config = matsimTestUtils.createConfig(); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); RoadPricingTestUtils.createNetwork2(scenario); @@ -204,7 +204,7 @@ public void testTolledActLink() { * to the next include tolled links */ @Test - public void testAllAlternativesTolled() { + void testAllAlternativesTolled() { Config config = matsimTestUtils.createConfig(); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); RoadPricingTestUtils.createNetwork2(scenario); @@ -243,7 +243,7 @@ private static Leg getLeg3(Config config, Population population, Id id1) } @Test - public void testOutsideTollTime() { + void testOutsideTollTime() { Config config = matsimTestUtils.createConfig(); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); RoadPricingTestUtils.createNetwork2(scenario); diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingConfigGroupTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingConfigGroupTest.java index ca59e1d482f..a22f0d46b39 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingConfigGroupTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingConfigGroupTest.java @@ -1,8 +1,8 @@ package org.matsim.contrib.roadpricing; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; @@ -12,13 +12,13 @@ public class RoadPricingConfigGroupTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void getTollLinksFile() { + void getTollLinksFile() { RoadPricingConfigGroup cg = new RoadPricingConfigGroup(); Assert.assertNull("Default roadpricing file is not set.", cg.getTollLinksFile()); } @Test - public void setTollLinksFile() { + void setTollLinksFile() { String file = "./test.xml.gz"; RoadPricingConfigGroup cg = new RoadPricingConfigGroup(); cg.setTollLinksFile(file); @@ -26,7 +26,7 @@ public void setTollLinksFile() { } @Test - public void getEnforcementProbability() { + void getEnforcementProbability() { RoadPricingConfigGroup cg = new RoadPricingConfigGroup(); Assert.assertEquals("Default probability should be 1.0", 1.0, cg.getEnforcementProbability(), MatsimTestUtils.EPSILON); @@ -36,7 +36,7 @@ public void getEnforcementProbability() { } @Test - public void setEnforcementProbability() { + void setEnforcementProbability() { RoadPricingConfigGroup cg = new RoadPricingConfigGroup(); try{ cg.setEnforcementProbability(1.2); diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingControlerIT.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingControlerIT.java index b4d8412ea5c..98260925936 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingControlerIT.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingControlerIT.java @@ -21,8 +21,8 @@ package org.matsim.contrib.roadpricing; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.core.config.Config; @@ -43,7 +43,7 @@ public class RoadPricingControlerIT { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testPaidTollsEndUpInScores() { + void testPaidTollsEndUpInScores() { // first run basecase Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil-extended"), "config.xml")); config.controller().setLastIteration(0); diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingIOTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingIOTest.java index a93960aeb94..012e8117b2d 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingIOTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingIOTest.java @@ -25,8 +25,8 @@ import java.io.File; import java.util.Iterator; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.ConfigUtils; @@ -48,7 +48,8 @@ public class RoadPricingIOTest { /** * Tests reader and writer to ensure that reading and writing does not modify the schemes. */ - @Test public void testWriteReadWrite() { + @Test + void testWriteReadWrite() { final String origFile = utils.getClassInputDirectory() + "roadpricing1.xml"; final String tmpFile1 = utils.getOutputDirectory() + "roadpricing1.xml"; final String tmpFile2 = utils.getOutputDirectory() + "roadpricing2.xml"; diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java index 6407bf1136d..8f41e3d40ab 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java @@ -26,9 +26,8 @@ import java.util.List; import jakarta.inject.Provider; - +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -73,7 +72,7 @@ public class TollTravelCostCalculatorTest { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testDisutilityResults() { + void testDisutilityResults() { Config config = ConfigUtils.createConfig() ; Scenario scenario = ScenarioUtils.createScenario(config) ; @@ -123,7 +122,7 @@ public void testDisutilityResults() { } @Test - public void testDistanceTollRouter() { + void testDistanceTollRouter() { Config config = utils.createConfig(); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); RoadPricingTestUtils.createNetwork2(scenario); @@ -208,7 +207,7 @@ public void testDistanceTollRouter() { } @Test - public void testLinkTollRouter() { + void testLinkTollRouter() { Config config = utils.createConfig(); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); RoadPricingTestUtils.createNetwork2(scenario); @@ -303,7 +302,7 @@ public void testLinkTollRouter() { } @Test - public void testCordonTollRouter() { + void testCordonTollRouter() { Config config = utils.createConfig(); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); RoadPricingTestUtils.createNetwork2(scenario); diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RoadPricingByConfigfileTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RoadPricingByConfigfileTest.java index 98ce6fec965..1869561d3b8 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RoadPricingByConfigfileTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RoadPricingByConfigfileTest.java @@ -21,8 +21,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; import org.matsim.core.events.EventsUtils; @@ -44,7 +44,7 @@ public class RoadPricingByConfigfileTest { private static final Logger log = LogManager.getLogger( RoadPricingByConfigfileTest.class ); @Test - public final void testMain() { + final void testMain() { try{ RunRoadPricingExample.main( new String []{ diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingExampleIT.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingExampleIT.java index b73a1169381..263b07483bd 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingExampleIT.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingExampleIT.java @@ -1,8 +1,8 @@ package org.matsim.contrib.roadpricing.run; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; public class RunRoadPricingExampleIT { @@ -11,7 +11,7 @@ public class RunRoadPricingExampleIT { private static final String TEST_CONFIG = "./test/input/org/matsim/contrib/roadpricing/AvoidTolledRouteTest/config.xml"; @Test - public void testRunToadPricingExample() { + void testRunToadPricingExample() { String[] args = new String[]{TEST_CONFIG , "--config:controler.outputDirectory=" + utils.getOutputDirectory() }; diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingFromCodeIT.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingFromCodeIT.java index ad85cf62146..6f29178e7e8 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingFromCodeIT.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingFromCodeIT.java @@ -3,7 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; @@ -12,7 +12,7 @@ public class RunRoadPricingFromCodeIT { private static final String TEST_CONFIG = "./test/input/org/matsim/contrib/roadpricing/AvoidTolledRouteTest/config.xml"; @Test - public void testRunRoadPricingFromCode(){ + void testRunRoadPricingFromCode(){ try{ LOG.info("Run context: " + new File("./").getAbsolutePath()); String[] args = new String[]{TEST_CONFIG}; diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingUsingTollFactorExampleIT.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingUsingTollFactorExampleIT.java index f43f85002f1..6431c4dab75 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingUsingTollFactorExampleIT.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingUsingTollFactorExampleIT.java @@ -1,13 +1,13 @@ package org.matsim.contrib.roadpricing.run; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class RunRoadPricingUsingTollFactorExampleIT { private static final String TEST_CONFIG = "./test/input/org/matsim/contrib/roadpricing/AvoidTolledRouteTest/config.xml"; @Test - public void testRunRoadPRicingUsingTollFactorExample() { + void testRunRoadPRicingUsingTollFactorExample() { String[] args = new String[]{TEST_CONFIG}; try { RunRoadPricingUsingTollFactorExample.main(args); diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/FloatMatrixIOTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/FloatMatrixIOTest.java index 1eb96dd4e35..8ee80d8a82b 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/FloatMatrixIOTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/FloatMatrixIOTest.java @@ -25,15 +25,15 @@ import java.util.HashSet; import java.util.Set; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author mrieser / SBB */ public class FloatMatrixIOTest { - @Test - public void testIO() throws IOException { + @Test + void testIO() throws IOException { Set zoneIds = new HashSet<>(); zoneIds.add("un"); zoneIds.add("dos"); diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/RooftopUtilsTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/RooftopUtilsTest.java index 7f42f0b8f0b..77d95e9430a 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/RooftopUtilsTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/RooftopUtilsTest.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.utils.misc.Time; /** @@ -32,8 +32,8 @@ */ public class RooftopUtilsTest { - @Test - public void testSortAndFilterConnections() { + @Test + void testSortAndFilterConnections() { List connections = new ArrayList<>(); // we'll misuse the transferCount as a connection identifier @@ -65,8 +65,8 @@ public void testSortAndFilterConnections() { Assert.assertEquals(4, connections.get(4).transferCount, 0.0); } - @Test - public void testCalcAverageAdaptionTime_1() { + @Test + void testCalcAverageAdaptionTime_1() { List connections = new ArrayList<>(); // 15-min headway, starting at 07:50, so the first rooftop is short and the last rooftop is cut @@ -106,8 +106,8 @@ public void testCalcAverageAdaptionTime_1() { // the frequency would be 3600 / 219 / 4 = 4.1096 } - @Test - public void testCalcAverageAdaptionTime_2() { + @Test + void testCalcAverageAdaptionTime_2() { List connections = new ArrayList<>(); // 15-min headway, starting at 07:59 (so the first rooftop is cut, and the last is short) @@ -124,8 +124,8 @@ public void testCalcAverageAdaptionTime_2() { // the frequency would be 3600 / 225 / 4 = 4.0 } - @Test - public void testCalcAverageAdaptionTime_noEarlierDeparture() { + @Test + void testCalcAverageAdaptionTime_noEarlierDeparture() { List connections = new ArrayList<>(); ODConnection c0, c1; @@ -143,8 +143,8 @@ public void testCalcAverageAdaptionTime_noEarlierDeparture() { Assert.assertEquals(1000.0, adaptionTime, 1e-7); } - @Test - public void testCalcAverageAdaptionTime_noLaterDeparture() { + @Test + void testCalcAverageAdaptionTime_noLaterDeparture() { List connections = new ArrayList<>(); ODConnection c0, c1; @@ -160,8 +160,8 @@ public void testCalcAverageAdaptionTime_noLaterDeparture() { Assert.assertEquals(900.0, adaptionTime, 1e-7); } - @Test - public void testCalcAverageAdaptionTime_noDepartureInRange() { + @Test + void testCalcAverageAdaptionTime_noDepartureInRange() { List connections = new ArrayList<>(); ODConnection c0, c1; @@ -177,8 +177,8 @@ public void testCalcAverageAdaptionTime_noDepartureInRange() { Assert.assertEquals(2600.0, adaptionTime, 1e-7); } - @Test - public void testCalcAverageAdaptionTime_singleDepartureEarly() { + @Test + void testCalcAverageAdaptionTime_singleDepartureEarly() { List connections = new ArrayList<>(); ODConnection c0, c1; @@ -193,8 +193,8 @@ public void testCalcAverageAdaptionTime_singleDepartureEarly() { Assert.assertEquals(4800.0, adaptionTime, 1e-7); } - @Test - public void testCalcAverageAdaptionTime_singleDepartureInRange() { + @Test + void testCalcAverageAdaptionTime_singleDepartureInRange() { List connections = new ArrayList<>(); ODConnection c0; @@ -209,8 +209,8 @@ public void testCalcAverageAdaptionTime_singleDepartureInRange() { Assert.assertEquals(1300.0, adaptionTime, 1e-7); } - @Test - public void testCalcAverageAdaptionTime_singleDepartureLate() { + @Test + void testCalcAverageAdaptionTime_singleDepartureLate() { List connections = new ArrayList<>(); ODConnection c0; @@ -225,8 +225,8 @@ public void testCalcAverageAdaptionTime_singleDepartureLate() { Assert.assertEquals(2400.0, adaptionTime, 1e-7); } - @Test - public void testCalcConnectionShares() { + @Test + void testCalcConnectionShares() { List connections = new ArrayList<>(); // 15-min headway @@ -283,8 +283,8 @@ public void testCalcConnectionShares() { Assert.assertEquals(2.0 / 60.0, shares.get(c5), 1e-7); } - @Test - public void testCalculationShares_noEarlierDeparture() { + @Test + void testCalculationShares_noEarlierDeparture() { List connections = new ArrayList<>(); ODConnection c0, c1; @@ -310,8 +310,8 @@ public void testCalculationShares_noEarlierDeparture() { Assert.assertEquals(0.0, shares.get(c1), 1e-7); } - @Test - public void testCalculationShares_noEarlierDeparture2() { + @Test + void testCalculationShares_noEarlierDeparture2() { List connections = new ArrayList<>(); ODConnection c0, c1; @@ -339,8 +339,8 @@ public void testCalculationShares_noEarlierDeparture2() { Assert.assertEquals(1.0 / 3.0, shares.get(c1), 1e-7); } - @Test - public void testCalculationShares_noLaterDeparture() { + @Test + void testCalculationShares_noLaterDeparture() { List connections = new ArrayList<>(); ODConnection c0, c1; @@ -368,8 +368,8 @@ public void testCalculationShares_noLaterDeparture() { Assert.assertEquals(5.0 / 6.0, shares.get(c1), 1e-7); } - @Test - public void testCalculationShares_noDepartureInRange() { + @Test + void testCalculationShares_noDepartureInRange() { List connections = new ArrayList<>(); ODConnection c0, c1; @@ -397,8 +397,8 @@ public void testCalculationShares_noDepartureInRange() { Assert.assertEquals(1.0 / 3.0, shares.get(c1), 1e-7); } - @Test - public void testCalculationShares_singleDepartureEarly() { + @Test + void testCalculationShares_singleDepartureEarly() { List connections = new ArrayList<>(); ODConnection c0, c1; @@ -408,8 +408,8 @@ public void testCalculationShares_singleDepartureEarly() { Assert.assertEquals(1.0, shares.get(c0), 1e-7); } - @Test - public void testCalculationShares_singleDepartureInRange() { + @Test + void testCalculationShares_singleDepartureInRange() { List connections = new ArrayList<>(); ODConnection c0, c1; @@ -419,8 +419,8 @@ public void testCalculationShares_singleDepartureInRange() { Assert.assertEquals(1.0, shares.get(c0), 1e-7); } - @Test - public void testCalculationShares_singleDepartureLate() { + @Test + void testCalculationShares_singleDepartureLate() { List connections = new ArrayList<>(); ODConnection c0, c1; diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/config/SBBTransitConfigGroupTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/config/SBBTransitConfigGroupTest.java index 5624833ef10..e78c20f85e2 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/config/SBBTransitConfigGroupTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/config/SBBTransitConfigGroupTest.java @@ -24,7 +24,7 @@ import java.io.OutputStreamWriter; import java.util.Collections; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigReader; import org.matsim.core.config.ConfigUtils; @@ -35,8 +35,8 @@ */ public class SBBTransitConfigGroupTest { - @Test - public void testConfigIO() { + @Test + void testConfigIO() { System.setProperty("matsim.preferLocalDtds", "true"); SBBTransitConfigGroup ptConfig1 = new SBBTransitConfigGroup(); diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java index f40c02b6b02..5c0b3452454 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java @@ -26,8 +26,8 @@ import java.nio.charset.StandardCharsets; import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigReader; @@ -51,9 +51,9 @@ public void setUp() { System.setProperty("matsim.preferLocalDtds", "true"); } - // https://github.com/SchweizerischeBundesbahnen/matsim-sbb-extensions/issues/3 - @Test - public void testIntegration() { + // https://github.com/SchweizerischeBundesbahnen/matsim-sbb-extensions/issues/3 + @Test + void testIntegration() { String xmlConfig = "\n" + "\n" + "\n" + diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java index 54dcc62891c..7a06e85d0ed 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java @@ -25,8 +25,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.controler.Controler; import org.matsim.core.mobsim.framework.Mobsim; import org.matsim.core.mobsim.qsim.QSim; @@ -42,8 +42,8 @@ public class SBBTransitQSimEngineIntegrationTest { private static final Logger log = LogManager.getLogger(SBBTransitQSimEngineIntegrationTest.class); @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void testIntegration() { + @Test + void testIntegration() { TestFixture f = new TestFixture(); f.config.controller().setOutputDirectory(this.utils.getOutputDirectory()); @@ -67,8 +67,8 @@ public void testIntegration() { Assert.assertFalse(components.hasNamedComponent(TransitEngineModule.TRANSIT_ENGINE_NAME)); } - @Test - public void testIntegration_misconfiguration() { + @Test + void testIntegration_misconfiguration() { TestFixture f = new TestFixture(); Set mainModes = new HashSet<>(); diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineTest.java index d80dc5793d5..f176c763bd0 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; import org.matsim.api.core.v01.events.ActivityStartEvent; @@ -69,8 +69,8 @@ private static void assertEqualEvent(Class eventClass, double t Assert.assertEquals(time, event.getTime(), 1e-7); } - @Test - public void testDriver() { + @Test + void testDriver() { TestFixture f = new TestFixture(); EventsManager eventsManager = EventsUtils.createEventsManager(f.config); @@ -117,8 +117,8 @@ private void assertNextStop(SBBTransitDriverAgent driver, TransitRouteStop stop, driver.depart(f, routeDepTime + depOffset); } - @Test - public void testEvents_withoutPassengers_withoutLinks() { + @Test + void testEvents_withoutPassengers_withoutLinks() { TestFixture f = new TestFixture(); EventsManager eventsManager = EventsUtils.createEventsManager(f.config); @@ -159,11 +159,11 @@ public void testEvents_withoutPassengers_withoutLinks() { assertEqualEvent(PersonArrivalEvent.class, 30720, allEvents.get(14)); } - /** - * This test also checks that the passenger boarding/leaving times are correctly taken into account - */ - @Test - public void testEvents_withPassengers_withoutLinks() { + /** + * This test also checks that the passenger boarding/leaving times are correctly taken into account + */ + @Test + void testEvents_withPassengers_withoutLinks() { TestFixture f = new TestFixture(); f.addSingleTransitDemand(); @@ -214,8 +214,8 @@ public void testEvents_withPassengers_withoutLinks() { assertEqualEvent(PersonArrivalEvent.class, 30720, allEvents.get(21)); // driver } - @Test - public void testEvents_withThreePassengers_withoutLinks() { + @Test + void testEvents_withThreePassengers_withoutLinks() { TestFixture f = new TestFixture(); f.addTripleTransitDemand(); @@ -280,8 +280,8 @@ public void testEvents_withThreePassengers_withoutLinks() { assertEqualEvent(PersonArrivalEvent.class, 30720, allEvents.get(35)); // driver } - @Test - public void testEvents_withoutPassengers_withLinks() { + @Test + void testEvents_withoutPassengers_withLinks() { TestFixture f = new TestFixture(); f.sbbConfig.setCreateLinkEventsInterval(1); @@ -331,8 +331,8 @@ public void testEvents_withoutPassengers_withLinks() { assertEqualEvent(PersonArrivalEvent.class, 30720, allEvents.get(22)); } - @Test - public void testEvents_withoutPassengers_withLinks_Sesselbahn() { + @Test + void testEvents_withoutPassengers_withLinks_Sesselbahn() { TestFixture f = new TestFixture(); f.addSesselbahn(true, false); f.sbbConfig.setCreateLinkEventsInterval(1); @@ -373,13 +373,13 @@ public void testEvents_withoutPassengers_withLinks_Sesselbahn() { assertEqualEvent(PersonArrivalEvent.class, 35120, allEvents.get(12)); } - /** - * during development, I had a case where the traveltime-offset between two stops was 0 seconds. This resulted in the 2nd stop being immediately handled, and only after that the - * linkLeave/linkEnter-Events were generated. As the 2nd stop happened to be the last one, the driver already left the vehicle, which then resulted in an exception in some event handler trying to - * figure out the driver of the vehicle driving around. This tests reproduces this situation in order to check that the code can correctly cope with such a situation. - */ - @Test - public void testEvents_withoutPassengers_withLinks_SesselbahnMalformed() { + /** + * during development, I had a case where the traveltime-offset between two stops was 0 seconds. This resulted in the 2nd stop being immediately handled, and only after that the + * linkLeave/linkEnter-Events were generated. As the 2nd stop happened to be the last one, the driver already left the vehicle, which then resulted in an exception in some event handler trying to + * figure out the driver of the vehicle driving around. This tests reproduces this situation in order to check that the code can correctly cope with such a situation. + */ + @Test + void testEvents_withoutPassengers_withLinks_SesselbahnMalformed() { TestFixture f = new TestFixture(); f.addSesselbahn(true, true); f.sbbConfig.setCreateLinkEventsInterval(1); @@ -420,12 +420,12 @@ public void testEvents_withoutPassengers_withLinks_SesselbahnMalformed() { assertEqualEvent(PersonArrivalEvent.class, 35000, allEvents.get(12)); } - /** - * During first tests, some events were out-of-order in time, leading to an exception, due to the first stop on a route having a departure offset > 0. This tests reproduces this situation in order - * to check that the code can correctly cope with such a situation. - */ - @Test - public void testEvents_withoutPassengers_withLinks_DelayedFirstDeparture() { + /** + * During first tests, some events were out-of-order in time, leading to an exception, due to the first stop on a route having a departure offset > 0. This tests reproduces this situation in order + * to check that the code can correctly cope with such a situation. + */ + @Test + void testEvents_withoutPassengers_withLinks_DelayedFirstDeparture() { TestFixture f = new TestFixture(); f.delayDepartureAtFirstStop(); f.sbbConfig.setCreateLinkEventsInterval(1); @@ -476,11 +476,11 @@ public void testEvents_withoutPassengers_withLinks_DelayedFirstDeparture() { assertEqualEvent(PersonArrivalEvent.class, 30720, allEvents.get(22)); } - /** - * During tests, the travel time between two stops was not correctly calculated when the two stops were connected with a single direct link, and each of the stops is on a zero-length loop link. - */ - @Test - public void testEvents_withoutPassengers_withLinks_FromToLoopLink() { + /** + * During tests, the travel time between two stops was not correctly calculated when the two stops were connected with a single direct link, and each of the stops is on a zero-length loop link. + */ + @Test + void testEvents_withoutPassengers_withLinks_FromToLoopLink() { TestFixture f = new TestFixture(); f.addLoopyRoute(true); f.sbbConfig.setCreateLinkEventsInterval(1); @@ -531,8 +531,8 @@ public void testEvents_withoutPassengers_withLinks_FromToLoopLink() { assertEqualEvent(PersonArrivalEvent.class, 30570, allEvents.get(22)); } - @Test - public void testMisconfiguration() { + @Test + void testMisconfiguration() { TestFixture f = new TestFixture(); f.config.transit().setTransitModes(CollectionUtils.stringToSet("pt,train,bus")); f.sbbConfig.setDeterministicServiceModes(CollectionUtils.stringToSet("train,tram,ship")); @@ -557,8 +557,8 @@ public void testMisconfiguration() { } - @Test - public void testCreateEventsInterval() { + @Test + void testCreateEventsInterval() { TestFixture f = new TestFixture(); f.sbbConfig.setCreateLinkEventsInterval(3); diff --git a/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java b/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java index 4afd46b468d..5e6a5d0cd48 100644 --- a/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java +++ b/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java @@ -10,7 +10,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.events.handler.PersonDepartureEventHandler; import org.matsim.contrib.shared_mobility.run.SharingConfigGroup; import org.matsim.contrib.shared_mobility.run.SharingModule; @@ -38,7 +38,7 @@ public class RunIT { @Test - public final void test() throws UncheckedIOException, ConfigurationException, URISyntaxException { + final void test() throws UncheckedIOException, ConfigurationException, URISyntaxException { URL scenarioUrl = ExamplesUtils.getTestScenarioURL("siouxfalls-2014"); diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/adaptiveSignals/AdaptiveSignalsExampleTest.java b/contribs/signals/src/test/java/org/matsim/codeexamples/adaptiveSignals/AdaptiveSignalsExampleTest.java index a8f3454f627..2ea82346bc0 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/adaptiveSignals/AdaptiveSignalsExampleTest.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/adaptiveSignals/AdaptiveSignalsExampleTest.java @@ -20,8 +20,8 @@ */ package org.matsim.codeexamples.adaptiveSignals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -33,7 +33,7 @@ public class AdaptiveSignalsExampleTest { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void testAdaptiveSignalsExample() { + void testAdaptiveSignalsExample() { String configFileName = "./examples/tutorial/singleCrossingScenario/config.xml"; RunAdaptiveSignalsExample.run(configFileName, testUtils.getOutputDirectory() + "/", false); } diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateIntergreensExampleTest.java b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateIntergreensExampleTest.java index 3068410bbba..f49b8bb8cca 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateIntergreensExampleTest.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateIntergreensExampleTest.java @@ -23,12 +23,12 @@ import java.io.IOException; -import org.junit.Assert; +import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.utils.misc.CRCChecksum; -import org.matsim.testcases.MatsimTestUtils; - +import org.matsim.testcases.MatsimTestUtils; + /** * @author tthunig * @@ -37,10 +37,10 @@ public class CreateIntergreensExampleTest { private static final String DIR_TO_COMPARE_WITH = "./examples/tutorial/example90TrafficLights/useSignalInput/"; - @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); - - @Test - public void testIntergreenExample(){ + @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); + + @Test + void testIntergreenExample(){ try { String[] args = {testUtils.getOutputDirectory()}; CreateIntergreensExample.main(args); diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleTest.java b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleTest.java index c52847d338b..bd97d5c2c26 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleTest.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleTest.java @@ -25,12 +25,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.utils.misc.CRCChecksum; -import org.matsim.testcases.MatsimTestUtils; - +import org.matsim.testcases.MatsimTestUtils; + /** * @author tthunig * @@ -40,10 +40,10 @@ public class CreateSignalInputExampleTest { private static final String DIR_TO_COMPARE_WITH = "./examples/tutorial/example90TrafficLights/useSignalInput/woLanes/"; - @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); - - @Test - public void testCreateSignalInputExample(){ + @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); + + @Test + void testCreateSignalInputExample(){ try { (new CreateSignalInputExample()).run(testUtils.getOutputDirectory()); } catch (IOException e) { diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleWithLanesTest.java b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleWithLanesTest.java index fd10d568b5c..f76efe99da2 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleWithLanesTest.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleWithLanesTest.java @@ -23,12 +23,12 @@ import java.io.IOException; -import org.junit.Assert; +import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.utils.misc.CRCChecksum; -import org.matsim.testcases.MatsimTestUtils; - +import org.matsim.testcases.MatsimTestUtils; + /** * @author tthunig * @@ -37,10 +37,10 @@ public class CreateSignalInputExampleWithLanesTest { private static final String DIR_TO_COMPARE_WITH = "./examples/tutorial/example90TrafficLights/useSignalInput/withLanes/"; - @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); - - @Test - public void testCreateSignalInputExampleWithLanes(){ + @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); + + @Test + void testCreateSignalInputExampleWithLanes(){ try { (new CreateSignalInputWithLanesExample()).run(testUtils.getOutputDirectory()); } catch (IOException e) { diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleTest.java b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleTest.java index 0b63f1b71a0..9da52c5d00a 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleTest.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleTest.java @@ -19,8 +19,8 @@ package org.matsim.codeexamples.fixedTimeSignals; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; @@ -35,7 +35,7 @@ public class RunSignalSystemsExampleTest { @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public final void testExampleWithHoles() { + final void testExampleWithHoles() { boolean usingOTFVis = false ; try { RunSignalSystemsExampleWithHoles.run(usingOTFVis); @@ -46,7 +46,7 @@ public final void testExampleWithHoles() { } @Test - public final void testMinimalExample() { + final void testMinimalExample() { try { Config config = ConfigUtils.loadConfig("./examples/tutorial/example90TrafficLights/useSignalInput/withLanes/config.xml"); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunVisualizeSignalScenarioWithLanesGUITest.java b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunVisualizeSignalScenarioWithLanesGUITest.java index 799610d8faf..c40f531b26f 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunVisualizeSignalScenarioWithLanesGUITest.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunVisualizeSignalScenarioWithLanesGUITest.java @@ -1,7 +1,7 @@ package org.matsim.codeexamples.fixedTimeSignals; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests otfvis for signals with/ without lanes. @@ -25,15 +25,15 @@ public static void main(String[] args) { Assert.fail("something went wrong") ; } } - + @Test - public void testSignalExampleVisualizationWithLanes(){ + void testSignalExampleVisualizationWithLanes(){ String[] startOtfvis = {"false"}; main(startOtfvis); } - + @Test - public void testSignalExampleVisualizationWoLanes(){ + void testSignalExampleVisualizationWoLanes(){ try { VisualizeSignalScenario.run(false); } catch (Exception ee) { diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/FixResponsiveSignalResultsIT.java b/contribs/signals/src/test/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/FixResponsiveSignalResultsIT.java index 486848880db..ce1989f66de 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/FixResponsiveSignalResultsIT.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/FixResponsiveSignalResultsIT.java @@ -25,9 +25,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.signals.data.SignalsData; import org.matsim.contrib.signals.data.signalcontrol.v20.SignalGroupSettingsData; @@ -36,9 +36,9 @@ import org.matsim.contrib.signals.model.SignalGroup; import org.matsim.contrib.signals.model.SignalPlan; import org.matsim.contrib.signals.model.SignalSystem; -import org.matsim.testcases.MatsimTestUtils; - - +import org.matsim.testcases.MatsimTestUtils; + + /** * @author tthunig * @@ -48,10 +48,10 @@ public class FixResponsiveSignalResultsIT { private static final Logger LOG = LogManager.getLogger(FixResponsiveSignalResultsIT.class); @RegisterExtension - private MatsimTestUtils testUtils = new MatsimTestUtils(); - - @Test - public void testOneCrossingExample() { + private MatsimTestUtils testUtils = new MatsimTestUtils(); + + @Test + void testOneCrossingExample() { LOG.info("Fix the results from the simple one-crossing-example in RunSimpleResponsiveSignalExample."); RunSimpleResponsiveSignalExample responsiveSignal = new RunSimpleResponsiveSignalExample(); responsiveSignal.run(); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/io/MatsimFileTypeGuesserSignalsTest.java b/contribs/signals/src/test/java/org/matsim/contrib/io/MatsimFileTypeGuesserSignalsTest.java index 9eca26c9a54..7bd326a50b0 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/io/MatsimFileTypeGuesserSignalsTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/io/MatsimFileTypeGuesserSignalsTest.java @@ -25,7 +25,7 @@ import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contrib.signals.data.MatsimSignalSystemsReader; import org.matsim.core.utils.io.MatsimFileTypeGuesser; @@ -34,18 +34,18 @@ * */ public class MatsimFileTypeGuesserSignalsTest { - + @Test - public void testSignalSystemsV20XML() throws IOException { + void testSignalSystemsV20XML() throws IOException { MatsimFileTypeGuesser g = new MatsimFileTypeGuesser("test/input/org/matsim/contrib/signals/data/signalsystems/v20/testSignalSystems_v2.0.xml"); assertEquals(MatsimFileTypeGuesser.FileType.SignalSystems, g.getGuessedFileType()); assertNull(g.getPublicId()); assertNotNull(g.getSystemId()); assertEquals(MatsimSignalSystemsReader.SIGNALSYSTEMS20, g.getSystemId()); } - + @Test - public void testSignalGroupsV20XML() throws IOException { + void testSignalGroupsV20XML() throws IOException { MatsimFileTypeGuesser g = new MatsimFileTypeGuesser("test/input/org/matsim/contrib/signals/data/signalgroups/v20/testSignalGroups_v2.0.xml"); assertEquals(MatsimFileTypeGuesser.FileType.SignalGroups, g.getGuessedFileType()); assertNull(g.getPublicId()); @@ -54,7 +54,7 @@ public void testSignalGroupsV20XML() throws IOException { } @Test - public void testSignalControlV20XML() throws IOException { + void testSignalControlV20XML() throws IOException { MatsimFileTypeGuesser g = new MatsimFileTypeGuesser("test/input/org/matsim/contrib/signals/data/signalcontrol/v20/testSignalControl_v2.0.xml"); assertEquals(MatsimFileTypeGuesser.FileType.SignalControl, g.getGuessedFileType()); assertNull(g.getPublicId()); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/CalculateAngleTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/CalculateAngleTest.java index d8ffa385400..196d6674661 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/CalculateAngleTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/CalculateAngleTest.java @@ -5,9 +5,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -21,9 +21,9 @@ import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.MutableScenario; import org.matsim.core.scenario.ScenarioUtils; -import org.matsim.testcases.MatsimTestUtils; - - +import org.matsim.testcases.MatsimTestUtils; + + /** * @author aneumann * @author dgrether @@ -32,13 +32,13 @@ public class CalculateAngleTest { private static final Logger log = LogManager.getLogger(CalculateAngleTest.class); - @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - - /** - * @author aneumann - */ - @Test - public void testGetLeftLane() { + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); + + /** + * @author aneumann + */ + @Test + void testGetLeftLane() { Config conf = utils.loadConfig(utils.getClassInputDirectory() + "config.xml"); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(conf); new MatsimNetworkReader(scenario.getNetwork()).parse(conf.network().getInputFileURL(conf.getContext())); @@ -61,13 +61,13 @@ public void testGetLeftLane() { Assert.assertEquals( scenario.getNetwork().getLinks().get(Id.create("5", Link.class)), NetworkUtils.getLeftmostTurnExcludingU(scenario.getNetwork().getLinks().get(Id.create("3", Link.class)))); - } - - /** - * @author dgrether - */ - @Test - public void testGetOutLinksSortedByAngle(){ + } + + /** + * @author dgrether + */ + @Test + void testGetOutLinksSortedByAngle(){ Scenario scenario; double twicePi = Math.PI * 2; double piStep = Math.PI / 180.0; diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/SignalUtilsTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/SignalUtilsTest.java index 22d76808d68..69a06a655fd 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/SignalUtilsTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/SignalUtilsTest.java @@ -21,9 +21,8 @@ import java.util.Map; -import org.junit.Assert; - -import org.junit.Test; +import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.signals.data.SignalsDataImpl; import org.matsim.contrib.signals.utils.SignalUtils; @@ -36,13 +35,13 @@ import org.matsim.contrib.signals.data.signalsystems.v20.SignalSystemsDataFactory; import org.matsim.contrib.signals.model.Signal; import org.matsim.contrib.signals.model.SignalGroup; -import org.matsim.contrib.signals.model.SignalSystem; - - -public class SignalUtilsTest { - - @Test - public final void testCreateAndAddSignalGroups4Signals() { +import org.matsim.contrib.signals.model.SignalSystem; + + +public class SignalUtilsTest { + + @Test + final void testCreateAndAddSignalGroups4Signals() { Id id1 = Id.create("1", SignalSystem.class); Id idSg1 = Id.create("1", SignalGroup.class); Id idSg3 = Id.create("3", SignalGroup.class); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/analysis/DelayAnalysisToolTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/analysis/DelayAnalysisToolTest.java index 468f9e7f376..a733aaac266 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/analysis/DelayAnalysisToolTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/analysis/DelayAnalysisToolTest.java @@ -4,8 +4,8 @@ import java.util.List; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -67,7 +67,7 @@ public class DelayAnalysisToolTest { private static final int NUMBER_OF_PERSONS = 5; @Test - public void testGetTotalDelayOnePerson(){ + void testGetTotalDelayOnePerson(){ Scenario scenario = prepareTest(1); EventsManager events = EventsUtils.createEventsManager(); @@ -95,7 +95,7 @@ public void handleEvent(Event event) { } @Test - public void testGetTotalDelaySeveralPerson(){ + void testGetTotalDelaySeveralPerson(){ Scenario scenario = prepareTest(NUMBER_OF_PERSONS); EventsManager events = EventsUtils.createEventsManager(); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/QSimSignalTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/QSimSignalTest.java index 62d0078f7c3..d46a231d78e 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/QSimSignalTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/QSimSignalTest.java @@ -19,11 +19,13 @@ * *********************************************************************** */ package org.matsim.contrib.signals.builder; +import static org.junit.jupiter.api.Assertions.assertThrows; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.LinkEnterEvent; import org.matsim.api.core.v01.events.handler.LinkEnterEventHandler; @@ -66,7 +68,7 @@ public class QSimSignalTest implements * Tests the setup with a traffic light that shows all the time green */ @Test - public void testTrafficLightIntersection2arms1AgentV20() { + void testTrafficLightIntersection2arms1AgentV20() { // configure and load standard scenario Scenario scenario = fixture.createAndLoadTestScenarioOneSignal(false ); @@ -79,7 +81,7 @@ public void testTrafficLightIntersection2arms1AgentV20() { * Tests the setup with a traffic light that shows red up to second 99 then in sec 100 green. */ @Test - public void testSignalSystems1AgentGreenAtSec100() { + void testSignalSystems1AgentGreenAtSec100() { // configure and load standard scenario Scenario scenario = fixture.createAndLoadTestScenarioOneSignal(false ); // modify scenario @@ -101,33 +103,35 @@ public void testSignalSystems1AgentGreenAtSec100() { /** * Tests the setup with a traffic light that shows red less than the specified intergreen time of five seconds. */ - @Test(expected = RuntimeException.class) - public void testIntergreensAbortOneAgentDriving() { - //configure and load standard scenario - Scenario scenario = fixture.createAndLoadTestScenarioOneSignal(true ); - // modify scenario - SignalsData signalsData = (SignalsData) scenario.getScenarioElement(SignalsData.ELEMENT_NAME); - SignalSystemControllerData controllerData = signalsData.getSignalControlData().getSignalSystemControllerDataBySystemId().get( - fixture.signalSystemId2 ); - SignalPlanData planData = controllerData.getSignalPlanData().get( fixture.signalPlanId2 ); - planData.setStartTime(0.0); - planData.setEndTime(0.0); - planData.setCycleTime(60); - SignalGroupSettingsData groupData = planData.getSignalGroupSettingsDataByGroupId().get( fixture.signalGroupId100 ); - groupData.setOnset(0); - groupData.setDropping(59); - - runQSimWithSignals(scenario, false); - - // if this code is reached, no exception has been thrown - Assert.fail("The simulation should abort because of intergreens violation."); + @Test + void testIntergreensAbortOneAgentDriving() { + assertThrows(RuntimeException.class, () -> { + //configure and load standard scenario + Scenario scenario = fixture.createAndLoadTestScenarioOneSignal(true); + // modify scenario + SignalsData signalsData = (SignalsData) scenario.getScenarioElement(SignalsData.ELEMENT_NAME); + SignalSystemControllerData controllerData = signalsData.getSignalControlData().getSignalSystemControllerDataBySystemId().get( + fixture.signalSystemId2); + SignalPlanData planData = controllerData.getSignalPlanData().get(fixture.signalPlanId2); + planData.setStartTime(0.0); + planData.setEndTime(0.0); + planData.setCycleTime(60); + SignalGroupSettingsData groupData = planData.getSignalGroupSettingsDataByGroupId().get(fixture.signalGroupId100); + groupData.setOnset(0); + groupData.setDropping(59); + + runQSimWithSignals(scenario, false); + + // if this code is reached, no exception has been thrown + Assert.fail("The simulation should abort because of intergreens violation."); + }); } /** * Tests the setup with a traffic light which red time corresponds to the specified intergreen time of five seconds. */ @Test - public void testIntergreensNoAbortOneAgentDriving() { + void testIntergreensNoAbortOneAgentDriving() { //configure and load standard scenario Scenario scenario = fixture.createAndLoadTestScenarioOneSignal(true ); // modify scenario @@ -149,22 +153,24 @@ public void testIntergreensNoAbortOneAgentDriving() { /** * Tests the setup with two conflicting directions showing green together */ - @Test(expected = RuntimeException.class) - public void testConflictingDirectionsAbortOneAgentDriving() { - //configure and load test scenario with data about conflicting directions - Scenario scenario = fixture.createAndLoadTestScenarioTwoSignals(true ); + @Test + void testConflictingDirectionsAbortOneAgentDriving() { + assertThrows(RuntimeException.class, () -> { + //configure and load test scenario with data about conflicting directions + Scenario scenario = fixture.createAndLoadTestScenarioTwoSignals(true); - runQSimWithSignals(scenario, false); + runQSimWithSignals(scenario, false); - // if this code is reached, no exception has been thrown - Assert.fail("The simulation should abort because of intergreens violation."); + // if this code is reached, no exception has been thrown + Assert.fail("The simulation should abort because of intergreens violation."); + }); } /** * Tests the setup with two conflicting directions not showing green together */ @Test - public void testConflictingDirectionsNoAbortOneAgentDriving() { + void testConflictingDirectionsNoAbortOneAgentDriving() { //configure and load test scenario with data about conflicting directions Scenario scenario = fixture.createAndLoadTestScenarioTwoSignals(true ); SignalsData signalsData = (SignalsData) scenario.getScenarioElement(SignalsData.ELEMENT_NAME); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeFourWaysTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeFourWaysTest.java index 350093c5ec6..30c81f963c2 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeFourWaysTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeFourWaysTest.java @@ -21,8 +21,8 @@ package org.matsim.contrib.signals.builder; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.signals.SignalSystemsConfigGroup; import org.matsim.contrib.signals.data.SignalsData; @@ -53,7 +53,7 @@ public class TravelTimeFourWaysTest { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void testTrafficLightIntersection4arms() { + void testTrafficLightIntersection4arms() { Scenario scenario = this.createTestScenario(); scenario.getConfig().plans().setInputFile("plans.xml.gz"); ScenarioUtils.loadScenario(scenario); @@ -62,7 +62,7 @@ public void testTrafficLightIntersection4arms() { } @Test - public void testTrafficLightIntersection4armsWithUTurn() { + void testTrafficLightIntersection4armsWithUTurn() { Scenario scenario = this.createTestScenario(); scenario.getConfig().plans().setInputFile("plans_uturn.xml.gz"); ScenarioUtils.loadScenario(scenario); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeOneWayTestIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeOneWayTestIT.java index 0dc9ba78923..958b2b252c4 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeOneWayTestIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeOneWayTestIT.java @@ -24,8 +24,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.LinkEnterEvent; @@ -70,22 +70,22 @@ public class TravelTimeOneWayTestIT { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void testSignalOutflow_withLanes() { + void testSignalOutflow_withLanes() { runAndTestDifferentGreensplitSignals(this.loadAllGreenScenario(true)); } @Test - public void testSignalOutflow_woLanes() { + void testSignalOutflow_woLanes() { runAndTestDifferentGreensplitSignals(this.loadAllGreenScenario(false)); } @Test - public void testAllGreenSignalVsNoSignal_withLanes() { + void testAllGreenSignalVsNoSignal_withLanes() { runAndCompareAllGreenWithNoSignals(this.loadAllGreenScenario(true)); } @Test - public void testAllGreenSignalVsNoSignal_woLanes() { + void testAllGreenSignalVsNoSignal_woLanes() { runAndCompareAllGreenWithNoSignals(this.loadAllGreenScenario(false)); } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java index b7498921eae..8fc875966e6 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java @@ -24,8 +24,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -85,7 +85,7 @@ public class DefaultPlanbasedSignalSystemControllerIT { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void test2SequentialPlansCompleteDay(){ + void test2SequentialPlansCompleteDay(){ ScenarioRunner runner = new ScenarioRunner(0.0, 3600*1.0, 3600*1.0, 3600*24.0); runner.setNoSimHours(1); SignalEventAnalyzer signalAnalyzer = runner.run(); @@ -109,7 +109,7 @@ public void test2SequentialPlansCompleteDay(){ } @Test - public void test2SequentialPlansUncompleteDayEnd(){ + void test2SequentialPlansUncompleteDayEnd(){ SignalEventAnalyzer signalAnalyzer = (new ScenarioRunner(0.0, 3600*1.0, 3600*1.0, 3600*2.0)).run(); log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); @@ -137,7 +137,7 @@ public void test2SequentialPlansUncompleteDayEnd(){ } @Test - public void test2SequentialPlansUncompleteDayStart(){ + void test2SequentialPlansUncompleteDayStart(){ SignalEventAnalyzer signalAnalyzer = (new ScenarioRunner(3600*1.0, 3600*2.0, 3600*2.0, 3600*24.0)).run(); log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); @@ -165,7 +165,7 @@ public void test2SequentialPlansUncompleteDayStart(){ } @Test - public void test2SequentialPlans1SecGap(){ + void test2SequentialPlans1SecGap(){ ScenarioRunner runner = new ScenarioRunner(0.0, 3600*1.0, 3600*1.0+1, 3600*24.0); runner.setNoSimHours(1); SignalEventAnalyzer signalAnalyzer = runner.run(); @@ -189,7 +189,7 @@ public void test2SequentialPlans1SecGap(){ } @Test - public void test2SequentialPlans1HourGap(){ + void test2SequentialPlans1HourGap(){ SignalEventAnalyzer signalAnalyzer = (new ScenarioRunner(3600*0.0, 3600*1.0, 3600*2.0, 3600*24.0)).run(); log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); @@ -218,7 +218,7 @@ public void test2SequentialPlans1HourGap(){ } @Test - public void test2SequentialPlans1HourGap2TimesOff(){ + void test2SequentialPlans1HourGap2TimesOff(){ ScenarioRunner runner = new ScenarioRunner(3600*0.0, 3600*1.0, 3600*2.0, 3600*3.0); runner.setNoSimHours(3); SignalEventAnalyzer signalAnalyzer = runner.run(); @@ -251,7 +251,7 @@ public void test2SequentialPlans1HourGap2TimesOff(){ } @Test - public void test2SequentialPlansOverMidnight(){ + void test2SequentialPlansOverMidnight(){ SignalEventAnalyzer signalAnalyzer = (new ScenarioRunner(3600*22.0, 3600*1.0, 3600*1.0, 3600*22.0)).run(); log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); @@ -273,7 +273,7 @@ public void test2SequentialPlansOverMidnight(){ } @Test - public void test1SignalPlanUncompleteDay(){ + void test1SignalPlanUncompleteDay(){ SignalEventAnalyzer signalAnalyzer = (new ScenarioRunner(3600*1.0, 3600*2.0, null, null)).run(); log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); @@ -307,7 +307,7 @@ public void test1SignalPlanUncompleteDay(){ * 2. all day signal plan starts again/ is still active, when simulation time exceeds 12pm */ @Test - public void test1AllDaySignalPlanOverMidnightLateStart(){ + void test1AllDaySignalPlanOverMidnightLateStart(){ ScenarioRunner runner = new ScenarioRunner(null, null, null, null); // i.e. new ScenarioRunner(0.0, 0.0, null, null); runner.setSimStart_h(23); SignalEventAnalyzer signalAnalyzer = runner.run(); @@ -336,7 +336,7 @@ public void test1AllDaySignalPlanOverMidnightLateStart(){ * 2. should directly start at time 0.0 */ @Test - public void test1AllDaySignalPlanMidnightStart(){ + void test1AllDaySignalPlanMidnightStart(){ SignalEventAnalyzer signalAnalyzer = (new ScenarioRunner(null, null, null, null)).run(); // i.e. new ScenarioRunner(0.0, 0.0, null, null); log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); @@ -356,7 +356,7 @@ public void test1AllDaySignalPlanMidnightStart(){ } @Test - public void test2SignalPlanFor25h(){ + void test2SignalPlanFor25h(){ ScenarioRunner runner = new ScenarioRunner(3600*0.0, 3600*12.0, 3600*12.0, 3600*24.0); runner.setNoSimHours(25); SignalEventAnalyzer signalAnalyzer = runner.run(); @@ -382,7 +382,7 @@ public void test2SignalPlanFor25h(){ } @Test - public void testSimStartAfterFirstDayPlan(){ + void testSimStartAfterFirstDayPlan(){ ScenarioRunner runner = new ScenarioRunner(3600*0.0, 3600*1.0, 3600*23.0, 3600*24.0); runner.setSimStart_h(23); runner.setNoSimHours(3); @@ -419,7 +419,7 @@ public void testSimStartAfterFirstDayPlan(){ * 1. overlapping signal plans (uncomplete day) result in an exception */ @Test - public void test2PlansSameTimesUncompleteDay(){ + void test2PlansSameTimesUncompleteDay(){ final String exceptionMessageOverlapping21 = "Signal plans SignalPlan2 and SignalPlan1 of signal system SignalSystem-3 overlap."; try{ @@ -436,7 +436,7 @@ public void test2PlansSameTimesUncompleteDay(){ * 1. overlapping signal plans (complete day) result in an exception */ @Test - public void test2PlansSameTimesCompleteDay(){ + void test2PlansSameTimesCompleteDay(){ final String exceptionMessageHoleDay = "Signal system SignalSystem-3 has multiple plans but at least one of them covers the hole day. " + "If multiple signal plans are used, they are not allowed to overlap."; @@ -451,7 +451,7 @@ public void test2PlansSameTimesCompleteDay(){ } @Test - public void test2OverlappingPlans(){ + void test2OverlappingPlans(){ final String exceptionMessageOverlapping12 = "Signal plans SignalPlan1 and SignalPlan2 of signal system SignalSystem-3 overlap."; try{ @@ -464,7 +464,7 @@ public void test2OverlappingPlans(){ } @Test - public void testNegativeOffset() { + void testNegativeOffset() { //plan1 is valid all day ScenarioRunner sr = new ScenarioRunner(0.0, 0.0, null, null); int offset1 = -3; @@ -479,7 +479,7 @@ public void testNegativeOffset() { } @Test - public void testNegativeOffsetEqualCycleTime() { + void testNegativeOffsetEqualCycleTime() { //plan1 is valid all day ScenarioRunner sr = new ScenarioRunner(0.0, 0.0, null, null); int offset1 = -120; @@ -494,7 +494,7 @@ public void testNegativeOffsetEqualCycleTime() { } @Test - public void testTwoPlansWithNegativeOffsets(){ + void testTwoPlansWithNegativeOffsets(){ ScenarioRunner sr = new ScenarioRunner(0.0*3600, 1.0*3600, 1.0*3600, 2.*3600 ); int offset1 = -3; @@ -516,7 +516,7 @@ public void testTwoPlansWithNegativeOffsets(){ } @Test - public void testTwoPlansWithNegativeOffsetsEqualCycleTime(){ + void testTwoPlansWithNegativeOffsetsEqualCycleTime(){ ScenarioRunner sr = new ScenarioRunner(0.0*3600, 1.0*3600, 1.0*3600, 2.*3600 ); int offset1 = -3; diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java index 570bb7374d4..8ce61447ac4 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java @@ -26,8 +26,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -78,7 +78,7 @@ public class LaemmerIT { * single intersection with demand (equals flow capacity) only in NS-direction. signals should show green only for the NS-direction. */ @Test - public void testSingleCrossingScenarioDemandNS() { + void testSingleCrossingScenarioDemandNS() { Fixture fixture = new Fixture(1800, 0, 5.0, Regime.COMBINED); SignalAnalysisTool signalAnalyzer = new SignalAnalysisTool(); DelayAnalysisTool generalAnalyzer = fixture.run(signalAnalyzer); @@ -107,7 +107,7 @@ public void testSingleCrossingScenarioDemandNS() { * single intersection with high demand in WE-direction, very low demand in NS-direction but minimum green time. I.e. the NS-signal should show green for exactly this 5 seconds per cycle. */ @Test - public void testSingleCrossingScenarioLowVsHighDemandWithMinG(){ + void testSingleCrossingScenarioLowVsHighDemandWithMinG(){ Fixture fixture = new Fixture(90, 1800, 5.0, Regime.COMBINED); SignalAnalysisTool signalAnalyzer = new SignalAnalysisTool(); DelayAnalysisTool generalAnalyzer = fixture.run(signalAnalyzer); @@ -140,7 +140,7 @@ public void testSingleCrossingScenarioLowVsHighDemandWithMinG(){ * single intersection with high demand in WE-direction, very low demand in NS-direction. No minimum green time! I.e. the NS-signal should show green for less than 5 seconds per cycle. */ @Test - public void testSingleCrossingScenarioLowVsHighDemandWoMinG(){ + void testSingleCrossingScenarioLowVsHighDemandWoMinG(){ Fixture fixture = new Fixture(90, 1800, 0.0, Regime.COMBINED); SignalAnalysisTool signalAnalyzer = new SignalAnalysisTool(); DelayAnalysisTool generalAnalyzer = fixture.run(signalAnalyzer); @@ -171,7 +171,7 @@ public void testSingleCrossingScenarioLowVsHighDemandWoMinG(){ * directions with the same demand-capacity-ration should get green for more or less the same time */ @Test - public void testSingleCrossingScenarioEqualDemandCapacityRatio(){ + void testSingleCrossingScenarioEqualDemandCapacityRatio(){ Fixture fixture = new Fixture(900, 1800, 0.0, Regime.COMBINED); SignalAnalysisTool signalAnalyzer = new SignalAnalysisTool(); DelayAnalysisTool generalAnalyzer = fixture.run(signalAnalyzer); @@ -206,7 +206,7 @@ public void testSingleCrossingScenarioEqualDemandCapacityRatio(){ * for low demand, i.e. an occupancy rate of 0.5 in the example of nico kuehnel's master thesis, the optimizing regime should be better than the stabilizing regime. */ @Test - public void testSingleCrossingScenarioStabilizingVsOptimizingRegimeLowDemand(){ + void testSingleCrossingScenarioStabilizingVsOptimizingRegimeLowDemand(){ Fixture fixtureStab = new Fixture(360, 1440, 0.0, Regime.STABILIZING); SignalAnalysisTool signalAnalyzerStab = new SignalAnalysisTool(); DelayAnalysisTool generalAnalyzerStab = fixtureStab.run(signalAnalyzerStab); @@ -293,7 +293,7 @@ public void testSingleCrossingScenarioStabilizingVsOptimizingRegimeLowDemand(){ * no standard cycle pattern). The stabilizing regime should still be stable, the combined regime should be the best. */ @Test - public void testSingleCrossingScenarioStabilizingVsOptimizingRegimeHighDemand(){ + void testSingleCrossingScenarioStabilizingVsOptimizingRegimeHighDemand(){ Fixture fixtureStab = new Fixture(360, 1800, 0.0, Regime.STABILIZING); SignalAnalysisTool signalAnalyzerStab = new SignalAnalysisTool(); DelayAnalysisTool generalAnalyzerStab = fixtureStab.run(signalAnalyzerStab); @@ -374,7 +374,7 @@ public void testSingleCrossingScenarioStabilizingVsOptimizingRegimeHighDemand(){ * exactly doubled (same departure times). */ @Test - public void testSingleCrossingScenarioWithDifferentFlowCapacityFactors(){ + void testSingleCrossingScenarioWithDifferentFlowCapacityFactors(){ Fixture fixtureFlowCap1 = new Fixture(360, 1800, 0.0, Regime.COMBINED); SignalAnalysisTool signalAnalyzerFlowCap1 = new SignalAnalysisTool(); DelayAnalysisTool generalAnalyzerFlowCap1 = fixtureFlowCap1.run(signalAnalyzerFlowCap1); @@ -431,7 +431,7 @@ public void testSingleCrossingScenarioWithDifferentFlowCapacityFactors(){ * Test Laemmer with multiple iterations (some variables have to be reset after iterations). */ @Test - public void testMultipleIterations() { + void testMultipleIterations() { Fixture fixture0It = new Fixture(500, 2000, 5.0, Regime.COMBINED); fixture0It.setLastIteration(0); fixture0It.addLeftTurnTraffic(); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java index 2d083c75e07..21c110b666a 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java @@ -24,8 +24,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -103,7 +103,7 @@ public class SylviaIT { * priority over the second. */ @Test - public void testDemandABPrioA() { + void testDemandABPrioA() { double[] noPersons = { 3600, 3600 }; SignalAnalysisTool signalAnalyzer = runScenario(noPersons, 0); @@ -141,7 +141,7 @@ public void testDemandABPrioA() { * priority over the second. */ @Test - public void testDemandABPrioB() { + void testDemandABPrioB() { double[] noPersons = { 3600, 3600 }; // change the priority (i.e. order in the plan) by using an offset of 5 seconds SignalAnalysisTool signalAnalyzer = runScenario(noPersons, 5); @@ -169,7 +169,7 @@ public void testDemandABPrioB() { * test sylvia with demand crossing only in east-west direction */ @Test - public void testDemandA() { + void testDemandA() { double[] noPersons = { 3600, 0 }; SignalAnalysisTool signalAnalyzer = runScenario(noPersons, 0); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/ambertimes/v10/AmberTimesData10ReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/ambertimes/v10/AmberTimesData10ReaderWriterTest.java index 5cccb0ced12..55e3b0ff974 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/ambertimes/v10/AmberTimesData10ReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/ambertimes/v10/AmberTimesData10ReaderWriterTest.java @@ -22,8 +22,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.signals.model.Signal; import org.matsim.contrib.signals.model.SignalSystem; @@ -49,7 +49,7 @@ public class AmberTimesData10ReaderWriterTest { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void testParser() throws IOException, JAXBException, SAXException, + void testParser() throws IOException, JAXBException, SAXException, ParserConfigurationException { AmberTimesData atd = new AmberTimesDataImpl(); AmberTimesReader10 reader = new AmberTimesReader10(atd); @@ -59,7 +59,7 @@ public void testParser() throws IOException, JAXBException, SAXException, } @Test - public void testWriter() throws JAXBException, SAXException, ParserConfigurationException, + void testWriter() throws JAXBException, SAXException, ParserConfigurationException, IOException { String testoutput = this.testUtils.getOutputDirectory() + "testAtdOutput.xml"; log.debug("reading file..."); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/SignalConflictDataReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/SignalConflictDataReaderWriterTest.java index 6513066495f..295e85c40eb 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/SignalConflictDataReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/SignalConflictDataReaderWriterTest.java @@ -23,8 +23,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Node; @@ -44,7 +44,7 @@ public class SignalConflictDataReaderWriterTest { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void testReaderAndWriter() { + void testReaderAndWriter() { LOG.info("create conflict data"); ConflictData conflictData = createConflictDataForTestCase(); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/UnprotectedLeftTurnLogicTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/UnprotectedLeftTurnLogicTest.java index 92eef4f43c2..e1c44259dab 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/UnprotectedLeftTurnLogicTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/UnprotectedLeftTurnLogicTest.java @@ -21,8 +21,8 @@ package org.matsim.contrib.signals.data.conflicts; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.signals.SignalSystemsConfigGroup; import org.matsim.contrib.signals.SignalSystemsConfigGroup.IntersectionLogic; @@ -45,7 +45,7 @@ public class UnprotectedLeftTurnLogicTest { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void testSingleIntersectionScenarioWithLeftTurns() { + void testSingleIntersectionScenarioWithLeftTurns() { // run scenarios from files AnalyzeSingleIntersectionLeftTurnDelays restrictedLeftTurns = runSimulation(IntersectionLogic.CONFLICTING_DIRECTIONS_AND_TURN_RESTRICTIONS); AnalyzeSingleIntersectionLeftTurnDelays unrestrictedLeftTurns = runSimulation(IntersectionLogic.CONFLICTING_DIRECTIONS_NO_TURN_RESTRICTIONS); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/intergreens/v10/IntergreenTimesData10ReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/intergreens/v10/IntergreenTimesData10ReaderWriterTest.java index 794b36a3482..9ac1b9ff35e 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/intergreens/v10/IntergreenTimesData10ReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/intergreens/v10/IntergreenTimesData10ReaderWriterTest.java @@ -27,8 +27,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.signals.model.SignalGroup; import org.matsim.contrib.signals.model.SignalSystem; @@ -56,7 +56,7 @@ public class IntergreenTimesData10ReaderWriterTest { private Id systemId42 = Id.create("42", SignalSystem.class); @Test - public void testParser() throws IOException, JAXBException, SAXException, + void testParser() throws IOException, JAXBException, SAXException, ParserConfigurationException { IntergreenTimesData atd = new IntergreenTimesDataImpl(); IntergreenTimesReader10 reader = new IntergreenTimesReader10(atd); @@ -66,7 +66,7 @@ public void testParser() throws IOException, JAXBException, SAXException, } @Test - public void testWriter() throws JAXBException, SAXException, ParserConfigurationException, + void testWriter() throws JAXBException, SAXException, ParserConfigurationException, IOException { String testoutput = this.testUtils.getOutputDirectory() + "testAtdOutput.xml"; log.debug("reading file..."); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalcontrol/v20/SignalControlData20ReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalcontrol/v20/SignalControlData20ReaderWriterTest.java index 7decd766c3a..283af98f161 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalcontrol/v20/SignalControlData20ReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalcontrol/v20/SignalControlData20ReaderWriterTest.java @@ -27,8 +27,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.signals.data.signalsystems.v20.SignalSystemControllerData; import org.matsim.contrib.signals.model.SignalGroup; @@ -63,15 +63,15 @@ public class SignalControlData20ReaderWriterTest { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void testReader() throws JAXBException, SAXException, ParserConfigurationException, IOException{ + void testReader() throws JAXBException, SAXException, ParserConfigurationException, IOException{ SignalControlData controlData = new SignalControlDataImpl(); SignalControlReader20 reader = new SignalControlReader20(controlData); reader.readFile(this.testUtils.getPackageInputDirectory() + TESTXML); checkContent(controlData); } - @Test - public void testWriter() throws JAXBException, SAXException, ParserConfigurationException, IOException { + @Test + void testWriter() throws JAXBException, SAXException, ParserConfigurationException, IOException { String testoutput = this.testUtils.getOutputDirectory() + "testSignalControlOutput.xml"; log.debug("reading file..."); //read the test file diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalgroups/v20/SignalGroups20ReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalgroups/v20/SignalGroups20ReaderWriterTest.java index a6d27f26127..1086d595d2a 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalgroups/v20/SignalGroups20ReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalgroups/v20/SignalGroups20ReaderWriterTest.java @@ -30,8 +30,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.signals.model.Signal; import org.matsim.contrib.signals.model.SignalGroup; @@ -63,7 +63,7 @@ public class SignalGroups20ReaderWriterTest { @Test - public void testParser() throws IOException, JAXBException, SAXException, + void testParser() throws IOException, JAXBException, SAXException, ParserConfigurationException { SignalGroupsData sgd = new SignalGroupsDataImpl(); SignalGroupsReader20 reader = new SignalGroupsReader20(sgd); @@ -73,7 +73,7 @@ public void testParser() throws IOException, JAXBException, SAXException, } @Test - public void testWriter() throws JAXBException, SAXException, ParserConfigurationException, + void testWriter() throws JAXBException, SAXException, ParserConfigurationException, IOException { String testoutput = this.testUtils.getOutputDirectory() + "testSgOutput.xml"; log.debug("reading file..."); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalsystems/v20/SignalSystemsData20ReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalsystems/v20/SignalSystemsData20ReaderWriterTest.java index 88fa1c1e46d..1fb40b18f1b 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalsystems/v20/SignalSystemsData20ReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalsystems/v20/SignalSystemsData20ReaderWriterTest.java @@ -25,11 +25,10 @@ import javax.xml.parsers.ParserConfigurationException; import org.junit.Assert; - +import org.junit.jupiter.api.Test; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.signals.model.Signal; @@ -66,8 +65,8 @@ public class SignalSystemsData20ReaderWriterTest { private Id linkId4 = Id.create("4", Link.class); - @Test - public void testParser() throws IOException, JAXBException, SAXException, ParserConfigurationException { + @Test + void testParser() throws IOException, JAXBException, SAXException, ParserConfigurationException { SignalSystemsData lss = new SignalSystemsDataImpl(); SignalSystemsReader20 reader = new SignalSystemsReader20(lss); reader.readFile(this.testUtils.getPackageInputDirectory() + TESTXML); @@ -75,8 +74,8 @@ public void testParser() throws IOException, JAXBException, SAXException, Parser checkContent(lss); } - @Test - public void testWriter() throws JAXBException, SAXException, ParserConfigurationException, IOException { + @Test + void testWriter() throws JAXBException, SAXException, ParserConfigurationException, IOException { String testoutput = this.testUtils.getOutputDirectory() + "testLssOutput.xml"; log.debug("reading file..."); //read the test file diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/SignalSystemsIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/SignalSystemsIT.java index c3be6656303..3091d160258 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/SignalSystemsIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/SignalSystemsIT.java @@ -20,8 +20,8 @@ package org.matsim.contrib.signals.integration; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.signals.builder.Signals; import org.matsim.contrib.signals.data.SignalsData; @@ -52,7 +52,7 @@ public class SignalSystemsIT { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void testSignalSystems() { + void testSignalSystems() { Config config = testUtils.loadConfig(testUtils.getClassInputDirectory() + CONFIG_FILE_NAME); config.plans().setActivityDurationInterpretation(PlansConfigGroup.ActivityDurationInterpretation.minOfDurationAndEndTime); String controlerOutputDir = testUtils.getOutputDirectory() + "controlerOutput/"; @@ -148,7 +148,7 @@ public void testSignalSystems() { } @Test - public void testSignalSystemsWTryEndTimeThenDuration() { + void testSignalSystemsWTryEndTimeThenDuration() { Config config = testUtils.loadConfig(testUtils.getClassInputDirectory() + CONFIG_FILE_NAME); // tryEndTimeThenDuration currently is the default config.plans().setActivityDurationInterpretation(PlansConfigGroup.ActivityDurationInterpretation.tryEndTimeThenDuration); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/invertednetworks/InvertedNetworksSignalsIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/invertednetworks/InvertedNetworksSignalsIT.java index 643e89a87b8..3cbb0e162d2 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/invertednetworks/InvertedNetworksSignalsIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/invertednetworks/InvertedNetworksSignalsIT.java @@ -20,8 +20,8 @@ package org.matsim.contrib.signals.integration.invertednetworks; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.signals.builder.Signals; @@ -47,7 +47,7 @@ public class InvertedNetworksSignalsIT { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public final void testSignalsInvertedNetworkRouting() { + final void testSignalsInvertedNetworkRouting() { InvertedNetworkRoutingSignalsFixture f = new InvertedNetworkRoutingSignalsFixture(false, false, true); f.scenario.getConfig().controller().setOutputDirectory(testUtils.getOutputDirectory()); Controler c = new Controler(f.scenario); @@ -67,7 +67,7 @@ public void notifyStartup(StartupEvent event) { } @Test - public final void testSignalsInvertedNetworkRoutingIterations() { + final void testSignalsInvertedNetworkRoutingIterations() { InvertedNetworkRoutingSignalsFixture f = new InvertedNetworkRoutingSignalsFixture(false, false, true); f.scenario.getConfig().controller().setOutputDirectory(testUtils.getOutputDirectory()); f.scenario.getConfig().controller().setLastIteration(1); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java index f2dd03ed0a0..297db365105 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java @@ -14,8 +14,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.matsim.api.core.v01.Coord; @@ -176,10 +176,9 @@ public OsmData constructSignalisedJunction(){ } - // @SuppressWarnings("ConstantConditions") - @Test - public void singleJunction(){ + @Test + void singleJunction(){ OsmData osmData = constructSignalisedJunction(); Path file = Paths.get(matsimTestUtils.getOutputDirectory(), "singleJunction.xml"); writeOsmData(osmData.getNodes(),osmData.getWays(),file); @@ -242,8 +241,8 @@ public void singleJunction(){ Assert.assertEquals("Assert number of Signals", 8, signals); } - @Test - public void singleJunctionWithBoundingBox(){ + @Test + void singleJunctionWithBoundingBox(){ OsmData osmData = constructSignalisedJunction(); Path file = Paths.get(matsimTestUtils.getOutputDirectory(), "singleJunction.xml"); writeOsmData(osmData.getNodes(),osmData.getWays(),file); @@ -308,8 +307,8 @@ public void singleJunctionWithBoundingBox(){ Assert.assertEquals("Assert number of Signals", 8, signals); } - @Test - public void singleJunctionBadBoundingBox(){ + @Test + void singleJunctionBadBoundingBox(){ OsmData osmData = constructSignalisedJunction(); Path file = Paths.get(matsimTestUtils.getOutputDirectory(), "singleJunction.xml"); writeOsmData(osmData.getNodes(),osmData.getWays(),file); @@ -367,8 +366,8 @@ public void singleJunctionBadBoundingBox(){ } } - @Test - public void berlinSnippet(){ + @Test + void berlinSnippet(){ Path inputfile = Paths.get(matsimTestUtils.getClassInputDirectory()); inputfile = Paths.get(inputfile.toString(),"berlinSnippet.osm.gz"); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/ControlerTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/ControlerTest.java index 8f1d630c363..79d7a09eb7c 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/ControlerTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/ControlerTest.java @@ -20,9 +20,8 @@ package org.matsim.contrib.signals.oneagent; import org.junit.Assert; - +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.LinkEnterEvent; @@ -59,7 +58,7 @@ public class ControlerTest { * the signal should be red in sec [0,99] and green in [100,2000] */ @Test - public void testModifySignalControlDataOnsetOffset() { + void testModifySignalControlDataOnsetOffset() { //configure and load standard scenario Fixture fixture = new Fixture(); Scenario scenario = fixture.createAndLoadTestScenarioOneSignal(false); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/sensor/LaneSensorTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/sensor/LaneSensorTest.java index 01cc49e43bc..837ae251427 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/sensor/LaneSensorTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/sensor/LaneSensorTest.java @@ -3,13 +3,13 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.api.experimental.events.LaneEnterEvent; public class LaneSensorTest { @Test - public void testGetAvgVehiclesPerSecondAfterBucketCollection() { + void testGetAvgVehiclesPerSecondAfterBucketCollection() { //test if average is working for constant flow LaneSensor sensor = new LaneSensor(null, null); sensor.registerAverageVehiclesPerSecondToMonitor(60, 15); @@ -22,9 +22,9 @@ public void testGetAvgVehiclesPerSecondAfterBucketCollection() { assertEquals(1.0/3.0, sensor.getAvgVehiclesPerSecond(time), 0.04); } } - + @Test - public void testGetAvgVehiclesPerSecondDuringBucketCollection() { + void testGetAvgVehiclesPerSecondDuringBucketCollection() { //test if average is working for constant flow LaneSensor sensor = new LaneSensor(null, null); sensor.registerAverageVehiclesPerSecondToMonitor(60, 15); @@ -37,9 +37,9 @@ public void testGetAvgVehiclesPerSecondDuringBucketCollection() { assertEquals(1.0/3.0, sensor.getAvgVehiclesPerSecond(time), 0.04); } } - + @Test - public void testGetAvgVehiclesPerSecondWithNoTrafficForTwoBucket() { + void testGetAvgVehiclesPerSecondWithNoTrafficForTwoBucket() { //test if average is working for constant flow LaneSensor sensor = new LaneSensor(null, null); sensor.registerAverageVehiclesPerSecondToMonitor(60, 15); @@ -58,9 +58,9 @@ public void testGetAvgVehiclesPerSecondWithNoTrafficForTwoBucket() { assertEquals((1.0/3.0), sensor.getAvgVehiclesPerSecond(time), 0.02); } } - + @Test - public void testGetAvgVehiclesPerSecondWithNoTrafficForTwoBucketWhileHavingNotEnoughBuckets() { + void testGetAvgVehiclesPerSecondWithNoTrafficForTwoBucketWhileHavingNotEnoughBuckets() { //test if average is working for constant flow LaneSensor sensor = new LaneSensor(null, null); sensor.registerAverageVehiclesPerSecondToMonitor(60, 15); @@ -83,9 +83,9 @@ public void testGetAvgVehiclesPerSecondWithNoTrafficForTwoBucketWhileHavingNotEn assertEquals((1.0/3.0), sensor.getAvgVehiclesPerSecond(time), 0.02); } } - + @Test - public void testClassicBehaviour() { + void testClassicBehaviour() { LaneSensor sensor = new LaneSensor(null, null); sensor.registerAverageVehiclesPerSecondToMonitor(); for (int time = 0; time <= 3600; time++) { diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/sensor/LinkSensorTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/sensor/LinkSensorTest.java index c7d9db8f858..66e78addeb7 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/sensor/LinkSensorTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/sensor/LinkSensorTest.java @@ -4,7 +4,7 @@ import static org.junit.Assert.assertTrue; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -25,7 +25,7 @@ public class LinkSensorTest { @Test - public void testGetAvgVehiclesPerSecondAfterBucketCollection() { + void testGetAvgVehiclesPerSecondAfterBucketCollection() { //test if average is working for constant flow LinkSensor sensor = new LinkSensor(null); sensor.registerAverageVehiclesPerSecondToMonitor(60, 15); @@ -38,9 +38,9 @@ public void testGetAvgVehiclesPerSecondAfterBucketCollection() { assertEquals(1.0/3.0, sensor.getAvgVehiclesPerSecond(time), 0.04); } } - + @Test - public void testGetAvgVehiclesPerSecondDuringBucketCollection() { + void testGetAvgVehiclesPerSecondDuringBucketCollection() { //test if average is working for constant flow LinkSensor sensor = new LinkSensor(null); sensor.registerAverageVehiclesPerSecondToMonitor(60, 15); @@ -53,9 +53,9 @@ public void testGetAvgVehiclesPerSecondDuringBucketCollection() { assertEquals(1.0/3.0, sensor.getAvgVehiclesPerSecond(time), 0.04); } } - + @Test - public void testGetAvgVehiclesPerSecondWithNoTrafficForTwoBucket() { + void testGetAvgVehiclesPerSecondWithNoTrafficForTwoBucket() { //test if average is working for constant flow LinkSensor sensor = new LinkSensor(null); sensor.registerAverageVehiclesPerSecondToMonitor(60, 15); @@ -74,9 +74,9 @@ public void testGetAvgVehiclesPerSecondWithNoTrafficForTwoBucket() { assertEquals((1.0/3.0), sensor.getAvgVehiclesPerSecond(time), 0.02); } } - + @Test - public void testGetAvgVehiclesPerSecondWithNoTrafficForTwoBucketWhileHavingNotEnoughBuckets() { + void testGetAvgVehiclesPerSecondWithNoTrafficForTwoBucketWhileHavingNotEnoughBuckets() { //test if average is working for constant flow LinkSensor sensor = new LinkSensor(null); sensor.registerAverageVehiclesPerSecondToMonitor(60, 15); @@ -99,9 +99,9 @@ public void testGetAvgVehiclesPerSecondWithNoTrafficForTwoBucketWhileHavingNotEn assertEquals((1.0/3.0), sensor.getAvgVehiclesPerSecond(time), 0.02); } } - + @Test - public void testClassicBehaviour() { + void testClassicBehaviour() { LinkSensor sensor = new LinkSensor(null); sensor.registerAverageVehiclesPerSecondToMonitor(); for (int time = 0; time <= 3600; time++) { @@ -147,10 +147,10 @@ private Scenario createScenario(){ l.setFreespeed(6.0); return sc; } - - + + @Test - public void testSensorNumberOfCarsMonitoring(){ + void testSensorNumberOfCarsMonitoring(){ Scenario sc = this.createScenario(); Link link = sc.getNetwork().getLinks().get(Id.create(1, Link.class)); LinkSensor sensor = new LinkSensor(link); @@ -200,9 +200,9 @@ public void testSensorNumberOfCarsMonitoring(){ numberOfCars = sensor.getNumberOfCarsOnLink(); Assert.assertEquals(0, numberOfCars); } - + @Test - public void testSensorDistanceMonitoring(){ + void testSensorDistanceMonitoring(){ Scenario sc = this.createScenario(); Link link = sc.getNetwork().getLinks().get(Id.create(1, Link.class)); LinkSensor sensor = new LinkSensor(link); diff --git a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/DefaultAnnealingAcceptorTest.java b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/DefaultAnnealingAcceptorTest.java index 656b2757262..0fc9099c9b0 100644 --- a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/DefaultAnnealingAcceptorTest.java +++ b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/DefaultAnnealingAcceptorTest.java @@ -10,7 +10,7 @@ import org.apache.commons.lang3.mutable.MutableInt; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.controler.IterationCounter; import org.matsim.contrib.simulatedannealing.acceptor.DefaultAnnealingAcceptor; import org.matsim.contrib.simulatedannealing.temperature.TemperatureFunction; @@ -23,7 +23,7 @@ public class DefaultAnnealingAcceptorTest { private final SimulatedAnnealingConfigGroup simAnCfg = new SimulatedAnnealingConfigGroup(); @Test - public void testAcceptor() { + void testAcceptor() { MutableInt iteration = new MutableInt(0); IterationCounter iterationCounter = iteration::getValue; diff --git a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingConfigGroupTest.java b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingConfigGroupTest.java index f9fd687abc1..4596d83435c 100644 --- a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingConfigGroupTest.java +++ b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingConfigGroupTest.java @@ -9,8 +9,8 @@ package org.matsim.contrib.simulatedannealing; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.jupiter.api.io.TempDir; import org.junit.rules.TemporaryFolder; import org.matsim.core.config.Config; @@ -52,7 +52,7 @@ private static Path writeConfig(final File tempFolder) throws IOException { } @Test - public void loadConfigGroupTest() throws IOException { + void loadConfigGroupTest() throws IOException { /* Test that exported values are correct imported again */ Path configFile = writeConfig(tempFolder); @@ -66,7 +66,7 @@ public void loadConfigGroupTest() throws IOException { @Test - public void perturbationParamsTest() { + void perturbationParamsTest() { Config config = createConfig(); SimulatedAnnealingConfigGroup saConfig = ConfigUtils.addOrGetModule(config, SimulatedAnnealingConfigGroup.class); diff --git a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingIT.java b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingIT.java index 87e9026ec3e..9312b06d731 100644 --- a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingIT.java +++ b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingIT.java @@ -1,8 +1,8 @@ package org.matsim.contrib.simulatedannealing; import com.google.inject.TypeLiteral; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.LinkLeaveEvent; import org.matsim.api.core.v01.events.handler.LinkLeaveEventHandler; @@ -35,7 +35,7 @@ public class SimulatedAnnealingIT { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testIntegratedAnnealingInQSim() { + void testIntegratedAnnealingInQSim() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); diff --git a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingTest.java b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingTest.java index 3fde6d85fa1..020a184d6ef 100644 --- a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingTest.java +++ b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingTest.java @@ -17,7 +17,7 @@ import org.apache.logging.log4j.core.config.Configuration; import org.apache.logging.log4j.core.config.LoggerConfig; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contrib.simulatedannealing.acceptor.Acceptor; import org.matsim.contrib.simulatedannealing.acceptor.DefaultAnnealingAcceptor; import org.matsim.contrib.simulatedannealing.cost.CostCalculator; @@ -37,7 +37,7 @@ public class SimulatedAnnealingTest { private final Random r = new Random(42); @Test - public void testSimulatedAnnealing() { + void testSimulatedAnnealing() { MatsimRandom.reset(); LoggerContext ctx = (LoggerContext) LogManager.getContext(false); diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperConfigGroupTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperConfigGroupTest.java index 9d3f59ae4e8..c58576d8cf4 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperConfigGroupTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperConfigGroupTest.java @@ -1,8 +1,8 @@ package org.matsim.simwrapper; import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.testcases.MatsimTestUtils; @@ -14,7 +14,7 @@ public class SimWrapperConfigGroupTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void config() { + void config() { Config config = ConfigUtils.createConfig(); SimWrapperConfigGroup sw = ConfigUtils.addOrGetModule(config, SimWrapperConfigGroup.class); diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperModuleTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperModuleTest.java index 8a6cdeba974..1c008e9bb17 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperModuleTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperModuleTest.java @@ -1,7 +1,7 @@ package org.matsim.simwrapper; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.controler.Controler; @@ -17,7 +17,7 @@ public class SimWrapperModuleTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void runScenario() { + void runScenario() { URL equil = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml"); diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperTest.java index b9e985f1fee..9784387d6d1 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperTest.java @@ -1,8 +1,8 @@ package org.matsim.simwrapper; import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.simwrapper.viz.*; import org.matsim.testcases.MatsimTestUtils; @@ -18,7 +18,7 @@ public class SimWrapperTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void vizElementsTest() throws IOException { + void vizElementsTest() throws IOException { SimWrapper simWrapper = SimWrapper.create(); diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/DashboardTests.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/DashboardTests.java index 1b103bdd313..cdf392f38df 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/DashboardTests.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/DashboardTests.java @@ -1,8 +1,8 @@ package org.matsim.simwrapper.dashboard; import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.application.MATSimApplication; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -37,7 +37,7 @@ private void run(Dashboard... dashboards) { } @Test - public void defaults() { + void defaults() { Path out = Path.of(utils.getOutputDirectory(), "analysis", "population"); @@ -49,7 +49,7 @@ public void defaults() { } @Test - public void stuckAgents() { + void stuckAgents() { Path out = Path.of(utils.getOutputDirectory(), "analysis", "population"); @@ -61,7 +61,7 @@ public void stuckAgents() { } @Test - public void trip() { + void trip() { Path out = Path.of(utils.getOutputDirectory(), "analysis", "population"); @@ -72,7 +72,7 @@ public void trip() { } @Test - public void tripRef() { + void tripRef() { Path out = Path.of(utils.getOutputDirectory(), "analysis", "population"); @@ -84,7 +84,7 @@ public void tripRef() { } @Test - public void populationAttribute() { + void populationAttribute() { Path out = Path.of(utils.getOutputDirectory(), "analysis", "population"); @@ -98,7 +98,7 @@ public void populationAttribute() { } @Test - public void traffic() { + void traffic() { Path out = Path.of(utils.getOutputDirectory(), "analysis", "traffic"); diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/EmissionsDashboardTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/EmissionsDashboardTest.java index c14a93d3d82..4cbd29d9e7d 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/EmissionsDashboardTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/EmissionsDashboardTest.java @@ -3,8 +3,8 @@ import com.google.common.collect.Iterables; import org.assertj.core.api.Assertions; import org.junit.Assume; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; import org.matsim.application.MATSimApplication; @@ -37,7 +37,7 @@ public class EmissionsDashboardTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void generate() { + void generate() { // This test can only run if the password is set Assume.assumeTrue(System.getenv("MATSIM_DECRYPTION_PASSWORD") != null); diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/TrafficCountsDashboardTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/TrafficCountsDashboardTest.java index 8078e9c6e44..29d99561d98 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/TrafficCountsDashboardTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/TrafficCountsDashboardTest.java @@ -1,8 +1,8 @@ package org.matsim.simwrapper.dashboard; import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -32,7 +32,7 @@ public class TrafficCountsDashboardTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void generate() { + void generate() { Config config = TestScenario.loadConfig(utils); diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyExamplesTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyExamplesTest.java index 6fc28108a5b..7d03f3966ae 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyExamplesTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyExamplesTest.java @@ -2,8 +2,8 @@ import com.fasterxml.jackson.databind.ObjectWriter; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; import tech.tablesaw.api.IntColumn; import tech.tablesaw.api.StringColumn; @@ -38,7 +38,7 @@ public void setUp() throws Exception { } @Test - public void pie() throws IOException { + void pie() throws IOException { String[] modes = {"car", "bike", "pt", "ride", "walk"}; double[] shares = {0.2, 0.15, 0.25, 0.1, 0.3}; @@ -52,7 +52,7 @@ public void pie() throws IOException { @Test - public void timeSeries() throws IOException { + void timeSeries() throws IOException { Table bush = Table.read().csv(new File(utils.getClassInputDirectory(), "bush.csv")); Figure figure = TimeSeriesPlot.create("George W. Bush approval ratings", bush, "date", "approval", "who"); @@ -63,7 +63,7 @@ public void timeSeries() throws IOException { } @Test - public void hist() throws IOException { + void hist() throws IOException { Table test = Table.create( StringColumn.create("type").append("apples").append("apples").append("apples").append("oranges").append("bananas"), @@ -81,7 +81,7 @@ public void hist() throws IOException { } @Test - public void heatmap() throws IOException { + void heatmap() throws IOException { Table table = Table.read().csv(new File(utils.getClassInputDirectory(), "bush.csv")); @@ -99,7 +99,7 @@ public void heatmap() throws IOException { } @Test - public void scatter() throws IOException { + void scatter() throws IOException { final double[] x = {1, 2, 3, 4, 5, 6}; final double[] y = {0, 1, 6, 14, 25, 39}; diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyTest.java index 987f1464e0b..3956c9d505c 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyTest.java @@ -11,8 +11,8 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.assertj.core.api.Assertions; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.simwrapper.ComponentMixin; import org.matsim.testcases.MatsimTestUtils; import tech.tablesaw.plotly.components.Line; @@ -54,7 +54,7 @@ public void setUp() throws Exception { } @Test - public void inline() throws IOException { + void inline() throws IOException { Object[] x = {"sheep", "cows", "fish", "tree sloths"}; double[] y = {1, 4, 9, 16}; @@ -73,7 +73,7 @@ public void inline() throws IOException { } @Test - public void data() throws IOException { + void data() throws IOException { ScatterTrace.ScatterBuilder trace = ScatterTrace.builder(Plotly.INPUT, Plotly.INPUT) .text(Plotly.TEXT_INPUT) @@ -98,7 +98,7 @@ public void data() throws IOException { } @Test - public void multiple() throws IOException { + void multiple() throws IOException { ScatterTrace scatter = ScatterTrace.builder(Plotly.INPUT, Plotly.INPUT) diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/events/CourtesyEventsTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/events/CourtesyEventsTest.java index 49a64a48325..63c5ecc5a71 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/events/CourtesyEventsTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/events/CourtesyEventsTest.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; import org.matsim.api.core.v01.events.ActivityStartEvent; @@ -53,7 +53,7 @@ public class CourtesyEventsTest { public static final String TYPE = "type"; @Test - public void testFullOverlap() { + void testFullOverlap() { testEvents( 4, // 1:|------------------| @@ -85,7 +85,7 @@ public void testFullOverlap() { } @Test - public void testPartialOverlap() { + void testPartialOverlap() { testEvents( 4, // 1:|------------------| // 2: |-------------------| @@ -116,7 +116,7 @@ public void testPartialOverlap() { } @Test - public void testNoOverlap() { + void testNoOverlap() { testEvents( 0, // 1:|-----| // 2: |------------| @@ -147,7 +147,7 @@ public void testNoOverlap() { } @Test - public void testStartTogether() { + void testStartTogether() { testEvents( 4, // 1:|-----| // 2:|------------------------| @@ -178,7 +178,7 @@ public void testStartTogether() { } @Test - public void testEndTogether() { + void testEndTogether() { testEvents( 4, // 1:|------------------------| // 2: |------------| diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanFactoryTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanFactoryTest.java index 7e34b17358a..6e2bd112d94 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanFactoryTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanFactoryTest.java @@ -24,7 +24,7 @@ import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -35,7 +35,7 @@ */ public class JointPlanFactoryTest { @Test - public void testAddAtIndividualLevel() throws Exception { + void testAddAtIndividualLevel() throws Exception { final Id id1 = Id.createPersonId( 1 ); final Person person1 = PopulationUtils.getFactory().createPerson(id1); @@ -64,7 +64,7 @@ public void testAddAtIndividualLevel() throws Exception { } @Test - public void testDoNotAddAtIndividualLevel() throws Exception { + void testDoNotAddAtIndividualLevel() throws Exception { final Id id1 = Id.createPersonId( 1 ); final Person person1 = PopulationUtils.getFactory().createPerson((Id) id1); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanIOTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanIOTest.java index 56cf258be11..cf248036757 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanIOTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanIOTest.java @@ -27,8 +27,8 @@ import java.util.Random; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -50,7 +50,7 @@ public class JointPlanIOTest { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testDumpAndRead() throws Exception { + void testDumpAndRead() throws Exception { final JointPlans jointPlans = new JointPlans(); final Scenario scenario = createScenario( jointPlans ); final Population population = scenario.getPopulation(); @@ -94,7 +94,7 @@ public void testDumpAndRead() throws Exception { } @Test - public void testPlansOrderIsStableInCoreIO() throws Exception { + void testPlansOrderIsStableInCoreIO() throws Exception { final JointPlans jointPlans = new JointPlans(); final Scenario scenario = createScenario( jointPlans ); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlansTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlansTest.java index ae28697cf8b..b8898723c03 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlansTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlansTest.java @@ -23,7 +23,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -34,12 +34,12 @@ */ public class JointPlansTest { @Test - public void testExceptionAddWithCache( ) throws Exception { + void testExceptionAddWithCache() throws Exception { testExceptionAdd( true ); } @Test - public void testExceptionAddWithoutCache( ) throws Exception { + void testExceptionAddWithoutCache() throws Exception { testExceptionAdd( false ); } @@ -74,12 +74,12 @@ private static void testExceptionAdd( final boolean withCache ) throws Exception } @Test - public void testExceptionRemoveWithCache( ) throws Exception { + void testExceptionRemoveWithCache() throws Exception { testExceptionRemove( true ); } @Test - public void testExceptionRemoveWithoutCache( ) throws Exception { + void testExceptionRemoveWithoutCache() throws Exception { testExceptionRemove( false ); } @@ -115,12 +115,12 @@ private static void testExceptionRemove( final boolean withCache ) throws Except } @Test - public void testAddAndGetSeveralInstancesWithCache( ) { + void testAddAndGetSeveralInstancesWithCache() { testAddAndGetSeveralInstances( true ); } @Test - public void testAddAndGetSeveralInstancesWithoutCache( ) { + void testAddAndGetSeveralInstancesWithoutCache() { testAddAndGetSeveralInstances( false ); } @@ -200,12 +200,12 @@ private static void testAddAndGetSeveralInstances( final boolean withCache ) { @Test - public void testClearWithoutCache( ) { + void testClearWithoutCache() { testClear( false ); } @Test - public void testClearWithCache( ) { + void testClearWithCache() { testClear( true ); } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkIOTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkIOTest.java index 9bc61d77eee..0a44ae0fd97 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkIOTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkIOTest.java @@ -25,8 +25,8 @@ import java.util.Set; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -43,12 +43,12 @@ public class SocialNetworkIOTest { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testReinputReflective() { + void testReinputReflective() { testReinput( true ); } @Test - public void testReinputNonReflective() { + void testReinputNonReflective() { testReinput( false ); } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkTest.java index ab70f3630c3..4728c8d94fb 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkTest.java @@ -24,7 +24,9 @@ import java.util.HashSet; import org.junit.Assert; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -32,14 +34,16 @@ * @author thibautd */ public class SocialNetworkTest { - @Test( expected=IllegalStateException.class ) - public void testFailsIfAddingDirectedTieInReflectiveNetwork() { - final SocialNetwork sn = new SocialNetworkImpl( true ); - sn.addMonodirectionalTie( Id.create( 1 , Person.class ) , Id.create( 2 , Person.class ) ); + @Test + void testFailsIfAddingDirectedTieInReflectiveNetwork() { + assertThrows(IllegalStateException.class, () -> { + final SocialNetwork sn = new SocialNetworkImpl( true ); + sn.addMonodirectionalTie(Id.create(1, Person.class), Id.create(2, Person.class)); + }); } @Test - public void testMonodirectionalTie() { + void testMonodirectionalTie() { final Id ego = Id.create( 1 , Person.class ); final Id alter = Id.create( 2 , Person.class ); @@ -65,7 +69,7 @@ public void testMonodirectionalTie() { } @Test - public void testBidirectionalTie() { + void testBidirectionalTie() { final Id ego = Id.create( 1 , Person.class ); final Id alter = Id.create( 2 , Person.class ); @@ -91,7 +95,7 @@ public void testBidirectionalTie() { } @Test - public void testRemoveEgo() { + void testRemoveEgo() { final SocialNetworkImpl sn = new SocialNetworkImpl( true ); final Id ego = Id.create( "ego" , Person.class ); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/DynamicGroupIdentifierTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/DynamicGroupIdentifierTest.java index ec936cb6b2e..1b992c0a25b 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/DynamicGroupIdentifierTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/DynamicGroupIdentifierTest.java @@ -24,7 +24,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -42,7 +42,7 @@ public class DynamicGroupIdentifierTest { @Test - public void testNGroupsNoJointPlansNoSocialNet() { + void testNGroupsNoJointPlansNoSocialNet() { final Scenario scenario = ScenarioUtils.createScenario( ConfigUtils.createConfig() ); scenario.addScenarioElement( JointPlans.ELEMENT_NAME , new JointPlans() ); @@ -62,7 +62,7 @@ public void testNGroupsNoJointPlansNoSocialNet() { } @Test - public void testNGroupsNoJointPlansCompleteSocialNet() { + void testNGroupsNoJointPlansCompleteSocialNet() { //LogManager.getLogger( DynamicGroupIdentifier.class ).setLevel( Level.TRACE ); final Scenario scenario = ScenarioUtils.createScenario( ConfigUtils.createConfig() ); scenario.addScenarioElement( JointPlans.ELEMENT_NAME , new JointPlans() ); @@ -92,7 +92,7 @@ public void testNGroupsNoJointPlansCompleteSocialNet() { } @Test - public void testNGroupsWithJointPlansNoSocialNet() { + void testNGroupsWithJointPlansNoSocialNet() { //LogManager.getLogger( DynamicGroupIdentifier.class ).setLevel( Level.TRACE ); final Scenario scenario = ScenarioUtils.createScenario( ConfigUtils.createConfig() ); @@ -139,7 +139,7 @@ public void testNGroupsWithJointPlansNoSocialNet() { } @Test - public void testNGroupsWithJointPlansCompleteSocialNet() { + void testNGroupsWithJointPlansCompleteSocialNet() { //LogManager.getLogger( DynamicGroupIdentifier.class ).setLevel( Level.TRACE ); final Scenario scenario = ScenarioUtils.createScenario( ConfigUtils.createConfig() ); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/FixedGroupsIT.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/FixedGroupsIT.java index 80a234c05fe..8e521b385ec 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/FixedGroupsIT.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/FixedGroupsIT.java @@ -22,8 +22,8 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -50,7 +50,7 @@ public class FixedGroupsIT { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testIterationOrderIsDeterministic() throws Exception { + void testIterationOrderIsDeterministic() throws Exception { final String configFile = new File( utils.getPackageInputDirectory() ).getParentFile().getParentFile().getParentFile()+"/config.xml"; final Config config = JointScenarioUtils.loadConfig( configFile ); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/GroupPlansTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/GroupPlansTest.java index 56e8fd3cc30..3893c8cb2ba 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/GroupPlansTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/GroupPlansTest.java @@ -31,7 +31,7 @@ import org.junit.After; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -86,7 +86,7 @@ public void clear() { } @Test - public void testGetters() throws Exception { + void testGetters() throws Exception { final List indivPlans = new ArrayList(); final List jointPlans = new ArrayList(); @@ -133,7 +133,7 @@ public void testGetters() throws Exception { } @Test - public void testCopyLooksValid() throws Exception { + void testCopyLooksValid() throws Exception { for (GroupPlans plans : testPlans) { GroupPlans copy = GroupPlans.copyPlans( factory , plans ); @@ -150,7 +150,7 @@ public void testCopyLooksValid() throws Exception { } @Test - public void testCopyIsNotSame() throws Exception { + void testCopyIsNotSame() throws Exception { for (GroupPlans plans : testPlans) { GroupPlans copy = GroupPlans.copyPlans( factory , plans ); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/ActivitySequenceMutatorAlgorithmTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/ActivitySequenceMutatorAlgorithmTest.java index c7a84036acc..2b80b22c47e 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/ActivitySequenceMutatorAlgorithmTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/ActivitySequenceMutatorAlgorithmTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.socnetsim.framework.replanning.modules; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Activity; @@ -37,7 +37,7 @@ */ public class ActivitySequenceMutatorAlgorithmTest { @Test - public void testTwoActivities() throws Exception { + void testTwoActivities() throws Exception { final Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create("somebody", Person.class))); plan.addActivity( PopulationUtils.createActivityFromLinkId("h", Id.create( "h" , Link.class )) ); @@ -69,7 +69,7 @@ public void testTwoActivities() throws Exception { } @Test - public void testOneActivities() throws Exception { + void testOneActivities() throws Exception { final Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create("somebody", Person.class))); plan.addActivity( PopulationUtils.createActivityFromLinkId("h", Id.create( "h" , Link.class )) ); @@ -95,7 +95,7 @@ public void testOneActivities() throws Exception { } @Test - public void testZeroActivities() throws Exception { + void testZeroActivities() throws Exception { final Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create("somebody", Person.class))); plan.addActivity( PopulationUtils.createActivityFromLinkId("h", Id.create( "h" , Link.class )) ); @@ -115,7 +115,7 @@ public void testZeroActivities() throws Exception { } @Test - public void testStage() throws Exception { + void testStage() throws Exception { final Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create("somebody", Person.class))); plan.addActivity( PopulationUtils.createActivityFromLinkId("h", Id.create( "h" , Link.class )) ); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/MergingTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/MergingTest.java index d03ca09ae4b..93de284d592 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/MergingTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/MergingTest.java @@ -30,7 +30,7 @@ import org.junit.After; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -89,7 +89,7 @@ public void allJoints() { // tests // ///////////////////////////////////////////////////////////////////////// @Test - public void testProbOne() throws Exception { + void testProbOne() throws Exception { JointPlanMergingAlgorithm algo = new JointPlanMergingAlgorithm( jointPlans.getFactory(), @@ -116,7 +116,7 @@ public void testProbOne() throws Exception { } @Test - public void testProbZero() throws Exception { + void testProbZero() throws Exception { JointPlanMergingAlgorithm algo = new JointPlanMergingAlgorithm( jointPlans.getFactory(), diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/TourModeUnifierAlgorithmTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/TourModeUnifierAlgorithmTest.java index b32c958f6f6..d76f7cb58f8 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/TourModeUnifierAlgorithmTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/TourModeUnifierAlgorithmTest.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.*; @@ -45,7 +45,7 @@ public class TourModeUnifierAlgorithmTest { private static final Logger log = LogManager.getLogger( TourModeUnifierAlgorithmTest.class ); @Test - public void testPlanWithOneSingleTour() throws Exception { + void testPlanWithOneSingleTour() throws Exception { final Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create("jojo", Person.class))); final Id anchorLink1 = Id.create( "anchor1" , Link.class ); @@ -138,7 +138,7 @@ public void testPlanWithOneSingleTour() throws Exception { } @Test - public void testPlanWithTwoToursOnOpenTour() throws Exception { + void testPlanWithTwoToursOnOpenTour() throws Exception { final Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create("jojo", Person.class))); final Id entranceLink = Id.create( "entrance" , Link.class ); @@ -238,7 +238,7 @@ public void testPlanWithTwoToursOnOpenTour() throws Exception { } @Test - public void testPlanWithTwoHomeBasedTours() throws Exception { + void testPlanWithTwoHomeBasedTours() throws Exception { final Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create("jojo", Person.class))); final Id anchorLink = Id.create( "anchor" , Link.class ); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/removers/LexicographicRemoverTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/removers/LexicographicRemoverTest.java index 8a6ba4fbd90..84a31fab439 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/removers/LexicographicRemoverTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/removers/LexicographicRemoverTest.java @@ -24,7 +24,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -41,7 +41,7 @@ public class LexicographicRemoverTest { @Test - public void testOnlyIndividualPlans() { + void testOnlyIndividualPlans() { final Map, Plan> toRemove = new LinkedHashMap< >(); final ReplanningGroup group = new ReplanningGroup(); final JointPlans jointPlans = new JointPlans(); @@ -67,7 +67,7 @@ public void testOnlyIndividualPlans() { } @Test - public void testOnlyOneComposition() { + void testOnlyOneComposition() { final ReplanningGroup group = new ReplanningGroup(); for ( int i=0; i < 4; i++ ) { @@ -101,7 +101,7 @@ public void testOnlyOneComposition() { } @Test - public void testOneCompositionAndOneExcedentaryPlan() { + void testOneCompositionAndOneExcedentaryPlan() { final ReplanningGroup group = new ReplanningGroup(); for ( int i=0; i < 4; i++ ) { diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/FullExplorationVsCuttoffTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/FullExplorationVsCuttoffTest.java index 5bc566bb884..e541b2ac672 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/FullExplorationVsCuttoffTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/FullExplorationVsCuttoffTest.java @@ -24,8 +24,8 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.population.Plan; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.misc.Counter; @@ -48,19 +48,19 @@ public class FullExplorationVsCuttoffTest { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testFullExplorationVsCuttoffNonBlocking() throws Exception { + void testFullExplorationVsCuttoffNonBlocking() throws Exception { log.info( "test: testFullExplorationVsCuttoffNonBlocking()" ); testFullExplorationVsCuttoff( new EmptyIncompatiblePlansIdentifierFactory() , false ); } @Test - public void testFullExplorationVsCuttoffBlocking() throws Exception { + void testFullExplorationVsCuttoffBlocking() throws Exception { log.info( "test: testFullExplorationVsCuttoffBlocking()" ); testFullExplorationVsCuttoff( new EmptyIncompatiblePlansIdentifierFactory() , true ); } @Test - public void testFullExplorationVsCuttoffIncompatibility() throws Exception { + void testFullExplorationVsCuttoffIncompatibility() throws Exception { log.info( "test: testFullExplorationVsCuttoffIncompatibility()" ); testFullExplorationVsCuttoff( new FewGroupsIncompatibilityFactory(), @@ -68,7 +68,7 @@ public void testFullExplorationVsCuttoffIncompatibility() throws Exception { } @Test - public void testFullExplorationVsCuttoffIncompatibilityBlocking() throws Exception { + void testFullExplorationVsCuttoffIncompatibilityBlocking() throws Exception { log.info( "test: testFullExplorationVsCuttoffIncompatibilityBlocking()" ); testFullExplorationVsCuttoff( new FewGroupsIncompatibilityFactory(), diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/HighestWeightSelectorTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/HighestWeightSelectorTest.java index c730ba9b0af..a1a9b606c00 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/HighestWeightSelectorTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/HighestWeightSelectorTest.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.matsim.api.core.v01.Id; @@ -1233,17 +1233,17 @@ public void setupLogging() { // Tests // ///////////////////////////////////////////////////////////////////////// @Test - public void testSelectedPlansNonBlocking() throws Exception { + void testSelectedPlansNonBlocking() throws Exception { testSelectedPlans( false , false ); } @Test - public void testSelectedPlansForbidding() throws Exception { + void testSelectedPlansForbidding() throws Exception { testSelectedPlans( false , true ); } @Test - public void testSelectedPlansBlocking() throws Exception { + void testSelectedPlansBlocking() throws Exception { testSelectedPlans( true , false ); } @@ -1252,7 +1252,7 @@ public void testSelectedPlansBlocking() throws Exception { * particularly when pruning unplausible plans. */ @Test - public void testNoSideEffects() throws Exception { + void testNoSideEffects() throws Exception { HighestScoreSumSelector selector = new HighestScoreSumSelector( new EmptyIncompatiblePlansIdentifierFactory(), diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/RandomSelectorsTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/RandomSelectorsTest.java index 185776cd819..13628424eaa 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/RandomSelectorsTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/RandomSelectorsTest.java @@ -22,7 +22,10 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.*; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -382,7 +385,7 @@ public void createRandomFixtures() { } @Test - public void testDeterminism() throws Exception { + void testDeterminism() throws Exception { final int seed = 1264; final Counter count = new Counter( "selection # " ); @@ -412,7 +415,7 @@ public void testDeterminism() throws Exception { } @Test - public void testNoFailuresWithVariousSeeds() throws Exception { + void testNoFailuresWithVariousSeeds() throws Exception { final RandomGroupLevelSelector selector = new RandomGroupLevelSelector( new Random( 123 ), new EmptyIncompatiblePlansIdentifierFactory()); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/CoalitionSelectorTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/CoalitionSelectorTest.java index cc1674f91c8..f9215f4ac9c 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/CoalitionSelectorTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/CoalitionSelectorTest.java @@ -28,7 +28,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.matsim.api.core.v01.Id; @@ -215,7 +215,7 @@ private static Collection toArgList(final FixtureFactory... ar // Tests // ///////////////////////////////////////////////////////////////////////// @Test - public void testSelectedPlans() { + void testSelectedPlans() { final Fixture fixture = fixtureFactory.create(); final CoalitionSelector selector = new CoalitionSelector(); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/LeastAverageWeightJointPlanPruningConflictSolverTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/LeastAverageWeightJointPlanPruningConflictSolverTest.java index 8d191571488..dc1a38d25bf 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/LeastAverageWeightJointPlanPruningConflictSolverTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/LeastAverageWeightJointPlanPruningConflictSolverTest.java @@ -23,7 +23,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -38,7 +38,7 @@ public class LeastAverageWeightJointPlanPruningConflictSolverTest { @Test - public void testPruneBiggestPlanWithHigherSum() { + void testPruneBiggestPlanWithHigherSum() { final JointPlans jointPlans = new JointPlans(); // two joint plans, biggest has a higher total weight, diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/LeastPointedPlanPruningConflictSolverTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/LeastPointedPlanPruningConflictSolverTest.java index 39c6c169dac..0626ebe295c 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/LeastPointedPlanPruningConflictSolverTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/LeastPointedPlanPruningConflictSolverTest.java @@ -22,8 +22,7 @@ import java.util.HashMap; import java.util.Map; import org.junit.Assert; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -38,7 +37,7 @@ public class LeastPointedPlanPruningConflictSolverTest { @Test - public void testPruneSmallestJointPlan() { + void testPruneSmallestJointPlan() { final JointPlans jointPlans = new JointPlans(); final Map, Plan> smallJp = new HashMap< >(); final Map, Plan> bigJp = new HashMap< >(); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/whoisthebossselector/WhoIsTheBossSelectorTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/whoisthebossselector/WhoIsTheBossSelectorTest.java index 5317fbb7542..fbbbfe0018c 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/whoisthebossselector/WhoIsTheBossSelectorTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/whoisthebossselector/WhoIsTheBossSelectorTest.java @@ -34,7 +34,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -55,7 +55,7 @@ public class WhoIsTheBossSelectorTest { @Test - public void testOnePlanSelectedForEachAgent() throws Exception { + void testOnePlanSelectedForEachAgent() throws Exception { final WhoIsTheBossSelector testee = new WhoIsTheBossSelector( new Random( 9087 ), @@ -120,8 +120,8 @@ private Set getGroupIds(final ReplanningGroup group) { } @Test - @Ignore( "TODO" ) - public void testBestPlanIsSelectedIfPossible() throws Exception { + @Ignore("TODO") + void testBestPlanIsSelectedIfPossible() throws Exception { throw new UnsupportedOperationException( "TODO" ); } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/scoring/GroupCompositionPenalizerTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/scoring/GroupCompositionPenalizerTest.java index 491b12a31a3..b653e3a7ec9 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/scoring/GroupCompositionPenalizerTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/scoring/GroupCompositionPenalizerTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -61,32 +61,32 @@ public class GroupCompositionPenalizerTest { private final double utilAlone = -1; @Test - public void testFullOverlap() { + void testFullOverlap() { test( new double[]{10 , 20} , new double[]{5 , 25} ); } @Test - public void testInnerOverlap() { + void testInnerOverlap() { test( new double[]{5 , 25} , new double[]{10 , 20} ); } @Test - public void testPartialOverlap() { + void testPartialOverlap() { test( new double[]{5 , 20 } , new double[]{10 , 25} ); } @Test - public void testExactOverlap() { + void testExactOverlap() { test( new double[]{10 , 20} , new double[]{10 , 20} ); } @Test - public void testComeAndGo() { + void testComeAndGo() { test( new double[]{10 , 11 , 15 , 20} , new double[]{10 , 20} ); } @Test - public void testInstantaneousComeAndGo() { + void testInstantaneousComeAndGo() { test( new double[]{10 , 15 , 15 , 20} , new double[]{5 , 20} ); } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointactivities/replanning/modules/RecomposeJointPlanAlgorithmTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointactivities/replanning/modules/RecomposeJointPlanAlgorithmTest.java index ceb2f58628d..9551650254f 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointactivities/replanning/modules/RecomposeJointPlanAlgorithmTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointactivities/replanning/modules/RecomposeJointPlanAlgorithmTest.java @@ -32,7 +32,7 @@ import java.util.Random; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -257,22 +257,22 @@ public boolean areLinked(final Plan p1, final Plan p2) { } @Test - public void testIndividualPlans() throws Exception { + void testIndividualPlans() throws Exception { test( createRandomFixtureWithIndividualPlans( new Random( 1234 ) ) ); } @Test - public void testUniqueJointPlan() throws Exception { + void testUniqueJointPlan() throws Exception { test( createRandomFixtureWithOneBigJointPlan( new Random( 1234 ) ) ); } @Test - public void testJointAndIndividualPlans() throws Exception { + void testJointAndIndividualPlans() throws Exception { test( createRandomFixtureWithJointAndIndividualPlans( new Random( 1234 ) ) ); } @Test - public void testIncompleteLinks() throws Exception { + void testIncompleteLinks() throws Exception { test( createRandomFixtureWithIncompleteLinks( new Random( 1234 ) ) ); } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointactivities/replanning/modules/randomlocationchoice/RandomJointLocationChoiceTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointactivities/replanning/modules/randomlocationchoice/RandomJointLocationChoiceTest.java index 1b807ae4e58..e6cab996be9 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointactivities/replanning/modules/randomlocationchoice/RandomJointLocationChoiceTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointactivities/replanning/modules/randomlocationchoice/RandomJointLocationChoiceTest.java @@ -25,7 +25,7 @@ import java.util.Random; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Activity; @@ -48,7 +48,7 @@ public class RandomJointLocationChoiceTest { // tests of individual critical methods // ///////////////////////////////////////////////////////////////////////// @Test - public void testBarycenterCalculation() { + void testBarycenterCalculation() { final ActivityFacilities facilities = new ActivityFacilitiesImpl(); final List activities = new ArrayList(); @@ -108,7 +108,7 @@ private static void addActivityAndFacility( } @Test - public void testFacilityRetrieval() { + void testFacilityRetrieval() { final ActivityFacilities facilities = new ActivityFacilitiesImpl(); final List activities = new ArrayList(); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/JointTravelUtilsTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/JointTravelUtilsTest.java index 78a1d811e63..5943c16f8f6 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/JointTravelUtilsTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/JointTravelUtilsTest.java @@ -22,7 +22,7 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -802,7 +802,7 @@ public void initOnePassengerTwoTripsInconsistentSequenceFixture() { } @Test - public void testExtractJointTrips() throws Exception { + void testExtractJointTrips() throws Exception { for ( Fixture f : fixtures ) { JointTravelStructure struct = JointTravelUtils.analyseJointTravel(f.plan); @@ -816,7 +816,7 @@ public void testExtractJointTrips() throws Exception { } @Test - public void testParseDriverTrips() throws Exception { + void testParseDriverTrips() throws Exception { for ( Fixture f : fixtures ) { List trips = JointTravelUtils.parseDriverTrips(f.plan); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/qsim/JointTravelingSimulationIntegrationTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/qsim/JointTravelingSimulationIntegrationTest.java index 9a86bd3f1bb..395e7cce92b 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/qsim/JointTravelingSimulationIntegrationTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/qsim/JointTravelingSimulationIntegrationTest.java @@ -23,8 +23,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -110,7 +110,7 @@ private static enum RouteType { private static final String DESTINATION_ACT = "stress"; @Test - public void testAgentsArriveTogetherWithoutDummies() throws Exception { + void testAgentsArriveTogetherWithoutDummies() throws Exception { testAgentsArriveTogether( createFixture( false, @@ -118,7 +118,7 @@ public void testAgentsArriveTogetherWithoutDummies() throws Exception { } @Test - public void testAgentsArriveTogetherWithDummies() throws Exception { + void testAgentsArriveTogetherWithDummies() throws Exception { testAgentsArriveTogether( createFixture( true, @@ -126,7 +126,7 @@ public void testAgentsArriveTogetherWithDummies() throws Exception { } @Test - public void testAgentsArriveTogetherWithDummiesAndDoAtPu() throws Exception { + void testAgentsArriveTogetherWithDummiesAndDoAtPu() throws Exception { testAgentsArriveTogether( createFixture( true, @@ -134,7 +134,7 @@ public void testAgentsArriveTogetherWithDummiesAndDoAtPu() throws Exception { } @Test - public void testAgentsArriveTogetherWithoutDummiesAndDoAtPu() throws Exception { + void testAgentsArriveTogetherWithoutDummiesAndDoAtPu() throws Exception { testAgentsArriveTogether( createFixture( false, @@ -142,7 +142,7 @@ public void testAgentsArriveTogetherWithoutDummiesAndDoAtPu() throws Exception { } @Test - public void testAgentsArriveTogetherWithDummiesAndDoAtPuFullCycle() throws Exception { + void testAgentsArriveTogetherWithDummiesAndDoAtPuFullCycle() throws Exception { testAgentsArriveTogether( createFixture( true, @@ -150,7 +150,7 @@ public void testAgentsArriveTogetherWithDummiesAndDoAtPuFullCycle() throws Excep } @Test - public void testAgentsArriveTogetherWithoutDummiesAndDoAtPuFullCycle() throws Exception { + void testAgentsArriveTogetherWithoutDummiesAndDoAtPuFullCycle() throws Exception { testAgentsArriveTogether( createFixture( false, @@ -158,7 +158,7 @@ public void testAgentsArriveTogetherWithoutDummiesAndDoAtPuFullCycle() throws Ex } @Test - public void testAgentsArriveTogetherWithDummiesAndEverythingAtOrigin() throws Exception { + void testAgentsArriveTogetherWithDummiesAndEverythingAtOrigin() throws Exception { testAgentsArriveTogether( createFixture( true, @@ -166,7 +166,7 @@ public void testAgentsArriveTogetherWithDummiesAndEverythingAtOrigin() throws Ex } @Test - public void testAgentsArriveTogetherWithoutDummiesAndEverythingAtOrigin() throws Exception { + void testAgentsArriveTogetherWithoutDummiesAndEverythingAtOrigin() throws Exception { testAgentsArriveTogether( createFixture( false, @@ -276,22 +276,22 @@ private static void logFinalQSimState(final QSim qsim) { } @Test - public void testNumberOfEnterLeaveVehicle() { + void testNumberOfEnterLeaveVehicle() { testNumberOfEnterLeaveVehicle( RouteType.normal ); } @Test - public void testNumberOfEnterLeaveVehicleEverythingAtOrigin() { + void testNumberOfEnterLeaveVehicleEverythingAtOrigin() { testNumberOfEnterLeaveVehicle( RouteType.everythingAtOrigin ); } @Test - public void testNumberOfEnterLeaveVehiclePuAtDo() { + void testNumberOfEnterLeaveVehiclePuAtDo() { testNumberOfEnterLeaveVehicle( RouteType.puAtDo ); } @Test - public void testNumberOfEnterLeaveVehiclePuAtDoFullCycle() { + void testNumberOfEnterLeaveVehiclePuAtDoFullCycle() { testNumberOfEnterLeaveVehicle( RouteType.puAtDoFullCycle ); } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIgnoranceBehaviorTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIgnoranceBehaviorTest.java index 6da1f83b85e..9e55848cf9a 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIgnoranceBehaviorTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIgnoranceBehaviorTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -66,7 +66,7 @@ public void init() { } @Test - public void testRemoverIgnorance() throws Exception { + void testRemoverIgnorance() throws Exception { final JointTripRemoverAlgorithm algo = new JointTripRemoverAlgorithm( random , new MainModeIdentifierImpl() ); JointPlan jointPlan = createPlanWithJointTrips(); @@ -78,7 +78,7 @@ public void testRemoverIgnorance() throws Exception { } @Test - public void testInsertorIgnorance() throws Exception { + void testInsertorIgnorance() throws Exception { final JointTripInsertorAlgorithm algo = new JointTripInsertorAlgorithm( random, diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIterativeActionTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIterativeActionTest.java index 01d9e49d7d9..01b85aa8a57 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIterativeActionTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIterativeActionTest.java @@ -30,7 +30,7 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -71,7 +71,7 @@ public void init() { } @Test - public void testNonIterativeRemoval() throws Exception { + void testNonIterativeRemoval() throws Exception { JointTripInsertorAndRemoverAlgorithm algo = new JointTripInsertorAndRemoverAlgorithm( ScenarioUtils.createScenario( config ), @@ -114,7 +114,7 @@ public void testNonIterativeRemoval() throws Exception { } @Test - public void testIterativeRemoval() throws Exception { + void testIterativeRemoval() throws Exception { JointTripInsertorAndRemoverAlgorithm algo = new JointTripInsertorAndRemoverAlgorithm( ScenarioUtils.createScenario( config ), @@ -157,7 +157,7 @@ public void testIterativeRemoval() throws Exception { } @Test - public void testNonIterativeInsertion() throws Exception { + void testNonIterativeInsertion() throws Exception { JointTripInsertorAndRemoverAlgorithm algo = new JointTripInsertorAndRemoverAlgorithm( ScenarioUtils.createScenario( config ), @@ -216,7 +216,7 @@ public void testNonIterativeInsertion() throws Exception { } @Test - public void testIterativeInsertion() throws Exception { + void testIterativeInsertion() throws Exception { JointTripInsertorAndRemoverAlgorithm algo = new JointTripInsertorAndRemoverAlgorithm( ScenarioUtils.createScenario( config ), diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripInsertionWithSocialNetworkTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripInsertionWithSocialNetworkTest.java index 68ade2ea095..45ece5211d0 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripInsertionWithSocialNetworkTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripInsertionWithSocialNetworkTest.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -58,7 +58,7 @@ public class JointTripInsertionWithSocialNetworkTest { LogManager.getLogger(JointTripInsertionWithSocialNetworkTest.class); @Test - public void testJointTripsGeneratedOnlyAlongSocialTies() { + void testJointTripsGeneratedOnlyAlongSocialTies() { final Random random = new Random( 123 ); for ( int i=0; i < 10; i++ ) { diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripRemoverAlgorithmTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripRemoverAlgorithmTest.java index ef8dc3e6d50..bc43d9c3a50 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripRemoverAlgorithmTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripRemoverAlgorithmTest.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -935,7 +935,7 @@ private Fixture createTwoDriversFixture(final boolean removeFirst) { // tests // ///////////////////////////////////////////////////////////////////////// @Test - public void testRemoval() throws Exception { + void testRemoval() throws Exception { // TODO: test driver and passenger removal separately for ( Fixture f : fixtures ) { log.info( "testing removal on fixture "+f.name ); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/SynchronizeCoTravelerPlansAlgorithmTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/SynchronizeCoTravelerPlansAlgorithmTest.java index 7904a3c5473..acce4c6faef 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/SynchronizeCoTravelerPlansAlgorithmTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/SynchronizeCoTravelerPlansAlgorithmTest.java @@ -27,7 +27,7 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -321,7 +321,7 @@ public Fixture build() { // tests // ///////////////////////////////////////////////////////////////////////// @Test - public void testDepartureTimes() throws Exception { + void testDepartureTimes() throws Exception { final SynchronizeCoTravelerPlansAlgorithm testee = new SynchronizeCoTravelerPlansAlgorithm(TimeInterpretation.create(ConfigUtils.createConfig())); for ( Fixture fixture : fixtures ) { testee.run( fixture.jointPlan ); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointPlanRouterTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointPlanRouterTest.java index 2107c271413..28203a5ed4a 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointPlanRouterTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointPlanRouterTest.java @@ -25,7 +25,7 @@ import java.util.Collection; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -56,7 +56,7 @@ */ public class JointPlanRouterTest { @Test - public void testDriverIdIsKept() throws Exception { + void testDriverIdIsKept() throws Exception { final Config config = ConfigUtils.createConfig(); final PopulationFactory populationFactory = ScenarioUtils.createScenario( @@ -111,7 +111,7 @@ public void testDriverIdIsKept() throws Exception { } @Test - public void testPassengerIdIsKept() throws Exception { + void testPassengerIdIsKept() throws Exception { final Config config = ConfigUtils.createConfig(); final PopulationFactory populationFactory = ScenarioUtils.createScenario( diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointTripRouterFactoryTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointTripRouterFactoryTest.java index 440691922b9..dbad52eb7e5 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointTripRouterFactoryTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointTripRouterFactoryTest.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -202,7 +202,7 @@ public void install() { } @Test - public void testPassengerRoute() throws Exception { + void testPassengerRoute() throws Exception { final PlanAlgorithm planRouter = new JointPlanRouterFactory( (ActivityFacilities) null, TimeInterpretation.create(ConfigUtils.createConfig()) ).createPlanRoutingAlgorithm( factory.get() ); @@ -239,7 +239,7 @@ public void testPassengerRoute() throws Exception { } @Test - public void testDriverRoute() throws Exception { + void testDriverRoute() throws Exception { final PlanAlgorithm planRouter = new JointPlanRouterFactory( (ActivityFacilities) null, TimeInterpretation.create(ConfigUtils.createConfig()) ).createPlanRoutingAlgorithm( factory.get() ); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/HouseholdBasedVehicleRessourcesTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/HouseholdBasedVehicleRessourcesTest.java index 9e5facbac6b..eaf2b1b5e08 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/HouseholdBasedVehicleRessourcesTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/HouseholdBasedVehicleRessourcesTest.java @@ -26,7 +26,7 @@ import java.util.HashSet; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.households.Household; @@ -41,7 +41,7 @@ public class HouseholdBasedVehicleRessourcesTest { @Test - public void testVehiclesIdsAreCorrect() throws Exception { + void testVehiclesIdsAreCorrect() throws Exception { final Households households = createHouseholds(); final VehicleRessources testee = new HouseholdBasedVehicleRessources( households ); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/PlanRouterWithVehicleRessourcesTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/PlanRouterWithVehicleRessourcesTest.java index 28c317816cc..a05a6cf60eb 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/PlanRouterWithVehicleRessourcesTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/PlanRouterWithVehicleRessourcesTest.java @@ -25,7 +25,7 @@ import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -56,7 +56,7 @@ public class PlanRouterWithVehicleRessourcesTest { @Test - public void testVehicleIdsAreKeptIfSomething() throws Exception { + void testVehicleIdsAreKeptIfSomething() throws Exception { final Config config = ConfigUtils.createConfig(); final PopulationFactory factory = ScenarioUtils.createScenario(config).getPopulation().getFactory(); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/qsim/PopulationAgentSourceWithVehiclesTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/qsim/PopulationAgentSourceWithVehiclesTest.java index f563bfb185c..dad937c6e08 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/qsim/PopulationAgentSourceWithVehiclesTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/qsim/PopulationAgentSourceWithVehiclesTest.java @@ -24,7 +24,7 @@ import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -55,7 +55,7 @@ public class PopulationAgentSourceWithVehiclesTest { //TODO: test that vehicles added where they should be @Test - public void testFailsIfOnlySomeRoutesHaveAVehicle() throws Exception { + void testFailsIfOnlySomeRoutesHaveAVehicle() throws Exception { final Config config = ConfigUtils.createConfig(); final Scenario scenario = ScenarioUtils.createScenario( config ); @@ -123,12 +123,12 @@ public void testFailsIfOnlySomeRoutesHaveAVehicle() throws Exception { } @Test - public void testNoFailIfAllHaveVehicles() throws Exception { + void testNoFailIfAllHaveVehicles() throws Exception { testNoFail( true ); } @Test - public void testNoFailIfNoneHaveVehicles() throws Exception { + void testNoFailIfNoneHaveVehicles() throws Exception { testNoFail( false ); } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/AllocateVehicleToPlansInGroupPlanAlgorithmTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/AllocateVehicleToPlansInGroupPlanAlgorithmTest.java index c91632f15f7..37f66567b28 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/AllocateVehicleToPlansInGroupPlanAlgorithmTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/AllocateVehicleToPlansInGroupPlanAlgorithmTest.java @@ -32,7 +32,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Leg; @@ -119,7 +119,7 @@ private GroupPlans createTestPlan() { } @Test - public void testEnoughVehiclesForEverybody() { + void testEnoughVehiclesForEverybody() { // tests that one vehicle is allocated to each one if possible final Random random = new Random( 1234 ); @@ -147,7 +147,7 @@ public void testEnoughVehiclesForEverybody() { } @Test - public void testOneVehiclePerTwoPersons() { + void testOneVehiclePerTwoPersons() { // tests that the allocation minimizes overlaps final Random random = new Random( 1234 ); @@ -181,7 +181,7 @@ public void testOneVehiclePerTwoPersons() { } @Test - public void testRandomness() { + void testRandomness() { final Random random = new Random( 1234 ); final Map allocations = new HashMap(); @@ -222,7 +222,7 @@ else if ( !oldV.equals( v ) ) { } @Test - public void testDeterminism() { + void testDeterminism() { final Map allocations = new HashMap(); final Set agentsWithSeveralVehicles = new HashSet(); for ( int i = 0; i < 50 ; i++ ) { diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/OptimizeVehicleAllocationAtTourLevelTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/OptimizeVehicleAllocationAtTourLevelTest.java index 4db1b102a6f..a5b3a7367bc 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/OptimizeVehicleAllocationAtTourLevelTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/OptimizeVehicleAllocationAtTourLevelTest.java @@ -28,7 +28,7 @@ import org.junit.Assert; import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Activity; @@ -102,13 +102,13 @@ private void fillPlan( } @Test - @Ignore( "TODO" ) - public void testVehiclesAreAllocatedAtTheTourLevel() throws Exception { + @Ignore("TODO") + void testVehiclesAreAllocatedAtTheTourLevel() throws Exception { throw new UnsupportedOperationException( "TODO" ); } @Test - public void testCannotFindBetterAllocationRandomly() throws Exception { + void testCannotFindBetterAllocationRandomly() throws Exception { Set stages = new HashSet<>();// formerly EmptyStageActivityTypes.INSTANCE; for ( int i = 0; i < 5; i++ ) { diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/GroupPlanStrategyTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/GroupPlanStrategyTest.java index 47ed3d7ce2a..203bec54de6 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/GroupPlanStrategyTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/GroupPlanStrategyTest.java @@ -30,7 +30,7 @@ import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -56,7 +56,7 @@ public class GroupPlanStrategyTest { private static final int N_INITIALLY_INDIV_PLANS = 8; @Test - public void testNewPlanIsSelected() throws Exception { + void testNewPlanIsSelected() throws Exception { final JointPlans jointPlans = new JointPlans(); final GroupPlanStrategy strategy = new GroupPlanStrategy( new HighestScoreSumSelector( @@ -88,7 +88,7 @@ public void testNewPlanIsSelected() throws Exception { } @Test - public void testNumberOfPlans() throws Exception { + void testNumberOfPlans() throws Exception { final JointPlans jointPlans = new JointPlans(); final GroupPlanStrategy strategy = new GroupPlanStrategy( new HighestScoreSumSelector( @@ -106,7 +106,7 @@ public void testNumberOfPlans() throws Exception { } @Test - public void testNumberOfSelectedJointPlans() throws Exception { + void testNumberOfSelectedJointPlans() throws Exception { final JointPlans jointPlans = new JointPlans(); final GroupPlanStrategy strategy = new GroupPlanStrategy( new HighestScoreSumSelector( @@ -140,7 +140,7 @@ public void testNumberOfSelectedJointPlans() throws Exception { } @Test - public void testNumberOfNonSelectedJointPlans() throws Exception { + void testNumberOfNonSelectedJointPlans() throws Exception { final JointPlans jointPlans = new JointPlans(); final GroupPlanStrategy strategy = new GroupPlanStrategy( new HighestScoreSumSelector( diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/JoinableActivitiesPlanLinkIdentifierTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/JoinableActivitiesPlanLinkIdentifierTest.java index fc58468165b..67e5fe79763 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/JoinableActivitiesPlanLinkIdentifierTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/JoinableActivitiesPlanLinkIdentifierTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.socnetsim.usage.replanning; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Activity; @@ -44,7 +44,7 @@ public class JoinableActivitiesPlanLinkIdentifierTest { ConfigUtils.createConfig() ).getPopulation().getFactory(); @Test - public void testOpenPlansSamePlaceSameType() { + void testOpenPlansSamePlaceSameType() { final String type = "type"; final Id facility = Id.create( "fac" , ActivityFacility.class); @@ -58,7 +58,7 @@ public void testOpenPlansSamePlaceSameType() { } @Test - public void testOpenPlansSamePlaceDifferentType() { + void testOpenPlansSamePlaceDifferentType() { final String type = "type"; final Id facility = Id.create( "fac" , ActivityFacility.class ); @@ -76,7 +76,7 @@ public void testOpenPlansSamePlaceDifferentType() { } @Test - public void testOpenPlansDifferentPlaceSameType() { + void testOpenPlansDifferentPlaceSameType() { final String type = "type"; final Id facility = Id.create( "fac" , ActivityFacility.class ); final Id facility2 = Id.create( "fa2" , ActivityFacility.class ); @@ -95,7 +95,7 @@ public void testOpenPlansDifferentPlaceSameType() { } @Test - public void testOpenPlansSamePlaceSameWrongType() { + void testOpenPlansSamePlaceSameWrongType() { final String type = "type"; final Id facility = Id.create( "fac" , ActivityFacility.class); @@ -127,7 +127,7 @@ private static Plan createOpenPlan( } @Test - public void testSingleTourOverlaping() { + void testSingleTourOverlaping() { final String type = "type"; final Id facility = Id.create( "fac" , ActivityFacility.class); @@ -158,7 +158,7 @@ public void testSingleTourOverlaping() { } @Test - public void testSingleTourPlansNonOverlaping() { + void testSingleTourPlansNonOverlaping() { //LogManager.getLogger( JoinableActivitiesPlanLinkIdentifier.class ).setLevel( Level.TRACE ); final String type = "type"; final Id facility = Id.create( "fac" , ActivityFacility.class ); @@ -190,7 +190,7 @@ public void testSingleTourPlansNonOverlaping() { } @Test - public void testSingleTourPlansZeroDurationAct() { + void testSingleTourPlansZeroDurationAct() { //LogManager.getLogger( JoinableActivitiesPlanLinkIdentifier.class ).setLevel( Level.TRACE ); final String type = "type"; final Id facility = Id.create( "fac" , ActivityFacility.class); @@ -222,7 +222,7 @@ public void testSingleTourPlansZeroDurationAct() { } @Test - public void testSingleTourPlansZeroDurationBegin() { + void testSingleTourPlansZeroDurationBegin() { //LogManager.getLogger( JoinableActivitiesPlanLinkIdentifier.class ).setLevel( Level.TRACE ); final String type = "type"; final Id facility = Id.create( "fac" , ActivityFacility.class); @@ -254,7 +254,7 @@ public void testSingleTourPlansZeroDurationBegin() { } @Test - public void testSingleTourPlansZeroDurationEnd() { + void testSingleTourPlansZeroDurationEnd() { //LogManager.getLogger( JoinableActivitiesPlanLinkIdentifier.class ).setLevel( Level.TRACE ); final String type = "type"; final Id facility = Id.create( "fac" , ActivityFacility.class ); @@ -286,7 +286,7 @@ public void testSingleTourPlansZeroDurationEnd() { } @Test - public void testDoubleTourPlansZeroDurationEnd() { + void testDoubleTourPlansZeroDurationEnd() { //LogManager.getLogger( JoinableActivitiesPlanLinkIdentifier.class ).setLevel( Level.TRACE ); final String type = "type"; final Id facility = Id.create( "fac" , ActivityFacility.class ); @@ -323,7 +323,7 @@ public void testDoubleTourPlansZeroDurationEnd() { } @Test - public void testSingleTourPlansInconsistentDurationAct() { + void testSingleTourPlansInconsistentDurationAct() { //LogManager.getLogger( JoinableActivitiesPlanLinkIdentifier.class ).setLevel( Level.TRACE ); final String type = "type"; final Id facility = Id.create( "fac" , ActivityFacility.class ); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/VehicularPlanLinkIdentifierTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/VehicularPlanLinkIdentifierTest.java index 60ac4a28f42..9cdb9bd5e83 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/VehicularPlanLinkIdentifierTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/VehicularPlanLinkIdentifierTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.socnetsim.usage.replanning; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.Leg; @@ -42,7 +42,7 @@ */ public class VehicularPlanLinkIdentifierTest { @Test - public void testNotLinkedWhenNoVehicleDefined() { + void testNotLinkedWhenNoVehicleDefined() { final Plan plan1 = createVehicularPlan( Id.create( 1 , Person.class ) , null ); final Plan plan2 = createVehicularPlan( Id.create( 2 , Person.class ) , null ); @@ -54,7 +54,7 @@ public void testNotLinkedWhenNoVehicleDefined() { } @Test - public void testDifferentVehiclesAreNotLinked() { + void testDifferentVehiclesAreNotLinked() { final Plan plan1 = createVehicularPlan( Id.create( 1 , Person.class ) , Id.create( 1 , Vehicle.class ) ); final Plan plan2 = createVehicularPlan( Id.create( 2 , Person.class ) , Id.create( 2 , Vehicle.class ) ); @@ -65,7 +65,7 @@ public void testDifferentVehiclesAreNotLinked() { } @Test - public void testSameVehiclesAreLinked() { + void testSameVehiclesAreLinked() { final Plan plan1 = createVehicularPlan( Id.create( 1 , Person.class ) , Id.create( "car" , Vehicle.class ) ); final Plan plan2 = createVehicularPlan( Id.create( 2 , Person.class ) , Id.create( "car" , Vehicle.class ) ); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/JointScenarioUtilsTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/JointScenarioUtilsTest.java index ceeca695ac9..96cd50a3de0 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/JointScenarioUtilsTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/JointScenarioUtilsTest.java @@ -23,8 +23,8 @@ import java.util.Collection; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -51,7 +51,7 @@ public class JointScenarioUtilsTest { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testJointTripsImport() throws Exception { + void testJointTripsImport() throws Exception { final Population dumpedPopulation = createPopulation(); final String popFile = utils.getOutputDirectory()+"/pop.xml"; diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/ObjectPoolTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/ObjectPoolTest.java index 511d1721315..22dcdc2bd7e 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/ObjectPoolTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/ObjectPoolTest.java @@ -19,16 +19,16 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.utils; -import org.junit.Test; - import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; + /** * @author thibautd */ public class ObjectPoolTest { @Test - public void testInstanceIsPooled() throws Exception { + void testInstanceIsPooled() throws Exception { final ObjectPool pool = new ObjectPool(); final String instance1 = new String( "jojo" ); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/QuadTreeRebuilderTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/QuadTreeRebuilderTest.java index b9c5001cc89..f8f8da6d46c 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/QuadTreeRebuilderTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/QuadTreeRebuilderTest.java @@ -1,13 +1,13 @@ package org.matsim.contrib.socnetsim.utils; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.collections.QuadTree; public class QuadTreeRebuilderTest { @Test - public void testGrowingQuadTree() { + void testGrowingQuadTree() { final QuadTreeRebuilder rebuilder = new QuadTreeRebuilder<>(); Assert.assertEquals( diff --git a/contribs/sumo/src/test/java/org/matsim/contrib/sumo/SumoNetworkConverterTest.java b/contribs/sumo/src/test/java/org/matsim/contrib/sumo/SumoNetworkConverterTest.java index 05af1565cae..2738f2927b7 100644 --- a/contribs/sumo/src/test/java/org/matsim/contrib/sumo/SumoNetworkConverterTest.java +++ b/contribs/sumo/src/test/java/org/matsim/contrib/sumo/SumoNetworkConverterTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.sumo; import com.google.common.io.Resources; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -22,8 +22,8 @@ public class SumoNetworkConverterTest { - @Test - public void convert() throws Exception { + @Test + void convert() throws Exception { Path input = Files.createTempFile("sumo", ".xml"); Path output = Files.createTempFile("matsim", ".xml"); diff --git a/contribs/sumo/src/test/java/org/matsim/contrib/sumo/SumoNetworkHandlerTest.java b/contribs/sumo/src/test/java/org/matsim/contrib/sumo/SumoNetworkHandlerTest.java index 9f1a81ce7bd..170d248e00f 100644 --- a/contribs/sumo/src/test/java/org/matsim/contrib/sumo/SumoNetworkHandlerTest.java +++ b/contribs/sumo/src/test/java/org/matsim/contrib/sumo/SumoNetworkHandlerTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.sumo; import com.google.common.io.Resources; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.net.URL; @@ -9,8 +9,8 @@ public class SumoNetworkHandlerTest { - @Test - public void read() throws Exception { + @Test + void read() throws Exception { URL resource = Resources.getResource("osm.net.xml"); diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiBenchmarkTest.java b/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiBenchmarkTest.java index 364bbb5a39a..71591180d86 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiBenchmarkTest.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiBenchmarkTest.java @@ -22,8 +22,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; @@ -38,7 +38,7 @@ public class RunETaxiBenchmarkTest { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testRuleBased() { + void testRuleBased() { String configPath = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("dvrp-grid"), "one_etaxi_benchmark_config.xml").toString(); String[] args = { configPath, "--config:controler.outputDirectory", utils.getOutputDirectory() }; // the config file suppresses most writing of output. Presumably, since it is to be run as a benchmark. One can override it here, but it is again overwritten later. So diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiScenarioIT.java b/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiScenarioIT.java index 218ca340f49..12572b18dcc 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiScenarioIT.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiScenarioIT.java @@ -19,8 +19,8 @@ package org.matsim.contrib.etaxi.run; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; @@ -39,19 +39,19 @@ public class RunETaxiScenarioIT { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testOneTaxi() { + void testOneTaxi() { String configPath = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("dvrp-grid"), "one_etaxi_config.xml").toString(); runScenario(configPath); } @Test - public void testRuleBased() { + void testRuleBased() { String configPath = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_etaxi_config.xml").toString(); runScenario(configPath); } @Test - public void testAssignment() { + void testAssignment() { String configPath = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_etaxi_config.xml").toString(); runScenario(configPath); } diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/benchmark/RunTaxiBenchmarkTest.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/benchmark/RunTaxiBenchmarkTest.java index 0c2b1047bcd..ea8934332dc 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/benchmark/RunTaxiBenchmarkTest.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/benchmark/RunTaxiBenchmarkTest.java @@ -21,13 +21,13 @@ import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; public class RunTaxiBenchmarkTest { @Test - public void testRunOneTaxi() { + void testRunOneTaxi() { URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("dvrp-grid"), "one_taxi_benchmark_config.xml"); RunTaxiBenchmark.run(configUrl, 3); } diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/assignment/AssignmentTaxiOptimizerIT.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/assignment/AssignmentTaxiOptimizerIT.java index baae47ffdb2..71970ec6316 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/assignment/AssignmentTaxiOptimizerIT.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/assignment/AssignmentTaxiOptimizerIT.java @@ -21,8 +21,8 @@ import static org.matsim.contrib.taxi.optimizer.TaxiOptimizerTests.runBenchmark; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.contrib.taxi.optimizer.assignment.TaxiToRequestAssignmentCostProvider.Mode; import org.matsim.testcases.MatsimTestUtils; @@ -31,7 +31,7 @@ public class AssignmentTaxiOptimizerIT { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testAssignment_arrivalTime() { + void testAssignment_arrivalTime() { AssignmentTaxiOptimizerParams params = new AssignmentTaxiOptimizerParams(); params.mode = Mode.ARRIVAL_TIME; params.vehPlanningHorizonOversupply = 99999; @@ -42,7 +42,7 @@ public void testAssignment_arrivalTime() { } @Test - public void testAssignment_pickupTime() { + void testAssignment_pickupTime() { AssignmentTaxiOptimizerParams params = new AssignmentTaxiOptimizerParams(); params.mode = Mode.PICKUP_TIME; params.vehPlanningHorizonOversupply = 120; @@ -54,7 +54,7 @@ public void testAssignment_pickupTime() { } @Test - public void testAssignment_dse() { + void testAssignment_dse() { AssignmentTaxiOptimizerParams params = new AssignmentTaxiOptimizerParams(); params.mode = Mode.DSE; params.vehPlanningHorizonOversupply = 120; @@ -66,7 +66,7 @@ public void testAssignment_dse() { } @Test - public void testAssignment_totalWaitTime() { + void testAssignment_totalWaitTime() { AssignmentTaxiOptimizerParams params = new AssignmentTaxiOptimizerParams(); params.mode = Mode.TOTAL_WAIT_TIME; params.vehPlanningHorizonOversupply = 120; diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/fifo/FifoTaxiOptimizerIT.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/fifo/FifoTaxiOptimizerIT.java index 3e4b0ebefdf..14070c159db 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/fifo/FifoTaxiOptimizerIT.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/fifo/FifoTaxiOptimizerIT.java @@ -21,8 +21,8 @@ import static org.matsim.contrib.taxi.optimizer.TaxiOptimizerTests.runBenchmark; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; public class FifoTaxiOptimizerIT { @@ -30,7 +30,7 @@ public class FifoTaxiOptimizerIT { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testFifo() { + void testFifo() { runBenchmark(true, new FifoTaxiOptimizerParams(), utils); } } diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/rules/RuleBasedTaxiOptimizerIT.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/rules/RuleBasedTaxiOptimizerIT.java index 2d58410b364..f70fc0d0d97 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/rules/RuleBasedTaxiOptimizerIT.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/rules/RuleBasedTaxiOptimizerIT.java @@ -21,8 +21,8 @@ import static org.matsim.contrib.taxi.optimizer.TaxiOptimizerTests.runBenchmark; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.contrib.taxi.optimizer.rules.RuleBasedRequestInserter.Goal; import org.matsim.testcases.MatsimTestUtils; @@ -31,7 +31,7 @@ public class RuleBasedTaxiOptimizerIT { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testRuleBased_dse() { + void testRuleBased_dse() { RuleBasedTaxiOptimizerParams params = new RuleBasedTaxiOptimizerParams(); params.goal = Goal.DEMAND_SUPPLY_EQUIL; params.nearestRequestsLimit = 99999; @@ -41,7 +41,7 @@ public void testRuleBased_dse() { } @Test - public void testRuleBased_minWaitTime() { + void testRuleBased_minWaitTime() { RuleBasedTaxiOptimizerParams params = new RuleBasedTaxiOptimizerParams(); params.goal = Goal.MIN_WAIT_TIME; params.nearestRequestsLimit = 10; @@ -51,7 +51,7 @@ public void testRuleBased_minWaitTime() { } @Test - public void testRuleBased_minPickupTime() { + void testRuleBased_minPickupTime() { RuleBasedTaxiOptimizerParams params = new RuleBasedTaxiOptimizerParams(); params.goal = Goal.MIN_PICKUP_TIME; params.nearestRequestsLimit = 1; diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/zonal/ZonalTaxiOptimizerIT.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/zonal/ZonalTaxiOptimizerIT.java index 370a7f37e3a..575f26a4603 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/zonal/ZonalTaxiOptimizerIT.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/zonal/ZonalTaxiOptimizerIT.java @@ -22,8 +22,8 @@ import static org.matsim.contrib.taxi.optimizer.TaxiOptimizerTests.runBenchmark; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.contrib.taxi.optimizer.rules.RuleBasedRequestInserter.Goal; import org.matsim.contrib.taxi.optimizer.rules.RuleBasedTaxiOptimizerParams; import org.matsim.contrib.zone.ZonalSystemParams; @@ -34,7 +34,7 @@ public class ZonalTaxiOptimizerIT { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testZonal_dse() { + void testZonal_dse() { RuleBasedTaxiOptimizerParams rbParams = new RuleBasedTaxiOptimizerParams(); rbParams.goal = Goal.DEMAND_SUPPLY_EQUIL; rbParams.nearestRequestsLimit = 99999; @@ -54,7 +54,7 @@ public void testZonal_dse() { } @Test - public void testZonal_minWaitTime() { + void testZonal_minWaitTime() { RuleBasedTaxiOptimizerParams rbParams = new RuleBasedTaxiOptimizerParams(); rbParams.goal = Goal.MIN_WAIT_TIME; rbParams.nearestRequestsLimit = 10; diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/RunTaxiScenarioTest.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/RunTaxiScenarioTest.java index ceb59015f11..4d0e7cbcaf3 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/RunTaxiScenarioTest.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/RunTaxiScenarioTest.java @@ -21,13 +21,13 @@ import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; public class RunTaxiScenarioTest { @Test - public void testRunOneTaxi() { + void testRunOneTaxi() { URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("dvrp-grid"), "one_taxi_config.xml"); RunTaxiScenario.run(configUrl, false); } diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/RunTaxiScenarioTestIT.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/RunTaxiScenarioTestIT.java index 714104455e7..00906216e35 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/RunTaxiScenarioTestIT.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/RunTaxiScenarioTestIT.java @@ -21,8 +21,8 @@ import java.net.URL; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.contrib.dvrp.run.DvrpConfigGroup; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -36,12 +36,12 @@ public class RunTaxiScenarioTestIT { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testRunMielecLowDemandLowSupply() { + void testRunMielecLowDemandLowSupply() { runMielec("plans_taxi_1.0.xml.gz", "taxis-25.xml"); } @Test - public void testRunMielecHighDemandLowSupply() { + void testRunMielecHighDemandLowSupply() { runMielec("plans_taxi_4.0.xml.gz", "taxis-25.xml"); } diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/examples/RunMultiModeTaxiExampleTestIT.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/examples/RunMultiModeTaxiExampleTestIT.java index e685a9c25c8..c450c0290a4 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/examples/RunMultiModeTaxiExampleTestIT.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/examples/RunMultiModeTaxiExampleTestIT.java @@ -22,13 +22,13 @@ import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; public class RunMultiModeTaxiExampleTestIT { @Test - public void testRun() { + void testRun() { URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("dvrp-grid"), "multi_mode_one_taxi_config.xml"); RunMultiModeTaxiExample.run(configUrl, false, 1); } diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/examples/RunTaxiExampleTestIT.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/examples/RunTaxiExampleTestIT.java index 9b18d237fcf..7e4b7bdb416 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/examples/RunTaxiExampleTestIT.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/examples/RunTaxiExampleTestIT.java @@ -21,13 +21,13 @@ import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; public class RunTaxiExampleTestIT { @Test - public void testRun() { + void testRun() { URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_taxi_config.xml"); RunTaxiExample.run(configUrl, false, 0); } diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/util/TaxiEventsReadersTest.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/util/TaxiEventsReadersTest.java index eba9e7a1c4b..0840511996e 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/util/TaxiEventsReadersTest.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/util/TaxiEventsReadersTest.java @@ -27,7 +27,7 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.Event; import org.matsim.api.core.v01.network.Link; @@ -71,7 +71,7 @@ public class TaxiEventsReadersTest { ); @Test - public void testReader() { + void testReader() { var outputStream = new ByteArrayOutputStream(); EventWriterXML writer = new EventWriterXML(outputStream); taxiEvents.forEach(writer::handleEvent); diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/util/stats/DurationStatsTest.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/util/stats/DurationStatsTest.java index 0c80e3f5f6c..afea968c590 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/util/stats/DurationStatsTest.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/util/stats/DurationStatsTest.java @@ -28,7 +28,7 @@ import java.util.SortedMap; import java.util.stream.Stream; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.contrib.taxi.util.stats.DurationStats.State; /** @@ -36,20 +36,20 @@ */ public class DurationStatsTest { @Test - public void totalStateDurationByTimeBinAndType_empty() { + void totalStateDurationByTimeBinAndType_empty() { SortedMap> durations = stateDurationByTimeBinAndState(Stream.of(), 100); assertThat(durations).isEmpty(); } @Test - public void totalStateDurationByTimeBinAndType_oneType_manyBins() { + void totalStateDurationByTimeBinAndType_oneType_manyBins() { SortedMap> durations = stateDurationByTimeBinAndState( Stream.of(sample(0, "A", 10, 300), sample(1, "A", 10, 300), sample(2, "A", 10, 300)), 100); assertThat(durations).containsExactly(entry(0, Map.of("A", 90.)), entry(1, Map.of("A", 100.)), entry(2, Map.of("A", 100.))); } @Test - public void totalStateDurationByTimeBinAndType_manyTypes_oneBin() { + void totalStateDurationByTimeBinAndType_manyTypes_oneBin() { SortedMap> durations = stateDurationByTimeBinAndState( Stream.of(sample(1, "A", 10, 300), sample(1, "B", 150, 300), sample(1, "C", 100, 120)), 100); assertThat(durations).containsExactly(entry(1, Map.of("A", 100., "B", 50., "C", 20.))); diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/util/stats/TimeBinSamplesTest.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/util/stats/TimeBinSamplesTest.java index b297b59fb90..6a97a94d2aa 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/util/stats/TimeBinSamplesTest.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/util/stats/TimeBinSamplesTest.java @@ -23,7 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.matsim.contrib.taxi.util.stats.TimeBinSamples.taskSamples; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.dvrp.analysis.ExecutedTask; import org.matsim.contrib.dvrp.schedule.Task; @@ -34,25 +34,25 @@ */ public class TimeBinSamplesTest { @Test - public void taskSamples_zeroDuration() { + void taskSamples_zeroDuration() { var task = task(10, 10); assertThat(taskSamples(task, 100)).isEmpty(); } @Test - public void taskSamples_oneSample() { + void taskSamples_oneSample() { var task = task(110, 190); assertThat(taskSamples(task, 100)).containsExactly(new TimeBinSample<>(1, task)); } @Test - public void taskSamples_threeSamples() { + void taskSamples_threeSamples() { var task = task(110, 390); assertThat(taskSamples(task, 100)).containsExactly(new TimeBinSample<>(1, task), new TimeBinSample<>(2, task), new TimeBinSample<>(3, task)); } @Test - public void taskSamples_taskEndEqualToTimeBinEnd() { + void taskSamples_taskEndEqualToTimeBinEnd() { var task = task(110, 300); assertThat(taskSamples(task, 100)).containsExactly(new TimeBinSample<>(1, task), new TimeBinSample<>(2, task)); } diff --git a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesIT.java b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesIT.java index 3ed9158cf9f..26908ea89bc 100644 --- a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesIT.java +++ b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesIT.java @@ -20,8 +20,8 @@ package org.matsim.core.scoring.functions; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.Person; @@ -44,9 +44,9 @@ public class PersonScoringParametersFromPersonAttributesIT { @RegisterExtension public MatsimTestUtils testUtils = new MatsimTestUtils(); - @SuppressWarnings("unchecked") - @Test - public void testSetAttributeAndRunEquil(){ + @SuppressWarnings("unchecked") + @Test + void testSetAttributeAndRunEquil(){ Config config = testUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); config.controller().setOutputDirectory(testUtils.getOutputDirectory()); config.controller().setLastIteration(0); diff --git a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java index 2db28b64006..70434051a10 100644 --- a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java +++ b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java @@ -21,8 +21,8 @@ import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.*; @@ -124,7 +124,7 @@ public void setUp() { } @Test - public void testPersonWithNegativeIncome(){ + void testPersonWithNegativeIncome(){ Id id = Id.createPersonId("negativeIncome"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); //person's attribute says it has negative income which is considered invalid and therefore the subpopulation's mgnUtilityOfMoney is taken (which is 1) @@ -132,7 +132,7 @@ public void testPersonWithNegativeIncome(){ } @Test - public void testPersonWithNoIncome(){ + void testPersonWithNoIncome(){ Id id = Id.createPersonId("zeroIncome"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); //person's attribute says it has 0 income which is considered invalid and therefore the subpopulation's mgnUtilityOfMoney is taken (which is 1) @@ -140,7 +140,7 @@ public void testPersonWithNoIncome(){ } @Test - public void testPersonWithLowIncomeLowCarAsc(){ + void testPersonWithLowIncomeLowCarAsc(){ Id id = Id.createPersonId("lowIncomeLowCarAsc"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssertMarginalUtilityOfMoneyAndPtWait(params, 0.5d, 0.5d); @@ -149,7 +149,7 @@ public void testPersonWithLowIncomeLowCarAsc(){ } @Test - public void testPersonWithHighIncomeLowCarAsc(){ + void testPersonWithHighIncomeLowCarAsc(){ Id id = Id.createPersonId("highIncomeLowCarAsc"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssertMarginalUtilityOfMoneyAndPtWait(params, 1.5d, 0.5d); @@ -158,7 +158,7 @@ public void testPersonWithHighIncomeLowCarAsc(){ } @Test - public void testPersonWithMediumIncomeHighCarAsc(){ + void testPersonWithMediumIncomeHighCarAsc(){ Id id = Id.createPersonId("mediumIncomeHighCarAsc"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssertMarginalUtilityOfMoneyAndPtWait(params, 1d, 0.5d); @@ -168,7 +168,7 @@ public void testPersonWithMediumIncomeHighCarAsc(){ } @Test - public void testMoneyScore(){ + void testMoneyScore(){ ScoringParameters paramsRich = personScoringParams.getScoringParameters(population.getPersons().get(Id.createPersonId("highIncomeLowCarAsc"))); CharyparNagelMoneyScoring moneyScoringRich = new CharyparNagelMoneyScoring(paramsRich); moneyScoringRich.addMoney(100); @@ -183,7 +183,7 @@ public void testMoneyScore(){ } @Test - public void testPersonSpecificAscScoring(){ + void testPersonSpecificAscScoring(){ ScoringParameters paramsRich = personScoringParams.getScoringParameters(population.getPersons().get(Id.createPersonId("highIncomeLowCarAsc"))); CharyparNagelLegScoring legScoringRichCarLeg = new CharyparNagelLegScoring(paramsRich, NetworkUtils.createNetwork(), Set.of(TransportMode.pt)); Leg carLegZeroDistanceTenSeconds = createLeg(TransportMode.car, 0.0d, 10.0d ); diff --git a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java index f7cd61abd9c..9ead6090cb8 100644 --- a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java +++ b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java @@ -21,8 +21,8 @@ import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.*; @@ -146,7 +146,7 @@ public void setUp() { } @Test - public void testPersonWithNegativeIncome(){ + void testPersonWithNegativeIncome(){ Id id = Id.createPersonId("negativeIncome"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); //person's attribute says it has negative income which is considered invalid and therefore the subpopulation's mgnUtilityOfMoney is taken (which is 1) @@ -154,7 +154,7 @@ public void testPersonWithNegativeIncome(){ } @Test - public void testPersonWithNoIncome(){ + void testPersonWithNoIncome(){ Id id = Id.createPersonId("zeroIncome"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); //person's attribute says it has 0 income which is considered invalid and therefore the subpopulation's mgnUtilityOfMoney is taken (which is 1) @@ -162,7 +162,7 @@ public void testPersonWithNoIncome(){ } @Test - public void testPersonWithLowIncomeLowCarAsc(){ + void testPersonWithLowIncomeLowCarAsc(){ Id id = Id.createPersonId("lowIncomeLowCarAsc"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssertMarginalUtilityOfMoneyAndPtWait(params, 0.5d, 0.5d); @@ -171,7 +171,7 @@ public void testPersonWithLowIncomeLowCarAsc(){ } @Test - public void testPersonWithHighIncomeLowCarAsc(){ + void testPersonWithHighIncomeLowCarAsc(){ Id id = Id.createPersonId("highIncomeLowCarAsc"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssertMarginalUtilityOfMoneyAndPtWait(params, 1.5d, 0.5d); @@ -180,7 +180,7 @@ public void testPersonWithHighIncomeLowCarAsc(){ } @Test - public void testPersonWithMediumIncomeHighCarAsc(){ + void testPersonWithMediumIncomeHighCarAsc(){ Id id = Id.createPersonId("mediumIncomeHighCarAsc"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssertMarginalUtilityOfMoneyAndPtWait(params, 1d, 0.5d); @@ -190,7 +190,7 @@ public void testPersonWithMediumIncomeHighCarAsc(){ } @Test - public void testPersonFreight(){ + void testPersonFreight(){ Id id = Id.createPersonId("freight"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); //freight agent has no income attribute set, so it should use the marginal utility of money that is set in its subpopulation scoring parameters! @@ -198,7 +198,7 @@ public void testPersonFreight(){ } @Test - public void testFreightWithIncome(){ + void testFreightWithIncome(){ Id id = Id.createPersonId("freightWithIncome1"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssertMarginalUtilityOfMoneyAndPtWait(params, 1.5/444d, 1d); @@ -208,7 +208,7 @@ public void testFreightWithIncome(){ } @Test - public void testMoneyScore(){ + void testMoneyScore(){ ScoringParameters paramsRich = personScoringParams.getScoringParameters(population.getPersons().get(Id.createPersonId("highIncomeLowCarAsc"))); CharyparNagelMoneyScoring moneyScoringRich = new CharyparNagelMoneyScoring(paramsRich); moneyScoringRich.addMoney(100); @@ -223,7 +223,7 @@ public void testMoneyScore(){ } @Test - public void testPersonSpecificAscScoring(){ + void testPersonSpecificAscScoring(){ ScoringParameters paramsRich = personScoringParams.getScoringParameters(population.getPersons().get(Id.createPersonId("highIncomeLowCarAsc"))); CharyparNagelLegScoring legScoringRichCarLeg = new CharyparNagelLegScoring(paramsRich, NetworkUtils.createNetwork(), Set.of(TransportMode.pt)); Leg carLegZeroDistanceTenSeconds = createLeg(TransportMode.car, 0.0d, 10.0d ); diff --git a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest.java b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest.java index da7035be7e5..75986b3e94c 100644 --- a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest.java +++ b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest.java @@ -21,8 +21,8 @@ package org.matsim.freight.carriers.analysis; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; import java.io.IOException; @@ -33,7 +33,7 @@ public class FreightAnalysisEventBasedTest { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void runFreightAnalysisEventBasedTest() throws IOException { + void runFreightAnalysisEventBasedTest() throws IOException { RunFreightAnalysisEventBased analysisEventBased = new RunFreightAnalysisEventBased(testUtils.getClassInputDirectory(), testUtils.getOutputDirectory(),null); analysisEventBased.runAnalysis(); diff --git a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java index 6ef803c9a77..5839ac4e77c 100644 --- a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java +++ b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java @@ -21,7 +21,9 @@ package org.matsim.freight.carriers.analysis; -import org.junit.*; +import org.junit.Assert; +import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Network; @@ -51,7 +53,7 @@ public void runAnalysis(){ } @Test - public void compareResults() { + void compareResults() { //some generale stats checkFile("carrierStats.tsv"); checkFile("freightVehicleStats.tsv"); @@ -74,7 +76,7 @@ private void checkFile(String filename) { } @Test - public void runVehicleTrackerTest(){ + void runVehicleTrackerTest(){ final String inputPath = testUtils.getClassInputDirectory(); File networkFile = new File(inputPath + "/output_network.xml.gz"); File carrierFile = new File(inputPath + "/output_carriers.xml"); @@ -204,7 +206,7 @@ public void runVehicleTrackerTest(){ } @Test - public void runServiceTrackerTest(){ + void runServiceTrackerTest(){ final String inputPath = testUtils.getClassInputDirectory(); File networkFile = new File(inputPath + "/output_network.xml.gz"); diff --git a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisWithShipmentTest.java b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisWithShipmentTest.java index 6a60941db1f..c96930e1f1f 100644 --- a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisWithShipmentTest.java +++ b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisWithShipmentTest.java @@ -22,8 +22,8 @@ package org.matsim.freight.carriers.analysis; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -47,8 +47,8 @@ public class RunFreightAnalysisWithShipmentTest { @RegisterExtension public MatsimTestUtils testUtils = new MatsimTestUtils(); - @Test - public void runShipmentTrackerTest(){ + @Test + void runShipmentTrackerTest(){ final String inputPath = testUtils.getClassInputDirectory(); File networkFile = new File(inputPath + "/shipment/output_network.xml.gz"); File carrierFile = new File(inputPath + "/shipment/output_carriers.xml"); diff --git a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java index c42b548f626..8bd5209f135 100644 --- a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java +++ b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java @@ -11,8 +11,8 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -96,7 +96,7 @@ enum DrtMode {none, teleportBeeline, teleportBasedOnNetworkRoute, full, withPreb // !! otfvis does not run within parameterized test :-( !! @Test - public void testPtAlongALineWithRaptorAndDrtServiceArea() { + void testPtAlongALineWithRaptorAndDrtServiceArea() { // Towards some understanding of what is going on here: // * In many situations, a good solution is that drt drives to some transit stop, and from there directly to the destination. The swiss rail // raptor will return a cost "infinity" of such a solution, in which case the calling method falls back onto transit_walk. @@ -570,7 +570,7 @@ public void install() { } @Test - public void intermodalAccessEgressPicksWrongVariant() { + void intermodalAccessEgressPicksWrongVariant() { // outdated comment: // this test fails because it picks a // drt-nonNetworkWalk-nonNetworkWalk-drt @@ -745,9 +745,10 @@ public void install() { controler.run(); } + // this test is failing because raptor treats "walk" in a special way. kai, jul'19 @Test - @Ignore // this test is failing because raptor treats "walk" in a special way. kai, jul'19 - public void networkWalkDoesNotWorkWithRaptor() { + @Ignore + void networkWalkDoesNotWorkWithRaptor() { // test fails with null pointer exception Config config = PtAlongALineTest.createConfig(utils.getOutputDirectory()); diff --git a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java index d8736f176fc..6c315ddf84b 100644 --- a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java +++ b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java @@ -4,8 +4,8 @@ import java.util.Set; import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -53,7 +53,7 @@ public class PtAlongALineTest { @Ignore @Test - public void testPtAlongALine() { + void testPtAlongALine() { Config config = createConfig(utils.getOutputDirectory()); @@ -70,7 +70,7 @@ public void testPtAlongALine() { */ @Ignore @Test - public void testPtAlongALineWithRaptorAndBike() { + void testPtAlongALineWithRaptorAndBike() { Config config = createConfig(utils.getOutputDirectory()); @@ -93,7 +93,7 @@ public void testPtAlongALineWithRaptorAndBike() { */ @Ignore @Test - public void testDrtAlongALine() { + void testDrtAlongALine() { Config config = ConfigUtils.createConfig(); @@ -204,7 +204,7 @@ public void testDrtAlongALine() { @Ignore @Test - public void testPtAlongALineWithRaptorAndDrtStopFilterAttribute() { + void testPtAlongALineWithRaptorAndDrtStopFilterAttribute() { Config config = PtAlongALineTest.createConfig(utils.getOutputDirectory()); config.qsim().setSimStarttimeInterpretation(QSimConfigGroup.StarttimeInterpretation.onlyUseStarttime); diff --git a/contribs/vsp/src/test/java/playground/vsp/airPollution/flatEmissions/EmissionCostFactorsTest.java b/contribs/vsp/src/test/java/playground/vsp/airPollution/flatEmissions/EmissionCostFactorsTest.java index 40f2a30e8d1..ed62c664a9f 100644 --- a/contribs/vsp/src/test/java/playground/vsp/airPollution/flatEmissions/EmissionCostFactorsTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/airPollution/flatEmissions/EmissionCostFactorsTest.java @@ -1,25 +1,28 @@ package playground.vsp.airPollution.flatEmissions; import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; import static playground.vsp.airPollution.flatEmissions.EmissionCostFactors.NOx; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class EmissionCostFactorsTest{ - @Test - public void test() { + @Test + void test() { System.out.println( "name=" + NOx.name() + "; factor=" + NOx.getCostFactor() ); System.out.println( "noxFactor=" + EmissionCostFactors.getCostFactor( "NOx" ) ) ; } - @Test(expected = IllegalArgumentException.class) - public void test_unknownParameter() { + @Test + void test_unknownParameter() { + assertThrows(IllegalArgumentException.class, () -> { - EmissionCostFactors.getCostFactor("does-not-exist"); - fail("Unknown pollutant should cause exception"); + EmissionCostFactors.getCostFactor("does-not-exist"); + fail("Unknown pollutant should cause exception"); + }); } } diff --git a/contribs/vsp/src/test/java/playground/vsp/analysis/modules/emissions/TestColdEmissionHandler.java b/contribs/vsp/src/test/java/playground/vsp/analysis/modules/emissions/TestColdEmissionHandler.java index ad8418126c7..a0c00826bc0 100644 --- a/contribs/vsp/src/test/java/playground/vsp/analysis/modules/emissions/TestColdEmissionHandler.java +++ b/contribs/vsp/src/test/java/playground/vsp/analysis/modules/emissions/TestColdEmissionHandler.java @@ -24,7 +24,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; @@ -47,7 +47,7 @@ public class TestColdEmissionHandler { @Test - public final void testEmissionPerPersonColdEventHandler(){ + final void testEmissionPerPersonColdEventHandler(){ //vehicle=person. this handler counts the cold emission events per vehicle id EmissionsPerPersonColdEventHandler handler = new EmissionsPerPersonColdEventHandler(); diff --git a/contribs/vsp/src/test/java/playground/vsp/analysis/modules/emissions/TestWarmEmissionHandler.java b/contribs/vsp/src/test/java/playground/vsp/analysis/modules/emissions/TestWarmEmissionHandler.java index 9892396fa5c..de5e284c121 100644 --- a/contribs/vsp/src/test/java/playground/vsp/analysis/modules/emissions/TestWarmEmissionHandler.java +++ b/contribs/vsp/src/test/java/playground/vsp/analysis/modules/emissions/TestWarmEmissionHandler.java @@ -24,7 +24,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; @@ -47,7 +47,7 @@ public class TestWarmEmissionHandler { @Test - public final void testEmissionPerPersonWarmEventHandler(){ + final void testEmissionPerPersonWarmEventHandler(){ EmissionsPerPersonWarmEventHandler handler = new EmissionsPerPersonWarmEventHandler(); diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2DepartureDelayAtStopMapDataTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2DepartureDelayAtStopMapDataTest.java index 58d50e18d78..f63bcbb2fd4 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2DepartureDelayAtStopMapDataTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2DepartureDelayAtStopMapDataTest.java @@ -1,7 +1,7 @@ package playground.vsp.andreas.bvgAna.level1; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.events.PersonDepartureEvent; @@ -13,11 +13,10 @@ import playground.vsp.andreas.bvgAna.level1.AgentId2DepartureDelayAtStopMapData; public class AgentId2DepartureDelayAtStopMapDataTest { - - + @Test - public void testAgentId2DepartureDelayAtStopMapData() { + void testAgentId2DepartureDelayAtStopMapData() { // assign Ids to routes, vehicles and agents to be used in Test diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2DepartureDelayAtStopMapTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2DepartureDelayAtStopMapTest.java index 2dc4d31fc58..c50c5e0c285 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2DepartureDelayAtStopMapTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2DepartureDelayAtStopMapTest.java @@ -4,7 +4,7 @@ import java.util.TreeSet; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.events.PersonDepartureEvent; @@ -16,7 +16,7 @@ public class AgentId2DepartureDelayAtStopMapTest { @Test - public void testAgentId2DepartureDelayAtStopMap() { + void testAgentId2DepartureDelayAtStopMap() { Set> idSet = new TreeSet<>(); for (int ii=0; ii<15; ii++){ diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2EnterLeaveVehicleEventHandlerTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2EnterLeaveVehicleEventHandlerTest.java index f873bb1ecda..e82f75ca5ec 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2EnterLeaveVehicleEventHandlerTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2EnterLeaveVehicleEventHandlerTest.java @@ -4,7 +4,7 @@ import java.util.TreeSet; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonEntersVehicleEvent; import org.matsim.api.core.v01.events.PersonLeavesVehicleEvent; @@ -15,12 +15,11 @@ public class AgentId2EnterLeaveVehicleEventHandlerTest { - /** - * Test method for {@link playground.vsp.andreas.bvgAna.level1.AgentId2EnterLeaveVehicleEventHandler#AgentId2EnterLeaveVehicleEventHandler(java.util.Set)}. - */ - @Test - - public void testAgentId2EnterLeaveVehicleEventHandler() { + /** + * Test method for {@link playground.vsp.andreas.bvgAna.level1.AgentId2EnterLeaveVehicleEventHandler#AgentId2EnterLeaveVehicleEventHandler(java.util.Set)}. + */ + @Test + void testAgentId2EnterLeaveVehicleEventHandler() { Set> idSet = new TreeSet<>(); for (int ii=0; ii<9; ii++){ diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2PtTripTravelTimeMapDataTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2PtTripTravelTimeMapDataTest.java index cd86ac00a41..3559c2d3082 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2PtTripTravelTimeMapDataTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2PtTripTravelTimeMapDataTest.java @@ -23,7 +23,7 @@ import java.util.TreeSet; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; @@ -38,7 +38,7 @@ public class AgentId2PtTripTravelTimeMapDataTest { @Test - public void testAgentId2PtTripTravelTimeMapData() { + void testAgentId2PtTripTravelTimeMapData() { Set> idSet = new TreeSet<>(); for (int ii=0; ii<15; ii++){ diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2PtTripTravelTimeMapTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2PtTripTravelTimeMapTest.java index b83a7e3c7e4..2adbd8450ef 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2PtTripTravelTimeMapTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2PtTripTravelTimeMapTest.java @@ -6,7 +6,7 @@ import java.util.TreeSet; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; @@ -30,8 +30,7 @@ public class AgentId2PtTripTravelTimeMapTest { * Test method for {@link playground.vsp.andreas.bvgAna.level1.AgentId2PtTripTravelTimeMap#AgentId2PtTripTravelTimeMap(java.util.Set)}. */ @Test - - public void testAgentId2PtTripTravelTimeMap() { + void testAgentId2PtTripTravelTimeMap() { Set> idSet = new TreeSet<>(); diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2LineId2PulkDataTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2LineId2PulkDataTest.java index e4a774082cf..34da2196a5f 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2LineId2PulkDataTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2LineId2PulkDataTest.java @@ -1,11 +1,11 @@ package playground.vsp.andreas.bvgAna.level1; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class StopId2LineId2PulkDataTest { - + @Test - public void testStopId2LineId2PulkData() { + void testStopId2LineId2PulkData() { // to be implemented diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2LineId2PulkTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2LineId2PulkTest.java index 0c6cab2dd42..5160fbce497 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2LineId2PulkTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2LineId2PulkTest.java @@ -2,7 +2,7 @@ import org.junit.Assert; import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.TransitDriverStartsEvent; import org.matsim.api.core.v01.population.Person; @@ -15,8 +15,9 @@ public class StopId2LineId2PulkTest { - @Test @Ignore - public void testStopId2LineId2Pulk() { + @Test + @Ignore + void testStopId2LineId2Pulk() { // assign Ids to routes, vehicles and agents to be used in Test diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2RouteId2DelayAtStopMapTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2RouteId2DelayAtStopMapTest.java index 00e0ca04df9..6205ab72888 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2RouteId2DelayAtStopMapTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2RouteId2DelayAtStopMapTest.java @@ -1,7 +1,7 @@ package playground.vsp.andreas.bvgAna.level1; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.TransitDriverStartsEvent; import org.matsim.api.core.v01.population.Person; @@ -15,7 +15,7 @@ public class StopId2RouteId2DelayAtStopMapTest { @Test - public void testStopId2RouteId2DelayAtStopMap() { + void testStopId2RouteId2DelayAtStopMap() { // assign Ids to routes, vehicles and agents to be used in Test diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2DelayAtStopMapDataTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2DelayAtStopMapDataTest.java index 2c1d406dcf9..720bf61b615 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2DelayAtStopMapDataTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2DelayAtStopMapDataTest.java @@ -1,7 +1,7 @@ package playground.vsp.andreas.bvgAna.level1; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.TransitDriverStartsEvent; import org.matsim.api.core.v01.population.Person; @@ -17,7 +17,7 @@ public class VehId2DelayAtStopMapDataTest { @Test - public void testVehId2DelayAtStopMapData() { + void testVehId2DelayAtStopMapData() { // assign Ids to routes, vehicles and agents to be used in Test diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2DelayAtStopMapTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2DelayAtStopMapTest.java index a3df217d43a..3621a8081cd 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2DelayAtStopMapTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2DelayAtStopMapTest.java @@ -4,7 +4,7 @@ import java.util.TreeMap; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.TransitDriverStartsEvent; import org.matsim.api.core.v01.population.Person; @@ -18,7 +18,7 @@ public class VehId2DelayAtStopMapTest { @Test - public void testVehId2DelayAtStopMap() { + void testVehId2DelayAtStopMap() { TreeMap> data = new TreeMap>(); diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2OccupancyHandlerTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2OccupancyHandlerTest.java index fc9248d4705..de708843b22 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2OccupancyHandlerTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2OccupancyHandlerTest.java @@ -3,14 +3,13 @@ import static org.junit.Assert.*; import org.junit.Assert; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import playground.vsp.andreas.bvgAna.level1.VehId2OccupancyHandler; public class VehId2OccupancyHandlerTest { @Test - public void testVehId2OccupancyHandler() { + void testVehId2OccupancyHandler() { VehId2OccupancyHandler test = new VehId2OccupancyHandler(); diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2PersonEnterLeaveVehicleMapTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2PersonEnterLeaveVehicleMapTest.java index 53f3fa8d302..26a36b3e80b 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2PersonEnterLeaveVehicleMapTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2PersonEnterLeaveVehicleMapTest.java @@ -4,7 +4,7 @@ import java.util.TreeMap; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonEntersVehicleEvent; import org.matsim.api.core.v01.events.PersonLeavesVehicleEvent; @@ -17,7 +17,7 @@ public class VehId2PersonEnterLeaveVehicleMapTest { TreeMap> leave = new TreeMap>(); @Test - public void testVehId2PersonEnterLeaveVehicleMap() { + void testVehId2PersonEnterLeaveVehicleMap() { // assign Ids to routes, vehicles and agents to be used in Test diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/osmBB/PTCountsNetworkSimplifierTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/osmBB/PTCountsNetworkSimplifierTest.java index d549920130b..e2eb11c4d0b 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/osmBB/PTCountsNetworkSimplifierTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/osmBB/PTCountsNetworkSimplifierTest.java @@ -24,8 +24,8 @@ import java.util.TreeSet; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -45,7 +45,8 @@ public class PTCountsNetworkSimplifierTest { * Test simple network */ - @Test public void testSimplifyEmptyNetwork(){ + @Test + void testSimplifyEmptyNetwork(){ String inputPath = utils.getClassInputDirectory(); String outputPath = utils.getOutputDirectory(); @@ -84,7 +85,8 @@ public class PTCountsNetworkSimplifierTest { * Test pt link */ - @Test public void testSimplifyPTNetwork(){ + @Test + void testSimplifyPTNetwork(){ String inputPath = utils.getClassInputDirectory(); String outputPath = utils.getOutputDirectory(); @@ -127,7 +129,8 @@ public class PTCountsNetworkSimplifierTest { * Test links with count stations */ - @Test public void testSimplifyCountsNetwork(){ + @Test + void testSimplifyCountsNetwork(){ String inputPath = utils.getClassInputDirectory(); String outputPath = utils.getOutputDirectory(); @@ -172,7 +175,8 @@ public class PTCountsNetworkSimplifierTest { * Test PT and Counts at once */ - @Test public void testSimplifyPTCountsNetwork(){ + @Test + void testSimplifyPTCountsNetwork(){ String inputPath = utils.getClassInputDirectory(); String outputPath = utils.getOutputDirectory(); @@ -220,7 +224,8 @@ public class PTCountsNetworkSimplifierTest { * Test additional links marked as blocked */ - @Test public void testSimplifyElseNetwork(){ + @Test + void testSimplifyElseNetwork(){ String inputPath = utils.getClassInputDirectory(); String outputPath = utils.getOutputDirectory(); @@ -272,7 +277,8 @@ public class PTCountsNetworkSimplifierTest { * Test all at once */ - @Test public void testSimplifyAllNetwork(){ + @Test + void testSimplifyAllNetwork(){ String inputPath = utils.getClassInputDirectory(); String outputPath = utils.getOutputDirectory(); diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java index db7023afb6a..104fcd8f336 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java @@ -1,7 +1,6 @@ package playground.vsp.cadyts.marginals; - +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.matsim.api.core.v01.Coord; @@ -254,7 +253,7 @@ private static Plan createPlan(String mode, String endLink, Network network, Pop * is set to have an equal share of car and bike users. The accepted error in the test is 5%, due to stochastic fuzziness */ @Test - public void test() { + void test() { Config config = createConfig(); CadytsConfigGroup cadytsConfigGroup = new CadytsConfigGroup(); diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java index ad2500ce36f..90a70f545a2 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java @@ -1,7 +1,6 @@ package playground.vsp.cadyts.marginals; - +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -52,7 +51,7 @@ public class ModalDistanceCadytsMultipleDistancesIT { * is set to have an equal share of car and bike users. The accepted error in the test is 5%, due to stochastic fuzziness */ @Test - public void test() { + void test() { Config config = createConfig(); CadytsConfigGroup cadytsConfigGroup = new CadytsConfigGroup(); diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java index 94c68a9d5bd..c2dfaf70610 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java @@ -18,9 +18,8 @@ * *********************************************************************** */ package playground.vsp.cadyts.marginals; - +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -61,13 +60,13 @@ public class ModalDistanceCadytsSingleDistanceIT { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); - /** - * This test runs a population of 1000 agents which have the same home and work place. All agents start with two plans. - * One with mode car and one with mode bike. The selected plan is the car plan. Now, the desired distance distribution - * is set to have an equal share of car and bike users. The accepted error in the test is 5%, due to stochastic fuzziness - */ - @Test - public void test() { + /** + * This test runs a population of 1000 agents which have the same home and work place. All agents start with two plans. + * One with mode car and one with mode bike. The selected plan is the car plan. Now, the desired distance distribution + * is set to have an equal share of car and bike users. The accepted error in the test is 5%, due to stochastic fuzziness + */ + @Test + void test() { Config config = createConfig(); CadytsConfigGroup cadytsConfigGroup = new CadytsConfigGroup(); diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java index e0c7d42e18a..8cccb793c66 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java @@ -1,7 +1,7 @@ package playground.vsp.cadyts.marginals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -40,7 +40,7 @@ public class TripEventHandlerTest { * @throws MalformedURLException another stupid api */ @Test - public void test() throws MalformedURLException { + void test() throws MalformedURLException { // url is such a weird api URL ptTutorial = URI.create(ExamplesUtils.getTestScenarioURL("pt-tutorial").toString() + "0.config.xml").toURL(); diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java b/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java index 22b9e50abc3..12089da0739 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java @@ -29,8 +29,8 @@ import jakarta.inject.Provider; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -76,7 +76,7 @@ public class AdvancedMarginalCongestionPricingIT { // test normal activities @Test - public final void test0a(){ + final void test0a(){ ScoringConfigGroup plansCalcScoreConfigGroup = new ScoringConfigGroup(); ActivityParams activityParams = new ActivityParams("work"); @@ -141,7 +141,7 @@ public final void test0a(){ // test overnight activities with first and last activity of the same type @Test - public final void test0b(){ + final void test0b(){ ScoringConfigGroup plansCalcScoreConfigGroup = new ScoringConfigGroup(); ActivityParams activityParams = new ActivityParams("overnightActivity"); @@ -189,7 +189,7 @@ public final void test0b(){ // test overnight activities with first and last activity of different types @Test - public final void test0c(){ + final void test0c(){ ScoringConfigGroup plansCalcScoreConfigGroup = new ScoringConfigGroup(); @@ -236,7 +236,7 @@ public final void test0c(){ // test if the delayed arrival at a normal activity (not the first or last activity) results in the right monetary amount @Test - public final void test1(){ + final void test1(){ String configFile = testUtils.getPackageInputDirectory() + "AdvancedMarginalCongestionPricingTest/config1.xml"; @@ -318,7 +318,7 @@ public ControlerListener get() { // test if a delayed arrival at the last activity results in the right monetary amount @Test - public final void test2(){ + final void test2(){ String configFile = testUtils.getPackageInputDirectory() + "AdvancedMarginalCongestionPricingTest/config2.xml"; @@ -404,7 +404,7 @@ public ControlerListener get() { // test if the right number of money events are thrown @Test - public final void test3(){ + final void test3(){ String configFile = testUtils.getPackageInputDirectory() + "AdvancedMarginalCongestionPricingTest/config3.xml"; @@ -472,7 +472,7 @@ public ControlerListener get() { // test if the right number of money events are thrown @Test - public final void test4(){ + final void test4(){ String configFile = testUtils.getPackageInputDirectory() + "AdvancedMarginalCongestionPricingTest/config4.xml"; diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/CombinedFlowAndStorageDelayTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/CombinedFlowAndStorageDelayTest.java index 792eb498409..a7406ecae28 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/CombinedFlowAndStorageDelayTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/CombinedFlowAndStorageDelayTest.java @@ -22,8 +22,8 @@ import java.util.List; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -75,7 +75,7 @@ public class CombinedFlowAndStorageDelayTest { * agents are stored to charge later if required. */ @Test - public final void implV4Test(){ + final void implV4Test(){ /* * In the test, two routes (1-2-3-4 and 5-3-4) are assigned to agents. First two agents (1,2) start on first route and next two (3,4) on * other route. After agent 1 leave the link 2 (marginal flow delay =100), agent 2 is delayed. Mean while, before agent 2 can move to next link, diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/CorridorNetworkTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/CorridorNetworkTest.java index 7486ec1c9eb..e583e5441de 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/CorridorNetworkTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/CorridorNetworkTest.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -65,7 +65,7 @@ public class CorridorNetworkTest { @Test - public void v3Test(){ + void v3Test(){ CorridorNetworkAndPlans inputs = new CorridorNetworkAndPlans(); Scenario sc = inputs.getDesiredScenario(); @@ -112,7 +112,7 @@ public void v3Test(){ } @Test - public void v4Test(){ + void v4Test(){ CorridorNetworkAndPlans inputs = new CorridorNetworkAndPlans(); Scenario sc = inputs.getDesiredScenario(); diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowQueueQsimTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowQueueQsimTest.java index 06b51cf1a47..b34e2adbf6d 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowQueueQsimTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowQueueQsimTest.java @@ -28,8 +28,8 @@ import java.util.Set; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -101,7 +101,7 @@ public class MarginalCongestionHandlerFlowQueueQsimTest { * V3 */ @Test - public final void testFlowCongestion_3agents_V3(){ + final void testFlowCongestion_3agents_V3(){ Scenario sc = loadScenario1(); setPopulation1(sc); @@ -140,7 +140,7 @@ public void handleEvent(CongestionEvent event) { * V7 */ @Test - public final void testFlowCongestion_3agents_V7(){ + final void testFlowCongestion_3agents_V7(){ Scenario sc = loadScenario1(); setPopulation1(sc); @@ -191,7 +191,7 @@ public void handleEvent(CongestionEvent event) { * V8 */ @Test - public final void testFlowCongestion_3agents_V8(){ + final void testFlowCongestion_3agents_V8(){ Scenario sc = loadScenario1(); setPopulation1(sc); diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java index 6a545ed494e..3029eda9921 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java @@ -34,8 +34,8 @@ import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -131,9 +131,9 @@ public class MarginalCongestionHandlerFlowSpillbackQueueQsimTest { * V3 * */ - @Ignore("Temporarily ignoring")//TODO for Amit - @Test - public final void testFlowAndStorageCongestion_3agents(){ + @Ignore("Temporarily ignoring")//TODO for Amit + @Test + final void testFlowAndStorageCongestion_3agents(){ Scenario sc = loadScenario1(); setPopulation1(sc); @@ -178,7 +178,7 @@ public void handleEvent(CongestionEvent event) { * */ @Test - public final void testFlowAndStorageCongestion_3agents_V9() { + final void testFlowAndStorageCongestion_3agents_V9() { Scenario sc = loadScenario1(); setPopulation1(sc); @@ -219,7 +219,7 @@ public void handleEvent(CongestionEvent event) { * */ @Test - public final void testFlowAndStorageCongestion_3agents_V8() { + final void testFlowAndStorageCongestion_3agents_V8() { Scenario sc = loadScenario1(); setPopulation1(sc); @@ -259,9 +259,9 @@ public void handleEvent(CongestionEvent event) { * V10 * */ - @Ignore("Temporarily ignoring")//TODO for Amit + @Ignore("Temporarily ignoring")//TODO for Amit @Test - public final void testFlowAndStorageCongestion_3agents_V10() { + final void testFlowAndStorageCongestion_3agents_V10() { Scenario sc = loadScenario1(); setPopulation1(sc); @@ -309,9 +309,9 @@ public void handleEvent(CongestionEvent event) { // in both iterations the "toll" and the "tollOldValue" should be the same // // 3 iterations are necessary to check the equality of the "toll" and the "tollOldValue" - @Ignore("Temporarily ignoring")//TODO for Amit + @Ignore("Temporarily ignoring")//TODO for Amit @Test - public final void testRouting(){ + final void testRouting(){ String configFile = testUtils.getPackageInputDirectory()+"MarginalCongestionHandlerV3QsimTest/configTestRouting.xml"; @@ -449,9 +449,9 @@ else if(((event.getServices().getConfig().controller().getLastIteration())-(even } // setInsertingWaitingVehiclesBeforeDrivingVehicles = false - @Ignore("Temporarily ignoring")//TODO for Amit + @Ignore("Temporarily ignoring")//TODO for Amit @Test - public final void testInsertingWaitingVehicles_01(){ + final void testInsertingWaitingVehicles_01(){ Scenario sc = loadScenario4(); setPopulation4(sc); @@ -508,9 +508,9 @@ public void handleEvent(LinkLeaveEvent event) { // setInsertingWaitingVehiclesBeforeDrivingVehicles = true // to compare - @Ignore("Temporarily ignoring")//TODO for Amit + @Ignore("Temporarily ignoring")//TODO for Amit @Test - public final void testInsertingWaitingVehicles_02(){ + final void testInsertingWaitingVehicles_02(){ Scenario sc = loadScenario5(); setPopulation5(sc); @@ -569,9 +569,9 @@ public void handleEvent(LinkLeaveEvent event) { // setInsertingWaitingVehiclesBeforeDrivingVehicles = false // agent 2 is already on link 2 when agent 3 ends his activity, // therefore agent 3 has to wait until agent 2 has left the link - @Ignore("Temporarily ignoring")//TODO for Amit + @Ignore("Temporarily ignoring")//TODO for Amit @Test - public final void testInsertingWaitingVehicles_03(){ + final void testInsertingWaitingVehicles_03(){ Scenario sc = loadScenario4(); setPopulation6(sc); @@ -627,9 +627,9 @@ public void handleEvent(LinkLeaveEvent event) { } - @Ignore("Temporarily ignoring")//TODO for Amit + @Ignore("Temporarily ignoring")//TODO for Amit @Test - public final void testStuckTimePeriod(){ + final void testStuckTimePeriod(){ Scenario sc = loadScenario1b(); setPopulation1(sc); diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java index 52ba06a0f54..c43f9c44301 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java @@ -31,8 +31,8 @@ import jakarta.inject.Provider; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -64,7 +64,7 @@ public class MarginalCongestionHandlerV3Test { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public final void testCongestionExample(){ + final void testCongestionExample(){ String configFile = testUtils.getPackageInputDirectory()+"MarginalCongestionHandlerV3Test/config.xml"; final List congestionEvents = new ArrayList(); diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionPricingTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionPricingTest.java index b3633c5a13b..ae8e105e244 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionPricingTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionPricingTest.java @@ -24,8 +24,8 @@ import java.util.Set; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -67,7 +67,7 @@ public class MarginalCongestionPricingTest { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public final void implV4Test(){ + final void implV4Test(){ int numberOfPersonInPlan = 10; createPseudoInputs pseudoInputs = new createPseudoInputs(); diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MultipleSpillbackCausingLinksTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MultipleSpillbackCausingLinksTest.java index c6ae3343755..ff9518ca966 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MultipleSpillbackCausingLinksTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MultipleSpillbackCausingLinksTest.java @@ -22,8 +22,8 @@ import java.util.List; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -69,7 +69,7 @@ public class MultipleSpillbackCausingLinksTest { * (2) an agent may have two different links as next link in the route and therefore correct one should be adopted. */ @Test - public final void multipleSpillBackTest(){ + final void multipleSpillBackTest(){ /* * 10 agents diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/TestForEmergenceTime.java b/contribs/vsp/src/test/java/playground/vsp/congestion/TestForEmergenceTime.java index 7b4be2a2cf1..46cbb7a5ebc 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/TestForEmergenceTime.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/TestForEmergenceTime.java @@ -22,8 +22,8 @@ import java.util.List; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -64,7 +64,7 @@ public class TestForEmergenceTime { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public final void emergenceTimeTest_v4(){ + final void emergenceTimeTest_v4(){ String [] congestionPricingImpl = {"v4"}; diff --git a/contribs/vsp/src/test/java/playground/vsp/ev/TransferFinalSocToNextIterTest.java b/contribs/vsp/src/test/java/playground/vsp/ev/TransferFinalSocToNextIterTest.java index 330e4bff5ad..28fca80e271 100644 --- a/contribs/vsp/src/test/java/playground/vsp/ev/TransferFinalSocToNextIterTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/ev/TransferFinalSocToNextIterTest.java @@ -24,8 +24,8 @@ import java.util.Map; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.ev.fleet.ElectricFleetUtils; @@ -49,7 +49,7 @@ public class TransferFinalSocToNextIterTest { private MatsimTestUtils matsimTestUtils = new MatsimTestUtils(); @Test - public void test() { + void test() { //adapt scenario scenario.getConfig().controller().setLastIteration(LAST_ITERATION); scenario.getConfig().controller().setOutputDirectory("test/output/playground/vsp/ev/FinalSoc2VehicleTypeTest/"); diff --git a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVIT.java b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVIT.java index b35592a42ca..c267b09bb17 100644 --- a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVIT.java @@ -2,8 +2,8 @@ import org.apache.logging.log4j.LogManager; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; import org.matsim.core.events.EventsUtils; @@ -18,7 +18,8 @@ public class UrbanEVIT { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void run() { + @Test + void run() { try { // final URL baseUrl = ExamplesUtils.getTestScenarioURL( "equil" ); diff --git a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java index aa1e6143b24..2611efa158e 100644 --- a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java +++ b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java @@ -8,7 +8,7 @@ import org.junit.Assert; import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -100,7 +100,7 @@ public void install() { } @Test - public void testAgentsExecuteSameNumberOfActsAsPlanned() { + void testAgentsExecuteSameNumberOfActsAsPlanned() { boolean fail = false; String personsWithDifferingActCount = ""; @@ -123,7 +123,7 @@ public void testAgentsExecuteSameNumberOfActsAsPlanned() { } @Test - public void testCarAndBikeAgent() { + void testCarAndBikeAgent() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Charge during leisure + bike"), List.of()); Assert.assertEquals(1, plugins.size(), 0); @@ -142,7 +142,7 @@ public void testCarAndBikeAgent() { } @Test - public void testTripleCharger() { + void testTripleCharger() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Triple Charger"), List.of()); Assert.assertEquals(plugins.size(), 3., 0); ActivityStartEvent pluginActStart = plugins.get(0); @@ -169,7 +169,7 @@ public void testTripleCharger() { } @Test - public void testChargerSelectionShopping() { + void testChargerSelectionShopping() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Charging during shopping"), List.of()); Assert.assertEquals(1, plugins.size(), 0); @@ -187,7 +187,7 @@ public void testChargerSelectionShopping() { } @Test - public void testLongDistance() { + void testLongDistance() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Charger Selection long distance leg"), List.of()); Assert.assertEquals(1, plugins.size(), 0); @@ -207,7 +207,7 @@ public void testLongDistance() { } @Test - public void testTwin() { + void testTwin() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Charger Selection long distance twin"), List.of()); Assert.assertEquals(1, plugins.size(), 0); @@ -226,7 +226,7 @@ public void testTwin() { } @Test - public void testDoubleCharger() { + void testDoubleCharger() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Double Charger"), List.of()); Assert.assertEquals(1, plugins.size(), 0); ActivityStartEvent pluginActStart = plugins.get(0); @@ -243,7 +243,7 @@ public void testDoubleCharger() { } @Test - public void testNotEnoughTimeCharger() { + void testNotEnoughTimeCharger() { //TODO this test succeeds if the corresponding agents is deleted List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Not enough time so no charge"), List.of()); Assert.assertTrue(plugins.isEmpty()); @@ -253,7 +253,7 @@ public void testNotEnoughTimeCharger() { } @Test - public void testEarlyCharger() { + void testEarlyCharger() { //this guy starts with more energy than the others, exceeds the threshold at the 3rd leg but can only charge during first non-home-act. charge is lasting long enough so no additional charge is needed List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Not enough time so charging early"), @@ -274,7 +274,7 @@ public void testEarlyCharger() { } @Test - public void testHomeCharger() { + void testHomeCharger() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Home Charger"), List.of()); Assert.assertEquals(1, plugins.size(), 0); ActivityStartEvent pluginActStart = plugins.get(0); @@ -288,7 +288,7 @@ public void testHomeCharger() { } @Test - public void testNoRoundTripSoNoHomeCharge() { + void testNoRoundTripSoNoHomeCharge() { //TODO this test succeeds if the corresponding agents is deleted List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("No Round Trip So No Home Charge"), List.of()); @@ -301,7 +301,7 @@ public void testNoRoundTripSoNoHomeCharge() { } @Test - public void testDoubleChargerHomeCharger() { + void testDoubleChargerHomeCharger() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Double Charger Home Charger"), List.of()); Assert.assertEquals(plugins.size(), 2, 0); ActivityStartEvent pluginActStart = plugins.get(0); diff --git a/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java b/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java index dc6fc153dbc..07a9345c92c 100644 --- a/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java @@ -3,8 +3,8 @@ import com.google.inject.Provides; import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -66,7 +66,7 @@ public class HierarchicalFLowEfficiencyCalculatorTest { private FlowEfficiencyHandler handler; @Test - public void testThatDrtAVMoveFaster(){ + void testThatDrtAVMoveFaster(){ Assert.assertTrue(handler.lastArrivalsPerLink.get(Id.createLinkId(258)) > handler.lastArrivalsPerLink.get(Id.createLinkId(259))); Assert.assertTrue(handler.lastArrivalsPerLink.get(Id.createLinkId(258)) > handler.lastArrivalsPerLink.get(Id.createLinkId(260))); diff --git a/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreatorTest.java b/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreatorTest.java index 524f1f3816e..56816559ba1 100644 --- a/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreatorTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreatorTest.java @@ -1,8 +1,8 @@ package playground.vsp.openberlinscenario.cemdap.input; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; import org.matsim.testcases.MatsimTestUtils; @@ -23,7 +23,7 @@ public class SynPopCreatorTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void TestGenerateDemand() { + void TestGenerateDemand() { // Input and output files String commuterFileOutgoingTest = utils.getInputDirectory() + "Teil1BR2009Ga_Test_kurz.txt"; diff --git a/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java b/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java index f8dedea8aa3..7f96e4d5879 100644 --- a/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java @@ -2,7 +2,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.*; +import org.junit.Assert; +import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -57,8 +59,8 @@ public void initializeTestPopulations() { modifiedPopulationCase2 = readPopulationFromFile(outputPlansFile2); } - @Test - public void testSelectionProbability() { + @Test + void testSelectionProbability() { LOG.info("OriginalPopulationCase1 size: " + originalPopulationCase.getPersons().size()); LOG.info("ModifiedPopulationCase1 size: " + modifiedPopulationCase1.getPersons().size()); @@ -70,8 +72,8 @@ public void testSelectionProbability() { MatsimTestUtils.EPSILON); } - @Test - public void testEveryPersonCopiedExistsInOriginal() { + @Test + void testEveryPersonCopiedExistsInOriginal() { for (Person copy : modifiedPopulationCase1.getPersons().values()) { Person original = originalPopulationCase.getPersons().get(copy.getId()); @@ -80,8 +82,8 @@ public void testEveryPersonCopiedExistsInOriginal() { } } - @Test - public void testOnlyTransferSelectedPlan() { + @Test + void testOnlyTransferSelectedPlan() { for (Person copy : modifiedPopulationCase2.getPersons().values()) { Person original = originalPopulationCase.getPersons().get(copy.getId()); @@ -90,8 +92,8 @@ public void testOnlyTransferSelectedPlan() { } } - @Test - public void testNotOnlyTransferSelectedPlan() { + @Test + void testNotOnlyTransferSelectedPlan() { //also tests if all plans were copied correctly for (Person copy : modifiedPopulationCase1.getPersons().values()) { @@ -107,8 +109,8 @@ public void testNotOnlyTransferSelectedPlan() { } } - @Test - public void testConsiderHomeStayingAgents() { + @Test + void testConsiderHomeStayingAgents() { boolean atLeastOneHomeStayingPerson = false; for (Person copy : modifiedPopulationCase2.getPersons().values()) { @@ -118,8 +120,8 @@ public void testConsiderHomeStayingAgents() { Assert.assertTrue("No home staying person found", atLeastOneHomeStayingPerson); } - @Test - public void testNotConsiderHomeStayingAgents() { + @Test + void testNotConsiderHomeStayingAgents() { for (Person copy : modifiedPopulationCase1.getPersons().values()) { Assert.assertTrue("No home staying agents allowed", @@ -127,8 +129,8 @@ public void testNotConsiderHomeStayingAgents() { } } - @Test - public void testIncludeStayHomePlans() { + @Test + void testIncludeStayHomePlans() { boolean atLeastOneHomeStayingPlan = false; for (Person copy : modifiedPopulationCase1.getPersons().values()) { @@ -139,8 +141,8 @@ public void testIncludeStayHomePlans() { Assert.assertTrue("No home staying plan found", atLeastOneHomeStayingPlan); } - @Test - public void testNotIncludeStayHomePlans() { + @Test + void testNotIncludeStayHomePlans() { for (Person copy : modifiedPopulationCase2.getPersons().values()) { for (Plan plan : copy.getPlans()) @@ -150,8 +152,8 @@ public void testNotIncludeStayHomePlans() { } } - @Test - public void testOnlyConsiderPeopleAlwaysGoingByCar() { + @Test + void testOnlyConsiderPeopleAlwaysGoingByCar() { for (Person copy : modifiedPopulationCase2.getPersons().values()) { for (Plan plan : copy.getPlans()) @@ -164,8 +166,8 @@ public void testOnlyConsiderPeopleAlwaysGoingByCar() { } } - @Test - public void testNotOnlyConsiderPeopleAlwaysGoingByCar() { + @Test + void testNotOnlyConsiderPeopleAlwaysGoingByCar() { boolean otherModeThanCarConsidered = false; for (Person copy : modifiedPopulationCase1.getPersons().values()) { @@ -179,8 +181,8 @@ public void testNotOnlyConsiderPeopleAlwaysGoingByCar() { Assert.assertTrue("There should be other modes than car", otherModeThanCarConsidered); } - @Test - public void testRemoveLinksAndRoutes() { + @Test + void testRemoveLinksAndRoutes() { for (Person copy : modifiedPopulationCase2.getPersons().values()) { for (Plan plan : copy.getPlans()) @@ -193,8 +195,8 @@ public void testRemoveLinksAndRoutes() { } } - @Test - public void testNotRemoveLinksAndRoutes() { + @Test + void testNotRemoveLinksAndRoutes() { boolean routeFound = false; for (Person copy : modifiedPopulationCase1.getPersons().values()) { diff --git a/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java b/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java index 2d5797dc1b8..875a03eb3ae 100644 --- a/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java @@ -5,8 +5,8 @@ import org.assertj.core.api.InstanceOfAssertFactories; import org.assertj.core.data.Offset; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.Leg; @@ -110,7 +110,7 @@ private List estimateAgent(Id personId) { } @Test - public void fare() { + void fare() { List est = estimateAgent(TestScenario.Agents.get(1)); System.out.println(est); @@ -123,7 +123,7 @@ public void fare() { } @Test - public void all() { + void all() { for (Id agent : TestScenario.Agents) { List est = estimateAgent(agent); @@ -135,7 +135,7 @@ public void all() { } @Test - public void planEstimate() { + void planEstimate() { Person person = controler.getScenario().getPopulation().getPersons().get(TestScenario.Agents.get(2)); Plan plan = person.getSelectedPlan(); diff --git a/contribs/vsp/src/test/java/playground/vsp/pt/ptdisturbances/EditTripsTest.java b/contribs/vsp/src/test/java/playground/vsp/pt/ptdisturbances/EditTripsTest.java index 341ad741a91..8ea37d7d2df 100644 --- a/contribs/vsp/src/test/java/playground/vsp/pt/ptdisturbances/EditTripsTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/pt/ptdisturbances/EditTripsTest.java @@ -33,8 +33,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -114,7 +114,7 @@ public class EditTripsTest { * Case 1.1.1 */ @Test - public void testAgentStaysAtStop() { + void testAgentStaysAtStop() { HashMap, Double> arrivalTimes = new HashMap<>(); HashMap, List> trips = new HashMap<>(); Config config = ConfigUtils @@ -148,13 +148,12 @@ public void testAgentStaysAtStop() { } - /** * Case 1.1.2 Looks awkward in otfvis, because after replanning there suddenly * are 2 testAgents at different places, but events are fine :-/ */ @Test - public void testAgentLeavesStop() { + void testAgentLeavesStop() { HashMap, Double> arrivalTimes = new HashMap<>(); HashMap, List> trips = new HashMap<>(); Config config = ConfigUtils.loadConfig(configURL); @@ -187,7 +186,7 @@ public void testAgentLeavesStop() { * Case 1.2.1 */ @Test - public void testAgentStaysInVehicle() { + void testAgentStaysInVehicle() { HashMap, Double> arrivalTimes = new HashMap<>(); HashMap, List> trips = new HashMap<>(); Config config = ConfigUtils @@ -224,7 +223,7 @@ public void testAgentStaysInVehicle() { * Case 1.2.2 */ @Test - public void testAgentLeavesVehicleAtNextStop() { + void testAgentLeavesVehicleAtNextStop() { HashMap, Double> arrivalTimes = new HashMap<>(); HashMap, List> trips = new HashMap<>(); Config config = ConfigUtils @@ -268,7 +267,7 @@ public void testAgentLeavesVehicleAtNextStop() { * This is due to the utility params for walk, pt_wait and pt being equal/indifferent. */ @Test - public void testAgentIsAtTeleportLegAndLeavesStop() { + void testAgentIsAtTeleportLegAndLeavesStop() { HashMap, Double> arrivalTimes = new HashMap<>(); HashMap, List> trips = new HashMap<>(); Config config = ConfigUtils.loadConfig(configURL); @@ -306,7 +305,7 @@ public void testAgentIsAtTeleportLegAndLeavesStop() { * pt_wait and pt. Strangely only works with walk being significantly worse, does not work with small differences. */ @Test - public void testAgentIsAtTeleportLegAndWaitsAtStop_walkUnattractive() { + void testAgentIsAtTeleportLegAndWaitsAtStop_walkUnattractive() { HashMap, Double> arrivalTimes = new HashMap<>(); HashMap, List> trips = new HashMap<>(); Config config = ConfigUtils @@ -346,7 +345,7 @@ public void testAgentIsAtTeleportLegAndWaitsAtStop_walkUnattractive() { * Case 2.2 */ @Test - public void testAgentIsAtTeleportLegAndWaitsAtStop() { + void testAgentIsAtTeleportLegAndWaitsAtStop() { HashMap, Double> arrivalTimes = new HashMap<>(); HashMap, List> trips = new HashMap<>(); Config config = ConfigUtils.loadConfig(configURL); @@ -383,7 +382,7 @@ public void testAgentIsAtTeleportLegAndWaitsAtStop() { * Simulates 900 agents so this case should include every possible state of an agent. Current and future trips are replanned. */ @Test - public void testOneAgentEveryFourSeconds() { + void testOneAgentEveryFourSeconds() { HashMap, Double> arrivalTimes = new HashMap<>(); HashMap, List> trips = new HashMap<>(); Config config = ConfigUtils diff --git a/contribs/vsp/src/test/java/playground/vsp/pt/transitRouteTrimmer/TransitRouteTrimmerTest.java b/contribs/vsp/src/test/java/playground/vsp/pt/transitRouteTrimmer/TransitRouteTrimmerTest.java index 549528ceb83..def2f9bebad 100644 --- a/contribs/vsp/src/test/java/playground/vsp/pt/transitRouteTrimmer/TransitRouteTrimmerTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/pt/transitRouteTrimmer/TransitRouteTrimmerTest.java @@ -23,7 +23,7 @@ import javafx.util.Pair; import org.junit.Assert; import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.locationtech.jts.geom.prep.PreparedGeometry; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -89,16 +89,16 @@ public enum routeType { } - /* + /* Part 1: these tests check whether the three route types are actually configured as described above */ - /** - * In the allIn scenario, the transitRoute in question should have all stops within zone. - */ - @Ignore - @Test - public void test_AllIn() { + /** + * In the allIn scenario, the transitRoute in question should have all stops within zone. + */ + @Ignore + @Test + void test_AllIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -122,13 +122,13 @@ public void test_AllIn() { assertEquals("All stops should be inside the zone", stopsTotal, stopsInZoneCnt); } - /** - * In the halfIn scenario, the transitRoute in question begins outside of the zone and - * ends within the zone. - */ - @Ignore - @Test - public void test_HalfIn() { + /** + * In the halfIn scenario, the transitRoute in question begins outside of the zone and + * ends within the zone. + */ + @Ignore + @Test + void test_HalfIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -150,13 +150,13 @@ public void test_HalfIn() { } - /** - * In the MiddleIn scenario, the transitRoute in question begins outside of the zone then dips - * into the zone, and finally leaves the zone once again - */ - @Ignore - @Test - public void test_MiddleIn() { + /** + * In the MiddleIn scenario, the transitRoute in question begins outside of the zone then dips + * into the zone, and finally leaves the zone once again + */ + @Ignore + @Test + void test_MiddleIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -178,19 +178,19 @@ public void test_MiddleIn() { } - /* + /* Part 2: These tests check functionality of all four trimming methods. For each trimming method, all three route types are checked. */ - /** - * trimming method: DeleteRoutesEntirelyInsideZone. - * route scenario: AllIn - * The testRoute should be deleted since all stops are within the zone. - */ - @Ignore - @Test - public void testDeleteRoutesEntirelyInsideZone_AllIn() { + /** + * trimming method: DeleteRoutesEntirelyInsideZone. + * route scenario: AllIn + * The testRoute should be deleted since all stops are within the zone. + */ + @Ignore + @Test + void testDeleteRoutesEntirelyInsideZone_AllIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -218,15 +218,15 @@ public void testDeleteRoutesEntirelyInsideZone_AllIn() { } - /** - * trimming method: DeleteRoutesEntirelyInsideZone. - * route scenario: HalfIn - * The testRoute should be retained and left unmodified, - * since some stops are outside the zone. - */ - @Ignore - @Test - public void testDeleteRoutesEntirelyInsideZone_HalfIn() { + /** + * trimming method: DeleteRoutesEntirelyInsideZone. + * route scenario: HalfIn + * The testRoute should be retained and left unmodified, + * since some stops are outside the zone. + */ + @Ignore + @Test + void testDeleteRoutesEntirelyInsideZone_HalfIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -266,15 +266,15 @@ public void testDeleteRoutesEntirelyInsideZone_HalfIn() { } - /** - * trimming method: DeleteRoutesEntirelyInsideZone. - * route scenario: MiddleIn - * The testRoute should be retained and left unmodified, - * since some stops are outside the zone. - */ - @Ignore - @Test - public void testDeleteRoutesEntirelyInsideZone_MiddleIn() { + /** + * trimming method: DeleteRoutesEntirelyInsideZone. + * route scenario: MiddleIn + * The testRoute should be retained and left unmodified, + * since some stops are outside the zone. + */ + @Ignore + @Test + void testDeleteRoutesEntirelyInsideZone_MiddleIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -314,14 +314,14 @@ public void testDeleteRoutesEntirelyInsideZone_MiddleIn() { } - /** - * trimming method: TrimEnds. - * route scenario: AllIn - * The testRoute should be deleted since all stops are within the zone. - */ - @Ignore - @Test - public void testTrimEnds_AllIn() { + /** + * trimming method: TrimEnds. + * route scenario: AllIn + * The testRoute should be deleted since all stops are within the zone. + */ + @Ignore + @Test + void testTrimEnds_AllIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -349,14 +349,14 @@ public void testTrimEnds_AllIn() { } - /** - * trimming method: TrimEnds. - * route scenario: HalfIn - * The second half of the route is outside the zone and should be trimmed - */ - @Ignore - @Test - public void testTrimEnds_HalfIn() { + /** + * trimming method: TrimEnds. + * route scenario: HalfIn + * The second half of the route is outside the zone and should be trimmed + */ + @Ignore + @Test + void testTrimEnds_HalfIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -406,14 +406,14 @@ public void testTrimEnds_HalfIn() { vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); } - /** - * trimming method: TrimEnds. - * route scenario: MiddleIn - * Since the ends are both outside of zone, route should not be modified - */ - @Ignore - @Test - public void testTrimEnds_MiddleIn() { + /** + * trimming method: TrimEnds. + * route scenario: MiddleIn + * Since the ends are both outside of zone, route should not be modified + */ + @Ignore + @Test + void testTrimEnds_MiddleIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -454,14 +454,14 @@ public void testTrimEnds_MiddleIn() { } - /** - * trimming method: SkipStops. - * route scenario: AllIn - * New route should be empty - */ - @Ignore - @Test - public void testSkipStops_AllIn() { + /** + * trimming method: SkipStops. + * route scenario: AllIn + * New route should be empty + */ + @Ignore + @Test + void testSkipStops_AllIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -486,14 +486,14 @@ public void testSkipStops_AllIn() { } - /** - * trimming method: SkipStops. - * route scenario: HalfIn - * Stops outside zone should be skipped - */ - @Ignore - @Test - public void testSkipStops_HalfIn() { + /** + * trimming method: SkipStops. + * route scenario: HalfIn + * Stops outside zone should be skipped + */ + @Ignore + @Test + void testSkipStops_HalfIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -538,14 +538,14 @@ public void testSkipStops_HalfIn() { } - /** - * trimming method: SkipStops. - * route scenario: MiddleIn - * New route should have less stops than old route, but same amount of links - */ - @Ignore - @Test - public void testSkipStops_MiddleIn() { + /** + * trimming method: SkipStops. + * route scenario: MiddleIn + * New route should have less stops than old route, but same amount of links + */ + @Ignore + @Test + void testSkipStops_MiddleIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -588,14 +588,14 @@ public void testSkipStops_MiddleIn() { vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); } - /** - * trimming method: SplitRoutes. - * route scenario: AllIn - * route will be deleted - */ - @Ignore - @Test - public void testSplitRoutes_AllIn() { + /** + * trimming method: SplitRoutes. + * route scenario: AllIn + * route will be deleted + */ + @Ignore + @Test + void testSplitRoutes_AllIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -623,14 +623,14 @@ public void testSplitRoutes_AllIn() { vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); } - /** - * trimming method: SplitRoutes. - * route scenario: HalfIn - * New route should have less stops than old route - */ - @Ignore - @Test - public void testSplitRoutes_HalfIn() { + /** + * trimming method: SplitRoutes. + * route scenario: HalfIn + * New route should have less stops than old route + */ + @Ignore + @Test + void testSplitRoutes_HalfIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -674,14 +674,14 @@ public void testSplitRoutes_HalfIn() { vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); } - /** - * trimming method: SplitRoutes. - * route scenario: MiddleIn - * Two routes should be created, each with only one stop within zone - */ - @Ignore - @Test - public void testSplitRoutes_MiddleIn() { + /** + * trimming method: SplitRoutes. + * route scenario: MiddleIn + * Two routes should be created, each with only one stop within zone + */ + @Ignore + @Test + void testSplitRoutes_MiddleIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -732,22 +732,22 @@ public void testSplitRoutes_MiddleIn() { } - /* - Part 3: tests hub functionality for SplitRoutes trimming method (using route type "middleIn") - Hubs allow route to extend into zone to reach a import transit stop (like a major transfer point) - */ + /* + Part 3: tests hub functionality for SplitRoutes trimming method (using route type "middleIn") + Hubs allow route to extend into zone to reach a import transit stop (like a major transfer point) + */ - /** - * Test Hub functionality - * trimming method: SplitRoutes. - * route scenario: MiddleIn - * tests reach of hubs. Left hub should be included in route 1, while right hub should not be - * included in route 2, due to lacking reach - */ - @Ignore - @Test - public void testSplitRoutes_MiddleIn_Hub_ValidateReach() { + /** + * Test Hub functionality + * trimming method: SplitRoutes. + * route scenario: MiddleIn + * tests reach of hubs. Left hub should be included in route 1, while right hub should not be + * included in route 2, due to lacking reach + */ + @Ignore + @Test + void testSplitRoutes_MiddleIn_Hub_ValidateReach() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -808,16 +808,16 @@ public void testSplitRoutes_MiddleIn_Hub_ValidateReach() { vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); } - /** - * Test Hub functionality - * trimming method: SplitRoutes. - * route scenario: MiddleIn - * tests parameter to include first nearest hub, even if reach is insufficient. - * Right hub should be included, even though reach is too low. - */ - @Ignore - @Test - public void testSplitRoutes_MiddleIn_Hub_IncludeFirstHubInZone() { + /** + * Test Hub functionality + * trimming method: SplitRoutes. + * route scenario: MiddleIn + * tests parameter to include first nearest hub, even if reach is insufficient. + * Right hub should be included, even though reach is too low. + */ + @Ignore + @Test + void testSplitRoutes_MiddleIn_Hub_IncludeFirstHubInZone() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); Id transitLineId = routeType.middleIn.transitLineId; @@ -886,15 +886,15 @@ public void testSplitRoutes_MiddleIn_Hub_IncludeFirstHubInZone() { vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); } - /** - * Test Hub functionality - * trimming method: SplitRoutes. - * route scenario: MiddleIn - * if multiple hubs are within reach of route, the route should go to further one - */ - @Ignore - @Test - public void testSplitRoutes_MiddleIn_Hub_MultipleHubs() { + /** + * Test Hub functionality + * trimming method: SplitRoutes. + * route scenario: MiddleIn + * if multiple hubs are within reach of route, the route should go to further one + */ + @Ignore + @Test + void testSplitRoutes_MiddleIn_Hub_MultipleHubs() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -954,16 +954,16 @@ public void testSplitRoutes_MiddleIn_Hub_MultipleHubs() { } - /** - * Test Hub functionality - * trimming method: SplitRoutes. - * route scenario: MiddleIn - * if two new routes overlap (because they both reach to same hub) - * then they should be combined into one route - */ - @Ignore - @Test - public void testSplitRoutes_MiddleIn_Hub_OverlapRoutes() { + /** + * Test Hub functionality + * trimming method: SplitRoutes. + * route scenario: MiddleIn + * if two new routes overlap (because they both reach to same hub) + * then they should be combined into one route + */ + @Ignore + @Test + void testSplitRoutes_MiddleIn_Hub_OverlapRoutes() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); @@ -1006,20 +1006,20 @@ public void testSplitRoutes_MiddleIn_Hub_OverlapRoutes() { } - /* - Part 4: Tests individual user-defined parameters - */ - - /** - * Test parameter allowableStopsWithinZone - * trimming method: SplitRoutes. - * route scenario: MiddleIn - * route should not be split, since the parameter allowableStopsWithinZone is equal to the number - * of stops within zone + /* + Part 4: Tests individual user-defined parameters */ - @Ignore - @Test - public void testSplitRoutes_MiddleIn_AllowableStopsWithin() { + + /** + * Test parameter allowableStopsWithinZone + * trimming method: SplitRoutes. + * route scenario: MiddleIn + * route should not be split, since the parameter allowableStopsWithinZone is equal to the number + * of stops within zone + */ + @Ignore + @Test + void testSplitRoutes_MiddleIn_AllowableStopsWithin() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); Id transitLineId = routeType.middleIn.transitLineId; @@ -1059,9 +1059,9 @@ public void testSplitRoutes_MiddleIn_AllowableStopsWithin() { } - @Ignore - @Test - public void testDeparturesAndOffsetsAndDescription() { + @Ignore + @Test + void testDeparturesAndOffsetsAndDescription() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); Set> stopsInZone = getStopsInZone(scenario.getTransitSchedule(), inZoneShpFile); diff --git a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java index 42fd52d8119..ba7aac9976a 100644 --- a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java @@ -2,8 +2,8 @@ import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; @@ -75,7 +75,7 @@ public void setUp() { } @Test - public void testPersonWithNegativeIncome(){ + void testPersonWithNegativeIncome(){ Id id = Id.createPersonId("negativeIncome"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); //person's attribute says it has negative income which is considered invalid and therefore the subpopulation's mgnUtilityOfMoney is taken (which is 1) @@ -83,7 +83,7 @@ public void testPersonWithNegativeIncome(){ } @Test - public void testPersonWithNoIncome(){ + void testPersonWithNoIncome(){ Id id = Id.createPersonId("zeroIncome"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); //person's attribute says it has 0 income which is considered invalid and therefore the subpopulation's mgnUtilityOfMoney is taken (which is 1) @@ -91,28 +91,28 @@ public void testPersonWithNoIncome(){ } @Test - public void testPersonWithLowIncome(){ + void testPersonWithLowIncome(){ Id id = Id.createPersonId("lowIncome"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssert(params, 0.5d, 0.5d); } @Test - public void testPersonWithHighIncome(){ + void testPersonWithHighIncome(){ Id id = Id.createPersonId("highIncome"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssert(params, 1.5d, 0.5d); } @Test - public void testPersonWithMediumIncome(){ + void testPersonWithMediumIncome(){ Id id = Id.createPersonId("mediumIncome"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssert(params, 1d, 0.5d); } @Test - public void testMoneyScore(){ + void testMoneyScore(){ ScoringParameters paramsRich = personScoringParams.getScoringParameters(population.getPersons().get(Id.createPersonId("highIncome"))); CharyparNagelMoneyScoring moneyScoringRich = new CharyparNagelMoneyScoring(paramsRich); moneyScoringRich.addMoney(100); diff --git a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java index d94fa19d64d..a6c9cdbb8d0 100644 --- a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java @@ -1,6 +1,8 @@ package playground.vsp.scoring; -import org.junit.*; +import org.junit.Assert; +import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -95,7 +97,7 @@ public void setUp() { } @Test - public void testPersonWithNegativeIncome(){ + void testPersonWithNegativeIncome(){ Id id = Id.createPersonId("negativeIncome"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); //person's attribute says it has negative income which is considered invalid and therefore the subpopulation's mgnUtilityOfMoney is taken (which is 1) @@ -103,7 +105,7 @@ public void testPersonWithNegativeIncome(){ } @Test - public void testPersonWithNoIncome(){ + void testPersonWithNoIncome(){ Id id = Id.createPersonId("zeroIncome"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); //person's attribute says it has 0 income which is considered invalid and therefore the subpopulation's mgnUtilityOfMoney is taken (which is 1) @@ -111,28 +113,28 @@ public void testPersonWithNoIncome(){ } @Test - public void testPersonWithLowIncome(){ + void testPersonWithLowIncome(){ Id id = Id.createPersonId("lowIncome"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssert(params, 0.5d, 0.5d); } @Test - public void testPersonWithHighIncome(){ + void testPersonWithHighIncome(){ Id id = Id.createPersonId("highIncome"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssert(params, 1.5d, 0.5d); } @Test - public void testPersonWithMediumIncome(){ + void testPersonWithMediumIncome(){ Id id = Id.createPersonId("mediumIncome"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssert(params, 1d, 0.5d); } @Test - public void testPersonFreight(){ + void testPersonFreight(){ Id id = Id.createPersonId("freight"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); //freight agent has no income attribute set, so it should use the marginal utility of money that is set in it's subpopulation scoring parameters! @@ -140,7 +142,7 @@ public void testPersonFreight(){ } @Test - public void testFreightWithIncome(){ + void testFreightWithIncome(){ Id id = Id.createPersonId("freightWithIncome1"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssert(params, 1.5/444d, 1d); @@ -150,7 +152,7 @@ public void testFreightWithIncome(){ } @Test - public void testMoneyScore(){ + void testMoneyScore(){ ScoringParameters paramsRich = personScoringParams.getScoringParameters(population.getPersons().get(Id.createPersonId("highIncome"))); CharyparNagelMoneyScoring moneyScoringRich = new CharyparNagelMoneyScoring(paramsRich); moneyScoringRich.addMoney(100); diff --git a/contribs/vsp/src/test/java/playground/vsp/zzArchive/bvwpOld/BvwpTest.java b/contribs/vsp/src/test/java/playground/vsp/zzArchive/bvwpOld/BvwpTest.java index fe8cee1a096..ea0ef7f8974 100644 --- a/contribs/vsp/src/test/java/playground/vsp/zzArchive/bvwpOld/BvwpTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/zzArchive/bvwpOld/BvwpTest.java @@ -20,19 +20,19 @@ package playground.vsp.zzArchive.bvwpOld; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; - public class BvwpTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testOne() { + @Test + void testOne() { Values economicValues = EconomicValues.createEconomicValuesForTest1(); diff --git a/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java b/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java index 2db9c5610db..eb432ad08a5 100644 --- a/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java @@ -27,7 +27,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigReader; @@ -49,8 +49,8 @@ public void setup() { System.setProperty("matsim.preferLocalDtds", "true"); } - @Test - public void testConfigIO_general() { + @Test + void testConfigIO_general() { SwissRailRaptorConfigGroup config1 = new SwissRailRaptorConfigGroup(); { // prepare config1 @@ -69,8 +69,8 @@ public void testConfigIO_general() { Assert.assertEquals(0.0031 * 3600, config2.getTransferPenaltyCostPerTravelTimeHour(), 0.0); } - @Test - public void testConfigIO_rangeQuery() { + @Test + void testConfigIO_rangeQuery() { SwissRailRaptorConfigGroup config1 = new SwissRailRaptorConfigGroup(); { // prepare config1 @@ -108,8 +108,8 @@ public void testConfigIO_rangeQuery() { Assert.assertEquals(15*60, range2.getMaxLaterDeparture()); } - @Test - public void testConfigIO_routeSelector() { + @Test + void testConfigIO_routeSelector() { SwissRailRaptorConfigGroup config1 = new SwissRailRaptorConfigGroup(); { // prepare config1 @@ -150,8 +150,8 @@ public void testConfigIO_routeSelector() { Assert.assertEquals(1.2, selector2.getBetaTravelTime(), 0.0); } - @Test - public void testConfigIO_intermodalAccessEgress() { + @Test + void testConfigIO_intermodalAccessEgress() { SwissRailRaptorConfigGroup config1 = new SwissRailRaptorConfigGroup(); { // prepare config1 @@ -215,8 +215,8 @@ public void testConfigIO_intermodalAccessEgress() { Assert.assertEquals("hub", paramSet2.getStopFilterValue()); } - @Test - public void testConfigIO_modeMappings() { + @Test + void testConfigIO_modeMappings() { SwissRailRaptorConfigGroup config1 = new SwissRailRaptorConfigGroup(); { // prepare config1 diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/CapacityDependentScoringTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/CapacityDependentScoringTest.java index 31ebe0fa112..0518b08dcf2 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/CapacityDependentScoringTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/CapacityDependentScoringTest.java @@ -20,7 +20,7 @@ package ch.sbb.matsim.routing.pt.raptor; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -81,7 +81,7 @@ public class CapacityDependentScoringTest { @Test - public void testScoring() { + void testScoring() { double normalScore = calcScore(new Fixture(), false); double capDepScore = calcScore(new Fixture(), true); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/OccupancyTrackerTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/OccupancyTrackerTest.java index 4e9b916dde4..809f316a4bd 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/OccupancyTrackerTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/OccupancyTrackerTest.java @@ -21,7 +21,7 @@ import ch.sbb.matsim.routing.pt.raptor.OccupancyData.DepartureData; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.PersonDepartureEvent; @@ -54,7 +54,7 @@ public class OccupancyTrackerTest { @Test - public void testGetNextDeparture() { + void testGetNextDeparture() { Fixture f = new Fixture(); EventsManager events = EventsUtils.createEventsManager(); @@ -131,7 +131,7 @@ public void testGetNextDeparture() { } @Test - public void testGetDepartureData() { + void testGetDepartureData() { Fixture f = new Fixture(); EventsManager events = EventsUtils.createEventsManager(); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java index 9f712b2edaf..1fe325b7801 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java @@ -21,7 +21,7 @@ import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -66,21 +66,19 @@ public class RaptorStopFinderTest { private final Facility toFac = new FakeFacility(new Coord(100000, 0), Id.create("XX", Link.class)); // stop X - /** Empty Initial Search Radius - * Tests the how the StopFinder reacts when there are no public transit stops within the Initial_Search_Radius. - * The expected behaviour of the StopFinder is to find the closest public transit stop and set the new search - * radius as the sum of the distance to the nearest stop and the Search_Extension_Radius. However, if the general - * radius is smaller than this new search radius, then the StopFinder will only search to the extents of the general - * Radius. - * - * This functionality is tested for the two RaptorStopFinders: 1) DefaultStopFinder and 2) RandomAccessEgressModeRaptorStopFinder - * For each RaptorStopFinder there is one test where StopFilterAttributes are not used to exlclude stops, and one test - * where StopFilterAttributes are used. - */ - - - @Test - public void testDefaultStopFinder_EmptyInitialSearchRadius() { + /** Empty Initial Search Radius + * Tests the how the StopFinder reacts when there are no public transit stops within the Initial_Search_Radius. + * The expected behaviour of the StopFinder is to find the closest public transit stop and set the new search + * radius as the sum of the distance to the nearest stop and the Search_Extension_Radius. However, if the general + * radius is smaller than this new search radius, then the StopFinder will only search to the extents of the general + * Radius. + * + * This functionality is tested for the two RaptorStopFinders: 1) DefaultStopFinder and 2) RandomAccessEgressModeRaptorStopFinder + * For each RaptorStopFinder there is one test where StopFilterAttributes are not used to exlclude stops, and one test + * where StopFilterAttributes are used. + */ + @Test + void testDefaultStopFinder_EmptyInitialSearchRadius() { /* General Radius includes no stops. Search_Extension_Radius is 0 Expected: StopFinder will find no stops, since closest stop is outside of general radius. Therefore agent will use transit_walk to get from A to X. @@ -198,8 +196,8 @@ public void testDefaultStopFinder_EmptyInitialSearchRadius() { } - @Test - public void testDefaultStopFinder_EmptyInitialSearchRadius_StopFilterAttributes() { + @Test + void testDefaultStopFinder_EmptyInitialSearchRadius_StopFilterAttributes() { /* Initial_Search_Radius and General Radius contain only stop B. Stop B is not "walkAccessible"; all other stops are "walkAccessible" Search_Extension_Radius is 0 Expected: StopFinder will find no stops, since closest accessible stop is outside of general radius. Therefore @@ -395,8 +393,8 @@ Initial_Search_Radius includes B (not "walkAccessible") } - @Test - public void testRandomAccessEgressModeRaptorStopFinder_EmptyInitialSearchRadius() { + @Test + void testRandomAccessEgressModeRaptorStopFinder_EmptyInitialSearchRadius() { /* General Radius includes no stops. Search_Extension_Radius is 0 Expected: StopFinder will find no stops, since closest stop is outside of general radius. Therefore agent will use transit_walk to get from A to X. @@ -516,8 +514,8 @@ public void testRandomAccessEgressModeRaptorStopFinder_EmptyInitialSearchRadius( } - @Test - public void testRandomAccessEgressModeRaptorStopFinder_EmptyInitialSearchRadius_StopFilterAttributes() { + @Test + void testRandomAccessEgressModeRaptorStopFinder_EmptyInitialSearchRadius_StopFilterAttributes() { /* Initial_Search_Radius and General Radius contain only stop B. Stop B is not "walkAccessible"; all other stops are "walkAccessible" Search_Extension_Radius is 0 Expected: StopFinder will find no stops, since closest accessible stop is outside of general radius. Therefore @@ -716,22 +714,22 @@ Initial_Search_Radius includes B (not "walkAccessible") } - // *********************************************************************************************************** - - /** Half Full Initial Search Radius - * Tests the how the StopFinder reacts when there is only one public transit stop within the Initial_Search_Radius. - * In this case, the Initial_Search_Radius will always contain stop B, but no other stops. - * The expected behaviour of the StopFinder define a new extended search radius, which is the sum of the distance - * to stop B and the Search_Extension_Radius. However, if the general - * radius is smaller than this new search radius, then the StopFinder will only search to the extents of the general - * Radius. - * - * This functionality is tested for the two RaptorStopFinders: 1) DefaultStopFinder and 2) RandomAccessEgressModeRaptorStopFinder - * For each RaptorStopFinder there is one test where StopFilterAttributes are not used to exlclude stops, and one test - * where StopFilterAttributes are used. - */ - @Test - public void testDefaultStopFinder_HalfFullInitialSearchRadius() { + // *********************************************************************************************************** + + /** Half Full Initial Search Radius + * Tests the how the StopFinder reacts when there is only one public transit stop within the Initial_Search_Radius. + * In this case, the Initial_Search_Radius will always contain stop B, but no other stops. + * The expected behaviour of the StopFinder define a new extended search radius, which is the sum of the distance + * to stop B and the Search_Extension_Radius. However, if the general + * radius is smaller than this new search radius, then the StopFinder will only search to the extents of the general + * Radius. + * + * This functionality is tested for the two RaptorStopFinders: 1) DefaultStopFinder and 2) RandomAccessEgressModeRaptorStopFinder + * For each RaptorStopFinder there is one test where StopFilterAttributes are not used to exlclude stops, and one test + * where StopFilterAttributes are used. + */ + @Test + void testDefaultStopFinder_HalfFullInitialSearchRadius() { /* Initial_Search_Radius includes B. Search_Extension_Radius is 0. General_Radius includes B, C, D and E Expected: Stop Finder will only find stop B, since the Search_Extension_Radius doesn't encompass more stops. @@ -867,8 +865,8 @@ public void testDefaultStopFinder_HalfFullInitialSearchRadius() { } - @Test - public void testDefaultStopFinder_HalfFullInitialSearchRadius_StopFilterAttributes() { + @Test + void testDefaultStopFinder_HalfFullInitialSearchRadius_StopFilterAttributes() { /* Initial_Search_Radius includes B and C. Search_Extension_Radius is 0. General_Radius includes B, C, D and E Stop B is not "walkAccessible", but all others are. @@ -973,8 +971,8 @@ public void testDefaultStopFinder_HalfFullInitialSearchRadius_StopFilterAttribut } - @Test - public void testRandomAccessEgressModeRaptorStopFinder_HalfFullInitialSearchRadius() { + @Test + void testRandomAccessEgressModeRaptorStopFinder_HalfFullInitialSearchRadius() { /* Initial_Search_Radius includes B. Search_Extension_Radius is 0. General_Radius includes B, C, D and E Expected: Stop Finder will only find stop B, since the Search_Extension_Radius doesn't encompass more stops. @@ -1113,8 +1111,8 @@ public void testRandomAccessEgressModeRaptorStopFinder_HalfFullInitialSearchRadi } - @Test - public void testRandomAccessEgressModeRaptorStopFinder_HalfFullInitialSearchRadius_StopFilterAttributes() { + @Test + void testRandomAccessEgressModeRaptorStopFinder_HalfFullInitialSearchRadius_StopFilterAttributes() { /* Initial_Search_Radius includes B and C. Search_Extension_Radius is 0. General_Radius includes B, C, D and E Stop B is not "walkAccessible", but all others are. @@ -1221,21 +1219,21 @@ public void testRandomAccessEgressModeRaptorStopFinder_HalfFullInitialSearchRadi } - // *********************************************************************************************************** + // *********************************************************************************************************** - /** Full Initial Search Radius - * Tests the how the StopFinder reacts when there are at least 2 stop within the Initial_Search_Radius. In the - * following tests, the Initial_Search_Radius includes stops B and C. - * The StopFinder should then not find stops outside of Initial_Search_Radius, even if the Search_Extension_Radius - * is initialized. If the general Radius is smaller than the Initial_Search_Radius, then the StopFinder should only - * search to the extents of the general radius. - * - * This functionality is tested for the two RaptorStopFinders: 1) DefaultStopFinder and 2) RandomAccessEgressModeRaptorStopFinder - * For each RaptorStopFinder there is one test where StopFilterAttributes are not used to exlclude stops, and one test - * where StopFilterAttributes are used. - */ - @Test - public void testDefaultStopFinder_FullInitialSearchRadius() { + /** Full Initial Search Radius + * Tests the how the StopFinder reacts when there are at least 2 stop within the Initial_Search_Radius. In the + * following tests, the Initial_Search_Radius includes stops B and C. + * The StopFinder should then not find stops outside of Initial_Search_Radius, even if the Search_Extension_Radius + * is initialized. If the general Radius is smaller than the Initial_Search_Radius, then the StopFinder should only + * search to the extents of the general radius. + * + * This functionality is tested for the two RaptorStopFinders: 1) DefaultStopFinder and 2) RandomAccessEgressModeRaptorStopFinder + * For each RaptorStopFinder there is one test where StopFilterAttributes are not used to exlclude stops, and one test + * where StopFilterAttributes are used. + */ + @Test + void testDefaultStopFinder_FullInitialSearchRadius() { /* Search_Extension_Radius includes D and E @@ -1331,8 +1329,8 @@ public void testDefaultStopFinder_FullInitialSearchRadius() { } - @Test - public void testDefaultStopFinder_FullInitialSearchRadius_StopFilterAttributes() { + @Test + void testDefaultStopFinder_FullInitialSearchRadius_StopFilterAttributes() { /* Initial_Search_Radius includes B, C, and D @@ -1445,8 +1443,8 @@ public void testDefaultStopFinder_FullInitialSearchRadius_StopFilterAttributes() } } - @Test - public void testRandomAccessEgressModeRaptorStopFinder_FullInitialSearchRadius() { + @Test + void testRandomAccessEgressModeRaptorStopFinder_FullInitialSearchRadius() { /* Search_Extension_Radius includes D and E @@ -1544,8 +1542,8 @@ public void testRandomAccessEgressModeRaptorStopFinder_FullInitialSearchRadius() } - @Test - public void testRandomAccessEgressModeRaptorStopFinder_FullInitialSearchRadius_StopFilterAttributes() { + @Test + void testRandomAccessEgressModeRaptorStopFinder_FullInitialSearchRadius_StopFilterAttributes() { /* Initial_Search_Radius includes B, C, and D @@ -1661,10 +1659,10 @@ public void testRandomAccessEgressModeRaptorStopFinder_FullInitialSearchRadius_S } - // *********************************************************************************************************** - @Deprecated - @Test - public void testDefaultStopFinder_testMultipleModes() { + // *********************************************************************************************************** + @Deprecated + @Test + void testDefaultStopFinder_testMultipleModes() { // Test 7: Test Stop Filter Attributes // Initial_Search_Radius includes B and C and D diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtilsTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtilsTest.java index 2a6ee7b9abc..d401ec3ba52 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtilsTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtilsTest.java @@ -22,7 +22,7 @@ import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigGroup; import org.matsim.core.config.ConfigReader; @@ -43,8 +43,8 @@ public void setup() { System.setProperty("matsim.preferLocalDtds", "true"); } - @Test - public void testConfigLoading() { + @Test + void testConfigLoading() { // prepare config SwissRailRaptorConfigGroup srrConfig = new SwissRailRaptorConfigGroup(); Config config1 = ConfigUtils.createConfig(srrConfig); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCapacitiesTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCapacitiesTest.java index a986cb26763..eaa6c0ddfc6 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCapacitiesTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCapacitiesTest.java @@ -21,7 +21,7 @@ import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -70,7 +70,7 @@ public class SwissRailRaptorCapacitiesTest { @Test - public void testUseSlowerAlternative() { + void testUseSlowerAlternative() { Fixture f = new Fixture(); // default case diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorDataTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorDataTest.java index 5a0a4711a2f..6fbd90145a8 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorDataTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorDataTest.java @@ -20,7 +20,7 @@ package ch.sbb.matsim.routing.pt.raptor; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.pt.transitSchedule.api.TransitStopFacility; @@ -29,8 +29,8 @@ */ public class SwissRailRaptorDataTest { - @Test - public void testTransfersFromSchedule() { + @Test + void testTransfersFromSchedule() { Fixture f = new Fixture(); f.init(); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorInVehicleCostTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorInVehicleCostTest.java index 76b098fa73f..05aa44fe5d2 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorInVehicleCostTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorInVehicleCostTest.java @@ -20,7 +20,7 @@ package ch.sbb.matsim.routing.pt.raptor; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -72,7 +72,7 @@ */ public class SwissRailRaptorInVehicleCostTest { - /* fastRoute takes 14min30sec. (==> 870 sec) + /*fastRoute takes 14min30sec. (==> 870 sec) * slowRoute takes 20min30sec (==> 1230 sec) and departs 1 min later. * slowRoute arrives 7 minutes later ==> 420 sec * @@ -82,19 +82,19 @@ public class SwissRailRaptorInVehicleCostTest { */ @Test - public void testBaseline_defaultInVehicleCostCalculator_uses_fastRoute() { + void testBaseline_defaultInVehicleCostCalculator_uses_fastRoute() { Fixture f = new Fixture(); runTest(f, new DefaultRaptorInVehicleCostCalculator(), f.fastLineId); } @Test - public void testBaseline_capacityDependentInVehicleCost_indifferent_uses_fastRoute() { + void testBaseline_capacityDependentInVehicleCost_indifferent_uses_fastRoute() { Fixture f = new Fixture(); runTest(f, new CapacityDependentInVehicleCostCalculator(1.0, 0.3, 0.6, 1.8), f.fastLineId); } @Test - public void test_capacityDependentInVehicleCost_prefersLowOccupancy_uses_slowRoute() { + void test_capacityDependentInVehicleCost_prefersLowOccupancy_uses_slowRoute() { Fixture f = new Fixture(); // from the note above: @@ -114,13 +114,13 @@ public void test_capacityDependentInVehicleCost_prefersLowOccupancy_uses_slowRou } @Test - public void test_capacityDependentInVehicleCost_minorHighOccupancyAvoidance_uses_fastRoute() { + void test_capacityDependentInVehicleCost_minorHighOccupancyAvoidance_uses_fastRoute() { Fixture f = new Fixture(); runTest(f, new CapacityDependentInVehicleCostCalculator(1.0, 0.3, 0.6, 1.2), f.fastLineId); } @Test - public void test_capacityDependentInVehicleCost_majorHighOccupancyAvoidance_uses_slowRoute() { + void test_capacityDependentInVehicleCost_majorHighOccupancyAvoidance_uses_slowRoute() { Fixture f = new Fixture(); runTest(f, new CapacityDependentInVehicleCostCalculator(1.0, 0.3, 0.6, 2.0), f.slowLineId); } diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java index 973d16bb1f2..61ddb4ba6de 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java @@ -22,7 +22,7 @@ import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup.IntermodalAccessEgressParameterSet; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -69,8 +69,8 @@ */ public class SwissRailRaptorIntermodalTest { - @Test - public void testIntermodalTrip() { + @Test + void testIntermodalTrip() { IntermodalFixture f = new IntermodalFixture(); ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); @@ -133,8 +133,8 @@ public void testIntermodalTrip() { Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } - @Test - public void testIntermodalTrip_TripRouterIntegration() { + @Test + void testIntermodalTrip_TripRouterIntegration() { IntermodalFixture f = new IntermodalFixture(); RoutingModule walkRoutingModule = new TeleportationRoutingModule(TransportMode.walk, f.scenario, 1.1, 1.3); @@ -214,8 +214,8 @@ public void testIntermodalTrip_TripRouterIntegration() { Assert.assertEquals(0.0, ((Activity)planElements.get(7)).getMaximumDuration().seconds(), 0.0); } - @Test - public void testIntermodalTrip_walkOnlyNoSubpop() { + @Test + void testIntermodalTrip_walkOnlyNoSubpop() { IntermodalFixture f = new IntermodalFixture(); ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); @@ -262,12 +262,12 @@ public void testIntermodalTrip_walkOnlyNoSubpop() { Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } - /** - * Test that if start and end are close to each other, such that the intermodal - * access and egress go to/from the same stop, still a direct transit_walk is returned. - */ - @Test - public void testIntermodalTrip_withoutPt() { + /** + * Test that if start and end are close to each other, such that the intermodal + * access and egress go to/from the same stop, still a direct transit_walk is returned. + */ + @Test + void testIntermodalTrip_withoutPt() { IntermodalFixture f = new IntermodalFixture(); ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); @@ -302,8 +302,8 @@ public void testIntermodalTrip_withoutPt() { Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); } - @Test - public void testDirectWalkFactor() { + @Test + void testDirectWalkFactor() { IntermodalFixture f = new IntermodalFixture(); f.config.scoring().setPerforming_utils_hr(6.0); @@ -392,8 +392,8 @@ public void testDirectWalkFactor() { Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } - @Test - public void testAccessEgressModeFasterThanPt() { + @Test + void testAccessEgressModeFasterThanPt() { IntermodalFixture f = new IntermodalFixture(); /* * setDirectWalkFactor(Double.POSITIVE_INFINITY) leads to the case where in SwissRailRaptor.calcRoute() both the found @@ -486,9 +486,8 @@ public void testAccessEgressModeFasterThanPt() { } - - @Test - public void testIntermodalTrip_competingAccess() { + @Test + void testIntermodalTrip_competingAccess() { IntermodalFixture f = new IntermodalFixture(); Map routingModules = new HashMap<>(); @@ -580,10 +579,10 @@ public void testIntermodalTrip_competingAccess() { } } - // Checks RandomAccessEgressModeRaptorStopFinder. The desired result is that the StopFinder will try out the different - // access/egress modes, regardless of the modes' freespeeds. - @Test - public void testIntermodalTrip_RandomAccessEgressModeRaptorStopFinder() { + // Checks RandomAccessEgressModeRaptorStopFinder. The desired result is that the StopFinder will try out the different + // access/egress modes, regardless of the modes' freespeeds. + @Test + void testIntermodalTrip_RandomAccessEgressModeRaptorStopFinder() { IntermodalFixture f = new IntermodalFixture(); Map routingModules = new HashMap<>(); @@ -682,13 +681,13 @@ else if ((((Leg)(legs.get(0))).getMode().equals(TransportMode.bike)) && (((Leg)l } } - /** - * Tests the following situation: two stops A and B close to each other, A has intermodal access, B not. - * The route is fastest from B to C, with intermodal access to A and then transferring from A to B. - * Make sure that in such cases the correct transit_walks are generated around stops A and B for access to pt. - */ - @Test - public void testIntermodalTrip_accessTransfer() { + /** + * Tests the following situation: two stops A and B close to each other, A has intermodal access, B not. + * The route is fastest from B to C, with intermodal access to A and then transferring from A to B. + * Make sure that in such cases the correct transit_walks are generated around stops A and B for access to pt. + */ + @Test + void testIntermodalTrip_accessTransfer() { IntermodalTransferFixture f = new IntermodalTransferFixture(); Facility fromFac = new FakeFacility(new Coord(10000, 500), Id.create("from", Link.class)); // stop B or C @@ -731,17 +730,17 @@ public void testIntermodalTrip_accessTransfer() { Assert.assertEquals("to", legAccess.getRoute().getEndLinkId().toString()); } - /** - * When using intermodal access/egress, transfers at the beginning are allowed to - * be able to transfer from a stop with intermodal access/egress to another stop - * with better connections to the destination. Earlier versions of SwissRailRaptor - * had a bug that resulted in only stops where such transfers were possible to be - * used for route finding, but not stops directly reachable and usable. - * This test tries to cover this case to make sure, route finding works as expected - * in all cases. - */ - @Test - public void testIntermodalTrip_singleReachableStop() { + /** + * When using intermodal access/egress, transfers at the beginning are allowed to + * be able to transfer from a stop with intermodal access/egress to another stop + * with better connections to the destination. Earlier versions of SwissRailRaptor + * had a bug that resulted in only stops where such transfers were possible to be + * used for route finding, but not stops directly reachable and usable. + * This test tries to cover this case to make sure, route finding works as expected + * in all cases. + */ + @Test + void testIntermodalTrip_singleReachableStop() { IntermodalTransferFixture f = new IntermodalTransferFixture(); f.srrConfig.getIntermodalAccessEgressParameterSets().removeIf(paramset -> paramset.getMode().equals("bike")); // we only want "walk" as mode @@ -777,8 +776,8 @@ public void testIntermodalTrip_singleReachableStop() { } - @Test - public void testIntermodalTrip_egressTransfer() { + @Test + void testIntermodalTrip_egressTransfer() { IntermodalTransferFixture f = new IntermodalTransferFixture(); Facility fromFac = new FakeFacility(new Coord(20000, 100), Id.create("from", Link.class)); // stop D @@ -821,12 +820,12 @@ public void testIntermodalTrip_egressTransfer() { Assert.assertEquals("to", legBike.getRoute().getEndLinkId().toString()); } - /** - * If there is no pt stop within the search radius, the Raptor will assign a transit_walk route from the fromFacility - * to the toFacility. In this case, the search radius is 500, but the fromFacility is 600 away from stop A. - */ - @Test - public void testIntermodalTrip_noPtStopsInRadius() { + /** + * If there is no pt stop within the search radius, the Raptor will assign a transit_walk route from the fromFacility + * to the toFacility. In this case, the search radius is 500, but the fromFacility is 600 away from stop A. + */ + @Test + void testIntermodalTrip_noPtStopsInRadius() { IntermodalTransferFixture f = new IntermodalTransferFixture(); f.srrConfig.getIntermodalAccessEgressParameterSets().removeIf(paramset -> paramset.getMode().equals("bike")); // we only want "walk" as mode @@ -843,7 +842,7 @@ public void testIntermodalTrip_noPtStopsInRadius() { Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); } - /** + /** * The agent is placed close to stop B, which is bike accessible. The agent is 600 meters away from stop B, which * puts it inside the Bike Radius for Access/Egress Mode but not in the Walk radius. This test is meant to verify * that the Swiss Rail Raptor will give the agent a transit_walk route if all the applicable intermodal @@ -858,8 +857,8 @@ public void testIntermodalTrip_noPtStopsInRadius() { * Swiss Rail Raptor will return a transit_walk between the fromFacility and the toFacility. */ - @Test - public void testIntermodalTrip_accessModeRouterReturnsNull() { + @Test + void testIntermodalTrip_accessModeRouterReturnsNull() { // Part 1: Bike is very fast. Bike Router will return intermodal route including bike, pt, and walk. IntermodalTransferFixture f = new IntermodalTransferFixture(); @@ -919,17 +918,18 @@ public List calcRoute(RoutingRequest request) { Assert.assertNull("The router should not find a route and return null, but did return something else.", legs2); } - /** - * - * The agent has a super-fast bike. So in theory it is faster to travel - * from stop_3 to the destination. However, with the introduced trip share - * constraint it will still take the closest stop accessible by the bike. - * If this constraint is not used the agent will take pt_3 stop as an - * access stop to his final destination. - * - */ - @Test - public void testIntermodalTrip_tripLengthShare() { + + /** + * + * The agent has a super-fast bike. So in theory it is faster to travel + * from stop_3 to the destination. However, with the introduced trip share + * constraint it will still take the closest stop accessible by the bike. + * If this constraint is not used the agent will take pt_3 stop as an + * access stop to his final destination. + * + */ + @Test + void testIntermodalTrip_tripLengthShare() { IntermodalFixture f = new IntermodalFixture(); ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); @@ -995,8 +995,8 @@ public void testIntermodalTrip_tripLengthShare() { Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } - @Test - public void testIntermodalTrip_activityInteraction() { + @Test + void testIntermodalTrip_activityInteraction() { double bikeInteractionDuration = 1.0; double walkSpeed = 1.1; IntermodalFixture f = new IntermodalFixture(); @@ -1110,14 +1110,14 @@ public List calcRoute(RoutingRequest request) { Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } - /** - * - * This test tests the intermodal router when access modes - * have interaction activities and it tests the inclusion of the - * pt interaction activities by the SwissRailRaptorRoutingModule - */ - @Test - public void testIntermodalTrip_activityInteractionAdd() { + /** + * + * This test tests the intermodal router when access modes + * have interaction activities and it tests the inclusion of the + * pt interaction activities by the SwissRailRaptorRoutingModule + */ + @Test + void testIntermodalTrip_activityInteractionAdd() { double bikeInteractionDuration = 1.0; double walkSpeed = 1.1; IntermodalFixture f = new IntermodalFixture(); @@ -1238,7 +1238,7 @@ public List calcRoute(RoutingRequest request) { } @Test - public void testIntermodalTripWithAccessAndEgressTimesAtStops() { + void testIntermodalTripWithAccessAndEgressTimesAtStops() { IntermodalFixture f = new IntermodalFixture(); f.scenario.getTransitSchedule().getFacilities().values() .forEach(stopFacility -> TransitScheduleUtils.setSymmetricStopAccessEgressTime(stopFacility,120.0)); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java index 13ab81099e8..f043d8bbc77 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java @@ -25,8 +25,8 @@ import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -90,8 +90,8 @@ public void setUp() { System.setProperty("matsim.preferLocalDtds", "true"); } - @Test - public void testInitialization() { + @Test + void testInitialization() { Config config = ConfigUtils.createConfig(); config.controller().setLastIteration(0); config.controller().setOutputDirectory(this.utils.getOutputDirectory()); @@ -117,8 +117,8 @@ public void install() { Assert.assertTrue(module instanceof SwissRailRaptorRoutingModule); } - @Test - public void testIntermodalIntegration() { + @Test + void testIntermodalIntegration() { IntermodalFixture f = new IntermodalFixture(); // add a single agent traveling with (intermodal) pt from A to B @@ -247,11 +247,11 @@ public void install() { } - /** - * Test update of SwissRailRaptorData after TransitScheduleChangedEvent - */ - @Test - public void testTransitScheduleUpdate() { + /** + * Test update of SwissRailRaptorData after TransitScheduleChangedEvent + */ + @Test + void testTransitScheduleUpdate() { Fixture f = new Fixture(); f.init(); f.addVehicles(); @@ -339,11 +339,11 @@ public void install() { Assert.assertEquals(Id.create("AddedLine" + 1, TransitLine.class), ptRoute.getLineId()); } - /** - * Test individual scoring parameters for agents - */ - @Test - public void testRaptorParametersForPerson() { + /** + * Test individual scoring parameters for agents + */ + @Test + void testRaptorParametersForPerson() { SwissRailRaptorConfigGroup srrConfig = new SwissRailRaptorConfigGroup(); srrConfig.setScoringParameters(ch.sbb.matsim.config.SwissRailRaptorConfigGroup.ScoringParameters.Individual); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java index e24bf036cc6..e37985287b6 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java @@ -22,7 +22,7 @@ import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptor.Builder; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -85,8 +85,8 @@ private SwissRailRaptor createTransitRouter(TransitSchedule schedule, Config con return raptor; } - @Test - public void testSingleLine() { + @Test + void testSingleLine() { Fixture f = new Fixture(); f.init(); RaptorParameters raptorParams = RaptorUtils.createParameters(f.config); @@ -117,8 +117,8 @@ public void testSingleLine() { assertEquals(15434, Math.ceil(distance), MatsimTestUtils.EPSILON); } - @Test - public void testSingleLine_linkIds() { + @Test + void testSingleLine_linkIds() { Fixture f = new Fixture(); f.init(); RaptorParameters raptorParams = RaptorUtils.createParameters(f.config); @@ -149,8 +149,8 @@ public void testSingleLine_linkIds() { assertEquals(Math.ceil(expectedTravelTime), actualTravelTime, MatsimTestUtils.EPSILON); } - @Test - public void testWalkDurations() { + @Test + void testWalkDurations() { Fixture f = new Fixture(); f.init(); RaptorParameters raptorParams = RaptorUtils.createParameters(f.config); @@ -171,7 +171,7 @@ public void testWalkDurations() { @Test - public void testStationAccessEgressTimes() { + void testStationAccessEgressTimes() { Fixture f = new Fixture(); f.init(); RaptorParameters raptorParams = RaptorUtils.createParameters(f.config); @@ -191,8 +191,8 @@ public void testStationAccessEgressTimes() { assertEquals(Math.ceil(expectedEgressWalkTime), ((Leg)legs.get(2)).getTravelTime().seconds(), MatsimTestUtils.EPSILON); } - @Test - public void testWalkDurations_range() { + @Test + void testWalkDurations_range() { Fixture f = new Fixture(); f.init(); RaptorParameters raptorParams = RaptorUtils.createParameters(f.config); @@ -213,15 +213,15 @@ public void testWalkDurations_range() { } - /** - * The fromFacility and toFacility are both closest to TransitStopFacility I. The expectation is that the Swiss Rail - * Raptor will return null (TripRouter / FallbackRouter will create a transit_walk between the fromFacility and - * toFacility) instead of routing the agent to make a major detour by walking the triangle from the fromFacility to - * the transitStopFacility and then to the toFacility, without once using pt. - */ + /** + * The fromFacility and toFacility are both closest to TransitStopFacility I. The expectation is that the Swiss Rail + * Raptor will return null (TripRouter / FallbackRouter will create a transit_walk between the fromFacility and + * toFacility) instead of routing the agent to make a major detour by walking the triangle from the fromFacility to + * the transitStopFacility and then to the toFacility, without once using pt. + */ - @Test - public void testFromToSameStop() { + @Test + void testFromToSameStop() { Fixture f = new Fixture(); f.init(); TransitRouter router = createTransitRouter(f.schedule, f.config, f.network); @@ -233,11 +233,10 @@ public void testFromToSameStop() { } - - // now the pt router should always try to return a pt route no matter whether a direct walk would be faster - // adjusted the test - gl aug'19 - @Test - public void testDirectWalkCheaper() { + // now the pt router should always try to return a pt route no matter whether a direct walk would be faster + // adjusted the test - gl aug'19 + @Test + void testDirectWalkCheaper() { Fixture f = new Fixture(); f.init(); SwissRailRaptorConfigGroup srrConfig = ConfigUtils.addOrGetModule(f.config,SwissRailRaptorConfigGroup.class); @@ -257,8 +256,8 @@ public void testDirectWalkCheaper() { assertEquals(expectedTravelTime, actualTravelTime, MatsimTestUtils.EPSILON); } - @Test - public void testDirectWalkFactor() { + @Test + void testDirectWalkFactor() { Fixture f = new Fixture(); f.init(); f.config.transitRouter().setDirectWalkFactor(100.0); @@ -287,8 +286,8 @@ public void testDirectWalkFactor() { assertEquals((5002-3000)*1.3, ((Leg)legs.get(2)).getRoute().getDistance(), 0.0); } - @Test - public void testSingleLine_DifferentWaitingTime() { + @Test + void testSingleLine_DifferentWaitingTime() { Fixture f = new Fixture(); f.init(); TransitRouter router = createTransitRouter(f.schedule, f.config, f.network); @@ -308,8 +307,8 @@ public void testSingleLine_DifferentWaitingTime() { } } - @Test - public void testLineChange() { + @Test + void testLineChange() { Fixture f = new Fixture(); f.init(); ConfigUtils.addOrGetModule(f.config, SwissRailRaptorConfigGroup.class).setTransferWalkMargin(0); @@ -345,8 +344,8 @@ public void testLineChange() { assertEquals(Math.ceil(expectedTravelTime), actualTravelTime, MatsimTestUtils.EPSILON); } - @Test - public void testFasterAlternative() { + @Test + void testFasterAlternative() { /* idea: travel from A to G * One could just take the blue line and travel from A to G (dep *:46, arrival *:28), * or one could first travel from A to C (dep *:46, arr *:58), and then take the red line @@ -387,8 +386,8 @@ public void testFasterAlternative() { } - @Test - public void testTransferWeights() { + @Test + void testTransferWeights() { /* idea: travel from C to F * If starting at the right time, one could take the red line to G and travel back with blue to F. * If one doesn't want to switch lines, one could take the blue line from C to F directly. @@ -425,8 +424,8 @@ public void testTransferWeights() { assertEquals(TransportMode.walk, ((Leg)legs.get(2)).getMode()); } - @Test - public void testTransferTime() { + @Test + void testTransferTime() { /* idea: travel from C to F * If starting at the right time, one could take the red line to G and travel back with blue to F. * If one doesn't want to switch lines, one could take the blue line from C to F directly. @@ -462,8 +461,8 @@ public void testTransferTime() { } - @Test - public void testAfterMidnight() { + @Test + void testAfterMidnight() { // in contrast to the default PT router, SwissRailRaptor will not automatically // repeat the schedule after 24 hours, so any agent departing late will have to walk if there // is no late service in the schedule. @@ -477,8 +476,8 @@ public void testAfterMidnight() { Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); } - @Test - public void testCoordFarAway() { + @Test + void testCoordFarAway() { Fixture f = new Fixture(); f.init(); TransitRouter router = createTransitRouter(f.schedule, f.config, f.network); @@ -497,12 +496,12 @@ public void testCoordFarAway() { assertEquals(Id.create("blue A > I", TransitRoute.class), ptRoute.getRouteId()); } - /** - * Tests that if only a single transfer-/walk-link is found, the router correctly only returns - * null (TripRouter/FallbackRouter will create a walk leg from start to end). - */ - @Test - public void testSingleWalkOnly() { + /** + * Tests that if only a single transfer-/walk-link is found, the router correctly only returns + * null (TripRouter/FallbackRouter will create a walk leg from start to end). + */ + @Test + void testSingleWalkOnly() { WalkFixture f = new WalkFixture(); f.scenario.getConfig().transitRouter().setSearchRadius(0.8 * CoordUtils.calcEuclideanDistance(f.coord2, f.coord4)); f.scenario.getConfig().transitRouter().setExtensionRadius(0.0); @@ -513,14 +512,14 @@ public void testSingleWalkOnly() { } - /** - * Tests that if only exactly two transfer-/walk-link are found, the router correctly only returns - * null (which will be replaced by the TripRouter and FallbackRouter with one walk leg from start - * to end). Differs from {@link #testSingleWalkOnly()} in that it tests for the correct internal - * working when more than one walk links are returned. - */ - @Test - public void testDoubleWalkOnly() { + /** + * Tests that if only exactly two transfer-/walk-link are found, the router correctly only returns + * null (which will be replaced by the TripRouter and FallbackRouter with one walk leg from start + * to end). Differs from {@link #testSingleWalkOnly()} in that it tests for the correct internal + * working when more than one walk links are returned. + */ + @Test + void testDoubleWalkOnly() { WalkFixture f = new WalkFixture(); f.scenario.getConfig().transitRouter().setSearchRadius(0.8 * CoordUtils.calcEuclideanDistance(f.coord2, f.coord4)); f.scenario.getConfig().transitRouter().setExtensionRadius(0.0); @@ -531,9 +530,9 @@ public void testDoubleWalkOnly() { Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); } - @SuppressWarnings("unchecked") - @Test - public void testLongTransferTime_withTransitRouterWrapper() { + @SuppressWarnings("unchecked") + @Test + void testLongTransferTime_withTransitRouterWrapper() { // 5 minutes additional transfer time { TransferFixture f = new TransferFixture(5 * 60.0); @@ -649,8 +648,8 @@ private static double calcTripDuration(List planElements) { return duration; } - @Test - public void testNightBus() { + @Test + void testNightBus() { // test a special case where a direct connection only runs at a late time, when typically // no other services run anymore. NightBusFixture f = new NightBusFixture(); @@ -684,8 +683,8 @@ public void testNightBus() { assertEquals(f.lineId3, ptRoute.getLineId()); } - @Test - public void testCircularLine() { + @Test + void testCircularLine() { Fixture f = new Fixture(); f.init(); @@ -713,8 +712,8 @@ public void testCircularLine() { Assert.assertEquals(Id.create(20, TransitStopFacility.class), ((TransitPassengerRoute) ((Leg)legs.get(3)).getRoute()).getEgressStopId()); } - @Test - public void testRangeQuery() { + @Test + void testRangeQuery() { Fixture f = new Fixture(); f.init(); SwissRailRaptor raptor = createTransitRouter(f.schedule, f.config, f.network); @@ -746,12 +745,12 @@ private void assertRaptorRoute(RaptorRoute route, String depTime, String arrTime Assert.assertEquals("wrong cost", expectedCost, route.getTotalCosts(), 1e-5); } - /** test for https://github.com/SchweizerischeBundesbahnen/matsim-sbb-extensions/issues/1 - * - * If there are StopFacilities in the transit schedule, that are not part of any route, the Router crashes with a NPE in SwissRailRaptorData at line 213, because toRouteStopIndices == null. - */ - @Test - public void testUnusedTransitStop() { + /** test for https://github.com/SchweizerischeBundesbahnen/matsim-sbb-extensions/issues/1 + * + * If there are StopFacilities in the transit schedule, that are not part of any route, the Router crashes with a NPE in SwissRailRaptorData at line 213, because toRouteStopIndices == null. + */ + @Test + void testUnusedTransitStop() { Fixture f = new Fixture(); f.init(); @@ -777,8 +776,8 @@ public void testUnusedTransitStop() { Assert.assertEquals(3, legs.size()); } - @Test - public void testTravelTimeDependentTransferCosts() { + @Test + void testTravelTimeDependentTransferCosts() { TravelTimeDependentTransferFixture f = new TravelTimeDependentTransferFixture(); { // test default 0 + 0 * tt @@ -862,8 +861,8 @@ public void testTravelTimeDependentTransferCosts() { } } - @Test - public void testCustomTransferCostCalculator() { + @Test + void testCustomTransferCostCalculator() { TransferFixture f = new TransferFixture(60.0); int[] transferCount = new int[] { 0 }; @@ -912,8 +911,8 @@ private Config prepareConfig(double transferFixedCost, double transferRelativeCo return config; } - @Test - public void testModeMapping() { + @Test + void testModeMapping() { Fixture f = new Fixture(); f.init(); for (TransitRoute route : f.blueLine.getRoutes().values()) { @@ -951,8 +950,8 @@ public void testModeMapping() { assertEquals(TransportMode.walk, ((Leg)legs.get(4)).getMode()); } - @Test - public void testModeMappingCosts() { + @Test + void testModeMappingCosts() { Fixture f = new Fixture(); f.init(); @@ -1045,13 +1044,13 @@ public void testModeMappingCosts() { } } - /** - * Tests what happens if there is a transit service available, but the agent's departure time (11 AM) is after the last transit - * departure time (9:46 AM). The expectation is that the router returns null and TripRouter/FallbackRouter will create a direct - * walk leg to get from the fromFacility to the toFacility. - */ - @Test - public void testDepartureAfterLastBus(){ + /** + * Tests what happens if there is a transit service available, but the agent's departure time (11 AM) is after the last transit + * departure time (9:46 AM). The expectation is that the router returns null and TripRouter/FallbackRouter will create a direct + * walk leg to get from the fromFacility to the toFacility. + */ + @Test + void testDepartureAfterLastBus(){ Fixture f = new Fixture(); f.init(); TransitRouter router = createTransitRouter(f.schedule, f.config, f.network); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTreeTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTreeTest.java index 05ad518af21..a380bd4ebca 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTreeTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTreeTest.java @@ -21,7 +21,7 @@ import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorCore.TravelInfo; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.core.utils.misc.Time; @@ -38,8 +38,8 @@ */ public class SwissRailRaptorTreeTest { - @Test - public void testSingleStop_dep0740atN_optimized() { + @Test + void testSingleStop_dep0740atN_optimized() { Fixture f = new Fixture(); f.init(); @@ -83,8 +83,8 @@ public void testSingleStop_dep0740atN_optimized() { assertTravelInfo(map, 23, "23", 0, "07:40:00", "07:40:00"); // our start location } - @Test - public void testSingleStop_dep0740atN_unoptimized() { + @Test + void testSingleStop_dep0740atN_unoptimized() { Fixture f = new Fixture(); f.init(); @@ -126,8 +126,8 @@ public void testSingleStop_dep0740atN_unoptimized() { assertTravelInfo(map, 23, "23", 0, "07:40:00", "07:40:00"); // our start location } - @Test - public void testSingleStop_dep0750atN_optimized() { + @Test + void testSingleStop_dep0750atN_optimized() { Fixture f = new Fixture(); f.init(); @@ -172,8 +172,8 @@ public void testSingleStop_dep0750atN_optimized() { assertTravelInfo(map, 23, "23", 0, "07:50:00", "07:50:00"); // our start location } - @Test - public void testSingleStop_dep0750atN_unoptimized() { + @Test + void testSingleStop_dep0750atN_unoptimized() { Fixture f = new Fixture(); f.init(); @@ -216,8 +216,8 @@ public void testSingleStop_dep0750atN_unoptimized() { assertTravelInfo(map, 23, "23", 0, "07:50:00", "07:50:00"); // our start location } - @Test - public void testMultipleStops_optimized() { + @Test + void testMultipleStops_optimized() { Fixture f = new Fixture(); f.init(); @@ -265,8 +265,8 @@ public void testMultipleStops_optimized() { assertTravelInfo(map, 23, "15", 1, "07:43:00", "08:11:00"); // from H, transfer at G, 7:48/7:51 green } - @Test - public void testMultipleStops_unoptimized() { + @Test + void testMultipleStops_unoptimized() { Fixture f = new Fixture(); f.init(); @@ -312,8 +312,8 @@ public void testMultipleStops_unoptimized() { assertTravelInfo(map, 23, "15", 1, "07:43:00", "08:11:00"); // from H, transfer at G, 7:48/7:51 green } - @Test - public void testSingleStop_costs_dep0740atN_optimized() { + @Test + void testSingleStop_costs_dep0740atN_optimized() { Fixture f = new Fixture(); f.init(); @@ -345,8 +345,8 @@ public void testSingleStop_costs_dep0740atN_optimized() { Assert.assertTrue("waiting cost should differ", info0740.waitingCost < info0739.waitingCost); } - @Test - public void testSingleStop_raptorroute_dep0740atN_optimized() { + @Test + void testSingleStop_raptorroute_dep0740atN_optimized() { Fixture f = new Fixture(); f.init(); diff --git a/matsim/src/test/java/org/matsim/analysis/CalcAverageTripLengthTest.java b/matsim/src/test/java/org/matsim/analysis/CalcAverageTripLengthTest.java index 17a8d0dea7d..05d463b8b0c 100644 --- a/matsim/src/test/java/org/matsim/analysis/CalcAverageTripLengthTest.java +++ b/matsim/src/test/java/org/matsim/analysis/CalcAverageTripLengthTest.java @@ -22,8 +22,7 @@ package org.matsim.analysis; import java.util.ArrayList; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -45,10 +44,10 @@ import org.junit.Assert; -public class CalcAverageTripLengthTest { + public class CalcAverageTripLengthTest { - @Test - public void testWithRoute() { + @Test + void testWithRoute() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network = scenario.getNetwork(); Population population = scenario.getPopulation(); @@ -112,8 +111,8 @@ public void testWithRoute() { Assert.assertEquals(500.0, catl.getAverageTripLength(), MatsimTestUtils.EPSILON); } - @Test - public void testWithRoute_OneLinkRoute() { + @Test + void testWithRoute_OneLinkRoute() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network = scenario.getNetwork(); Population population = scenario.getPopulation(); @@ -149,8 +148,8 @@ public void testWithRoute_OneLinkRoute() { Assert.assertEquals(100.0, catl.getAverageTripLength(), MatsimTestUtils.EPSILON); } - @Test - public void testWithRoute_StartEndOnSameLink() { + @Test + void testWithRoute_StartEndOnSameLink() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network = scenario.getNetwork(); Population population = scenario.getPopulation(); diff --git a/matsim/src/test/java/org/matsim/analysis/CalcLegTimesTest.java b/matsim/src/test/java/org/matsim/analysis/CalcLegTimesTest.java index f04fdbd7ffc..88e253fa21b 100644 --- a/matsim/src/test/java/org/matsim/analysis/CalcLegTimesTest.java +++ b/matsim/src/test/java/org/matsim/analysis/CalcLegTimesTest.java @@ -26,8 +26,8 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -102,7 +102,8 @@ public class CalcLegTimesTest { this.network = null; } - @Test public void testNoEvents() throws IOException { + @Test + void testNoEvents() throws IOException { CalcLegTimes testee = new CalcLegTimes(); @@ -114,7 +115,8 @@ public class CalcLegTimesTest { this.runTest(testee); } - @Test public void testAveraging() throws IOException { + @Test + void testAveraging() throws IOException { CalcLegTimes testee = new CalcLegTimes(); diff --git a/matsim/src/test/java/org/matsim/analysis/CalcLinkStatsTest.java b/matsim/src/test/java/org/matsim/analysis/CalcLinkStatsTest.java index 72eaa88a2bb..06e85721459 100644 --- a/matsim/src/test/java/org/matsim/analysis/CalcLinkStatsTest.java +++ b/matsim/src/test/java/org/matsim/analysis/CalcLinkStatsTest.java @@ -22,8 +22,8 @@ import java.io.File; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -50,7 +50,7 @@ public class CalcLinkStatsTest { @RegisterExtension private MatsimTestUtils util = new MatsimTestUtils(); @Test - public void testAddData() { + void testAddData() { Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network = s.getNetwork(); NetworkFactory nf = network.getFactory(); @@ -131,7 +131,7 @@ public void testAddData() { * @author ikaddoura */ @Test - public void testAddDataObservedTravelTime() { + void testAddDataObservedTravelTime() { Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network = s.getNetwork(); NetworkFactory nf = network.getFactory(); @@ -215,7 +215,7 @@ public void testAddDataObservedTravelTime() { } @Test - public void testWriteRead() { + void testWriteRead() { Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network = s.getNetwork(); NetworkFactory nf = network.getFactory(); diff --git a/matsim/src/test/java/org/matsim/analysis/IterationTravelStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/IterationTravelStatsControlerListenerTest.java index 10c333db369..4d16738191e 100644 --- a/matsim/src/test/java/org/matsim/analysis/IterationTravelStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/IterationTravelStatsControlerListenerTest.java @@ -11,8 +11,8 @@ import java.util.zip.GZIPInputStream; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.IdMap; import org.matsim.api.core.v01.Scenario; @@ -54,7 +54,7 @@ public class IterationTravelStatsControlerListenerTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testIterationTravelStatsControlerListener() { + void testIterationTravelStatsControlerListener() { Plans plans = new Plans(); diff --git a/matsim/src/test/java/org/matsim/analysis/LegHistogramTest.java b/matsim/src/test/java/org/matsim/analysis/LegHistogramTest.java index 9146970dde1..e29dfc0af55 100644 --- a/matsim/src/test/java/org/matsim/analysis/LegHistogramTest.java +++ b/matsim/src/test/java/org/matsim/analysis/LegHistogramTest.java @@ -24,8 +24,8 @@ import java.util.Set; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -54,7 +54,8 @@ public class LegHistogramTest { * accordingly. Also tests that modes not defined as constants are * handled correctly. */ - @Test public void testDeparturesMiscModes() { + @Test + void testDeparturesMiscModes() { Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create(1, Node.class), new Coord((double) 0, (double) 0)); Node node2 = NetworkUtils.createAndAddNode(network, Id.create(2, Node.class), new Coord((double) 1000, (double) 0)); @@ -107,7 +108,8 @@ public class LegHistogramTest { * taken into account and that times larger than what is covered by the bins * do not lead to an exception. */ - @Test public void testNofBins() { + @Test + void testNofBins() { Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create(1, Node.class), new Coord((double) 0, (double) 0)); Node node2 = NetworkUtils.createAndAddNode(network, Id.create(2, Node.class), new Coord((double) 1000, (double) 0)); @@ -147,7 +149,8 @@ public class LegHistogramTest { assertEquals(2, histo.getArrivals()[10]); } - @Test public void testReset() { + @Test + void testReset() { Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create(1, Node.class), new Coord((double) 0, (double) 0)); Node node2 = NetworkUtils.createAndAddNode(network, Id.create(2, Node.class), new Coord((double) 1000, (double) 0)); diff --git a/matsim/src/test/java/org/matsim/analysis/LinkStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/LinkStatsControlerListenerTest.java index 17538d237d8..214b7fffb9b 100644 --- a/matsim/src/test/java/org/matsim/analysis/LinkStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/LinkStatsControlerListenerTest.java @@ -21,8 +21,8 @@ import com.google.inject.*; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -61,7 +61,7 @@ public class LinkStatsControlerListenerTest { private MatsimTestUtils util = new MatsimTestUtils(); @Test - public void testlinksOutputCSV() throws IOException { + void testlinksOutputCSV() throws IOException { String outputDirectory = util.getOutputDirectory(); Config config = this.util.loadConfig("test/scenarios/equil/config_plans1.xml"); @@ -82,7 +82,7 @@ public void testlinksOutputCSV() throws IOException { } @Test - public void testUseVolumesOfIteration() { + void testUseVolumesOfIteration() { Config config = ConfigUtils.createConfig(); config.controller().setOutputDirectory(util.getOutputDirectory()); final Scenario scenario = ScenarioUtils.createScenario(config); @@ -309,7 +309,7 @@ public void install() { } @Test - public void test_writeLinkStatsInterval() { + void test_writeLinkStatsInterval() { Config config = this.util.loadConfig((String) null); LinkStatsConfigGroup lsConfig = config.linkStats(); @@ -346,7 +346,7 @@ public void install() { } @Test - public void testReset_CorrectlyExecuted() throws IOException { + void testReset_CorrectlyExecuted() throws IOException { Config config = this.util.loadConfig((String) null); config.controller().setMobsim("dummy"); config.controller().setFirstIteration(0); diff --git a/matsim/src/test/java/org/matsim/analysis/ModeChoiceCoverageControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/ModeChoiceCoverageControlerListenerTest.java index 76927ec7a57..51f97e29a64 100644 --- a/matsim/src/test/java/org/matsim/analysis/ModeChoiceCoverageControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/ModeChoiceCoverageControlerListenerTest.java @@ -1,8 +1,8 @@ package org.matsim.analysis; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -34,8 +34,8 @@ public class ModeChoiceCoverageControlerListenerTest { public MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void testChangePlanModes() { + @Test + void testChangePlanModes() { Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig()); ScoringConfigGroup scoreConfig = new ScoringConfigGroup(); @@ -92,8 +92,8 @@ public void testChangePlanModes() { (Double) 1.0, modeChoiceCoverageHistory.get(1).get(TransportMode.bike).get(2)); } - @Test - public void testTwoAgents() { + @Test + void testTwoAgents() { Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig()); ScoringConfigGroup scoreConfig = new ScoringConfigGroup(); TransportPlanningMainModeIdentifier transportId = new TransportPlanningMainModeIdentifier(); @@ -162,8 +162,8 @@ public void testTwoAgents() { (Double) 0.75, modeChoiceCoverageHistory.get(1).get(TransportMode.bike).get(2)); } - @Test - public void testDifferentLevels() { + @Test + void testDifferentLevels() { Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig()); ScoringConfigGroup scoreConfig = new ScoringConfigGroup(); diff --git a/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java index ab15ea48c94..400c0b270f8 100644 --- a/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java @@ -11,8 +11,8 @@ import java.util.List; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -56,7 +56,7 @@ public class ModeStatsControlerListenerTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testModeStatsControlerListener() { + void testModeStatsControlerListener() { Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig()); final List planElem = new ArrayList(); diff --git a/matsim/src/test/java/org/matsim/analysis/OutputTravelStatsTest.java b/matsim/src/test/java/org/matsim/analysis/OutputTravelStatsTest.java index da31465d1c5..33f09c31ff1 100644 --- a/matsim/src/test/java/org/matsim/analysis/OutputTravelStatsTest.java +++ b/matsim/src/test/java/org/matsim/analysis/OutputTravelStatsTest.java @@ -19,8 +19,8 @@ package org.matsim.analysis; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.controler.Controler; import org.matsim.testcases.MatsimTestUtils; @@ -40,7 +40,7 @@ public class OutputTravelStatsTest { private MatsimTestUtils util = new MatsimTestUtils(); @Test - public void testActivitiesOutputCSV() throws IOException { + void testActivitiesOutputCSV() throws IOException { String outputDirectory = util.getOutputDirectory(); Config config = this.util.loadConfig("test/scenarios/equil/config_plans1.xml"); diff --git a/matsim/src/test/java/org/matsim/analysis/PHbyModeCalculatorTest.java b/matsim/src/test/java/org/matsim/analysis/PHbyModeCalculatorTest.java index 4622a31b6b9..38e5bec0a4e 100644 --- a/matsim/src/test/java/org/matsim/analysis/PHbyModeCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/analysis/PHbyModeCalculatorTest.java @@ -9,9 +9,9 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; -import org.junit.Assert; +import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.IdMap; import org.matsim.api.core.v01.population.Activity; @@ -26,8 +26,8 @@ import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.router.StageActivityTypeIdentifier; import org.matsim.core.scoring.EventsToLegs; -import org.matsim.testcases.MatsimTestUtils; - +import org.matsim.testcases.MatsimTestUtils; + /** * @author Aravind * @@ -49,10 +49,10 @@ public class PHbyModeCalculatorTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - final IdMap map = new IdMap<>(Person.class); - - @Test - public void testPKMbyModeCalculator() { + final IdMap map = new IdMap<>(Person.class); + + @Test + void testPKMbyModeCalculator() { Plans plans = new Plans(); diff --git a/matsim/src/test/java/org/matsim/analysis/PKMbyModeCalculatorTest.java b/matsim/src/test/java/org/matsim/analysis/PKMbyModeCalculatorTest.java index 8af9981fb13..b2153471206 100644 --- a/matsim/src/test/java/org/matsim/analysis/PKMbyModeCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/analysis/PKMbyModeCalculatorTest.java @@ -9,8 +9,8 @@ import java.util.HashMap; import java.util.stream.Collectors; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.IdMap; import org.matsim.api.core.v01.TransportMode; @@ -44,7 +44,7 @@ public class PKMbyModeCalculatorTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testPKMbyModeCalculator() { + void testPKMbyModeCalculator() { final IdMap map = new IdMap<>(Person.class); Plans plans = new Plans(); diff --git a/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java index 9c6d251a048..1fb5b7900f9 100644 --- a/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java @@ -7,8 +7,8 @@ import org.assertj.core.api.Assertions; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -52,7 +52,7 @@ public class ScoreStatsControlerListenerTest { private Population population = scenario.getPopulation(); @Test - public void testScoreStatsControlerListner() throws IOException { + void testScoreStatsControlerListner() throws IOException { /************************************ * Person - creating person 1 diff --git a/matsim/src/test/java/org/matsim/analysis/TransportPlanningMainModeIdentifierTest.java b/matsim/src/test/java/org/matsim/analysis/TransportPlanningMainModeIdentifierTest.java index d2141c89b78..0ed11f63558 100644 --- a/matsim/src/test/java/org/matsim/analysis/TransportPlanningMainModeIdentifierTest.java +++ b/matsim/src/test/java/org/matsim/analysis/TransportPlanningMainModeIdentifierTest.java @@ -6,15 +6,15 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Assert; +import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.Leg; import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.PlanElement; -import org.matsim.testcases.MatsimTestUtils; - +import org.matsim.testcases.MatsimTestUtils; + /** * @author Aravind * @@ -24,10 +24,10 @@ public class TransportPlanningMainModeIdentifierTest { private final List modeHierarchy = new ArrayList<>(); @RegisterExtension - private MatsimTestUtils utils = new MatsimTestUtils(); - - @Test - public void testIterationTravelStatsControlerListener() { + private MatsimTestUtils utils = new MatsimTestUtils(); + + @Test + void testIterationTravelStatsControlerListener() { modeHierarchy.add(TransportMode.non_network_walk); modeHierarchy.add("undefined"); diff --git a/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java b/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java index 4836dbb1e1c..a98fef56fbf 100644 --- a/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java +++ b/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java @@ -10,8 +10,8 @@ import java.util.stream.Collectors; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.IdMap; import org.matsim.api.core.v01.TransportMode; @@ -55,7 +55,7 @@ public class TravelDistanceStatsTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testTravelDistanceStats() { + void testTravelDistanceStats() { final IdMap map = new IdMap<>(Person.class); diff --git a/matsim/src/test/java/org/matsim/analysis/TripsAnalysisIT.java b/matsim/src/test/java/org/matsim/analysis/TripsAnalysisIT.java index e0a372d519b..528fefa6d41 100644 --- a/matsim/src/test/java/org/matsim/analysis/TripsAnalysisIT.java +++ b/matsim/src/test/java/org/matsim/analysis/TripsAnalysisIT.java @@ -23,8 +23,8 @@ import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -46,7 +46,7 @@ public class TripsAnalysisIT { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void testMainMode() { + void testMainMode() { final Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/matsim/src/test/java/org/matsim/analysis/TripsAndLegsCSVWriterTest.java b/matsim/src/test/java/org/matsim/analysis/TripsAndLegsCSVWriterTest.java index cfb58800664..e5eccd66e12 100644 --- a/matsim/src/test/java/org/matsim/analysis/TripsAndLegsCSVWriterTest.java +++ b/matsim/src/test/java/org/matsim/analysis/TripsAndLegsCSVWriterTest.java @@ -21,8 +21,8 @@ package org.matsim.analysis; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.analysis.TripsAndLegsCSVWriter.NoLegsWriterExtension; import org.matsim.analysis.TripsAndLegsCSVWriter.NoTripWriterExtension; import org.matsim.api.core.v01.*; @@ -116,7 +116,7 @@ public class TripsAndLegsCSVWriterTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testTripsAndLegsCSVWriter() { + void testTripsAndLegsCSVWriter() { Plans plans = new Plans(); diff --git a/matsim/src/test/java/org/matsim/analysis/VolumesAnalyzerTest.java b/matsim/src/test/java/org/matsim/analysis/VolumesAnalyzerTest.java index 01ade096cca..511778fce7c 100644 --- a/matsim/src/test/java/org/matsim/analysis/VolumesAnalyzerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/VolumesAnalyzerTest.java @@ -3,9 +3,9 @@ */ package org.matsim.analysis; -import org.junit.Assert; +import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -20,8 +20,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.testcases.MatsimTestUtils; -import org.matsim.vehicles.Vehicle; - +import org.matsim.vehicles.Vehicle; + /** * @author Aravind * @@ -29,10 +29,10 @@ public class VolumesAnalyzerTest { @RegisterExtension - private MatsimTestUtils util = new MatsimTestUtils(); - - @Test - public void performTest() { + private MatsimTestUtils util = new MatsimTestUtils(); + + @Test + void performTest() { final Id link1 = Id.create(10723, Link.class); final Id link2 = Id.create(123160, Link.class); diff --git a/matsim/src/test/java/org/matsim/analysis/linkPaxVolumes/LinkPaxVolumesAnalysisTest.java b/matsim/src/test/java/org/matsim/analysis/linkPaxVolumes/LinkPaxVolumesAnalysisTest.java index 126b90c8dcf..e8686cd7cf4 100644 --- a/matsim/src/test/java/org/matsim/analysis/linkPaxVolumes/LinkPaxVolumesAnalysisTest.java +++ b/matsim/src/test/java/org/matsim/analysis/linkPaxVolumes/LinkPaxVolumesAnalysisTest.java @@ -23,8 +23,8 @@ import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.analysis.linkpaxvolumes.LinkPaxVolumesAnalysis; import org.matsim.analysis.linkpaxvolumes.LinkPaxVolumesWriter; import org.matsim.analysis.linkpaxvolumes.VehicleStatsPerVehicleType; @@ -55,12 +55,12 @@ public class LinkPaxVolumesAnalysisTest { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); - /** - * Test method for {@link LinkPaxVolumesAnalysis}. - */ + /** + * Test method for {@link LinkPaxVolumesAnalysis}. + */ - @Test - public void testLinkPaxVolumes() { + @Test + void testLinkPaxVolumes() { Config config = ConfigUtils.createConfig(); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/analysis/personMoney/PersonMoneyEventAggregatorTest.java b/matsim/src/test/java/org/matsim/analysis/personMoney/PersonMoneyEventAggregatorTest.java index 542b72deb15..4e1e6b20caf 100644 --- a/matsim/src/test/java/org/matsim/analysis/personMoney/PersonMoneyEventAggregatorTest.java +++ b/matsim/src/test/java/org/matsim/analysis/personMoney/PersonMoneyEventAggregatorTest.java @@ -23,8 +23,8 @@ import org.apache.commons.csv.CSVRecord; import org.apache.commons.lang3.mutable.MutableDouble; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonMoneyEvent; import org.matsim.api.core.v01.events.handler.PersonMoneyEventHandler; @@ -46,7 +46,7 @@ public class PersonMoneyEventAggregatorTest { * Test method for {@link org.matsim.analysis.personMoney.PersonMoneyEventsCollector}. */ @Test - public void testPersonMoneyEventCollector() { + void testPersonMoneyEventCollector() { Id passenger1 = Id.createPersonId("passenger1"); diff --git a/matsim/src/test/java/org/matsim/analysis/pt/stop2stop/PtStop2StopAnalysisTest.java b/matsim/src/test/java/org/matsim/analysis/pt/stop2stop/PtStop2StopAnalysisTest.java index 9007107f017..dc39adf4358 100644 --- a/matsim/src/test/java/org/matsim/analysis/pt/stop2stop/PtStop2StopAnalysisTest.java +++ b/matsim/src/test/java/org/matsim/analysis/pt/stop2stop/PtStop2StopAnalysisTest.java @@ -20,7 +20,7 @@ package org.matsim.analysis.pt.stop2stop; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -50,11 +50,11 @@ public class PtStop2StopAnalysisTest { - /** - * Test method for {@link PtStop2StopAnalysis}. - */ - @Test - public void testPtStop2StopAnalysisSingle() { + /** + * Test method for {@link PtStop2StopAnalysis}. + */ + @Test + void testPtStop2StopAnalysisSingle() { Config config = ConfigUtils.createConfig(); Scenario scenario = ScenarioUtils.createScenario(config); @@ -173,8 +173,8 @@ public void testPtStop2StopAnalysisSingle() { // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - @Test - public void testPtStop2StopAnalysisMulti() { + @Test + void testPtStop2StopAnalysisMulti() { Config config = ConfigUtils.createConfig(); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/api/core/v01/CoordTest.java b/matsim/src/test/java/org/matsim/api/core/v01/CoordTest.java index 0697ffe8289..8a9e0264d4b 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/CoordTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/CoordTest.java @@ -22,13 +22,13 @@ import static org.junit.Assert.*; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.testcases.MatsimTestUtils; public class CoordTest { @Test - public void testCoord2D() { + void testCoord2D() { @SuppressWarnings("unused") Coord c; try{ @@ -39,7 +39,7 @@ public void testCoord2D() { } @Test - public void testCoord3D() { + void testCoord3D() { @SuppressWarnings("unused") Coord c; try{ @@ -60,7 +60,7 @@ public void testCoord3D() { } @Test - public void testGetX() { + void testGetX() { // 2D Coord c2 = new Coord(0.0, 1.0); assertEquals("Wrong x-value.", 0.0, c2.getX(), MatsimTestUtils.EPSILON); @@ -71,7 +71,7 @@ public void testGetX() { } @Test - public void testGetY() { + void testGetY() { // 2D Coord c2 = new Coord(0.0, 1.0); assertEquals("Wrong y-value.", 1.0, c2.getY(), MatsimTestUtils.EPSILON); @@ -82,7 +82,7 @@ public void testGetY() { } @Test - public void testGetZ() { + void testGetZ() { // 2D Coord c2 = new Coord(0.0, 1.0); try{ @@ -99,7 +99,7 @@ public void testGetZ() { } @Test - public void testEqualsObject() { + void testEqualsObject() { Double dummy = 0.0; Coord c2a = new Coord(0.0, 1.0); @@ -122,7 +122,7 @@ public void testEqualsObject() { } @Test - public void testToString() { + void testToString() { Coord c2 = new Coord(0.0, 1.0); assertTrue(c2.toString().equalsIgnoreCase("[x=0.0 | y=1.0]")); diff --git a/matsim/src/test/java/org/matsim/api/core/v01/DemandGenerationTest.java b/matsim/src/test/java/org/matsim/api/core/v01/DemandGenerationTest.java index 254e8a05703..b92c50d4c4d 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/DemandGenerationTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/DemandGenerationTest.java @@ -25,8 +25,8 @@ import org.junit.After; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.network.Node; @@ -68,7 +68,8 @@ public class DemandGenerationTest { this.sc = null; } - @Test public void testDemandGeneration(){ + @Test + void testDemandGeneration(){ Config conf = sc.getConfig(); assertNotNull(conf); diff --git a/matsim/src/test/java/org/matsim/api/core/v01/IdAnnotationsTest.java b/matsim/src/test/java/org/matsim/api/core/v01/IdAnnotationsTest.java index dcfa4db3a27..f2e82c6ecdb 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/IdAnnotationsTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/IdAnnotationsTest.java @@ -3,7 +3,7 @@ import java.util.Objects; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.IdAnnotations.JsonId; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Node; @@ -19,7 +19,7 @@ public class IdAnnotationsTest { private static final ObjectMapper objectMapper = new ObjectMapper(); @Test - public void testRecordJsonIds() throws JsonProcessingException { + void testRecordJsonIds() throws JsonProcessingException { Id personId = Id.createPersonId("person"); RecordWithIds recordWithIds1 = new RecordWithIds( personId, @@ -35,7 +35,7 @@ public void testRecordJsonIds() throws JsonProcessingException { } @Test - public void testRecordJsonIdsWithNull() throws JsonProcessingException { + void testRecordJsonIdsWithNull() throws JsonProcessingException { Id personId = null; RecordWithIds recordWithIds1 = new RecordWithIds(personId, null, null); @@ -48,7 +48,7 @@ public void testRecordJsonIdsWithNull() throws JsonProcessingException { } @Test - public void testClassJsonIds() throws JsonProcessingException { + void testClassJsonIds() throws JsonProcessingException { Id personId = Id.createPersonId("person"); ClassWithIds classWithIds1 = new ClassWithIds( personId, @@ -64,7 +64,7 @@ public void testClassJsonIds() throws JsonProcessingException { } @Test - public void testClassJsonIdsWithNull() throws JsonProcessingException { + void testClassJsonIdsWithNull() throws JsonProcessingException { Id personId = null; ClassWithIds classWithIds1 = new ClassWithIds(personId, null, null); diff --git a/matsim/src/test/java/org/matsim/api/core/v01/IdCollectorsTest.java b/matsim/src/test/java/org/matsim/api/core/v01/IdCollectorsTest.java index 12dac47e927..4ef8664b489 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/IdCollectorsTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/IdCollectorsTest.java @@ -26,7 +26,7 @@ import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.vehicles.Vehicle; /** @@ -35,7 +35,7 @@ public class IdCollectorsTest { @Test - public void testToIdMap() { + void testToIdMap() { record Entry(Id id, String value) { } @@ -53,7 +53,7 @@ record Entry(Id id, String value) { } @Test - public void testToIdMap_streamWithDuplicateKeys() { + void testToIdMap_streamWithDuplicateKeys() { record Entry(Id id, String value) { } @@ -65,7 +65,7 @@ record Entry(Id id, String value) { } @Test - public void testToIdMap_withMerge() { + void testToIdMap_withMerge() { record Entry(Id id, int value) { } @@ -82,7 +82,7 @@ record Entry(Id id, int value) { } @Test - public void testToIdSet() { + void testToIdSet() { var id1 = Id.createVehicleId("v1"); var id2 = Id.createVehicleId("v2"); var id3 = Id.createVehicleId("v3"); diff --git a/matsim/src/test/java/org/matsim/api/core/v01/IdDeSerializationModuleTest.java b/matsim/src/test/java/org/matsim/api/core/v01/IdDeSerializationModuleTest.java index 6550f16c2d4..2562a5798c8 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/IdDeSerializationModuleTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/IdDeSerializationModuleTest.java @@ -5,7 +5,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.network.Link; import com.fasterxml.jackson.core.JsonProcessingException; @@ -26,7 +26,7 @@ public void init() { } @Test - public void testMapKey() { + void testMapKey() { // create map with Id as keys Map, String> map0 = new LinkedHashMap<>(); @@ -65,7 +65,7 @@ public void testMapKey() { } @Test - public void testMapValue() { + void testMapValue() { // create map with Id as values Map> map0 = new LinkedHashMap<>(); diff --git a/matsim/src/test/java/org/matsim/api/core/v01/IdMapTest.java b/matsim/src/test/java/org/matsim/api/core/v01/IdMapTest.java index 716609ed586..f57550f3272 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/IdMapTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/IdMapTest.java @@ -1,7 +1,7 @@ package org.matsim.api.core.v01; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.population.Person; import org.matsim.core.utils.collections.Tuple; @@ -14,7 +14,7 @@ public class IdMapTest { @Test - public void testPutGetRemoveSize() { + void testPutGetRemoveSize() { IdMap map = new IdMap<>(Person.class, 10); Assert.assertEquals(0, map.size()); @@ -50,7 +50,7 @@ public void testPutGetRemoveSize() { } @Test - public void testIterable() { + void testIterable() { IdMap map = new IdMap<>(Person.class, 10); map.put(Id.create(1, Person.class), "one"); @@ -78,7 +78,7 @@ public void testIterable() { } @Test - public void testForEach() { + void testForEach() { IdMap map = new IdMap<>(Person.class, 10); map.put(Id.create(1, Person.class), "one"); @@ -105,7 +105,7 @@ public void testForEach() { } @Test - public void testContainsKey() { + void testContainsKey() { IdMap map = new IdMap<>(Person.class, 10); map.put(Id.create(1, Person.class), "one"); @@ -137,7 +137,7 @@ public void testContainsKey() { } @Test - public void testContainsValue() { + void testContainsValue() { IdMap map = new IdMap<>(Person.class, 10); map.put(Id.create(1, Person.class), "one"); @@ -155,7 +155,7 @@ public void testContainsValue() { } @Test - public void testPutAll_IdMap() { + void testPutAll_IdMap() { IdMap map = new IdMap<>(Person.class, 10); IdMap map2 = new IdMap<>(Person.class, 10); @@ -177,7 +177,7 @@ public void testPutAll_IdMap() { } @Test - public void testPutAll_GenericMap() { + void testPutAll_GenericMap() { IdMap map = new IdMap<>(Person.class, 10); Map, String> map2 = new HashMap<>(); @@ -199,7 +199,7 @@ public void testPutAll_GenericMap() { } @Test - public void testClear() { + void testClear() { IdMap map = new IdMap<>(Person.class, 10); map.put(Id.create(1, Person.class), "one"); @@ -222,7 +222,7 @@ public void testClear() { } @Test - public void testValues() { + void testValues() { IdMap map = new IdMap<>(Person.class, 10); map.put(Id.create(1, Person.class), "one"); @@ -257,7 +257,7 @@ public void testValues() { } @Test - public void testKeySet() { + void testKeySet() { Id id1 = Id.create(1, Person.class); Id id2 = Id.create(2, Person.class); Id id3 = Id.create(3, Person.class); @@ -298,7 +298,7 @@ public void testKeySet() { } @Test - public void testEntrySet() { + void testEntrySet() { Id id1 = Id.create(1, Person.class); Id id2 = Id.create(2, Person.class); Id id3 = Id.create(3, Person.class); @@ -352,7 +352,7 @@ public void testEntrySet() { } @Test - public void testIterator_iterate() { + void testIterator_iterate() { Id id1 = Id.create(1, Person.class); Id id2 = Id.create(2, Person.class); Id id3 = Id.create(3, Person.class); @@ -393,7 +393,7 @@ public void testIterator_iterate() { } @Test - public void testIterator_remove() { + void testIterator_remove() { Id id1 = Id.create(1, Person.class); Id id2 = Id.create(2, Person.class); Id id3 = Id.create(3, Person.class); @@ -430,7 +430,7 @@ public void testIterator_remove() { } @Test - public void testKeySetToArray() { + void testKeySetToArray() { Id id1 = Id.create(1, Person.class); Id id2 = Id.create(2, Person.class); Id id3 = Id.create(3, Person.class); @@ -454,7 +454,7 @@ public void testKeySetToArray() { } @Test - public void testEqualsAndHashCode() { + void testEqualsAndHashCode() { Id id1 = Id.create(1, Person.class); Id id2 = Id.create(2, Person.class); Id id3 = Id.create(3, Person.class); diff --git a/matsim/src/test/java/org/matsim/api/core/v01/IdSetTest.java b/matsim/src/test/java/org/matsim/api/core/v01/IdSetTest.java index 7d79338bfa2..63bee1c218d 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/IdSetTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/IdSetTest.java @@ -1,7 +1,7 @@ package org.matsim.api.core.v01; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; @@ -15,7 +15,7 @@ public class IdSetTest { @Test - public void testAddContainsRemoveSize() { + void testAddContainsRemoveSize() { IdSet set = new IdSet<>(Person.class); Id id1 = Id.create("1", Person.class); @@ -56,7 +56,7 @@ public void testAddContainsRemoveSize() { } @Test - public void testIterator() { + void testIterator() { IdSet set = new IdSet<>(Person.class); Id id1 = Id.create("1", Person.class); @@ -85,7 +85,7 @@ public void testIterator() { } @Test - public void testClear() { + void testClear() { IdSet set = new IdSet<>(Person.class); Id id1 = Id.create("1", Person.class); @@ -110,7 +110,7 @@ public void testClear() { } @Test - public void testAddAll() { + void testAddAll() { IdSet set1 = new IdSet<>(Person.class); IdSet set2 = new IdSet<>(Person.class); @@ -142,7 +142,7 @@ public void testAddAll() { } @Test - public void testRemoveAll() { + void testRemoveAll() { IdSet set1 = new IdSet<>(Person.class); IdSet set2 = new IdSet<>(Person.class); @@ -173,7 +173,7 @@ public void testRemoveAll() { } @Test - public void testRetainAll() { + void testRetainAll() { IdSet set1 = new IdSet<>(Person.class); IdSet set2 = new IdSet<>(Person.class); @@ -205,7 +205,7 @@ public void testRetainAll() { } @Test - public void testContainsAll() { + void testContainsAll() { IdSet set1 = new IdSet<>(Person.class); IdSet set2 = new IdSet<>(Person.class); @@ -233,7 +233,7 @@ public void testContainsAll() { } @Test - public void testToArray() { + void testToArray() { IdSet set = new IdSet<>(Person.class); Id id1 = Id.create("1", Person.class); @@ -302,7 +302,7 @@ public void testToArray() { } @Test - public void testEqualsAndHashCode() { + void testEqualsAndHashCode() { Id id1 = Id.create("1", Person.class); Id id2 = Id.create("2", Person.class); Id id3 = Id.create("3", Person.class); diff --git a/matsim/src/test/java/org/matsim/api/core/v01/IdTest.java b/matsim/src/test/java/org/matsim/api/core/v01/IdTest.java index bee42066ee6..77bc2676621 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/IdTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/IdTest.java @@ -23,18 +23,18 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.utils.collections.Tuple; import java.util.ArrayList; import java.util.List; -public class IdTest { + public class IdTest { private final static Logger LOG = LogManager.getLogger(IdTest.class); - @Test - public void testConstructor() { + @Test + void testConstructor() { Id linkId1 = Id.create("1", TLink.class); Id linkId2 = Id.create("2", TLink.class); @@ -42,22 +42,22 @@ public void testConstructor() { Assert.assertEquals("2", linkId2.toString()); } - @Test - public void testIdConstructor() { + @Test + void testIdConstructor() { Id nodeId1 = Id.create("1", TNode.class); Id linkId1 = Id.create(nodeId1, TLink.class); Assert.assertEquals("1", linkId1.toString()); } - - @Test - public void testIdConstructor_Null() { + + @Test + void testIdConstructor_Null() { Id linkId1 = Id.create((Id) null, TLink.class); Assert.assertNull(linkId1); } - - @Test - public void testObjectIdentity_cache() { + + @Test + void testObjectIdentity_cache() { Id linkId1 = Id.create("1", TLink.class); Id linkId2 = Id.create("2", TLink.class); Id linkId1again = Id.create("1", TLink.class); @@ -65,17 +65,17 @@ public void testObjectIdentity_cache() { Assert.assertTrue(linkId1 == linkId1again); Assert.assertFalse(linkId1 == linkId2); } - - @Test - public void testObjectIdentity_types() { + + @Test + void testObjectIdentity_types() { Id linkId1 = Id.create("1", TLink.class); Id nodeId1 = Id.create("1", TNode.class); Assert.assertFalse((Id) linkId1 == (Id) nodeId1); } - - @Test - public void testCompareTo() { + + @Test + void testCompareTo() { Id linkId1 = Id.create("1", TLink.class); Id linkId2 = Id.create("2", TLink.class); Id linkId1again = Id.create("1", TLink.class); @@ -94,8 +94,8 @@ public void testCompareTo() { // } // FIXME temporarily deactivated } - @Test - public void testResetCaches() { + @Test + void testResetCaches() { Id.create("1", TLink.class); Id.create("2", TLink.class); int count = Id.getNumberOfIds(TLink.class); @@ -108,8 +108,8 @@ public void testResetCaches() { Assert.assertEquals(3, Id.getNumberOfIds(TLink.class)); } - @Test - public void testResetCaches_onlyFromJUnit() throws InterruptedException { + @Test + void testResetCaches_onlyFromJUnit() throws InterruptedException { Id.create("1", TLink.class); int countBefore = Id.getNumberOfIds(TLink.class); Assert.assertTrue(countBefore > 0); diff --git a/matsim/src/test/java/org/matsim/api/core/v01/NetworkCreationTest.java b/matsim/src/test/java/org/matsim/api/core/v01/NetworkCreationTest.java index ce259d996c2..c6e62203b22 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/NetworkCreationTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/NetworkCreationTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.network.NetworkFactory; @@ -43,7 +43,8 @@ public class NetworkCreationTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testCreateNetwork() { + @Test + void testCreateNetwork() { Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Id nodeId1 = Id.create("1", Node.class); diff --git a/matsim/src/test/java/org/matsim/api/core/v01/network/AbstractNetworkTest.java b/matsim/src/test/java/org/matsim/api/core/v01/network/AbstractNetworkTest.java index 0b4a790d2ce..0e52b8b0594 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/network/AbstractNetworkTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/network/AbstractNetworkTest.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -38,7 +38,7 @@ public abstract class AbstractNetworkTest { public abstract Network getEmptyTestNetwork(); @Test - public void removeLink() { + void removeLink() { Fixture f = new Fixture(getEmptyTestNetwork()); Assert.assertTrue(f.network.getLinks().containsKey(f.linkIds[1])); @@ -63,7 +63,7 @@ public void removeLink() { } @Test - public void removeNode() { + void removeNode() { Fixture f = new Fixture(getEmptyTestNetwork()); Assert.assertEquals(8, f.network.getNodes().size()); diff --git a/matsim/src/test/java/org/matsim/core/config/CommandLineTest.java b/matsim/src/test/java/org/matsim/core/config/CommandLineTest.java index 4d623e74764..8a5ea4b5d90 100644 --- a/matsim/src/test/java/org/matsim/core/config/CommandLineTest.java +++ b/matsim/src/test/java/org/matsim/core/config/CommandLineTest.java @@ -1,8 +1,10 @@ package org.matsim.core.config; +import static org.junit.jupiter.api.Assertions.assertThrows; + import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; import java.util.NoSuchElementException; @@ -12,7 +14,7 @@ public class CommandLineTest{ @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public void testStandardUsage() { + void testStandardUsage() { String outDir = utils.getOutputDirectory() ; final String configFilename = outDir + "/config.xml"; @@ -29,25 +31,28 @@ public void testStandardUsage() { } - @Test( expected = NoSuchElementException.class ) - public void testTypo() { + @Test + void testTypo() { + assertThrows(NoSuchElementException.class, () -> { - final String configFilename = utils.getOutputDirectory() + "/config.xml"; + final String configFilename = utils.getOutputDirectory() + "/config.xml"; - // write some config: - ConfigUtils.writeConfig( ConfigUtils.createConfig(), configFilename ); + // write some config: + ConfigUtils.writeConfig(ConfigUtils.createConfig(), configFilename); - String [] args = {configFilename, "--something=abc"} ; + String [] args = {configFilename, "--something=abc"} ; - Config config = ConfigUtils.loadConfig( args ) ; - CommandLine cmd = ConfigUtils.getCommandLine( args ); + Config config = ConfigUtils.loadConfig(args) ; + CommandLine cmd = ConfigUtils.getCommandLine(args); - Assert.assertEquals( "abc", cmd.getOption( "someting" ).get() ); + Assert.assertEquals("abc", cmd.getOption("someting").get()); + + }); } @Test - public void testAdditionalConfigGroup() { + void testAdditionalConfigGroup() { final String configFilename = utils.getOutputDirectory() + "/config.xml"; @@ -67,7 +72,7 @@ public void testAdditionalConfigGroup() { } @Test - public void testSetParameterInAllParameterSets() { + void testSetParameterInAllParameterSets() { final String configFilename = utils.getOutputDirectory() + "/config.xml"; @@ -94,24 +99,26 @@ public void testSetParameterInAllParameterSets() { } } - @Test( expected = RuntimeException.class ) - public void testNotYetExistingAdditionalConfigGroup() { - final String configFilename = utils.getOutputDirectory() + "/config.xml"; - { - // write some config: - final Config config = ConfigUtils.createConfig() ; - ConfigUtils.writeConfig( config, configFilename ); - } - { - String[] args = {configFilename, "--config:mockConfigGroup.abc=28"}; - Config config = ConfigUtils.loadConfig( args ); - // (fails in the above line because CommandLine can not deal with the additional config group when it does not know about it + @Test + void testNotYetExistingAdditionalConfigGroup() { + assertThrows(RuntimeException.class, () -> { + final String configFilename = utils.getOutputDirectory() + "/config.xml"; + { + // write some config: + final Config config = ConfigUtils.createConfig() ; + ConfigUtils.writeConfig(config, configFilename); + } + { + String[] args = {configFilename, "--config:mockConfigGroup.abc=28"}; + Config config = ConfigUtils.loadConfig(args); + // (fails in the above line because CommandLine can not deal with the additional config group when it does not know about it - } + } + }); } @Test - public void testFixNotYetExistingAdditionalConfigGroup() { + void testFixNotYetExistingAdditionalConfigGroup() { final String configFilename = utils.getOutputDirectory() + "/config.xml"; { // write some config: diff --git a/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java b/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java index af1a7d1a58b..89bf12288d9 100644 --- a/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java +++ b/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java @@ -1,7 +1,7 @@ package org.matsim.core.config; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.config.groups.ControllerConfigGroup; import java.io.ByteArrayInputStream; @@ -15,7 +15,7 @@ public class ConfigReaderMatsimV2Test { @Test - public void testModuleNameAlias() { + void testModuleNameAlias() { Config config = ConfigUtils.createConfig(); ConfigReaderMatsimV2 r2 = new ConfigReaderMatsimV2(config); @@ -37,7 +37,7 @@ public void testModuleNameAlias() { } @Test - public void testModuleNameAlias_noOldModules() { + void testModuleNameAlias_noOldModules() { Config config = ConfigUtils.createConfig(); ConfigReaderMatsimV2 r2 = new ConfigReaderMatsimV2(config); @@ -59,7 +59,7 @@ public void testModuleNameAlias_noOldModules() { } @Test - public void testParamNameAlias() { + void testParamNameAlias() { Config config = ConfigUtils.createConfig(); ConfigReaderMatsimV2 r2 = new ConfigReaderMatsimV2(config); @@ -81,7 +81,7 @@ public void testParamNameAlias() { } @Test - public void testModuleAndParamNameAlias() { + void testModuleAndParamNameAlias() { Config config = ConfigUtils.createConfig(); ConfigReaderMatsimV2 r2 = new ConfigReaderMatsimV2(config); @@ -107,7 +107,7 @@ public void testModuleAndParamNameAlias() { * Test that a parameter can be renamed inside a renamed module. */ @Test - public void testConditionalParamNameAliasWithModuleRenaming() { + void testConditionalParamNameAliasWithModuleRenaming() { Config config = ConfigUtils.createConfig(); ConfigReaderMatsimV2 r2 = new ConfigReaderMatsimV2(config); @@ -141,7 +141,7 @@ public void testConditionalParamNameAliasWithModuleRenaming() { * different parameter names depending on in which module they are in. */ @Test - public void testConditionalParamNameAlias() { + void testConditionalParamNameAlias() { Config config = ConfigUtils.createConfig(); ConfigReaderMatsimV2 r2 = new ConfigReaderMatsimV2(config); @@ -171,7 +171,7 @@ public void testConditionalParamNameAlias() { * Test that an alias only matches if its path also matches. */ @Test - public void testConditionalParamNameAlias2() { + void testConditionalParamNameAlias2() { Config config = ConfigUtils.createConfig(); ConfigReaderMatsimV2 r2 = new ConfigReaderMatsimV2(config); @@ -200,7 +200,7 @@ public void testConditionalParamNameAlias2() { * Test that an alias only matches if its path also matches. */ @Test - public void testConditionalParamNameAlias3() { + void testConditionalParamNameAlias3() { Config config = ConfigUtils.createConfig(); ConfigReaderMatsimV2 r2 = new ConfigReaderMatsimV2(config); @@ -225,7 +225,7 @@ public void testConditionalParamNameAlias3() { * Test that an alias only matches if its path also matches. */ @Test - public void testConditionalParamNameAlias4() { + void testConditionalParamNameAlias4() { Config config = ConfigUtils.createConfig(); ConfigReaderMatsimV2 r2 = new ConfigReaderMatsimV2(config); @@ -251,7 +251,7 @@ public void testConditionalParamNameAlias4() { * Test that an alias also matches in nested parameter sets. */ @Test - public void testAliasWithParamSets() { + void testAliasWithParamSets() { Config config = ConfigUtils.createConfig(); ConfigReaderMatsimV2 r2 = new ConfigReaderMatsimV2(config); diff --git a/matsim/src/test/java/org/matsim/core/config/ConfigTest.java b/matsim/src/test/java/org/matsim/core/config/ConfigTest.java index 1f37611804a..07c481b7935 100644 --- a/matsim/src/test/java/org/matsim/core/config/ConfigTest.java +++ b/matsim/src/test/java/org/matsim/core/config/ConfigTest.java @@ -22,7 +22,7 @@ import java.io.ByteArrayInputStream; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author mrieser / senozon @@ -30,7 +30,7 @@ public class ConfigTest { @Test - public void testAddModule_beforeLoading() { + void testAddModule_beforeLoading() { Config config = new Config(); ConfigTestGroup group = new ConfigTestGroup(); @@ -54,7 +54,7 @@ public void testAddModule_beforeLoading() { } @Test - public void testAddModule_afterLoading() { + void testAddModule_afterLoading() { Config config = new Config(); ConfigTestGroup group = new ConfigTestGroup(); diff --git a/matsim/src/test/java/org/matsim/core/config/MaterializeConfigTest.java b/matsim/src/test/java/org/matsim/core/config/MaterializeConfigTest.java index 57f77ab8bca..0bdd7443ea7 100644 --- a/matsim/src/test/java/org/matsim/core/config/MaterializeConfigTest.java +++ b/matsim/src/test/java/org/matsim/core/config/MaterializeConfigTest.java @@ -3,8 +3,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; public class MaterializeConfigTest { @@ -14,7 +14,7 @@ public class MaterializeConfigTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public final void testMaterializeAfterReadParameterSets() { + final void testMaterializeAfterReadParameterSets() { { // generate a test config that sets two values away from their defaults, and // write it to file: diff --git a/matsim/src/test/java/org/matsim/core/config/ReflectiveConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/ReflectiveConfigGroupTest.java index a0302aea465..45243363ca7 100644 --- a/matsim/src/test/java/org/matsim/core/config/ReflectiveConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/ReflectiveConfigGroupTest.java @@ -33,8 +33,8 @@ import java.util.Set; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -52,7 +52,7 @@ public class ReflectiveConfigGroupTest { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testDumpAndRead() { + void testDumpAndRead() { MyModule dumpedModule = new MyModule(); dumpedModule.setDoubleField(1000); dumpedModule.setIdField(Id.create(123, Link.class)); @@ -76,13 +76,13 @@ public void testDumpAndRead() { } @Test - public void testDumpAndReadNulls() { + void testDumpAndReadNulls() { MyModule dumpedModule = new MyModule(); assertEqualAfterDumpAndRead(dumpedModule); } @Test - public void testDumpAndReadEmptyCollections() { + void testDumpAndReadEmptyCollections() { MyModule dumpedModule = new MyModule(); dumpedModule.listField = List.of(); dumpedModule.setField = ImmutableSet.of(); @@ -92,7 +92,7 @@ public void testDumpAndReadEmptyCollections() { } @Test - public void testDumpAndReadCollectionsWithExactlyOneEmptyString() { + void testDumpAndReadCollectionsWithExactlyOneEmptyString() { MyModule dumpedModule = new MyModule(); //fail on list @@ -109,7 +109,7 @@ public void testDumpAndReadCollectionsWithExactlyOneEmptyString() { } @Test - public void testDumpAndReadCollectionsIncludingEmptyString() { + void testDumpAndReadCollectionsIncludingEmptyString() { MyModule dumpedModule = new MyModule(); //fail on list @@ -141,7 +141,7 @@ private void assertEqualAfterDumpAndRead(MyModule dumpedModule) { } @Test - public void testReadCollectionsIncludingEmptyString() { + void testReadCollectionsIncludingEmptyString() { String fileName = utils.getInputDirectory() + "/config_with_blank_comma_separated_elements.xml"; final Config readConfig = ConfigUtils.loadConfig(fileName); final MyModule readModule = new MyModule(); @@ -152,7 +152,7 @@ public void testReadCollectionsIncludingEmptyString() { } @Test - public void testComments() { + void testComments() { var expectedComments = new HashMap<>(); expectedComments.put("floatField", "float"); expectedComments.put("longField", "long"); @@ -173,7 +173,7 @@ public void testComments() { } @Test - public void testFailOnConstructingOrphanSetter() { + void testFailOnConstructingOrphanSetter() { assertThatThrownBy(() -> new ReflectiveConfigGroup("name") { @StringSetter("setterWithoutGetter") public void setStuff(String s) { @@ -182,7 +182,7 @@ public void setStuff(String s) { } @Test - public void testFailOnConstructingOrphanGetter() { + void testFailOnConstructingOrphanGetter() { assertThatThrownBy(() -> new ReflectiveConfigGroup("name") { @StringGetter("setterWithoutGetter") public Coord getStuff() { @@ -192,7 +192,7 @@ public Coord getStuff() { } @Test - public void testFailOnConstructingInvalidSetter() { + void testFailOnConstructingInvalidSetter() { assertThatThrownBy(() -> new ReflectiveConfigGroup("name") { // no arg: no good @StringSetter("field") @@ -221,7 +221,7 @@ public Object getStuff() { } @Test - public void testFailOnConstructingInvalidGetter() { + void testFailOnConstructingInvalidGetter() { assertThatThrownBy(() -> new ReflectiveConfigGroup("name") { @StringSetter("field") public Object setStuff(String s) { @@ -249,7 +249,7 @@ public Object getStuff(Object someArg) { } @Test - public void testFailOnConstructingSeveralGetters() { + void testFailOnConstructingSeveralGetters() { assertThatThrownBy(() -> new ReflectiveConfigGroup("name") { @StringSetter("field") public void setStuff(String s) { @@ -268,7 +268,7 @@ public Object getStuff2() { } @Test - public void testFailOnConstructingSeveralSetters() { + void testFailOnConstructingSeveralSetters() { assertThatThrownBy(() -> new ReflectiveConfigGroup("name") { @StringSetter("field") public void setStuff(String s) { @@ -286,7 +286,7 @@ public Object getStuff() { } @Test - public void testFailOnConstructingSeveralParameters() { + void testFailOnConstructingSeveralParameters() { assertThatThrownBy(() -> new ReflectiveConfigGroup("name") { @Parameter double field; @@ -297,7 +297,7 @@ public void testFailOnConstructingSeveralParameters() { } @Test - public void testFailOnMixingGettersSettersWithParameters() { + void testFailOnMixingGettersSettersWithParameters() { assertThatThrownBy(() -> new ReflectiveConfigGroup("name") { @StringSetter("field") public void setStuff(double s) { @@ -314,7 +314,7 @@ public Object getStuff() { } @Test - public void testFailUnsupportedType_StringCollections() { + void testFailUnsupportedType_StringCollections() { assertThatThrownBy(() -> new ReflectiveConfigGroup("name") { @Parameter("field") private Collection stuff; @@ -322,7 +322,7 @@ public void testFailUnsupportedType_StringCollections() { } @Test - public void testFailUnsupportedType_NonStringList() { + void testFailUnsupportedType_NonStringList() { assertThatThrownBy(() -> new ReflectiveConfigGroup("name") { @Parameter("field") private List stuff; @@ -330,7 +330,7 @@ public void testFailUnsupportedType_NonStringList() { } @Test - public void testFailUnsupportedType_StringHashSet() { + void testFailUnsupportedType_StringHashSet() { assertThatThrownBy(() -> new ReflectiveConfigGroup("name") { @Parameter("field") private HashSet stuff; @@ -338,7 +338,7 @@ public void testFailUnsupportedType_StringHashSet() { } @Test - public void testPreferCustomCommentToAutoGeneratedEnumComment() { + void testPreferCustomCommentToAutoGeneratedEnumComment() { var config = new ReflectiveConfigGroup("name") { @Comment("my comment") @Parameter("field") @@ -348,7 +348,7 @@ public void testPreferCustomCommentToAutoGeneratedEnumComment() { } @Test - public void testBehaviorWhenAcceptingUnknownParameters() { + void testBehaviorWhenAcceptingUnknownParameters() { final ConfigGroup testee = new ReflectiveConfigGroup("name", true) { @StringSetter("field") public void setStuff(String s) { @@ -367,7 +367,7 @@ public Object getStuff() { } @Test - public void testBehaviorWhenRejectingUnknownParameters() { + void testBehaviorWhenRejectingUnknownParameters() { final ConfigGroup testee = new ReflectiveConfigGroup("name", false) { @StringSetter("field") public void setStuff(String s) { @@ -388,7 +388,7 @@ public Object getStuff() { } @Test - public void testExceptionRedirection() { + void testExceptionRedirection() { final RuntimeException expectedException = new RuntimeException(); final ConfigGroup m = new ReflectiveConfigGroup("name") { @StringSetter("field") diff --git a/matsim/src/test/java/org/matsim/core/config/URLTest.java b/matsim/src/test/java/org/matsim/core/config/URLTest.java index 2b75f03cff3..c5472f0c73a 100644 --- a/matsim/src/test/java/org/matsim/core/config/URLTest.java +++ b/matsim/src/test/java/org/matsim/core/config/URLTest.java @@ -21,17 +21,17 @@ package org.matsim.core.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.scenario.ScenarioUtils; import java.net.MalformedURLException; import java.net.URL; -public class URLTest { + public class URLTest { - @Test - public void testLoadWithURL() throws MalformedURLException { + @Test + void testLoadWithURL() throws MalformedURLException { Config config = ConfigUtils.loadConfig(new URL("file:../examples/scenarios/equil/config.xml")); Scenario scenario = ScenarioUtils.loadScenario(config); } diff --git a/matsim/src/test/java/org/matsim/core/config/consistency/BeanValidationConfigConsistencyCheckerTest.java b/matsim/src/test/java/org/matsim/core/config/consistency/BeanValidationConfigConsistencyCheckerTest.java index 083c74cf9e6..b6e9eba0719 100644 --- a/matsim/src/test/java/org/matsim/core/config/consistency/BeanValidationConfigConsistencyCheckerTest.java +++ b/matsim/src/test/java/org/matsim/core/config/consistency/BeanValidationConfigConsistencyCheckerTest.java @@ -32,7 +32,7 @@ import jakarta.validation.constraints.PositiveOrZero; import org.assertj.core.api.Assertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigGroup; import org.matsim.core.config.ConfigUtils; @@ -44,17 +44,17 @@ public class BeanValidationConfigConsistencyCheckerTest { @Test - public void emptyConfig_valid() { + void emptyConfig_valid() { assertThat(getViolationTuples(new Config())).isEmpty(); } @Test - public void defaultConfig_valid() { + void defaultConfig_valid() { assertThat(getViolationTuples(ConfigUtils.createConfig())).isEmpty(); } @Test - public void invalidConfigGroup_violationsReturned() { + void invalidConfigGroup_violationsReturned() { { Config config = ConfigUtils.createConfig(); config.qsim().setFlowCapFactor(0); @@ -75,7 +75,7 @@ public void invalidConfigGroup_violationsReturned() { } @Test - public void invalidParameterSet_violationsReturned() { + void invalidParameterSet_violationsReturned() { ConfigGroup configGroup = new ConfigGroup("config_group"); configGroup.addParameterSet(new ConfigGroup("invalid_param_set") { @PositiveOrZero @@ -88,7 +88,7 @@ public void invalidParameterSet_violationsReturned() { } @Test - public void manyConfigGroupsInvalid_violationsReturned() { + void manyConfigGroupsInvalid_violationsReturned() { { Config config = ConfigUtils.createConfig(); config.qsim().setFlowCapFactor(0); diff --git a/matsim/src/test/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImplTest.java b/matsim/src/test/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImplTest.java index 737607dae7d..1e996282944 100644 --- a/matsim/src/test/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImplTest.java +++ b/matsim/src/test/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImplTest.java @@ -21,7 +21,7 @@ import org.apache.logging.log4j.Level; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -38,7 +38,7 @@ public class ConfigConsistencyCheckerImplTest { @Test - public void testCheckPlanCalcScore_DefaultsOk() { + void testCheckPlanCalcScore_DefaultsOk() { Config config = new Config(); config.addCoreModules(); @@ -54,7 +54,7 @@ public void testCheckPlanCalcScore_DefaultsOk() { } @Test - public void testCheckPlanCalcScore_Traveling() { + void testCheckPlanCalcScore_Traveling() { Config config = new Config(); config.addCoreModules(); @@ -72,7 +72,7 @@ public void testCheckPlanCalcScore_Traveling() { } @Test - public void testCheckPlanCalcScore_TravelingPt() { + void testCheckPlanCalcScore_TravelingPt() { Config config = new Config(); config.addCoreModules(); @@ -90,7 +90,7 @@ public void testCheckPlanCalcScore_TravelingPt() { } @Test - public void testCheckPlanCalcScore_TravelingBike() { + void testCheckPlanCalcScore_TravelingBike() { Config config = new Config(); config.addCoreModules(); @@ -108,7 +108,7 @@ public void testCheckPlanCalcScore_TravelingBike() { } @Test - public void testCheckPlanCalcScore_TravelingWalk() { + void testCheckPlanCalcScore_TravelingWalk() { Config config = new Config(); config.addCoreModules(); @@ -126,7 +126,7 @@ public void testCheckPlanCalcScore_TravelingWalk() { } @Test - public void testCheckPlanCalcScore_PtInteractionActivity() { + void testCheckPlanCalcScore_PtInteractionActivity() { Config config = new Config(); config.addCoreModules(); @@ -154,7 +154,7 @@ public void testCheckPlanCalcScore_PtInteractionActivity() { @Test - public void checkConsistencyBetweenRouterAndTravelTimeCalculatorTest(){ + void checkConsistencyBetweenRouterAndTravelTimeCalculatorTest(){ { Config config = ConfigUtils.createConfig(); diff --git a/matsim/src/test/java/org/matsim/core/config/groups/ControllerConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/ControllerConfigGroupTest.java index a1c50b1d46f..26499157749 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/ControllerConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/ControllerConfigGroupTest.java @@ -24,7 +24,7 @@ import java.util.Set; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.config.groups.ControllerConfigGroup.EventsFileFormat; public class ControllerConfigGroupTest { @@ -36,7 +36,7 @@ public class ControllerConfigGroupTest { * @author mrieser */ @Test - public void testEventsFileFormat() { + void testEventsFileFormat() { ControllerConfigGroup cg = new ControllerConfigGroup(); Set formats; // test initial value @@ -86,7 +86,7 @@ public void testEventsFileFormat() { * @author mrieser */ @Test - public void testMobsim() { + void testMobsim() { ControllerConfigGroup cg = new ControllerConfigGroup(); // test initial value Assert.assertEquals("qsim", cg.getMobsim()); @@ -108,7 +108,7 @@ public void testMobsim() { * @author mrieser */ @Test - public void testWritePlansInterval() { + void testWritePlansInterval() { ControllerConfigGroup cg = new ControllerConfigGroup(); // test initial value Assert.assertEquals(50, cg.getWritePlansInterval()); @@ -125,7 +125,7 @@ public void testWritePlansInterval() { * returned with the getters and setters. */ @Test - public void testLink2LinkRouting(){ + void testLink2LinkRouting(){ ControllerConfigGroup cg = new ControllerConfigGroup(); //initial value Assert.assertFalse(cg.isLinkToLinkRoutingEnabled()); @@ -148,7 +148,7 @@ public void testLink2LinkRouting(){ * returned with the getters and setters. */ @Test - public void testWriteSnapshotInterval(){ + void testWriteSnapshotInterval(){ ControllerConfigGroup cg = new ControllerConfigGroup(); //initial value Assert.assertEquals(1, cg.getWriteSnapshotsInterval()); diff --git a/matsim/src/test/java/org/matsim/core/config/groups/CountsConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/CountsConfigGroupTest.java index 64016c97940..f1c2fdf7276 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/CountsConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/CountsConfigGroupTest.java @@ -20,7 +20,7 @@ package org.matsim.core.config.groups; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author mrieser @@ -28,7 +28,7 @@ public class CountsConfigGroupTest { @Test - public void testWriteCountsInterval() { + void testWriteCountsInterval() { CountsConfigGroup cg = new CountsConfigGroup(); // test initial value Assert.assertEquals(10, cg.getWriteCountsInterval()); @@ -44,13 +44,13 @@ public void testWriteCountsInterval() { } @Test - public void testGetParams_writeCountsInterval() { + void testGetParams_writeCountsInterval() { CountsConfigGroup cg = new CountsConfigGroup(); Assert.assertNotNull(cg.getParams().get("writeCountsInterval")); } - + @Test - public void testWriteAverageOverIterations() { + void testWriteAverageOverIterations() { CountsConfigGroup cg = new CountsConfigGroup(); // test initial value Assert.assertEquals(5, cg.getAverageCountsOverIterations()); @@ -64,9 +64,9 @@ public void testWriteAverageOverIterations() { Assert.assertEquals(2, cg.getAverageCountsOverIterations()); Assert.assertEquals("2", cg.getValue("averageCountsOverIterations")); } - + @Test - public void testGetParams_averageCountsOverIterations() { + void testGetParams_averageCountsOverIterations() { CountsConfigGroup cg = new CountsConfigGroup(); Assert.assertNotNull(cg.getParams().get("averageCountsOverIterations")); } diff --git a/matsim/src/test/java/org/matsim/core/config/groups/LinkStatsConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/LinkStatsConfigGroupTest.java index 95397daf264..363c5eca282 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/LinkStatsConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/LinkStatsConfigGroupTest.java @@ -20,7 +20,7 @@ package org.matsim.core.config.groups; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author mrieser @@ -28,7 +28,7 @@ public class LinkStatsConfigGroupTest { @Test - public void testWriteLinkStatsInterval() { + void testWriteLinkStatsInterval() { LinkStatsConfigGroup cg = new LinkStatsConfigGroup(); // test initial value Assert.assertEquals(50, cg.getWriteLinkStatsInterval()); @@ -44,13 +44,13 @@ public void testWriteLinkStatsInterval() { } @Test - public void testGetParams_writeLinkStatsInterval() { + void testGetParams_writeLinkStatsInterval() { LinkStatsConfigGroup cg = new LinkStatsConfigGroup(); Assert.assertNotNull(cg.getParams().get("writeLinkStatsInterval")); } - + @Test - public void testWriteAverageOverIterations() { + void testWriteAverageOverIterations() { LinkStatsConfigGroup cg = new LinkStatsConfigGroup(); // test initial value Assert.assertEquals(5, cg.getAverageLinkStatsOverIterations()); @@ -64,9 +64,9 @@ public void testWriteAverageOverIterations() { Assert.assertEquals(2, cg.getAverageLinkStatsOverIterations()); Assert.assertEquals("2", cg.getValue("averageLinkStatsOverIterations")); } - + @Test - public void testGetParams_averageLinkStatsOverIterations() { + void testGetParams_averageLinkStatsOverIterations() { LinkStatsConfigGroup cg = new LinkStatsConfigGroup(); Assert.assertNotNull(cg.getParams().get("averageLinkStatsOverIterations")); } diff --git a/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java index ba0fae597fa..ba0ff07c5f3 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java @@ -27,8 +27,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigGroup; @@ -55,7 +55,7 @@ public class ReplanningConfigGroupTest { * @author mrieser */ @Test - public void testParamNames() { + void testParamNames() { ReplanningConfigGroup configGroup = new ReplanningConfigGroup(); configGroup.addParam("maxAgentPlanMemorySize", "3"); configGroup.addParam("Module_1", "ReRoute"); @@ -79,7 +79,7 @@ public void testParamNames() { * @author mrieser */ @Test - public void testCheckConsistency() { + void testCheckConsistency() { // start with a simple configuration with exactly one module defined ReplanningConfigGroup configGroup = new ReplanningConfigGroup(); configGroup.addParam("maxAgentPlanMemorySize", "3"); @@ -148,7 +148,7 @@ public void testCheckConsistency() { } @Test - public void testIOWithFormatChange() { + void testIOWithFormatChange() { final ReplanningConfigGroup initialGroup = createTestConfigGroup(); final String v1path = utils.getOutputDirectory() + "/configv1_out.xml"; diff --git a/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java index 5b04311c78f..45f9c4e335c 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java @@ -23,10 +23,12 @@ import java.util.Map; import org.apache.logging.log4j.LogManager; + +import static org.junit.jupiter.api.Assertions.assertThrows; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigGroup; @@ -44,7 +46,7 @@ public class RoutingConfigGroupTest { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testAddModeParamsTwice() { + void testAddModeParamsTwice() { String outdir = utils.getOutputDirectory(); final String filename = outdir + "config.xml"; { @@ -67,8 +69,9 @@ public void testAddModeParamsTwice() { Assert.assertEquals( 0, group.getModeRoutingParams().size() ); } } + @Test - public void testClearParamsWriteRead() { + void testClearParamsWriteRead() { String outdir = utils.getOutputDirectory(); final String filename = outdir + "config.xml"; { @@ -91,8 +94,9 @@ public void testClearParamsWriteRead() { Assert.assertEquals( 0, group.getModeRoutingParams().size() ); } } + @Test - public void testRemoveParamsWriteRead() { + void testRemoveParamsWriteRead() { String outdir = utils.getOutputDirectory(); final String filename = outdir + "config.xml"; { @@ -116,8 +120,9 @@ public void testRemoveParamsWriteRead() { Assert.assertEquals( 0, group.getModeRoutingParams().size() ); } } + @Test - public void testClearDefaults() { + void testClearDefaults() { Config config = ConfigUtils.createConfig( ) ; RoutingConfigGroup group = config.routing() ; Assert.assertEquals( N_MODE_ROUTING_PARAMS_DEFAULT, group.getModeRoutingParams().size() ); @@ -128,22 +133,26 @@ public void testClearDefaults() { group.clearModeRoutingParams( ); Assert.assertEquals( 0, group.getModeRoutingParams().size() ); } + @Test - public void test3() { + void test3() { Config config = ConfigUtils.createConfig( ) ; RoutingConfigGroup group = config.routing() ; group.clearModeRoutingParams(); group.setClearingDefaultModeRoutingParams( true ); // should be ok } - @Test( expected = RuntimeException.class ) - public void testInconsistencyBetweenActionAndState() { - RoutingConfigGroup group = new RoutingConfigGroup() ; - group.clearModeRoutingParams(); - group.setClearingDefaultModeRoutingParams( false ); // should fail + + @Test + void testInconsistencyBetweenActionAndState() { + assertThrows(RuntimeException.class, () -> { + RoutingConfigGroup group = new RoutingConfigGroup() ; + group.clearModeRoutingParams(); + group.setClearingDefaultModeRoutingParams(false); // should fail + }); // should fail } @Test - public void testBackwardsCompatibility() { + void testBackwardsCompatibility() { RoutingConfigGroup group = new RoutingConfigGroup(); // test default @@ -161,7 +170,7 @@ public void testBackwardsCompatibility() { } @Test - public void testDefaultsAreCleared() { + void testDefaultsAreCleared() { RoutingConfigGroup group = new RoutingConfigGroup(); // group.clearModeRoutingParams(); group.setTeleportedModeSpeed( "skateboard" , 20 / 3.6 ); @@ -173,7 +182,7 @@ public void testDefaultsAreCleared() { } @Test - public void testIODifferentVersions() + void testIODifferentVersions() { final RoutingConfigGroup initialGroup = createTestConfigGroup(); @@ -210,29 +219,35 @@ public void testIODifferentVersions() assertIdentical("re-read v2", initialGroup, configV2.routing()); } - @Test( expected=RuntimeException.class ) - public void testConsistencyCheckIfNoTeleportedSpeed() { - final Config config = ConfigUtils.createConfig(); + @Test + void testConsistencyCheckIfNoTeleportedSpeed() { + assertThrows(RuntimeException.class, () -> { + final Config config = ConfigUtils.createConfig(); - final TeleportedModeParams params = new TeleportedModeParams( "skateboard" ); - config.routing().addModeRoutingParams( params ); - // (one needs to set one of the teleported speed settings) + final TeleportedModeParams params = new TeleportedModeParams( "skateboard" ); + config.routing().addModeRoutingParams(params); + // (one needs to set one of the teleported speed settings) - config.checkConsistency(); + config.checkConsistency(); + }); } - @Test( expected=IllegalStateException.class ) - public void testCannotAddSpeedAfterFactor() { - final TeleportedModeParams params = new TeleportedModeParams( "overboard" ); - params.setTeleportedModeFreespeedFactor( 2.0 ); - params.setTeleportedModeSpeed( 12.0 ); + @Test + void testCannotAddSpeedAfterFactor() { + assertThrows(IllegalStateException.class, () -> { + final TeleportedModeParams params = new TeleportedModeParams( "overboard" ); + params.setTeleportedModeFreespeedFactor(2.0); + params.setTeleportedModeSpeed(12.0); + }); } - @Test( expected=IllegalStateException.class ) - public void testCannotAddFactorAfterSpeed() { - final TeleportedModeParams params = new TeleportedModeParams( "overboard" ); - params.setTeleportedModeSpeed( 12.0 ); - params.setTeleportedModeFreespeedFactor( 2.0 ); + @Test + void testCannotAddFactorAfterSpeed() { + assertThrows(IllegalStateException.class, () -> { + final TeleportedModeParams params = new TeleportedModeParams( "overboard" ); + params.setTeleportedModeSpeed(12.0); + params.setTeleportedModeFreespeedFactor(2.0); + }); } private static void assertIdentical( diff --git a/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java index d75ee413732..80512022e3f 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java @@ -29,8 +29,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigGroup; @@ -41,7 +41,7 @@ import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; import org.matsim.testcases.MatsimTestUtils; -public class ScoringConfigGroupTest { + public class ScoringConfigGroupTest { private static final Logger log = LogManager.getLogger(ScoringConfigGroupTest.class); @@ -78,8 +78,8 @@ private void testResultsAfterCheckConsistency( Config config ) { } } - @Test - public void testFullyHierarchicalVersion() { + @Test + void testFullyHierarchicalVersion() { Config config = ConfigUtils.loadConfig( utils.getClassInputDirectory() + "config_v2_w_scoringparams.xml" ) ; ScoringConfigGroup scoringConfig = config.scoring() ; testResultsBeforeCheckConsistency( config, true ) ; @@ -106,8 +106,9 @@ public void testFullyHierarchicalVersion() { } log.warn( "" ); } - @Test - public void testVersionWoScoringparams() { + + @Test + void testVersionWoScoringparams() { Config config = ConfigUtils.loadConfig( utils.getClassInputDirectory() + "config_v2_wo_scoringparams.xml" ) ; ScoringConfigGroup scoringConfig = config.scoring() ; testResultsBeforeCheckConsistency( config, false ) ; @@ -135,8 +136,8 @@ public void testVersionWoScoringparams() { log.warn( "" ); } - @Test - public void testAddActivityParams() { + @Test + void testAddActivityParams() { ScoringConfigGroup c = new ScoringConfigGroup(); int originalSize = c.getActivityParams().size(); Assert.assertNull(c.getActivityParams("type1")); @@ -148,8 +149,8 @@ public void testAddActivityParams() { Assert.assertEquals(originalSize + 1, c.getActivityParams().size()); } - @Test - public void testIODifferentVersions() { + @Test + void testIODifferentVersions() { final ScoringConfigGroup initialGroup = createTestConfigGroup(); final String v1path = utils.getOutputDirectory() + "/configv1_out.xml"; diff --git a/matsim/src/test/java/org/matsim/core/config/groups/SubtourModeChoiceConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/SubtourModeChoiceConfigGroupTest.java index 23a51557f6d..77bcf5c5869 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/SubtourModeChoiceConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/SubtourModeChoiceConfigGroupTest.java @@ -24,7 +24,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author thibautd @@ -32,7 +32,7 @@ public class SubtourModeChoiceConfigGroupTest { @Test - public void testModes() throws Exception { + void testModes() throws Exception { SubtourModeChoiceConfigGroup group = new SubtourModeChoiceConfigGroup(); final String msg = "Wrong values for modes"; final String msgString = "Wrong string representation"; @@ -78,7 +78,7 @@ public void testModes() throws Exception { } @Test - public void testChainBasedModes() throws Exception { + void testChainBasedModes() throws Exception { SubtourModeChoiceConfigGroup group = new SubtourModeChoiceConfigGroup(); final String msg = "Wrong values for chain based modes"; final String msgString = "Wrong string representation"; @@ -124,7 +124,7 @@ public void testChainBasedModes() throws Exception { } @Test - public void testCarAvail() throws Exception { + void testCarAvail() throws Exception { SubtourModeChoiceConfigGroup group = new SubtourModeChoiceConfigGroup(); assertFalse( diff --git a/matsim/src/test/java/org/matsim/core/config/groups/VspExperimentalConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/VspExperimentalConfigGroupTest.java index 088d486fea7..9ddaaa3fde0 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/VspExperimentalConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/VspExperimentalConfigGroupTest.java @@ -22,8 +22,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; public class VspExperimentalConfigGroupTest { @@ -34,7 +34,8 @@ public class VspExperimentalConfigGroupTest { private static final Logger log = LogManager.getLogger(VspExperimentalConfigGroupTest.class); - @Test public void testVspConfigGroup() { + @Test + void testVspConfigGroup() { // VspExperimentalConfigGroup vspConfig = ConfigUtils.createConfig().vspExperimental() ; // diff --git a/matsim/src/test/java/org/matsim/core/controler/AbstractModuleTest.java b/matsim/src/test/java/org/matsim/core/controler/AbstractModuleTest.java index 5651097897f..14ce2ce7150 100644 --- a/matsim/src/test/java/org/matsim/core/controler/AbstractModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/AbstractModuleTest.java @@ -5,8 +5,8 @@ import com.google.inject.name.Named; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; import org.matsim.core.config.Config; @@ -25,7 +25,7 @@ public class AbstractModuleTest{ @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public void test1() { + void test1() { Config config = ConfigUtils.createConfig() ; config.controller().setOutputDirectory( utils.getOutputDirectory() ); diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java b/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java index a1739b52361..d4b1efc64b6 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java @@ -28,8 +28,8 @@ import org.junit.After; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.controler.events.IterationEndsEvent; import org.matsim.core.controler.events.IterationStartsEvent; @@ -60,7 +60,8 @@ void addCalledStartupListenerNumber(int i) { this.calledStartupListener = null; } - @Test public void testCoreListenerExecutionOrder() { + @Test + void testCoreListenerExecutionOrder() { Config config = utils.loadConfig(utils.getClassInputDirectory() + "config.xml"); TestController controler = new TestController(config); @@ -77,7 +78,8 @@ void addCalledStartupListenerNumber(int i) { assertEquals(1, this.calledStartupListener.get(2).intValue()); } - @Test public void testEvents() { + @Test + void testEvents() { Config config = utils.loadConfig(utils.getClassInputDirectory() + "config.xml"); TestController controler = new TestController(config); diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java b/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java index 3f49cbf2b46..b304f34dbd1 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java @@ -21,6 +21,7 @@ package org.matsim.core.controler; import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.matsim.core.config.groups.ControllerConfigGroup.CompressionType; import static org.matsim.core.config.groups.ControllerConfigGroup.SnapshotFormat; @@ -34,8 +35,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @@ -95,7 +96,7 @@ public static Collection parameterObjects () { } @Test - public void testScenarioLoading() { + void testScenarioLoading() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); Controler controler = new Controler( config ); @@ -113,7 +114,7 @@ public void testScenarioLoading() { } @Test - public void testTerminationCriterion() { + void testTerminationCriterion() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); config.controller().setOutputDirectory(utils.getOutputDirectory()); Controler controler = new Controler(config); @@ -132,7 +133,7 @@ public boolean doTerminate(int iteration) { } @Test - public void testConstructor_EventsManagerTypeImmutable() { + void testConstructor_EventsManagerTypeImmutable() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); MatsimServices controler = new Controler(config); try { @@ -156,7 +157,7 @@ public void testConstructor_EventsManagerTypeImmutable() { * @author mrieser */ @Test - public void testTravelTimeCalculation() { + void testTravelTimeCalculation() { Fixture f = new Fixture(ConfigUtils.createConfig()); Config config = f.scenario.getConfig(); @@ -249,7 +250,7 @@ public void testTravelTimeCalculation() { * @author mrieser */ @Test - public void testSetScoringFunctionFactory() { + void testSetScoringFunctionFactory() { final Config config = this.utils.loadConfig((String) null); config.controller().setLastIteration(0); @@ -297,7 +298,7 @@ public Mobsim get() { * @author mrieser */ @Test - public void testCalcMissingRoutes() { + void testCalcMissingRoutes() { Config config = this.utils.loadConfig((String) null); Fixture f = new Fixture(config); @@ -386,7 +387,7 @@ public Mobsim get() { * @author mrieser */ @Test - public void testCalcMissingActLinks() { + void testCalcMissingActLinks() { Config config = this.utils.loadConfig((String) null); Fixture f = new Fixture(config); @@ -499,7 +500,7 @@ public Mobsim get() { * @author mrieser */ @Test - public void testCompressionType() { + void testCompressionType() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); config.controller().setLastIteration(0); config.controller().setCompressionType( CompressionType.zst ); @@ -538,7 +539,7 @@ public Mobsim get() { * @author mrieser */ @Test - public void testSetWriteEventsInterval() { + void testSetWriteEventsInterval() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); config.controller().setLastIteration(10); config.controller().setWritePlansInterval(0); @@ -582,7 +583,7 @@ public Mobsim get() { * @author wrashid */ @Test - public void testSetWriteEventsIntervalConfig() { + void testSetWriteEventsIntervalConfig() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); config.controller().setLastIteration(10); config.controller().setWritePlansInterval(0); @@ -623,7 +624,7 @@ public Mobsim get() { * @author mrieser */ @Test - public void testSetWriteEventsNever() { + void testSetWriteEventsNever() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); config.controller().setLastIteration(1); config.controller().setWritePlansInterval(0); @@ -656,7 +657,7 @@ public Mobsim get() { * @author mrieser */ @Test - public void testSetWriteEventsAlways() { + void testSetWriteEventsAlways() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); config.controller().setLastIteration(1); config.controller().setWritePlansInterval(0); @@ -687,7 +688,7 @@ public Mobsim get() { * @author mrieser */ @Test - public void testSetWriteEventsXml() { + void testSetWriteEventsXml() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); config.controller().setLastIteration(0); config.controller().setWritePlansInterval(0); @@ -718,7 +719,7 @@ public Mobsim get() { * @author mrieser */ @Test - public void testSetDumpDataAtEnd_true() { + void testSetDumpDataAtEnd_true() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); config.controller().setLastIteration(0); config.controller().setWritePlansInterval(0); @@ -748,7 +749,7 @@ public Mobsim get() { * @author mrieser */ @Test - public void testSetDumpDataAtEnd_false() { + void testSetDumpDataAtEnd_false() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); config.controller().setLastIteration(0); config.controller().setWritePlansInterval(0); @@ -775,25 +776,27 @@ public Mobsim get() { assertFalse(new File(controler.getControlerIO().getOutputFilename(Controler.DefaultFiles.population)).exists()); } - @Test(expected = RuntimeException.class) - public void testShutdown_UncaughtException() { - final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - config.controller().setLastIteration(1); + @Test + void testShutdown_UncaughtException() { + assertThrows(RuntimeException.class, () -> { + final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); + config.controller().setLastIteration(1); - Controler controler = new Controler(config); - controler.addOverridingModule(new AbstractModule() { - @Override - public void install() { - bindMobsim().to(CrashingMobsim.class); - } + Controler controler = new Controler(config); + controler.addOverridingModule(new AbstractModule() { + @Override + public void install() { + bindMobsim().to(CrashingMobsim.class); + } + }); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); + controler.run(); }); - controler.getConfig().controller().setCreateGraphs(false); - controler.getConfig().controller().setDumpDataAtEnd(false); - controler.run(); } @Test - public void test_ExceptionOnMissingPopulationFile() { + void test_ExceptionOnMissingPopulationFile() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); config.controller().setLastIteration(0); config.controller().setWriteEventsInterval(0); @@ -828,7 +831,7 @@ public Mobsim get() { } @Test - public void test_ExceptionOnMissingNetworkFile() { + void test_ExceptionOnMissingNetworkFile() { try { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); config.controller().setLastIteration(0); @@ -863,7 +866,7 @@ public Mobsim get() { } @Test - public void test_ExceptionOnMissingFacilitiesFile() { + void test_ExceptionOnMissingFacilitiesFile() { try { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); config.controller().setLastIteration(0); @@ -898,7 +901,7 @@ public Mobsim get() { } @Test - public void testOneSnapshotWriterInConfig() { + void testOneSnapshotWriterInConfig() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); config.controller().setLastIteration(0); config.controller().setWriteEventsInterval(0); @@ -915,7 +918,7 @@ public void testOneSnapshotWriterInConfig() { } @Test - public void testTransimsSnapshotWriterOnQSim() { + void testTransimsSnapshotWriterOnQSim() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); config.controller().setLastIteration(2); config.controller().setWriteEventsInterval(0); @@ -944,36 +947,38 @@ public void testTransimsSnapshotWriterOnQSim() { * @thibautd * */ - @Test( expected = RuntimeException.class ) - public void testGuiceModulesCannotAddModules() { - final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - config.controller().setLastIteration( 0 ); - final Controler controler = new Controler( config ); + @Test + void testGuiceModulesCannotAddModules() { + assertThrows(RuntimeException.class, () -> { + final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); + config.controller().setLastIteration(0); + final Controler controler = new Controler( config ); - final Scenario replacementScenario = ScenarioUtils.createScenario( config ); + final Scenario replacementScenario = ScenarioUtils.createScenario(config); - controler.addOverridingModule( - new AbstractModule() { - @Override - public void install() { - controler.addOverridingModule( - new AbstractModule() { - @Override - public void install() { - bind( Scenario.class ).toInstance( replacementScenario ); + controler.addOverridingModule( + new AbstractModule() { + @Override + public void install() { + controler.addOverridingModule( + new AbstractModule() { + @Override + public void install() { + bind(Scenario.class).toInstance(replacementScenario); + } } - } - ); + ); + } } - } - ); + ); - controler.run(); + controler.run(); - Assert.assertSame( - "adding a Guice module to the controler from a Guice module is allowed but has no effect", - replacementScenario, - controler.getScenario() ); + Assert.assertSame( + "adding a Guice module to the controler from a Guice module is allowed but has no effect", + replacementScenario, + controler.getScenario()); + }); } static class FakeMobsim implements Mobsim { diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerListenerManagerImplTest.java b/matsim/src/test/java/org/matsim/core/controler/ControlerListenerManagerImplTest.java index f22e7b4c87b..762a73afc2e 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerListenerManagerImplTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerListenerManagerImplTest.java @@ -22,7 +22,7 @@ package org.matsim.core.controler; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.controler.events.IterationStartsEvent; import org.matsim.core.controler.events.ShutdownEvent; import org.matsim.core.controler.events.StartupEvent; @@ -30,13 +30,13 @@ import org.matsim.core.controler.listener.ShutdownListener; import org.matsim.core.controler.listener.StartupListener; -/** + /** * @author mrieser / senozon */ public class ControlerListenerManagerImplTest { - @Test - public void testAddControlerListener_ClassHierarchy() { + @Test + void testAddControlerListener_ClassHierarchy() { ControlerListenerManagerImpl m = new ControlerListenerManagerImpl(); CountingControlerListener ccl = new CountingControlerListener(); ExtendedControlerListener ecl = new ExtendedControlerListener(); @@ -72,8 +72,8 @@ public void testAddControlerListener_ClassHierarchy() { Assert.assertEquals(1, ecl.nOfShutdowns); } - @Test - public void testAddCoreControlerListener_ClassHierarchy() { + @Test + void testAddCoreControlerListener_ClassHierarchy() { ControlerListenerManagerImpl m = new ControlerListenerManagerImpl(); CountingControlerListener ccl = new CountingControlerListener(); ExtendedControlerListener ecl = new ExtendedControlerListener(); diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerMobsimIntegrationTest.java b/matsim/src/test/java/org/matsim/core/controler/ControlerMobsimIntegrationTest.java index d20bc0a6222..af2cf20fe23 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerMobsimIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerMobsimIntegrationTest.java @@ -19,12 +19,14 @@ package org.matsim.core.controler; +import static org.junit.jupiter.api.Assertions.assertThrows; + import com.google.inject.Provider; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; @@ -43,7 +45,7 @@ public class ControlerMobsimIntegrationTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testRunMobsim_customMobsim() { + void testRunMobsim_customMobsim() { Config cfg = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); cfg.controller().setLastIteration(0); cfg.controller().setMobsim("counting"); @@ -70,17 +72,19 @@ public Mobsim get() { Assert.assertEquals(1, mf.callCount); } - @Test(expected = RuntimeException.class) - public void testRunMobsim_missingMobsimFactory() { - Config cfg = this.utils.loadConfig("test/scenarios/equil/config_plans1.xml"); - cfg.controller().setLastIteration(0); - cfg.controller().setMobsim("counting"); - cfg.controller().setWritePlansInterval(0); - Controler c = new Controler(cfg); - c.getConfig().controller().setCreateGraphs(false); - c.getConfig().controller().setDumpDataAtEnd(false); - c.getConfig().controller().setWriteEventsInterval(0); - c.run(); + @Test + void testRunMobsim_missingMobsimFactory() { + assertThrows(RuntimeException.class, () -> { + Config cfg = this.utils.loadConfig("test/scenarios/equil/config_plans1.xml"); + cfg.controller().setLastIteration(0); + cfg.controller().setMobsim("counting"); + cfg.controller().setWritePlansInterval(0); + Controler c = new Controler(cfg); + c.getConfig().controller().setCreateGraphs(false); + c.getConfig().controller().setDumpDataAtEnd(false); + c.getConfig().controller().setWriteEventsInterval(0); + c.run(); + }); } private static class CountingMobsimFactory implements MobsimFactory { diff --git a/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java b/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java index 9c7e303230d..1bb0b102e20 100644 --- a/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java @@ -23,22 +23,22 @@ import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.controler.events.IterationStartsEvent; import org.matsim.core.controler.listener.IterationStartsListener; import org.matsim.testcases.MatsimTestUtils; -public class MatsimServicesImplTest { + public class MatsimServicesImplTest { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); - @Ignore - @Test - public void testIterationInServicesEqualsIterationInEvent() { + @Ignore + @Test + void testIterationInServicesEqualsIterationInEvent() { Config config = ConfigUtils.createConfig(); config.controller().setLastIteration(1); diff --git a/matsim/src/test/java/org/matsim/core/controler/MobsimListenerTest.java b/matsim/src/test/java/org/matsim/core/controler/MobsimListenerTest.java index 8818f2b63b6..4efe0580ad6 100644 --- a/matsim/src/test/java/org/matsim/core/controler/MobsimListenerTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/MobsimListenerTest.java @@ -21,9 +21,8 @@ */ package org.matsim.core.controler; - +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.mobsim.framework.events.MobsimInitializedEvent; import org.matsim.core.mobsim.framework.listeners.MobsimInitializedListener; @@ -31,13 +30,15 @@ import jakarta.inject.Singleton; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class MobsimListenerTest { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void testRunMobsim_listenerTransient() { + @Test + void testRunMobsim_listenerTransient() { Config cfg = this.utils.loadConfig("test/scenarios/equil/config_plans1.xml"); cfg.controller().setLastIteration(1); cfg.controller().setWritePlansInterval(0); @@ -54,23 +55,25 @@ public void install() { c.run(); } - @Test(expected = RuntimeException.class) - public void testRunMobsim_listenerSingleton() { - Config cfg = this.utils.loadConfig("test/scenarios/equil/config_plans1.xml"); - cfg.controller().setLastIteration(1); - cfg.controller().setWritePlansInterval(0); - final Controler c = new Controler(cfg); - c.addOverridingModule(new AbstractModule() { - @Override - public void install() { - addMobsimListenerBinding().to(SingletonCountingMobsimListener.class); - } - }); - c.getConfig().controller().setCreateGraphs(false); - c.getConfig().controller().setDumpDataAtEnd(false); - c.getConfig().controller().setWriteEventsInterval(0); - c.run(); - } + @Test + void testRunMobsim_listenerSingleton() { + assertThrows(RuntimeException.class, () -> { + Config cfg = this.utils.loadConfig("test/scenarios/equil/config_plans1.xml"); + cfg.controller().setLastIteration(1); + cfg.controller().setWritePlansInterval(0); + final Controler c = new Controler(cfg); + c.addOverridingModule(new AbstractModule() { + @Override + public void install() { + addMobsimListenerBinding().to(SingletonCountingMobsimListener.class); + } + }); + c.getConfig().controller().setCreateGraphs(false); + c.getConfig().controller().setDumpDataAtEnd(false); + c.getConfig().controller().setWriteEventsInterval(0); + c.run(); + }); + } private static class CountingMobsimListener implements MobsimInitializedListener { diff --git a/matsim/src/test/java/org/matsim/core/controler/NewControlerTest.java b/matsim/src/test/java/org/matsim/core/controler/NewControlerTest.java index b10a0509487..b5195d537e7 100644 --- a/matsim/src/test/java/org/matsim/core/controler/NewControlerTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/NewControlerTest.java @@ -21,8 +21,8 @@ package org.matsim.core.controler; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.groups.FacilitiesConfigGroup; @@ -33,13 +33,13 @@ import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; -public class NewControlerTest { + public class NewControlerTest { @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); - @Test - public void testInjectionBeforeControler() { + @Test + void testInjectionBeforeControler() { Config config = testUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); // a scenario is created and none of the files are loaded; diff --git a/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java b/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java index 9f9e788218e..76d790ebe04 100644 --- a/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java @@ -19,8 +19,8 @@ package org.matsim.core.controler; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.utils.io.IOUtils; import org.matsim.testcases.MatsimTestUtils; @@ -38,7 +38,7 @@ public class OutputDirectoryHierarchyTest { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testFailureIfDirectoryExists() { + void testFailureIfDirectoryExists() { final String outputDirectory = utils.getOutputDirectory(); IOUtils.deleteDirectoryRecursively(new File( outputDirectory ).toPath()); @@ -74,7 +74,7 @@ public void testFailureIfDirectoryExists() { } @Test - public void testOverrideIfDirectoryExists() { + void testOverrideIfDirectoryExists() { final String outputDirectory = utils.getOutputDirectory(); IOUtils.deleteDirectoryRecursively(new File( outputDirectory ).toPath()); @@ -109,7 +109,7 @@ public void testOverrideIfDirectoryExists() { } @Test - public void testDeleteIfDirectoryExists() { + void testDeleteIfDirectoryExists() { final String outputDirectory = utils.getOutputDirectory(); IOUtils.deleteDirectoryRecursively(new File( outputDirectory ).toPath()); diff --git a/matsim/src/test/java/org/matsim/core/controler/PrepareForSimImplTest.java b/matsim/src/test/java/org/matsim/core/controler/PrepareForSimImplTest.java index d711ebceaaa..582276839b3 100644 --- a/matsim/src/test/java/org/matsim/core/controler/PrepareForSimImplTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/PrepareForSimImplTest.java @@ -22,7 +22,7 @@ import java.util.*; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -72,7 +72,7 @@ public class PrepareForSimImplTest { @Test - public void testSingleLegTripRoutingMode() { + void testSingleLegTripRoutingMode() { Config config = ConfigUtils.createConfig(); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); Scenario scenario = ScenarioUtils.createScenario(config); @@ -135,7 +135,7 @@ public void testSingleLegTripRoutingMode() { } @Test - public void testSingleFallbackModeLegTrip() { + void testSingleFallbackModeLegTrip() { Config config = ConfigUtils.createConfig(); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); Scenario scenario = ScenarioUtils.createScenario(config); @@ -200,7 +200,7 @@ public void testSingleFallbackModeLegTrip() { } @Test - public void testCorrectTripsRemainUnchanged() { + void testCorrectTripsRemainUnchanged() { Config config = ConfigUtils.createConfig(); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); Scenario scenario = ScenarioUtils.createScenario(config); @@ -366,7 +366,7 @@ public void testCorrectTripsRemainUnchanged() { } @Test - public void testRoutingModeConsistency() { + void testRoutingModeConsistency() { Config config = ConfigUtils.createConfig(); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); Scenario scenario = ScenarioUtils.createScenario(config); @@ -449,7 +449,7 @@ public void testRoutingModeConsistency() { } @Test - public void testOutdatedHelperModesReplacement() { + void testOutdatedHelperModesReplacement() { Config config = ConfigUtils.createConfig(); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.reject); @@ -672,7 +672,7 @@ public void testOutdatedHelperModesReplacement() { } @Test - public void testOutdatedFallbackAndHelperModesReplacement() { + void testOutdatedFallbackAndHelperModesReplacement() { Config config = ConfigUtils.createConfig(); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.reject); @@ -763,7 +763,7 @@ public void testOutdatedFallbackAndHelperModesReplacement() { } @Test - public void vehicleTypes() { + void vehicleTypes() { Config config = ConfigUtils.createConfig(); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); diff --git a/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java b/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java index 6bfbc27f763..cd9a12401fe 100644 --- a/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java @@ -3,8 +3,8 @@ import java.io.File; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.PersonDepartureEvent; import org.matsim.api.core.v01.events.handler.PersonDepartureEventHandler; @@ -34,7 +34,7 @@ public class TerminationTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testSimulationEndsOnInterval() { + void testSimulationEndsOnInterval() { prepareExperiment(2, 4, ControllerConfigGroup.CleanIterations.keep).run(); Assert.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.4/4.events.xml.gz").exists()); @@ -46,7 +46,7 @@ public void testSimulationEndsOnInterval() { } @Test - public void testOnlyRunIterationZero() { + void testOnlyRunIterationZero() { prepareExperiment(2, 0, ControllerConfigGroup.CleanIterations.keep).run(); Assert.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.0/0.events.xml.gz").exists()); @@ -58,7 +58,7 @@ public void testOnlyRunIterationZero() { } @Test - public void testSimulationEndsOffInterval() { + void testSimulationEndsOffInterval() { // This is the case when the TerminationCriterion decides that the simulation is // done, but it does not fall at the same time as the output interval. @@ -74,7 +74,7 @@ public void testSimulationEndsOffInterval() { } @Test - public void testSimulationEndDeleteIters() { + void testSimulationEndDeleteIters() { prepareExperiment(2, 3, ControllerConfigGroup.CleanIterations.delete).run(); Assert.assertFalse(new File(utils.getOutputDirectory(), "/ITERS").exists()); } @@ -91,7 +91,7 @@ private Controler prepareExperiment(int interval, int criterion, ControllerConfi } @Test - public void testMultipleLastIterations() { + void testMultipleLastIterations() { /** * This test covers the case where the termination criterion decides that the * coming iteration may be the last, but then, after analysis and after the data @@ -125,7 +125,7 @@ public boolean doTerminate(int iteration) { } @Test - public void testCustomConverenceCriterion() { + void testCustomConverenceCriterion() { /** * In this test, we set all legs to walk and let agents change them to car. We * stop the simulation once there are more car legs than walk legs. diff --git a/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java b/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java index b02ba76fbe4..c2be0f5b584 100644 --- a/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java @@ -25,8 +25,8 @@ import java.util.ArrayList; import java.util.Collections; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -65,7 +65,8 @@ public class TransitControlerIntegrationTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testTransitRouteCopy() { + @Test + void testTransitRouteCopy() { Config config = utils.loadConfig((String)null); config.transit().setUseTransit(true); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/controler/corelisteners/ListenersInjectionTest.java b/matsim/src/test/java/org/matsim/core/controler/corelisteners/ListenersInjectionTest.java index 300296fbc27..bf569a37ec6 100644 --- a/matsim/src/test/java/org/matsim/core/controler/corelisteners/ListenersInjectionTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/corelisteners/ListenersInjectionTest.java @@ -20,8 +20,8 @@ package org.matsim.core.controler.corelisteners; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.analysis.IterationStopWatch; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -46,27 +46,27 @@ public class ListenersInjectionTest { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testDumpDataAtEndIsSingleton() { + void testDumpDataAtEndIsSingleton() { testIsSingleton( DumpDataAtEnd.class ); } @Test - public void testEvensHandlingIsSingleton() { + void testEvensHandlingIsSingleton() { testIsSingleton( EventsHandling.class ); } @Test - public void testPlansDumpingIsSingleton() { + void testPlansDumpingIsSingleton() { testIsSingleton( PlansDumping.class ); } @Test - public void testPlansReplanningIsSingleton() { + void testPlansReplanningIsSingleton() { testIsSingleton( PlansReplanning.class ); } @Test - public void testPlansScoringIsSingleton() { + void testPlansScoringIsSingleton() { testIsSingleton( PlansScoring.class ); } diff --git a/matsim/src/test/java/org/matsim/core/controler/corelisteners/PlansDumpingIT.java b/matsim/src/test/java/org/matsim/core/controler/corelisteners/PlansDumpingIT.java index 68e67547cb2..a686c394e77 100644 --- a/matsim/src/test/java/org/matsim/core/controler/corelisteners/PlansDumpingIT.java +++ b/matsim/src/test/java/org/matsim/core/controler/corelisteners/PlansDumpingIT.java @@ -19,8 +19,8 @@ package org.matsim.core.controler.corelisteners; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.controler.Controler; import org.matsim.testcases.MatsimTestUtils; @@ -38,7 +38,7 @@ public class PlansDumpingIT { @RegisterExtension private MatsimTestUtils util = new MatsimTestUtils(); @Test - public void testPlansDump_Interval() { + void testPlansDump_Interval() { Config config = this.util.loadConfig("test/scenarios/equil/config_plans1.xml"); config.controller().setLastIteration(10); config.controller().setWritePlansInterval(3); @@ -62,7 +62,7 @@ public void testPlansDump_Interval() { } @Test - public void testPlansDump_Never() { + void testPlansDump_Never() { Config config = this.util.loadConfig("test/scenarios/equil/config_plans1.xml"); config.controller().setLastIteration(10); config.controller().setWritePlansInterval(0); @@ -86,7 +86,7 @@ public void testPlansDump_Never() { } @Test - public void testPlansDump_Always() { + void testPlansDump_Always() { Config config = this.util.loadConfig("test/scenarios/equil/config_plans1.xml"); config.controller().setLastIteration(10); config.controller().setWritePlansInterval(1); diff --git a/matsim/src/test/java/org/matsim/core/events/ActEndEventTest.java b/matsim/src/test/java/org/matsim/core/events/ActEndEventTest.java index aee383139ab..fe6e6f93cef 100644 --- a/matsim/src/test/java/org/matsim/core/events/ActEndEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/ActEndEventTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; @@ -41,7 +41,8 @@ public class ActEndEventTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteReadXml() { + @Test + void testWriteReadXml() { final ActivityEndEvent event = XmlEventsTester.testWriteReadXml(utils.getOutputDirectory() + "events.xml", new ActivityEndEvent(7893.14, Id.create("143", Person.class), Id.create("293", Link.class), Id.create("f811", ActivityFacility.class), "home", new Coord( 234., 5.67 ))); diff --git a/matsim/src/test/java/org/matsim/core/events/ActStartEventTest.java b/matsim/src/test/java/org/matsim/core/events/ActStartEventTest.java index 7a57d2334e3..c0a64d343d4 100644 --- a/matsim/src/test/java/org/matsim/core/events/ActStartEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/ActStartEventTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityStartEvent; @@ -41,7 +41,8 @@ public class ActStartEventTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteReadXml() { + @Test + void testWriteReadXml() { final ActivityStartEvent event = XmlEventsTester.testWriteReadXml(utils.getOutputDirectory() + "events.xml", new ActivityStartEvent(5668.27, Id.create("a92", Person.class), Id.create("l081", Link.class), Id.create("f792", ActivityFacility.class), "work", new Coord( 234., 5.67 ) ) ); diff --git a/matsim/src/test/java/org/matsim/core/events/AgentMoneyEventTest.java b/matsim/src/test/java/org/matsim/core/events/AgentMoneyEventTest.java index 0a40dc47137..b0645c6f797 100644 --- a/matsim/src/test/java/org/matsim/core/events/AgentMoneyEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/AgentMoneyEventTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonMoneyEvent; import org.matsim.api.core.v01.population.Person; @@ -38,7 +38,8 @@ public class AgentMoneyEventTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteReadXml() { + @Test + void testWriteReadXml() { final PersonMoneyEvent event1 = new PersonMoneyEvent(25560.23, Id.create("1", Person.class), 2.71828, "tollRefund", "motorwayOperator"); final PersonMoneyEvent event2 = XmlEventsTester.testWriteReadXml(utils.getOutputDirectory() + "events.xml", event1); assertEquals(event1.getTime(), event2.getTime(), MatsimTestUtils.EPSILON); diff --git a/matsim/src/test/java/org/matsim/core/events/AgentWaitingForPtEventTest.java b/matsim/src/test/java/org/matsim/core/events/AgentWaitingForPtEventTest.java index 08e5667ce31..0bc24ebe510 100644 --- a/matsim/src/test/java/org/matsim/core/events/AgentWaitingForPtEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/AgentWaitingForPtEventTest.java @@ -20,8 +20,8 @@ package org.matsim.core.events; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.core.api.experimental.events.AgentWaitingForPtEvent; @@ -37,7 +37,7 @@ public class AgentWaitingForPtEventTest { @RegisterExtension private MatsimTestUtils helper = new MatsimTestUtils(); @Test - public void testReadWriteXml() { + void testReadWriteXml() { Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Id waitStopId = Id.create("1980", TransitStopFacility.class); Id destinationStopId = Id.create("0511", TransitStopFacility.class); diff --git a/matsim/src/test/java/org/matsim/core/events/BasicEventsHandlerTest.java b/matsim/src/test/java/org/matsim/core/events/BasicEventsHandlerTest.java index d8c25c4eaa5..86fd56add98 100644 --- a/matsim/src/test/java/org/matsim/core/events/BasicEventsHandlerTest.java +++ b/matsim/src/test/java/org/matsim/core/events/BasicEventsHandlerTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.LinkEnterEvent; @@ -43,7 +43,8 @@ public class BasicEventsHandlerTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testLinkEnterEventHandler() { + @Test + void testLinkEnterEventHandler() { EventsManager events = EventsUtils.createEventsManager(); MyLinkEnterEventHandler handler = new MyLinkEnterEventHandler(); events.addHandler(handler); diff --git a/matsim/src/test/java/org/matsim/core/events/CustomEventTest.java b/matsim/src/test/java/org/matsim/core/events/CustomEventTest.java index 5741890da92..bee022f3d97 100644 --- a/matsim/src/test/java/org/matsim/core/events/CustomEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/CustomEventTest.java @@ -29,7 +29,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.Event; import org.matsim.api.core.v01.population.Person; @@ -70,7 +70,7 @@ public Map getAttributes() { } @Test - public void testCustomEventCanBeWrittenAndRead_XML() { + void testCustomEventCanBeWrittenAndRead_XML() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); EventsManager eventsManager1 = EventsUtils.createEventsManager(); @@ -109,7 +109,7 @@ public void reset(int iteration) { } @Test - public void testCustomEventCanBeWrittenAndRead_Json() { + void testCustomEventCanBeWrittenAndRead_Json() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); EventsManager eventsManager1 = EventsUtils.createEventsManager(); diff --git a/matsim/src/test/java/org/matsim/core/events/EventsHandlerHierarchyTest.java b/matsim/src/test/java/org/matsim/core/events/EventsHandlerHierarchyTest.java index 6c09b3bd184..7bbdfa343bc 100644 --- a/matsim/src/test/java/org/matsim/core/events/EventsHandlerHierarchyTest.java +++ b/matsim/src/test/java/org/matsim/core/events/EventsHandlerHierarchyTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.Event; import org.matsim.api.core.v01.events.LinkLeaveEvent; @@ -67,7 +67,8 @@ class B extends A {} @SuppressWarnings("unused") class C extends A implements BasicEventHandler, LinkLeaveEventHandler {} - @Test public final void testHandlerHierarchy() { + @Test + final void testHandlerHierarchy() { EventsManager events = EventsUtils.createEventsManager(); Id linkId = Id.create("1", Link.class); Id vehId = Id.create("1", Vehicle.class); @@ -83,7 +84,8 @@ class C extends A implements BasicEventHandler, LinkLeaveEventHandler {} assertEquals(this.eventHandled, 1); } - @Test public final void testHierarchicalReset() { + @Test + final void testHierarchicalReset() { EventsManager events = EventsUtils.createEventsManager(); Id linkId = Id.create("1", Link.class); Id vehId = Id.create("1", Vehicle.class); diff --git a/matsim/src/test/java/org/matsim/core/events/EventsManagerImplTest.java b/matsim/src/test/java/org/matsim/core/events/EventsManagerImplTest.java index 6746d32d64c..0ea80ab3d12 100644 --- a/matsim/src/test/java/org/matsim/core/events/EventsManagerImplTest.java +++ b/matsim/src/test/java/org/matsim/core/events/EventsManagerImplTest.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.events.Event; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.events.handler.EventHandler; @@ -38,7 +38,7 @@ public class EventsManagerImplTest { * @author mrieser */ @Test - public void testProcessEvent_CustomEventHandler() { + void testProcessEvent_CustomEventHandler() { EventsManager manager = EventsUtils.createEventsManager(); CountingMyEventHandler handler = new CountingMyEventHandler(); manager.addHandler(handler); @@ -52,7 +52,7 @@ public void testProcessEvent_CustomEventHandler() { * @author mrieser */ @Test - public void testProcessEvent_ExceptionInEventHandler() { + void testProcessEvent_ExceptionInEventHandler() { EventsManager manager = EventsUtils.createEventsManager(); CrashingMyEventHandler handler = new CrashingMyEventHandler(); manager.addHandler(handler); diff --git a/matsim/src/test/java/org/matsim/core/events/EventsReadersTest.java b/matsim/src/test/java/org/matsim/core/events/EventsReadersTest.java index 24f43377b2d..ca1a804be6d 100644 --- a/matsim/src/test/java/org/matsim/core/events/EventsReadersTest.java +++ b/matsim/src/test/java/org/matsim/core/events/EventsReadersTest.java @@ -26,8 +26,8 @@ import javax.xml.parsers.ParserConfigurationException; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; import org.matsim.api.core.v01.events.ActivityStartEvent; @@ -143,7 +143,8 @@ public void handleEvent(final PersonStuckEvent event) { } - @Test public final void testXmlReader() throws SAXException, ParserConfigurationException, IOException { + @Test + final void testXmlReader() throws SAXException, ParserConfigurationException, IOException { EventsManager events = EventsUtils.createEventsManager(); TestHandler handler = new TestHandler(); events.addHandler(handler); @@ -154,7 +155,8 @@ public void handleEvent(final PersonStuckEvent event) { assertEquals("number of read events", 8, handler.eventCounter); } - @Test public final void testAutoFormatReaderXml() { + @Test + final void testAutoFormatReaderXml() { EventsManager events = EventsUtils.createEventsManager(); TestHandler handler = new TestHandler(); events.addHandler(handler); diff --git a/matsim/src/test/java/org/matsim/core/events/GenericEventTest.java b/matsim/src/test/java/org/matsim/core/events/GenericEventTest.java index b24edda5020..705c6e08aff 100644 --- a/matsim/src/test/java/org/matsim/core/events/GenericEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/GenericEventTest.java @@ -21,8 +21,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.events.GenericEvent; import org.matsim.testcases.MatsimTestUtils; @@ -36,7 +36,8 @@ public class GenericEventTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteReadXml() { + @Test + void testWriteReadXml() { final String TYPE = "GenericEvent"; final String KEY1 = "k1"; final String VALUE1 = "v1"; diff --git a/matsim/src/test/java/org/matsim/core/events/LinkEnterEventTest.java b/matsim/src/test/java/org/matsim/core/events/LinkEnterEventTest.java index c098d01d14a..7a400077bce 100644 --- a/matsim/src/test/java/org/matsim/core/events/LinkEnterEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/LinkEnterEventTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.LinkEnterEvent; import org.matsim.api.core.v01.network.Link; @@ -39,7 +39,8 @@ public class LinkEnterEventTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteReadXml() { + @Test + void testWriteReadXml() { final LinkEnterEvent event1 = new LinkEnterEvent(6823.8, Id.create("veh", Vehicle.class), Id.create("abcd", Link.class)); final LinkEnterEvent event2 = XmlEventsTester.testWriteReadXml(utils.getOutputDirectory() + "events.xml", event1); diff --git a/matsim/src/test/java/org/matsim/core/events/LinkLeaveEventTest.java b/matsim/src/test/java/org/matsim/core/events/LinkLeaveEventTest.java index 10c7c168aee..7a9f373ed82 100644 --- a/matsim/src/test/java/org/matsim/core/events/LinkLeaveEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/LinkLeaveEventTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.LinkLeaveEvent; import org.matsim.api.core.v01.network.Link; @@ -39,7 +39,8 @@ public class LinkLeaveEventTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteReadXml() { + @Test + void testWriteReadXml() { final LinkLeaveEvent event1 = new LinkLeaveEvent(68423.98, Id.create("veh", Vehicle.class), Id.create(".235", Link.class)); final LinkLeaveEvent event2 = XmlEventsTester.testWriteReadXml(utils.getOutputDirectory() + "events.xml", event1); diff --git a/matsim/src/test/java/org/matsim/core/events/MobsimScopeEventHandlingTest.java b/matsim/src/test/java/org/matsim/core/events/MobsimScopeEventHandlingTest.java index b20e06fcec8..6767ab3394d 100644 --- a/matsim/src/test/java/org/matsim/core/events/MobsimScopeEventHandlingTest.java +++ b/matsim/src/test/java/org/matsim/core/events/MobsimScopeEventHandlingTest.java @@ -22,7 +22,7 @@ import static org.mockito.Mockito.*; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.controler.events.AfterMobsimEvent; @@ -35,14 +35,14 @@ public class MobsimScopeEventHandlingTest { private final MobsimScopeEventHandler handler = mock(MobsimScopeEventHandler.class); @Test - public void test_addMobsimScopeHandler() { + void test_addMobsimScopeHandler() { eventHandling.addMobsimScopeHandler(handler); verify(eventsManager, times(1)).addHandler(argThat(arg -> arg == handler)); } @Test - public void test_notifyAfterMobsim_oneHandler() { + void test_notifyAfterMobsim_oneHandler() { eventHandling.addMobsimScopeHandler(handler); eventHandling.notifyAfterMobsim(new AfterMobsimEvent(null, 99, false)); @@ -51,7 +51,7 @@ public void test_notifyAfterMobsim_oneHandler() { } @Test - public void test_notifyAfterMobsim_noHandlersAfterRemoval() { + void test_notifyAfterMobsim_noHandlersAfterRemoval() { eventHandling.addMobsimScopeHandler(handler); eventHandling.notifyAfterMobsim(new AfterMobsimEvent(null, 99, false)); diff --git a/matsim/src/test/java/org/matsim/core/events/ParallelEventsManagerTest.java b/matsim/src/test/java/org/matsim/core/events/ParallelEventsManagerTest.java index db33e1b7b58..373075691ec 100644 --- a/matsim/src/test/java/org/matsim/core/events/ParallelEventsManagerTest.java +++ b/matsim/src/test/java/org/matsim/core/events/ParallelEventsManagerTest.java @@ -1,7 +1,7 @@ package org.matsim.core.events; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.events.Event; import org.matsim.core.api.experimental.events.EventsManager; @@ -19,8 +19,8 @@ public void setUp() throws Exception { handler = new EventsManagerImplTest.CountingMyEventHandler(); } - @Test - public void forgetInit() { + @Test + void forgetInit() { EventsManager m = EventsUtils.createParallelEventsManager(); @@ -36,8 +36,8 @@ public void forgetInit() { assertEquals(1, handler.counter); } - @Test - public void lateHandler() { + @Test + void lateHandler() { EventsManager m = EventsUtils.createParallelEventsManager(); m.initProcessing(); diff --git a/matsim/src/test/java/org/matsim/core/events/PersonArrivalEventTest.java b/matsim/src/test/java/org/matsim/core/events/PersonArrivalEventTest.java index b5a2e03edca..60110acc6ce 100644 --- a/matsim/src/test/java/org/matsim/core/events/PersonArrivalEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/PersonArrivalEventTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.events.PersonArrivalEvent; @@ -40,7 +40,8 @@ public class PersonArrivalEventTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteReadXml() { + @Test + void testWriteReadXml() { final PersonArrivalEvent event = XmlEventsTester.testWriteReadXml(utils.getOutputDirectory() + "events.xml", new PersonArrivalEvent(68423.98, Id.create("443", Person.class), Id.create("78-3", Link.class), TransportMode.bike)); assertEquals(68423.98, event.getTime(), MatsimTestUtils.EPSILON); diff --git a/matsim/src/test/java/org/matsim/core/events/PersonDepartureEventTest.java b/matsim/src/test/java/org/matsim/core/events/PersonDepartureEventTest.java index 7f42ea5a472..f1372da2f07 100644 --- a/matsim/src/test/java/org/matsim/core/events/PersonDepartureEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/PersonDepartureEventTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.events.PersonDepartureEvent; @@ -40,7 +40,8 @@ public class PersonDepartureEventTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteReadXml() { + @Test + void testWriteReadXml() { final PersonDepartureEvent event = XmlEventsTester.testWriteReadXml(utils.getOutputDirectory() + "events.xml", new PersonDepartureEvent(25669.05, Id.create("921", Person.class), Id.create("390", Link.class), TransportMode.bike, "bikeRoutingMode")); assertEquals(25669.05, event.getTime(), MatsimTestUtils.EPSILON); diff --git a/matsim/src/test/java/org/matsim/core/events/PersonEntersVehicleEventTest.java b/matsim/src/test/java/org/matsim/core/events/PersonEntersVehicleEventTest.java index bb554d35908..849a0f7878e 100644 --- a/matsim/src/test/java/org/matsim/core/events/PersonEntersVehicleEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/PersonEntersVehicleEventTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonEntersVehicleEvent; import org.matsim.api.core.v01.population.Person; @@ -42,7 +42,8 @@ public class PersonEntersVehicleEventTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testReadWriteXml() { + @Test + void testReadWriteXml() { Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("testVehType", VehicleType.class ) ); Vehicle vehicle = VehicleUtils.createVehicle(Id.create(80, Vehicle.class ), vehicleType ); diff --git a/matsim/src/test/java/org/matsim/core/events/PersonLeavesVehicleEventTest.java b/matsim/src/test/java/org/matsim/core/events/PersonLeavesVehicleEventTest.java index bd0c7ac42c6..867624642ad 100644 --- a/matsim/src/test/java/org/matsim/core/events/PersonLeavesVehicleEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/PersonLeavesVehicleEventTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonLeavesVehicleEvent; import org.matsim.api.core.v01.population.Person; @@ -42,7 +42,8 @@ public class PersonLeavesVehicleEventTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteReadXml() { + @Test + void testWriteReadXml() { Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("testVehType", VehicleType.class ) ); Vehicle vehicle = VehicleUtils.createVehicle(Id.create(80, Vehicle.class ), vehicleType ); diff --git a/matsim/src/test/java/org/matsim/core/events/PersonStuckEventTest.java b/matsim/src/test/java/org/matsim/core/events/PersonStuckEventTest.java index 090c2512aa5..b17e124d471 100644 --- a/matsim/src/test/java/org/matsim/core/events/PersonStuckEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/PersonStuckEventTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.events.PersonStuckEvent; @@ -40,7 +40,8 @@ public class PersonStuckEventTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteReadXml() { + @Test + void testWriteReadXml() { final PersonStuckEvent event1 = new PersonStuckEvent(81153.3, Id.create("a007", Person.class), Id.create("link1", Link.class), TransportMode.walk); final PersonStuckEvent event2 = XmlEventsTester.testWriteReadXml(utils.getOutputDirectory() + "events.xml", event1); assertEquals(event1.getTime(), event2.getTime(), MatsimTestUtils.EPSILON); @@ -49,7 +50,8 @@ public class PersonStuckEventTest { assertEquals(event1.getLegMode(), event2.getLegMode()); } - @Test public void testWriteReadXmlWithLinkIdNull() { + @Test + void testWriteReadXmlWithLinkIdNull() { final PersonStuckEvent event1 = new PersonStuckEvent(81153.3, Id.create("a007", Person.class), null, TransportMode.walk); final PersonStuckEvent event2 = XmlEventsTester.testWriteReadXml(utils.getOutputDirectory() + "events.xml", event1); assertEquals(event1.getTime(), event2.getTime(), MatsimTestUtils.EPSILON); diff --git a/matsim/src/test/java/org/matsim/core/events/SimStepParallelEventsManagerImplTest.java b/matsim/src/test/java/org/matsim/core/events/SimStepParallelEventsManagerImplTest.java index 39c8280f4cf..894bc9661b1 100644 --- a/matsim/src/test/java/org/matsim/core/events/SimStepParallelEventsManagerImplTest.java +++ b/matsim/src/test/java/org/matsim/core/events/SimStepParallelEventsManagerImplTest.java @@ -22,7 +22,7 @@ package org.matsim.core.events; import org.assertj.core.api.Assertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.LinkEnterEvent; import org.matsim.api.core.v01.events.LinkLeaveEvent; @@ -30,10 +30,10 @@ import org.matsim.api.core.v01.events.handler.LinkEnterEventHandler; import org.matsim.testcases.utils.EventsCollector; -public class SimStepParallelEventsManagerImplTest { + public class SimStepParallelEventsManagerImplTest { - @Test - public void testEventHandlerCanProduceAdditionalEventLateInSimStep() { + @Test + void testEventHandlerCanProduceAdditionalEventLateInSimStep() { final SimStepParallelEventsManagerImpl events = new SimStepParallelEventsManagerImpl(8); events.addHandler(new LinkEnterEventHandler() { @Override diff --git a/matsim/src/test/java/org/matsim/core/events/TransitDriverStartsEventTest.java b/matsim/src/test/java/org/matsim/core/events/TransitDriverStartsEventTest.java index 4f9076d4f51..37d6156086e 100644 --- a/matsim/src/test/java/org/matsim/core/events/TransitDriverStartsEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/TransitDriverStartsEventTest.java @@ -20,8 +20,8 @@ package org.matsim.core.events; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.TransitDriverStartsEvent; import org.matsim.api.core.v01.population.Person; @@ -39,7 +39,7 @@ public class TransitDriverStartsEventTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testWriteReadXml() { + void testWriteReadXml() { final TransitDriverStartsEvent event1 = new TransitDriverStartsEvent(36095.2, Id.create("ptDrvr-1", Person.class), Id.create("vehicle-bus5", Vehicle.class), diff --git a/matsim/src/test/java/org/matsim/core/events/VehicleAbortsEventTest.java b/matsim/src/test/java/org/matsim/core/events/VehicleAbortsEventTest.java index 274cb9b762a..15d82589b79 100644 --- a/matsim/src/test/java/org/matsim/core/events/VehicleAbortsEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/VehicleAbortsEventTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.VehicleAbortsEvent; import org.matsim.api.core.v01.network.Link; @@ -39,7 +39,8 @@ public class VehicleAbortsEventTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteReadXml() { + @Test + void testWriteReadXml() { final VehicleAbortsEvent event1 = new VehicleAbortsEvent(81153.3, Id.create("a007", Vehicle.class), Id.create("link1", Link.class)); final VehicleAbortsEvent event2 = XmlEventsTester.testWriteReadXml(utils.getOutputDirectory() + "events.xml", event1); assertEquals(event1.getTime(), event2.getTime(), MatsimTestUtils.EPSILON); diff --git a/matsim/src/test/java/org/matsim/core/events/VehicleArrivesAtFacilityEventImplTest.java b/matsim/src/test/java/org/matsim/core/events/VehicleArrivesAtFacilityEventImplTest.java index 05929edf7e8..26d0fa561f8 100644 --- a/matsim/src/test/java/org/matsim/core/events/VehicleArrivesAtFacilityEventImplTest.java +++ b/matsim/src/test/java/org/matsim/core/events/VehicleArrivesAtFacilityEventImplTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent; import org.matsim.core.utils.misc.Time; @@ -37,7 +37,8 @@ public class VehicleArrivesAtFacilityEventImplTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteReadXml() { + @Test + void testWriteReadXml() { VehicleArrivesAtFacilityEvent event = new VehicleArrivesAtFacilityEvent(Time.parseTime("10:55:00"), Id.create(5, Vehicle.class), Id.create(11, TransitStopFacility.class), diff --git a/matsim/src/test/java/org/matsim/core/events/VehicleDepartsAtFacilityEventImplTest.java b/matsim/src/test/java/org/matsim/core/events/VehicleDepartsAtFacilityEventImplTest.java index 99b3396177a..11e414b40f2 100644 --- a/matsim/src/test/java/org/matsim/core/events/VehicleDepartsAtFacilityEventImplTest.java +++ b/matsim/src/test/java/org/matsim/core/events/VehicleDepartsAtFacilityEventImplTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.core.api.experimental.events.VehicleDepartsAtFacilityEvent; import org.matsim.core.utils.misc.Time; @@ -37,7 +37,8 @@ public class VehicleDepartsAtFacilityEventImplTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteReadXml() { + @Test + void testWriteReadXml() { VehicleDepartsAtFacilityEvent event = new VehicleDepartsAtFacilityEvent(Time.parseTime("10:55:00"), Id.create(5, Vehicle.class), Id.create(11, TransitStopFacility.class), -1.2); VehicleDepartsAtFacilityEvent event2 = XmlEventsTester.testWriteReadXml(utils.getOutputDirectory() + "events.xml", event); assertEquals(Time.parseTime("10:55:00"), event2.getTime(), MatsimTestUtils.EPSILON); diff --git a/matsim/src/test/java/org/matsim/core/events/VehicleEntersTrafficEventTest.java b/matsim/src/test/java/org/matsim/core/events/VehicleEntersTrafficEventTest.java index 45f4676e80b..af9686b35bc 100644 --- a/matsim/src/test/java/org/matsim/core/events/VehicleEntersTrafficEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/VehicleEntersTrafficEventTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.events.VehicleEntersTrafficEvent; @@ -41,7 +41,8 @@ public class VehicleEntersTrafficEventTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteReadXml() { + @Test + void testWriteReadXml() { final VehicleEntersTrafficEvent event1 = new VehicleEntersTrafficEvent(8463.7301, Id.create("483", Person.class), Id.create("783", Link.class), Id.create("veh7", Vehicle.class), TransportMode.car, 1.0); final VehicleEntersTrafficEvent event2 = XmlEventsTester.testWriteReadXml(utils.getOutputDirectory() + "events.xml", event1); diff --git a/matsim/src/test/java/org/matsim/core/events/VehicleLeavesTrafficEventTest.java b/matsim/src/test/java/org/matsim/core/events/VehicleLeavesTrafficEventTest.java index 241e0b9f382..7428df475b5 100644 --- a/matsim/src/test/java/org/matsim/core/events/VehicleLeavesTrafficEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/VehicleLeavesTrafficEventTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.events.VehicleLeavesTrafficEvent; @@ -41,7 +41,8 @@ public class VehicleLeavesTrafficEventTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteReadXml() { + @Test + void testWriteReadXml() { final VehicleLeavesTrafficEvent event1 = new VehicleLeavesTrafficEvent(8463.7301, Id.create("483", Person.class), Id.create("783", Link.class), Id.create("veh7", Vehicle.class), TransportMode.car,1.0); final VehicleLeavesTrafficEvent event2 = XmlEventsTester.testWriteReadXml(utils.getOutputDirectory() + "events.xml", event1); diff --git a/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterJsonTest.java b/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterJsonTest.java index 9756af4c134..60a4cc3c49a 100644 --- a/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterJsonTest.java +++ b/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterJsonTest.java @@ -1,7 +1,7 @@ package org.matsim.core.events.algorithms; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.GenericEvent; import org.matsim.api.core.v01.events.LinkLeaveEvent; @@ -26,7 +26,7 @@ public class EventWriterJsonTest { * values are correctly encoded when written to a file. */ @Test - public void testSpecialCharacters() { + void testSpecialCharacters() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); EventWriterJson writer = new EventWriterJson(baos); @@ -55,7 +55,7 @@ public void testSpecialCharacters() { } @Test - public void testNullAttribute() { + void testNullAttribute() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); EventWriterJson writer = new EventWriterJson(baos); diff --git a/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterXMLTest.java b/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterXMLTest.java index a84b21baf2d..114d27637b1 100644 --- a/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterXMLTest.java +++ b/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterXMLTest.java @@ -22,8 +22,8 @@ import java.io.File; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.GenericEvent; import org.matsim.api.core.v01.events.LinkLeaveEvent; @@ -47,7 +47,7 @@ public class EventWriterXMLTest { * values are correctly encoded when written to a file. */ @Test - public void testSpecialCharacters() { + void testSpecialCharacters() { String filename = this.utils.getOutputDirectory() + "testEvents.xml"; EventWriterXML writer = new EventWriterXML(filename); @@ -76,7 +76,7 @@ public void testSpecialCharacters() { } @Test - public void testNullAttribute() { + void testNullAttribute() { String filename = this.utils.getOutputDirectory() + "testEvents.xml"; EventWriterXML writer = new EventWriterXML(filename); diff --git a/matsim/src/test/java/org/matsim/core/gbl/MatsimRandomTest.java b/matsim/src/test/java/org/matsim/core/gbl/MatsimRandomTest.java index c9e1aa8c73c..741469401ff 100644 --- a/matsim/src/test/java/org/matsim/core/gbl/MatsimRandomTest.java +++ b/matsim/src/test/java/org/matsim/core/gbl/MatsimRandomTest.java @@ -25,8 +25,8 @@ import java.util.Random; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -41,7 +41,8 @@ public class MatsimRandomTest { /** * Test that MatsimRandom returns different values. */ - @Test public void testRandomness() { + @Test + void testRandomness() { final double value1 = MatsimRandom.getRandom().nextDouble(); final double value2 = MatsimRandom.getRandom().nextDouble(); final double value3 = MatsimRandom.getRandom().nextDouble(); @@ -53,7 +54,8 @@ public class MatsimRandomTest { /** * Tests that resetting the RandomObject creates the same random numbers again. */ - @Test public void testReset() { + @Test + void testReset() { MatsimRandom.reset(); int value1 = MatsimRandom.getRandom().nextInt(); MatsimRandom.reset(); @@ -65,7 +67,8 @@ public class MatsimRandomTest { * Tests that the same number of random numbers is generated if a custom seed * is used, and that these numbers are different with different seeds. */ - @Test public void testSeedReset() { + @Test + void testSeedReset() { final long seed1 = 123L; final long seed2 = 234L; @@ -84,7 +87,8 @@ public class MatsimRandomTest { * Tests that local instances can be recreated (=are deterministic) if the * same random seed is used to generate them. */ - @Test public void testLocalInstances_deterministic() { + @Test + void testLocalInstances_deterministic() { MatsimRandom.reset(); Random local1a = MatsimRandom.getLocalInstance(); Random local1b = MatsimRandom.getLocalInstance(); @@ -101,7 +105,8 @@ public class MatsimRandomTest { * Tests that multiple local instance return different random numbers, * and that they are more or less evenly distributed. */ - @Test public void testLocalInstances_distribution() { + @Test + void testLocalInstances_distribution() { MatsimRandom.reset(123L); Random local1a = MatsimRandom.getLocalInstance(); double value1 = local1a.nextDouble(); diff --git a/matsim/src/test/java/org/matsim/core/gbl/MatsimResourceTest.java b/matsim/src/test/java/org/matsim/core/gbl/MatsimResourceTest.java index 40394904b1f..a47adfa7e6c 100644 --- a/matsim/src/test/java/org/matsim/core/gbl/MatsimResourceTest.java +++ b/matsim/src/test/java/org/matsim/core/gbl/MatsimResourceTest.java @@ -24,8 +24,8 @@ import java.awt.Image; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -37,7 +37,8 @@ public class MatsimResourceTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public final void testGetAsImage() { + @Test + final void testGetAsImage() { final Image logo = MatsimResource.getAsImage("matsim_logo_transparent.png"); // verify that the correct image was correctly loaded by testing its dimension diff --git a/matsim/src/test/java/org/matsim/core/mobsim/AbstractMobsimModuleTest.java b/matsim/src/test/java/org/matsim/core/mobsim/AbstractMobsimModuleTest.java index af4f89cf383..9675beba522 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/AbstractMobsimModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/AbstractMobsimModuleTest.java @@ -24,7 +24,7 @@ import java.util.Collections; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.mobsim.framework.AbstractMobsimModule; @@ -32,9 +32,9 @@ import com.google.inject.Guice; import com.google.inject.Injector; -public class AbstractMobsimModuleTest { - @Test - public void testOverrides() { + public class AbstractMobsimModuleTest { + @Test + void testOverrides() { AbstractMobsimModule moduleA = new AbstractMobsimModule() { @Override protected void configureMobsim() { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/AgentTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/AgentTest.java index e360f31ec6e..2a571c61146 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/AgentTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/AgentTest.java @@ -19,14 +19,14 @@ package org.matsim.core.mobsim.hermes; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.locationtech.jts.util.Assert; import static org.junit.Assert.assertEquals; public class AgentTest { @Test - public void prepareLinkEntry() { + void prepareLinkEntry() { for (int eventid = 1; eventid < HermesConfigGroup.MAX_EVENTS_AGENT; eventid *= 8) { for (int lid = 1; lid < HermesConfigGroup.MAX_LINK_ID; lid *= 8) { for (int j = 0; j < 255; j++) { @@ -49,55 +49,55 @@ public void prepareLinkEntry() { } @Test - public void fastSpeedIsEncodedByAdding90() { + void fastSpeedIsEncodedByAdding90() { int encoded = Agent.prepareVelocityForLinkEntry(15); assertEquals(15 + 90, encoded); } @Test - public void fastSpeedIsDecodedBySubtracting90() { + void fastSpeedIsDecodedBySubtracting90() { double decoded = Agent.decodeVelocityFromLinkEntry(15 + 90); assertEquals(15.0, decoded, 0.0); } @Test - public void encodingFastDecimalPointSpeedRoundsDownToNearestInteger() { + void encodingFastDecimalPointSpeedRoundsDownToNearestInteger() { int encoded = Agent.prepareVelocityForLinkEntry(15.3); assertEquals(15 + 90, encoded); } @Test - public void encodingFastDecimalPointSpeedRoundsUpToNearestInteger() { + void encodingFastDecimalPointSpeedRoundsUpToNearestInteger() { int encoded = Agent.prepareVelocityForLinkEntry(15.6); assertEquals(16 + 90, encoded); } @Test - public void slowSpeedIsEncodedByMultiplyingBy10() { + void slowSpeedIsEncodedByMultiplyingBy10() { int encoded = Agent.prepareVelocityForLinkEntry(4.6); assertEquals(46, encoded); } @Test - public void slowSpeedIsDecodedByDividingBy10() { + void slowSpeedIsDecodedByDividingBy10() { double decoded = Agent.decodeVelocityFromLinkEntry(46); assertEquals(4.6, decoded, 0.0); } @Test - public void encodingSlowDecimalPointSpeedRoundsDown() { + void encodingSlowDecimalPointSpeedRoundsDown() { int encoded = Agent.prepareVelocityForLinkEntry(5.33); assertEquals(53, encoded); } @Test - public void encodingSlowDecimalPointSpeedRoundsUp() { + void encodingSlowDecimalPointSpeedRoundsUp() { int encoded = Agent.prepareVelocityForLinkEntry(5.66); assertEquals(57, encoded); } @Test - public void fastSpeedIsIntegerWithFlatPlan() { + void fastSpeedIsIntegerWithFlatPlan() { int eventId = 0; int linkId = 0; double velocity = 15.2; @@ -108,7 +108,7 @@ public void fastSpeedIsIntegerWithFlatPlan() { } @Test - public void smallSpeedHasOneDecimalPointAccuracyWithFlatPlan() { + void smallSpeedHasOneDecimalPointAccuracyWithFlatPlan() { int eventId = 0; int linkId = 0; double velocity = 3.43; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/FlowCapacityTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/FlowCapacityTest.java index 1cdf91d61d0..83a4f62d0d4 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/FlowCapacityTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/FlowCapacityTest.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.analysis.VolumesAnalyzer; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -63,7 +63,7 @@ public void setup() { * @author mrieser */ @Test - public void testFlowCapacityDriving() { + void testFlowCapacityDriving() { Fixture f = new Fixture(); // add a lot of persons with legs from link1 to link3, starting at 6:30 @@ -133,7 +133,7 @@ public void testFlowCapacityDriving() { */ @Test - public void testFlowCapacityDrivingFlowCapacityFactors() { + void testFlowCapacityDrivingFlowCapacityFactors() { Fixture f = new Fixture(); // add a lot of persons with legs from link1 to link3, starting at 6:30 for (int i = 1; i <= 1200; i++) { @@ -190,7 +190,7 @@ public void testFlowCapacityDrivingFlowCapacityFactors() { */ @Test - public void testFlowCapacityDrivingFlowEfficiencyFactors() { + void testFlowCapacityDrivingFlowEfficiencyFactors() { Fixture f = new Fixture(); ScenarioImporter.flush(); @@ -255,7 +255,7 @@ public void testFlowCapacityDrivingFlowEfficiencyFactors() { */ @Test - public void testFlowCapacityDrivingFlowEfficiencyFactorsWithDownscaling() { + void testFlowCapacityDrivingFlowEfficiencyFactorsWithDownscaling() { Fixture f = new Fixture(); ScenarioImporter.flush(); @@ -319,7 +319,7 @@ public void testFlowCapacityDrivingFlowEfficiencyFactorsWithDownscaling() { */ @Test - public void testFlowCapacityEfficiencyFactorWithLowValueAndDownscaling() { + void testFlowCapacityEfficiencyFactorWithLowValueAndDownscaling() { Fixture f = new Fixture(); ScenarioImporter.flush(); @@ -384,7 +384,7 @@ public void testFlowCapacityEfficiencyFactorWithLowValueAndDownscaling() { * @author michaz */ @Test - public void testFlowCapacityDrivingFraction() { + void testFlowCapacityDrivingFraction() { Fixture f = new Fixture(); ScenarioImporter.flush(); f.link2.setCapacity(900.0); // One vehicle every 4 seconds diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesRoundaboutTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesRoundaboutTest.java index e8dcd098d1b..14af770067d 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesRoundaboutTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesRoundaboutTest.java @@ -20,8 +20,9 @@ import java.util.List; import java.util.Map; + +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.locationtech.jts.util.Assert; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -65,7 +66,7 @@ public class HermesRoundaboutTest { @Test - public void testRoundaboutBehavior(){ + void testRoundaboutBehavior(){ ScenarioImporter.flush(); final Config config = createConfig(); config.controller().setMobsim("hermes"); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTest.java index bc9ebc23292..69fc3bfbd3e 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTest.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -116,7 +116,7 @@ public void prepareTest() { * @author mrieser */ @Test - public void testSingleAgent() { + void testSingleAgent() { Fixture f = new Fixture(); // add a single person with leg from link1 to link3 @@ -156,7 +156,7 @@ public void testSingleAgent() { * @author Kai Nagel */ @Test - public void testSingleAgentWithEndOnLeg() { + void testSingleAgentWithEndOnLeg() { Fixture f = new Fixture(); // add a single person with leg from link1 to link3 @@ -202,7 +202,7 @@ public void testSingleAgentWithEndOnLeg() { * @author mrieser */ @Test - public void testTwoAgent() { + void testTwoAgent() { Fixture f = new Fixture(); // add two persons with leg from link1 to link3, the first starting at 6am, the second at 7am @@ -243,7 +243,7 @@ public void testTwoAgent() { * @author mrieser */ @Test - public void testTeleportationSingleAgent() { + void testTeleportationSingleAgent() { Fixture f = new Fixture(); // add a single person with leg from link1 to link3 @@ -290,7 +290,7 @@ public void testTeleportationSingleAgent() { * @author cdobler */ @Test - public void testSingleAgentImmediateDeparture() { + void testSingleAgentImmediateDeparture() { Fixture f = new Fixture(); // add a single person with leg from link1 to link3 @@ -335,7 +335,7 @@ public void testSingleAgentImmediateDeparture() { * @author mrieser */ @Test - public void testSingleAgent_EmptyRoute() { + void testSingleAgent_EmptyRoute() { Fixture f = new Fixture(); // add a single person with leg from link1 to link1 @@ -408,7 +408,7 @@ public void testSingleAgent_EmptyRoute() { * @author mrieser */ @Test - public void testSingleAgent_LastLinkIsLoop() { + void testSingleAgent_LastLinkIsLoop() { Fixture f = new Fixture(); Link loopLink = NetworkUtils.createAndAddLink(f.network,Id.create("loop", Link.class), f.node4, f.node4, 100.0, 10.0, 500, 1 ); @@ -478,7 +478,7 @@ public void reset(final int iteration) { * @author mrieser */ @Test - public void testAgentWithoutLeg() { + void testAgentWithoutLeg() { Fixture f = new Fixture(); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -505,7 +505,7 @@ public void testAgentWithoutLeg() { * @author mrieser */ @Test - public void testAgentWithoutLegWithEndtime() { + void testAgentWithoutLegWithEndtime() { Fixture f = new Fixture(); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -533,7 +533,7 @@ public void testAgentWithoutLegWithEndtime() { * @author mrieser */ @Test - public void testAgentWithLastActWithEndtime() { + void testAgentWithLastActWithEndtime() { Fixture f = new Fixture(); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -567,7 +567,7 @@ public void testAgentWithLastActWithEndtime() { * @author mrieser */ @Test - public void testVehicleTeleportationTrue() { + void testVehicleTeleportationTrue() { Fixture f = new Fixture(); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan plan = PersonUtils.createAndAddPlan(person, true); @@ -621,7 +621,7 @@ public void testVehicleTeleportationTrue() { * @author mrieser */ @Test - public void testCircleAsRoute() { + void testCircleAsRoute() { Fixture f = new Fixture(); Link link4 = NetworkUtils.createAndAddLink(f.network,Id.create(4, Link.class), f.node4, f.node1, 1000.0, 100.0, 6000, 1.0 ); // close the network @@ -683,7 +683,7 @@ public void testCircleAsRoute() { * @author mrieser */ @Test - public void testRouteWithEndLinkTwice() { + void testRouteWithEndLinkTwice() { Fixture f = new Fixture(); Link link4 = NetworkUtils.createAndAddLink(f.network,Id.create(4, Link.class), f.node4, f.node1, 1000.0, 100.0, 6000, 1.0 ); // close the network @@ -801,7 +801,7 @@ private LogCounter runConsistentRoutesTestSim(final String startLinkId, final St } @Test - public void testStartAndEndTime() { + void testStartAndEndTime() { final Config config = ConfigUtils.createConfig(); @@ -857,7 +857,7 @@ public void testStartAndEndTime() { * @author mrieser */ @Test - public void testCleanupSim_EarlyEnd() { + void testCleanupSim_EarlyEnd() { MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); Config config = scenario.getConfig(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTransitTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTransitTest.java index c85f63ffcd0..332dbb4660a 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTransitTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTransitTest.java @@ -2,7 +2,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @@ -114,7 +114,7 @@ public void prepareTest() { * Makes sure Hermes works also when not all stop facilities are used by transit lines. */ @Test - public void testSuperflousStopFacilities() { + void testSuperflousStopFacilities() { Fixture f = new Fixture(); f.config.transit().setUseTransit(true); f.config.hermes().setDeterministicPt(this.isDeterministic); @@ -199,7 +199,7 @@ public void testSuperflousStopFacilities() { * Makes sure Hermes works also when transit routes in different lines have the same Id */ @Test - public void testRepeatedRouteIds() { + void testRepeatedRouteIds() { Fixture f = new Fixture(); f.config.transit().setUseTransit(true); f.config.hermes().setDeterministicPt(this.isDeterministic); @@ -301,7 +301,7 @@ public void testRepeatedRouteIds() { * Originally, this resulted in wrong events because there was an exception that there is at most one stop per link. */ @Test - public void testConsecutiveStopsWithSameLink_1() { + void testConsecutiveStopsWithSameLink_1() { Fixture f = new Fixture(); f.config.transit().setUseTransit(true); f.config.hermes().setDeterministicPt(this.isDeterministic); @@ -394,7 +394,7 @@ public void testConsecutiveStopsWithSameLink_1() { * and this 0 meters than resulted in infinite values somewhere later on. */ @Test - public void testConsecutiveStopsWithSameLink_2() { + void testConsecutiveStopsWithSameLink_2() { Fixture f = new Fixture(); f.config.transit().setUseTransit(true); f.config.hermes().setDeterministicPt(this.isDeterministic); @@ -487,7 +487,7 @@ public void testConsecutiveStopsWithSameLink_2() { * Makes sure Hermes does not produce exceptions when the configured end time is before the latest transit event */ @Test - public void testEarlyEnd() { + void testEarlyEnd() { double baseTime = 30 * 3600 - 10; // HERMES has a default of 30:00:00 as end time, so let's start later Fixture f = new Fixture(); f.config.transit().setUseTransit(true); @@ -558,7 +558,7 @@ public void testEarlyEnd() { * Makes sure Hermes correctly handles strange transit routes with some links before the first stop is served. */ @Test - public void testLinksAtRouteStart() { + void testLinksAtRouteStart() { Fixture f = new Fixture(); f.config.transit().setUseTransit(true); f.config.hermes().setDeterministicPt(this.isDeterministic); @@ -628,7 +628,7 @@ public void testLinksAtRouteStart() { * In some cases, the time information of linkEnter/linkLeave events was wrong. */ @Test - public void testDeterministicCorrectTiming() { + void testDeterministicCorrectTiming() { Fixture f = new Fixture(); f.config.transit().setUseTransit(true); f.config.hermes().setDeterministicPt(this.isDeterministic); @@ -753,7 +753,7 @@ public void testDeterministicCorrectTiming() { * Tests that event times are correct when a transit route starts with some links before arriving at the first stop. */ @Test - public void testDeterministicCorrectTiming_initialLinks() { + void testDeterministicCorrectTiming_initialLinks() { Fixture f = new Fixture(); f.config.transit().setUseTransit(true); f.config.hermes().setDeterministicPt(this.isDeterministic); @@ -872,7 +872,7 @@ public void testDeterministicCorrectTiming_initialLinks() { * Tests that everything is correct when a transit route ends with some links after arriving at the last stop. */ @Test - public void testTrailingLinksInRoute() { + void testTrailingLinksInRoute() { Fixture f = new Fixture(); f.config.transit().setUseTransit(true); f.config.hermes().setDeterministicPt(this.isDeterministic); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/StorageCapacityTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/StorageCapacityTest.java index bd3289bc276..2f331bc9f8e 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/StorageCapacityTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/StorageCapacityTest.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.Set; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -64,7 +64,7 @@ public class StorageCapacityTest { * @author jfbischoff */ @Test - public void testStorageCapacity() { + void testStorageCapacity() { ScenarioImporter.flush(); Config config = ConfigUtils.createConfig(); config.hermes().setStuckTime(Integer.MAX_VALUE); @@ -113,7 +113,7 @@ public void testStorageCapacity() { * @author jfbischoff */ @Test - public void testStorageCapacityDownscaling() { + void testStorageCapacityDownscaling() { ScenarioImporter.flush(); Config config = ConfigUtils.createConfig(); config.hermes().setStuckTime(Integer.MAX_VALUE); @@ -165,8 +165,7 @@ public void testStorageCapacityDownscaling() { * @author jfbischoff */ @Test - - public void testStorageCapacityWithDifferentPCUs() { + void testStorageCapacityWithDifferentPCUs() { ScenarioImporter.flush(); Config config = ConfigUtils.createConfig(); config.hermes().setStuckTime(Integer.MAX_VALUE); @@ -230,8 +229,7 @@ public void testStorageCapacityWithDifferentPCUs() { * @author jfbischoff */ @Test - - public void testStorageCapacityWithVaryingPCUs() { + void testStorageCapacityWithVaryingPCUs() { ScenarioImporter.flush(); Config config = ConfigUtils.createConfig(); config.routing().setNetworkModes(Set.of(TransportMode.car, TransportMode.truck)); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/TravelTimeTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/TravelTimeTest.java index b8429e4dd45..e75676a0ae5 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/TravelTimeTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/TravelTimeTest.java @@ -23,7 +23,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.LinkEnterEvent; @@ -47,7 +47,7 @@ public class TravelTimeTest { @Test - public void testEquilOneAgent() { + void testEquilOneAgent() { Map, Map, Double>> agentTravelTimes = new HashMap<>(); Config config = ConfigUtils.loadConfig("test/scenarios/equil/config.xml"); @@ -77,13 +77,13 @@ public void testEquilOneAgent() { Assert.assertEquals(358.0, travelTimes.get(Id.create(23, Link.class)).intValue(), MatsimTestUtils.EPSILON); } - @Test /** * This test shows that the Netsim always rounds up link travel times. * Please note that a computed link travel time of 400.0s is treated the same, * i.e. it is rounded up to 401s. */ - public void testEquilOneAgentTravelTimeRounding() { + @Test + void testEquilOneAgentTravelTimeRounding() { Map, Map, Double>> agentTravelTimes = new HashMap<>(); Config config = ConfigUtils.loadConfig("test/scenarios/equil/config.xml"); @@ -173,7 +173,7 @@ public void testEquilOneAgentTravelTimeRounding() { } @Test - public void testEquilTwoAgents() { + void testEquilTwoAgents() { Map, Map, Double>> agentTravelTimes = new HashMap<>(); Config config = ConfigUtils.loadConfig("test/scenarios/equil/config.xml"); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/ConfigParameterTest.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/ConfigParameterTest.java index f95aa9149da..06be879f616 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/ConfigParameterTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/ConfigParameterTest.java @@ -21,8 +21,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.testcases.MatsimTestUtils; @@ -33,7 +33,8 @@ public class ConfigParameterTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testParametersSetCorrectly() { + @Test + void testParametersSetCorrectly() { Config config = utils.loadConfig(utils.getPackageInputDirectory() + "config.xml"); JDEQSimConfigGroup jdeqSimConfigGroup = ConfigUtils.addOrGetModule(config, JDEQSimConfigGroup.NAME, JDEQSimConfigGroup.class); assertEquals(360.0, jdeqSimConfigGroup.getSimulationEndTime().seconds(), MatsimTestUtils.EPSILON); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/EmptyCarLegTest.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/EmptyCarLegTest.java index 706eaa0a34a..0fe0da3b23a 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/EmptyCarLegTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/EmptyCarLegTest.java @@ -21,9 +21,9 @@ package org.matsim.core.mobsim.jdeqsim; -import java.util.List; - -import org.junit.Test; +import java.util.List; + +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.ActivityEndEvent; import org.matsim.api.core.v01.events.ActivityStartEvent; @@ -36,12 +36,12 @@ import org.matsim.core.utils.io.IOUtils; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class EmptyCarLegTest extends AbstractJDEQSimTest { - - @Test - public void test_EmptyCarRoute() { +import static org.junit.Assert.assertTrue; + + public class EmptyCarLegTest extends AbstractJDEQSimTest { + + @Test + void test_EmptyCarRoute() { Config config = utils.loadConfig(IOUtils.extendUrl(utils.packageInputResourcePath(), "config1.xml")); MatsimRandom.reset(config.global().getRandomSeed()); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/EquilPlans1Test.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/EquilPlans1Test.java index 505cec87b6e..43157abe660 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/EquilPlans1Test.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/EquilPlans1Test.java @@ -21,9 +21,9 @@ package org.matsim.core.mobsim.jdeqsim; -import java.util.List; - -import org.junit.Test; +import java.util.List; + +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.ActivityEndEvent; import org.matsim.api.core.v01.events.ActivityStartEvent; @@ -39,12 +39,12 @@ import org.matsim.core.scenario.ScenarioUtils; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class EquilPlans1Test extends AbstractJDEQSimTest { - - @Test - public void test_EmptyCarRoute() { +import static org.junit.Assert.assertTrue; + + public class EquilPlans1Test extends AbstractJDEQSimTest { + + @Test + void test_EmptyCarRoute() { Config config = ConfigUtils.loadConfig("test/scenarios/equil/config_plans1.xml"); MatsimRandom.reset(config.global().getRandomSeed()); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/NonCarLegTest.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/NonCarLegTest.java index c5d931819a1..a9760a740ef 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/NonCarLegTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/NonCarLegTest.java @@ -21,9 +21,9 @@ package org.matsim.core.mobsim.jdeqsim; -import java.util.List; - -import org.junit.Test; +import java.util.List; + +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.ActivityEndEvent; import org.matsim.api.core.v01.events.ActivityStartEvent; @@ -35,12 +35,12 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.io.IOUtils; -import static org.junit.Assert.assertTrue; - -public class NonCarLegTest extends AbstractJDEQSimTest { - - @Test - public void test_EmptyCarRoute() { +import static org.junit.Assert.assertTrue; + + public class NonCarLegTest extends AbstractJDEQSimTest { + + @Test + void test_EmptyCarRoute() { Config config = utils.loadConfig(IOUtils.extendUrl(utils.packageInputResourcePath(), "config2.xml")); MatsimRandom.reset(config.global().getRandomSeed()); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestDESStarter_Berlin.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestDESStarter_Berlin.java index afc9477d20f..cec376de710 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestDESStarter_Berlin.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestDESStarter_Berlin.java @@ -19,22 +19,22 @@ * * * *********************************************************************** */ - package org.matsim.core.mobsim.jdeqsim; - -import org.junit.Test; + package org.matsim.core.mobsim.jdeqsim; + +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.scenario.ScenarioUtils; -import static org.junit.Assert.assertEquals; - - -public class TestDESStarter_Berlin extends AbstractJDEQSimTest { - - @Test - public void test_Berlin_TestHandlerDetailedEventChecker() { +import static org.junit.Assert.assertEquals; + + + public class TestDESStarter_Berlin extends AbstractJDEQSimTest { + + @Test + void test_Berlin_TestHandlerDetailedEventChecker() { Config config = ConfigUtils.loadConfig("test/scenarios/berlin/config.xml"); MatsimRandom.reset(config.global().getRandomSeed()); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestDESStarter_EquilPopulationPlans1Modified1.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestDESStarter_EquilPopulationPlans1Modified1.java index 510aa5add88..a1d95ea3a89 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestDESStarter_EquilPopulationPlans1Modified1.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestDESStarter_EquilPopulationPlans1Modified1.java @@ -19,9 +19,9 @@ * * * *********************************************************************** */ - package org.matsim.core.mobsim.jdeqsim; - -import org.junit.Test; + package org.matsim.core.mobsim.jdeqsim; + +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -29,12 +29,12 @@ import org.matsim.core.mobsim.jdeqsim.scenarios.EquilPopulationPlans1Modified1; import org.matsim.core.scenario.ScenarioUtils; -import static org.junit.Assert.assertEquals; - -public class TestDESStarter_EquilPopulationPlans1Modified1 extends AbstractJDEQSimTest { - - @Test - public void test_EquilPopulationPlans1Modified1_TestHandlerDetailedEventChecker() { +import static org.junit.Assert.assertEquals; + + public class TestDESStarter_EquilPopulationPlans1Modified1 extends AbstractJDEQSimTest { + + @Test + void test_EquilPopulationPlans1Modified1_TestHandlerDetailedEventChecker() { Config config = ConfigUtils.loadConfig("test/scenarios/equil/config.xml"); config.plans().setInputFile("plans1.xml"); MatsimRandom.reset(config.global().getRandomSeed()); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestDESStarter_equilPlans100.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestDESStarter_equilPlans100.java index 88e0e59a7f0..2fcb20b2bdc 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestDESStarter_equilPlans100.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestDESStarter_equilPlans100.java @@ -19,21 +19,21 @@ * * * *********************************************************************** */ - package org.matsim.core.mobsim.jdeqsim; - -import org.junit.Test; + package org.matsim.core.mobsim.jdeqsim; + +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.scenario.ScenarioUtils; -import static org.junit.Assert.assertEquals; - -public class TestDESStarter_equilPlans100 extends AbstractJDEQSimTest { - - @Test - public void test_equilPlans100_TestHandlerDetailedEventChecker() { +import static org.junit.Assert.assertEquals; + + public class TestDESStarter_equilPlans100 extends AbstractJDEQSimTest { + + @Test + void test_equilPlans100_TestHandlerDetailedEventChecker() { Config config = ConfigUtils.loadConfig("test/scenarios/equil/config.xml"); MatsimRandom.reset(config.global().getRandomSeed()); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestEventLog.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestEventLog.java index fb8231a0859..cb90b9b6390 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestEventLog.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestEventLog.java @@ -23,8 +23,8 @@ import java.util.ArrayList; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.mobsim.jdeqsim.util.CppEventFileParser; import org.matsim.testcases.MatsimTestUtils; @@ -34,12 +34,14 @@ public class TestEventLog { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testGetTravelTime(){ + @Test + void testGetTravelTime(){ ArrayList deqSimLog=CppEventFileParser.parseFile(utils.getPackageInputDirectory() + "deq_events.txt"); assertEquals(3599.0, Math.floor(EventLog.getTravelTime(deqSimLog,1)), MatsimTestUtils.EPSILON); } - @Test public void testGetAverageTravelTime(){ + @Test + void testGetAverageTravelTime(){ ArrayList deqSimLog=CppEventFileParser.parseFile(utils.getPackageInputDirectory() + "deq_events.txt"); assertEquals(EventLog.getTravelTime(deqSimLog,1), EventLog.getSumTravelTime(deqSimLog), MatsimTestUtils.EPSILON); } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestMessageFactory.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestMessageFactory.java index 0906d2c8814..23a43d3328f 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestMessageFactory.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestMessageFactory.java @@ -23,8 +23,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.core.config.ConfigUtils; @@ -33,13 +33,14 @@ import org.matsim.core.utils.timing.TimeInterpretation; import org.matsim.testcases.MatsimTestUtils; -public class TestMessageFactory { + public class TestMessageFactory { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - // check if gc turned on - @Test public void testMessageFactory1(){ + // check if gc turned on + @Test + void testMessageFactory1(){ MessageFactory.GC_ALL_MESSAGES(); JDEQSimConfigGroup.setGC_MESSAGES(true); MessageFactory.disposeEndLegMessage(new EndLegMessage(null,null, TimeInterpretation.create(ConfigUtils.createConfig()))); @@ -57,8 +58,9 @@ public class TestMessageFactory { assertEquals(0, MessageFactory.getEndLegMessageQueue().size()); } - // check when gc turned off - @Test public void testMessageFactory2(){ + // check when gc turned off + @Test + void testMessageFactory2(){ MessageFactory.GC_ALL_MESSAGES(); JDEQSimConfigGroup.setGC_MESSAGES(false); MessageFactory.disposeEndLegMessage(new EndLegMessage(null,null, TimeInterpretation.create(ConfigUtils.createConfig()))); @@ -76,8 +78,9 @@ public class TestMessageFactory { assertEquals(1, MessageFactory.getEndLegMessageQueue().size()); } - // check check use of Message factory - @Test public void testMessageFactory3(){ + // check check use of Message factory + @Test + void testMessageFactory3(){ MessageFactory.GC_ALL_MESSAGES(); JDEQSimConfigGroup.setGC_MESSAGES(false); MessageFactory.disposeEndLegMessage(new EndLegMessage(null,null, TimeInterpretation.create(ConfigUtils.createConfig()))); @@ -102,8 +105,9 @@ public class TestMessageFactory { assertEquals(0, MessageFactory.getEndLegMessageQueue().size()); } - // check initialization using constructer - @Test public void testMessageFactory5(){ + // check initialization using constructer + @Test + void testMessageFactory5(){ MessageFactory.GC_ALL_MESSAGES(); JDEQSimConfigGroup.setGC_MESSAGES(true); Scheduler scheduler=new Scheduler(new MessageQueue()); @@ -127,8 +131,9 @@ public class TestMessageFactory { assertEquals(true,MessageFactory.getDeadlockPreventionMessage(scheduler, vehicle).vehicle==vehicle); } - // check initialization using rest - @Test public void testMessageFactory6(){ + // check initialization using rest + @Test + void testMessageFactory6(){ MessageFactory.GC_ALL_MESSAGES(); JDEQSimConfigGroup.setGC_MESSAGES(false); Scheduler scheduler=new Scheduler(new MessageQueue()); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestMessageQueue.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestMessageQueue.java index 23bc2712123..def946b6c71 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestMessageQueue.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestMessageQueue.java @@ -23,18 +23,19 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.mobsim.jdeqsim.util.DummyMessage; import org.matsim.testcases.MatsimTestUtils; -public class TestMessageQueue { + public class TestMessageQueue { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testPutMessage1(){ + @Test + void testPutMessage1(){ MessageQueue mq=new MessageQueue(); Message m1=new DummyMessage(); m1.setMessageArrivalTime(1); @@ -48,7 +49,8 @@ public class TestMessageQueue { assertEquals(true, mq.getNextMessage()==m1); } - @Test public void testPutMessage2(){ + @Test + void testPutMessage2(){ MessageQueue mq=new MessageQueue(); Message m1=new DummyMessage(); m1.setMessageArrivalTime(2); @@ -62,7 +64,8 @@ public class TestMessageQueue { assertEquals(true, mq.getNextMessage()==m2); } - @Test public void testPutMessage3(){ + @Test + void testPutMessage3(){ MessageQueue mq=new MessageQueue(); Message m1=new DummyMessage(); m1.setMessageArrivalTime(2); @@ -80,7 +83,8 @@ public class TestMessageQueue { assertEquals(true, mq.getNextMessage().getMessageArrivalTime()==1); } - @Test public void testRemoveMessage1(){ + @Test + void testRemoveMessage1(){ MessageQueue mq=new MessageQueue(); Message m1=new DummyMessage(); m1.setMessageArrivalTime(1); @@ -96,7 +100,8 @@ public class TestMessageQueue { assertEquals(0, mq.getQueueSize()); } - @Test public void testRemoveMessage2(){ + @Test + void testRemoveMessage2(){ MessageQueue mq=new MessageQueue(); Message m1=new DummyMessage(); m1.setMessageArrivalTime(1); @@ -112,7 +117,8 @@ public class TestMessageQueue { assertEquals(0, mq.getQueueSize()); } - @Test public void testRemoveMessage3(){ + @Test + void testRemoveMessage3(){ MessageQueue mq=new MessageQueue(); Message m1=new DummyMessage(); m1.setMessageArrivalTime(1); @@ -130,9 +136,10 @@ public class TestMessageQueue { assertEquals(true, mq.isEmpty()); } - // a higher priority message will be at front of queue, if there are - // several messages with same time - @Test public void testMessagePriority(){ + // a higher priority message will be at front of queue, if there are + // several messages with same time + @Test + void testMessagePriority(){ MessageQueue mq=new MessageQueue(); Message m1=new DummyMessage(); m1.setMessageArrivalTime(1); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestScheduler.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestScheduler.java index a5074d8ad20..6e2f13ebe7f 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestScheduler.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/TestScheduler.java @@ -21,29 +21,29 @@ package org.matsim.core.mobsim.jdeqsim; -import org.junit.Assert; -import org.junit.Test; +import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.matsim.core.mobsim.jdeqsim.util.DummyMessage; import org.matsim.core.mobsim.jdeqsim.util.DummyMessage1; -import org.matsim.core.mobsim.jdeqsim.util.DummySimUnit; - -public class TestScheduler { - - // the time at the end of the simulation is equal to the time of the last message processed - @Test - public void testSchedule1(){ +import org.matsim.core.mobsim.jdeqsim.util.DummySimUnit; + + public class TestScheduler { + + // the time at the end of the simulation is equal to the time of the last message processed + @Test + void testSchedule1(){ Scheduler scheduler=new Scheduler(new MessageQueue()); SimUnit sm1=new DummySimUnit(scheduler); Message m1=new DummyMessage(); sm1.sendMessage(m1, sm1, 9000); scheduler.startSimulation(); Assert.assertEquals(9000.0, scheduler.getSimTime(), 0.0); - } - - // a message is scheduled and unscheduled before starting the simulation - // this causes the simulation to stop immediatly (because no messages in queue) - @Test - public void testUnschedule(){ + } + + // a message is scheduled and unscheduled before starting the simulation + // this causes the simulation to stop immediatly (because no messages in queue) + @Test + void testUnschedule(){ Scheduler scheduler=new Scheduler(new MessageQueue()); SimUnit sm1=new DummySimUnit(scheduler); Message m1=new DummyMessage(); @@ -51,12 +51,12 @@ public void testUnschedule(){ scheduler.unschedule(m1); scheduler.startSimulation(); Assert.assertEquals(0.0, scheduler.getSimTime(), 0.0); - } - - // We shedule two messages, but the first message deletes upon handling the message the second message. - // This results in that the simulation stops not at time 10, but immediatly at time 1. - @Test - public void testUnschedule2(){ + } + + // We shedule two messages, but the first message deletes upon handling the message the second message. + // This results in that the simulation stops not at time 10, but immediatly at time 1. + @Test + void testUnschedule2(){ Scheduler scheduler=new Scheduler(new MessageQueue()); SimUnit sm1=new DummySimUnit(scheduler); Message m1=new DummyMessage(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/util/TestEventLibrary.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/util/TestEventLibrary.java index 314faf79eb5..acbcd8498fb 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/util/TestEventLibrary.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/util/TestEventLibrary.java @@ -25,8 +25,8 @@ import java.util.LinkedList; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.events.Event; @@ -36,13 +36,14 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.testcases.MatsimTestUtils; -public class TestEventLibrary { + public class TestEventLibrary { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testGetTravelTime(){ + @Test + void testGetTravelTime(){ LinkedList events=new LinkedList(); events.add(new PersonDepartureEvent(20, Id.create("2", Person.class), Id.create("0", Link.class), TransportMode.car, TransportMode.car)); events.add(new PersonArrivalEvent(30, Id.create("2", Person.class), Id.create("0", Link.class), TransportMode.car)); @@ -52,7 +53,8 @@ public class TestEventLibrary { assertEquals(20.0, EventLibrary.getTravelTime(events,1), MatsimTestUtils.EPSILON); } - @Test public void testGetAverageTravelTime(){ + @Test + void testGetAverageTravelTime(){ LinkedList events=new LinkedList(); events.add(new PersonDepartureEvent(20, Id.create("2", Person.class), Id.create("0", Link.class), TransportMode.car, TransportMode.car)); events.add(new PersonArrivalEvent(30, Id.create("2", Person.class), Id.create("0", Link.class), TransportMode.car)); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/AbstractQSimModuleTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/AbstractQSimModuleTest.java index 02166c720bb..b2cdc109615 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/AbstractQSimModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/AbstractQSimModuleTest.java @@ -25,7 +25,7 @@ import java.util.concurrent.atomic.AtomicLong; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -47,9 +47,9 @@ import com.google.inject.Inject; import com.google.inject.Injector; -public class AbstractQSimModuleTest { - @Test - public void testOverrides() { + public class AbstractQSimModuleTest { + @Test + void testOverrides() { AbstractQSimModule moduleA = new AbstractQSimModule() { @Override protected void configureQSim() { @@ -80,8 +80,8 @@ protected void configureQSim() { Assert.assertEquals("testBString", injector.getInstance(String.class)); } - @Test - public void testOverrideAgentFactory() { + @Test + void testOverrideAgentFactory() { Config config = ConfigUtils.createConfig(); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setLastIteration(0); @@ -104,8 +104,8 @@ public void testOverrideAgentFactory() { Assert.assertTrue(value.get() > 0); } - @Test - public void testOverrideAgentFactoryTwice() { + @Test + void testOverrideAgentFactoryTwice() { Config config = ConfigUtils.createConfig(); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setLastIteration(0); @@ -162,8 +162,8 @@ public MobsimAgent createMobsimAgentFromPerson(Person p) { } } - @Test - public void testAddEngine() { + @Test + void testAddEngine() { Config config = ConfigUtils.createConfig(); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setLastIteration(0); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/AgentNotificationTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/AgentNotificationTest.java index 55a02dfcfd6..49a35771959 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/AgentNotificationTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/AgentNotificationTest.java @@ -31,7 +31,7 @@ import org.hamcrest.FeatureMatcher; import org.hamcrest.Matcher; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -76,7 +76,7 @@ import org.matsim.vehicles.Vehicle; -public class AgentNotificationTest { + public class AgentNotificationTest { private static class MyAgentFactory implements AgentFactory { @@ -261,9 +261,9 @@ public PlanElement getPreviousPlanElement() { } - @SuppressWarnings("static-method") - @Test - public void testAgentNotification() { + @SuppressWarnings("static-method") + @Test + void testAgentNotification() { Scenario scenario = createSimpleScenario(); EventsManager eventsManager = EventsUtils.createEventsManager(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/FlowStorageSpillbackTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/FlowStorageSpillbackTest.java index 0b5d2e4d65c..5dd21d977ed 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/FlowStorageSpillbackTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/FlowStorageSpillbackTest.java @@ -24,8 +24,8 @@ import java.util.*; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @@ -89,7 +89,7 @@ public static Collection parameterObjects () { private Id linkId4 = Id.create("link4", Link.class); @Test - public final void testFlowCongestion(){ + final void testFlowCongestion(){ Scenario sc = loadScenario(); setPopulation(sc); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/MobsimListenerManagerTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/MobsimListenerManagerTest.java index ec84c16752d..1c4930b1271 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/MobsimListenerManagerTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/MobsimListenerManagerTest.java @@ -20,7 +20,7 @@ package org.matsim.core.mobsim.qsim; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.mobsim.framework.events.MobsimInitializedEvent; import org.matsim.core.mobsim.framework.listeners.MobsimInitializedListener; @@ -30,7 +30,7 @@ public class MobsimListenerManagerTest { @Test - public void testAddQueueSimulationListener() { + void testAddQueueSimulationListener() { MobsimListenerManager manager = new MobsimListenerManager(null); TestSimListener simpleListener = new TestSimListener(); TestSubSimListener subListener = new TestSubSimListener(); @@ -48,7 +48,7 @@ public void testAddQueueSimulationListener() { } @Test - public void testRemoveQueueSimulationListener() { + void testRemoveQueueSimulationListener() { MobsimListenerManager manager = new MobsimListenerManager(null); TestSimListener simpleListener = new TestSimListener(); TestSubSimListener subListener = new TestSubSimListener(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NetsimRoutingConsistencyTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NetsimRoutingConsistencyTest.java index c93509f82c9..94d1ed9b117 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NetsimRoutingConsistencyTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NetsimRoutingConsistencyTest.java @@ -26,7 +26,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -64,65 +64,65 @@ import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleUtils; -public class NetsimRoutingConsistencyTest { - @Test + public class NetsimRoutingConsistencyTest { /* - * This test shows that the travel time that is predicted with the - * NetworkRoutingModule is NOT equivalent to the travel time that is produced by - * the Netsim. - * - * The scenario is as follows: - * - * N1 ----- N2 ----- N3 ----- N4 ----- N5 - * L12 L23 L34 L45 - * - * There are nodes Ni and connecting links Lij. There is one agent P who wants - * to depart at L12 and arrive at L45. He has a plan with an activity at L12 and - * another one at L45 and a connecting leg by car. - * - * This car leg is produced (as would be in the full stack simulation) using the - * NetworkRoutingModule. For the disutility OnlyTimeDependentDisutility is used, - * for the TravelTime, freespeed is used. The freespeed of all links is 10, - * while the length is 1000, hence the traversal time for each link is 100. - * - * Accordingly, the NetworkRoutingModule produces a Leg for the agent with a - * travel time of - * - * routingTravelTime = 200.0 - * - * because link L23 and L45 are taken into account. As expected the routing goes - * from the end node of the departure link to the start node of the arrival - * link. We already know that this will not be the true Netsim simulated time, - * because traversal times are rounded up. So we would expect a - * - * adjustedRoutingTravelTime = 202.0 - * - * because we need to add 1s per traversed link. - * - * Now, the scenario is simulated using the QSim/Netsim. An event handler is set - * up that captures the only "departure" event and the only "arrival" event in - * the simulation (which is produced by the leg of the agent). The travel time - * can be computed an we get: - * - * netsimTravelTime = 303.0 - * - * Apparently, looking at QueueWithBuffer::moveQueueToBuffer , the agent needs - * to traverse the arrival link before he can arrive there. This leads to a - * travel time that is higher than expected by the router and so predictions - * done by the NetworkRoutingModule are inconsistent. - * - * Not sure, what to do about that. Possible options: - * - Adjust Netsim such that agents arrive before they traverse the arrival link - * - Adjust the car routing such that the travel time of the final link is added - * - Adjust the car routing such that the routing goes to the end node of the arrival link - * - Explicitly document this behaviour somewhere - * - * I guess usually this should not make such a big difference for MATSim, - * because the shortest path is found anyway. However, if one wants to predict - * travel times one should state that the NetworkRoutingModule has a bias by the - * arrival link. - */ - public void testRoutingVsSimulation() { +* This test shows that the travel time that is predicted with the +* NetworkRoutingModule is NOT equivalent to the travel time that is produced by +* the Netsim. + * +* The scenario is as follows: + * +* N1 ----- N2 ----- N3 ----- N4 ----- N5 +* L12 L23 L34 L45 + * +* There are nodes Ni and connecting links Lij. There is one agent P who wants +* to depart at L12 and arrive at L45. He has a plan with an activity at L12 and +* another one at L45 and a connecting leg by car. + * +* This car leg is produced (as would be in the full stack simulation) using the +* NetworkRoutingModule. For the disutility OnlyTimeDependentDisutility is used, +* for the TravelTime, freespeed is used. The freespeed of all links is 10, +* while the length is 1000, hence the traversal time for each link is 100. + * +* Accordingly, the NetworkRoutingModule produces a Leg for the agent with a +* travel time of + * +* routingTravelTime = 200.0 + * +* because link L23 and L45 are taken into account. As expected the routing goes +* from the end node of the departure link to the start node of the arrival +* link. We already know that this will not be the true Netsim simulated time, +* because traversal times are rounded up. So we would expect a + * +* adjustedRoutingTravelTime = 202.0 + * +* because we need to add 1s per traversed link. + * +* Now, the scenario is simulated using the QSim/Netsim. An event handler is set +* up that captures the only "departure" event and the only "arrival" event in +* the simulation (which is produced by the leg of the agent). The travel time +* can be computed an we get: + * +* netsimTravelTime = 303.0 + * +* Apparently, looking at QueueWithBuffer::moveQueueToBuffer , the agent needs +* to traverse the arrival link before he can arrive there. This leads to a +* travel time that is higher than expected by the router and so predictions +* done by the NetworkRoutingModule are inconsistent. + * +* Not sure, what to do about that. Possible options: +* - Adjust Netsim such that agents arrive before they traverse the arrival link +* - Adjust the car routing such that the travel time of the final link is added +* - Adjust the car routing such that the routing goes to the end node of the arrival link +* - Explicitly document this behaviour somewhere + * +* I guess usually this should not make such a big difference for MATSim, +* because the shortest path is found anyway. However, if one wants to predict +* travel times one should state that the NetworkRoutingModule has a bias by the +* arrival link. + */ + @Test + void testRoutingVsSimulation() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network = scenario.getNetwork(); @@ -206,12 +206,12 @@ public void testRoutingVsSimulation() { Assert.assertEquals(adjustedRoutingTravelTime, 202.0, 1e-3); } - @Test /* - * The same test as above, but here the full stack MATSim setup is used (i.e. the - * NetworkRoutingModule, etc. are created implicitly by the Controler). - */ - public void testRoutingVsSimulationFullStack() { +* The same test as above, but here the full stack MATSim setup is used (i.e. the +* NetworkRoutingModule, etc. are created implicitly by the Controler). + */ + @Test + void testRoutingVsSimulationFullStack() { Config config = ConfigUtils.createConfig(); config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java index 954f61a3eda..23711c823b1 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java @@ -27,7 +27,7 @@ import java.util.TreeMap; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.matsim.api.core.v01.Coord; @@ -90,7 +90,7 @@ public NodeTransitionTest(boolean useFastCapUpdate) { } @Test - public void testMergeSituationWithEmptyBufferAfterBufferRandomDistribution() { + void testMergeSituationWithEmptyBufferAfterBufferRandomDistribution() { Scenario scenario = Fixture.createMergeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.emptyBufferAfterBufferRandomDistribution_dontBlockNode); scenario.getConfig().qsim().setUsingFastCapacityUpdate(useFastCapUpdate); @@ -158,7 +158,7 @@ public void testMergeSituationWithEmptyBufferAfterBufferRandomDistribution() { } @Test - public void testMergeSituationWithMoveVehByVehRandomDistribution() { + void testMergeSituationWithMoveVehByVehRandomDistribution() { Scenario scenario = Fixture.createMergeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.moveVehByVehRandomDistribution_dontBlockNode); scenario.getConfig().qsim().setUsingFastCapacityUpdate(useFastCapUpdate); @@ -233,7 +233,7 @@ public void testMergeSituationWithMoveVehByVehRandomDistribution() { } @Test - public void testMergeSituationWithMoveVehByVehDeterministicPriorities() { + void testMergeSituationWithMoveVehByVehDeterministicPriorities() { Scenario scenario = Fixture.createMergeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.moveVehByVehDeterministicPriorities_nodeBlockedWhenSingleOutlinkFull); // note: the deterministic node transition is only implemented for the case when the node is blocked as soon as one outgoing link is full @@ -302,7 +302,7 @@ public void testMergeSituationWithMoveVehByVehDeterministicPriorities() { } @Test - public void testBlockedNodeSituationWithEmptyBufferAfterBufferRandomDistribution() { + void testBlockedNodeSituationWithEmptyBufferAfterBufferRandomDistribution() { Scenario scenario = Fixture.createBlockedNodeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.emptyBufferAfterBufferRandomDistribution_nodeBlockedWhenSingleOutlinkFull); scenario.getConfig().qsim().setUsingFastCapacityUpdate(useFastCapUpdate); @@ -383,7 +383,7 @@ public void testBlockedNodeSituationWithEmptyBufferAfterBufferRandomDistribution } @Test - public void testBlockedNodeSituationWithMoveVehByVehRandomDistribution() { + void testBlockedNodeSituationWithMoveVehByVehRandomDistribution() { Scenario scenario = Fixture.createBlockedNodeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.moveVehByVehRandomDistribution_nodeBlockedWhenSingleOutlinkFull); scenario.getConfig().qsim().setUsingFastCapacityUpdate(useFastCapUpdate); @@ -465,7 +465,7 @@ public void testBlockedNodeSituationWithMoveVehByVehRandomDistribution() { } @Test - public void testBlockedNodeSituationWithMoveVehByVehDeterministicPriorities() { + void testBlockedNodeSituationWithMoveVehByVehDeterministicPriorities() { Scenario scenario = Fixture.createBlockedNodeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.moveVehByVehDeterministicPriorities_nodeBlockedWhenSingleOutlinkFull); scenario.getConfig().qsim().setUsingFastCapacityUpdate(useFastCapUpdate); @@ -554,7 +554,7 @@ public void testBlockedNodeSituationWithMoveVehByVehDeterministicPriorities() { * 3. both streams are independently (because blockNode=false). */ @Test - public void testNodeTransitionWithTimeStepSizeSmallerOne() { + void testNodeTransitionWithTimeStepSizeSmallerOne() { Scenario scenario = Fixture.createBlockedNodeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.emptyBufferAfterBufferRandomDistribution_dontBlockNode); scenario.getConfig().qsim().setTimeStepSize(0.5); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimEventsIntegrationTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimEventsIntegrationTest.java index e7ec111bd4b..e9cbe1d2d6e 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimEventsIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimEventsIntegrationTest.java @@ -22,9 +22,9 @@ package org.matsim.core.mobsim.qsim; import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.handler.LinkLeaveEventHandler; import org.matsim.core.api.experimental.events.EventsManager; @@ -41,7 +41,7 @@ public class QSimEventsIntegrationTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void netsimEngineHandlesExceptionCorrectly() { + void netsimEngineHandlesExceptionCorrectly() { Config config = utils.loadConfig("test/scenarios/equil/config_plans1.xml"); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -58,7 +58,7 @@ public void netsimEngineHandlesExceptionCorrectly() { } @Test - public void controlerHandlesExceptionCorrectly_syncOnSimSteps() { + void controlerHandlesExceptionCorrectly_syncOnSimSteps() { Config config = utils.loadConfig("test/scenarios/equil/config_plans1.xml"); config.eventsManager().setNumberOfThreads(1); config.eventsManager().setSynchronizeOnSimSteps(true); @@ -73,7 +73,7 @@ public void controlerHandlesExceptionCorrectly_syncOnSimSteps() { } @Test - public void controlerHandlesExceptionCorrectly_noSyncOnSimSteps() { + void controlerHandlesExceptionCorrectly_noSyncOnSimSteps() { Config config = utils.loadConfig("test/scenarios/equil/config_plans1.xml"); config.eventsManager().setNumberOfThreads(1); config.eventsManager().setSynchronizeOnSimSteps(false); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimTest.java index a322a208f70..b27f758dfb3 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimTest.java @@ -30,7 +30,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @@ -144,7 +144,7 @@ private static QSim createQSim(Fixture f, EventsManager events) { * @author mrieser */ @Test - public void testSingleAgent() { + void testSingleAgent() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add a single person with leg from link1 to link3 @@ -184,7 +184,7 @@ public void testSingleAgent() { * @author Kai Nagel */ @Test - public void testSingleAgentWithEndOnLeg() { + void testSingleAgentWithEndOnLeg() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add a single person with leg from link1 to link3 @@ -250,7 +250,7 @@ public void testSingleAgentWithEndOnLeg() { * @author mrieser */ @Test - public void testTwoAgent() { + void testTwoAgent() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add two persons with leg from link1 to link3, the first starting at 6am, the second at 7am @@ -291,7 +291,7 @@ public void testTwoAgent() { * @author mrieser */ @Test - public void testTeleportationSingleAgent() { + void testTeleportationSingleAgent() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add a single person with leg from link1 to link3 @@ -338,7 +338,7 @@ public void testTeleportationSingleAgent() { * @author cdobler */ @Test - public void testSingleAgentImmediateDeparture() { + void testSingleAgentImmediateDeparture() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add a single person with leg from link1 to link3 @@ -383,7 +383,7 @@ public void testSingleAgentImmediateDeparture() { * @author mrieser */ @Test - public void testSingleAgent_EmptyRoute() { + void testSingleAgent_EmptyRoute() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add a single person with leg from link1 to link1 @@ -456,7 +456,7 @@ public void testSingleAgent_EmptyRoute() { * @author mrieser */ @Test - public void testSingleAgent_LastLinkIsLoop() { + void testSingleAgent_LastLinkIsLoop() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); Link loopLink = NetworkUtils.createAndAddLink(f.network,Id.create("loop", Link.class), f.node4, f.node4, 100.0, 10.0, 500, 1 ); @@ -526,7 +526,7 @@ public void reset(final int iteration) { * @author mrieser */ @Test - public void testAgentWithoutLeg() { + void testAgentWithoutLeg() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -553,7 +553,7 @@ public void testAgentWithoutLeg() { * @author mrieser */ @Test - public void testAgentWithoutLegWithEndtime() { + void testAgentWithoutLegWithEndtime() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -581,7 +581,7 @@ public void testAgentWithoutLegWithEndtime() { * @author mrieser */ @Test - public void testAgentWithLastActWithEndtime() { + void testAgentWithLastActWithEndtime() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -616,7 +616,7 @@ public void testAgentWithLastActWithEndtime() { * @author mrieser */ @Test - public void testFlowCapacityDriving() { + void testFlowCapacityDriving() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add a lot of persons with legs from link1 to link3, starting at 6:30 @@ -681,7 +681,7 @@ public void testFlowCapacityDriving() { * @author michaz */ @Test - public void testFlowCapacityDrivingFraction() { + void testFlowCapacityDrivingFraction() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); f.link2.setCapacity(900.0); // One vehicle every 4 seconds @@ -736,7 +736,7 @@ public void testFlowCapacityDrivingFraction() { * @author mrieser */ @Test - public void testFlowCapacityStarting() { + void testFlowCapacityStarting() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add a lot of persons with legs from link2 to link3 @@ -791,7 +791,7 @@ public void testFlowCapacityStarting() { * @author mrieser */ @Test - public void testFlowCapacityMixed() { + void testFlowCapacityMixed() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add a lot of persons with legs from link2 to link3 @@ -859,7 +859,7 @@ public void testFlowCapacityMixed() { * @author mrieser */ @Test - public void testVehicleTeleportationTrue() { + void testVehicleTeleportationTrue() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan plan = PersonUtils.createAndAddPlan(person, true); @@ -914,7 +914,7 @@ public void testVehicleTeleportationTrue() { * @author michaz */ @Test - public void testWaitingForCar() { + void testWaitingForCar() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); f.scenario.getConfig().qsim().setVehicleBehavior(QSimConfigGroup.VehicleBehavior.wait); f.scenario.getConfig().qsim().setEndTime(24.0 * 60.0 * 60.0); @@ -1009,7 +1009,7 @@ public void testWaitingForCar() { * @author mrieser */ @Test - public void testVehicleTeleportationFalse() { + void testVehicleTeleportationFalse() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); f.scenario.getConfig().qsim().setVehicleBehavior(QSimConfigGroup.VehicleBehavior.exception); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -1062,7 +1062,7 @@ public void testVehicleTeleportationFalse() { * @author mrieser */ @Test - public void testAssignedVehicles() { + void testAssignedVehicles() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); // do not add person to population, we'll do it ourselves for the test Plan plan = PersonUtils.createAndAddPlan(person, true); @@ -1118,7 +1118,7 @@ public void testAssignedVehicles() { * @author mrieser */ @Test - public void testCircleAsRoute() { + void testCircleAsRoute() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); Link link4 = NetworkUtils.createAndAddLink(f.network,Id.create(4, Link.class), f.node4, f.node1, 1000.0, 100.0, 6000, 1.0 ); // close the network @@ -1176,7 +1176,7 @@ public void testCircleAsRoute() { * @author mrieser */ @Test - public void testRouteWithEndLinkTwice() { + void testRouteWithEndLinkTwice() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); Link link4 = NetworkUtils.createAndAddLink(f.network,Id.create(4, Link.class), f.node4, f.node1, 1000.0, 100.0, 6000, 1.0 ); // close the network @@ -1237,7 +1237,7 @@ public void testRouteWithEndLinkTwice() { * @author mrieser */ @Test - public void testConsistentRoutes_WrongRoute() { + void testConsistentRoutes_WrongRoute() { EventsManager events = EventsUtils.createEventsManager(); EnterLinkEventCounter counter = new EnterLinkEventCounter("6"); events.addHandler(counter); @@ -1253,7 +1253,7 @@ public void testConsistentRoutes_WrongRoute() { * @author mrieser */ @Test - public void testConsistentRoutes_WrongStartLink() { + void testConsistentRoutes_WrongStartLink() { EventsManager events = EventsUtils.createEventsManager(); EnterLinkEventCounter counter = new EnterLinkEventCounter("6"); events.addHandler(counter); @@ -1269,7 +1269,7 @@ public void testConsistentRoutes_WrongStartLink() { * @author mrieser */ @Test - public void testConsistentRoutes_WrongEndLink() { + void testConsistentRoutes_WrongEndLink() { EventsManager events = EventsUtils.createEventsManager(); EnterLinkEventCounter counter = new EnterLinkEventCounter("6"); events.addHandler(counter); @@ -1286,7 +1286,7 @@ public void testConsistentRoutes_WrongEndLink() { * @author mrieser */ @Test - public void testConsistentRoutes_ImpossibleRoute() { + void testConsistentRoutes_ImpossibleRoute() { EventsManager events = EventsUtils.createEventsManager(); EnterLinkEventCounter counter = new EnterLinkEventCounter("6"); events.addHandler(counter); @@ -1302,7 +1302,7 @@ public void testConsistentRoutes_ImpossibleRoute() { * @author mrieser */ @Test - public void testConsistentRoutes_MissingRoute() { + void testConsistentRoutes_MissingRoute() { EventsManager events = EventsUtils.createEventsManager(); EnterLinkEventCounter counter = new EnterLinkEventCounter("6"); events.addHandler(counter); @@ -1371,7 +1371,7 @@ private LogCounter runConsistentRoutesTestSim(final String startLinkId, final St } @Test - public void testStartAndEndTime() { + void testStartAndEndTime() { final Config config = ConfigUtils.createConfig(); config.qsim().setUsingFastCapacityUpdate(isUsingFastCapacityUpdate); @@ -1437,7 +1437,7 @@ public void testStartAndEndTime() { * @author mrieser */ @Test - public void testCleanupSim_EarlyEnd() { + void testCleanupSim_EarlyEnd() { MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); Config config = scenario.getConfig(); @@ -1535,7 +1535,7 @@ public void testCleanupSim_EarlyEnd() { * @author ikaddoura based on mrieser */ @Test - public void testFlowCapacityDrivingKinematicWavesWithFlowReductionCorrectionBehavior() { + void testFlowCapacityDrivingKinematicWavesWithFlowReductionCorrectionBehavior() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); f.config.qsim().setTrafficDynamics(TrafficDynamics.kinematicWaves); f.config.qsim().setInflowCapacitySetting(QSimConfigGroup.InflowCapacitySetting.INFLOW_FROM_FDIAG); @@ -1595,7 +1595,7 @@ public void testFlowCapacityDrivingKinematicWavesWithFlowReductionCorrectionBeha * @author ikaddoura based on mrieser */ @Test - public void testFlowCapacityDrivingKinematicWavesWithLaneIncreaseCorrectionBehavior() { + void testFlowCapacityDrivingKinematicWavesWithLaneIncreaseCorrectionBehavior() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); f.config.qsim().setTrafficDynamics(TrafficDynamics.kinematicWaves); f.config.qsim().setInflowCapacitySetting(QSimConfigGroup.InflowCapacitySetting.NR_OF_LANES_FROM_FDIAG); @@ -1655,7 +1655,7 @@ public void testFlowCapacityDrivingKinematicWavesWithLaneIncreaseCorrectionBehav * @author tschlenther based on ikaddoura based on mrieser */ @Test - public void testFlowCapacityDrivingKinematicWavesWithInflowEqualToMaxCapForOneLane() { + void testFlowCapacityDrivingKinematicWavesWithInflowEqualToMaxCapForOneLane() { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); f.config.qsim().setTrafficDynamics(TrafficDynamics.kinematicWaves); f.config.qsim().setInflowCapacitySetting(QSimConfigGroup.InflowCapacitySetting.MAX_CAP_FOR_ONE_LANE); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/TeleportationEngineWDistanceCheckTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/TeleportationEngineWDistanceCheckTest.java index 0af1d61514c..8f0286cf9cd 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/TeleportationEngineWDistanceCheckTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/TeleportationEngineWDistanceCheckTest.java @@ -20,8 +20,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -59,7 +59,7 @@ public class TeleportationEngineWDistanceCheckTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public final void test() { + final void test() { Config config = ConfigUtils.createConfig(); config.controller().setOutputDirectory( utils.getOutputDirectory() ); config.controller().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/TransitQueueNetworkTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/TransitQueueNetworkTest.java index 0d9a67d768e..deb611bbab7 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/TransitQueueNetworkTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/TransitQueueNetworkTest.java @@ -28,7 +28,7 @@ import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -78,16 +78,17 @@ public class TransitQueueNetworkTest { - /** - * Tests that a non-blocking stops on the first link of a transit vehicle's network - * route is correctly handled. - * @throws NoSuchMethodException - * @throws SecurityException - * @throws InvocationTargetException - * @throws IllegalAccessException - * @throws IllegalArgumentException - */ - @Test public void testNonBlockingStop_FirstLink() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { + /** + * Tests that a non-blocking stops on the first link of a transit vehicle's network + * route is correctly handled. + * @throws NoSuchMethodException + * @throws SecurityException + * @throws InvocationTargetException + * @throws IllegalAccessException + * @throws IllegalArgumentException + */ + @Test + void testNonBlockingStop_FirstLink() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { Fixture f = new Fixture(1, false, 0, false); f.simEngine.doSimStep(100); @@ -122,20 +123,21 @@ public class TransitQueueNetworkTest { assertEquals(2, f.qlink2.getAllVehicles().size()); } - /** - * Tests that blocking stops are correctly handled on the - * first link of a transit vehicle's network route. - * Note that on the first link, a stop is by definition non-blocking, - * as the wait2buffer-queue is seen as similary independent than the transit stop queue! - * So, it essentially tests the same thing as {@link #testNonBlockingStop_FirstLink()}. - * - * @throws NoSuchMethodException - * @throws SecurityException - * @throws InvocationTargetException - * @throws IllegalAccessException - * @throws IllegalArgumentException - */ - @Test public void testBlockingStop_FirstLink() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { + /** + * Tests that blocking stops are correctly handled on the + * first link of a transit vehicle's network route. + * Note that on the first link, a stop is by definition non-blocking, + * as the wait2buffer-queue is seen as similary independent than the transit stop queue! + * So, it essentially tests the same thing as {@link #testNonBlockingStop_FirstLink()}. + * + * @throws NoSuchMethodException + * @throws SecurityException + * @throws InvocationTargetException + * @throws IllegalAccessException + * @throws IllegalArgumentException + */ + @Test + void testBlockingStop_FirstLink() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { Fixture f = new Fixture(1, true, 0, false); f.qsim.getSimTimer().setTime(100); @@ -167,16 +169,17 @@ public class TransitQueueNetworkTest { assertEquals(2, f.qlink2.getAllVehicles().size()); } - /** - * Tests that a non-blocking stop is correctly handled when it is somewhere in the middle - * of the transit vehicle's network route. - * @throws NoSuchMethodException - * @throws SecurityException - * @throws InvocationTargetException - * @throws IllegalAccessException - * @throws IllegalArgumentException - */ - @Test public void testNonBlockingStop_MiddleLink() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { + /** + * Tests that a non-blocking stop is correctly handled when it is somewhere in the middle + * of the transit vehicle's network route. + * @throws NoSuchMethodException + * @throws SecurityException + * @throws InvocationTargetException + * @throws IllegalAccessException + * @throws IllegalArgumentException + */ + @Test + void testNonBlockingStop_MiddleLink() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { Fixture f = new Fixture(2, false, 0, false); // time 100: agents start, transitVeh is moved to qlink1.buffer @@ -250,16 +253,17 @@ public class TransitQueueNetworkTest { assertEquals(f.transitVehicle, vehicles[1]); } - /** - * Tests that a blocking stop is correctly handled when it is somewhere in the middle - * of the transit vehicle's network route. - * @throws NoSuchMethodException - * @throws SecurityException - * @throws InvocationTargetException - * @throws IllegalAccessException - * @throws IllegalArgumentException - */ - @Test public void testBlockingStop_MiddleLink() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { + /** + * Tests that a blocking stop is correctly handled when it is somewhere in the middle + * of the transit vehicle's network route. + * @throws NoSuchMethodException + * @throws SecurityException + * @throws InvocationTargetException + * @throws IllegalAccessException + * @throws IllegalArgumentException + */ + @Test + void testBlockingStop_MiddleLink() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { Fixture f = new Fixture(2, true, 0, false); // time 100: agents start, transitVeh is moved to qlink1.buffer @@ -330,16 +334,17 @@ public class TransitQueueNetworkTest { assertEquals(f.normalVehicle, vehicles[1]); } - /** - * Tests that a non-blocking stop is correctly handled when it is the last link - * of the transit vehicle's network route. - * @throws NoSuchMethodException - * @throws SecurityException - * @throws InvocationTargetException - * @throws IllegalAccessException - * @throws IllegalArgumentException - */ - @Test public void testNonBlockingStop_LastLink() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { + /** + * Tests that a non-blocking stop is correctly handled when it is the last link + * of the transit vehicle's network route. + * @throws NoSuchMethodException + * @throws SecurityException + * @throws InvocationTargetException + * @throws IllegalAccessException + * @throws IllegalArgumentException + */ + @Test + void testNonBlockingStop_LastLink() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { Fixture f = new Fixture(3, false, 0, false); // time 100: agents start, transitVeh is moved to qlink1.buffer @@ -412,16 +417,17 @@ public class TransitQueueNetworkTest { assertEquals(0, f.qlink3.getAllNonParkedVehicles().size()); } - /** - * Tests that a blocking stop is correctly handled when it is the last link - * of the transit vehicle's network route. - * @throws NoSuchMethodException - * @throws SecurityException - * @throws InvocationTargetException - * @throws IllegalAccessException - * @throws IllegalArgumentException - */ - @Test public void testBlockingStop_LastLink() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { + /** + * Tests that a blocking stop is correctly handled when it is the last link + * of the transit vehicle's network route. + * @throws NoSuchMethodException + * @throws SecurityException + * @throws InvocationTargetException + * @throws IllegalAccessException + * @throws IllegalArgumentException + */ + @Test + void testBlockingStop_LastLink() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { Fixture f = new Fixture(3, true, 0, false); // time 100: agents start, transitVeh is moved to qlink1.buffer @@ -487,7 +493,8 @@ public class TransitQueueNetworkTest { assertEquals(0, f.qlink3.getAllNonParkedVehicles().size()); } - @Test public void testTwoStopsOnOneLink_FirstLink() throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { + @Test + void testTwoStopsOnOneLink_FirstLink() throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { Fixture f = new Fixture(1, true, 1, true); // first stop at the first link is non-blocking by definition! // time 100: agents start, transitVeh is moved to qlink1.transitStopQueue (delay 19, exit-time 119), normalVeh is moved to qlink1.buffer @@ -536,7 +543,8 @@ public class TransitQueueNetworkTest { assertEquals(f.transitVehicle, vehicles[2]); } - @Test public void testTwoStopsOnOneLink_MiddleLink_FirstBlockThenNonBlock() throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { + @Test + void testTwoStopsOnOneLink_MiddleLink_FirstBlockThenNonBlock() throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { Fixture f = new Fixture(2, true, 2, false); // time 100: agents start, transitVeh is moved to qlink1.buffer @@ -638,7 +646,8 @@ public class TransitQueueNetworkTest { assertEquals(f.normalVehicle2, vehicles[2]); } - @Test public void testTwoStopsOnOneLink_MiddleLink_FirstNonBlockThenBlock() throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { + @Test + void testTwoStopsOnOneLink_MiddleLink_FirstNonBlockThenBlock() throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { Fixture f = new Fixture(2, false, 2, true); // time 100: agents start, transitVeh is moved to qlink1.buffer @@ -752,7 +761,8 @@ public class TransitQueueNetworkTest { assertEquals(f.normalVehicle2, vehicles[2]); } - @Test public void testTwoStopsOnOneLink_LastLink_FirstBlockThenNonBlock() throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { + @Test + void testTwoStopsOnOneLink_LastLink_FirstBlockThenNonBlock() throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { Fixture f = new Fixture(3, true, 3, false); // time 100: agents start, transitVeh is moved to qlink1.buffer @@ -865,7 +875,8 @@ public class TransitQueueNetworkTest { assertEquals(0, f.qlink3.getAllNonParkedVehicles().size()); } - @Test public void testTwoStopsOnOneLink_LastLink_FirstNonBlockThenBlock() throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { + @Test + void testTwoStopsOnOneLink_LastLink_FirstNonBlockThenBlock() throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { Fixture f = new Fixture(3, false, 3, true); // time 100: agents start, transitVeh is moved to qlink1.buffer diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/TravelTimeTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/TravelTimeTest.java index d5ed75191cd..6670ac30280 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/TravelTimeTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/TravelTimeTest.java @@ -23,7 +23,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.LinkEnterEvent; @@ -47,7 +47,7 @@ public class TravelTimeTest { @Test - public void testEquilOneAgent() { + void testEquilOneAgent() { Map, Map, Double>> agentTravelTimes = new HashMap<>(); Config config = ConfigUtils.loadConfig("test/scenarios/equil/config.xml"); @@ -77,14 +77,14 @@ public void testEquilOneAgent() { Assert.assertEquals(1260.0, travelTimes.get(Id.create(22, Link.class)).intValue(), MatsimTestUtils.EPSILON); Assert.assertEquals(360.0, travelTimes.get(Id.create(23, Link.class)).intValue(), MatsimTestUtils.EPSILON); } - - @Test + /** * This test shows that the Netsim always rounds up link travel times. * Please note that a computed link travel time of 400.0s is treated the same, * i.e. it is rounded up to 401s. */ - public void testEquilOneAgentTravelTimeRounding() { + @Test + void testEquilOneAgentTravelTimeRounding() { Map, Map, Double>> agentTravelTimes = new HashMap<>(); Config config = ConfigUtils.loadConfig("test/scenarios/equil/config.xml"); @@ -174,7 +174,7 @@ public void testEquilOneAgentTravelTimeRounding() { } @Test - public void testEquilTwoAgents() { + void testEquilTwoAgents() { Map, Map, Double>> agentTravelTimes = new HashMap<>(); Config config = ConfigUtils.loadConfig("test/scenarios/equil/config.xml"); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java index 5ffc5e3b6af..6b84f956f3f 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java @@ -19,8 +19,8 @@ package org.matsim.core.mobsim.qsim; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @@ -108,7 +108,7 @@ public static Collection parameterObjects () { private Link link3; @Test - public void main() { + void main() { scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); createNetwork(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/changeeventsengine/NetworkChangeEventsEngineTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/changeeventsengine/NetworkChangeEventsEngineTest.java index d62f119e79c..6eb210f684d 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/changeeventsengine/NetworkChangeEventsEngineTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/changeeventsengine/NetworkChangeEventsEngineTest.java @@ -22,7 +22,7 @@ package org.matsim.core.mobsim.qsim.changeeventsengine; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -46,13 +46,13 @@ import java.util.List; -/** + /** * @author mrieser / Simunto GmbH */ public class NetworkChangeEventsEngineTest { - @Test - public void testActivation_inactive() { + @Test + void testActivation_inactive() { Config config = ConfigUtils.createConfig(); Scenario scenario = ScenarioUtils.createScenario(config); @@ -86,8 +86,8 @@ public void testActivation_inactive() { } } - @Test - public void testActivation_timedepOnly_freespeed() { + @Test + void testActivation_timedepOnly_freespeed() { Config config = ConfigUtils.createConfig(); config.network().setTimeVariantNetwork(true); Scenario scenario = ScenarioUtils.createScenario(config); @@ -122,8 +122,8 @@ public void testActivation_timedepOnly_freespeed() { Assert.assertEquals("it should be 50 now.", 50, link1.getFreespeed(40), 0); } - @Test - public void testActivation_timedepOnly_capacity() { + @Test + void testActivation_timedepOnly_capacity() { Config config = ConfigUtils.createConfig(); config.network().setTimeVariantNetwork(true); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/QSimComponentsTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/QSimComponentsTest.java index a11cadd58c0..3e97d857a17 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/QSimComponentsTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/QSimComponentsTest.java @@ -32,7 +32,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.Event; import org.matsim.core.api.experimental.events.EventsManager; @@ -52,12 +52,13 @@ import static java.lang.annotation.ElementType.*; import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.junit.jupiter.api.Assertions.assertThrows; -public class QSimComponentsTest { + public class QSimComponentsTest { private static final Logger log = LogManager.getLogger( QSimComponentsTest.class ) ; - @Test - public void testAddComponentViaString() { + @Test + void testAddComponentViaString() { // request "abc" component by config: Config config = ConfigUtils.createConfig(); @@ -97,12 +98,13 @@ public void testAddComponentViaString() { Assert.assertTrue( "MockMobsimListener was not added to QSim", handler.hasBeenCalled() ) ; } - /** - * this tests what happens when we run the same as in {@link #testAddComponentViaString()}, but without requesting the "abc" - * component by config. "abc" will not be activated (although it is "registered" = added as a qsim module). - */ - @Test - public void testAddModuleOnly() { + + /** + * this tests what happens when we run the same as in {@link #testAddComponentViaString()}, but without requesting the "abc" + * component by config. "abc" will not be activated (although it is "registered" = added as a qsim module). + */ + @Test + void testAddModuleOnly() { Config config = ConfigUtils.createConfig(); @@ -140,52 +142,57 @@ public void testAddModuleOnly() { Assert.assertFalse( "MockMobsimListener was added to QSim although it should not have been added", handler.hasBeenCalled() ) ; } - /** - * this tests what happens when we run the same as in {@link #testAddComponentViaString()}, but without registering the "abc" - * module. Evidently, it throws an exception. - */ - @Test( expected = ProvisionException.class ) - public void testAddComponentOnly() { - Config config = ConfigUtils.createConfig(); - - QSimComponentsConfigGroup qsimComponentsConfig = ConfigUtils.addOrGetModule( config, QSimComponentsConfigGroup.class ); - List list = new ArrayList<>( qsimComponentsConfig.getActiveComponents() ) ; // contains the "standard components" (*) - list.add( "abc" ) ; - qsimComponentsConfig.setActiveComponents( list ); - - log.warn( "" ); - log.warn( "qsimComponentsConfig=" + qsimComponentsConfig + "; active components:"); - for( String component : qsimComponentsConfig.getActiveComponents() ){ - log.warn( component ); - } - log.warn( "" ); - - Scenario scenario = ScenarioUtils.createScenario(config); - EventsManager eventsManager = EventsUtils.createEventsManager(); + /** + * this tests what happens when we run the same as in {@link #testAddComponentViaString()}, but without registering the "abc" + * module. Evidently, it throws an exception. + */ + @Test + void testAddComponentOnly() { + assertThrows(ProvisionException.class, () -> { + Config config = ConfigUtils.createConfig(); + + QSimComponentsConfigGroup qsimComponentsConfig = ConfigUtils.addOrGetModule(config, QSimComponentsConfigGroup.class); + List list = new ArrayList<>( qsimComponentsConfig.getActiveComponents() ) ; // contains the "standard components" (*) + list.add("abc") ; + qsimComponentsConfig.setActiveComponents(list); + + log.warn(""); + log.warn("qsimComponentsConfig=" + qsimComponentsConfig + "; active components:"); + for (String component : qsimComponentsConfig.getActiveComponents()) { + log.warn(component); + } + log.warn(""); + + Scenario scenario = ScenarioUtils.createScenario(config); + EventsManager eventsManager = EventsUtils.createEventsManager(); + + AnalysisEventsHandler handler = new AnalysisEventsHandler() ; + eventsManager.addHandler(handler); + + AbstractQSimModule module = new AbstractQSimModule() { + @Override + protected void configureQSim() { + addQSimComponentBinding("abc").to(MockMobsimListener.class) ; + } + }; - AnalysisEventsHandler handler = new AnalysisEventsHandler() ; - eventsManager.addHandler( handler ); + new QSimBuilder(config) // + .useDefaultComponents() // uses components from config + .useDefaultQSimModules() // registers the default modules (needed here because of (*)) +// .addQSimModule(module) // registers the additional modules + .build(scenario, eventsManager) // + .run(); - AbstractQSimModule module = new AbstractQSimModule() { - @Override protected void configureQSim() { - addQSimComponentBinding( "abc" ).to( MockMobsimListener.class ) ; - } - }; + }); - new QSimBuilder(config) // - .useDefaultComponents() // uses components from config - .useDefaultQSimModules() // registers the default modules (needed here because of (*)) -// .addQSimModule(module) // registers the additional modules - .build(scenario, eventsManager) // - .run(); + } - } - /** - * this tests what happens when we run the same as in {@link #testAddComponentViaString()}, but request the "abc" component twice. - */ - @Test -// ( expected = IllegalStateException.class ) - public void testAddComponentViaStringTwice() { + /** + * this tests what happens when we run the same as in {@link #testAddComponentViaString()}, but request the "abc" component twice. + */ + // ( expected = IllegalStateException.class ) + @Test + void testAddComponentViaStringTwice() { // request "abc" component by config: Config config = ConfigUtils.createConfig(); @@ -228,8 +235,8 @@ public void testAddComponentViaStringTwice() { } - @Test - public void testGenericAddComponentMethod() { + @Test + void testGenericAddComponentMethod() { Config config = ConfigUtils.createConfig(); Scenario scenario = ScenarioUtils.createScenario(config); EventsManager eventsManager = EventsUtils.createEventsManager(); @@ -258,8 +265,8 @@ public void testGenericAddComponentMethod() { Assert.assertTrue( handler.hasBeenCalled() ) ; } - @Test - public void testGenericAddComponentMethodWithoutConfiguringIt() { + @Test + void testGenericAddComponentMethodWithoutConfiguringIt() { Config config = ConfigUtils.createConfig(); Scenario scenario = ScenarioUtils.createScenario(config); EventsManager eventsManager = EventsUtils.createEventsManager(); @@ -281,8 +288,8 @@ public void testGenericAddComponentMethodWithoutConfiguringIt() { Assert.assertFalse( handler.hasBeenCalled() ) ; } - @Test - public void testMultipleBindings() { + @Test + void testMultipleBindings() { Config config = ConfigUtils.createConfig(); Scenario scenario = ScenarioUtils.createScenario(config); EventsManager eventsManager = EventsUtils.createEventsManager(); @@ -308,8 +315,8 @@ protected void configureQSim() { Assert.assertTrue(mockEngineB.isCalled); } - @Test - public void testExplicitAnnotationConfiguration() { + @Test + void testExplicitAnnotationConfiguration() { Config config = ConfigUtils.createConfig(); Scenario scenario = ScenarioUtils.createScenario(config); EventsManager eventsManager = EventsUtils.createEventsManager(); @@ -332,8 +339,8 @@ protected void configureQSim() { Assert.assertTrue(mockEngine.isCalled); } - @Test - public void testManualConfiguration() { + @Test + void testManualConfiguration() { Config config = ConfigUtils.createConfig(); Scenario scenario = ScenarioUtils.createScenario(config); EventsManager eventsManager = EventsUtils.createEventsManager(); @@ -356,8 +363,8 @@ protected void configureQSim() { Assert.assertTrue(mockEngine.isCalled); } - @Test - public void testUseConfigGroup() { + @Test + void testUseConfigGroup() { Config config = ConfigUtils.createConfig(); QSimComponentsConfigGroup componentsConfig = new QSimComponentsConfigGroup(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/guice/ExplicitBindingsRequiredTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/guice/ExplicitBindingsRequiredTest.java index b7f017bbc8d..d750d1e2efc 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/guice/ExplicitBindingsRequiredTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/guice/ExplicitBindingsRequiredTest.java @@ -22,15 +22,14 @@ package org.matsim.core.mobsim.qsim.components.guice; import org.junit.Assert; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import com.google.inject.AbstractModule; import com.google.inject.CreationException; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; -/** + /** * This test shows how Guice works with child injectors and explicit bindings. * In the test there is a ParentScopeObject in a parent injector. Then a child * injector is created which contains a ChildScopeObject, which has the @@ -60,8 +59,8 @@ static class OtherChildScopeObject { } - @Test - public void testExplicitBindings() { + @Test + void testExplicitBindings() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/guice/MultipleBindingsTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/guice/MultipleBindingsTest.java index e17420704ed..b558b40965a 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/guice/MultipleBindingsTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/guice/MultipleBindingsTest.java @@ -22,15 +22,14 @@ package org.matsim.core.mobsim.qsim.components.guice; import org.junit.Assert; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.name.Names; -/** + /** * This test shows that Guice creates Singletons solely based on the *class * name*. So as shown in the example one can bind the same class to different * interfaces, even with different names. If the class is declared in the @@ -47,8 +46,8 @@ static class Implementation implements InterfaceA, InterfaceB { } - @Test - public void testGuiceComponentNaming() { + @Test + void testGuiceComponentNaming() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/jdeqsimengine/JDEQSimPluginTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/jdeqsimengine/JDEQSimPluginTest.java index af6cfbc3aa3..ab45f904bf2 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/jdeqsimengine/JDEQSimPluginTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/jdeqsimengine/JDEQSimPluginTest.java @@ -21,8 +21,8 @@ package org.matsim.core.mobsim.qsim.jdeqsimengine; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.ConfigUtils; @@ -33,7 +33,7 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.testcases.MatsimTestUtils; -/** + /** * Created by michaelzilske on 19/03/14. */ public class JDEQSimPluginTest { @@ -50,7 +50,8 @@ private QSim prepareQSim(Scenario scenario, EventsManager eventsManager) { .build(scenario, eventsManager); } - @Test public void testRunsAtAll() { + @Test + void testRunsAtAll() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); EventsManager eventsManager = EventsUtils.createEventsManager(scenario.getConfig()); eventsManager.initProcessing(); @@ -60,7 +61,8 @@ private QSim prepareQSim(Scenario scenario, EventsManager eventsManager) { qsim.run(); } - @Test public void testRunsEquil() { + @Test + void testRunsEquil() { Scenario scenario = ScenarioUtils.loadScenario(utils.loadConfig("test/scenarios/equil/config.xml")); EventsManager eventsManager = EventsUtils.createEventsManager(scenario.getConfig()); eventsManager.initProcessing(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/QSimIntegrationTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/QSimIntegrationTest.java index 125ca9ac88f..b85534b5e04 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/QSimIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/QSimIntegrationTest.java @@ -26,7 +26,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.Event; @@ -61,7 +61,7 @@ public class QSimIntegrationTest { @Test - public void test_twoStopsOnFirstLink() throws SAXException, ParserConfigurationException, IOException { + void test_twoStopsOnFirstLink() throws SAXException, ParserConfigurationException, IOException { Fixture f = new Fixture(); String scheduleXml = "" + "" + @@ -121,7 +121,7 @@ public void test_twoStopsOnFirstLink() throws SAXException, ParserConfigurationE } @Test - public void test_multipleStopsOnFirstLink_singleLinkRoute_noPassengers() throws SAXException, ParserConfigurationException, IOException { + void test_multipleStopsOnFirstLink_singleLinkRoute_noPassengers() throws SAXException, ParserConfigurationException, IOException { Fixture f = new Fixture(); String scheduleXml = "" + "" + @@ -184,7 +184,7 @@ public void test_multipleStopsOnFirstLink_singleLinkRoute_noPassengers() throws } @Test - public void test_multipleStopsOnFirstLink_singleLinkRoute_withPassengersAtFirstStop() throws SAXException, ParserConfigurationException, IOException { + void test_multipleStopsOnFirstLink_singleLinkRoute_withPassengersAtFirstStop() throws SAXException, ParserConfigurationException, IOException { Fixture f = new Fixture(); String scheduleXml = "" + "" + @@ -269,7 +269,7 @@ public void test_multipleStopsOnFirstLink_singleLinkRoute_withPassengersAtFirstS } @Test - public void test_multipleStopsOnFirstLink_singleLinkRoute_withPassengersAtSecondStop() throws SAXException, ParserConfigurationException, IOException { + void test_multipleStopsOnFirstLink_singleLinkRoute_withPassengersAtSecondStop() throws SAXException, ParserConfigurationException, IOException { Fixture f = new Fixture(); String scheduleXml = "" + "" + @@ -366,7 +366,7 @@ public void test_multipleStopsOnFirstLink_singleLinkRoute_withPassengersAtSecond * @throws IOException */ @Test - public void test_circularEmptyRoute_singleLinkRoute_noPassengers() throws SAXException, ParserConfigurationException, IOException { + void test_circularEmptyRoute_singleLinkRoute_noPassengers() throws SAXException, ParserConfigurationException, IOException { Fixture f = new Fixture(); String scheduleXml = "" + "" + diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitAgentTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitAgentTest.java index 3b9a0802515..6ec86bdcb5b 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitAgentTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitAgentTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -63,7 +63,8 @@ */ public class TransitAgentTest { - @Test public void testAcceptLineRoute() { + @Test + void testAcceptLineRoute() { MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network = (Network) scenario.getNetwork(); @@ -114,7 +115,8 @@ public class TransitAgentTest { assertTrue(agent.getEnterTransitRoute(line1, route1a, route1a.getStops(), null)); // offering the same line again should yield "true" } - @Test public void testArriveAtStop() { + @Test + void testArriveAtStop() { MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network = (Network) scenario.getNetwork(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitDriverTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitDriverTest.java index e8239c343e0..13b7f743fb8 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitDriverTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitDriverTest.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -78,7 +78,7 @@ public class TransitDriverTest { public MatsimTestUtils util = new MatsimTestUtils(); @Test - public void testInitializationNetworkRoute() { + void testInitializationNetworkRoute() { Config config = ConfigUtils.createConfig(); config.transit().setUseTransit(true); Scenario scenario = ScenarioUtils.createScenario(config); @@ -165,7 +165,7 @@ public void testInitializationNetworkRoute() { } @Test - public void testInitializationDeparture() { + void testInitializationDeparture() { Config config = ConfigUtils.createConfig(); config.transit().setUseTransit(true); Scenario scenario = ScenarioUtils.createScenario(config); @@ -194,7 +194,7 @@ public void testInitializationDeparture() { } @Test - public void testInitializationStops() { + void testInitializationStops() { EventsManager eventsManager = EventsUtils.createEventsManager(); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitLine tLine = builder.createTransitLine(Id.create("L", TransitLine.class)); @@ -246,7 +246,7 @@ public void testInitializationStops() { } @Test - public void testHandleStop_EnterPassengers() { + void testHandleStop_EnterPassengers() { EventsManager eventsManager = EventsUtils.createEventsManager(); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitLine tLine = builder.createTransitLine(Id.create("L", TransitLine.class)); @@ -351,7 +351,7 @@ public void handleEvent(Event ev) { } @Test - public void testHandleStop_ExitPassengers() { + void testHandleStop_ExitPassengers() { EventsManager eventsManager = EventsUtils.createEventsManager(); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitLine tLine = builder.createTransitLine(Id.create("L", TransitLine.class)); @@ -418,7 +418,7 @@ public void testHandleStop_ExitPassengers() { } @Test - public void testHandleStop_CorrectIdentification() { + void testHandleStop_CorrectIdentification() { EventsManager eventsManager = EventsUtils.createEventsManager(); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitLine tLine = builder.createTransitLine(Id.create("L", TransitLine.class)); @@ -461,7 +461,7 @@ public void testHandleStop_CorrectIdentification() { } @Test - public void testHandleStop_AwaitDepartureTime() { + void testHandleStop_AwaitDepartureTime() { EventsManager eventsManager = EventsUtils.createEventsManager(); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitLine tLine = builder.createTransitLine(Id.create("L", TransitLine.class)); @@ -520,7 +520,7 @@ public void testHandleStop_AwaitDepartureTime() { } @Test - public void testExceptionWhenNotEmptyAfterLastStop() { + void testExceptionWhenNotEmptyAfterLastStop() { EventsManager eventsManager = EventsUtils.createEventsManager(); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitLine tLine = builder.createTransitLine(Id.create("L", TransitLine.class)); @@ -581,7 +581,7 @@ public void testExceptionWhenNotEmptyAfterLastStop() { } @Test - public void testExceptionWhenNotAllStopsServed() { + void testExceptionWhenNotAllStopsServed() { EventsManager eventsManager = EventsUtils.createEventsManager(); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitLine tLine = builder.createTransitLine(Id.create("L", TransitLine.class)); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitQueueSimulationTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitQueueSimulationTest.java index d113070bae9..9424a078021 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitQueueSimulationTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitQueueSimulationTest.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.ArrayList; import java.util.Collections; @@ -30,7 +31,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -102,11 +103,11 @@ */ public class TransitQueueSimulationTest { - /** - * Ensure that for each departure an agent is created and departs - */ - @Test - public void testCreateAgents() { + /** + * Ensure that for each departure an agent is created and departs + */ + @Test + void testCreateAgents() { // setup: config final Config config = ConfigUtils.createConfig(); config.transit().setUseTransit(true); @@ -236,11 +237,11 @@ public int compare(MobsimAgent mobsimAgent, MobsimAgent mobsimAgent1) { assertEquals(9.0*3600, agents.get(4).getActivityEndTime(), MatsimTestUtils.EPSILON); } - /** - * Tests that the simulation is adding an agent correctly to the transit stop - */ - @Test - public void testAddAgentToStop() { + /** + * Tests that the simulation is adding an agent correctly to the transit stop + */ + @Test + void testAddAgentToStop() { // setup: config final Config config = ConfigUtils.createConfig(); config.transit().setUseTransit(true); @@ -301,83 +302,85 @@ public void testAddAgentToStop() { assertEquals(1, transitEngine.getAgentTracker().getAgentsAtFacility(stop1.getId()).size()); } - /** - * Tests that the simulation refuses to let an agent teleport herself by starting a transit - * leg on a link where she isn't. - * - */ - @Test(expected = TransitAgentTriesToTeleportException.class) - public void testAddAgentToStopWrongLink() { - // setup: config - final Config config = ConfigUtils.createConfig(); - config.transit().setUseTransit(true); - - MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); - - // setup: network - Network network = scenario.getNetwork(); - Node node1 = network.getFactory().createNode(Id.create("1", Node.class), new Coord((double) 0, (double) 0)); - Node node2 = network.getFactory().createNode(Id.create("2", Node.class), new Coord((double) 1000, (double) 0)); - Node node3 = network.getFactory().createNode(Id.create("3", Node.class), new Coord((double) 2000, (double) 0)); - network.addNode(node1); - network.addNode(node2); - network.addNode(node3); - Link link1 = network.getFactory().createLink(Id.create("1", Link.class), node1, node2); - Link link2 = network.getFactory().createLink(Id.create("2", Link.class), node2, node3); - setDefaultLinkAttributes(link1); - network.addLink(link1); - setDefaultLinkAttributes(link2); - network.addLink(link2); - - // setup: transit schedule - TransitSchedule schedule = scenario.getTransitSchedule(); - TransitScheduleFactory builder = schedule.getFactory(); - TransitLine line = builder.createTransitLine(Id.create("1", TransitLine.class)); - - TransitStopFacility stop1 = builder.createTransitStopFacility(Id.create("stop1", TransitStopFacility.class), new Coord((double) 0, (double) 0), false); - stop1.setLinkId(link1.getId()); - TransitStopFacility stop2 = builder.createTransitStopFacility(Id.create("stop2", TransitStopFacility.class), new Coord((double) 0, (double) 0), false); - stop2.setLinkId(link2.getId()); - schedule.addStopFacility(stop1); - schedule.addStopFacility(stop2); - - // setup: population - Population population = scenario.getPopulation(); - PopulationFactory pb = population.getFactory(); - Person person = pb.createPerson(Id.create("1", Person.class)); - Plan plan = pb.createPlan(); - person.addPlan(plan); - Activity homeAct = pb.createActivityFromLinkId("home", Id.create("2", Link.class)); - - homeAct.setEndTime(7.0*3600 - 10.0); - // as no transit line runs, make sure to stop the simulation manually. - scenario.getConfig().qsim().setEndTime(7.0*3600); - - Leg leg = pb.createLeg(TransportMode.pt); - leg.setRoute(new DefaultTransitPassengerRoute(stop1, line, null, stop2)); - Activity workAct = pb.createActivityFromLinkId("work", Id.create("1", Link.class)); - plan.addActivity(homeAct); - plan.addLeg(leg); - plan.addActivity(workAct); - population.addPerson(person); - - // run simulation - EventsManager events = EventsUtils.createEventsManager(); - PrepareForSimUtils.createDefaultPrepareForSim(scenario).run(); - new QSimBuilder(scenario.getConfig()) // - .useDefaults() // - .build(scenario, events) // - .run(); - } - - /** - * Tests that a vehicle's handleStop() method is correctly called, e.g. - * it is re-called again when returning a delay > 0, and that is is correctly - * called when the stop is located on the first link of the network route, on the last - * link of the network route, or any intermediary link. - */ - @Test - public void testHandleStop() { + /** + * Tests that the simulation refuses to let an agent teleport herself by starting a transit + * leg on a link where she isn't. + * + */ + @Test + void testAddAgentToStopWrongLink() { + assertThrows(TransitAgentTriesToTeleportException.class, () -> { + // setup: config + final Config config = ConfigUtils.createConfig(); + config.transit().setUseTransit(true); + + MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); + + // setup: network + Network network = scenario.getNetwork(); + Node node1 = network.getFactory().createNode(Id.create("1", Node.class), new Coord((double) 0, (double) 0)); + Node node2 = network.getFactory().createNode(Id.create("2", Node.class), new Coord((double) 1000, (double) 0)); + Node node3 = network.getFactory().createNode(Id.create("3", Node.class), new Coord((double) 2000, (double) 0)); + network.addNode(node1); + network.addNode(node2); + network.addNode(node3); + Link link1 = network.getFactory().createLink(Id.create("1", Link.class), node1, node2); + Link link2 = network.getFactory().createLink(Id.create("2", Link.class), node2, node3); + setDefaultLinkAttributes(link1); + network.addLink(link1); + setDefaultLinkAttributes(link2); + network.addLink(link2); + + // setup: transit schedule + TransitSchedule schedule = scenario.getTransitSchedule(); + TransitScheduleFactory builder = schedule.getFactory(); + TransitLine line = builder.createTransitLine(Id.create("1", TransitLine.class)); + + TransitStopFacility stop1 = builder.createTransitStopFacility(Id.create("stop1", TransitStopFacility.class), new Coord((double) 0, (double) 0), false); + stop1.setLinkId(link1.getId()); + TransitStopFacility stop2 = builder.createTransitStopFacility(Id.create("stop2", TransitStopFacility.class), new Coord((double) 0, (double) 0), false); + stop2.setLinkId(link2.getId()); + schedule.addStopFacility(stop1); + schedule.addStopFacility(stop2); + + // setup: population + Population population = scenario.getPopulation(); + PopulationFactory pb = population.getFactory(); + Person person = pb.createPerson(Id.create("1", Person.class)); + Plan plan = pb.createPlan(); + person.addPlan(plan); + Activity homeAct = pb.createActivityFromLinkId("home", Id.create("2", Link.class)); + + homeAct.setEndTime(7.0 * 3600 - 10.0); + // as no transit line runs, make sure to stop the simulation manually. + scenario.getConfig().qsim().setEndTime(7.0 * 3600); + + Leg leg = pb.createLeg(TransportMode.pt); + leg.setRoute(new DefaultTransitPassengerRoute(stop1, line, null, stop2)); + Activity workAct = pb.createActivityFromLinkId("work", Id.create("1", Link.class)); + plan.addActivity(homeAct); + plan.addLeg(leg); + plan.addActivity(workAct); + population.addPerson(person); + + // run simulation + EventsManager events = EventsUtils.createEventsManager(); + PrepareForSimUtils.createDefaultPrepareForSim(scenario).run(); + new QSimBuilder(scenario.getConfig()) // + .useDefaults() // + .build(scenario, events) // + .run(); + }); + } + + /** + * Tests that a vehicle's handleStop() method is correctly called, e.g. + * it is re-called again when returning a delay > 0, and that is is correctly + * called when the stop is located on the first link of the network route, on the last + * link of the network route, or any intermediary link. + */ + @Test + void testHandleStop() { // setup: config final Config config = ConfigUtils.createConfig(); config.transit().setUseTransit(true); @@ -627,8 +630,8 @@ protected SpyHandleStopData(final TransitStopFacility stopFacility, final double } } - @Test - public void testStartAndEndTime() { + @Test + void testStartAndEndTime() { final Config config = ConfigUtils.createConfig(); config.transit().setUseTransit(true); @@ -724,8 +727,8 @@ public void reset(final int iteration) { } } - @Test - public void testEvents() { + @Test + void testEvents() { final Config config = ConfigUtils.createConfig(); config.transit().setUseTransit(true); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitStopAgentTrackerTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitStopAgentTrackerTest.java index 661db42f779..fe957af3ece 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitStopAgentTrackerTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitStopAgentTrackerTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.core.api.experimental.events.EventsManager; @@ -42,7 +42,8 @@ public class TransitStopAgentTrackerTest { private static final Logger log = LogManager.getLogger(TransitStopAgentTrackerTest.class); - @Test public void testAddAgent() { + @Test + void testAddAgent() { EventsManager events = EventsUtils.createEventsManager(); TransitStopAgentTracker tracker = new TransitStopAgentTracker(events); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); @@ -67,7 +68,8 @@ public class TransitStopAgentTrackerTest { assertTrue(tracker.getAgentsAtFacility(stop2.getId()).contains(agent3)); } - @Test public void testRemoveAgent() { + @Test + void testRemoveAgent() { EventsManager events = EventsUtils.createEventsManager(); TransitStopAgentTracker tracker = new TransitStopAgentTracker(events); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); @@ -92,7 +94,8 @@ public class TransitStopAgentTrackerTest { assertEquals(1, tracker.getAgentsAtFacility(stop1.getId()).size()); // should stay the same } - @Test public void testGetAgentsAtStopImmutable() { + @Test + void testGetAgentsAtStopImmutable() { EventsManager events = EventsUtils.createEventsManager(); TransitStopAgentTracker tracker = new TransitStopAgentTracker(events); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitVehicleTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitVehicleTest.java index 33a84d1219f..dcc4082886c 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitVehicleTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitVehicleTest.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.pt.fakes.FakePassengerAgent; import org.matsim.testcases.MatsimTestUtils; @@ -46,7 +46,8 @@ private TransitVehicle createTransitVehicle(final Vehicle vehicle) { return new TransitQVehicle(vehicle); } - @Test public void testSizeInEquivalents() { + @Test + void testSizeInEquivalents() { VehicleType carType = VehicleUtils.createVehicleType(Id.create("carType", VehicleType.class ) ); VehicleType busType = VehicleUtils.createVehicleType(Id.create("busType", VehicleType.class ) ); busType.setPcuEquivalents(2.5); @@ -60,7 +61,8 @@ private TransitVehicle createTransitVehicle(final Vehicle vehicle) { assertEquals(2.5, veh.getSizeInEquivalents(), MatsimTestUtils.EPSILON); } - @Test public void testInitialization_SeatAndStandCapacity() { + @Test + void testInitialization_SeatAndStandCapacity() { VehicleType vehType = VehicleUtils.createVehicleType(Id.create("busType", VehicleType.class ) ); vehType.getCapacity().setSeats(Integer.valueOf(5)); vehType.getCapacity().setStandingRoom(Integer.valueOf(2)); @@ -70,7 +72,8 @@ private TransitVehicle createTransitVehicle(final Vehicle vehicle) { assertEquals(7, veh.getPassengerCapacity()); } - @Test public void testInitialization_SeatOnlyCapacity() { + @Test + void testInitialization_SeatOnlyCapacity() { VehicleType vehType = VehicleUtils.createVehicleType(Id.create("busType", VehicleType.class ) ); vehType.getCapacity().setSeats(Integer.valueOf(4)); Vehicle vehicle = VehicleUtils.createVehicle(Id.create(1976, Vehicle.class ), vehType ); @@ -79,7 +82,8 @@ private TransitVehicle createTransitVehicle(final Vehicle vehicle) { assertEquals(4, veh.getPassengerCapacity()); } - @Test public void testInitialization_NoCapacity() { + @Test + void testInitialization_NoCapacity() { VehicleType vehType = VehicleUtils.createVehicleType(Id.create("busType", VehicleType.class ) ); Vehicle vehicle = VehicleUtils.createVehicle(Id.create(1976, Vehicle.class ), vehType ); try { @@ -91,7 +95,8 @@ private TransitVehicle createTransitVehicle(final Vehicle vehicle) { } } - @Test public void testAddPassenger() { + @Test + void testAddPassenger() { VehicleType vehType = VehicleUtils.createVehicleType(Id.create("busType", VehicleType.class ) ); vehType.getCapacity().setSeats(Integer.valueOf(5)); Vehicle vehicle = VehicleUtils.createVehicle(Id.create(1976, Vehicle.class ), vehType ); @@ -111,7 +116,8 @@ private TransitVehicle createTransitVehicle(final Vehicle vehicle) { assertFalse(veh.addPassenger(new FakePassengerAgent(null))); } - @Test public void testRemovePassenger() { + @Test + void testRemovePassenger() { VehicleType vehType = VehicleUtils.createVehicleType(Id.create("busType", VehicleType.class ) ); vehType.getCapacity().setSeats(Integer.valueOf(5)); Vehicle vehicle = VehicleUtils.createVehicle(Id.create(1976, Vehicle.class ), vehType ); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/UmlaufDriverTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/UmlaufDriverTest.java index a30dfcc609f..bf5bd5adb2c 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/UmlaufDriverTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/UmlaufDriverTest.java @@ -29,8 +29,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -84,7 +84,8 @@ public class UmlaufDriverTest { utils.loadConfig((String)null); } - @Test public void testInitializationNetworkRoute() { + @Test + void testInitializationNetworkRoute() { TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitLine tLine = builder.createTransitLine(Id.create("L", TransitLine.class)); ArrayList> linkIds = new ArrayList>(); @@ -172,7 +173,8 @@ private Umlauf buildUmlauf(TransitLine tLine) { return new SingletonUmlaufBuilderImpl(Collections.singletonList(tLine)).build().get(0); } - @Test public void testInitializationDeparture() { + @Test + void testInitializationDeparture() { TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitLine tLine = builder.createTransitLine(Id.create("L", TransitLine.class)); NetworkRoute route = RouteUtils.createLinkNetworkRouteImpl(null, null); @@ -197,7 +199,8 @@ private Umlauf buildUmlauf(TransitLine tLine) { assertEquals(depTime, driver.getActivityEndTime(), MatsimTestUtils.EPSILON); } - @Test public void testInitializationStops() { + @Test + void testInitializationStops() { EventsManager events = EventsUtils.createEventsManager(); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitLine tLine = builder.createTransitLine(Id.create("L", TransitLine.class)); @@ -248,7 +251,8 @@ private Umlauf buildUmlauf(TransitLine tLine) { assertEquals(null, driver.getNextTransitStop()); } - @Test public void testHandleStop_EnterPassengers() { + @Test + void testHandleStop_EnterPassengers() { EventsManager events = EventsUtils.createEventsManager(); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitLine tLine = builder.createTransitLine(Id.create("L", TransitLine.class)); @@ -324,7 +328,8 @@ private Umlauf buildUmlauf(TransitLine tLine) { 0.0, driver.handleTransitStop(stop2, 170), MatsimTestUtils.EPSILON); } - @Test public void testHandleStop_ExitPassengers() { + @Test + void testHandleStop_ExitPassengers() { EventsManager events = EventsUtils.createEventsManager(); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitLine tLine = builder.createTransitLine(Id.create("L", TransitLine.class)); @@ -391,7 +396,8 @@ private Umlauf buildUmlauf(TransitLine tLine) { assertEquals(0.0, driver.handleTransitStop(stop2, 160), MatsimTestUtils.EPSILON); } - @Test public void testReturnSensiblePlanElements() { + @Test + void testReturnSensiblePlanElements() { EventsManager events = EventsUtils.createEventsManager(); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitLine tLine = builder.createTransitLine(Id.create("L", TransitLine.class)); @@ -434,7 +440,8 @@ private Umlauf buildUmlauf(TransitLine tLine) { assertTrue(driver.getCurrentPlanElement() instanceof Activity); } - @Test public void testHandleStop_CorrectIdentification() { + @Test + void testHandleStop_CorrectIdentification() { EventsManager events = EventsUtils.createEventsManager(); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitLine tLine = builder.createTransitLine(Id.create("L", TransitLine.class)); @@ -476,7 +483,8 @@ private Umlauf buildUmlauf(TransitLine tLine) { assertEquals(tLine, agent.offeredLine); } - @Test public void testHandleStop_AwaitDepartureTime() { + @Test + void testHandleStop_AwaitDepartureTime() { EventsManager events = EventsUtils.createEventsManager(); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitLine tLine = builder.createTransitLine(Id.create("L", TransitLine.class)); @@ -535,7 +543,8 @@ private Umlauf buildUmlauf(TransitLine tLine) { assertEquals(0.0, driver.handleTransitStop(stop3, departureTime + 210), MatsimTestUtils.EPSILON); } - @Test public void testExceptionWhenNotEmptyAfterLastStop() { + @Test + void testExceptionWhenNotEmptyAfterLastStop() { EventsManager events = EventsUtils.createEventsManager(); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitLine tLine = builder.createTransitLine(Id.create("L", TransitLine.class)); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/DeparturesOnSameLinkSameTimeTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/DeparturesOnSameLinkSameTimeTest.java index f6af0e77d91..69911b6e800 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/DeparturesOnSameLinkSameTimeTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/DeparturesOnSameLinkSameTimeTest.java @@ -19,7 +19,7 @@ package org.matsim.core.mobsim.qsim.qnetsimengine; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -60,7 +60,7 @@ public class DeparturesOnSameLinkSameTimeTest { * whereas cars should leave at a gap of one second. */ @Test - public void test4LinkEnterTimeOfCarAndBike () { + void test4LinkEnterTimeOfCarAndBike() { Id firstAgent = Id.createVehicleId(1); Id secondAgent = Id.createVehicleId(2); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/EquiDistAgentSnapshotInfoBuilderTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/EquiDistAgentSnapshotInfoBuilderTest.java index 0e9d83d72ea..21566dda480 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/EquiDistAgentSnapshotInfoBuilderTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/EquiDistAgentSnapshotInfoBuilderTest.java @@ -1,6 +1,6 @@ package org.matsim.core.mobsim.qsim.qnetsimengine; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -32,8 +32,8 @@ public class EquiDistAgentSnapshotInfoBuilderTest { - @Test - public void positionVehiclesAlongLine_singleVehicleFreeFlow(){ + @Test + void positionVehiclesAlongLine_singleVehicleFreeFlow(){ var setUp = new SimpleTestSetUp(); List outCollection = new ArrayList<>(); @@ -64,8 +64,8 @@ public void positionVehiclesAlongLine_singleVehicleFreeFlow(){ assertEquals(setUp.linkLength / 2, firstEntry.getEasting(), 0.00001); } - @Test - public void positionVehiclesAlongLine_congestedAboveCapacityLimit() { + @Test + void positionVehiclesAlongLine_congestedAboveCapacityLimit() { var setUp = new SimpleTestSetUp(); List outCollection = new ArrayList<>(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowCapacityVariationTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowCapacityVariationTest.java index aac8fccef3f..644fab1765f 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowCapacityVariationTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowCapacityVariationTest.java @@ -21,7 +21,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -59,23 +59,23 @@ * @author amit */ public class FlowCapacityVariationTest { - + @Test - public void twoCarsLeavingTimes () { + void twoCarsLeavingTimes() { vehiclesLeavingSameTime(TransportMode.car,3601); } - @Test - public void twoMotorbikesTravelTime(){ + @Test + void twoMotorbikesTravelTime(){ /* linkCapacity higher than 1PCU/sec*/ vehiclesLeavingSameTime("motorbike",3601); /*link capacuty higher than 1motorbike/sec = 0.25PCU/sec */ vehiclesLeavingSameTime("motorbike",1800); } - - @Test - public void twoBikesTravelTime(){ + + @Test + void twoBikesTravelTime(){ /* linkCapacity higher than 1PCU/sec */ vehiclesLeavingSameTime(TransportMode.bike,3601); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowEfficiencyCalculatorTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowEfficiencyCalculatorTest.java index c343ec924ae..aaf251d8c0d 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowEfficiencyCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowEfficiencyCalculatorTest.java @@ -23,7 +23,7 @@ import com.google.inject.Provides; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -50,7 +50,7 @@ public class FlowEfficiencyCalculatorTest { @Test - public void testFlowEfficiencyCalculator() { + void testFlowEfficiencyCalculator() { // In this test we send 1000 vehicles over a link with capacity 500. We then // define a custom FlowEfficiencyCalculator that varies the flow efficiency // globally. We see that with infinite flow efficiency, vehicles move in diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/JavaRoundingErrorInQsimTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/JavaRoundingErrorInQsimTest.java index cf722576d5b..bf1b8ee6733 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/JavaRoundingErrorInQsimTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/JavaRoundingErrorInQsimTest.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -66,7 +66,7 @@ public class JavaRoundingErrorInQsimTest { @Test - public void printDecimalSum(){ + void printDecimalSum(){ double a = 0.1; double sum =0; double counter = 0; @@ -77,9 +77,9 @@ public void printDecimalSum(){ System.out.println("Sum at counter "+counter+" is "+sum); } } - + @Test - public void testToCheckTravelTime () { + void testToCheckTravelTime() { // 2 cars depart on same time, central (bottleneck) link allow only 1 agent / 10 sec. PseudoInputs net = new PseudoInputs(); net.createNetwork(360); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/LinkSpeedCalculatorIntegrationTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/LinkSpeedCalculatorIntegrationTest.java index 7f1d04bc347..f72301f3fd0 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/LinkSpeedCalculatorIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/LinkSpeedCalculatorIntegrationTest.java @@ -23,8 +23,8 @@ import jakarta.inject.Inject; import jakarta.inject.Provider; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -61,7 +61,7 @@ public class LinkSpeedCalculatorIntegrationTest { @RegisterExtension private MatsimTestUtils helper = new MatsimTestUtils(); @Test - public void testIntegration_Default() { + void testIntegration_Default() { Fixture f = new Fixture(); EventsCollector collector = new EventsCollector(); f.events.addHandler(collector); @@ -90,7 +90,7 @@ public void testIntegration_Default() { @SuppressWarnings("static-method") @Test - public void testIntegration_Slow() { + void testIntegration_Slow() { Fixture f = new Fixture(); final Scenario scenario = f.scenario ; @@ -142,7 +142,7 @@ public void testIntegration_Slow() { @SuppressWarnings("static-method") @Test - public void testIntegration_Fast() { + void testIntegration_Fast() { Fixture f = new Fixture(); final Scenario scenario = f.scenario ; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/PassingTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/PassingTest.java index 554b88b3059..ceac270a514 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/PassingTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/PassingTest.java @@ -21,8 +21,8 @@ import java.util.*; import jakarta.inject.Inject; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -71,7 +71,7 @@ public class PassingTest { * tt_car = 50 sec; tt_bike = 200 sec */ @Test - public void test4PassingInFreeFlowState(){ + void test4PassingInFreeFlowState(){ SimpleNetwork net = new SimpleNetwork(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkLanesTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkLanesTest.java index 064025f4fe1..76e0c77788b 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkLanesTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkLanesTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -134,7 +134,8 @@ private static void createThreeLanes(Scenario scenario) { lanes.addLanesToLinkAssignment(lanesForLink1); } - @Test public void testCapacityWoLanes() { + @Test + void testCapacityWoLanes() { Config config = ConfigUtils.createConfig(); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); initNetwork(scenario.getNetwork()); @@ -151,7 +152,8 @@ private static void createThreeLanes(Scenario scenario) { assertEquals(268.0, ql.getSpaceCap(), 0); } - @Test public void testCapacityWithOneLaneOneLane() { + @Test + void testCapacityWithOneLaneOneLane() { Config config = ConfigUtils.createConfig(); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); initNetwork(scenario.getNetwork()); @@ -186,7 +188,8 @@ private static void createThreeLanes(Scenario scenario) { assertEquals(14.0, qlane.getStorageCapacity(), 0); } - @Test public void testCapacityWithOneLaneTwoLanes() { + @Test + void testCapacityWithOneLaneTwoLanes() { Config config = ConfigUtils.createConfig(); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); initNetwork(scenario.getNetwork()); @@ -222,8 +225,8 @@ private static void createThreeLanes(Scenario scenario) { } - - @Test public void testCapacityWithLanes() { + @Test + void testCapacityWithLanes() { Config config = ConfigUtils.createConfig(); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); initNetwork(scenario.getNetwork()); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkTest.java index bb83c11c1d8..9ccdd910c12 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkTest.java @@ -28,8 +28,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @@ -106,7 +106,8 @@ public static Collection parameterObjects () { } - @Test public void testInit() { + @Test + void testInit() { Fixture f = new Fixture(isUsingFastCapacityUpdate); assertNotNull(f.qlink1); assertEquals(1.0, f.qlink1.getSimulatedFlowCapacityPerTimeStep(), MatsimTestUtils.EPSILON); @@ -120,7 +121,8 @@ public static Collection parameterObjects () { } - @Test public void testAdd() { + @Test + void testAdd() { Fixture f = new Fixture(isUsingFastCapacityUpdate); assertEquals(0, ((QueueWithBuffer) f.qlink1.getAcceptingQLane()).getAllVehicles().size()); QVehicle v = new QVehicleImpl(f.basicVehicle); @@ -151,7 +153,8 @@ private static PersonDriverAgentImpl createAndInsertPersonDriverAgentImpl(Person * @author mrieser */ - @Test public void testGetVehicle_Driving() { + @Test + void testGetVehicle_Driving() { Fixture f = new Fixture(isUsingFastCapacityUpdate); Id id1 = Id.create("1", Vehicle.class); @@ -216,7 +219,8 @@ private static PersonDriverAgentImpl createAndInsertPersonDriverAgentImpl(Person * @author mrieser */ - @Test public void testGetVehicle_Parking() { + @Test + void testGetVehicle_Parking() { Fixture f = new Fixture(isUsingFastCapacityUpdate); Id id1 = Id.create("1", Vehicle.class); @@ -253,7 +257,8 @@ private static PersonDriverAgentImpl createAndInsertPersonDriverAgentImpl(Person * @author mrieser */ - @Test public void testGetVehicle_Departing() { + @Test + void testGetVehicle_Departing() { Fixture f = new Fixture(isUsingFastCapacityUpdate); Id id1 = Id.create("1", Vehicle.class); @@ -317,7 +322,8 @@ private static PersonDriverAgentImpl createAndInsertPersonDriverAgentImpl(Person * @author mrieser */ - @Test public void testBuffer() { + @Test + void testBuffer() { Config conf = utils.loadConfig((String)null); conf.qsim().setUsingFastCapacityUpdate(isUsingFastCapacityUpdate); @@ -440,7 +446,8 @@ private static Person createPerson(Id personId, MutableScenario scenario } - @Test public void testStorageSpaceDifferentVehicleSizes() { + @Test + void testStorageSpaceDifferentVehicleSizes() { Fixture f = new Fixture(isUsingFastCapacityUpdate); @@ -541,7 +548,8 @@ private Person createPerson2(Id personId, Fixture f) { } - @Test public void testStuckEvents() { + @Test + void testStuckEvents() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); scenario.getConfig().qsim().setStuckTime(100); scenario.getConfig().qsim().setRemoveStuckVehicles(true); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QSimComponentsTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QSimComponentsTest.java index 28f2c1bd0dd..2a3cf2d781e 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QSimComponentsTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QSimComponentsTest.java @@ -1,11 +1,13 @@ package org.matsim.core.mobsim.qsim.qnetsimengine; +import static org.junit.jupiter.api.Assertions.assertThrows; + import com.google.inject.Inject; import com.google.inject.ProvisionException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Node; @@ -32,59 +34,65 @@ public class QSimComponentsTest{ private static final Logger log = LogManager.getLogger( QSimComponentsTest.class ); @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Test(expected = RuntimeException.class) - public void testRemoveNetsimEngine() { - // test removing a default qsim module by name + @Test + void testRemoveNetsimEngine() { + assertThrows(RuntimeException.class, () -> { + // test removing a default qsim module by name - // running MATSim should fail after removing the netsim engine, since some of the routes do not have a travel time, and in consequence cannot - // be teleported if netsim engine is missing. Thus, the RuntimeException confirms that removing the module worked. + // running MATSim should fail after removing the netsim engine, since some of the routes do not have a travel time, and in consequence cannot + // be teleported if netsim engine is missing. Thus, the RuntimeException confirms that removing the module worked. - Config config = ConfigUtils.loadConfig( IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ) ); - config.controller().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); - config.controller().setLastIteration( 0 ); - config.controller().setOutputDirectory(utils.getOutputDirectory()); + Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); + config.controller().setOutputDirectory(utils.getOutputDirectory()); - // remove the module: (There is also syntax at some intermediate level for this, but I prefer the syntax at config level. kai, oct'22) - QSimComponentsConfigGroup componentsConfig = ConfigUtils.addOrGetModule( config, QSimComponentsConfigGroup.class ); - List components = componentsConfig.getActiveComponents(); - components.remove( QNetsimEngineModule.COMPONENT_NAME ); - componentsConfig.setActiveComponents( components ); + // remove the module: (There is also syntax at some intermediate level for this, but I prefer the syntax at config level. kai, oct'22) + QSimComponentsConfigGroup componentsConfig = ConfigUtils.addOrGetModule(config, QSimComponentsConfigGroup.class); + List components = componentsConfig.getActiveComponents(); + components.remove(QNetsimEngineModule.COMPONENT_NAME); + componentsConfig.setActiveComponents(components); - Scenario scenario = ScenarioUtils.loadScenario( config ); + Scenario scenario = ScenarioUtils.loadScenario(config); - Controler controler = new Controler( scenario ); + Controler controler = new Controler( scenario ); - controler.run(); + controler.run(); + }); } - @Test(expected= ProvisionException.class) - public void testReplaceQNetworkFactory() { - // here we try to replace the QNetworkFactory. Complains that QNetworkFactory is bound multiple times. - - Config config = ConfigUtils.loadConfig( IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ) ); - config.controller().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); - config.controller().setLastIteration( 0 ); - config.controller().setOutputDirectory(utils.getOutputDirectory()); - - Scenario scenario = ScenarioUtils.loadScenario( config ); - - Controler controler = new Controler( scenario ); - - controler.addOverridingModule( new AbstractModule(){ - @Override public void install(){ - this.installQSimModule( new AbstractQSimModule(){ - @Override protected void configureQSim(){ - bind( QNetworkFactory.class ).to( MyNetworkFactory.class ); - } - } ); - } - } ); - - controler.run(); + @Test + void testReplaceQNetworkFactory() { + assertThrows(ProvisionException.class, () -> { + // here we try to replace the QNetworkFactory. Complains that QNetworkFactory is bound multiple times. + + Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + + Scenario scenario = ScenarioUtils.loadScenario(config); + + Controler controler = new Controler( scenario ); + + controler.addOverridingModule(new AbstractModule(){ + @Override + public void install() { + this.installQSimModule(new AbstractQSimModule(){ + @Override + protected void configureQSim() { + bind(QNetworkFactory.class).to(MyNetworkFactory.class); + } + }); + } + }); + + controler.run(); + }); } @Test - public void testReplaceQNetworkFactory2() { + void testReplaceQNetworkFactory2() { // here we try to replace the QNetworkFactory at AbstractQSimModule. This works. Config config = ConfigUtils.loadConfig( IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ) ); @@ -106,7 +114,7 @@ public void testReplaceQNetworkFactory2() { } @Test - public void testOverridingQSimModule() { + void testOverridingQSimModule() { // use the newly implemented install _overriding_ qsim module. With this, replacing the QNetworkFactory now works as part of AbstractModule. Config config = ConfigUtils.loadConfig( IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ) ); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QueueAgentSnapshotInfoBuilderTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QueueAgentSnapshotInfoBuilderTest.java index ae07ea71565..325ef2996c1 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QueueAgentSnapshotInfoBuilderTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QueueAgentSnapshotInfoBuilderTest.java @@ -1,6 +1,6 @@ package org.matsim.core.mobsim.qsim.qnetsimengine; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -32,8 +32,8 @@ public class QueueAgentSnapshotInfoBuilderTest { - @Test - public void positionVehiclesAlongLine_singleVehicleFreeFlow() { + @Test + void positionVehiclesAlongLine_singleVehicleFreeFlow() { var setUp = new SimpleTestSetUp(); List outCollection = new ArrayList<>(); @@ -73,8 +73,8 @@ public void positionVehiclesAlongLine_singleVehicleFreeFlow() { assertEquals(AgentSnapshotInfo.AgentState.PERSON_DRIVING_CAR, firstEntry.getAgentState()); } - @Test - public void positionVehiclesAlongLine_congestedAboveCapacityLimit() { + @Test + void positionVehiclesAlongLine_congestedAboveCapacityLimit() { var setUp = new SimpleTestSetUp(); List outCollection = new ArrayList<>(); @@ -111,8 +111,8 @@ public void positionVehiclesAlongLine_congestedAboveCapacityLimit() { } } - @Test - public void positionVehiclesAlongLine_queueAtEnd() { + @Test + void positionVehiclesAlongLine_queueAtEnd() { var setUp = new SimpleTestSetUp(); // use other vehicle list than in simple set up @@ -180,8 +180,8 @@ private static void assertStackedPositions(Collection positio } } - @Test - public void positionAgentsInActivities() { + @Test + void positionAgentsInActivities() { var setUp = new SimpleTestSetUp(); List outCollection = new ArrayList<>(); @@ -197,8 +197,8 @@ public void positionAgentsInActivities() { } - @Test - public void positionVehiclesFromWaitingList() { + @Test + void positionVehiclesFromWaitingList() { var setUp = new SimpleTestSetUp(); List outCollection = new ArrayList<>(); @@ -218,8 +218,8 @@ public void positionVehiclesFromWaitingList() { outCollection.forEach(position -> assertEquals(Id.createVehicleId(1), position.getVehicleId())); } - @Test - public void positionVehiclesFromTransitStop() { + @Test + void positionVehiclesFromTransitStop() { var setUp = new SimpleTestSetUp(); List outCollection = new ArrayList<>(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/RunConfigurableQNetworkFactoryExampleTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/RunConfigurableQNetworkFactoryExampleTest.java index 958ba50b9ea..57751c8381a 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/RunConfigurableQNetworkFactoryExampleTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/RunConfigurableQNetworkFactoryExampleTest.java @@ -18,7 +18,7 @@ * *********************************************************************** */ package org.matsim.core.mobsim.qsim.qnetsimengine; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; @@ -34,7 +34,7 @@ public class RunConfigurableQNetworkFactoryExampleTest { */ @SuppressWarnings("static-method") @Test - public final void testMain() { + final void testMain() { try { Config config = ConfigUtils.createConfig() ; config.controller().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SeepageTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SeepageTest.java index 4002e1b4cbb..6a18868b17d 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SeepageTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SeepageTest.java @@ -21,7 +21,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @@ -75,7 +75,7 @@ public static Collection parameterObjects () { Object [] capacityUpdates = new Object [] { false, true }; return Arrays.asList(capacityUpdates); } - + /** * Two carAgents end act at time 948 and 949 sec and walkAgent ends act at 49 sec. * Link length is 1 km and flow capacity 1 PCU/min. Speed of car and walk is 20 mps and 1 mps. @@ -83,8 +83,8 @@ public static Collection parameterObjects () { * WalkAgent joins queue at 1050 sec but leave link before second car at 1060 sec and thus blocking link for another 6 sec(flowCap*PCU) * Thus, second car leaves link after walkAgent. */ - @Test - public void seepageOfWalkInCongestedRegime(){ + @Test + void seepageOfWalkInCongestedRegime(){ SimpleNetwork net = new SimpleNetwork(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java index 01ee89e122e..92e225da500 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java @@ -27,8 +27,8 @@ import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -207,7 +207,8 @@ private static void initPopulation(Population population) { * test simulated capacity of link 1 in case without lanes. * the capacity should correspond to the given flow capacity of the link */ - @Test public void testCapacityWoLanes() { + @Test + void testCapacityWoLanes() { Config config = ConfigUtils.createConfig(); ActivityParams dummyAct = new ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); @@ -234,7 +235,8 @@ private static void initPopulation(Population population) { * test simulated capacities of link 1 in case of one lane representing one lane. * the capacity of the link should correspond to the capacity of the lane, also when it is less than the link capacity given in the network. */ - @Test public void testCapacityWithOneLaneOneLane() { + @Test + void testCapacityWithOneLaneOneLane() { Config config = ConfigUtils.createConfig(); ActivityParams dummyAct = new ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); @@ -265,7 +267,8 @@ private static void initPopulation(Population population) { * test simulated capacities of link 1 in case of one lane representing two lanes. * the capacity of the link should correspond to the capacity of the lane, also when it is less than the link capacity given in the network. */ - @Test public void testCapacityWithOneLaneTwoLanes() { + @Test + void testCapacityWithOneLaneTwoLanes() { Config config = ConfigUtils.createConfig(); ActivityParams dummyAct = new ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); @@ -297,7 +300,8 @@ private static void initPopulation(Population population) { * Interestingly, it also corresponds to this sum, if it is more than the link capacity given in the network. * And, finally, it still only uses the lane capacity given in the network, when it is higher than the link capacity (see lane 2 here). */ - @Test public void testCapacityWithThreeLanes() { + @Test + void testCapacityWithThreeLanes() { Config config = ConfigUtils.createConfig(); ActivityParams dummyAct = new ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SpeedCalculatorTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SpeedCalculatorTest.java index dcef567b287..cc4b76d055c 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SpeedCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SpeedCalculatorTest.java @@ -1,8 +1,8 @@ package org.matsim.core.mobsim.qsim.qnetsimengine; import com.google.inject.Singleton; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -37,7 +37,8 @@ public class SpeedCalculatorTest{ private final Config config = ConfigUtils.createConfig(); private final Network unusedNetwork = NetworkUtils.createNetwork(); - @Test public void limitedByVehicleSpeed() { + @Test + void limitedByVehicleSpeed() { Link link = createLinkWithNoGradientAndNoSpecialSurface(); VehicleType type = VehicleUtils.createVehicleType(Id.create("no-bike", VehicleType.class ) ); type.setMaximumVelocity(link.getFreespeed() / 2); // less than the link's freespeed @@ -48,7 +49,9 @@ public class SpeedCalculatorTest{ assertEquals( type.getMaximumVelocity(), getSpeedOnLink( link, vehicle ), 0.0 ); } - @Test public void limitedByLinkSpeed() { + + @Test + void limitedByLinkSpeed() { Link link = createLinkWithNoGradientAndNoSpecialSurface(); @@ -61,7 +64,9 @@ public class SpeedCalculatorTest{ assertEquals( link.getFreespeed(), getSpeedOnLink( link, vehicle ), 0.0 ); } - @Test public void bikeWithSpecificLinkSpeedCalculator() { + + @Test + void bikeWithSpecificLinkSpeedCalculator() { Link link = createLinkWithNoGradientAndNoSpecialSurface(); @@ -76,7 +81,9 @@ public class SpeedCalculatorTest{ assertEquals( type.getMaximumVelocity()*1.5, getSpeedOnLink( link, vehicle ), 0.0 ); // (specific link speed calculator uses speed that is larger than maximum vehicle speed) } - @Test public void bikeLimitedByLinkFreespeed() { + + @Test + void bikeLimitedByLinkFreespeed() { Link link = createLinkWithNoGradientAndNoSpecialSurface(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehVsLinkSpeedTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehVsLinkSpeedTest.java index bb7c940987c..765d3875106 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehVsLinkSpeedTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehVsLinkSpeedTest.java @@ -20,7 +20,7 @@ import java.util.*; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @@ -77,9 +77,9 @@ public static Collection createFds() { }; return Arrays.asList(vehSpeeds); } - - @Test - public void testVehicleSpeed(){ + + @Test + void testVehicleSpeed(){ SimpleNetwork net = new SimpleNetwork(); Id id = Id.createPersonId(0); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java index 6919f8f020c..b258f338ef5 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java @@ -24,8 +24,8 @@ import java.util.Arrays; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -61,7 +61,7 @@ public class VehicleHandlerTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testVehicleHandler() { + void testVehicleHandler() { // This is a test where there is a link with a certain parking capacity. As soon // as // it is reached the link is blocking, until a vehicle is leaving the link diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleWaitingTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleWaitingTest.java index c8b0231e2c5..133dd1d9ed9 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleWaitingTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleWaitingTest.java @@ -26,7 +26,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -66,22 +66,22 @@ public class VehicleWaitingTest { @Test - public void testVehicleWaitingOneLapDoesntFailNoDummies() { + void testVehicleWaitingOneLapDoesntFailNoDummies() { testVehicleWaitingDoesntFail( 1 , false ); } @Test - public void testVehicleWaitingOneLapDoesntFailDummies() { + void testVehicleWaitingOneLapDoesntFailDummies() { testVehicleWaitingDoesntFail( 1 , true ); } @Test - public void testVehicleWaitingSeveralLapDoesntFailNoDummies() { + void testVehicleWaitingSeveralLapDoesntFailNoDummies() { testVehicleWaitingDoesntFail( 4 , false ); } @Test - public void testVehicleWaitingSeveralLapDoesntFailDummies() { + void testVehicleWaitingSeveralLapDoesntFailDummies() { testVehicleWaitingDoesntFail( 4 , true ); } diff --git a/matsim/src/test/java/org/matsim/core/network/AbstractNetworkWriterReaderTest.java b/matsim/src/test/java/org/matsim/core/network/AbstractNetworkWriterReaderTest.java index 7391d0b4d2f..33464907505 100644 --- a/matsim/src/test/java/org/matsim/core/network/AbstractNetworkWriterReaderTest.java +++ b/matsim/src/test/java/org/matsim/core/network/AbstractNetworkWriterReaderTest.java @@ -34,8 +34,8 @@ import java.util.Set; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -93,19 +93,23 @@ public abstract class AbstractNetworkWriterReaderTest { */ protected abstract void readNetwork(final Scenario scenario, final InputStream stream); - @Test public void testAllowedModes_multipleModes() { + @Test + void testAllowedModes_multipleModes() { doTestAllowedModes(createHashSet("bus", "train"), utils.getOutputDirectory() + "network.xml"); } - @Test public void testAllowedModes_singleMode() { + @Test + void testAllowedModes_singleMode() { doTestAllowedModes(createHashSet("miv"), utils.getOutputDirectory() + "network.xml"); } - @Test public void testAllowedModes_noMode() { + @Test + void testAllowedModes_noMode() { doTestAllowedModes(new HashSet(), utils.getOutputDirectory() + "network.xml"); } - @Test public void testNodes_withoutElevation(){ + @Test + void testNodes_withoutElevation(){ List nodes = new ArrayList<>(2); Node n1 = NetworkUtils.createNode( Id.create("1", Node.class), @@ -118,7 +122,8 @@ public abstract class AbstractNetworkWriterReaderTest { doTestNodes(nodes, utils.getOutputDirectory() + "network.xml"); } - @Test public void testNodes_withElevation(){ + @Test + void testNodes_withElevation(){ List nodes = new ArrayList<>(2); Node n1 = NetworkUtils.createNode( Id.create("1", Node.class), @@ -131,7 +136,8 @@ public abstract class AbstractNetworkWriterReaderTest { doTestNodes(nodes, utils.getOutputDirectory() + "network.xml"); } - @Test public void testNodes_withAndWithoutElevation(){ + @Test + void testNodes_withAndWithoutElevation(){ List nodes = new ArrayList<>(2); Node n1 = NetworkUtils.createNode( Id.create("1", Node.class), @@ -144,7 +150,8 @@ public abstract class AbstractNetworkWriterReaderTest { doTestNodes(nodes, utils.getOutputDirectory() + "network.xml"); } - @Test public void testNodes_IdSpecialCharacters() { + @Test + void testNodes_IdSpecialCharacters() { Network network1 = NetworkUtils.createNetwork(); NetworkFactory nf = network1.getFactory(); Node nodeA1 = nf.createNode(Id.create("A & 1 \"'aa", Node.class), new Coord(100, 200)); @@ -162,7 +169,8 @@ public abstract class AbstractNetworkWriterReaderTest { Assert.assertNotSame(nodeB1, nodeB2); } - @Test public void testLinks_IdSpecialCharacters() { + @Test + void testLinks_IdSpecialCharacters() { Network network1 = NetworkUtils.createNetwork(); NetworkFactory nf = network1.getFactory(); Node nodeA1 = nf.createNode(Id.create("A & 1 \"'aa", Node.class), new Coord(100, 200)); @@ -190,7 +198,8 @@ public abstract class AbstractNetworkWriterReaderTest { // Assert.assertEquals(NetworkUtils.getOrigId(linkB1), NetworkUtils.getOrigId(linkB2)); // origId is not supported anymore in v2 } - @Test public void testNetwork_NameSpecialCharacters() { + @Test + void testNetwork_NameSpecialCharacters() { Network network1 = NetworkUtils.createNetwork(); network1.setName("Special & characters < are > in \" this ' name."); NetworkFactory nf = network1.getFactory(); diff --git a/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksTest.java b/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksTest.java index f48d85ecc6b..c4e230ce20f 100644 --- a/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksTest.java +++ b/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksTest.java @@ -8,8 +8,8 @@ import java.util.Map; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.jupiter.api.io.TempDir; import org.junit.rules.TemporaryFolder; import org.matsim.api.core.v01.Coord; @@ -27,7 +27,7 @@ public class DisallowedNextLinksTest { public File tempFolder; @Test - public void testEquals() { + void testEquals() { DisallowedNextLinks dnl0 = new DisallowedNextLinks(); DisallowedNextLinks dnl1 = new DisallowedNextLinks(); dnl0.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"), Id.createLinkId("1"))); @@ -43,13 +43,13 @@ public void testEquals() { } @Test - public void testIsEmpty() { + void testIsEmpty() { DisallowedNextLinks dnl= new DisallowedNextLinks(); Assert.assertTrue(dnl.isEmpty()); } @Test - public void testAdding() { + void testAdding() { DisallowedNextLinks dnl = new DisallowedNextLinks(); dnl.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"), Id.createLinkId("1"))); dnl.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"))); @@ -62,7 +62,7 @@ public void testAdding() { } @Test - public void testRemoving() { + void testRemoving() { DisallowedNextLinks dnl = new DisallowedNextLinks(); dnl.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"), Id.createLinkId("1"))); dnl.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"))); @@ -76,7 +76,7 @@ public void testRemoving() { } @Test - public void testNotAddingDuplicates() { + void testNotAddingDuplicates() { DisallowedNextLinks dnl = new DisallowedNextLinks(); Assert.assertTrue(dnl.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"), Id.createLinkId("1")))); @@ -85,21 +85,21 @@ public void testNotAddingDuplicates() { } @Test - public void testNotAddingEmpty() { + void testNotAddingEmpty() { DisallowedNextLinks dnl = new DisallowedNextLinks(); Assert.assertFalse(dnl.addDisallowedLinkSequence("car", Collections.emptyList())); } @Test - public void testNotAddingSequenceWithDuplicates() { + void testNotAddingSequenceWithDuplicates() { DisallowedNextLinks dnl = new DisallowedNextLinks(); Assert.assertFalse(dnl.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"), Id.createLinkId("0")))); } @Test - public void testEqualAndHashCode() { + void testEqualAndHashCode() { DisallowedNextLinks dnl0 = new DisallowedNextLinks(); dnl0.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"), Id.createLinkId("1"))); dnl0.addDisallowedLinkSequence("car", List.of(Id.createLinkId("4"), Id.createLinkId("5"))); @@ -112,7 +112,7 @@ public void testEqualAndHashCode() { } @Test - public void testSerialization() { + void testSerialization() { DisallowedNextLinks dnl0 = new DisallowedNextLinks(); dnl0.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"), Id.createLinkId("3"))); dnl0.addDisallowedLinkSequence("car", @@ -130,7 +130,7 @@ public void testSerialization() { } @Test - public void testNetworkWritingAndReading() throws IOException { + void testNetworkWritingAndReading() throws IOException { Network n = createNetwork(); Link l1 = n.getLinks().get(Id.createLinkId("1")); diff --git a/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksUtilsTest.java b/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksUtilsTest.java index 494314c5f6a..42ea61a6022 100644 --- a/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksUtilsTest.java @@ -4,7 +4,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -14,12 +14,12 @@ public class DisallowedNextLinksUtilsTest { Network n = DisallowedNextLinksTest.createNetwork(); @Test - public void testNoDisallowedNextLinks() { + void testNoDisallowedNextLinks() { Assert.assertTrue(DisallowedNextLinksUtils.isValid(n)); } @Test - public void testIsNotValid1() { + void testIsNotValid1() { Map, ? extends Link> links = n.getLinks(); Link l1 = links.get(Id.createLinkId("1")); Link l3 = links.get(Id.createLinkId("3")); @@ -32,7 +32,7 @@ public void testIsNotValid1() { } @Test - public void testIsNotValid2() { + void testIsNotValid2() { Map, ? extends Link> links = n.getLinks(); Link l1 = links.get(Id.createLinkId("1")); Link l3 = links.get(Id.createLinkId("3")); @@ -45,7 +45,7 @@ public void testIsNotValid2() { } @Test - public void testIsValid() { + void testIsValid() { Map, ? extends Link> links = n.getLinks(); Link l1 = links.get(Id.createLinkId("1")); Link l3 = links.get(Id.createLinkId("3")); diff --git a/matsim/src/test/java/org/matsim/core/network/LinkImplTest.java b/matsim/src/test/java/org/matsim/core/network/LinkImplTest.java index 13c944bd144..26257dffe0a 100644 --- a/matsim/src/test/java/org/matsim/core/network/LinkImplTest.java +++ b/matsim/src/test/java/org/matsim/core/network/LinkImplTest.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -47,7 +47,7 @@ public class LinkImplTest { @Test - public void testCalcDistance() { + void testCalcDistance() { /* create a sample network: * * (3)---3---(4) @@ -180,7 +180,7 @@ public void testCalcDistance() { } @Test - public void testSetAttributes() { + void testSetAttributes() { Network network = new NetworkImpl(new LinkFactoryImpl()); network.setCapacityPeriod(3600.0); Node node1 = NetworkUtils.createAndAddNode(network, Id.create(1, Node.class), new Coord((double) 0, (double) 0)); @@ -200,7 +200,7 @@ public void testSetAttributes() { * */ @Test - public void testAllowedModes() { + void testAllowedModes() { Network network = new NetworkImpl(new LinkFactoryImpl()); Node n1 = NetworkUtils.createAndAddNode(network, Id.create(1, Node.class), new Coord((double) 0, (double) 0)); Node n2 = NetworkUtils.createAndAddNode(network, Id.create(2, Node.class), new Coord((double) 1000, (double) 0)); @@ -233,7 +233,7 @@ public void testAllowedModes() { @Test - public void testHashSetCache_get_unmodifiable() { + void testHashSetCache_get_unmodifiable() { Set s1 = new TreeSet(); s1.add("A"); s1.add("B"); @@ -258,14 +258,14 @@ public void testHashSetCache_get_unmodifiable() { @Test - public void testHashSetCache_get_null() { + void testHashSetCache_get_null() { Set s = HashSetCache.get((Set) null); Assert.assertNull(s); } @Test - public void testHashSetCache_get_emptySet() { + void testHashSetCache_get_emptySet() { Set s = HashSetCache.get(new TreeSet()); Assert.assertNotNull(s); Assert.assertEquals(0, s.size()); @@ -273,7 +273,7 @@ public void testHashSetCache_get_emptySet() { @Test - public void testHashSetCache_get() { + void testHashSetCache_get() { Set s1 = new TreeSet(); s1.add("A"); s1.add("B"); @@ -312,7 +312,7 @@ public void testHashSetCache_get() { @Test - public void testHashSetCache_get_identicalObjects() { + void testHashSetCache_get_identicalObjects() { Set s1 = new TreeSet(); s1.add("A"); s1.add("B"); diff --git a/matsim/src/test/java/org/matsim/core/network/LinkQuadTreeTest.java b/matsim/src/test/java/org/matsim/core/network/LinkQuadTreeTest.java index 6c2a92fa703..897e0d47506 100644 --- a/matsim/src/test/java/org/matsim/core/network/LinkQuadTreeTest.java +++ b/matsim/src/test/java/org/matsim/core/network/LinkQuadTreeTest.java @@ -22,7 +22,7 @@ package org.matsim.core.network; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -32,13 +32,13 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.scenario.ScenarioUtils; -/** + /** * @author mrieser / senozon */ public class LinkQuadTreeTest { - @Test - public void testGetNearest() { + @Test + void testGetNearest() { Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); @@ -68,8 +68,8 @@ public void testGetNearest() { Assert.assertEquals(c, qt.getNearest(1205, 1101)); } - @Test - public void testGetNearest_longNear_smallFarAway() { + @Test + void testGetNearest_longNear_smallFarAway() { /* * Test the following constellation: @@ -98,9 +98,9 @@ public void testGetNearest_longNear_smallFarAway() { Assert.assertEquals(b, qt.getNearest(300, 210)); // outside of segment (1)-(2), thus (3)-(4) is closer Assert.assertEquals(a, qt.getNearest(400, 210)); // distance to (1) is smaller than to (3)-(4) } - - @Test - public void testPut_zeroLengthLink() { + + @Test + void testPut_zeroLengthLink() { /* * Test the following constellation: * @@ -144,8 +144,8 @@ public void testPut_zeroLengthLink() { Assert.assertEquals(l13, qt.getNearest(100, 800)); } - @Test - public void testPut_zeroLengthLink_negativeCoords() { + @Test + void testPut_zeroLengthLink_negativeCoords() { /* Same as test above, but with negative coords */ @@ -169,8 +169,8 @@ public void testPut_zeroLengthLink_negativeCoords() { Assert.assertEquals(l13, qt.getNearest(-100, -800)); } - @Test - public void testRemove() { + @Test + void testRemove() { Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); LinkQuadTree qt = new LinkQuadTree(0, 0, 1000, 1000); @@ -189,11 +189,11 @@ public void testRemove() { Assert.assertEquals(l23, qt.getNearest(100, 800)); } - /** - * Test for MATSIM-687: links not stored in top-node are not removed - */ - @Test - public void testRemove_inSubNode() { + /** + * Test for MATSIM-687: links not stored in top-node are not removed + */ + @Test + void testRemove_inSubNode() { Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); LinkQuadTree qt = new LinkQuadTree(0, 0, 1000, 1000); diff --git a/matsim/src/test/java/org/matsim/core/network/NetworkChangeEventsParserWriterTest.java b/matsim/src/test/java/org/matsim/core/network/NetworkChangeEventsParserWriterTest.java index 44479f38383..f3d135ce74e 100644 --- a/matsim/src/test/java/org/matsim/core/network/NetworkChangeEventsParserWriterTest.java +++ b/matsim/src/test/java/org/matsim/core/network/NetworkChangeEventsParserWriterTest.java @@ -21,8 +21,8 @@ package org.matsim.core.network; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -40,6 +40,7 @@ import static org.hamcrest.core.IsCollectionContaining.hasItem; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; public class NetworkChangeEventsParserWriterTest { @@ -47,7 +48,7 @@ public class NetworkChangeEventsParserWriterTest { private MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public void testChangeEventsParserWriter() { + void testChangeEventsParserWriter() { String input = utils.getInputDirectory() + "testNetworkChangeEvents.xml"; String output = utils.getOutputDirectory() + "outputTestNetworkChangeEvents.xml"; final Network network = new NetworkImpl(new VariableIntervalTimeVariantLinkFactory()); @@ -67,19 +68,21 @@ public void testChangeEventsParserWriter() { assertEquals(checksum_ref, checksum_run); } - @Test(expected = Exception.class) - public void testWriteChangeEventWithoutLinkDoesntWork() { - final String fileName = utils.getOutputDirectory() + "wurst.xml"; - - List events = new ArrayList<>(); - final NetworkChangeEvent e = new NetworkChangeEvent(0.0); - e.setFlowCapacityChange(new NetworkChangeEvent.ChangeValue(NetworkChangeEvent.ChangeType.ABSOLUTE_IN_SI_UNITS, 10)); - events.add(e); - new NetworkChangeEventsWriter().write(fileName, events); + @Test + void testWriteChangeEventWithoutLinkDoesntWork() { + assertThrows(Exception.class, () -> { + final String fileName = utils.getOutputDirectory() + "wurst.xml"; + + List events = new ArrayList<>(); + final NetworkChangeEvent e = new NetworkChangeEvent(0.0); + e.setFlowCapacityChange(new NetworkChangeEvent.ChangeValue(NetworkChangeEvent.ChangeType.ABSOLUTE_IN_SI_UNITS, 10)); + events.add(e); + new NetworkChangeEventsWriter().write(fileName, events); + }); } @Test - public void testWriteChangeEventWithSmallValueAndReadBack() { + void testWriteChangeEventWithSmallValueAndReadBack() { final String fileName = utils.getOutputDirectory() + "wurst.xml"; final Network network = NetworkUtils.createNetwork(); @@ -101,8 +104,9 @@ public void testWriteChangeEventWithSmallValueAndReadBack() { assertThat(inputEvents, hasItem(event)); } - @Test // see MATSIM-770 - public void testWriteReadZeroChangeEvents() { + // see MATSIM-770 + @Test + void testWriteReadZeroChangeEvents() { final String fileName = this.utils.getOutputDirectory() + "zeroChanges.xml"; List changeEvents = new ArrayList<>(); new NetworkChangeEventsWriter().write(fileName, changeEvents); @@ -116,7 +120,7 @@ public void testWriteReadZeroChangeEvents() { } @Test - public void testAbsoluteChangeEvents() { + void testAbsoluteChangeEvents() { final Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord((double) 0, (double) 0)); Node node2 = NetworkUtils.createAndAddNode(network, Id.create("2", Node.class), new Coord((double) 0, (double) 1000)); @@ -144,7 +148,7 @@ public void testAbsoluteChangeEvents() { } @Test - public void testScaleFactorChangeEvents() { + void testScaleFactorChangeEvents() { final Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord((double) 0, (double) 0)); Node node2 = NetworkUtils.createAndAddNode(network, Id.create("2", Node.class), new Coord((double) 0, (double) 1000)); @@ -172,7 +176,7 @@ public void testScaleFactorChangeEvents() { } @Test - public void testPositiveOffsetChangeEvents() { + void testPositiveOffsetChangeEvents() { final Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord((double) 0, (double) 0)); Node node2 = NetworkUtils.createAndAddNode(network, Id.create("2", Node.class), new Coord((double) 0, (double) 1000)); @@ -200,7 +204,7 @@ public void testPositiveOffsetChangeEvents() { } @Test - public void testNegativeOffsetChangeEvents() { + void testNegativeOffsetChangeEvents() { final Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord((double) 0, (double) 0)); Node node2 = NetworkUtils.createAndAddNode(network, Id.create("2", Node.class), new Coord((double) 0, (double) 1000)); diff --git a/matsim/src/test/java/org/matsim/core/network/NetworkCollectorTest.java b/matsim/src/test/java/org/matsim/core/network/NetworkCollectorTest.java index e9516aaad85..36184ddc30d 100644 --- a/matsim/src/test/java/org/matsim/core/network/NetworkCollectorTest.java +++ b/matsim/src/test/java/org/matsim/core/network/NetworkCollectorTest.java @@ -1,6 +1,6 @@ package org.matsim.core.network; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.network.Node; @@ -21,8 +21,8 @@ private static Network getNetworkFromExample() { return network; } - @Test - public void testWithSequentialStream() { + @Test + void testWithSequentialStream() { var network = getNetworkFromExample(); @@ -32,8 +32,8 @@ public void testWithSequentialStream() { assertTrue(NetworkUtils.compare(network, collectedNetwork)); } - @Test - public void testWithParallelStream() { + @Test + void testWithParallelStream() { var network = getNetworkFromExample(); @@ -43,8 +43,8 @@ public void testWithParallelStream() { assertTrue(NetworkUtils.compare(network, collectedNetwork)); } - @Test - public void testWithFilter() { + @Test + void testWithFilter() { var network = getNetworkFromExample(); // choose link 73 because both of its nodes have multiple in and out links diff --git a/matsim/src/test/java/org/matsim/core/network/NetworkImplTest.java b/matsim/src/test/java/org/matsim/core/network/NetworkImplTest.java index f5da909f975..1a4de57b8aa 100644 --- a/matsim/src/test/java/org/matsim/core/network/NetworkImplTest.java +++ b/matsim/src/test/java/org/matsim/core/network/NetworkImplTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.AbstractNetworkTest; @@ -44,12 +44,12 @@ public class NetworkImplTest extends AbstractNetworkTest { public Network getEmptyTestNetwork() { return new NetworkImpl(new LinkFactoryImpl()); } - + /** * Tests if the default values of a network instance are the same as the defaults specified in the network_v1.dtd */ @Test - public void testDefaultValues(){ + void testDefaultValues(){ Network net = new NetworkImpl(new LinkFactoryImpl()); Assert.assertEquals(7.5, net.getEffectiveCellSize(), 0.0); Assert.assertEquals(3.75, net.getEffectiveLaneWidth(), 0.0); @@ -72,7 +72,7 @@ public void testDefaultValues(){ * second time. */ @Test - public void testAddLink_existingId() { + void testAddLink_existingId() { Network network = new NetworkImpl(new LinkFactoryImpl()); Node node1 = NetworkUtils.createNode(Id.create(1, Node.class), new Coord((double) 0, (double) 0)); Node node2 = NetworkUtils.createNode(Id.create(2, Node.class), new Coord((double) 1000, (double) 0)); @@ -102,14 +102,14 @@ public void testAddLink_existingId() { network.addLink(link2); // adding the same link again should just be ignored Assert.assertEquals(2, network.getLinks().size()); } - + /** * Tests that if a link is added when its associated nodes are not in the network, * an exception is thrown. If the node is already in the network, no exception * should be thrown. */ @Test - public void testAddLink_noNodes(){ + void testAddLink_noNodes(){ Network n = NetworkUtils.createNetwork(); Node a = n.getFactory().createNode(Id.create("a", Node.class), new Coord(0.0, 0.0)); Node b = n.getFactory().createNode(Id.create("b", Node.class), new Coord(1000.0, 0.0)); @@ -156,9 +156,9 @@ public void testAddLink_noNodes(){ } } - + @Test - public void testAddNode_existingId() { + void testAddNode_existingId() { Network network = new NetworkImpl(new LinkFactoryImpl()); Node node1 = NetworkUtils.createNode(Id.create(1, Node.class), new Coord((double) 0, (double) 0)); Node node2 = NetworkUtils.createNode(Id.create(2, Node.class), new Coord((double) 1000, (double) 0)); @@ -180,14 +180,14 @@ public void testAddNode_existingId() { network.addNode(node3); Assert.assertEquals(3, network.getNodes().size()); } - + /** * MATSIM-278, 10jun2015: adding a node if quadtree only contained one node * * @author mrieser / Senozon AG */ @Test - public void testAddNode_singleNodeFirstOnly() { + void testAddNode_singleNodeFirstOnly() { Network network = new NetworkImpl(new LinkFactoryImpl()); Node node1 = NetworkUtils.createNode(Id.create(1, Node.class), new Coord((double) 500, (double) 400)); Node node2 = NetworkUtils.createNode(Id.create(2, Node.class), new Coord((double) 600, (double) 500)); @@ -210,7 +210,7 @@ public void testAddNode_singleNodeFirstOnly() { * @author droeder / Senozon Deutschland GmbH */ @Test - public void testAddTwoNodes_initializedEmptyQuadtree() { + void testAddTwoNodes_initializedEmptyQuadtree() { Network network = new NetworkImpl(new LinkFactoryImpl()); Node node1 = NetworkUtils.createNode(Id.create(1, Node.class), new Coord((double) 500, (double) 400)); Node node2 = NetworkUtils.createNode(Id.create(2, Node.class), new Coord((double) 600, (double) 500)); @@ -231,7 +231,7 @@ public void testAddTwoNodes_initializedEmptyQuadtree() { } @Test - public void testRemoveLink_alsoInQuadTrees() { + void testRemoveLink_alsoInQuadTrees() { Network network = new NetworkImpl(new LinkFactoryImpl()); Node node1 = NetworkUtils.createNode(Id.create(1, Node.class), new Coord(100, 100)); Node node2 = NetworkUtils.createNode(Id.create(2, Node.class), new Coord(1000, 200)); @@ -269,7 +269,7 @@ public void testRemoveLink_alsoInQuadTrees() { } @Test - public void testAddLink_alsoInQuadTrees() { + void testAddLink_alsoInQuadTrees() { Network network = new NetworkImpl(new LinkFactoryImpl()); Node node1 = NetworkUtils.createNode(Id.create(1, Node.class), new Coord(100, 100)); Node node2 = NetworkUtils.createNode(Id.create(2, Node.class), new Coord(1000, 200)); @@ -296,7 +296,7 @@ public void testAddLink_alsoInQuadTrees() { } @Test - public void testAddLink_intoEmptyQuadTree() { + void testAddLink_intoEmptyQuadTree() { Network network = new NetworkImpl(new LinkFactoryImpl()); Assert.assertEquals(0, network.getLinks().size()); diff --git a/matsim/src/test/java/org/matsim/core/network/NetworkUtilsTest.java b/matsim/src/test/java/org/matsim/core/network/NetworkUtilsTest.java index 28008eaa50c..9144ea61f59 100644 --- a/matsim/src/test/java/org/matsim/core/network/NetworkUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/network/NetworkUtilsTest.java @@ -21,8 +21,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -54,7 +54,7 @@ public class NetworkUtilsTest { * Test method for {@link org.matsim.core.network.NetworkUtils#isMultimodal(org.matsim.api.core.v01.network.Network)}. */ @Test - public final void testIsMultimodal() { + final void testIsMultimodal() { Config config = utils.createConfigWithInputResourcePathAsContext(); config.network().setInputFile("network.xml" ); @@ -70,7 +70,7 @@ public final void testIsMultimodal() { @SuppressWarnings("static-method") @Test - public final void getOutLinksSortedByAngleTest() { + final void getOutLinksSortedByAngleTest() { final Network network = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getNetwork(); // (we need the network to properly connect the links) @@ -146,7 +146,7 @@ public final void getOutLinksSortedByAngleTest() { } @Test - public void testfindNearestPointOnLink(){ + void testfindNearestPointOnLink(){ Network network = NetworkUtils.createNetwork(); Coord n1 = new Coord(1, 1); Coord n2 = new Coord(100,100); @@ -204,7 +204,7 @@ public void testfindNearestPointOnLink(){ } @Test - public void getOriginalGeometry() { + void getOriginalGeometry() { var network = NetworkUtils.createNetwork(); var fromNode = NetworkUtils.createAndAddNode(network, Id.createNodeId("from"), new Coord(0, 0)); @@ -235,7 +235,7 @@ public void getOriginalGeometry() { } @Test - public void getOriginalGeometry_noGeometryStored() { + void getOriginalGeometry_noGeometryStored() { var network = NetworkUtils.createNetwork(); var fromNode = NetworkUtils.createAndAddNode(network, Id.createNodeId("from"), new Coord(0, 0)); @@ -263,7 +263,7 @@ public void getOriginalGeometry_noGeometryStored() { * splits an empty string ("") into string[""]... */ @Test - public void getOriginalGeometry_emptyGeometryStored() { + void getOriginalGeometry_emptyGeometryStored() { var network = NetworkUtils.createNetwork(); var fromNode = NetworkUtils.createAndAddNode(network, Id.createNodeId("from"), new Coord(0, 0)); diff --git a/matsim/src/test/java/org/matsim/core/network/NetworkV2IOTest.java b/matsim/src/test/java/org/matsim/core/network/NetworkV2IOTest.java index 589ec99ba16..a3d9ddb7587 100644 --- a/matsim/src/test/java/org/matsim/core/network/NetworkV2IOTest.java +++ b/matsim/src/test/java/org/matsim/core/network/NetworkV2IOTest.java @@ -22,8 +22,8 @@ package org.matsim.core.network; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -33,15 +33,15 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.testcases.MatsimTestUtils; -/** + /** * @author thibautd */ public class NetworkV2IOTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void testNetworkAttributes() { + @Test + void testNetworkAttributes() { final Scenario sc = createTestNetwork( false ); new NetworkWriter( sc.getNetwork() ).writeV2( utils.getOutputDirectory()+"network.xml" ); @@ -54,8 +54,8 @@ public void testNetworkAttributes() { read.getNetwork().getAttributes().getAttribute( "year" ) ); } - @Test - public void testNodesAttributes() { + @Test + void testNodesAttributes() { final Scenario sc = createTestNetwork( false ); new NetworkWriter( sc.getNetwork() ).writeV2( utils.getOutputDirectory()+"network.xml" ); @@ -74,8 +74,8 @@ public void testNodesAttributes() { read.getNetwork().getNodes().get( id ).getAttributes().getAttribute( "Developper Meeting" ) ); } - @Test - public void testNo3DCoord() { + @Test + void testNo3DCoord() { // should be done through once "mixed" network as soon as possible final Scenario sc = createTestNetwork( false ); @@ -92,8 +92,8 @@ public void testNo3DCoord() { zhCoord.hasZ() ); } - @Test - public void test3DCoord() { + @Test + void test3DCoord() { // should be done through once "mixed" network as soon as possible final Scenario sc = createTestNetwork( true ); @@ -115,8 +115,8 @@ public void test3DCoord() { MatsimTestUtils.EPSILON ); } - @Test - public void testLinksAttributes() { + @Test + void testLinksAttributes() { final Scenario sc = createTestNetwork( false ); new NetworkWriter( sc.getNetwork() ).writeV2( utils.getOutputDirectory()+"network.xml" ); diff --git a/matsim/src/test/java/org/matsim/core/network/ReadFromURLIT.java b/matsim/src/test/java/org/matsim/core/network/ReadFromURLIT.java index 9d1ef4ffef9..596e4d515a4 100644 --- a/matsim/src/test/java/org/matsim/core/network/ReadFromURLIT.java +++ b/matsim/src/test/java/org/matsim/core/network/ReadFromURLIT.java @@ -19,7 +19,7 @@ package org.matsim.core.network; import org.assertj.core.api.Assertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.ConfigUtils; import org.matsim.core.network.io.MatsimNetworkReader; @@ -36,7 +36,7 @@ public class ReadFromURLIT { @Test - public void testReadingFromURLWorks() throws MalformedURLException { + void testReadingFromURLWorks() throws MalformedURLException { Network network = ScenarioUtils.createScenario( ConfigUtils.createConfig() ).getNetwork() ; MatsimNetworkReader reader = new MatsimNetworkReader(network) ; // reader.parse(new URL("https://raw.githubusercontent.com/matsim-org/matsim/master/matsim/examples/equil/network.xml")); diff --git a/matsim/src/test/java/org/matsim/core/network/TimeVariantLinkImplTest.java b/matsim/src/test/java/org/matsim/core/network/TimeVariantLinkImplTest.java index 5b84ddb4263..6ee99a6bbe7 100644 --- a/matsim/src/test/java/org/matsim/core/network/TimeVariantLinkImplTest.java +++ b/matsim/src/test/java/org/matsim/core/network/TimeVariantLinkImplTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -46,7 +46,8 @@ public class TimeVariantLinkImplTest { private static final double TIME_BEFORE_FIRST_CHANGE_EVENTS = -99999;//when base (default) link properties are used /** Tests the method {@link NetworkUtils#getFreespeedTravelTime(Link, double)}. */ - @Test public void testGetFreespeedTravelTime(){ + @Test + void testGetFreespeedTravelTime(){ for (LinkFactory lf : linkFactories(1, 5)) { final Network network = new NetworkImpl(lf); Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord((double) 0, (double) 0)); @@ -86,7 +87,8 @@ public class TimeVariantLinkImplTest { /** * Tests whether an absolute change in the freespeed really can be seen in the link's travel time */ - @Test public void testFreespeedChangeAbsolute() { + @Test + void testFreespeedChangeAbsolute() { for (LinkFactory lf : linkFactories(15 * 60, 30 * 3600)) { final Network network = new NetworkImpl(lf); @@ -128,7 +130,8 @@ public class TimeVariantLinkImplTest { /** * Tests whether a relative change in the freespeed really can be seen in the link's travel time */ - @Test public void testFreespeedChangeRelative() { + @Test + void testFreespeedChangeRelative() { for (LinkFactory lf : linkFactories(15 * 60, 30 * 3600)) { final Network network = new NetworkImpl(lf); @@ -170,7 +173,8 @@ public class TimeVariantLinkImplTest { /** * Tests how multiple freespeed changes interact with each other on the link. */ - @Test public void testMultipleFreespeedChanges() { + @Test + void testMultipleFreespeedChanges() { for (LinkFactory lf : linkFactories(15 * 60, 30 * 3600)) { final Network network = new NetworkImpl(lf); @@ -276,7 +280,8 @@ public class TimeVariantLinkImplTest { /** * Tests whether an absolute change to the flow capacity really can be observed on the link . */ - @Test public void testFlowCapChangeAbsolute() { + @Test + void testFlowCapChangeAbsolute() { for (LinkFactory lf : linkFactories(15 * 60, 30 * 3600)) { final Network network = new NetworkImpl(lf); network.setCapacityPeriod(3600.0); @@ -312,7 +317,8 @@ public class TimeVariantLinkImplTest { /** * Tests whether an absolute change to the number of lanes really can be observed on the link. */ - @Test public void testLanesChangeAbsolute() { + @Test + void testLanesChangeAbsolute() { for (LinkFactory lf : linkFactories(15 * 60, 30 * 3600)) { final Network network = new NetworkImpl(lf); network.setCapacityPeriod(3600.0); diff --git a/matsim/src/test/java/org/matsim/core/network/TravelTimeCalculatorIntegrationTest.java b/matsim/src/test/java/org/matsim/core/network/TravelTimeCalculatorIntegrationTest.java index 8a886da7975..f7cc016d101 100644 --- a/matsim/src/test/java/org/matsim/core/network/TravelTimeCalculatorIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/network/TravelTimeCalculatorIntegrationTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -47,7 +47,8 @@ public class TravelTimeCalculatorIntegrationTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testTravelTimeCalculatorArray() { + @Test + void testTravelTimeCalculatorArray() { for (LinkFactory lf : TimeVariantLinkImplTest.linkFactories(15 * 60, 30 * 3600)) { Config config = utils.loadConfig((String)null); @@ -88,7 +89,8 @@ public class TravelTimeCalculatorIntegrationTest { } } - @Test public void testTravelTimeCalculatorHashMap() { + @Test + void testTravelTimeCalculatorHashMap() { for (LinkFactory lf : TimeVariantLinkImplTest.linkFactories(15 * 60, 30 * 3600)) { Config config = utils.loadConfig((String)null); diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/CalcBoundingBoxTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/CalcBoundingBoxTest.java index 37bca87b1f5..fa57c2fb070 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/CalcBoundingBoxTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/CalcBoundingBoxTest.java @@ -20,8 +20,7 @@ package org.matsim.core.network.algorithms; import org.junit.Assert; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -36,7 +35,7 @@ public class CalcBoundingBoxTest { @Test - public void testRun() { + void testRun() { Network net = NetworkUtils.createNetwork(); NetworkFactory nf = net.getFactory(); @@ -72,7 +71,7 @@ public void testRun() { } @Test - public void testRun_allNegative() { + void testRun_allNegative() { Network net = NetworkUtils.createNetwork(); NetworkFactory nf = net.getFactory(); diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/MultimodalNetworkCleanerTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/MultimodalNetworkCleanerTest.java index 227f6038b81..7021557104f 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/MultimodalNetworkCleanerTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/MultimodalNetworkCleanerTest.java @@ -24,8 +24,7 @@ import java.util.Set; import org.junit.Assert; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -43,7 +42,7 @@ public class MultimodalNetworkCleanerTest { @Test - public void testRun_singleMode() { + void testRun_singleMode() { Fixture f = new Fixture(); Network network = f.scenario.getNetwork(); MultimodalNetworkCleaner cleaner = new MultimodalNetworkCleaner(network); @@ -62,7 +61,7 @@ public void testRun_singleMode() { } @Test - public void testRun_singleMode_separateLink() { + void testRun_singleMode_separateLink() { Fixture f = new Fixture(); Network network = f.scenario.getNetwork(); Node node1 = network.getNodes().get(f.nodeIds[1]); @@ -106,7 +105,7 @@ public void testRun_singleMode_separateLink() { } @Test - public void testRun_singleInexistantMode() { + void testRun_singleInexistantMode() { Fixture f = new Fixture(); Network network = f.scenario.getNetwork(); @@ -126,7 +125,7 @@ public void testRun_singleInexistantMode() { } @Test - public void testRun_singleMode_singleSink() { + void testRun_singleMode_singleSink() { Fixture f = new Fixture(); Network network = f.scenario.getNetwork(); Node node1 = network.getNodes().get(f.nodeIds[1]); @@ -179,7 +178,7 @@ public void testRun_singleMode_singleSink() { } @Test - public void testRun_singleMode_singleSinkIntegrated() { + void testRun_singleMode_singleSinkIntegrated() { Fixture f = new Fixture(); Network network = f.scenario.getNetwork(); network.getLinks().get(f.linkIds[1]).setAllowedModes(f.modesCW); // integrate the sinks into the existing network @@ -221,7 +220,7 @@ public void testRun_singleMode_singleSinkIntegrated() { } @Test - public void testRun_singleMode_doubleSink() { + void testRun_singleMode_doubleSink() { Fixture f = new Fixture(); Network network = f.scenario.getNetwork(); Node node1 = network.getNodes().get(f.nodeIds[1]); @@ -278,7 +277,7 @@ public void testRun_singleMode_doubleSink() { @Test - public void testRun_singleMode_singleSource() { + void testRun_singleMode_singleSource() { Fixture f = new Fixture(); Network network = f.scenario.getNetwork(); Node node1 = network.getNodes().get(f.nodeIds[1]); @@ -331,7 +330,7 @@ public void testRun_singleMode_singleSource() { } @Test - public void testRemoveNodesWithoutLinks() { + void testRemoveNodesWithoutLinks() { Fixture f = new Fixture(); Network network = f.scenario.getNetwork(); network.addNode(network.getFactory().createNode(f.nodeIds[10], new Coord((double) 300, (double) 300))); @@ -351,7 +350,7 @@ public void testRemoveNodesWithoutLinks() { } @Test - public void testRun_singleMode_doubleSource() { + void testRun_singleMode_doubleSource() { Fixture f = new Fixture(); Network network = f.scenario.getNetwork(); Node node1 = network.getNodes().get(f.nodeIds[1]); @@ -407,7 +406,7 @@ public void testRun_singleMode_doubleSource() { } @Test - public void testRun_multipleModes() { + void testRun_multipleModes() { Fixture f = new MultimodeFixture(); Network network = f.scenario.getNetwork(); @@ -431,7 +430,7 @@ public void testRun_multipleModes() { } @Test - public void testRun_multipleModes_doubleSink() { + void testRun_multipleModes_doubleSink() { Fixture f = new MultimodeFixture(); Network network = f.scenario.getNetwork(); @@ -465,7 +464,7 @@ public void testRun_multipleModes_doubleSink() { } @Test - public void testRun_multipleModes_doubleSource() { + void testRun_multipleModes_doubleSource() { Fixture f = new MultimodeFixture(); Network network = f.scenario.getNetwork(); @@ -499,7 +498,7 @@ public void testRun_multipleModes_doubleSource() { } @Test - public void testRun_emptyModes() { + void testRun_emptyModes() { Fixture f = new Fixture(); Network network = f.scenario.getNetwork(); @@ -520,7 +519,7 @@ public void testRun_emptyModes() { } @Test - public void testRun_unknownMode() { + void testRun_unknownMode() { Fixture f = new Fixture(); Network network = f.scenario.getNetwork(); @@ -541,7 +540,7 @@ public void testRun_unknownMode() { } @Test - public void testRun_singleLinkNetwork() { + void testRun_singleLinkNetwork() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network = scenario.getNetwork(); NetworkFactory factory = network.getFactory(); @@ -566,7 +565,7 @@ public void testRun_singleLinkNetwork() { } @Test - public void testRun_singleModeWithConnectivity() { + void testRun_singleModeWithConnectivity() { MultimodalFixture2 f = new MultimodalFixture2(); Network network = f.scenario.getNetwork(); Assert.assertEquals(6, network.getNodes().size()); @@ -577,7 +576,7 @@ public void testRun_singleModeWithConnectivity() { } @Test - public void testRun_withConnectivity_connectedSource() { + void testRun_withConnectivity_connectedSource() { MultimodalFixture2 f = new MultimodalFixture2(); Network network = f.scenario.getNetwork(); NetworkFactory nf = network.getFactory(); @@ -597,7 +596,7 @@ public void testRun_withConnectivity_connectedSource() { } @Test - public void testRun_withConnectivity_connectedSink() { + void testRun_withConnectivity_connectedSink() { MultimodalFixture2 f = new MultimodalFixture2(); Network network = f.scenario.getNetwork(); NetworkFactory nf = network.getFactory(); @@ -617,7 +616,7 @@ public void testRun_withConnectivity_connectedSink() { } @Test - public void testRun_withConnectivity_unconnectedSource() { + void testRun_withConnectivity_unconnectedSource() { MultimodalFixture2 f = new MultimodalFixture2(); Network network = f.scenario.getNetwork(); NetworkFactory nf = network.getFactory(); @@ -638,7 +637,7 @@ public void testRun_withConnectivity_unconnectedSource() { } @Test - public void testRun_withConnectivity_unconnectedSink() { + void testRun_withConnectivity_unconnectedSink() { MultimodalFixture2 f = new MultimodalFixture2(); Network network = f.scenario.getNetwork(); NetworkFactory nf = network.getFactory(); @@ -659,7 +658,7 @@ public void testRun_withConnectivity_unconnectedSink() { } @Test - public void testRun_withConnectivity_unconnectedLink() { + void testRun_withConnectivity_unconnectedLink() { MultimodalFixture2 f = new MultimodalFixture2(); Network network = f.scenario.getNetwork(); NetworkFactory nf = network.getFactory(); diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkCleanerTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkCleanerTest.java index 3bacc7f7f42..82612458c85 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkCleanerTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkCleanerTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -39,7 +39,8 @@ */ public class NetworkCleanerTest { - @Test public void testSink() { + @Test + void testSink() { // create a simple network Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord((double) 0, (double) 0)); @@ -74,7 +75,8 @@ public class NetworkCleanerTest { assertEquals("# links", 4, network.getLinks().size()); } - @Test public void testDoubleSink() { + @Test + void testDoubleSink() { // create a simple network Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord((double) 0, (double) 0)); @@ -112,7 +114,8 @@ public class NetworkCleanerTest { assertEquals("# links", 4, network.getLinks().size()); } - @Test public void testSource() { + @Test + void testSource() { // create a simple network Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord((double) 0, (double) 0)); @@ -147,7 +150,8 @@ public class NetworkCleanerTest { assertEquals("# links", 4, network.getLinks().size()); } - @Test public void testDoubleSource() { + @Test + void testDoubleSource() { // create a simple network Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord((double) 0, (double) 0)); diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkExpandNodeTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkExpandNodeTest.java index 114120578e5..582e14d9a15 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkExpandNodeTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkExpandNodeTest.java @@ -24,8 +24,7 @@ import java.util.Set; import org.junit.Assert; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -45,7 +44,7 @@ public class NetworkExpandNodeTest { @Test - public void testExpandNode() { + void testExpandNode() { Fixture f = new Fixture(); f.createNetwork_ThreeWayIntersection(); @@ -153,7 +152,7 @@ public void testExpandNode() { } @Test - public void testExpandNode_sameCoordinateLinks() { + void testExpandNode_sameCoordinateLinks() { Fixture f = new Fixture(); f.createNetwork_ThreeWayIntersection(); Coord c = f.scenario.getNetwork().getNodes().get(Id.create("3", Node.class)).getCoord(); @@ -265,7 +264,7 @@ public void testExpandNode_sameCoordinateLinks() { } @Test - public void testExpandNode_specificModes() { + void testExpandNode_specificModes() { Fixture f = new Fixture(); f.createNetwork_ThreeWayIntersection(); @@ -388,7 +387,7 @@ public void testExpandNode_specificModes() { } @Test - public void testTurnsAreSameAsSingleNode_IncludeUTurns() { + void testTurnsAreSameAsSingleNode_IncludeUTurns() { Fixture f = new Fixture(); f.createNetwork_ThreeWayIntersection(); @@ -426,7 +425,7 @@ public void testTurnsAreSameAsSingleNode_IncludeUTurns() { } @Test - public void testTurnsAreSameAsSingleNode_IgnoreUTurns() { + void testTurnsAreSameAsSingleNode_IgnoreUTurns() { Fixture f = new Fixture(); f.createNetwork_ThreeWayIntersection(); @@ -463,9 +462,9 @@ public void testTurnsAreSameAsSingleNode_IgnoreUTurns() { Assert.assertTrue(exp.turnsAreSameAsSingleNode(nodeId, turns, true)); } - + @Test - public void testTurnInfo_equals() { + void testTurnInfo_equals() { Set modes1 = new HashSet(); Set modes2 = new HashSet(); modes2.add(TransportMode.car); diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkMergeDoubleLinksTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkMergeDoubleLinksTest.java index a2d95be4089..c5d32dbbc18 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkMergeDoubleLinksTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkMergeDoubleLinksTest.java @@ -20,8 +20,7 @@ package org.matsim.core.network.algorithms; import org.junit.Assert; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -39,7 +38,7 @@ public class NetworkMergeDoubleLinksTest { @Test - public void testRun_remove() { + void testRun_remove() { Fixture f = new Fixture(); NetworkMergeDoubleLinks merger = new NetworkMergeDoubleLinks(NetworkMergeDoubleLinks.MergeType.REMOVE); merger.run(f.network); @@ -70,7 +69,7 @@ public void testRun_remove() { } @Test - public void testRun_additive() { + void testRun_additive() { Fixture f = new Fixture(); NetworkMergeDoubleLinks merger = new NetworkMergeDoubleLinks(NetworkMergeDoubleLinks.MergeType.ADDITIVE); merger.run(f.network); @@ -101,7 +100,7 @@ public void testRun_additive() { } @Test - public void testRun_maximum() { + void testRun_maximum() { Fixture f = new Fixture(); NetworkMergeDoubleLinks merger = new NetworkMergeDoubleLinks(NetworkMergeDoubleLinks.MergeType.MAXIMUM); merger.run(f.network); diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierPass2WayTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierPass2WayTest.java index 5fc61aa82d3..94feb8bcf41 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierPass2WayTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierPass2WayTest.java @@ -25,7 +25,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Test; + +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.network.Node; @@ -40,8 +41,8 @@ public class NetworkSimplifierPass2WayTest { - @Test - public void testSimplifying(){ + @Test + void testSimplifying(){ List networks = buildNetworks(); int counter = 0; diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierTest.java index aefb7a099fc..542823a3ad4 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierTest.java @@ -27,7 +27,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -44,14 +44,14 @@ public void setUp() { } @Test - public void testBuildNetwork() { + void testBuildNetwork() { Network network = buildNetwork(); assertEquals("Wrong number of nodes.", 6, network.getNodes().size()); assertEquals("Wrong number of links.", 5, network.getLinks().size()); } @Test - public void testRun() { + void testRun() { Network network = buildNetwork(); NetworkSimplifier nst = new NetworkSimplifier(); @@ -62,9 +62,9 @@ public void testRun() { assertNotNull("Expected link not found.", network.getLinks().get(Id.createLinkId("DE-EF"))); } - + @Test - public void testRunMergeLinkStats() { + void testRunMergeLinkStats() { Network network = buildNetwork(); NetworkSimplifier nst = new NetworkSimplifier(); @@ -85,7 +85,7 @@ public void testRunMergeLinkStats() { } @Test - public void testDifferentAttributesPerDirection() { + void testDifferentAttributesPerDirection() { /* Test-Network diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/TransportModeNetworkFilterTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/TransportModeNetworkFilterTest.java index ff3cd805ed9..1bfe470b9c8 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/TransportModeNetworkFilterTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/TransportModeNetworkFilterTest.java @@ -24,8 +24,7 @@ import java.util.Set; import org.junit.Assert; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -50,7 +49,7 @@ public class TransportModeNetworkFilterTest { @Test - public void testFilter_SingleMode() { + void testFilter_SingleMode() { final Fixture f = new Fixture(); TransportModeNetworkFilter filter = new TransportModeNetworkFilter(f.scenario.getNetwork()); @@ -142,7 +141,7 @@ public void testFilter_SingleMode() { } @Test - public void testFilter_MultipleModes() { + void testFilter_MultipleModes() { final Fixture f = new Fixture(); TransportModeNetworkFilter filter = new TransportModeNetworkFilter(f.scenario.getNetwork()); @@ -223,7 +222,7 @@ public void testFilter_MultipleModes() { } @Test - public void testFilter_NoModes() { + void testFilter_NoModes() { final Fixture f = new Fixture(); TransportModeNetworkFilter filter = new TransportModeNetworkFilter(f.scenario.getNetwork()); @@ -234,7 +233,7 @@ public void testFilter_NoModes() { } @Test - public void testFilter_AdditionalModes() { + void testFilter_AdditionalModes() { final Fixture f = new Fixture(); TransportModeNetworkFilter filter = new TransportModeNetworkFilter(f.scenario.getNetwork()); @@ -262,7 +261,7 @@ public void testFilter_AdditionalModes() { } @Test - public void testFilter_NoCommonModes() { + void testFilter_NoCommonModes() { final Fixture f = new Fixture(); TransportModeNetworkFilter filter = new TransportModeNetworkFilter(f.scenario.getNetwork()); @@ -271,7 +270,7 @@ public void testFilter_NoCommonModes() { Assert.assertEquals("wrong number of nodes.", 0, subNetwork.getNodes().size()); Assert.assertEquals("wrong number of links", 0, subNetwork.getLinks().size()); } - + /** * Tests the algorithm for the case the network contains direct loops, i.e. * links with the same from and to node. @@ -284,7 +283,7 @@ public void testFilter_NoCommonModes() { * scenario from scratch. */ @Test - public void testFilter_SingleMode_loop() { + void testFilter_SingleMode_loop() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); final Network network = scenario.getNetwork(); final NetworkFactory factory = network.getFactory(); @@ -303,12 +302,12 @@ public void testFilter_SingleMode_loop() { Assert.assertEquals("wrong number of links", 1, subNetwork.getLinks().size()); Assert.assertTrue(subNetwork.getLinks().containsKey(Id.create(1, Link.class))); } - + /** * Tests that tiem-varying information is converted */ @Test - public void testFilter_timeVariant() { + void testFilter_timeVariant() { Config config = ConfigUtils.createConfig(); config.network().setTimeVariantNetwork(true); diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/DensityClusterTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/DensityClusterTest.java index 0e7518744a0..6299e3dd572 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/DensityClusterTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/DensityClusterTest.java @@ -24,15 +24,15 @@ import java.util.List; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Node; import org.matsim.core.network.NetworkUtils; public class DensityClusterTest{ - - + + /** * Tests if the following cluster pattern is clustered into two clusters: * ___________ @@ -46,7 +46,7 @@ public class DensityClusterTest{ * |___________| */ @Test - public void testDJCluster(){ + void testDJCluster(){ List al = buildTestArrayList(); DensityCluster djc = new DensityCluster(al, false); djc.clusterInput(2, 3); diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/HullConverterTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/HullConverterTest.java index aebdcf8e8ea..b5964c3c526 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/HullConverterTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/HullConverterTest.java @@ -20,7 +20,7 @@ package org.matsim.core.network.algorithms.intersectionSimplifier; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.LineString; @@ -31,7 +31,7 @@ public class HullConverterTest { public void testConvert() { - } + } /** * 4 3 @@ -44,7 +44,7 @@ public void testConvert() { * 1 2 */ @Test - public void testConvertString(){ + void testConvertString(){ /* Must pass a Geometry. */ Object o = new Integer(0); HullConverter hc = new HullConverter(); @@ -81,8 +81,8 @@ public void testConvertString(){ String polygonString = "(0.0;0.0),(5.0;0.0),(5.0;5.0),(0.0;5.0),(0.0;0.0)"; Assert.assertTrue("Wrong string for polygon.", polygonString.equalsIgnoreCase(s)); } - - + + /** * (5,0)-------(5,5) * | | @@ -92,7 +92,7 @@ public void testConvertString(){ * (0,0)-------(5,0) */ @Test - public void testConstructor(){ + void testConstructor(){ HullConverter hc = new HullConverter(); GeometryFactory gf = new GeometryFactory(); Coordinate[] ca = new Coordinate[5]; diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/IntersectionSimplifierTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/IntersectionSimplifierTest.java index 8d8e0f6639c..035a913d729 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/IntersectionSimplifierTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/IntersectionSimplifierTest.java @@ -25,8 +25,8 @@ import java.util.List; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Network; @@ -44,7 +44,7 @@ public class IntersectionSimplifierTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testComplexIntersection() { + void testComplexIntersection() { Network network = null; try { network = buildComplexIntersection(); @@ -58,7 +58,7 @@ public void testComplexIntersection() { } @Test - public void testSimplifyCallOnlyOnce() { + void testSimplifyCallOnlyOnce() { Network network = buildComplexIntersection(); IntersectionSimplifier is = new IntersectionSimplifier(10.0, 2); try{ @@ -79,7 +79,7 @@ public void testSimplifyCallOnlyOnce() { @Test - public void testGetClusteredNode() { + void testGetClusteredNode() { Network network = buildComplexIntersection(); IntersectionSimplifier is = new IntersectionSimplifier(10.0, 2); @@ -100,7 +100,7 @@ public void testGetClusteredNode() { @Test - public void testSimplifyOne() { + void testSimplifyOne() { Network network = buildComplexIntersection(); IntersectionSimplifier is = new IntersectionSimplifier(10.0, 2); Network simpleNetwork = is.simplify(network); @@ -122,7 +122,7 @@ public void testSimplifyOne() { } @Test - public void testSimplifyTwo() { + void testSimplifyTwo() { Network network = buildComplexIntersection(); IntersectionSimplifier is = new IntersectionSimplifier(30.0, 4); Network simpleNetwork = is.simplify(network); @@ -147,7 +147,7 @@ public void testSimplifyTwo() { * The network cleaner will/should ensure that full connectivity remains. */ @Test - public void testNetworkCleaner() { + void testNetworkCleaner() { Network network = buildComplexIntersection(); IntersectionSimplifier is = new IntersectionSimplifier(10.0, 2); Network simpleNetwork = is.simplify(network); @@ -182,7 +182,7 @@ public void testNetworkCleaner() { } @Test - public void testNetworkSimplifier() { + void testNetworkSimplifier() { Network network = buildComplexIntersection(); IntersectionSimplifier is = new IntersectionSimplifier(10.0, 2); Network simpleNetwork = is.simplify(network); diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/containers/ConcaveHullTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/containers/ConcaveHullTest.java index 8fdde25b9eb..35c3cfd024d 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/containers/ConcaveHullTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/containers/ConcaveHullTest.java @@ -20,8 +20,8 @@ package org.matsim.core.network.algorithms.intersectionSimplifier.containers; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryCollection; @@ -35,7 +35,7 @@ public class ConcaveHullTest { /** Test whether duplicate input points are removed. **/ @Test - public void testConstructor(){ + void testConstructor(){ GeometryCollection gcIncorrect = setupWithDuplicates(); ConcaveHull ch1 = new ConcaveHull(gcIncorrect, 2); Assert.assertEquals("Duplicates not removed.", 8, ch1.getInputPoints()); diff --git a/matsim/src/test/java/org/matsim/core/network/filter/NetworkFilterManagerTest.java b/matsim/src/test/java/org/matsim/core/network/filter/NetworkFilterManagerTest.java index 935482c7a0c..8796cc67bc4 100644 --- a/matsim/src/test/java/org/matsim/core/network/filter/NetworkFilterManagerTest.java +++ b/matsim/src/test/java/org/matsim/core/network/filter/NetworkFilterManagerTest.java @@ -23,7 +23,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -88,7 +88,7 @@ private static void enrichLink(Link link) { } @Test - public void filterTest() { + void filterTest() { NetworkFilterManager networkFilterManager = new NetworkFilterManager(filterNetwork, new NetworkConfigGroup()); networkFilterManager.addNodeFilter(new NetworkNodeFilter() { @Override diff --git a/matsim/src/test/java/org/matsim/core/network/io/NetworkAttributeConversionTest.java b/matsim/src/test/java/org/matsim/core/network/io/NetworkAttributeConversionTest.java index e122adda402..313018fab00 100644 --- a/matsim/src/test/java/org/matsim/core/network/io/NetworkAttributeConversionTest.java +++ b/matsim/src/test/java/org/matsim/core/network/io/NetworkAttributeConversionTest.java @@ -22,8 +22,8 @@ package org.matsim.core.network.io; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.ConfigUtils; @@ -34,19 +34,19 @@ import java.util.Objects; import java.util.function.Consumer; -public class NetworkAttributeConversionTest { + public class NetworkAttributeConversionTest { @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void testDefaults() { + @Test + void testDefaults() { final String path = utils.getOutputDirectory()+"/network.xml"; testWriteAndReread(w -> w.write(path), w -> w.readFile(path)); } - @Test - public void testV2() { + @Test + void testV2() { final String path = utils.getOutputDirectory()+"/network.xml"; testWriteAndReread(w -> w.writeFileV2(path), w -> w.readFile(path)); diff --git a/matsim/src/test/java/org/matsim/core/network/io/NetworkReaderMatsimV1Test.java b/matsim/src/test/java/org/matsim/core/network/io/NetworkReaderMatsimV1Test.java index 33517747af2..05795477641 100644 --- a/matsim/src/test/java/org/matsim/core/network/io/NetworkReaderMatsimV1Test.java +++ b/matsim/src/test/java/org/matsim/core/network/io/NetworkReaderMatsimV1Test.java @@ -25,8 +25,8 @@ import java.util.Set; import java.util.Stack; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -49,7 +49,8 @@ public class NetworkReaderMatsimV1Test { /** * @author mrieser */ - @Test public void testAllowedModes_singleMode() { + @Test + void testAllowedModes_singleMode() { Link link = prepareTestAllowedModes("car"); Set modes = link.getAllowedModes(); assertEquals("wrong number of allowed modes.", 1, modes.size()); @@ -65,7 +66,8 @@ public class NetworkReaderMatsimV1Test { /** * @author mrieser */ - @Test public void testAllowedModes_emptyMode() { + @Test + void testAllowedModes_emptyMode() { Link link = prepareTestAllowedModes(""); Set modes = link.getAllowedModes(); assertEquals("wrong number of allowed modes.", 0, modes.size()); @@ -74,7 +76,8 @@ public class NetworkReaderMatsimV1Test { /** * @author mrieser */ - @Test public void testAllowedModes_multipleModes() { + @Test + void testAllowedModes_multipleModes() { Link link = prepareTestAllowedModes("car,bus"); Set modes = link.getAllowedModes(); assertEquals("wrong number of allowed modes.", 2, modes.size()); diff --git a/matsim/src/test/java/org/matsim/core/network/io/NetworkReprojectionIOTest.java b/matsim/src/test/java/org/matsim/core/network/io/NetworkReprojectionIOTest.java index 980cddcc1eb..b57fd8ab3f5 100644 --- a/matsim/src/test/java/org/matsim/core/network/io/NetworkReprojectionIOTest.java +++ b/matsim/src/test/java/org/matsim/core/network/io/NetworkReprojectionIOTest.java @@ -22,8 +22,8 @@ package org.matsim.core.network.io; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -40,7 +40,7 @@ import org.matsim.core.utils.geometry.transformations.TransformationFactory; import org.matsim.testcases.MatsimTestUtils; -/** + /** * @author thibautd */ public class NetworkReprojectionIOTest { @@ -54,8 +54,8 @@ public class NetworkReprojectionIOTest { @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void testInput() { + @Test + void testInput() { final String networkFile = utils.getOutputDirectory()+"/network.xml"; final Network initialNetwork = createInitialNetwork(); @@ -81,8 +81,8 @@ public void testInput() { } } - @Test - public void testOutput() { + @Test + void testOutput() { final String networkFile = utils.getOutputDirectory()+"/network.xml"; final Network initialNetwork = createInitialNetwork(); @@ -109,8 +109,8 @@ public void testOutput() { } } - @Test - public void testWithControlerAndAttributes() { + @Test + void testWithControlerAndAttributes() { final String networkFile = utils.getOutputDirectory()+"/network.xml"; final Network initialNetwork = createInitialNetwork(); @@ -163,8 +163,8 @@ public void testWithControlerAndAttributes() { } } - @Test - public void testWithControlerAndConfigParameters() { + @Test + void testWithControlerAndConfigParameters() { final String networkFile = utils.getOutputDirectory()+"/network.xml"; final Network initialNetwork = createInitialNetwork(); diff --git a/matsim/src/test/java/org/matsim/core/population/PersonImplTest.java b/matsim/src/test/java/org/matsim/core/population/PersonImplTest.java index 732657460e2..7b63c140391 100644 --- a/matsim/src/test/java/org/matsim/core/population/PersonImplTest.java +++ b/matsim/src/test/java/org/matsim/core/population/PersonImplTest.java @@ -24,8 +24,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -50,7 +50,8 @@ public class PersonImplTest { /** * @author mrieser */ - @Test public void testGetRandomUnscoredPlan() { + @Test + void testGetRandomUnscoredPlan() { Population population = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getPopulation(); Person person = null; Plan[] plans = new Plan[10]; @@ -97,7 +98,8 @@ public class PersonImplTest { /** * @author mrieser */ - @Test public void testRemoveUnselectedPlans() { + @Test + void testRemoveUnselectedPlans() { Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); PersonUtils.createAndAddPlan(person, false); PersonUtils.createAndAddPlan(person, false); @@ -112,7 +114,8 @@ public class PersonImplTest { assertEquals("remaining plan should be selPlan.", selPlan, person.getPlans().get(0)); } - @Test public void testRemovePlan() { + @Test + void testRemovePlan() { Person person = PopulationUtils.getFactory().createPerson(Id.create(5, Person.class)); Plan p1 = PersonUtils.createAndAddPlan(person, false); Plan p2 = PersonUtils.createAndAddPlan(person, true); @@ -137,7 +140,8 @@ public class PersonImplTest { assertEquals("wrong number of plans.", 0, person.getPlans().size()); } - @Test public void testSetSelectedPlan() { + @Test + void testSetSelectedPlan() { Person person = PopulationUtils.getFactory().createPerson(Id.create(11, Person.class)); Plan p1 = PersonUtils.createAndAddPlan(person, false); assertEquals(p1, person.getSelectedPlan()); @@ -159,7 +163,8 @@ public class PersonImplTest { /** * @author mrieser */ - @Test public void testGetBestPlan() { + @Test + void testGetBestPlan() { Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan p1 = PopulationUtils.createPlan(); p1.setScore(90.0); @@ -174,7 +179,8 @@ public class PersonImplTest { /** * @author mrieser */ - @Test public void testGetBestPlan_multipleBest() { + @Test + void testGetBestPlan_multipleBest() { Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan p1 = PopulationUtils.createPlan(); p1.setScore(11.0); @@ -192,7 +198,8 @@ public class PersonImplTest { /** * @author mrieser */ - @Test public void testGetBestPlan_oneWithoutScore() { + @Test + void testGetBestPlan_oneWithoutScore() { Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan p1 = PopulationUtils.createPlan(); Plan p2 = PopulationUtils.createPlan(); @@ -206,7 +213,8 @@ public class PersonImplTest { /** * @author mrieser */ - @Test public void testGetBestPlan_allWithoutScore() { + @Test + void testGetBestPlan_allWithoutScore() { Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan p1 = PopulationUtils.createPlan(); Plan p2 = PopulationUtils.createPlan(); diff --git a/matsim/src/test/java/org/matsim/core/population/PlanImplTest.java b/matsim/src/test/java/org/matsim/core/population/PlanImplTest.java index ed49d1c3bda..b818a7ec02c 100644 --- a/matsim/src/test/java/org/matsim/core/population/PlanImplTest.java +++ b/matsim/src/test/java/org/matsim/core/population/PlanImplTest.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -49,7 +49,7 @@ public class PlanImplTest { * @author mrieser */ @Test - public void testCreateAndAddActAndLeg() { + void testCreateAndAddActAndLeg() { Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); try { PopulationUtils.createAndAddLeg( plan, TransportMode.car ); @@ -68,7 +68,7 @@ public void testCreateAndAddActAndLeg() { * @author mrieser */ @Test - public void testInsertActLeg_Between() { + void testInsertActLeg_Between() { Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); Activity homeAct = PopulationUtils.createAndAddActivityFromCoord(plan, "h", new Coord(0, 0)); Leg leg1 = PopulationUtils.createAndAddLeg( plan, TransportMode.car ); @@ -97,7 +97,7 @@ public void testInsertActLeg_Between() { * @author mrieser */ @Test - public void testInsertActLeg_AtEnd() { + void testInsertActLeg_AtEnd() { Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); Activity homeAct = PopulationUtils.createAndAddActivityFromCoord(plan, "h", new Coord(0, 0)); Leg leg1 = PopulationUtils.createAndAddLeg( plan, TransportMode.car ); @@ -126,7 +126,7 @@ public void testInsertActLeg_AtEnd() { * @author mrieser */ @Test - public void testInsertActLeg_AtWrongPosition() { + void testInsertActLeg_AtWrongPosition() { Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); PopulationUtils.createAndAddActivityFromCoord(plan, "h", new Coord(0, 0)); PopulationUtils.createAndAddLeg( plan, TransportMode.car ); @@ -152,7 +152,7 @@ public void testInsertActLeg_AtWrongPosition() { * @author mrieser */ @Test - public void testInsertActLeg_AtStart() { + void testInsertActLeg_AtStart() { Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); PopulationUtils.createAndAddActivityFromCoord(plan, "h", new Coord(0, 0)); PopulationUtils.createAndAddLeg( plan, TransportMode.car ); @@ -179,7 +179,7 @@ public void testInsertActLeg_AtStart() { * @author mrieser */ @Test - public void testInsertActLeg_BehindEnd() { + void testInsertActLeg_BehindEnd() { Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); PopulationUtils.createAndAddActivityFromCoord(plan, "h", new Coord(0, 0)); PopulationUtils.createAndAddLeg( plan, TransportMode.car ); @@ -212,7 +212,7 @@ public void testInsertActLeg_BehindEnd() { } @Test - public void testCopyPlan_NetworkRoute() { + void testCopyPlan_NetworkRoute() { Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create(1, Node.class), new Coord(0, 0)); Node node2 = NetworkUtils.createAndAddNode(network, Id.create(2, Node.class), new Coord(1000, 0)); @@ -243,7 +243,7 @@ public void testCopyPlan_NetworkRoute() { } @Test - public void testCopyPlan_GenericRoute() { + void testCopyPlan_GenericRoute() { Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create(1, Node.class), new Coord(0, 0)); Node node2 = NetworkUtils.createAndAddNode(network, Id.create(2, Node.class), new Coord(1000, 0)); @@ -277,7 +277,7 @@ public void testCopyPlan_GenericRoute() { * @author meisterk */ @Test - public void testRemoveActivity() { + void testRemoveActivity() { Plan testee = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); PopulationUtils.createAndAddActivityFromCoord(testee, "h", new Coord(0, 0)); @@ -297,7 +297,7 @@ public void testRemoveActivity() { * @author meisterk */ @Test - public void testRemoveLeg() { + void testRemoveLeg() { Plan testee = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); PopulationUtils.createAndAddActivityFromCoord(testee, "h", new Coord(0, 0)); PopulationUtils.createAndAddLeg( testee, TransportMode.car ); @@ -313,7 +313,7 @@ public void testRemoveLeg() { } @Test - public void addMultipleLegs() { + void addMultipleLegs() { Plan p = PopulationUtils.createPlan(); p.addActivity(new ActivityImpl("h")); p.addLeg(PopulationUtils.createLeg(TransportMode.walk)); @@ -330,7 +330,7 @@ public void addMultipleLegs() { } @Test - public void addMultipleActs() { + void addMultipleActs() { Plan p = PopulationUtils.createPlan(); p.addActivity(new ActivityImpl("h")); p.addLeg(PopulationUtils.createLeg(TransportMode.walk)); @@ -345,7 +345,7 @@ public void addMultipleActs() { } @Test - public void createAndAddMultipleLegs() { + void createAndAddMultipleLegs() { Plan p = PopulationUtils.createPlan(); PopulationUtils.createAndAddActivity(p, "h"); PopulationUtils.createAndAddLeg( p, TransportMode.walk ); @@ -362,7 +362,7 @@ public void createAndAddMultipleLegs() { } @Test - public void createAndAddMultipleActs() { + void createAndAddMultipleActs() { Plan p = PopulationUtils.createPlan(); PopulationUtils.createAndAddActivity(p, "h"); PopulationUtils.createAndAddLeg( p, TransportMode.walk ); diff --git a/matsim/src/test/java/org/matsim/core/population/PopulationUtilsTest.java b/matsim/src/test/java/org/matsim/core/population/PopulationUtilsTest.java index d89a8100ec9..4b083a3fb9d 100644 --- a/matsim/src/test/java/org/matsim/core/population/PopulationUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/population/PopulationUtilsTest.java @@ -22,7 +22,7 @@ package org.matsim.core.population; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -31,13 +31,13 @@ import org.matsim.core.population.io.PopulationReader; import org.matsim.core.scenario.ScenarioUtils; -/** + /** * @author thibautd */ public class PopulationUtilsTest { - @Test - public void testPlanAttributesCopy() { + @Test + void testPlanAttributesCopy() { final Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig() ); final Person person = population.getFactory().createPerson(Id.createPersonId( "Donald Trump")); diff --git a/matsim/src/test/java/org/matsim/core/population/io/CompressedRoutesIntegrationTest.java b/matsim/src/test/java/org/matsim/core/population/io/CompressedRoutesIntegrationTest.java index 3f39ecacb02..58072ae7794 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/CompressedRoutesIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/population/io/CompressedRoutesIntegrationTest.java @@ -20,7 +20,7 @@ package org.matsim.core.population.io; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Leg; @@ -36,7 +36,7 @@ public class CompressedRoutesIntegrationTest { @Test - public void testReadingPlansV4parallel() { + void testReadingPlansV4parallel() { Config config = ConfigUtils.createConfig(); config.plans().setNetworkRouteType("CompressedNetworkRoute"); Scenario s = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/population/io/MatsimPopulationReaderTest.java b/matsim/src/test/java/org/matsim/core/population/io/MatsimPopulationReaderTest.java index c9627bf4c3c..7bf327f170d 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/MatsimPopulationReaderTest.java +++ b/matsim/src/test/java/org/matsim/core/population/io/MatsimPopulationReaderTest.java @@ -22,7 +22,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -42,7 +42,7 @@ public class MatsimPopulationReaderTest { @Test - public void testReadFile_v4() { + void testReadFile_v4() { Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Assert.assertEquals(0, s.getPopulation().getPersons().size()); new MatsimNetworkReader(s.getNetwork()).readFile("test/scenarios/equil/network.xml"); @@ -51,7 +51,7 @@ public void testReadFile_v4() { } @Test - public void testReadFile_v5() { + void testReadFile_v5() { Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Assert.assertEquals(0, s.getPopulation().getPersons().size()); new PopulationReader(s).readFile("test/input/org/matsim/core/utils/io/MatsimFileTypeGuesserTest/population_v5_example.xml"); @@ -66,9 +66,9 @@ public void testReadFile_v5() { Assert.assertTrue(planElements.get(1) instanceof Leg); Assert.assertTrue(planElements.get(2) instanceof Activity); } - + @Test - public void testReadFile_v5_multipleSuccessiveLegs() { + void testReadFile_v5_multipleSuccessiveLegs() { Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Assert.assertEquals(0, s.getPopulation().getPersons().size()); new PopulationReader(s).readFile("test/input/org/matsim/core/utils/io/MatsimFileTypeGuesserTest/population_v5_multipleLegs.xml"); @@ -85,9 +85,9 @@ public void testReadFile_v5_multipleSuccessiveLegs() { Assert.assertTrue(planElements.get(3) instanceof Leg); Assert.assertTrue(planElements.get(4) instanceof Activity); } - + @Test - public void testReadFile_v5_multipleSuccessiveLegsWithRoutes() { + void testReadFile_v5_multipleSuccessiveLegsWithRoutes() { Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Assert.assertEquals(0, s.getPopulation().getPersons().size()); new PopulationReader(s).readFile("test/input/org/matsim/core/utils/io/MatsimFileTypeGuesserTest/population_v5_multipleLegsWithRoutes.xml"); @@ -110,9 +110,9 @@ public void testReadFile_v5_multipleSuccessiveLegsWithRoutes() { Assert.assertEquals(Id.create("6", Link.class), ((Leg) planElements.get(3)).getRoute().getEndLinkId()); Assert.assertTrue(planElements.get(4) instanceof Activity); } - + @Test - public void testReadFile_v5_multipleSuccessiveLegsWithTeleportation() { + void testReadFile_v5_multipleSuccessiveLegsWithTeleportation() { Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Assert.assertEquals(0, s.getPopulation().getPersons().size()); new PopulationReader(s).readFile("test/input/org/matsim/core/utils/io/MatsimFileTypeGuesserTest/population_v5_multipleTeleportedLegs.xml"); diff --git a/matsim/src/test/java/org/matsim/core/population/io/ParallelPopulationReaderTest.java b/matsim/src/test/java/org/matsim/core/population/io/ParallelPopulationReaderTest.java index ba5efe96823..54e4e2fbd33 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/ParallelPopulationReaderTest.java +++ b/matsim/src/test/java/org/matsim/core/population/io/ParallelPopulationReaderTest.java @@ -1,7 +1,7 @@ package org.matsim.core.population.io; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.ConfigUtils; import org.matsim.core.scenario.ScenarioUtils; @@ -13,7 +13,7 @@ public class ParallelPopulationReaderTest { @Test - public void testParallelPopulationReaderV4_escalateException() { + void testParallelPopulationReaderV4_escalateException() { String xml = """ @@ -42,7 +42,7 @@ public void testParallelPopulationReaderV4_escalateException() { } @Test - public void testParallelPopulationReaderV6_escalateException() { + void testParallelPopulationReaderV6_escalateException() { String xml = """ diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationAttributeConversionTest.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationAttributeConversionTest.java index 8fe0bef6f34..86824f40ec2 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationAttributeConversionTest.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationAttributeConversionTest.java @@ -22,8 +22,8 @@ package org.matsim.core.population.io; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -38,33 +38,33 @@ import java.util.Objects; import java.util.function.Consumer; -public class PopulationAttributeConversionTest { + public class PopulationAttributeConversionTest { @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void testDefaults() { + @Test + void testDefaults() { final String path = utils.getOutputDirectory()+"/plans.xml"; testWriteAndReread(w -> w.write(path), w -> w.readFile(path)); } - @Test - public void testDefaultsStream() { + @Test + void testDefaultsStream() { final String path = utils.getOutputDirectory()+"/plans.xml"; testWriteAndReread(w -> w.write(IOUtils.getOutputStream(IOUtils.getFileUrl(path), false)), w -> w.readFile(path)); } - @Test - public void testV6() { + @Test + void testV6() { final String path = utils.getOutputDirectory()+"/plans.xml"; testWriteAndReread(w -> w.writeV6(path), w -> w.readFile(path)); } - @Test - public void testV7() { + @Test + void testV7() { final String path = utils.getOutputDirectory()+"/plans.xml"; testWriteAndReread(w -> w.writeV6(IOUtils.getOutputStream(IOUtils.getFileUrl(path), false)), w -> w.readFile(path)); diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationReaderMatsimV4Test.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationReaderMatsimV4Test.java index 0706d6d3644..c406b80ada0 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationReaderMatsimV4Test.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationReaderMatsimV4Test.java @@ -27,7 +27,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -61,7 +61,7 @@ public class PopulationReaderMatsimV4Test { * @throws IOException */ @Test - public void testReadRoute() throws SAXException, ParserConfigurationException, IOException { + void testReadRoute() throws SAXException, ParserConfigurationException, IOException { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); final Network network = scenario.getNetwork(); final Population population = scenario.getPopulation(); @@ -154,7 +154,7 @@ public void testReadRoute() throws SAXException, ParserConfigurationException, I * @author mrieser */ @Test - public void testReadRouteWithoutActivityLinks() { + void testReadRouteWithoutActivityLinks() { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); final Population population = scenario.getPopulation(); @@ -188,7 +188,7 @@ public void testReadRouteWithoutActivityLinks() { * @author mrieser */ @Test - public void testReadActivity() { + void testReadActivity() { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); final Network network = (Network) scenario.getNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord(0, 0)); @@ -219,9 +219,9 @@ public void testReadActivity() { Assert.assertEquals(link3.getId(), ((Activity) plan.getPlanElements().get(0)).getLinkId()); Assert.assertEquals(Id.create("2", Link.class), ((Activity) plan.getPlanElements().get(2)).getLinkId()); } - + @Test - public void testReadingRoutesWithoutType() { + void testReadingRoutesWithoutType() { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); PopulationReaderMatsimV4 reader = new PopulationReaderMatsimV4(scenario); final Population population = scenario.getPopulation(); @@ -276,7 +276,7 @@ public void testReadingRoutesWithoutType() { } @Test - public void testRepeatingLegs() { + void testRepeatingLegs() { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); PopulationReaderMatsimV4 reader = new PopulationReaderMatsimV4(scenario); final Population population = scenario.getPopulation(); @@ -306,7 +306,7 @@ public void testRepeatingLegs() { } @Test - public void testRepeatingActs() { + void testRepeatingActs() { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); PopulationReaderMatsimV4 reader = new PopulationReaderMatsimV4(scenario); final Population population = scenario.getPopulation(); diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationReaderMatsimV5Test.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationReaderMatsimV5Test.java index 95774b949dd..d6e6c4b31d9 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationReaderMatsimV5Test.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationReaderMatsimV5Test.java @@ -27,7 +27,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Leg; @@ -52,7 +52,7 @@ public class PopulationReaderMatsimV5Test { @Test - public void testReadRoute() throws SAXException, ParserConfigurationException, IOException { + void testReadRoute() throws SAXException, ParserConfigurationException, IOException { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); final Population population = scenario.getPopulation(); @@ -136,7 +136,7 @@ public void testReadRoute() throws SAXException, ParserConfigurationException, I } @Test - public void testReadRoute_sameLinkRoute() throws SAXException, ParserConfigurationException, IOException { + void testReadRoute_sameLinkRoute() throws SAXException, ParserConfigurationException, IOException { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); final Population population = scenario.getPopulation(); @@ -172,7 +172,7 @@ public void testReadRoute_sameLinkRoute() throws SAXException, ParserConfigurati } @Test - public void testReadRoute_consequentLinks() throws SAXException, ParserConfigurationException, IOException { + void testReadRoute_consequentLinks() throws SAXException, ParserConfigurationException, IOException { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); final Population population = scenario.getPopulation(); @@ -215,7 +215,7 @@ public void testReadRoute_consequentLinks() throws SAXException, ParserConfigura * @author mrieser */ @Test - public void testReadRouteWithoutActivityLinks() { + void testReadRouteWithoutActivityLinks() { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); final Population population = scenario.getPopulation(); @@ -246,7 +246,7 @@ public void testReadRouteWithoutActivityLinks() { } @Test - public void testReadingOldRoutesWithoutType() { + void testReadingOldRoutesWithoutType() { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); PopulationReaderMatsimV5 reader = new PopulationReaderMatsimV5(scenario); final Population population = scenario.getPopulation(); @@ -301,12 +301,12 @@ public void testReadingOldRoutesWithoutType() { Assert.assertTrue(route3 instanceof TransitPassengerRoute); } - + /** * @author mrieser */ @Test - public void testReadActivity() { + void testReadActivity() { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); final Population population = scenario.getPopulation(); @@ -333,7 +333,7 @@ public void testReadActivity() { } @Test - public void testRepeatingLegs() { + void testRepeatingLegs() { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); PopulationReaderMatsimV5 reader = new PopulationReaderMatsimV5(scenario); final Population population = scenario.getPopulation(); @@ -363,7 +363,7 @@ public void testRepeatingLegs() { } @Test - public void testRepeatingActs() { + void testRepeatingActs() { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); PopulationReaderMatsimV5 reader = new PopulationReaderMatsimV5(scenario); final Population population = scenario.getPopulation(); @@ -391,7 +391,7 @@ public void testRepeatingActs() { } @Test - public void testVehicleIdInRoute() { + void testVehicleIdInRoute() { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); PopulationReaderMatsimV5 reader = new PopulationReaderMatsimV5(scenario); final Population population = scenario.getPopulation(); diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationReprojectionIOIT.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationReprojectionIOIT.java index 7518db2c084..adeec746849 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationReprojectionIOIT.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationReprojectionIOIT.java @@ -28,8 +28,8 @@ import java.util.List; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -52,7 +52,7 @@ import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; -/** + /** * @author thibautd */ public class PopulationReprojectionIOIT { @@ -69,8 +69,8 @@ public class PopulationReprojectionIOIT { @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void testInput_V4() { + @Test + void testInput_V4() { final String testFile = new File(utils.getOutputDirectory() + "/plans.xml.gz").getAbsolutePath(); // create test file in V4 format @@ -84,8 +84,8 @@ public void testInput_V4() { testConversionAtInput(testFile); } - @Test - public void testInput_V5() { + @Test + void testInput_V5() { final String testFile = new File(utils.getOutputDirectory() + "/plans.xml.gz").getAbsolutePath(); // create test file in V5 format @@ -99,8 +99,8 @@ public void testInput_V5() { testConversionAtInput(testFile); } - @Test - public void testOutput_V4() { + @Test + void testOutput_V4() { final String testFile = new File(utils.getOutputDirectory() + "/plans.xml.gz").getAbsolutePath(); // read test population @@ -125,8 +125,8 @@ public void testOutput_V4() { assertPopulationCorrectlyTransformed( originalScenario.getPopulation() , reprojectedScenario.getPopulation() ); } - @Test - public void testOutput_V5() { + @Test + void testOutput_V5() { final String testFile = new File(utils.getOutputDirectory() + "/plans.xml.gz").getAbsolutePath(); // read test population @@ -149,8 +149,8 @@ public void testOutput_V5() { assertPopulationCorrectlyTransformed( originalScenario.getPopulation() , reprojectedScenario.getPopulation() ); } - @Test - public void testWithControlerAndAttributes() { + @Test + void testWithControlerAndAttributes() { // accept a rounding error of 1 cm. // this is used both to compare equality and non-equality, so the more we accept difference between input // and output coordinates, the more we require the internally reprojected coordinates to be different. @@ -265,8 +265,8 @@ private URL getOutputURL() { } } - @Test - public void testWithControlerAndConfigParameters() { + @Test + void testWithControlerAndConfigParameters() { // accept a rounding error of 1 cm. // this is used both to compare equality and non-equality, so the more we accept difference between input // and output coordinates, the more we require the internally reprojected coordinates to be different. diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationV6IOTest.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationV6IOTest.java index 07e7629c7cb..b30030727e9 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationV6IOTest.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationV6IOTest.java @@ -22,8 +22,8 @@ package org.matsim.core.population.io; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -54,15 +54,15 @@ import java.util.Map; -/** + /** * @author thibautd */ public class PopulationV6IOTest { @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void testCoord3dIO() { + @Test + void testCoord3dIO() { final Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig() ); final Person person = population.getFactory().createPerson(Id.createPersonId( "Donald Trump")); @@ -95,8 +95,8 @@ public void testCoord3dIO() { MatsimTestUtils.EPSILON ); } - @Test - public void testEmptyPersonAttributesIO() { + @Test + void testEmptyPersonAttributesIO() { final Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig() ); final Person person = population.getFactory().createPerson(Id.createPersonId( "Donald Trump")); @@ -110,8 +110,8 @@ public void testEmptyPersonAttributesIO() { new PopulationReader( readScenario ).readFile( file ); } - @Test - public void testPersonAttributesIO() { + @Test + void testPersonAttributesIO() { final Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig() ); final Person person = population.getFactory().createPerson(Id.createPersonId( "Donald Trump")); @@ -145,8 +145,8 @@ public void testPersonAttributesIO() { VehicleUtils.getVehicleIds(readPerson) ); } - @Test - public void testActivityAttributesIO() { + @Test + void testActivityAttributesIO() { final Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig() ); final Person person = population.getFactory().createPerson(Id.createPersonId( "Donald Trump")); @@ -178,8 +178,8 @@ public void testActivityAttributesIO() { readAct.getAttributes().getAttribute( "length" ) ); } - @Test - public void testLegAttributesIO() { + @Test + void testLegAttributesIO() { final Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig() ); final Person person = population.getFactory().createPerson(Id.createPersonId( "Donald Trump")); @@ -212,8 +212,8 @@ public void testLegAttributesIO() { Assert.assertEquals("RoutingMode not set in Leg.", TransportMode.car, readLeg.getRoutingMode()); } - @Test - public void testLegAttributesLegacyIO() { + @Test + void testLegAttributesLegacyIO() { final Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig() ); final Person person = population.getFactory().createPerson(Id.createPersonId( "Donald Trump")); @@ -246,8 +246,8 @@ public void testLegAttributesLegacyIO() { Assert.assertEquals("RoutingMode not set in Leg.", TransportMode.car, readLeg.getRoutingMode()); } - @Test - public void testPlanAttributesIO() { + @Test + void testPlanAttributesIO() { final Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig() ); final Person person = population.getFactory().createPerson(Id.createPersonId( "Donald Trump")); @@ -275,8 +275,8 @@ public void testPlanAttributesIO() { readPlan.getAttributes().getAttribute( "beauty" ) ); } - @Test - public void testPopulationAttributesIO() { + @Test + void testPopulationAttributesIO() { final Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig() ); population.getAttributes().putAttribute( "type" , "candidates" ); @@ -297,9 +297,9 @@ public void testPopulationAttributesIO() { readScenario.getPopulation().getAttributes().getAttribute( "type" ) ); } - // see MATSIM-927, https://matsim.atlassian.net/browse/MATSIM-927 - @Test - public void testRouteIO() { + // see MATSIM-927, https://matsim.atlassian.net/browse/MATSIM-927 + @Test + void testRouteIO() { Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig()); PopulationFactory pf = population.getFactory(); @@ -332,9 +332,9 @@ public void testRouteIO() { Assert.assertEquals(route.getRouteDescription(), ((Leg) scenario.getPopulation().getPersons().get(person1.getId()).getSelectedPlan().getPlanElements().get(1)).getRoute().getRouteDescription()); } - // inspired from MATSIM-927, https://matsim.atlassian.net/browse/MATSIM-927 - @Test - public void testSpecialCharactersIO() { + // inspired from MATSIM-927, https://matsim.atlassian.net/browse/MATSIM-927 + @Test + void testSpecialCharactersIO() { Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig()); PopulationFactory pf = population.getFactory(); @@ -379,8 +379,8 @@ public void testSpecialCharactersIO() { Assert.assertEquals(route.getRouteDescription(), ((Leg) scenario.getPopulation().getPersons().get(person1.getId()).getSelectedPlan().getPlanElements().get(1)).getRoute().getRouteDescription()); } - @Test - public void testSingleActivityLocationInfoIO() { + @Test + void testSingleActivityLocationInfoIO() { Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig()); PopulationFactory pf = population.getFactory(); @@ -432,8 +432,8 @@ public void testSingleActivityLocationInfoIO() { Assert.assertEquals(((Activity) pp1.getPlanElements().get(4)).getLinkId(), linkId); } - @Test - public void testPopulationCoordinateTransformationIO() { + @Test + void testPopulationCoordinateTransformationIO() { String outputDirectory = utils.getOutputDirectory(); // Create a population with CRS EPSG:25832 diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV4Test.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV4Test.java index 7a242e6ab54..1de5e13e690 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV4Test.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV4Test.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -49,7 +49,8 @@ public class PopulationWriterHandlerImplV4Test { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteGenericRoute() { + @Test + void testWriteGenericRoute() { MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(utils.loadConfig((String)null)); Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile("test/scenarios/equil/network.xml"); diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV5Test.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV5Test.java index a0e79a87e89..a28f6de0734 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV5Test.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV5Test.java @@ -24,8 +24,8 @@ import java.util.Stack; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -55,7 +55,7 @@ public class PopulationWriterHandlerImplV5Test { @RegisterExtension private MatsimTestUtils util = new MatsimTestUtils(); @Test - public void test_writeNetworkRoute_sameStartEndLink() { + void test_writeNetworkRoute_sameStartEndLink() { doTestWriteNetworkRoute("1", "", "1", "1"); // round trip @@ -63,12 +63,12 @@ public void test_writeNetworkRoute_sameStartEndLink() { } @Test - public void test_writeNetworkRoute_consequentLinks() { + void test_writeNetworkRoute_consequentLinks() { doTestWriteNetworkRoute("1", "", "2", "1 2"); } @Test - public void test_writeNetworkRoute_regularCase() { + void test_writeNetworkRoute_regularCase() { doTestWriteNetworkRoute("1", "2", "3", "1 2 3"); doTestWriteNetworkRoute("1", "2 3", "4", "1 2 3 4"); } @@ -117,7 +117,7 @@ private NetworkRoute doTestWriteNetworkRoute(final String startLinkId, final Str } @Test - public void testWriteGenericRouteRoute() { + void testWriteGenericRouteRoute() { MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(this.util.loadConfig((String) null)); String startLinkId = "1"; String endLinkId = "4"; diff --git a/matsim/src/test/java/org/matsim/core/population/io/StreamingPopulationAttributeConversionTest.java b/matsim/src/test/java/org/matsim/core/population/io/StreamingPopulationAttributeConversionTest.java index de959287f47..add49f76e92 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/StreamingPopulationAttributeConversionTest.java +++ b/matsim/src/test/java/org/matsim/core/population/io/StreamingPopulationAttributeConversionTest.java @@ -26,8 +26,8 @@ import java.util.function.Consumer; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -44,7 +44,7 @@ public class StreamingPopulationAttributeConversionTest { public final MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testDefaults() { + void testDefaults() { final String path = utils.getOutputDirectory() + "/plans.xml"; testWriteAndRereadStreaming((w, persons) -> { diff --git a/matsim/src/test/java/org/matsim/core/population/routes/AbstractNetworkRouteTest.java b/matsim/src/test/java/org/matsim/core/population/routes/AbstractNetworkRouteTest.java index d3158731d54..b3410153f72 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/AbstractNetworkRouteTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/AbstractNetworkRouteTest.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -50,7 +50,7 @@ public abstract class AbstractNetworkRouteTest { abstract protected NetworkRoute getNetworkRouteInstance(final Id fromLinkId, final Id toLinkId, final Network network); @Test - public void testSetLinkIds() { + void testSetLinkIds() { Network network = createTestNetwork(); List> links = NetworkUtils.getLinkIds("-22 2 3 24 14"); final Id link11 = Id.create(11, Link.class); @@ -68,7 +68,7 @@ public void testSetLinkIds() { } @Test - public void testSetLinks_linksNull() { + void testSetLinks_linksNull() { Network network = createTestNetwork(); Id link1 = Id.create("1", Link.class); Id link4 = Id.create("4", Link.class); @@ -88,7 +88,7 @@ public void testSetLinks_linksNull() { } @Test - public void testSetLinks_AllNull() { + void testSetLinks_AllNull() { Network network = createTestNetwork(); Id link1 = Id.create("1", Link.class); Id link4 = Id.create("4", Link.class); @@ -107,7 +107,7 @@ public void testSetLinks_AllNull() { } @Test - public void testGetDistance() { + void testGetDistance() { Network network = createTestNetwork(); Id link1 = Id.create("1", Link.class); Id link4 = Id.create("4", Link.class); @@ -119,7 +119,7 @@ public void testGetDistance() { } @Test - public void testGetLinkIds() { + void testGetLinkIds() { Network network = createTestNetwork(); Id link1 = Id.create("1", Link.class); Id link4 = Id.create("4", Link.class); @@ -135,7 +135,7 @@ public void testGetLinkIds() { } @Test - public void testGetSubRoute() { + void testGetSubRoute() { Network network = createTestNetwork(); Id id0 = Id.create("0", Link.class); Id id3 = Id.create("3", Link.class); @@ -156,7 +156,7 @@ public void testGetSubRoute() { } @Test - public void testGetSubRoute_fromStart() { + void testGetSubRoute_fromStart() { Network network = createTestNetwork(); Id id0 = Id.create("0", Link.class); Id id1 = Id.create("1", Link.class); @@ -180,7 +180,7 @@ public void testGetSubRoute_fromStart() { } @Test - public void testGetSubRoute_toEnd() { + void testGetSubRoute_toEnd() { Network network = createTestNetwork(); Id id0 = Id.create("0", Link.class); Id id3 = Id.create("3", Link.class); @@ -200,7 +200,7 @@ public void testGetSubRoute_toEnd() { } @Test - public void testGetSubRoute_startOnly() { + void testGetSubRoute_startOnly() { Network network = createTestNetwork(); Id id0 = Id.create("0", Link.class); Id id15 = Id.create("15", Link.class); @@ -215,7 +215,7 @@ public void testGetSubRoute_startOnly() { } @Test - public void testGetSubRoute_endOnly() { + void testGetSubRoute_endOnly() { Network network = createTestNetwork(); Id id0 = Id.create("0", Link.class); Id id15 = Id.create("15", Link.class); @@ -230,7 +230,7 @@ public void testGetSubRoute_endOnly() { } @Test - public void testGetSubRoute_wrongStart() { + void testGetSubRoute_wrongStart() { Network network = createTestNetwork(); Id id0 = Id.create("0", Link.class); Id id1 = Id.create("1", Link.class); @@ -247,7 +247,7 @@ public void testGetSubRoute_wrongStart() { } @Test - public void testGetSubRoute_wrongEnd() { + void testGetSubRoute_wrongEnd() { Network network = createTestNetwork(); Id id1 = Id.create("1", Link.class); Id id14 = Id.create("14", Link.class); @@ -264,7 +264,7 @@ public void testGetSubRoute_wrongEnd() { } @Test - public void testGetSubRoute_sameLinks() { + void testGetSubRoute_sameLinks() { Network network = createTestNetwork(); Id id1 = Id.create("1", Link.class); Id id12 = Id.create("12", Link.class); @@ -280,7 +280,7 @@ public void testGetSubRoute_sameLinks() { } @Test - public void testGetSubRoute_sameLinks_emptyRoute1() { + void testGetSubRoute_sameLinks_emptyRoute1() { Network network = createTestNetwork(); Id id1 = Id.create("1", Link.class); NetworkRoute route = getNetworkRouteInstance(id1, id1, network); @@ -294,7 +294,7 @@ public void testGetSubRoute_sameLinks_emptyRoute1() { } @Test - public void testGetSubRoute_sameLinks_emptyRoute2() { + void testGetSubRoute_sameLinks_emptyRoute2() { Network network = createTestNetwork(); Id id1 = Id.create("1", Link.class); Id id2 = Id.create("2", Link.class); @@ -315,7 +315,7 @@ public void testGetSubRoute_sameLinks_emptyRoute2() { } @Test - public void testGetSubRoute_fullRoute() { + void testGetSubRoute_fullRoute() { Network network = createTestNetwork(); Id id0 = Id.create("0", Link.class); Id id4 = Id.create("4", Link.class); @@ -335,7 +335,7 @@ public void testGetSubRoute_fullRoute() { } @Test - public void testGetSubRoute_circleInRoute() { + void testGetSubRoute_circleInRoute() { Network network = createTestNetwork(); NetworkUtils.createAndAddLink(network,Id.create(-3, Link.class), network.getNodes().get(Id.create(4, Node.class)), network.getNodes().get(Id.create(3, Node.class)), 1000.0, 100.0, 3600.0, (double) 1 ); Id id11 = Id.create("11", Link.class); @@ -358,7 +358,7 @@ public void testGetSubRoute_circleInRoute() { } @Test - public void testGetSubRoute_startInCircle() { + void testGetSubRoute_startInCircle() { Network network = createTestNetwork(); NetworkUtils.createAndAddLink(network,Id.create(-3, Link.class), network.getNodes().get(Id.create(4, Node.class)), network.getNodes().get(Id.create(3, Node.class)), 1000.0, 100.0, 3600.0, (double) 1 ); Id id11 = Id.create("11", Link.class); @@ -378,7 +378,7 @@ public void testGetSubRoute_startInCircle() { } @Test - public void testGetSubRoute_startInCircle_CircleInEnd() { + void testGetSubRoute_startInCircle_CircleInEnd() { Network network = createTestNetwork(); NetworkUtils.createAndAddLink(network,Id.create(-3, Link.class), network.getNodes().get(Id.create(4, Node.class)), network.getNodes().get(Id.create(3, Node.class)), 1000.0, 100.0, 3600.0, (double) 1 ); Id id11 = Id.create("11", Link.class); @@ -397,7 +397,7 @@ public void testGetSubRoute_startInCircle_CircleInEnd() { } @Test - public void testGetSubRoute_CircleAtStart() { + void testGetSubRoute_CircleAtStart() { Network network = createTestNetwork(); NetworkUtils.createAndAddLink(network,Id.create(-3, Link.class), network.getNodes().get(Id.create(4, Node.class)), network.getNodes().get(Id.create(3, Node.class)), 1000.0, 100.0, 3600.0, (double) 1 ); Id id13 = Id.create("13", Link.class); @@ -414,7 +414,7 @@ public void testGetSubRoute_CircleAtStart() { } @Test - public void testStartAndEndOnSameLinks_setLinks() { + void testStartAndEndOnSameLinks_setLinks() { Network network = createTestNetwork(); Id link = Id.create("3", Link.class); NetworkRoute route = getNetworkRouteInstance(link, link, network); @@ -423,7 +423,7 @@ public void testStartAndEndOnSameLinks_setLinks() { } @Test - public void testStartAndEndOnSubsequentLinks_setLinks() { + void testStartAndEndOnSubsequentLinks_setLinks() { Network network = createTestNetwork(); final Id link13 = Id.create("13", Link.class); final Id link14 = Id.create("14", Link.class); @@ -433,7 +433,7 @@ public void testStartAndEndOnSubsequentLinks_setLinks() { } @Test - public void testVehicleId() { + void testVehicleId() { Network network = createTestNetwork(); Id link0 = Id.create("0", Link.class); Id link15 = Id.create("15", Link.class); diff --git a/matsim/src/test/java/org/matsim/core/population/routes/LinkNetworkRouteTest.java b/matsim/src/test/java/org/matsim/core/population/routes/LinkNetworkRouteTest.java index 7c8ddcfa934..82fcb5fb6d7 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/LinkNetworkRouteTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/LinkNetworkRouteTest.java @@ -23,7 +23,7 @@ import java.util.ArrayList; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -40,7 +40,7 @@ public NetworkRoute getNetworkRouteInstance(final Id fromLinkId, final Id< } @Test - public void testClone() { + void testClone() { Id id1 = Id.create(1, Link.class); Id id2 = Id.create(2, Link.class); Id id3 = Id.create(3, Link.class); diff --git a/matsim/src/test/java/org/matsim/core/population/routes/NetworkFactoryTest.java b/matsim/src/test/java/org/matsim/core/population/routes/NetworkFactoryTest.java index d0025c9bb74..4288ce19e19 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/NetworkFactoryTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/NetworkFactoryTest.java @@ -21,8 +21,8 @@ package org.matsim.core.population.routes; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.PopulationFactory; @@ -108,7 +108,8 @@ public String getCreatedRouteType() { } - @Test public void testSetRouteFactory() { + @Test + void testSetRouteFactory() { PopulationFactory factory = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getPopulation().getFactory(); // test default diff --git a/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryImplTest.java b/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryImplTest.java index 9f418fdeda1..943fb3c9adc 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryImplTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryImplTest.java @@ -18,8 +18,7 @@ * *********************************************************************** */ package org.matsim.core.population.routes; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -40,7 +39,7 @@ public class RouteFactoryImplTest { @Test - public void testConstructor_DefaultNetworkRouteType() { + void testConstructor_DefaultNetworkRouteType() { Config config = ConfigUtils.createConfig(); Scenario scenario = ScenarioUtils.createScenario(config); PopulationFactory pf = scenario.getPopulation().getFactory(); @@ -52,7 +51,7 @@ public void testConstructor_DefaultNetworkRouteType() { } @Test - public void testConstructor_LinkNetworkRouteType() { + void testConstructor_LinkNetworkRouteType() { Config config = ConfigUtils.createConfig(); config.plans().setNetworkRouteType(PlansConfigGroup.NetworkRouteType.LinkNetworkRoute); Scenario scenario = ScenarioUtils.createScenario(config); @@ -65,7 +64,7 @@ public void testConstructor_LinkNetworkRouteType() { } @Test - public void testConstructor_HeavyCompressedNetworkRouteType() { + void testConstructor_HeavyCompressedNetworkRouteType() { Config config = ConfigUtils.createConfig(); config.plans().setNetworkRouteType(PlansConfigGroup.NetworkRouteType.HeavyCompressedNetworkRoute); Scenario scenario = ScenarioUtils.createScenario(config); @@ -78,7 +77,7 @@ public void testConstructor_HeavyCompressedNetworkRouteType() { } @Test - public void testConstructor_MediumCompressedNetworkRouteType() { + void testConstructor_MediumCompressedNetworkRouteType() { Config config = ConfigUtils.createConfig(); config.plans().setNetworkRouteType(PlansConfigGroup.NetworkRouteType.MediumCompressedNetworkRoute); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java b/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java index e72eb1ecde7..25b4b0ba526 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java @@ -21,8 +21,8 @@ package org.matsim.core.population.routes; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.*; import org.matsim.core.config.Config; @@ -50,7 +50,7 @@ public class RouteFactoryIntegrationTest { * Tests that the plans-reader and ReRoute-strategy module use the specified RouteFactory. */ @Test - public void testRouteFactoryIntegration() { + void testRouteFactoryIntegration() { Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); config.plans().setInputFile("plans2.xml"); Collection settings = config.replanning().getStrategySettings(); diff --git a/matsim/src/test/java/org/matsim/core/population/routes/heavycompressed/HeavyCompressedNetworkRouteTest.java b/matsim/src/test/java/org/matsim/core/population/routes/heavycompressed/HeavyCompressedNetworkRouteTest.java index 769da3bfc32..ed788d2cb1a 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/heavycompressed/HeavyCompressedNetworkRouteTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/heavycompressed/HeavyCompressedNetworkRouteTest.java @@ -21,7 +21,7 @@ package org.matsim.core.population.routes.heavycompressed; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -55,7 +55,7 @@ public NetworkRoute getNetworkRouteInstance(final Id fromLinkId, final Id< * different in this case where we do not actually store the links. */ @Test - public void testGetLinks_setLinks() { + void testGetLinks_setLinks() { Network network = createTestNetwork(); Link link1 = network.getLinks().get(Id.create("1", Link.class)); Link link22 = network.getLinks().get(Id.create("22", Link.class)); @@ -76,7 +76,7 @@ public void testGetLinks_setLinks() { } @Test - public void testGetLinks_onlySubsequentLinks() { + void testGetLinks_onlySubsequentLinks() { Network network = createTestNetwork(); Link link0 = network.getLinks().get(Id.create("0", Link.class)); Link link1 = network.getLinks().get(Id.create("1", Link.class)); @@ -107,7 +107,7 @@ public void testGetLinks_onlySubsequentLinks() { * hang when a route object is not correctly initialized. */ @Test - public void testGetLinkIds_incompleteInitialization() { + void testGetLinkIds_incompleteInitialization() { Network network = createTestNetwork(); Link link0 = network.getLinks().get(Id.create("0", Link.class)); Link link1 = network.getLinks().get(Id.create("1", Link.class)); @@ -129,7 +129,7 @@ public void testGetLinkIds_incompleteInitialization() { } @Test - public void testClone() { + void testClone() { Network network = NetworkUtils.createNetwork(); NetworkFactory builder = network.getFactory(); @@ -181,7 +181,7 @@ public void testClone() { } @Test - public void testGetLinks_setLinks_alternative() { + void testGetLinks_setLinks_alternative() { Network network = createTestNetwork(); Link link1 = network.getLinks().get(Id.create("1", Link.class)); Link link22 = network.getLinks().get(Id.create("22", Link.class)); @@ -202,7 +202,7 @@ public void testGetLinks_setLinks_alternative() { } @Test - public void testGetLinks_setLinks_endLoopLink() { + void testGetLinks_setLinks_endLoopLink() { Network network = createTestNetwork(); final Node node5 = network.getNodes().get(Id.create("5", Node.class)); @@ -228,7 +228,7 @@ public void testGetLinks_setLinks_endLoopLink() { } @Test - public void testGetLinks_setLinks_containsLargeLoop() { + void testGetLinks_setLinks_containsLargeLoop() { Network network = createTestNetwork(); final Node node13 = network.getNodes().get(Id.create("13", Node.class)); @@ -256,7 +256,7 @@ public void testGetLinks_setLinks_containsLargeLoop() { } @Test - public void testGetLinks_setLinks_containsLargeLoop_alternative() { + void testGetLinks_setLinks_containsLargeLoop_alternative() { Network network = createTestNetwork(); network.removeLink(Id.create("4", Link.class)); @@ -294,7 +294,7 @@ public void testGetLinks_setLinks_containsLargeLoop_alternative() { } @Test - public void testGetLinks_setLinks_isLargeLoop() { + void testGetLinks_setLinks_isLargeLoop() { Network network = createTestNetwork(); final Node node14 = network.getNodes().get(Id.create("14", Node.class)); diff --git a/matsim/src/test/java/org/matsim/core/population/routes/mediumcompressed/MediumCompressedNetworkRouteTest.java b/matsim/src/test/java/org/matsim/core/population/routes/mediumcompressed/MediumCompressedNetworkRouteTest.java index 4467fee0a63..483f7955606 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/mediumcompressed/MediumCompressedNetworkRouteTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/mediumcompressed/MediumCompressedNetworkRouteTest.java @@ -21,7 +21,7 @@ package org.matsim.core.population.routes.mediumcompressed; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -54,7 +54,7 @@ public NetworkRoute getNetworkRouteInstance(final Id fromLinkId, final Id< * different in this case where we do not actually store the links. */ @Test - public void testGetLinks_setLinks() { + void testGetLinks_setLinks() { Network network = createTestNetwork(); Link link1 = network.getLinks().get(Id.create("1", Link.class)); Link link22 = network.getLinks().get(Id.create("22", Link.class)); @@ -75,7 +75,7 @@ public void testGetLinks_setLinks() { } @Test - public void testGetLinks_onlySubsequentLinks() { + void testGetLinks_onlySubsequentLinks() { Network network = createTestNetwork(); Link link0 = network.getLinks().get(Id.create("0", Link.class)); Link link1 = network.getLinks().get(Id.create("1", Link.class)); @@ -100,7 +100,7 @@ public void testGetLinks_onlySubsequentLinks() { * hang when a route object is not correctly initialized. */ @Test - public void testGetLinkIds_incompleteInitialization() { + void testGetLinkIds_incompleteInitialization() { Network network = createTestNetwork(); Link link0 = network.getLinks().get(Id.create("0", Link.class)); Link link4 = network.getLinks().get(Id.create("4", Link.class)); @@ -113,7 +113,7 @@ public void testGetLinkIds_incompleteInitialization() { } @Test - public void testClone() { + void testClone() { Network network = NetworkUtils.createNetwork(); NetworkFactory builder = network.getFactory(); @@ -159,7 +159,7 @@ public void testClone() { } @Test - public void testGetLinks_setLinks_alternative() { + void testGetLinks_setLinks_alternative() { Network network = createTestNetwork(); Link link1 = network.getLinks().get(Id.create("1", Link.class)); Link link22 = network.getLinks().get(Id.create("22", Link.class)); @@ -180,7 +180,7 @@ public void testGetLinks_setLinks_alternative() { } @Test - public void testGetLinks_setLinks_endLoopLink() { + void testGetLinks_setLinks_endLoopLink() { Network network = createTestNetwork(); final Node node5 = network.getNodes().get(Id.create("5", Node.class)); @@ -206,7 +206,7 @@ public void testGetLinks_setLinks_endLoopLink() { } @Test - public void testGetLinks_setLinks_containsLargeLoop() { + void testGetLinks_setLinks_containsLargeLoop() { Network network = createTestNetwork(); final Node node13 = network.getNodes().get(Id.create("13", Node.class)); @@ -234,7 +234,7 @@ public void testGetLinks_setLinks_containsLargeLoop() { } @Test - public void testGetLinks_setLinks_containsLargeLoop_alternative() { + void testGetLinks_setLinks_containsLargeLoop_alternative() { Network network = createTestNetwork(); network.removeLink(Id.create("4", Link.class)); @@ -272,7 +272,7 @@ public void testGetLinks_setLinks_containsLargeLoop_alternative() { } @Test - public void testGetLinks_setLinks_isLargeLoop() { + void testGetLinks_setLinks_isLargeLoop() { Network network = createTestNetwork(); final Node node14 = network.getNodes().get(Id.create("14", Node.class)); diff --git a/matsim/src/test/java/org/matsim/core/replanning/PlanStrategyTest.java b/matsim/src/test/java/org/matsim/core/replanning/PlanStrategyTest.java index 8e4407f56e8..00f3b6ba499 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/PlanStrategyTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/PlanStrategyTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.replanning.PlanStrategyModule; import org.matsim.core.replanning.selectors.RandomPlanSelector; @@ -38,7 +38,8 @@ public class PlanStrategyTest { /** * @author mrieser */ - @Test public void testGetNumberOfStrategyModules() { + @Test + void testGetNumberOfStrategyModules() { final PlanStrategyImpl strategy = new PlanStrategyImpl(new RandomPlanSelector()); assertEquals(0, strategy.getNumberOfStrategyModules()); strategy.addStrategyModule(new DummyStrategyModule()); diff --git a/matsim/src/test/java/org/matsim/core/replanning/StrategyManagerSubpopulationsTest.java b/matsim/src/test/java/org/matsim/core/replanning/StrategyManagerSubpopulationsTest.java index a85d0c92315..df7709658c9 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/StrategyManagerSubpopulationsTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/StrategyManagerSubpopulationsTest.java @@ -23,7 +23,7 @@ import java.util.Random; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.HasPlansAndId; import org.matsim.api.core.v01.population.Person; @@ -42,7 +42,7 @@ public class StrategyManagerSubpopulationsTest { private static final String POP_NAME_2 = "buveurs_de_vin"; @Test - public void testStrategiesAreExecutedOnlyForGivenSubpopulation() { + void testStrategiesAreExecutedOnlyForGivenSubpopulation() { final StrategyManager manager = new StrategyManager(); final Random r = new Random(123); diff --git a/matsim/src/test/java/org/matsim/core/replanning/StrategyManagerTest.java b/matsim/src/test/java/org/matsim/core/replanning/StrategyManagerTest.java index 83457232183..90748e9f33b 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/StrategyManagerTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/StrategyManagerTest.java @@ -21,7 +21,7 @@ package org.matsim.core.replanning; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.HasPlansAndId; import org.matsim.api.core.v01.population.Person; @@ -40,6 +40,7 @@ import java.util.List; import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertThrows; public class StrategyManagerTest { @@ -51,7 +52,7 @@ public class StrategyManagerTest { * @author mrieser */ @Test - public void testChangeRequests() { + void testChangeRequests() { MatsimRandom.reset(4711); Population population = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getPopulation(); @@ -126,12 +127,14 @@ public void testChangeRequests() { assertEquals(498, strategy4.getCounter()); } - @Test( expected=IllegalStateException.class ) - public void testAddTwiceStrategy() { - final StrategyManager manager = new StrategyManager(); - final PlanStrategy s = new PlanStrategyImpl.Builder( new RandomPlanSelector() ).build(); - manager.addStrategy( s , null , 1 ); - manager.addStrategy( s , null , 10 ); + @Test + void testAddTwiceStrategy() { + assertThrows(IllegalStateException.class, () -> { + final StrategyManager manager = new StrategyManager(); + final PlanStrategy s = new PlanStrategyImpl.Builder( new RandomPlanSelector() ).build(); + manager.addStrategy(s, null, 1); + manager.addStrategy(s, null, 10); + }); } /** @@ -141,7 +144,7 @@ public void testAddTwiceStrategy() { * @author mrieser */ @Test - public void testRemoveStrategy() { + void testRemoveStrategy() { MatsimRandom.reset(4711); Population population = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getPopulation(); @@ -200,7 +203,7 @@ public void testRemoveStrategy() { * @author mrieser */ @Test - public void testOptimisticBehavior() { + void testOptimisticBehavior() { Population population = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getPopulation(); Person person = null; @@ -250,7 +253,7 @@ public void testOptimisticBehavior() { } @Test - public void testSetPlanSelectorForRemoval() { + void testSetPlanSelectorForRemoval() { // init StrategyManager StrategyManager manager = new StrategyManager(); manager.addStrategy( new PlanStrategyImpl(new RandomPlanSelector()), null, 1.0 ); @@ -288,7 +291,7 @@ public void testSetPlanSelectorForRemoval() { } @Test - public void testGetStrategies() { + void testGetStrategies() { // init StrategyManager StrategyManager manager = new StrategyManager(); PlanStrategy str1 = new PlanStrategyImpl(new RandomPlanSelector()); @@ -306,9 +309,9 @@ public void testGetStrategies() { Assert.assertEquals(str2, strategies.get(1)); Assert.assertEquals(str3, strategies.get(2)); } - + @Test - public void testGetWeights() { + void testGetWeights() { // init StrategyManager StrategyManager manager = new StrategyManager(); PlanStrategy str1 = new PlanStrategyImpl(new RandomPlanSelector()); @@ -326,9 +329,9 @@ public void testGetWeights() { Assert.assertEquals(2.0, weights.get(1), 1e-8); Assert.assertEquals(0.5, weights.get(2), 1e-8); } - + @Test - public void testGetWeights_ChangeRequests() { + void testGetWeights_ChangeRequests() { // init StrategyManager StrategyManager manager = new StrategyManager(); PlanStrategy str1 = new PlanStrategyImpl(new RandomPlanSelector()); diff --git a/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java b/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java index e741f3d3066..4d2a55cfbb1 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java @@ -5,8 +5,8 @@ import java.util.List; import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -191,8 +191,8 @@ public void setup() { this.scenario = ScenarioUtils.createScenario(this.config); } - @Test - public void testLinearAnneal() throws IOException { + @Test + void testLinearAnneal() throws IOException { this.saConfigVar.setAnnealType("linear"); this.saConfigVar.setEndValue(0.0); this.saConfigVar.setStartValue(0.5); @@ -208,8 +208,8 @@ public void testLinearAnneal() throws IOException { Assert.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); } - @Test - public void testMsaAnneal() throws IOException { + @Test + void testMsaAnneal() throws IOException { this.saConfigVar.setAnnealType("msa"); this.saConfigVar.setShapeFactor(1.0); this.saConfigVar.setStartValue(0.5); @@ -225,8 +225,8 @@ public void testMsaAnneal() throws IOException { Assert.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); } - @Test - public void testGeometricAnneal() throws IOException { + @Test + void testGeometricAnneal() throws IOException { this.saConfigVar.setAnnealType("geometric"); this.saConfigVar.setShapeFactor(0.9); this.saConfigVar.setStartValue(0.5); @@ -242,8 +242,8 @@ public void testGeometricAnneal() throws IOException { Assert.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); } - @Test - public void testExponentialAnneal() throws IOException { + @Test + void testExponentialAnneal() throws IOException { this.saConfigVar.setAnnealType("exponential"); this.saConfigVar.setHalfLife(0.5); this.saConfigVar.setStartValue(0.5); @@ -259,8 +259,8 @@ public void testExponentialAnneal() throws IOException { Assert.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); } - @Test - public void testSigmoidAnneal() throws IOException { + @Test + void testSigmoidAnneal() throws IOException { this.saConfigVar.setAnnealType("sigmoid"); this.saConfigVar.setHalfLife(0.5); this.saConfigVar.setShapeFactor(1.0); @@ -277,8 +277,8 @@ public void testSigmoidAnneal() throws IOException { Assert.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); } - @Test - public void testParameterAnneal() throws IOException { + @Test + void testParameterAnneal() throws IOException { this.saConfigVar.setAnnealType("linear"); this.saConfigVar.setAnnealParameter("BrainExpBeta"); this.saConfigVar.setEndValue(0.0); @@ -291,8 +291,8 @@ public void testParameterAnneal() throws IOException { Assert.assertEquals(0.0, controler.getConfig().scoring().getBrainExpBeta(), 1e-4); } - @Test - public void testTwoParameterAnneal() throws IOException { + @Test + void testTwoParameterAnneal() throws IOException { this.saConfigVar.setAnnealType("msa"); this.saConfigVar.setShapeFactor(1.0); this.saConfigVar.setStartValue(0.5); @@ -316,8 +316,8 @@ public void testTwoParameterAnneal() throws IOException { Assert.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); } - @Test - public void testInnovationSwitchoffAnneal() throws IOException { + @Test + void testInnovationSwitchoffAnneal() throws IOException { this.config.replanning().setFractionOfIterationsToDisableInnovation(0.5); this.saConfigVar.setAnnealType("msa"); this.saConfigVar.setShapeFactor(1.0); @@ -334,8 +334,8 @@ public void testInnovationSwitchoffAnneal() throws IOException { Assert.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); } - @Test - public void testFreezeEarlyAnneal() throws IOException { + @Test + void testFreezeEarlyAnneal() throws IOException { this.saConfigVar.setAnnealType("msa"); this.saConfigVar.setShapeFactor(1.0); this.saConfigVar.setEndValue(0.1); @@ -352,8 +352,8 @@ public void testFreezeEarlyAnneal() throws IOException { Assert.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); } - @Test - public void testSubpopulationAnneal() throws IOException { + @Test + void testSubpopulationAnneal() throws IOException { String targetSubpop = "subpop"; this.saConfigVar.setAnnealType("linear"); this.saConfigVar.setEndValue(0.0); diff --git a/matsim/src/test/java/org/matsim/core/replanning/choosers/ForceInnovationStrategyChooserTest.java b/matsim/src/test/java/org/matsim/core/replanning/choosers/ForceInnovationStrategyChooserTest.java index 6e292e5c75f..b6683edb58c 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/choosers/ForceInnovationStrategyChooserTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/choosers/ForceInnovationStrategyChooserTest.java @@ -1,12 +1,12 @@ package org.matsim.core.replanning.choosers; -import org.junit.Test; - import java.util.ArrayList; import java.util.List; import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; + public class ForceInnovationStrategyChooserTest { private static final int N = 10000; @@ -16,7 +16,7 @@ public class ForceInnovationStrategyChooserTest { * Shows how numbers are selected and permuted every iteration. */ @Test - public void permutation() { + void permutation() { List collected = new ArrayList<>(); diff --git a/matsim/src/test/java/org/matsim/core/replanning/conflicts/ReplanningWithConflictsTest.java b/matsim/src/test/java/org/matsim/core/replanning/conflicts/ReplanningWithConflictsTest.java index 66db3fd7806..1015bd7582c 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/conflicts/ReplanningWithConflictsTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/conflicts/ReplanningWithConflictsTest.java @@ -2,8 +2,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.IdSet; @@ -42,7 +42,7 @@ public class ReplanningWithConflictsTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testModeRestriction() { + void testModeRestriction() { /* * This is the possibly simplest use of the the conflict resolution logic. We * have 100 agents and two modes, one is "unrestricted", the other one is diff --git a/matsim/src/test/java/org/matsim/core/replanning/modules/AbstractMultithreadedModuleTest.java b/matsim/src/test/java/org/matsim/core/replanning/modules/AbstractMultithreadedModuleTest.java index cc7eedfddeb..042b090e267 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/modules/AbstractMultithreadedModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/modules/AbstractMultithreadedModuleTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.population.Plan; import org.matsim.core.config.Config; import org.matsim.core.config.groups.GlobalConfigGroup; @@ -37,7 +37,7 @@ public class AbstractMultithreadedModuleTest { private final static Logger log = LogManager.getLogger(AbstractMultithreadedModuleTest.class); @Test - public void testGetNumOfThreads() { + void testGetNumOfThreads() { Config config = new Config(); config.addCoreModules(); config.global().setNumberOfThreads(3); @@ -46,7 +46,7 @@ public void testGetNumOfThreads() { } @Test - public void testCrashingThread() { + void testCrashingThread() { try { DummyCrashingModule testee = new DummyCrashingModule(2); testee.prepareReplanning(null); diff --git a/matsim/src/test/java/org/matsim/core/replanning/modules/ChangeLegModeTest.java b/matsim/src/test/java/org/matsim/core/replanning/modules/ChangeLegModeTest.java index d54116712d7..b3fb4b3a27c 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/modules/ChangeLegModeTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/modules/ChangeLegModeTest.java @@ -21,7 +21,7 @@ package org.matsim.core.replanning.modules; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -43,7 +43,7 @@ public class ChangeLegModeTest { @Test - public void testDefaultModes() { + void testDefaultModes() { Config config = ConfigUtils.createConfig(); config.global().setNumberOfThreads(0); @@ -53,7 +53,7 @@ public void testDefaultModes() { } @Test - public void testWithConfig() { + void testWithConfig() { Config config = ConfigUtils.createConfig(); config.global().setNumberOfThreads(0); config.setParam(ChangeModeConfigGroup.CONFIG_MODULE, ChangeModeConfigGroup.CONFIG_PARAM_MODES, " car,pt ,bike,walk "); @@ -64,7 +64,7 @@ public void testWithConfig() { } @Test - public void test_behavior_allowSwitchFromListedModesOnly() { + void test_behavior_allowSwitchFromListedModesOnly() { Config config = ConfigUtils.createConfig(); config.global().setNumberOfThreads(0); config.setParam(ChangeModeConfigGroup.CONFIG_MODULE, ChangeModeConfigGroup.CONFIG_PARAM_MODES, "pt,bike,walk"); // do not include car @@ -76,7 +76,7 @@ public void test_behavior_allowSwitchFromListedModesOnly() { } @Test - public void test_behavior_fromAllModesToSpecifiedModes() { + void test_behavior_fromAllModesToSpecifiedModes() { Config config = ConfigUtils.createConfig(); config.global().setNumberOfThreads(0); config.setParam(ChangeModeConfigGroup.CONFIG_MODULE, ChangeModeConfigGroup.CONFIG_PARAM_MODES, "pt,bike,walk"); // do not include car @@ -88,14 +88,14 @@ public void test_behavior_fromAllModesToSpecifiedModes() { } @Test - public void testWithConstructor() { + void testWithConstructor() { final ChangeLegMode module = new ChangeLegMode(0, new String[] {"car", "pt", "bike", "walk"}, true, false); final String[] modes = new String[] {TransportMode.car, TransportMode.pt, TransportMode.bike, TransportMode.walk}; runTest(module, modes); } @Test - public void testWithConfig_withoutIgnoreCarAvailability() { + void testWithConfig_withoutIgnoreCarAvailability() { Config config = ConfigUtils.createConfig(); config.global().setNumberOfThreads(0); config.setParam(ChangeModeConfigGroup.CONFIG_MODULE, ChangeModeConfigGroup.CONFIG_PARAM_MODES, "car,pt,walk"); diff --git a/matsim/src/test/java/org/matsim/core/replanning/modules/ChangeSingleLegModeTest.java b/matsim/src/test/java/org/matsim/core/replanning/modules/ChangeSingleLegModeTest.java index 8b3b1a8bc8d..fd66a829450 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/modules/ChangeSingleLegModeTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/modules/ChangeSingleLegModeTest.java @@ -24,7 +24,7 @@ import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -43,7 +43,7 @@ public class ChangeSingleLegModeTest { @Test - public void testDefaultModes() { + void testDefaultModes() { Config config = ConfigUtils.createConfig(); config.global().setNumberOfThreads(0); @@ -53,7 +53,7 @@ public void testDefaultModes() { } @Test - public void testWithConfig() { + void testWithConfig() { Config config = ConfigUtils.createConfig(); config.global().setNumberOfThreads(0); config.setParam(ChangeModeConfigGroup.CONFIG_MODULE, ChangeModeConfigGroup.CONFIG_PARAM_MODES, " car,pt ,bike,walk "); @@ -62,16 +62,16 @@ public void testWithConfig() { final String[] modes = new String[] {TransportMode.car, TransportMode.pt, TransportMode.bike, TransportMode.walk}; runTest(module, modes, 20); } - + @Test - public void testWithConstructor() { + void testWithConstructor() { final ChangeSingleLegMode module = new ChangeSingleLegMode(0, new String[] {"car", "pt", "bike", "walk"}, true); final String[] modes = new String[] {TransportMode.car, TransportMode.pt, TransportMode.bike, TransportMode.walk}; runTest(module, modes, 20); } @Test - public void testWithConfig_withoutIgnoreCarAvailability() { + void testWithConfig_withoutIgnoreCarAvailability() { Config config = ConfigUtils.createConfig(); config.global().setNumberOfThreads(0); config.setParam(ChangeModeConfigGroup.CONFIG_MODULE, ChangeModeConfigGroup.CONFIG_PARAM_MODES, "car,pt,walk"); diff --git a/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java b/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java index 6612877c0f1..d739f20c19c 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java @@ -24,8 +24,8 @@ import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; @@ -71,8 +71,8 @@ public void setUp() { // prepareForSim.run(); } - @Test - public void testNoOpExternalModule() { + @Test + void testNoOpExternalModule() { ExternalModule testee = new ExternalModule(new ExternalModule.ExeRunnerDelegate() { @Override public boolean invoke() { @@ -85,8 +85,8 @@ public boolean invoke() { Assert.assertTrue(PopulationUtils.equalPopulation(scenario.getPopulation(), originalScenario.getPopulation())); } - @Test - public void testPlanEmptyingExternalModule() { + @Test + void testPlanEmptyingExternalModule() { ExternalModule testee = new ExternalModule(new ExternalModule.ExeRunnerDelegate() { @Override public boolean invoke() { diff --git a/matsim/src/test/java/org/matsim/core/replanning/planInheritance/PlanInheritanceTest.java b/matsim/src/test/java/org/matsim/core/replanning/planInheritance/PlanInheritanceTest.java index e6ca4326678..d1063c87dd6 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/planInheritance/PlanInheritanceTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/planInheritance/PlanInheritanceTest.java @@ -7,8 +7,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; + +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -24,7 +25,6 @@ import org.matsim.testcases.MatsimTestUtils; - public class PlanInheritanceTest { /** * @author alex94263 @@ -33,8 +33,8 @@ public class PlanInheritanceTest { @RegisterExtension public MatsimTestUtils util = new MatsimTestUtils(); - @Test - public void testPlanInheritanceEnabled() throws IOException { + @Test + void testPlanInheritanceEnabled() throws IOException { String outputDirectory = util.getOutputDirectory(); Config config = this.util.loadConfig("test/scenarios/equil/config_plans1.xml"); @@ -91,8 +91,8 @@ public void run(Person person) { } - @Test - public void testPlanInheritanceDisabled() throws IOException { + @Test + void testPlanInheritanceDisabled() throws IOException { String outputDirectory = util.getOutputDirectory(); Config config = this.util.loadConfig("test/scenarios/equil/config_plans1.xml"); diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/AbstractPlanSelectorTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/AbstractPlanSelectorTest.java index d6c414c47ee..8b0774ada00 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/AbstractPlanSelectorTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/AbstractPlanSelectorTest.java @@ -23,8 +23,8 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.HasPlansAndId; import org.matsim.api.core.v01.population.Person; @@ -57,7 +57,8 @@ public abstract class AbstractPlanSelectorTest { * * @author mrieser */ - @Test public void testUndefinedScore() { + @Test + void testUndefinedScore() { Person person; PlanSelector selector = getPlanSelector(); Plan plan; @@ -98,7 +99,8 @@ public abstract class AbstractPlanSelectorTest { * * @author mrieser */ - @Test public void testNoPlans() { + @Test + void testNoPlans() { Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); assertNull(getPlanSelector().selectPlan(person)); } @@ -109,7 +111,8 @@ public abstract class AbstractPlanSelectorTest { * * @author mrieser */ - @Test public void testNegativeScore() { + @Test + void testNegativeScore() { PlanSelector selector = getPlanSelector(); Plan plan; // test with only one plan... @@ -147,7 +150,8 @@ public abstract class AbstractPlanSelectorTest { * Test how a plan selector reacts when a plan has a score of zero (0.0). * This test only ensures that a plan is returned and no Exception occurred when selecting a plan. */ - @Test public void testZeroScore() { + @Test + void testZeroScore() { PlanSelector selector = getPlanSelector(); Plan plan; Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/BestPlanSelectorTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/BestPlanSelectorTest.java index c6cfca634b7..53a61e636db 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/BestPlanSelectorTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/BestPlanSelectorTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -47,7 +47,8 @@ protected PlanSelector getPlanSelector() { * * @author mrieser */ - @Test public void testBestPlan() { + @Test + void testBestPlan() { Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan plan; PersonUtils.createAndAddPlan(person, false); diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelectorTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelectorTest.java index 5de64cd172d..fa08c8705d5 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelectorTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelectorTest.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.Logger; import org.junit.After; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -60,7 +60,8 @@ protected ExpBetaPlanSelector getPlanSelector() { /** * Test that plans are selected depending on their weight, use beta = 2.0. */ - @Test public void testExpBeta2() { + @Test + void testExpBeta2() { this.config.scoring().setBrainExpBeta(2.0); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); // weight = Math.exp(this.beta * (plan.getScore() - maxScore)); @@ -112,7 +113,8 @@ protected ExpBetaPlanSelector getPlanSelector() { /** * Test that plans are selected depending on their weight, use beta = 2.0. */ - @Test public void testExpBeta1() { + @Test + void testExpBeta1() { this.config.scoring().setBrainExpBeta(1.0); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); // weight = Math.exp(this.beta * (plan.getScore() - maxScore)); @@ -168,7 +170,8 @@ protected ExpBetaPlanSelector getPlanSelector() { assertEquals(6460, cnt5); } - @Test public void testGetSelectionProbability() { + @Test + void testGetSelectionProbability() { /* * the expected results were computed with R. The standard output of double precision numbers in R has 7 digits. diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/KeepSelectedTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/KeepSelectedTest.java index fc257f49907..97f74593bc3 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/KeepSelectedTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/KeepSelectedTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -46,7 +46,8 @@ protected KeepSelected getPlanSelector() { * * @author mrieser */ - @Test public void testSelected() { + @Test + void testSelected() { Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan plan1 = PersonUtils.createAndAddPlan(person, false); Plan plan2 = PersonUtils.createAndAddPlan(person, true); diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/PathSizeLogitSelectorTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/PathSizeLogitSelectorTest.java index f21680b1ea9..6a50781d5c5 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/PathSizeLogitSelectorTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/PathSizeLogitSelectorTest.java @@ -29,7 +29,7 @@ import org.apache.logging.log4j.Logger; import org.junit.After; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -215,7 +215,8 @@ protected PlanSelector getPlanSelector() { assertNotNull(selector.selectPlan(person)); } - @Test public void testPathSizeLogitSelector() { + @Test + void testPathSizeLogitSelector() { this.network = createNetwork(); Link l1 = network.getLinks().get(Id.create("1", Link.class)); diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/RandomPlanSelectorTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/RandomPlanSelectorTest.java index 9d21f06c9aa..2d1bd9c14b5 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/RandomPlanSelectorTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/RandomPlanSelectorTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -48,7 +48,8 @@ protected PlanSelector getPlanSelector() { /** * Test that each of a person's plans is randomly selected. */ - @Test public void testRandom() { + @Test + void testRandom() { Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan plan1 = PersonUtils.createAndAddPlan(person, false); Plan plan2 = PersonUtils.createAndAddPlan(person, false); diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/WorstPlanForRemovalSelectorTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/WorstPlanForRemovalSelectorTest.java index 10058a49a59..631173aa68d 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/WorstPlanForRemovalSelectorTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/WorstPlanForRemovalSelectorTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.*; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -40,7 +40,8 @@ protected PlanSelector getPlanSelector() { * * @author mrieser */ - @Test public void testRemoveWorstPlans_nullType() { + @Test + void testRemoveWorstPlans_nullType() { PlanSelector selector = getPlanSelector(); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -80,7 +81,8 @@ protected PlanSelector getPlanSelector() { * * @author mrieser */ - @Test public void testRemoveWorstPlans_withTypes() { + @Test + void testRemoveWorstPlans_withTypes() { PlanSelector selector = getPlanSelector(); /* The used plans, ordered by score: * plan2: b, 22.0 diff --git a/matsim/src/test/java/org/matsim/core/replanning/strategies/DeterministicMultithreadedReplanningIT.java b/matsim/src/test/java/org/matsim/core/replanning/strategies/DeterministicMultithreadedReplanningIT.java index bbf1f35fa4f..1e32151930b 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/strategies/DeterministicMultithreadedReplanningIT.java +++ b/matsim/src/test/java/org/matsim/core/replanning/strategies/DeterministicMultithreadedReplanningIT.java @@ -23,8 +23,8 @@ import com.google.inject.Singleton; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.controler.AbstractModule; @@ -66,7 +66,7 @@ public class DeterministicMultithreadedReplanningIT { * with the same number of threads. */ @Test - public void testTimeAllocationMutator() { + void testTimeAllocationMutator() { int lastIteration = 5; Config config = testUtils.loadConfig("test/scenarios/equil/config.xml"); config.controller().setLastIteration(lastIteration); @@ -113,7 +113,7 @@ public void testTimeAllocationMutator() { * the same results with the same number of threads. */ @Test - public void testReRouteTimeAllocationMutator() { + void testReRouteTimeAllocationMutator() { int lastIteration = 5; Config config = testUtils.loadConfig("test/scenarios/equil/config.xml"); config.controller().setLastIteration(lastIteration); @@ -166,7 +166,7 @@ public void testReRouteTimeAllocationMutator() { * REGARDLESS the number of threads using only one agent. */ @Test - public void testReRouteOneAgent() { + void testReRouteOneAgent() { int lastIteration = 5; Config config = testUtils.loadConfig("test/scenarios/equil/config.xml"); @@ -221,7 +221,7 @@ public void testReRouteOneAgent() { * REGARDLESS the same number of threads. */ @Test - public void testReRoute() { + void testReRoute() { int lastIteration = 5; Config config = testUtils.loadConfig("test/scenarios/equil/config.xml"); config.controller().setLastIteration(lastIteration); diff --git a/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java b/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java index 62aa5944e92..16d45333e37 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java @@ -24,10 +24,10 @@ import com.google.inject.*; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -62,7 +62,7 @@ public class InnovationSwitchOffTest { * Integration test for testing if switching off of innovative strategies works. */ @Test - public void testInnovationSwitchOff() { + void testInnovationSwitchOff() { Config config = ConfigUtils.createConfig(ExamplesUtils.getTestScenarioURL("equil")); config.controller().setOutputDirectory(this.utils.getOutputDirectory()); diff --git a/matsim/src/test/java/org/matsim/core/replanning/strategies/TimeAllocationMutatorModuleTest.java b/matsim/src/test/java/org/matsim/core/replanning/strategies/TimeAllocationMutatorModuleTest.java index c27cf25f777..e82ed18aab7 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/strategies/TimeAllocationMutatorModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/strategies/TimeAllocationMutatorModuleTest.java @@ -23,8 +23,8 @@ import static org.junit.Assert.assertTrue; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -56,7 +56,8 @@ public class TimeAllocationMutatorModuleTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testSimplifiedMutation() { + @Test + void testSimplifiedMutation() { boolean affectingDuration = true ; runSimplifiedMutationRangeTest(new MutateActivityTimeAllocation( 750, affectingDuration, MatsimRandom.getLocalInstance(),24*3600,false,1), 750); @@ -150,7 +151,7 @@ private static void assertValueInRange(final String message, final double actual @Test - public void testRun() { + void testRun() { // setup population with one person Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan plan = PersonUtils.createAndAddPlan(person, true); @@ -188,7 +189,7 @@ public void testRun() { } @Test - public void testRunLatestEndTime() { + void testRunLatestEndTime() { // setup population with one person Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan plan = PersonUtils.createAndAddPlan(person, true); @@ -243,8 +244,9 @@ public void testRunLatestEndTime() { } } } + @Test - public void testLegTimesAreSetCorrectly() { + void testLegTimesAreSetCorrectly() { // setup population with one person Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan plan = PersonUtils.createAndAddPlan(person, true); diff --git a/matsim/src/test/java/org/matsim/core/router/AbstractLeastCostPathCalculatorTest.java b/matsim/src/test/java/org/matsim/core/router/AbstractLeastCostPathCalculatorTest.java index ecad20f4e9b..67ccf869eeb 100644 --- a/matsim/src/test/java/org/matsim/core/router/AbstractLeastCostPathCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/router/AbstractLeastCostPathCalculatorTest.java @@ -26,8 +26,8 @@ import javax.xml.parsers.ParserConfigurationException; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -54,7 +54,8 @@ public abstract class AbstractLeastCostPathCalculatorTest { private static final String MODE_RESTRICTION_NOT_SUPPORTED = "Router algo does not support mode restrictions. "; - @Test public void testCalcLeastCostPath_Normal() throws SAXException, ParserConfigurationException, IOException { + @Test + void testCalcLeastCostPath_Normal() throws SAXException, ParserConfigurationException, IOException { Config config = utils.loadConfig((String)null); Scenario scenario = ScenarioUtils.createScenario(config); Network network = scenario.getNetwork(); @@ -76,7 +77,8 @@ public abstract class AbstractLeastCostPathCalculatorTest { assertEquals(network.getLinks().get(Id.create("22", Link.class)), path.links.get(2)); } - @Test public void testCalcLeastCostPath_SameFromTo() throws SAXException, ParserConfigurationException, IOException { + @Test + void testCalcLeastCostPath_SameFromTo() throws SAXException, ParserConfigurationException, IOException { Scenario scenario = ScenarioUtils.createScenario(utils.loadConfig((String)null)); Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile("test/scenarios/equil/network.xml"); diff --git a/matsim/src/test/java/org/matsim/core/router/DefaultAnalysisMainModeIdentifierTest.java b/matsim/src/test/java/org/matsim/core/router/DefaultAnalysisMainModeIdentifierTest.java index 2f38c60ab90..cfb9a453501 100644 --- a/matsim/src/test/java/org/matsim/core/router/DefaultAnalysisMainModeIdentifierTest.java +++ b/matsim/src/test/java/org/matsim/core/router/DefaultAnalysisMainModeIdentifierTest.java @@ -1,6 +1,6 @@ package org.matsim.core.router; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.PlanElement; import org.matsim.core.population.PopulationUtils; @@ -21,7 +21,7 @@ private static List legs(String... modes) { } @Test - public void correctModes() { + void correctModes() { assertThat(mmi.identifyMainMode(legs(TransportMode.walk, TransportMode.car, TransportMode.walk))) .isEqualTo(TransportMode.car); @@ -44,7 +44,7 @@ public void correctModes() { } @Test - public void failingModes() { + void failingModes() { assertThatThrownBy(() -> mmi.identifyMainMode(legs("new_mode", TransportMode.walk, "other_new_mode"))). isInstanceOf(IllegalStateException.class); @@ -61,7 +61,7 @@ public void failingModes() { } @Test - public final void testIntermodalPtDrtTrip() { + final void testIntermodalPtDrtTrip() { assertThat(mmi.identifyMainMode(legs(TransportMode.non_network_walk, TransportMode.walk, TransportMode.non_network_walk, TransportMode.drt, TransportMode.walk, TransportMode.pt, TransportMode.walk, TransportMode.pt, TransportMode.walk))) diff --git a/matsim/src/test/java/org/matsim/core/router/FallbackRoutingModuleTest.java b/matsim/src/test/java/org/matsim/core/router/FallbackRoutingModuleTest.java index 97d039dd334..b2654bc7734 100644 --- a/matsim/src/test/java/org/matsim/core/router/FallbackRoutingModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/FallbackRoutingModuleTest.java @@ -2,8 +2,8 @@ import java.util.List; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -30,7 +30,7 @@ public class FallbackRoutingModuleTest{ @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void calcRoute(){ + void calcRoute(){ Config config = ConfigUtils.createConfig(); config.controller().setOutputDirectory( utils.getOutputDirectory() ); diff --git a/matsim/src/test/java/org/matsim/core/router/InvertertedNetworkRoutingTest.java b/matsim/src/test/java/org/matsim/core/router/InvertertedNetworkRoutingTest.java index 4f1a60665cd..22f15d7f73e 100644 --- a/matsim/src/test/java/org/matsim/core/router/InvertertedNetworkRoutingTest.java +++ b/matsim/src/test/java/org/matsim/core/router/InvertertedNetworkRoutingTest.java @@ -18,8 +18,7 @@ * * * *********************************************************************** */ package org.matsim.core.router; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.*; import org.matsim.api.core.v01.network.*; import org.matsim.api.core.v01.population.*; @@ -45,7 +44,7 @@ public class InvertertedNetworkRoutingTest { @Test - public void testInvertedNetworkLegRouter() { + void testInvertedNetworkLegRouter() { Fixture f = new Fixture(); LinkToLinkTravelTimeStub tt = new LinkToLinkTravelTimeStub(); TravelDisutilityFactory tc = new RandomizingTimeDistanceTravelDisutilityFactory( TransportMode.car, f.s.getConfig() ); diff --git a/matsim/src/test/java/org/matsim/core/router/MultimodalLinkChooserTest.java b/matsim/src/test/java/org/matsim/core/router/MultimodalLinkChooserTest.java index d3691722e80..c7dfc9741e8 100644 --- a/matsim/src/test/java/org/matsim/core/router/MultimodalLinkChooserTest.java +++ b/matsim/src/test/java/org/matsim/core/router/MultimodalLinkChooserTest.java @@ -20,7 +20,7 @@ package org.matsim.core.router; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -43,8 +43,8 @@ public class MultimodalLinkChooserTest { - @Test - public void testDecideOnLink() { + @Test + void testDecideOnLink() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); diff --git a/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java b/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java index 4883342c79d..5329d4c68ee 100644 --- a/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java @@ -1,7 +1,7 @@ package org.matsim.core.router; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.locationtech.jts.util.Assert; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -34,6 +34,7 @@ import java.util.stream.Collectors; import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertThrows; public class NetworkRoutingInclAccessEgressModuleTest { @@ -177,8 +178,8 @@ private static List> getNetworkRoute(List elements) { .collect(Collectors.toList()); } - @Test - public void calcRoute_modeVehiclesFromVehiclesData_differentTypesTakeDifferentRoutes() { + @Test + void calcRoute_modeVehiclesFromVehiclesData_differentTypesTakeDifferentRoutes() { Config config = createConfig(); @@ -230,10 +231,8 @@ public void calcRoute_modeVehiclesFromVehiclesData_differentTypesTakeDifferentRo } - - - @Test - public void calcRoute_defaultVehicle_defaultVehicleIsAssigned() { + @Test + void calcRoute_defaultVehicle_defaultVehicleIsAssigned() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); @@ -258,8 +257,8 @@ public void calcRoute_defaultVehicle_defaultVehicleIsAssigned() { } - @Test - public void useAccessEgressTimeFromLinkAttributes() { + @Test + void useAccessEgressTimeFromLinkAttributes() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); @@ -279,8 +278,8 @@ public void useAccessEgressTimeFromLinkAttributes() { Assert.equals(180.0,legs.get(2).getTravelTime().seconds()); } - @Test - public void useAccessEgressTimeFromConstantAndWalkTime() { + @Test + void useAccessEgressTimeFromConstantAndWalkTime() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); @@ -302,8 +301,8 @@ public void useAccessEgressTimeFromConstantAndWalkTime() { Assert.equals(180.0,legs.get(2).getTravelTime().seconds()); } - @Test - public void routingModeInEvents() { + @Test + void routingModeInEvents() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); @@ -344,37 +343,41 @@ public void handleEvent(PersonDepartureEvent event) { Assert.isTrue(routingModes.contains("car")); } - @Test(expected = RuntimeException.class) - public void failifNoAccessTimeSet() { - - Config config = createConfig(); - config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); - config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.walkConstantTimeToLink); - Scenario scenario = createScenario(config); - NetworkUtils.setLinkAccessTime(scenario.getNetwork().getLinks().get(Id.createLinkId(START_LINK)),TransportMode.car,75); - Person person = createPerson("slow-person", TransportMode.car, scenario.getPopulation().getFactory()); - scenario.getPopulation().addPerson(person); - Controler controler = createControler(scenario); - controler.run(); - } - - - @Test(expected = RuntimeException.class) - public void failifNoEgressTimeSet() { - - Config config = createConfig(); - config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); - config.routing().setAccessEgressType(AccessEgressType.walkConstantTimeToLink); - Scenario scenario = createScenario(config); - NetworkUtils.setLinkEgressTime(scenario.getNetwork().getLinks().get(Id.createLinkId(END_LINK)),TransportMode.car,180); - Person person = createPerson("slow-person", TransportMode.car, scenario.getPopulation().getFactory()); - scenario.getPopulation().addPerson(person); - Controler controler = createControler(scenario); - controler.run(); - } + @Test + void failifNoAccessTimeSet() { + assertThrows(RuntimeException.class, () -> { + + Config config = createConfig(); + config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.walkConstantTimeToLink); + Scenario scenario = createScenario(config); + NetworkUtils.setLinkAccessTime(scenario.getNetwork().getLinks().get(Id.createLinkId(START_LINK)), TransportMode.car, 75); + Person person = createPerson("slow-person", TransportMode.car, scenario.getPopulation().getFactory()); + scenario.getPopulation().addPerson(person); + Controler controler = createControler(scenario); + controler.run(); + }); + } + + + @Test + void failifNoEgressTimeSet() { + assertThrows(RuntimeException.class, () -> { + + Config config = createConfig(); + config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); + config.routing().setAccessEgressType(AccessEgressType.walkConstantTimeToLink); + Scenario scenario = createScenario(config); + NetworkUtils.setLinkEgressTime(scenario.getNetwork().getLinks().get(Id.createLinkId(END_LINK)), TransportMode.car, 180); + Person person = createPerson("slow-person", TransportMode.car, scenario.getPopulation().getFactory()); + scenario.getPopulation().addPerson(person); + Controler controler = createControler(scenario); + controler.run(); + }); + } - @Test - public void calcAccessTimeFromDistanceToLink() { + @Test + void calcAccessTimeFromDistanceToLink() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); @@ -398,8 +401,8 @@ public void calcAccessTimeFromDistanceToLink() { Assert.equals(0.0,legs.get(2).getTravelTime().seconds()); } - @Test - public void noBushwackingLegs() { + @Test + void noBushwackingLegs() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); diff --git a/matsim/src/test/java/org/matsim/core/router/NetworkRoutingModuleTest.java b/matsim/src/test/java/org/matsim/core/router/NetworkRoutingModuleTest.java index ac63754fd20..57ee84872c5 100644 --- a/matsim/src/test/java/org/matsim/core/router/NetworkRoutingModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/NetworkRoutingModuleTest.java @@ -22,7 +22,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -51,7 +51,7 @@ public class NetworkRoutingModuleTest { @Test - public void testRouteLeg() { + void testRouteLeg() { Fixture f = new Fixture(); FreespeedTravelTimeAndDisutility freespeed = new FreespeedTravelTimeAndDisutility(-6.0/3600, +6.0/3600, 0.0); LeastCostPathCalculator routeAlgo = new Dijkstra(f.s.getNetwork(), freespeed, freespeed); @@ -77,7 +77,7 @@ public void testRouteLeg() { } @Test - public void testRouteLegWithDistance() { + void testRouteLegWithDistance() { Fixture f = new Fixture(); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); diff --git a/matsim/src/test/java/org/matsim/core/router/PersonalizableDisutilityIntegrationTest.java b/matsim/src/test/java/org/matsim/core/router/PersonalizableDisutilityIntegrationTest.java index a2822d64d4a..703cf44b966 100644 --- a/matsim/src/test/java/org/matsim/core/router/PersonalizableDisutilityIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/router/PersonalizableDisutilityIntegrationTest.java @@ -20,7 +20,7 @@ package org.matsim.core.router; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -47,7 +47,7 @@ public class PersonalizableDisutilityIntegrationTest { @Test - public void testPersonAvailableForDisutility_Dijkstra() { + void testPersonAvailableForDisutility_Dijkstra() { Fixture f = new Fixture(); Dijkstra router = new Dijkstra(f.network, f.costFunction, new FreeSpeedTravelTime()); @@ -61,7 +61,7 @@ public void testPersonAvailableForDisutility_Dijkstra() { } @Test - public void testPersonAvailableForDisutility_AStarEuclidean() { + void testPersonAvailableForDisutility_AStarEuclidean() { Fixture f = new Fixture(); PreProcessEuclidean preprocess = new PreProcessEuclidean(f.costFunction); preprocess.run(f.network); @@ -76,7 +76,7 @@ public void testPersonAvailableForDisutility_AStarEuclidean() { } @Test - public void testPersonAvailableForDisutility_SpeedyALT() { + void testPersonAvailableForDisutility_SpeedyALT() { Fixture f = new Fixture(); LeastCostPathCalculatorFactory routerFactory = new SpeedyALTFactory(); LeastCostPathCalculator router = routerFactory.createPathCalculator(f.network, f.costFunction, new FreeSpeedTravelTime()); diff --git a/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java b/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java index 9061316cef6..be691aa8394 100644 --- a/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java @@ -22,8 +22,8 @@ import java.util.List; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -61,7 +61,7 @@ public class PseudoTransitRoutingModuleTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testRouteLeg() { + void testRouteLeg() { final Fixture f = new Fixture(); FreespeedTravelTimeAndDisutility freespeed = new FreespeedTravelTimeAndDisutility(-6.0/3600, +6.0/3600, 0.0); LeastCostPathCalculator routeAlgo = new Dijkstra(f.s.getNetwork(), freespeed, freespeed); diff --git a/matsim/src/test/java/org/matsim/core/router/RoutingIT.java b/matsim/src/test/java/org/matsim/core/router/RoutingIT.java index 33bf594d4c5..41da4c9aa46 100644 --- a/matsim/src/test/java/org/matsim/core/router/RoutingIT.java +++ b/matsim/src/test/java/org/matsim/core/router/RoutingIT.java @@ -25,8 +25,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.population.Person; @@ -61,8 +61,9 @@ private interface RouterProvider { public String getName(); public LeastCostPathCalculatorFactory getFactory(Network network, TravelDisutility costCalc, TravelTime timeCalc); } + @Test - public void testDijkstra() { + void testDijkstra() { doTest(new RouterProvider() { @Override public String getName() { @@ -74,8 +75,9 @@ public LeastCostPathCalculatorFactory getFactory(final Network network, final Tr } }); } + @Test - public void testSpeedyDijkstra() { + void testSpeedyDijkstra() { doTest(new RouterProvider() { @Override public String getName() { @@ -87,8 +89,9 @@ public LeastCostPathCalculatorFactory getFactory(final Network network, final Tr } }); } + @Test - public void testDijkstraPruneDeadEnds() { + void testDijkstraPruneDeadEnds() { doTest(new RouterProvider() { @Override public String getName() { @@ -102,7 +105,7 @@ public LeastCostPathCalculatorFactory getFactory(final Network network, final Tr } @Test - public void testAStarEuclidean() { + void testAStarEuclidean() { doTest(new RouterProvider() { @Override public String getName() { @@ -114,8 +117,9 @@ public LeastCostPathCalculatorFactory getFactory(final Network network, final Tr } }); } + @Test - public void testAStarLandmarks() { + void testAStarLandmarks() { doTest(new RouterProvider() { @Override public String getName() { @@ -129,7 +133,7 @@ public LeastCostPathCalculatorFactory getFactory(final Network network, final Tr } @Test - public void testSpeedyALT() { + void testSpeedyALT() { doTest(new RouterProvider() { @Override public String getName() { diff --git a/matsim/src/test/java/org/matsim/core/router/TeleportationRoutingModuleTest.java b/matsim/src/test/java/org/matsim/core/router/TeleportationRoutingModuleTest.java index a14ff151ccb..2245d7effe3 100644 --- a/matsim/src/test/java/org/matsim/core/router/TeleportationRoutingModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TeleportationRoutingModuleTest.java @@ -20,7 +20,7 @@ package org.matsim.core.router; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -41,7 +41,7 @@ public class TeleportationRoutingModuleTest { @Test - public void testRouteLeg() { + void testRouteLeg() { final Scenario scenario = ScenarioUtils.createScenario( ConfigUtils.createConfig() ); PopulationFactory populationFactory = scenario.getPopulation().getFactory(); RouteFactories routeFactory = new RouteFactories(); diff --git a/matsim/src/test/java/org/matsim/core/router/TestActivityWrapperFacility.java b/matsim/src/test/java/org/matsim/core/router/TestActivityWrapperFacility.java index 160dd39a481..fb433b944c3 100644 --- a/matsim/src/test/java/org/matsim/core/router/TestActivityWrapperFacility.java +++ b/matsim/src/test/java/org/matsim/core/router/TestActivityWrapperFacility.java @@ -24,7 +24,7 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -58,7 +58,7 @@ public void init() { } @Test - public void testWrapper() { + void testWrapper() { for (Activity activity : activities) { Facility wrapper = FacilitiesUtils.toFacility( activity, null ); diff --git a/matsim/src/test/java/org/matsim/core/router/TripRouterFactoryImplTest.java b/matsim/src/test/java/org/matsim/core/router/TripRouterFactoryImplTest.java index 25948e78d56..a49ac52dfd4 100644 --- a/matsim/src/test/java/org/matsim/core/router/TripRouterFactoryImplTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TripRouterFactoryImplTest.java @@ -20,7 +20,7 @@ package org.matsim.core.router; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -64,7 +64,7 @@ public class TripRouterFactoryImplTest { * such as railways. */ @Test - public void testRestrictedNetworkNoPt() throws Exception { + void testRestrictedNetworkNoPt() throws Exception { Config config = ConfigUtils.createConfig(); config.transit().setUseTransit( false ); @@ -152,7 +152,7 @@ public void install() { * Checks that routes are found when using a monomodal network (ie modes are not restricted) */ @Test - public void testMonomodalNetwork() throws Exception { + void testMonomodalNetwork() throws Exception { final Config config = ConfigUtils.createConfig(); final Scenario scenario = ScenarioUtils.createScenario( config ); Network net = scenario.getNetwork(); diff --git a/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java b/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java index 20447170bcd..7fd09524d24 100644 --- a/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java @@ -23,8 +23,8 @@ package org.matsim.core.router; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -41,8 +41,8 @@ public class TripRouterModuleTest { @RegisterExtension public MatsimTestUtils matsimTestUtils = new MatsimTestUtils(); - @Test - public void testRouterCreation() { + @Test + void testRouterCreation() { for (ControllerConfigGroup.RoutingAlgorithmType routingAlgorithmType : ControllerConfigGroup.RoutingAlgorithmType.values()) { Config config = ConfigUtils.createConfig(); config.controller().setRoutingAlgorithmType(routingAlgorithmType); diff --git a/matsim/src/test/java/org/matsim/core/router/TripRouterTest.java b/matsim/src/test/java/org/matsim/core/router/TripRouterTest.java index c74e3736a71..d3150f2c945 100644 --- a/matsim/src/test/java/org/matsim/core/router/TripRouterTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TripRouterTest.java @@ -25,7 +25,7 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -43,7 +43,7 @@ */ public class TripRouterTest { @Test - public void testTripInsertion() { + void testTripInsertion() { Plan plan = PopulationUtils.createPlan(); PopulationUtils.createAndAddActivity(plan, "-4"); PopulationUtils.createAndAddLeg( plan, "-3" ); @@ -87,7 +87,7 @@ public void testTripInsertion() { } @Test - public void testTripInsertionIfActivitiesImplementEquals() { + void testTripInsertionIfActivitiesImplementEquals() { Plan plan = PopulationUtils.createPlan(); plan.addActivity( new EqualsActivity( "-4" , Id.create( 1, Link.class ) ) ); PopulationUtils.createAndAddLeg( plan, "-3" ); @@ -133,7 +133,7 @@ public void testTripInsertionIfActivitiesImplementEquals() { } @Test - public void testReturnedOldTrip() throws Exception { + void testReturnedOldTrip() throws Exception { List expected = new ArrayList(); Plan plan = PopulationUtils.createPlan(); diff --git a/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsSubtoursTest.java b/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsSubtoursTest.java index 3606f570b2a..9ca21632379 100644 --- a/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsSubtoursTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsSubtoursTest.java @@ -29,7 +29,7 @@ import java.util.HashSet; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @@ -749,45 +749,45 @@ private static Collection allFixtures(final boolean anchorAtFacilities) // tests // ///////////////////////////////////////////////////////////////////////// @Test - public void testOneSubtour() { + void testOneSubtour() { performTest( createMonoSubtourFixture( useFacilitiesAsAnchorPoint ) ); } @Test - public void testTwoNestedSubtours() { + void testTwoNestedSubtours() { performTest( createTwoNestedSubtours(useFacilitiesAsAnchorPoint) ); } @Test - public void testTwoChildren() { + void testTwoChildren() { performTest( createTwoChildren(useFacilitiesAsAnchorPoint) ); } @Test - public void testComplexSubtours() { + void testComplexSubtours() { performTest( createComplexSubtours(useFacilitiesAsAnchorPoint) ); } @Test - public void testOpenPlan() { + void testOpenPlan() { performTest( createOpenPlan(useFacilitiesAsAnchorPoint) ); } @Test - public void testLoops() { + void testLoops() { performTest( createPlanWithLoops(useFacilitiesAsAnchorPoint) ); } @Test - public void testTwoIndependentTours() { + void testTwoIndependentTours() { performTest( createTwoIndependentTours(useFacilitiesAsAnchorPoint) ); } @Test - public void testTripFromSomewhereElse() { performTest( createSingleTourComingFromSomewhereElse(useFacilitiesAsAnchorPoint));} + void testTripFromSomewhereElse() { performTest( createSingleTourComingFromSomewhereElse(useFacilitiesAsAnchorPoint));} @Test - public void testTripToSomewhereElse() { performTest( createSingleTourGoingToSomewhereElse(useFacilitiesAsAnchorPoint));} + void testTripToSomewhereElse() { performTest( createSingleTourGoingToSomewhereElse(useFacilitiesAsAnchorPoint));} private static void performTest(final Fixture fixture) { final Collection subtours = @@ -809,7 +809,7 @@ private static void performTest(final Fixture fixture) { } @Test - public void testInconsistentPlan() throws Exception { + void testInconsistentPlan() throws Exception { final Fixture fixture = createInconsistentTrips( useFacilitiesAsAnchorPoint ); boolean hadException = false; try { @@ -826,7 +826,7 @@ public void testInconsistentPlan() throws Exception { } @Test - public void testGetTripsWithoutSubSubtours() throws Exception { + void testGetTripsWithoutSubSubtours() throws Exception { for (Fixture f : allFixtures( useFacilitiesAsAnchorPoint )) { final int nTrips = TripStructureUtils.getTrips( f.plan ).size(); final Collection subtours = @@ -846,7 +846,7 @@ public void testGetTripsWithoutSubSubtours() throws Exception { } @Test - public void testFatherhood() throws Exception { + void testFatherhood() throws Exception { for (Fixture f : allFixtures( useFacilitiesAsAnchorPoint )) { final Collection subtours = TripStructureUtils.getSubtours( f.plan ); diff --git a/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsTest.java b/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsTest.java index 1b72153915a..c27172a82ca 100644 --- a/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsTest.java @@ -25,7 +25,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.*; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -40,6 +43,7 @@ import org.matsim.core.scenario.ScenarioUtils; import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * @author thibautd @@ -375,9 +379,8 @@ public void createFixtureWithAccessEgress() { } - @Test - public void testActivities() throws Exception { + void testActivities() throws Exception { for (Fixture fixture : fixtures) { final List acts = TripStructureUtils.getActivities( @@ -398,7 +401,7 @@ public void testActivities() throws Exception { } @Test - public void testTrips() throws Exception { + void testTrips() throws Exception { for (Fixture fixture : fixtures) { final List trips = TripStructureUtils.getTrips(fixture.plan); @@ -436,7 +439,7 @@ public void testTrips() throws Exception { } @Test - public void testLegs() throws Exception { + void testLegs() throws Exception { for (Fixture fixture : fixtures) { final List trips = TripStructureUtils.getTrips(fixture.plan); @@ -454,29 +457,31 @@ public void testLegs() throws Exception { } - @Test( expected=NullPointerException.class ) - public void testNPEWhenLocationNullInSubtourAnalysis() { - // this may sound surprising, but for a long time the algorithm - // was perfectly fine with that if assertions were disabled... - - final Plan plan = populationFactory.createPlan(); - - // link ids are null - plan.addActivity( - populationFactory.createActivityFromCoord( - "type", - new Coord((double) 0, (double) 0)) ); - plan.addLeg( populationFactory.createLeg( "mode" ) ); - plan.addActivity( - populationFactory.createActivityFromCoord( - "type", - new Coord((double) 0, (double) 0)) ); - - TripStructureUtils.getSubtours( plan ); + @Test + void testNPEWhenLocationNullInSubtourAnalysis() { + assertThrows(NullPointerException.class, () -> { + // this may sound surprising, but for a long time the algorithm + // was perfectly fine with that if assertions were disabled... + + final Plan plan = populationFactory.createPlan(); + + // link ids are null + plan.addActivity( + populationFactory.createActivityFromCoord( + "type", + new Coord((double) 0, (double) 0))); + plan.addLeg(populationFactory.createLeg("mode")); + plan.addActivity( + populationFactory.createActivityFromCoord( + "type", + new Coord((double) 0, (double) 0))); + + TripStructureUtils.getSubtours(plan); + }); } @Test - public void testSubtourCoords() { + void testSubtourCoords() { final Plan plan = populationFactory.createPlan(); @@ -507,7 +512,7 @@ public void testSubtourCoords() { } @Test - public void testFindTripAtPlanElement() { + void testFindTripAtPlanElement() { Fixture theFixture = null ; for( Fixture fixture : fixtures ){ if ( fixture.name.equals( WITH_ACCESS_EGRESS ) ){ diff --git a/matsim/src/test/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityTest.java b/matsim/src/test/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityTest.java index 1cee2106490..b5526dd425a 100644 --- a/matsim/src/test/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityTest.java +++ b/matsim/src/test/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityTest.java @@ -24,7 +24,7 @@ import java.util.Set; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -57,7 +57,7 @@ public class RandomizingTimeDistanceTravelDisutilityTest { @Test - public void testRoutesForDifferentSigmas() { + void testRoutesForDifferentSigmas() { { Set routes = new HashSet<>(); diff --git a/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java b/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java index 395299f5f62..128a511292e 100644 --- a/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java +++ b/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java @@ -23,8 +23,8 @@ package org.matsim.core.router.old; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -58,8 +58,8 @@ public class PlanRouterTest { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void passesVehicleFromOldPlan() { + @Test + void passesVehicleFromOldPlan() { final Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); config.plans().setInputFile("plans1.xml"); final Scenario scenario = ScenarioUtils.loadScenario(config); @@ -88,8 +88,8 @@ public void install() { } } - @Test - public void keepsVehicleIfTripRouterUsesOneAlready() { + @Test + void keepsVehicleIfTripRouterUsesOneAlready() { final Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); config.plans().setInputFile("plans1.xml"); final Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/router/priorityqueue/BinaryMinHeapTest.java b/matsim/src/test/java/org/matsim/core/router/priorityqueue/BinaryMinHeapTest.java index bba6b88dab8..3cc3590ef0c 100644 --- a/matsim/src/test/java/org/matsim/core/router/priorityqueue/BinaryMinHeapTest.java +++ b/matsim/src/test/java/org/matsim/core/router/priorityqueue/BinaryMinHeapTest.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author cdobler @@ -38,9 +38,9 @@ public class BinaryMinHeapTest { protected static final Logger log = LogManager.getLogger(BinaryMinHeapTest.class); private int maxElements = 10; - + @Test - public void testAdd() { + void testAdd() { testAdd(createMinHeap(true)); testAdd(createMinHeap(false)); testAdd(createWrappedMinHeap(true)); @@ -65,7 +65,7 @@ private void testAdd(MinHeap pq) { } @Test - public void testAdd_Null() { + void testAdd_Null() { testAdd_Null(createMinHeap(true)); testAdd_Null(createMinHeap(false)); testAdd_Null(createWrappedMinHeap(true)); @@ -85,7 +85,7 @@ private void testAdd_Null(MinHeap pq) { } @Test - public void testPoll() { + void testPoll() { testPoll(createMinHeap(true)); testPoll(createMinHeap(false)); testPoll(createWrappedMinHeap(true)); @@ -119,9 +119,9 @@ private void testPoll(MinHeap pq) { Assert.assertEquals(0, pq.size()); Assert.assertNull(pq.poll()); } - + @Test - public void testPoll2() { + void testPoll2() { testPoll2(createMinHeap(true)); testPoll2(createMinHeap(false)); testPoll2(createWrappedMinHeap(true)); @@ -158,7 +158,7 @@ private void testPoll2(MinHeap pq) { } @Test - public void testIterator() { + void testIterator() { testIterator(createMinHeap(true)); testIterator(createMinHeap(false)); testIterator(createWrappedMinHeap(true)); @@ -182,7 +182,7 @@ private void testIterator(MinHeap pq) { } @Test - public void testIterator_ConcurrentModification_add() { + void testIterator_ConcurrentModification_add() { testIterator_ConcurrentModification_add(createMinHeap(true)); testIterator_ConcurrentModification_add(createMinHeap(false)); testIterator_ConcurrentModification_add(createWrappedMinHeap(true)); @@ -216,7 +216,7 @@ private void testIterator_ConcurrentModification_add(MinHeap pq) { } @Test - public void testIterator_ConcurrentModification_poll() { + void testIterator_ConcurrentModification_poll() { testIterator_ConcurrentModification_poll(createMinHeap(true)); testIterator_ConcurrentModification_poll(createMinHeap(false)); testIterator_ConcurrentModification_poll(createWrappedMinHeap(true)); @@ -249,7 +249,7 @@ private void testIterator_ConcurrentModification_poll(MinHeap pq) { } @Test - public void testIterator_ConcurrentModification_remove() { + void testIterator_ConcurrentModification_remove() { testIterator_ConcurrentModification_remove(createMinHeap(true)); testIterator_ConcurrentModification_remove(createMinHeap(false)); testIterator_ConcurrentModification_remove(createWrappedMinHeap(true)); @@ -285,7 +285,7 @@ private void testIterator_ConcurrentModification_remove(MinHeap pq) { } @Test - public void testIterator_RemoveUnsupported() { + void testIterator_RemoveUnsupported() { testIterator_RemoveUnsupported(createMinHeap(true)); testIterator_RemoveUnsupported(createMinHeap(false)); testIterator_RemoveUnsupported(createWrappedMinHeap(true)); @@ -312,7 +312,7 @@ private void testIterator_RemoveUnsupported(MinHeap pq) { } @Test - public void testRemove() { + void testRemove() { testRemove(createMinHeap(true)); testRemove(createMinHeap(false)); testRemove(createWrappedMinHeap(true)); @@ -365,7 +365,7 @@ private void testRemove(MinHeap pq) { } @Test - public void testRemoveAndAdd_LowerPriority() { + void testRemoveAndAdd_LowerPriority() { testRemoveAndAdd_LowerPriority(createMinHeap(true)); testRemoveAndAdd_LowerPriority(createMinHeap(false)); testRemoveAndAdd_LowerPriority(createWrappedMinHeap(true)); @@ -393,9 +393,9 @@ private void testRemoveAndAdd_LowerPriority(MinHeap pq) { Assert.assertNull(pq.poll()); } - @Test // increase priority -> decrease key since it is a min-heap - public void testIncreasePriority() { + @Test + void testIncreasePriority() { testIncreasePriority(createMinHeap(true)); testIncreasePriority(createMinHeap(false)); testIncreasePriority(createWrappedMinHeap(true)); @@ -447,9 +447,9 @@ private void testIncreasePriority(MinHeap pq) { assertEqualsHE(entry0, pq.poll()); Assert.assertNull(pq.poll()); } - + @Test - public void testRemoveAndAdd_HigherPriority() { + void testRemoveAndAdd_HigherPriority() { testRemoveAndAdd_HigherPriority(createMinHeap(true)); testRemoveAndAdd_HigherPriority(createMinHeap(false)); testRemoveAndAdd_HigherPriority(createWrappedMinHeap(true)); @@ -478,7 +478,7 @@ private void testRemoveAndAdd_HigherPriority(MinHeap pq) { } @Test - public void testEqualCosts() { + void testEqualCosts() { testEqualCosts(createMinHeap(true)); testEqualCosts(createMinHeap(false)); testEqualCosts(createWrappedMinHeap(true)); @@ -520,7 +520,7 @@ private void testEqualCosts(MinHeap pq) { } @Test - public void testEqualCosts2() { + void testEqualCosts2() { testEqualCosts2(createMinHeap(true)); testEqualCosts2(createMinHeap(false)); testEqualCosts2(createWrappedMinHeap(true)); @@ -579,9 +579,9 @@ private void testEqualCosts2(MinHeap pq) { assertEqualsHE(entry9, pq.poll()); Assert.assertNull(pq.poll()); } - + @Test - public void testExceedCapacity() { + void testExceedCapacity() { testExceedCapacity(createMinHeap(true)); testExceedCapacity(createMinHeap(false)); testExceedCapacity(createWrappedMinHeap(true)); @@ -620,9 +620,9 @@ private void testExceedCapacity(MinHeap pq) { log.info("catched expected exception. ", e); } } - + @Test - public void testOddOrder() { + void testOddOrder() { testOddOrder(createMinHeap(true)); testOddOrder(createMinHeap(false)); testOddOrder(createWrappedMinHeap(true)); diff --git a/matsim/src/test/java/org/matsim/core/router/speedy/DAryMinHeapTest.java b/matsim/src/test/java/org/matsim/core/router/speedy/DAryMinHeapTest.java index 3f2714b2818..f2737b2ed76 100644 --- a/matsim/src/test/java/org/matsim/core/router/speedy/DAryMinHeapTest.java +++ b/matsim/src/test/java/org/matsim/core/router/speedy/DAryMinHeapTest.java @@ -1,7 +1,7 @@ package org.matsim.core.router.speedy; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Random; @@ -11,7 +11,7 @@ public class DAryMinHeapTest { @Test - public void testPoll() { + void testPoll() { double cost[] = new double[10]; DAryMinHeap pq = new DAryMinHeap(20, 3); @@ -52,7 +52,7 @@ public void testPoll() { } @Test - public void testDecreaseKey() { + void testDecreaseKey() { DAryMinHeap pq = new DAryMinHeap(20, 4); pq.insert(2, 4); @@ -68,7 +68,7 @@ public void testDecreaseKey() { } @Test - public void stresstest() { + void stresstest() { int cnt = 2000; double[] cost = new double[cnt]; Random r = new Random(20190210L); diff --git a/matsim/src/test/java/org/matsim/core/router/speedy/SpeedyGraphTest.java b/matsim/src/test/java/org/matsim/core/router/speedy/SpeedyGraphTest.java index a473bc5f700..2127d559b03 100644 --- a/matsim/src/test/java/org/matsim/core/router/speedy/SpeedyGraphTest.java +++ b/matsim/src/test/java/org/matsim/core/router/speedy/SpeedyGraphTest.java @@ -1,7 +1,7 @@ package org.matsim.core.router.speedy; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -16,8 +16,8 @@ */ public class SpeedyGraphTest { - @Test - public void testConstruction() { + @Test + void testConstruction() { Id.resetCaches(); Fixture f = new Fixture(); diff --git a/matsim/src/test/java/org/matsim/core/scenario/LoadScenarioByHTTPIT.java b/matsim/src/test/java/org/matsim/core/scenario/LoadScenarioByHTTPIT.java index 8fe8587ad72..01f7fcc56ba 100644 --- a/matsim/src/test/java/org/matsim/core/scenario/LoadScenarioByHTTPIT.java +++ b/matsim/src/test/java/org/matsim/core/scenario/LoadScenarioByHTTPIT.java @@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -35,7 +35,7 @@ public class LoadScenarioByHTTPIT { @Test - public void testLoadingScenarioFromURLWorks() throws MalformedURLException { + void testLoadingScenarioFromURLWorks() throws MalformedURLException { // Config config = ConfigUtils.loadConfig(new URL("https://raw.githubusercontent.com/matsim-org/matsimExamples/master/tutorial/lesson-3/config.xml")); Config config = ConfigUtils.loadConfig(new URL("https://github.com/matsim-org/matsim/raw/master/examples/scenarios/lesson-3/config.xml")); Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/scenario/ScenarioByConfigInjectionTest.java b/matsim/src/test/java/org/matsim/core/scenario/ScenarioByConfigInjectionTest.java index bc7cc4793ed..a11338e58e2 100644 --- a/matsim/src/test/java/org/matsim/core/scenario/ScenarioByConfigInjectionTest.java +++ b/matsim/src/test/java/org/matsim/core/scenario/ScenarioByConfigInjectionTest.java @@ -24,8 +24,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -42,7 +42,7 @@ import org.matsim.utils.objectattributes.ObjectAttributes; import org.matsim.utils.objectattributes.ObjectAttributesXmlWriter; -/** + /** * @author thibautd */ public class ScenarioByConfigInjectionTest { @@ -50,8 +50,8 @@ public class ScenarioByConfigInjectionTest { @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void testAttributeConvertersAreInjected_deprecated() { + @Test + void testAttributeConvertersAreInjected_deprecated() { log.info( "create test scenario" ); final Config config = createTestScenario(); diff --git a/matsim/src/test/java/org/matsim/core/scenario/ScenarioImplTest.java b/matsim/src/test/java/org/matsim/core/scenario/ScenarioImplTest.java index 01762ce553d..20585a8dd28 100644 --- a/matsim/src/test/java/org/matsim/core/scenario/ScenarioImplTest.java +++ b/matsim/src/test/java/org/matsim/core/scenario/ScenarioImplTest.java @@ -20,7 +20,7 @@ package org.matsim.core.scenario; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.config.ConfigUtils; import org.matsim.households.Households; import org.matsim.pt.transitSchedule.api.TransitSchedule; @@ -31,7 +31,7 @@ */ public class ScenarioImplTest { @Test - public void testAddAndGetScenarioElement() { + void testAddAndGetScenarioElement() { final MutableScenario s = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); final Object element1 = new Object(); @@ -59,7 +59,7 @@ public void testAddAndGetScenarioElement() { } @Test - public void testCannotAddAnElementToAnExistingName() { + void testCannotAddAnElementToAnExistingName() { final MutableScenario s = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); final String name = "bruce_wayne"; @@ -78,7 +78,7 @@ public void testCannotAddAnElementToAnExistingName() { } @Test - public void testRemoveElement() { + void testRemoveElement() { final MutableScenario s = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); final Object element = new Object(); diff --git a/matsim/src/test/java/org/matsim/core/scenario/ScenarioLoaderImplTest.java b/matsim/src/test/java/org/matsim/core/scenario/ScenarioLoaderImplTest.java index bca2d701757..1cdae1fd44a 100644 --- a/matsim/src/test/java/org/matsim/core/scenario/ScenarioLoaderImplTest.java +++ b/matsim/src/test/java/org/matsim/core/scenario/ScenarioLoaderImplTest.java @@ -21,8 +21,8 @@ import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; @@ -49,7 +49,7 @@ public class ScenarioLoaderImplTest { @RegisterExtension private MatsimTestUtils util = new MatsimTestUtils(); @Test - public void testLoadScenario_loadTransitData() { + void testLoadScenario_loadTransitData() { // test the create/load sequence: { ScenarioBuilder builder = new ScenarioBuilder(ConfigUtils.loadConfig(IOUtils.extendUrl(this.util.classInputResourcePath(), "transitConfig.xml"))); @@ -71,7 +71,7 @@ public void testLoadScenario_loadTransitData() { } @Test - public void testLoadScenario_loadPersonAttributes_nowDeprecated() { + void testLoadScenario_loadPersonAttributes_nowDeprecated() { Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(this.util.classInputResourcePath(), "personAttributesConfig.xml")); config.plans().addParam("inputPersonAttributesFile", "personAttributes.xml"); config.plans().setInsistingOnUsingDeprecatedPersonAttributeFile( true ); @@ -83,7 +83,7 @@ public void testLoadScenario_loadPersonAttributes_nowDeprecated() { } @Test - public void testLoadScenario_loadPersonAttributes() { + void testLoadScenario_loadPersonAttributes() { Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(this.util.classInputResourcePath(), "personAttributesConfig.xml")); config.plans().addParam("inputPersonAttributesFile", "personAttributes.xml"); boolean caughtException=false ; @@ -99,7 +99,7 @@ public void testLoadScenario_loadPersonAttributes() { @Test - public void testLoadScenario_loadFacilitiesAttributes() { + void testLoadScenario_loadFacilitiesAttributes() { Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(this.util.classInputResourcePath(), "facilityAttributesConfig.xml")); config.facilities().setInsistingOnUsingDeprecatedFacilitiesAttributeFile(true); config.facilities().addParam("inputFacilityAttributesFile", "facilityAttributes.xml"); @@ -113,7 +113,7 @@ public void testLoadScenario_loadFacilitiesAttributes() { } @Test - public void testLoadScenario_loadHouseholdAttributes() { + void testLoadScenario_loadHouseholdAttributes() { Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(this.util.classInputResourcePath(), "householdAttributesConfig.xml")); config.households().addParam("inputHouseholdAttributesFile", "householdAttributes.xml"); config.households().setInsistingOnUsingDeprecatedHouseholdsAttributeFile(true); diff --git a/matsim/src/test/java/org/matsim/core/scenario/ScenarioUtilsTest.java b/matsim/src/test/java/org/matsim/core/scenario/ScenarioUtilsTest.java index 0a3c90f6e6e..2e6b2aa7e22 100644 --- a/matsim/src/test/java/org/matsim/core/scenario/ScenarioUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/scenario/ScenarioUtilsTest.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; /** @@ -33,7 +33,7 @@ public class ScenarioUtilsTest { private final static Logger log = LogManager.getLogger(ScenarioUtilsTest.class); @Test - public void testCreateScenario_nullConfig() { + void testCreateScenario_nullConfig() { try { Scenario s = ScenarioUtils.createScenario(null); Assert.fail("expected NPE, but got none." + s.toString()); diff --git a/matsim/src/test/java/org/matsim/core/scoring/EventsToActivitiesTest.java b/matsim/src/test/java/org/matsim/core/scoring/EventsToActivitiesTest.java index 9a4b46a6dda..9af33789d81 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/EventsToActivitiesTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/EventsToActivitiesTest.java @@ -20,7 +20,7 @@ package org.matsim.core.scoring; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; @@ -33,7 +33,7 @@ public class EventsToActivitiesTest { @Test - public void testCreatesActivty() { + void testCreatesActivty() { EventsToActivities testee = new EventsToActivities(); MockActivityHandler ah = new MockActivityHandler(); testee.addActivityHandler(ah); @@ -50,7 +50,7 @@ public void testCreatesActivty() { } @Test - public void testCreateNightActivity() { + void testCreateNightActivity() { EventsToActivities testee = new EventsToActivities(); MockActivityHandler ah = new MockActivityHandler(); testee.addActivityHandler(ah); @@ -70,9 +70,9 @@ public void testCreateNightActivity() { Assert.assertEquals( 123., ah.handledActivity.getActivity().getCoord().getX(), 0. ); Assert.assertEquals( 4.56, ah.handledActivity.getActivity().getCoord().getY(), 0. ); } - + @Test - public void testDontCreateNightActivityIfNoneIsBeingPerformedWhenSimulationEnds() { + void testDontCreateNightActivityIfNoneIsBeingPerformedWhenSimulationEnds() { EventsToActivities testee = new EventsToActivities(); MockActivityHandler ah = new MockActivityHandler(); testee.addActivityHandler(ah); diff --git a/matsim/src/test/java/org/matsim/core/scoring/EventsToLegsTest.java b/matsim/src/test/java/org/matsim/core/scoring/EventsToLegsTest.java index 82ba5a610ba..e4867f43cad 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/EventsToLegsTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/EventsToLegsTest.java @@ -22,7 +22,7 @@ import java.util.Collections; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -61,7 +61,7 @@ public class EventsToLegsTest { @Test - public void testCreatesLeg() { + void testCreatesLeg() { Scenario scenario = createTriangularNetwork(); EventsToLegs eventsToLegs = new EventsToLegs(scenario); RememberingLegHandler lh = new RememberingLegHandler(); @@ -73,7 +73,7 @@ public void testCreatesLeg() { } @Test - public void testCreatesLegWithRoute() { + void testCreatesLegWithRoute() { Scenario scenario = createTriangularNetwork(); EventsToLegs eventsToLegs = new EventsToLegs(scenario); RememberingLegHandler lh = new RememberingLegHandler(); @@ -93,7 +93,7 @@ public void testCreatesLegWithRoute() { } @Test - public void testCreatesLegWithRoute_jointTrip() { + void testCreatesLegWithRoute_jointTrip() { Scenario scenario = createTriangularNetwork(); EventsToLegs eventsToLegs = new EventsToLegs(scenario); RememberingLegHandler lh = new RememberingLegHandler(); @@ -135,7 +135,7 @@ public void testCreatesLegWithRoute_jointTrip() { } @Test - public void testCreatesLegWithRoute_withoutEnteringTraffic() { + void testCreatesLegWithRoute_withoutEnteringTraffic() { Scenario scenario = createTriangularNetwork(); EventsToLegs eventsToLegs = new EventsToLegs(scenario); RememberingLegHandler lh = new RememberingLegHandler(); @@ -153,7 +153,7 @@ public void testCreatesLegWithRoute_withoutEnteringTraffic() { } @Test - public void testCreatesLegWithRoute_withLeavingTrafficOnTheSameLink() { + void testCreatesLegWithRoute_withLeavingTrafficOnTheSameLink() { Scenario scenario = createTriangularNetwork(); EventsToLegs eventsToLegs = new EventsToLegs(scenario); RememberingLegHandler lh = new RememberingLegHandler(); @@ -173,9 +173,9 @@ public void testCreatesLegWithRoute_withLeavingTrafficOnTheSameLink() { Assert.assertEquals(EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME + " missing or incorrect!", 10.0, lh.handledLeg.getLeg().getAttributes().getAttribute(EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME)); } - + @Test - public void testCreatesTransitPassengerRoute() { + void testCreatesTransitPassengerRoute() { Config config = ConfigUtils.createConfig(); config.transit().setUseTransit(true); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/scoring/EventsToScoreTest.java b/matsim/src/test/java/org/matsim/core/scoring/EventsToScoreTest.java index 4873a3759ec..ea8da87ea56 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/EventsToScoreTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/EventsToScoreTest.java @@ -21,8 +21,8 @@ package org.matsim.core.scoring; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.PersonMoneyEvent; @@ -51,7 +51,8 @@ public class EventsToScoreTest { /** * Tests that an AgentUtilityEvent is handled by calling the method addUtility() of a scoring function. */ - @Test public void testAddMoney() { + @Test + void testAddMoney() { MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); Population population = scenario.getPopulation(); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -67,7 +68,8 @@ public class EventsToScoreTest { Assert.assertEquals(3.4, e2s.getAgentScore(person.getId()), 0); } - @Test public void testMsaAveraging() { + @Test + void testMsaAveraging() { Config config = ConfigUtils.createConfig() ; config.controller().setFirstIteration(10); diff --git a/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java b/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java index 30f51ac024c..2f180299805 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java +++ b/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java @@ -21,7 +21,7 @@ package org.matsim.core.scoring; import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.ActivityEndEvent; @@ -45,36 +45,39 @@ import org.matsim.core.scoring.functions.CharyparNagelScoringFunctionFactory; import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class ScoringFunctionsForPopulationStressIT { static final int MAX = 1000000; - @Test(expected = RuntimeException.class) - public void exceptionInScoringFunctionPropagates() { - Config config = ConfigUtils.createConfig(); - Scenario scenario = ScenarioUtils.createScenario(config); - Id personId = Id.createPersonId(1); - scenario.getPopulation().addPerson(scenario.getPopulation().getFactory().createPerson(personId)); - EventsManager events = EventsUtils.createEventsManager(config); - ControlerListenerManagerImpl controlerListenerManager = new ControlerListenerManagerImpl(); - ScoringFunctionFactory throwingScoringFunctionFactory = new ThrowingScoringFunctionFactory(); - EventsToActivities e2acts = new EventsToActivities(controlerListenerManager); - EventsToLegs e2legs = new EventsToLegs(scenario.getNetwork()); - EventsToLegsAndActivities e2legsActs = new EventsToLegsAndActivities(e2legs, e2acts); - events.addHandler(e2legsActs); - ScoringFunctionsForPopulation scoringFunctionsForPopulation = new ScoringFunctionsForPopulation( - controlerListenerManager, - events, - e2acts, - e2legs, - scenario.getPopulation(), - throwingScoringFunctionFactory, - config - ); - controlerListenerManager.fireControlerIterationStartsEvent(0, false); - events.processEvent(new PersonMoneyEvent(3600.0, personId, 3.4, "tollRefund", "motorwayOperator")); - scoringFunctionsForPopulation.finishScoringFunctions(); + @Test + void exceptionInScoringFunctionPropagates() { + assertThrows(RuntimeException.class, () -> { + Config config = ConfigUtils.createConfig(); + Scenario scenario = ScenarioUtils.createScenario(config); + Id personId = Id.createPersonId(1); + scenario.getPopulation().addPerson(scenario.getPopulation().getFactory().createPerson(personId)); + EventsManager events = EventsUtils.createEventsManager(config); + ControlerListenerManagerImpl controlerListenerManager = new ControlerListenerManagerImpl(); + ScoringFunctionFactory throwingScoringFunctionFactory = new ThrowingScoringFunctionFactory(); + EventsToActivities e2acts = new EventsToActivities(controlerListenerManager); + EventsToLegs e2legs = new EventsToLegs(scenario.getNetwork()); + EventsToLegsAndActivities e2legsActs = new EventsToLegsAndActivities(e2legs, e2acts); + events.addHandler(e2legsActs); + ScoringFunctionsForPopulation scoringFunctionsForPopulation = new ScoringFunctionsForPopulation( + controlerListenerManager, + events, + e2acts, + e2legs, + scenario.getPopulation(), + throwingScoringFunctionFactory, + config + ); + controlerListenerManager.fireControlerIterationStartsEvent(0, false); + events.processEvent(new PersonMoneyEvent(3600.0, personId, 3.4, "tollRefund", "motorwayOperator")); + scoringFunctionsForPopulation.finishScoringFunctions(); + }); } private class ThrowingScoringFunctionFactory implements ScoringFunctionFactory { @@ -130,14 +133,14 @@ public void handleEvent(Event event) { } @Test - public void workWithNewEventsManager() { + void workWithNewEventsManager() { Config config = ConfigUtils.createConfig(); config.eventsManager().setOneThreadPerHandler(true); work(config); } @Test - public void workWithOldEventsManager() { + void workWithOldEventsManager() { Config config = ConfigUtils.createConfig(); config.eventsManager().setNumberOfThreads(8); work(config); @@ -241,15 +244,16 @@ public void handleEvent(Event event) { assertEquals(1.0/6.0 * MAX, scoringFunctionsForPopulation.getScoringFunctionForAgent(personId).getScore(), 1.0); } - /* I (mrieser, 2019-01-09) disabled this test. By definition, events for one person should come in the right sequence, - so this tests actually tests some additional (and potentially optional) behavior. But, more importantly, it poses - inherent problems with the addition of trip scoring: to detect trips, it is important that activities and legs - occur in the correct sequence, which means that also the corresponding events must be in the right sequence. - If the sequence is disturbed, the trip detection already fails. So, with trip scoring, this test would always fail - as it tests some non-required functionality. + /*I (mrieser, 2019-01-09) disabled this test. By definition, events for one person should come in the right sequence, + so this tests actually tests some additional (and potentially optional) behavior. But, more importantly, it poses + inherent problems with the addition of trip scoring: to detect trips, it is important that activities and legs + occur in the correct sequence, which means that also the corresponding events must be in the right sequence. + If the sequence is disturbed, the trip detection already fails. So, with trip scoring, this test would always fail + as it tests some non-required functionality. */ - @Test @Ignore - public void unlikelyTimingOfScoringFunctionStillWorks() { + @Test + @Ignore + void unlikelyTimingOfScoringFunctionStillWorks() { Config config = ConfigUtils.createConfig(); config.eventsManager().setNumberOfThreads(8); config.eventsManager().setOneThreadPerHandler(true); diff --git a/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationTest.java b/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationTest.java index 71ca0d7f584..9eec6681fb6 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationTest.java @@ -22,7 +22,7 @@ package org.matsim.core.scoring; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -44,13 +44,13 @@ import org.matsim.core.router.TripStructureUtils; import org.matsim.core.scenario.ScenarioUtils; -/** + /** * @author mrieser / Simunto GmbH */ public class ScoringFunctionsForPopulationTest { - @Test - public void testTripScoring() { + @Test + void testTripScoring() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Population population = scenario.getPopulation(); PopulationFactory pf = population.getFactory(); @@ -103,8 +103,8 @@ public void testTripScoring() { Assert.assertEquals("transit_walk", ((Leg) rs.lastTrip.getTripElements().get(4)).getMode()); } - @Test - public void testPersonScoreEventScoring() { + @Test + void testPersonScoreEventScoring() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Population population = scenario.getPopulation(); PopulationFactory pf = population.getFactory(); diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringDailyConstantsTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringDailyConstantsTest.java index 5b143bd9623..20f3e790285 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringDailyConstantsTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringDailyConstantsTest.java @@ -20,7 +20,7 @@ package org.matsim.core.scoring.functions; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -53,7 +53,7 @@ public class CharyparNagelLegScoringDailyConstantsTest { * Tests whether daily constants are considered in the scoring. */ @Test - public void test1() throws Exception { + void test1() throws Exception { final Network network = createNetwork(); final CharyparNagelLegScoring scoring1 = createScoringOnlyConstants( network ); final CharyparNagelLegScoring scoring2 = createDefaultPlusConstants( network ); diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringPtChangeTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringPtChangeTest.java index 6271fd0934c..7993c58251f 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringPtChangeTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringPtChangeTest.java @@ -22,7 +22,7 @@ import java.util.Random; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -63,7 +63,7 @@ public class CharyparNagelLegScoringPtChangeTest { * the start of the waiting). */ @Test - public void testPtParamsDoNotInfluenceCarScore() throws Exception { + void testPtParamsDoNotInfluenceCarScore() throws Exception { final Network network = createNetwork(); final CharyparNagelLegScoring scoring1 = createScoring( 1 , network ); final CharyparNagelLegScoring scoring2 = createScoring( 2 , network ); diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelOpenTimesScoringFunctionTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelOpenTimesScoringFunctionTest.java index 5e87ef5bf27..be33cc41056 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelOpenTimesScoringFunctionTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelOpenTimesScoringFunctionTest.java @@ -24,8 +24,8 @@ import org.junit.After; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -91,7 +91,8 @@ public class CharyparNagelOpenTimesScoringFunctionTest { this.facilities = null; } - @Test public void testGetOpeningInterval() { + @Test + void testGetOpeningInterval() { Activity act = (Activity) person.getSelectedPlan().getPlanElements().get(0) ; FacilityOpeningIntervalCalculator testee = diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java index 53358733184..c6d2b91d154 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java @@ -25,7 +25,7 @@ import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; @@ -131,7 +131,7 @@ private double getZeroUtilDuration_hrs(final double typicalDuration_hrs, final d * Test the calculation of the zero-utility-duration. */ @Test - public void testZeroUtilityDuration() { + void testZeroUtilityDuration() { double zeroUtilDurW = getZeroUtilDuration_hrs(8.0, 1.0); double zeroUtilDurH = getZeroUtilDuration_hrs(16.0, 1.0); double zeroUtilDurW2 = getZeroUtilDuration_hrs(8.0, 2.0); @@ -181,13 +181,13 @@ public void testZeroUtilityDuration() { * Test the scoring function when all parameters are set to 0. */ @Test - public void testZero() { + void testZero() { Fixture f = new Fixture(); assertEquals(0.0, calcScore(f), EPSILON); } @Test - public void testTravelingAndConstantCar() { + void testTravelingAndConstantCar() { Fixture f = new Fixture(); final double traveling = -6.0; f.config.scoring().getModes().get(TransportMode.car).setMarginalUtilityOfTraveling(traveling); @@ -198,7 +198,7 @@ public void testTravelingAndConstantCar() { } @Test - public void testTravelingPtAndConstantPt() { + void testTravelingPtAndConstantPt() { Fixture f = new Fixture(); final double travelingPt = -9.0; f.config.scoring().getModes().get(TransportMode.pt).setMarginalUtilityOfTraveling(travelingPt); @@ -209,7 +209,7 @@ public void testTravelingPtAndConstantPt() { } @Test - public void testTravelingWalkAndConstantWalk() { + void testTravelingWalkAndConstantWalk() { Fixture f = new Fixture(); final double travelingWalk = -18.0; f.config.scoring().getModes().get(TransportMode.walk).setMarginalUtilityOfTraveling(travelingWalk); @@ -220,7 +220,7 @@ public void testTravelingWalkAndConstantWalk() { } @Test - public void testTravelingBikeAndConstantBike(){ + void testTravelingBikeAndConstantBike(){ Fixture f = new Fixture(); final double travelingBike = -6.0; f.config.scoring().getModes().get(TransportMode.bike).setMarginalUtilityOfTraveling(travelingBike); @@ -234,7 +234,7 @@ public void testTravelingBikeAndConstantBike(){ * Test the performing part of the scoring function. */ @Test - public void testPerforming() { + void testPerforming() { Fixture f = new Fixture(); double perf = +6.0; @@ -266,7 +266,7 @@ public void testPerforming() { * Test the performing part of the scoring function when an activity has an OpeningTime set. */ @Test - public void testOpeningTime() { + void testOpeningTime() { Fixture f = new Fixture(); double perf = +6.0; f.config.scoring().setPerforming_utils_hr(perf); @@ -284,7 +284,7 @@ public void testOpeningTime() { * Test the performing part of the scoring function when an activity has a ClosingTime set. */ @Test - public void testClosingTime() { + void testClosingTime() { Fixture f = new Fixture(); double perf = +6.0; f.config.scoring().setPerforming_utils_hr(perf); @@ -302,7 +302,7 @@ public void testClosingTime() { * Test the performing part of the scoring function when an activity has OpeningTime and ClosingTime set. */ @Test - public void testOpeningClosingTime() { + void testOpeningClosingTime() { Fixture f = new Fixture(); double perf_hrs = +6.0; f.config.scoring().setPerforming_utils_hr(perf_hrs); @@ -366,7 +366,7 @@ public void testOpeningClosingTime() { * Test the waiting part of the scoring function. */ @Test - public void testWaitingTime() { + void testWaitingTime() { Fixture f = new Fixture(); double waiting = -10.0; f.config.scoring().setMarginalUtlOfWaiting_utils_hr(waiting); @@ -383,7 +383,7 @@ public void testWaitingTime() { * Test the scoring function in regards to early departures. */ @Test - public void testEarlyDeparture() { + void testEarlyDeparture() { Fixture f = new Fixture(); double disutility = -10.0; f.config.scoring().setEarlyDeparture_utils_hr(disutility); @@ -399,7 +399,7 @@ public void testEarlyDeparture() { * Test the scoring function in regards to early departures. */ @Test - public void testMinimumDuration() { + void testMinimumDuration() { Fixture f = new Fixture(); double disutility = -10.0; f.config.scoring().setEarlyDeparture_utils_hr(disutility); @@ -415,7 +415,7 @@ public void testMinimumDuration() { * Test the scoring function in regards to late arrival. */ @Test - public void testLateArrival() { + void testLateArrival() { Fixture f = new Fixture(); double disutility = -10.0; f.config.scoring().setLateArrival_utils_hr(disutility); @@ -432,7 +432,7 @@ public void testLateArrival() { * could gain. */ @Test - public void testStuckPenalty() { + void testStuckPenalty() { Fixture f = new Fixture(); // test 1 where late arrival has the biggest impact f.config.scoring().setLateArrival_utils_hr(-18.0); @@ -469,7 +469,7 @@ public void testStuckPenalty() { } @Test - public void testDistanceCostScoringCar() { + void testDistanceCostScoringCar() { Fixture f = new Fixture(); // test 1 where marginalUtitityOfMoney is fixed to 1.0 f.config.scoring().setMarginalUtilityOfMoney(1.0); @@ -488,7 +488,7 @@ public void testDistanceCostScoringCar() { } @Test - public void testDistanceCostScoringPt() { + void testDistanceCostScoringPt() { Fixture f = new Fixture(); // test 1 where marginalUtitityOfMoney is fixed to 1.0 f.config.scoring().setMarginalUtilityOfMoney(1.0); @@ -510,7 +510,7 @@ public void testDistanceCostScoringPt() { * Test how the scoring function reacts when the first and the last activity do not have the same act-type. */ @Test - public void testDifferentFirstLastAct() { + void testDifferentFirstLastAct() { Fixture f = new Fixture(); // change the last act to something different than the first act ((Activity) f.plan.getPlanElements().get(8)).setType("h2"); @@ -546,7 +546,7 @@ public void testDifferentFirstLastAct() { * when the first and last activity aren't the same. */ @Test - public void testNoNightActivity() { + void testNoNightActivity() { double zeroUtilDurW = getZeroUtilDuration_hrs(3.0, 1.0); double zeroUtilDurH = getZeroUtilDuration_hrs(7.0, 1.0); @@ -587,7 +587,7 @@ public void testNoNightActivity() { * aforementioned plan. */ @Test - public void testAddMoney() { + void testAddMoney() { Fixture f = new Fixture(); // score the same plan twice @@ -629,7 +629,7 @@ public void testAddMoney() { * Tests if the scoring function correctly handles {@link PersonScoreEvent}. */ @Test - public void testAddScore() { + void testAddScore() { Fixture f = new Fixture(); // score the same plan twice @@ -668,7 +668,7 @@ public void testAddScore() { } @Test - public void testUnusualMode() { + void testUnusualMode() { Fixture f = new Fixture(); Leg leg = (Leg) f.plan.getPlanElements().get(1); leg.setMode("sackhuepfen"); diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelWithSubpopulationsTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelWithSubpopulationsTest.java index 80043ee95e8..0ea4ba8bcd4 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelWithSubpopulationsTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelWithSubpopulationsTest.java @@ -19,7 +19,7 @@ package org.matsim.core.scoring.functions; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Activity; @@ -41,7 +41,7 @@ */ public class CharyparNagelWithSubpopulationsTest { @Test - public void testLegsScoredDifferently() { + void testLegsScoredDifferently() { final Scenario sc = createTestScenario(); final CharyparNagelScoringFunctionFactory functionFactory = new CharyparNagelScoringFunctionFactory( sc ); @@ -77,7 +77,7 @@ public void testLegsScoredDifferently() { } @Test - public void testActivitiesScoredDifferently() { + void testActivitiesScoredDifferently() { final Scenario sc = createTestScenario(); final CharyparNagelScoringFunctionFactory functionFactory = new CharyparNagelScoringFunctionFactory( sc ); diff --git a/matsim/src/test/java/org/matsim/core/trafficmonitoring/LinkToLinkTravelTimeCalculatorTest.java b/matsim/src/test/java/org/matsim/core/trafficmonitoring/LinkToLinkTravelTimeCalculatorTest.java index 179a9254981..8fa5e790ab5 100644 --- a/matsim/src/test/java/org/matsim/core/trafficmonitoring/LinkToLinkTravelTimeCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/trafficmonitoring/LinkToLinkTravelTimeCalculatorTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.LinkEnterEvent; @@ -47,7 +47,8 @@ public class LinkToLinkTravelTimeCalculatorTest { /** * @author mrieser */ - @Test public void testLongTravelTimeInEmptySlot() { + @Test + void testLongTravelTimeInEmptySlot() { MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(utils.loadConfig((String)null)); scenario.getConfig().travelTimeCalculator().setCalculateLinkToLinkTravelTimes(true); Network network = (Network) scenario.getNetwork(); diff --git a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModuleTest.java b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModuleTest.java index 00654aa914e..5c20985f8cb 100644 --- a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModuleTest.java @@ -23,9 +23,9 @@ import com.google.inject.Key; import com.google.inject.Singleton; -import com.google.inject.name.Names; +import com.google.inject.name.Names; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -50,15 +50,15 @@ import java.util.LinkedHashSet; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -public class TravelTimeCalculatorModuleTest { +import static org.junit.Assert.assertThat; + + public class TravelTimeCalculatorModuleTest { @RegisterExtension - private MatsimTestUtils utils = new MatsimTestUtils(); - - @Test - public void testOneTravelTimeCalculatorForAll() { + private MatsimTestUtils utils = new MatsimTestUtils(); + + @Test + void testOneTravelTimeCalculatorForAll() { Config config = ConfigUtils.createConfig(); config.travelTimeCalculator().setSeparateModes(false); Scenario scenario = ScenarioUtils.createScenario(config); @@ -90,11 +90,11 @@ public void install() { events.processEvent(new VehicleLeavesTrafficEvent(8.0, Id.createPersonId(1), linkId, Id.createVehicleId(1), "bike", 0.0)); assertThat(testee.getLinkTravelTimes().getLinkTravelTime(link, 0.0,null,null), is(5.0)); - } - - - @Test - public void testOneTravelTimeCalculatorPerMode() { + } + + + @Test + void testOneTravelTimeCalculatorPerMode() { Config config = ConfigUtils.createConfig(); // config.travelTimeCalculator().setAnalyzedModesAsString("car,bike" ); diff --git a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorTest.java b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorTest.java index 45c0595a509..552d6399169 100644 --- a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorTest.java @@ -33,8 +33,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -76,7 +76,8 @@ public class TravelTimeCalculatorTest { private final static Logger log = LogManager.getLogger(TravelTimeCalculatorTest.class); - @Test public final void testTravelTimeCalculator_Array_Optimistic() throws IOException { + @Test + final void testTravelTimeCalculator_Array_Optimistic() throws IOException { int endTime = 30*3600; int binSize = 15*60; @@ -91,7 +92,8 @@ public class TravelTimeCalculatorTest { travelTimeAggregator, binSize, endTime, compareFile, false, utils.getClassInputDirectory(), travelTimeGetter ); } - @Test public final void testTravelTimeCalculator_Array_Optimistic_LinearInterpolation() throws IOException { + @Test + final void testTravelTimeCalculator_Array_Optimistic_LinearInterpolation() throws IOException { int endTime = 30*3600; int binSize = 15*60; @@ -189,7 +191,8 @@ private static void doTravelTimeCalculatorTest( final MutableScenario scenario, * * @author mrieser, tthunig */ - @Test public void testLongTravelTimeInEmptySlot() { + @Test + void testLongTravelTimeInEmptySlot() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network = scenario.getNetwork(); network.setCapacityPeriod(3600.0); @@ -226,7 +229,8 @@ private static void doTravelTimeCalculatorTest( final MutableScenario scenario, * * @author tthunig */ - @Test public void testLongTravelTimeInEmptySlotWithDoubleTimeBins() { + @Test + void testLongTravelTimeInEmptySlotWithDoubleTimeBins() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network = scenario.getNetwork(); network.setCapacityPeriod(3600.0); @@ -280,7 +284,8 @@ private static void doTravelTimeCalculatorTest( final MutableScenario scenario, * * @author tthunig */ - @Test public void testInterpolatedTravelTimes() { + @Test + void testInterpolatedTravelTimes() { Config config = ConfigUtils.createConfig(); config.travelTimeCalculator().setTravelTimeGetterType("linearinterpolation"); int timeBinSize = 15*60; @@ -327,7 +332,8 @@ private static void doTravelTimeCalculatorTest( final MutableScenario scenario, * @throws ParserConfigurationException * @throws SAXException */ - @Test public void testReadFromFile_LargeScenarioCase() throws SAXException, ParserConfigurationException, IOException { + @Test + void testReadFromFile_LargeScenarioCase() throws SAXException, ParserConfigurationException, IOException { /* Assume, you have a big events file from a huge scenario and you want to do data-mining... * Then you likely want to calculate link travel times. This requires the network, but NOT * the population. Thus, using "new Events(new EventsBuilderImpl(scenario))" is not appropriate @@ -360,7 +366,8 @@ private static void doTravelTimeCalculatorTest( final MutableScenario scenario, /** * @author mrieser / senozon */ - @Test public void testGetLinkTravelTime_ignorePtVehiclesAtStop() { + @Test + void testGetLinkTravelTime_ignorePtVehiclesAtStop() { Network network = NetworkUtils.createNetwork(); TravelTimeCalculatorConfigGroup config = new TravelTimeCalculatorConfigGroup(); config.setTraveltimeBinSize(900); @@ -388,7 +395,8 @@ private static void doTravelTimeCalculatorTest( final MutableScenario scenario, /** * @author mrieser / senozon */ - @Test public void testGetLinkTravelTime_usePtVehiclesWithoutStop() { + @Test + void testGetLinkTravelTime_usePtVehiclesWithoutStop() { Network network = NetworkUtils.createNetwork(); TravelTimeCalculatorConfigGroup config = new TravelTimeCalculatorConfigGroup(); config.setTraveltimeBinSize(900); @@ -418,7 +426,8 @@ private static void doTravelTimeCalculatorTest( final MutableScenario scenario, * Expect that all link travel times are ignored. * @author cdobler */ - @Test public void testGetLinkTravelTime_NoAnalyzedModes() { + @Test + void testGetLinkTravelTime_NoAnalyzedModes() { Network network = NetworkUtils.createNetwork(); TravelTimeCalculatorConfigGroup config = new TravelTimeCalculatorConfigGroup(); config.setTraveltimeBinSize(900); @@ -454,7 +463,8 @@ private static void doTravelTimeCalculatorTest( final MutableScenario scenario, * Expect that walk legs are ignored. * @author cdobler */ - @Test public void testGetLinkTravelTime_CarAnalyzedModes() { + @Test + void testGetLinkTravelTime_CarAnalyzedModes() { Network network = NetworkUtils.createNetwork(); TravelTimeCalculatorConfigGroup config = new TravelTimeCalculatorConfigGroup(); config.setTraveltimeBinSize(900); @@ -495,7 +505,8 @@ private static void doTravelTimeCalculatorTest( final MutableScenario scenario, * Expect that still all modes are counted. * @author cdobler */ - @Test public void testGetLinkTravelTime_NoFilterModes() { + @Test + void testGetLinkTravelTime_NoFilterModes() { Network network = NetworkUtils.createNetwork(); TravelTimeCalculatorConfigGroup config = new TravelTimeCalculatorConfigGroup(); config.setTraveltimeBinSize(900); @@ -536,7 +547,8 @@ private static void doTravelTimeCalculatorTest( final MutableScenario scenario, * Expect that the default value (=car) will be used for the modes to be counted. * @author cdobler */ - @Test public void testGetLinkTravelTime_FilterDefaultModes() { + @Test + void testGetLinkTravelTime_FilterDefaultModes() { Network network = NetworkUtils.createNetwork(); TravelTimeCalculatorConfigGroup config = new TravelTimeCalculatorConfigGroup(); config.setTraveltimeBinSize(900); diff --git a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeDataArrayTest.java b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeDataArrayTest.java index e56a8cb3a51..c002d90c52c 100644 --- a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeDataArrayTest.java +++ b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeDataArrayTest.java @@ -2,8 +2,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -16,7 +16,7 @@ public class TravelTimeDataArrayTest{ @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void test() { + void test() { Network network = NetworkUtils.createNetwork(); Node from = NetworkUtils.createNode(Id.createNodeId("1")); Node to = NetworkUtils.createNode( Id.createNodeId( "2" ) ); diff --git a/matsim/src/test/java/org/matsim/core/utils/charts/BarChartTest.java b/matsim/src/test/java/org/matsim/core/utils/charts/BarChartTest.java index b13c9fd28a8..4d9f848e412 100644 --- a/matsim/src/test/java/org/matsim/core/utils/charts/BarChartTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/charts/BarChartTest.java @@ -29,8 +29,8 @@ import javax.imageio.ImageIO; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -48,7 +48,8 @@ public class BarChartTest { * Test that a file was really generated, and that the image, when loaded, has the specified size. * @throws IOException possible exception when reading the image for validation */ - @Test public void testBarChartDemo() throws IOException { + @Test + void testBarChartDemo() throws IOException { System.setProperty("java.awt.headless", "true"); String imageFilename = utils.getOutputDirectory() + "barchart.png"; diff --git a/matsim/src/test/java/org/matsim/core/utils/charts/LineChartTest.java b/matsim/src/test/java/org/matsim/core/utils/charts/LineChartTest.java index 4c70f43a26d..d51e8a862ad 100644 --- a/matsim/src/test/java/org/matsim/core/utils/charts/LineChartTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/charts/LineChartTest.java @@ -29,8 +29,8 @@ import javax.imageio.ImageIO; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -48,7 +48,8 @@ public class LineChartTest { * Test that a file was really generated, and that the image, when loaded, has the specified size. * @throws IOException possible exception when reading the image for validation */ - @Test public void testLineChartDemo() throws IOException { + @Test + void testLineChartDemo() throws IOException { String imageFilename = utils.getOutputDirectory() + "linechart.png"; Demo demo = new Demo(); demo.createLineChart(imageFilename); diff --git a/matsim/src/test/java/org/matsim/core/utils/charts/XYLineChartTest.java b/matsim/src/test/java/org/matsim/core/utils/charts/XYLineChartTest.java index 1410b27b202..2820560dec5 100644 --- a/matsim/src/test/java/org/matsim/core/utils/charts/XYLineChartTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/charts/XYLineChartTest.java @@ -29,8 +29,8 @@ import javax.imageio.ImageIO; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -48,7 +48,8 @@ public class XYLineChartTest { * Test that a file was really generated, and that the image, when loaded, has the specified size. * @throws IOException possible exception when reading the image for validation */ - @Test public void testXYLineChartDemo() throws IOException { + @Test + void testXYLineChartDemo() throws IOException { String imageFilename = utils.getOutputDirectory() + "xylinechart.png"; Demo demo = new Demo(); demo.createXYLineChart(imageFilename); diff --git a/matsim/src/test/java/org/matsim/core/utils/charts/XYScatterChartTest.java b/matsim/src/test/java/org/matsim/core/utils/charts/XYScatterChartTest.java index 03c60398659..146203c96d9 100644 --- a/matsim/src/test/java/org/matsim/core/utils/charts/XYScatterChartTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/charts/XYScatterChartTest.java @@ -29,8 +29,8 @@ import javax.imageio.ImageIO; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -48,7 +48,8 @@ public class XYScatterChartTest { * Test that a file was really generated, and that the image, when loaded, has the specified size. * @throws IOException possible exception when reading the image for validation */ - @Test public void testXYScatterChartDemo() throws IOException { + @Test + void testXYScatterChartDemo() throws IOException { String imageFilename = utils.getOutputDirectory() + "xyscatterchart.png"; Demo demo = new Demo(); demo.createXYScatterChart(imageFilename); diff --git a/matsim/src/test/java/org/matsim/core/utils/collections/ArrayMapTest.java b/matsim/src/test/java/org/matsim/core/utils/collections/ArrayMapTest.java index 6c82f754508..c50c2131c3e 100644 --- a/matsim/src/test/java/org/matsim/core/utils/collections/ArrayMapTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/collections/ArrayMapTest.java @@ -1,7 +1,7 @@ package org.matsim.core.utils.collections; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Collection; @@ -19,7 +19,7 @@ public class ArrayMapTest { @Test - public void testPutGetRemoveSize() { + void testPutGetRemoveSize() { ArrayMap map = new ArrayMap<>(); Assert.assertEquals(0, map.size()); @@ -55,7 +55,7 @@ public void testPutGetRemoveSize() { } @Test - public void testValuesIterable() { + void testValuesIterable() { ArrayMap map = new ArrayMap<>(); map.put("1", "one"); @@ -82,7 +82,7 @@ public void testValuesIterable() { } @Test - public void testForEach() { + void testForEach() { ArrayMap map = new ArrayMap<>(); map.put("1", "one"); @@ -108,7 +108,7 @@ public void testForEach() { } @Test - public void testContainsKey() { + void testContainsKey() { ArrayMap map = new ArrayMap<>(); map.put("1", "one"); @@ -132,7 +132,7 @@ public void testContainsKey() { } @Test - public void testContainsValue() { + void testContainsValue() { ArrayMap map = new ArrayMap<>(); map.put("1", "one"); @@ -149,7 +149,7 @@ public void testContainsValue() { } @Test - public void testPutAll_ArrayMap() { + void testPutAll_ArrayMap() { ArrayMap map = new ArrayMap<>(); ArrayMap map2 = new ArrayMap<>(); @@ -170,7 +170,7 @@ public void testPutAll_ArrayMap() { } @Test - public void testPutAll_GenericMap() { + void testPutAll_GenericMap() { ArrayMap map = new ArrayMap<>(); Map map2 = new HashMap<>(); @@ -191,7 +191,7 @@ public void testPutAll_GenericMap() { } @Test - public void testClear() { + void testClear() { ArrayMap map = new ArrayMap<>(); map.put("1", "one"); @@ -213,7 +213,7 @@ public void testClear() { } @Test - public void testValues() { + void testValues() { ArrayMap map = new ArrayMap<>(); map.put("1", "one"); @@ -247,7 +247,7 @@ public void testValues() { } @Test - public void testKeySet() { + void testKeySet() { String key1 = "1"; String key2 = "2"; String key3 = "3"; @@ -288,7 +288,7 @@ public void testKeySet() { } @Test - public void testEntrySet() { + void testEntrySet() { String key1 = "1"; String key2 = "2"; String key4 = "4"; @@ -342,7 +342,7 @@ public void testEntrySet() { } @Test - public void testValuesIterator_iterate() { + void testValuesIterator_iterate() { String key1 = "1"; String key2 = "2"; String key4 = "4"; @@ -381,7 +381,7 @@ public void testValuesIterator_iterate() { } @Test - public void testValuesIterator_remove() { + void testValuesIterator_remove() { String key1 = "1"; String key2 = "2"; String key4 = "4"; @@ -416,7 +416,7 @@ public void testValuesIterator_remove() { } @Test - public void testKeySetIterator_iterate() { + void testKeySetIterator_iterate() { String key1 = "1"; String key2 = "2"; String key4 = "4"; @@ -455,7 +455,7 @@ public void testKeySetIterator_iterate() { } @Test - public void testKeySetIterator_remove() { + void testKeySetIterator_remove() { String key1 = "1"; String key2 = "2"; String key4 = "4"; @@ -490,7 +490,7 @@ public void testKeySetIterator_remove() { } @Test - public void testKeySetToArray() { + void testKeySetToArray() { String key1 = "1"; String key2 = "2"; String key4 = "4"; @@ -512,7 +512,7 @@ public void testKeySetToArray() { } @Test - public void testCopyConstructor() { + void testCopyConstructor() { Map map0 = new HashMap<>(); map0.put("1", "one"); map0.put("2", "two"); diff --git a/matsim/src/test/java/org/matsim/core/utils/collections/CollectionUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/collections/CollectionUtilsTest.java index bf8adaa1fa4..40ad88c902d 100644 --- a/matsim/src/test/java/org/matsim/core/utils/collections/CollectionUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/collections/CollectionUtilsTest.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -38,7 +38,7 @@ public class CollectionUtilsTest { private final static Logger log = LogManager.getLogger(CollectionUtilsTest.class); @Test - public void testSetToString() { + void testSetToString() { Set set = new LinkedHashSet(); set.add("Aaa"); set.add("Bbb"); @@ -48,13 +48,13 @@ public void testSetToString() { } @Test - public void testArrayToString() { + void testArrayToString() { String[] array = new String[] {"Aaa", "Bbb", "Ddd", "Ccc"}; Assert.assertEquals("Aaa,Bbb,Ddd,Ccc", CollectionUtils.arrayToString(array)); } @Test - public void testStringToSet() { + void testStringToSet() { String[] testStrings = new String[] { "Aaa,Bbb,Ddd,Ccc", ",Aaa,Bbb,Ddd,Ccc", @@ -79,13 +79,13 @@ public void testStringToSet() { } @Test - public void testNullStringToSet() { + void testNullStringToSet() { Set set = CollectionUtils.stringToSet(null); Assert.assertEquals(0, set.size()); } @Test - public void testStringToArray() { + void testStringToArray() { String[] testStrings = new String[] { "Aaa,Bbb,Ddd,Ccc", ",Aaa,Bbb,Ddd,Ccc", @@ -108,13 +108,13 @@ public void testStringToArray() { } @Test - public void testNullStringToArray() { + void testNullStringToArray() { String[] array = CollectionUtils.stringToArray(null); Assert.assertEquals(0, array.length); } @Test - public void testIdSetToString() { + void testIdSetToString() { Set> set = new LinkedHashSet>(); set.add(Id.create("Aaa", Link.class)); set.add(Id.create("Bbb", Link.class)); diff --git a/matsim/src/test/java/org/matsim/core/utils/collections/IdentifiableArrayMapTest.java b/matsim/src/test/java/org/matsim/core/utils/collections/IdentifiableArrayMapTest.java index 642582ca629..d7ab9d6f2a6 100644 --- a/matsim/src/test/java/org/matsim/core/utils/collections/IdentifiableArrayMapTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/collections/IdentifiableArrayMapTest.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Identifiable; @@ -38,16 +38,16 @@ public class IdentifiableArrayMapTest { private final static Logger log = LogManager.getLogger(IdentifiableArrayMapTest.class); - + @Test - public void testConstructor() { + void testConstructor() { Map, TO> map = new IdentifiableArrayMap<>(); Assert.assertEquals(0, map.size()); Assert.assertTrue(map.isEmpty()); } - + @Test - public void testPutGet() { + void testPutGet() { Map, TO> map = new IdentifiableArrayMap<>(); Id id1 = Id.create(1, TO.class); Id id2 = Id.create(2, TO.class); @@ -72,9 +72,9 @@ public void testPutGet() { Assert.assertEquals(to2, map.get(id2)); Assert.assertEquals(to1, map.get(id1)); } - + @Test - public void testPutGet_identifiablePut() { + void testPutGet_identifiablePut() { IdentifiableArrayMap map = new IdentifiableArrayMap<>(); Id id1 = Id.create(1, TO.class); Id id2 = Id.create(2, TO.class); @@ -98,9 +98,9 @@ public void testPutGet_identifiablePut() { Assert.assertEquals(to2, map.get(id2)); Assert.assertEquals(to1, map.get(id1)); } - + @Test - public void testPut_multiple() { + void testPut_multiple() { Map, TO> map = new IdentifiableArrayMap<>(); Id id1 = Id.create(1, TO.class); Id id2 = Id.create(2, TO.class); @@ -131,9 +131,9 @@ public void testPut_multiple() { map.put(id1, to1); Assert.assertEquals(3, map.size()); } - + @Test - public void testGet_equalKeys() { + void testGet_equalKeys() { Map, TO> map = new IdentifiableArrayMap<>(); Id id2a = Id.create(2, TO.class); Id id2b = Id.create(2, TO.class); @@ -147,7 +147,7 @@ public void testGet_equalKeys() { } @Test - public void testPut_Overwrite() { + void testPut_Overwrite() { Map, TO> map = new IdentifiableArrayMap<>(); Id id1 = Id.create(1, TO.class); Id id2a = Id.create(2, TO.class); @@ -173,9 +173,9 @@ public void testPut_Overwrite() { Assert.assertEquals(to2b, map.get(id2b)); Assert.assertEquals(to2b, map.get(id2a)); } - + @Test - public void testContainsKey() { + void testContainsKey() { Map, TO> map = new IdentifiableArrayMap<>(); Id id1 = Id.create(1, TO.class); Id id2 = Id.create(2, TO.class); @@ -209,9 +209,9 @@ public void testContainsKey() { Assert.assertTrue(map.containsKey(id2b)); Assert.assertTrue(map.containsKey(id3)); } - + @Test - public void testContainsValue() { + void testContainsValue() { Map, TO> map = new IdentifiableArrayMap<>(); Id id1 = Id.create(1, TO.class); Id id2 = Id.create(2, TO.class); @@ -240,9 +240,9 @@ public void testContainsValue() { Assert.assertTrue(map.containsValue(to2)); Assert.assertTrue(map.containsValue(to3)); } - + @Test - public void testRemove_middle() { + void testRemove_middle() { Map, TO> map = new IdentifiableArrayMap<>(); Id id1 = Id.create(1, TO.class); Id id2 = Id.create(2, TO.class); @@ -263,9 +263,9 @@ public void testRemove_middle() { Assert.assertFalse(map.containsValue(to2)); Assert.assertTrue(map.containsValue(to3)); } - + @Test - public void testRemove_start() { + void testRemove_start() { Map, TO> map = new IdentifiableArrayMap<>(); Id id1 = Id.create(1, TO.class); Id id2 = Id.create(2, TO.class); @@ -286,9 +286,9 @@ public void testRemove_start() { Assert.assertTrue(map.containsValue(to2)); Assert.assertTrue(map.containsValue(to3)); } - + @Test - public void testRemove_end() { + void testRemove_end() { Map, TO> map = new IdentifiableArrayMap<>(); Id id1 = Id.create(1, TO.class); Id id2 = Id.create(2, TO.class); @@ -309,9 +309,9 @@ public void testRemove_end() { Assert.assertTrue(map.containsValue(to2)); Assert.assertFalse(map.containsValue(to3)); } - + @Test - public void testClear() { + void testClear() { Map, TO> map = new IdentifiableArrayMap<>(); Id id1 = Id.create(1, TO.class); Id id2 = Id.create(2, TO.class); @@ -334,9 +334,9 @@ public void testClear() { Assert.assertFalse(map.containsValue(to2)); Assert.assertNull(map.get(id2)); } - + @Test - public void testValues() { + void testValues() { Map, TO> map = new IdentifiableArrayMap<>(); Id id1 = Id.create(1, TO.class); Id id2 = Id.create(2, TO.class); @@ -357,9 +357,9 @@ public void testValues() { Assert.assertTrue(values.contains(to2)); Assert.assertTrue(values.contains(to3)); } - + @Test - public void testKeySet() { + void testKeySet() { Map, TO> map = new IdentifiableArrayMap<>(); Id id1 = Id.create(1, TO.class); Id id2 = Id.create(2, TO.class); @@ -380,9 +380,9 @@ public void testKeySet() { Assert.assertTrue(keys.contains(id2)); Assert.assertTrue(keys.contains(id3)); } - + @Test - public void testEntrySet() { + void testEntrySet() { Map, TO> map = new IdentifiableArrayMap<>(); Id id1 = Id.create(1, TO.class); Id id2 = Id.create(2, TO.class); @@ -400,9 +400,9 @@ public void testEntrySet() { Assert.assertEquals(3, entries.size()); } - + @Test - public void testValuesIterator() { + void testValuesIterator() { Map, TO> map = new IdentifiableArrayMap<>(); Id id1 = Id.create(1, TO.class); Id id2 = Id.create(2, TO.class); @@ -435,7 +435,7 @@ public void testValuesIterator() { } @Test - public void testValuesToArray() { + void testValuesToArray() { Map, TO> map = new IdentifiableArrayMap<>(); Id id1 = Id.create(1, TO.class); Id id2 = Id.create(2, TO.class); @@ -469,7 +469,7 @@ public void testValuesToArray() { } @Test - public void testValuesIterator_SingleDiretor() { + void testValuesIterator_SingleDiretor() { Map, TO> map = new IdentifiableArrayMap<>(); Id id1 = Id.create(1, TO.class); diff --git a/matsim/src/test/java/org/matsim/core/utils/collections/IntArrayMapTest.java b/matsim/src/test/java/org/matsim/core/utils/collections/IntArrayMapTest.java index 6e2257639b5..a23afe67ad0 100644 --- a/matsim/src/test/java/org/matsim/core/utils/collections/IntArrayMapTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/collections/IntArrayMapTest.java @@ -1,7 +1,7 @@ package org.matsim.core.utils.collections; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Collection; @@ -19,7 +19,7 @@ public class IntArrayMapTest { @Test - public void testPutGetRemoveSize() { + void testPutGetRemoveSize() { IntArrayMap map = new IntArrayMap<>(); Assert.assertEquals(0, map.size()); @@ -55,7 +55,7 @@ public void testPutGetRemoveSize() { } @Test - public void testValuesIterable() { + void testValuesIterable() { IntArrayMap map = new IntArrayMap<>(); map.put(1, "one"); @@ -82,7 +82,7 @@ public void testValuesIterable() { } @Test - public void testForEach() { + void testForEach() { IntArrayMap map = new IntArrayMap<>(); map.put(1, "one"); @@ -108,7 +108,7 @@ public void testForEach() { } @Test - public void testContainsKey() { + void testContainsKey() { IntArrayMap map = new IntArrayMap<>(); map.put(1, "one"); @@ -132,7 +132,7 @@ public void testContainsKey() { } @Test - public void testContainsValue() { + void testContainsValue() { IntArrayMap map = new IntArrayMap<>(); map.put(1, "one"); @@ -149,7 +149,7 @@ public void testContainsValue() { } @Test - public void testPutAll_ArrayMap() { + void testPutAll_ArrayMap() { IntArrayMap map = new IntArrayMap<>(); IntArrayMap map2 = new IntArrayMap<>(); @@ -170,7 +170,7 @@ public void testPutAll_ArrayMap() { } @Test - public void testPutAll_GenericMap() { + void testPutAll_GenericMap() { IntArrayMap map = new IntArrayMap<>(); Map map2 = new HashMap<>(); @@ -191,7 +191,7 @@ public void testPutAll_GenericMap() { } @Test - public void testClear() { + void testClear() { IntArrayMap map = new IntArrayMap<>(); map.put(1, "one"); @@ -213,7 +213,7 @@ public void testClear() { } @Test - public void testValues() { + void testValues() { IntArrayMap map = new IntArrayMap<>(); map.put(1, "one"); @@ -247,7 +247,7 @@ public void testValues() { } @Test - public void testKeySet() { + void testKeySet() { int key1 = 1; int key2 = 2; int key3 = 3; @@ -288,7 +288,7 @@ public void testKeySet() { } @Test - public void testEntrySet() { + void testEntrySet() { int key1 = 1; int key2 = 2; int key4 = 4; @@ -342,7 +342,7 @@ public void testEntrySet() { } @Test - public void testValuesIterator_iterate() { + void testValuesIterator_iterate() { int key1 = 1; int key2 = 2; int key4 = 4; @@ -381,7 +381,7 @@ public void testValuesIterator_iterate() { } @Test - public void testValuesIterator_remove() { + void testValuesIterator_remove() { int key1 = 1; int key2 = 2; int key4 = 4; @@ -417,7 +417,7 @@ public void testValuesIterator_remove() { } @Test - public void testKeySetIterator_iterate() { + void testKeySetIterator_iterate() { int key1 = 1; int key2 = 2; int key4 = 4; @@ -456,7 +456,7 @@ public void testKeySetIterator_iterate() { } @Test - public void testKeySetIterator_remove() { + void testKeySetIterator_remove() { int key1 = 1; int key2 = 2; int key4 = 4; @@ -492,7 +492,7 @@ public void testKeySetIterator_remove() { } @Test - public void testKeySetToArray() { + void testKeySetToArray() { int key1 = 1; int key2 = 2; int key4 = 4; diff --git a/matsim/src/test/java/org/matsim/core/utils/collections/PseudoRemovePriorityQueueTest.java b/matsim/src/test/java/org/matsim/core/utils/collections/PseudoRemovePriorityQueueTest.java index 6eb6d83b918..d1f726ab458 100644 --- a/matsim/src/test/java/org/matsim/core/utils/collections/PseudoRemovePriorityQueueTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/collections/PseudoRemovePriorityQueueTest.java @@ -29,7 +29,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author mrieser @@ -38,7 +38,8 @@ public class PseudoRemovePriorityQueueTest { private static final Logger log = LogManager.getLogger(PseudoRemovePriorityQueueTest.class); - @Test public void testAdd() { + @Test + void testAdd() { PseudoRemovePriorityQueue pq = new PseudoRemovePriorityQueue(10); assertEquals(0, pq.size()); pq.add(Integer.valueOf(1), 1.0); @@ -52,7 +53,8 @@ public class PseudoRemovePriorityQueueTest { assertEquals(3, iteratorElementCount(pq.iterator())); } - @Test public void testAdd_Null() { + @Test + void testAdd_Null() { PseudoRemovePriorityQueue pq = new PseudoRemovePriorityQueue(10); try { pq.add(null, 1.0); @@ -65,7 +67,8 @@ public class PseudoRemovePriorityQueueTest { assertEquals(0, iteratorElementCount(pq.iterator())); } - @Test public void testPoll() { + @Test + void testPoll() { PseudoRemovePriorityQueue pq = new PseudoRemovePriorityQueue(10); pq.add(Integer.valueOf(5), 5.0); pq.add(Integer.valueOf(3), 3.0); @@ -86,7 +89,8 @@ public class PseudoRemovePriorityQueueTest { assertNull(pq.poll()); } - @Test public void testIterator() { + @Test + void testIterator() { PseudoRemovePriorityQueue pq = new PseudoRemovePriorityQueue(10); pq.add(Integer.valueOf(5), 5.0); pq.add(Integer.valueOf(3), 3.0); @@ -99,7 +103,8 @@ public class PseudoRemovePriorityQueueTest { assertFalse(coll.contains(Integer.valueOf(4))); } - @Test public void testIterator_ConcurrentModification_add() { + @Test + void testIterator_ConcurrentModification_add() { PseudoRemovePriorityQueue pq = new PseudoRemovePriorityQueue(10); pq.add(Integer.valueOf(5), 5.0); pq.add(Integer.valueOf(3), 3.0); @@ -122,7 +127,8 @@ public class PseudoRemovePriorityQueueTest { assertNotNull(iter.next()); } - @Test public void testIterator_ConcurrentModification_poll() { + @Test + void testIterator_ConcurrentModification_poll() { PseudoRemovePriorityQueue pq = new PseudoRemovePriorityQueue(10); pq.add(Integer.valueOf(5), 5.0); pq.add(Integer.valueOf(3), 3.0); @@ -145,7 +151,8 @@ public class PseudoRemovePriorityQueueTest { assertNotNull(iter.next()); } - @Test public void testIterator_ConcurrentModification_remove() { + @Test + void testIterator_ConcurrentModification_remove() { PseudoRemovePriorityQueue pq = new PseudoRemovePriorityQueue(10); pq.add(Integer.valueOf(5), 5.0); pq.add(Integer.valueOf(3), 3.0); @@ -171,7 +178,8 @@ public class PseudoRemovePriorityQueueTest { assertNotNull(iter.next()); } - @Test public void testIterator_RemoveUnsupported() { + @Test + void testIterator_RemoveUnsupported() { PseudoRemovePriorityQueue pq = new PseudoRemovePriorityQueue(10); pq.add(Integer.valueOf(5), 5.0); pq.add(Integer.valueOf(3), 3.0); @@ -188,7 +196,8 @@ public class PseudoRemovePriorityQueueTest { } } - @Test public void testRemove() { + @Test + void testRemove() { PseudoRemovePriorityQueue pq = new PseudoRemovePriorityQueue(10); pq.add(Integer.valueOf(5), 5.0); pq.add(Integer.valueOf(3), 3.0); @@ -230,7 +239,8 @@ public class PseudoRemovePriorityQueueTest { assertNull(pq.poll()); } - @Test public void testRemoveAndAdd_LowerPriority() { + @Test + void testRemoveAndAdd_LowerPriority() { PseudoRemovePriorityQueue pq = new PseudoRemovePriorityQueue(10); pq.add(Integer.valueOf(5), 5.0); pq.add(Integer.valueOf(3), 3.0); @@ -249,7 +259,8 @@ public class PseudoRemovePriorityQueueTest { assertNull(pq.poll()); } - @Test public void testRemoveAndAdd_HigherPriority() { + @Test + void testRemoveAndAdd_HigherPriority() { PseudoRemovePriorityQueue pq = new PseudoRemovePriorityQueue(10); pq.add(Integer.valueOf(5), 5.0); pq.add(Integer.valueOf(3), 3.0); @@ -268,7 +279,8 @@ public class PseudoRemovePriorityQueueTest { assertNull(pq.poll()); } - @Test public void testDecreaseKey() { + @Test + void testDecreaseKey() { // PseudoRemovePriorityQueue pq = new PseudoRemovePriorityQueue(10); // pq.add(Integer.valueOf(5), 5.0); // pq.add(Integer.valueOf(3), 3.0); diff --git a/matsim/src/test/java/org/matsim/core/utils/collections/QuadTreeTest.java b/matsim/src/test/java/org/matsim/core/utils/collections/QuadTreeTest.java index c479979a069..56a7867b1f9 100644 --- a/matsim/src/test/java/org/matsim/core/utils/collections/QuadTreeTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/collections/QuadTreeTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.collections.QuadTree.Rect; import org.matsim.core.utils.geometry.CoordUtils; @@ -75,7 +75,7 @@ private QuadTree getTestTree() { * Test {@link QuadTree#QuadTree(double, double, double, double)}. */ @Test - public void testConstructor() { + void testConstructor() { QuadTree qt = new QuadTree<>(-50.0, -40.0, +30.0, +20.0); assertEquals(-50.0, qt.getMinEasting(), 0.0); assertEquals(-40.0, qt.getMinNorthing(), 0.0); @@ -87,7 +87,7 @@ public void testConstructor() { * Test putting values into a QuadTree using {@link QuadTree#put(double, double, Object)}. */ @Test - public void testPut() { + void testPut() { QuadTree qt = new QuadTree<>(-50.0, -50.0, +150.0, +150.0); assertEquals(0, qt.size()); qt.put(10.0, 10.0, "10.0, 10.0"); @@ -107,7 +107,7 @@ public void testPut() { } @Test - public void testPutOutsideBounds() { + void testPutOutsideBounds() { QuadTree qt = new QuadTree<>(-50.0, -50.0, 50.0, 50.0); try { qt.put( -100 , 0 , "-100 0" ); @@ -147,7 +147,7 @@ public void testPutOutsideBounds() { * and {@link QuadTree#getDisk(double, double, double)}. */ @Test - public void testGet() { + void testGet() { QuadTree qt = getTestTree(); // test single get @@ -218,7 +218,7 @@ public void testGet() { } @Test - public void testGetXY_EntryOnDividingBorder() { + void testGetXY_EntryOnDividingBorder() { QuadTree qt = new QuadTree<>(0, 0, 40, 60); qt.put(10.0, 10.0, "10.0, 10.0"); qt.put(20.0, 20.0, "20.0, 20.0"); // on vertical border @@ -231,7 +231,7 @@ public void testGetXY_EntryOnDividingBorder() { } @Test - public void testGetXY_EntryOnOutsideBorder() { + void testGetXY_EntryOnOutsideBorder() { QuadTree qt = new QuadTree<>(0.0, 0.0, 40.0, 60.0); // the 4 corners qt.put(0.0, 0.0, "SW"); @@ -255,7 +255,7 @@ public void testGetXY_EntryOnOutsideBorder() { } @Test - public void testGetDistance_fromOutsideExtent() { + void testGetDistance_fromOutsideExtent() { QuadTree qt = getTestTree(); assertContains(new String[] {"100.0, 0.0"}, qt.getDisk(160.0, 0, 60.1)); // E assertContains(new String[] {"15.0, 15.0", "15.0, 15.0 B"}, qt.getDisk(15.0, 160, 145.1)); // N @@ -264,7 +264,7 @@ public void testGetDistance_fromOutsideExtent() { } @Test - public void testGetDistance_EntryOnDividingBorder() { + void testGetDistance_EntryOnDividingBorder() { QuadTree qt = new QuadTree<>(0, 0, 40, 60); qt.put(10.0, 10.0, "10.0, 10.0"); qt.put(20.0, 20.0, "20.0, 20.0"); // on vertical border @@ -286,7 +286,7 @@ public void testGetDistance_EntryOnDividingBorder() { } @Test - public void testGetDistance_EntryOnOutsideBorder() { + void testGetDistance_EntryOnOutsideBorder() { QuadTree qt = new QuadTree<>(0.0, 0.0, 40.0, 60.0); // the 4 corners qt.put(0.0, 0.0, "SW"); @@ -311,7 +311,7 @@ public void testGetDistance_EntryOnOutsideBorder() { } @Test - public void testGetElliptical() { + void testGetElliptical() { final Collection all = new ArrayList<>(); QuadTree qt = new QuadTree<>(0, 0, 40, 60); @@ -379,7 +379,7 @@ public void testGetElliptical() { } @Test - public void testGetRect() { + void testGetRect() { QuadTree qt = new QuadTree<>(0, 0, 1000, 1000); qt.put(100, 200, "node1"); qt.put(400, 900, "node2"); @@ -394,7 +394,7 @@ public void testGetRect() { } @Test - public void testGetRect_flatNetwork() { + void testGetRect_flatNetwork() { QuadTree qt = new QuadTree<>(0, 0, 1000, 0); qt.put(0, 0, "node1"); qt.put(100, 0, "node2"); @@ -418,7 +418,7 @@ public void testGetRect_flatNetwork() { * Test removing values from a QuadTree using {@link QuadTree#remove(double, double, Object)}. */ @Test - public void testRemove() { + void testRemove() { QuadTree qt = getTestTree(); int size = qt.size(); // test real removal @@ -452,7 +452,7 @@ public void testRemove() { * Test {@link QuadTree#clear()}. */ @Test - public void testClear() { + void testClear() { QuadTree qt = getTestTree(); int size = qt.size(); assertTrue(size > 0); // it makes no sense to test clear() on an empty tree @@ -465,7 +465,7 @@ public void testClear() { * Test {@link QuadTree#values()} that it returns the correct content. */ @Test - public void testValues() { + void testValues() { QuadTree qt = getTestTree(); int size = qt.size(); assertEquals(6, size); @@ -503,7 +503,7 @@ public void testValues() { * as well. */ @Test - public void testValues_isView() { + void testValues_isView() { QuadTree qt = getTestTree(); int size = qt.size(); Collection values = qt.values(); @@ -523,7 +523,7 @@ public void testValues_isView() { } @Test - public void testValuesIterator_ConcurrentModification() { + void testValuesIterator_ConcurrentModification() { QuadTree qt = getTestTree(); Iterator iter = qt.values().iterator(); assertTrue(iter.hasNext()); @@ -543,7 +543,7 @@ public void testValuesIterator_ConcurrentModification() { * Test {@link QuadTree#execute(double, double, double, double, QuadTree.Executor)}. */ @Test - public void testExecute() { + void testExecute() { QuadTree qt = getTestTree(); TestExecutor executor = new TestExecutor(); int count = qt.execute(0.0, 0.0, 20.1, 20.1, executor); @@ -573,7 +573,7 @@ public void testExecute() { * @throws ClassNotFoundException */ @Test - public void testSerialization() throws IOException, ClassNotFoundException { + void testSerialization() throws IOException, ClassNotFoundException { QuadTree qt = getTestTree(); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); @@ -637,7 +637,7 @@ public void execute(final double x, final double y, final String object) { * Test read access on {@link QuadTree#getRing(double, double, double, double)}. */ @Test - public void testGetRing() { + void testGetRing() { QuadTree qt = new QuadTree(0, 0, 3, 3); for(int x = 0; x < 4; x++) { @@ -686,7 +686,7 @@ public void testGetRing() { * tests that also for a large number of entries, values() returns the correct result. */ @Test - public void testGetValues() { + void testGetValues() { double minX = -1000; double minY = -5000; double maxX = 20000; diff --git a/matsim/src/test/java/org/matsim/core/utils/collections/TupleTest.java b/matsim/src/test/java/org/matsim/core/utils/collections/TupleTest.java index ca81f47c19c..bb7a2d62046 100644 --- a/matsim/src/test/java/org/matsim/core/utils/collections/TupleTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/collections/TupleTest.java @@ -22,17 +22,19 @@ import static org.junit.Assert.*; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TupleTest { - @Test public void testOf() { + @Test + void testOf() { Tuple t1 = new Tuple<>(1, 1.1); Tuple t2 = Tuple.of(1, 1.1); assertEquals(t1, t2); } - @Test public void testEquals() { + @Test + void testEquals() { // the basic Tuple we will usually compare against Tuple t1 = new Tuple(1, 1.1); @@ -69,7 +71,8 @@ public class TupleTest { assertFalse(t1.equals(Integer.valueOf(1))); } - @Test public void testEquals_withNull() { + @Test + void testEquals_withNull() { Integer i1 = Integer.valueOf(1); Integer i2 = Integer.valueOf(2); Tuple tuple1a = new Tuple(i1, null); @@ -100,7 +103,8 @@ public class TupleTest { assertFalse(tuple3a.equals(tuple4)); } - @Test public void testHashCode_withNull() { + @Test + void testHashCode_withNull() { Integer i1 = Integer.valueOf(1); Integer i2 = Integer.valueOf(2); Tuple tuple = new Tuple(i1, i2); diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/CoordImplTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/CoordImplTest.java index da30eb32e76..ee6b99929f1 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/CoordImplTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/CoordImplTest.java @@ -22,7 +22,7 @@ import java.util.Arrays; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; /** @@ -36,7 +36,7 @@ public class CoordImplTest { * the new hashCode implementation does not have this problem. */ @Test - public void testHashCode() { + void testHashCode() { int[] hashCodes = new int[] { new Coord(1.0, 1.0).hashCode(), new Coord(2.0, 2.0).hashCode(), diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/CoordUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/CoordUtilsTest.java index c2729e3e132..01bb58b1090 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/CoordUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/CoordUtilsTest.java @@ -24,14 +24,14 @@ import org.junit.Assert; import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.testcases.MatsimTestUtils; public class CoordUtilsTest { @Test - public void testCreateCoord2D() { + void testCreateCoord2D() { Coord c1 = new Coord(0.0, 1.0); Coord c2 = CoordUtils.createCoord(0.0, 1.0); Coord c3 = CoordUtils.createCoord(0.0, 2.0); @@ -40,7 +40,7 @@ public void testCreateCoord2D() { } @Test - public void testCreateCoord3D() { + void testCreateCoord3D() { Coord c1 = new Coord(0.0, 1.0, 2.0); Coord c2 = CoordUtils.createCoord(0.0, 1.0, 2.0); Coord c3 = CoordUtils.createCoord(0.0, 2.0, 2.0); @@ -49,7 +49,7 @@ public void testCreateCoord3D() { } @Test - public void testPlus() { + void testPlus() { Coord c2a = CoordUtils.createCoord(1.0, 1.0); Coord c2b = CoordUtils.createCoord(2.0, 2.0); Coord c2c = CoordUtils.createCoord(3.0, 3.0); @@ -80,7 +80,7 @@ public void testPlus() { } @Test - public void testMinus() { + void testMinus() { Coord c2a = CoordUtils.createCoord(1.0, 1.0); Coord c2b = CoordUtils.createCoord(2.0, 2.0); Coord c2c = CoordUtils.createCoord(3.0, 3.0); @@ -111,7 +111,7 @@ public void testMinus() { } @Test - public void testScalarMult() { + void testScalarMult() { // 2D Coord c2a = CoordUtils.createCoord(1.0, 1.0); Coord c2b = CoordUtils.createCoord(2.0, 2.0); @@ -124,7 +124,7 @@ public void testScalarMult() { } @Test - public void testGetCenter() { + void testGetCenter() { // 2D Coord c2a = CoordUtils.createCoord(0.0, 0.0); Coord c2b = CoordUtils.createCoord(2.0, 2.0); @@ -139,7 +139,7 @@ public void testGetCenter() { } @Test - public void testLength() { + void testLength() { // 2D Coord c2 = CoordUtils.createCoord(2.0, 2.0); assertEquals(Math.sqrt(8.0), CoordUtils.length(c2), MatsimTestUtils.EPSILON); @@ -149,7 +149,7 @@ public void testLength() { } @Test - public void testRotateToRight() { + void testRotateToRight() { Coord coord1 = new Coord(3., 2.); Coord result = CoordUtils.rotateToRight( coord1 ) ; @@ -171,12 +171,12 @@ public void testRotateToRight() { @Test @Ignore - public void testGetCenterWOffset() { + void testGetCenterWOffset() { fail("Not yet implemented"); } @Test - public void testCalcEuclideanDistance() { + void testCalcEuclideanDistance() { // 2D Coord c2a = CoordUtils.createCoord(0.0, 0.0); Coord c2b = CoordUtils.createCoord(1.0, 0.0); @@ -200,10 +200,10 @@ public void testCalcEuclideanDistance() { // Mixed 2D and 3D assertEquals(Math.sqrt(2.0), CoordUtils.calcEuclideanDistance(c2a, c3e), MatsimTestUtils.EPSILON); } - - + + @Test - public void testCalcProjectedDistance() { + void testCalcProjectedDistance() { // 2D Coord c2a = CoordUtils.createCoord(0.0, 0.0); Coord c2b = CoordUtils.createCoord(1.0, 1.0); @@ -217,11 +217,10 @@ public void testCalcProjectedDistance() { // Mixed 2D and 3D assertEquals(Math.sqrt(2.0), CoordUtils.calcProjectedEuclideanDistance(c2a, c3b), MatsimTestUtils.EPSILON); } - - + @Test - public void testDistancePointLinesegment() { + void testDistancePointLinesegment() { /* First: 2D */ /* * (0,1) c1 @@ -268,9 +267,9 @@ public void testDistancePointLinesegment() { dist = CoordUtils.distancePointLinesegment(c2, c3, c1); assertEquals(CoordUtils.calcEuclideanDistance(c3, c1), dist, MatsimTestUtils.EPSILON); } - + @Test - public void testOrthogonalProjectionOnLineSegment(){ + void testOrthogonalProjectionOnLineSegment(){ /* First: 2D */ Coord point = CoordUtils.createCoord(2.0, 0.0); Coord lineFrom = CoordUtils.createCoord(0.0, 0.0); diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/GeometryUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/GeometryUtilsTest.java index 4e4a7495248..10527d9d759 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/GeometryUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/GeometryUtilsTest.java @@ -21,8 +21,8 @@ package org.matsim.core.utils.geometry; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.LineString; @@ -49,7 +49,7 @@ public class GeometryUtilsTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public final void testIntersectingLinks() { + final void testIntersectingLinks() { Config config = ConfigUtils.loadConfig( IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL("equil"), "config.xml" ) ) ; diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/geotools/MGCTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/geotools/MGCTest.java index 65265390b9f..bef47a55d81 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/geotools/MGCTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/geotools/MGCTest.java @@ -21,14 +21,14 @@ package org.matsim.core.utils.geometry.geotools; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Point; import org.matsim.api.core.v01.Coord; import org.matsim.testcases.MatsimTestUtils; -/** + /** * * @author laemmel * @@ -39,7 +39,8 @@ public class MGCTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testCoord2CoordinateAndViceVersa(){ + @Test + void testCoord2CoordinateAndViceVersa(){ double x = 123.456789; double y = 987.654321; double delta = 0.0000001; @@ -52,7 +53,8 @@ public class MGCTest { org.junit.Assert.assertEquals(y,y1,delta); } - @Test public void testCoord2PointAndViceVersa(){ + @Test + void testCoord2PointAndViceVersa(){ double x = 123.456789; double y = 987.654321; double delta = 0.0000001; @@ -66,7 +68,8 @@ public class MGCTest { } - @Test public void testGetUTMEPSGCodeForWGS84Coordinate() { + @Test + void testGetUTMEPSGCodeForWGS84Coordinate() { { //Hamburg - should be UTM 32 North --> EPSG:32632 double lat = 53.562021; @@ -111,7 +114,8 @@ public class MGCTest { } } - @Test public void testGetCRS(){ + @Test + void testGetCRS(){ // CH1903_LV03 Id org.junit.Assert.assertNotNull(MGC.getCRS("EPSG:21781")); diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03PlustoWGS84Test.java b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03PlustoWGS84Test.java index 3b9f5b6d5db..3c88bf71af1 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03PlustoWGS84Test.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03PlustoWGS84Test.java @@ -22,7 +22,7 @@ package org.matsim.core.utils.geometry.transformations; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; /** @@ -35,7 +35,7 @@ public class CH1903LV03PlustoWGS84Test { * http://www.swisstopo.admin.ch/internet/swisstopo/de/home/topics/survey/sys/refsys/switzerland.parsysrelated1.24280.downloadList.87003.DownloadFile.tmp/ch1903wgs84de.pdf */ @Test - public void testTransform() { + void testTransform() { double xx = 8.0 + 43.0/60 + 49.80/3600; double yy = 46.0 + 02.0/60 + 38.86/3600; double epsilon = 1e-6; diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03PlustofromCH1903LV03Test.java b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03PlustofromCH1903LV03Test.java index f0eacb3de92..3f7420d1340 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03PlustofromCH1903LV03Test.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03PlustofromCH1903LV03Test.java @@ -22,7 +22,7 @@ package org.matsim.core.utils.geometry.transformations; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; /** @@ -31,7 +31,7 @@ public class CH1903LV03PlustofromCH1903LV03Test { @Test - public void testCH1903LV03PlustoCH1903LV03() { + void testCH1903LV03PlustoCH1903LV03() { CH1903LV03PlustoCH1903LV03 converter = new CH1903LV03PlustoCH1903LV03(); Coord n = converter.transform(new Coord((double) 2700000, (double) 1100000)); Assert.assertEquals(700000, n.getX(), 0.0); @@ -39,7 +39,7 @@ public void testCH1903LV03PlustoCH1903LV03() { } @Test - public void testCH1903LV03toCH1903LV03Plus() { + void testCH1903LV03toCH1903LV03Plus() { CH1903LV03toCH1903LV03Plus converter = new CH1903LV03toCH1903LV03Plus(); Coord n = converter.transform(new Coord((double) 700000, (double) 100000)); Assert.assertEquals(2700000, n.getX(), 0.0); diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03toWGS84Test.java b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03toWGS84Test.java index 246195bb663..a8e43c4d8ed 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03toWGS84Test.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03toWGS84Test.java @@ -20,8 +20,7 @@ package org.matsim.core.utils.geometry.transformations; import org.junit.Assert; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; /** @@ -34,7 +33,7 @@ public class CH1903LV03toWGS84Test { * http://www.swisstopo.ch/pub/down/basics/geo/system/ch1903_wgs84_de.pdf */ @Test - public void testTransform() { + void testTransform() { double xx = 8.0 + 43.0/60 + 49.80/3600; double yy = 46.0 + 02.0/60 + 38.86/3600; double epsilon = 1e-6; diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/GeotoolsTransformationTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/GeotoolsTransformationTest.java index 7fd2cacc8df..aac31a1b9be 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/GeotoolsTransformationTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/GeotoolsTransformationTest.java @@ -20,8 +20,8 @@ package org.matsim.core.utils.geometry.transformations; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.testcases.MatsimTestUtils; @@ -36,7 +36,8 @@ public class GeotoolsTransformationTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testTransform(){ + @Test + void testTransform(){ String toCRS = "WGS84"; String fromCRS = "WGS84_UTM47S"; diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/TransformationFactoryTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/TransformationFactoryTest.java index 1b1dcafc096..f55454c7314 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/TransformationFactoryTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/TransformationFactoryTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.core.utils.geometry.CoordinateTransformation; public class TransformationFactoryTest { @@ -35,7 +35,8 @@ public class TransformationFactoryTest { * Test if a custom implemented, non-GeoTools coordinate transformation can * be instantiated. */ - @Test public final void testKnownCustomTransformation() { + @Test + final void testKnownCustomTransformation() { CoordinateTransformation transformation = TransformationFactory.getCoordinateTransformation(TransformationFactory.GK4, TransformationFactory.WGS84); assertNotNull(transformation); assertTrue(transformation instanceof GK4toWGS84); @@ -44,7 +45,8 @@ public class TransformationFactoryTest { /** * Test if GeoTools handles the requested coordinate transformation. */ - @Test public final void testKnownGeotoolsTransformation() { + @Test + final void testKnownGeotoolsTransformation() { CoordinateTransformation transformation = TransformationFactory.getCoordinateTransformation(TransformationFactory.WGS84_UTM35S, TransformationFactory.WGS84); assertNotNull(transformation); assertTrue(transformation instanceof GeotoolsTransformation); @@ -54,7 +56,8 @@ public class TransformationFactoryTest { * Test if a correct, GeoTools' Well-Known-Text (WKT) is correctly recognized, * instead of our shortcut names. */ - @Test public final void testUnknownWKTTransformation() { + @Test + final void testUnknownWKTTransformation() { final String wgs84utm35s = "PROJCS[\"WGS_1984_UTM_Zone_35S\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",27],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",10000000],UNIT[\"Meter\",1]]"; final String wgs84 = "GEOGCS[\"WGS84\", DATUM[\"WGS84\", SPHEROID[\"WGS84\", 6378137.0, 298.257223563]], PRIMEM[\"Greenwich\", 0.0], UNIT[\"degree\",0.017453292519943295], AXIS[\"Longitude\",EAST], AXIS[\"Latitude\",NORTH]]"; CoordinateTransformation transformation1 = TransformationFactory.getCoordinateTransformation(wgs84utm35s, TransformationFactory.WGS84); @@ -68,7 +71,8 @@ public class TransformationFactoryTest { /** * Test if a wrong, non-Well-Known-Text according to GeoTools is correctly rejected. */ - @Test public final void testUnknownBadTransformation() { + @Test + final void testUnknownBadTransformation() { // GeoTools recognize misspellings in WKTs, but not (possibly) missing parameters. // Don't be fooled by the many Strings in WKTs, many of them are just names, NOT identifiers! @@ -92,32 +96,38 @@ public class TransformationFactoryTest { } } - @Test public final void testIdentityTransformation() { + @Test + final void testIdentityTransformation() { CoordinateTransformation transformation = TransformationFactory.getCoordinateTransformation(TransformationFactory.ATLANTIS, TransformationFactory.ATLANTIS); assertTrue(transformation instanceof IdentityTransformation); } - @Test public final void testToCH1903LV03() { + @Test + final void testToCH1903LV03() { CoordinateTransformation transformation = TransformationFactory.getCoordinateTransformation(TransformationFactory.WGS84, TransformationFactory.CH1903_LV03); assertTrue(transformation instanceof WGS84toCH1903LV03); } - @Test public final void testFromCH1903LV03() { + @Test + final void testFromCH1903LV03() { CoordinateTransformation transformation = TransformationFactory.getCoordinateTransformation(TransformationFactory.CH1903_LV03, TransformationFactory.WGS84); assertTrue(transformation instanceof CH1903LV03toWGS84); } - @Test public final void testToCH1903LV03Plus() { + @Test + final void testToCH1903LV03Plus() { CoordinateTransformation transformation = TransformationFactory.getCoordinateTransformation(TransformationFactory.WGS84, TransformationFactory.CH1903_LV03_Plus); assertTrue(transformation instanceof WGS84toCH1903LV03Plus); } - @Test public final void testFromCH1903LV03Plus() { + @Test + final void testFromCH1903LV03Plus() { CoordinateTransformation transformation = TransformationFactory.getCoordinateTransformation(TransformationFactory.CH1903_LV03_Plus, TransformationFactory.WGS84); assertTrue(transformation instanceof CH1903LV03PlustoWGS84); } - @Test public final void testFromAtlantis() { + @Test + final void testFromAtlantis() { CoordinateTransformation transformation = TransformationFactory.getCoordinateTransformation(TransformationFactory.ATLANTIS, TransformationFactory.WGS84); assertTrue(transformation instanceof AtlantisToWGS84); } diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/WGS84toCH1903LV03PlusTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/WGS84toCH1903LV03PlusTest.java index 8d0078af315..93fecc49e19 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/WGS84toCH1903LV03PlusTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/WGS84toCH1903LV03PlusTest.java @@ -22,7 +22,7 @@ package org.matsim.core.utils.geometry.transformations; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; /** @@ -35,7 +35,7 @@ public class WGS84toCH1903LV03PlusTest { * http://www.swisstopo.admin.ch/internet/swisstopo/de/home/topics/survey/sys/refsys/switzerland.parsysrelated1.24280.downloadList.87003.DownloadFile.tmp/ch1903wgs84de.pdf */ @Test - public void testTransform() { + void testTransform() { double xx = 8.0 + 43.0/60 + 49.79/3600; double yy = 46.0 + 02.0/60 + 38.87/3600; double epsilon = 1e-2; diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/WGS84toCH1903LV03Test.java b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/WGS84toCH1903LV03Test.java index c32e329e80c..717fa4da70c 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/WGS84toCH1903LV03Test.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/WGS84toCH1903LV03Test.java @@ -20,8 +20,7 @@ package org.matsim.core.utils.geometry.transformations; import org.junit.Assert; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; /** @@ -30,7 +29,7 @@ public class WGS84toCH1903LV03Test { @Test - public void testTransform() { + void testTransform() { double xx = 8.0 + 43.0/60 + 49.79/3600; double yy = 46.0 + 02.0/60 + 38.87/3600; double epsilon = 1e-2; diff --git a/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileReaderTest.java b/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileReaderTest.java index 155a9f62128..650293090b4 100644 --- a/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileReaderTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileReaderTest.java @@ -25,8 +25,8 @@ import org.geotools.data.FeatureSource; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -41,7 +41,7 @@ public class ShapeFileReaderTest { * @throws IOException */ @Test - public void testPlusInFilename() throws IOException { + void testPlusInFilename() throws IOException { String filename = "src/test/resources/" + utils.getInputDirectory() + "test+test.shp"; FeatureSource fs = ShapeFileReader.readDataFile(filename); Assert.assertEquals(3, fs.getFeatures().size()); diff --git a/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileWriterTest.java b/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileWriterTest.java index bf9b3ee2a90..a953c2bfd62 100644 --- a/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileWriterTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileWriterTest.java @@ -33,8 +33,8 @@ import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.geotools.referencing.crs.DefaultGeographicCRS; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -50,7 +50,7 @@ public class ShapeFileWriterTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testShapeFileWriter() throws IOException{ + void testShapeFileWriter() throws IOException{ String inFile = "src/test/resources/" + utils.getInputDirectory() + "test.shp"; @@ -75,7 +75,7 @@ public void testShapeFileWriter() throws IOException{ } @Test - public void testShapeFileWriterWithSelfCreatedContent() throws IOException { + void testShapeFileWriterWithSelfCreatedContent() throws IOException { String outFile = utils.getOutputDirectory() + "/test.shp"; SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setName("EvacuationArea"); @@ -108,7 +108,7 @@ public void testShapeFileWriterWithSelfCreatedContent() throws IOException { } @Test - public void testShapeFileWriterWithSelfCreatedContent_withMatsimFactory_Polygon() throws IOException { + void testShapeFileWriterWithSelfCreatedContent_withMatsimFactory_Polygon() throws IOException { String outFile = utils.getOutputDirectory() + "test.shp"; PolygonFeatureFactory ff = new PolygonFeatureFactory.Builder() @@ -137,7 +137,7 @@ public void testShapeFileWriterWithSelfCreatedContent_withMatsimFactory_Polygon( } @Test - public void testShapeFileWriterWithSelfCreatedContent_withMatsimFactory_Polyline() throws IOException { + void testShapeFileWriterWithSelfCreatedContent_withMatsimFactory_Polyline() throws IOException { String outFile = utils.getOutputDirectory() + "test.shp"; PolylineFeatureFactory ff = new PolylineFeatureFactory.Builder() @@ -166,7 +166,7 @@ public void testShapeFileWriterWithSelfCreatedContent_withMatsimFactory_Polyline } @Test - public void testShapeFileWriterWithSelfCreatedContent_withMatsimFactory_Point() throws IOException { + void testShapeFileWriterWithSelfCreatedContent_withMatsimFactory_Point() throws IOException { String outFile = utils.getOutputDirectory() + "test.shp"; PointFeatureFactory ff = new PointFeatureFactory.Builder() diff --git a/matsim/src/test/java/org/matsim/core/utils/io/IOUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/io/IOUtilsTest.java index db3784f59e6..150f1982025 100644 --- a/matsim/src/test/java/org/matsim/core/utils/io/IOUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/io/IOUtilsTest.java @@ -19,9 +19,11 @@ * *********************************************************************** */ package org.matsim.core.utils.io; +import static org.junit.jupiter.api.Assertions.assertThrows; + import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.controler.OutputDirectoryLogging; import org.matsim.core.utils.misc.CRCChecksum; import org.matsim.testcases.MatsimTestUtils; @@ -42,7 +44,7 @@ public class IOUtilsTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testInitOutputDirLogging() throws IOException { + void testInitOutputDirLogging() throws IOException { System.out.println(utils.getOutputDirectory()); String outDir = utils.getOutputDirectory(); OutputDirectoryLogging.initLoggingWithOutputDirectory(outDir); @@ -57,7 +59,7 @@ public void testInitOutputDirLogging() throws IOException { * @author mrieser */ @Test - public void testDeleteDir() throws IOException { + void testDeleteDir() throws IOException { String outputDir = utils.getOutputDirectory(); String testDir = outputDir + "a"; String someFilename = testDir + "/a.txt"; @@ -75,17 +77,19 @@ public void testDeleteDir() throws IOException { /** * @author mrieser */ - @Test(expected = UncheckedIOException.class) - public void testDeleteDir_InexistentDir() { - String outputDir = utils.getOutputDirectory(); - String testDir = outputDir + "a"; - File dir = new File(testDir); - IOUtils.deleteDirectoryRecursively(dir.toPath()); - Assert.assertFalse(dir.exists()); + @Test + void testDeleteDir_InexistentDir() { + assertThrows(UncheckedIOException.class, () -> { + String outputDir = utils.getOutputDirectory(); + String testDir = outputDir + "a"; + File dir = new File(testDir); + IOUtils.deleteDirectoryRecursively(dir.toPath()); + Assert.assertFalse(dir.exists()); + }); } @Test - public void testGetBufferedReader_encodingMacRoman() throws IOException { + void testGetBufferedReader_encodingMacRoman() throws IOException { URL url = IOUtils.resolveFileOrResource(this.utils.getClassInputDirectory() + "textsample_MacRoman.txt"); BufferedReader reader = IOUtils.getBufferedReader(url, Charset.forName("MacRoman")); String line = reader.readLine(); @@ -94,7 +98,7 @@ public void testGetBufferedReader_encodingMacRoman() throws IOException { } @Test - public void testGetBufferedReader_encodingIsoLatin1() throws IOException { + void testGetBufferedReader_encodingIsoLatin1() throws IOException { URL url = IOUtils.resolveFileOrResource(this.utils.getClassInputDirectory() + "textsample_IsoLatin1.txt"); BufferedReader reader = IOUtils.getBufferedReader(url, Charset.forName("ISO-8859-1")); String line = reader.readLine(); @@ -103,7 +107,7 @@ public void testGetBufferedReader_encodingIsoLatin1() throws IOException { } @Test - public void testGetBufferedReader_encodingUTF8() throws IOException { + void testGetBufferedReader_encodingUTF8() throws IOException { URL url = IOUtils.resolveFileOrResource(this.utils.getClassInputDirectory() + "textsample_UTF8.txt"); BufferedReader reader = IOUtils.getBufferedReader(url); String line = reader.readLine(); @@ -112,7 +116,7 @@ public void testGetBufferedReader_encodingUTF8() throws IOException { } @Test - public void testGetBufferedWriter_encodingMacRoman() throws IOException { + void testGetBufferedWriter_encodingMacRoman() throws IOException { String filename = this.utils.getOutputDirectory() + "textsample_MacRoman.txt"; URL url = IOUtils.getFileUrl(filename); BufferedWriter writer = IOUtils.getBufferedWriter(url, Charset.forName("MacRoman"), false); @@ -124,7 +128,7 @@ public void testGetBufferedWriter_encodingMacRoman() throws IOException { } @Test - public void testGetBufferedWriter_encodingIsoLatin1() throws IOException { + void testGetBufferedWriter_encodingIsoLatin1() throws IOException { String filename = this.utils.getOutputDirectory() + "textsample_IsoLatin1.txt"; URL url = IOUtils.getFileUrl(filename); BufferedWriter writer = IOUtils.getBufferedWriter(url, Charset.forName("ISO-8859-1"), false); @@ -136,7 +140,7 @@ public void testGetBufferedWriter_encodingIsoLatin1() throws IOException { } @Test - public void testGetBufferedWriter_encodingUTF8() throws IOException { + void testGetBufferedWriter_encodingUTF8() throws IOException { String filename = this.utils.getOutputDirectory() + "textsample_UTF8.txt"; URL url = IOUtils.getFileUrl(filename); BufferedWriter writer = IOUtils.getBufferedWriter(url); @@ -148,7 +152,7 @@ public void testGetBufferedWriter_encodingUTF8() throws IOException { } @Test - public void testGetBufferedWriter_overwrite() throws IOException { + void testGetBufferedWriter_overwrite() throws IOException { String filename = this.utils.getOutputDirectory() + "test.txt"; URL url = IOUtils.getFileUrl(filename); BufferedWriter writer = IOUtils.getBufferedWriter(url); @@ -163,7 +167,7 @@ public void testGetBufferedWriter_overwrite() throws IOException { } @Test - public void testGetBufferedWriter_append() throws IOException { + void testGetBufferedWriter_append() throws IOException { String filename = this.utils.getOutputDirectory() + "test.txt"; URL url = IOUtils.getFileUrl(filename); BufferedWriter writer = IOUtils.getBufferedWriter(url, IOUtils.CHARSET_UTF8, true); @@ -178,7 +182,7 @@ public void testGetBufferedWriter_append() throws IOException { } @Test - public void testGetBufferedWriter_overwrite_gzipped() throws IOException { + void testGetBufferedWriter_overwrite_gzipped() throws IOException { String filename = this.utils.getOutputDirectory() + "test.txt.gz"; URL url = IOUtils.getFileUrl(filename); BufferedWriter writer = IOUtils.getBufferedWriter(url); @@ -192,18 +196,20 @@ public void testGetBufferedWriter_overwrite_gzipped() throws IOException { Assert.assertEquals("bbb", line); } - @Test(expected = UncheckedIOException.class) - public void testGetBufferedWriter_append_gzipped() throws IOException { - String filename = this.utils.getOutputDirectory() + "test.txt.gz"; - URL url = IOUtils.getFileUrl(filename); - BufferedWriter writer = IOUtils.getBufferedWriter(url, IOUtils.CHARSET_UTF8, true); - writer.write("aaa"); - writer.close(); - IOUtils.getBufferedWriter(url, IOUtils.CHARSET_UTF8, true); + @Test + void testGetBufferedWriter_append_gzipped() throws IOException { + assertThrows(UncheckedIOException.class, () -> { + String filename = this.utils.getOutputDirectory() + "test.txt.gz"; + URL url = IOUtils.getFileUrl(filename); + BufferedWriter writer = IOUtils.getBufferedWriter(url, IOUtils.CHARSET_UTF8, true); + writer.write("aaa"); + writer.close(); + IOUtils.getBufferedWriter(url, IOUtils.CHARSET_UTF8, true); + }); } @Test - public void testGetBufferedWriter_gzipped() throws IOException { + void testGetBufferedWriter_gzipped() throws IOException { String filename = this.utils.getOutputDirectory() + "test.txt.gz"; URL url = IOUtils.getFileUrl(filename); BufferedWriter writer = IOUtils.getBufferedWriter(url); @@ -213,18 +219,20 @@ public void testGetBufferedWriter_gzipped() throws IOException { Assert.assertTrue("compressed file should be less than 50 bytes, but is " + file.length(), file.length() < 50); } - @Test(expected = UncheckedIOException.class) - public void testGetBufferedWriter_append_lz4() throws IOException { - String filename = this.utils.getOutputDirectory() + "test.txt.lz4"; - URL url = IOUtils.getFileUrl(filename); - BufferedWriter writer = IOUtils.getBufferedWriter(url, IOUtils.CHARSET_UTF8, true); - writer.write("aaa"); - writer.close(); - IOUtils.getBufferedWriter(url, IOUtils.CHARSET_UTF8, true); + @Test + void testGetBufferedWriter_append_lz4() throws IOException { + assertThrows(UncheckedIOException.class, () -> { + String filename = this.utils.getOutputDirectory() + "test.txt.lz4"; + URL url = IOUtils.getFileUrl(filename); + BufferedWriter writer = IOUtils.getBufferedWriter(url, IOUtils.CHARSET_UTF8, true); + writer.write("aaa"); + writer.close(); + IOUtils.getBufferedWriter(url, IOUtils.CHARSET_UTF8, true); + }); } @Test - public void testGetBufferedWriter_lz4() throws IOException { + void testGetBufferedWriter_lz4() throws IOException { String filename = this.utils.getOutputDirectory() + "test.txt.lz4"; URL url = IOUtils.getFileUrl(filename); BufferedWriter writer = IOUtils.getBufferedWriter(url); @@ -237,18 +245,20 @@ public void testGetBufferedWriter_lz4() throws IOException { Assert.assertEquals("12345678901234567890123456789012345678901234567890", content); } - @Test(expected = UncheckedIOException.class) - public void testGetBufferedWriter_append_bz2() throws IOException { - String filename = this.utils.getOutputDirectory() + "test.txt.bz2"; - URL url = IOUtils.getFileUrl(filename); - BufferedWriter writer = IOUtils.getBufferedWriter(url, IOUtils.CHARSET_UTF8, true); - writer.write("aaa"); - writer.close(); - IOUtils.getBufferedWriter(url, IOUtils.CHARSET_UTF8, true); + @Test + void testGetBufferedWriter_append_bz2() throws IOException { + assertThrows(UncheckedIOException.class, () -> { + String filename = this.utils.getOutputDirectory() + "test.txt.bz2"; + URL url = IOUtils.getFileUrl(filename); + BufferedWriter writer = IOUtils.getBufferedWriter(url, IOUtils.CHARSET_UTF8, true); + writer.write("aaa"); + writer.close(); + IOUtils.getBufferedWriter(url, IOUtils.CHARSET_UTF8, true); + }); } @Test - public void testGetBufferedWriter_bz2() throws IOException { + void testGetBufferedWriter_bz2() throws IOException { String filename = this.utils.getOutputDirectory() + "test.txt.bz2"; URL url = IOUtils.getFileUrl(filename); BufferedWriter writer = IOUtils.getBufferedWriter(url); @@ -259,7 +269,7 @@ public void testGetBufferedWriter_bz2() throws IOException { } @Test - public void testGetBufferedWriter_append_zst() throws IOException { + void testGetBufferedWriter_append_zst() throws IOException { String filename = this.utils.getOutputDirectory() + "test.txt.zst"; URL url = IOUtils.getFileUrl(filename); BufferedWriter writer = IOUtils.getBufferedWriter(url, IOUtils.CHARSET_UTF8, true); @@ -274,7 +284,7 @@ public void testGetBufferedWriter_append_zst() throws IOException { } @Test - public void testGetBufferedWriter_zst() throws IOException { + void testGetBufferedWriter_zst() throws IOException { String filename = this.utils.getOutputDirectory() + "test.txt.zst"; URL url = IOUtils.getFileUrl(filename); BufferedWriter writer = IOUtils.getBufferedWriter(url); @@ -285,7 +295,7 @@ public void testGetBufferedWriter_zst() throws IOException { } @Test - public void testGetInputStream_UTFwithoutBOM() throws IOException { + void testGetInputStream_UTFwithoutBOM() throws IOException { String filename = utils.getOutputDirectory() + "test.txt"; FileOutputStream out = new FileOutputStream(filename); out.write("ABCdef".getBytes()); @@ -297,7 +307,7 @@ public void testGetInputStream_UTFwithoutBOM() throws IOException { } @Test - public void testGetInputStream_UTFwithBOM() throws IOException { + void testGetInputStream_UTFwithBOM() throws IOException { String filename = utils.getOutputDirectory() + "test.txt"; FileOutputStream out = new FileOutputStream(filename); out.write(new byte[] {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF}); @@ -310,7 +320,7 @@ public void testGetInputStream_UTFwithBOM() throws IOException { } @Test - public void testGetInputStream_UTFwithBOM_Compressed() throws IOException { + void testGetInputStream_UTFwithBOM_Compressed() throws IOException { String filename = utils.getOutputDirectory() + "test.txt.gz"; OutputStream out = IOUtils.getOutputStream(IOUtils.getFileUrl(filename), false); out.write(new byte[] {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF}); @@ -323,7 +333,7 @@ public void testGetInputStream_UTFwithBOM_Compressed() throws IOException { } @Test - public void testGetInputStream_UTFwithBOM_Lz4() throws IOException { + void testGetInputStream_UTFwithBOM_Lz4() throws IOException { String filename = utils.getOutputDirectory() + "test.txt.lz4"; OutputStream out = IOUtils.getOutputStream(IOUtils.getFileUrl(filename), false); out.write(new byte[] {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF}); @@ -336,7 +346,7 @@ public void testGetInputStream_UTFwithBOM_Lz4() throws IOException { } @Test - public void testGetInputStream_UTFwithBOM_bz2() throws IOException { + void testGetInputStream_UTFwithBOM_bz2() throws IOException { String filename = utils.getOutputDirectory() + "test.txt.bz2"; OutputStream out = IOUtils.getOutputStream(IOUtils.getFileUrl(filename), false); out.write(new byte[] {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF}); @@ -349,7 +359,7 @@ public void testGetInputStream_UTFwithBOM_bz2() throws IOException { } @Test - public void testGetInputStream_UTFwithBOM_zst() throws IOException { + void testGetInputStream_UTFwithBOM_zst() throws IOException { String filename = utils.getOutputDirectory() + "test.txt.zst"; OutputStream out = IOUtils.getOutputStream(IOUtils.getFileUrl(filename), false); out.write(new byte[] {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF}); @@ -362,7 +372,7 @@ public void testGetInputStream_UTFwithBOM_zst() throws IOException { } @Test - public void testGetBufferedReader_UTFwithoutBOM() throws IOException { + void testGetBufferedReader_UTFwithoutBOM() throws IOException { String filename = utils.getOutputDirectory() + "test.txt"; FileOutputStream out = new FileOutputStream(filename); out.write("ABCdef".getBytes()); @@ -386,7 +396,7 @@ public void testGetBufferedReader_UTFwithoutBOM() throws IOException { } @Test - public void testGetBufferedReader_UTFwithBOM() throws IOException { + void testGetBufferedReader_UTFwithBOM() throws IOException { String filename = utils.getOutputDirectory() + "test.txt"; FileOutputStream out = new FileOutputStream(filename); out.write(new byte[] {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF}); @@ -411,7 +421,7 @@ public void testGetBufferedReader_UTFwithBOM() throws IOException { } @Test - public void testGetBufferedReader_UTFwithBOM_Compressed() throws IOException { + void testGetBufferedReader_UTFwithBOM_Compressed() throws IOException { String filename = utils.getOutputDirectory() + "test.txt.gz"; OutputStream out = IOUtils.getOutputStream(IOUtils.getFileUrl(filename), false); out.write(new byte[] {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF}); @@ -441,7 +451,7 @@ public void testGetBufferedReader_UTFwithBOM_Compressed() throws IOException { } @Test - public void testGetBufferedReader_UTFwithBOM_lz4() throws IOException { + void testGetBufferedReader_UTFwithBOM_lz4() throws IOException { String filename = utils.getOutputDirectory() + "test.txt.lz4"; OutputStream out = IOUtils.getOutputStream(IOUtils.getFileUrl(filename), false); out.write(new byte[] {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF}); @@ -466,7 +476,7 @@ public void testGetBufferedReader_UTFwithBOM_lz4() throws IOException { } @Test - public void testGetBufferedReader_UTFwithBOM_bz2() throws IOException { + void testGetBufferedReader_UTFwithBOM_bz2() throws IOException { String filename = utils.getOutputDirectory() + "test.txt.bz2"; OutputStream out = IOUtils.getOutputStream(IOUtils.getFileUrl(filename), false); out.write(new byte[] {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF}); @@ -491,7 +501,7 @@ public void testGetBufferedReader_UTFwithBOM_bz2() throws IOException { } @Test - public void testGetBufferedReader_UTFwithBOM_zst() throws IOException { + void testGetBufferedReader_UTFwithBOM_zst() throws IOException { String filename = utils.getOutputDirectory() + "test.txt.zst"; OutputStream out = IOUtils.getOutputStream(IOUtils.getFileUrl(filename), false); out.write(new byte[] {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF}); @@ -522,7 +532,7 @@ public void testGetBufferedReader_UTFwithBOM_zst() throws IOException { * @throws IOException */ @Test - public void testGetBufferedWriter_withPlusInFilename() throws IOException { + void testGetBufferedWriter_withPlusInFilename() throws IOException { String filename = this.utils.getOutputDirectory() + "test+test.txt"; BufferedWriter writer = IOUtils.getBufferedWriter(IOUtils.getFileUrl(filename)); writer.write("hello world!"); @@ -534,7 +544,7 @@ public void testGetBufferedWriter_withPlusInFilename() throws IOException { } @Test - public void testNewUrl() throws MalformedURLException { + void testNewUrl() throws MalformedURLException { URL context = Paths.get("").toUri().toURL(); System.out.println(context.toString()); URL url = IOUtils.extendUrl(context, "C:\\windows\\directory\\filename.txt"); @@ -542,7 +552,7 @@ public void testNewUrl() throws MalformedURLException { } @Test - public void testResolveFileOrResource() throws URISyntaxException, IOException { + void testResolveFileOrResource() throws URISyntaxException, IOException { File jarFile = new File("test/input/org/matsim/core/utils/io/IOUtils/testfile.jar"); String jarUrlString = "file:" + jarFile.getAbsolutePath(); // URLs require absolute paths @@ -558,7 +568,7 @@ public void testResolveFileOrResource() throws URISyntaxException, IOException { } @Test - public void testResolveFileOrResource_withWhitespace() throws URISyntaxException, IOException { + void testResolveFileOrResource_withWhitespace() throws URISyntaxException, IOException { File jarFile = new File("test/input/org/matsim/core/utils/io/IOUtils/test directory/testfile.jar"); String fileUrlString = "jar:" + jarFile.toURI().toString() + "!/the_file.txt"; @@ -574,7 +584,7 @@ public void testResolveFileOrResource_withWhitespace() throws URISyntaxException } @Test - public void testEncryptedFile() throws IOException { + void testEncryptedFile() throws IOException { System.setProperty(CipherUtils.ENVIRONMENT_VARIABLE, "abc123"); diff --git a/matsim/src/test/java/org/matsim/core/utils/io/MatsimFileTypeGuesserTest.java b/matsim/src/test/java/org/matsim/core/utils/io/MatsimFileTypeGuesserTest.java index 34b26897bd8..3ec8ab16e69 100644 --- a/matsim/src/test/java/org/matsim/core/utils/io/MatsimFileTypeGuesserTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/io/MatsimFileTypeGuesserTest.java @@ -30,7 +30,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.lanes.LanesReader; /** @@ -42,7 +42,7 @@ public class MatsimFileTypeGuesserTest { private final static Logger log = LogManager.getLogger(MatsimFileTypeGuesserTest.class); @Test - public void testNetworkV1Dtd() throws IOException { + void testNetworkV1Dtd() throws IOException { MatsimFileTypeGuesser g = new MatsimFileTypeGuesser("test/scenarios/equil/network.xml"); assertEquals(MatsimFileTypeGuesser.FileType.Network, g.getGuessedFileType()); assertNull(g.getPublicId()); @@ -50,7 +50,7 @@ public void testNetworkV1Dtd() throws IOException { } @Test - public void testConfigV2Dtd() throws IOException { + void testConfigV2Dtd() throws IOException { MatsimFileTypeGuesser g = new MatsimFileTypeGuesser("test/scenarios/equil/config.xml"); assertEquals(MatsimFileTypeGuesser.FileType.Config, g.getGuessedFileType()); assertNull(g.getPublicId()); @@ -58,7 +58,7 @@ public void testConfigV2Dtd() throws IOException { } @Test - public void testPlansV4Dtd() throws IOException { + void testPlansV4Dtd() throws IOException { MatsimFileTypeGuesser g = new MatsimFileTypeGuesser("test/scenarios/equil/plans100.xml"); assertEquals(MatsimFileTypeGuesser.FileType.Population, g.getGuessedFileType()); assertNull(g.getPublicId()); @@ -66,7 +66,7 @@ public void testPlansV4Dtd() throws IOException { } @Test - public void testPopulationV5Dtd() throws IOException { + void testPopulationV5Dtd() throws IOException { MatsimFileTypeGuesser g = new MatsimFileTypeGuesser("test/input/org/matsim/core/utils/io/MatsimFileTypeGuesserTest/population_v5_example.xml"); assertEquals(MatsimFileTypeGuesser.FileType.Population, g.getGuessedFileType()); assertNull(g.getPublicId()); @@ -74,7 +74,7 @@ public void testPopulationV5Dtd() throws IOException { } @Test - public void testFacilitiesV1Dtd() throws IOException { + void testFacilitiesV1Dtd() throws IOException { MatsimFileTypeGuesser g = new MatsimFileTypeGuesser("test/scenarios/equil/facilities.xml"); assertEquals(MatsimFileTypeGuesser.FileType.Facilities, g.getGuessedFileType()); assertNull(g.getPublicId()); @@ -82,7 +82,7 @@ public void testFacilitiesV1Dtd() throws IOException { } @Test - public void testCountsV1Xsd() throws IOException { + void testCountsV1Xsd() throws IOException { MatsimFileTypeGuesser g = new MatsimFileTypeGuesser("test/scenarios/equil/counts100.xml"); assertEquals(MatsimFileTypeGuesser.FileType.Counts, g.getGuessedFileType()); assertNull(g.getPublicId()); @@ -90,7 +90,7 @@ public void testCountsV1Xsd() throws IOException { } @Test - public void testEventsV1Txt() throws IOException { + void testEventsV1Txt() throws IOException { MatsimFileTypeGuesser g = new MatsimFileTypeGuesser("test/input/org/matsim/events/EventsReadersTest/events.txt"); assertEquals(MatsimFileTypeGuesser.FileType.Events, g.getGuessedFileType()); assertNull(g.getPublicId()); @@ -98,7 +98,7 @@ public void testEventsV1Txt() throws IOException { } @Test - public void testEventsV1Xml() throws IOException { + void testEventsV1Xml() throws IOException { MatsimFileTypeGuesser g = new MatsimFileTypeGuesser("test/input/org/matsim/core/events/EventsReadersTest/events.xml"); assertEquals(MatsimFileTypeGuesser.FileType.Events, g.getGuessedFileType()); assertNull(g.getPublicId()); @@ -106,7 +106,7 @@ public void testEventsV1Xml() throws IOException { } @Test - public void testLanesV20XML() throws IOException { + void testLanesV20XML() throws IOException { MatsimFileTypeGuesser g = new MatsimFileTypeGuesser("test/input/org/matsim/lanes/data/LanesReaderWriterTest/testLanes.xml"); assertEquals(MatsimFileTypeGuesser.FileType.LaneDefinitions, g.getGuessedFileType()); assertNull(g.getPublicId()); @@ -115,7 +115,7 @@ public void testLanesV20XML() throws IOException { } @Test - public void testTransitScheduleV1XML() throws IOException { + void testTransitScheduleV1XML() throws IOException { MatsimFileTypeGuesser g = new MatsimFileTypeGuesser("test/input/org/matsim/pt/transitSchedule/TransitScheduleReaderTest/transitSchedule.xml"); assertEquals(MatsimFileTypeGuesser.FileType.TransitSchedule, g.getGuessedFileType()); assertNull(g.getPublicId()); @@ -124,7 +124,7 @@ public void testTransitScheduleV1XML() throws IOException { } @Test - public void testVehiclesV1XML() throws IOException { + void testVehiclesV1XML() throws IOException { MatsimFileTypeGuesser g = new MatsimFileTypeGuesser("test/input/org/matsim/vehicles/testVehicles_v1.xml"); assertEquals(MatsimFileTypeGuesser.FileType.Vehicles, g.getGuessedFileType()); assertNull(g.getPublicId()); @@ -133,7 +133,7 @@ public void testVehiclesV1XML() throws IOException { } @Test - public void testObjectAttributesV1XML_withDtd() throws IOException { + void testObjectAttributesV1XML_withDtd() throws IOException { MatsimFileTypeGuesser g = new MatsimFileTypeGuesser("test/input/org/matsim/utils/objectattributes/objectattributes_withDtd_v1.xml"); assertEquals(MatsimFileTypeGuesser.FileType.ObjectAttributes, g.getGuessedFileType()); assertNull(g.getPublicId()); @@ -142,7 +142,7 @@ public void testObjectAttributesV1XML_withDtd() throws IOException { } @Test - public void testObjectAttributesV1XML_withoutDtd() throws IOException { + void testObjectAttributesV1XML_withoutDtd() throws IOException { MatsimFileTypeGuesser g = new MatsimFileTypeGuesser("test/input/org/matsim/utils/objectattributes/objectattributes_withoutDtd_v1.xml"); assertEquals(MatsimFileTypeGuesser.FileType.ObjectAttributes, g.getGuessedFileType()); assertNull(g.getPublicId()); @@ -150,7 +150,7 @@ public void testObjectAttributesV1XML_withoutDtd() throws IOException { } @Test - public void testNotExistant() { + void testNotExistant() { try { new MatsimFileTypeGuesser("examples/equil/dummy.xml"); fail("expected IOException"); diff --git a/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlParserTest.java b/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlParserTest.java index 972b0a99be4..7f692064d1d 100644 --- a/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlParserTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlParserTest.java @@ -20,8 +20,8 @@ package org.matsim.core.utils.io; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.jupiter.api.io.TempDir; import org.junit.rules.TemporaryFolder; import org.xml.sax.Attributes; @@ -48,7 +48,7 @@ public class MatsimXmlParserTest { public File tempFolder; @Test - public void testParsingReservedEntities_AttributeValue() { + void testParsingReservedEntities_AttributeValue() { String str = "\n" + "content"; @@ -66,7 +66,7 @@ public void testParsingReservedEntities_AttributeValue() { } @Test - public void testParsingReservedEntities_Content() { + void testParsingReservedEntities_Content() { String str = "\n" + "content"&<>content"; @@ -88,7 +88,7 @@ public void testParsingReservedEntities_Content() { * Based on a (non-reproducible) bug message on the users-mailing list 2012-04-26. */ @Test - public void testParsing_WindowsLinebreaks() { + void testParsing_WindowsLinebreaks() { String str = """ \r \r @@ -134,7 +134,7 @@ public void endTag(String name, String content, Stack context) { } @Test - public void testParsingPlusSign() { + void testParsingPlusSign() { String str = "\n" + "content+content"; @@ -152,7 +152,7 @@ public void testParsingPlusSign() { } @Test - public void testParse_parseEntities() { + void testParse_parseEntities() { String xml = """ context) { } @Test - public void testParse_dtdValidation() { + void testParse_dtdValidation() { String xml = """ @@ -220,7 +220,7 @@ public void endTag(String name, String content, Stack context) { } @Test - public void testParse_xsdValidationSuccess() { + void testParse_xsdValidationSuccess() { String xml = """ @@ -255,7 +255,7 @@ public void endTag(String name, String content, Stack context) { } @Test - public void testParse_xsdValidationFailure() { + void testParse_xsdValidationFailure() { String xml = """ @@ -298,7 +298,7 @@ public void endTag(String name, String content, Stack context) { } @Test - public void testParse_preventXEEattack_woodstox() throws IOException { + void testParse_preventXEEattack_woodstox() throws IOException { // XEE: XML eXternal Entity attack: https://en.wikipedia.org/wiki/XML_external_entity_attack String secretValue = "S3CR3T"; @@ -345,7 +345,7 @@ public void endTag(String name, String content, Stack context) { } @Test - public void testParse_preventXEEattack_xerces() throws IOException { + void testParse_preventXEEattack_xerces() throws IOException { // XEE: XML eXternal Entity attack: https://en.wikipedia.org/wiki/XML_external_entity_attack String secretValue = "S3CR3T"; diff --git a/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlWriterTest.java b/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlWriterTest.java index 9616d6108ef..031e405293e 100644 --- a/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlWriterTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlWriterTest.java @@ -1,12 +1,12 @@ package org.matsim.core.utils.io; -import org.junit.Test; - import java.io.ByteArrayOutputStream; import java.util.List; import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; + /** * @author mrieser / Simunto */ @@ -18,7 +18,7 @@ public class MatsimXmlWriterTest { * special values like infinity and not-a-number must be written as "INF", "-INF" and "NaN". */ @Test - public void testWriteInfiniteValuesInAttributes() { + void testWriteInfiniteValuesInAttributes() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DummyXmlWriter writer = new DummyXmlWriter(); diff --git a/matsim/src/test/java/org/matsim/core/utils/io/OsmNetworkReaderTest.java b/matsim/src/test/java/org/matsim/core/utils/io/OsmNetworkReaderTest.java index a43441e5c8f..b307e54c47d 100644 --- a/matsim/src/test/java/org/matsim/core/utils/io/OsmNetworkReaderTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/io/OsmNetworkReaderTest.java @@ -20,8 +20,8 @@ package org.matsim.core.utils.io; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -44,7 +44,7 @@ public class OsmNetworkReaderTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testConversion() { + void testConversion() { String filename = this.utils.getClassInputDirectory() + "adliswil.osm.gz"; Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); @@ -63,7 +63,7 @@ public void testConversion() { } @Test - public void testConversionWithDetails() { + void testConversionWithDetails() { String filename = this.utils.getClassInputDirectory() + "adliswil.osm.gz"; Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); @@ -84,7 +84,7 @@ public void testConversionWithDetails() { } @Test - public void testConversionWithDetails_witMemoryOptimized() { + void testConversionWithDetails_witMemoryOptimized() { String filename = this.utils.getClassInputDirectory() + "adliswil.osm.gz"; Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); @@ -106,7 +106,7 @@ public void testConversionWithDetails_witMemoryOptimized() { } @Test - public void testConversionWithSettings() { + void testConversionWithSettings() { String filename = this.utils.getClassInputDirectory() + "adliswil.osm.gz"; Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); @@ -127,7 +127,7 @@ public void testConversionWithSettings() { } @Test - public void testConversionWithSettings_withMemoryOptimization() { + void testConversionWithSettings_withMemoryOptimization() { String filename = this.utils.getClassInputDirectory() + "adliswil.osm.gz"; Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); @@ -148,7 +148,7 @@ public void testConversionWithSettings_withMemoryOptimization() { } @Test - public void testConversionWithSettingsAndDetails() { + void testConversionWithSettingsAndDetails() { String filename = this.utils.getClassInputDirectory() + "adliswil.osm.gz"; Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); @@ -169,7 +169,7 @@ public void testConversionWithSettingsAndDetails() { } @Test - public void testConversion_MissingNodeRef() { + void testConversion_MissingNodeRef() { Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network net = sc.getNetwork(); CoordinateTransformation ct = new IdentityTransformation(); @@ -200,7 +200,7 @@ public void testConversion_MissingNodeRef() { } @Test - public void testConversion_maxspeeds() { + void testConversion_maxspeeds() { Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network net = sc.getNetwork(); CoordinateTransformation ct = new IdentityTransformation(); @@ -261,7 +261,7 @@ public void testConversion_maxspeeds() { * Reported by jjoubert,15nov2012. */ @Test - public void testConversion_emptyWay() { + void testConversion_emptyWay() { Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network net = sc.getNetwork(); CoordinateTransformation ct = new IdentityTransformation(); diff --git a/matsim/src/test/java/org/matsim/core/utils/io/XmlUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/io/XmlUtilsTest.java index e5d979ba8ca..1923fddcfae 100644 --- a/matsim/src/test/java/org/matsim/core/utils/io/XmlUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/io/XmlUtilsTest.java @@ -20,7 +20,7 @@ package org.matsim.core.utils.io; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author mrieser @@ -28,7 +28,7 @@ public class XmlUtilsTest { @Test - public void testEncodeAttributeValue() { + void testEncodeAttributeValue() { Assert.assertEquals("hello world!", XmlUtils.encodeAttributeValue("hello world!")); Assert.assertEquals("you & me", XmlUtils.encodeAttributeValue("you & me")); Assert.assertEquals("you & me & her", XmlUtils.encodeAttributeValue("you & me & her")); @@ -39,7 +39,7 @@ public void testEncodeAttributeValue() { } @Test - public void testEncodedContent() { + void testEncodedContent() { Assert.assertEquals("hello world!", XmlUtils.encodeContent("hello world!")); Assert.assertEquals("you & me", XmlUtils.encodeContent("you & me")); Assert.assertEquals("you & me & her", XmlUtils.encodeContent("you & me & her")); diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/ArgumentParserTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/ArgumentParserTest.java index 8b30ecbdf30..3e4e9948379 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/ArgumentParserTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/ArgumentParserTest.java @@ -26,8 +26,8 @@ import java.util.Iterator; import java.util.NoSuchElementException; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -44,7 +44,8 @@ public class ArgumentParserTest { /** * Test if regular arguments (no options) are correctly recognized. */ - @Test public void testArguments() { + @Test + void testArguments() { ArgumentParser parser = new ArgumentParser( new String[] {"a", "bc", "def=g", "hjk=lmn opq"}); Iterator iter = parser.iterator(); @@ -58,7 +59,8 @@ public class ArgumentParserTest { /** * Test if short options (beginning with '-'), which can be written in a collapsed form, are correctly recognized. */ - @Test public void testShortOptions() { + @Test + void testShortOptions() { ArgumentParser parser = new ArgumentParser( new String[] {"-a", "-b", "-cd", "-efg", "-h=j", "-kl=m", "-nop=qrs", "-tu=vw xyz", "=", "-", "-=", "-1", "-2=", "-=3", "-=4=5"}, true); Iterator iter = parser.iterator(); @@ -96,7 +98,8 @@ public class ArgumentParserTest { /** * Test if long options (beginning with '--') are correctly recognized. */ - @Test public void testLongOptions() { + @Test + void testLongOptions() { ArgumentParser parser = new ArgumentParser( new String[] {"--a", "--bc", "--def=ghj", "--kl=mn op", "=", "--qr=", "--=", "--=st", "--=uv=wxy z"}, true); Iterator iter = parser.iterator(); @@ -118,7 +121,8 @@ public class ArgumentParserTest { /** * Test if a mix of arguments and options are correctly recognized. */ - @Test public void testMixed() { + @Test + void testMixed() { // first test it with short arguments enabled ArgumentParser parser = new ArgumentParser( new String[] {"-xcf", "myfile.tgz", "file1", "file2", "--verbose"}, true); diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/ByteBufferUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/ByteBufferUtilsTest.java index 8741b572cd5..2325de69101 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/ByteBufferUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/ByteBufferUtilsTest.java @@ -26,8 +26,8 @@ import java.io.Serializable; import java.nio.ByteBuffer; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -43,7 +43,8 @@ public class ByteBufferUtilsTest { * Tests {@link ByteBufferUtils#putString(java.nio.ByteBuffer, String)} and * {@link ByteBufferUtils#getString(java.nio.ByteBuffer)}. */ - @Test public void testPutGetString() { + @Test + void testPutGetString() { final ByteBuffer buffer = ByteBuffer.allocate(100); buffer.putInt(5); ByteBufferUtils.putString(buffer, "foo bar"); @@ -65,7 +66,8 @@ public class ByteBufferUtilsTest { * Tests {@link ByteBufferUtils#putObject(java.nio.ByteBuffer, Serializable)} and * {@link ByteBufferUtils#getObject(java.nio.ByteBuffer)}. */ - @Test public void testPutGetObject() { + @Test + void testPutGetObject() { final ByteBuffer buffer = ByteBuffer.allocate(100); buffer.putInt(5); ByteBufferUtils.putObject(buffer, "foo bar"); diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/ClassUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/ClassUtilsTest.java index 1f0b5bb0642..de4b6b6bb0c 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/ClassUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/ClassUtilsTest.java @@ -22,7 +22,7 @@ import java.util.Set; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author mrieser @@ -30,14 +30,14 @@ public class ClassUtilsTest { @Test - public void testInterfaceNoInheritance() { + void testInterfaceNoInheritance() { Set> set = ClassUtils.getAllTypes(A.class); Assert.assertEquals(1, set.size()); Assert.assertTrue(set.contains(A.class)); } @Test - public void testClassNoInheritance() { + void testClassNoInheritance() { Set> set = ClassUtils.getAllTypes(Z.class); Assert.assertEquals(2, set.size()); Assert.assertTrue(set.contains(Z.class)); @@ -45,7 +45,7 @@ public void testClassNoInheritance() { } @Test - public void testInterfaceSingleInheritance() { + void testInterfaceSingleInheritance() { Set> set = ClassUtils.getAllTypes(B.class); Assert.assertEquals(2, set.size()); Assert.assertTrue(set.contains(A.class)); @@ -53,7 +53,7 @@ public void testInterfaceSingleInheritance() { } @Test - public void testClassSingleInheritance() { + void testClassSingleInheritance() { Set> set = ClassUtils.getAllTypes(Y.class); Assert.assertEquals(3, set.size()); Assert.assertTrue(set.contains(Z.class)); @@ -62,7 +62,7 @@ public void testClassSingleInheritance() { } @Test - public void testInterfaceMultipleInheritance_SingleLevel() { + void testInterfaceMultipleInheritance_SingleLevel() { Set> set = ClassUtils.getAllTypes(AB.class); Assert.assertEquals(3, set.size()); Assert.assertTrue(set.contains(A.class)); @@ -71,7 +71,7 @@ public void testInterfaceMultipleInheritance_SingleLevel() { } @Test - public void testInterfaceMultipleInheritance_MultipleLevel() { + void testInterfaceMultipleInheritance_MultipleLevel() { Set> set = ClassUtils.getAllTypes(C.class); Assert.assertEquals(3, set.size()); Assert.assertTrue(set.contains(A.class)); @@ -80,7 +80,7 @@ public void testInterfaceMultipleInheritance_MultipleLevel() { } @Test - public void testClassMultipleInheritance_MultipleLevel() { + void testClassMultipleInheritance_MultipleLevel() { Set> set = ClassUtils.getAllTypes(X.class); Assert.assertEquals(4, set.size()); Assert.assertTrue(set.contains(Z.class)); @@ -90,7 +90,7 @@ public void testClassMultipleInheritance_MultipleLevel() { } @Test - public void testSingleInterfaceImplementation() { + void testSingleInterfaceImplementation() { Set> set = ClassUtils.getAllTypes(Aimpl.class); Assert.assertEquals(3, set.size()); Assert.assertTrue(set.contains(Aimpl.class)); @@ -99,7 +99,7 @@ public void testSingleInterfaceImplementation() { } @Test - public void testSingleInterfaceImplementation_MultipleLevel() { + void testSingleInterfaceImplementation_MultipleLevel() { Set> set = ClassUtils.getAllTypes(Bimpl.class); Assert.assertEquals(4, set.size()); Assert.assertTrue(set.contains(Bimpl.class)); @@ -109,7 +109,7 @@ public void testSingleInterfaceImplementation_MultipleLevel() { } @Test - public void testMultipleInterfaceImplementation() { + void testMultipleInterfaceImplementation() { Set> set = ClassUtils.getAllTypes(ABimpl.class); Assert.assertEquals(4, set.size()); Assert.assertTrue(set.contains(ABimpl.class)); @@ -119,7 +119,7 @@ public void testMultipleInterfaceImplementation() { } @Test - public void testComplexClass() { + void testComplexClass() { Set> set = ClassUtils.getAllTypes(Dimpl.class); Assert.assertEquals(5, set.size()); Assert.assertTrue(set.contains(Dimpl.class)); diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java index cf2e00940eb..383eba26f43 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java @@ -25,8 +25,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.utils.io.IOUtils; @@ -44,14 +44,14 @@ public class ConfigUtilsTest { private MatsimTestUtils util = new MatsimTestUtils(); @Test - public void testLoadConfig_filenameOnly() throws IOException { + void testLoadConfig_filenameOnly() throws IOException { Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); Assert.assertNotNull(config); Assert.assertEquals("network.xml", config.network().getInputFile()); } @Test - public void testLoadConfig_emptyConfig() throws IOException { + void testLoadConfig_emptyConfig() throws IOException { Config config = new Config(); Assert.assertNull(config.network()); ConfigUtils.loadConfig(config, IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); @@ -60,7 +60,7 @@ public void testLoadConfig_emptyConfig() throws IOException { } @Test - public void testLoadConfig_preparedConfig() throws IOException { + void testLoadConfig_preparedConfig() throws IOException { Config config = new Config(); config.addCoreModules(); Assert.assertNotNull(config.network()); @@ -70,7 +70,7 @@ public void testLoadConfig_preparedConfig() throws IOException { } @Test - public void testModifyPaths_missingSeparator() throws IOException { + void testModifyPaths_missingSeparator() throws IOException { Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); Assert.assertEquals("network.xml", config.network().getInputFile()); ConfigUtils.modifyFilePaths(config, "/home/username/matsim"); @@ -79,7 +79,7 @@ public void testModifyPaths_missingSeparator() throws IOException { } @Test - public void testModifyPaths_withSeparator() throws IOException { + void testModifyPaths_withSeparator() throws IOException { Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); Assert.assertEquals("network.xml", config.network().getInputFile()); ConfigUtils.modifyFilePaths(config, "/home/username/matsim/"); @@ -87,14 +87,15 @@ public void testModifyPaths_withSeparator() throws IOException { } @Test - public void loadConfigWithTypedArgs(){ + void loadConfigWithTypedArgs(){ final URL url = IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ); final String [] typedArgs = {"--config:controler.outputDirectory=abc"} ; Config config = ConfigUtils.loadConfig( url, typedArgs ); Assert.assertEquals("abc", config.controller().getOutputDirectory()); } + @Test - public void loadConfigWithTypedArgsWithTypo(){ + void loadConfigWithTypedArgsWithTypo(){ boolean hasFailed = false ; try{ final URL url = IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ); diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/NetworkUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/NetworkUtilsTest.java index 23f22a269ea..8f9caadb543 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/NetworkUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/NetworkUtilsTest.java @@ -28,10 +28,9 @@ import java.util.List; import org.junit.Assert; - +import org.junit.jupiter.api.Test; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -51,7 +50,7 @@ public class NetworkUtilsTest { private final static double EPSILON = 1e-8; @Test - public void testGetNodes_Empty() { + void testGetNodes_Empty() { Network network = getTestNetwork(); List nodes = NetworkUtils.getNodes(network, ""); assertEquals(0, nodes.size()); @@ -64,14 +63,14 @@ public void testGetNodes_Empty() { } @Test - public void testGetNodes_Null() { + void testGetNodes_Null() { Network network = getTestNetwork(); List nodes = NetworkUtils.getNodes(network, null); assertEquals(0, nodes.size()); } @Test - public void testGetNodes_mixedDelimiters() { + void testGetNodes_mixedDelimiters() { Network network = getTestNetwork(); List nodes = NetworkUtils.getNodes(network, " 1\t\t2 \n4\t \t5 3 "); assertEquals(5, nodes.size()); @@ -83,7 +82,7 @@ public void testGetNodes_mixedDelimiters() { } @Test - public void testGetNodes_NonExistant() { + void testGetNodes_NonExistant() { Network network = getTestNetwork(); try { NetworkUtils.getNodes(network, "1 3 ab 5"); @@ -94,7 +93,7 @@ public void testGetNodes_NonExistant() { } @Test - public void testGetLinks_Empty() { + void testGetLinks_Empty() { Network network = getTestNetwork(); List links = NetworkUtils.getLinks(network, ""); assertEquals(0, links.size()); @@ -107,14 +106,14 @@ public void testGetLinks_Empty() { } @Test - public void testGetLinks_StringNull() { + void testGetLinks_StringNull() { Network network = getTestNetwork(); List links = NetworkUtils.getLinks(network, (String)null); assertEquals(0, links.size()); } @Test - public void testGetLinks_mixedDelimiters() { + void testGetLinks_mixedDelimiters() { Network network = getTestNetwork(); List links = NetworkUtils.getLinks(network, " 1\t\t2 \n4\t \t 3 "); assertEquals(4, links.size()); @@ -125,7 +124,7 @@ public void testGetLinks_mixedDelimiters() { } @Test - public void testGetLinks_NonExistant() { + void testGetLinks_NonExistant() { Network network = getTestNetwork(); try { NetworkUtils.getLinks(network, "1 3 ab 4"); @@ -136,19 +135,19 @@ public void testGetLinks_NonExistant() { } @Test - public void testGetLinksID_ListNull() { + void testGetLinksID_ListNull() { List> linkIds = NetworkUtils.getLinkIds((List) null); assertEquals(0, linkIds.size()); } @Test - public void testGetLinksID_StringNull() { + void testGetLinksID_StringNull() { List> linkIds = NetworkUtils.getLinkIds((String) null); assertEquals(0, linkIds.size()); } @Test - public void testGetNumberOfLanesAsInt() { + void testGetNumberOfLanesAsInt() { assertEquals(3, NetworkUtils.getNumberOfLanesAsInt(7*3600, new PseudoLink(3.2))); assertEquals(3, NetworkUtils.getNumberOfLanesAsInt(7*3600, new PseudoLink(3.1))); assertEquals(3, NetworkUtils.getNumberOfLanesAsInt(7*3600, new PseudoLink(3.0))); @@ -179,7 +178,7 @@ public void testGetNumberOfLanesAsInt() { } @Test - public void testGetBoundingBox() { + void testGetBoundingBox() { Collection nodes = new ArrayList(); Id id = Id.create("dummy", Node.class); nodes.add(new PseudoNode(id, new Coord((double) 100, (double) 100))); @@ -195,7 +194,7 @@ public void testGetBoundingBox() { } @Test - public void testGetBoundingBox_negativeNodesOnly() { + void testGetBoundingBox_negativeNodesOnly() { Collection nodes = new ArrayList(); Id id = Id.create("dummy", Node.class); final double x4 = -100; @@ -221,7 +220,7 @@ public void testGetBoundingBox_negativeNodesOnly() { } @Test - public void testIsMultimodal_carOnly() { + void testIsMultimodal_carOnly() { MultimodalFixture f = new MultimodalFixture(); for (Link l : f.links) { l.setAllowedModes(CollectionUtils.stringToSet("car")); @@ -230,7 +229,7 @@ public void testIsMultimodal_carOnly() { } @Test - public void testIsMultimodal_walkOnly() { + void testIsMultimodal_walkOnly() { // tests that isMultimodal is not somehow hard-coded on "car" MultimodalFixture f = new MultimodalFixture(); for (Link l : f.links) { @@ -240,7 +239,7 @@ public void testIsMultimodal_walkOnly() { } @Test - public void testIsMultimodal_2modesOnSingleLink() { + void testIsMultimodal_2modesOnSingleLink() { MultimodalFixture f = new MultimodalFixture(); for (Link l : f.links) { l.setAllowedModes(CollectionUtils.stringToSet("car")); @@ -250,7 +249,7 @@ public void testIsMultimodal_2modesOnSingleLink() { } @Test - public void testIsMultimodal_2modesOnDifferentLinks() { + void testIsMultimodal_2modesOnDifferentLinks() { MultimodalFixture f = new MultimodalFixture(); for (Link l : f.links) { l.setAllowedModes(CollectionUtils.stringToSet("car")); @@ -260,7 +259,7 @@ public void testIsMultimodal_2modesOnDifferentLinks() { } @Test - public void testIsMultimodal_3modes() { + void testIsMultimodal_3modes() { MultimodalFixture f = new MultimodalFixture(); for (Link l : f.links) { l.setAllowedModes(CollectionUtils.stringToSet("car")); @@ -270,7 +269,7 @@ public void testIsMultimodal_3modes() { } @Test - public void testIsMultimodal_onlyNoModes() { + void testIsMultimodal_onlyNoModes() { MultimodalFixture f = new MultimodalFixture(); for (Link l : f.links) { l.setAllowedModes(CollectionUtils.stringToSet("")); @@ -279,7 +278,7 @@ public void testIsMultimodal_onlyNoModes() { } @Test - public void testIsMultimodal_sometimesNoModes() { + void testIsMultimodal_sometimesNoModes() { MultimodalFixture f = new MultimodalFixture(); for (Link l : f.links) { l.setAllowedModes(CollectionUtils.stringToSet("car")); @@ -289,7 +288,7 @@ public void testIsMultimodal_sometimesNoModes() { } @Test - public void testGetConnectingLink() { + void testGetConnectingLink() { Network net = getTestNetwork(); Node node1 = net.getNodes().get(Id.create(1, Node.class)); Node node2 = net.getNodes().get(Id.create(2, Node.class)); diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/OptionalTimeTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/OptionalTimeTest.java index 956184dbb2f..2dea7df7cf5 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/OptionalTimeTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/OptionalTimeTest.java @@ -26,14 +26,14 @@ import java.util.function.Supplier; import org.apache.commons.lang3.mutable.MutableDouble; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Michal Maciejewski (michalm) */ public class OptionalTimeTest { @Test - public void test_defined_seconds() { + void test_defined_seconds() { //defined assertThat(OptionalTime.defined(0).seconds()).isEqualTo(0); assertThat(OptionalTime.defined(1).seconds()).isEqualTo(1); @@ -50,7 +50,7 @@ public void test_defined_seconds() { } @Test - public void test_undefined_seconds() { + void test_undefined_seconds() { assertThat(OptionalTime.undefined().isUndefined()).isTrue(); assertThatThrownBy(() -> OptionalTime.undefined().seconds()).isExactlyInstanceOf(NoSuchElementException.class) @@ -58,38 +58,38 @@ public void test_undefined_seconds() { } @Test - public void test_cachedValues() { + void test_cachedValues() { //currently 0 and undefined are cached assertThat(OptionalTime.defined(0)).isSameAs(OptionalTime.defined(0)); assertThat(OptionalTime.undefined()).isSameAs(OptionalTime.undefined()); } @Test - public void test_isUndefined() { + void test_isUndefined() { assertThat(OptionalTime.undefined().isUndefined()).isTrue(); assertThat(OptionalTime.defined(1).isUndefined()).isFalse(); } @Test - public void test_isDefined() { + void test_isDefined() { assertThat(OptionalTime.undefined().isDefined()).isFalse(); assertThat(OptionalTime.defined(1).isDefined()).isTrue(); } @Test - public void test_orElse() { + void test_orElse() { assertThat(OptionalTime.undefined().orElse(0)).isEqualTo(0); assertThat(OptionalTime.defined(1).orElse(0)).isEqualTo(1); } @Test - public void test_orElseGet() { + void test_orElseGet() { assertThat(OptionalTime.undefined().orElseGet(() -> 0)).isEqualTo(0); assertThat(OptionalTime.defined(1).orElseGet(() -> 0)).isEqualTo(1); } @Test - public void test_orElseThrow() { + void test_orElseThrow() { assertThatThrownBy(() -> OptionalTime.undefined() .orElseThrow(() -> new IllegalStateException("Undefined time error"))).isExactlyInstanceOf( IllegalStateException.class).hasMessage("Undefined time error"); @@ -99,7 +99,7 @@ public void test_orElseThrow() { } @Test - public void test_ifDefined() { + void test_ifDefined() { MutableDouble counter = new MutableDouble(0); OptionalTime.undefined().ifDefined(counter::add); @@ -110,7 +110,7 @@ public void test_ifDefined() { } @Test - public void test_ifDefinedOrElse() { + void test_ifDefinedOrElse() { MutableDouble ifCounter = new MutableDouble(0); MutableDouble elseCounter = new MutableDouble(0); @@ -124,14 +124,14 @@ public void test_ifDefinedOrElse() { } @Test - public void test_stream() { + void test_stream() { assertThat(OptionalTime.undefined().stream()).containsExactly(); assertThat(OptionalTime.defined(0).stream()).containsExactly(0.); assertThat(OptionalTime.defined(10).stream()).containsExactly(10.); } @Test - public void test_or_OptionalTime() { + void test_or_OptionalTime() { assertThat(OptionalTime.undefined().or(OptionalTime.undefined()).isUndefined()).isTrue(); assertThat(OptionalTime.undefined().or(OptionalTime.defined(3)).seconds()).isEqualTo(3); assertThat(OptionalTime.defined(1).or(OptionalTime.undefined()).seconds()).isEqualTo(1); @@ -142,7 +142,7 @@ public void test_or_OptionalTime() { } @Test - public void test_or_OptionalTimeSupplier() { + void test_or_OptionalTimeSupplier() { assertThat(OptionalTime.undefined().or(OptionalTime::undefined).isUndefined()).isTrue(); assertThat(OptionalTime.undefined().or(() -> OptionalTime.defined(3)).seconds()).isEqualTo(3); assertThat(OptionalTime.defined(1).or(OptionalTime::undefined).seconds()).isEqualTo(1); @@ -155,7 +155,7 @@ public void test_or_OptionalTimeSupplier() { } @Test - public void test_equals() { + void test_equals() { assertThat(OptionalTime.undefined()).isEqualTo(OptionalTime.undefined()); assertThat(OptionalTime.undefined()).isNotEqualTo(OptionalTime.defined(0)); @@ -165,7 +165,7 @@ public void test_equals() { } @Test - public void test_hashCode() { + void test_hashCode() { assertThat(OptionalTime.undefined()).hasSameHashCodeAs(Time.UNDEFINED_TIME); assertThat(OptionalTime.defined(0)).hasSameHashCodeAs(0.); assertThat(OptionalTime.defined(-Double.MAX_VALUE)).hasSameHashCodeAs(-Double.MAX_VALUE); diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/OptionalTimesTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/OptionalTimesTest.java index 5010c22a8f2..b651884bb2e 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/OptionalTimesTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/OptionalTimesTest.java @@ -23,14 +23,14 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Michal Maciejewski (michalm) */ public class OptionalTimesTest { @Test - public void requireDefined() { + void requireDefined() { assertThatThrownBy(() -> OptionalTimes.requireDefined(OptionalTime.undefined())).isExactlyInstanceOf( IllegalArgumentException.class).hasMessage("Time must be defined"); diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/PopulationUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/PopulationUtilsTest.java index 6e5a02f746e..5f30320cbd3 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/PopulationUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/PopulationUtilsTest.java @@ -21,8 +21,8 @@ import java.util.List; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -51,7 +51,7 @@ public class PopulationUtilsTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; @Test - public void testLegOverlap() { + void testLegOverlap() { Fixture f = new Fixture() ; List legs1 = PopulationUtils.getLegs(f.plan1) ; List legs2 = PopulationUtils.getLegs(f.plan2); @@ -68,7 +68,7 @@ public void testLegOverlap() { } @Test - public void testActivityOverlap() { + void testActivityOverlap() { Fixture f = new Fixture() ; List acts1 = PopulationUtils.getActivities(f.plan1, StageActivityHandling.StagesAsNormalActivities ) ; List acts2 = PopulationUtils.getActivities(f.plan2, StageActivityHandling.StagesAsNormalActivities ) ; @@ -150,14 +150,14 @@ private static class Fixture { } @Test - public void testEmptyPopulation() { + void testEmptyPopulation() { Scenario s1 = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario s2 = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Assert.assertTrue(PopulationUtils.equalPopulation(s1.getPopulation(), s2.getPopulation())); } @Test - public void testEmptyPopulationVsOnePerson() { + void testEmptyPopulationVsOnePerson() { Scenario s1 = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario s2 = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Person person = s2.getPopulation().getFactory().createPerson(Id.create("1", Person.class)); @@ -167,7 +167,7 @@ public void testEmptyPopulationVsOnePerson() { } @Test - public void testCompareBigPopulationWithItself() { + void testCompareBigPopulationWithItself() { Scenario s1 = ScenarioUtils.createScenario(ConfigUtils.createConfig()); String netFileName = "test/scenarios/berlin/network.xml"; String popFileName = "test/scenarios/berlin/plans_hwh_1pct.xml.gz"; diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/RouteUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/RouteUtilsTest.java index f0977d0396c..01c37c7d52f 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/RouteUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/RouteUtilsTest.java @@ -24,7 +24,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -40,9 +40,9 @@ import org.matsim.testcases.MatsimTestUtils; public class RouteUtilsTest { - + @Test - public void testCalculateCoverage() { + void testCalculateCoverage() { Fixture f = new Fixture(); f.network.getLinks().get(f.linkIds[0]).setLength(100.0); f.network.getLinks().get(f.linkIds[1]).setLength(200.0); @@ -85,7 +85,7 @@ public void testCalculateCoverage() { } @Test - public void testGetNodes() { + void testGetNodes() { Fixture f = new Fixture(); Link startLink = f.network.getLinks().get(f.linkIds[0]); Link endLink = f.network.getLinks().get(f.linkIds[5]); @@ -104,7 +104,7 @@ public void testGetNodes() { } @Test - public void testGetNodes_SameStartEndLink() { + void testGetNodes_SameStartEndLink() { Fixture f = new Fixture(); Link startLink = f.network.getLinks().get(f.linkIds[2]); Link endLink = f.network.getLinks().get(f.linkIds[2]); @@ -117,7 +117,7 @@ public void testGetNodes_SameStartEndLink() { } @Test - public void testGetNodes_NoLinksBetween() { + void testGetNodes_NoLinksBetween() { Fixture f = new Fixture(); Id startLinkId = f.linkIds[3]; Id endLinkId = f.linkIds[4]; @@ -131,7 +131,7 @@ public void testGetNodes_NoLinksBetween() { } @Test - public void testGetNodes_CircularRoute() { + void testGetNodes_CircularRoute() { Fixture f = new Fixture(); Id id99 = Id.create("99", Link.class); f.network.addLink(f.network.getFactory().createLink(id99, f.network.getNodes().get(f.nodeIds[6]), f.network.getNodes().get(f.nodeIds[0]))); @@ -155,7 +155,7 @@ public void testGetNodes_CircularRoute() { } @Test - public void testGetLinksFromNodes() { + void testGetLinksFromNodes() { Fixture f = new Fixture(); ArrayList nodes = new ArrayList(); List links = RouteUtils.getLinksFromNodes(nodes); @@ -186,7 +186,7 @@ public void testGetLinksFromNodes() { } @Test - public void testGetSubRoute() { + void testGetSubRoute() { Fixture f = new Fixture(); NetworkRoute route = RouteUtils.createLinkNetworkRouteImpl(f.linkIds[0], f.linkIds[5]); List> linkIds = new ArrayList>(); @@ -202,7 +202,7 @@ public void testGetSubRoute() { } @Test - public void testGetSubRoute_fullRoute() { + void testGetSubRoute_fullRoute() { Fixture f = new Fixture(); NetworkRoute route = RouteUtils.createLinkNetworkRouteImpl(f.linkIds[0], f.linkIds[5]); List> linkIds = new ArrayList>(); @@ -220,7 +220,7 @@ public void testGetSubRoute_fullRoute() { } @Test - public void testGetSubRoute_emptySubRoute() { + void testGetSubRoute_emptySubRoute() { Fixture f = new Fixture(); NetworkRoute route = RouteUtils.createLinkNetworkRouteImpl(f.linkIds[0], f.linkIds[5]); List> linkIds = new ArrayList>(); @@ -234,7 +234,7 @@ public void testGetSubRoute_emptySubRoute() { } @Test - public void testGetSubRoute_sameStartEnd() { + void testGetSubRoute_sameStartEnd() { Fixture f = new Fixture(); NetworkRoute route = RouteUtils.createLinkNetworkRouteImpl(f.linkIds[0], f.linkIds[5]); List> linkIds = new ArrayList>(); @@ -248,7 +248,7 @@ public void testGetSubRoute_sameStartEnd() { } @Test - public void testCalcDistance() { + void testCalcDistance() { Fixture f = new Fixture(); f.network.getLinks().get(f.linkIds[0]).setLength(100.0); f.network.getLinks().get(f.linkIds[1]).setLength(200.0); @@ -270,7 +270,7 @@ public void testCalcDistance() { } @Test - public void testCalcDistance_sameStartEndRoute() { + void testCalcDistance_sameStartEndRoute() { Fixture f = new Fixture(); f.network.getLinks().get(f.linkIds[0]).setLength(100.0); f.network.getLinks().get(f.linkIds[1]).setLength(200.0); @@ -287,7 +287,7 @@ public void testCalcDistance_sameStartEndRoute() { } @Test - public void testCalcDistance_subsequentStartEndRoute() { + void testCalcDistance_subsequentStartEndRoute() { Fixture f = new Fixture(); f.network.getLinks().get(f.linkIds[0]).setLength(100.0); f.network.getLinks().get(f.linkIds[1]).setLength(200.0); @@ -303,7 +303,7 @@ public void testCalcDistance_subsequentStartEndRoute() { } @Test - public void testCalcDistance_oneLinkRoute() { + void testCalcDistance_oneLinkRoute() { Fixture f = new Fixture(); f.network.getLinks().get(f.linkIds[0]).setLength(100.0); f.network.getLinks().get(f.linkIds[1]).setLength(200.0); diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/StringUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/StringUtilsTest.java index 873fad98d90..b4048bb20f6 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/StringUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/StringUtilsTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -41,7 +41,8 @@ public class StringUtilsTest { * Tests the method explode(String, char), which should always return the same as * String.split(String) does. */ - @Test public void testExplode() { + @Test + void testExplode() { String[] testStrings = {"a:b", "ab:cd", "ab::cd", ":ab:cd", "ab:cd:", ":ab:cd:", "::ab::cd::", "a", "ab", ""}; for (String test : testStrings) { String[] resultExplode = StringUtils.explode(test, ':'); @@ -57,7 +58,8 @@ public class StringUtilsTest { * Tests the method explode(String, char, int), which should always return the same as * String.split(String, int) does. */ - @Test public void testExplodeLimit() { + @Test + void testExplodeLimit() { String[] testStrings = {"a:b", "a:b:c", "a:b:c:d", "a:::b:c", ":::::", "a", ""}; for (String test : testStrings) { String[] resultExplode = StringUtils.explode(test, ':', 3); diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/TimeTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/TimeTest.java index 56209e8f4a0..1654c1330ba 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/TimeTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/TimeTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests for {@link Time}. @@ -32,7 +32,8 @@ */ public class TimeTest { - @Test public void testFormats() { + @Test + void testFormats() { double time = 12*3600 + 34*60 + 56.789; assertEquals("12:34:56", Time.writeTime(time, Time.TIMEFORMAT_HHMMSS)); assertEquals("12:34", Time.writeTime(time, Time.TIMEFORMAT_HHMM)); @@ -83,7 +84,8 @@ public class TimeTest { } catch (IllegalArgumentException expected) {} } - @Test public void testSeparators() { + @Test + void testSeparators() { // test writing double dTime = 12*3600 + 34*60 + 56.789; assertEquals("12:34:56", Time.writeTime(dTime, ':')); @@ -102,7 +104,8 @@ public class TimeTest { assertEquals(-iTime, Time.parseTime( "-12-34-56", '-').seconds(), 0.0); } - @Test public void testUndefined() { + @Test + void testUndefined() { // test writing assertEquals("undefined", Time.writeTime(OptionalTime.undefined())); @@ -112,7 +115,8 @@ public class TimeTest { assertEquals(OptionalTime.undefined(), Time.parseOptionalTime(null)); } - @Test public void testSetDefault() { + @Test + void testSetDefault() { Time.setDefaultTimeFormat(Time.TIMEFORMAT_HHMMSS); assertEquals("12:34:56", Time.writeTime(12*3600 + 34*60 + 56.789)); Time.setDefaultTimeFormat(Time.TIMEFORMAT_HHMM); @@ -127,7 +131,8 @@ public class TimeTest { // kai/gregor, nov'11) } - @Test public void testWriting() { + @Test + void testWriting() { Time.setDefaultTimeFormat(Time.TIMEFORMAT_HHMMSS); assertEquals( "12:34:56", Time.writeTime( 12*3600 + 34*60 + 56.789));// positive assertEquals( "01:02:03", Time.writeTime( 1*3600 + 2*60 + 3.4)); // positive with leading zero @@ -142,7 +147,8 @@ public class TimeTest { assertEquals("-596523:14:08", Time.writeTime(Integer.MIN_VALUE)); } - @Test public void testParsing() { + @Test + void testParsing() { assertEquals( 12*3600.0 + 34*60.0 + 56.0, Time.parseTime( "12:34:56"), 0.0); assertEquals( 12*3600.0 + 34*60.0 + 56.7, Time.parseTime( "12:34:56.7"), 0.0); assertEquals( 1*3600.0 + 2*60.0 + 3.0, Time.parseTime( "01:02:03"), 0.0); @@ -155,7 +161,8 @@ public class TimeTest { assertEquals(Long.MAX_VALUE, Time.parseTime("2562047788015215:28:07"), 0.0); } - @Test public void testConvertHHMMInteger() { + @Test + void testConvertHHMMInteger() { assertEquals( 12*3600.0 + 34*60.0, Time.convertHHMMInteger(Integer.valueOf("1234")), 0.0); assertEquals( 1*3600.0 + 2*60.0, Time.convertHHMMInteger(Integer.valueOf("0102")), 0.0); } diff --git a/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java b/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java index 58e06bfdf21..51722441ce6 100644 --- a/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java @@ -24,8 +24,8 @@ import java.util.List; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -52,7 +52,8 @@ public class TimeInterpretationTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testIgnoreDelays() { + @Test + void testIgnoreDelays() { Config config = ConfigUtils.createConfig(); config.plans().setTripDurationHandling(TripDurationHandling.ignoreDelays); @@ -72,7 +73,8 @@ public class TimeInterpretationTest { } - @Test public void testShiftActivityEndTime() { + @Test + void testShiftActivityEndTime() { Config config = ConfigUtils.createConfig(); config.plans().setTripDurationHandling(TripDurationHandling.shiftActivityEndTimes); diff --git a/matsim/src/test/java/org/matsim/counts/CountTest.java b/matsim/src/test/java/org/matsim/counts/CountTest.java index 7575c4bd529..7b5194b49c9 100644 --- a/matsim/src/test/java/org/matsim/counts/CountTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountTest.java @@ -25,8 +25,8 @@ import java.util.Iterator; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.testcases.MatsimTestUtils; @@ -43,20 +43,23 @@ public void setUp() throws Exception { this.counts = new Counts<>(); } - @Test public void testCreateVolume() { + @Test + void testCreateVolume() { Count count = counts.createAndAddCount(Id.create(0, Link.class), "1"); Volume volume = count.createVolume(1, 100.0); assertTrue("Creation and initialization of volume failed", volume.getHourOfDayStartingWithOne()==1); assertTrue("Creation and initialization of volume failed", volume.getValue()==100.0); } - @Test public void testGetVolume() { + @Test + void testGetVolume() { Count count = counts.createAndAddCount(Id.create(0, Link.class), "1"); count.createVolume(1, 100.0); assertTrue("Getting volume failed", count.getVolume(1).getValue() == 100.0); } - @Test public void testGetVolumes() { + @Test + void testGetVolumes() { Count count = counts.createAndAddCount(Id.create(0, Link.class), "1"); count.createVolume(1, 100.0); diff --git a/matsim/src/test/java/org/matsim/counts/CountsComparisonAlgorithmTest.java b/matsim/src/test/java/org/matsim/counts/CountsComparisonAlgorithmTest.java index ecefd40d4b1..7e652c0e25a 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsComparisonAlgorithmTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsComparisonAlgorithmTest.java @@ -24,8 +24,8 @@ import java.util.List; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.counts.algorithms.CountsComparisonAlgorithm; import org.matsim.testcases.MatsimTestUtils; @@ -35,7 +35,8 @@ public class CountsComparisonAlgorithmTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testCompare() { + @Test + void testCompare() { CountsFixture fixture = new CountsFixture(); fixture.setUp(); @@ -52,7 +53,8 @@ public class CountsComparisonAlgorithmTest { }//while } - @Test public void testDistanceFilter() { + @Test + void testDistanceFilter() { CountsFixture fixture = new CountsFixture(); fixture.setUp(); diff --git a/matsim/src/test/java/org/matsim/counts/CountsControlerListenerTest.java b/matsim/src/test/java/org/matsim/counts/CountsControlerListenerTest.java index 21b0939f3d8..9327948fec4 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsControlerListenerTest.java @@ -27,8 +27,8 @@ import jakarta.inject.Singleton; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -62,7 +62,7 @@ public class CountsControlerListenerTest { @RegisterExtension private MatsimTestUtils util = new MatsimTestUtils(); @Test - public void testUseVolumesOfIteration() { + void testUseVolumesOfIteration() { Config config = ConfigUtils.createConfig(); Scenario scenario = ScenarioUtils.createScenario(config); CountsControlerListener ccl = new CountsControlerListener(config.global(), scenario.getNetwork(), config.controller(), config.counts(), null, null, null); @@ -249,7 +249,7 @@ public void testUseVolumesOfIteration() { } @Test - public void test_writeCountsInterval() { + void test_writeCountsInterval() { Config config = this.util.createConfig(ExamplesUtils.getTestScenarioURL("triangle")); CountsConfigGroup cConfig = config.counts(); @@ -285,7 +285,7 @@ public void install() { } @Test - public void testReset_CorrectlyExecuted() throws IOException { + void testReset_CorrectlyExecuted() throws IOException { Config config = this.util.createConfig(ExamplesUtils.getTestScenarioURL("triangle")); config.network().setInputFile("network.xml"); // network file which is used by the counts file @@ -326,7 +326,7 @@ public void install() { } @Test - public void testFilterAnalyzedModes() throws IOException { + void testFilterAnalyzedModes() throws IOException { Config config = util.createConfig(ExamplesUtils.getTestScenarioURL("triangle")); config.network().setInputFile("network.xml"); // network file which is used by the counts file diff --git a/matsim/src/test/java/org/matsim/counts/CountsErrorGraphTest.java b/matsim/src/test/java/org/matsim/counts/CountsErrorGraphTest.java index dd1627a5c0e..9b517b8e4e1 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsErrorGraphTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsErrorGraphTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.counts.algorithms.graphs.BoxPlotErrorGraph; import org.matsim.testcases.MatsimTestUtils; @@ -33,7 +33,8 @@ public class CountsErrorGraphTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testCreateChart() { + @Test + void testCreateChart() { CountsFixture fixture = new CountsFixture(); fixture.setUp(); diff --git a/matsim/src/test/java/org/matsim/counts/CountsHtmlAndGraphsWriterTest.java b/matsim/src/test/java/org/matsim/counts/CountsHtmlAndGraphsWriterTest.java index 50dac9c7a41..853f4d548e7 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsHtmlAndGraphsWriterTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsHtmlAndGraphsWriterTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.counts.algorithms.CountsComparisonAlgorithm; import org.matsim.counts.algorithms.CountsHtmlAndGraphsWriter; import org.matsim.counts.algorithms.graphs.CountsErrorGraphCreator; @@ -42,7 +42,8 @@ public class CountsHtmlAndGraphsWriterTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testGraphCreation() { + @Test + void testGraphCreation() { CountsFixture fixture = new CountsFixture(); fixture.setUp(); diff --git a/matsim/src/test/java/org/matsim/counts/CountsLoadCurveGraphTest.java b/matsim/src/test/java/org/matsim/counts/CountsLoadCurveGraphTest.java index 63a2002b7af..b8dc6aecacb 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsLoadCurveGraphTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsLoadCurveGraphTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.counts.algorithms.graphs.CountsLoadCurveGraph; import org.matsim.testcases.MatsimTestUtils; @@ -33,7 +33,8 @@ public class CountsLoadCurveGraphTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testCreateChart() { + @Test + void testCreateChart() { CountsFixture fixture = new CountsFixture(); fixture.setUp(); diff --git a/matsim/src/test/java/org/matsim/counts/CountsParserTest.java b/matsim/src/test/java/org/matsim/counts/CountsParserTest.java index 804c0be2f33..5dabdc4ac08 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsParserTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsParserTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.testcases.MatsimTestUtils; @@ -35,7 +35,8 @@ public class CountsParserTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testSEElementCounts() throws SAXException { + @Test + void testSEElementCounts() throws SAXException { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); MatsimCountsReader reader = new MatsimCountsReader(counts); @@ -53,7 +54,8 @@ public class CountsParserTest { } } - @Test public void testSEElementCountWithoutCoords() throws SAXException { + @Test + void testSEElementCountWithoutCoords() throws SAXException { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); MatsimCountsReader reader = new MatsimCountsReader(counts); @@ -70,7 +72,8 @@ public class CountsParserTest { reader.endElement("", "counts", "counts"); } - @Test public void testSEElementCountWithCoords() throws SAXException { + @Test + void testSEElementCountWithCoords() throws SAXException { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); MatsimCountsReader reader = new MatsimCountsReader(counts); @@ -88,7 +91,8 @@ public class CountsParserTest { reader.endElement("", "counts", "counts"); } - @Test public void testSEElementVolume() throws SAXException { + @Test + void testSEElementVolume() throws SAXException { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); MatsimCountsReader reader = new MatsimCountsReader(counts); diff --git a/matsim/src/test/java/org/matsim/counts/CountsParserWriterTest.java b/matsim/src/test/java/org/matsim/counts/CountsParserWriterTest.java index e548ece2bd0..6c7e2a9e76b 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsParserWriterTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsParserWriterTest.java @@ -27,8 +27,8 @@ import javax.xml.parsers.ParserConfigurationException; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; import org.xml.sax.SAXException; @@ -45,7 +45,7 @@ public class CountsParserWriterTest { * @author ahorni */ @Test - public void testParserWriter() { + void testParserWriter() { CountsFixture fixture = new CountsFixture(); fixture.setUp(); @@ -91,7 +91,7 @@ public void testParserWriter() { * @author mrieser */ @Test - public void testWriteParse_nameIsNull() throws SAXException, ParserConfigurationException, IOException { + void testWriteParse_nameIsNull() throws SAXException, ParserConfigurationException, IOException { CountsFixture f = new CountsFixture(); f.setUp(); f.counts.setName(null); diff --git a/matsim/src/test/java/org/matsim/counts/CountsReaderHandlerImplV1Test.java b/matsim/src/test/java/org/matsim/counts/CountsReaderHandlerImplV1Test.java index 70f99f38dd9..d4214f2485f 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsReaderHandlerImplV1Test.java +++ b/matsim/src/test/java/org/matsim/counts/CountsReaderHandlerImplV1Test.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.testcases.MatsimTestUtils; @@ -34,7 +34,8 @@ public class CountsReaderHandlerImplV1Test { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testSECounts() { + @Test + void testSECounts() { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); CountsReaderMatsimV1 reader = new CountsReaderMatsimV1(counts); @@ -45,7 +46,8 @@ public class CountsReaderHandlerImplV1Test { assertEquals("Counts attribute setting failed", 2000, counts.getYear()); } - @Test public void testSECount() { + @Test + void testSECount() { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); CountsReaderMatsimV1 reader = new CountsReaderMatsimV1(counts); @@ -56,7 +58,8 @@ public class CountsReaderHandlerImplV1Test { assertEquals("Count attribute setting failed", "testNr", counts.getCount(Id.create(1, Link.class)).getCsLabel()); } - @Test public void testSEVolume() { + @Test + void testSEVolume() { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); CountsReaderMatsimV1 reader = new CountsReaderMatsimV1(counts); diff --git a/matsim/src/test/java/org/matsim/counts/CountsReprojectionIOTest.java b/matsim/src/test/java/org/matsim/counts/CountsReprojectionIOTest.java index 627d918b98d..860767a6553 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsReprojectionIOTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsReprojectionIOTest.java @@ -24,8 +24,8 @@ import com.google.inject.Key; import com.google.inject.TypeLiteral; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -38,15 +38,15 @@ import org.matsim.core.utils.geometry.transformations.TransformationFactory; import org.matsim.testcases.MatsimTestUtils; -/** + /** * @author thibautd */ public class CountsReprojectionIOTest { @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void testInput() { + @Test + void testInput() { final String file = utils.getOutputDirectory()+"/counts.xml"; final Counts originalCounts = createDummyCounts(); @@ -58,8 +58,8 @@ public void testInput() { assertCountsAreReprojectedCorrectly( originalCounts , reprojectedCounts ); } - @Test - public void testOutput() { + @Test + void testOutput() { final String file = utils.getOutputDirectory()+"/counts.xml"; final Counts originalCounts = createDummyCounts(); @@ -71,8 +71,8 @@ public void testOutput() { assertCountsAreReprojectedCorrectly( originalCounts , reprojectedCounts ); } - @Test - public void testWithControlerAndConfigParameters() { + @Test + void testWithControlerAndConfigParameters() { final String file = utils.getOutputDirectory()+"/counts.xml"; final Counts originalCounts = createDummyCounts(); diff --git a/matsim/src/test/java/org/matsim/counts/CountsSimRealPerHourGraphTest.java b/matsim/src/test/java/org/matsim/counts/CountsSimRealPerHourGraphTest.java index 93d404cbe68..2df385e8ab3 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsSimRealPerHourGraphTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsSimRealPerHourGraphTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.counts.algorithms.graphs.CountsSimRealPerHourGraph; import org.matsim.testcases.MatsimTestUtils; @@ -33,7 +33,8 @@ public class CountsSimRealPerHourGraphTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testCreateChart() { + @Test + void testCreateChart() { CountsFixture fixture = new CountsFixture(); fixture.setUp(); diff --git a/matsim/src/test/java/org/matsim/counts/CountsTableWriterTest.java b/matsim/src/test/java/org/matsim/counts/CountsTableWriterTest.java index f869f6edaa3..f373db66b6f 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsTableWriterTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsTableWriterTest.java @@ -25,8 +25,8 @@ import java.io.File; import java.util.Locale; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.counts.algorithms.CountSimComparisonTableWriter; import org.matsim.counts.algorithms.CountsComparisonAlgorithm; import org.matsim.testcases.MatsimTestUtils; @@ -38,7 +38,8 @@ public class CountsTableWriterTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testTableCreation() { + @Test + void testTableCreation() { CountsFixture fixture = new CountsFixture(); fixture.setUp(); diff --git a/matsim/src/test/java/org/matsim/counts/CountsTest.java b/matsim/src/test/java/org/matsim/counts/CountsTest.java index af9ae2d6249..f8ee0015e52 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.testcases.MatsimTestUtils; @@ -34,7 +34,8 @@ public class CountsTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testGetCounts() { + @Test + void testGetCounts() { final Counts counts = new Counts(); counts.createAndAddCount(Id.create(0, Link.class), "1"); assertEquals("Getting counts failed", 1, counts.getCounts().size()); diff --git a/matsim/src/test/java/org/matsim/counts/CountsV2Test.java b/matsim/src/test/java/org/matsim/counts/CountsV2Test.java index 46e306ae4d5..3ee67c26678 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsV2Test.java +++ b/matsim/src/test/java/org/matsim/counts/CountsV2Test.java @@ -2,8 +2,8 @@ import org.assertj.core.api.Assertions; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -22,6 +22,7 @@ import java.util.SplittableRandom; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; public class CountsV2Test { @@ -30,7 +31,7 @@ public class CountsV2Test { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void test_general_handling() throws IOException { + void test_general_handling() throws IOException { Counts counts = new Counts<>(); counts.setName("test"); @@ -49,7 +50,7 @@ public void test_general_handling() throws IOException { } @Test - public void test_reader_writer() throws IOException { + void test_reader_writer() throws IOException { String filename = utils.getOutputDirectory() + "test_counts.xml"; @@ -88,21 +89,24 @@ public void test_reader_writer() throws IOException { } - @Test(expected = IllegalArgumentException.class) - public void test_illegal() { + @Test + void test_illegal() { + assertThrows(IllegalArgumentException.class, () -> { - Counts dummyCounts = new Counts<>(); + Counts dummyCounts = new Counts<>(); + + MeasurementLocation station = dummyCounts.createAndAddMeasureLocation(Id.create("12", Link.class), "12_test"); + Measurable volume = station.createVolume(TransportMode.car, Measurable.HOURLY); - MeasurementLocation station = dummyCounts.createAndAddMeasureLocation(Id.create("12", Link.class), "12_test"); - Measurable volume = station.createVolume(TransportMode.car, Measurable.HOURLY); + volume.setAtHour(-1, 500); - volume.setAtHour(-1, 500); + }); } @Test - public void aggregate() { + void aggregate() { Counts counts = new Counts<>(); diff --git a/matsim/src/test/java/org/matsim/counts/MatsimCountsIOTest.java b/matsim/src/test/java/org/matsim/counts/MatsimCountsIOTest.java index 3e3ef220219..6f2da37f269 100644 --- a/matsim/src/test/java/org/matsim/counts/MatsimCountsIOTest.java +++ b/matsim/src/test/java/org/matsim/counts/MatsimCountsIOTest.java @@ -22,23 +22,23 @@ package org.matsim.counts; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; -/** + /** * @author mrieser / Simunto GmbH */ public class MatsimCountsIOTest { - /** - * Such a file with year 0 could be created by MATSim when the year was not explicitly set, - * but it could not be read back in as "0" was not recognized as a valid year by the XML validator originally. - */ - @Test - public void testReading_year0() { + /** + * Such a file with year 0 could be created by MATSim when the year was not explicitly set, + * but it could not be read back in as "0" was not recognized as a valid year by the XML validator originally. + */ + @Test + void testReading_year0() { String xml = "\n" + "\n" + " parameterObjects () { } @Test - public void testEquil() { + void testEquil() { Config config = ConfigUtils.createConfig() ; config.controller().setOutputDirectory( utils.getOutputDirectory() ); config.qsim().setUsingFastCapacityUpdate(this.isUsingFastCapacityUpdate); diff --git a/matsim/src/test/java/org/matsim/examples/OnePercentBerlin10sIT.java b/matsim/src/test/java/org/matsim/examples/OnePercentBerlin10sIT.java index 48c7bb036f8..5c3a02d326b 100644 --- a/matsim/src/test/java/org/matsim/examples/OnePercentBerlin10sIT.java +++ b/matsim/src/test/java/org/matsim/examples/OnePercentBerlin10sIT.java @@ -24,8 +24,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; @@ -50,7 +50,8 @@ public class OnePercentBerlin10sIT { private static final Logger log = LogManager.getLogger(OnePercentBerlin10sIT.class); - @Test public void testOnePercent10sQSim() { + @Test + void testOnePercent10sQSim() { Config config = utils.loadConfig((String)null); // input files are in the main directory in the resource path! String netFileName = "test/scenarios/berlin/network.xml"; @@ -96,7 +97,8 @@ public class OnePercentBerlin10sIT { } - @Test public void testOnePercent10sQSimTryEndTimeThenDuration() { + @Test + void testOnePercent10sQSimTryEndTimeThenDuration() { Config config = utils.loadConfig((String)null); String netFileName = "test/scenarios/berlin/network.xml"; String popFileName = "test/scenarios/berlin/plans_hwh_1pct.xml.gz"; diff --git a/matsim/src/test/java/org/matsim/examples/PtTutorialIT.java b/matsim/src/test/java/org/matsim/examples/PtTutorialIT.java index 781f3587b01..3b7f7fd87ca 100644 --- a/matsim/src/test/java/org/matsim/examples/PtTutorialIT.java +++ b/matsim/src/test/java/org/matsim/examples/PtTutorialIT.java @@ -27,8 +27,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; import org.matsim.api.core.v01.events.ActivityStartEvent; @@ -56,7 +56,7 @@ public class PtTutorialIT { public MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void ensure_tutorial_runs() throws MalformedURLException { + void ensure_tutorial_runs() throws MalformedURLException { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-tutorial"), "0.config.xml")); config.controller().setLastIteration(1); diff --git a/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java b/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java index 0c63dacd949..a2ef3a5a8ec 100644 --- a/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java +++ b/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java @@ -22,8 +22,8 @@ import java.util.List; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; @@ -64,7 +64,7 @@ public static Object[] testParameters() { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void test_PtScoringLineswitch() { + void test_PtScoringLineswitch() { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-simple-lineswitch"), "config.xml")); ScoringConfigGroup pcs = config.scoring() ; @@ -215,8 +215,9 @@ public void test_PtScoringLineswitch() { } } + @Test - public void test_PtScoringLineswitchAndPtConstant() { + void test_PtScoringLineswitchAndPtConstant() { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-simple-lineswitch"), "config.xml")); ScoringConfigGroup pcs = config.scoring() ; @@ -370,8 +371,9 @@ public void test_PtScoringLineswitchAndPtConstant() { } } + @Test - public void test_PtScoring_Wait() { + void test_PtScoring_Wait() { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-simple"), "config.xml")); ScoringConfigGroup pcs = config.scoring(); @@ -457,7 +459,7 @@ public void test_PtScoring_Wait() { } @Test - public void test_PtScoring() { + void test_PtScoring() { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-simple"), "config.xml")); ScoringConfigGroup pcs = config.scoring() ; diff --git a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesFactoryImplTest.java b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesFactoryImplTest.java index 01dafb87234..e5f8838a405 100644 --- a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesFactoryImplTest.java +++ b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesFactoryImplTest.java @@ -20,7 +20,7 @@ package org.matsim.facilities; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -30,7 +30,7 @@ public class ActivityFacilitiesFactoryImplTest { @Test - public void testCreateActivityFacility() { + void testCreateActivityFacility() { ActivityFacilitiesFactoryImpl factory = new ActivityFacilitiesFactoryImpl(); ActivityFacility facility = factory.createActivityFacility(Id.create(1980, ActivityFacility.class), new Coord((double) 5, (double) 11)); @@ -40,7 +40,7 @@ public void testCreateActivityFacility() { } @Test - public void testCreateActivityOption() { + void testCreateActivityOption() { ActivityFacilitiesFactoryImpl factory = new ActivityFacilitiesFactoryImpl(); ActivityOption option = factory.createActivityOption("leisure"); diff --git a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesImplTest.java b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesImplTest.java index 1be2f455b55..223c6e20898 100644 --- a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesImplTest.java +++ b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesImplTest.java @@ -20,7 +20,7 @@ package org.matsim.facilities; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -30,7 +30,7 @@ public class ActivityFacilitiesImplTest { @Test - public void testAddActivityFacility() { + void testAddActivityFacility() { ActivityFacilities facilities = new ActivityFacilitiesImpl(); ActivityFacilitiesFactory factory = facilities.getFactory(); ActivityFacility facility1 = factory.createActivityFacility(Id.create(1, ActivityFacility.class), new Coord((double) 200, (double) 5000)); @@ -48,7 +48,7 @@ public void testAddActivityFacility() { } @Test - public void testAddActivityFacility_addingTwice() { + void testAddActivityFacility_addingTwice() { ActivityFacilities facilities = new ActivityFacilitiesImpl(); ActivityFacilitiesFactory factory = facilities.getFactory(); ActivityFacility facility1 = factory.createActivityFacility(Id.create(1, ActivityFacility.class), new Coord((double) 200, (double) 5000)); @@ -69,7 +69,7 @@ public void testAddActivityFacility_addingTwice() { } @Test - public void testAddActivityFacility_sameId() { + void testAddActivityFacility_sameId() { ActivityFacilities facilities = new ActivityFacilitiesImpl(); ActivityFacilitiesFactory factory = facilities.getFactory(); ActivityFacility facility1 = factory.createActivityFacility(Id.create(1, ActivityFacility.class), new Coord((double) 200, (double) 5000)); @@ -92,7 +92,7 @@ public void testAddActivityFacility_sameId() { * is used internally, and if the map is modifiable at all... */ @Test - public void testRemove() { + void testRemove() { ActivityFacilities facilities = new ActivityFacilitiesImpl(); ActivityFacilitiesFactory factory = facilities.getFactory(); ActivityFacility facility1 = factory.createActivityFacility(Id.create(1, ActivityFacility.class), new Coord((double) 200, (double) 5000)); diff --git a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java index 25b4d5a96ed..08eb702178b 100644 --- a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java +++ b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java @@ -20,8 +20,8 @@ package org.matsim.facilities; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.matsim.api.core.v01.Coord; @@ -80,7 +80,7 @@ public static Collection parametersForFacilitiesSourceTest() { } @Test - public void test(){ + void test(){ String outDir = utils.getOutputDirectory() ; String testOutDir = outDir + "/" + facilitiesSource.toString() + "_facilitiesWithCoordOnly_" + String.valueOf(facilitiesWithCoordOnly) + "/"; new File(testOutDir).mkdirs(); diff --git a/matsim/src/test/java/org/matsim/facilities/ActivityWithOnlyFacilityIdTest.java b/matsim/src/test/java/org/matsim/facilities/ActivityWithOnlyFacilityIdTest.java index 11666860066..8c768e8be87 100644 --- a/matsim/src/test/java/org/matsim/facilities/ActivityWithOnlyFacilityIdTest.java +++ b/matsim/src/test/java/org/matsim/facilities/ActivityWithOnlyFacilityIdTest.java @@ -4,9 +4,9 @@ import java.net.URL; import java.util.Set; -import java.util.stream.Collectors; - -import org.junit.Test; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Activity; import org.matsim.core.config.Config; @@ -15,12 +15,12 @@ import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.io.IOUtils; -import org.matsim.examples.ExamplesUtils; - -public class ActivityWithOnlyFacilityIdTest { - - @Test - public void testSiouxFallsWithOnlyFacilityIds() { +import org.matsim.examples.ExamplesUtils; + +public class ActivityWithOnlyFacilityIdTest { + + @Test + void testSiouxFallsWithOnlyFacilityIds() { URL scenarioURL = ExamplesUtils.getTestScenarioURL("siouxfalls-2014"); Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(scenarioURL, "config_default.xml")); diff --git a/matsim/src/test/java/org/matsim/facilities/FacilitiesAttributeConvertionTest.java b/matsim/src/test/java/org/matsim/facilities/FacilitiesAttributeConvertionTest.java index 9120b176773..15ecc2fe919 100644 --- a/matsim/src/test/java/org/matsim/facilities/FacilitiesAttributeConvertionTest.java +++ b/matsim/src/test/java/org/matsim/facilities/FacilitiesAttributeConvertionTest.java @@ -22,8 +22,8 @@ package org.matsim.facilities; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.ConfigUtils; import org.matsim.core.scenario.ScenarioUtils; @@ -34,26 +34,26 @@ import java.util.Objects; import java.util.function.Consumer; -public class FacilitiesAttributeConvertionTest { + public class FacilitiesAttributeConvertionTest { @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void testDefaults() { + @Test + void testDefaults() { final String path = utils.getOutputDirectory()+"/facilities.xml"; testWriteAndReread(w -> w.write(path), w -> w.readFile(path)); } - @Test - public void testV1() { + @Test + void testV1() { final String path = utils.getOutputDirectory()+"/facilities.xml"; testWriteAndReread(w -> w.writeV1(path), w -> w.readFile(path)); } - @Test - public void testDefaultsStream() { + @Test + void testDefaultsStream() { final String path = utils.getOutputDirectory()+"/facilities.xml"; testWriteAndReread(w -> w.write(IOUtils.getOutputStream(IOUtils.getFileUrl(path), false)), w -> w.readFile(path)); diff --git a/matsim/src/test/java/org/matsim/facilities/FacilitiesFromPopulationTest.java b/matsim/src/test/java/org/matsim/facilities/FacilitiesFromPopulationTest.java index fa503cb96f4..9de3293c4ed 100644 --- a/matsim/src/test/java/org/matsim/facilities/FacilitiesFromPopulationTest.java +++ b/matsim/src/test/java/org/matsim/facilities/FacilitiesFromPopulationTest.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.Set; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -47,7 +47,7 @@ public class FacilitiesFromPopulationTest { @Test - public void testRun_onePerLink_assignLinks() { + void testRun_onePerLink_assignLinks() { Fixture f = new Fixture(); FacilitiesFromPopulation generator = new FacilitiesFromPopulation(f.scenario.getActivityFacilities()); @@ -74,7 +74,7 @@ public void testRun_onePerLink_assignLinks() { } @Test - public void testRun_onePerLink_assignLinks_openingTimes() { + void testRun_onePerLink_assignLinks_openingTimes() { Fixture f = new Fixture(); FacilitiesFromPopulation generator = new FacilitiesFromPopulation(f.scenario.getActivityFacilities()); @@ -110,7 +110,7 @@ public void testRun_onePerLink_assignLinks_openingTimes() { } @Test - public void testRun_multiple_assignLinks() { + void testRun_multiple_assignLinks() { Fixture f = new Fixture(); FacilitiesFromPopulation generator = new FacilitiesFromPopulation(f.scenario.getActivityFacilities()); diff --git a/matsim/src/test/java/org/matsim/facilities/FacilitiesParserWriterTest.java b/matsim/src/test/java/org/matsim/facilities/FacilitiesParserWriterTest.java index 90bde039ca5..a56aa037fdd 100644 --- a/matsim/src/test/java/org/matsim/facilities/FacilitiesParserWriterTest.java +++ b/matsim/src/test/java/org/matsim/facilities/FacilitiesParserWriterTest.java @@ -21,8 +21,8 @@ package org.matsim.facilities; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -45,7 +45,7 @@ public class FacilitiesParserWriterTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testParserWriter1() { + void testParserWriter1() { Config config = ConfigUtils.createConfig(); TriangleScenario.setUpScenarioConfig(config); @@ -62,7 +62,7 @@ public void testParserWriter1() { } @Test - public void testWriteReadV2_withActivities() { + void testWriteReadV2_withActivities() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); ActivityFacilities facilities = scenario.getActivityFacilities(); @@ -103,7 +103,7 @@ public void testWriteReadV2_withActivities() { } @Test - public void testWriteReadV2_withAttributes() { + void testWriteReadV2_withAttributes() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); ActivityFacilities facilities = scenario.getActivityFacilities(); @@ -140,7 +140,7 @@ public void testWriteReadV2_withAttributes() { } @Test - public void testWriteReadV2_withActivitiesAndAttributes() { // MATSIM-859 + void testWriteReadV2_withActivitiesAndAttributes() { // MATSIM-859 Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); ActivityFacilities facilities = scenario.getActivityFacilities(); diff --git a/matsim/src/test/java/org/matsim/facilities/FacilitiesReprojectionIOTest.java b/matsim/src/test/java/org/matsim/facilities/FacilitiesReprojectionIOTest.java index f4154bb23d4..23682c3794b 100644 --- a/matsim/src/test/java/org/matsim/facilities/FacilitiesReprojectionIOTest.java +++ b/matsim/src/test/java/org/matsim/facilities/FacilitiesReprojectionIOTest.java @@ -22,8 +22,8 @@ package org.matsim.facilities; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -39,7 +39,7 @@ import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; -/** + /** * @author thibautd */ public class FacilitiesReprojectionIOTest { @@ -53,8 +53,8 @@ public class FacilitiesReprojectionIOTest { @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void testReprojectionAtImport() { + @Test + void testReprojectionAtImport() { final Scenario originalScenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); final Scenario reprojectedScenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); @@ -64,8 +64,8 @@ public void testReprojectionAtImport() { assertScenarioReprojectedCorrectly(originalScenario, reprojectedScenario); } - @Test - public void testReprojectionAtExport() { + @Test + void testReprojectionAtExport() { final Scenario originalScenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); new MatsimFacilitiesReader( originalScenario ).parse(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("chessboard"), "facilities.xml")); @@ -78,8 +78,8 @@ public void testReprojectionAtExport() { assertScenarioReprojectedCorrectly(originalScenario, reprojectedScenario); } - @Test - public void testWithControlerAndObjectAttributes() { + @Test + void testWithControlerAndObjectAttributes() { // accept a rounding error of 1 cm. // this is used both to compare equality and non-equality, so the more we accept difference between input // and output coordinates, the more we require the internally reprojected coordinates to be different. @@ -140,8 +140,8 @@ public void testWithControlerAndObjectAttributes() { } } - @Test - public void testWithControlerAndConfigParameters() { + @Test + void testWithControlerAndConfigParameters() { // accept a rounding error of 1 cm. // this is used both to compare equality and non-equality, so the more we accept difference between input // and output coordinates, the more we require the internally reprojected coordinates to be different. diff --git a/matsim/src/test/java/org/matsim/facilities/FacilitiesWriterTest.java b/matsim/src/test/java/org/matsim/facilities/FacilitiesWriterTest.java index a0d8396330c..2cef9ffb5d5 100644 --- a/matsim/src/test/java/org/matsim/facilities/FacilitiesWriterTest.java +++ b/matsim/src/test/java/org/matsim/facilities/FacilitiesWriterTest.java @@ -22,7 +22,7 @@ package org.matsim.facilities; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -33,13 +33,13 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -/** + /** * @author mrieser */ public class FacilitiesWriterTest { - @Test - public void testWriteLinkId() { + @Test + void testWriteLinkId() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); ActivityFacilities facilities = scenario.getActivityFacilities(); ActivityFacilitiesFactory factory = facilities.getFactory(); @@ -83,8 +83,8 @@ public void testWriteLinkId() { Assert.assertEquals("pepsiCo", fac3b.getAttributes().getAttribute("owner")); } - @Test - public void testWrite3DCoord() { + @Test + void testWrite3DCoord() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); ActivityFacilities facilities = scenario.getActivityFacilities(); ActivityFacilitiesFactory factory = facilities.getFactory(); @@ -121,9 +121,9 @@ public void testWrite3DCoord() { Assert.assertFalse(fac3b.getCoord().hasZ()); } - @Test - // the better fix for https://github.com/matsim-org/matsim/pull/505 - public void testFacilityDescription() { + // the better fix for https://github.com/matsim-org/matsim/pull/505 + @Test + void testFacilityDescription() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); ActivityFacilities facilities = scenario.getActivityFacilities(); ActivityFacilitiesFactory factory = facilities.getFactory(); @@ -156,9 +156,9 @@ public void testFacilityDescription() { Assert.assertEquals(desc, desc2); } - @Test - // inspired by https://github.com/matsim-org/matsim/pull/505 - public void testFacilitiesName() { + // inspired by https://github.com/matsim-org/matsim/pull/505 + @Test + void testFacilitiesName() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); ActivityFacilities facilities = scenario.getActivityFacilities(); ActivityFacilitiesFactory factory = facilities.getFactory(); diff --git a/matsim/src/test/java/org/matsim/facilities/MatsimFacilitiesReaderTest.java b/matsim/src/test/java/org/matsim/facilities/MatsimFacilitiesReaderTest.java index 79414f1d327..e1b5329bb19 100644 --- a/matsim/src/test/java/org/matsim/facilities/MatsimFacilitiesReaderTest.java +++ b/matsim/src/test/java/org/matsim/facilities/MatsimFacilitiesReaderTest.java @@ -24,20 +24,20 @@ import java.io.ByteArrayInputStream; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.ConfigUtils; import org.matsim.core.scenario.ScenarioUtils; -/** + /** * @author mrieser / Senozon AG */ public class MatsimFacilitiesReaderTest { - @Test - public void testReadLinkId() { + @Test + void testReadLinkId() { String str = "\n" + "\n" + "\n" + @@ -84,8 +84,8 @@ public void testReadLinkId() { Assert.assertNull(fac20.getLinkId()); } - @Test - public void testRead3DCoord() { + @Test + void testRead3DCoord() { String str = "\n" + "\n" + "\n" + diff --git a/matsim/src/test/java/org/matsim/facilities/StreamingActivityFacilitiesTest.java b/matsim/src/test/java/org/matsim/facilities/StreamingActivityFacilitiesTest.java index 06cc2bd7cbd..58a92229f5d 100644 --- a/matsim/src/test/java/org/matsim/facilities/StreamingActivityFacilitiesTest.java +++ b/matsim/src/test/java/org/matsim/facilities/StreamingActivityFacilitiesTest.java @@ -1,7 +1,7 @@ package org.matsim.facilities; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; @@ -11,7 +11,7 @@ public class StreamingActivityFacilitiesTest { @Test - public void testFacilityIsComplete() { + void testFacilityIsComplete() { String str = "\n" + "\n" + "\n" + diff --git a/matsim/src/test/java/org/matsim/facilities/algorithms/AbstractFacilityAlgorithmTest.java b/matsim/src/test/java/org/matsim/facilities/algorithms/AbstractFacilityAlgorithmTest.java index 99083e55eb7..f115010be8a 100644 --- a/matsim/src/test/java/org/matsim/facilities/algorithms/AbstractFacilityAlgorithmTest.java +++ b/matsim/src/test/java/org/matsim/facilities/algorithms/AbstractFacilityAlgorithmTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.facilities.ActivityFacilitiesImpl; @@ -36,7 +36,8 @@ public class AbstractFacilityAlgorithmTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testRunAlgorithms() { + @Test + void testRunAlgorithms() { final ActivityFacilitiesImpl facilities = new ActivityFacilitiesImpl(); // create 2 facilities facilities.createAndAddFacility(Id.create(1, ActivityFacility.class), new Coord(1.0, 1.0)); diff --git a/matsim/src/test/java/org/matsim/households/HouseholdAttributeConversionTest.java b/matsim/src/test/java/org/matsim/households/HouseholdAttributeConversionTest.java index 14d81eb0be3..3c3b207f51f 100644 --- a/matsim/src/test/java/org/matsim/households/HouseholdAttributeConversionTest.java +++ b/matsim/src/test/java/org/matsim/households/HouseholdAttributeConversionTest.java @@ -24,8 +24,8 @@ import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.ConfigUtils; @@ -39,12 +39,12 @@ import java.util.Objects; import java.util.function.Consumer; -public class HouseholdAttributeConversionTest { + public class HouseholdAttributeConversionTest { @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void testDefaults() { + @Test + void testDefaults() { final String path = utils.getOutputDirectory()+"/households.xml"; testWriteAndReread(w -> w.writeFile(path), w -> w.readFile(path)); diff --git a/matsim/src/test/java/org/matsim/households/HouseholdImplTest.java b/matsim/src/test/java/org/matsim/households/HouseholdImplTest.java index 83f7d596c35..8aa02ede926 100644 --- a/matsim/src/test/java/org/matsim/households/HouseholdImplTest.java +++ b/matsim/src/test/java/org/matsim/households/HouseholdImplTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.testcases.MatsimTestUtils; @@ -36,7 +36,8 @@ public class HouseholdImplTest { /** * Test that households with the same {@link Id} are not accepted. */ - @Test public void testAddHousehold_DuplicateId(){ + @Test + void testAddHousehold_DuplicateId(){ HouseholdsImpl hhs = new HouseholdsImpl(); Household hh1 = new HouseholdImpl(Id.create("1", Household.class)); Household hh2 = new HouseholdImpl(Id.create("1", Household.class)); @@ -56,7 +57,8 @@ public class HouseholdImplTest { /** * Test that households are accumulated if streaming is off. */ - @Test public void testAddHousehold_NoStreaming(){ + @Test + void testAddHousehold_NoStreaming(){ HouseholdsImpl hhs = new HouseholdsImpl(); Household hh1 = new HouseholdImpl(Id.create("1", Household.class)); Household hh2 = new HouseholdImpl(Id.create("2", Household.class)); diff --git a/matsim/src/test/java/org/matsim/households/HouseholdsIoTest.java b/matsim/src/test/java/org/matsim/households/HouseholdsIoTest.java index 28f68261192..bba8e6a3916 100644 --- a/matsim/src/test/java/org/matsim/households/HouseholdsIoTest.java +++ b/matsim/src/test/java/org/matsim/households/HouseholdsIoTest.java @@ -27,8 +27,8 @@ import java.util.Collections; import java.util.List; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.households.Income.IncomePeriod; @@ -59,7 +59,8 @@ public class HouseholdsIoTest { private final Id id24 = Id.create("24", Household.class); private final Id id25 = Id.create("25", Household.class); - @Test public void testBasicReaderWriter() throws IOException { + @Test + void testBasicReaderWriter() throws IOException { Households households = new HouseholdsImpl(); HouseholdsReaderV10 reader = new HouseholdsReaderV10(households); reader.readFile(utils.getPackageInputDirectory() + TESTHOUSEHOLDSINPUT); diff --git a/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java b/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java index d458b8af9a5..3db4c83d19f 100644 --- a/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java +++ b/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java @@ -21,8 +21,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; import org.matsim.api.core.v01.events.ActivityStartEvent; @@ -88,7 +88,7 @@ public class EquilTwoAgentsTest { private TestSingleIterationEventHandler handler; @Test - public void testSingleIterationPlansV4() { + void testSingleIterationPlansV4() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); ConfigUtils.loadConfig(config, IOUtils.extendUrl(utils.classInputResourcePath(), "config.xml")); config.plans().setInputFile(IOUtils.extendUrl(utils.classInputResourcePath(), "plans2.xml").toString()); diff --git a/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java b/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java index a7235c552d9..0ed09266633 100644 --- a/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java +++ b/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java @@ -24,8 +24,8 @@ import java.util.Arrays; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -86,7 +86,8 @@ public class SimulateAndScoreTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testRealPtScore() { + @Test + void testRealPtScore() { final Config config = ConfigUtils.createConfig(); config.transit().setUseTransit(true); @@ -237,7 +238,8 @@ public void install() { } - @Test public void testTeleportationScore() { + @Test + void testTeleportationScore() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network = scenario.getNetwork(); Node node1 = network.getFactory().createNode(Id.create("1", Node.class), new Coord(0, 0)); diff --git a/matsim/src/test/java/org/matsim/integration/events/PersonMoneyEventIntegrationTest.java b/matsim/src/test/java/org/matsim/integration/events/PersonMoneyEventIntegrationTest.java index d255daabe55..c99bcf65622 100644 --- a/matsim/src/test/java/org/matsim/integration/events/PersonMoneyEventIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/integration/events/PersonMoneyEventIntegrationTest.java @@ -26,8 +26,8 @@ import java.io.BufferedWriter; import java.io.IOException; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonMoneyEvent; import org.matsim.api.core.v01.population.Person; @@ -48,7 +48,8 @@ public class PersonMoneyEventIntegrationTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteReadXxml() { + @Test + void testWriteReadXxml() { final PersonMoneyEvent event1 = new PersonMoneyEvent(7.0*3600, Id.create(1, Person.class), 2.34, "tollRefund", "motorwayOperator"); final PersonMoneyEvent event2 = new PersonMoneyEvent(8.5*3600, Id.create(2, Person.class), -3.45, "toll", "motorwayOperator"); @@ -100,7 +101,8 @@ public class PersonMoneyEventIntegrationTest { * This test checks that old event files can still be parsed. * @throws IOException */ - @Test public void testWriteReadXml_oldName() throws IOException { + @Test + void testWriteReadXml_oldName() throws IOException { // write some events to file diff --git a/matsim/src/test/java/org/matsim/integration/events/PersonScoreEventTest.java b/matsim/src/test/java/org/matsim/integration/events/PersonScoreEventTest.java index 501d668165c..8e690949e5e 100644 --- a/matsim/src/test/java/org/matsim/integration/events/PersonScoreEventTest.java +++ b/matsim/src/test/java/org/matsim/integration/events/PersonScoreEventTest.java @@ -24,7 +24,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonScoreEvent; import org.matsim.api.core.v01.population.Person; @@ -42,7 +42,8 @@ */ public class PersonScoreEventTest { - @Test public void testWriteReadXml() { + @Test + void testWriteReadXml() { final PersonScoreEvent event1 = new PersonScoreEvent(7.0*3600, Id.create(1, Person.class), 2.34, "act"); final PersonScoreEvent event2 = new PersonScoreEvent(8.5*3600, Id.create(2, Person.class), -3.45, "leg"); @@ -92,7 +93,8 @@ public class PersonScoreEventTest { assertEquals(event2.getKind(), e2.getKind()); } - @Test public void testWriteReadJson() { + @Test + void testWriteReadJson() { final PersonScoreEvent event1 = new PersonScoreEvent(7.0*3600, Id.create(1, Person.class), 2.34, "act"); final PersonScoreEvent event2 = new PersonScoreEvent(8.5*3600, Id.create(2, Person.class), -3.45, "leg"); diff --git a/matsim/src/test/java/org/matsim/integration/events/TransitDriverStartsEventHandlerIntegrationTest.java b/matsim/src/test/java/org/matsim/integration/events/TransitDriverStartsEventHandlerIntegrationTest.java index 485ec9befbf..4ed3071fb8e 100644 --- a/matsim/src/test/java/org/matsim/integration/events/TransitDriverStartsEventHandlerIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/integration/events/TransitDriverStartsEventHandlerIntegrationTest.java @@ -23,7 +23,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.TransitDriverStartsEvent; import org.matsim.api.core.v01.events.handler.TransitDriverStartsEventHandler; @@ -41,7 +41,7 @@ public class TransitDriverStartsEventHandlerIntegrationTest { @Test - public void testProcessEventIntegration() { + void testProcessEventIntegration() { EventsManager em = EventsUtils.createEventsManager(); TransitDriverStartsEvent e1 = new TransitDriverStartsEvent(12345, Id.create("driver", Person.class), Id.create("veh", Vehicle.class), Id.create("line", TransitLine.class), Id.create("route", TransitRoute.class), Id.create("dep", Departure.class)); diff --git a/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingIT.java b/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingIT.java index acf0bf75e71..438b9fa07c4 100644 --- a/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingIT.java +++ b/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingIT.java @@ -20,9 +20,8 @@ package org.matsim.integration.invertednetworks; import org.junit.Assert; - +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.controler.Controler; import org.matsim.core.controler.events.StartupEvent; import org.matsim.core.controler.listener.StartupListener; @@ -34,7 +33,7 @@ public class InvertedNetworkRoutingIT { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public final void testLanesInvertedNetworkRouting() { + final void testLanesInvertedNetworkRouting() { InvertedNetworkRoutingTestFixture f = new InvertedNetworkRoutingTestFixture(false, true, false); f.scenario.getConfig().controller().setOutputDirectory(testUtils.getOutputDirectory()); f.scenario.getConfig().travelTimeCalculator().setSeparateModes( false ); @@ -54,7 +53,7 @@ public void notifyStartup(StartupEvent event) { @Test - public final void testModesInvertedNetworkRouting() { + final void testModesInvertedNetworkRouting() { InvertedNetworkRoutingTestFixture f = new InvertedNetworkRoutingTestFixture(true, false, false); f.scenario.getConfig().controller().setOutputDirectory(testUtils.getOutputDirectory()); f.scenario.getConfig().travelTimeCalculator().setSeparateModes( false ); @@ -73,7 +72,7 @@ public void notifyStartup(StartupEvent event) { } @Test - public final void testModesNotInvertedNetworkRouting() { + final void testModesNotInvertedNetworkRouting() { InvertedNetworkRoutingTestFixture f = new InvertedNetworkRoutingTestFixture(true, false, false); f.scenario.getConfig().controller().setOutputDirectory(testUtils.getOutputDirectory()); f.scenario.getConfig().controller().setLinkToLinkRoutingEnabled(false); diff --git a/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java b/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java index e3f49875139..f5c0a37ec99 100644 --- a/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java +++ b/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java @@ -24,8 +24,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.LinkEnterEvent; import org.matsim.api.core.v01.events.handler.LinkEnterEventHandler; @@ -60,7 +60,7 @@ public class LanesIT { private MatsimTestUtils testUtils = new MatsimTestUtils(); @Test - public void testLanes(){ + void testLanes(){ String configFilename = testUtils.getClassInputDirectory() + "config.xml"; Config config = ConfigUtils.loadConfig(configFilename); config.network().setInputFile("network.xml"); diff --git a/matsim/src/test/java/org/matsim/integration/population/NonAlternatingPlanElementsIT.java b/matsim/src/test/java/org/matsim/integration/population/NonAlternatingPlanElementsIT.java index 9e4952cb95a..8d745a9e89f 100644 --- a/matsim/src/test/java/org/matsim/integration/population/NonAlternatingPlanElementsIT.java +++ b/matsim/src/test/java/org/matsim/integration/population/NonAlternatingPlanElementsIT.java @@ -23,8 +23,8 @@ import java.util.List; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -63,7 +63,7 @@ public class NonAlternatingPlanElementsIT { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void test_Controler_QSim_Routechoice_acts() { + void test_Controler_QSim_Routechoice_acts() { Config config = this.utils.loadConfig("test/scenarios/equil/config.xml"); config.controller().setMobsim("qsim"); config.controller().setLastIteration(10); @@ -95,7 +95,7 @@ public void test_Controler_QSim_Routechoice_acts() { } @Test - public void test_Controler_QSim_Routechoice_legs() { + void test_Controler_QSim_Routechoice_legs() { Config config = this.utils.loadConfig("test/scenarios/equil/config.xml"); config.controller().setMobsim("qsim"); config.controller().setLastIteration(10); diff --git a/matsim/src/test/java/org/matsim/integration/pt/TransitIntegrationTest.java b/matsim/src/test/java/org/matsim/integration/pt/TransitIntegrationTest.java index 7f957b6bf4e..910037148b6 100644 --- a/matsim/src/test/java/org/matsim/integration/pt/TransitIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/integration/pt/TransitIntegrationTest.java @@ -19,8 +19,10 @@ package org.matsim.integration.pt; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.ScoringConfigGroup; @@ -33,39 +35,43 @@ public class TransitIntegrationTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Test(expected = RuntimeException.class) - public void testPtInteractionParams() { - Config config = ConfigUtils.createConfig(); - config.controller().setOutputDirectory(utils.getOutputDirectory()); - ScoringConfigGroup.ActivityParams params = new ScoringConfigGroup.ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); - params.setScoringThisActivityAtAll(true); - params.setTypicalDuration(60.0); - config.scoring().addActivityParams(params); - // --- - config.controller().setLastIteration(0); // in case the exception is _not_ thrown, we don't need 100 iterations to find that out ... - // --- - Controler controler = new Controler(config); - controler.run(); + @Test + void testPtInteractionParams() { + assertThrows(RuntimeException.class, () -> { + Config config = ConfigUtils.createConfig(); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + ScoringConfigGroup.ActivityParams params = new ScoringConfigGroup.ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); + params.setScoringThisActivityAtAll(true); + params.setTypicalDuration(60.0); + config.scoring().addActivityParams(params); + // --- + config.controller().setLastIteration(0); // in case the exception is _not_ thrown, we don't need 100 iterations to find that out ... + // --- + Controler controler = new Controler(config); + controler.run(); + }); } - @Test(expected = RuntimeException.class) - public void testSubpopulationParams() { - Config config = ConfigUtils.createConfig(); - config.controller().setOutputDirectory(utils.getOutputDirectory()); - ScoringConfigGroup.ActivityParams params = new ScoringConfigGroup.ActivityParams("home"); - params.setScoringThisActivityAtAll(true); - params.setTypicalDuration(60.0); - ScoringParameterSet sps = config.scoring().getOrCreateScoringParameters("one"); - sps.addActivityParams(params); - ScoringParameterSet sps2 = config.scoring().getOrCreateScoringParameters("two"); - sps2.addActivityParams(params); - // --- - config.controller().setLastIteration(0); // in case the exception is _not_ thrown, we don't need 100 iterations to find that out ... - config.checkConsistency(); + @Test + void testSubpopulationParams() { + assertThrows(RuntimeException.class, () -> { + Config config = ConfigUtils.createConfig(); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + ScoringConfigGroup.ActivityParams params = new ScoringConfigGroup.ActivityParams("home"); + params.setScoringThisActivityAtAll(true); + params.setTypicalDuration(60.0); + ScoringParameterSet sps = config.scoring().getOrCreateScoringParameters("one"); + sps.addActivityParams(params); + ScoringParameterSet sps2 = config.scoring().getOrCreateScoringParameters("two"); + sps2.addActivityParams(params); + // --- + config.controller().setLastIteration(0); // in case the exception is _not_ thrown, we don't need 100 iterations to find that out ... + config.checkConsistency(); - Controler controler = new Controler(config); - controler.run(); + Controler controler = new Controler(config); + controler.run(); + }); } } diff --git a/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java b/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java index 8dc31bb2b98..933fb43fbf6 100644 --- a/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java @@ -23,8 +23,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -74,7 +74,8 @@ public class ChangeTripModeIntegrationTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testStrategyManagerConfigLoaderIntegration() { + @Test + void testStrategyManagerConfigLoaderIntegration() { // setup config final Config config = utils.loadConfig((String)null); final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java b/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java index eeba73759b9..2375b591263 100644 --- a/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java +++ b/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java @@ -27,8 +27,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.PopulationWriter; import org.matsim.core.config.Config; @@ -77,7 +77,7 @@ private Scenario loadScenario() { } @Test - public void testReRoutingDijkstra() throws MalformedURLException { + void testReRoutingDijkstra() throws MalformedURLException { Scenario scenario = this.loadScenario(); scenario.getConfig().controller().setRoutingAlgorithmType(RoutingAlgorithmType.Dijkstra); Controler controler = new Controler(scenario); @@ -88,7 +88,7 @@ public void testReRoutingDijkstra() throws MalformedURLException { } @Test - public void testReRoutingAStarLandmarks() throws MalformedURLException { + void testReRoutingAStarLandmarks() throws MalformedURLException { Scenario scenario = this.loadScenario(); scenario.getConfig().controller().setRoutingAlgorithmType(RoutingAlgorithmType.AStarLandmarks); Controler controler = new Controler(scenario); @@ -99,7 +99,7 @@ public void testReRoutingAStarLandmarks() throws MalformedURLException { } @Test - public void testReRoutingSpeedyALT() throws MalformedURLException { + void testReRoutingSpeedyALT() throws MalformedURLException { Scenario scenario = this.loadScenario(); scenario.getConfig().controller().setRoutingAlgorithmType(RoutingAlgorithmType.SpeedyALT); Controler controler = new Controler(scenario); diff --git a/matsim/src/test/java/org/matsim/integration/replanning/ResumableRunsIT.java b/matsim/src/test/java/org/matsim/integration/replanning/ResumableRunsIT.java index feb4b69ff3c..23691588cff 100644 --- a/matsim/src/test/java/org/matsim/integration/replanning/ResumableRunsIT.java +++ b/matsim/src/test/java/org/matsim/integration/replanning/ResumableRunsIT.java @@ -21,8 +21,8 @@ package org.matsim.integration.replanning; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.controler.Controler; @@ -56,7 +56,7 @@ public class ResumableRunsIT { * re-planning, which both could depend on random numbers. */ @Test - public void testResumableRuns() throws MalformedURLException { + void testResumableRuns() throws MalformedURLException { Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); config.controller().setLastIteration(11); config.controller().setWriteEventsInterval(1); diff --git a/matsim/src/test/java/org/matsim/integration/timevariantnetworks/QSimIntegrationTest.java b/matsim/src/test/java/org/matsim/integration/timevariantnetworks/QSimIntegrationTest.java index 9808f4b5f2c..214a92bc0a0 100644 --- a/matsim/src/test/java/org/matsim/integration/timevariantnetworks/QSimIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/integration/timevariantnetworks/QSimIntegrationTest.java @@ -26,8 +26,8 @@ import java.util.List; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -79,7 +79,8 @@ public class QSimIntegrationTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testFreespeed() { + @Test + void testFreespeed() { Config config = utils.loadConfig((String)null); config.network().setTimeVariantNetwork(true); Scenario scenario = ScenarioUtils.createScenario(config); @@ -125,7 +126,8 @@ public class QSimIntegrationTest { * * @author illenberger */ - @Test public void testCapacity() { + @Test + void testCapacity() { final int personsPerWave = 10; final double capacityFactor = 0.5; @@ -196,7 +198,8 @@ public class QSimIntegrationTest { * * @author dgrether */ - @Test public void testZeroCapacity() { + @Test + void testZeroCapacity() { final double capacityFactor = 0.0; Config config = utils.loadConfig((String)null); diff --git a/matsim/src/test/java/org/matsim/lanes/LanesUtilsTest.java b/matsim/src/test/java/org/matsim/lanes/LanesUtilsTest.java index 19abf4f1c3d..700a8bac5f7 100644 --- a/matsim/src/test/java/org/matsim/lanes/LanesUtilsTest.java +++ b/matsim/src/test/java/org/matsim/lanes/LanesUtilsTest.java @@ -1,6 +1,6 @@ package org.matsim.lanes; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -55,8 +55,8 @@ private LanesToLinkAssignment createLaneAssignment(Scenario scenario, double inL return laneLinkAssignment; } - @Test - public void correctOrder() { + @Test + void correctOrder() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); NetworkFactory f = scenario.getNetwork().getFactory(); diff --git a/matsim/src/test/java/org/matsim/lanes/data/LanesReaderWriterTest.java b/matsim/src/test/java/org/matsim/lanes/data/LanesReaderWriterTest.java index c032d3409c9..55ca134f315 100644 --- a/matsim/src/test/java/org/matsim/lanes/data/LanesReaderWriterTest.java +++ b/matsim/src/test/java/org/matsim/lanes/data/LanesReaderWriterTest.java @@ -27,8 +27,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -79,14 +79,16 @@ private static final class Fixture{ } } - @Test public void testReader20() { + @Test + void testReader20() { Fixture f = new Fixture(); LanesReader reader = new LanesReader(f.scenario); reader.readFile(utils.getClassInputDirectory() + FILENAME); checkContent(f.scenario.getLanes()); } - @Test public void testWriter20() { + @Test + void testWriter20() { Fixture f = new Fixture(); String testoutput = utils.getOutputDirectory() + "testLaneDefinitions2.0out.xml.gz"; log.debug("reading file..."); diff --git a/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java b/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java index caf4baac619..a76a672ff7a 100644 --- a/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java +++ b/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java @@ -29,8 +29,8 @@ import jakarta.inject.Inject; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @@ -71,7 +71,7 @@ public static Collection parameterObjects () { } @Test - public void testScoreStats() { + void testScoreStats() { Config config = utils.loadConfig("test/scenarios/equil/config.xml"); config.qsim().setUsingFastCapacityUpdate(this.isUsingFastCapacityUpdate); diff --git a/matsim/src/test/java/org/matsim/other/DownloadAndReadXmlTest.java b/matsim/src/test/java/org/matsim/other/DownloadAndReadXmlTest.java index 883aa930f3a..a2aa6eaf190 100644 --- a/matsim/src/test/java/org/matsim/other/DownloadAndReadXmlTest.java +++ b/matsim/src/test/java/org/matsim/other/DownloadAndReadXmlTest.java @@ -21,8 +21,8 @@ import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -42,11 +42,10 @@ public class DownloadAndReadXmlTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Ignore - @Test - /** + @Test /** * Http downloads from the SVN server will be forbidden soon, according to jwilk. */ - public final void testHttpFromSvn() { + final void testHttpFromSvn() { Config config = ConfigUtils.createConfig(); System.out.println(utils.getInputDirectory() + "../../"); @@ -66,7 +65,7 @@ public final void testHttpFromSvn() { } @Test - public final void testHttpsFromSvn() { + final void testHttpsFromSvn() { Config config = ConfigUtils.createConfig(); System.out.println(utils.getInputDirectory() + "../../"); diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourComplexTripsTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourComplexTripsTest.java index 6e0bb24b6d5..bcf1d9d33ee 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourComplexTripsTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourComplexTripsTest.java @@ -25,7 +25,7 @@ import java.util.List; import java.util.Random; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.matsim.api.core.v01.Id; @@ -457,10 +457,10 @@ public static Collection createTests() { public ChooseRandomLegModeForSubtourComplexTripsTest( double proba ) { this.probaForRandomSingleTripMode = proba ; } - - + + @Test - public void testMutatedTrips() { + void testMutatedTrips() { Config config = ConfigUtils.createConfig(); config.subtourModeChoice().setModes(MODES); config.subtourModeChoice().setConsiderCarAvailability(false); diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourDiffModesTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourDiffModesTest.java index 5f4759c45c6..95030f763d7 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourDiffModesTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourDiffModesTest.java @@ -25,7 +25,7 @@ import java.util.List; import java.util.Random; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.matsim.api.core.v01.Id; @@ -109,9 +109,9 @@ public static Collection createTests() { public ChooseRandomLegModeForSubtourDiffModesTest( double proba ) { this.probaForRandomSingleTripMode = proba ; } - + @Test - public void testMutatedTrips() { + void testMutatedTrips() { Config config = ConfigUtils.createConfig(); config.subtourModeChoice().setModes(MODES); config.subtourModeChoice().setConsiderCarAvailability(false); diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourTest.java index 68c8df6fd01..091cb019655 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourTest.java @@ -30,8 +30,8 @@ import java.util.List; import java.util.Random; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.matsim.api.core.v01.Coord; @@ -119,7 +119,7 @@ public ChooseRandomLegModeForSubtourTest( double proba ) { @Test - public void testHandleEmptyPlan() { + void testHandleEmptyPlan() { String[] modes = new String[] {TransportMode.car, TransportMode.pt, TransportMode.walk}; ChooseRandomLegModeForSubtour algo = new ChooseRandomLegModeForSubtour( new MainModeIdentifierImpl() , new AllowTheseModesForEveryone(modes), modes, CHAIN_BASED_MODES, MatsimRandom.getRandom(), SubtourModeChoice.Behavior.fromSpecifiedModesToSpecifiedModes, probaForRandomSingleTripMode); @@ -129,7 +129,7 @@ public void testHandleEmptyPlan() { } @Test - public void testHandlePlanWithoutLeg() { + void testHandlePlanWithoutLeg() { String[] modes = new String[] {TransportMode.car, TransportMode.pt, TransportMode.walk}; ChooseRandomLegModeForSubtour algo = new ChooseRandomLegModeForSubtour( new MainModeIdentifierImpl() ,new AllowTheseModesForEveryone(modes), modes, CHAIN_BASED_MODES, MatsimRandom.getRandom(), SubtourModeChoice.Behavior.fromSpecifiedModesToSpecifiedModes, probaForRandomSingleTripMode); @@ -141,7 +141,7 @@ public void testHandlePlanWithoutLeg() { @Test - public void testSubTourMutationNetworkBased() { + void testSubTourMutationNetworkBased() { Config config = utils.loadConfig(CONFIGFILE); Scenario scenario = ScenarioUtils.createScenario(config); Network network = scenario.getNetwork(); @@ -152,7 +152,7 @@ public void testSubTourMutationNetworkBased() { } @Test - public void testSubTourMutationFacilitiesBased() { + void testSubTourMutationFacilitiesBased() { Config config = utils.loadConfig(CONFIGFILE); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); ActivityFacilitiesImpl facilities = (ActivityFacilitiesImpl) scenario.getActivityFacilities(); @@ -163,7 +163,7 @@ public void testSubTourMutationFacilitiesBased() { } @Test - public void testCarDoesntTeleportFromHome() { + void testCarDoesntTeleportFromHome() { Config config = utils.loadConfig(CONFIGFILE); Scenario scenario = ScenarioUtils.createScenario(config); Network network = scenario.getNetwork(); @@ -173,7 +173,7 @@ public void testCarDoesntTeleportFromHome() { } @Test - public void testSingleTripSubtourHandling() { + void testSingleTripSubtourHandling() { String[] modes = new String[] {"car", "pt", "walk"}; ChooseRandomLegModeForSubtour testee = new ChooseRandomLegModeForSubtour( new MainModeIdentifierImpl() ,new AllowTheseModesForEveryone(modes), modes, CHAIN_BASED_MODES, new Random(15102011), SubtourModeChoice.Behavior.fromSpecifiedModesToSpecifiedModes, probaForRandomSingleTripMode); @@ -258,7 +258,7 @@ public void testSingleTripSubtourHandling() { @Test - public void testUnclosedSubtour() { + void testUnclosedSubtour() { String[] modes = new String[] {"car", "pt", "walk"}; diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeTest.java index e52d56eca60..3e9b98977f7 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeTest.java @@ -24,8 +24,8 @@ import java.util.Random; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -47,7 +47,8 @@ public class ChooseRandomLegModeTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testRandomChoice() { + @Test + void testRandomChoice() { ChooseRandomLegMode algo = new ChooseRandomLegMode(new String[] {TransportMode.car, TransportMode.pt, TransportMode.walk}, MatsimRandom.getRandom(), false); Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); PopulationUtils.createAndAddActivityFromCoord(plan, "home", new Coord(0, 0)); @@ -76,7 +77,8 @@ public class ChooseRandomLegModeTest { assertTrue("expected to find walk-mode", foundWalkMode); } - @Test public void testRandomChoiceWithinListedModesOnly() { + @Test + void testRandomChoiceWithinListedModesOnly() { ChooseRandomLegMode algo = new ChooseRandomLegMode(new String[] {TransportMode.car, TransportMode.pt, TransportMode.walk}, MatsimRandom.getRandom(), true); Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); PopulationUtils.createAndAddActivityFromCoord(plan, "home", new Coord(0, 0)); @@ -105,7 +107,8 @@ public class ChooseRandomLegModeTest { assertTrue("expected to find walk-mode", foundWalkMode); } - @Test public void testRandomChoiceWithinListedModesOnlyWorks() { + @Test + void testRandomChoiceWithinListedModesOnlyWorks() { ChooseRandomLegMode algo = new ChooseRandomLegMode(new String[] {TransportMode.pt, TransportMode.walk}, MatsimRandom.getRandom(), true); Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); PopulationUtils.createAndAddActivityFromCoord(plan, "home", new Coord(0, 0)); @@ -117,15 +120,16 @@ public class ChooseRandomLegModeTest { } - - @Test public void testHandleEmptyPlan() { + @Test + void testHandleEmptyPlan() { ChooseRandomLegMode algo = new ChooseRandomLegMode(new String[] {TransportMode.car, TransportMode.pt, TransportMode.walk}, MatsimRandom.getRandom(), false); Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); algo.run(plan); // no specific assert, but there should also be no NullPointerException or similar stuff that could theoretically happen } - @Test public void testHandlePlanWithoutLeg() { + @Test + void testHandlePlanWithoutLeg() { ChooseRandomLegMode algo = new ChooseRandomLegMode(new String[] {TransportMode.car, TransportMode.pt, TransportMode.walk}, MatsimRandom.getRandom(), false); Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); PopulationUtils.createAndAddActivityFromCoord(plan, "home", new Coord(0, 0)); @@ -136,7 +140,8 @@ public class ChooseRandomLegModeTest { /** * Test that all the legs have the same, changed mode */ - @Test public void testMultipleLegs() { + @Test + void testMultipleLegs() { ChooseRandomLegMode algo = new ChooseRandomLegMode(new String[] {TransportMode.car, TransportMode.pt}, MatsimRandom.getRandom(), false); Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); PopulationUtils.createAndAddActivityFromCoord(plan, "home", new Coord(0, 0)); @@ -152,7 +157,8 @@ public class ChooseRandomLegModeTest { assertEquals("unexpected leg mode in leg 3.", TransportMode.pt, ((Leg) plan.getPlanElements().get(5)).getMode()); } - @Test public void testIgnoreCarAvailability_Never() { + @Test + void testIgnoreCarAvailability_Never() { ChooseRandomLegMode algo = new ChooseRandomLegMode(new String[] {TransportMode.car, TransportMode.pt, TransportMode.bike}, MatsimRandom.getRandom(), false); algo.setIgnoreCarAvailability(false); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -169,7 +175,8 @@ public class ChooseRandomLegModeTest { assertEquals("unexpected leg mode in leg 1.", TransportMode.bike, ((Leg) plan.getPlanElements().get(1)).getMode()); } - @Test public void testIgnoreCarAvailability_Never_noChoice() { + @Test + void testIgnoreCarAvailability_Never_noChoice() { ChooseRandomLegMode algo = new ChooseRandomLegMode(new String[] {TransportMode.car, TransportMode.pt}, MatsimRandom.getRandom(), false); algo.setIgnoreCarAvailability(false); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -182,7 +189,8 @@ public class ChooseRandomLegModeTest { assertEquals("unexpected leg mode in leg 1.", TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode()); } - @Test public void testIgnoreCarAvailability_Always() { + @Test + void testIgnoreCarAvailability_Always() { ChooseRandomLegMode algo = new ChooseRandomLegMode(new String[] {TransportMode.car, TransportMode.pt, TransportMode.bike}, new Random(1), false); algo.setIgnoreCarAvailability(false); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomSingleLegModeTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomSingleLegModeTest.java index f4fd0a2ac7f..c8e4b31cefa 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomSingleLegModeTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomSingleLegModeTest.java @@ -27,7 +27,7 @@ import java.util.Random; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -46,7 +46,7 @@ public class ChooseRandomSingleLegModeTest { @Test - public void testRandomChoice() { + void testRandomChoice() { ChooseRandomSingleLegMode algo = new ChooseRandomSingleLegMode(new String[] {TransportMode.car, TransportMode.pt, TransportMode.walk}, MatsimRandom.getRandom(),false); Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); PopulationUtils.createAndAddActivityFromCoord(plan, "home", new Coord((double) 0, (double) 0)); @@ -75,7 +75,7 @@ public void testRandomChoice() { @Test - public void testRandomChoiceWithListedModesOnly() { + void testRandomChoiceWithListedModesOnly() { ChooseRandomSingleLegMode algo = new ChooseRandomSingleLegMode(new String[] {TransportMode.car, TransportMode.pt, TransportMode.walk}, MatsimRandom.getRandom(),true); Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); PopulationUtils.createAndAddActivityFromCoord(plan, "home", new Coord((double) 0, (double) 0)); @@ -103,7 +103,7 @@ public void testRandomChoiceWithListedModesOnly() { } @Test - public void testRandomChoiceWithListedModesOnlyAndDifferentFromMode() { + void testRandomChoiceWithListedModesOnlyAndDifferentFromMode() { ChooseRandomSingleLegMode algo = new ChooseRandomSingleLegMode(new String[]{TransportMode.pt, TransportMode.walk}, MatsimRandom.getRandom(), true); Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); PopulationUtils.createAndAddActivityFromCoord(plan, "home", new Coord((double) 0, (double) 0)); @@ -113,8 +113,9 @@ public void testRandomChoiceWithListedModesOnlyAndDifferentFromMode() { String mode = leg.getMode(); Assert.assertSame(TransportMode.car, mode); } + @Test - public void testHandleEmptyPlan() { + void testHandleEmptyPlan() { ChooseRandomSingleLegMode algo = new ChooseRandomSingleLegMode(new String[] {TransportMode.car, TransportMode.pt, TransportMode.walk}, MatsimRandom.getRandom(),false); Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); algo.run(plan); @@ -122,7 +123,7 @@ public void testHandleEmptyPlan() { } @Test - public void testHandlePlanWithoutLeg() { + void testHandlePlanWithoutLeg() { ChooseRandomSingleLegMode algo = new ChooseRandomSingleLegMode(new String[] {TransportMode.car, TransportMode.pt, TransportMode.walk}, MatsimRandom.getRandom(),false); Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); PopulationUtils.createAndAddActivityFromCoord(plan, "home", new Coord(0, 0)); @@ -131,7 +132,7 @@ public void testHandlePlanWithoutLeg() { } @Test - public void testHandlePlan_DifferentThanLastMode() { + void testHandlePlan_DifferentThanLastMode() { ChooseRandomSingleLegMode algo = new ChooseRandomSingleLegMode(new String[] {TransportMode.car, TransportMode.pt, TransportMode.walk}, MatsimRandom.getRandom(),false); Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); PopulationUtils.createAndAddActivityFromCoord(plan, "home", new Coord((double) 0, (double) 0)); @@ -147,7 +148,7 @@ public void testHandlePlan_DifferentThanLastMode() { } @Test - public void testHandlePlan_OnlySingleLegChanged() { + void testHandlePlan_OnlySingleLegChanged() { ChooseRandomSingleLegMode algo = new ChooseRandomSingleLegMode(new String[] {TransportMode.car, TransportMode.pt, TransportMode.walk}, MatsimRandom.getRandom(),false); Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(1, Person.class))); PopulationUtils.createAndAddActivityFromCoord(plan, "home", new Coord(0, 0)); @@ -175,7 +176,7 @@ public void testHandlePlan_OnlySingleLegChanged() { } @Test - public void testIgnoreCarAvailability_Never() { + void testIgnoreCarAvailability_Never() { ChooseRandomSingleLegMode algo = new ChooseRandomSingleLegMode(new String[] {TransportMode.car, TransportMode.pt, TransportMode.bike}, MatsimRandom.getRandom(),false); algo.setIgnoreCarAvailability(false); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -195,7 +196,7 @@ public void testIgnoreCarAvailability_Never() { } @Test - public void testIgnoreCarAvailability_Never_noChoice() { + void testIgnoreCarAvailability_Never_noChoice() { ChooseRandomSingleLegMode algo = new ChooseRandomSingleLegMode(new String[] {TransportMode.car, TransportMode.pt}, MatsimRandom.getRandom(),false); algo.setIgnoreCarAvailability(false); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -209,7 +210,7 @@ public void testIgnoreCarAvailability_Never_noChoice() { } @Test - public void testIgnoreCarAvailability_Always() { + void testIgnoreCarAvailability_Always() { ChooseRandomSingleLegMode algo = new ChooseRandomSingleLegMode(new String[] {TransportMode.car, TransportMode.pt, TransportMode.bike}, new Random(1),false); algo.setIgnoreCarAvailability(false); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ParallelPersonAlgorithmRunnerTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ParallelPersonAlgorithmRunnerTest.java index d6a11b6485d..319411270e0 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ParallelPersonAlgorithmRunnerTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ParallelPersonAlgorithmRunnerTest.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; @@ -49,7 +49,7 @@ public class ParallelPersonAlgorithmRunnerTest { * @author mrieser */ @Test - public void testNumberOfThreads() { + void testNumberOfThreads() { Population population = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getPopulation(); PersonAlgorithmTester algo = new PersonAlgorithmTester(); PersonAlgoProviderTester tester = new PersonAlgoProviderTester(algo); @@ -67,7 +67,7 @@ public void testNumberOfThreads() { * @author mrieser */ @Test - public void testNofPersons() { + void testNofPersons() { MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); Population population = scenario.getPopulation(); for (int i = 0; i < 100; i++) { @@ -91,7 +91,7 @@ public void testNofPersons() { } @Test - public void testCrashingAlgorithm() { + void testCrashingAlgorithm() { try { MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); Population population = scenario.getPopulation(); diff --git a/matsim/src/test/java/org/matsim/population/algorithms/PermissibleModesCalculatorImplTest.java b/matsim/src/test/java/org/matsim/population/algorithms/PermissibleModesCalculatorImplTest.java index a27adff51c5..e4889cb2097 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/PermissibleModesCalculatorImplTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/PermissibleModesCalculatorImplTest.java @@ -28,7 +28,7 @@ import java.util.List; import org.junit.After; import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.Person; @@ -101,7 +101,7 @@ public void fixtureWithCarSometimes() { } @Test - public void testWhenConsideringCarAvailability() throws Exception { + void testWhenConsideringCarAvailability() throws Exception { final List modesWithCar = Arrays.asList(TransportMode.car, "rail", "plane"); final List modesWithoutCar = Arrays.asList("rail", "plane"); Config config = ConfigUtils.createConfig(); @@ -120,7 +120,7 @@ public void testWhenConsideringCarAvailability() throws Exception { } @Test - public void testWhenNotConsideringCarAvailability() throws Exception { + void testWhenNotConsideringCarAvailability() throws Exception { final List modesWithCar = Arrays.asList(TransportMode.car, "rail", "plane"); Config config = ConfigUtils.createConfig(); config.subtourModeChoice().setModes(modesWithCar.toArray(new String[0])); diff --git a/matsim/src/test/java/org/matsim/population/algorithms/PersonPrepareForSimTest.java b/matsim/src/test/java/org/matsim/population/algorithms/PersonPrepareForSimTest.java index 1841a0b0a43..f7766a370df 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/PersonPrepareForSimTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/PersonPrepareForSimTest.java @@ -24,7 +24,7 @@ import org.junit.Assert; import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -58,7 +58,7 @@ public class PersonPrepareForSimTest { @Test - public void testRun_MultimodalNetwork() { + void testRun_MultimodalNetwork() { Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); createAndAddNetwork(sc); Id link1id = Id.createLinkId("1"); @@ -90,7 +90,7 @@ public void testRun_MultimodalNetwork() { } @Test - public void testRun_MultimodalScenario() { + void testRun_MultimodalScenario() { Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); createAndAddNetwork(sc); Id link1id = Id.createLinkId("1"); @@ -120,9 +120,9 @@ public void testRun_MultimodalScenario() { Assert.assertEquals(link1id, a1.getLinkId()); Assert.assertEquals(link1id, a2.getLinkId()); // must also be linked to l1, as l2 has no car mode } - + @Test - public void testSingleLegTripRoutingMode() { + void testSingleLegTripRoutingMode() { Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); createAndAddNetwork(sc); Population pop = sc.getPopulation(); @@ -171,7 +171,7 @@ public void testSingleLegTripRoutingMode() { TripStructureUtils.getRoutingMode(leg)); } } - + /** * Fallback modes are outdated with the introduction of routingMode. So, we want the simulation to crash if we encounter * them after {@link PrepareForSimImpl} was run (and adapted outdated plans). However, for the time being we do not @@ -181,7 +181,7 @@ public void testSingleLegTripRoutingMode() { * checked explicitly). */ @Test - public void testSingleFallbackModeLegTrip() { + void testSingleFallbackModeLegTrip() { Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); createAndAddNetwork(sc); Population pop = sc.getPopulation(); @@ -231,9 +231,9 @@ public void testSingleFallbackModeLegTrip() { TripStructureUtils.getRoutingMode(leg)); } } - + @Test - public void testCorrectTripsRemainUnchanged() { + void testCorrectTripsRemainUnchanged() { Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); createAndAddNetwork(sc); Population pop = sc.getPopulation(); @@ -358,9 +358,9 @@ public void testCorrectTripsRemainUnchanged() { Assert.assertEquals("wrong routing mode set", TransportMode.pt, TripStructureUtils.getRoutingMode(leg11)); } } - + @Test - public void testRoutingModeConsistency() { + void testRoutingModeConsistency() { Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); createAndAddNetwork(sc); Population pop = sc.getPopulation(); @@ -429,7 +429,7 @@ public void testRoutingModeConsistency() { } @Test - public void testReplaceExperimentalTransitRoute() { + void testReplaceExperimentalTransitRoute() { Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); createAndAddNetwork(sc); Id startLink = Id.createLinkId("1"); diff --git a/matsim/src/test/java/org/matsim/population/algorithms/TripsToLegsAlgorithmTest.java b/matsim/src/test/java/org/matsim/population/algorithms/TripsToLegsAlgorithmTest.java index c6bda247ec9..2cb4da8a744 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/TripsToLegsAlgorithmTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/TripsToLegsAlgorithmTest.java @@ -26,7 +26,7 @@ import java.util.Iterator; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -62,7 +62,7 @@ public Fixture( private static final String DUMMY_2 = "dummy_2 interaction"; @Test - public void testMonoLegPlan() throws Exception { + void testMonoLegPlan() throws Exception { final Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create("id", Person.class))); final List structure = new ArrayList(); @@ -93,7 +93,7 @@ public void testMonoLegPlan() throws Exception { } @Test - public void testMultiLegPlan() throws Exception { + void testMultiLegPlan() throws Exception { final Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create("id", Person.class))); final List structure = new ArrayList(); @@ -134,7 +134,7 @@ public void testMultiLegPlan() throws Exception { } @Test - public void testDummyActsPlan() throws Exception { + void testDummyActsPlan() throws Exception { final Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create("id", Person.class))); final List structure = new ArrayList(); @@ -182,7 +182,7 @@ public void testDummyActsPlan() throws Exception { } @Test - public void testPtPlan() throws Exception { + void testPtPlan() throws Exception { final Plan plan = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create("id", Person.class))); final List structure = new ArrayList(); diff --git a/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadIntegrationTest.java b/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadIntegrationTest.java index 8e43b745d0a..d6b291abc83 100644 --- a/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadIntegrationTest.java @@ -20,8 +20,8 @@ package org.matsim.pt.analysis; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; @@ -44,7 +44,7 @@ public class TransitLoadIntegrationTest { @RegisterExtension private MatsimTestUtils util = new MatsimTestUtils(); @Test - public void testIntegration() { + void testIntegration() { final Config cfg = this.util.loadConfig("test/scenarios/pt-tutorial/0.config.xml"); cfg.controller().setLastIteration(0); cfg.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier); diff --git a/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadTest.java b/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadTest.java index 295d8b616bd..8e8aa411ba8 100644 --- a/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadTest.java +++ b/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadTest.java @@ -24,7 +24,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonEntersVehicleEvent; @@ -47,7 +47,7 @@ public class TransitLoadTest { @Test - public void testTransitLoad_singleLine() { + void testTransitLoad_singleLine() { TransitScheduleFactory factory = new TransitScheduleFactoryImpl(); TransitSchedule schedule = factory.createTransitSchedule(); TransitStopFacility stop1 = factory.createTransitStopFacility(Id.create(0, TransitStopFacility.class), new Coord((double) 0, (double) 0), false); diff --git a/matsim/src/test/java/org/matsim/pt/config/TransitConfigGroupTest.java b/matsim/src/test/java/org/matsim/pt/config/TransitConfigGroupTest.java index 0ec00c3e6bc..c00969cd10e 100644 --- a/matsim/src/test/java/org/matsim/pt/config/TransitConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/pt/config/TransitConfigGroupTest.java @@ -25,7 +25,7 @@ import java.util.HashSet; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; /** @@ -41,7 +41,8 @@ public class TransitConfigGroupTest { * {@link TransitConfigGroup#getParams()} for setting and getting * the transit schedule input file. */ - @Test public void testTransitScheduleFile() { + @Test + void testTransitScheduleFile() { TransitConfigGroup cg = new TransitConfigGroup(); // test initial value assertNull(cg.getTransitScheduleFile()); @@ -71,7 +72,8 @@ public class TransitConfigGroupTest { assertEquals(filename, cg.getParams().get(TransitConfigGroup.TRANSIT_SCHEDULE_FILE)); } - @Test public void testVehiclesFile() { + @Test + void testVehiclesFile() { TransitConfigGroup cg = new TransitConfigGroup(); // test initial value assertNull(cg.getVehiclesFile()); @@ -101,7 +103,8 @@ public class TransitConfigGroupTest { assertEquals(filename, cg.getParams().get(TransitConfigGroup.VEHICLES_FILE)); } - @Test public void testTransitModes() { + @Test + void testTransitModes() { TransitConfigGroup cg = new TransitConfigGroup(); Set modes; // test initial value diff --git a/matsim/src/test/java/org/matsim/pt/router/TransitActsRemoverTest.java b/matsim/src/test/java/org/matsim/pt/router/TransitActsRemoverTest.java index 962f0975417..e4f2d81ba07 100644 --- a/matsim/src/test/java/org/matsim/pt/router/TransitActsRemoverTest.java +++ b/matsim/src/test/java/org/matsim/pt/router/TransitActsRemoverTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.Activity; @@ -35,7 +35,8 @@ public class TransitActsRemoverTest { - @Test public void testNormalTransitPlan() { + @Test + void testNormalTransitPlan() { Plan plan = PopulationUtils.createPlan(); Coord dummyCoord = new Coord((double) 0, (double) 0); plan.addActivity(PopulationUtils.createActivityFromCoord("h", dummyCoord)); @@ -83,14 +84,16 @@ public class TransitActsRemoverTest { assertEquals("h", ((Activity) plan.getPlanElements().get(6)).getType()); } - @Test public void testEmptyPlan() { + @Test + void testEmptyPlan() { Plan plan = PopulationUtils.createPlan(); new TransitActsRemover().run(plan); assertEquals(0, plan.getPlanElements().size()); // this mostly checks that there is no exception } - @Test public void testPlanWithoutLegs() { + @Test + void testPlanWithoutLegs() { Plan plan = PopulationUtils.createPlan(); Coord dummyCoord = new Coord((double) 0, (double) 0); plan.addActivity(PopulationUtils.createActivityFromCoord("h", dummyCoord)); @@ -99,7 +102,8 @@ public class TransitActsRemoverTest { // this mostly checks that there is no exception } - @Test public void testWalkOnlyPlan() { + @Test + void testWalkOnlyPlan() { Plan plan = PopulationUtils.createPlan(); Coord dummyCoord = new Coord((double) 0, (double) 0); plan.addActivity(PopulationUtils.createActivityFromCoord("h", dummyCoord)); @@ -110,7 +114,8 @@ public class TransitActsRemoverTest { assertEquals(TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode()); } - @Test public void testNoTransitActPlan() { + @Test + void testNoTransitActPlan() { Plan plan = PopulationUtils.createPlan(); Coord dummyCoord = new Coord((double) 0, (double) 0); plan.addActivity(PopulationUtils.createActivityFromCoord("h", dummyCoord)); diff --git a/matsim/src/test/java/org/matsim/pt/router/TransitRouterConfigTest.java b/matsim/src/test/java/org/matsim/pt/router/TransitRouterConfigTest.java index a7a3f3cad17..3b2f4b585c0 100644 --- a/matsim/src/test/java/org/matsim/pt/router/TransitRouterConfigTest.java +++ b/matsim/src/test/java/org/matsim/pt/router/TransitRouterConfigTest.java @@ -20,8 +20,7 @@ package org.matsim.pt.router; import org.junit.Assert; - -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.RoutingConfigGroup; @@ -34,7 +33,7 @@ public class TransitRouterConfigTest { @Test - public void testConstructor() { + void testConstructor() { ScoringConfigGroup planScoring = new ScoringConfigGroup(); RoutingConfigGroup planRouting = new RoutingConfigGroup(); TransitRouterConfigGroup transitRouting = new TransitRouterConfigGroup(); diff --git a/matsim/src/test/java/org/matsim/pt/router/TransitRouterModuleTest.java b/matsim/src/test/java/org/matsim/pt/router/TransitRouterModuleTest.java index 7d573d29ed8..86df76d670e 100644 --- a/matsim/src/test/java/org/matsim/pt/router/TransitRouterModuleTest.java +++ b/matsim/src/test/java/org/matsim/pt/router/TransitRouterModuleTest.java @@ -3,8 +3,8 @@ import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptor; import com.google.inject.Injector; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.mobsim.framework.Mobsim; @@ -19,7 +19,7 @@ public class TransitRouterModuleTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testTransitRoutingAlgorithm_DependencyInjection_Raptor() { + void testTransitRoutingAlgorithm_DependencyInjection_Raptor() { Fixture f = new Fixture(); f.config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.SwissRailRaptor); f.config.controller().setOutputDirectory(this.utils.getOutputDirectory()); diff --git a/matsim/src/test/java/org/matsim/pt/routes/DefaultTransitPassengerRouteTest.java b/matsim/src/test/java/org/matsim/pt/routes/DefaultTransitPassengerRouteTest.java index f3ef18d4a24..b0dcdd68f44 100644 --- a/matsim/src/test/java/org/matsim/pt/routes/DefaultTransitPassengerRouteTest.java +++ b/matsim/src/test/java/org/matsim/pt/routes/DefaultTransitPassengerRouteTest.java @@ -24,7 +24,7 @@ import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -40,7 +40,8 @@ // Mainly copied from ExperimentalTransitRouteTest public class DefaultTransitPassengerRouteTest { - @Test public void testReadWrite_null() { + @Test + void testReadWrite_null() { DefaultTransitPassengerRoute routeA = new DefaultTransitPassengerRoute(null, null); String description = routeA.getRouteDescription(); @@ -53,7 +54,8 @@ public class DefaultTransitPassengerRouteTest { assertNull(routeB.getRouteId()); } - @Test public void testReadWrite() { + @Test + void testReadWrite() { Id accessId = Id.create("access", TransitStopFacility.class); Id egressId = Id.create("egress", TransitStopFacility.class); Id lineId = Id.create("line", TransitLine.class); @@ -71,7 +73,8 @@ public class DefaultTransitPassengerRouteTest { assertEquals(routeId, routeB.getRouteId()); } - @Test public void testInitializationLinks() { + @Test + void testInitializationLinks() { Link link1 = new FakeLink(Id.create(1, Link.class)); Link link2 = new FakeLink(Id.create(2, Link.class)); DefaultTransitPassengerRoute route = new DefaultTransitPassengerRoute(link1.getId(), link2.getId()); @@ -82,7 +85,8 @@ public class DefaultTransitPassengerRouteTest { assertNull(route.getEgressStopId()); } - @Test public void testInitializationStops() { + @Test + void testInitializationStops() { TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitStopFacility stop1 = builder.createTransitStopFacility(Id.create(1, TransitStopFacility.class), new Coord(5, 11), false); TransitStopFacility stop2 = builder.createTransitStopFacility(Id.create(2, TransitStopFacility.class), new Coord(18, 7), false); @@ -103,7 +107,8 @@ public class DefaultTransitPassengerRouteTest { assertEquals(123.0, route.getBoardingTime().seconds(), 1e-3); } - @Test public void testLinks() { + @Test + void testLinks() { Link link1 = new FakeLink(Id.create(1, Link.class)); Link link2 = new FakeLink(Id.create(2, Link.class)); Link link3 = new FakeLink(Id.create(3, Link.class)); @@ -117,7 +122,8 @@ public class DefaultTransitPassengerRouteTest { assertEquals(link4.getId(), route.getEndLinkId()); } - @Test public void testTravelTime() { + @Test + void testTravelTime() { DefaultTransitPassengerRoute route = new DefaultTransitPassengerRoute(null, null); assertTrue(route.getTravelTime().isUndefined()); double traveltime = 987.65; @@ -125,7 +131,8 @@ public class DefaultTransitPassengerRouteTest { assertEquals(traveltime, route.getTravelTime().seconds(), MatsimTestUtils.EPSILON); } - @Test public void testSetRouteDescription_PtRoute() { + @Test + void testSetRouteDescription_PtRoute() { DefaultTransitPassengerRoute route = new DefaultTransitPassengerRoute(null, null); route.setRouteDescription("" + "{" + @@ -142,7 +149,8 @@ public class DefaultTransitPassengerRouteTest { assertEquals("{\"transitRouteId\":\"1980\",\"boardingTime\":\"undefined\",\"transitLineId\":\"11\",\"accessFacilityId\":\"5\",\"egressFacilityId\":\"1055\"}", route.getRouteDescription()); } - @Test public void testSetRouteDescription_NonPtRoute() { + @Test + void testSetRouteDescription_NonPtRoute() { try { DefaultTransitPassengerRoute route = new DefaultTransitPassengerRoute(null, null); route.setRouteDescription("23 42 7 21"); diff --git a/matsim/src/test/java/org/matsim/pt/routes/ExperimentalTransitRouteTest.java b/matsim/src/test/java/org/matsim/pt/routes/ExperimentalTransitRouteTest.java index 1b1705471f1..68439b3b087 100644 --- a/matsim/src/test/java/org/matsim/pt/routes/ExperimentalTransitRouteTest.java +++ b/matsim/src/test/java/org/matsim/pt/routes/ExperimentalTransitRouteTest.java @@ -24,7 +24,7 @@ import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -39,7 +39,8 @@ public class ExperimentalTransitRouteTest { - @Test public void testInitializationLinks() { + @Test + void testInitializationLinks() { Link link1 = new FakeLink(Id.create(1, Link.class)); Link link2 = new FakeLink(Id.create(2, Link.class)); ExperimentalTransitRoute route = new ExperimentalTransitRoute(link1.getId(), link2.getId()); @@ -50,7 +51,8 @@ public class ExperimentalTransitRouteTest { assertNull(route.getEgressStopId()); } - @Test public void testInitializationStops() { + @Test + void testInitializationStops() { TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitStopFacility stop1 = builder.createTransitStopFacility(Id.create(1, TransitStopFacility.class), new Coord(5, 11), false); TransitStopFacility stop2 = builder.createTransitStopFacility(Id.create(2, TransitStopFacility.class), new Coord(18, 7), false); @@ -69,7 +71,8 @@ public class ExperimentalTransitRouteTest { assertEquals(link2.getId(), route.getEndLinkId()); } - @Test public void testLinks() { + @Test + void testLinks() { Link link1 = new FakeLink(Id.create(1, Link.class)); Link link2 = new FakeLink(Id.create(2, Link.class)); Link link3 = new FakeLink(Id.create(3, Link.class)); @@ -83,7 +86,8 @@ public class ExperimentalTransitRouteTest { assertEquals(link4.getId(), route.getEndLinkId()); } - @Test public void testTravelTime() { + @Test + void testTravelTime() { ExperimentalTransitRoute route = new ExperimentalTransitRoute(null, null); assertTrue(route.getTravelTime().isUndefined()); double traveltime = 987.65; @@ -91,7 +95,8 @@ public class ExperimentalTransitRouteTest { assertEquals(traveltime, route.getTravelTime().seconds(), MatsimTestUtils.EPSILON); } - @Test public void testSetRouteDescription_PtRoute() { + @Test + void testSetRouteDescription_PtRoute() { ExperimentalTransitRoute route = new ExperimentalTransitRoute(null, null); route.setRouteDescription("PT1===5===11===1980===1055"); assertEquals("5", route.getAccessStopId().toString()); @@ -101,7 +106,8 @@ public class ExperimentalTransitRouteTest { assertEquals("PT1===5===11===1980===1055", route.getRouteDescription()); } - @Test public void testSetRouteDescription_PtRouteWithDescription() { + @Test + void testSetRouteDescription_PtRouteWithDescription() { ExperimentalTransitRoute route = new ExperimentalTransitRoute(null, null); route.setRouteDescription("PT1===5===11===1980===1055===this is a===valid route"); assertEquals("5", route.getAccessStopId().toString()); @@ -111,7 +117,8 @@ public class ExperimentalTransitRouteTest { assertEquals("PT1===5===11===1980===1055===this is a===valid route", route.getRouteDescription()); } - @Test public void testSetRouteDescription_NonPtRoute() { + @Test + void testSetRouteDescription_NonPtRoute() { ExperimentalTransitRoute route = new ExperimentalTransitRoute(null, null); route.setRouteDescription("23 42 7 21"); assertNull(route.getAccessStopId()); diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/DepartureTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/DepartureTest.java index d79bcd590e4..57b725f2d9b 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/DepartureTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/DepartureTest.java @@ -23,8 +23,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.pt.transitSchedule.api.Departure; import org.matsim.testcases.MatsimTestUtils; @@ -52,7 +52,8 @@ protected Departure createDeparture(final Id id, final double time) { return new DepartureImpl(id, time); } - @Test public void testInitialization() { + @Test + void testInitialization() { Id id = Id.create(1591, Departure.class); double time = 11.0 * 3600; Departure dep = createDeparture(id, time); @@ -60,7 +61,8 @@ protected Departure createDeparture(final Id id, final double time) { assertEquals(time, dep.getDepartureTime(), MatsimTestUtils.EPSILON); } - @Test public void testVehicleId() { + @Test + void testVehicleId() { Departure dep = createDeparture(Id.create(6791, Departure.class), 7.0*3600); assertNull(dep.getVehicleId()); Id vehId = Id.create(2491, Vehicle.class); diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/MinimalTransferTimesImplTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/MinimalTransferTimesImplTest.java index e8b4e3458f6..f58e13bf1fd 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/MinimalTransferTimesImplTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/MinimalTransferTimesImplTest.java @@ -20,7 +20,7 @@ package org.matsim.pt.transitSchedule; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.pt.transitSchedule.api.MinimalTransferTimes; import org.matsim.pt.transitSchedule.api.TransitStopFacility; @@ -39,7 +39,7 @@ public class MinimalTransferTimesImplTest { private Id stopId5 = Id.create(5, TransitStopFacility.class); @Test - public void testSetGet() { + void testSetGet() { MinimalTransferTimes mtt = new MinimalTransferTimesImpl(); Assert.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId2), 0.0); mtt.set(this.stopId1, this.stopId2, 180.0); @@ -56,7 +56,7 @@ public void testSetGet() { } @Test - public void testGetWithDefault() { + void testGetWithDefault() { MinimalTransferTimes mtt = new MinimalTransferTimesImpl(); double defaultSeconds = 60.0; Assert.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId2), 0.0); @@ -71,7 +71,7 @@ public void testGetWithDefault() { } @Test - public void testRemove() { + void testRemove() { MinimalTransferTimes mtt = new MinimalTransferTimesImpl(); Assert.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId2), 0.0); mtt.set(this.stopId1, this.stopId2, 180.0); @@ -89,7 +89,7 @@ public void testRemove() { } @Test - public void testNotBidirection() { + void testNotBidirection() { MinimalTransferTimes mtt = new MinimalTransferTimesImpl(); mtt.set(this.stopId1, this.stopId2, 180.0); mtt.set(this.stopId1, this.stopId3, 240.0); @@ -105,7 +105,7 @@ public void testNotBidirection() { } @Test - public void testNotTransitive() { + void testNotTransitive() { MinimalTransferTimes mtt = new MinimalTransferTimesImpl(); mtt.set(this.stopId1, this.stopId2, 180.0); mtt.set(this.stopId2, this.stopId3, 240.0); @@ -120,7 +120,7 @@ public void testNotTransitive() { } @Test - public void testIterator_empty() { + void testIterator_empty() { MinimalTransferTimes mtt = new MinimalTransferTimesImpl(); MinimalTransferTimes.MinimalTransferTimesIterator iter = mtt.iterator(); @@ -154,7 +154,7 @@ public void testIterator_empty() { } @Test - public void testIterator() { + void testIterator() { MinimalTransferTimes mtt = new MinimalTransferTimesImpl(); MinimalTransferTimes.MinimalTransferTimesIterator iter = mtt.iterator(); @@ -223,7 +223,7 @@ public void testIterator() { } @Test - public void testIterator_withRemove() { + void testIterator_withRemove() { MinimalTransferTimes mtt = new MinimalTransferTimesImpl(); mtt.set(this.stopId1, this.stopId2, 180); mtt.set(this.stopId2, this.stopId3, 240); diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitLineTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitLineTest.java index 05c4b721b6d..fa5bd256eb4 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitLineTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitLineTest.java @@ -26,8 +26,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.pt.transitSchedule.api.TransitLine; import org.matsim.pt.transitSchedule.api.TransitRoute; @@ -57,14 +57,16 @@ protected TransitLine createTransitLine(final Id id) { return new TransitLineImpl(id); } - @Test public void testInitialization() { + @Test + void testInitialization() { Id id = Id.create(511, TransitLine.class); TransitLine tLine = createTransitLine(id); assertNotNull(tLine); assertEquals("different ids.", id.toString(), tLine.getId().toString()); } - @Test public void testAddRoute() { + @Test + void testAddRoute() { TransitLine tLine = createTransitLine(Id.create("0891", TransitLine.class)); TransitRoute route1 = new TransitRouteImpl(Id.create("1", TransitRoute.class), null, new ArrayList(), "bus"); TransitRoute route2 = new TransitRouteImpl(Id.create("2", TransitRoute.class), null, new ArrayList(), "bus"); @@ -78,7 +80,8 @@ protected TransitLine createTransitLine(final Id id) { assertNotNull(tLine.getRoutes().get(route2.getId())); } - @Test public void testAddRouteException() { + @Test + void testAddRouteException() { TransitLine tLine = createTransitLine(Id.create("0891", TransitLine.class)); TransitRoute route1a = new TransitRouteImpl(Id.create("1", TransitRoute.class), null, new ArrayList(), "bus"); TransitRoute route1b = new TransitRouteImpl(Id.create("1", TransitRoute.class), null, new ArrayList(), "bus"); @@ -104,7 +107,8 @@ protected TransitLine createTransitLine(final Id id) { } - @Test public void testRemoveRoute() { + @Test + void testRemoveRoute() { TransitLine tLine = createTransitLine(Id.create("1980", TransitLine.class)); TransitRoute route1 = new TransitRouteImpl(Id.create("11", TransitRoute.class), null, new ArrayList(), "bus"); TransitRoute route2 = new TransitRouteImpl(Id.create("5", TransitRoute.class), null, new ArrayList(), "bus"); @@ -131,7 +135,8 @@ protected TransitLine createTransitLine(final Id id) { assertNotNull(tLine.getRoutes().get(route1.getId())); } - @Test public void testGetRoutesImmutable() { + @Test + void testGetRoutesImmutable() { TransitLine tLine = createTransitLine(Id.create("1980", TransitLine.class)); TransitRoute route1 = new TransitRouteImpl(Id.create("11", TransitRoute.class), null, new ArrayList(), "bus"); try { diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteStopTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteStopTest.java index 176ac89d5c3..812205dc8e8 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteStopTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteStopTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.pt.transitSchedule.api.TransitRouteStop; @@ -43,7 +43,8 @@ protected TransitRouteStop createTransitRouteStop(final TransitStopFacility stop return new TransitRouteStopImpl.Builder().stop(stop).arrivalOffset(arrivalDelay).departureOffset(departureDelay).build(); } - @Test public void testInitialization() { + @Test + void testInitialization() { TransitStopFacility stopFacility = new TransitStopFacilityImpl(Id.create(1, TransitStopFacility.class), new Coord((double) 2, (double) 3), false); double arrivalDelay = 4; double departureDelay = 5; @@ -53,7 +54,8 @@ protected TransitRouteStop createTransitRouteStop(final TransitStopFacility stop assertEquals(departureDelay, routeStop.getDepartureOffset().seconds(), MatsimTestUtils.EPSILON); } - @Test public void testStopFacility() { + @Test + void testStopFacility() { TransitStopFacility stopFacility1 = new TransitStopFacilityImpl(Id.create(1, TransitStopFacility.class), new Coord((double) 2, (double) 3), false); TransitStopFacility stopFacility2 = new TransitStopFacilityImpl(Id.create(2, TransitStopFacility.class), new Coord((double) 3, (double) 4), false); double arrivalDelay = 4; @@ -64,7 +66,8 @@ protected TransitRouteStop createTransitRouteStop(final TransitStopFacility stop assertEquals(stopFacility2, routeStop.getStopFacility()); } - @Test public void testAwaitDepartureTime() { + @Test + void testAwaitDepartureTime() { TransitStopFacility stopFacility = new TransitStopFacilityImpl(Id.create(1, TransitStopFacility.class), new Coord((double) 2, (double) 3), false); double arrivalDelay = 4; double departureDelay = 5; @@ -76,7 +79,8 @@ protected TransitRouteStop createTransitRouteStop(final TransitStopFacility stop assertFalse(routeStop.isAwaitDepartureTime()); } - @Test public void testEquals() { + @Test + void testEquals() { TransitStopFacility stopFacility1 = new TransitStopFacilityImpl(Id.create(1, TransitStopFacility.class), new Coord((double) 2, (double) 3), false); TransitStopFacility stopFacility2 = new TransitStopFacilityImpl(Id.create(2, TransitStopFacility.class), new Coord((double) 3, (double) 4), false); TransitRouteStop stop1 = createTransitRouteStop(stopFacility1, 10, 50); diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteTest.java index d55881a2542..58da3c5f807 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteTest.java @@ -27,8 +27,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -67,7 +67,8 @@ protected static TransitRoute createTransitRoute(final Id id, fina return new TransitRouteImpl(id, route, stops, mode); } - @Test public void testInitialization() { + @Test + void testInitialization() { Id id = Id.create(9791, TransitRoute.class); Link fromLink = new FakeLink(Id.create(10, Link.class), null, null); Link toLink = new FakeLink(Id.create(5, Link.class), null, null); @@ -84,7 +85,8 @@ protected static TransitRoute createTransitRoute(final Id id, fina assertEquals("train", tRoute.getTransportMode()); } - @Test public void testDescription() { + @Test + void testDescription() { Fixture f = new Fixture(); assertNull(f.tRoute.getDescription()); String desc = "some random description string."; @@ -95,7 +97,8 @@ protected static TransitRoute createTransitRoute(final Id id, fina assertEquals(desc, f.tRoute.getDescription()); } - @Test public void testTransportMode() { + @Test + void testTransportMode() { Fixture f = new Fixture(); // test default of Fixture assertEquals("train", f.tRoute.getTransportMode()); @@ -104,7 +107,8 @@ protected static TransitRoute createTransitRoute(final Id id, fina assertEquals("tram", f.tRoute.getTransportMode()); } - @Test public void testAddDepartures() { + @Test + void testAddDepartures() { Fixture f = new Fixture(); Departure dep1 = new DepartureImpl(Id.create(1, Departure.class), 7.0*3600); Departure dep2 = new DepartureImpl(Id.create(2, Departure.class), 8.0*3600); @@ -123,7 +127,8 @@ protected static TransitRoute createTransitRoute(final Id id, fina assertEquals(dep3, f.tRoute.getDepartures().get(dep3.getId())); } - @Test public void testAddDeparturesException() { + @Test + void testAddDeparturesException() { Fixture f = new Fixture(); Departure dep1a = new DepartureImpl(Id.create(1, Departure.class), 7.0*3600); Departure dep1b = new DepartureImpl(Id.create(1, Departure.class), 7.0*3600); @@ -139,7 +144,8 @@ protected static TransitRoute createTransitRoute(final Id id, fina } } - @Test public void testRemoveDepartures() { + @Test + void testRemoveDepartures() { Fixture f = new Fixture(); Departure dep1 = new DepartureImpl(Id.create(1, Departure.class), 7.0*3600); Departure dep2 = new DepartureImpl(Id.create(2, Departure.class), 8.0*3600); @@ -165,7 +171,8 @@ protected static TransitRoute createTransitRoute(final Id id, fina assertNotNull(f.tRoute.getDepartures().get(dep1.getId())); } - @Test public void testGetDeparturesImmutable() { + @Test + void testGetDeparturesImmutable() { Fixture f = new Fixture(); Departure dep1 = new DepartureImpl(Id.create(1, Departure.class), 7.0*3600); assertEquals(0, f.tRoute.getDepartures().size()); @@ -178,7 +185,8 @@ protected static TransitRoute createTransitRoute(final Id id, fina } } - @Test public void testRoute() { + @Test + void testRoute() { Fixture f = new Fixture(); Link link1 = new FakeLink(Id.create(1, Link.class), null, null); Link link2 = new FakeLink(Id.create(2, Link.class), null, null); @@ -192,7 +200,8 @@ protected static TransitRoute createTransitRoute(final Id id, fina assertEquals(route2, f.tRoute.getRoute()); } - @Test public void testStops() { + @Test + void testStops() { Id id = Id.create(9791, TransitRoute.class); Link fromLink = new FakeLink(Id.create(10, Link.class), null, null); Link toLink = new FakeLink(Id.create(5, Link.class), null, null); @@ -224,7 +233,8 @@ protected static TransitRoute createTransitRoute(final Id id, fina assertNull(tRoute.getStop(stopFacility4)); } - @Test public void testGetStopsImmutable() { + @Test + void testGetStopsImmutable() { Fixture f = new Fixture(); // test default of Fixture assertEquals(1, f.tRoute.getStops().size()); diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFactoryTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFactoryTest.java index 4c0aec7ddcf..1940a5c8976 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFactoryTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFactoryTest.java @@ -24,7 +24,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -50,14 +50,14 @@ protected TransitScheduleFactory createTransitScheduleBuilder() { } @Test - public void testCreateTransitSchedule() { + void testCreateTransitSchedule() { TransitScheduleFactory builder = createTransitScheduleBuilder(); TransitSchedule schedule = builder.createTransitSchedule(); Assert.assertEquals(builder, schedule.getFactory()); } @Test - public void testCreateTransitLine() { + void testCreateTransitLine() { TransitScheduleFactory builder = createTransitScheduleBuilder(); Id id = Id.create(1, TransitLine.class); TransitLine line = builder.createTransitLine(id); @@ -65,7 +65,7 @@ public void testCreateTransitLine() { } @Test - public void testCreateTransitRoute() { + void testCreateTransitRoute() { TransitScheduleFactory builder = createTransitScheduleBuilder(); Id id = Id.create(2, TransitRoute.class); NetworkRoute route = RouteUtils.createLinkNetworkRouteImpl(Id.create(3, Link.class), Id.create(4, Link.class)); @@ -82,7 +82,7 @@ public void testCreateTransitRoute() { } @Test - public void testCreateTransitRouteStop() { + void testCreateTransitRouteStop() { TransitScheduleFactory builder = createTransitScheduleBuilder(); TransitStopFacility stopFacility = new TransitStopFacilityImpl(Id.create(5, TransitStopFacility.class), new Coord((double) 6, (double) 6), false); double arrivalOffset = 23; @@ -94,7 +94,7 @@ public void testCreateTransitRouteStop() { } @Test - public void testCreateTransitStopFacility() { + void testCreateTransitStopFacility() { TransitScheduleFactory builder = createTransitScheduleBuilder(); Id id1 = Id.create(6, TransitStopFacility.class); Coord coord1 = new Coord((double) 511, (double) 1980); @@ -113,7 +113,7 @@ public void testCreateTransitStopFacility() { } @Test - public void testCreateDeparture() { + void testCreateDeparture() { TransitScheduleFactory builder = createTransitScheduleBuilder(); Id id = Id.create(8, Departure.class); double time = 9.0*3600; diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFormatV1Test.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFormatV1Test.java index 665f560b7db..d43aee23f33 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFormatV1Test.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFormatV1Test.java @@ -28,8 +28,8 @@ import javax.xml.parsers.ParserConfigurationException; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -65,7 +65,8 @@ public class TransitScheduleFormatV1Test { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testWriteRead() throws IOException, SAXException, ParserConfigurationException { + @Test + void testWriteRead() throws IOException, SAXException, ParserConfigurationException { // prepare required data Network network = NetworkUtils.createNetwork(); Node n1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord((double) 0, (double) 0)); diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleIOTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleIOTest.java index 2b3fb903657..8157150e23a 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleIOTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleIOTest.java @@ -25,7 +25,7 @@ import java.util.List; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -51,7 +51,7 @@ public class TransitScheduleIOTest { @Test - public void testWriteRead_V2() { + void testWriteRead_V2() { TransitScheduleFactory f = new TransitScheduleFactoryImpl(); TransitSchedule schedule = new TransitScheduleImpl(f); { // prepare data diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderTest.java index a634df0d228..d65d912f554 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderTest.java @@ -29,8 +29,8 @@ import javax.xml.parsers.ParserConfigurationException; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -63,7 +63,8 @@ public class TransitScheduleReaderTest { private static final String INPUT_TEST_FILE_TRANSITSCHEDULE = "transitSchedule.xml"; private static final String INPUT_TEST_FILE_NETWORK = "network.xml"; - @Test public void testReadFileV1() throws SAXException, ParserConfigurationException, IOException { + @Test + void testReadFileV1() throws SAXException, ParserConfigurationException, IOException { final String inputDir = utils.getClassInputDirectory(); Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); @@ -98,7 +99,8 @@ public class TransitScheduleReaderTest { assertEquals("wrong number of links in route.", 4, route.getLinkIds().size()); } - @Test public void testReadFile() throws IOException, SAXException, ParserConfigurationException { + @Test + void testReadFile() throws IOException, SAXException, ParserConfigurationException { final String inputDir = utils.getClassInputDirectory(); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderV1Test.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderV1Test.java index 890fac22ddd..c7e8c372a5e 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderV1Test.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderV1Test.java @@ -24,7 +24,7 @@ import java.util.Stack; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -56,7 +56,7 @@ public class TransitScheduleReaderV1Test { private static final String EMPTY_STRING = ""; @Test - public void testStopFacility_Minimalistic() { + void testStopFacility_Minimalistic() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack context = new Stack<>(); @@ -83,7 +83,7 @@ public void testStopFacility_Minimalistic() { } @Test - public void testStopFacility_withLink() { + void testStopFacility_withLink() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create(1, Node.class), new Coord((double) 10, (double) 5)); @@ -115,7 +115,7 @@ public void testStopFacility_withLink() { } @Test - public void testStopFacility_withBadLink() { + void testStopFacility_withBadLink() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create(1, Node.class), new Coord((double) 10, (double) 5)); @@ -146,7 +146,7 @@ public void testStopFacility_withBadLink() { } @Test - public void testStopFacility_withName() { + void testStopFacility_withName() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack context = new Stack<>(); @@ -171,7 +171,7 @@ public void testStopFacility_withName() { } @Test - public void testStopFacility_isBlocking() { + void testStopFacility_isBlocking() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); @@ -197,7 +197,7 @@ public void testStopFacility_isBlocking() { } @Test - public void testStopFacility_Multiple() { + void testStopFacility_Multiple() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack context = new Stack<>(); @@ -232,7 +232,7 @@ public void testStopFacility_Multiple() { } @Test - public void testTransitLine_Single() { + void testTransitLine_Single() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack context = new Stack<>(); @@ -250,7 +250,7 @@ public void testTransitLine_Single() { } @Test - public void testTransitLine_Multiple() { + void testTransitLine_Multiple() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack context = new Stack<>(); @@ -274,7 +274,7 @@ public void testTransitLine_Multiple() { } @Test - public void testTransitRoute_Single() { + void testTransitRoute_Single() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack context = new Stack<>(); @@ -313,7 +313,7 @@ public void testTransitRoute_Single() { } @Test - public void testTransitRoute_Multiple() { + void testTransitRoute_Multiple() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack context = new Stack<>(); @@ -368,7 +368,7 @@ public void testTransitRoute_Multiple() { } @Test - public void testTransitRoute_Description() { + void testTransitRoute_Description() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack context = new Stack<>(); @@ -406,7 +406,7 @@ public void testTransitRoute_Description() { } @Test - public void testRouteProfile_SingleStop() { + void testRouteProfile_SingleStop() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack context = new Stack<>(); @@ -460,7 +460,7 @@ public void testRouteProfile_SingleStop() { } @Test - public void testRouteProfile_MultipleStop() { + void testRouteProfile_MultipleStop() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack context = new Stack<>(); @@ -531,7 +531,7 @@ public void testRouteProfile_MultipleStop() { } @Test - public void testRouteProfileStop_Offsets() { + void testRouteProfileStop_Offsets() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack context = new Stack<>(); @@ -627,7 +627,7 @@ public void testRouteProfileStop_Offsets() { } @Test - public void testRouteProfileStop_AwaitDeparture() { + void testRouteProfileStop_AwaitDeparture() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack context = new Stack<>(); @@ -697,7 +697,7 @@ public void testRouteProfileStop_AwaitDeparture() { } @Test - public void testRouteProfileRoute_NoLink() { + void testRouteProfileRoute_NoLink() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack context = new Stack<>(); @@ -735,7 +735,7 @@ public void testRouteProfileRoute_NoLink() { } @Test - public void testRouteProfileRoute_OneLink() { + void testRouteProfileRoute_OneLink() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); Network network = NetworkUtils.createNetwork(); @@ -802,7 +802,7 @@ public void testRouteProfileRoute_OneLink() { } @Test - public void testRouteProfileRoute_TwoLinks() { + void testRouteProfileRoute_TwoLinks() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); Network network = NetworkUtils.createNetwork(); @@ -871,7 +871,7 @@ public void testRouteProfileRoute_TwoLinks() { } @Test - public void testRouteProfileRoute_MoreLinks() { + void testRouteProfileRoute_MoreLinks() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); Network network = NetworkUtils.createNetwork(); @@ -946,7 +946,7 @@ public void testRouteProfileRoute_MoreLinks() { } @Test - public void testDepartures_Single() { + void testDepartures_Single() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack context = new Stack<>(); @@ -988,7 +988,7 @@ public void testDepartures_Single() { } @Test - public void testDepartures_Multiple() { + void testDepartures_Multiple() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack context = new Stack<>(); @@ -1040,7 +1040,7 @@ public void testDepartures_Multiple() { } @Test - public void testDepartures_withVehicleRef() { + void testDepartures_withVehicleRef() { TransitSchedule schedule = new TransitScheduleFactoryImpl().createTransitSchedule(); TransitScheduleReaderV1 reader = new TransitScheduleReaderV1(schedule, new RouteFactories()); Stack context = new Stack<>(); diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReprojectionIOTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReprojectionIOTest.java index 460bb4930b3..d53fb2163cd 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReprojectionIOTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReprojectionIOTest.java @@ -24,8 +24,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -49,7 +49,7 @@ import java.io.File; import java.net.URL; -/** + /** * @author thibautd */ public class TransitScheduleReprojectionIOTest { @@ -65,8 +65,8 @@ public class TransitScheduleReprojectionIOTest { @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); - @Test - public void testInput() { + @Test + void testInput() { URL transitSchedule = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-tutorial"), "transitschedule.xml"); final Scenario originalScenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); new TransitScheduleReader( originalScenario ).readURL(transitSchedule ); @@ -77,8 +77,8 @@ public void testInput() { assertCorrectlyReprojected( originalScenario.getTransitSchedule() , reprojectedScenario.getTransitSchedule() ); } - @Test - public void testOutput() { + @Test + void testOutput() { URL transitSchedule = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-tutorial"), "transitschedule.xml"); final Scenario originalScenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); new TransitScheduleReader(originalScenario).readURL(transitSchedule ); @@ -92,8 +92,8 @@ public void testOutput() { assertCorrectlyReprojected( originalScenario.getTransitSchedule() , reprojectedScenario.getTransitSchedule() ); } - @Test - public void testWithControlerAndConfigParameters() { + @Test + void testWithControlerAndConfigParameters() { // read transitschedule.xml into empty scenario: Scenario originalScenario ; { @@ -151,8 +151,8 @@ public void testWithControlerAndConfigParameters() { } } - @Test - public void testWithControlerAndAttributes() { + @Test + void testWithControlerAndAttributes() { // read transit schedule into empty scenario: Scenario originalScenario ; { diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleTest.java index 834bdce9be1..dc67a806b9d 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleTest.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.pt.transitSchedule.api.TransitLine; @@ -42,14 +42,14 @@ public class TransitScheduleTest { private static final Logger log = LogManager.getLogger(TransitScheduleTest.class); @Test - public void testInitialization() { + void testInitialization() { TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); TransitSchedule schedule = new TransitScheduleImpl(builder); assertEquals(builder, schedule.getFactory()); } @Test - public void testAddTransitLine() { + void testAddTransitLine() { TransitSchedule schedule = new TransitScheduleImpl(new TransitScheduleFactoryImpl()); TransitLine line1 = new TransitLineImpl(Id.create(1, TransitLine.class)); TransitLine line2 = new TransitLineImpl(Id.create(2, TransitLine.class)); @@ -64,7 +64,7 @@ public void testAddTransitLine() { } @Test - public void testAddTransitLineException() { + void testAddTransitLineException() { TransitSchedule schedule = new TransitScheduleImpl(new TransitScheduleFactoryImpl()); TransitLine line1a = new TransitLineImpl(Id.create(1, TransitLine.class)); TransitLine line1b = new TransitLineImpl(Id.create(1, TransitLine.class)); @@ -93,7 +93,7 @@ public void testAddTransitLineException() { } @Test - public void testAddStopFacility() { + void testAddStopFacility() { TransitSchedule schedule = new TransitScheduleImpl(new TransitScheduleFactoryImpl()); TransitStopFacility stop1 = new TransitStopFacilityImpl(Id.create(1, TransitStopFacility.class), new Coord((double) 0, (double) 0), false); TransitStopFacility stop2 = new TransitStopFacilityImpl(Id.create(2, TransitStopFacility.class), new Coord((double) 1, (double) 1), false); @@ -108,7 +108,7 @@ public void testAddStopFacility() { } @Test - public void testAddStopFacilityException() { + void testAddStopFacilityException() { TransitSchedule schedule = new TransitScheduleImpl(new TransitScheduleFactoryImpl()); TransitStopFacility stop1a = new TransitStopFacilityImpl(Id.create(1, TransitStopFacility.class), new Coord((double) 2, (double) 2), false); TransitStopFacility stop1b = new TransitStopFacilityImpl(Id.create(1, TransitStopFacility.class), new Coord((double) 3, (double) 3), false); @@ -137,7 +137,7 @@ public void testAddStopFacilityException() { } @Test - public void testGetTransitLinesImmutable() { + void testGetTransitLinesImmutable() { TransitSchedule schedule = new TransitScheduleImpl(new TransitScheduleFactoryImpl()); TransitLine line1 = new TransitLineImpl(Id.create(1, TransitLine.class)); try { @@ -148,9 +148,9 @@ public void testGetTransitLinesImmutable() { log.info("catched expected exception.", e); } } - + @Test - public void testGetFacilitiesImmutable() { + void testGetFacilitiesImmutable() { TransitSchedule schedule = new TransitScheduleImpl(new TransitScheduleFactoryImpl()); TransitStopFacility stop1 = new TransitStopFacilityImpl(Id.create(1, TransitStopFacility.class), new Coord((double) 0, (double) 0), false); try { @@ -163,7 +163,7 @@ public void testGetFacilitiesImmutable() { } @Test - public void testRemoveStopFacility() { + void testRemoveStopFacility() { TransitSchedule schedule = new TransitScheduleImpl(new TransitScheduleFactoryImpl()); TransitStopFacility stop1 = new TransitStopFacilityImpl(Id.create(1, TransitStopFacility.class), new Coord((double) 0, (double) 0), false); TransitStopFacility stop1b = new TransitStopFacilityImpl(Id.create(1, TransitStopFacility.class), new Coord((double) 10, (double) 10), false); @@ -174,7 +174,7 @@ public void testRemoveStopFacility() { } @Test - public void testRemoveTransitLine() { + void testRemoveTransitLine() { TransitSchedule schedule = new TransitScheduleImpl(new TransitScheduleFactoryImpl()); TransitLine line1 = new TransitLineImpl(Id.create(1, TransitLine.class)); TransitLine line1b = new TransitLineImpl(Id.create(1, TransitLine.class)); diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleWriterTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleWriterTest.java index c628d33117e..ad6a354bbff 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleWriterTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleWriterTest.java @@ -25,8 +25,8 @@ import javax.xml.parsers.ParserConfigurationException; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.core.population.routes.RouteFactories; import org.matsim.pt.transitSchedule.api.TransitLine; @@ -51,7 +51,7 @@ public class TransitScheduleWriterTest { * @throws ParserConfigurationException */ @Test - public void testDefaultV2() throws IOException, SAXException, ParserConfigurationException { + void testDefaultV2() throws IOException, SAXException, ParserConfigurationException { String filename = this.utils.getOutputDirectory() + "schedule.xml"; TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); @@ -69,7 +69,7 @@ public void testDefaultV2() throws IOException, SAXException, ParserConfiguratio } @Test - public void testTransitLineName() { + void testTransitLineName() { String filename = this.utils.getOutputDirectory() + "schedule.xml"; TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitStopFacilityTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitStopFacilityTest.java index 5f8cd61b7b1..1f0a7edb5ec 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitStopFacilityTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitStopFacilityTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -53,7 +53,8 @@ protected TransitStopFacility createTransitStopFacility(final Id id = Id.create(2491, TransitStopFacility.class); Coord coord = new Coord((double) 30, (double) 5); TransitStopFacility stop = createTransitStopFacility(id, coord, false); @@ -63,7 +64,8 @@ protected TransitStopFacility createTransitStopFacility(final Id id = Id.create(2491, TransitStopFacility.class); Coord coord = new Coord((double) 30, (double) 5); TransitStopFacility stop = createTransitStopFacility(id, coord, false); @@ -72,7 +74,8 @@ protected TransitStopFacility createTransitStopFacility(final Id id = Id.create(2491, TransitStopFacility.class); Coord coord = new Coord((double) 30, (double) 5); TransitStopFacility stop = createTransitStopFacility(id, coord, false); @@ -84,7 +87,8 @@ protected TransitStopFacility createTransitStopFacility(final Id id = Id.create(9791, TransitStopFacility.class); Coord coord = new Coord((double) 10, (double) 5); TransitStopFacility stop = createTransitStopFacility(id, coord, false); diff --git a/matsim/src/test/java/org/matsim/pt/utils/TransitScheduleValidatorTest.java b/matsim/src/test/java/org/matsim/pt/utils/TransitScheduleValidatorTest.java index 3c8e6327813..721bdffe4ec 100644 --- a/matsim/src/test/java/org/matsim/pt/utils/TransitScheduleValidatorTest.java +++ b/matsim/src/test/java/org/matsim/pt/utils/TransitScheduleValidatorTest.java @@ -23,7 +23,7 @@ import org.assertj.core.api.Assertions; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -42,7 +42,7 @@ public class TransitScheduleValidatorTest { @Test - public void testPtTutorial() { + void testPtTutorial() { Scenario scenario = ScenarioUtils.loadScenario( ConfigUtils.loadConfig("test/scenarios/pt-tutorial/0.config.xml")); TransitScheduleValidator.ValidationResult validationResult = TransitScheduleValidator.validateAll( @@ -51,7 +51,7 @@ public void testPtTutorial() { } @Test - public void testPtTutorialWithError() { + void testPtTutorialWithError() { Scenario scenario = ScenarioUtils.loadScenario( ConfigUtils.loadConfig("test/scenarios/pt-tutorial/0.config.xml")); TransitLine transitLine = scenario.getTransitSchedule() @@ -74,7 +74,7 @@ public void testPtTutorialWithError() { } @Test - public void testValidator_Transfers_implausibleTime() { + void testValidator_Transfers_implausibleTime() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); TransitSchedule schedule = scenario.getTransitSchedule(); TransitScheduleFactory factory = schedule.getFactory(); @@ -97,7 +97,7 @@ public void testValidator_Transfers_implausibleTime() { } @Test - public void testValidator_Transfers_missingStop() { + void testValidator_Transfers_missingStop() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); TransitSchedule schedule = scenario.getTransitSchedule(); TransitScheduleFactory factory = schedule.getFactory(); diff --git a/matsim/src/test/java/org/matsim/run/CreateFullConfigTest.java b/matsim/src/test/java/org/matsim/run/CreateFullConfigTest.java index cf324a220c0..fafc8d3307a 100644 --- a/matsim/src/test/java/org/matsim/run/CreateFullConfigTest.java +++ b/matsim/src/test/java/org/matsim/run/CreateFullConfigTest.java @@ -24,8 +24,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -38,7 +38,7 @@ public class CreateFullConfigTest { @RegisterExtension private MatsimTestUtils helper = new MatsimTestUtils(); @Test - public void testMain() { + void testMain() { String[] args = new String[1]; args[0] = helper.getOutputDirectory() + "newConfig.xml"; diff --git a/matsim/src/test/java/org/matsim/run/InitRoutesTest.java b/matsim/src/test/java/org/matsim/run/InitRoutesTest.java index b44932b7cf4..ae311cd6fc6 100644 --- a/matsim/src/test/java/org/matsim/run/InitRoutesTest.java +++ b/matsim/src/test/java/org/matsim/run/InitRoutesTest.java @@ -24,8 +24,8 @@ import java.io.File; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -61,7 +61,8 @@ public class InitRoutesTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testMain() throws Exception { + @Test + void testMain() throws Exception { Config config = utils.loadConfig((String)null); final String NETWORK_FILE = "test/scenarios/equil/network.xml"; final String PLANS_FILE_TESTINPUT = utils.getOutputDirectory() + "plans.in.xml"; diff --git a/matsim/src/test/java/org/matsim/run/XY2LinksTest.java b/matsim/src/test/java/org/matsim/run/XY2LinksTest.java index b403682c30a..5d0e67a2f27 100644 --- a/matsim/src/test/java/org/matsim/run/XY2LinksTest.java +++ b/matsim/src/test/java/org/matsim/run/XY2LinksTest.java @@ -24,8 +24,8 @@ import java.io.File; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Network; @@ -58,7 +58,8 @@ public class XY2LinksTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testMain() throws Exception { + @Test + void testMain() throws Exception { Config config = utils.loadConfig((String)null); final String NETWORK_FILE = "test/scenarios/equil/network.xml"; final String PLANS_FILE_TESTINPUT = utils.getOutputDirectory() + "plans.in.xml"; diff --git a/matsim/src/test/java/org/matsim/testcases/utils/LogCounterTest.java b/matsim/src/test/java/org/matsim/testcases/utils/LogCounterTest.java index cdc1bf66cb6..0c32d32d939 100644 --- a/matsim/src/test/java/org/matsim/testcases/utils/LogCounterTest.java +++ b/matsim/src/test/java/org/matsim/testcases/utils/LogCounterTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; @@ -35,7 +35,7 @@ public class LogCounterTest { private final static Logger LOG = LogManager.getLogger(LogCounterTest.class); @Test - public void testLogCounter_INFO() throws IOException { + void testLogCounter_INFO() throws IOException { LogCounter counter = new LogCounter(Level.INFO); counter.activate(); LOG.info("hello world - this is just a test"); @@ -50,7 +50,7 @@ public void testLogCounter_INFO() throws IOException { } @Test - public void testLogCounter_WARN() throws IOException { + void testLogCounter_WARN() throws IOException { LogCounter counter = new LogCounter(Level.WARN); counter.activate(); LOG.info("hello world - this is just a test"); diff --git a/matsim/src/test/java/org/matsim/utils/eventsfilecomparison/EventsFileComparatorTest.java b/matsim/src/test/java/org/matsim/utils/eventsfilecomparison/EventsFileComparatorTest.java index 76c4b86140b..b0870fa8b7b 100644 --- a/matsim/src/test/java/org/matsim/utils/eventsfilecomparison/EventsFileComparatorTest.java +++ b/matsim/src/test/java/org/matsim/utils/eventsfilecomparison/EventsFileComparatorTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; import static org.matsim.utils.eventsfilecomparison.EventsFileComparator.Result.*; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; /** @@ -36,7 +36,8 @@ public class EventsFileComparatorTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testRetCode0() { + @Test + void testRetCode0() { String f1 = utils.getClassInputDirectory() + "/events0.xml.gz"; String f2 = utils.getClassInputDirectory() + "/events5.xml.gz"; assertEquals("return val = " + FILES_ARE_EQUAL, FILES_ARE_EQUAL, EventsFileComparator.compare(f1, f2)); @@ -44,7 +45,8 @@ public class EventsFileComparatorTest { assertEquals("return val = " + FILES_ARE_EQUAL, FILES_ARE_EQUAL, EventsFileComparator.compare(f2, f1)); } - @Test public void testRetCodeM1() { + @Test + void testRetCodeM1() { String f1 = utils.getClassInputDirectory() + "/events0.xml.gz"; String f2 = utils.getClassInputDirectory() + "/events1.xml.gz"; assertEquals("return val " +DIFFERENT_NUMBER_OF_TIMESTEPS, DIFFERENT_NUMBER_OF_TIMESTEPS, EventsFileComparator.compare(f1, f2)); @@ -52,7 +54,8 @@ public class EventsFileComparatorTest { assertEquals("return val " +DIFFERENT_NUMBER_OF_TIMESTEPS, DIFFERENT_NUMBER_OF_TIMESTEPS, EventsFileComparator.compare(f2, f1)); } - @Test public void testRetCodeM2() { + @Test + void testRetCodeM2() { String f1 = utils.getClassInputDirectory() + "/events0.xml.gz"; String f2 = utils.getClassInputDirectory() + "/events2.xml.gz"; assertEquals("return val = " + DIFFERENT_TIMESTEPS, DIFFERENT_TIMESTEPS, EventsFileComparator.compare(f1, f2)); @@ -60,7 +63,8 @@ public class EventsFileComparatorTest { assertEquals("return val = " + DIFFERENT_TIMESTEPS, DIFFERENT_TIMESTEPS, EventsFileComparator.compare(f2, f1)); } - @Test public void testRetCodeM3() { + @Test + void testRetCodeM3() { String f1 = utils.getClassInputDirectory() + "/events0.xml.gz"; String f2 = utils.getClassInputDirectory() + "/events3.xml.gz"; assertEquals("return val = " + MISSING_EVENT, MISSING_EVENT, EventsFileComparator.compare(f1, f2)); @@ -68,7 +72,8 @@ public class EventsFileComparatorTest { assertEquals("return val = " + MISSING_EVENT, MISSING_EVENT, EventsFileComparator.compare(f2, f1)); } - @Test public void testRetCodeM4() { + @Test + void testRetCodeM4() { String f1 = utils.getClassInputDirectory() + "/events0.xml.gz"; String f2 = utils.getClassInputDirectory() + "/events4.xml.gz"; assertEquals("return val = " + WRONG_EVENT_COUNT, WRONG_EVENT_COUNT, EventsFileComparator.compare(f1, f2)); diff --git a/matsim/src/test/java/org/matsim/utils/geometry/CoordUtilsTest.java b/matsim/src/test/java/org/matsim/utils/geometry/CoordUtilsTest.java index b30f886d2bc..d2c2fc47982 100644 --- a/matsim/src/test/java/org/matsim/utils/geometry/CoordUtilsTest.java +++ b/matsim/src/test/java/org/matsim/utils/geometry/CoordUtilsTest.java @@ -21,7 +21,7 @@ package org.matsim.utils.geometry; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.geometry.CoordUtils; @@ -35,7 +35,7 @@ public class CoordUtilsTest { * Test method for {@link org.matsim.core.utils.geometry.CoordUtils#plus(org.matsim.api.core.v01.Coord, org.matsim.api.core.v01.Coord)}. */ @Test - public void testPlus() { + void testPlus() { Coord coord1 = new Coord(1., 2.); Coord coord2 = new Coord(3., 4.); Coord result = CoordUtils.plus( coord1, coord2 ) ; @@ -47,7 +47,7 @@ public void testPlus() { * Test method for {@link org.matsim.core.utils.geometry.CoordUtils#minus(org.matsim.api.core.v01.Coord, org.matsim.api.core.v01.Coord)}. */ @Test - public void testMinus() { + void testMinus() { Coord coord1 = new Coord(1., 2.); Coord coord2 = new Coord(3., 5.); Coord result = CoordUtils.minus( coord1, coord2 ) ; @@ -59,7 +59,7 @@ public void testMinus() { * Test method for {@link org.matsim.core.utils.geometry.CoordUtils#scalarMult(double, org.matsim.api.core.v01.Coord)}. */ @Test - public void testScalarMult() { + void testScalarMult() { Coord coord1 = new Coord(1., 2.); Coord result = CoordUtils.scalarMult( -0.33 , coord1 ) ; Assert.assertEquals( -0.33, result.getX(), delta) ; @@ -70,7 +70,7 @@ public void testScalarMult() { * Test method for {@link org.matsim.core.utils.geometry.CoordUtils#getCenter(org.matsim.api.core.v01.Coord, org.matsim.api.core.v01.Coord)}. */ @Test - public void testGetCenter() { + void testGetCenter() { Coord coord1 = new Coord(1., 2.); Coord coord2 = new Coord(3., 5.); Coord result = CoordUtils.getCenter( coord1, coord2 ) ; @@ -82,7 +82,7 @@ public void testGetCenter() { * Test method for {@link org.matsim.core.utils.geometry.CoordUtils#length(org.matsim.api.core.v01.Coord)}. */ @Test - public void testLength() { + void testLength() { Coord coord1 = new Coord(3., 2.); double result = CoordUtils.length( coord1 ) ; Assert.assertEquals( Math.sqrt( 9. + 4. ), result, delta) ; diff --git a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/LanesBasedWidthCalculatorTest.java b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/LanesBasedWidthCalculatorTest.java index 5bc21ef5dc1..dfb2d043f62 100644 --- a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/LanesBasedWidthCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/LanesBasedWidthCalculatorTest.java @@ -20,7 +20,7 @@ package org.matsim.utils.gis.matsim2esri.network; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -34,7 +34,7 @@ public class LanesBasedWidthCalculatorTest { @Test - public void testGetWidth_laneWidthNaN() { + void testGetWidth_laneWidthNaN() { Network net = NetworkUtils.createNetwork(); Node n1 = net.getFactory().createNode(Id.create("1", Node.class), new Coord((double) 0, (double) 0)); Node n2 = net.getFactory().createNode(Id.create("2", Node.class), new Coord((double) 1000, (double) 0)); diff --git a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/Network2ESRIShapeTest.java b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/Network2ESRIShapeTest.java index 298f06bcbb0..4a5d5f918eb 100755 --- a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/Network2ESRIShapeTest.java +++ b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/Network2ESRIShapeTest.java @@ -23,8 +23,8 @@ import java.util.Collection; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.ConfigUtils; @@ -41,7 +41,8 @@ public class Network2ESRIShapeTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testPolygonCapacityShape() { + @Test + void testPolygonCapacityShape() { String netFileName = "test/scenarios/equil/network.xml"; String outputFileP = utils.getOutputDirectory() + "./network.shp"; @@ -63,7 +64,8 @@ public class Network2ESRIShapeTest { Assert.assertEquals(network.getLinks().size(), writtenFeatures.size()); } - @Test public void testPolygonLanesShape() { + @Test + void testPolygonLanesShape() { String netFileName = "test/scenarios/equil/network.xml"; String outputFileP = utils.getOutputDirectory() + "./network.shp"; @@ -85,7 +87,8 @@ public class Network2ESRIShapeTest { Assert.assertEquals(network.getLinks().size(), writtenFeatures.size()); } - @Test public void testPolygonFreespeedShape() { + @Test + void testPolygonFreespeedShape() { String netFileName = "test/scenarios/equil/network.xml"; String outputFileP = utils.getOutputDirectory() + "./network.shp"; @@ -107,7 +110,8 @@ public class Network2ESRIShapeTest { Assert.assertEquals(network.getLinks().size(), writtenFeatures.size()); } - @Test public void testLineStringShape() { + @Test + void testLineStringShape() { String netFileName = "test/scenarios/equil/network.xml"; String outputFileShp = utils.getOutputDirectory() + "./network.shp"; @@ -129,7 +133,8 @@ public class Network2ESRIShapeTest { Assert.assertEquals(network.getLinks().size(), writtenFeatures.size()); } - @Test public void testNodesShape() { + @Test + void testNodesShape() { String netFileName = "test/scenarios/equil/network.xml"; String outputFileShp = utils.getOutputDirectory() + "./network.shp"; diff --git a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShapeTest.java b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShapeTest.java index eb8441dce27..13f5e0eb3c4 100755 --- a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShapeTest.java +++ b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShapeTest.java @@ -25,8 +25,8 @@ import java.util.zip.GZIPInputStream; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.population.Population; @@ -45,7 +45,8 @@ public class SelectedPlans2ESRIShapeTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testSelectedPlansActsShape() throws IOException { + @Test + void testSelectedPlansActsShape() throws IOException { String outputDir = utils.getOutputDirectory(); String outShp = utils.getOutputDirectory() + "acts.shp"; @@ -69,7 +70,8 @@ public class SelectedPlans2ESRIShapeTest { Assert.assertEquals(2235, writtenFeatures.size()); } - @Test public void testSelectedPlansLegsShape() throws IOException { + @Test + void testSelectedPlansLegsShape() throws IOException { String outputDir = utils.getOutputDirectory(); String outShp = utils.getOutputDirectory() + "legs.shp"; diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesConverterTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesConverterTest.java index 320a488bd17..3ae0e9ed2ab 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesConverterTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesConverterTest.java @@ -22,7 +22,7 @@ package org.matsim.utils.objectattributes; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.time.Month; import java.util.Arrays; @@ -33,13 +33,13 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -/** + /** * @author thibautd */ public class ObjectAttributesConverterTest { - @Test - public void testEnumToString() { + @Test + void testEnumToString() { final ObjectAttributesConverter converter = new ObjectAttributesConverter(); // cannot use an enum type defined here, because test classes are not on classpath for classes outside of test... // And is thus unavailable to the ObjectAttributesConverter @@ -48,15 +48,15 @@ public void testEnumToString() { Assert.assertEquals("unexpected string converted from enum value", "JANUARY", converted); } - @Test - public void testStringToEnum() { + @Test + void testStringToEnum() { final ObjectAttributesConverter converter = new ObjectAttributesConverter(); Object converted = converter.convert(Month.class.getCanonicalName(), "JANUARY"); Assert.assertEquals("unexpected enum converted from String value", Month.JANUARY, converted); } - @Test - public void testHashMap() { + @Test + void testHashMap() { var expectedString = "{\"a\":\"value-a\",\"b\":\"value-b\"}"; final var converter = new ObjectAttributesConverter(); @@ -67,8 +67,8 @@ public void testHashMap() { assertEquals(expectedString, serialized); } - @Test - public void testEmptyHashMap() { + @Test + void testEmptyHashMap() { var expectedString = "{}"; final var converter = new ObjectAttributesConverter(); @@ -79,8 +79,8 @@ public void testEmptyHashMap() { assertEquals(expectedString, serialized); } - @Test - public void testCollection() { + @Test + void testCollection() { var expectedString = "[\"a\",\"b\"]"; final var converter = new ObjectAttributesConverter(); @@ -91,8 +91,8 @@ public void testCollection() { assertEquals(expectedString, serialized); } - @Test - public void testEmptyCollection() { + @Test + void testEmptyCollection() { var expectedString = "[]"; final var converter = new ObjectAttributesConverter(); @@ -103,8 +103,8 @@ public void testEmptyCollection() { assertEquals(expectedString, serialized); } - @Test - public void testUnsupported() { + @Test + void testUnsupported() { final var converter = new ObjectAttributesConverter(); var serialized = converter.convertToString(new UnsupportedType()); diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesTest.java index a4f2994f7e6..68d563e731a 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesTest.java @@ -20,7 +20,7 @@ package org.matsim.utils.objectattributes; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author mrieser @@ -28,7 +28,7 @@ public class ObjectAttributesTest { @Test - public void testPutGet() { + void testPutGet() { ObjectAttributes linkAttributes = new ObjectAttributes(); Assert.assertNull(linkAttributes.getAttribute("1", "osm:roadtype")); Assert.assertNull(linkAttributes.putAttribute("1", "osm:roadtype", "trunk")); diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesUtilsTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesUtilsTest.java index 02e88fe5b0f..44b32343163 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesUtilsTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesUtilsTest.java @@ -23,7 +23,7 @@ import java.util.Iterator; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author mrieser / Senozon AG @@ -31,7 +31,7 @@ public class ObjectAttributesUtilsTest { @Test - public void testGetAllAttributes() { + void testGetAllAttributes() { ObjectAttributes oa = new ObjectAttributes(); oa.putAttribute("1", "a", "A"); oa.putAttribute("1", "b", "B"); @@ -44,9 +44,9 @@ public void testGetAllAttributes() { Assert.assertTrue(names.contains("c")); Assert.assertFalse(names.contains("d")); } - + @Test - public void testGetAllAttributes_isImmutable() { + void testGetAllAttributes_isImmutable() { ObjectAttributes oa = new ObjectAttributes(); oa.putAttribute("1", "a", "A"); oa.putAttribute("1", "b", "B"); diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlIOTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlIOTest.java index 8cbc027a81b..dd98dd5db7b 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlIOTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlIOTest.java @@ -24,8 +24,8 @@ import javax.xml.parsers.ParserConfigurationException; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; import org.xml.sax.SAXException; @@ -38,7 +38,7 @@ public class ObjectAttributesXmlIOTest { public MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testReadWrite() throws IOException, SAXException, ParserConfigurationException { + void testReadWrite() throws IOException, SAXException, ParserConfigurationException { ObjectAttributes oa1 = new ObjectAttributes(); oa1.putAttribute("one", "a", "A"); oa1.putAttribute("one", "b", Integer.valueOf(1)); @@ -55,7 +55,7 @@ public void testReadWrite() throws IOException, SAXException, ParserConfiguratio } @Test - public void testReadWrite_CustomAttribute() { + void testReadWrite_CustomAttribute() { ObjectAttributes oa1 = new ObjectAttributes(); MyTuple t = new MyTuple(3, 4); oa1.putAttribute("1", "A", t); diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlReaderTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlReaderTest.java index b02914eaada..b9b0f592bb0 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlReaderTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlReaderTest.java @@ -25,8 +25,8 @@ import javax.xml.parsers.ParserConfigurationException; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; import org.xml.sax.SAXException; @@ -38,7 +38,7 @@ public class ObjectAttributesXmlReaderTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testParse_customConverter() throws SAXException, ParserConfigurationException, IOException { + void testParse_customConverter() throws SAXException, ParserConfigurationException, IOException { String tupleClass = MyTuple.class.getCanonicalName(); String str = "\n" + "\n" + @@ -66,7 +66,7 @@ public void testParse_customConverter() throws SAXException, ParserConfiguration } @Test - public void testParse_missingConverter() throws SAXException, ParserConfigurationException, IOException { + void testParse_missingConverter() throws SAXException, ParserConfigurationException, IOException { String tupleClass = MyTuple.class.getCanonicalName(); String str = "\n" + "\n" + @@ -97,7 +97,7 @@ public void testParse_missingConverter() throws SAXException, ParserConfiguratio } @Test - public void testParse_withDtd() throws SAXException, ParserConfigurationException, IOException { + void testParse_withDtd() throws SAXException, ParserConfigurationException, IOException { String filename = this.utils.getPackageInputDirectory() + "objectattributes_withDtd_v1.xml"; ObjectAttributes oa = new ObjectAttributes(); new ObjectAttributesXmlReader(oa).readFile(filename); @@ -116,7 +116,7 @@ public void testParse_withDtd() throws SAXException, ParserConfigurationExceptio } @Test - public void testParse_withoutDtd() throws SAXException, ParserConfigurationException, IOException { + void testParse_withoutDtd() throws SAXException, ParserConfigurationException, IOException { String filename = this.utils.getPackageInputDirectory() + "objectattributes_withoutDtd_v1.xml"; ObjectAttributes oa = new ObjectAttributes(); new ObjectAttributesXmlReader(oa).readFile(filename); diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/attributable/AttributesTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/attributable/AttributesTest.java index 9f579912697..6b43346e33c 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/attributable/AttributesTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/attributable/AttributesTest.java @@ -22,18 +22,18 @@ package org.matsim.utils.objectattributes.attributable; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; -/** + /** * @author thibautd */ public class AttributesTest { - @Test - public void testInsertion() { + @Test + void testInsertion() { final Attributes attributes = new AttributesImpl(); attributes.putAttribute( "sun" , "nice" ); @@ -61,8 +61,8 @@ public void testInsertion() { attributes.getAttribute( "1 the begin" ) ); } - @Test - public void testReplacement() { + @Test + void testReplacement() { final Attributes attributes = new AttributesImpl(); attributes.putAttribute( "sun" , "nice" ); @@ -84,8 +84,8 @@ public void testReplacement() { attributes.getAttribute( "the answer" ) ); } - @Test - public void testRemoval() { + @Test + void testRemoval() { final Attributes attributes = new AttributesImpl(); attributes.putAttribute( "sun" , "nice" ); @@ -106,8 +106,8 @@ public void testRemoval() { attributes.getAttribute( "rain is nice" ) ); } - @Test - public void testGetAsMap() { + @Test + void testGetAsMap() { final Attributes attributes = new AttributesImpl(); attributes.putAttribute( "sun" , "nice" ); diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/attributable/AttributesUtilsTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/attributable/AttributesUtilsTest.java index 6899fcafc30..7507806be8e 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/attributable/AttributesUtilsTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/attributable/AttributesUtilsTest.java @@ -1,13 +1,13 @@ package org.matsim.utils.objectattributes.attributable; -import org.junit.Test; - import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; + public class AttributesUtilsTest { @Test - public void testCopyToWithPrimitive() { + void testCopyToWithPrimitive() { var data = 1L; var attributeKey = "data-key"; diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/CoordArrayConverterTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/CoordArrayConverterTest.java index d276dfa2fd1..c57aa1a4b75 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/CoordArrayConverterTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/CoordArrayConverterTest.java @@ -21,14 +21,13 @@ package org.matsim.utils.objectattributes.attributeconverters; import org.junit.Assert; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; public class CoordArrayConverterTest { - @Test - public void testFromToString() { + @Test + void testFromToString() { final CoordArrayConverter converter = new CoordArrayConverter(); String a = "[(223380.4988791829;6758072.4280857295),(223404.67545027257;6758049.17275259),(223417.0127605943;6758038.021038004),(223450.67625251273;6757924.791645723),(223456.13332351885;6757906.359813054)]"; Coord[] coords = converter.convert(a); diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/CoordConverterTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/CoordConverterTest.java index d0124325540..ee8b2db2c58 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/CoordConverterTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/CoordConverterTest.java @@ -21,14 +21,14 @@ package org.matsim.utils.objectattributes.attributeconverters; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; public class CoordConverterTest { - @Test - public void testFromToString() { + @Test + void testFromToString() { final CoordConverter converter = new CoordConverter(); String a = "(224489.3667496938;6757449.720111595)"; Coord coord = converter.convert(a); diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/DoubleArrayConverterTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/DoubleArrayConverterTest.java index 16a43974d74..e97d61653a8 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/DoubleArrayConverterTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/DoubleArrayConverterTest.java @@ -22,16 +22,16 @@ package org.matsim.utils.objectattributes.attributeconverters; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; -/** + /** * @author jbischoff */ public class DoubleArrayConverterTest { - @Test - public void testFromToString() { + @Test + void testFromToString() { final DoubleArrayConverter converter = new DoubleArrayConverter(); String a = "-0.1,0,0.0005,17.3,5.2E22"; double[] array = converter.convert(a); diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/EnumConverterTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/EnumConverterTest.java index 5044319f55d..63318c6c71a 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/EnumConverterTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/EnumConverterTest.java @@ -22,9 +22,9 @@ package org.matsim.utils.objectattributes.attributeconverters; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; -/** + /** * @author thibautd */ public class EnumConverterTest { @@ -38,8 +38,8 @@ public String toString() { } } - @Test - public void testFromString() { + @Test + void testFromString() { final EnumConverter converter = new EnumConverter<>( MyEnum.class ); MyEnum some = converter.convert( "SOME_CONSTANT" ); @@ -49,8 +49,8 @@ public void testFromString() { Assert.assertEquals("unexpected enum", MyEnum.SOME_OTHER_CONSTANT, other); } - @Test - public void testToString() { + @Test + void testToString() { final EnumConverter converter = new EnumConverter<>( MyEnum.class ); Assert.assertEquals( "unexpected String value", "SOME_CONSTANT", converter.convertToString( MyEnum.SOME_CONSTANT ) ); diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/StringCollectionConverterTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/StringCollectionConverterTest.java index 3eb55a83e1c..7470881f42d 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/StringCollectionConverterTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/StringCollectionConverterTest.java @@ -1,16 +1,16 @@ package org.matsim.utils.objectattributes.attributeconverters; -import org.junit.Test; - import java.util.Collection; import java.util.Map; import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; + public class StringCollectionConverterTest { @Test - public void test() { + void test() { var expectedString = "[\"a\",\"b\"]"; var converter = new StringCollectionConverter(); diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/StringStringMapConverterTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/StringStringMapConverterTest.java index 31e56474bf7..686cc3efe37 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/StringStringMapConverterTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/StringStringMapConverterTest.java @@ -1,13 +1,13 @@ package org.matsim.utils.objectattributes.attributeconverters; -import org.junit.Test; - import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; + public class StringStringMapConverterTest { @Test - public void test() { + void test() { var expectedString = "{\"a\":\"value-a\",\"b\":\"value-b\"}"; var converter = new StringStringMapConverter(); diff --git a/matsim/src/test/java/org/matsim/vehicles/MatsimVehicleWriterTest.java b/matsim/src/test/java/org/matsim/vehicles/MatsimVehicleWriterTest.java index 6c0b4d9858e..152586c364d 100644 --- a/matsim/src/test/java/org/matsim/vehicles/MatsimVehicleWriterTest.java +++ b/matsim/src/test/java/org/matsim/vehicles/MatsimVehicleWriterTest.java @@ -29,8 +29,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.testcases.MatsimTestUtils; @@ -60,7 +60,8 @@ public class MatsimVehicleWriterTest { id42_23 = Id.create(" 42 23", Vehicle.class); } - @Test public void testWriter() throws FileNotFoundException, IOException { + @Test + void testWriter() throws FileNotFoundException, IOException { { String outfileName = utils.getOutputDirectory() + "testOutputVehicles.xml"; diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV1Test.java b/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV1Test.java index 4ff191bfbfc..7f6716c5acd 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV1Test.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV1Test.java @@ -24,8 +24,8 @@ import java.util.Map; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.testcases.MatsimTestUtils; @@ -63,12 +63,14 @@ public class VehicleReaderV1Test { id42_23 = Id.create(" 42 23", Vehicle.class); } - @Test public void test_NumberOfVehicleTypeisReadCorrectly() { + @Test + void test_NumberOfVehicleTypeisReadCorrectly() { assertNotNull(vehicleTypes); assertEquals(2, vehicleTypes.size()); } - @Test public void test_VehicleTypeValuesAreReadCorrectly_normalCar() { + @Test + void test_VehicleTypeValuesAreReadCorrectly_normalCar() { assertNotNull(vehicleTypes); assertEquals(2, vehicleTypes.size()); VehicleType vehType = vehicleTypes.get(Id.create("normal&Car", VehicleType.class)); @@ -91,7 +93,8 @@ public class VehicleReaderV1Test { assertEquals(2.0, vehType.getPcuEquivalents(), 0); } - @Test public void test_VehicleTypeValuesAreReadCorrectly_defaultCar() { + @Test + void test_VehicleTypeValuesAreReadCorrectly_defaultCar() { VehicleType vehType = vehicleTypes.get(Id.create("defaultValue>Car", VehicleType.class)); assertNotNull(vehType); assertEquals(7.5, vehType.getLength(), MatsimTestUtils.EPSILON); @@ -101,12 +104,14 @@ public class VehicleReaderV1Test { assertEquals(1.0, vehType.getPcuEquivalents(), 0); } - @Test public void test_NumberOfVehiclesIsReadCorrectly() { + @Test + void test_NumberOfVehiclesIsReadCorrectly() { assertNotNull(vehicles); assertEquals(3, vehicles.size()); } - @Test public void test_VehicleTypeToVehiclesAssignmentIsReadCorrectly() { + @Test + void test_VehicleTypeToVehiclesAssignmentIsReadCorrectly() { assertNotNull(vehicles.get(id23)); assertEquals(id23, vehicles.get(id23).getId()); assertEquals(Id.create("normal&Car", VehicleType.class), vehicles.get(id23).getType().getId()); diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV2Test.java b/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV2Test.java index 5e2208a4a88..599b853217d 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV2Test.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV2Test.java @@ -24,8 +24,8 @@ import java.util.Map; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.testcases.MatsimTestUtils; @@ -64,12 +64,14 @@ public class VehicleReaderV2Test { id42_23 = Id.create(" 42 23", Vehicle.class); } - @Test public void test_NumberOfVehicleTypeisReadCorrectly() { + @Test + void test_NumberOfVehicleTypeisReadCorrectly() { assertNotNull(vehicleTypes); assertEquals(3, vehicleTypes.size()); } - @Test public void test_VehicleAttributesReadCorrectly(){ + @Test + void test_VehicleAttributesReadCorrectly(){ assertNotNull(vehicleTypes); /* First vehicle has an attribute. */ Vehicle v1 = vehicles.get(Id.createVehicleId("23")); @@ -91,7 +93,8 @@ public class VehicleReaderV2Test { } - @Test public void test_VehicleTypeValuesAreReadCorrectly_normalCar() { + @Test + void test_VehicleTypeValuesAreReadCorrectly_normalCar() { VehicleType vehTypeNormalCar = vehicleTypes.get(Id.create("normal&Car", VehicleType.class)); assertNotNull(vehTypeNormalCar); assertEquals(9.5, vehTypeNormalCar.getLength(), MatsimTestUtils.EPSILON); @@ -131,7 +134,8 @@ public class VehicleReaderV2Test { assertEquals(VehicleType.DoorOperationMode.parallel, VehicleUtils.getDoorOperationMode(vehTypeNormalCar)); } - @Test public void test_VehicleTypeValuesAreReadCorrectly_defaultCar() { + @Test + void test_VehicleTypeValuesAreReadCorrectly_defaultCar() { VehicleType vehTypeDefaultCar = vehicleTypes.get(Id.create("defaultValue>Car", VehicleType.class)); assertNotNull(vehTypeDefaultCar); assertEquals(7.5, vehTypeDefaultCar.getLength(), MatsimTestUtils.EPSILON); @@ -147,7 +151,8 @@ public class VehicleReaderV2Test { assertEquals(2, vehTypeDefaultCar.getAttributes().getAttribute("Attribute2")); } - @Test public void test_VehicleTypeValuesAreReadCorrectly_smallTruck() { + @Test + void test_VehicleTypeValuesAreReadCorrectly_smallTruck() { VehicleType vehTypeSmallTruck = vehicleTypes.get(Id.create("smallTruck", VehicleType.class)); assertNotNull(vehTypeSmallTruck); assertEquals("This is a small truck", vehTypeSmallTruck.getDescription()); @@ -169,12 +174,14 @@ public class VehicleReaderV2Test { assertEquals(0.15, VehicleUtils.getCostsPerSecondInService(vehTypeSmallTruck.getCostInformation()), MatsimTestUtils.EPSILON); } - @Test public void test_NumberOfVehiclesIsReadCorrectly() { + @Test + void test_NumberOfVehiclesIsReadCorrectly() { assertNotNull(vehicles); assertEquals(3, vehicles.size()); } - @Test public void test_VehicleTypeToVehiclesAssignmentIsReadCorrectly() { + @Test + void test_VehicleTypeToVehiclesAssignmentIsReadCorrectly() { assertNotNull(vehicles.get(id23)); assertEquals(id23, vehicles.get(id23).getId()); assertEquals(Id.create("normal&Car", VehicleType.class), vehicles.get(id23).getType().getId()); diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleWriteReadTest.java b/matsim/src/test/java/org/matsim/vehicles/VehicleWriteReadTest.java index ea13e5dd1b4..3caafd4c6af 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleWriteReadTest.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleWriteReadTest.java @@ -6,8 +6,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.testcases.MatsimTestUtils; public class VehicleWriteReadTest{ @@ -28,7 +28,7 @@ public void setUp() throws IOException { } @Test - public void v1_isWrittenCorrect () throws FileNotFoundException, IOException { + void v1_isWrittenCorrect() throws FileNotFoundException, IOException { //----- V1 -------- //read it Vehicles vehicles1 = VehicleUtils.createVehiclesContainer(); @@ -46,7 +46,7 @@ public void v1_isWrittenCorrect () throws FileNotFoundException, IOException { } @Test - public void v2_isWrittenCorrect () throws FileNotFoundException, IOException { + void v2_isWrittenCorrect() throws FileNotFoundException, IOException { //----- V2 -------- //read it Vehicles vehicles2 = VehicleUtils.createVehiclesContainer(); diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV1Test.java b/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV1Test.java index 7625ba85319..d103a29f287 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV1Test.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV1Test.java @@ -27,8 +27,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.testcases.MatsimTestUtils; @@ -59,7 +59,8 @@ public class VehicleWriterV1Test { id42_23 = Id.create(" 42 23", Vehicle.class); } - @Test public void testWriter() { + @Test + void testWriter() { String outfileName = utils.getOutputDirectory() + "testOutputVehicles.xml"; diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV2Test.java b/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV2Test.java index d7242617d79..9b65d2f6608 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV2Test.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV2Test.java @@ -28,8 +28,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.testcases.MatsimTestUtils; @@ -81,13 +81,15 @@ public class VehicleWriterV2Test { } - @Test public void test_NumberOfVehicleTypeisReadCorrectly() { + @Test + void test_NumberOfVehicleTypeisReadCorrectly() { assertNotNull(vehicleTypes); assertEquals(3, vehicleTypes.size()); } - @Test public void test_VehicleTypeValuesAreReadCorrectly_normalCar() { + @Test + void test_VehicleTypeValuesAreReadCorrectly_normalCar() { VehicleType vehTypeNormalCar = vehicleTypes.get(Id.create("normal&Car", VehicleType.class)); assertNotNull(vehTypeNormalCar); assertEquals(9.5, vehTypeNormalCar.getLength(), MatsimTestUtils.EPSILON); @@ -128,7 +130,8 @@ public class VehicleWriterV2Test { } - @Test public void test_VehicleTypeValuesAreReadCorrectly_defaultCar() { + @Test + void test_VehicleTypeValuesAreReadCorrectly_defaultCar() { VehicleType vehTypeDefaultCar = vehicleTypes.get(Id.create("defaultValue>Car", VehicleType.class)); assertNotNull(vehTypeDefaultCar); assertEquals(7.5, vehTypeDefaultCar.getLength(), MatsimTestUtils.EPSILON); @@ -147,7 +150,8 @@ public class VehicleWriterV2Test { } - @Test public void test_VehicleTypeValuesAreReadCorrectly_smallTruck() { + @Test + void test_VehicleTypeValuesAreReadCorrectly_smallTruck() { VehicleType vehTypeSmallTruck = vehicleTypes.get(Id.create("smallTruck", VehicleType.class)); assertNotNull(vehTypeSmallTruck); assertEquals("This is a small truck", vehTypeSmallTruck.getDescription()); @@ -163,13 +167,15 @@ public class VehicleWriterV2Test { } - @Test public void test_NumberOfVehiclesIsReadCorrectly() { + @Test + void test_NumberOfVehiclesIsReadCorrectly() { assertNotNull(vehicles); assertEquals(3, vehicles.size()); } - @Test public void test_VehicleAttributesReadCorrectly(){ + @Test + void test_VehicleAttributesReadCorrectly(){ assertNotNull(vehicleTypes); /* First vehicle has an attribute. */ Vehicle v1 = vehicles.get(Id.createVehicleId("23")); @@ -191,8 +197,8 @@ public class VehicleWriterV2Test { } - - @Test public void test_VehicleTypeToVehiclesAssignmentIsReadCorrectly() { + @Test + void test_VehicleTypeToVehiclesAssignmentIsReadCorrectly() { assertNotNull(vehicles.get(id23)); assertEquals(id23, vehicles.get(id23).getId()); assertEquals(Id.create("normal&Car", VehicleType.class), vehicles.get(id23).getType().getId()); diff --git a/matsim/src/test/java/org/matsim/vehicles/VehiclesImplTest.java b/matsim/src/test/java/org/matsim/vehicles/VehiclesImplTest.java index 96b8671f064..2cace0fd2e6 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehiclesImplTest.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehiclesImplTest.java @@ -20,7 +20,7 @@ package org.matsim.vehicles; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; /** @@ -31,7 +31,7 @@ public class VehiclesImplTest { @Test - public void testAddVehicle() { + void testAddVehicle() { Vehicles vehicles = VehicleUtils.createVehiclesContainer(); VehicleType testType = vehicles.getFactory().createVehicleType(Id.create("test", VehicleType.class)); @@ -59,7 +59,7 @@ public void testAddVehicle() { @Test - public void testGetVehicles(){ + void testGetVehicles(){ Vehicles vehicles = VehicleUtils.createVehiclesContainer(); VehicleType testType = vehicles.getFactory().createVehicleType(Id.create("test", VehicleType.class)); @@ -78,7 +78,7 @@ public void testGetVehicles(){ @Test - public void testGetVehicleTypes(){ + void testGetVehicleTypes(){ Vehicles vehicles = VehicleUtils.createVehiclesContainer(); VehicleType t1 = vehicles.getFactory().createVehicleType(Id.create("type1", VehicleType.class)); @@ -92,7 +92,7 @@ public void testGetVehicleTypes(){ } @Test - public void testAddVehicleType(){ + void testAddVehicleType(){ Vehicles vehicles = VehicleUtils.createVehiclesContainer(); VehicleType t1 = vehicles.getFactory().createVehicleType(Id.create("type1", VehicleType.class)); @@ -108,7 +108,7 @@ public void testAddVehicleType(){ } @Test - public void testRemoveVehicle() { + void testRemoveVehicle() { Vehicles vehicles = VehicleUtils.createVehiclesContainer(); VehicleType t1 = vehicles.getFactory().createVehicleType(Id.create("type1", VehicleType.class)); vehicles.addVehicleType(t1); @@ -123,7 +123,7 @@ public void testRemoveVehicle() { } @Test - public void testRemoveVehicleType() { + void testRemoveVehicleType() { Vehicles vehicles = VehicleUtils.createVehiclesContainer(); VehicleType t1 = vehicles.getFactory().createVehicleType(Id.create("type1", VehicleType.class)); vehicles.addVehicleType(t1); diff --git a/matsim/src/test/java/org/matsim/vis/snapshotwriters/PositionInfoTest.java b/matsim/src/test/java/org/matsim/vis/snapshotwriters/PositionInfoTest.java index 84d11f60338..178b07d1236 100644 --- a/matsim/src/test/java/org/matsim/vis/snapshotwriters/PositionInfoTest.java +++ b/matsim/src/test/java/org/matsim/vis/snapshotwriters/PositionInfoTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -46,7 +46,8 @@ public class PositionInfoTest { * * @author mrieser */ - @Test public void testDistanceOnLink_shortLink() { + @Test + void testDistanceOnLink_shortLink() { Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord(0, 0)); @@ -82,7 +83,8 @@ public class PositionInfoTest { * * @author mrieser */ - @Test public void testDistanceOnLink_longLink() { + @Test + void testDistanceOnLink_longLink() { Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord(0, 0)); diff --git a/matsim/src/test/java/org/matsim/withinday/controller/ExampleWithinDayControllerTest.java b/matsim/src/test/java/org/matsim/withinday/controller/ExampleWithinDayControllerTest.java index 4512cfea7e0..a20e95d2d0b 100644 --- a/matsim/src/test/java/org/matsim/withinday/controller/ExampleWithinDayControllerTest.java +++ b/matsim/src/test/java/org/matsim/withinday/controller/ExampleWithinDayControllerTest.java @@ -22,8 +22,8 @@ package org.matsim.withinday.controller; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Leg; import org.matsim.core.config.Config; @@ -43,7 +43,7 @@ public class ExampleWithinDayControllerTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testRun() { + void testRun() { Config config = utils.loadConfig("test/scenarios/equil/config.xml"); config.controller().setLastIteration(1); config.controller().setRoutingAlgorithmType(ControllerConfigGroup.RoutingAlgorithmType.Dijkstra); diff --git a/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java b/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java index c1b95aa5670..88ee4b705a2 100644 --- a/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java +++ b/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java @@ -23,8 +23,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -77,7 +77,7 @@ public class ExperiencedPlansWriterTest { private MatsimTestUtils utils = new MatsimTestUtils(); @Test - public void testWriteFile() { + void testWriteFile() { Config config = ConfigUtils.createConfig(); diff --git a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java index 59c2ed7e244..f0870a25f99 100644 --- a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java +++ b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java @@ -26,9 +26,8 @@ import java.util.Map; import jakarta.inject.Inject; - +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Person; @@ -58,7 +57,8 @@ public class ActivityReplanningMapTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @Test public void testGetTimeBin() { + @Test + void testGetTimeBin() { ActivityReplanningMap arp = new ActivityReplanningMap(null, EventsUtils.createEventsManager()); // test default setting with start time = 0.0 and time step size = 1.0 @@ -97,7 +97,8 @@ public class ActivityReplanningMapTest { assertEquals(2, arp.getTimeBin(12.1)); } - @Test public void testScenarioRun() { + @Test + void testScenarioRun() { // load config and use ParallelQSim with 2 Threads Config config = utils.loadConfig("test/scenarios/equil/config.xml"); diff --git a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java index 4f5157fb784..ed3ffd5c1a7 100644 --- a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java +++ b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java @@ -23,9 +23,8 @@ import static org.junit.Assert.assertEquals; import jakarta.inject.Inject; - +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; @@ -49,8 +48,8 @@ public class LinkReplanningMapTest { private MatsimTestUtils utils = new MatsimTestUtils(); - - @Test public void testScenarioRun() { + @Test + void testScenarioRun() { // load config and use ParallelQSim with 2 Threads Config config = utils.loadConfig("test/scenarios/equil/config.xml"); diff --git a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java index 7af481f6af8..8bb4b9ca4f6 100644 --- a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java +++ b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; @@ -62,12 +62,12 @@ public class WithinDayTravelTimeTest { private double originalFreeSpeed22; @Test - public void testGetLinkTravelTime_fastCapacityUpdate() { + void testGetLinkTravelTime_fastCapacityUpdate() { testGetLinkTravelTime(true); } @Test - public void testGetLinkTravelTime_noFastCapacityUpdate() { + void testGetLinkTravelTime_noFastCapacityUpdate() { testGetLinkTravelTime(false); } diff --git a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java index 25f5076e8b9..85961c100a2 100644 --- a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java +++ b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java @@ -25,8 +25,8 @@ import java.util.Set; import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -72,7 +72,7 @@ public class WithinDayTravelTimeWithNetworkChangeEventsTest { private Id link23 = Id.createLinkId("link_2_3"); @Test - public final void testTTviaMobSimAfterSimStepListener() { + final void testTTviaMobSimAfterSimStepListener() { String outputDirectory = testUtils.getOutputDirectory() + "output_TTviaMobsimAfterSimStepListener/"; diff --git a/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java b/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java index 8c87bda545e..6931b60b91f 100644 --- a/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java +++ b/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java @@ -28,8 +28,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -87,7 +87,8 @@ public class EditRoutesTest { /** * @author cdobler */ - @Test public void testReplanFutureLegRoute() { + @Test + void testReplanFutureLegRoute() { // this is ok (we can still replan a single leg with the computer science router). kai, dec'15 createScenario(); @@ -144,7 +145,8 @@ public class EditRoutesTest { assertEquals(3, networkRouteWH.getLinkIds().size()); // l4, l5, l2 } - @Test public void testRelocateFutureLegRoute() { + @Test + void testRelocateFutureLegRoute() { // yyyy this test is misleading. "relocateFutureLegRoute" is ok, but it does not look after the overall plan consistency, // as this test implies. kai, feb'16 @@ -226,7 +228,8 @@ public class EditRoutesTest { /** * @author cdobler */ - @Test public void testReplanCurrentLegRouteOne() + @Test + void testReplanCurrentLegRouteOne() // this is ok (we can still replan a single leg with the computer science router). kai, dec'15 { createScenario(); @@ -270,7 +273,9 @@ public class EditRoutesTest { assertEquals(true, ed.replanCurrentLegRoute((Leg) plan.getPlanElements().get(scndCarLeg), plan.getPerson(), 4, 8.0*3600 )); // WH, end Link } - @Test public void testReplanCurrentLegRouteTwo() + + @Test + void testReplanCurrentLegRouteTwo() { /* * replace destinations and create new routes @@ -297,7 +302,9 @@ public class EditRoutesTest { log.warn( route ); assertEquals(true, checkRouteValidity(route)); } - @Test public void testReplanCurrentLegRouteThree() + + @Test + void testReplanCurrentLegRouteThree() { createScenario(); // reset scenario EditRoutes ed = new EditRoutes(scenario.getNetwork(), pathCalculator, scenario.getPopulation().getFactory()); @@ -317,7 +324,9 @@ public class EditRoutesTest { final NetworkRoute route = (NetworkRoute)((Leg)plan.getPlanElements().get(firstCarLeg)).getRoute(); assertEquals(true, checkRouteValidity(route)); } - @Test public void testReplanCurrentLegRouteFour() + + @Test + void testReplanCurrentLegRouteFour() { createScenario(); // reset scenario EditRoutes ed = new EditRoutes(scenario.getNetwork(), pathCalculator, scenario.getPopulation().getFactory()); @@ -337,7 +346,9 @@ public class EditRoutesTest { final NetworkRoute route = (NetworkRoute)((Leg)plan.getPlanElements().get(firstCarLeg)).getRoute(); assertEquals(true, checkRouteValidity(route)); } - @Test public void testReplanCurrentLegRouteFive() + + @Test + void testReplanCurrentLegRouteFive() { // create new routes for WH-trip createScenario(); // reset scenario @@ -357,7 +368,9 @@ public class EditRoutesTest { assertEquals(true, ed.replanCurrentLegRoute((Leg) plan.getPlanElements().get(scndCarLeg), plan.getPerson(), 0, 8.0*3600 )); // WH, start Link assertEquals(true, checkRouteValidity((NetworkRoute)((Leg)plan.getPlanElements().get(scndCarLeg)).getRoute())); } - @Test public void testReplanCurrentLegRouteSix() + + @Test + void testReplanCurrentLegRouteSix() { createScenario(); // reset scenario EditRoutes ed = new EditRoutes(scenario.getNetwork(), pathCalculator, scenario.getPopulation().getFactory()); @@ -376,7 +389,9 @@ public class EditRoutesTest { assertEquals(true, ed.replanCurrentLegRoute((Leg) plan.getPlanElements().get(scndCarLeg), plan.getPerson(), 1, 8.0*3600 )); // WH, en-route assertEquals(true, checkRouteValidity((NetworkRoute)((Leg)plan.getPlanElements().get(scndCarLeg)).getRoute())); } - @Test public void testReplanCurrentLegRouteSeven() + + @Test + void testReplanCurrentLegRouteSeven() { createScenario(); // reset scenario EditRoutes ed = new EditRoutes(scenario.getNetwork(), pathCalculator, scenario.getPopulation().getFactory()); @@ -395,7 +410,9 @@ public class EditRoutesTest { assertEquals(true, ed.replanCurrentLegRoute((Leg) plan.getPlanElements().get(scndCarLeg), plan.getPerson(), 2, 8.0*3600 )); // WH, en-route assertEquals(true, checkRouteValidity((NetworkRoute)((Leg)plan.getPlanElements().get(scndCarLeg)).getRoute())); } - @Test public void testReplanCurrentLegRouteEight() + + @Test + void testReplanCurrentLegRouteEight() { createScenario(); // reset scenario EditRoutes ed = new EditRoutes(scenario.getNetwork(), pathCalculator, scenario.getPopulation().getFactory()); @@ -414,7 +431,9 @@ public class EditRoutesTest { assertEquals(true, ed.replanCurrentLegRoute((Leg) plan.getPlanElements().get(scndCarLeg), plan.getPerson(), 3, 8.0*3600 ) ); // WH, en-route assertEquals(true, checkRouteValidity((NetworkRoute)((Leg)plan.getPlanElements().get(scndCarLeg)).getRoute())); } - @Test public void testReplanCurrentLegRouteNine() + + @Test + void testReplanCurrentLegRouteNine() { createScenario(); // reset scenario EditRoutes ed = new EditRoutes(scenario.getNetwork(), pathCalculator, scenario.getPopulation().getFactory()); @@ -434,7 +453,9 @@ public class EditRoutesTest { assertEquals(true, checkRouteValidity((NetworkRoute)((Leg)plan.getPlanElements().get(scndCarLeg)).getRoute())); } - @Test public void testReplanCurrentLegRouteTen() + + @Test + void testReplanCurrentLegRouteTen() { // expect EditRoutes to return false if the Route in the leg is not a NetworkRoute createScenario(); // reset scenario diff --git a/matsim/src/test/java/org/matsim/withinday/utils/ReplacePlanElementsTest.java b/matsim/src/test/java/org/matsim/withinday/utils/ReplacePlanElementsTest.java index 23c69bdc66d..3d2f16c8350 100644 --- a/matsim/src/test/java/org/matsim/withinday/utils/ReplacePlanElementsTest.java +++ b/matsim/src/test/java/org/matsim/withinday/utils/ReplacePlanElementsTest.java @@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -44,7 +44,8 @@ public class ReplacePlanElementsTest { /** * @author cdobler */ - @Test public void testReplaceActivity() { + @Test + void testReplaceActivity() { Plan plan = createSamplePlan(); Activity oldActivity = (Activity)plan.getPlanElements().get(0); Activity newActivity = PopulationUtils.createActivityFromCoord("s", new Coord((double) 200, (double) 200)); @@ -67,7 +68,8 @@ public class ReplacePlanElementsTest { /** * @author cdobler */ - @Test public void testReplaceLeg() { + @Test + void testReplaceLeg() { Plan plan = createSamplePlan(); Leg oldLeg = (Leg)plan.getPlanElements().get(1); Leg newLeg = PopulationUtils.createLeg(TransportMode.walk); From 3416b4a62a0e3fa4885f315cd6ec6cbb67888e3a Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Mon, 11 Dec 2023 19:42:25 +0100 Subject: [PATCH 11/21] Migrate JUnit 4 Assert To JUnit Jupiter Assertions --- .../accessibility/LeastCostPathTreeTest.java | 14 +- .../accessibility/grid/SpatialGridTest.java | 6 +- .../CompareLogsumFormulas2Test.java | 4 +- .../CompareLogsumFormulasTest.java | 4 +- .../ComputeLogsumFormulas3Test.java | 6 +- .../run/AccessibilityIntegrationTest.java | 112 ++-- .../accessibility/run/NetworkUtilTest.java | 106 +-- .../run/TinyAccessibilityTest.java | 18 +- .../run/TinyMultimodalAccessibilityTest.java | 26 +- .../BvwpAccidentsCostComputationTest.java | 8 +- .../org/matsim/contrib/accidents/RunTest.java | 6 +- .../contrib/accidents/RunTestEquil.java | 13 +- .../PersonIntersectAreaFilterTest.java | 18 +- .../population/RouteLinkFilterTest.java | 4 +- .../kai/KNAnalysisEventsHandlerTest.java | 4 +- .../contrib/analysis/spatial/GridTest.java | 4 +- .../spatial/SpatialInterpolationTest.java | 4 +- .../contrib/analysis/time/TimeBinMapTest.java | 3 +- .../GoogleMapRouteValidatorTest.java | 4 +- .../HereMapsRouteValidatorTest.java | 2 +- .../application/ApplicationUtilsTest.java | 2 +- .../application/MATSimApplicationTest.java | 4 +- .../application/options/ShpOptionsTest.java | 4 +- .../counts/CreateCountsFromBAStDataTest.java | 6 +- .../CarrierReaderFromCSVTest.java | 176 ++--- .../DemandReaderFromCSVTest.java | 286 ++++---- .../FreightDemandGenerationTest.java | 4 +- .../FreightDemandGenerationUtilsTest.java | 112 ++-- .../LanduseBuildingAnalysisTest.java | 252 +++---- ...nerateSmallScaleCommercialTrafficTest.java | 16 +- .../SmallScaleCommercialTrafficUtilsTest.java | 18 +- .../TrafficVolumeGenerationTest.java | 542 +++++++-------- .../TripDistributionMatrixTest.java | 34 +- .../contrib/av/flow/TestAvFlowFactor.java | 6 +- .../RunTaxiPTIntermodalExampleIT.java | 6 +- .../BicycleLinkSpeedCalculatorTest.java | 4 +- .../bicycle/BicycleUtilityUtilsTest.java | 2 +- .../contrib/bicycle/run/BicycleTest.java | 83 +-- .../contrib/cadyts/car/CadytsCarIT.java | 64 +- .../cadyts/car/CadytsCarWithPtScenarioIT.java | 8 +- .../utils/CalibrationStatReaderTest.java | 27 +- .../runExample/RunCarsharingIT.java | 50 +- .../ChangeCommercialJobOperatorTest.java | 10 +- .../DefaultCommercialServiceScoreTest.java | 10 +- .../IsTheRightCustomerScoredTest.java | 14 +- .../always/BetaTravelTest66IT.java | 4 +- .../integration/always/BetaTravelTest6IT.java | 4 +- .../DecongestionPricingTestIT.java | 66 +- .../SubtourModeChoiceReplacementTest.java | 4 +- .../VehicleTourConstraintTest.java | 4 +- .../components/readers/ApolloTest.java | 4 +- .../tour_finder/ActivityTourFinderTest.java | 4 +- .../ScheduleWaitingTimeEstimatorTest.java | 4 +- .../examples/TestSiouxFalls.java | 4 +- .../models/MaximumUtilityTest.java | 4 +- .../models/MultinomialLogitTest.java | 4 +- .../models/NestedLogitTest.java | 4 +- .../models/RandomUtilityTest.java | 4 +- .../models/nested/NestCalculatorTest.java | 2 +- .../modules/config/ConfigTest.java | 4 +- .../replanning/TestDepartureTimes.java | 4 +- .../DrtWithExtensionsConfigGroupTest.java | 10 +- .../extension/edrt/run/RunEDrtScenarioIT.java | 4 +- .../extension/fiss/RunFissDrtScenarioIT.java | 4 +- .../insertion/DrtInsertionExtensionIT.java | 4 +- .../OperationFacilitiesIOTest.java | 24 +- .../operations/shifts/ShiftsIOTest.java | 2 +- .../efficiency/ShiftEfficiencyTest.java | 12 +- .../analysis/zonal/DrtZonalSystemTest.java | 2 +- .../drt/config/ConfigBehaviorTest.java | 10 +- .../contrib/drt/fare/DrtFareHandlerTest.java | 6 +- .../insertion/DrtPoolingParameterTest.java | 98 +-- .../drt/prebooking/AbandonAndCancelTest.java | 4 +- .../prebooking/ComplexUnschedulerTest.java | 16 +- .../prebooking/PersonStuckPrebookingTest.java | 4 +- .../drt/prebooking/PrebookingTest.java | 2 +- .../drt/routing/DrtRoutingModuleTest.java | 50 +- .../MultiModeDrtMainModeIdentifierTest.java | 8 +- .../drt/run/examples/RunDrtExampleIT.java | 2 +- .../contrib/dvrp/router/DiversionTest.java | 17 +- .../contrib/emissions/EmissionModuleTest.java | 2 +- .../emissions/OsmHbefaMappingTest.java | 3 +- .../TestColdEmissionAnalysisModule.java | 6 +- .../TestColdEmissionAnalysisModuleCase1.java | 4 +- .../TestColdEmissionAnalysisModuleCase2.java | 4 +- .../TestColdEmissionAnalysisModuleCase3.java | 4 +- .../TestColdEmissionAnalysisModuleCase4.java | 4 +- .../TestColdEmissionAnalysisModuleCase6.java | 4 +- .../TestColdEmissionsFallbackBehaviour.java | 14 +- .../TestHbefaColdEmissionFactorKey.java | 26 +- .../emissions/TestHbefaVehicleAttributes.java | 42 +- .../TestHbefaWarmEmissionFactorKey.java | 24 +- .../emissions/TestPositionEmissionModule.java | 4 +- .../TestWarmEmissionAnalysisModule.java | 44 +- .../TestWarmEmissionAnalysisModuleCase1.java | 184 +++--- .../TestWarmEmissionAnalysisModuleCase2.java | 38 +- .../TestWarmEmissionAnalysisModuleCase3.java | 38 +- .../TestWarmEmissionAnalysisModuleCase4.java | 38 +- .../TestWarmEmissionAnalysisModuleCase5.java | 6 +- .../TestWarmEmissionsFallbackBehaviour.java | 14 +- .../VspHbefaRoadTypeMappingTest.java | 2 +- .../analysis/EmissionGridAnalyzerTest.java | 3 +- .../analysis/EmissionsByPollutantTest.java | 4 +- .../EmissionsOnLinkEventHandlerTest.java | 2 +- .../FastEmissionGridAnalyzerTest.java | 4 +- .../emissions/analysis/RasterTest.java | 4 +- .../analysis/RawEmissionEventsReaderTest.java | 2 +- .../events/TestColdEmissionEventImpl.java | 29 +- .../events/TestWarmEmissionEventImpl.java | 35 +- .../events/VehicleLeavesTrafficEventTest.java | 4 +- ...unAverageEmissionToolOfflineExampleIT.java | 10 +- ...nDetailedEmissionToolOfflineExampleIT.java | 8 +- ...EmissionToolOnlineExampleIT_vehTypeV1.java | 6 +- ...eExampleIT_vehTypeV1FallbackToAverage.java | 4 +- ...EmissionToolOnlineExampleIT_vehTypeV2.java | 6 +- ...eExampleIT_vehTypeV2FallbackToAverage.java | 4 +- .../emissions/utils/EmissionUtilsTest.java | 265 ++++---- ...nEvExampleWithLTHConsumptionModelTest.java | 8 +- ...emperatureChangeModuleIntegrationTest.java | 7 +- .../carriers/CarrierEventsReadersTest.java | 16 +- .../carriers/CarrierPlanReaderV1Test.java | 30 +- .../carriers/CarrierPlanXmlReaderV2Test.java | 50 +- .../CarrierPlanXmlReaderV2WithDtdTest.java | 36 +- .../carriers/CarrierPlanXmlWriterV2Test.java | 2 +- .../CarrierPlanXmlWriterV2_1Test.java | 2 +- .../CarrierVehicleTypeLoaderTest.java | 34 +- .../CarrierVehicleTypeReaderTest.java | 4 +- .../carriers/CarrierVehicleTypeTest.java | 50 +- .../freight/carriers/CarriersUtilsTest.java | 46 +- .../FreightCarriersConfigGroupTest.java | 22 +- .../EquilWithCarrierWithPersonsIT.java | 6 +- .../EquilWithCarrierWithoutPersonsIT.java | 16 +- ...istanceConstraintFromVehiclesFileTest.java | 100 +-- .../jsprit/DistanceConstraintTest.java | 134 ++-- .../carriers/jsprit/FixedCostsTest.java | 8 +- .../carriers/jsprit/IntegrationIT.java | 4 +- .../jsprit/MatsimTransformerTest.java | 2 +- .../NetworkBasedTransportCostsTest.java | 20 +- .../freight/carriers/jsprit/SkillsIT.java | 14 +- .../usecases/chessboard/RunChessboardIT.java | 8 +- .../RunPassengerAlongWithCarriersIT.java | 4 +- .../utils/CarrierControlerUtilsIT.java | 18 +- .../utils/CarrierControlerUtilsTest.java | 173 +++-- .../ReceiverCostAllocationFixedTest.java | 4 +- .../freightreceiver/ReceiverPlanTest.java | 6 +- .../freightreceiver/ReceiversReaderTest.java | 88 +-- .../freightreceiver/ReceiversTest.java | 64 +- .../freightreceiver/ReceiversWriterTest.java | 10 +- .../freightreceiver/SSReorderPolicyTest.java | 8 +- .../RelaxedSubtourConstraintTest.java | 2 +- .../integration/daily/SomeDailyTest.java | 4 +- .../integration/weekly/SomeWeeklyTest.java | 4 +- .../locationchoice/LocationChoiceIT.java | 4 +- .../frozenepsilons/FacilityPenaltyTest.java | 6 +- .../FrozenEpsilonLocaChoiceIT.java | 10 +- .../frozenepsilons/SamplerTest.java | 4 +- .../frozenepsilons/ScoringPenaltyTest.java | 4 +- .../LocationMutatorwChoiceSetTest.java | 4 +- .../timegeography/ManageSubchainsTest.java | 2 +- .../timegeography/SubChainTest.java | 2 +- .../router/BackwardFastMultiNodeTest.java | 210 +++--- .../matsim/core/router/FastMultiNodeTest.java | 210 +++--- .../core/router/MultiNodeDijkstraTest.java | 166 ++--- .../MatrixBasedPtRouterIT.java | 4 +- .../matrixbasedptrouter/PtMatrixTest.java | 39 +- .../matrixbasedptrouter/TestQuadTree.java | 6 +- .../genericUtils/TerminusStopFinderTest.java | 10 +- .../minibus/integration/PControlerTestIT.java | 52 +- .../integration/SubsidyContextTestIT.java | 46 +- .../minibus/integration/SubsidyTestIT.java | 6 +- .../replanning/EndRouteExtensionTest.java | 84 +-- .../MaxRandomEndTimeAllocatorTest.java | 28 +- .../MaxRandomStartTimeAllocatorTest.java | 28 +- .../SidewaysRouteExtensionTest.java | 146 ++-- .../minibus/replanning/TimeProviderTest.java | 18 +- .../WeightedEndTimeExtensionTest.java | 48 +- .../WeightedStartTimeExtensionTest.java | 48 +- .../ComplexCircleScheduleProviderTest.java | 34 +- .../SimpleCircleScheduleProviderTest.java | 20 +- ...tionApproachesAndBetweenJunctionsTest.java | 110 +-- .../CreateStopsForAllCarLinksTest.java | 6 +- ...eaBtwLinksVsTerminiBeelinePenaltyTest.java | 4 +- .../RouteDesignScoringManagerTest.java | 16 +- .../StopServedMultipleTimesPenaltyTest.java | 4 +- .../RecursiveStatsApproxContainerTest.java | 66 +- .../stats/RecursiveStatsContainerTest.java | 66 +- .../MultiModalControlerListenerTest.java | 54 +- .../multimodal/MultiModalTripRouterTest.java | 4 +- .../multimodal/RunMultimodalExampleTest.java | 4 +- .../pt/MultiModalPTCombinationTest.java | 10 +- .../router/util/BikeTravelTimeTest.java | 18 +- .../router/util/WalkTravelTimeTest.java | 16 +- .../multimodal/simengine/StuckAgentTest.java | 6 +- .../contrib/noise/NoiseConfigGroupIT.java | 18 +- .../org/matsim/contrib/noise/NoiseIT.java | 298 ++++----- .../contrib/noise/NoiseOnlineExampleIT.java | 8 +- .../matsim/contrib/noise/NoiseRLS19IT.java | 26 +- .../osm/networkReader/LinkPropertiesTest.java | 4 +- .../networkReader/OsmBicycleReaderTest.java | 2 +- .../networkReader/OsmNetworkParserTest.java | 4 +- .../networkReader/OsmSignalsParserTest.java | 4 +- .../SupersonicOsmNetworkReaderTest.java | 2 +- .../contrib/osm/networkReader/Utils.java | 28 +- ...SupersonicOsmNetworkReaderBuilderTest.java | 4 +- .../org/matsim/contrib/otfvis/OTFVisIT.java | 10 +- .../contrib/parking/lib/GeneralLibTest.java | 2 +- .../lib/obj/DoubleValueHashMapTest.java | 2 +- .../lib/obj/LinkedListValueHashMapTest.java | 4 +- .../ParkingCostVehicleTrackerTest.java | 44 +- .../RideParkingCostTrackerTest.java | 44 +- .../run/RunParkingSearchScenarioIT.java | 18 +- .../contrib/pseudosimulation/RunPSimTest.java | 6 +- .../integration/RailsimIntegrationTest.java | 16 +- .../roadpricing/AvoidTolledRouteTest.java | 10 +- .../contrib/roadpricing/CalcPaidTollTest.java | 6 +- .../RoadPricingConfigGroupTest.java | 12 +- .../roadpricing/RoadPricingControlerIT.java | 4 +- .../roadpricing/RoadPricingIOTest.java | 2 +- .../roadpricing/RoadPricingTestUtils.java | 10 +- .../TollTravelCostCalculatorTest.java | 4 +- .../run/RoadPricingByConfigfileTest.java | 10 +- .../run/RunRoadPricingExampleIT.java | 4 +- .../run/RunRoadPricingFromCodeIT.java | 4 +- ...unRoadPricingUsingTollFactorExampleIT.java | 4 +- .../analysis/skims/FloatMatrixIOTest.java | 21 +- .../analysis/skims/RooftopUtilsTest.java | 113 ++-- .../config/SBBTransitConfigGroupTest.java | 8 +- .../matsim/mobsim/qsim/SBBQSimModuleTest.java | 4 +- .../SBBTransitQSimEngineIntegrationTest.java | 14 +- .../qsim/pt/SBBTransitQSimEngineTest.java | 38 +- .../matsim/contrib/shared_mobility/RunIT.java | 40 +- .../CreateIntergreensExampleTest.java | 10 +- .../CreateSignalInputExampleTest.java | 24 +- ...CreateSignalInputExampleWithLanesTest.java | 28 +- .../RunSignalSystemsExampleTest.java | 6 +- ...sualizeSignalScenarioWithLanesGUITest.java | 6 +- .../FixResponsiveSignalResultsIT.java | 12 +- .../io/MatsimFileTypeGuesserSignalsTest.java | 4 +- .../contrib/signals/CalculateAngleTest.java | 25 +- .../contrib/signals/SignalUtilsTest.java | 24 +- .../analysis/DelayAnalysisToolTest.java | 6 +- .../signals/builder/QSimSignalTest.java | 10 +- .../builder/TravelTimeFourWaysTest.java | 4 +- .../builder/TravelTimeOneWayTestIT.java | 16 +- ...aultPlanbasedSignalSystemControllerIT.java | 184 +++--- .../controller/laemmerFix/LaemmerIT.java | 162 +++-- .../signals/controller/sylvia/SylviaIT.java | 30 +- .../v10/AmberTimesData10ReaderWriterTest.java | 26 +- .../SignalConflictDataReaderWriterTest.java | 32 +- .../UnprotectedLeftTurnLogicTest.java | 10 +- ...IntergreenTimesData10ReaderWriterTest.java | 28 +- .../SignalControlData20ReaderWriterTest.java | 48 +- .../v20/SignalGroups20ReaderWriterTest.java | 24 +- .../SignalSystemsData20ReaderWriterTest.java | 64 +- .../signals/integration/SignalSystemsIT.java | 54 +- .../InvertedNetworksSignalsIT.java | 6 +- .../SignalsAndLanesOsmNetworkReaderTest.java | 142 ++-- .../signals/oneagent/ControlerTest.java | 8 +- .../signals/sensor/LaneSensorTest.java | 4 +- .../signals/sensor/LinkSensorTest.java | 48 +- .../DefaultAnnealingAcceptorTest.java | 20 +- .../SimulatedAnnealingConfigGroupTest.java | 16 +- .../SimulatedAnnealingTest.java | 4 +- .../framework/events/CourtesyEventsTest.java | 8 +- .../population/JointPlanFactoryTest.java | 20 +- .../framework/population/JointPlanIOTest.java | 32 +- .../framework/population/JointPlansTest.java | 86 +-- .../population/SocialNetworkIOTest.java | 38 +- .../population/SocialNetworkTest.java | 68 +- .../grouping/DynamicGroupIdentifierTest.java | 14 +- .../replanning/grouping/FixedGroupsIT.java | 14 +- .../replanning/grouping/GroupPlansTest.java | 40 +- .../ActivitySequenceMutatorAlgorithmTest.java | 62 +- .../replanning/modules/MergingTest.java | 28 +- .../modules/TourModeUnifierAlgorithmTest.java | 100 +-- .../removers/LexicographicRemoverTest.java | 14 +- .../FullExplorationVsCuttoffTest.java | 10 +- .../selectors/HighestWeightSelectorTest.java | 20 +- .../selectors/RandomSelectorsTest.java | 16 +- .../CoalitionSelectorTest.java | 8 +- ...ghtJointPlanPruningConflictSolverTest.java | 14 +- ...tPointedPlanPruningConflictSolverTest.java | 14 +- .../WhoIsTheBossSelectorTest.java | 14 +- .../GroupCompositionPenalizerTest.java | 8 +- .../RecomposeJointPlanAlgorithmTest.java | 24 +- .../RandomJointLocationChoiceTest.java | 8 +- .../jointtrips/JointTravelUtilsTest.java | 22 +- ...intTravelingSimulationIntegrationTest.java | 32 +- ...InsertionRemovalIgnoranceBehaviorTest.java | 12 +- .../InsertionRemovalIterativeActionTest.java | 101 ++- ...intTripInsertionWithSocialNetworkTest.java | 8 +- .../JointTripRemoverAlgorithmTest.java | 32 +- ...nchronizeCoTravelerPlansAlgorithmTest.java | 14 +- .../router/JointPlanRouterTest.java | 30 +- .../router/JointTripRouterFactoryTest.java | 20 +- .../HouseholdBasedVehicleRessourcesTest.java | 8 +- .../PlanRouterWithVehicleRessourcesTest.java | 8 +- ...PopulationAgentSourceWithVehiclesTest.java | 12 +- ...ehicleToPlansInGroupPlanAlgorithmTest.java | 38 +- ...imizeVehicleAllocationAtTourLevelTest.java | 8 +- .../replanning/GroupPlanStrategyTest.java | 32 +- ...nableActivitiesPlanLinkIdentifierTest.java | 110 +-- .../VehicularPlanLinkIdentifierTest.java | 20 +- .../utils/JointScenarioUtilsTest.java | 28 +- .../socnetsim/utils/ObjectPoolTest.java | 20 +- .../utils/QuadTreeRebuilderTest.java | 32 +- .../contrib/etaxi/run/RunETaxiScenarioIT.java | 6 +- .../taxi/optimizer/TaxiOptimizerTests.java | 6 +- ...oringParametersFromPersonAttributesIT.java | 9 +- ...omPersonAttributesNoSubpopulationTest.java | 38 +- ...ingParametersFromPersonAttributesTest.java | 38 +- .../analysis/RunFreightAnalysisIT.java | 180 ++--- .../RunFreightAnalysisWithShipmentTest.java | 16 +- .../drtAndPt/PtAlongALine2Test.java | 44 +- .../EmissionCostFactorsTest.java | 2 +- .../emissions/TestColdEmissionHandler.java | 24 +- .../emissions/TestWarmEmissionHandler.java | 28 +- ...entId2DepartureDelayAtStopMapDataTest.java | 6 +- .../AgentId2DepartureDelayAtStopMapTest.java | 10 +- ...tId2EnterLeaveVehicleEventHandlerTest.java | 14 +- .../AgentId2PtTripTravelTimeMapDataTest.java | 6 +- .../AgentId2PtTripTravelTimeMapTest.java | 4 +- ...EnterLeaveVehicle2ActivityHandlerTest.java | 4 +- .../bvgAna/level1/StopId2LineId2PulkTest.java | 4 +- .../StopId2RouteId2DelayAtStopMapTest.java | 8 +- .../level1/VehId2DelayAtStopMapDataTest.java | 4 +- .../level1/VehId2DelayAtStopMapTest.java | 10 +- .../level1/VehId2OccupancyHandlerTest.java | 6 +- .../VehId2PersonEnterLeaveVehicleMapTest.java | 10 +- .../osmBB/PTCountsNetworkSimplifierTest.java | 92 +-- .../ModalDistanceAndCountsCadytsIT.java | 8 +- ...odalDistanceCadytsMultipleDistancesIT.java | 4 +- .../ModalDistanceCadytsSingleDistanceIT.java | 4 +- .../marginals/TripEventHandlerTest.java | 4 +- .../AdvancedMarginalCongestionPricingIT.java | 47 +- .../CombinedFlowAndStorageDelayTest.java | 10 +- .../vsp/congestion/CorridorNetworkTest.java | 40 +- ...nalCongestionHandlerFlowQueueQsimTest.java | 28 +- ...tionHandlerFlowSpillbackQueueQsimTest.java | 66 +- .../MarginalCongestionHandlerV3Test.java | 9 +- .../MarginalCongestionPricingTest.java | 36 +- .../MultipleSpillbackCausingLinksTest.java | 14 +- .../vsp/congestion/TestForEmergenceTime.java | 6 +- .../ev/TransferFinalSocToNextIterTest.java | 10 +- .../java/playground/vsp/ev/UrbanEVIT.java | 8 +- .../java/playground/vsp/ev/UrbanEVTests.java | 142 ++-- ...rarchicalFLowEfficiencyCalculatorTest.java | 20 +- .../cemdap/input/SynPopCreatorTest.java | 40 +- .../PlanFileModifierTest.java | 50 +- .../vsp/pt/ptdisturbances/EditTripsTest.java | 154 ++--- .../TransitRouteTrimmerTest.java | 264 ++++---- ...nScoringParametersNoSubpopulationTest.java | 12 +- ...ityOfMoneyPersonScoringParametersTest.java | 12 +- .../SwissRailRaptorConfigGroupTest.java | 122 ++-- .../raptor/CapacityDependentScoringTest.java | 6 +- .../pt/raptor/OccupancyTrackerTest.java | 56 +- .../pt/raptor/RaptorStopFinderTest.java | 624 +++++++++--------- .../routing/pt/raptor/RaptorUtilsTest.java | 22 +- .../raptor/SwissRailRaptorCapacitiesTest.java | 26 +- .../pt/raptor/SwissRailRaptorDataTest.java | 20 +- .../SwissRailRaptorInVehicleCostTest.java | 14 +- .../raptor/SwissRailRaptorIntermodalTest.java | 500 +++++++------- .../pt/raptor/SwissRailRaptorModuleTest.java | 114 ++-- .../pt/raptor/SwissRailRaptorTest.java | 160 ++--- .../pt/raptor/SwissRailRaptorTreeTest.java | 108 +-- .../analysis/CalcAverageTripLengthTest.java | 18 +- .../org/matsim/analysis/CalcLegTimesTest.java | 4 +- .../matsim/analysis/CalcLinkStatsTest.java | 54 +- ...ationTravelStatsControlerListenerTest.java | 16 +- .../org/matsim/analysis/LegHistogramTest.java | 4 +- .../LinkStatsControlerListenerTest.java | 394 +++++------ ...deChoiceCoverageControlerListenerTest.java | 80 +-- .../ModeStatsControlerListenerTest.java | 32 +- .../analysis/PHbyModeCalculatorTest.java | 25 +- .../analysis/PKMbyModeCalculatorTest.java | 9 +- .../ScoreStatsControlerListenerTest.java | 22 +- ...ansportPlanningMainModeIdentifierTest.java | 8 +- .../analysis/TravelDistanceStatsTest.java | 12 +- .../analysis/TripsAndLegsCSVWriterTest.java | 108 +-- .../matsim/analysis/VolumesAnalyzerTest.java | 22 +- .../LinkPaxVolumesAnalysisTest.java | 58 +- .../PersonMoneyEventAggregatorTest.java | 18 +- .../pt/stop2stop/PtStop2StopAnalysisTest.java | 110 +-- .../org/matsim/api/core/v01/CoordTest.java | 28 +- .../api/core/v01/DemandGenerationTest.java | 2 +- .../api/core/v01/IdAnnotationsTest.java | 26 +- .../core/v01/IdDeSerializationModuleTest.java | 18 +- .../org/matsim/api/core/v01/IdMapTest.java | 380 +++++------ .../org/matsim/api/core/v01/IdSetTest.java | 196 +++--- .../java/org/matsim/api/core/v01/IdTest.java | 38 +- .../api/core/v01/NetworkCreationTest.java | 4 +- .../core/v01/network/AbstractNetworkTest.java | 74 +-- .../matsim/core/config/CommandLineTest.java | 14 +- .../core/config/ConfigReaderMatsimV2Test.java | 32 +- .../org/matsim/core/config/ConfigTest.java | 26 +- .../core/config/MaterializeConfigTest.java | 19 +- .../config/ReflectiveConfigGroupTest.java | 5 +- .../ConfigConsistencyCheckerImplTest.java | 28 +- .../groups/ControllerConfigGroupTest.java | 78 +-- .../config/groups/CountsConfigGroupTest.java | 30 +- .../groups/LinkStatsConfigGroupTest.java | 30 +- .../groups/ReplanningConfigGroupTest.java | 36 +- .../config/groups/RoutingConfigGroupTest.java | 74 +-- .../config/groups/ScoringConfigGroupTest.java | 252 +++---- .../SubtourModeChoiceConfigGroupTest.java | 61 +- .../core/controler/ControlerEventsTest.java | 8 +- .../matsim/core/controler/ControlerIT.java | 65 +- .../ControlerListenerManagerImplTest.java | 84 +-- .../ControlerMobsimIntegrationTest.java | 4 +- .../controler/MatsimServicesImplTest.java | 6 +- .../OutputDirectoryHierarchyTest.java | 40 +- .../controler/OverrideCarTraveltimeTest.java | 10 +- .../core/controler/PrepareForSimImplTest.java | 154 ++--- .../core/controler/TerminationTest.java | 42 +- .../TransitControlerIntegrationTest.java | 4 +- .../corelisteners/ListenersInjectionTest.java | 8 +- .../corelisteners/PlansDumpingIT.java | 4 +- .../matsim/core/events/ActEndEventTest.java | 2 +- .../matsim/core/events/ActStartEventTest.java | 2 +- .../core/events/AgentMoneyEventTest.java | 2 +- .../events/AgentWaitingForPtEventTest.java | 10 +- .../core/events/BasicEventsHandlerTest.java | 4 +- .../matsim/core/events/CustomEventTest.java | 18 +- .../events/EventsHandlerHierarchyTest.java | 2 +- .../core/events/EventsManagerImplTest.java | 10 +- .../matsim/core/events/EventsReadersTest.java | 24 +- .../matsim/core/events/GenericEventTest.java | 2 +- .../core/events/LinkEnterEventTest.java | 2 +- .../core/events/LinkLeaveEventTest.java | 2 +- .../events/ParallelEventsManagerTest.java | 4 +- .../core/events/PersonArrivalEventTest.java | 2 +- .../core/events/PersonDepartureEventTest.java | 2 +- .../events/PersonEntersVehicleEventTest.java | 6 +- .../events/PersonLeavesVehicleEventTest.java | 6 +- .../core/events/PersonStuckEventTest.java | 2 +- .../events/TransitDriverStartsEventTest.java | 14 +- .../core/events/VehicleAbortsEventTest.java | 2 +- ...VehicleArrivesAtFacilityEventImplTest.java | 2 +- ...VehicleDepartsAtFacilityEventImplTest.java | 2 +- .../events/VehicleEntersTrafficEventTest.java | 2 +- .../events/VehicleLeavesTrafficEventTest.java | 2 +- .../matsim/core/events/XmlEventsTester.java | 11 +- .../algorithms/EventWriterJsonTest.java | 18 +- .../events/algorithms/EventWriterXMLTest.java | 18 +- .../org/matsim/core/gbl/MatsimRandomTest.java | 6 +- .../matsim/core/gbl/MatsimResourceTest.java | 4 +- .../core/mobsim/AbstractMobsimModuleTest.java | 10 +- .../matsim/core/mobsim/hermes/AgentTest.java | 3 +- .../core/mobsim/hermes/FlowCapacityTest.java | 50 +- .../matsim/core/mobsim/hermes/HermesTest.java | 272 ++++---- .../core/mobsim/hermes/HermesTransitTest.java | 190 +++--- .../mobsim/hermes/StorageCapacityTest.java | 23 +- .../core/mobsim/hermes/TravelTimeTest.java | 50 +- .../mobsim/jdeqsim/AbstractJDEQSimTest.java | 6 +- .../mobsim/jdeqsim/ConfigParameterTest.java | 2 +- .../core/mobsim/jdeqsim/EmptyCarLegTest.java | 10 +- .../core/mobsim/jdeqsim/EquilPlans1Test.java | 6 +- .../core/mobsim/jdeqsim/NonCarLegTest.java | 8 +- .../mobsim/jdeqsim/TestDESStarter_Berlin.java | 8 +- ...tarter_EquilPopulationPlans1Modified1.java | 8 +- .../jdeqsim/TestDESStarter_equilPlans100.java | 8 +- .../core/mobsim/jdeqsim/TestEventLog.java | 4 +- .../mobsim/jdeqsim/TestMessageFactory.java | 4 +- .../core/mobsim/jdeqsim/TestMessageQueue.java | 4 +- .../core/mobsim/jdeqsim/TestScheduler.java | 10 +- .../mobsim/jdeqsim/util/TestEventLibrary.java | 6 +- .../mobsim/qsim/AbstractQSimModuleTest.java | 18 +- .../mobsim/qsim/FlowStorageSpillbackTest.java | 5 +- .../qsim/MobsimListenerManagerTest.java | 26 +- .../qsim/NetsimRoutingConsistencyTest.java | 12 +- .../core/mobsim/qsim/NodeTransitionTest.java | 128 ++-- .../org/matsim/core/mobsim/qsim/QSimTest.java | 420 ++++++------ .../mobsim/qsim/TransitQueueNetworkTest.java | 4 +- .../core/mobsim/qsim/TravelTimeTest.java | 50 +- .../core/mobsim/qsim/VehicleSourceTest.java | 11 +- .../NetworkChangeEventsEngineTest.java | 14 +- .../qsim/components/QSimComponentsTest.java | 22 +- .../guice/ExplicitBindingsRequiredTest.java | 7 +- .../guice/MultipleBindingsTest.java | 7 +- .../mobsim/qsim/pt/QSimIntegrationTest.java | 136 ++-- .../core/mobsim/qsim/pt/TransitAgentTest.java | 4 +- .../mobsim/qsim/pt/TransitDriverTest.java | 33 +- .../qsim/pt/TransitQueueSimulationTest.java | 4 +- .../qsim/pt/TransitStopAgentTrackerTest.java | 2 +- .../mobsim/qsim/pt/TransitVehicleTest.java | 2 +- .../core/mobsim/qsim/pt/UmlaufDriverTest.java | 33 +- .../DeparturesOnSameLinkSameTimeTest.java | 8 +- .../EquiDistAgentSnapshotInfoBuilderTest.java | 2 +- .../FlowCapacityVariationTest.java | 6 +- .../FlowEfficiencyCalculatorTest.java | 10 +- .../JavaRoundingErrorInQsimTest.java | 6 +- .../LinkSpeedCalculatorIntegrationTest.java | 44 +- .../qsim/qnetsimengine/PassingTest.java | 8 +- .../qsim/qnetsimengine/QLinkLanesTest.java | 4 +- .../mobsim/qsim/qnetsimengine/QLinkTest.java | 20 +- .../QueueAgentSnapshotInfoBuilderTest.java | 4 +- .../qsim/qnetsimengine/SeepageTest.java | 8 +- .../SimulatedLaneFlowCapacityTest.java | 4 +- .../qnetsimengine/SpeedCalculatorTest.java | 4 +- .../qnetsimengine/VehVsLinkSpeedTest.java | 6 +- .../qnetsimengine/VehicleHandlerTest.java | 19 +- .../qnetsimengine/VehicleWaitingTest.java | 14 +- .../AbstractNetworkWriterReaderTest.java | 40 +- .../core/network/DisallowedNextLinksTest.java | 44 +- .../network/DisallowedNextLinksUtilsTest.java | 10 +- .../org/matsim/core/network/LinkImplTest.java | 204 +++--- .../matsim/core/network/LinkQuadTreeTest.java | 44 +- .../NetworkChangeEventsParserWriterTest.java | 46 +- .../core/network/NetworkCollectorTest.java | 4 +- .../matsim/core/network/NetworkImplTest.java | 106 +-- .../matsim/core/network/NetworkUtilsTest.java | 12 +- .../matsim/core/network/NetworkV2IOTest.java | 42 +- .../core/network/TimeVariantLinkImplTest.java | 2 +- .../TravelTimeCalculatorIntegrationTest.java | 2 +- .../algorithms/CalcBoundingBoxTest.java | 18 +- .../MultimodalNetworkCleanerTest.java | 590 ++++++++--------- .../algorithms/NetworkCleanerTest.java | 34 +- .../algorithms/NetworkExpandNodeTest.java | 404 ++++++------ .../NetworkMergeDoubleLinksTest.java | 128 ++-- .../NetworkSimplifierPass2WayTest.java | 17 +- .../algorithms/NetworkSimplifierTest.java | 92 +-- .../TransportModeNetworkFilterTest.java | 358 +++++----- .../DensityClusterTest.java | 8 +- .../HullConverterTest.java | 16 +- .../IntersectionSimplifierTest.java | 128 ++-- .../containers/ConcaveHullTest.java | 8 +- .../filter/NetworkFilterManagerTest.java | 22 +- .../io/NetworkAttributeConversionTest.java | 10 +- .../network/io/NetworkReaderMatsimV1Test.java | 36 +- .../network/io/NetworkReprojectionIOTest.java | 70 +- .../core/population/PersonImplTest.java | 28 +- .../matsim/core/population/PlanImplTest.java | 56 +- .../core/population/PopulationUtilsTest.java | 28 +- .../io/CompressedRoutesIntegrationTest.java | 4 +- .../io/MatsimPopulationReaderTest.java | 88 +-- .../io/ParallelPopulationReaderTest.java | 6 +- .../io/PopulationAttributeConversionTest.java | 10 +- .../io/PopulationReaderMatsimV4Test.java | 76 +-- .../io/PopulationReaderMatsimV5Test.java | 102 +-- .../io/PopulationReprojectionIOIT.java | 88 +-- .../population/io/PopulationV6IOTest.java | 112 ++-- .../io/PopulationWriterHandlerImplV4Test.java | 2 +- .../io/PopulationWriterHandlerImplV5Test.java | 22 +- ...mingPopulationAttributeConversionTest.java | 8 +- .../routes/AbstractNetworkRouteTest.java | 174 ++--- .../routes/LinkNetworkRouteTest.java | 8 +- .../population/routes/NetworkFactoryTest.java | 12 +- .../routes/RouteFactoryImplTest.java | 11 +- .../routes/RouteFactoryIntegrationTest.java | 8 +- .../HeavyCompressedNetworkRouteTest.java | 40 +- .../MediumCompressedNetworkRouteTest.java | 40 +- .../core/replanning/PlanStrategyTest.java | 2 +- .../StrategyManagerSubpopulationsTest.java | 22 +- .../core/replanning/StrategyManagerTest.java | 63 +- .../annealing/ReplanningAnnealerTest.java | 44 +- .../ForceInnovationStrategyChooserTest.java | 2 +- .../ReplanningWithConflictsTest.java | 2 +- .../AbstractMultithreadedModuleTest.java | 6 +- .../replanning/modules/ChangeLegModeTest.java | 8 +- .../modules/ChangeSingleLegModeTest.java | 8 +- .../modules/ExternalModuleTest.java | 6 +- .../selectors/AbstractPlanSelectorTest.java | 4 +- .../selectors/BestPlanSelectorTest.java | 4 +- .../selectors/ExpBetaPlanSelectorTest.java | 2 +- .../selectors/KeepSelectedTest.java | 2 +- .../selectors/PathSizeLogitSelectorTest.java | 4 +- .../selectors/RandomPlanSelectorTest.java | 2 +- .../WorstPlanForRemovalSelectorTest.java | 36 +- ...eterministicMultithreadedReplanningIT.java | 19 +- .../strategies/InnovationSwitchOffTest.java | 10 +- .../TimeAllocationMutatorModuleTest.java | 38 +- .../AbstractLeastCostPathCalculatorTest.java | 12 +- .../router/InvertertedNetworkRoutingTest.java | 44 +- .../router/MultimodalLinkChooserTest.java | 8 +- ...workRoutingInclAccessEgressModuleTest.java | 3 +- .../core/router/NetworkRoutingModuleTest.java | 24 +- ...rsonalizableDisutilityIntegrationTest.java | 12 +- .../PseudoTransitRoutingModuleTest.java | 18 +- .../org/matsim/core/router/RoutingIT.java | 4 +- .../TeleportationRoutingModuleTest.java | 20 +- .../router/TestActivityWrapperFacility.java | 14 +- .../router/TripRouterFactoryImplTest.java | 27 +- .../core/router/TripRouterModuleTest.java | 4 +- .../matsim/core/router/TripRouterTest.java | 24 +- .../TripStructureUtilsSubtoursTest.java | 38 +- .../core/router/TripStructureUtilsTest.java | 41 +- ...izingTimeDistanceTravelDisutilityTest.java | 8 +- .../core/router/old/PlanRouterTest.java | 10 +- .../priorityqueue/BinaryMinHeapTest.java | 190 +++--- .../core/router/speedy/DAryMinHeapTest.java | 42 +- .../core/router/speedy/SpeedyGraphTest.java | 100 +-- .../ScenarioByConfigInjectionTest.java | 46 +- .../core/scenario/ScenarioImplTest.java | 36 +- .../core/scenario/ScenarioLoaderImplTest.java | 30 +- .../core/scenario/ScenarioUtilsTest.java | 6 +- .../core/scoring/EventsToActivitiesTest.java | 36 +- .../matsim/core/scoring/EventsToLegsTest.java | 34 +- .../core/scoring/EventsToScoreTest.java | 28 +- ...ScoringFunctionsForPopulationStressIT.java | 2 +- .../ScoringFunctionsForPopulationTest.java | 44 +- ...yparNagelLegScoringDailyConstantsTest.java | 14 +- .../CharyparNagelLegScoringPtChangeTest.java | 8 +- ...yparNagelOpenTimesScoringFunctionTest.java | 2 +- .../CharyparNagelScoringFunctionTest.java | 4 +- .../CharyparNagelWithSubpopulationsTest.java | 14 +- .../LinkToLinkTravelTimeCalculatorTest.java | 2 +- .../TravelTimeCalculatorTest.java | 24 +- .../core/utils/charts/BarChartTest.java | 4 +- .../core/utils/charts/LineChartTest.java | 4 +- .../core/utils/charts/XYLineChartTest.java | 4 +- .../core/utils/charts/XYScatterChartTest.java | 4 +- .../core/utils/collections/ArrayMapTest.java | 376 +++++------ .../collections/CollectionUtilsTest.java | 34 +- .../collections/IdentifiableArrayMapTest.java | 248 +++---- .../utils/collections/IntArrayMapTest.java | 340 +++++----- .../PseudoRemovePriorityQueueTest.java | 2 +- .../core/utils/collections/QuadTreeTest.java | 60 +- .../core/utils/collections/TupleTest.java | 2 +- .../core/utils/geometry/CoordImplTest.java | 4 +- .../core/utils/geometry/CoordUtilsTest.java | 20 +- .../utils/geometry/GeometryUtilsTest.java | 10 +- .../core/utils/geometry/geotools/MGCTest.java | 29 +- .../CH1903LV03PlustoWGS84Test.java | 6 +- .../CH1903LV03PlustofromCH1903LV03Test.java | 10 +- .../CH1903LV03toWGS84Test.java | 6 +- .../GeotoolsTransformationTest.java | 5 +- .../TransformationFactoryTest.java | 2 +- .../WGS84toCH1903LV03PlusTest.java | 6 +- .../WGS84toCH1903LV03Test.java | 6 +- .../core/utils/gis/ShapeFileReaderTest.java | 4 +- .../core/utils/gis/ShapeFileWriterTest.java | 12 +- .../org/matsim/core/utils/io/IOUtilsTest.java | 120 ++-- .../utils/io/MatsimFileTypeGuesserTest.java | 5 +- .../core/utils/io/MatsimXmlParserTest.java | 122 ++-- .../core/utils/io/MatsimXmlWriterTest.java | 2 +- .../core/utils/io/OsmNetworkReaderTest.java | 72 +- .../matsim/core/utils/io/XmlUtilsTest.java | 30 +- .../core/utils/misc/ArgumentParserTest.java | 4 +- .../core/utils/misc/ByteBufferUtilsTest.java | 4 +- .../core/utils/misc/ClassUtilsTest.java | 106 +-- .../core/utils/misc/ConfigUtilsTest.java | 25 +- .../core/utils/misc/NetworkUtilsTest.java | 30 +- .../core/utils/misc/PopulationUtilsTest.java | 18 +- .../core/utils/misc/RouteUtilsTest.java | 122 ++-- .../core/utils/misc/StringUtilsTest.java | 10 +- .../org/matsim/core/utils/misc/TimeTest.java | 4 +- .../utils/timing/TimeInterpretationTest.java | 4 +- .../java/org/matsim/counts/CountTest.java | 12 +- .../counts/CountsComparisonAlgorithmTest.java | 8 +- .../counts/CountsControlerListenerTest.java | 352 +++++----- .../matsim/counts/CountsErrorGraphTest.java | 4 +- .../counts/CountsHtmlAndGraphsWriterTest.java | 2 +- .../counts/CountsLoadCurveGraphTest.java | 4 +- .../org/matsim/counts/CountsParserTest.java | 20 +- .../matsim/counts/CountsParserWriterTest.java | 20 +- .../counts/CountsReaderHandlerImplV1Test.java | 12 +- .../counts/CountsReprojectionIOTest.java | 46 +- .../counts/CountsSimRealPerHourGraphTest.java | 4 +- .../matsim/counts/CountsTableWriterTest.java | 4 +- .../java/org/matsim/counts/CountsTest.java | 4 +- .../java/org/matsim/counts/CountsV2Test.java | 6 +- .../org/matsim/counts/MatsimCountsIOTest.java | 8 +- .../org/matsim/counts/OutputDelegateTest.java | 10 +- .../java/org/matsim/examples/EquilTest.java | 4 +- .../examples/OnePercentBerlin10sIT.java | 12 +- .../org/matsim/examples/PtTutorialIT.java | 24 +- .../matsim/examples/simple/PtScoringTest.java | 18 +- .../ActivityFacilitiesFactoryImplTest.java | 12 +- .../ActivityFacilitiesImplTest.java | 30 +- .../ActivityFacilitiesSourceTest.java | 20 +- .../ActivityWithOnlyFacilityIdTest.java | 6 +- .../FacilitiesAttributeConvertionTest.java | 10 +- .../FacilitiesFromPopulationTest.java | 62 +- .../FacilitiesParserWriterTest.java | 58 +- .../FacilitiesReprojectionIOTest.java | 64 +- .../facilities/FacilitiesWriterTest.java | 36 +- .../MatsimFacilitiesReaderTest.java | 24 +- .../StreamingActivityFacilitiesTest.java | 26 +- .../AbstractFacilityAlgorithmTest.java | 4 +- .../HouseholdAttributeConversionTest.java | 10 +- .../matsim/households/HouseholdImplTest.java | 18 +- .../matsim/households/HouseholdsIoTest.java | 4 +- .../integration/EquilTwoAgentsTest.java | 2 +- .../integration/SimulateAndScoreTest.java | 6 +- .../PersonMoneyEventIntegrationTest.java | 4 +- .../events/PersonScoreEventTest.java | 4 +- ...iverStartsEventHandlerIntegrationTest.java | 8 +- .../InvertedNetworkRoutingIT.java | 8 +- .../integration/invertednetworks/LanesIT.java | 14 +- .../NonAlternatingPlanElementsIT.java | 6 +- .../ChangeTripModeIntegrationTest.java | 8 +- .../integration/replanning/ReRoutingIT.java | 4 +- .../replanning/ResumableRunsIT.java | 8 +- .../QSimIntegrationTest.java | 24 +- .../lanes/data/LanesReaderWriterTest.java | 4 +- .../matsim/modules/ScoreStatsModuleTest.java | 35 +- .../matsim/other/DownloadAndReadXmlTest.java | 10 +- ...ndomLegModeForSubtourComplexTripsTest.java | 32 +- ...eRandomLegModeForSubtourDiffModesTest.java | 38 +- .../ChooseRandomLegModeForSubtourTest.java | 54 +- .../algorithms/ChooseRandomLegModeTest.java | 42 +- .../ChooseRandomSingleLegModeTest.java | 37 +- .../ParallelPersonAlgorithmRunnerTest.java | 12 +- .../PermissibleModesCalculatorImplTest.java | 12 +- .../algorithms/PersonPrepareForSimTest.java | 81 +-- .../algorithms/TripsToLegsAlgorithmTest.java | 24 +- .../analysis/TransitLoadIntegrationTest.java | 4 +- .../matsim/pt/analysis/TransitLoadTest.java | 62 +- .../pt/config/TransitConfigGroupTest.java | 2 +- .../pt/router/TransitActsRemoverTest.java | 4 +- .../pt/router/TransitRouterConfigTest.java | 38 +- .../pt/router/TransitRouterModuleTest.java | 4 +- .../DefaultTransitPassengerRouteTest.java | 2 +- .../routes/ExperimentalTransitRouteTest.java | 2 +- .../pt/transitSchedule/DepartureTest.java | 4 +- .../MinimalTransferTimesImplTest.java | 108 +-- .../pt/transitSchedule/TransitLineTest.java | 4 +- .../transitSchedule/TransitRouteStopTest.java | 2 +- .../pt/transitSchedule/TransitRouteTest.java | 6 +- .../TransitScheduleFactoryTest.java | 42 +- .../TransitScheduleFormatV1Test.java | 56 +- .../TransitScheduleIOTest.java | 48 +- .../TransitScheduleReaderTest.java | 30 +- .../TransitScheduleReaderV1Test.java | 2 +- .../TransitScheduleReprojectionIOTest.java | 46 +- .../transitSchedule/TransitScheduleTest.java | 18 +- .../TransitScheduleWriterTest.java | 8 +- .../TransitStopFacilityTest.java | 2 +- .../utils/TransitScheduleValidatorTest.java | 14 +- .../org/matsim/run/CreateFullConfigTest.java | 6 +- .../java/org/matsim/run/InitRoutesTest.java | 16 +- .../java/org/matsim/run/XY2LinksTest.java | 14 +- .../testcases/utils/LogCounterTest.java | 18 +- .../EventsFileComparatorTest.java | 22 +- .../matsim/utils/geometry/CoordUtilsTest.java | 20 +- .../LanesBasedWidthCalculatorTest.java | 8 +- .../network/Network2ESRIShapeTest.java | 12 +- .../plans/SelectedPlans2ESRIShapeTest.java | 6 +- .../ObjectAttributesConverterTest.java | 12 +- .../ObjectAttributesTest.java | 12 +- .../ObjectAttributesUtilsTest.java | 18 +- .../ObjectAttributesXmlIOTest.java | 20 +- .../ObjectAttributesXmlReaderTest.java | 50 +- .../attributable/AttributesTest.java | 73 +- .../attributable/AttributesUtilsTest.java | 2 +- .../CoordArrayConverterTest.java | 36 +- .../CoordConverterTest.java | 10 +- .../DoubleArrayConverterTest.java | 18 +- .../EnumConverterTest.java | 12 +- .../StringCollectionConverterTest.java | 4 +- .../StringStringMapConverterTest.java | 2 +- .../vehicles/MatsimVehicleWriterTest.java | 2 +- .../matsim/vehicles/VehicleReaderV1Test.java | 2 +- .../matsim/vehicles/VehicleReaderV2Test.java | 2 +- .../matsim/vehicles/VehicleWriterV1Test.java | 2 +- .../matsim/vehicles/VehicleWriterV2Test.java | 2 +- .../org/matsim/vehicles/VehiclesImplTest.java | 20 +- .../vis/snapshotwriters/PositionInfoTest.java | 2 +- .../ExperiencedPlansWriterTest.java | 8 +- .../tools/ActivityReplanningMapTest.java | 4 +- .../tools/LinkReplanningMapTest.java | 2 +- .../trafficmonitoring/TtmobsimListener.java | 17 +- .../WithinDayTravelTimeTest.java | 2 +- ...TravelTimeWithNetworkChangeEventsTest.java | 6 +- .../withinday/utils/EditRoutesTest.java | 2 +- .../utils/ReplacePlanElementsTest.java | 2 +- 766 files changed, 13121 insertions(+), 13227 deletions(-) diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/LeastCostPathTreeTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/LeastCostPathTreeTest.java index 0de803d1434..23d32279ec6 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/LeastCostPathTreeTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/LeastCostPathTreeTest.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -55,11 +55,11 @@ private void compareRouteChoices(){ printResults(arrivalTime, travelTime); // travel time = cost = (50s+50s) = 100s // check route (visited nodes should be 1,2,4) List> spTimeVisitedNodes = getVisitedNodes(lcptTime, destination, "Travel Time"); - Assert.assertTrue( containsNode(spTimeVisitedNodes, Id.create("2", Node.class))); + Assertions.assertTrue( containsNode(spTimeVisitedNodes, Id.create("2", Node.class))); // check travel duration - Assert.assertTrue( travelTime == 100 ); + Assertions.assertTrue( travelTime == 100 ); // check travel time - Assert.assertTrue( arrivalTime - departureTime == 100 ); + Assertions.assertTrue( arrivalTime - departureTime == 100 ); lcptDistance.calculate(this.scenario.getNetwork(), origin, departureTime); double arrivalTimeTD = lcptDistance.getTree().get( destination.getId() ).getTime(); @@ -67,11 +67,11 @@ private void compareRouteChoices(){ printResults(arrivalTimeTD, travelDistance); // travel time = 1000s, cost = (50m+50m) = 100m // check route ( visited nodes should be 1,3,4) List> spDistenceVisitedNodes = getVisitedNodes(lcptDistance, destination, "Travel Distance"); - Assert.assertTrue( containsNode(spDistenceVisitedNodes, Id.create("3", Node.class))); + Assertions.assertTrue( containsNode(spDistenceVisitedNodes, Id.create("3", Node.class))); // check travel distance - Assert.assertTrue( travelDistance == 100 ); + Assertions.assertTrue( travelDistance == 100 ); // check travel time - Assert.assertTrue( arrivalTimeTD - departureTime == 1000 ); + Assertions.assertTrue( arrivalTimeTD - departureTime == 1000 ); } private void printResults(double tt, double tc){ diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/grid/SpatialGridTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/grid/SpatialGridTest.java index 0a43df9c1b6..74bae0a5363 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/grid/SpatialGridTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/grid/SpatialGridTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.accessibility.grid; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.network.Network; @@ -32,11 +32,11 @@ void testSpatialGrid() { // get number of rows int rows = testGrid.getNumRows(); double numOfExpectedRows = ((nbb.getYMax() - nbb.getYMin()) / cellSize) + 1; - Assert.assertTrue(rows == numOfExpectedRows); + Assertions.assertTrue(rows == numOfExpectedRows); // get number of columns int cols = testGrid.getNumCols(0); double numOfExpectedCols = ((nbb.getXMax() - nbb.getXMin()) / cellSize) + 1; - Assert.assertTrue(cols == numOfExpectedCols); + Assertions.assertTrue(cols == numOfExpectedCols); } } diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulas2Test.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulas2Test.java index 8d4c324a49a..f7e6672c053 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulas2Test.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulas2Test.java @@ -22,7 +22,7 @@ */ package org.matsim.contrib.accessibility.logsumComputations; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -66,7 +66,7 @@ void testLogsumFormulas(){ double Sum2 =PreFactor * AggregationSum; System.out.println(Sum2); - Assert.assertTrue( Sum1 == Sum2 ); + Assertions.assertTrue( Sum1 == Sum2 ); } } diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulasTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulasTest.java index 95517505f79..19501ebb49f 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulasTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/CompareLogsumFormulasTest.java @@ -22,7 +22,7 @@ */ package org.matsim.contrib.accessibility.logsumComputations; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -73,7 +73,7 @@ void testLogsumFormulas(){ double Ai = computeLogsum(betaWalkTT, betaWalkTD, cik1TT, cik2TT, cik3TT, cik1TD, cik2TD, cik3TD); double Ai2 =computeTransformedLogsum(betaWalkTT, betaWalkTD, cijTT, cjk1TT, cjk2TT, cjk3TT, cijTD, cjk1TD, cjk2TD, cjk3TD); - Assert.assertTrue( Ai == Ai2 ); + Assertions.assertTrue( Ai == Ai2 ); } /** diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/ComputeLogsumFormulas3Test.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/ComputeLogsumFormulas3Test.java index a746fd57137..1b35497b3c7 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/ComputeLogsumFormulas3Test.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/logsumComputations/ComputeLogsumFormulas3Test.java @@ -22,7 +22,7 @@ */ package org.matsim.contrib.accessibility.logsumComputations; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -101,7 +101,7 @@ void testLogsumFormulas(){ // double expNewVhj= Math.exp( VhjNew ); // double expNewVhk= expNewVhj * sumExpVjk; - Assert.assertTrue(VhjOld == VhjNew); // old accessibility computation == new accessibility computation + Assertions.assertTrue(VhjOld == VhjNew); // old accessibility computation == new accessibility computation /////// // NEW @@ -113,7 +113,7 @@ void testLogsumFormulas(){ double dummyExp1 = Math.exp( dummyVijCar + dummyVhiWalk ); double dummyExp2 = Math.exp( dummyVijCar ) * Math.exp( dummyVhiWalk ); - Assert.assertEquals(dummyExp1,dummyExp2,1.e-10); // exp(VijCar + VijWalk) == exp(VijCar) * exp(VijWalk) + Assertions.assertEquals(dummyExp1,dummyExp2,1.e-10); // exp(VijCar + VijWalk) == exp(VijCar) * exp(VijWalk) } } diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java index 0b3aa1ebf8c..e859cf969bb 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java @@ -27,8 +27,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.locationtech.jts.geom.Envelope; @@ -101,15 +101,15 @@ public void startRow(String[] row) { if (x == 50) { if (y == 50) { - Assert.assertEquals("Wrong work accessibility value at x=" + x + ", y=" + y + ":", 2.1486094237531126, value, utils.EPSILON); + Assertions.assertEquals(2.1486094237531126, value, utils.EPSILON, "Wrong work accessibility value at x=" + x + ", y=" + y + ":"); } else if (y == 150){ - Assert.assertEquals("Wrong work accessibility value at x=" + x + ", y=" + y + ":", 2.1766435716006005, value, utils.EPSILON); + Assertions.assertEquals(2.1766435716006005, value, utils.EPSILON, "Wrong work accessibility value at x=" + x + ", y=" + y + ":"); } } else if (x == 150) { if (y == 50) { - Assert.assertEquals("Wrong work accessibility value at x=" + x + ", y=" + y + ":", 2.1486094237531126, value, utils.EPSILON); + Assertions.assertEquals(2.1486094237531126, value, utils.EPSILON, "Wrong work accessibility value at x=" + x + ", y=" + y + ":"); } else if (y == 150){ - Assert.assertEquals("Wrong work accessibility value at x=" + x + ", y=" + y + ":", 2.2055702759681273, value, utils.EPSILON); + Assertions.assertEquals(2.2055702759681273, value, utils.EPSILON, "Wrong work accessibility value at x=" + x + ", y=" + y + ":"); } } } @@ -271,7 +271,7 @@ void testWithExtentDeterminedShapeFile() { if(!f.exists()){ LOG.error("Shape file not found! testWithExtentDeterminedShapeFile could not be tested..."); - Assert.assertTrue(f.exists()); + Assertions.assertTrue(f.exists()); } final AccessibilityConfigGroup acg = ConfigUtils.addOrGetModule(config, AccessibilityConfigGroup.class); @@ -311,7 +311,7 @@ void testWithPredefinedMeasuringPoints() { if(!f.exists()){ LOG.error("Facilities file with measuring points not found! testWithMeasuringPointsInFacilitiesFile could not be performed..."); - Assert.assertTrue(f.exists()); + Assertions.assertTrue(f.exists()); } Scenario measuringPointsSc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); @@ -359,7 +359,7 @@ void testWithFile(){ File f = new File(this.utils.getInputDirectory() + "pointFile.csv"); if(!f.exists()){ LOG.error("Point file not found! testWithFile could not be tested..."); - Assert.assertTrue(f.exists()); + Assertions.assertTrue(f.exists()); } final AccessibilityConfigGroup acg = ConfigUtils.addOrGetModule(config, AccessibilityConfigGroup.class); @@ -598,12 +598,12 @@ public void finish() { for (String mode : accessibilitiesMap.get(tuple).keySet()) { double value = accessibilitiesMap.get(tuple).get(mode); switch (mode) { // commented values are before (a) Marcel's change of the QuadTree in Oct'18, (b) change in TravelTimeCalculator in Apr'21 - case "freespeed": Assert.assertEquals(2.207441799716032, value, MatsimTestUtils.EPSILON); break; // (a) 2.1486094237531126 - case TransportMode.car: Assert.assertEquals(2.2058369602991204, value, MatsimTestUtils.EPSILON); break; // (a) 2.1482840466191093 (b) 2.205836861444427 - case TransportMode.bike: Assert.assertEquals(2.2645288908389554, value, MatsimTestUtils.EPSILON); break; // (a) 2.2257398663221 - case TransportMode.walk: Assert.assertEquals(1.8697283849051263, value, MatsimTestUtils.EPSILON); break; // (a) 1.70054725728361 - case TransportMode.pt: Assert.assertEquals(2.1581641260040683, value, MatsimTestUtils.EPSILON); break; - case "matrixBasedPt": Assert.assertEquals(1.6542905235735796, value, MatsimTestUtils.EPSILON); break; // (a) 0.461863556339195 + case "freespeed": Assertions.assertEquals(2.207441799716032, value, MatsimTestUtils.EPSILON); break; // (a) 2.1486094237531126 + case TransportMode.car: Assertions.assertEquals(2.2058369602991204, value, MatsimTestUtils.EPSILON); break; // (a) 2.1482840466191093 (b) 2.205836861444427 + case TransportMode.bike: Assertions.assertEquals(2.2645288908389554, value, MatsimTestUtils.EPSILON); break; // (a) 2.2257398663221 + case TransportMode.walk: Assertions.assertEquals(1.8697283849051263, value, MatsimTestUtils.EPSILON); break; // (a) 1.70054725728361 + case TransportMode.pt: Assertions.assertEquals(2.1581641260040683, value, MatsimTestUtils.EPSILON); break; + case "matrixBasedPt": Assertions.assertEquals(1.6542905235735796, value, MatsimTestUtils.EPSILON); break; // (a) 0.461863556339195 } } } @@ -611,12 +611,12 @@ else if (tuple.getFirst().getCoord().getY() == 150.) { for (String mode : accessibilitiesMap.get(tuple).keySet()) { double value = accessibilitiesMap.get(tuple).get(mode); switch (mode) { - case "freespeed": Assert.assertEquals(2.207441799716032, value, MatsimTestUtils.EPSILON); break; // (a) 2.1766435716006005 - case TransportMode.car: Assert.assertEquals(2.207441960299121, value, MatsimTestUtils.EPSILON); break; // (a) 2.176238564675181 (b) 2.207441799716032 - case TransportMode.bike: Assert.assertEquals(2.2645288908389554, value, MatsimTestUtils.EPSILON); break; // (a) 2.2445468698643367 - case TransportMode.walk: Assert.assertEquals(1.8697283849051263, value, MatsimTestUtils.EPSILON); break; // (a) 1.7719146868026079 - case TransportMode.pt: Assert.assertEquals(2.1581641260040683, value, MatsimTestUtils.EPSILON); break; // (a) 2.057596373646452 - case "matrixBasedPt": Assert.assertEquals(1.6542905235735796, value, MatsimTestUtils.EPSILON); break; // (a) 0.461863556339195 + case "freespeed": Assertions.assertEquals(2.207441799716032, value, MatsimTestUtils.EPSILON); break; // (a) 2.1766435716006005 + case TransportMode.car: Assertions.assertEquals(2.207441960299121, value, MatsimTestUtils.EPSILON); break; // (a) 2.176238564675181 (b) 2.207441799716032 + case TransportMode.bike: Assertions.assertEquals(2.2645288908389554, value, MatsimTestUtils.EPSILON); break; // (a) 2.2445468698643367 + case TransportMode.walk: Assertions.assertEquals(1.8697283849051263, value, MatsimTestUtils.EPSILON); break; // (a) 1.7719146868026079 + case TransportMode.pt: Assertions.assertEquals(2.1581641260040683, value, MatsimTestUtils.EPSILON); break; // (a) 2.057596373646452 + case "matrixBasedPt": Assertions.assertEquals(1.6542905235735796, value, MatsimTestUtils.EPSILON); break; // (a) 0.461863556339195 } } } @@ -626,12 +626,12 @@ else if (tuple.getFirst().getCoord().getY() == 150.) { for (String mode : accessibilitiesMap.get(tuple).keySet()) { double value = accessibilitiesMap.get(tuple).get(mode); switch (mode) { - case "freespeed": Assert.assertEquals(2.235503385314382, value, MatsimTestUtils.EPSILON); break; // (a) 2.1486094237531126 - case TransportMode.car: Assert.assertEquals(2.23550352057971, value, MatsimTestUtils.EPSILON); break; // (a) 2.1482840466191093 (b) 2.235503385314382 - case TransportMode.bike: Assert.assertEquals(2.2833435568892395, value, MatsimTestUtils.EPSILON); break; // (a) 2.2257398663221 - case TransportMode.walk: Assert.assertEquals(1.9418539664691532, value, MatsimTestUtils.EPSILON); break; // (a) 1.70054725728361 - case TransportMode.pt: Assert.assertEquals(2.0032465393091434, value, MatsimTestUtils.EPSILON); break; - case "matrixBasedPt": Assert.assertEquals(1.6542905235735796, value, MatsimTestUtils.EPSILON); break; // (a) 0.461863556339195 + case "freespeed": Assertions.assertEquals(2.235503385314382, value, MatsimTestUtils.EPSILON); break; // (a) 2.1486094237531126 + case TransportMode.car: Assertions.assertEquals(2.23550352057971, value, MatsimTestUtils.EPSILON); break; // (a) 2.1482840466191093 (b) 2.235503385314382 + case TransportMode.bike: Assertions.assertEquals(2.2833435568892395, value, MatsimTestUtils.EPSILON); break; // (a) 2.2257398663221 + case TransportMode.walk: Assertions.assertEquals(1.9418539664691532, value, MatsimTestUtils.EPSILON); break; // (a) 1.70054725728361 + case TransportMode.pt: Assertions.assertEquals(2.0032465393091434, value, MatsimTestUtils.EPSILON); break; + case "matrixBasedPt": Assertions.assertEquals(1.6542905235735796, value, MatsimTestUtils.EPSILON); break; // (a) 0.461863556339195 } } } @@ -639,12 +639,12 @@ else if (tuple.getFirst().getCoord().getY() == 150.) { for (String mode : accessibilitiesMap.get(tuple).keySet()) { double value = accessibilitiesMap.get(tuple).get(mode); switch (mode) { - case "freespeed": Assert.assertEquals(2.235503385314382, value, MatsimTestUtils.EPSILON); break; // (a) 2.2055702759681273 - case TransportMode.car: Assert.assertEquals(2.23550352057971, value, MatsimTestUtils.EPSILON); break; // (a) 2.2052225231109226 (b) 2.235503385314382 - case TransportMode.bike: Assert.assertEquals(2.2833435568892395, value, MatsimTestUtils.EPSILON); break; // (a) 2.2637376515333636 - case TransportMode.walk: Assert.assertEquals(1.9418539664691532, value, MatsimTestUtils.EPSILON); break; // (a) 1.851165291193725 - case TransportMode.pt: Assert.assertEquals(2.0032465393091434, value, MatsimTestUtils.EPSILON); break; // (a) 1.9202710265495115 - case "matrixBasedPt": Assert.assertEquals(1.5073890466447624, value, MatsimTestUtils.EPSILON); break; // (a) 0.624928280738513 + case "freespeed": Assertions.assertEquals(2.235503385314382, value, MatsimTestUtils.EPSILON); break; // (a) 2.2055702759681273 + case TransportMode.car: Assertions.assertEquals(2.23550352057971, value, MatsimTestUtils.EPSILON); break; // (a) 2.2052225231109226 (b) 2.235503385314382 + case TransportMode.bike: Assertions.assertEquals(2.2833435568892395, value, MatsimTestUtils.EPSILON); break; // (a) 2.2637376515333636 + case TransportMode.walk: Assertions.assertEquals(1.9418539664691532, value, MatsimTestUtils.EPSILON); break; // (a) 1.851165291193725 + case TransportMode.pt: Assertions.assertEquals(2.0032465393091434, value, MatsimTestUtils.EPSILON); break; // (a) 1.9202710265495115 + case "matrixBasedPt": Assertions.assertEquals(1.5073890466447624, value, MatsimTestUtils.EPSILON); break; // (a) 0.624928280738513 } } } @@ -656,12 +656,12 @@ else if (tuple.getFirst().getCoord().getY() == 150.) { for (String mode : accessibilitiesMap.get(tuple).keySet()) { double value = accessibilitiesMap.get(tuple).get(mode); switch (mode) { - case "freespeed": Assert.assertEquals(3.5937361608359226, value, MatsimTestUtils.EPSILON); break; // (a) 3.534903784873003 - case TransportMode.car: Assert.assertEquals(3.592131321419011, value, MatsimTestUtils.EPSILON); break; // (a) 3.534578407739 (b) 3.592131222564318 - case TransportMode.bike: Assert.assertEquals(3.650823251958846, value, MatsimTestUtils.EPSILON); break; // (a) 3.6120342274419914 - case TransportMode.walk: Assert.assertEquals(3.256022746025017, value, MatsimTestUtils.EPSILON); break; // (a) 3.086841618403501 - case TransportMode.pt: Assert.assertEquals(3.5444584871239586, value, MatsimTestUtils.EPSILON); break; - case "matrixBasedPt": Assert.assertEquals(3.0405848846934704, value, MatsimTestUtils.EPSILON); break; // (a) 1.8481579174590859 + case "freespeed": Assertions.assertEquals(3.5937361608359226, value, MatsimTestUtils.EPSILON); break; // (a) 3.534903784873003 + case TransportMode.car: Assertions.assertEquals(3.592131321419011, value, MatsimTestUtils.EPSILON); break; // (a) 3.534578407739 (b) 3.592131222564318 + case TransportMode.bike: Assertions.assertEquals(3.650823251958846, value, MatsimTestUtils.EPSILON); break; // (a) 3.6120342274419914 + case TransportMode.walk: Assertions.assertEquals(3.256022746025017, value, MatsimTestUtils.EPSILON); break; // (a) 3.086841618403501 + case TransportMode.pt: Assertions.assertEquals(3.5444584871239586, value, MatsimTestUtils.EPSILON); break; + case "matrixBasedPt": Assertions.assertEquals(3.0405848846934704, value, MatsimTestUtils.EPSILON); break; // (a) 1.8481579174590859 } } } @@ -669,12 +669,12 @@ else if (tuple.getFirst().getCoord().getY() == 150.) { for (String mode : accessibilitiesMap.get(tuple).keySet()) { double value = accessibilitiesMap.get(tuple).get(mode); switch (mode) { - case "freespeed": Assert.assertEquals(3.5937361608359226, value, MatsimTestUtils.EPSILON); break; // (a) 3.562937932720491 - case TransportMode.car: Assert.assertEquals(3.5937363214190112, value, MatsimTestUtils.EPSILON); break; // (a) 3.5625329257950717 (b) 3.5937361608359226 - case TransportMode.bike: Assert.assertEquals(3.650823251958846, value, MatsimTestUtils.EPSILON); break; // (a) 3.6308412309842275 - case TransportMode.walk: Assert.assertEquals(3.256022746025017, value, MatsimTestUtils.EPSILON); break; // (a) 3.1582090479224982 - case TransportMode.pt: Assert.assertEquals(3.5444584871239586, value, MatsimTestUtils.EPSILON); break; // (a) 3.443890734766343 - case "matrixBasedPt": Assert.assertEquals(3.0405848846934704, value, MatsimTestUtils.EPSILON); break; // (a) 1.8481579174590859 + case "freespeed": Assertions.assertEquals(3.5937361608359226, value, MatsimTestUtils.EPSILON); break; // (a) 3.562937932720491 + case TransportMode.car: Assertions.assertEquals(3.5937363214190112, value, MatsimTestUtils.EPSILON); break; // (a) 3.5625329257950717 (b) 3.5937361608359226 + case TransportMode.bike: Assertions.assertEquals(3.650823251958846, value, MatsimTestUtils.EPSILON); break; // (a) 3.6308412309842275 + case TransportMode.walk: Assertions.assertEquals(3.256022746025017, value, MatsimTestUtils.EPSILON); break; // (a) 3.1582090479224982 + case TransportMode.pt: Assertions.assertEquals(3.5444584871239586, value, MatsimTestUtils.EPSILON); break; // (a) 3.443890734766343 + case "matrixBasedPt": Assertions.assertEquals(3.0405848846934704, value, MatsimTestUtils.EPSILON); break; // (a) 1.8481579174590859 } } } @@ -684,12 +684,12 @@ else if (tuple.getFirst().getCoord().getY() == 150.) { for (String mode : accessibilitiesMap.get(tuple).keySet()) { double value = accessibilitiesMap.get(tuple).get(mode); switch (mode) { - case "freespeed": Assert.assertEquals(3.621797746434273, value, MatsimTestUtils.EPSILON); break; // (a) 3.534903784873003 - case TransportMode.car: Assert.assertEquals(3.621797881699601, value, MatsimTestUtils.EPSILON); break; // (a) 3.534578407739 (b) 3.621797746434273 - case TransportMode.bike: Assert.assertEquals(3.66963791800913, value, MatsimTestUtils.EPSILON); break; // (a) 3.6120342274419914 - case TransportMode.walk: Assert.assertEquals(3.328148327589044, value, MatsimTestUtils.EPSILON); break; // (a) 3.086841618403501 - case TransportMode.pt: Assert.assertEquals(3.389540900429034, value, MatsimTestUtils.EPSILON); break; - case "matrixBasedPt": Assert.assertEquals(3.0405848846934704, value, MatsimTestUtils.EPSILON); break; // (a) 1.8481579174590859 + case "freespeed": Assertions.assertEquals(3.621797746434273, value, MatsimTestUtils.EPSILON); break; // (a) 3.534903784873003 + case TransportMode.car: Assertions.assertEquals(3.621797881699601, value, MatsimTestUtils.EPSILON); break; // (a) 3.534578407739 (b) 3.621797746434273 + case TransportMode.bike: Assertions.assertEquals(3.66963791800913, value, MatsimTestUtils.EPSILON); break; // (a) 3.6120342274419914 + case TransportMode.walk: Assertions.assertEquals(3.328148327589044, value, MatsimTestUtils.EPSILON); break; // (a) 3.086841618403501 + case TransportMode.pt: Assertions.assertEquals(3.389540900429034, value, MatsimTestUtils.EPSILON); break; + case "matrixBasedPt": Assertions.assertEquals(3.0405848846934704, value, MatsimTestUtils.EPSILON); break; // (a) 1.8481579174590859 } } } @@ -697,12 +697,12 @@ else if (tuple.getFirst().getCoord().getY() == 150.) { for (String mode : accessibilitiesMap.get(tuple).keySet()) { double value = accessibilitiesMap.get(tuple).get(mode); switch (mode) { - case "freespeed": Assert.assertEquals(3.621797746434273, value, MatsimTestUtils.EPSILON); break; // (a) 3.5918646370880176 - case TransportMode.car: Assert.assertEquals(3.621797881699601, value, MatsimTestUtils.EPSILON); break; // (a) 3.591516884230813 (b) 3.621797746434273 - case TransportMode.bike: Assert.assertEquals(3.66963791800913, value, MatsimTestUtils.EPSILON); break; // (a) 3.6500320126532544 - case TransportMode.walk: Assert.assertEquals(3.328148327589044, value, MatsimTestUtils.EPSILON); break; // (a) 3.2374596523136154 - case TransportMode.pt: Assert.assertEquals(3.389540900429034, value, MatsimTestUtils.EPSILON); break; // (a) 3.3065653876694023 - case "matrixBasedPt": Assert.assertEquals(2.893683407764653, value, MatsimTestUtils.EPSILON); break; // (a) 2.0112226418584043 + case "freespeed": Assertions.assertEquals(3.621797746434273, value, MatsimTestUtils.EPSILON); break; // (a) 3.5918646370880176 + case TransportMode.car: Assertions.assertEquals(3.621797881699601, value, MatsimTestUtils.EPSILON); break; // (a) 3.591516884230813 (b) 3.621797746434273 + case TransportMode.bike: Assertions.assertEquals(3.66963791800913, value, MatsimTestUtils.EPSILON); break; // (a) 3.6500320126532544 + case TransportMode.walk: Assertions.assertEquals(3.328148327589044, value, MatsimTestUtils.EPSILON); break; // (a) 3.2374596523136154 + case TransportMode.pt: Assertions.assertEquals(3.389540900429034, value, MatsimTestUtils.EPSILON); break; // (a) 3.3065653876694023 + case "matrixBasedPt": Assertions.assertEquals(2.893683407764653, value, MatsimTestUtils.EPSILON); break; // (a) 2.0112226418584043 } } } diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/NetworkUtilTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/NetworkUtilTest.java index e131507e5ad..cf03d50fa9d 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/NetworkUtilTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/NetworkUtilTest.java @@ -21,7 +21,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -89,119 +89,119 @@ void testNetworkUtil() { Distances distanceA11 = NetworkUtil.getDistances2NodeViaGivenLink(a, link1, node1); - Assert.assertEquals("distanceA11.getDistancePoint2Road()", 100., distanceA11.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); - Assert.assertEquals("distanceA11.getDistanceRoad2Node()", 0., distanceA11.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(100., distanceA11.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON, "distanceA11.getDistancePoint2Road()"); + Assertions.assertEquals(0., distanceA11.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON, "distanceA11.getDistanceRoad2Node()"); Coord projectionA11 = CoordUtils.orthogonalProjectionOnLineSegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), a); - Assert.assertEquals("projectionA11.getX()", 0., projectionA11.getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals("projectionA11.getY()", 0., projectionA11.getY(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0., projectionA11.getX(), MatsimTestUtils.EPSILON, "projectionA11.getX()"); + Assertions.assertEquals(0., projectionA11.getY(), MatsimTestUtils.EPSILON, "projectionA11.getY()"); Distances distanceB11 = NetworkUtil.getDistances2NodeViaGivenLink(b, link1, node1); - Assert.assertEquals("distanceB11.getDistancePoint2Road()", 100., distanceB11.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); - Assert.assertEquals("distanceB11.getDistanceRoad2Node()", 100., distanceB11.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(100., distanceB11.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON, "distanceB11.getDistancePoint2Road()"); + Assertions.assertEquals(100., distanceB11.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON, "distanceB11.getDistanceRoad2Node()"); Coord projectionB11 = CoordUtils.orthogonalProjectionOnLineSegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), b); - Assert.assertEquals("projectionB11.getX()", 0., projectionB11.getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals("projectionB11.getY()", 100., projectionB11.getY(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0., projectionB11.getX(), MatsimTestUtils.EPSILON, "projectionB11.getX()"); + Assertions.assertEquals(100., projectionB11.getY(), MatsimTestUtils.EPSILON, "projectionB11.getY()"); Distances distanceB12 = NetworkUtil.getDistances2NodeViaGivenLink(b, link1, node2); - Assert.assertEquals("distanceB12.getDistancePoint2Road()", 100., distanceB12.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); - Assert.assertEquals("distanceB12.getDistanceRoad2Node()", 900., distanceB12.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(100., distanceB12.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON, "distanceB12.getDistancePoint2Road()"); + Assertions.assertEquals(900., distanceB12.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON, "distanceB12.getDistanceRoad2Node()"); Coord projectionB12 = CoordUtils.orthogonalProjectionOnLineSegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), b); - Assert.assertEquals("projectionB12.getX()", 0., projectionB12.getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals("projectionB12.getY()", 100., projectionB12.getY(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0., projectionB12.getX(), MatsimTestUtils.EPSILON, "projectionB12.getX()"); + Assertions.assertEquals(100., projectionB12.getY(), MatsimTestUtils.EPSILON, "projectionB12.getY()"); Distances distanceC11 = NetworkUtil.getDistances2NodeViaGivenLink(c, link1, node1); - Assert.assertEquals("distanceC11.getDistancePoint2Road()", 100., distanceC11.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); - Assert.assertEquals("distanceC11.getDistanceRoad2Node()", 1000., distanceC11.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(100., distanceC11.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON, "distanceC11.getDistancePoint2Road()"); + Assertions.assertEquals(1000., distanceC11.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON, "distanceC11.getDistanceRoad2Node()"); Coord projectionC11 = CoordUtils.orthogonalProjectionOnLineSegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), c); - Assert.assertEquals("projectionC11.getX()", 0., projectionC11.getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals("projectionC11.getY()", 1000., projectionC11.getY(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0., projectionC11.getX(), MatsimTestUtils.EPSILON, "projectionC11.getX()"); + Assertions.assertEquals(1000., projectionC11.getY(), MatsimTestUtils.EPSILON, "projectionC11.getY()"); Distances distanceC12 = NetworkUtil.getDistances2NodeViaGivenLink(c, link1, node2); - Assert.assertEquals("distanceC12.getDistancePoint2Road()", 100., distanceC12.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); - Assert.assertEquals("distanceC12.getDistanceRoad2Node()", 0., distanceC12.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(100., distanceC12.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON, "distanceC12.getDistancePoint2Road()"); + Assertions.assertEquals(0., distanceC12.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON, "distanceC12.getDistanceRoad2Node()"); Coord projectionC12 = CoordUtils.orthogonalProjectionOnLineSegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), c); - Assert.assertEquals("projectionC12.getX()", 0., projectionC12.getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals("projectionC12.getY()", 1000., projectionC12.getY(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0., projectionC12.getX(), MatsimTestUtils.EPSILON, "projectionC12.getX()"); + Assertions.assertEquals(1000., projectionC12.getY(), MatsimTestUtils.EPSILON, "projectionC12.getY()"); Distances distanceC22 = NetworkUtil.getDistances2NodeViaGivenLink(c, link2, node2); - Assert.assertEquals("distanceC22.getDistancePoint2Road()", Math.sqrt(2.) / 2. * 100., distanceC22.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); - Assert.assertEquals("distanceC22.getDistanceRoad2Node()", Math.sqrt(2.) / 2. * 100., distanceC22.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(Math.sqrt(2.) / 2. * 100., distanceC22.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON, "distanceC22.getDistancePoint2Road()"); + Assertions.assertEquals(Math.sqrt(2.) / 2. * 100., distanceC22.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON, "distanceC22.getDistanceRoad2Node()"); Coord projectionC22 = CoordUtils.orthogonalProjectionOnLineSegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), c); - Assert.assertEquals("projectionC22.getX()", 50., projectionC22.getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals("projectionC22.getY()", 1050., projectionC22.getY(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(50., projectionC22.getX(), MatsimTestUtils.EPSILON, "projectionC22.getX()"); + Assertions.assertEquals(1050., projectionC22.getY(), MatsimTestUtils.EPSILON, "projectionC22.getY()"); Distances distanceC23 = NetworkUtil.getDistances2NodeViaGivenLink(c, link2, node3); - Assert.assertEquals("distanceC23.getDistancePoint2Road()", Math.sqrt(2.) / 2. * 100., distanceC23.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); - Assert.assertEquals("distanceC23.getDistanceRoad2Node()", Math.sqrt(2) * 1000. - Math.sqrt(2.) / 2. * 100., distanceC23.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(Math.sqrt(2.) / 2. * 100., distanceC23.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON, "distanceC23.getDistancePoint2Road()"); + Assertions.assertEquals(Math.sqrt(2) * 1000. - Math.sqrt(2.) / 2. * 100., distanceC23.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON, "distanceC23.getDistanceRoad2Node()"); Coord projectionC23 = CoordUtils.orthogonalProjectionOnLineSegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), c); - Assert.assertEquals("projectionC23.getX()", 50., projectionC23.getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals("projectionC23.getY()", 1050., projectionC23.getY(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(50., projectionC23.getX(), MatsimTestUtils.EPSILON, "projectionC23.getX()"); + Assertions.assertEquals(1050., projectionC23.getY(), MatsimTestUtils.EPSILON, "projectionC23.getY()"); Distances distanceD22 = NetworkUtil.getDistances2NodeViaGivenLink(d, link2, node2); - Assert.assertEquals("distanceD22.getDistancePoint2Road()", Math.sqrt(2.) / 2. * 100.0, distanceD22.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); - Assert.assertEquals("distanceD22.getDistanceRoad2Node()", Math.sqrt(2.) / 2. * 100.0 + Math.sqrt(2) * 200., distanceD22.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(Math.sqrt(2.) / 2. * 100.0, distanceD22.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON, "distanceD22.getDistancePoint2Road()"); + Assertions.assertEquals(Math.sqrt(2.) / 2. * 100.0 + Math.sqrt(2) * 200., distanceD22.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON, "distanceD22.getDistanceRoad2Node()"); Coord projectionD22 = CoordUtils.orthogonalProjectionOnLineSegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), d); - Assert.assertEquals("projectionD22.getX()", 250., projectionD22.getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals("projectionD22.getY()", 1250., projectionD22.getY(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(250., projectionD22.getX(), MatsimTestUtils.EPSILON, "projectionD22.getX()"); + Assertions.assertEquals(1250., projectionD22.getY(), MatsimTestUtils.EPSILON, "projectionD22.getY()"); Distances distanceD23 = NetworkUtil.getDistances2NodeViaGivenLink(d, link2, node3); - Assert.assertEquals("distanceD23.getDistancePoint2Road()", Math.sqrt(2.)/2.*100.0, distanceD23.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); - Assert.assertEquals("distanceD23.getDistanceRoad2Node()", Math.sqrt(2.)/2.*100.0 + Math.sqrt(2) * 700., distanceD23.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(Math.sqrt(2.)/2.*100.0, distanceD23.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON, "distanceD23.getDistancePoint2Road()"); + Assertions.assertEquals(Math.sqrt(2.)/2.*100.0 + Math.sqrt(2) * 700., distanceD23.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON, "distanceD23.getDistanceRoad2Node()"); Coord projectionD23 = CoordUtils.orthogonalProjectionOnLineSegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), d); - Assert.assertEquals("projectionD23.getX()", 250., projectionD23.getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals("projectionD23.getY()", 1250., projectionD23.getY(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(250., projectionD23.getX(), MatsimTestUtils.EPSILON, "projectionD23.getX()"); + Assertions.assertEquals(1250., projectionD23.getY(), MatsimTestUtils.EPSILON, "projectionD23.getY()"); Distances distanceE33 = NetworkUtil.getDistances2NodeViaGivenLink(e, link3, node3); - Assert.assertEquals("distanceE33.getDistancePoint2Road()", 100.0, distanceE33.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); - Assert.assertEquals("distanceE33.getDistanceRoad2Node()", 300.0, distanceE33.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(100.0, distanceE33.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON, "distanceE33.getDistancePoint2Road()"); + Assertions.assertEquals(300.0, distanceE33.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON, "distanceE33.getDistanceRoad2Node()"); Coord projectionE33 = CoordUtils.orthogonalProjectionOnLineSegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), e); - Assert.assertEquals("projectionE33.getX()", 1300., projectionE33.getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals("projectionE33.getY()", 2000., projectionE33.getY(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1300., projectionE33.getX(), MatsimTestUtils.EPSILON, "projectionE33.getX()"); + Assertions.assertEquals(2000., projectionE33.getY(), MatsimTestUtils.EPSILON, "projectionE33.getY()"); Distances distanceE34 = NetworkUtil.getDistances2NodeViaGivenLink(e, link3, node4); - Assert.assertEquals("distanceE34.getDistancePoint2Road()", 100.0, distanceE34.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); - Assert.assertEquals("distanceE34.getDistanceRoad2Node()", 700.0, distanceE34.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(100.0, distanceE34.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON, "distanceE34.getDistancePoint2Road()"); + Assertions.assertEquals(700.0, distanceE34.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON, "distanceE34.getDistanceRoad2Node()"); Coord projectionE34 = CoordUtils.orthogonalProjectionOnLineSegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), e); - Assert.assertEquals("projectionE34.getX()", 1300., projectionE34.getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals("projectionE34.getY()", 2000., projectionE34.getY(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1300., projectionE34.getX(), MatsimTestUtils.EPSILON, "projectionE34.getX()"); + Assertions.assertEquals(2000., projectionE34.getY(), MatsimTestUtils.EPSILON, "projectionE34.getY()"); Distances distanceF33 = NetworkUtil.getDistances2NodeViaGivenLink(f, link3, node3); - Assert.assertEquals("distanceF33.getDistancePoint2Road()", Math.sqrt(Math.pow(100, 2) + Math.pow(300, 2)), distanceF33.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); - Assert.assertEquals("distanceF33.getDistanceRoad2Node()", 1000., distanceF33.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(Math.sqrt(Math.pow(100, 2) + Math.pow(300, 2)), distanceF33.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON, "distanceF33.getDistancePoint2Road()"); + Assertions.assertEquals(1000., distanceF33.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON, "distanceF33.getDistanceRoad2Node()"); Coord projectionF33 = CoordUtils.orthogonalProjectionOnLineSegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), e); - Assert.assertEquals("projectionF33.getX()", 1300., projectionF33.getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals("projectionF33.getY()", 2000., projectionF33.getY(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1300., projectionF33.getX(), MatsimTestUtils.EPSILON, "projectionF33.getX()"); + Assertions.assertEquals(2000., projectionF33.getY(), MatsimTestUtils.EPSILON, "projectionF33.getY()"); Distances distanceF34 = NetworkUtil.getDistances2NodeViaGivenLink(f, link3, node4); - Assert.assertEquals("distanceF34.getDistancePoint2Road()", Math.sqrt(Math.pow(100, 2) + Math.pow(300, 2)), distanceF34.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON); - Assert.assertEquals("distanceF34.getDistanceRoad2Node()", 0., distanceF34.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(Math.sqrt(Math.pow(100, 2) + Math.pow(300, 2)), distanceF34.getDistancePoint2Intersection(), MatsimTestUtils.EPSILON, "distanceF34.getDistancePoint2Road()"); + Assertions.assertEquals(0., distanceF34.getDistanceIntersection2Node(), MatsimTestUtils.EPSILON, "distanceF34.getDistanceRoad2Node()"); Coord projectionF34 = CoordUtils.orthogonalProjectionOnLineSegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), f); - Assert.assertEquals("projectionF34.getX()", 2000., projectionF34.getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals("projectionF34.getY()", 2000., projectionF34.getY(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2000., projectionF34.getX(), MatsimTestUtils.EPSILON, "projectionF34.getX()"); + Assertions.assertEquals(2000., projectionF34.getY(), MatsimTestUtils.EPSILON, "projectionF34.getY()"); } } diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyAccessibilityTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyAccessibilityTest.java index 9e7a6eb30f1..8c1e52924b4 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyAccessibilityTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyAccessibilityTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -262,20 +262,20 @@ public void finish() { LOG.warn("CHECK X = " + tuple.getFirst().getCoord().getX() + " -- Y = " + tuple.getFirst().getCoord().getY() + " -- car value = " + accessibilitiesMap.get(tuple).get(TransportMode.car)); if (tuple.getFirst().getCoord().getX() == 50.) { if (tuple.getFirst().getCoord().getY() == 50.) { - Assert.assertEquals(-0.017248522428805767, accessibilitiesMap.get(tuple).get("freespeed"), MatsimTestUtils.EPSILON); - Assert.assertEquals(-0.017240250823867296, accessibilitiesMap.get(tuple).get(TransportMode.car), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.017248522428805767, accessibilitiesMap.get(tuple).get("freespeed"), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.017240250823867296, accessibilitiesMap.get(tuple).get(TransportMode.car), MatsimTestUtils.EPSILON); } else if (tuple.getFirst().getCoord().getY() == 150.) { - Assert.assertEquals(-0.017248522428805767, accessibilitiesMap.get(tuple).get("freespeed"), MatsimTestUtils.EPSILON); - Assert.assertEquals(-0.017240250823867296, accessibilitiesMap.get(tuple).get(TransportMode.car), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.017248522428805767, accessibilitiesMap.get(tuple).get("freespeed"), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.017240250823867296, accessibilitiesMap.get(tuple).get(TransportMode.car), MatsimTestUtils.EPSILON); } } if (tuple.getFirst().getCoord().getX() == 150.) { if (tuple.getFirst().getCoord().getY() == 50.) { - Assert.assertEquals(0.2758252376673665, accessibilitiesMap.get(tuple).get("freespeed"), MatsimTestUtils.EPSILON); - Assert.assertEquals(0.27582980607476704, accessibilitiesMap.get(tuple).get(TransportMode.car), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.2758252376673665, accessibilitiesMap.get(tuple).get("freespeed"), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.27582980607476704, accessibilitiesMap.get(tuple).get(TransportMode.car), MatsimTestUtils.EPSILON); } else if (tuple.getFirst().getCoord().getY() == 150.) { - Assert.assertEquals(0.2758252376673665, accessibilitiesMap.get(tuple).get("freespeed"), MatsimTestUtils.EPSILON); - Assert.assertEquals(0.27582980607476704, accessibilitiesMap.get(tuple).get(TransportMode.car), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.2758252376673665, accessibilitiesMap.get(tuple).get("freespeed"), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.27582980607476704, accessibilitiesMap.get(tuple).get(TransportMode.car), MatsimTestUtils.EPSILON); } } } diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java index 3f407b42ffb..d7ab5eaaf3c 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java @@ -21,8 +21,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -310,24 +310,24 @@ public void finish() { LOG.warn("CHECK X = " + tuple.getFirst().getCoord().getX() + " -- Y = " + tuple.getFirst().getCoord().getY() + " -- car value = " + accessibilitiesMap.get(tuple).get(TransportMode.car)); if (tuple.getFirst().getCoord().getX() == 50.) { if (tuple.getFirst().getCoord().getY() == 50.) { - Assert.assertEquals(-0.017248522428805767, accessibilitiesMap.get(tuple).get("freespeed"), MatsimTestUtils.EPSILON); - Assert.assertEquals(-0.017248522428805767, accessibilitiesMap.get(tuple).get(TransportMode.car), MatsimTestUtils.EPSILON); - Assert.assertEquals(0.0020510618020555325, accessibilitiesMap.get(tuple).get(TransportMode.pt), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.017248522428805767, accessibilitiesMap.get(tuple).get("freespeed"), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.017248522428805767, accessibilitiesMap.get(tuple).get(TransportMode.car), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0020510618020555325, accessibilitiesMap.get(tuple).get(TransportMode.pt), MatsimTestUtils.EPSILON); } else if (tuple.getFirst().getCoord().getY() == 150.) { - Assert.assertEquals(-0.017248522428805767, accessibilitiesMap.get(tuple).get("freespeed"), MatsimTestUtils.EPSILON); - Assert.assertEquals(-0.017248522428805767, accessibilitiesMap.get(tuple).get(TransportMode.car), MatsimTestUtils.EPSILON); - Assert.assertEquals(-0.04152005026781742, accessibilitiesMap.get(tuple).get(TransportMode.pt), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.017248522428805767, accessibilitiesMap.get(tuple).get("freespeed"), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.017248522428805767, accessibilitiesMap.get(tuple).get(TransportMode.car), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.04152005026781742, accessibilitiesMap.get(tuple).get(TransportMode.pt), MatsimTestUtils.EPSILON); } } if (tuple.getFirst().getCoord().getX() == 150.) { if (tuple.getFirst().getCoord().getY() == 50.) { - Assert.assertEquals(0.2758252376673665, accessibilitiesMap.get(tuple).get("freespeed"), MatsimTestUtils.EPSILON); - Assert.assertEquals(0.2758252376673665, accessibilitiesMap.get(tuple).get(TransportMode.car), MatsimTestUtils.EPSILON); - Assert.assertEquals(0.25069951470887114, accessibilitiesMap.get(tuple).get(TransportMode.pt), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.2758252376673665, accessibilitiesMap.get(tuple).get("freespeed"), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.2758252376673665, accessibilitiesMap.get(tuple).get(TransportMode.car), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.25069951470887114, accessibilitiesMap.get(tuple).get(TransportMode.pt), MatsimTestUtils.EPSILON); } else if (tuple.getFirst().getCoord().getY() == 150.) { - Assert.assertEquals(0.2758252376673665, accessibilitiesMap.get(tuple).get("freespeed"), MatsimTestUtils.EPSILON); - Assert.assertEquals(0.2758252376673665, accessibilitiesMap.get(tuple).get(TransportMode.car), MatsimTestUtils.EPSILON); - Assert.assertEquals(0.25069951470887114, accessibilitiesMap.get(tuple).get(TransportMode.pt), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.2758252376673665, accessibilitiesMap.get(tuple).get("freespeed"), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.2758252376673665, accessibilitiesMap.get(tuple).get(TransportMode.car), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.25069951470887114, accessibilitiesMap.get(tuple).get(TransportMode.pt), MatsimTestUtils.EPSILON); } } } diff --git a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/BvwpAccidentsCostComputationTest.java b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/BvwpAccidentsCostComputationTest.java index 5e6bd4a91d0..3cb595ee1e6 100644 --- a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/BvwpAccidentsCostComputationTest.java +++ b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/BvwpAccidentsCostComputationTest.java @@ -2,7 +2,7 @@ import java.util.ArrayList; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -40,7 +40,7 @@ void test1() { list.add(2, 2); //2 Lanes double costs = AccidentCostComputationBVWP.computeAccidentCosts(4820, link1, list); - Assert.assertEquals("wrong cost", 1772.13863066011, costs, MatsimTestUtils.EPSILON); + Assertions.assertEquals(1772.13863066011, costs, MatsimTestUtils.EPSILON, "wrong cost"); } @Test @@ -62,7 +62,7 @@ void test2() { list.add(2, 2); //2 Lanes double costs = AccidentCostComputationBVWP.computeAccidentCosts(1000, link1, list); - Assert.assertEquals("wrong cost", 23.165, costs, MatsimTestUtils.EPSILON); + Assertions.assertEquals(23.165, costs, MatsimTestUtils.EPSILON, "wrong cost"); } @Test @@ -84,6 +84,6 @@ void test3() { list.add(2, 3); //2 Lanes double costs = AccidentCostComputationBVWP.computeAccidentCosts(1000, link1, list); - Assert.assertEquals("wrong cost", 101.53, costs, MatsimTestUtils.EPSILON); + Assertions.assertEquals(101.53, costs, MatsimTestUtils.EPSILON, "wrong cost"); } } diff --git a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTest.java b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTest.java index b087e316b5b..f07d1d8d5f9 100644 --- a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTest.java +++ b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTest.java @@ -3,7 +3,7 @@ import java.io.BufferedReader; import java.io.IOException; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -86,12 +86,12 @@ void test1() { if (lineCounter == 0 && column == 25) { double accidentCosts = Double.valueOf(columns[column]); - Assert.assertEquals("wrong accident costs", 10.38, accidentCosts , MatsimTestUtils.EPSILON); + Assertions.assertEquals(10.38, accidentCosts , MatsimTestUtils.EPSILON, "wrong accident costs"); } if (lineCounter == 1 && column == 25) { double accidentCosts = Double.valueOf(columns[column]); - Assert.assertEquals("wrong accident costs", 16.68, accidentCosts , MatsimTestUtils.EPSILON); + Assertions.assertEquals(16.68, accidentCosts , MatsimTestUtils.EPSILON, "wrong accident costs"); } } diff --git a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTestEquil.java b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTestEquil.java index 94e8df01123..486baf7f3ec 100644 --- a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTestEquil.java +++ b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTestEquil.java @@ -1,8 +1,9 @@ package org.matsim.contrib.accidents; import java.io.BufferedReader; -import java.io.IOException; -import org.junit.Assert; +import java.io.IOException; + +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -88,7 +89,7 @@ void test1() { int agents = 100; int lengthKM = 35; double accidentCostsManualCalculation = (agents * lengthKM * 61.785) / 1000. * 10; - Assert.assertEquals("wrong accident costs", accidentCostsManualCalculation, accidentCosts , 0.01); + Assertions.assertEquals(accidentCostsManualCalculation, accidentCosts , 0.01, "wrong accident costs"); } // link 1 if (lineCounter == 11 && column == 121) { @@ -96,7 +97,7 @@ void test1() { int agents = 100; int lengthKM = 10; double accidentCostsManualCalculation = (agents * lengthKM * 61.785) / 1000. * 10; - Assert.assertEquals("wrong accident costs", accidentCostsManualCalculation, accidentCosts , 0.01); + Assertions.assertEquals(accidentCostsManualCalculation, accidentCosts , 0.01, "wrong accident costs"); } // link 6 @@ -105,7 +106,7 @@ void test1() { int agents = 100; int lengthKM = 10; double accidentCostsManualCalculation = (agents * lengthKM * 34.735) / 1000. * 10; - Assert.assertEquals("wrong accident costs", accidentCostsManualCalculation, accidentCosts , 0.01); + Assertions.assertEquals(accidentCostsManualCalculation, accidentCosts , 0.01, "wrong accident costs"); } // link 15 @@ -114,7 +115,7 @@ void test1() { int agents = 100; int lengthKM = 5; double accidentCostsManualCalculation = (agents * lengthKM * 31.63) / 1000. * 10; - Assert.assertEquals("wrong accident costs", accidentCostsManualCalculation, accidentCosts , 0.01); + Assertions.assertEquals(accidentCostsManualCalculation, accidentCosts , 0.01, "wrong accident costs"); } } diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/PersonIntersectAreaFilterTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/PersonIntersectAreaFilterTest.java index 53501436d54..aed33926f02 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/PersonIntersectAreaFilterTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/PersonIntersectAreaFilterTest.java @@ -20,8 +20,8 @@ package org.matsim.contrib.analysis.filters.population; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.HashMap; @@ -114,25 +114,25 @@ void testFilter() throws Exception { aoi.clear(); aoi.put(link2.getId(), link2); filter = new PersonIntersectAreaFilter(null, aoi, network); - assertTrue("test route through aoi", filter.judge(person)); + assertTrue(filter.judge(person), "test route through aoi"); // test departure link aoi.clear(); aoi.put(link0.getId(), link0); filter = new PersonIntersectAreaFilter(null, aoi, network); - assertTrue("test departure link as aoi", filter.judge(person)); + assertTrue(filter.judge(person), "test departure link as aoi"); // test arrival link aoi.clear(); aoi.put(link5.getId(), link5); filter = new PersonIntersectAreaFilter(null, aoi, network); - assertTrue("test arrival link as aoi", filter.judge(person)); + assertTrue(filter.judge(person), "test arrival link as aoi"); // test route outside aoi aoi.clear(); aoi.put(link4.getId(), link4); filter = new PersonIntersectAreaFilter(null, aoi, network); - assertFalse("test route outside aoi", filter.judge(person)); + assertFalse(filter.judge(person), "test route outside aoi"); // prepare bee-line tests leg.setMode(TransportMode.walk); @@ -142,21 +142,21 @@ void testFilter() throws Exception { aoi.clear(); aoi.put(link2.getId(), link2); filter = new PersonIntersectAreaFilter(null, aoi, network); - assertFalse("test bee-line without alternative aoi", filter.judge(person)); + assertFalse(filter.judge(person), "test bee-line without alternative aoi"); // test bee-line with too small alternative aoi aoi.clear(); aoi.put(link2.getId(), link2); filter = new PersonIntersectAreaFilter(null, aoi, network); filter.setAlternativeAOI(new Coord((double) 100, (double) 0), 20.0); - assertFalse("test bee-line with too small alternative aoi", filter.judge(person)); + assertFalse(filter.judge(person), "test bee-line with too small alternative aoi"); // test bee-line with big enough alternative aoi aoi.clear(); aoi.put(link2.getId(), link2); filter = new PersonIntersectAreaFilter(null, aoi, network); filter.setAlternativeAOI(new Coord((double) 100, (double) 0), 80.0); - assertTrue("test bee-line with big enough alternative aoi", filter.judge(person)); + assertTrue(filter.judge(person), "test bee-line with big enough alternative aoi"); } diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/RouteLinkFilterTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/RouteLinkFilterTest.java index 4f5b186f055..c434dca8a24 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/RouteLinkFilterTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/filters/population/RouteLinkFilterTest.java @@ -20,8 +20,8 @@ package org.matsim.contrib.analysis.filters.population; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java index f474729f527..a42e5780cc4 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java @@ -23,9 +23,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -172,7 +172,7 @@ protected void runTest(KNAnalysisEventsHandler calcLegTimes) { LogManager.getLogger(this.getClass()).info( "comparing " + str ); final long expectedChecksum = CRCChecksum.getCRCFromFile(utils.getInputDirectory() + str); final long actualChecksum = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + str); - Assert.assertEquals("Output files differ.", expectedChecksum, actualChecksum); + Assertions.assertEquals(expectedChecksum, actualChecksum, "Output files differ."); } } diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/GridTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/GridTest.java index 1b223b21821..804de493d3a 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/GridTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/GridTest.java @@ -1,10 +1,10 @@ package org.matsim.contrib.analysis.spatial; -import static org.junit.Assert.assertEquals; - import java.util.Collection; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.GeometryFactory; diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/SpatialInterpolationTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/SpatialInterpolationTest.java index e739ab2b847..1fe102d3534 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/SpatialInterpolationTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/spatial/SpatialInterpolationTest.java @@ -1,8 +1,6 @@ package org.matsim.contrib.analysis.spatial; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; import org.locationtech.jts.geom.Coordinate; diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/time/TimeBinMapTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/time/TimeBinMapTest.java index 3acb0feeec5..13e5e7f291c 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/time/TimeBinMapTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/time/TimeBinMapTest.java @@ -2,8 +2,7 @@ import java.util.Map; -import static org.junit.Assert.*; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java index 3d322dec849..96b87268dc9 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/GoogleMapRouteValidatorTest.java @@ -8,8 +8,8 @@ import java.io.*; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class GoogleMapRouteValidatorTest { @RegisterExtension diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java index 72ec7f44e30..bd95386c9a0 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/vsp/traveltimedistance/HereMapsRouteValidatorTest.java @@ -8,7 +8,7 @@ import java.io.*; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class HereMapsRouteValidatorTest { @RegisterExtension diff --git a/contribs/application/src/test/java/org/matsim/application/ApplicationUtilsTest.java b/contribs/application/src/test/java/org/matsim/application/ApplicationUtilsTest.java index 85a1f820674..31d1d3d1970 100644 --- a/contribs/application/src/test/java/org/matsim/application/ApplicationUtilsTest.java +++ b/contribs/application/src/test/java/org/matsim/application/ApplicationUtilsTest.java @@ -5,7 +5,7 @@ import org.matsim.application.analysis.TestDependentAnalysis; import org.matsim.application.options.ShpOptions; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class ApplicationUtilsTest { diff --git a/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java b/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java index 1abf0991cf0..0db41fd13eb 100644 --- a/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java +++ b/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java @@ -24,7 +24,7 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class MATSimApplicationTest { @@ -36,7 +36,7 @@ void help() { int ret = MATSimApplication.execute(TestScenario.class, "--help"); - assertEquals("Return code should be 0", 0, ret); + assertEquals(0, ret, "Return code should be 0"); } @Test diff --git a/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java b/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java index ca5a7785d4b..e38c4b764c7 100644 --- a/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java +++ b/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java @@ -1,7 +1,7 @@ package org.matsim.application.options; -import org.junit.Assert; import org.junit.Assume; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.locationtech.jts.geom.Geometry; @@ -86,6 +86,6 @@ void testGetGeometry() { expectedGeometry = expectedGeometry.union(geometryToJoin); } - Assert.assertTrue(geometry.equals(expectedGeometry)); + Assertions.assertTrue(geometry.equals(expectedGeometry)); } } diff --git a/contribs/application/src/test/java/org/matsim/application/prepare/counts/CreateCountsFromBAStDataTest.java b/contribs/application/src/test/java/org/matsim/application/prepare/counts/CreateCountsFromBAStDataTest.java index 4c35b94c282..c74d59b7801 100644 --- a/contribs/application/src/test/java/org/matsim/application/prepare/counts/CreateCountsFromBAStDataTest.java +++ b/contribs/application/src/test/java/org/matsim/application/prepare/counts/CreateCountsFromBAStDataTest.java @@ -1,6 +1,6 @@ package org.matsim.application.prepare.counts; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -159,7 +159,7 @@ void testManualMatchedCounts() { MeasurementLocation actual = map.get(supposed); String actualStation = actual.getStationName(); - Assert.assertEquals(station, actualStation); + Assertions.assertEquals(station, actualStation); } } @@ -181,6 +181,6 @@ void testManualMatchingWithWrongInput() { "--manual-matched-counts=" + utils.getPackageInputDirectory() + wrongManualMatchedCounts, }; - Assert.assertThrows(RuntimeException.class, () -> new CreateCountsFromBAStData().execute(args)); + Assertions.assertThrows(RuntimeException.class, () -> new CreateCountsFromBAStData().execute(args)); } } diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/CarrierReaderFromCSVTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/CarrierReaderFromCSVTest.java index e66b63d3dd1..1bcb22e6b80 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/CarrierReaderFromCSVTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/CarrierReaderFromCSVTest.java @@ -9,7 +9,7 @@ import java.util.Map; import java.util.Set; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -61,101 +61,101 @@ void carrierCreation() throws IOException { CarrierReaderFromCSV.checkNewCarrier(allNewCarrierInformation, freightCarriersConfigGroup, scenario, polygonsInShape, shapeCategory); CarrierReaderFromCSV.createNewCarrierAndAddVehicleTypes(scenario, allNewCarrierInformation, freightCarriersConfigGroup, polygonsInShape, 1, null); - Assert.assertEquals(3, CarriersUtils.getCarriers(scenario).getCarriers().size()); - Assert.assertTrue( + Assertions.assertEquals(3, CarriersUtils.getCarriers(scenario).getCarriers().size()); + Assertions.assertTrue( CarriersUtils.getCarriers(scenario).getCarriers().containsKey(Id.create("testCarrier1", Carrier.class))); - Assert.assertTrue( + Assertions.assertTrue( CarriersUtils.getCarriers(scenario).getCarriers().containsKey(Id.create("testCarrier2", Carrier.class))); - Assert.assertTrue( + Assertions.assertTrue( CarriersUtils.getCarriers(scenario).getCarriers().containsKey(Id.create("testCarrier3", Carrier.class))); // check carrier 1 Carrier testCarrier1 = CarriersUtils.getCarriers(scenario).getCarriers() .get(Id.create("testCarrier1", Carrier.class)); - Assert.assertEquals(FleetSize.INFINITE, testCarrier1.getCarrierCapabilities().getFleetSize()); - Assert.assertEquals(10, CarriersUtils.getJspritIterations(testCarrier1)); - Assert.assertEquals(4, testCarrier1.getCarrierCapabilities().getCarrierVehicles().size()); + Assertions.assertEquals(FleetSize.INFINITE, testCarrier1.getCarrierCapabilities().getFleetSize()); + Assertions.assertEquals(10, CarriersUtils.getJspritIterations(testCarrier1)); + Assertions.assertEquals(4, testCarrier1.getCarrierCapabilities().getCarrierVehicles().size()); Object2IntMap depotSums = new Object2IntOpenHashMap<>(); Map> typesPerDepot = new HashMap<>(); for (CarrierVehicle carrierVehicle : testCarrier1.getCarrierCapabilities().getCarrierVehicles().values()) { typesPerDepot.computeIfAbsent(carrierVehicle.getLinkId().toString(), ( k) -> new ArrayList<>() ) .add(carrierVehicle.getVehicleTypeId().toString()); depotSums.merge(carrierVehicle.getLinkId().toString(), 1, Integer::sum ); - Assert.assertEquals(3600, carrierVehicle.getEarliestStartTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals(50000, carrierVehicle.getLatestEndTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3600, carrierVehicle.getEarliestStartTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(50000, carrierVehicle.getLatestEndTime(), MatsimTestUtils.EPSILON); } - Assert.assertEquals(2, depotSums.size()); - Assert.assertTrue(depotSums.containsKey("i(2,0)")); - Assert.assertEquals(2, depotSums.getInt("i(2,0)")); - Assert.assertTrue(depotSums.containsKey("j(2,4)R")); - Assert.assertEquals(2, depotSums.getInt("j(2,4)R")); - Assert.assertEquals(2, typesPerDepot.size()); - Assert.assertTrue(typesPerDepot.containsKey("i(2,0)")); - Assert.assertEquals(2, typesPerDepot.get("i(2,0)").size()); - Assert.assertTrue(typesPerDepot.get("i(2,0)").contains("testVehicle1")); - Assert.assertTrue(typesPerDepot.get("i(2,0)").contains("testVehicle2")); - Assert.assertTrue(typesPerDepot.containsKey("j(2,4)R")); - Assert.assertEquals(2, typesPerDepot.get("j(2,4)R").size()); - Assert.assertTrue(typesPerDepot.get("j(2,4)R").contains("testVehicle1")); - Assert.assertTrue(typesPerDepot.get("j(2,4)R").contains("testVehicle2")); + Assertions.assertEquals(2, depotSums.size()); + Assertions.assertTrue(depotSums.containsKey("i(2,0)")); + Assertions.assertEquals(2, depotSums.getInt("i(2,0)")); + Assertions.assertTrue(depotSums.containsKey("j(2,4)R")); + Assertions.assertEquals(2, depotSums.getInt("j(2,4)R")); + Assertions.assertEquals(2, typesPerDepot.size()); + Assertions.assertTrue(typesPerDepot.containsKey("i(2,0)")); + Assertions.assertEquals(2, typesPerDepot.get("i(2,0)").size()); + Assertions.assertTrue(typesPerDepot.get("i(2,0)").contains("testVehicle1")); + Assertions.assertTrue(typesPerDepot.get("i(2,0)").contains("testVehicle2")); + Assertions.assertTrue(typesPerDepot.containsKey("j(2,4)R")); + Assertions.assertEquals(2, typesPerDepot.get("j(2,4)R").size()); + Assertions.assertTrue(typesPerDepot.get("j(2,4)R").contains("testVehicle1")); + Assertions.assertTrue(typesPerDepot.get("j(2,4)R").contains("testVehicle2")); // check carrier 2 Carrier testCarrier2 = CarriersUtils.getCarriers(scenario).getCarriers() .get(Id.create("testCarrier2", Carrier.class)); - Assert.assertEquals(FleetSize.FINITE, testCarrier2.getCarrierCapabilities().getFleetSize()); - Assert.assertEquals(15, CarriersUtils.getJspritIterations(testCarrier2)); - Assert.assertEquals(9, testCarrier2.getCarrierCapabilities().getCarrierVehicles().size()); + Assertions.assertEquals(FleetSize.FINITE, testCarrier2.getCarrierCapabilities().getFleetSize()); + Assertions.assertEquals(15, CarriersUtils.getJspritIterations(testCarrier2)); + Assertions.assertEquals(9, testCarrier2.getCarrierCapabilities().getCarrierVehicles().size()); depotSums = new Object2IntOpenHashMap<>(); typesPerDepot = new HashMap<>(); for (CarrierVehicle carrierVehicle : testCarrier2.getCarrierCapabilities().getCarrierVehicles().values()) { typesPerDepot.computeIfAbsent(carrierVehicle.getLinkId().toString(), ( k) -> new ArrayList<>() ) .add(carrierVehicle.getVehicleTypeId().toString()); depotSums.merge(carrierVehicle.getLinkId().toString(), 1, Integer::sum ); - Assert.assertEquals(3600, carrierVehicle.getEarliestStartTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals(50000, carrierVehicle.getLatestEndTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3600, carrierVehicle.getEarliestStartTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(50000, carrierVehicle.getLatestEndTime(), MatsimTestUtils.EPSILON); } - Assert.assertEquals(3, depotSums.size()); - Assert.assertTrue(depotSums.containsKey("j(4,3)R")); - Assert.assertEquals(3, depotSums.getInt("j(4,3)R")); - Assert.assertEquals(3, typesPerDepot.size()); - Assert.assertTrue(typesPerDepot.containsKey("j(4,3)R")); - Assert.assertEquals(3, typesPerDepot.get("j(4,3)R").size()); - Assert.assertTrue(typesPerDepot.get("j(4,3)R").contains("testVehicle2")); + Assertions.assertEquals(3, depotSums.size()); + Assertions.assertTrue(depotSums.containsKey("j(4,3)R")); + Assertions.assertEquals(3, depotSums.getInt("j(4,3)R")); + Assertions.assertEquals(3, typesPerDepot.size()); + Assertions.assertTrue(typesPerDepot.containsKey("j(4,3)R")); + Assertions.assertEquals(3, typesPerDepot.get("j(4,3)R").size()); + Assertions.assertTrue(typesPerDepot.get("j(4,3)R").contains("testVehicle2")); // check carrier 3 Network network = NetworkUtils.readNetwork( "https://raw.githubusercontent.com/matsim-org/matsim-libs/master/examples/scenarios/freight-chessboard-9x9/grid9x9.xml"); Carrier testCarrier3 = CarriersUtils.getCarriers(scenario).getCarriers() .get(Id.create("testCarrier3", Carrier.class)); - Assert.assertEquals(FleetSize.INFINITE, testCarrier3.getCarrierCapabilities().getFleetSize()); - Assert.assertEquals(1, CarriersUtils.getJspritIterations(testCarrier3)); - Assert.assertEquals(2, testCarrier3.getCarrierCapabilities().getCarrierVehicles().size()); + Assertions.assertEquals(FleetSize.INFINITE, testCarrier3.getCarrierCapabilities().getFleetSize()); + Assertions.assertEquals(1, CarriersUtils.getJspritIterations(testCarrier3)); + Assertions.assertEquals(2, testCarrier3.getCarrierCapabilities().getCarrierVehicles().size()); depotSums = new Object2IntOpenHashMap<>(); typesPerDepot = new HashMap<>(); for (CarrierVehicle carrierVehicle : testCarrier3.getCarrierCapabilities().getCarrierVehicles().values()) { typesPerDepot.computeIfAbsent(carrierVehicle.getLinkId().toString(), ( k) -> new ArrayList<>() ) .add(carrierVehicle.getVehicleTypeId().toString()); depotSums.merge(carrierVehicle.getLinkId().toString(), 1, Integer::sum ); - Assert.assertEquals(50000, carrierVehicle.getEarliestStartTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals(80000, carrierVehicle.getLatestEndTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(50000, carrierVehicle.getEarliestStartTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(80000, carrierVehicle.getLatestEndTime(), MatsimTestUtils.EPSILON); } - Assert.assertEquals(2, depotSums.size()); - Assert.assertTrue(depotSums.containsKey("j(2,6)R")); - Assert.assertEquals(1, depotSums.getInt("j(2,6)R")); + Assertions.assertEquals(2, depotSums.size()); + Assertions.assertTrue(depotSums.containsKey("j(2,6)R")); + Assertions.assertEquals(1, depotSums.getInt("j(2,6)R")); for (String depot : depotSums.keySet()) { if (!depot.equals("j(2,6)R")) { Link link = network.getLinks().get(Id.createLinkId(depot)); - Assert.assertTrue( + Assertions.assertTrue( FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, null, null)); - Assert.assertTrue(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[]{"area1"}, null)); - Assert.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[]{"area2"}, null)); + Assertions.assertTrue(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[]{"area1"}, null)); + Assertions.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[]{"area2"}, null)); } } - Assert.assertEquals(2, typesPerDepot.size()); - Assert.assertTrue(typesPerDepot.containsKey("j(2,6)R")); - Assert.assertEquals(1, typesPerDepot.get("j(2,6)R").size()); - Assert.assertTrue(typesPerDepot.get("j(2,6)R").contains("testVehicle1")); + Assertions.assertEquals(2, typesPerDepot.size()); + Assertions.assertTrue(typesPerDepot.containsKey("j(2,6)R")); + Assertions.assertEquals(1, typesPerDepot.get("j(2,6)R").size()); + Assertions.assertTrue(typesPerDepot.get("j(2,6)R").contains("testVehicle1")); } @@ -165,53 +165,53 @@ void csvCarrierReader() throws IOException { Path carrierCSVLocation = Path.of(utils.getPackageInputDirectory() + "testCarrierCSV.csv"); Set allNewCarrierInformation = CarrierReaderFromCSV .readCarrierInformation(carrierCSVLocation); - Assert.assertEquals(3, allNewCarrierInformation.size()); + Assertions.assertEquals(3, allNewCarrierInformation.size()); for (CarrierInformationElement carrierInformationElement : allNewCarrierInformation) { if (carrierInformationElement.getName().equals("testCarrier1")) { - Assert.assertNull(carrierInformationElement.getAreaOfAdditionalDepots()); - Assert.assertEquals(0, carrierInformationElement.getFixedNumberOfVehiclePerTypeAndLocation()); - Assert.assertEquals(FleetSize.INFINITE, carrierInformationElement.getFleetSize()); - Assert.assertEquals(10, carrierInformationElement.getJspritIterations()); - Assert.assertEquals(2, carrierInformationElement.getNumberOfDepotsPerType()); - Assert.assertEquals(3600, carrierInformationElement.getVehicleStartTime()); - Assert.assertEquals(50000, carrierInformationElement.getVehicleEndTime()); - Assert.assertEquals(2, carrierInformationElement.getVehicleDepots().size()); - Assert.assertTrue(carrierInformationElement.getVehicleDepots().contains("i(2,0)") + Assertions.assertNull(carrierInformationElement.getAreaOfAdditionalDepots()); + Assertions.assertEquals(0, carrierInformationElement.getFixedNumberOfVehiclePerTypeAndLocation()); + Assertions.assertEquals(FleetSize.INFINITE, carrierInformationElement.getFleetSize()); + Assertions.assertEquals(10, carrierInformationElement.getJspritIterations()); + Assertions.assertEquals(2, carrierInformationElement.getNumberOfDepotsPerType()); + Assertions.assertEquals(3600, carrierInformationElement.getVehicleStartTime()); + Assertions.assertEquals(50000, carrierInformationElement.getVehicleEndTime()); + Assertions.assertEquals(2, carrierInformationElement.getVehicleDepots().size()); + Assertions.assertTrue(carrierInformationElement.getVehicleDepots().contains("i(2,0)") && carrierInformationElement.getVehicleDepots().contains("j(2,4)R")); - Assert.assertEquals(2, carrierInformationElement.getVehicleTypes().length); - Assert.assertTrue(carrierInformationElement.getVehicleTypes()[0].equals("testVehicle1") + Assertions.assertEquals(2, carrierInformationElement.getVehicleTypes().length); + Assertions.assertTrue(carrierInformationElement.getVehicleTypes()[0].equals("testVehicle1") || carrierInformationElement.getVehicleTypes()[0].equals("testVehicle2")); - Assert.assertNotEquals(carrierInformationElement.getVehicleTypes()[0], carrierInformationElement.getVehicleTypes()[1]); + Assertions.assertNotEquals(carrierInformationElement.getVehicleTypes()[0], carrierInformationElement.getVehicleTypes()[1]); } else if (carrierInformationElement.getName().equals("testCarrier3")) { - Assert.assertEquals(1, carrierInformationElement.getAreaOfAdditionalDepots().length); - Assert.assertEquals("area1", carrierInformationElement.getAreaOfAdditionalDepots()[0]); - Assert.assertEquals(0, carrierInformationElement.getFixedNumberOfVehiclePerTypeAndLocation()); - Assert.assertEquals(FleetSize.INFINITE, carrierInformationElement.getFleetSize()); - Assert.assertEquals(0, carrierInformationElement.getJspritIterations()); - Assert.assertEquals(2, carrierInformationElement.getNumberOfDepotsPerType()); - Assert.assertEquals(50000, carrierInformationElement.getVehicleStartTime()); - Assert.assertEquals(80000, carrierInformationElement.getVehicleEndTime()); - Assert.assertEquals(1, carrierInformationElement.getVehicleDepots().size()); - Assert.assertEquals("j(2,6)R", carrierInformationElement.getVehicleDepots().get(0)); - Assert.assertEquals(1, carrierInformationElement.getVehicleTypes().length); - Assert.assertEquals("testVehicle1", carrierInformationElement.getVehicleTypes()[0]); + Assertions.assertEquals(1, carrierInformationElement.getAreaOfAdditionalDepots().length); + Assertions.assertEquals("area1", carrierInformationElement.getAreaOfAdditionalDepots()[0]); + Assertions.assertEquals(0, carrierInformationElement.getFixedNumberOfVehiclePerTypeAndLocation()); + Assertions.assertEquals(FleetSize.INFINITE, carrierInformationElement.getFleetSize()); + Assertions.assertEquals(0, carrierInformationElement.getJspritIterations()); + Assertions.assertEquals(2, carrierInformationElement.getNumberOfDepotsPerType()); + Assertions.assertEquals(50000, carrierInformationElement.getVehicleStartTime()); + Assertions.assertEquals(80000, carrierInformationElement.getVehicleEndTime()); + Assertions.assertEquals(1, carrierInformationElement.getVehicleDepots().size()); + Assertions.assertEquals("j(2,6)R", carrierInformationElement.getVehicleDepots().get(0)); + Assertions.assertEquals(1, carrierInformationElement.getVehicleTypes().length); + Assertions.assertEquals("testVehicle1", carrierInformationElement.getVehicleTypes()[0]); } else if (carrierInformationElement.getName().equals("testCarrier2")) { - Assert.assertNull(carrierInformationElement.getAreaOfAdditionalDepots()); - Assert.assertEquals(3, carrierInformationElement.getFixedNumberOfVehiclePerTypeAndLocation()); - Assert.assertEquals(FleetSize.FINITE, carrierInformationElement.getFleetSize()); - Assert.assertEquals(15, carrierInformationElement.getJspritIterations()); - Assert.assertEquals(3, carrierInformationElement.getNumberOfDepotsPerType()); - Assert.assertEquals(3600, carrierInformationElement.getVehicleStartTime()); - Assert.assertEquals(50000, carrierInformationElement.getVehicleEndTime()); - Assert.assertEquals(1, carrierInformationElement.getVehicleDepots().size()); - Assert.assertEquals("j(4,3)R", carrierInformationElement.getVehicleDepots().get(0)); - Assert.assertEquals(1, carrierInformationElement.getVehicleTypes().length); - Assert.assertEquals("testVehicle2", carrierInformationElement.getVehicleTypes()[0]); + Assertions.assertNull(carrierInformationElement.getAreaOfAdditionalDepots()); + Assertions.assertEquals(3, carrierInformationElement.getFixedNumberOfVehiclePerTypeAndLocation()); + Assertions.assertEquals(FleetSize.FINITE, carrierInformationElement.getFleetSize()); + Assertions.assertEquals(15, carrierInformationElement.getJspritIterations()); + Assertions.assertEquals(3, carrierInformationElement.getNumberOfDepotsPerType()); + Assertions.assertEquals(3600, carrierInformationElement.getVehicleStartTime()); + Assertions.assertEquals(50000, carrierInformationElement.getVehicleEndTime()); + Assertions.assertEquals(1, carrierInformationElement.getVehicleDepots().size()); + Assertions.assertEquals("j(4,3)R", carrierInformationElement.getVehicleDepots().get(0)); + Assertions.assertEquals(1, carrierInformationElement.getVehicleTypes().length); + Assertions.assertEquals("testVehicle2", carrierInformationElement.getVehicleTypes()[0]); } else { - Assert.fail("No expected carrierInformationElement found"); + Assertions.fail("No expected carrierInformationElement found"); } } diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java index 7db97056e79..da396bb7a9e 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java @@ -8,7 +8,7 @@ import java.util.Map; import java.util.Set; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -53,14 +53,14 @@ void testLinkForPerson() throws IOException { for (Person person : population.getPersons().values()) { DemandReaderFromCSV.findLinksForPersons(scenario, nearestLinkPerPerson, person); } - Assert.assertEquals("j(1,8)",nearestLinkPerPerson.get(Id.createPersonId("person1")).values().iterator().next()); - Assert.assertEquals("j(3,3)",nearestLinkPerPerson.get(Id.createPersonId("person2")).values().iterator().next()); - Assert.assertEquals("j(4,5)R",nearestLinkPerPerson.get(Id.createPersonId("person3")).values().iterator().next()); - Assert.assertEquals("j(5,3)",nearestLinkPerPerson.get(Id.createPersonId("person4")).values().iterator().next()); - Assert.assertEquals("j(5,6)",nearestLinkPerPerson.get(Id.createPersonId("person5")).values().iterator().next()); - Assert.assertEquals("j(8,8)R",nearestLinkPerPerson.get(Id.createPersonId("person6")).values().iterator().next()); - Assert.assertEquals("i(5,9)R",nearestLinkPerPerson.get(Id.createPersonId("person7")).values().iterator().next()); - Assert.assertEquals("i(9,5)R",nearestLinkPerPerson.get(Id.createPersonId("person8")).values().iterator().next()); + Assertions.assertEquals("j(1,8)",nearestLinkPerPerson.get(Id.createPersonId("person1")).values().iterator().next()); + Assertions.assertEquals("j(3,3)",nearestLinkPerPerson.get(Id.createPersonId("person2")).values().iterator().next()); + Assertions.assertEquals("j(4,5)R",nearestLinkPerPerson.get(Id.createPersonId("person3")).values().iterator().next()); + Assertions.assertEquals("j(5,3)",nearestLinkPerPerson.get(Id.createPersonId("person4")).values().iterator().next()); + Assertions.assertEquals("j(5,6)",nearestLinkPerPerson.get(Id.createPersonId("person5")).values().iterator().next()); + Assertions.assertEquals("j(8,8)R",nearestLinkPerPerson.get(Id.createPersonId("person6")).values().iterator().next()); + Assertions.assertEquals("i(5,9)R",nearestLinkPerPerson.get(Id.createPersonId("person7")).values().iterator().next()); + Assertions.assertEquals("i(9,5)R",nearestLinkPerPerson.get(Id.createPersonId("person8")).values().iterator().next()); @@ -95,12 +95,12 @@ void demandCreation() throws IOException { DemandReaderFromCSV.checkNewDemand(scenario, demandInformation, polygonsInShape, shapeCategory); DemandReaderFromCSV.createDemandForCarriers(scenario, polygonsInShape, demandInformation, population, false, null); - Assert.assertEquals(3, CarriersUtils.getCarriers(scenario).getCarriers().size()); - Assert.assertTrue( + Assertions.assertEquals(3, CarriersUtils.getCarriers(scenario).getCarriers().size()); + Assertions.assertTrue( CarriersUtils.getCarriers(scenario).getCarriers().containsKey(Id.create("testCarrier1", Carrier.class))); - Assert.assertTrue( + Assertions.assertTrue( CarriersUtils.getCarriers(scenario).getCarriers().containsKey(Id.create("testCarrier2", Carrier.class))); - Assert.assertTrue( + Assertions.assertTrue( CarriersUtils.getCarriers(scenario).getCarriers().containsKey(Id.create("testCarrier3", Carrier.class))); // check carrier 1 @@ -108,8 +108,8 @@ void demandCreation() throws IOException { "https://raw.githubusercontent.com/matsim-org/matsim-libs/master/examples/scenarios/freight-chessboard-9x9/grid9x9.xml"); Carrier testCarrier1 = CarriersUtils.getCarriers(scenario).getCarriers() .get(Id.create("testCarrier1", Carrier.class)); - Assert.assertEquals(14, testCarrier1.getServices().size()); - Assert.assertEquals(0, testCarrier1.getShipments().size()); + Assertions.assertEquals(14, testCarrier1.getServices().size()); + Assertions.assertEquals(0, testCarrier1.getShipments().size()); Object2IntMap countServicesWithCertainDemand = new Object2IntOpenHashMap<>(); Map> locationsPerServiceElement = new HashMap<>(); int countDemand = 0; @@ -117,45 +117,45 @@ void demandCreation() throws IOException { countServicesWithCertainDemand.merge((Integer) service.getCapacityDemand(), 1, Integer::sum); countDemand = countDemand + service.getCapacityDemand(); if (service.getCapacityDemand() == 0) { - Assert.assertEquals(180, service.getServiceDuration(), MatsimTestUtils.EPSILON); - Assert.assertEquals(TimeWindow.newInstance(3000, 13000), service.getServiceStartTimeWindow()); + Assertions.assertEquals(180, service.getServiceDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(3000, 13000), service.getServiceStartTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement1", (k) -> new HashSet<>()) .add(service.getLocationLinkId().toString()); } else if (service.getCapacityDemand() == 1) { - Assert.assertEquals(100, service.getServiceDuration(), MatsimTestUtils.EPSILON); - Assert.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStartTimeWindow()); + Assertions.assertEquals(100, service.getServiceDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStartTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement2", (k) -> new HashSet<>()) .add(service.getLocationLinkId().toString()); } else if (service.getCapacityDemand() == 2) { - Assert.assertEquals(200, service.getServiceDuration(), MatsimTestUtils.EPSILON); - Assert.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStartTimeWindow()); + Assertions.assertEquals(200, service.getServiceDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStartTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement2", (k) -> new HashSet<>()) .add(service.getLocationLinkId().toString()); } else - Assert.fail("Service has a wrong demand."); + Assertions.fail("Service has a wrong demand."); } - Assert.assertEquals(12, countDemand); - Assert.assertEquals(4, countServicesWithCertainDemand.getInt(0)); - Assert.assertEquals(8, countServicesWithCertainDemand.getInt(1)); - Assert.assertEquals(2, countServicesWithCertainDemand.getInt(2)); - Assert.assertEquals(4, locationsPerServiceElement.get("serviceElement1").size()); + Assertions.assertEquals(12, countDemand); + Assertions.assertEquals(4, countServicesWithCertainDemand.getInt(0)); + Assertions.assertEquals(8, countServicesWithCertainDemand.getInt(1)); + Assertions.assertEquals(2, countServicesWithCertainDemand.getInt(2)); + Assertions.assertEquals(4, locationsPerServiceElement.get("serviceElement1").size()); for (String locationsOfServiceElement : locationsPerServiceElement.get("serviceElement1")) { Link link = network.getLinks().get(Id.createLinkId(locationsOfServiceElement)); - Assert.assertTrue( + Assertions.assertTrue( FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, null, null)); - Assert.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, + Assertions.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[] { "area1" }, null)); - Assert.assertTrue(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, + Assertions.assertTrue(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[] { "area2" }, null)); } - Assert.assertEquals(4, locationsPerServiceElement.get("serviceElement2").size()); - Assert.assertTrue(locationsPerServiceElement.get("serviceElement2").contains("i(2,0)")); + Assertions.assertEquals(4, locationsPerServiceElement.get("serviceElement2").size()); + Assertions.assertTrue(locationsPerServiceElement.get("serviceElement2").contains("i(2,0)")); // check carrier 2 Carrier testCarrier2 = CarriersUtils.getCarriers(scenario).getCarriers() .get(Id.create("testCarrier2", Carrier.class)); - Assert.assertEquals(0, testCarrier2.getServices().size()); - Assert.assertEquals(11, testCarrier2.getShipments().size()); + Assertions.assertEquals(0, testCarrier2.getServices().size()); + Assertions.assertEquals(11, testCarrier2.getShipments().size()); Object2IntMap countShipmentsWithCertainDemand = new Object2IntOpenHashMap<>(); Map> locationsPerShipmentElement = new HashMap<>(); countDemand = 0; @@ -163,77 +163,77 @@ void demandCreation() throws IOException { countShipmentsWithCertainDemand.merge((Integer) shipment.getSize(), 1, Integer::sum); countDemand = countDemand + shipment.getSize(); if (shipment.getSize() == 0) { - Assert.assertEquals(300, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals(350, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals(TimeWindow.newInstance(10000, 45000), shipment.getPickupTimeWindow()); - Assert.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getDeliveryTimeWindow()); + Assertions.assertEquals(300, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(350, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(10000, 45000), shipment.getPickupTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getDeliveryTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmenElement1_pickup", (k) -> new HashSet<>()) .add(shipment.getFrom().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmenElement1_delivery", (k) -> new HashSet<>()) .add(shipment.getTo().toString()); } else if (shipment.getSize() == 2) { - Assert.assertEquals(400, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals(400, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupTimeWindow()); - Assert.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryTimeWindow()); + Assertions.assertEquals(400, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(400, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmenElement2_pickup", (k) -> new HashSet<>()) .add(shipment.getFrom().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmenElement2_delivery", (k) -> new HashSet<>()) .add(shipment.getTo().toString()); } else if (shipment.getSize() == 3) { - Assert.assertEquals(600, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals(600, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupTimeWindow()); - Assert.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryTimeWindow()); + Assertions.assertEquals(600, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(600, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmenElement2_pickup", (k) -> new HashSet<>()) .add(shipment.getFrom().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmenElement2_delivery", (k) -> new HashSet<>()) .add(shipment.getTo().toString()); } else - Assert.fail("Shipment has an unexpected demand."); + Assertions.fail("Shipment has an unexpected demand."); } - Assert.assertEquals(15, countDemand); - Assert.assertEquals(4, countShipmentsWithCertainDemand.getInt(0)); - Assert.assertEquals(6, countShipmentsWithCertainDemand.getInt(2)); - Assert.assertEquals(1, countShipmentsWithCertainDemand.getInt(3)); - Assert.assertEquals(4, locationsPerShipmentElement.get("ShipmenElement1_pickup").size()); - Assert.assertEquals(1, locationsPerShipmentElement.get("ShipmenElement1_delivery").size()); - Assert.assertTrue(locationsPerShipmentElement.get("ShipmenElement1_delivery").contains("i(2,0)")); - Assert.assertEquals(1, locationsPerShipmentElement.get("ShipmenElement2_pickup").size()); - Assert.assertEquals(2, locationsPerShipmentElement.get("ShipmenElement2_delivery").size()); + Assertions.assertEquals(15, countDemand); + Assertions.assertEquals(4, countShipmentsWithCertainDemand.getInt(0)); + Assertions.assertEquals(6, countShipmentsWithCertainDemand.getInt(2)); + Assertions.assertEquals(1, countShipmentsWithCertainDemand.getInt(3)); + Assertions.assertEquals(4, locationsPerShipmentElement.get("ShipmenElement1_pickup").size()); + Assertions.assertEquals(1, locationsPerShipmentElement.get("ShipmenElement1_delivery").size()); + Assertions.assertTrue(locationsPerShipmentElement.get("ShipmenElement1_delivery").contains("i(2,0)")); + Assertions.assertEquals(1, locationsPerShipmentElement.get("ShipmenElement2_pickup").size()); + Assertions.assertEquals(2, locationsPerShipmentElement.get("ShipmenElement2_delivery").size()); // check carrier 3 Carrier testCarrier3 = CarriersUtils.getCarriers(scenario).getCarriers() .get(Id.create("testCarrier3", Carrier.class)); - Assert.assertEquals(0, testCarrier3.getServices().size()); - Assert.assertEquals(4, testCarrier3.getShipments().size()); + Assertions.assertEquals(0, testCarrier3.getServices().size()); + Assertions.assertEquals(4, testCarrier3.getShipments().size()); countShipmentsWithCertainDemand = new Object2IntOpenHashMap<>(); locationsPerShipmentElement = new HashMap<>(); countDemand = 0; for (CarrierShipment shipment : testCarrier3.getShipments().values()) { countShipmentsWithCertainDemand.merge((Integer) shipment.getSize(), 1, Integer::sum); countDemand = countDemand + shipment.getSize(); - Assert.assertEquals(5, shipment.getSize()); - Assert.assertEquals(2000, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1250, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupTimeWindow()); - Assert.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryTimeWindow()); + Assertions.assertEquals(5, shipment.getSize()); + Assertions.assertEquals(2000, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1250, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmenElement1_pickup", (k) -> new HashSet<>()) .add(shipment.getFrom().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmenElement1_delivery", (k) -> new HashSet<>()) .add(shipment.getTo().toString()); } - Assert.assertEquals(20, countDemand); - Assert.assertEquals(4, countShipmentsWithCertainDemand.getInt(5)); - Assert.assertEquals(2, locationsPerShipmentElement.get("ShipmenElement1_pickup").size()); - Assert.assertEquals(4, locationsPerShipmentElement.get("ShipmenElement1_delivery").size()); + Assertions.assertEquals(20, countDemand); + Assertions.assertEquals(4, countShipmentsWithCertainDemand.getInt(5)); + Assertions.assertEquals(2, locationsPerShipmentElement.get("ShipmenElement1_pickup").size()); + Assertions.assertEquals(4, locationsPerShipmentElement.get("ShipmenElement1_delivery").size()); for (String locationsOfShipmentElement : locationsPerShipmentElement.get("ShipmenElement1_delivery")) { Link link = network.getLinks().get(Id.createLinkId(locationsOfShipmentElement)); - Assert.assertTrue( + Assertions.assertTrue( FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, null, null)); - Assert.assertTrue(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, + Assertions.assertTrue(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[] { "area1" }, null)); - Assert.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, + Assertions.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[] { "area2" }, null)); } } @@ -243,101 +243,101 @@ void csvDemandReader() throws IOException { Path demandCSVLocation = Path.of(utils.getPackageInputDirectory() + "testDemandCSV.csv"); Set demandInformation = DemandReaderFromCSV.readDemandInformation(demandCSVLocation); - Assert.assertEquals(5, demandInformation.size()); + Assertions.assertEquals(5, demandInformation.size()); for (DemandInformationElement demandInformationElement : demandInformation) { if (demandInformationElement.getCarrierName().equals("testCarrier1") && demandInformationElement.getNumberOfJobs() == 4) { - Assert.assertEquals(0, (int) demandInformationElement.getDemandToDistribute()); - Assert.assertNull(demandInformationElement.getShareOfPopulationWithFirstJobElement()); - Assert.assertEquals(1, demandInformationElement.getAreasFirstJobElement().length); - Assert.assertEquals("area2", demandInformationElement.getAreasFirstJobElement()[0]); - Assert.assertNull(demandInformationElement.getNumberOfFirstJobElementLocations()); - Assert.assertNull(demandInformationElement.getLocationsOfFirstJobElement()); - Assert.assertEquals(180, (int) demandInformationElement.getFirstJobElementTimePerUnit()); - Assert.assertEquals(TimeWindow.newInstance(3000, 13000), + Assertions.assertEquals(0, (int) demandInformationElement.getDemandToDistribute()); + Assertions.assertNull(demandInformationElement.getShareOfPopulationWithFirstJobElement()); + Assertions.assertEquals(1, demandInformationElement.getAreasFirstJobElement().length); + Assertions.assertEquals("area2", demandInformationElement.getAreasFirstJobElement()[0]); + Assertions.assertNull(demandInformationElement.getNumberOfFirstJobElementLocations()); + Assertions.assertNull(demandInformationElement.getLocationsOfFirstJobElement()); + Assertions.assertEquals(180, (int) demandInformationElement.getFirstJobElementTimePerUnit()); + Assertions.assertEquals(TimeWindow.newInstance(3000, 13000), demandInformationElement.getFirstJobElementTimeWindow()); - Assert.assertNull(demandInformationElement.getShareOfPopulationWithSecondJobElement()); - Assert.assertNull(demandInformationElement.getNumberOfSecondJobElementLocations()); - Assert.assertNull(demandInformationElement.getLocationsOfSecondJobElement()); - Assert.assertNull(demandInformationElement.getSecondJobElementTimePerUnit()); - Assert.assertNull(demandInformationElement.getSecondJobElementTimeWindow()); + Assertions.assertNull(demandInformationElement.getShareOfPopulationWithSecondJobElement()); + Assertions.assertNull(demandInformationElement.getNumberOfSecondJobElementLocations()); + Assertions.assertNull(demandInformationElement.getLocationsOfSecondJobElement()); + Assertions.assertNull(demandInformationElement.getSecondJobElementTimePerUnit()); + Assertions.assertNull(demandInformationElement.getSecondJobElementTimeWindow()); } else if (demandInformationElement.getCarrierName().equals("testCarrier1") && demandInformationElement.getNumberOfJobs() == 10) { - Assert.assertEquals(12, (int) demandInformationElement.getDemandToDistribute()); - Assert.assertNull(demandInformationElement.getShareOfPopulationWithFirstJobElement()); - Assert.assertNull(demandInformationElement.getAreasFirstJobElement()); - Assert.assertEquals(4, (int) demandInformationElement.getNumberOfFirstJobElementLocations()); - Assert.assertEquals(1, demandInformationElement.getLocationsOfFirstJobElement().length); - Assert.assertEquals("i(2,0)", demandInformationElement.getLocationsOfFirstJobElement()[0]); - Assert.assertEquals(100, (int) demandInformationElement.getFirstJobElementTimePerUnit()); - Assert.assertEquals(TimeWindow.newInstance(5000, 20000), + Assertions.assertEquals(12, (int) demandInformationElement.getDemandToDistribute()); + Assertions.assertNull(demandInformationElement.getShareOfPopulationWithFirstJobElement()); + Assertions.assertNull(demandInformationElement.getAreasFirstJobElement()); + Assertions.assertEquals(4, (int) demandInformationElement.getNumberOfFirstJobElementLocations()); + Assertions.assertEquals(1, demandInformationElement.getLocationsOfFirstJobElement().length); + Assertions.assertEquals("i(2,0)", demandInformationElement.getLocationsOfFirstJobElement()[0]); + Assertions.assertEquals(100, (int) demandInformationElement.getFirstJobElementTimePerUnit()); + Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), demandInformationElement.getFirstJobElementTimeWindow()); - Assert.assertNull(demandInformationElement.getShareOfPopulationWithSecondJobElement()); - Assert.assertNull(demandInformationElement.getAreasSecondJobElement()); - Assert.assertNull(demandInformationElement.getNumberOfSecondJobElementLocations()); - Assert.assertNull(demandInformationElement.getLocationsOfSecondJobElement()); - Assert.assertNull(demandInformationElement.getSecondJobElementTimePerUnit()); - Assert.assertNull(demandInformationElement.getSecondJobElementTimeWindow()); + Assertions.assertNull(demandInformationElement.getShareOfPopulationWithSecondJobElement()); + Assertions.assertNull(demandInformationElement.getAreasSecondJobElement()); + Assertions.assertNull(demandInformationElement.getNumberOfSecondJobElementLocations()); + Assertions.assertNull(demandInformationElement.getLocationsOfSecondJobElement()); + Assertions.assertNull(demandInformationElement.getSecondJobElementTimePerUnit()); + Assertions.assertNull(demandInformationElement.getSecondJobElementTimeWindow()); } else if (demandInformationElement.getCarrierName().equals("testCarrier2") && demandInformationElement.getDemandToDistribute() == 0) { - Assert.assertEquals(0, (int) demandInformationElement.getDemandToDistribute()); - Assert.assertEquals(4, (int) demandInformationElement.getNumberOfJobs()); - Assert.assertNull(demandInformationElement.getShareOfPopulationWithFirstJobElement()); - Assert.assertNull(demandInformationElement.getAreasFirstJobElement()); - Assert.assertNull(demandInformationElement.getNumberOfFirstJobElementLocations()); - Assert.assertNull(demandInformationElement.getLocationsOfFirstJobElement()); - Assert.assertEquals(300, (int) demandInformationElement.getFirstJobElementTimePerUnit()); - Assert.assertEquals(TimeWindow.newInstance(10000, 45000), + Assertions.assertEquals(0, (int) demandInformationElement.getDemandToDistribute()); + Assertions.assertEquals(4, (int) demandInformationElement.getNumberOfJobs()); + Assertions.assertNull(demandInformationElement.getShareOfPopulationWithFirstJobElement()); + Assertions.assertNull(demandInformationElement.getAreasFirstJobElement()); + Assertions.assertNull(demandInformationElement.getNumberOfFirstJobElementLocations()); + Assertions.assertNull(demandInformationElement.getLocationsOfFirstJobElement()); + Assertions.assertEquals(300, (int) demandInformationElement.getFirstJobElementTimePerUnit()); + Assertions.assertEquals(TimeWindow.newInstance(10000, 45000), demandInformationElement.getFirstJobElementTimeWindow()); - Assert.assertNull(demandInformationElement.getShareOfPopulationWithSecondJobElement()); - Assert.assertNull(demandInformationElement.getAreasSecondJobElement()); - Assert.assertEquals(1, (int) demandInformationElement.getNumberOfSecondJobElementLocations()); - Assert.assertEquals(1, demandInformationElement.getLocationsOfSecondJobElement().length); - Assert.assertTrue(demandInformationElement.getLocationsOfSecondJobElement()[0].equals("i(2,0)")); - Assert.assertEquals(350, (int) demandInformationElement.getSecondJobElementTimePerUnit()); - Assert.assertEquals(TimeWindow.newInstance(11000, 44000), + Assertions.assertNull(demandInformationElement.getShareOfPopulationWithSecondJobElement()); + Assertions.assertNull(demandInformationElement.getAreasSecondJobElement()); + Assertions.assertEquals(1, (int) demandInformationElement.getNumberOfSecondJobElementLocations()); + Assertions.assertEquals(1, demandInformationElement.getLocationsOfSecondJobElement().length); + Assertions.assertTrue(demandInformationElement.getLocationsOfSecondJobElement()[0].equals("i(2,0)")); + Assertions.assertEquals(350, (int) demandInformationElement.getSecondJobElementTimePerUnit()); + Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), demandInformationElement.getSecondJobElementTimeWindow()); } else if (demandInformationElement.getCarrierName().equals("testCarrier2") && demandInformationElement.getDemandToDistribute() == 15) { - Assert.assertEquals(15, (int) demandInformationElement.getDemandToDistribute()); - Assert.assertEquals(7, (int) demandInformationElement.getNumberOfJobs()); - Assert.assertNull(demandInformationElement.getShareOfPopulationWithFirstJobElement()); - Assert.assertNull(demandInformationElement.getAreasFirstJobElement()); - Assert.assertEquals(1, (int) demandInformationElement.getNumberOfFirstJobElementLocations()); - Assert.assertNull(demandInformationElement.getLocationsOfFirstJobElement()); - Assert.assertEquals(200, (int) demandInformationElement.getFirstJobElementTimePerUnit()); - Assert.assertEquals(TimeWindow.newInstance(11000, 44000), + Assertions.assertEquals(15, (int) demandInformationElement.getDemandToDistribute()); + Assertions.assertEquals(7, (int) demandInformationElement.getNumberOfJobs()); + Assertions.assertNull(demandInformationElement.getShareOfPopulationWithFirstJobElement()); + Assertions.assertNull(demandInformationElement.getAreasFirstJobElement()); + Assertions.assertEquals(1, (int) demandInformationElement.getNumberOfFirstJobElementLocations()); + Assertions.assertNull(demandInformationElement.getLocationsOfFirstJobElement()); + Assertions.assertEquals(200, (int) demandInformationElement.getFirstJobElementTimePerUnit()); + Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), demandInformationElement.getFirstJobElementTimeWindow()); - Assert.assertNull(demandInformationElement.getShareOfPopulationWithSecondJobElement()); - Assert.assertNull(demandInformationElement.getAreasSecondJobElement()); - Assert.assertEquals(2, (int) demandInformationElement.getNumberOfSecondJobElementLocations()); - Assert.assertNull(demandInformationElement.getLocationsOfSecondJobElement()); - Assert.assertEquals(200, (int) demandInformationElement.getSecondJobElementTimePerUnit()); - Assert.assertEquals(TimeWindow.newInstance(20000, 40000), + Assertions.assertNull(demandInformationElement.getShareOfPopulationWithSecondJobElement()); + Assertions.assertNull(demandInformationElement.getAreasSecondJobElement()); + Assertions.assertEquals(2, (int) demandInformationElement.getNumberOfSecondJobElementLocations()); + Assertions.assertNull(demandInformationElement.getLocationsOfSecondJobElement()); + Assertions.assertEquals(200, (int) demandInformationElement.getSecondJobElementTimePerUnit()); + Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), demandInformationElement.getSecondJobElementTimeWindow()); } else if (demandInformationElement.getCarrierName().equals("testCarrier3")) { - Assert.assertEquals(20, (int) demandInformationElement.getDemandToDistribute()); - Assert.assertNull(demandInformationElement.getNumberOfJobs()); - Assert.assertEquals(0.125, (double) demandInformationElement.getShareOfPopulationWithFirstJobElement(), + Assertions.assertEquals(20, (int) demandInformationElement.getDemandToDistribute()); + Assertions.assertNull(demandInformationElement.getNumberOfJobs()); + Assertions.assertEquals(0.125, (double) demandInformationElement.getShareOfPopulationWithFirstJobElement(), MatsimTestUtils.EPSILON); - Assert.assertNull(demandInformationElement.getAreasFirstJobElement()); - Assert.assertNull(demandInformationElement.getNumberOfFirstJobElementLocations()); - Assert.assertNull(demandInformationElement.getLocationsOfFirstJobElement()); - Assert.assertEquals(400, (int) demandInformationElement.getFirstJobElementTimePerUnit()); - Assert.assertEquals(TimeWindow.newInstance(8000, 50000), + Assertions.assertNull(demandInformationElement.getAreasFirstJobElement()); + Assertions.assertNull(demandInformationElement.getNumberOfFirstJobElementLocations()); + Assertions.assertNull(demandInformationElement.getLocationsOfFirstJobElement()); + Assertions.assertEquals(400, (int) demandInformationElement.getFirstJobElementTimePerUnit()); + Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), demandInformationElement.getFirstJobElementTimeWindow()); - Assert.assertEquals(0.4, (double) demandInformationElement.getShareOfPopulationWithSecondJobElement(), + Assertions.assertEquals(0.4, (double) demandInformationElement.getShareOfPopulationWithSecondJobElement(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, demandInformationElement.getAreasSecondJobElement().length); - Assert.assertEquals("area1", demandInformationElement.getAreasSecondJobElement()[0]); - Assert.assertNull(demandInformationElement.getNumberOfSecondJobElementLocations()); - Assert.assertNull(demandInformationElement.getLocationsOfSecondJobElement()); - Assert.assertEquals(250, (int) demandInformationElement.getSecondJobElementTimePerUnit()); - Assert.assertEquals(TimeWindow.newInstance(10000, 60000), + Assertions.assertEquals(1, demandInformationElement.getAreasSecondJobElement().length); + Assertions.assertEquals("area1", demandInformationElement.getAreasSecondJobElement()[0]); + Assertions.assertNull(demandInformationElement.getNumberOfSecondJobElementLocations()); + Assertions.assertNull(demandInformationElement.getLocationsOfSecondJobElement()); + Assertions.assertEquals(250, (int) demandInformationElement.getSecondJobElementTimePerUnit()); + Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), demandInformationElement.getSecondJobElementTimeWindow()); } else - Assert.fail("No expected demandInformationElement found"); + Assertions.fail("No expected demandInformationElement found"); } } } diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationTest.java index f1285ff809a..a79ca63b52d 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationTest.java @@ -1,7 +1,7 @@ package org.matsim.freightDemandGeneration; import org.apache.logging.log4j.LogManager; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -57,7 +57,7 @@ void testMain() { LogManager.getLogger(this.getClass()).fatal("there was an exception: \n" + ee); ee.printStackTrace(); // if one catches an exception, then one needs to explicitly fail the test: - Assert.fail(); + Assertions.fail(); } } } diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtilsTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtilsTest.java index cedeccd9dfb..e1528caf871 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtilsTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtilsTest.java @@ -3,7 +3,7 @@ import java.nio.file.Path; import java.util.Collection; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.locationtech.jts.geom.Point; @@ -34,50 +34,50 @@ void testPreparePopulation() { String populationLocation = utils.getPackageInputDirectory() + "testPopulation.xml"; Population population = PopulationUtils.readPopulation(populationLocation); FreightDemandGenerationUtils.preparePopulation(population, 1.0, 1.0, "changeNumberOfLocationsWithDemand"); - Assert.assertEquals(8, population.getPersons().size()); - Assert.assertEquals(1.0,population.getAttributes().getAttribute("sampleSize")); - Assert.assertEquals(1.0,population.getAttributes().getAttribute("samplingTo")); - Assert.assertEquals("changeNumberOfLocationsWithDemand",population.getAttributes().getAttribute("samplingOption")); + Assertions.assertEquals(8, population.getPersons().size()); + Assertions.assertEquals(1.0,population.getAttributes().getAttribute("sampleSize")); + Assertions.assertEquals(1.0,population.getAttributes().getAttribute("samplingTo")); + Assertions.assertEquals("changeNumberOfLocationsWithDemand",population.getAttributes().getAttribute("samplingOption")); Person person = population.getPersons().get(Id.createPersonId("person1")); - Assert.assertEquals(1200.0,person.getAttributes().getAttribute("homeX")); - Assert.assertEquals(7700.0,person.getAttributes().getAttribute("homeY")); - Assert.assertEquals(0, person.getPlans().size()); - Assert.assertNull(person.getSelectedPlan()); + Assertions.assertEquals(1200.0,person.getAttributes().getAttribute("homeX")); + Assertions.assertEquals(7700.0,person.getAttributes().getAttribute("homeY")); + Assertions.assertEquals(0, person.getPlans().size()); + Assertions.assertNull(person.getSelectedPlan()); person = population.getPersons().get(Id.createPersonId("person2")); - Assert.assertEquals(2900.0,person.getAttributes().getAttribute("homeX")); - Assert.assertEquals(2800.0,person.getAttributes().getAttribute("homeY")); - Assert.assertEquals(0, person.getPlans().size()); - Assert.assertNull(person.getSelectedPlan()); + Assertions.assertEquals(2900.0,person.getAttributes().getAttribute("homeX")); + Assertions.assertEquals(2800.0,person.getAttributes().getAttribute("homeY")); + Assertions.assertEquals(0, person.getPlans().size()); + Assertions.assertNull(person.getSelectedPlan()); person = population.getPersons().get(Id.createPersonId("person3")); - Assert.assertEquals(4200.0,person.getAttributes().getAttribute("homeX")); - Assert.assertEquals(4400.0,person.getAttributes().getAttribute("homeY")); - Assert.assertEquals(0, person.getPlans().size()); - Assert.assertNull(person.getSelectedPlan()); + Assertions.assertEquals(4200.0,person.getAttributes().getAttribute("homeX")); + Assertions.assertEquals(4400.0,person.getAttributes().getAttribute("homeY")); + Assertions.assertEquals(0, person.getPlans().size()); + Assertions.assertNull(person.getSelectedPlan()); person = population.getPersons().get(Id.createPersonId("person4")); - Assert.assertEquals(5200.0,person.getAttributes().getAttribute("homeX")); - Assert.assertEquals(2600.0,person.getAttributes().getAttribute("homeY")); - Assert.assertEquals(0, person.getPlans().size()); - Assert.assertNull(person.getSelectedPlan()); + Assertions.assertEquals(5200.0,person.getAttributes().getAttribute("homeX")); + Assertions.assertEquals(2600.0,person.getAttributes().getAttribute("homeY")); + Assertions.assertEquals(0, person.getPlans().size()); + Assertions.assertNull(person.getSelectedPlan()); person = population.getPersons().get(Id.createPersonId("person5")); - Assert.assertEquals(5200.0,person.getAttributes().getAttribute("homeX")); - Assert.assertEquals(5500.0,person.getAttributes().getAttribute("homeY")); - Assert.assertEquals(0, person.getPlans().size()); - Assert.assertNull(person.getSelectedPlan()); + Assertions.assertEquals(5200.0,person.getAttributes().getAttribute("homeX")); + Assertions.assertEquals(5500.0,person.getAttributes().getAttribute("homeY")); + Assertions.assertEquals(0, person.getPlans().size()); + Assertions.assertNull(person.getSelectedPlan()); person = population.getPersons().get(Id.createPersonId("person6")); - Assert.assertEquals(7900.0,person.getAttributes().getAttribute("homeX")); - Assert.assertEquals(7500.0,person.getAttributes().getAttribute("homeY")); - Assert.assertEquals(0, person.getPlans().size()); - Assert.assertNull(person.getSelectedPlan()); + Assertions.assertEquals(7900.0,person.getAttributes().getAttribute("homeX")); + Assertions.assertEquals(7500.0,person.getAttributes().getAttribute("homeY")); + Assertions.assertEquals(0, person.getPlans().size()); + Assertions.assertNull(person.getSelectedPlan()); person = population.getPersons().get(Id.createPersonId("person7")); - Assert.assertEquals(4900.0,person.getAttributes().getAttribute("homeX")); - Assert.assertEquals(8900.0,person.getAttributes().getAttribute("homeY")); - Assert.assertEquals(0, person.getPlans().size()); - Assert.assertNull(person.getSelectedPlan()); + Assertions.assertEquals(4900.0,person.getAttributes().getAttribute("homeX")); + Assertions.assertEquals(8900.0,person.getAttributes().getAttribute("homeY")); + Assertions.assertEquals(0, person.getPlans().size()); + Assertions.assertNull(person.getSelectedPlan()); person = population.getPersons().get(Id.createPersonId("person8")); - Assert.assertEquals(8400.0,person.getAttributes().getAttribute("homeX")); - Assert.assertEquals(5200.0,person.getAttributes().getAttribute("homeY")); - Assert.assertEquals(0, person.getPlans().size()); - Assert.assertNull(person.getSelectedPlan()); + Assertions.assertEquals(8400.0,person.getAttributes().getAttribute("homeX")); + Assertions.assertEquals(5200.0,person.getAttributes().getAttribute("homeY")); + Assertions.assertEquals(0, person.getPlans().size()); + Assertions.assertNull(person.getSelectedPlan()); } @Test @@ -85,12 +85,12 @@ void testCoordOfMiddlePointOfLink() { Network network = NetworkUtils.readNetwork("https://raw.githubusercontent.com/matsim-org/matsim-libs/master/examples/scenarios/freight-chessboard-9x9/grid9x9.xml"); Link link = network.getLinks().get(Id.createLinkId("i(8,8)")); Coord middlePoint = FreightDemandGenerationUtils.getCoordOfMiddlePointOfLink(link); - Assert.assertEquals(7500, middlePoint.getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals(8000, middlePoint.getY(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(7500, middlePoint.getX(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(8000, middlePoint.getY(), MatsimTestUtils.EPSILON); Link link2 = network.getLinks().get(Id.createLinkId("j(5,8)")); Coord middlePoint2 = FreightDemandGenerationUtils.getCoordOfMiddlePointOfLink(link2); - Assert.assertEquals(5000, middlePoint2.getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals(7500, middlePoint2.getY(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(5000, middlePoint2.getX(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(7500, middlePoint2.getY(), MatsimTestUtils.EPSILON); } @Test @@ -102,9 +102,9 @@ void testReducePopulationToShapeArea() { ShpOptions shp = new ShpOptions(shapeFilePath,"WGS84", null); ShpOptions.Index index = shp.createIndex("WGS84", "_"); FreightDemandGenerationUtils.reducePopulationToShapeArea(population, index); - Assert.assertEquals(6, population.getPersons().size()); - Assert.assertFalse(population.getPersons().containsKey(Id.createPersonId("person2"))); - Assert.assertFalse(population.getPersons().containsKey(Id.createPersonId("person4"))); + Assertions.assertEquals(6, population.getPersons().size()); + Assertions.assertFalse(population.getPersons().containsKey(Id.createPersonId("person2"))); + Assertions.assertFalse(population.getPersons().containsKey(Id.createPersonId("person4"))); } @Test @@ -114,13 +114,13 @@ void testCheckPositionInShape_link() { Path shapeFilePath = Path.of(utils.getPackageInputDirectory() + "testShape/testShape.shp"); ShpOptions shp = new ShpOptions(shapeFilePath,"WGS84", null); Collection polygonsInShape = shp.readFeatures(); - Assert.assertTrue(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, null, null)); - Assert.assertTrue(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[]{"area1"}, null)); - Assert.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[]{"area2"}, null)); + Assertions.assertTrue(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, null, null)); + Assertions.assertTrue(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[]{"area1"}, null)); + Assertions.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[]{"area2"}, null)); link = network.getLinks().get(Id.createLinkId("i(6,3)R")); - Assert.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, null, null)); - Assert.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[]{"area1"}, null)); - Assert.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[]{"area2"}, null)); + Assertions.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, null, null)); + Assertions.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[]{"area1"}, null)); + Assertions.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape, new String[]{"area2"}, null)); } @@ -130,13 +130,13 @@ void testCheckPositionInShape_point() { ShpOptions shp = new ShpOptions(shapeFilePath,"WGS84", null); Collection polygonsInShape = shp.readFeatures(); Point point = MGC.xy2Point(6000, 6000); - Assert.assertTrue(FreightDemandGenerationUtils.checkPositionInShape(null, point, polygonsInShape, null, null)); - Assert.assertTrue(FreightDemandGenerationUtils.checkPositionInShape(null, point, polygonsInShape, new String[]{"area1"}, null)); - Assert.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(null, point, polygonsInShape, new String[]{"area2"}, null)); + Assertions.assertTrue(FreightDemandGenerationUtils.checkPositionInShape(null, point, polygonsInShape, null, null)); + Assertions.assertTrue(FreightDemandGenerationUtils.checkPositionInShape(null, point, polygonsInShape, new String[]{"area1"}, null)); + Assertions.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(null, point, polygonsInShape, new String[]{"area2"}, null)); point = MGC.xy2Point(2000, 2000); - Assert.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(null, point, polygonsInShape, null, null)); - Assert.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(null, point, polygonsInShape, new String[]{"area1"}, null)); - Assert.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(null, point, polygonsInShape, new String[]{"area2"}, null)); + Assertions.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(null, point, polygonsInShape, null, null)); + Assertions.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(null, point, polygonsInShape, new String[]{"area1"}, null)); + Assertions.assertFalse(FreightDemandGenerationUtils.checkPositionInShape(null, point, polygonsInShape, new String[]{"area2"}, null)); } } diff --git a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/LanduseBuildingAnalysisTest.java b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/LanduseBuildingAnalysisTest.java index 4255b694d0e..9957d7ef446 100644 --- a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/LanduseBuildingAnalysisTest.java +++ b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/LanduseBuildingAnalysisTest.java @@ -20,7 +20,7 @@ package org.matsim.smallScaleCommercialTrafficGeneration; import it.unimi.dsi.fastutil.objects.Object2DoubleMap; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.application.options.ShpOptions; @@ -65,24 +65,24 @@ void testReadOfDataDistributionPerZoneAndBuildingAnalysis() throws IOException { inputDataDirectory, usedLanduseConfiguration, shapeFileLandusePath, shapeFileZonePath, shapeFileBuildingsPath, null, buildingsPerZone); - Assert.assertEquals(3, resultingDataPerZone.size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, resultingDataPerZone.size(), MatsimTestUtils.EPSILON); - Assert.assertTrue(resultingDataPerZone.containsKey("testArea1_area1")); - Assert.assertTrue(resultingDataPerZone.containsKey("testArea1_area2")); - Assert.assertTrue(resultingDataPerZone.containsKey("testArea2_area3")); + Assertions.assertTrue(resultingDataPerZone.containsKey("testArea1_area1")); + Assertions.assertTrue(resultingDataPerZone.containsKey("testArea1_area2")); + Assertions.assertTrue(resultingDataPerZone.containsKey("testArea2_area3")); for (String zone : resultingDataPerZone.keySet()) { Object2DoubleMap categories = resultingDataPerZone.get(zone); int employeeSum = 0; - Assert.assertEquals(8, categories.size(), MatsimTestUtils.EPSILON); - Assert.assertTrue(categories.containsKey("Inhabitants")); - Assert.assertTrue(categories.containsKey("Employee")); - Assert.assertTrue(categories.containsKey("Employee Primary Sector")); - Assert.assertTrue(categories.containsKey("Employee Construction")); - Assert.assertTrue(categories.containsKey("Employee Secondary Sector Rest")); - Assert.assertTrue(categories.containsKey("Employee Retail")); - Assert.assertTrue(categories.containsKey("Employee Traffic/Parcels")); - Assert.assertTrue(categories.containsKey("Employee Tertiary Sector Rest")); + Assertions.assertEquals(8, categories.size(), MatsimTestUtils.EPSILON); + Assertions.assertTrue(categories.containsKey("Inhabitants")); + Assertions.assertTrue(categories.containsKey("Employee")); + Assertions.assertTrue(categories.containsKey("Employee Primary Sector")); + Assertions.assertTrue(categories.containsKey("Employee Construction")); + Assertions.assertTrue(categories.containsKey("Employee Secondary Sector Rest")); + Assertions.assertTrue(categories.containsKey("Employee Retail")); + Assertions.assertTrue(categories.containsKey("Employee Traffic/Parcels")); + Assertions.assertTrue(categories.containsKey("Employee Tertiary Sector Rest")); employeeSum += (int) categories.getDouble("Employee Primary Sector"); employeeSum += (int) categories.getDouble("Employee Construction"); @@ -91,60 +91,60 @@ void testReadOfDataDistributionPerZoneAndBuildingAnalysis() throws IOException { employeeSum += (int) categories.getDouble("Employee Traffic/Parcels"); employeeSum += (int) categories.getDouble("Employee Tertiary Sector Rest"); - Assert.assertEquals(categories.getDouble("Employee"), employeeSum, MatsimTestUtils.EPSILON); + Assertions.assertEquals(categories.getDouble("Employee"), employeeSum, MatsimTestUtils.EPSILON); if (zone.equals("testArea1_area1")) { - Assert.assertEquals(4000, resultingDataPerZone.get(zone).getDouble("Inhabitants"), + Assertions.assertEquals(4000, resultingDataPerZone.get(zone).getDouble("Inhabitants"), MatsimTestUtils.EPSILON); - Assert.assertEquals(3500, resultingDataPerZone.get(zone).getDouble("Employee"), + Assertions.assertEquals(3500, resultingDataPerZone.get(zone).getDouble("Employee"), MatsimTestUtils.EPSILON); - Assert.assertEquals(0, resultingDataPerZone.get(zone).getDouble("Employee Primary Sector"), + Assertions.assertEquals(0, resultingDataPerZone.get(zone).getDouble("Employee Primary Sector"), MatsimTestUtils.EPSILON); - Assert.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Construction"), + Assertions.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Construction"), MatsimTestUtils.EPSILON); - Assert.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Secondary Sector Rest"), + Assertions.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Secondary Sector Rest"), MatsimTestUtils.EPSILON); - Assert.assertEquals(1000, resultingDataPerZone.get(zone).getDouble("Employee Retail"), + Assertions.assertEquals(1000, resultingDataPerZone.get(zone).getDouble("Employee Retail"), MatsimTestUtils.EPSILON); - Assert.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Traffic/Parcels"), + Assertions.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Traffic/Parcels"), MatsimTestUtils.EPSILON); - Assert.assertEquals(1000, resultingDataPerZone.get(zone).getDouble("Employee Tertiary Sector Rest"), + Assertions.assertEquals(1000, resultingDataPerZone.get(zone).getDouble("Employee Tertiary Sector Rest"), MatsimTestUtils.EPSILON); } if (zone.equals("testArea1_area2")) { - Assert.assertEquals(4000, resultingDataPerZone.get(zone).getDouble("Inhabitants"), + Assertions.assertEquals(4000, resultingDataPerZone.get(zone).getDouble("Inhabitants"), MatsimTestUtils.EPSILON); - Assert.assertEquals(6500, resultingDataPerZone.get(zone).getDouble("Employee"), + Assertions.assertEquals(6500, resultingDataPerZone.get(zone).getDouble("Employee"), MatsimTestUtils.EPSILON); - Assert.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Primary Sector"), + Assertions.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Primary Sector"), MatsimTestUtils.EPSILON); - Assert.assertEquals(1500, resultingDataPerZone.get(zone).getDouble("Employee Construction"), + Assertions.assertEquals(1500, resultingDataPerZone.get(zone).getDouble("Employee Construction"), MatsimTestUtils.EPSILON); - Assert.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Secondary Sector Rest"), + Assertions.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Secondary Sector Rest"), MatsimTestUtils.EPSILON); - Assert.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Retail"), + Assertions.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Retail"), MatsimTestUtils.EPSILON); - Assert.assertEquals(1500, resultingDataPerZone.get(zone).getDouble("Employee Traffic/Parcels"), + Assertions.assertEquals(1500, resultingDataPerZone.get(zone).getDouble("Employee Traffic/Parcels"), MatsimTestUtils.EPSILON); - Assert.assertEquals(2000, resultingDataPerZone.get(zone).getDouble("Employee Tertiary Sector Rest"), + Assertions.assertEquals(2000, resultingDataPerZone.get(zone).getDouble("Employee Tertiary Sector Rest"), MatsimTestUtils.EPSILON); } if (zone.equals("testArea2_area3")) { - Assert.assertEquals(800, resultingDataPerZone.get(zone).getDouble("Inhabitants"), + Assertions.assertEquals(800, resultingDataPerZone.get(zone).getDouble("Inhabitants"), MatsimTestUtils.EPSILON); - Assert.assertEquals(1000, resultingDataPerZone.get(zone).getDouble("Employee"), + Assertions.assertEquals(1000, resultingDataPerZone.get(zone).getDouble("Employee"), MatsimTestUtils.EPSILON); - Assert.assertEquals(50, resultingDataPerZone.get(zone).getDouble("Employee Primary Sector"), + Assertions.assertEquals(50, resultingDataPerZone.get(zone).getDouble("Employee Primary Sector"), MatsimTestUtils.EPSILON); - Assert.assertEquals(200, resultingDataPerZone.get(zone).getDouble("Employee Construction"), + Assertions.assertEquals(200, resultingDataPerZone.get(zone).getDouble("Employee Construction"), MatsimTestUtils.EPSILON); - Assert.assertEquals(100, resultingDataPerZone.get(zone).getDouble("Employee Secondary Sector Rest"), + Assertions.assertEquals(100, resultingDataPerZone.get(zone).getDouble("Employee Secondary Sector Rest"), MatsimTestUtils.EPSILON); - Assert.assertEquals(150, resultingDataPerZone.get(zone).getDouble("Employee Retail"), + Assertions.assertEquals(150, resultingDataPerZone.get(zone).getDouble("Employee Retail"), MatsimTestUtils.EPSILON); - Assert.assertEquals(200, resultingDataPerZone.get(zone).getDouble("Employee Traffic/Parcels"), + Assertions.assertEquals(200, resultingDataPerZone.get(zone).getDouble("Employee Traffic/Parcels"), MatsimTestUtils.EPSILON); - Assert.assertEquals(300, resultingDataPerZone.get(zone).getDouble("Employee Tertiary Sector Rest"), + Assertions.assertEquals(300, resultingDataPerZone.get(zone).getDouble("Employee Tertiary Sector Rest"), MatsimTestUtils.EPSILON); } } @@ -153,89 +153,89 @@ void testReadOfDataDistributionPerZoneAndBuildingAnalysis() throws IOException { Index indexZones = SmallScaleCommercialTrafficUtils.getIndexZones(shapeFileZonePath, shapeCRS); ShpOptions shpBuildings = new ShpOptions(shapeFileBuildingsPath, null, StandardCharsets.UTF_8); List buildingsFeatures = shpBuildings.readFeatures(); - Assert.assertEquals(31, buildingsFeatures.size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(31, buildingsFeatures.size(), MatsimTestUtils.EPSILON); LanduseBuildingAnalysis.analyzeBuildingType(buildingsFeatures, buildingsPerZone, landuseCategoriesAndDataConnection, shapeFileLandusePath, indexZones, shapeCRS); - Assert.assertEquals(3, buildingsPerZone.size(), MatsimTestUtils.EPSILON); - Assert.assertTrue(buildingsPerZone.containsKey("testArea1_area1")); - Assert.assertTrue(buildingsPerZone.containsKey("testArea1_area2")); - Assert.assertTrue(buildingsPerZone.containsKey("testArea2_area3")); + Assertions.assertEquals(3, buildingsPerZone.size(), MatsimTestUtils.EPSILON); + Assertions.assertTrue(buildingsPerZone.containsKey("testArea1_area1")); + Assertions.assertTrue(buildingsPerZone.containsKey("testArea1_area2")); + Assertions.assertTrue(buildingsPerZone.containsKey("testArea2_area3")); // test for area1 HashMap> builingsPerArea1 = buildingsPerZone.get("testArea1_area1"); - Assert.assertEquals(7, builingsPerArea1.size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(7, builingsPerArea1.size(), MatsimTestUtils.EPSILON); ArrayList inhabitantsBuildings = builingsPerArea1.get("Inhabitants"); - Assert.assertEquals(4, inhabitantsBuildings.size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(4, inhabitantsBuildings.size(), MatsimTestUtils.EPSILON); for (SimpleFeature singleBuilding : inhabitantsBuildings) { int id = (int) (long) singleBuilding.getAttribute("osm_id"); if (id == 11) { - Assert.assertEquals("2", String.valueOf(singleBuilding.getAttribute("levels"))); - Assert.assertEquals("apartments", String.valueOf(singleBuilding.getAttribute("type"))); + Assertions.assertEquals("2", String.valueOf(singleBuilding.getAttribute("levels"))); + Assertions.assertEquals("apartments", String.valueOf(singleBuilding.getAttribute("type"))); } else if (id == 12) { - Assert.assertEquals("1", String.valueOf(singleBuilding.getAttribute("levels"))); - Assert.assertEquals("house", String.valueOf(singleBuilding.getAttribute("type"))); + Assertions.assertEquals("1", String.valueOf(singleBuilding.getAttribute("levels"))); + Assertions.assertEquals("house", String.valueOf(singleBuilding.getAttribute("type"))); } else if (id == 13) { - Assert.assertEquals("2", String.valueOf(singleBuilding.getAttribute("levels"))); - Assert.assertEquals("residential", String.valueOf(singleBuilding.getAttribute("type"))); + Assertions.assertEquals("2", String.valueOf(singleBuilding.getAttribute("levels"))); + Assertions.assertEquals("residential", String.valueOf(singleBuilding.getAttribute("type"))); } else if (id == 19) { - Assert.assertEquals("2", String.valueOf(singleBuilding.getAttribute("levels"))); - Assert.assertEquals("detached", String.valueOf(singleBuilding.getAttribute("type"))); + Assertions.assertEquals("2", String.valueOf(singleBuilding.getAttribute("levels"))); + Assertions.assertEquals("detached", String.valueOf(singleBuilding.getAttribute("type"))); } else - Assert.fail(); + Assertions.fail(); } - Assert.assertFalse(builingsPerArea1.containsKey("Employee Primary Sector")); - Assert.assertEquals(1, builingsPerArea1.get("Employee Construction").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, builingsPerArea1.get("Employee Secondary Sector Rest").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2, builingsPerArea1.get("Employee Retail").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, builingsPerArea1.get("Employee Traffic/Parcels").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2, builingsPerArea1.get("Employee Tertiary Sector Rest").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(6, builingsPerArea1.get("Employee").size(), MatsimTestUtils.EPSILON); + Assertions.assertFalse(builingsPerArea1.containsKey("Employee Primary Sector")); + Assertions.assertEquals(1, builingsPerArea1.get("Employee Construction").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, builingsPerArea1.get("Employee Secondary Sector Rest").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, builingsPerArea1.get("Employee Retail").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, builingsPerArea1.get("Employee Traffic/Parcels").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, builingsPerArea1.get("Employee Tertiary Sector Rest").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(6, builingsPerArea1.get("Employee").size(), MatsimTestUtils.EPSILON); // test for area2 HashMap> builingsPerArea2 = buildingsPerZone.get("testArea1_area2"); - Assert.assertEquals(8, builingsPerArea2.size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(8, builingsPerArea2.size(), MatsimTestUtils.EPSILON); ArrayList employeeRetail = builingsPerArea2.get("Employee Retail"); - Assert.assertEquals(2, employeeRetail.size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, employeeRetail.size(), MatsimTestUtils.EPSILON); for (SimpleFeature singleBuilding : employeeRetail) { int id = (int) (long) singleBuilding.getAttribute("osm_id"); if (id == 1) { - Assert.assertEquals("1", String.valueOf(singleBuilding.getAttribute("levels"))); - Assert.assertEquals("retail", String.valueOf(singleBuilding.getAttribute("type"))); + Assertions.assertEquals("1", String.valueOf(singleBuilding.getAttribute("levels"))); + Assertions.assertEquals("retail", String.valueOf(singleBuilding.getAttribute("type"))); } else if (id == 3) { - Assert.assertEquals("2", String.valueOf(singleBuilding.getAttribute("levels"))); - Assert.assertEquals("retail", String.valueOf(singleBuilding.getAttribute("type"))); + Assertions.assertEquals("2", String.valueOf(singleBuilding.getAttribute("levels"))); + Assertions.assertEquals("retail", String.valueOf(singleBuilding.getAttribute("type"))); } else - Assert.fail(); + Assertions.fail(); } - Assert.assertEquals(2, builingsPerArea2.get("Inhabitants").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, builingsPerArea2.get("Employee Primary Sector").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, builingsPerArea2.get("Employee Construction").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, builingsPerArea2.get("Employee Secondary Sector Rest").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2, builingsPerArea2.get("Employee Traffic/Parcels").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2, builingsPerArea2.get("Employee Tertiary Sector Rest").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(8, builingsPerArea2.get("Employee").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, builingsPerArea2.get("Inhabitants").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, builingsPerArea2.get("Employee Primary Sector").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, builingsPerArea2.get("Employee Construction").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, builingsPerArea2.get("Employee Secondary Sector Rest").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, builingsPerArea2.get("Employee Traffic/Parcels").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, builingsPerArea2.get("Employee Tertiary Sector Rest").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(8, builingsPerArea2.get("Employee").size(), MatsimTestUtils.EPSILON); // test for area3 HashMap> builingsPerArea3 = buildingsPerZone.get("testArea2_area3"); - Assert.assertEquals(8, builingsPerArea3.size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(8, builingsPerArea3.size(), MatsimTestUtils.EPSILON); ArrayList tertiaryRetail = builingsPerArea3.get("Employee Tertiary Sector Rest"); - Assert.assertEquals(1, tertiaryRetail.size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, tertiaryRetail.size(), MatsimTestUtils.EPSILON); for (SimpleFeature singleBuilding : tertiaryRetail) { int id = (int) (long) singleBuilding.getAttribute("osm_id"); if (id == 26) { - Assert.assertEquals("2", String.valueOf(singleBuilding.getAttribute("levels"))); - Assert.assertEquals("foundation", String.valueOf(singleBuilding.getAttribute("type"))); + Assertions.assertEquals("2", String.valueOf(singleBuilding.getAttribute("levels"))); + Assertions.assertEquals("foundation", String.valueOf(singleBuilding.getAttribute("type"))); } else - Assert.fail(); + Assertions.fail(); } - Assert.assertEquals(3, builingsPerArea3.get("Inhabitants").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, builingsPerArea3.get("Employee Primary Sector").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, builingsPerArea3.get("Employee Construction").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, builingsPerArea3.get("Employee Secondary Sector Rest").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, builingsPerArea3.get("Employee Traffic/Parcels").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2, builingsPerArea3.get("Employee Retail").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(7, builingsPerArea3.get("Employee").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, builingsPerArea3.get("Inhabitants").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, builingsPerArea3.get("Employee Primary Sector").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, builingsPerArea3.get("Employee Construction").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, builingsPerArea3.get("Employee Secondary Sector Rest").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, builingsPerArea3.get("Employee Traffic/Parcels").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, builingsPerArea3.get("Employee Retail").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(7, builingsPerArea3.get("Employee").size(), MatsimTestUtils.EPSILON); } @Test @@ -257,24 +257,24 @@ void testLanduseDistribution() throws IOException { inputDataDirectory, usedLanduseConfiguration, shapeFileLandusePath, shapeFileZonePath, shapeFileBuildingsPath, null, buildingsPerZone); - Assert.assertEquals(3, resultingDataPerZone.size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, resultingDataPerZone.size(), MatsimTestUtils.EPSILON); - Assert.assertTrue(resultingDataPerZone.containsKey("testArea1_area1")); - Assert.assertTrue(resultingDataPerZone.containsKey("testArea1_area2")); - Assert.assertTrue(resultingDataPerZone.containsKey("testArea2_area3")); + Assertions.assertTrue(resultingDataPerZone.containsKey("testArea1_area1")); + Assertions.assertTrue(resultingDataPerZone.containsKey("testArea1_area2")); + Assertions.assertTrue(resultingDataPerZone.containsKey("testArea2_area3")); for (String zone : resultingDataPerZone.keySet()) { Object2DoubleMap categories = resultingDataPerZone.get(zone); int employeeSum = 0; - Assert.assertEquals(8, categories.size(), MatsimTestUtils.EPSILON); - Assert.assertTrue(categories.containsKey("Inhabitants")); - Assert.assertTrue(categories.containsKey("Employee")); - Assert.assertTrue(categories.containsKey("Employee Primary Sector")); - Assert.assertTrue(categories.containsKey("Employee Construction")); - Assert.assertTrue(categories.containsKey("Employee Secondary Sector Rest")); - Assert.assertTrue(categories.containsKey("Employee Retail")); - Assert.assertTrue(categories.containsKey("Employee Traffic/Parcels")); - Assert.assertTrue(categories.containsKey("Employee Tertiary Sector Rest")); + Assertions.assertEquals(8, categories.size(), MatsimTestUtils.EPSILON); + Assertions.assertTrue(categories.containsKey("Inhabitants")); + Assertions.assertTrue(categories.containsKey("Employee")); + Assertions.assertTrue(categories.containsKey("Employee Primary Sector")); + Assertions.assertTrue(categories.containsKey("Employee Construction")); + Assertions.assertTrue(categories.containsKey("Employee Secondary Sector Rest")); + Assertions.assertTrue(categories.containsKey("Employee Retail")); + Assertions.assertTrue(categories.containsKey("Employee Traffic/Parcels")); + Assertions.assertTrue(categories.containsKey("Employee Tertiary Sector Rest")); employeeSum += (int) categories.getDouble("Employee Primary Sector"); employeeSum += (int) categories.getDouble("Employee Construction"); @@ -283,60 +283,60 @@ void testLanduseDistribution() throws IOException { employeeSum += (int) categories.getDouble("Employee Traffic/Parcels"); employeeSum += (int) categories.getDouble("Employee Tertiary Sector Rest"); - Assert.assertEquals(categories.getDouble("Employee"), employeeSum, MatsimTestUtils.EPSILON); + Assertions.assertEquals(categories.getDouble("Employee"), employeeSum, MatsimTestUtils.EPSILON); if (zone.equals("testArea1_area1")) { - Assert.assertEquals(4000, resultingDataPerZone.get(zone).getDouble("Inhabitants"), + Assertions.assertEquals(4000, resultingDataPerZone.get(zone).getDouble("Inhabitants"), MatsimTestUtils.EPSILON); - Assert.assertEquals(3500, resultingDataPerZone.get(zone).getDouble("Employee"), + Assertions.assertEquals(3500, resultingDataPerZone.get(zone).getDouble("Employee"), MatsimTestUtils.EPSILON); - Assert.assertEquals(0, resultingDataPerZone.get(zone).getDouble("Employee Primary Sector"), + Assertions.assertEquals(0, resultingDataPerZone.get(zone).getDouble("Employee Primary Sector"), MatsimTestUtils.EPSILON); - Assert.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Construction"), + Assertions.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Construction"), MatsimTestUtils.EPSILON); - Assert.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Secondary Sector Rest"), + Assertions.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Secondary Sector Rest"), MatsimTestUtils.EPSILON); - Assert.assertEquals(1000, resultingDataPerZone.get(zone).getDouble("Employee Retail"), + Assertions.assertEquals(1000, resultingDataPerZone.get(zone).getDouble("Employee Retail"), MatsimTestUtils.EPSILON); - Assert.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Traffic/Parcels"), + Assertions.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Traffic/Parcels"), MatsimTestUtils.EPSILON); - Assert.assertEquals(1000, resultingDataPerZone.get(zone).getDouble("Employee Tertiary Sector Rest"), + Assertions.assertEquals(1000, resultingDataPerZone.get(zone).getDouble("Employee Tertiary Sector Rest"), MatsimTestUtils.EPSILON); } if (zone.equals("testArea1_area2")) { - Assert.assertEquals(4000, resultingDataPerZone.get(zone).getDouble("Inhabitants"), + Assertions.assertEquals(4000, resultingDataPerZone.get(zone).getDouble("Inhabitants"), MatsimTestUtils.EPSILON); - Assert.assertEquals(6500, resultingDataPerZone.get(zone).getDouble("Employee"), + Assertions.assertEquals(6500, resultingDataPerZone.get(zone).getDouble("Employee"), MatsimTestUtils.EPSILON); - Assert.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Primary Sector"), + Assertions.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Primary Sector"), MatsimTestUtils.EPSILON); - Assert.assertEquals(1500, resultingDataPerZone.get(zone).getDouble("Employee Construction"), + Assertions.assertEquals(1500, resultingDataPerZone.get(zone).getDouble("Employee Construction"), MatsimTestUtils.EPSILON); - Assert.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Secondary Sector Rest"), + Assertions.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Secondary Sector Rest"), MatsimTestUtils.EPSILON); - Assert.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Retail"), + Assertions.assertEquals(500, resultingDataPerZone.get(zone).getDouble("Employee Retail"), MatsimTestUtils.EPSILON); - Assert.assertEquals(1500, resultingDataPerZone.get(zone).getDouble("Employee Traffic/Parcels"), + Assertions.assertEquals(1500, resultingDataPerZone.get(zone).getDouble("Employee Traffic/Parcels"), MatsimTestUtils.EPSILON); - Assert.assertEquals(2000, resultingDataPerZone.get(zone).getDouble("Employee Tertiary Sector Rest"), + Assertions.assertEquals(2000, resultingDataPerZone.get(zone).getDouble("Employee Tertiary Sector Rest"), MatsimTestUtils.EPSILON); } if (zone.equals("testArea2_area3")) { - Assert.assertEquals(800, resultingDataPerZone.get(zone).getDouble("Inhabitants"), + Assertions.assertEquals(800, resultingDataPerZone.get(zone).getDouble("Inhabitants"), MatsimTestUtils.EPSILON); - Assert.assertEquals(1000, resultingDataPerZone.get(zone).getDouble("Employee"), + Assertions.assertEquals(1000, resultingDataPerZone.get(zone).getDouble("Employee"), MatsimTestUtils.EPSILON); - Assert.assertEquals(50, resultingDataPerZone.get(zone).getDouble("Employee Primary Sector"), + Assertions.assertEquals(50, resultingDataPerZone.get(zone).getDouble("Employee Primary Sector"), MatsimTestUtils.EPSILON); - Assert.assertEquals(200, resultingDataPerZone.get(zone).getDouble("Employee Construction"), + Assertions.assertEquals(200, resultingDataPerZone.get(zone).getDouble("Employee Construction"), MatsimTestUtils.EPSILON); - Assert.assertEquals(100, resultingDataPerZone.get(zone).getDouble("Employee Secondary Sector Rest"), + Assertions.assertEquals(100, resultingDataPerZone.get(zone).getDouble("Employee Secondary Sector Rest"), MatsimTestUtils.EPSILON); - Assert.assertEquals(150, resultingDataPerZone.get(zone).getDouble("Employee Retail"), + Assertions.assertEquals(150, resultingDataPerZone.get(zone).getDouble("Employee Retail"), MatsimTestUtils.EPSILON); - Assert.assertEquals(200, resultingDataPerZone.get(zone).getDouble("Employee Traffic/Parcels"), + Assertions.assertEquals(200, resultingDataPerZone.get(zone).getDouble("Employee Traffic/Parcels"), MatsimTestUtils.EPSILON); - Assert.assertEquals(300, resultingDataPerZone.get(zone).getDouble("Employee Tertiary Sector Rest"), + Assertions.assertEquals(300, resultingDataPerZone.get(zone).getDouble("Employee Tertiary Sector Rest"), MatsimTestUtils.EPSILON); } } diff --git a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/RunGenerateSmallScaleCommercialTrafficTest.java b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/RunGenerateSmallScaleCommercialTrafficTest.java index 43fa34e8a5d..62127e7e2f5 100644 --- a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/RunGenerateSmallScaleCommercialTrafficTest.java +++ b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/RunGenerateSmallScaleCommercialTrafficTest.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.smallScaleCommercialTrafficGeneration; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -102,19 +102,19 @@ void testMainRunAndResults() { assert population != null; for (Person person : population.getPersons().values()) { - Assert.assertNotNull(person.getSelectedPlan()); - Assert.assertTrue(person.getAttributes().getAsMap().containsKey("tourStartArea")); - Assert.assertTrue(person.getAttributes().getAsMap().containsKey("vehicles")); - Assert.assertTrue(person.getAttributes().getAsMap().containsKey("subpopulation")); - Assert.assertTrue(person.getAttributes().getAsMap().containsKey("purpose")); + Assertions.assertNotNull(person.getSelectedPlan()); + Assertions.assertTrue(person.getAttributes().getAsMap().containsKey("tourStartArea")); + Assertions.assertTrue(person.getAttributes().getAsMap().containsKey("vehicles")); + Assertions.assertTrue(person.getAttributes().getAsMap().containsKey("subpopulation")); + Assertions.assertTrue(person.getAttributes().getAsMap().containsKey("purpose")); } - Assert.assertEquals(CarriersUtils.addOrGetCarriers(scenarioWSolution).getCarriers().size(), + Assertions.assertEquals(CarriersUtils.addOrGetCarriers(scenarioWSolution).getCarriers().size(), CarriersUtils.addOrGetCarriers(scenarioWOSolution).getCarriers().size(), 0); int countedTours = 0; for (Carrier carrier_withSolution : CarriersUtils.addOrGetCarriers(scenarioWSolution).getCarriers().values()) { countedTours += carrier_withSolution.getSelectedPlan().getScheduledTours().size(); } - Assert.assertEquals(population.getPersons().size(), countedTours, 0); + Assertions.assertEquals(population.getPersons().size(), countedTours, 0); } } diff --git a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/SmallScaleCommercialTrafficUtilsTest.java b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/SmallScaleCommercialTrafficUtilsTest.java index f73b0698099..0b89332ca30 100644 --- a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/SmallScaleCommercialTrafficUtilsTest.java +++ b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/SmallScaleCommercialTrafficUtilsTest.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.smallScaleCommercialTrafficGeneration; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -67,14 +67,14 @@ void findZoneOfLinksTest() throws IOException, URISyntaxException { .filterLinksForZones(scenario, shpZones, SmallScaleCommercialTrafficUtils.getIndexZones(shapeFileZonePath, config.global().getCoordinateSystem()), buildingsPerZone); - Assert.assertEquals(3, regionLinksMap.size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(60, regionLinksMap.get("testArea1_area1").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(41, regionLinksMap.get("testArea1_area2").size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(28, regionLinksMap.get("testArea2_area3").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, regionLinksMap.size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(60, regionLinksMap.get("testArea1_area1").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(41, regionLinksMap.get("testArea1_area2").size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(28, regionLinksMap.get("testArea2_area3").size(), MatsimTestUtils.EPSILON); - Assert.assertNull(SmallScaleCommercialTrafficUtils.findZoneOfLink(Id.createLinkId("j(5,4)"), regionLinksMap)); - Assert.assertEquals("testArea1_area1", SmallScaleCommercialTrafficUtils.findZoneOfLink(Id.createLinkId("j(6,5)R"), regionLinksMap)); - Assert.assertEquals("testArea1_area2", SmallScaleCommercialTrafficUtils.findZoneOfLink(Id.createLinkId("j(2,7)R"), regionLinksMap)); - Assert.assertEquals("testArea2_area3", SmallScaleCommercialTrafficUtils.findZoneOfLink(Id.createLinkId("j(2,2)R"), regionLinksMap)); + Assertions.assertNull(SmallScaleCommercialTrafficUtils.findZoneOfLink(Id.createLinkId("j(5,4)"), regionLinksMap)); + Assertions.assertEquals("testArea1_area1", SmallScaleCommercialTrafficUtils.findZoneOfLink(Id.createLinkId("j(6,5)R"), regionLinksMap)); + Assertions.assertEquals("testArea1_area2", SmallScaleCommercialTrafficUtils.findZoneOfLink(Id.createLinkId("j(2,7)R"), regionLinksMap)); + Assertions.assertEquals("testArea2_area3", SmallScaleCommercialTrafficUtils.findZoneOfLink(Id.createLinkId("j(2,2)R"), regionLinksMap)); } } diff --git a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TrafficVolumeGenerationTest.java b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TrafficVolumeGenerationTest.java index c2e7ff89bd0..c1d80ed77d6 100644 --- a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TrafficVolumeGenerationTest.java +++ b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TrafficVolumeGenerationTest.java @@ -20,7 +20,7 @@ package org.matsim.smallScaleCommercialTrafficGeneration; import it.unimi.dsi.fastutil.objects.Object2DoubleMap; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -84,52 +84,52 @@ void testTrafficVolumeGenerationCommercialPersonTraffic() throws IOException { HashMap> trafficVolumePerTypeAndZone_stop = TrafficVolumeGeneration .createTrafficVolume_stop(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType); - Assert.assertEquals(3, trafficVolumePerTypeAndZone_start.size()); - Assert.assertEquals(3, trafficVolumePerTypeAndZone_stop.size()); + Assertions.assertEquals(3, trafficVolumePerTypeAndZone_start.size()); + Assertions.assertEquals(3, trafficVolumePerTypeAndZone_stop.size()); for (String zone : resultingDataPerZone.keySet()) { TrafficVolumeKey trafficVolumeKey = TrafficVolumeGeneration.makeTrafficVolumeKey(zone, modesORvehTypes.get(0)); - Assert.assertTrue(trafficVolumePerTypeAndZone_start.containsKey(trafficVolumeKey)); - Assert.assertTrue(trafficVolumePerTypeAndZone_stop.containsKey(trafficVolumeKey)); + Assertions.assertTrue(trafficVolumePerTypeAndZone_start.containsKey(trafficVolumeKey)); + Assertions.assertTrue(trafficVolumePerTypeAndZone_stop.containsKey(trafficVolumeKey)); } TrafficVolumeKey trafficVolumeKey = TrafficVolumeGeneration.makeTrafficVolumeKey("testArea1_area1", modesORvehTypes.get(0)); - Assert.assertEquals(30, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(124, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(277, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(175, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(250, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - - Assert.assertEquals(10, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(105, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(426, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(121, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(65, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(30, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(124, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(277, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(175, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(250, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(10, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(105, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(426, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(121, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(65, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); trafficVolumeKey = TrafficVolumeGeneration.makeTrafficVolumeKey("testArea1_area2", modesORvehTypes.get(0)); - Assert.assertEquals(30, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(211, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(514, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(441, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(630, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - - Assert.assertEquals(10, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(202, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(859, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(246, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(102, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(30, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(211, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(514, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(441, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(630, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(10, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(202, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(859, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(246, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(102, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); trafficVolumeKey = TrafficVolumeGeneration.makeTrafficVolumeKey("testArea2_area3", modesORvehTypes.get(0)); - Assert.assertEquals(6, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(34, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(79, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(62, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(88, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(6, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(34, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(79, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(62, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(88, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(2, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(31, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(128, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(37, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(17, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(31, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(128, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(37, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(17, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); //test with different sample @@ -139,47 +139,47 @@ void testTrafficVolumeGenerationCommercialPersonTraffic() throws IOException { trafficVolumePerTypeAndZone_stop = TrafficVolumeGeneration .createTrafficVolume_stop(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType); - Assert.assertEquals(3, trafficVolumePerTypeAndZone_start.size()); - Assert.assertEquals(3, trafficVolumePerTypeAndZone_stop.size()); + Assertions.assertEquals(3, trafficVolumePerTypeAndZone_start.size()); + Assertions.assertEquals(3, trafficVolumePerTypeAndZone_stop.size()); trafficVolumeKey = TrafficVolumeGeneration.makeTrafficVolumeKey("testArea1_area1", modesORvehTypes.get(0)); - Assert.assertEquals(7, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(31, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(69, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(44, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(63, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - - Assert.assertEquals(3, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(26, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(106, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(30, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(16, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(7, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(31, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(69, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(44, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(63, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(3, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(26, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(106, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(30, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(16, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); trafficVolumeKey = TrafficVolumeGeneration.makeTrafficVolumeKey("testArea1_area2", modesORvehTypes.get(0)); - Assert.assertEquals(7, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(53, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(129, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(110, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(158, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - - Assert.assertEquals(3, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(50, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(215, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(61, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(25, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(7, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(53, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(129, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(110, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(158, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(3, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(50, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(215, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(61, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(25, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); trafficVolumeKey = TrafficVolumeGeneration.makeTrafficVolumeKey("testArea2_area3", modesORvehTypes.get(0)); - Assert.assertEquals(1, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(8, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(20, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(15, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(22, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - - Assert.assertEquals(1, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(8, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(32, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(9, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(4, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(8, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(20, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(15, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(22, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(1, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(8, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(32, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(9, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(4, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); } @Test @@ -214,14 +214,14 @@ void testTrafficVolumeGenerationGoodsTraffic() throws IOException { HashMap> trafficVolumePerTypeAndZone_stop = TrafficVolumeGeneration .createTrafficVolume_stop(resultingDataPerZone, output, sample, modesORvehTypes, usedTrafficType); - Assert.assertEquals(15, trafficVolumePerTypeAndZone_start.size()); - Assert.assertEquals(15, trafficVolumePerTypeAndZone_stop.size()); + Assertions.assertEquals(15, trafficVolumePerTypeAndZone_start.size()); + Assertions.assertEquals(15, trafficVolumePerTypeAndZone_stop.size()); for (String zone : resultingDataPerZone.keySet()) { for (String modesORvehType : modesORvehTypes) { TrafficVolumeKey trafficVolumeKey = TrafficVolumeGeneration.makeTrafficVolumeKey(zone, modesORvehType); - Assert.assertTrue(trafficVolumePerTypeAndZone_start.containsKey(trafficVolumeKey)); - Assert.assertTrue(trafficVolumePerTypeAndZone_stop.containsKey(trafficVolumeKey)); + Assertions.assertTrue(trafficVolumePerTypeAndZone_start.containsKey(trafficVolumeKey)); + Assertions.assertTrue(trafficVolumePerTypeAndZone_stop.containsKey(trafficVolumeKey)); } } @@ -249,83 +249,83 @@ void testTrafficVolumeGenerationGoodsTraffic() throws IOException { sumStart += trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(i); sumStop += trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(i); if (modeORvehType.equals("vehTyp1")) { - Assert.assertEquals(5, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(16, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(101, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(36, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(33, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(0, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); - - Assert.assertEquals(5, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(17, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(73, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(54, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(10, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(0, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); + Assertions.assertEquals(5, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(16, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(101, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(36, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(33, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(5, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(17, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(73, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(54, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); } if (modeORvehType.equals("vehTyp2")) { - Assert.assertEquals(1, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(3, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(21, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(11, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(23, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(10, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); - - Assert.assertEquals(2, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(3, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(13, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(20, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(7, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(11, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(21, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(11, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(23, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(2, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(13, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(20, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(7, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(11, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); } if (modeORvehType.equals("vehTyp3")) { - Assert.assertEquals(3, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(6, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(44, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(42, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(28, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(23, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); - - Assert.assertEquals(4, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(8, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(28, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(73, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(6, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(15, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(6, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(44, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(42, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(28, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(23, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(4, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(8, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(28, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(73, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(6, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(15, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); } if (modeORvehType.equals("vehTyp4")) { - Assert.assertEquals(1, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(10, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(13, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(2, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(3, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); - - Assert.assertEquals(0, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(2, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(5, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(20, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(5, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(13, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(0, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(5, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(20, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(5, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); } if (modeORvehType.equals("vehTyp5")) { - Assert.assertEquals(2, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(4, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(29, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(72, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(31, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(0, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); - - Assert.assertEquals(4, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(6, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(20, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(133, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(8, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(0, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(4, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(29, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(72, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(31, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(4, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(6, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(20, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(133, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(8, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); } } - Assert.assertEquals(estimatesStart.get(i), sumStart, MatsimTestUtils.EPSILON); - Assert.assertEquals(estimatesStop.get(i), sumStop, MatsimTestUtils.EPSILON); + Assertions.assertEquals(estimatesStart.get(i), sumStart, MatsimTestUtils.EPSILON); + Assertions.assertEquals(estimatesStop.get(i), sumStop, MatsimTestUtils.EPSILON); } // test for "testArea1_area2" @@ -352,8 +352,8 @@ void testTrafficVolumeGenerationGoodsTraffic() throws IOException { sumStart += trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(i); sumStop += trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(i); } - Assert.assertEquals(estimatesStart.get(i), sumStart, MatsimTestUtils.EPSILON); - Assert.assertEquals(estimatesStop.get(i), sumStop, MatsimTestUtils.EPSILON); + Assertions.assertEquals(estimatesStart.get(i), sumStart, MatsimTestUtils.EPSILON); + Assertions.assertEquals(estimatesStop.get(i), sumStop, MatsimTestUtils.EPSILON); } // test for "testArea2_area3" @@ -380,8 +380,8 @@ void testTrafficVolumeGenerationGoodsTraffic() throws IOException { sumStart += trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(i); sumStop += trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(i); } - Assert.assertEquals(estimatesStart.get(i), sumStart, MatsimTestUtils.EPSILON); - Assert.assertEquals(estimatesStop.get(i), sumStop, MatsimTestUtils.EPSILON); + Assertions.assertEquals(estimatesStart.get(i), sumStart, MatsimTestUtils.EPSILON); + Assertions.assertEquals(estimatesStop.get(i), sumStop, MatsimTestUtils.EPSILON); } } @@ -406,49 +406,49 @@ void testAddingExistingScenarios() throws Exception { SmallScaleCommercialTrafficUtils.readExistingModels(scenario, sample, regionLinksMap); - Assert.assertEquals(3, CarriersUtils.getCarriers(scenario).getCarriers().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, CarriersUtils.getCarrierVehicleTypes(scenario).getVehicleTypes().size(), MatsimTestUtils.EPSILON); - Assert.assertTrue(CarriersUtils.getCarriers(scenario).getCarriers().containsKey(Id.create("exampleServiceCarrier_carrier1", Carrier.class))); - Assert.assertTrue(CarriersUtils.getCarriers(scenario).getCarriers().containsKey(Id.create("exampleServiceCarrier_carrier2", Carrier.class))); - Assert.assertTrue(CarriersUtils.getCarriers(scenario).getCarriers().containsKey(Id.create("exampleShipmentCarrier_carrier1", Carrier.class))); + Assertions.assertEquals(3, CarriersUtils.getCarriers(scenario).getCarriers().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, CarriersUtils.getCarrierVehicleTypes(scenario).getVehicleTypes().size(), MatsimTestUtils.EPSILON); + Assertions.assertTrue(CarriersUtils.getCarriers(scenario).getCarriers().containsKey(Id.create("exampleServiceCarrier_carrier1", Carrier.class))); + Assertions.assertTrue(CarriersUtils.getCarriers(scenario).getCarriers().containsKey(Id.create("exampleServiceCarrier_carrier2", Carrier.class))); + Assertions.assertTrue(CarriersUtils.getCarriers(scenario).getCarriers().containsKey(Id.create("exampleShipmentCarrier_carrier1", Carrier.class))); Carrier addedCarrier1 = CarriersUtils.getCarriers(scenario).getCarriers().get(Id.create("exampleServiceCarrier_carrier1", Carrier.class)); - Assert.assertNotNull(addedCarrier1.getSelectedPlan()); - Assert.assertEquals(0, CarriersUtils.getJspritIterations(addedCarrier1), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, addedCarrier1.getCarrierCapabilities().getCarrierVehicles().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, addedCarrier1.getCarrierCapabilities().getVehicleTypes().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(3, addedCarrier1.getSelectedPlan().getScheduledTours().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(30, addedCarrier1.getServices().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(6, addedCarrier1.getAttributes().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals("commercialPersonTraffic", addedCarrier1.getAttributes().getAttribute("subpopulation")); - Assert.assertEquals(2, (int) addedCarrier1.getAttributes().getAttribute("purpose")); - Assert.assertEquals("exampleServiceCarrier", addedCarrier1.getAttributes().getAttribute("existingModel")); - Assert.assertEquals("car", addedCarrier1.getAttributes().getAttribute("networkMode")); - Assert.assertNull(addedCarrier1.getAttributes().getAttribute("vehicleType")); - Assert.assertEquals("testArea2_area3", addedCarrier1.getAttributes().getAttribute("tourStartArea")); + Assertions.assertNotNull(addedCarrier1.getSelectedPlan()); + Assertions.assertEquals(0, CarriersUtils.getJspritIterations(addedCarrier1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, addedCarrier1.getCarrierCapabilities().getCarrierVehicles().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, addedCarrier1.getCarrierCapabilities().getVehicleTypes().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, addedCarrier1.getSelectedPlan().getScheduledTours().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(30, addedCarrier1.getServices().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(6, addedCarrier1.getAttributes().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals("commercialPersonTraffic", addedCarrier1.getAttributes().getAttribute("subpopulation")); + Assertions.assertEquals(2, (int) addedCarrier1.getAttributes().getAttribute("purpose")); + Assertions.assertEquals("exampleServiceCarrier", addedCarrier1.getAttributes().getAttribute("existingModel")); + Assertions.assertEquals("car", addedCarrier1.getAttributes().getAttribute("networkMode")); + Assertions.assertNull(addedCarrier1.getAttributes().getAttribute("vehicleType")); + Assertions.assertEquals("testArea2_area3", addedCarrier1.getAttributes().getAttribute("tourStartArea")); Carrier addedCarrier2 = CarriersUtils.getCarriers(scenario).getCarriers().get(Id.create("exampleServiceCarrier_carrier2", Carrier.class)); - Assert.assertNotNull(addedCarrier2.getSelectedPlan()); - Assert.assertEquals(0, CarriersUtils.getJspritIterations(addedCarrier2), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, addedCarrier2.getCarrierCapabilities().getCarrierVehicles().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, addedCarrier2.getCarrierCapabilities().getVehicleTypes().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2, addedCarrier2.getSelectedPlan().getScheduledTours().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(20, addedCarrier2.getServices().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals("commercialPersonTraffic", addedCarrier2.getAttributes().getAttribute("subpopulation")); - Assert.assertEquals(2, (int) addedCarrier2.getAttributes().getAttribute("purpose")); - Assert.assertEquals("exampleServiceCarrier", addedCarrier2.getAttributes().getAttribute("existingModel")); - Assert.assertEquals("car", addedCarrier2.getAttributes().getAttribute("networkMode")); - Assert.assertNull(addedCarrier2.getAttributes().getAttribute("vehicleType")); - Assert.assertEquals("testArea2_area3", addedCarrier2.getAttributes().getAttribute("tourStartArea")); + Assertions.assertNotNull(addedCarrier2.getSelectedPlan()); + Assertions.assertEquals(0, CarriersUtils.getJspritIterations(addedCarrier2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, addedCarrier2.getCarrierCapabilities().getCarrierVehicles().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, addedCarrier2.getCarrierCapabilities().getVehicleTypes().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, addedCarrier2.getSelectedPlan().getScheduledTours().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(20, addedCarrier2.getServices().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals("commercialPersonTraffic", addedCarrier2.getAttributes().getAttribute("subpopulation")); + Assertions.assertEquals(2, (int) addedCarrier2.getAttributes().getAttribute("purpose")); + Assertions.assertEquals("exampleServiceCarrier", addedCarrier2.getAttributes().getAttribute("existingModel")); + Assertions.assertEquals("car", addedCarrier2.getAttributes().getAttribute("networkMode")); + Assertions.assertNull(addedCarrier2.getAttributes().getAttribute("vehicleType")); + Assertions.assertEquals("testArea2_area3", addedCarrier2.getAttributes().getAttribute("tourStartArea")); Carrier addedCarrier3 = CarriersUtils.getCarriers(scenario).getCarriers().get(Id.create("exampleShipmentCarrier_carrier1", Carrier.class)); - Assert.assertNull(addedCarrier3.getSelectedPlan()); - Assert.assertEquals(50, CarriersUtils.getJspritIterations(addedCarrier3), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, addedCarrier3.getCarrierCapabilities().getCarrierVehicles().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, addedCarrier3.getCarrierCapabilities().getVehicleTypes().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(FleetSize.INFINITE, addedCarrier3.getCarrierCapabilities().getFleetSize()); - Assert.assertEquals(0, addedCarrier3.getServices().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(5, addedCarrier3.getShipments().size(), MatsimTestUtils.EPSILON); + Assertions.assertNull(addedCarrier3.getSelectedPlan()); + Assertions.assertEquals(50, CarriersUtils.getJspritIterations(addedCarrier3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, addedCarrier3.getCarrierCapabilities().getCarrierVehicles().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, addedCarrier3.getCarrierCapabilities().getVehicleTypes().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(FleetSize.INFINITE, addedCarrier3.getCarrierCapabilities().getFleetSize()); + Assertions.assertEquals(0, addedCarrier3.getServices().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(5, addedCarrier3.getShipments().size(), MatsimTestUtils.EPSILON); } @Test @@ -472,34 +472,34 @@ void testAddingExistingScenariosWithSample() throws Exception { SmallScaleCommercialTrafficUtils.readExistingModels(scenario, sample, regionLinksMap); - Assert.assertEquals(2, CarriersUtils.getCarriers(scenario).getCarriers().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, CarriersUtils.getCarrierVehicleTypes(scenario).getVehicleTypes().size(), MatsimTestUtils.EPSILON); - Assert.assertTrue(CarriersUtils.getCarriers(scenario).getCarriers().containsKey(Id.create("exampleServiceCarrier_carrier1", Carrier.class))); - Assert.assertTrue(CarriersUtils.getCarriers(scenario).getCarriers().containsKey(Id.create("exampleShipmentCarrier_carrier1", Carrier.class))); + Assertions.assertEquals(2, CarriersUtils.getCarriers(scenario).getCarriers().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, CarriersUtils.getCarrierVehicleTypes(scenario).getVehicleTypes().size(), MatsimTestUtils.EPSILON); + Assertions.assertTrue(CarriersUtils.getCarriers(scenario).getCarriers().containsKey(Id.create("exampleServiceCarrier_carrier1", Carrier.class))); + Assertions.assertTrue(CarriersUtils.getCarriers(scenario).getCarriers().containsKey(Id.create("exampleShipmentCarrier_carrier1", Carrier.class))); Carrier addedCarrier1 = CarriersUtils.getCarriers(scenario).getCarriers().get(Id.create("exampleServiceCarrier_carrier1", Carrier.class)); - Assert.assertNotNull(addedCarrier1.getSelectedPlan()); - Assert.assertEquals(0, CarriersUtils.getJspritIterations(addedCarrier1), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, addedCarrier1.getCarrierCapabilities().getCarrierVehicles().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, addedCarrier1.getCarrierCapabilities().getVehicleTypes().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, addedCarrier1.getSelectedPlan().getScheduledTours().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(10, addedCarrier1.getServices().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(6, addedCarrier1.getAttributes().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals("commercialPersonTraffic", addedCarrier1.getAttributes().getAttribute("subpopulation")); - Assert.assertEquals(2, (int) addedCarrier1.getAttributes().getAttribute("purpose")); - Assert.assertEquals("exampleServiceCarrier", addedCarrier1.getAttributes().getAttribute("existingModel")); - Assert.assertEquals("car", addedCarrier1.getAttributes().getAttribute("networkMode")); - Assert.assertNull(addedCarrier1.getAttributes().getAttribute("vehicleType")); - Assert.assertEquals("testArea2_area3", addedCarrier1.getAttributes().getAttribute("tourStartArea")); + Assertions.assertNotNull(addedCarrier1.getSelectedPlan()); + Assertions.assertEquals(0, CarriersUtils.getJspritIterations(addedCarrier1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, addedCarrier1.getCarrierCapabilities().getCarrierVehicles().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, addedCarrier1.getCarrierCapabilities().getVehicleTypes().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, addedCarrier1.getSelectedPlan().getScheduledTours().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10, addedCarrier1.getServices().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(6, addedCarrier1.getAttributes().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals("commercialPersonTraffic", addedCarrier1.getAttributes().getAttribute("subpopulation")); + Assertions.assertEquals(2, (int) addedCarrier1.getAttributes().getAttribute("purpose")); + Assertions.assertEquals("exampleServiceCarrier", addedCarrier1.getAttributes().getAttribute("existingModel")); + Assertions.assertEquals("car", addedCarrier1.getAttributes().getAttribute("networkMode")); + Assertions.assertNull(addedCarrier1.getAttributes().getAttribute("vehicleType")); + Assertions.assertEquals("testArea2_area3", addedCarrier1.getAttributes().getAttribute("tourStartArea")); Carrier addedCarrier3 = CarriersUtils.getCarriers(scenario).getCarriers().get(Id.create("exampleShipmentCarrier_carrier1", Carrier.class)); - Assert.assertNull(addedCarrier3.getSelectedPlan()); - Assert.assertEquals(50, CarriersUtils.getJspritIterations(addedCarrier3), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, addedCarrier3.getCarrierCapabilities().getCarrierVehicles().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, addedCarrier3.getCarrierCapabilities().getVehicleTypes().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(FleetSize.INFINITE, addedCarrier3.getCarrierCapabilities().getFleetSize()); - Assert.assertEquals(0, addedCarrier3.getServices().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, addedCarrier3.getShipments().size(), MatsimTestUtils.EPSILON); + Assertions.assertNull(addedCarrier3.getSelectedPlan()); + Assertions.assertEquals(50, CarriersUtils.getJspritIterations(addedCarrier3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, addedCarrier3.getCarrierCapabilities().getCarrierVehicles().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, addedCarrier3.getCarrierCapabilities().getVehicleTypes().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(FleetSize.INFINITE, addedCarrier3.getCarrierCapabilities().getFleetSize()); + Assertions.assertEquals(0, addedCarrier3.getServices().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, addedCarrier3.getShipments().size(), MatsimTestUtils.EPSILON); } @Test @@ -571,23 +571,23 @@ void testReducingDemandAfterAddingExistingScenarios_goods() throws Exception { sumStart += trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(i); sumStop += trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(i); if (modeORvehType.equals("vehTyp3")) { - Assert.assertEquals(3, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(6, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(44, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(42, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(28, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(23, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); - - Assert.assertEquals(4, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(8, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(26, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(73, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(6, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(15, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(6, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(44, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(42, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(28, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(23, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(4, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(8, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(26, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(73, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(6, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(15, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); } } - Assert.assertEquals(estimatesStart.get(i), sumStart, MatsimTestUtils.EPSILON); - Assert.assertEquals(estimatesStop.get(i), sumStop, MatsimTestUtils.EPSILON); + Assertions.assertEquals(estimatesStart.get(i), sumStart, MatsimTestUtils.EPSILON); + Assertions.assertEquals(estimatesStop.get(i), sumStop, MatsimTestUtils.EPSILON); } // test for "testArea1_area2" @@ -614,8 +614,8 @@ void testReducingDemandAfterAddingExistingScenarios_goods() throws Exception { sumStart += trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(i); sumStop += trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(i); } - Assert.assertEquals(estimatesStart.get(i), sumStart, MatsimTestUtils.EPSILON); - Assert.assertEquals(estimatesStop.get(i), sumStop, MatsimTestUtils.EPSILON); + Assertions.assertEquals(estimatesStart.get(i), sumStart, MatsimTestUtils.EPSILON); + Assertions.assertEquals(estimatesStop.get(i), sumStop, MatsimTestUtils.EPSILON); } // test for "testArea2_area3" @@ -642,23 +642,23 @@ void testReducingDemandAfterAddingExistingScenarios_goods() throws Exception { sumStart += trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(i); sumStop += trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(i); if (modeORvehType.equals("vehTyp3")) { - Assert.assertEquals(1, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(7, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(17, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(11, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(5, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); - - Assert.assertEquals(1, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(2, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(6, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(14, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(3, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(7, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(17, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(11, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(5, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(1, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(6, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(14, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(6), MatsimTestUtils.EPSILON); } } - Assert.assertEquals(estimatesStart.get(i), sumStart, MatsimTestUtils.EPSILON); - Assert.assertEquals(estimatesStop.get(i), sumStop, MatsimTestUtils.EPSILON); + Assertions.assertEquals(estimatesStart.get(i), sumStart, MatsimTestUtils.EPSILON); + Assertions.assertEquals(estimatesStop.get(i), sumStop, MatsimTestUtils.EPSILON); } } @@ -711,46 +711,46 @@ void testReducingDemandAfterAddingExistingScenarios_commercialPersonTraffic() th double sumOfStartOtherAreas = 0; TrafficVolumeKey trafficVolumeKey = TrafficVolumeGeneration.makeTrafficVolumeKey("testArea1_area1", modesORvehTypes.get(0)); - Assert.assertEquals(30, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(30, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); sumOfStartOtherAreas += trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2); - Assert.assertEquals(277, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(175, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(250, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(277, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(175, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(250, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(10, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(85, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(426, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(121, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(65, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(85, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(426, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(121, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(65, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); trafficVolumeKey = TrafficVolumeGeneration.makeTrafficVolumeKey("testArea1_area2", modesORvehTypes.get(0)); - Assert.assertEquals(30, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(30, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); sumOfStartOtherAreas += trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2); - Assert.assertEquals(514, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(441, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(630, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(514, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(441, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(630, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(10, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(187, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(859, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(246, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(102, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(187, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(859, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(246, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(102, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); trafficVolumeKey = TrafficVolumeGeneration.makeTrafficVolumeKey("testArea2_area3", modesORvehTypes.get(0)); - Assert.assertEquals(6, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(0, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(6, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); sumOfStartOtherAreas += trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(2); - Assert.assertEquals(79, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(62, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(88, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(79, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(62, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(88, trafficVolumePerTypeAndZone_start.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(2, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); - Assert.assertEquals(27, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); - Assert.assertEquals(128, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); - Assert.assertEquals(37, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); - Assert.assertEquals(17, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(27, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(128, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(37, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(4), MatsimTestUtils.EPSILON); + Assertions.assertEquals(17, trafficVolumePerTypeAndZone_stop.get(trafficVolumeKey).getDouble(5), MatsimTestUtils.EPSILON); - Assert.assertEquals(330, sumOfStartOtherAreas, MatsimTestUtils.EPSILON); + Assertions.assertEquals(330, sumOfStartOtherAreas, MatsimTestUtils.EPSILON); } @@ -761,7 +761,7 @@ void testTrafficVolumeKeyGeneration() { TrafficVolumeKey newKey = TrafficVolumeGeneration.makeTrafficVolumeKey(zone, mode); - Assert.assertEquals(newKey.getZone(), zone); - Assert.assertEquals(newKey.getModeORvehType(), mode); + Assertions.assertEquals(newKey.getZone(), zone); + Assertions.assertEquals(newKey.getModeORvehType(), mode); } } diff --git a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrixTest.java b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrixTest.java index 5d439e96bc9..0c8f2522a37 100644 --- a/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrixTest.java +++ b/contribs/application/src/test/java/org/matsim/smallScaleCommercialTrafficGeneration/TripDistributionMatrixTest.java @@ -20,7 +20,7 @@ package org.matsim.smallScaleCommercialTrafficGeneration; import it.unimi.dsi.fastutil.objects.Object2DoubleMap; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -104,16 +104,16 @@ void testTripDistributionCommercialPersonTrafficTraffic() throws IOException { odMatrix.clearRoundingError(); //tests - Assert.assertEquals(3, odMatrix.getListOfZones().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, odMatrix.getListOfZones().size(), MatsimTestUtils.EPSILON); for (String zone : resultingDataPerZone.keySet()) { - Assert.assertTrue(odMatrix.getListOfZones().contains(zone)); + Assertions.assertTrue(odMatrix.getListOfZones().contains(zone)); } - Assert.assertEquals(1, odMatrix.getListOfModesOrVehTypes().size(), MatsimTestUtils.EPSILON); - Assert.assertTrue(odMatrix.getListOfModesOrVehTypes().contains("total")); + Assertions.assertEquals(1, odMatrix.getListOfModesOrVehTypes().size(), MatsimTestUtils.EPSILON); + Assertions.assertTrue(odMatrix.getListOfModesOrVehTypes().contains("total")); - Assert.assertEquals(5, odMatrix.getListOfPurposes().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(5, odMatrix.getListOfPurposes().size(), MatsimTestUtils.EPSILON); for (int i = 1; i <= 5; i++) { - Assert.assertTrue(odMatrix.getListOfPurposes().contains(i)); + Assertions.assertTrue(odMatrix.getListOfPurposes().contains(i)); } double sumStartServices = 0; double sumStopServices = 0; @@ -129,11 +129,11 @@ void testTripDistributionCommercialPersonTrafficTraffic() throws IOException { sumStartServices += odMatrix.getSumOfServicesForStartZone(zone, modeORvehType, purpose, usedTrafficType); double planedVolume = trafficVolumePerTypeAndZone_stop.get(key).getDouble(purpose); - Assert.assertEquals(planedVolume, generatedVolume, MatsimTestUtils.EPSILON); + Assertions.assertEquals(planedVolume, generatedVolume, MatsimTestUtils.EPSILON); } } } - Assert.assertEquals(sumStartServices, sumStopServices, MatsimTestUtils.EPSILON); + Assertions.assertEquals(sumStartServices, sumStopServices, MatsimTestUtils.EPSILON); } @Test @@ -194,18 +194,18 @@ void testTripDistributionGoodsTraffic() throws IOException { odMatrix.clearRoundingError(); //tests - Assert.assertEquals(3, odMatrix.getListOfZones().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, odMatrix.getListOfZones().size(), MatsimTestUtils.EPSILON); for (String zone : resultingDataPerZone.keySet()) { - Assert.assertTrue(odMatrix.getListOfZones().contains(zone)); + Assertions.assertTrue(odMatrix.getListOfZones().contains(zone)); } - Assert.assertEquals(5, odMatrix.getListOfModesOrVehTypes().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(5, odMatrix.getListOfModesOrVehTypes().size(), MatsimTestUtils.EPSILON); for (String modeORvehType : modesORvehTypes) { - Assert.assertTrue(odMatrix.getListOfModesOrVehTypes().contains(modeORvehType)); + Assertions.assertTrue(odMatrix.getListOfModesOrVehTypes().contains(modeORvehType)); } - Assert.assertEquals(6, odMatrix.getListOfPurposes().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(6, odMatrix.getListOfPurposes().size(), MatsimTestUtils.EPSILON); for (int i = 1; i <= 6; i++) { - Assert.assertTrue(odMatrix.getListOfPurposes().contains(i)); + Assertions.assertTrue(odMatrix.getListOfPurposes().contains(i)); } double sumStartServices = 0; double sumStopServices = 0; @@ -221,10 +221,10 @@ void testTripDistributionGoodsTraffic() throws IOException { sumStartServices += odMatrix.getSumOfServicesForStartZone(zone, modeORvehType, purpose, usedTrafficType); double planedVolume = trafficVolumePerTypeAndZone_stop.get(key).getDouble(purpose); - Assert.assertEquals(planedVolume, generatedVolume, MatsimTestUtils.EPSILON); + Assertions.assertEquals(planedVolume, generatedVolume, MatsimTestUtils.EPSILON); } } } - Assert.assertEquals(sumStartServices, sumStopServices, MatsimTestUtils.EPSILON); + Assertions.assertEquals(sumStartServices, sumStopServices, MatsimTestUtils.EPSILON); } } diff --git a/contribs/av/src/test/java/org/matsim/contrib/av/flow/TestAvFlowFactor.java b/contribs/av/src/test/java/org/matsim/contrib/av/flow/TestAvFlowFactor.java index 2fe06af31f4..8a486ca716e 100644 --- a/contribs/av/src/test/java/org/matsim/contrib/av/flow/TestAvFlowFactor.java +++ b/contribs/av/src/test/java/org/matsim/contrib/av/flow/TestAvFlowFactor.java @@ -26,7 +26,7 @@ import java.net.MalformedURLException; import java.net.URL; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -70,8 +70,8 @@ void testAvFlowFactor() throws MalformedURLException { controler.getEvents().addHandler(vehicleTimeCounter); controler.run(); - Assert.assertEquals(vehicleTimeCounter.lastAVEnterTime, 32598, 0.1); - Assert.assertEquals(vehicleTimeCounter.lastNonAVEnterTime, 36179, 0.1); + Assertions.assertEquals(vehicleTimeCounter.lastAVEnterTime, 32598, 0.1); + Assertions.assertEquals(vehicleTimeCounter.lastNonAVEnterTime, 36179, 0.1); } diff --git a/contribs/av/src/test/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExampleIT.java b/contribs/av/src/test/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExampleIT.java index 5d7aae5a4e5..2721030096d 100644 --- a/contribs/av/src/test/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExampleIT.java +++ b/contribs/av/src/test/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExampleIT.java @@ -29,7 +29,7 @@ import java.util.List; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -83,7 +83,7 @@ void testIntermodalExample() throws MalformedURLException { } } - Assert.assertTrue("no pt agent has any intermodal route (=taxi for access or egress to pt)", - intermodalTripCounter > 0); + Assertions.assertTrue(intermodalTripCounter > 0, + "no pt agent has any intermodal route (=taxi for access or egress to pt)"); } } diff --git a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleLinkSpeedCalculatorTest.java b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleLinkSpeedCalculatorTest.java index 9bba0878b85..bb131f1005a 100644 --- a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleLinkSpeedCalculatorTest.java +++ b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleLinkSpeedCalculatorTest.java @@ -30,8 +30,8 @@ import java.util.UUID; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class BicycleLinkSpeedCalculatorTest { @RegisterExtension diff --git a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleUtilityUtilsTest.java b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleUtilityUtilsTest.java index 5e8ebb2f5d9..3d9d4ff5c90 100644 --- a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleUtilityUtilsTest.java +++ b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleUtilityUtilsTest.java @@ -6,7 +6,7 @@ import org.matsim.api.core.v01.network.Link; import org.matsim.core.network.NetworkUtils; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class BicycleUtilityUtilsTest { diff --git a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java index e14c9e48b76..961e43f0182 100644 --- a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java +++ b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java @@ -20,7 +20,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -63,8 +63,8 @@ import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.matsim.utils.eventsfilecomparison.EventsFileComparator.Result.FILES_ARE_EQUAL; /** @@ -97,8 +97,9 @@ void testNormal() { LOG.info("Checking MATSim events file ..."); final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; - assertEquals("Different event files.", FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew)); + assertEquals(FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew), + "Different event files."); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); @@ -107,9 +108,9 @@ void testNormal() { for (Id personId : scenarioReference.getPopulation().getPersons().keySet()) { double scoreReference = scenarioReference.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); double scoreCurrent = scenarioCurrent.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); - Assert.assertEquals("Scores of persons " + personId + " are different", scoreReference, scoreCurrent, MatsimTestUtils.EPSILON); + Assertions.assertEquals(scoreReference, scoreCurrent, MatsimTestUtils.EPSILON, "Scores of persons " + personId + " are different"); } - assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); + assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); } @Test @@ -134,14 +135,15 @@ void testCobblestone() { Scenario scenarioCurrent = ScenarioUtils.createScenario( ConfigUtils.createConfig() ); new PopulationReader( scenarioReference ).readFile( utils.getInputDirectory() + "output_plans.xml.gz" ); new PopulationReader( scenarioCurrent ).readFile( utils.getOutputDirectory() + "output_plans.xml.gz" ); - assertTrue( "Populations are different", PopulationUtils.equalPopulation( scenarioReference.getPopulation(), scenarioCurrent.getPopulation() ) ); + assertTrue( PopulationUtils.equalPopulation( scenarioReference.getPopulation(), scenarioCurrent.getPopulation() ), "Populations are different" ); } { LOG.info( "Checking MATSim events file ..." ); final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; - assertEquals( "Different event files.", FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew )); + assertEquals( FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew ), + "Different event files."); } } @@ -164,14 +166,15 @@ void testPedestrian() { LOG.info("Checking MATSim events file ..."); final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; - assertEquals("Different event files.", FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew)); + assertEquals(FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew), + "Different event files."); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); - assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); + assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); } @Test @@ -193,14 +196,15 @@ void testLane() { LOG.info("Checking MATSim events file ..."); final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; - assertEquals("Different event files.", FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew)); + assertEquals(FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew), + "Different event files."); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); - assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); + assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); } @Test @@ -222,14 +226,15 @@ void testGradient() { LOG.info("Checking MATSim events file ..."); final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; - assertEquals("Different event files.", FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew)); + assertEquals(FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( eventsFilenameReference, eventsFilenameNew), + "Different event files."); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); - assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); + assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); } @Test @@ -252,14 +257,15 @@ void testGradientLane() { LOG.info("Checking MATSim events file ..."); final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; - assertEquals("Different event files.", FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew)); + assertEquals(FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew), + "Different event files."); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); - assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); + assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); } @Test @@ -284,14 +290,15 @@ void testNormal10It() { LOG.info("Checking MATSim events file ..."); final String eventsFilenameReference = utils.getInputDirectory() + "output_events.xml.gz"; final String eventsFilenameNew = utils.getOutputDirectory() + "output_events.xml.gz"; - assertEquals("Different event files.", FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew)); + assertEquals(FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison(eventsFilenameReference, eventsFilenameNew), + "Different event files."); Scenario scenarioReference = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario scenarioCurrent = ScenarioUtils.createScenario(ConfigUtils.createConfig()); new PopulationReader(scenarioReference).readFile(utils.getInputDirectory() + "output_plans.xml.gz"); new PopulationReader(scenarioCurrent).readFile(utils.getOutputDirectory() + "output_plans.xml.gz"); - assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); + assertTrue(PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation()), "Populations are different"); } @Test @@ -322,7 +329,7 @@ void testLinkBasedScoring() { for (Id personId : scenarioReference.getPopulation().getPersons().keySet()) { double scoreReference = scenarioReference.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); double scoreCurrent = scenarioCurrent.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); - Assert.assertEquals("Scores of persons " + personId + " are different", scoreReference, scoreCurrent, MatsimTestUtils.EPSILON); + Assertions.assertEquals(scoreReference, scoreCurrent, MatsimTestUtils.EPSILON, "Scores of persons " + personId + " are different"); } // assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); } @@ -410,7 +417,7 @@ void testLinkVsLegMotorizedScoring() { for (Id personId : scenarioReference.getPopulation().getPersons().keySet()) { double scoreReference = scenarioReference.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); double scoreCurrent = scenarioCurrent.getPopulation().getPersons().get(personId).getSelectedPlan().getScore(); - Assert.assertEquals("Scores of person=" + personId + " are different", scoreReference, scoreCurrent, MatsimTestUtils.EPSILON); + Assertions.assertEquals(scoreReference, scoreCurrent, MatsimTestUtils.EPSILON, "Scores of person=" + personId + " are different"); } // assertTrue("Populations are different", PopulationUtils.equalPopulation(scenarioReference.getPopulation(), scenarioCurrent.getPopulation())); } @@ -528,14 +535,14 @@ public void install() { controler.run(); - Assert.assertEquals("All bicycle users should use the longest but fastest route where the bicycle infrastructur speed factor is set to 1.0", 3, linkHandler.getLinkId2demand().get(Id.createLinkId("2")), MatsimTestUtils.EPSILON); - Assert.assertEquals("Only the car user should use the shortest route", 1, linkHandler.getLinkId2demand().get(Id.createLinkId("6")), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, linkHandler.getLinkId2demand().get(Id.createLinkId("2")), MatsimTestUtils.EPSILON, "All bicycle users should use the longest but fastest route where the bicycle infrastructur speed factor is set to 1.0"); + Assertions.assertEquals(1, linkHandler.getLinkId2demand().get(Id.createLinkId("6")), MatsimTestUtils.EPSILON, "Only the car user should use the shortest route"); - Assert.assertEquals("Wrong travel time (bicycle user)", 1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(0), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time (bicycle user)", 1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(1), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time (bicycle user)", 1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(0), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); + Assertions.assertEquals(1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(1), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); + Assertions.assertEquals(1.0 + Math.ceil( 13000 / (25.0 /3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("2")).get(2), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); - Assert.assertEquals("Wrong travel time (car user)", Math.ceil( 10000 / (13.88) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(0), MatsimTestUtils.EPSILON); + Assertions.assertEquals(Math.ceil( 10000 / (13.88) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(0), MatsimTestUtils.EPSILON, "Wrong travel time (car user)"); } @@ -615,11 +622,11 @@ void testInfrastructureSpeedFactorDistanceMoreRelevantThanTravelTime() { controler.run(); - Assert.assertEquals("All bicycle users should use the shortest route even though the bicycle infrastructur speed factor is set to 0.1", 4, linkHandler.getLinkId2demand().get(Id.createLinkId("6")), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time (car user)", Math.ceil(10000 / 13.88 ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(0), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time (bicycle user)", Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(1), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time (bicycle user)", Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(2), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time (bicycle user)", Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(3), MatsimTestUtils.EPSILON); + Assertions.assertEquals(4, linkHandler.getLinkId2demand().get(Id.createLinkId("6")), MatsimTestUtils.EPSILON, "All bicycle users should use the shortest route even though the bicycle infrastructur speed factor is set to 0.1"); + Assertions.assertEquals(Math.ceil(10000 / 13.88 ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(0), MatsimTestUtils.EPSILON, "Wrong travel time (car user)"); + Assertions.assertEquals(Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(1), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); + Assertions.assertEquals(Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(2), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); + Assertions.assertEquals(Math.ceil( 10000 / (25. * 0.1 / 3.6) ), linkHandler.getLinkId2travelTimes().get(Id.createLinkId("6")).get(3), MatsimTestUtils.EPSILON, "Wrong travel time (bicycle user)"); } private Config createConfig( int lastIteration ){ diff --git a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java index 85c1d6f6e88..848b371c711 100644 --- a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java +++ b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java @@ -23,7 +23,7 @@ import cadyts.measurements.SingleLinkMeasurement; import cadyts.utilities.io.tabularFileParser.TabularFileParser; import cadyts.utilities.misc.DynamicData; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -141,14 +141,14 @@ public PlanStrategy get() { CadytsContext context = injector.getInstance(CadytsContext.class); //test calibration settings - Assert.assertEquals(true, context.getCalibrator().getBruteForce()); - Assert.assertEquals(false, context.getCalibrator().getCenterRegression()); - Assert.assertEquals(Integer.MAX_VALUE, context.getCalibrator().getFreezeIteration()); - Assert.assertEquals(8.0, context.getCalibrator().getMinStddev(SingleLinkMeasurement.TYPE.FLOW_VEH_H), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, context.getCalibrator().getPreparatoryIterations()); - Assert.assertEquals(0.95, context.getCalibrator().getRegressionInertia(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1.0, context.getCalibrator().getVarianceScale(), MatsimTestUtils.EPSILON); - Assert.assertEquals(3600.0, context.getCalibrator().getTimeBinSize_s(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(true, context.getCalibrator().getBruteForce()); + Assertions.assertEquals(false, context.getCalibrator().getCenterRegression()); + Assertions.assertEquals(Integer.MAX_VALUE, context.getCalibrator().getFreezeIteration()); + Assertions.assertEquals(8.0, context.getCalibrator().getMinStddev(SingleLinkMeasurement.TYPE.FLOW_VEH_H), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, context.getCalibrator().getPreparatoryIterations()); + Assertions.assertEquals(0.95, context.getCalibrator().getRegressionInertia(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1.0, context.getCalibrator().getVarianceScale(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3600.0, context.getCalibrator().getTimeBinSize_s(), MatsimTestUtils.EPSILON); } @@ -212,26 +212,26 @@ public ScoringFunction createNewScoringFunction(Person person) { //scenario data test Scenario scenario = injector.getInstance(Scenario.class); - Assert.assertEquals("Different number of links in network.", scenario.getNetwork().getLinks().size() , 23 ); - Assert.assertEquals("Different number of nodes in network.", scenario.getNetwork().getNodes().size() , 15 ); + Assertions.assertEquals(scenario.getNetwork().getLinks().size() , 23, "Different number of links in network." ); + Assertions.assertEquals(scenario.getNetwork().getNodes().size() , 15, "Different number of nodes in network." ); - Assert.assertNotNull("Population is null.", scenario.getPopulation()); + Assertions.assertNotNull(scenario.getPopulation(), "Population is null."); - Assert.assertEquals("Num. of persons in population is wrong.", scenario.getPopulation().getPersons().size(), 5); - Assert.assertEquals("Scale factor is wrong.", scenario.getConfig().counts().getCountsScaleFactor(), 1.0, MatsimTestUtils.EPSILON); + Assertions.assertEquals(scenario.getPopulation().getPersons().size(), 5, "Num. of persons in population is wrong."); + Assertions.assertEquals(scenario.getConfig().counts().getCountsScaleFactor(), 1.0, MatsimTestUtils.EPSILON, "Scale factor is wrong."); //counts - Assert.assertEquals("Count file is wrong.", scenario.getConfig().counts().getCountsFileName(), inputDir + "counts5.xml"); + Assertions.assertEquals(scenario.getConfig().counts().getCountsFileName(), inputDir + "counts5.xml", "Count file is wrong."); Counts occupCounts = new Counts<>(); new MatsimCountsReader(occupCounts).readFile(scenario.getConfig().counts().getCountsFileName()); Count count = occupCounts.getCount(Id.create(19, Link.class)); - Assert.assertEquals("Occupancy counts description is wrong", occupCounts.getDescription(), "counts values for equil net"); - Assert.assertEquals("CsId is wrong.", count.getCsLabel() , "link_19"); - Assert.assertEquals("Volume of hour 6 is wrong", count.getVolume(7).getValue(), 5.0 , MatsimTestUtils.EPSILON); - Assert.assertEquals("Max count volume is wrong.", count.getMaxVolume().getValue(), 5.0 , MatsimTestUtils.EPSILON); + Assertions.assertEquals(occupCounts.getDescription(), "counts values for equil net", "Occupancy counts description is wrong"); + Assertions.assertEquals(count.getCsLabel() , "link_19", "CsId is wrong."); + Assertions.assertEquals(count.getVolume(7).getValue(), 5.0 , MatsimTestUtils.EPSILON, "Volume of hour 6 is wrong"); + Assertions.assertEquals(count.getMaxVolume().getValue(), 5.0 , MatsimTestUtils.EPSILON, "Max count volume is wrong."); String outCounts = outputDir + "ITERS/it." + lastIteration + "/" + lastIteration + ".countscompare.txt"; AdHocCountsReaderCar reader = new AdHocCountsReaderCar(outCounts); @@ -240,29 +240,29 @@ public ScoringFunction createNewScoringFunction(Person person) { { double[] simValues = reader.getSimulatedValues( locId11 ); double[] realValues = reader.getRealValues( locId11 ); - Assert.assertEquals( "Volume of hour 6 is wrong", 0.0, simValues[6], MatsimTestUtils.EPSILON ); - Assert.assertEquals( "Volume of hour 6 is wrong", 0.0, realValues[6], MatsimTestUtils.EPSILON ); + Assertions.assertEquals( 0.0, simValues[6], MatsimTestUtils.EPSILON, "Volume of hour 6 is wrong" ); + Assertions.assertEquals( 0.0, realValues[6], MatsimTestUtils.EPSILON, "Volume of hour 6 is wrong" ); } { Id locId12 = Id.create( "12", Link.class ); double[] simValues = reader.getSimulatedValues( locId12 ); double[] realValues = reader.getRealValues( locId12 ); - Assert.assertEquals( "Volume of hour 6 is wrong", 0.0, simValues[6], MatsimTestUtils.EPSILON ); - Assert.assertEquals( "Volume of hour 6 is wrong", 0.0, realValues[6], MatsimTestUtils.EPSILON ); + Assertions.assertEquals( 0.0, simValues[6], MatsimTestUtils.EPSILON, "Volume of hour 6 is wrong" ); + Assertions.assertEquals( 0.0, realValues[6], MatsimTestUtils.EPSILON, "Volume of hour 6 is wrong" ); } Id locId19 = Id.create( "19", Link.class ); { double[] simValues = reader.getSimulatedValues( locId19 ); double[] realValues = reader.getRealValues( locId19 ); - Assert.assertEquals( "Volume of hour 6 is wrong", 5.0, simValues[6], MatsimTestUtils.EPSILON ); - Assert.assertEquals( "Volume of hour 6 is wrong", 5.0, realValues[6], MatsimTestUtils.EPSILON ); + Assertions.assertEquals( 5.0, simValues[6], MatsimTestUtils.EPSILON, "Volume of hour 6 is wrong" ); + Assertions.assertEquals( 5.0, realValues[6], MatsimTestUtils.EPSILON, "Volume of hour 6 is wrong" ); } { Id locId21 = Id.create( "21", Link.class ); double[] simValues = reader.getSimulatedValues( locId21 ); double[] realValues = reader.getRealValues( locId21 ); - Assert.assertEquals( "Volume of hour 6 is wrong", 5.0, simValues[6], MatsimTestUtils.EPSILON ); - Assert.assertEquals( "Volume of hour 6 is wrong", 5.0, realValues[6], MatsimTestUtils.EPSILON ); + Assertions.assertEquals( 5.0, simValues[6], MatsimTestUtils.EPSILON, "Volume of hour 6 is wrong" ); + Assertions.assertEquals( 5.0, realValues[6], MatsimTestUtils.EPSILON, "Volume of hour 6 is wrong" ); } // test calibration statistics String testCalibStatPath = outputDir + "calibration-stats.txt"; @@ -273,7 +273,7 @@ public ScoringFunction createNewScoringFunction(Person person) { // Assert.assertEquals("different Count_ll", "-0.046875", outStatData.getCount_ll() ); // Assert.assertEquals("different Count_ll_pred_err", "0.01836234363152515" , outStatData.getCount_ll_pred_err() ); // Assert.assertEquals("different Link_lambda_avg", "-2.2604922388914356E-10", outStatData.getLink_lambda_avg() ); - Assert.assertEquals("different Link_lambda_avg", "3.2261421242498865E-5", outStatData.getLink_lambda_avg() ); + Assertions.assertEquals("3.2261421242498865E-5", outStatData.getLink_lambda_avg(), "different Link_lambda_avg" ); // Assert.assertEquals("different Link_lambda_max", "0.0" , outStatData.getLink_lambda_max() ); // Assert.assertEquals("different Link_lambda_min", "-7.233575164452593E-9", outStatData.getLink_lambda_min() ); // Assert.assertEquals("different Link_lambda_stddev", "1.261054219517188E-9", outStatData.getLink_lambda_stddev()); @@ -283,7 +283,7 @@ public ScoringFunction createNewScoringFunction(Person person) { // Assert.assertEquals("different Plan_lambda_min", "-7.233575164452593E-9" , outStatData.getPlan_lambda_min() ); // Assert.assertEquals("different Plan_lambda_stddev", "0.0" , outStatData.getPlan_lambda_stddev()); // Assert.assertEquals("different Total_ll", "-0.046875", outStatData.getTotal_ll() ); - Assert.assertEquals("different Total_ll", "0.0", outStatData.getTotal_ll() ); + Assertions.assertEquals("0.0", outStatData.getTotal_ll(), "different Total_ll" ); //test link offsets final Network network = scenario.getNetwork(); @@ -304,10 +304,10 @@ public ScoringFunction createNewScoringFunction(Person person) { isZero = (Math.abs(linkOffsets.getBinValue(link19 , binIndex) - 0.0) < MatsimTestUtils.EPSILON); }while (isZero && binIndex<86400); - Assert.assertEquals("Wrong bin index for first link offset", 6, binIndex); + Assertions.assertEquals(6, binIndex, "Wrong bin index for first link offset"); - Assert.assertEquals("Wrong link offset of link 11", 0.0, linkOffsets.getBinValue(link11 , binIndex), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong link offset of link 19", 0.0014707121641471912, linkOffsets.getBinValue(link19 , binIndex), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, linkOffsets.getBinValue(link11 , binIndex), MatsimTestUtils.EPSILON, "Wrong link offset of link 11"); + Assertions.assertEquals(0.0014707121641471912, linkOffsets.getBinValue(link19 , binIndex), MatsimTestUtils.EPSILON, "Wrong link offset of link 19"); } diff --git a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarWithPtScenarioIT.java b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarWithPtScenarioIT.java index 08ccf453ef9..9ab184be6b4 100644 --- a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarWithPtScenarioIT.java +++ b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarWithPtScenarioIT.java @@ -1,10 +1,10 @@ package org.matsim.contrib.cadyts.car; -import static org.junit.Assert.assertTrue; - import java.util.concurrent.atomic.AtomicInteger; import org.junit.Ignore; + +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -44,8 +44,8 @@ void testCadytsWithPtVehicles() { } }); controler.run(); - assertTrue("There's at least one bus on the test link", bussesSeenOnLink.get() > 0); - assertTrue("This test runs to the end, meaning cadyts doesn't throw an exception with pt", true); + assertTrue(bussesSeenOnLink.get() > 0, "There's at least one bus on the test link"); + assertTrue(true, "This test runs to the end, meaning cadyts doesn't throw an exception with pt"); } } diff --git a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/utils/CalibrationStatReaderTest.java b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/utils/CalibrationStatReaderTest.java index 1da4d65881a..98cc6caaebe 100644 --- a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/utils/CalibrationStatReaderTest.java +++ b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/utils/CalibrationStatReaderTest.java @@ -20,8 +20,7 @@ package org.matsim.contrib.cadyts.utils; import java.io.IOException; - -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -40,17 +39,17 @@ void testReader() throws IOException { CalibrationStatReader calibrationStatReader = new CalibrationStatReader(); tabularFileParser.parse(calibStatFile, calibrationStatReader); CalibrationStatReader.StatisticsData statData6= calibrationStatReader.getCalStatMap().get(Integer.valueOf(6)); - Assert.assertEquals("different Count_ll", "-1.546875", statData6.getCount_ll() ); - Assert.assertEquals("different Count_ll_pred_err", "9.917082938182276E-8" , statData6.getCount_ll_pred_err() ); - Assert.assertEquals("different Link_lambda_avg", "0.0013507168476099964", statData6.getLink_lambda_avg() ); - Assert.assertEquals("different Link_lambda_max", "0.031434867572002166" , statData6.getLink_lambda_max() ); - Assert.assertEquals("different Link_lambda_min", "0.0", statData6.getLink_lambda_min() ); - Assert.assertEquals("different Link_lambda_stddev", "0.0058320747961925256" , statData6.getLink_lambda_stddev()); - Assert.assertEquals("different P2p_ll", "--" , statData6.getP2p_ll()); - Assert.assertEquals("different Plan_lambda_avg", "0.04322293912351989", statData6.getPlan_lambda_avg() ); - Assert.assertEquals("different Plan_lambda_max", "0.04715229919344063" , statData6.getPlan_lambda_max() ); - Assert.assertEquals("different Plan_lambda_min", "0.03929357905359915" , statData6.getPlan_lambda_min() ); - Assert.assertEquals("different Plan_lambda_stddev", "0.004200662608832472" , statData6.getPlan_lambda_stddev()); - Assert.assertEquals("different Total_ll", "-1.546875", statData6.getTotal_ll() ); + Assertions.assertEquals("-1.546875", statData6.getCount_ll(), "different Count_ll" ); + Assertions.assertEquals("9.917082938182276E-8" , statData6.getCount_ll_pred_err(), "different Count_ll_pred_err" ); + Assertions.assertEquals("0.0013507168476099964", statData6.getLink_lambda_avg(), "different Link_lambda_avg" ); + Assertions.assertEquals("0.031434867572002166" , statData6.getLink_lambda_max(), "different Link_lambda_max" ); + Assertions.assertEquals("0.0", statData6.getLink_lambda_min(), "different Link_lambda_min" ); + Assertions.assertEquals("0.0058320747961925256" , statData6.getLink_lambda_stddev(), "different Link_lambda_stddev"); + Assertions.assertEquals("--" , statData6.getP2p_ll(), "different P2p_ll"); + Assertions.assertEquals("0.04322293912351989", statData6.getPlan_lambda_avg(), "different Plan_lambda_avg" ); + Assertions.assertEquals("0.04715229919344063" , statData6.getPlan_lambda_max(), "different Plan_lambda_max" ); + Assertions.assertEquals("0.03929357905359915" , statData6.getPlan_lambda_min(), "different Plan_lambda_min" ); + Assertions.assertEquals("0.004200662608832472" , statData6.getPlan_lambda_stddev(), "different Plan_lambda_stddev"); + Assertions.assertEquals("-1.546875", statData6.getTotal_ll(), "different Total_ll" ); } } diff --git a/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java b/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java index 4f862921469..045303dc9c2 100644 --- a/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java +++ b/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java @@ -25,7 +25,7 @@ import com.google.inject.Inject; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.analysis.LegHistogram; @@ -162,63 +162,63 @@ void testOutput(int iteration) { if (TransportMode.walk.equals(legMode)) { // walk is used for access+egress to car // -> number of walk legs for access+egress equals twice the number of car legs = 44 - Assert.assertEquals(44, nOfModeLegs); + Assertions.assertEquals(44, nOfModeLegs); } else if ("oneway_vehicle".equals(legMode)) { - Assert.assertEquals(0, nOfModeLegs); + Assertions.assertEquals(0, nOfModeLegs); } else if (TransportMode.car.equals(legMode)) { - Assert.assertEquals(22, nOfModeLegs); + Assertions.assertEquals(22, nOfModeLegs); } else if ("egress_walk_ow".equals(legMode)) { - Assert.assertEquals(0, nOfModeLegs); + Assertions.assertEquals(0, nOfModeLegs); } else if ("access_walk_ow".equals(legMode)) { - Assert.assertEquals(0, nOfModeLegs); + Assertions.assertEquals(0, nOfModeLegs); } } else if (iteration == 10) { if (TransportMode.walk.equals(legMode)) { - Assert.assertEquals(2, nOfModeLegs); + Assertions.assertEquals(2, nOfModeLegs); } else if ("bike".equals(legMode)) { - Assert.assertEquals(2, nOfModeLegs); + Assertions.assertEquals(2, nOfModeLegs); } else if (TransportMode.car.equals(legMode)) { - Assert.assertEquals(0, nOfModeLegs); + Assertions.assertEquals(0, nOfModeLegs); } else if ("twoway_vehicle".equals(legMode)) { - Assert.assertEquals(6, nOfModeLegs); + Assertions.assertEquals(6, nOfModeLegs); } else if ("oneway_vehicle".equals(legMode)) { - Assert.assertEquals(0, nOfModeLegs); + Assertions.assertEquals(0, nOfModeLegs); } else if ("egress_walk_ow".equals(legMode)) { - Assert.assertEquals(0, nOfModeLegs); + Assertions.assertEquals(0, nOfModeLegs); } else if ("access_walk_ow".equals(legMode)) { - Assert.assertEquals(0, nOfModeLegs); + Assertions.assertEquals(0, nOfModeLegs); } else if ("egress_walk_tw".equals(legMode)) { - Assert.assertEquals(3, nOfModeLegs); + Assertions.assertEquals(3, nOfModeLegs); } else if ("access_walk_tw".equals(legMode)) { - Assert.assertEquals(3, nOfModeLegs); + Assertions.assertEquals(3, nOfModeLegs); } else if ("egress_walk_ff".equals(legMode)) { - Assert.assertEquals(2, nOfModeLegs); + Assertions.assertEquals(2, nOfModeLegs); } else if ("access_walk_ff".equals(legMode)) { - Assert.assertEquals(0, nOfModeLegs); + Assertions.assertEquals(0, nOfModeLegs); } } else if (iteration == 20) { if (TransportMode.walk.equals(legMode)) { - Assert.assertEquals(5, nOfModeLegs); + Assertions.assertEquals(5, nOfModeLegs); } else if ("bike".equals(legMode)) { - Assert.assertEquals(0, nOfModeLegs); + Assertions.assertEquals(0, nOfModeLegs); } else if ("twoway_vehicle".equals(legMode)) { - Assert.assertEquals(6, nOfModeLegs); + Assertions.assertEquals(6, nOfModeLegs); } else if ("freefloating_vehicle".equals(legMode)) { - Assert.assertEquals(0, nOfModeLegs); + Assertions.assertEquals(0, nOfModeLegs); } else if ("egress_walk_tw".equals(legMode)) { - Assert.assertEquals(3, nOfModeLegs); + Assertions.assertEquals(3, nOfModeLegs); } else if ("access_walk_tw".equals(legMode)) { - Assert.assertEquals(3, nOfModeLegs); + Assertions.assertEquals(3, nOfModeLegs); } else if ("access_walk_ff".equals(legMode)) { - Assert.assertEquals(0, nOfModeLegs); + Assertions.assertEquals(0, nOfModeLegs); } else if ("egress_walk_ff".equals(legMode)) { - Assert.assertEquals(0, nOfModeLegs); + Assertions.assertEquals(0, nOfModeLegs); } } diff --git a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/ChangeCommercialJobOperatorTest.java b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/ChangeCommercialJobOperatorTest.java index 6fb30f6b0b7..5dad7e11991 100644 --- a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/ChangeCommercialJobOperatorTest.java +++ b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/ChangeCommercialJobOperatorTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.commercialTrafficApplications.jointDemand; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -31,18 +31,18 @@ void getPlanAlgoInstance() { Activity work = (Activity) testPlan.getPlanElements().get(2); Id carrierId = JointDemandUtils.getCurrentlySelectedCarrierForJob(work, 1); - Assert.assertEquals("the person should expect a pizza", "pizza", JointDemandUtils.getCarrierMarket(carriers.getCarriers().get(carrierId))); - Assert.assertTrue("the person should expect a pizza from the italian place", carrierId.toString().contains("italian")); + Assertions.assertEquals("pizza", JointDemandUtils.getCarrierMarket(carriers.getCarriers().get(carrierId)), "the person should expect a pizza"); + Assertions.assertTrue(carrierId.toString().contains("italian"), "the person should expect a pizza from the italian place"); changeCommercialJobOperator.getPlanAlgoInstance().run(testPlan); carrierId = JointDemandUtils.getCurrentlySelectedCarrierForJob(work, 1); - Assert.assertTrue("the person should expect a pizza from the american place", carrierId.toString().contains("american")); + Assertions.assertTrue(carrierId.toString().contains("american"), "the person should expect a pizza from the american place"); changeCommercialJobOperator.getPlanAlgoInstance().run(testPlan); carrierId = JointDemandUtils.getCurrentlySelectedCarrierForJob(work, 1); - Assert.assertTrue("the person should expect a pizza from the italian place", carrierId.toString().contains("italian")); + Assertions.assertTrue(carrierId.toString().contains("italian"), "the person should expect a pizza from the italian place"); } diff --git a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialServiceScoreTest.java b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialServiceScoreTest.java index 051e97829e9..d2ce82e986d 100644 --- a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialServiceScoreTest.java +++ b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialServiceScoreTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.commercialTrafficApplications.jointDemand; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.contrib.commercialTrafficApplications.jointDemand.DefaultCommercialServiceScore; @@ -10,10 +10,10 @@ public class DefaultCommercialServiceScoreTest { void calcScore() { DefaultCommercialServiceScore serviceScore = new DefaultCommercialServiceScore(6, -6, 1800); - Assert.assertEquals(serviceScore.calcScore(0), 6., 0.001); - Assert.assertEquals(serviceScore.calcScore(1800), 0, 0.001); - Assert.assertEquals(serviceScore.calcScore(3600), -6., 0.001); - Assert.assertEquals(serviceScore.calcScore(7200), -6., 0.001); + Assertions.assertEquals(serviceScore.calcScore(0), 6., 0.001); + Assertions.assertEquals(serviceScore.calcScore(1800), 0, 0.001); + Assertions.assertEquals(serviceScore.calcScore(3600), -6., 0.001); + Assertions.assertEquals(serviceScore.calcScore(7200), -6., 0.001); } } \ No newline at end of file diff --git a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/IsTheRightCustomerScoredTest.java b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/IsTheRightCustomerScoredTest.java index f71e9a3a3ed..8e083962c5d 100644 --- a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/IsTheRightCustomerScoredTest.java +++ b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/IsTheRightCustomerScoredTest.java @@ -18,8 +18,8 @@ package org.matsim.contrib.commercialTrafficApplications.jointDemand; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -113,14 +113,14 @@ void testIfTheRightPersonIsScoredForReceivingAJob() { .map(carrierService -> carrierService.getId()) .findFirst().orElseThrow(() -> new RuntimeException("no service activity found in scheduledTours")); - Assert.assertEquals("the person that is delivered pizza should be customerOrderingForParty", partyPizzaPlan.getPerson().getId().toString(), serviceActivity.toString().split("_")[0]); + Assertions.assertEquals(partyPizzaPlan.getPerson().getId().toString(), serviceActivity.toString().split("_")[0], "the person that is delivered pizza should be customerOrderingForParty"); //compare scores - Assert.assertTrue("the plan of the customer receiving a job should get a higher score than the plan of the non customer ", partyPizzaPlan.getScore() > nonCustomerPlan.getScore()); - Assert.assertTrue("the plan of the customer receiving a job should get a higher score than the plan of the customer not receiving one ", partyPizzaPlan.getScore() > lonelyPizzaPlan.getScore()); - Assert.assertTrue("the difference of receiving a job in time and not receiving it at all should be the maxJobScore=" + MAX_JOB_SCORE + " as job is performed in time", partyPizzaPlan.getScore() - lonelyPizzaPlan.getScore() == MAX_JOB_SCORE); - Assert.assertEquals("not receiving a job at all should be scored with zero", lonelyPizzaPlan.getScore(), 0.0, MatsimTestUtils.EPSILON); - Assert.assertTrue(lonelyPizzaPlan.getScore() - nonCustomerPlan.getScore() == 0); + Assertions.assertTrue(partyPizzaPlan.getScore() > nonCustomerPlan.getScore(), "the plan of the customer receiving a job should get a higher score than the plan of the non customer "); + Assertions.assertTrue(partyPizzaPlan.getScore() > lonelyPizzaPlan.getScore(), "the plan of the customer receiving a job should get a higher score than the plan of the customer not receiving one "); + Assertions.assertTrue(partyPizzaPlan.getScore() - lonelyPizzaPlan.getScore() == MAX_JOB_SCORE, "the difference of receiving a job in time and not receiving it at all should be the maxJobScore=" + MAX_JOB_SCORE + " as job is performed in time"); + Assertions.assertEquals(lonelyPizzaPlan.getScore(), 0.0, MatsimTestUtils.EPSILON, "not receiving a job at all should be scored with zero"); + Assertions.assertTrue(lonelyPizzaPlan.getScore() - nonCustomerPlan.getScore() == 0); } diff --git a/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest66IT.java b/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest66IT.java index 09772d843d3..e6a0711851a 100644 --- a/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest66IT.java +++ b/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest66IT.java @@ -20,14 +20,14 @@ package org.matsim.integration.always; -import static org.junit.Assert.assertEquals; - import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import jakarta.inject.Inject; + +import static org.junit.jupiter.api.Assertions.assertEquals; import jakarta.inject.Provider; import org.apache.logging.log4j.LogManager; diff --git a/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest6IT.java b/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest6IT.java index da2037aa8cd..49ec89733a1 100644 --- a/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest6IT.java +++ b/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest6IT.java @@ -20,14 +20,14 @@ package org.matsim.integration.always; -import static org.junit.Assert.assertEquals; - import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import jakarta.inject.Inject; + +import static org.junit.jupiter.api.Assertions.assertEquals; import jakarta.inject.Provider; import org.apache.logging.log4j.LogManager; diff --git a/contribs/decongestion/src/test/java/org/matsim/contrib/decongestion/DecongestionPricingTestIT.java b/contribs/decongestion/src/test/java/org/matsim/contrib/decongestion/DecongestionPricingTestIT.java index 7ff2403f49b..2562177bd77 100644 --- a/contribs/decongestion/src/test/java/org/matsim/contrib/decongestion/DecongestionPricingTestIT.java +++ b/contribs/decongestion/src/test/java/org/matsim/contrib/decongestion/DecongestionPricingTestIT.java @@ -22,7 +22,7 @@ */ package org.matsim.contrib.decongestion; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.analysis.ScoreStatsControlerListener.ScoreItem; @@ -130,19 +130,19 @@ public void install() { double tt1 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 63, null, null); double tt2 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 15. * 60, null, null); - Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt0, MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 150.5, tt1, MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt2, MatsimTestUtils.EPSILON); + Assertions.assertEquals(100.0, tt0, MatsimTestUtils.EPSILON, "Wrong travel time. The run output seems to have changed."); + Assertions.assertEquals(150.5, tt1, MatsimTestUtils.EPSILON, "Wrong travel time. The run output seems to have changed."); + Assertions.assertEquals(100.0, tt2, MatsimTestUtils.EPSILON, "Wrong travel time. The run output seems to have changed."); final int index = config.controller().getLastIteration() - config.controller().getFirstIteration(); double avgScore = controler.getScoreStats().getScoreHistory().get( ScoreItem.executed ).get(index); - Assert.assertEquals("Wrong average executed score. The tolls seem to have changed.", -33.940316666666666, avgScore, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-33.940316666666666, avgScore, MatsimTestUtils.EPSILON, "Wrong average executed score. The tolls seem to have changed."); System.out.println(info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().toString()); System.out.println(info.getlinkInfos().get(Id.createLinkId("link12")).getTime2avgDelay().toString()); - Assert.assertEquals("Wrong average delay (capacity is set in a way that one of the two agents has to wait 101 sec. Thus the average is 50.5", 50.5, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2avgDelay().get(84), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong toll.", 50.5 * 0.0123, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(84), MatsimTestUtils.EPSILON); + Assertions.assertEquals(50.5, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2avgDelay().get(84), MatsimTestUtils.EPSILON, "Wrong average delay (capacity is set in a way that one of the two agents has to wait 101 sec. Thus the average is 50.5"); + Assertions.assertEquals(50.5 * 0.0123, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(84), MatsimTestUtils.EPSILON, "Wrong toll."); } @@ -197,13 +197,13 @@ public void install() { double tt1 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 63, null, null); double tt2 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 15. * 60, null, null); - Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt0, MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 150.5, tt1, MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt2, MatsimTestUtils.EPSILON); + Assertions.assertEquals(100.0, tt0, MatsimTestUtils.EPSILON, "Wrong travel time. The run output seems to have changed."); + Assertions.assertEquals(150.5, tt1, MatsimTestUtils.EPSILON, "Wrong travel time. The run output seems to have changed."); + Assertions.assertEquals(100.0, tt2, MatsimTestUtils.EPSILON, "Wrong travel time. The run output seems to have changed."); final int index = config.controller().getLastIteration() - config.controller().getFirstIteration(); double avgScore = controler.getScoreStats().getScoreHistory().get( ScoreItem.executed ).get(index); - Assert.assertEquals("Wrong average executed score. The tolls seem to have changed.", -33.940316666666666, avgScore, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-33.940316666666666, avgScore, MatsimTestUtils.EPSILON, "Wrong average executed score. The tolls seem to have changed."); } /** @@ -279,19 +279,19 @@ public void install() { double tt1 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 63, null, null); double tt2 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 15. * 60, null, null); - Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt0, MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 150.5, tt1, MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt2, MatsimTestUtils.EPSILON); + Assertions.assertEquals(100.0, tt0, MatsimTestUtils.EPSILON, "Wrong travel time. The run output seems to have changed."); + Assertions.assertEquals(150.5, tt1, MatsimTestUtils.EPSILON, "Wrong travel time. The run output seems to have changed."); + Assertions.assertEquals(100.0, tt2, MatsimTestUtils.EPSILON, "Wrong travel time. The run output seems to have changed."); final int index = config.controller().getLastIteration() - config.controller().getFirstIteration(); double avgScore = controler.getScoreStats().getScoreHistory().get( ScoreItem.executed ).get(index); - Assert.assertEquals("Wrong average executed score. The tolls seem to have changed.", -134.31916666666666, avgScore, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-134.31916666666666, avgScore, MatsimTestUtils.EPSILON, "Wrong average executed score. The tolls seem to have changed."); System.out.println(info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().toString()); System.out.println(info.getlinkInfos().get(Id.createLinkId("link12")).getTime2avgDelay().toString()); - Assert.assertEquals("Wrong average delay (capacity is set in a way that one of the two agents has to wait 101 sec. Thus the average is 50.5", 50.5, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2avgDelay().get(84), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong toll.", 50.5 * 2, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(84), MatsimTestUtils.EPSILON); + Assertions.assertEquals(50.5, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2avgDelay().get(84), MatsimTestUtils.EPSILON, "Wrong average delay (capacity is set in a way that one of the two agents has to wait 101 sec. Thus the average is 50.5"); + Assertions.assertEquals(50.5 * 2, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(84), MatsimTestUtils.EPSILON, "Wrong toll."); } /** @@ -345,13 +345,13 @@ public void install() { double tt1 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 63, null, null); double tt2 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 15. * 60, null, null); - Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt0, MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 150.5, tt1, MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt2, MatsimTestUtils.EPSILON); + Assertions.assertEquals(100.0, tt0, MatsimTestUtils.EPSILON, "Wrong travel time. The run output seems to have changed."); + Assertions.assertEquals(150.5, tt1, MatsimTestUtils.EPSILON, "Wrong travel time. The run output seems to have changed."); + Assertions.assertEquals(100.0, tt2, MatsimTestUtils.EPSILON, "Wrong travel time. The run output seems to have changed."); final int index = config.controller().getLastIteration() - config.controller().getFirstIteration(); double avgScore = controler.getScoreStats().getScoreHistory().get( ScoreItem.executed ).get(index); - Assert.assertEquals("Wrong average executed score. The tolls seem to have changed.", -134.31916666666666, avgScore, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-134.31916666666666, avgScore, MatsimTestUtils.EPSILON, "Wrong average executed score. The tolls seem to have changed."); } /** @@ -419,19 +419,19 @@ public void install() { double tt1 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 63, null, null); double tt2 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 15. * 60, null, null); - Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt0, MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 150.5, tt1, MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt2, MatsimTestUtils.EPSILON); + Assertions.assertEquals(100.0, tt0, MatsimTestUtils.EPSILON, "Wrong travel time. The run output seems to have changed."); + Assertions.assertEquals(150.5, tt1, MatsimTestUtils.EPSILON, "Wrong travel time. The run output seems to have changed."); + Assertions.assertEquals(100.0, tt2, MatsimTestUtils.EPSILON, "Wrong travel time. The run output seems to have changed."); final int index = config.controller().getLastIteration() - config.controller().getFirstIteration(); double avgScore = controler.getScoreStats().getScoreHistory().get( ScoreItem.executed ).get(index); - Assert.assertEquals("Wrong average executed score. The tolls seem to have changed.", -33.31916666666666, avgScore, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-33.31916666666666, avgScore, MatsimTestUtils.EPSILON, "Wrong average executed score. The tolls seem to have changed."); System.out.println(info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().toString()); System.out.println(info.getlinkInfos().get(Id.createLinkId("link12")).getTime2avgDelay().toString()); - Assert.assertEquals("Wrong average delay (capacity is set in a way that one of the two agents has to wait 101 sec. Thus the average is 50.5", 50.5, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2avgDelay().get(84), MatsimTestUtils.EPSILON); - Assert.assertNull("Wrong toll.", info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(84)); + Assertions.assertEquals(50.5, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2avgDelay().get(84), MatsimTestUtils.EPSILON, "Wrong average delay (capacity is set in a way that one of the two agents has to wait 101 sec. Thus the average is 50.5"); + Assertions.assertNull(info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(84), "Wrong toll."); } @@ -489,11 +489,11 @@ public void install() { final int index = config.controller().getLastIteration() - config.controller().getFirstIteration(); double avgScore = controler.getScoreStats().getScoreHistory().get( ScoreItem.executed ).get(index) ; - Assert.assertEquals("Wrong average executed score. The run output seems to have changed.", -12036.177448472225, avgScore, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-12036.177448472225, avgScore, MatsimTestUtils.EPSILON, "Wrong average executed score. The run output seems to have changed."); System.out.println(info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().toString()); - Assert.assertEquals("Wrong toll in time bin 61.", 9.197000000000003, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(61), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong toll in time bin 73.", 12.963999999999984, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(73), MatsimTestUtils.EPSILON); + Assertions.assertEquals(9.197000000000003, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(61), MatsimTestUtils.EPSILON, "Wrong toll in time bin 61."); + Assertions.assertEquals(12.963999999999984, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(73), MatsimTestUtils.EPSILON, "Wrong toll in time bin 73."); } /** @@ -551,11 +551,11 @@ public void install() { final int index = config.controller().getLastIteration() - config.controller().getFirstIteration(); double avgScore = controler.getScoreStats().getScoreHistory().get( ScoreItem.executed ).get( index ) ; - Assert.assertEquals("Wrong average executed score. The run output seems to have changed.", -55.215645833333184, avgScore, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-55.215645833333184, avgScore, MatsimTestUtils.EPSILON, "Wrong average executed score. The run output seems to have changed."); System.out.println(info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().toString()); - Assert.assertEquals("Wrong toll in time bin 61.", 13., info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(61), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong toll in time bin 73.", 13., info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(73), MatsimTestUtils.EPSILON); + Assertions.assertEquals(13., info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(61), MatsimTestUtils.EPSILON, "Wrong toll in time bin 61."); + Assertions.assertEquals(13., info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(73), MatsimTestUtils.EPSILON, "Wrong toll in time bin 73."); } } diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/SubtourModeChoiceReplacementTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/SubtourModeChoiceReplacementTest.java index b9cab362620..416162e725e 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/SubtourModeChoiceReplacementTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/SubtourModeChoiceReplacementTest.java @@ -1,7 +1,5 @@ package org.matsim.contrib.discrete_mode_choice; -import static org.junit.Assert.assertEquals; - import java.util.Arrays; import java.util.Collections; import java.util.HashSet; @@ -10,6 +8,8 @@ import java.util.Set; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.matsim.api.core.v01.population.Plan; import org.matsim.contrib.discrete_mode_choice.test_utils.PlanBuilder; import org.matsim.contrib.discrete_mode_choice.test_utils.PlanTester; diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/constraints/VehicleTourConstraintTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/constraints/VehicleTourConstraintTest.java index a95458ffdf4..f5c0fd7ce92 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/constraints/VehicleTourConstraintTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/constraints/VehicleTourConstraintTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.discrete_mode_choice.components.constraints; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import java.util.Collection; diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/readers/ApolloTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/readers/ApolloTest.java index 3e396542e5f..c588e1864cf 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/readers/ApolloTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/readers/ApolloTest.java @@ -1,11 +1,11 @@ package org.matsim.contrib.discrete_mode_choice.components.readers; -import static org.junit.Assert.assertEquals; - import java.io.IOException; import java.net.URL; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.matsim.contribs.discrete_mode_choice.components.readers.ApolloParameterReader; import org.matsim.contribs.discrete_mode_choice.components.readers.ApolloParameters; diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/tour_finder/ActivityTourFinderTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/tour_finder/ActivityTourFinderTest.java index 8fd14c7f09a..483cfa96dfb 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/tour_finder/ActivityTourFinderTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/tour_finder/ActivityTourFinderTest.java @@ -1,12 +1,12 @@ package org.matsim.contrib.discrete_mode_choice.components.tour_finder; -import static org.junit.Assert.assertEquals; - import java.util.Arrays; import java.util.LinkedList; import java.util.List; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.matsim.api.core.v01.population.Plan; import org.matsim.contribs.discrete_mode_choice.components.tour_finder.ActivityTourFinder; import org.matsim.contribs.discrete_mode_choice.model.DiscreteModeChoiceTrip; diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/utils/ScheduleWaitingTimeEstimatorTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/utils/ScheduleWaitingTimeEstimatorTest.java index 2e69210fff1..f9c951bb195 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/utils/ScheduleWaitingTimeEstimatorTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/components/utils/ScheduleWaitingTimeEstimatorTest.java @@ -1,5 +1,7 @@ package org.matsim.contrib.discrete_mode_choice.components.utils; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -25,8 +27,6 @@ import java.util.LinkedList; import java.util.List; -import static org.junit.Assert.assertEquals; - public class ScheduleWaitingTimeEstimatorTest { @Test void testValidSingleCase() throws IOException { diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/examples/TestSiouxFalls.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/examples/TestSiouxFalls.java index 5a1edb6623e..299d69644dd 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/examples/TestSiouxFalls.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/examples/TestSiouxFalls.java @@ -1,12 +1,12 @@ package org.matsim.contrib.discrete_mode_choice.examples; -import static org.junit.Assert.assertEquals; - import java.net.URL; import java.util.HashMap; import java.util.Map; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.PersonArrivalEvent; import org.matsim.api.core.v01.events.handler.PersonArrivalEventHandler; diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/MaximumUtilityTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/MaximumUtilityTest.java index 31bff842634..b186857b40b 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/MaximumUtilityTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/MaximumUtilityTest.java @@ -1,13 +1,13 @@ package org.matsim.contrib.discrete_mode_choice.models; -import static org.junit.Assert.assertEquals; - import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Random; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.population.Activity; import org.matsim.contribs.discrete_mode_choice.model.DiscreteModeChoiceModel.FallbackBehaviour; diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/MultinomialLogitTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/MultinomialLogitTest.java index dbe32f1e8a3..fcee4f218af 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/MultinomialLogitTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/MultinomialLogitTest.java @@ -1,7 +1,5 @@ package org.matsim.contrib.discrete_mode_choice.models; -import static org.junit.Assert.assertEquals; - import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -10,6 +8,8 @@ import java.util.Random; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.population.Activity; import org.matsim.contribs.discrete_mode_choice.model.DiscreteModeChoiceModel.FallbackBehaviour; diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/NestedLogitTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/NestedLogitTest.java index 38e7b54df7d..b25de2aeb32 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/NestedLogitTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/NestedLogitTest.java @@ -1,7 +1,5 @@ package org.matsim.contrib.discrete_mode_choice.models; -import static org.junit.Assert.assertEquals; - import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -10,6 +8,8 @@ import java.util.Random; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.population.Activity; import org.matsim.contribs.discrete_mode_choice.model.DiscreteModeChoiceModel.FallbackBehaviour; diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/RandomUtilityTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/RandomUtilityTest.java index e69eae5ee23..8df0f2cf4ae 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/RandomUtilityTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/RandomUtilityTest.java @@ -1,7 +1,5 @@ package org.matsim.contrib.discrete_mode_choice.models; -import static org.junit.Assert.assertEquals; - import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -10,6 +8,8 @@ import java.util.Random; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.population.Activity; import org.matsim.contribs.discrete_mode_choice.components.estimators.UniformTripEstimator; diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/nested/NestCalculatorTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/nested/NestCalculatorTest.java index 5c344aabd51..d65e211943b 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/nested/NestCalculatorTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/models/nested/NestCalculatorTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.discrete_mode_choice.models.nested; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.matsim.contribs.discrete_mode_choice.model.DiscreteModeChoiceModel.NoFeasibleChoiceException; diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/modules/config/ConfigTest.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/modules/config/ConfigTest.java index 4090739bcd5..a516cf31ec3 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/modules/config/ConfigTest.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/modules/config/ConfigTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.discrete_mode_choice.modules.config; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.BufferedReader; import java.io.File; diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/replanning/TestDepartureTimes.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/replanning/TestDepartureTimes.java index c3e744e0880..69f766da8d4 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/replanning/TestDepartureTimes.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/replanning/TestDepartureTimes.java @@ -1,7 +1,5 @@ package org.matsim.contrib.discrete_mode_choice.replanning; -import static org.junit.Assert.assertEquals; - import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; @@ -9,6 +7,8 @@ import java.util.Random; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.matsim.api.core.v01.population.Leg; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtWithExtensionsConfigGroupTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtWithExtensionsConfigGroupTest.java index 8ca27490ae3..10b53461d07 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtWithExtensionsConfigGroupTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtWithExtensionsConfigGroupTest.java @@ -24,7 +24,7 @@ import java.nio.file.Path; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.io.TempDir; @@ -85,10 +85,10 @@ void loadConfigGroupTest() throws IOException { Config config = ConfigUtils.createConfig(); ConfigUtils.loadConfig(config, configFile.toString()); DrtWithExtensionsConfigGroup loadedCfg = ConfigUtils.addOrGetModule(config, DrtWithExtensionsConfigGroup.class); - Assert.assertTrue(loadedCfg.getDrtCompanionParams().isPresent()); - Assert.assertTrue(loadedCfg.getDrtCompanionParams().get().getDrtCompanionSamplingWeights().get(0).equals(WEIGHT_1)); - Assert.assertTrue(loadedCfg.getDrtCompanionParams().get().getDrtCompanionSamplingWeights().get(1).equals(WEIGHT_2)); - Assert.assertTrue(loadedCfg.getDrtCompanionParams().get().getDrtCompanionSamplingWeights().get(2).equals(WEIGHT_3)); + Assertions.assertTrue(loadedCfg.getDrtCompanionParams().isPresent()); + Assertions.assertTrue(loadedCfg.getDrtCompanionParams().get().getDrtCompanionSamplingWeights().get(0).equals(WEIGHT_1)); + Assertions.assertTrue(loadedCfg.getDrtCompanionParams().get().getDrtCompanionSamplingWeights().get(1).equals(WEIGHT_2)); + Assertions.assertTrue(loadedCfg.getDrtCompanionParams().get().getDrtCompanionSamplingWeights().get(2).equals(WEIGHT_3)); } } diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/edrt/run/RunEDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/edrt/run/RunEDrtScenarioIT.java index 370304d1bdb..051867cb5f8 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/edrt/run/RunEDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/edrt/run/RunEDrtScenarioIT.java @@ -18,11 +18,11 @@ package org.matsim.contrib.drt.extension.edrt.run; -import static org.junit.Assert.assertEquals; - import java.net.URL; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.matsim.contrib.drt.prebooking.PrebookingParams; import org.matsim.contrib.drt.prebooking.logic.ProbabilityBasedPrebookingLogic; import org.matsim.contrib.drt.run.DrtConfigGroup; diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java index 52da0c3199a..6034419d22e 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java @@ -1,6 +1,6 @@ package org.matsim.contrib.drt.extension.fiss; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.events.LinkLeaveEvent; @@ -173,7 +173,7 @@ public void install() { } run.run(); - Assert.assertEquals(23817, linkCounter.getLinkLeaveCount()); + Assertions.assertEquals(23817, linkCounter.getLinkLeaveCount()); } static class LinkCounter implements LinkLeaveEventHandler { diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/insertion/DrtInsertionExtensionIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/insertion/DrtInsertionExtensionIT.java index 91d5699623d..69febd3aab0 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/insertion/DrtInsertionExtensionIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/insertion/DrtInsertionExtensionIT.java @@ -1,7 +1,7 @@ package org.matsim.contrib.drt.extension.insertion; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.net.URL; import java.util.ArrayList; diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/operationFacilities/OperationFacilitiesIOTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/operationFacilities/OperationFacilitiesIOTest.java index 427416b3b4b..06bcd185b89 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/operationFacilities/OperationFacilitiesIOTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/operationFacilities/OperationFacilitiesIOTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.drt.extension.operations.operationFacilities; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -58,12 +58,12 @@ void test() { Id charger = Id.create(i, Charger.class); Id charger2 = Id.create(i+"_2", Charger.class); final OperationFacilitySpecification facility = copy.getOperationFacilitySpecifications().get(id); - Assert.assertEquals(linkId.toString(), facility.getLinkId().toString()); - Assert.assertEquals(coord.getX(), facility.getCoord().getX(), 0); - Assert.assertEquals(coord.getY(), facility.getCoord().getY(), 0); - Assert.assertEquals(capacity, facility.getCapacity()); - Assert.assertEquals(charger.toString(), facility.getChargers().get(0).toString()); - Assert.assertEquals(charger2.toString(), facility.getChargers().get(1).toString()); + Assertions.assertEquals(linkId.toString(), facility.getLinkId().toString()); + Assertions.assertEquals(coord.getX(), facility.getCoord().getX(), 0); + Assertions.assertEquals(coord.getY(), facility.getCoord().getY(), 0); + Assertions.assertEquals(capacity, facility.getCapacity()); + Assertions.assertEquals(charger.toString(), facility.getChargers().get(0).toString()); + Assertions.assertEquals(charger2.toString(), facility.getChargers().get(1).toString()); } for (int i = 10; i < 20; i++) { @@ -73,11 +73,11 @@ void test() { int capacity = i; Id charger = Id.create(i, Charger.class); final OperationFacilitySpecification facility = copy.getOperationFacilitySpecifications().get(id); - Assert.assertEquals(linkId.toString(), facility.getLinkId().toString()); - Assert.assertEquals(coord.getX(), facility.getCoord().getX(), 0); - Assert.assertEquals(coord.getY(), facility.getCoord().getY(), 0); - Assert.assertEquals(capacity, facility.getCapacity()); - Assert.assertEquals(charger.toString(), facility.getChargers().get(0).toString()); + Assertions.assertEquals(linkId.toString(), facility.getLinkId().toString()); + Assertions.assertEquals(coord.getX(), facility.getCoord().getX(), 0); + Assertions.assertEquals(coord.getY(), facility.getCoord().getY(), 0); + Assertions.assertEquals(capacity, facility.getCapacity()); + Assertions.assertEquals(charger.toString(), facility.getChargers().get(0).toString()); } } } diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/ShiftsIOTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/ShiftsIOTest.java index d2f4c3e27f2..ff5eb57ecdc 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/ShiftsIOTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/ShiftsIOTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.drt.extension.operations.shifts; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.io.File; import java.util.Optional; diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/efficiency/ShiftEfficiencyTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/efficiency/ShiftEfficiencyTest.java index d3b4dfb001c..b3e8db5e38d 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/efficiency/ShiftEfficiencyTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/efficiency/ShiftEfficiencyTest.java @@ -9,7 +9,7 @@ package org.matsim.contrib.drt.extension.operations.shifts.analysis.efficiency; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonMoneyEvent; @@ -53,7 +53,7 @@ void testDrtShiftEfficiency() { events.processEvent(new DrtShiftStartedEvent(10 * 3600, shift1, vehicle1, link1) ); // should throw because vehicle is already registered with another shift - Assert.assertThrows(RuntimeException.class, () -> { + Assertions.assertThrows(RuntimeException.class, () -> { events.processEvent(new DrtShiftStartedEvent(10 * 3600, shift1, vehicle1, link1)); }); @@ -62,14 +62,14 @@ void testDrtShiftEfficiency() { events.processEvent(new PassengerDroppedOffEvent(11 * 3600, "drt", request1, person1, vehicle1)); - Assert.assertTrue(shiftEfficiencyTracker.getCurrentRecord().getRequestsByShift().get(shift1).contains(request1)); + Assertions.assertTrue(shiftEfficiencyTracker.getCurrentRecord().getRequestsByShift().get(shift1).contains(request1)); events.processEvent(new PersonMoneyEvent(11 * 3600, person1, -FARE, DrtFareHandler.PERSON_MONEY_EVENT_PURPOSE_DRT_FARE, "drt", request1.toString())); - Assert.assertEquals(FARE, shiftEfficiencyTracker.getCurrentRecord().getRevenueByShift().get(shift1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(FARE, shiftEfficiencyTracker.getCurrentRecord().getRevenueByShift().get(shift1), MatsimTestUtils.EPSILON); - Assert.assertFalse(shiftEfficiencyTracker.getCurrentRecord().getFinishedShifts().containsKey(shift1)); + Assertions.assertFalse(shiftEfficiencyTracker.getCurrentRecord().getFinishedShifts().containsKey(shift1)); events.processEvent(new DrtShiftEndedEvent(20 * 3600, shift1, vehicle1, link1, operationFacility1)); - Assert.assertTrue(shiftEfficiencyTracker.getCurrentRecord().getFinishedShifts().containsKey(shift1)); + Assertions.assertTrue(shiftEfficiencyTracker.getCurrentRecord().getFinishedShifts().containsKey(shift1)); } } diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/analysis/zonal/DrtZonalSystemTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/analysis/zonal/DrtZonalSystemTest.java index 6e58adfdbe5..a49cc10a3d0 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/analysis/zonal/DrtZonalSystemTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/analysis/zonal/DrtZonalSystemTest.java @@ -21,7 +21,7 @@ package org.matsim.contrib.drt.analysis.zonal; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.matsim.contrib.drt.analysis.zonal.DrtGridUtilsTest.createNetwork; import static org.matsim.contrib.drt.analysis.zonal.DrtZonalSystem.createFromPreparedGeometries; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/config/ConfigBehaviorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/config/ConfigBehaviorTest.java index 791902fbf14..003b183046c 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/config/ConfigBehaviorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/config/ConfigBehaviorTest.java @@ -2,7 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.contrib.drt.run.DrtConfigGroup; @@ -46,13 +46,13 @@ final void testMaterializeAfterReadParameterSets() { MultiModeDrtConfigGroup multiModeDrtConfigGroup = ConfigUtils.addOrGetModule( config, MultiModeDrtConfigGroup.class ); // this should have two config groups here, but does not: - Assert.assertEquals( 2, multiModeDrtConfigGroup.getModalElements().size() ); + Assertions.assertEquals( 2, multiModeDrtConfigGroup.getModalElements().size() ); // check if you are getting back the values from the config file: for( DrtConfigGroup drtConfigGroup : multiModeDrtConfigGroup.getModalElements() ){ log.info( drtConfigGroup.getMode() ); if ( ! ( drtConfigGroup.getMode().equals( "drt20" ) || drtConfigGroup.getMode().equals( "drt20000" ) ) ) { - Assert.fail(); + Assertions.fail(); } } @@ -79,8 +79,8 @@ final void testMaterializeAfterReadStandardParams() { DvrpConfigGroup dvrpConfig = ConfigUtils.addOrGetModule( config, DvrpConfigGroup.class ); // check if you are getting back the values from the config file: - Assert.assertEquals( 1.23, dvrpConfig.travelTimeEstimationAlpha, Double.MIN_VALUE ); - Assert.assertEquals( 4.56, dvrpConfig.travelTimeEstimationBeta, Double.MIN_VALUE ); + Assertions.assertEquals( 1.23, dvrpConfig.travelTimeEstimationAlpha, Double.MIN_VALUE ); + Assertions.assertEquals( 4.56, dvrpConfig.travelTimeEstimationBeta, Double.MIN_VALUE ); } } diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/fare/DrtFareHandlerTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/fare/DrtFareHandlerTest.java index fc3c85c6c57..35e41f5d018 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/fare/DrtFareHandlerTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/fare/DrtFareHandlerTest.java @@ -21,7 +21,7 @@ package org.matsim.contrib.drt.fare; import org.apache.commons.lang3.mutable.MutableDouble; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonMoneyEvent; @@ -77,7 +77,7 @@ public void reset(int iteration) { events.flush(); //fare: 1 (daily fee) + 1 (distance()+ 1 basefare + 1 (time) - Assert.assertEquals(-4.0, fare.getValue(), 0); + Assertions.assertEquals(-4.0, fare.getValue(), 0); } { // test minFarePerTrip @@ -91,7 +91,7 @@ public void reset(int iteration) { * fare new trip: 0 (daily fee already paid) + 0.1 (distance)+ 1 basefare + 0.1 (time) = 1.2 < minFarePerTrip = 1.5 * --> new total fare: 4 (previous trip) + 1.5 (minFarePerTrip for new trip) = 5.5 */ - Assert.assertEquals(-5.5, fare.getValue(), 0); + Assertions.assertEquals(-5.5, fare.getValue(), 0); } } diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java index 6b01f318098..76b6f176cde 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java @@ -3,7 +3,7 @@ import java.net.URL; import java.util.*; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -66,7 +66,7 @@ public class DrtPoolingParameterTest { @Test void testMaxWaitTimeNoVehicles() { PersonEnterDrtVehicleEventHandler handler = setupAndRunScenario(50, 10.0, 10000.); - Assert.assertEquals("There should be no vehicle used", 0, handler.getVehRequestCount().size()); + Assertions.assertEquals(0, handler.getVehRequestCount().size(), "There should be no vehicle used"); } @@ -79,17 +79,17 @@ void testMaxWaitTimeNoVehicles() { void testMaxWaitTimeTwoVehiclesForTwoAgents() { PersonEnterDrtVehicleEventHandler handler = setupAndRunScenario(121, 10.0, 10000.); - Assert.assertEquals("There should two vehicle used", 2, handler.getVehRequestCount().size()); + Assertions.assertEquals(2, handler.getVehRequestCount().size(), "There should two vehicle used"); Id drt_veh_1_1 = Id.create("drt_veh_1_1", DvrpVehicle.class); Id drt_veh_1_2 = Id.create("drt_veh_1_2", DvrpVehicle.class); - Assert.assertTrue("drt_veh_1_1 should be requested in general", - handler.getVehRequestCount().containsKey(drt_veh_1_1)); - Assert.assertEquals("drt_veh_1_1 should be requested exactly once", 1, - handler.getVehRequestCount().get(drt_veh_1_1), 0); - Assert.assertTrue("drt_veh_1_2 should be requested in general", - handler.getVehRequestCount().containsKey(drt_veh_1_2)); - Assert.assertEquals("drt_veh_1_2 should be requested exactly once", 1, - handler.getVehRequestCount().get(drt_veh_1_2), 0); + Assertions.assertTrue(handler.getVehRequestCount().containsKey(drt_veh_1_1), + "drt_veh_1_1 should be requested in general"); + Assertions.assertEquals(1, + handler.getVehRequestCount().get(drt_veh_1_1), 0, "drt_veh_1_1 should be requested exactly once"); + Assertions.assertTrue(handler.getVehRequestCount().containsKey(drt_veh_1_2), + "drt_veh_1_2 should be requested in general"); + Assertions.assertEquals(1, + handler.getVehRequestCount().get(drt_veh_1_2), 0, "drt_veh_1_2 should be requested exactly once"); } @@ -100,17 +100,17 @@ void testMaxWaitTimeTwoVehiclesForTwoAgents() { void testMaxWaitTimeTwoVehiclesForFourAgents() { PersonEnterDrtVehicleEventHandler handler = setupAndRunScenario(250, 10.0, 10000.); - Assert.assertEquals("There should two vehicle used", 2, handler.getVehRequestCount().size()); + Assertions.assertEquals(2, handler.getVehRequestCount().size(), "There should two vehicle used"); Id drt_veh_1_1 = Id.create("drt_veh_1_1", DvrpVehicle.class); Id drt_veh_1_2 = Id.create("drt_veh_1_2", DvrpVehicle.class); - Assert.assertTrue("drt_veh_1_1 should be requested in general", - handler.getVehRequestCount().containsKey(drt_veh_1_1)); - Assert.assertEquals("drt_veh_1_1 should be requested exactly twice", 2, - handler.getVehRequestCount().get(drt_veh_1_1), 0); - Assert.assertTrue("drt_veh_1_2 should be requested in general", - handler.getVehRequestCount().containsKey(drt_veh_1_2)); - Assert.assertEquals("drt_veh_1_2 should be requested exactly twice", 2, - handler.getVehRequestCount().get(drt_veh_1_2), 0); + Assertions.assertTrue(handler.getVehRequestCount().containsKey(drt_veh_1_1), + "drt_veh_1_1 should be requested in general"); + Assertions.assertEquals(2, + handler.getVehRequestCount().get(drt_veh_1_1), 0, "drt_veh_1_1 should be requested exactly twice"); + Assertions.assertTrue(handler.getVehRequestCount().containsKey(drt_veh_1_2), + "drt_veh_1_2 should be requested in general"); + Assertions.assertEquals(2, + handler.getVehRequestCount().get(drt_veh_1_2), 0, "drt_veh_1_2 should be requested exactly twice"); } @@ -122,12 +122,12 @@ void testMaxWaitTimeOneVehicleForFourAgents() { PersonEnterDrtVehicleEventHandler handler = setupAndRunScenario(500, 10.0, 10000.); System.out.println(handler.getVehRequestCount()); - Assert.assertEquals("There should only be one vehicle used", 1, handler.getVehRequestCount().size()); + Assertions.assertEquals(1, handler.getVehRequestCount().size(), "There should only be one vehicle used"); Id drt_veh_1_1 = Id.create("drt_veh_1_1", DvrpVehicle.class); - Assert.assertTrue("drt_veh_1_1 should be requested in general", - handler.getVehRequestCount().containsKey(drt_veh_1_1)); - Assert.assertEquals("drt_veh_1_1 should be requested exactly four times", 4, - handler.getVehRequestCount().get(drt_veh_1_1), 0); + Assertions.assertTrue(handler.getVehRequestCount().containsKey(drt_veh_1_1), + "drt_veh_1_1 should be requested in general"); + Assertions.assertEquals(4, + handler.getVehRequestCount().get(drt_veh_1_1), 0, "drt_veh_1_1 should be requested exactly four times"); } @@ -143,7 +143,7 @@ void testMaxWaitTimeOneVehicleForFourAgents() { void testBetaNoVehicles() { PersonEnterDrtVehicleEventHandler handler = setupAndRunScenario(5000, 1.0, 0.); - Assert.assertEquals("There should only be zero vehicles used", 0, handler.getVehRequestCount().size()); + Assertions.assertEquals(0, handler.getVehRequestCount().size(), "There should only be zero vehicles used"); } @@ -155,17 +155,17 @@ void testBetaNoVehicles() { void testBetaTwoVehiclesForTwoAgents() { PersonEnterDrtVehicleEventHandler handler = setupAndRunScenario(5000, 1.0, 150); - Assert.assertEquals("There should two vehicle used", 2, handler.getVehRequestCount().size()); + Assertions.assertEquals(2, handler.getVehRequestCount().size(), "There should two vehicle used"); Id drt_veh_1_1 = Id.create("drt_veh_1_1", DvrpVehicle.class); Id drt_veh_1_2 = Id.create("drt_veh_1_2", DvrpVehicle.class); - Assert.assertTrue("drt_veh_1_1 should be requested in general", - handler.getVehRequestCount().containsKey(drt_veh_1_1)); - Assert.assertEquals("drt_veh_1_1 should be requested exactly once", 1, - handler.getVehRequestCount().get(drt_veh_1_1), 0); - Assert.assertTrue("drt_veh_1_2 should be requested in general", - handler.getVehRequestCount().containsKey(drt_veh_1_2)); - Assert.assertEquals("drt_veh_1_2 should be requested exactly once", 1, - handler.getVehRequestCount().get(drt_veh_1_2), 0); + Assertions.assertTrue(handler.getVehRequestCount().containsKey(drt_veh_1_1), + "drt_veh_1_1 should be requested in general"); + Assertions.assertEquals(1, + handler.getVehRequestCount().get(drt_veh_1_1), 0, "drt_veh_1_1 should be requested exactly once"); + Assertions.assertTrue(handler.getVehRequestCount().containsKey(drt_veh_1_2), + "drt_veh_1_2 should be requested in general"); + Assertions.assertEquals(1, + handler.getVehRequestCount().get(drt_veh_1_2), 0, "drt_veh_1_2 should be requested exactly once"); } @@ -176,17 +176,17 @@ void testBetaTwoVehiclesForTwoAgents() { void testBetaTwoVehiclesForFourAgents() { PersonEnterDrtVehicleEventHandler handler = setupAndRunScenario(5000, 1.0, 250); - Assert.assertEquals("There should two vehicle used", 2, handler.getVehRequestCount().size()); + Assertions.assertEquals(2, handler.getVehRequestCount().size(), "There should two vehicle used"); Id drt_veh_1_1 = Id.create("drt_veh_1_1", DvrpVehicle.class); Id drt_veh_1_2 = Id.create("drt_veh_1_2", DvrpVehicle.class); - Assert.assertTrue("drt_veh_1_1 should be requested in general", - handler.getVehRequestCount().containsKey(drt_veh_1_1)); - Assert.assertEquals("drt_veh_1_1 should be requested exactly twice", 2, - handler.getVehRequestCount().get(drt_veh_1_1), 0); - Assert.assertTrue("drt_veh_1_2 should be requested in general", - handler.getVehRequestCount().containsKey(drt_veh_1_2)); - Assert.assertEquals("drt_veh_1_2 should be requested exactly twice", 2, - handler.getVehRequestCount().get(drt_veh_1_2), 0); + Assertions.assertTrue(handler.getVehRequestCount().containsKey(drt_veh_1_1), + "drt_veh_1_1 should be requested in general"); + Assertions.assertEquals(2, + handler.getVehRequestCount().get(drt_veh_1_1), 0, "drt_veh_1_1 should be requested exactly twice"); + Assertions.assertTrue(handler.getVehRequestCount().containsKey(drt_veh_1_2), + "drt_veh_1_2 should be requested in general"); + Assertions.assertEquals(2, + handler.getVehRequestCount().get(drt_veh_1_2), 0, "drt_veh_1_2 should be requested exactly twice"); } /** @@ -196,12 +196,12 @@ void testBetaTwoVehiclesForFourAgents() { void testBetaOneVehicleForFourAgents() { PersonEnterDrtVehicleEventHandler handler = setupAndRunScenario(5000, 1.0, 400); - Assert.assertEquals("There should only be one vehicle used", 1, handler.getVehRequestCount().size()); + Assertions.assertEquals(1, handler.getVehRequestCount().size(), "There should only be one vehicle used"); Id drt_veh_1_1 = Id.create("drt_veh_1_1", DvrpVehicle.class); - Assert.assertTrue("drt_veh_1_1 should be requested in general", - handler.getVehRequestCount().containsKey(drt_veh_1_1)); - Assert.assertEquals("drt_veh_1_1 should be requested exactly four times", 4, - handler.getVehRequestCount().get(drt_veh_1_1), 0); + Assertions.assertTrue(handler.getVehRequestCount().containsKey(drt_veh_1_1), + "drt_veh_1_1 should be requested in general"); + Assertions.assertEquals(4, + handler.getVehRequestCount().get(drt_veh_1_1), 0, "drt_veh_1_1 should be requested exactly four times"); } diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/AbandonAndCancelTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/AbandonAndCancelTest.java index 692657020d8..61241d7c293 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/AbandonAndCancelTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/AbandonAndCancelTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.drt.prebooking; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/ComplexUnschedulerTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/ComplexUnschedulerTest.java index f6155aceec8..93a59a769bd 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/ComplexUnschedulerTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/ComplexUnschedulerTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.drt.prebooking; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import java.util.Collections; @@ -541,16 +541,16 @@ private static void assertTasks(Schedule schedule, List reference Task task = schedule.getTasks().get(i); ReferenceTask reference = references.get(i); - assertEquals("wrong type in task " + i, reference.taskType, task.getClass()); - assertEquals("wrong begin time in task " + i, reference.startTime, task.getBeginTime(), 1e-3); - assertEquals("wrong end time in task " + i, reference.endTime, task.getEndTime(), 1e-3); + assertEquals(reference.taskType, task.getClass(), "wrong type in task " + i); + assertEquals(reference.startTime, task.getBeginTime(), 1e-3, "wrong begin time in task " + i); + assertEquals(reference.endTime, task.getEndTime(), 1e-3, "wrong end time in task " + i); if (i > 0) { - assertEquals("wrong transition from " + (i - 1) + " to " + i, schedule.getTasks().get(i).getBeginTime(), - schedule.getTasks().get(i - 1).getEndTime(), 1e-3); + assertEquals(schedule.getTasks().get(i).getBeginTime(), + schedule.getTasks().get(i - 1).getEndTime(), 1e-3, "wrong transition from " + (i - 1) + " to " + i); } - assertTrue("invalid task " + i, task.getEndTime() >= task.getBeginTime()); + assertTrue(task.getEndTime() >= task.getBeginTime(), "invalid task " + i); } } diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PersonStuckPrebookingTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PersonStuckPrebookingTest.java index 35605aac125..4245cd4b4ca 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PersonStuckPrebookingTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PersonStuckPrebookingTest.java @@ -1,12 +1,12 @@ package org.matsim.contrib.drt.prebooking; -import static org.junit.Assert.assertEquals; - import java.util.Arrays; import java.util.Collections; import java.util.Set; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Activity; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTest.java index 05f5eeb2eb8..cb149fc1f3b 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.drt.prebooking; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java index 71dc3a222b8..e4d242dabcf 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/DrtRoutingModuleTest.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -111,7 +111,7 @@ void testCottbusClosestAccessEgressStopFinder() { List routedList = dvrpRoutingModule.calcRoute( DefaultRoutingRequest.withoutAttributes(hf, wf, 8 * 3600, p1)); - Assert.assertEquals(5, routedList.size()); + Assertions.assertEquals(5, routedList.size()); Leg accessLegP1 = (Leg)routedList.get(0); GenericRouteImpl accessLegP1Route = (GenericRouteImpl)accessLegP1.getRoute(); @@ -129,32 +129,32 @@ void testCottbusClosestAccessEgressStopFinder() { // drt boarding should be at link id 2183 or 2184, not totally clear which one of these (from and to nodes inverted) // drt alighting should be at link id 5866 or 5867, not totally clear which one of these (from and to nodes inverted) - Assert.assertEquals(TransportMode.walk, accessLegP1.getMode()); - Assert.assertEquals(Id.createLinkId(3699), accessLegP1Route.getStartLinkId()); - Assert.assertEquals(Id.createLinkId(2184), accessLegP1Route.getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, accessLegP1.getMode()); + Assertions.assertEquals(Id.createLinkId(3699), accessLegP1Route.getStartLinkId()); + Assertions.assertEquals(Id.createLinkId(2184), accessLegP1Route.getEndLinkId()); - Assert.assertEquals(drtMode + " interaction", stageActivityAccessP1.getType()); - Assert.assertEquals(Id.createLinkId(2184), stageActivityAccessP1.getLinkId()); + Assertions.assertEquals(drtMode + " interaction", stageActivityAccessP1.getType()); + Assertions.assertEquals(Id.createLinkId(2184), stageActivityAccessP1.getLinkId()); - Assert.assertEquals(drtMode, realDrtLegP1.getMode()); - Assert.assertEquals(Id.createLinkId(2184), realDrtLegP1Route.getStartLinkId()); + Assertions.assertEquals(drtMode, realDrtLegP1.getMode()); + Assertions.assertEquals(Id.createLinkId(2184), realDrtLegP1Route.getStartLinkId()); /* * links 5866 and 5867 are located between the same nodes, so their drt stops should be at the same place place, * too. Therefore it is not clear which one of these is the right one, as ClosestAccessEgressStopFinder should * find the nearest drt stop, but both have the same distance from the destination facility. */ - Assert.assertTrue( + Assertions.assertTrue( realDrtLegP1Route.getEndLinkId().equals(Id.createLinkId(5866)) || realDrtLegP1Route.getEndLinkId() .equals(Id.createLinkId(5867))); Id endLink = realDrtLegP1Route.getEndLinkId(); // Check of other, more drt-specific attributes of the DrtRoute is missing, maybe these should be tested in DrtRoutingModule instead - Assert.assertEquals(drtMode + " interaction", stageActivityEgressP1.getType()); - Assert.assertEquals(endLink, stageActivityEgressP1.getLinkId()); + Assertions.assertEquals(drtMode + " interaction", stageActivityEgressP1.getType()); + Assertions.assertEquals(endLink, stageActivityEgressP1.getLinkId()); - Assert.assertEquals(TransportMode.walk, egressLegP1.getMode()); - Assert.assertEquals(endLink, egressLegP1Route.getStartLinkId()); - Assert.assertEquals(Id.createLinkId(7871), egressLegP1Route.getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, egressLegP1.getMode()); + Assertions.assertEquals(endLink, egressLegP1Route.getStartLinkId()); + Assertions.assertEquals(Id.createLinkId(7871), egressLegP1Route.getEndLinkId()); // case 2: origin and destination outside max walking distance from next stop (>2000m vs. max 200m) Person p2 = scenario.getPopulation().getPersons().get(Id.createPersonId(2)); @@ -167,7 +167,7 @@ void testCottbusClosestAccessEgressStopFinder() { List routedList2 = dvrpRoutingModule.calcRoute( DefaultRoutingRequest.withoutAttributes(hf2, wf2, 8 * 3600, p2)); - Assert.assertNull(routedList2); + Assertions.assertNull(routedList2); // case 3: origin and destination at the same coordinate, > 2000 m walking distance from next stop Person p3 = scenario.getPopulation().getPersons().get(Id.createPersonId(3)); @@ -180,7 +180,7 @@ void testCottbusClosestAccessEgressStopFinder() { List routedList3 = dvrpRoutingModule.calcRoute( DefaultRoutingRequest.withoutAttributes(hf3, wf3, 8 * 3600, p3)); - Assert.assertNull(routedList3); + Assertions.assertNull(routedList3); // case 4: origin and destination at the same coordinate, in 200 m walking distance from next stop Person p4 = scenario.getPopulation().getPersons().get(Id.createPersonId(4)); @@ -193,7 +193,7 @@ void testCottbusClosestAccessEgressStopFinder() { List routedList4 = dvrpRoutingModule.calcRoute( DefaultRoutingRequest.withoutAttributes(hf4, wf4, 8 * 3600, p4)); - Assert.assertNull(routedList4); + Assertions.assertNull(routedList4); // case 5: origin within 200 m walking distance from next stop, but destination outside walking distance Person p5 = scenario.getPopulation().getPersons().get(Id.createPersonId(5)); @@ -207,7 +207,7 @@ void testCottbusClosestAccessEgressStopFinder() { DefaultRoutingRequest.withoutAttributes(hf5, wf5, 8 * 3600, p5)); // TODO: Asserts are prepared for interpreting maxWalkingDistance as a real maximum, but routing still works wrongly - Assert.assertNull(routedList5); + Assertions.assertNull(routedList5); // case 6: destination within 200 m walking distance from next stop, but origin outside walking distance Person p6 = scenario.getPopulation().getPersons().get(Id.createPersonId(6)); @@ -221,7 +221,7 @@ void testCottbusClosestAccessEgressStopFinder() { DefaultRoutingRequest.withoutAttributes(hf6, wf6, 8 * 3600, p6)); // TODO: Asserts are prepared for interpreting maxWalkingDistance as a real maximum, but routing still works wrongly - Assert.assertNull(routedList6); + Assertions.assertNull(routedList6); } @@ -243,13 +243,13 @@ void testRouteDescriptionHandling() { DrtRoute drtRoute = new DrtRoute(h.getLinkId(), w.getLinkId()); drtRoute.setRouteDescription(oldRouteFormat); - Assert.assertTrue(drtRoute.getMaxWaitTime() == 600.); - Assert.assertTrue(drtRoute.getDirectRideTime() == 400); + Assertions.assertTrue(drtRoute.getMaxWaitTime() == 600.); + Assertions.assertTrue(drtRoute.getDirectRideTime() == 400); drtRoute.setRouteDescription(newRouteFormat); - Assert.assertTrue(drtRoute.getMaxWaitTime() == 600.); - Assert.assertTrue(drtRoute.getDirectRideTime() == 400); - Assert.assertTrue(drtRoute.getUnsharedPath().equals(Arrays.asList("a", "b", "c"))); + Assertions.assertTrue(drtRoute.getMaxWaitTime() == 600.); + Assertions.assertTrue(drtRoute.getDirectRideTime() == 400); + Assertions.assertTrue(drtRoute.getUnsharedPath().equals(Arrays.asList("a", "b", "c"))); } diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/MultiModeDrtMainModeIdentifierTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/MultiModeDrtMainModeIdentifierTest.java index 517321d1305..cfdc3002eee 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/MultiModeDrtMainModeIdentifierTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/MultiModeDrtMainModeIdentifierTest.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.TransportMode; @@ -34,13 +34,13 @@ void test() { List testElements = new ArrayList<>(); Leg l1 = PopulationUtils.createLeg(TransportMode.car); testElements.add(l1); - Assert.assertEquals(TransportMode.car, mmi.identifyMainMode(testElements)); + Assertions.assertEquals(TransportMode.car, mmi.identifyMainMode(testElements)); } { List testElements = new ArrayList<>(); Leg l1 = PopulationUtils.createLeg(drtMode); testElements.add(l1); - Assert.assertEquals(drtMode, mmi.identifyMainMode(testElements)); + Assertions.assertEquals(drtMode, mmi.identifyMainMode(testElements)); } { String drtStageActivityType = ScoringConfigGroup.createStageActivityType(drtMode); @@ -58,7 +58,7 @@ void test() { testElements.add(l2); testElements.add(a3); testElements.add(l3); - Assert.assertEquals(drtMode, mmi.identifyMainMode(testElements)); + Assertions.assertEquals(drtMode, mmi.identifyMainMode(testElements)); } } } diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java index 04bd15fa5c8..e3ac88d4985 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java @@ -20,7 +20,7 @@ package org.matsim.contrib.drt.run.examples; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.net.URL; diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/router/DiversionTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/router/DiversionTest.java index 822f23b36c9..2aa72304e53 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/router/DiversionTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/router/DiversionTest.java @@ -4,8 +4,7 @@ import java.util.List; import java.util.Objects; import java.util.Set; - -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -221,18 +220,18 @@ protected void configureQSim() { // Took the fixed value from the simulation, to make sure this stays consistent // over refactorings - Assert.assertEquals(testTracker.eventBasedArrivalTime, 657.0, 0); + Assertions.assertEquals(testTracker.eventBasedArrivalTime, 657.0, 0); // Initially calculated arrival time should predict correctly the final arrival // time - Assert.assertEquals(testTracker.initialArrivalTime, 657.0, 0); + Assertions.assertEquals(testTracker.initialArrivalTime, 657.0, 0); // Along the route, when diverting to the same destination, arrival time should // stay constant - testTracker.diversionArrivalTimes.forEach(t -> Assert.assertEquals(t, 657.0, 0)); + testTracker.diversionArrivalTimes.forEach(t -> Assertions.assertEquals(t, 657.0, 0)); // Also ,the task end time should be consistent with the path - testTracker.taskEndTimes.forEach(t -> Assert.assertEquals(t, 657.0, 0)); + testTracker.taskEndTimes.forEach(t -> Assertions.assertEquals(t, 657.0, 0)); } static private class TestModeModule extends AbstractDvrpModeModule { @@ -549,15 +548,15 @@ protected void configureQSim() { // Took the fixed value from the simulation, to make sure this stays consistent // over refactorings - same as previous unit test - Assert.assertEquals(testTracker.eventBasedArrivalTime, 657.0, 0); + Assertions.assertEquals(testTracker.eventBasedArrivalTime, 657.0, 0); // Initially calculated arrival time should predict correctly the final arrival // time - as in the first unit test as we route to L8 - Assert.assertEquals(testTracker.initialArrivalTime, 657.0, 0); + Assertions.assertEquals(testTracker.initialArrivalTime, 657.0, 0); // Along the route, when diverting to the same destination, arrival time should // stay constant - testTracker.diversionArrivalTimes.forEach(t -> Assert.assertEquals(t, 739.0, 0)); + testTracker.diversionArrivalTimes.forEach(t -> Assertions.assertEquals(t, 739.0, 0)); // Without fix in OnlineDriveTaskTrackerImpl, the last test will lead to a // difference of one second for the samples at late times diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/EmissionModuleTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/EmissionModuleTest.java index ea2bb982d8e..c7cde9b6eb1 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/EmissionModuleTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/EmissionModuleTest.java @@ -15,8 +15,8 @@ import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; -import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; /** * Most of the other test implicitly test the EmissionModule as well. Still, I guess it makes sense to have this here diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/OsmHbefaMappingTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/OsmHbefaMappingTest.java index af88ae935a2..195fc6e6fcb 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/OsmHbefaMappingTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/OsmHbefaMappingTest.java @@ -6,8 +6,7 @@ import org.matsim.api.core.v01.network.Link; import org.matsim.core.network.NetworkUtils; -import static org.junit.Assert.*; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; public class OsmHbefaMappingTest { diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModule.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModule.java index 5f39db1437a..18bf6881844 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModule.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModule.java @@ -20,8 +20,8 @@ package org.matsim.contrib.emissions; -import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -128,7 +128,7 @@ void calculateColdEmissionsAndThrowEventTest_Exceptions() { } catch (Exception e) { excep = true; } - Assert.assertTrue(message, excep); + Assertions.assertTrue(excep, message); excep = false; } @@ -154,7 +154,7 @@ void calculateColdEmissionsAndThrowEventTest_minimalVehicleInformation() { String message = "The expected emissions for an emissions event with vehicle information string '" + vehInfo11 + "' are " + numberOfColdEmissions * averageAverageFactor + " but were " + sumOfEmissions; - Assert.assertEquals( message, numberOfColdEmissions * averageAverageFactor, sumOfEmissions, MatsimTestUtils.EPSILON ); + Assertions.assertEquals( numberOfColdEmissions * averageAverageFactor, sumOfEmissions, MatsimTestUtils.EPSILON, message ); } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase1.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase1.java index a5785997e66..690ee4ed802 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase1.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase1.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -119,7 +119,7 @@ void calculateColdEmissionsAndThrowEventTest_completeData() { double sumOfEmissions = calculatedPollutants.values().stream().mapToDouble(Double::doubleValue).sum(); String message = "The expected emissions for " + testCase1.toString() + " are " + pollutants.size() * (Double) testCase1.get(4) + " but were " + sumOfEmissions; - Assert.assertEquals(message, pollutants.size() * (Double) testCase1.get(4), sumOfEmissions, MatsimTestUtils.EPSILON); + Assertions.assertEquals(pollutants.size() * (Double) testCase1.get(4), sumOfEmissions, MatsimTestUtils.EPSILON, message); } private static ColdEmissionAnalysisModule setUp() { diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase2.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase2.java index d975c75f447..c97de7d7ecd 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase2.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase2.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -112,7 +112,7 @@ void calculateColdEmissionsAndThrowEventTest_completeData() { double sumOfEmissions = calculatedPollutants.values().stream().mapToDouble(Double::doubleValue).sum(); String message = "The expected emissions for " + testCase2.toString() + " are " + pollutants.size() * (Double) testCase2.get( 4 ) + " but were " + sumOfEmissions; - Assert.assertEquals( message, pollutants.size() * (Double) testCase2.get( 4 ), sumOfEmissions, MatsimTestUtils.EPSILON ); + Assertions.assertEquals( pollutants.size() * (Double) testCase2.get( 4 ), sumOfEmissions, MatsimTestUtils.EPSILON, message ); } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase3.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase3.java index e925e1df1d6..3da0de0f540 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase3.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase3.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -116,7 +116,7 @@ void calculateColdEmissionsAndThrowEventTest_completeData() { double sumOfEmissions = calculatedPollutants.values().stream().mapToDouble(Double::doubleValue).sum(); String message = "The expected emissions for " + testCase3.toString() + " are " + pollutants.size() * (Double) testCase3.get( 4 ) + " but were " + sumOfEmissions; - Assert.assertEquals( message, pollutants.size() * (Double) testCase3.get( 4 ), sumOfEmissions, MatsimTestUtils.EPSILON ); + Assertions.assertEquals( pollutants.size() * (Double) testCase3.get( 4 ), sumOfEmissions, MatsimTestUtils.EPSILON, message ); } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase4.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase4.java index 06a4298fb58..726297486d3 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase4.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase4.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -126,7 +126,7 @@ void calculateColdEmissionsAndThrowEventTest_completeData() { double sumOfEmissions = calculatedPollutants.values().stream().mapToDouble(Double::doubleValue).sum(); String message = "The expected emissions for " + testCase4.toString() + " are " + pollutants.size() * (Double) testCase4.get( 4 ) + " but were " + sumOfEmissions; - Assert.assertEquals( message, pollutants.size() * (Double) testCase4.get( 4 ), sumOfEmissions, MatsimTestUtils.EPSILON ); + Assertions.assertEquals( pollutants.size() * (Double) testCase4.get( 4 ), sumOfEmissions, MatsimTestUtils.EPSILON, message ); } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase6.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase6.java index 735adde0f16..97abfd77803 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase6.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModuleCase6.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -121,7 +121,7 @@ void calculateColdEmissionsAndThrowEventTest_completeData() { double sumOfEmissions = calculatedPollutants.values().stream().mapToDouble(Double::doubleValue).sum(); String message = "The expected emissions for " + testCase6.toString() + " are " + pollutants.size() * (Double) testCase6.get( 4 ) + " but were " + sumOfEmissions; - Assert.assertEquals( message, pollutants.size() * (Double) testCase6.get( 4 ), sumOfEmissions, MatsimTestUtils.EPSILON ); + Assertions.assertEquals( pollutants.size() * (Double) testCase6.get( 4 ), sumOfEmissions, MatsimTestUtils.EPSILON, message ); } private ColdEmissionAnalysisModule setUp() { diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionsFallbackBehaviour.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionsFallbackBehaviour.java index 6c81637cc12..cef4618571e 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionsFallbackBehaviour.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionsFallbackBehaviour.java @@ -23,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -89,7 +89,7 @@ void testColdDetailedValueOnlyDetailed() { .checkVehicleInfoAndCalculateWColdEmissions(vehicleFull.getType(), vehicleFull.getId(), link.getId(), startTime, parkingDuration, distance); - Assert.assertEquals(emissionsFactorInGrammPerKilometer_Detailed, coldEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(emissionsFactorInGrammPerKilometer_Detailed, coldEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); } @@ -147,7 +147,7 @@ void testCold_DetailedThenTechnologyAverageElseAbort_FallbackNotNeeded() { .checkVehicleInfoAndCalculateWColdEmissions(vehicleFull.getType(), vehicleFull.getId(), link.getId(), startTime, parkingDuration, distance); - Assert.assertEquals(emissionsFactorInGrammPerKilometer_Detailed, coldEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(emissionsFactorInGrammPerKilometer_Detailed, coldEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); } @@ -167,7 +167,7 @@ void testCold_DetailedThenTechnologyAverageElseAbort_FallbackToTechnologyAverage vehicleFallbackToTechnologyAverage.getId(), link.getId(), startTime, parkingDuration, distance); - Assert.assertEquals(emissionsFactorInGrammPerKilometer_TechnologyAverage, coldEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(emissionsFactorInGrammPerKilometer_TechnologyAverage, coldEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); } /** @@ -205,7 +205,7 @@ void testCold_DetailedThenTechnologyAverageThenAverageTable_FallbackNotNeeded() .checkVehicleInfoAndCalculateWColdEmissions(vehicleFull.getType(), vehicleFull.getId(), link.getId(), startTime, parkingDuration, distance); - Assert.assertEquals(emissionsFactorInGrammPerKilometer_Detailed, coldEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(emissionsFactorInGrammPerKilometer_Detailed, coldEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); } @@ -224,7 +224,7 @@ void testCold_DetailedThenTechnologyAverageThenAverageTable_FallbackToTechnology .checkVehicleInfoAndCalculateWColdEmissions(vehicleFallbackToTechnologyAverage.getType(), vehicleFallbackToTechnologyAverage.getId(), link.getId(), startTime, parkingDuration, distance); - Assert.assertEquals(emissionsFactorInGrammPerKilometer_TechnologyAverage, coldEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(emissionsFactorInGrammPerKilometer_TechnologyAverage, coldEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); } /** @@ -244,7 +244,7 @@ void testCold_DetailedThenTechnologyAverageThenAverageTable_FallbackToAverageTab .checkVehicleInfoAndCalculateWColdEmissions(vehicleFallbackToAverageTable.getType(), vehicleFallbackToAverageTable.getId(), link.getId(), startTime, parkingDuration, distance); - Assert.assertEquals(emissionsFactorInGrammPerKilometer_AverageTable, coldEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(emissionsFactorInGrammPerKilometer_AverageTable, coldEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaColdEmissionFactorKey.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaColdEmissionFactorKey.java index e3bbaecef8f..13efc7bf890 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaColdEmissionFactorKey.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaColdEmissionFactorKey.java @@ -20,10 +20,10 @@ package org.matsim.contrib.emissions; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import static org.matsim.contrib.emissions.Pollutant.CO; import static org.matsim.contrib.emissions.Pollutant.FC; @@ -83,8 +83,8 @@ final void testEqualsForCompleteKeys() { compare.setVehicleCategory(hbefaVehCategory); String message = "these two objects should be the same but are not: " + normal.toString() + " and " + compare.toString(); - Assert.assertEquals(message, normal, compare); - Assert.assertEquals(message, compare, normal); + Assertions.assertEquals(normal, compare, message); + Assertions.assertEquals(compare, normal, message); } { @@ -101,8 +101,8 @@ final void testEqualsForCompleteKeys() { different.setVehicleCategory(HbefaVehicleCategory.HEAVY_GOODS_VEHICLE); String message = "these two objects should not be the same: " + normal.toString() + " and " + different.toString(); - assertNotEquals(message, normal, different); - assertNotEquals(message, different, normal); + assertNotEquals(normal, different, message); + assertNotEquals(different, normal, message); } } @@ -128,7 +128,7 @@ final void testEqualsForIncompleteKeys_vehicleCategory(){ noVehCat.setVehicleAttributes(hbefaVehicleAttributes); String message = "these two HbefaColdEmissionFactorKeys should not be the same: " + normal.toString() + " and " + noVehCat.toString(); - assertFalse(message, noVehCat.equals(normal)); + assertFalse(noVehCat.equals(normal), message); } @Test @@ -147,7 +147,7 @@ final void testEqualsForIncompleteKeys_pollutant(){ noColdPollutant.setVehicleAttributes(hbefaVehicleAttributes); String message = "these two HbefaColdEmissionFactorKeys should not be the same: " + normal.toString() + " and " + noColdPollutant.toString(); - assertFalse(message, noColdPollutant.equals(normal)); + assertFalse(noColdPollutant.equals(normal), message); } @Test @@ -166,7 +166,7 @@ final void testEqualsForIncompleteKeys_parkingTime() { noParkingTime.setVehicleAttributes(hbefaVehicleAttributes); String message = "these two HbefaColdEmissionFactorKeys should not be the same: " + normal.toString() + " and " + noParkingTime.toString(); - assertFalse(message, noParkingTime.equals(normal)); + assertFalse(noParkingTime.equals(normal), message); } @Test @@ -185,7 +185,7 @@ final void testEqualsForIncompleteKeys_distance() { noDistance.setVehicleAttributes(hbefaVehicleAttributes); String message = "these two HbefaColdEmissionFactorKeys should not be the same: " + normal.toString() + " and " + noDistance.toString(); - assertFalse(message, noDistance.equals(normal)); + assertFalse(noDistance.equals(normal), message); } @Test @@ -200,7 +200,7 @@ final void testEqualsForIncompleteKeys_emptyKey() { HbefaColdEmissionFactorKey emptyKey = new HbefaColdEmissionFactorKey(); String message = "these two HbefaColdEmissionFactorKeys should not be the same: " + normal.toString() + " and " + emptyKey.toString(); - assertFalse(message, emptyKey.equals(normal)); + assertFalse(emptyKey.equals(normal), message); } @Test @@ -227,7 +227,7 @@ final void testEqualsForIncompleteKeys_VehicleAttributes(){ noVehAtt.setVehicleCategory(hbefaVehCategory); String message = "these two HbefaColdEmissionFactorKeys should not be the same: " + normal.toString() + " and " + noVehAtt.toString(); - assertFalse(message, noVehAtt.equals(normal)); + assertFalse(noVehAtt.equals(normal), message); //set the vehicle attributes of the normal hbefaColdWmissionFactorKey to 'average' @@ -239,7 +239,7 @@ final void testEqualsForIncompleteKeys_VehicleAttributes(){ hbefaVehicleAttributesAverage.setHbefaTechnology("average"); normal.setVehicleAttributes(hbefaVehicleAttributesAverage); - Assert.assertTrue(message, noVehAtt.equals(normal)); + Assertions.assertTrue(noVehAtt.equals(normal), message); } } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaVehicleAttributes.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaVehicleAttributes.java index 49a3e04e8cd..bb8743783d9 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaVehicleAttributes.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaVehicleAttributes.java @@ -20,7 +20,7 @@ package org.matsim.contrib.emissions; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -54,8 +54,8 @@ final void testEqualsForCompleteAttributes(){ String assertErrorMessage = "These hbefa vehicle attribute objects should have been the same: "; assertErrorMessage += normal.toString() + " and " + compare.toString(); - Assert.assertEquals(assertErrorMessage, normal, compare); - Assert.assertEquals(assertErrorMessage, compare, normal); + Assertions.assertEquals(normal, compare, assertErrorMessage); + Assertions.assertEquals(compare, normal, assertErrorMessage); } @@ -74,8 +74,8 @@ final void testEqualsForCompleteAttributes_emConcept(){ differentValues.setHbefaTechnology(technology); assertErrorMessage = "These hbefa vehicle attribute objects should not have been the same: "; assertErrorMessage += normal.toString() + " and " + differentValues.toString(); - Assert.assertNotEquals(assertErrorMessage, normal, differentValues); - Assert.assertNotEquals(assertErrorMessage, differentValues, normal); + Assertions.assertNotEquals(normal, differentValues, assertErrorMessage); + Assertions.assertNotEquals(differentValues, normal, assertErrorMessage); } @Test @@ -92,8 +92,8 @@ final void testEqualsForCompleteAttributes_sizeClass(){ differentValues.setHbefaTechnology(technology); assertErrorMessage = "These hbefa vehicle attribute objects should not have been the same: "; assertErrorMessage += normal.toString() + " and " + differentValues.toString(); - Assert.assertNotEquals(assertErrorMessage, normal, differentValues); - Assert.assertNotEquals(assertErrorMessage, differentValues, normal); + Assertions.assertNotEquals(normal, differentValues, assertErrorMessage); + Assertions.assertNotEquals(differentValues, normal, assertErrorMessage); } @@ -111,8 +111,8 @@ final void testEqualsForCompleteAttributes_technologies(){ differentValues.setHbefaTechnology("other technology"); assertErrorMessage = "These hbefa vehicle attribute objects should not have been the same: "; assertErrorMessage += normal.toString() + " and " + differentValues.toString(); - Assert.assertNotEquals(assertErrorMessage, normal, differentValues); - Assert.assertNotEquals(assertErrorMessage, differentValues, normal); + Assertions.assertNotEquals(normal, differentValues, assertErrorMessage); + Assertions.assertNotEquals(differentValues, normal, assertErrorMessage); } @@ -131,13 +131,13 @@ final void testEqualsForIncompleteAttributes_emConcept(){ noEmConcept.setHbefaSizeClass(sizeClass); noEmConcept.setHbefaTechnology(technology); message = "no em concept was set, therefore " + normal.getHbefaEmConcept() + " should not equal " + noEmConcept.getHbefaEmConcept(); - Assert.assertNotEquals(message, noEmConcept, normal); - Assert.assertNotEquals(message, normal, noEmConcept); + Assertions.assertNotEquals(noEmConcept, normal, message); + Assertions.assertNotEquals(normal, noEmConcept, message); normal.setHbefaEmConcept("average"); message = "no em concept was set, therefore " + noEmConcept.getHbefaEmConcept() + "should be set to 'average'"; - Assert.assertEquals(message, noEmConcept, normal); - Assert.assertEquals(message, normal, noEmConcept); + Assertions.assertEquals(noEmConcept, normal, message); + Assertions.assertEquals(normal, noEmConcept, message); } @@ -153,15 +153,15 @@ final void testEqualsForIncompleteAttributes_technology() { noTechnology.setHbefaEmConcept(concept); noTechnology.setHbefaSizeClass(sizeClass); message = "no technology was set, therefore " + normal.getHbefaTechnology() + " should not equal " + noTechnology.getHbefaTechnology(); - Assert.assertNotEquals(message, noTechnology, normal); - Assert.assertNotEquals(message, normal, noTechnology); + Assertions.assertNotEquals(noTechnology, normal, message); + Assertions.assertNotEquals(normal, noTechnology, message); //set the hbefa technology of the normal vehicle attributes to 'average' //then noTechnology is equal to normal normal.setHbefaTechnology("average"); message = "no em concept was set, therefore " + noTechnology.getHbefaEmConcept() + "should be set to 'average'"; - Assert.assertEquals(message, noTechnology, normal); - Assert.assertEquals(message, normal, noTechnology); + Assertions.assertEquals(noTechnology, normal, message); + Assertions.assertEquals(normal, noTechnology, message); } @@ -178,13 +178,13 @@ final void testEqualsForIncompleteAttributes_sizeClass(){ noSize.setHbefaEmConcept(concept); noSize.setHbefaTechnology(technology); message = "no size class was set, therefore " + normal.getHbefaSizeClass() + " should not equal " + noSize.getHbefaSizeClass(); - Assert.assertNotEquals(message, noSize, normal); - Assert.assertNotEquals(message, normal, noSize); + Assertions.assertNotEquals(noSize, normal, message); + Assertions.assertNotEquals(normal, noSize, message); normal.setHbefaSizeClass("average"); message = "no size class was set, therefore " + noSize.getHbefaEmConcept() + "should be set to 'average'"; - Assert.assertEquals(message, noSize, normal); - Assert.assertEquals(message, normal, noSize); + Assertions.assertEquals(noSize, normal, message); + Assertions.assertEquals(normal, noSize, message); } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaWarmEmissionFactorKey.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaWarmEmissionFactorKey.java index c8c60aeaee3..2ff96fb02bd 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaWarmEmissionFactorKey.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestHbefaWarmEmissionFactorKey.java @@ -22,10 +22,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.matsim.contrib.emissions.Pollutant.CO; import static org.matsim.contrib.emissions.Pollutant.FC; @@ -80,8 +80,8 @@ final void testEqualsForCompleteKeys(){ compare.setVehicleCategory(hbefaVehicleCategory); String message = "these two objects should be the same but are not: " + normal.toString() + " and " + compare.toString(); - Assert.assertTrue(message, normal.equals(compare)); - Assert.assertTrue(message, compare.equals(normal)); + Assertions.assertTrue(normal.equals(compare), message); + Assertions.assertTrue(compare.equals(normal), message); //two unequal but complete objects HbefaWarmEmissionFactorKey different = new HbefaWarmEmissionFactorKey(); @@ -97,8 +97,8 @@ final void testEqualsForCompleteKeys(){ message = "these two objects should not be the same: " + normal.toString() + " and " + different.toString(); - assertFalse(message, different.equals(normal)); - assertFalse(message, normal.equals(different)); + assertFalse(different.equals(normal), message); + assertFalse(normal.equals(different), message); } // the following tests each compare a incomplete key to a complete key @@ -169,8 +169,8 @@ final void testEqualsForIncompleteKeys_roadCategory() { String message = "these two HbefaWarmEmissionFactorKeys should not be the same: " + normal.toString() + " and " + noRoadCat.toString(); String message2 = "this key should not be comparable since no road category is set"; - Assert.assertTrue(message2, equalErr); - assertFalse(message, normal.equals(noRoadCat)); + Assertions.assertTrue(equalErr, message2); + assertFalse(normal.equals(noRoadCat), message); } @Test @@ -233,11 +233,11 @@ final void testEqualsForIncompleteKeys_vehicleAttributes(){ } String message = "these two HbefaWarmEmissionFactorKeys should not be the same: " + normal.toString() + " and " + noVehAtt.toString(); - assertFalse(message, noVehAtt.equals(normal)); + assertFalse(noVehAtt.equals(normal), message); assertFalse(equalErr); // veh attributes are allowed to be not initiated // therefore this should not throw a nullpointer but return false - assertFalse(message, normal.equals(noVehAtt)); + assertFalse(normal.equals(noVehAtt), message); //set the vehicle attributes of the normal hbefacoldemissionfactorkey to 'average' //then noVehAtt is equal to normal @@ -248,8 +248,8 @@ final void testEqualsForIncompleteKeys_vehicleAttributes(){ normal.setVehicleAttributes(hbefaVehicleAttributesAverage); message = "these two HbefaWarmEmissionFactorKeys should be the same: " + normal.toString() + " and " + noVehAtt.toString(); - Assert.assertTrue(message, normal.equals(noVehAtt)); - Assert.assertTrue(message, noVehAtt.equals(normal)); + Assertions.assertTrue(normal.equals(noVehAtt), message); + Assertions.assertTrue(noVehAtt.equals(normal), message); } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java index 03d6e88cbbf..b54c7c286c5 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java @@ -43,13 +43,13 @@ import org.matsim.vis.snapshotwriters.PositionEvent; import jakarta.inject.Singleton; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; -import static org.junit.Assert.assertEquals; - public class TestPositionEmissionModule { private static final String configFile = IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "emissions-sampleScenario/testv2_Vehv2" ), "config_detailed.xml" ).toString(); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModule.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModule.java index fd437883c91..92440ecfd30 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModule.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModule.java @@ -20,7 +20,7 @@ package org.matsim.contrib.emissions; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -149,18 +149,18 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent6() catch(RuntimeException re){ exceptionThrown = true; } - Assert.assertTrue("An average speed higher than the free flow speed should throw a runtime exception",exceptionThrown); + Assertions.assertTrue(exceptionThrown,"An average speed higher than the free flow speed should throw a runtime exception"); { //avg=ff=sg -> use ff factors Map warmEmissions = emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(sgffVehicle, sgflink, sgffLinklength / AVG_PASSENGER_CAR_SPEED_FF_KMH * 3.6); - Assert.assertEquals(DETAILED_SGFF_FACTOR_FF * sgffLinklength / 1000., warmEmissions.get(NO2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(DETAILED_SGFF_FACTOR_FF * sgffLinklength / 1000., warmEmissions.get(NO2), MatsimTestUtils.EPSILON); } { //avg use sg factors Map warmEmissions = emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(sgffVehicle, sgflink, 2*sgffLinklength/ AVG_PASSENGER_CAR_SPEED_FF_KMH *3.6 ); - Assert.assertEquals( DETAILED_SGFF_FACTOR_SG *sgffLinklength/1000., warmEmissions.get(NO2 ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( DETAILED_SGFF_FACTOR_SG *sgffLinklength/1000., warmEmissions.get(NO2 ), MatsimTestUtils.EPSILON ); } } @@ -191,7 +191,7 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Ex }catch(Exception e){ excep = true; } - Assert.assertFalse(excep); + Assertions.assertFalse(excep); excep=false; } @@ -218,7 +218,7 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Ex }catch(Exception e){ excep = true; } - Assert.assertTrue(excep); excep=false; + Assertions.assertTrue(excep); excep=false; } @Test @@ -242,7 +242,7 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Ex }catch(Exception e){ excep = true; } - Assert.assertTrue(excep); excep=false; + Assertions.assertTrue(excep); excep=false; } @Test @@ -264,7 +264,7 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Ex }catch(Exception e){ excep = true; } - Assert.assertTrue(excep); excep=false; + Assertions.assertTrue(excep); excep=false; } @@ -285,25 +285,25 @@ void testCounters7(){ // ff < avg < ff+1 - handled like free flow double travelTime = tableLinkLength/(AVG_PASSENGER_CAR_SPEED_FF_KMH +0.5)*3.6; emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(tableVehicle, tableLink, travelTime ); - Assert.assertEquals(0, emissionsModule.getFractionOccurences() ); - Assert.assertEquals(tableLinkLength/1000., emissionsModule.getFreeFlowKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(1, emissionsModule.getFreeFlowOccurences() ); - Assert.assertEquals(tableLinkLength/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(0., emissionsModule.getStopGoKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(0, emissionsModule.getStopGoOccurences() ); - Assert.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); + Assertions.assertEquals(0, emissionsModule.getFractionOccurences() ); + Assertions.assertEquals(tableLinkLength/1000., emissionsModule.getFreeFlowKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(1, emissionsModule.getFreeFlowOccurences() ); + Assertions.assertEquals(tableLinkLength/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(0., emissionsModule.getStopGoKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(0, emissionsModule.getStopGoOccurences() ); + Assertions.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); emissionsModule.reset(); // ff < sg < avg - handled like free flow as well - no additional test needed // avg < ff < sg - handled like stop go emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(tableVehicle, tableLink, 2* tableLinkLength/(AVG_PASSENGER_CAR_SPEED_FF_KMH)*3.6 ); - Assert.assertEquals(0, emissionsModule.getFractionOccurences() ); - Assert.assertEquals(0., emissionsModule.getFreeFlowKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(0, emissionsModule.getFreeFlowOccurences() ); - Assert.assertEquals(tableLinkLength/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(tableLinkLength/1000, emissionsModule.getStopGoKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(1, emissionsModule.getStopGoOccurences() ); - Assert.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); + Assertions.assertEquals(0, emissionsModule.getFractionOccurences() ); + Assertions.assertEquals(0., emissionsModule.getFreeFlowKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(0, emissionsModule.getFreeFlowOccurences() ); + Assertions.assertEquals(tableLinkLength/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(tableLinkLength/1000, emissionsModule.getStopGoKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(1, emissionsModule.getStopGoOccurences() ); + Assertions.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); emissionsModule.reset(); } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase1.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase1.java index ed4a1e7322a..48734493dce 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase1.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase1.java @@ -20,7 +20,7 @@ package org.matsim.contrib.emissions; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -150,12 +150,12 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent1() Vehicle vehicle = vehFac.createVehicle(vehicleId, vehFac.createVehicleType(vehicleTypeId)); Map warmEmissions = warmEmissionAnalysisModule.checkVehicleInfoAndCalculateWarmEmissions( vehicle, mockLink, linkLength / PETROL_SPEED_FF * 3.6 ); - Assert.assertEquals(DETAILED_PETROL_FACTOR_FF *linkLength/1000., warmEmissions.get( CO2_TOTAL ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(DETAILED_PETROL_FACTOR_FF *linkLength/1000., warmEmissions.get( CO2_TOTAL ), MatsimTestUtils.EPSILON ); emissionEventManager.reset(); warmEmissionAnalysisModule.throwWarmEmissionEvent(leaveTime, mockLink.getId(), vehicleId, warmEmissions ); - Assert.assertEquals( pollutants.size() * DETAILED_PETROL_FACTOR_FF *linkLength/1000., emissionEventManager.getSum(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( pollutants.size() * DETAILED_PETROL_FACTOR_FF *linkLength/1000., emissionEventManager.getSum(), MatsimTestUtils.EPSILON ); emissionEventManager.reset(); warmEmissions.clear(); @@ -186,24 +186,24 @@ void testCounters1(){ // s&g speed, ff speed @@ -249,7 +249,7 @@ void testCounters1(){ }catch(RuntimeException re){ exceptionThrown = true; } - Assert.assertTrue("An average speed higher than the free flow speed should throw a runtime exception", exceptionThrown); + Assertions.assertTrue(exceptionThrown, "An average speed higher than the free flow speed should throw a runtime exception"); warmEmissionAnalysisModule.reset(); } @@ -282,26 +282,26 @@ void testCounters5(){ switch( emissionsComputationMethod ) { case StopAndGoFraction: - Assert.assertEquals(0, emissionsModule.getFreeFlowOccurences() ); + Assertions.assertEquals(0, emissionsModule.getFreeFlowOccurences() ); break; case AverageSpeed: - Assert.assertEquals(1, emissionsModule.getFreeFlowOccurences() ); + Assertions.assertEquals(1, emissionsModule.getFreeFlowOccurences() ); break; default: throw new IllegalStateException( "Unexpected value: " + emissionsComputationMethod ); } - Assert.assertEquals(inconff/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(0, emissionsModule.getStopGoOccurences() ); - Assert.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); + Assertions.assertEquals(inconff/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(0, emissionsModule.getStopGoOccurences() ); + Assertions.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); emissionsModule.reset(); // average speed equals wrong free flow speed emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(inconffVehicle, inconLink, inconff / inconffavgSpeed * 3.6); - Assert.assertEquals(1, emissionsModule.getFreeFlowOccurences() ); - Assert.assertEquals(inconff/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(0, emissionsModule.getStopGoOccurences() ); - Assert.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); + Assertions.assertEquals(1, emissionsModule.getFreeFlowOccurences() ); + Assertions.assertEquals(inconff/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(0, emissionsModule.getStopGoOccurences() ); + Assertions.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); //@KMT is there the need for adding a test here? emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(inconffVehicle, inconLink, 2 * inconff / (PETROL_SPEED_FF + PETROL_SPEED_SG) * 3.6); @@ -331,50 +331,50 @@ void testCounters1fractional(){ // s&g speed, ff speed @@ -384,7 +384,7 @@ void testCounters1fractional(){ }catch(RuntimeException re){ exceptionThrown = true; } - Assert.assertTrue("An average speed higher than the free flow speed should throw a runtime exception", exceptionThrown); + Assertions.assertTrue(exceptionThrown, "An average speed higher than the free flow speed should throw a runtime exception"); emissionsModule.reset(); emissionsModule.getEcg().setEmissionsComputationMethod(AverageSpeed ); @@ -413,20 +413,20 @@ void testCounters6(){ // average speed equals free flow speed from table emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(inconffVehicle, inconLink, inconff / PETROL_SPEED_FF * 3.6); - Assert.assertEquals(1, emissionsModule.getFractionOccurences() ); - Assert.assertEquals(0, emissionsModule.getFreeFlowOccurences() ); - Assert.assertEquals(inconff/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(0, emissionsModule.getStopGoOccurences() ); - Assert.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); + Assertions.assertEquals(1, emissionsModule.getFractionOccurences() ); + Assertions.assertEquals(0, emissionsModule.getFreeFlowOccurences() ); + Assertions.assertEquals(inconff/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(0, emissionsModule.getStopGoOccurences() ); + Assertions.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); emissionsModule.reset(); // average speed equals wrong free flow speed emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(inconffVehicle, inconLink, inconff / inconffavgSpeed * 3.6); - Assert.assertEquals(0, emissionsModule.getFractionOccurences() ); - Assert.assertEquals(1, emissionsModule.getFreeFlowOccurences() ); - Assert.assertEquals(inconff/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(0, emissionsModule.getStopGoOccurences() ); - Assert.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); + Assertions.assertEquals(0, emissionsModule.getFractionOccurences() ); + Assertions.assertEquals(1, emissionsModule.getFreeFlowOccurences() ); + Assertions.assertEquals(inconff/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(0, emissionsModule.getStopGoOccurences() ); + Assertions.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(inconffVehicle, inconLink, 2 * inconff / (PETROL_SPEED_FF + PETROL_SPEED_SG) * 3.6); } @@ -448,13 +448,13 @@ void testCounters8(){ Link pcLink = createMockLink("link table", linkLength, PETROL_SPEED_FF / 3.6 ); emissionsModule.reset(); - Assert.assertEquals(0, emissionsModule.getFractionOccurences() ); - Assert.assertEquals(0., emissionsModule.getFreeFlowKmCounter(), 1e-7 ); - Assert.assertEquals(0, emissionsModule.getFreeFlowOccurences() ); - Assert.assertEquals(0., emissionsModule.getKmCounter(), 1e-7 ); - Assert.assertEquals(0., emissionsModule.getStopGoKmCounter(), 1e-7 ); - Assert.assertEquals(0, emissionsModule.getStopGoOccurences() ); - Assert.assertEquals(0, emissionsModule.getWarmEmissionEventCounter() ); + Assertions.assertEquals(0, emissionsModule.getFractionOccurences() ); + Assertions.assertEquals(0., emissionsModule.getFreeFlowKmCounter(), 1e-7 ); + Assertions.assertEquals(0, emissionsModule.getFreeFlowOccurences() ); + Assertions.assertEquals(0., emissionsModule.getKmCounter(), 1e-7 ); + Assertions.assertEquals(0., emissionsModule.getStopGoKmCounter(), 1e-7 ); + Assertions.assertEquals(0, emissionsModule.getStopGoOccurences() ); + Assertions.assertEquals(0, emissionsModule.getWarmEmissionEventCounter() ); // < s&g speed emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(vehicle, pcLink, travelTime * 3.6); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase2.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase2.java index b79d61d4bd2..4549248da51 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase2.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase2.java @@ -20,7 +20,7 @@ package org.matsim.contrib.emissions; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -158,11 +158,11 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent2() // After discussion with Kai N. we decided to let it as it is for the time being. I will add a log.info in the consistency checker. KMT Jul'20 //results should be equal here, because in both cases only the freeflow value is relevant (100% freeflow, 0% stop&go). - Assert.assertEquals( 0.1, warmEmissions.get( NMHC ), MatsimTestUtils.EPSILON ); //(*#) + Assertions.assertEquals( 0.1, warmEmissions.get( NMHC ), MatsimTestUtils.EPSILON ); //(*#) // throw and test corresponding event: emissionsModule.throwWarmEmissionEvent( leaveTime, pclink.getId(), pcVehicleId, warmEmissions ); - Assert.assertEquals( 2.3, emissionEventManager.getSum(), MatsimTestUtils.EPSILON ); //seems to be (0.1 (g/km -- see expected values a few lines above(*#) * number of entries in enum Pollutant) + Assertions.assertEquals( 2.3, emissionEventManager.getSum(), MatsimTestUtils.EPSILON ); //seems to be (0.1 (g/km -- see expected values a few lines above(*#) * number of entries in enum Pollutant) emissionEventManager.reset(); warmEmissions.clear(); @@ -171,10 +171,10 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent2() // sub case avg speed = stop go speed { warmEmissions = emissionsModule.checkVehicleInfoAndCalculateWarmEmissions( pcVehicle, pclink, pclinkLength / PCSG_VELOCITY_KMH * 3.6 ); - Assert.assertEquals( AVG_PC_FACTOR_SG * pclinkLength / 1000., warmEmissions.get( NMHC ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( AVG_PC_FACTOR_SG * pclinkLength / 1000., warmEmissions.get( NMHC ), MatsimTestUtils.EPSILON ); emissionsModule.throwWarmEmissionEvent( leaveTime, pclink.getId(), pcVehicleId, warmEmissions ); - Assert.assertEquals(pollutants.size() * AVG_PC_FACTOR_SG * pclinkLength / 1000., emissionEventManager.getSum(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(pollutants.size() * AVG_PC_FACTOR_SG * pclinkLength / 1000., emissionEventManager.getSum(), MatsimTestUtils.EPSILON ); emissionsModule.reset(); warmEmissions.clear(); } @@ -200,24 +200,24 @@ void testCounters3(){ // sub case: current speed equals free flow speed warmEmissions = emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(pcVehicle,pclink, pclinkLength/ PC_FREE_VELOCITY_KMH *3.6 ); - Assert.assertEquals(0, emissionsModule.getFractionOccurences() ); - Assert.assertEquals(pclinkLength/1000, emissionsModule.getFreeFlowKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(1, emissionsModule.getFreeFlowOccurences() ); - Assert.assertEquals(pclinkLength/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(0., emissionsModule.getStopGoKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(0, emissionsModule.getStopGoOccurences() ); - Assert.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); + Assertions.assertEquals(0, emissionsModule.getFractionOccurences() ); + Assertions.assertEquals(pclinkLength/1000, emissionsModule.getFreeFlowKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(1, emissionsModule.getFreeFlowOccurences() ); + Assertions.assertEquals(pclinkLength/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(0., emissionsModule.getStopGoKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(0, emissionsModule.getStopGoOccurences() ); + Assertions.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); emissionsModule.reset(); // sub case: current speed equals stop go speed warmEmissions = emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(pcVehicle, pclink, pclinkLength/ PCSG_VELOCITY_KMH *3.6 ); - Assert.assertEquals(0, emissionsModule.getFractionOccurences() ); - Assert.assertEquals(0., emissionsModule.getFreeFlowKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(0, emissionsModule.getFreeFlowOccurences() ); - Assert.assertEquals(pclinkLength/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(pclinkLength/1000, emissionsModule.getStopGoKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(1, emissionsModule.getStopGoOccurences() ); - Assert.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); + Assertions.assertEquals(0, emissionsModule.getFractionOccurences() ); + Assertions.assertEquals(0., emissionsModule.getFreeFlowKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(0, emissionsModule.getFreeFlowOccurences() ); + Assertions.assertEquals(pclinkLength/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(pclinkLength/1000, emissionsModule.getStopGoKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(1, emissionsModule.getStopGoOccurences() ); + Assertions.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase3.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase3.java index 70c8e007f2b..b0c11c1f770 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase3.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase3.java @@ -20,7 +20,7 @@ package org.matsim.contrib.emissions; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -133,19 +133,19 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent3() // sub case avg speed = free flow speed warmEmissions = emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(dieselVehicle, diesellink, dieselLinkLength/ TestWarmEmissionAnalysisModule.AVG_PASSENGER_CAR_SPEED_FF_KMH *3.6 ); - Assert.assertEquals( AVG_PC_FACTOR_FF *dieselLinkLength/1000., warmEmissions.get(PM ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( AVG_PC_FACTOR_FF *dieselLinkLength/1000., warmEmissions.get(PM ), MatsimTestUtils.EPSILON ); emissionEventManager.reset(); emissionsModule.throwWarmEmissionEvent(leaveTime, diesellink.getId(), dieselVehicleId, warmEmissions ); - Assert.assertEquals( pollutants.size() * AVG_PC_FACTOR_FF *dieselLinkLength/1000., emissionEventManager.getSum(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( pollutants.size() * AVG_PC_FACTOR_FF *dieselLinkLength/1000., emissionEventManager.getSum(), MatsimTestUtils.EPSILON ); emissionEventManager.reset(); warmEmissions.clear(); // sub case avg speed = stop go speed warmEmissions = emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(dieselVehicle, diesellink, dieselLinkLength/ TestWarmEmissionAnalysisModule.AVG_PASSENGER_CAR_SPEED_SG_KMH *3.6 ); - Assert.assertEquals( AVG_PC_FACTOR_SG *dieselLinkLength/1000., warmEmissions.get(PM ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( AVG_PC_FACTOR_SG *dieselLinkLength/1000., warmEmissions.get(PM ), MatsimTestUtils.EPSILON ); emissionEventManager.reset(); emissionsModule.throwWarmEmissionEvent(leaveTime, diesellink.getId(), dieselVehicleId, warmEmissions ); - Assert.assertEquals( pollutants.size() * AVG_PC_FACTOR_SG *dieselLinkLength/1000., emissionEventManager.getSum(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( pollutants.size() * AVG_PC_FACTOR_SG *dieselLinkLength/1000., emissionEventManager.getSum(), MatsimTestUtils.EPSILON ); emissionEventManager.reset(); warmEmissions.clear(); } @@ -170,24 +170,24 @@ void testCounters4(){ // sub case: current speed equals free flow speed warmEmissions = emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(dieselVehicle, diesellink, dieselLinkLength/ TestWarmEmissionAnalysisModule.AVG_PASSENGER_CAR_SPEED_FF_KMH *3.6 ); - Assert.assertEquals(0, emissionsModule.getFractionOccurences() ); - Assert.assertEquals(dieselLinkLength/1000., emissionsModule.getFreeFlowKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(1, emissionsModule.getFreeFlowOccurences() ); - Assert.assertEquals(dieselLinkLength/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(0., emissionsModule.getStopGoKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(0, emissionsModule.getStopGoOccurences() ); - Assert.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); + Assertions.assertEquals(0, emissionsModule.getFractionOccurences() ); + Assertions.assertEquals(dieselLinkLength/1000., emissionsModule.getFreeFlowKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(1, emissionsModule.getFreeFlowOccurences() ); + Assertions.assertEquals(dieselLinkLength/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(0., emissionsModule.getStopGoKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(0, emissionsModule.getStopGoOccurences() ); + Assertions.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); emissionsModule.reset(); // sub case: current speed equals stop go speed warmEmissions = emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(dieselVehicle, diesellink, dieselLinkLength/ TestWarmEmissionAnalysisModule.AVG_PASSENGER_CAR_SPEED_SG_KMH *3.6 ); - Assert.assertEquals(0, emissionsModule.getFractionOccurences() ); - Assert.assertEquals(0., emissionsModule.getFreeFlowKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(0, emissionsModule.getFreeFlowOccurences() ); - Assert.assertEquals(dieselLinkLength/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(dieselLinkLength/1000., emissionsModule.getStopGoKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(1, emissionsModule.getStopGoOccurences() ); - Assert.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); + Assertions.assertEquals(0, emissionsModule.getFractionOccurences() ); + Assertions.assertEquals(0., emissionsModule.getFreeFlowKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(0, emissionsModule.getFreeFlowOccurences() ); + Assertions.assertEquals(dieselLinkLength/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(dieselLinkLength/1000., emissionsModule.getStopGoKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(1, emissionsModule.getStopGoOccurences() ); + Assertions.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); emissionsModule.reset(); } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase4.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase4.java index 8202a25ca35..6ceab142803 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase4.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase4.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -139,19 +139,19 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent4() // sub case avg speed = stop go speed warmEmissions = emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(lpgVehicle, lpglink, lpgLinkLength/ SPEED_SG *3.6 ); - Assert.assertEquals( AVG_PC_FACTOR_SG *lpgLinkLength/1000., warmEmissions.get(PM), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( AVG_PC_FACTOR_SG *lpgLinkLength/1000., warmEmissions.get(PM), MatsimTestUtils.EPSILON ); emissionEventManager.reset(); emissionsModule.throwWarmEmissionEvent(leaveTime, lpglink.getId(), lpgVehicleId, warmEmissions ); - Assert.assertEquals( pollutants.size() * AVG_PC_FACTOR_SG *lpgLinkLength/1000., emissionEventManager.getSum(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( pollutants.size() * AVG_PC_FACTOR_SG *lpgLinkLength/1000., emissionEventManager.getSum(), MatsimTestUtils.EPSILON ); emissionEventManager.reset(); warmEmissions.clear(); // sub case avg speed = free flow speed warmEmissions = emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(lpgVehicle, lpglink, lpgLinkLength/ SPEED_FF *3.6 ); - Assert.assertEquals( AVG_PC_FACTOR_FF *lpgLinkLength/1000., warmEmissions.get(PM ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( AVG_PC_FACTOR_FF *lpgLinkLength/1000., warmEmissions.get(PM ), MatsimTestUtils.EPSILON ); emissionEventManager.reset(); emissionsModule.throwWarmEmissionEvent(leaveTime, lpglink.getId(), lpgVehicleId, warmEmissions ); - Assert.assertEquals( pollutants.size() * AVG_PC_FACTOR_FF *lpgLinkLength/1000., emissionEventManager.getSum(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( pollutants.size() * AVG_PC_FACTOR_FF *lpgLinkLength/1000., emissionEventManager.getSum(), MatsimTestUtils.EPSILON ); warmEmissions.clear(); } @@ -176,24 +176,24 @@ void testCounters2(){ // sub case: current speed equals free flow speed warmEmissions = emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(vehicle, lpgLink, lpgLinkLength/ SPEED_FF *3.6 ); - Assert.assertEquals(0, emissionsModule.getFractionOccurences() ); - Assert.assertEquals(lpgLinkLength/1000, emissionsModule.getFreeFlowKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(1, emissionsModule.getFreeFlowOccurences() ); - Assert.assertEquals(lpgLinkLength/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(.0, emissionsModule.getStopGoKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(0, emissionsModule.getStopGoOccurences() ); - Assert.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); + Assertions.assertEquals(0, emissionsModule.getFractionOccurences() ); + Assertions.assertEquals(lpgLinkLength/1000, emissionsModule.getFreeFlowKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(1, emissionsModule.getFreeFlowOccurences() ); + Assertions.assertEquals(lpgLinkLength/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(.0, emissionsModule.getStopGoKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(0, emissionsModule.getStopGoOccurences() ); + Assertions.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); emissionsModule.reset(); // sub case: current speed equals free flow speed warmEmissions = emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(vehicle, lpgLink, lpgLinkLength/ SPEED_SG *3.6 ); - Assert.assertEquals(0, emissionsModule.getFractionOccurences() ); - Assert.assertEquals(0., emissionsModule.getFreeFlowKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(0, emissionsModule.getFreeFlowOccurences() ); - Assert.assertEquals(lpgLinkLength/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(lpgLinkLength/1000, emissionsModule.getStopGoKmCounter(), MatsimTestUtils.EPSILON ); - Assert.assertEquals(1, emissionsModule.getStopGoOccurences() ); - Assert.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); + Assertions.assertEquals(0, emissionsModule.getFractionOccurences() ); + Assertions.assertEquals(0., emissionsModule.getFreeFlowKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(0, emissionsModule.getFreeFlowOccurences() ); + Assertions.assertEquals(lpgLinkLength/1000, emissionsModule.getKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(lpgLinkLength/1000, emissionsModule.getStopGoKmCounter(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(1, emissionsModule.getStopGoOccurences() ); + Assertions.assertEquals(1, emissionsModule.getWarmEmissionEventCounter() ); } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase5.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase5.java index 3fd040f0950..86a2dbc4792 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase5.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase5.java @@ -20,7 +20,7 @@ package org.matsim.contrib.emissions; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -137,10 +137,10 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent5() Vehicle zeroVehicle = vehFac.createVehicle(zeroVehicleId, vehFac.createVehicleType(zeroVehicleTypeId)); Map warmEmissions = emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(zeroVehicle, zerolink, 2 * zeroLinklength / (zeroFreeVelocity + zeroSgVelocity) * 3.6); - Assert.assertEquals( DETAILED_ZERO_FACTOR_FF *zeroLinklength/1000., warmEmissions.get(PM ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( DETAILED_ZERO_FACTOR_FF *zeroLinklength/1000., warmEmissions.get(PM ), MatsimTestUtils.EPSILON ); emissionsModule.throwWarmEmissionEvent(22., lpgLinkId, zeroVehicleId, warmEmissions); - Assert.assertEquals( pollutants.size() * DETAILED_ZERO_FACTOR_FF *zeroLinklength/1000., emissionEventManager.getSum(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( pollutants.size() * DETAILED_ZERO_FACTOR_FF *zeroLinklength/1000., emissionEventManager.getSum(), MatsimTestUtils.EPSILON ); warmEmissions.clear(); } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionsFallbackBehaviour.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionsFallbackBehaviour.java index ee7ccc6eeee..4d7d500299e 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionsFallbackBehaviour.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionsFallbackBehaviour.java @@ -23,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -76,7 +76,7 @@ void testWarmDetailedValueOnlyDetailed() { Map warmEmissions = emissionModule.getWarmEmissionAnalysisModule().checkVehicleInfoAndCalculateWarmEmissions(vehicleFull, link, travelTimeOnLink); double expectedValue = 30.34984742; // = 200m * 151.7492371 g/km - Assert.assertEquals( expectedValue, warmEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( expectedValue, warmEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); } @@ -132,7 +132,7 @@ void testWarm_DetailedThenTechnologyAverageElseAbort_FallbackNotNeeded() { Map warmEmissions = emissionModule.getWarmEmissionAnalysisModule().checkVehicleInfoAndCalculateWarmEmissions(vehicleFull, link, travelTimeOnLink); double expectedValue = 30.34984742; // = 200m * 151.7492371 g/km - Assert.assertEquals( expectedValue, warmEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( expectedValue, warmEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); } @@ -151,7 +151,7 @@ void testWarm_DetailedThenTechnologyAverageElseAbort_FallbackToTechnologyAverage Map warmEmissions = emissionModule.getWarmEmissionAnalysisModule().checkVehicleInfoAndCalculateWarmEmissions(vehicleFallbackToTechnologyAverage, link, travelTimeOnLink); double expectedValue = 31.53711548; // = 200m * 157.6855774 g/km - Assert.assertEquals( expectedValue, warmEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( expectedValue, warmEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); } /** @@ -188,7 +188,7 @@ void testWarm_DetailedThenTechnologyAverageThenAverageTable_FallbackNotNeeded() Map warmEmissions = emissionModule.getWarmEmissionAnalysisModule().checkVehicleInfoAndCalculateWarmEmissions(vehicleFull, link, travelTimeOnLink); double expectedValue = 30.34984742; // = 200m * 151.7492371 g/km - Assert.assertEquals( expectedValue, warmEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( expectedValue, warmEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); } @@ -207,7 +207,7 @@ void testWarm_DetailedThenTechnologyAverageThenAverageTable_FallbackToTechnology Map warmEmissions = emissionModule.getWarmEmissionAnalysisModule().checkVehicleInfoAndCalculateWarmEmissions(vehicleFallbackToTechnologyAverage, link, travelTimeOnLink); double expectedValue = 31.53711548; // = 200m * 157.6855774 g/km - Assert.assertEquals( expectedValue, warmEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( expectedValue, warmEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); } /** @@ -227,7 +227,7 @@ void testWarm_DetailedThenTechnologyAverageThenAverageTable_FallbackToAverageTab Map warmEmissions = emissionModule.getWarmEmissionAnalysisModule().checkVehicleInfoAndCalculateWarmEmissions(vehicleFallbackToAverageTable, link, travelTimeOnLink); double expectedValue = 31.1947174; // = 200m * 155.973587 g/km - Assert.assertEquals( expectedValue, warmEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( expectedValue, warmEmissions.get(Pollutant.CO2_TOTAL ), MatsimTestUtils.EPSILON ); } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/VspHbefaRoadTypeMappingTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/VspHbefaRoadTypeMappingTest.java index 7caf57a3bc9..f0164d11e86 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/VspHbefaRoadTypeMappingTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/VspHbefaRoadTypeMappingTest.java @@ -6,7 +6,7 @@ import org.matsim.api.core.v01.network.Link; import org.matsim.core.network.NetworkUtils; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class VspHbefaRoadTypeMappingTest { diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionGridAnalyzerTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionGridAnalyzerTest.java index df4bd3474a3..d9614bd3dea 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionGridAnalyzerTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionGridAnalyzerTest.java @@ -32,8 +32,7 @@ import java.util.Map; import java.util.UUID; -import static org.junit.Assert.*; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; import static org.matsim.contrib.emissions.Pollutant.*; public class EmissionGridAnalyzerTest { diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionsByPollutantTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionsByPollutantTest.java index 2575ebf4470..635affd8832 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionsByPollutantTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionsByPollutantTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.emissions.analysis; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.matsim.contrib.emissions.Pollutant.CO; import static org.matsim.contrib.emissions.Pollutant.NO2; diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionsOnLinkEventHandlerTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionsOnLinkEventHandlerTest.java index cc7b9df638c..fe8c91a53ab 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionsOnLinkEventHandlerTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/EmissionsOnLinkEventHandlerTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.emissions.analysis; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import static org.matsim.contrib.emissions.Pollutant.HC; import java.util.ArrayList; diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/FastEmissionGridAnalyzerTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/FastEmissionGridAnalyzerTest.java index 0ea0f7b3f9b..423131e4f6f 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/FastEmissionGridAnalyzerTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/FastEmissionGridAnalyzerTest.java @@ -15,8 +15,8 @@ import java.nio.file.Paths; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class FastEmissionGridAnalyzerTest { diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RasterTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RasterTest.java index 2bcc4d639db..7e6b360020d 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RasterTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RasterTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.emissions.analysis; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import org.junit.jupiter.api.Test; diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RawEmissionEventsReaderTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RawEmissionEventsReaderTest.java index 307667309b6..4592d26ec17 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RawEmissionEventsReaderTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/analysis/RawEmissionEventsReaderTest.java @@ -12,7 +12,7 @@ import java.nio.file.Paths; import java.util.concurrent.atomic.AtomicInteger; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class RawEmissionEventsReaderTest { diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/TestColdEmissionEventImpl.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/TestColdEmissionEventImpl.java index c4dff777494..022265df9f0 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/TestColdEmissionEventImpl.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/TestColdEmissionEventImpl.java @@ -21,7 +21,7 @@ package org.matsim.contrib.emissions.events; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -64,20 +64,13 @@ final void testGetAttributesForCompleteEmissionMaps(){ ColdEmissionEvent ce = new ColdEmissionEvent(0.0, linkId, vehicleId, coldEmissionsMap); Map ceg = ce.getAttributes(); - Assert.assertEquals("the CO value of this cold emission event was "+ Double.parseDouble(ceg.get(CO.name()))+ "but should have been "+ co, - Double.parseDouble(ceg.get(CO.name())), co, MatsimTestUtils.EPSILON); - Assert.assertEquals("the FC value of this cold emission event was "+ Double.parseDouble(ceg.get(FC.name()))+ "but should have been "+ fc, - Double.parseDouble(ceg.get(FC.name())), fc, MatsimTestUtils.EPSILON); - Assert.assertEquals("the HC value of this cold emission event was "+ Double.parseDouble(ceg.get(HC.name()))+ "but should have been "+ hc, - Double.parseDouble(ceg.get(HC.name())), hc, MatsimTestUtils.EPSILON); - Assert.assertEquals("the NMHC value of this cold emission event was "+ Double.parseDouble(ceg.get(NMHC.name()))+ "but should have been "+ nm, - Double.parseDouble(ceg.get(NMHC.name())), nm, MatsimTestUtils.EPSILON); - Assert.assertEquals("the NO2 value of this cold emission event was "+ Double.parseDouble(ceg.get(NO2.name()))+ "but should have been "+ n2, - Double.parseDouble(ceg.get(NO2.name())), n2, MatsimTestUtils.EPSILON); - Assert.assertEquals("the NOx value of this cold emission event was "+ Double.parseDouble(ceg.get(NOx.name()))+ "but should have been "+ nx, - Double.parseDouble(ceg.get(NOx.name())), nx, MatsimTestUtils.EPSILON); - Assert.assertEquals("the PM value of this cold emission event was "+ Double.parseDouble(ceg.get(PM.name()))+ "but should have been "+ pm, - Double.parseDouble(ceg.get(PM.name())), pm, MatsimTestUtils.EPSILON); + Assertions.assertEquals(Double.parseDouble(ceg.get(CO.name())), co, MatsimTestUtils.EPSILON, "the CO value of this cold emission event was "+ Double.parseDouble(ceg.get(CO.name()))+ "but should have been "+ co); + Assertions.assertEquals(Double.parseDouble(ceg.get(FC.name())), fc, MatsimTestUtils.EPSILON, "the FC value of this cold emission event was "+ Double.parseDouble(ceg.get(FC.name()))+ "but should have been "+ fc); + Assertions.assertEquals(Double.parseDouble(ceg.get(HC.name())), hc, MatsimTestUtils.EPSILON, "the HC value of this cold emission event was "+ Double.parseDouble(ceg.get(HC.name()))+ "but should have been "+ hc); + Assertions.assertEquals(Double.parseDouble(ceg.get(NMHC.name())), nm, MatsimTestUtils.EPSILON, "the NMHC value of this cold emission event was "+ Double.parseDouble(ceg.get(NMHC.name()))+ "but should have been "+ nm); + Assertions.assertEquals(Double.parseDouble(ceg.get(NO2.name())), n2, MatsimTestUtils.EPSILON, "the NO2 value of this cold emission event was "+ Double.parseDouble(ceg.get(NO2.name()))+ "but should have been "+ n2); + Assertions.assertEquals(Double.parseDouble(ceg.get(NOx.name())), nx, MatsimTestUtils.EPSILON, "the NOx value of this cold emission event was "+ Double.parseDouble(ceg.get(NOx.name()))+ "but should have been "+ nx); + Assertions.assertEquals(Double.parseDouble(ceg.get(PM.name())), pm, MatsimTestUtils.EPSILON, "the PM value of this cold emission event was "+ Double.parseDouble(ceg.get(PM.name()))+ "but should have been "+ pm); } @@ -124,7 +117,7 @@ final void testGetAttributesForIncompleteMaps(){ for(Pollutant cp : coldPollutants){ //empty map - Assert.assertNull(emptyMapEvent.getAttributes().get(cp)); + Assertions.assertNull(emptyMapEvent.getAttributes().get(cp)); //values not set try{ @@ -142,8 +135,8 @@ final void testGetAttributesForIncompleteMaps(){ noMapNullPointers++; } } - Assert.assertEquals(numberOfColdPollutants, valNullPointers); - Assert.assertEquals(numberOfColdPollutants, noMapNullPointers); + Assertions.assertEquals(numberOfColdPollutants, valNullPointers); + Assertions.assertEquals(numberOfColdPollutants, noMapNullPointers); } } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/TestWarmEmissionEventImpl.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/TestWarmEmissionEventImpl.java index b10f7129d27..62691c3670f 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/TestWarmEmissionEventImpl.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/TestWarmEmissionEventImpl.java @@ -28,7 +28,7 @@ * 3 test the number of attributes returned */ -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -82,24 +82,15 @@ final void testGetAttributesForCompleteEmissionMaps(){ WarmEmissionEvent we = new WarmEmissionEvent(0.0, linkId, vehicleId, map); Map weg = we.getAttributes(); - Assert.assertEquals("the CO value of this warm emission event was "+ Double.parseDouble(weg.get(CO.name()))+ "but should have been "+ co, - Double.parseDouble(weg.get(CO.name())), co, MatsimTestUtils.EPSILON); - Assert.assertEquals("the CO2 value of this warm emission event was "+ Double.parseDouble(weg.get(CO2_TOTAL.name()))+ "but should have been "+ c2, - Double.parseDouble(weg.get(CO2_TOTAL.name())), c2, MatsimTestUtils.EPSILON); - Assert.assertEquals("the FC value of this warm emission event was "+ Double.parseDouble(weg.get(FC.name()))+ "but should have been "+ fc, - Double.parseDouble(weg.get(FC.name())), fc, MatsimTestUtils.EPSILON); - Assert.assertEquals("the HC value of this warm emission event was "+ Double.parseDouble(weg.get(HC.name()))+ "but should have been "+ hc, - Double.parseDouble(weg.get(HC.name())), hc, MatsimTestUtils.EPSILON); - Assert.assertEquals("the NMHC value of this warm emission event was "+ Double.parseDouble(weg.get(NMHC.name()))+ "but should have been "+ nm, - Double.parseDouble(weg.get(NMHC.name())), nm, MatsimTestUtils.EPSILON); - Assert.assertEquals("the NO2 value of this warm emission event was "+ Double.parseDouble(weg.get(NO2.name()))+ "but should have been "+ n2, - Double.parseDouble(weg.get(NO2.name())), n2, MatsimTestUtils.EPSILON); - Assert.assertEquals("the NOx value of this warm emission event was "+ Double.parseDouble(weg.get(NOx.name()))+ "but should have been "+ nx, - Double.parseDouble(weg.get(NOx.name())), nx, MatsimTestUtils.EPSILON); - Assert.assertEquals("the PM value of this warm emission event was "+ Double.parseDouble(weg.get(PM.name()))+ "but should have been "+ pm, - Double.parseDouble(weg.get(PM.name())), pm, MatsimTestUtils.EPSILON); - Assert.assertEquals("the SO2 value of this warm emission event was "+ Double.parseDouble(weg.get(SO2.name()))+ "but should have been "+ so, - Double.parseDouble(weg.get(SO2.name())), so, MatsimTestUtils.EPSILON); + Assertions.assertEquals(Double.parseDouble(weg.get(CO.name())), co, MatsimTestUtils.EPSILON, "the CO value of this warm emission event was "+ Double.parseDouble(weg.get(CO.name()))+ "but should have been "+ co); + Assertions.assertEquals(Double.parseDouble(weg.get(CO2_TOTAL.name())), c2, MatsimTestUtils.EPSILON, "the CO2 value of this warm emission event was "+ Double.parseDouble(weg.get(CO2_TOTAL.name()))+ "but should have been "+ c2); + Assertions.assertEquals(Double.parseDouble(weg.get(FC.name())), fc, MatsimTestUtils.EPSILON, "the FC value of this warm emission event was "+ Double.parseDouble(weg.get(FC.name()))+ "but should have been "+ fc); + Assertions.assertEquals(Double.parseDouble(weg.get(HC.name())), hc, MatsimTestUtils.EPSILON, "the HC value of this warm emission event was "+ Double.parseDouble(weg.get(HC.name()))+ "but should have been "+ hc); + Assertions.assertEquals(Double.parseDouble(weg.get(NMHC.name())), nm, MatsimTestUtils.EPSILON, "the NMHC value of this warm emission event was "+ Double.parseDouble(weg.get(NMHC.name()))+ "but should have been "+ nm); + Assertions.assertEquals(Double.parseDouble(weg.get(NO2.name())), n2, MatsimTestUtils.EPSILON, "the NO2 value of this warm emission event was "+ Double.parseDouble(weg.get(NO2.name()))+ "but should have been "+ n2); + Assertions.assertEquals(Double.parseDouble(weg.get(NOx.name())), nx, MatsimTestUtils.EPSILON, "the NOx value of this warm emission event was "+ Double.parseDouble(weg.get(NOx.name()))+ "but should have been "+ nx); + Assertions.assertEquals(Double.parseDouble(weg.get(PM.name())), pm, MatsimTestUtils.EPSILON, "the PM value of this warm emission event was "+ Double.parseDouble(weg.get(PM.name()))+ "but should have been "+ pm); + Assertions.assertEquals(Double.parseDouble(weg.get(SO2.name())), so, MatsimTestUtils.EPSILON, "the SO2 value of this warm emission event was "+ Double.parseDouble(weg.get(SO2.name()))+ "but should have been "+ so); } @Test @@ -140,7 +131,7 @@ final void testGetAttributesForIncompleteMaps(){ String wp=wpEnum.name(); //empty map - Assert.assertNull(emptyMapEvent.getAttributes().get(wp)); + Assertions.assertNull(emptyMapEvent.getAttributes().get(wp)); //values not set try{ @@ -158,8 +149,8 @@ final void testGetAttributesForIncompleteMaps(){ noMapNullPointers++; } } - Assert.assertEquals(numberOfWarmPollutants, valuesNotSetNullPointers); - Assert.assertEquals(numberOfWarmPollutants, noMapNullPointers); + Assertions.assertEquals(numberOfWarmPollutants, valuesNotSetNullPointers); + Assertions.assertEquals(numberOfWarmPollutants, noMapNullPointers); } } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/VehicleLeavesTrafficEventTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/VehicleLeavesTrafficEventTest.java index 28c1b9ab2a6..2858e572d58 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/VehicleLeavesTrafficEventTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/events/VehicleLeavesTrafficEventTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.emissions.events; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -82,7 +82,7 @@ public void install(){ } final String expected = utils.getClassInputDirectory() + emissionEventsFileName; EventsFileComparator.Result result = EventsUtils.compareEventsFiles(expected, resultingEvents); - Assert.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result); + Assertions.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result); } } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExampleIT.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExampleIT.java index ede97411a51..951ed2fb237 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExampleIT.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExampleIT.java @@ -18,7 +18,7 @@ * *********************************************************************** */ package org.matsim.contrib.emissions.example; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.contrib.emissions.EmissionUtils; @@ -59,7 +59,7 @@ final void testAverage_vehTypeV1() { String expected = utils.getInputDirectory() + RunAverageEmissionToolOfflineExample.emissionEventsFilename; String actual = utils.getOutputDirectory() + RunAverageEmissionToolOfflineExample.emissionEventsFilename; Result result = EventsUtils.compareEventsFiles( expected, actual ); - Assert.assertEquals( Result.FILES_ARE_EQUAL, result); + Assertions.assertEquals( Result.FILES_ARE_EQUAL, result); } @Test @@ -81,7 +81,7 @@ final void testAverage_vehTypeV2() { String expected = utils.getInputDirectory() + RunAverageEmissionToolOfflineExample.emissionEventsFilename; String actual = utils.getOutputDirectory() + RunAverageEmissionToolOfflineExample.emissionEventsFilename; Result result = EventsUtils.compareEventsFiles( expected, actual ); - Assert.assertEquals( Result.FILES_ARE_EQUAL, result); + Assertions.assertEquals( Result.FILES_ARE_EQUAL, result); } /** @@ -107,7 +107,7 @@ final void testAverage_vehTypeV2b() { String expected = utils.getInputDirectory() + RunAverageEmissionToolOfflineExample.emissionEventsFilename; String actual = utils.getOutputDirectory() + RunAverageEmissionToolOfflineExample.emissionEventsFilename; Result result = EventsUtils.compareEventsFiles( expected, actual ); - Assert.assertEquals( Result.FILES_ARE_EQUAL, result); + Assertions.assertEquals( Result.FILES_ARE_EQUAL, result); } @@ -131,6 +131,6 @@ final void testAverage_vehTypeV2_HBEFA4() { String expected = utils.getInputDirectory() + RunAverageEmissionToolOfflineExample.emissionEventsFilename; String actual = utils.getOutputDirectory() + RunAverageEmissionToolOfflineExample.emissionEventsFilename; Result result = EventsUtils.compareEventsFiles( expected, actual ); - Assert.assertEquals( Result.FILES_ARE_EQUAL, result); + Assertions.assertEquals( Result.FILES_ARE_EQUAL, result); } } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExampleIT.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExampleIT.java index 26a96f651e4..e2ed6c54bba 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExampleIT.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExampleIT.java @@ -18,7 +18,7 @@ * *********************************************************************** */ package org.matsim.contrib.emissions.example; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; @@ -64,7 +64,7 @@ final void testDetailed_vehTypeV1() { } catch (Exception ee ) { gotAnException = true ; } - Assert.assertTrue( gotAnException ); + Assertions.assertTrue( gotAnException ); } // Expecting RuntimeException, because requested values are only in average file. Without fallback it has to fail! @@ -88,7 +88,7 @@ final void testDetailed_vehTypeV2() { } catch (Exception ee ) { gotAnException = true ; } - Assert.assertTrue( gotAnException ); + Assertions.assertTrue( gotAnException ); } // Expecting RuntimeException, because requested values are only in average file. Without fallback it has to fail! @@ -114,7 +114,7 @@ final void testDetailed_vehTypeV2_HBEFA4() { } catch (Exception ee ) { gotAnException = true ; } - Assert.assertTrue( gotAnException ); + Assertions.assertTrue( gotAnException ); } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1.java index ad7e875891a..b73afd4d36f 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1.java @@ -18,8 +18,8 @@ * *********************************************************************** */ package org.matsim.contrib.emissions.example; -import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -28,8 +28,6 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.testcases.MatsimTestUtils; -import static org.junit.Assert.fail; - /** * @author nagel * @@ -65,7 +63,7 @@ final void testDetailed_vehTypeV1() { } catch (Exception ee ) { gotAnException = true ; } - Assert.assertTrue( gotAnException ); + Assertions.assertTrue( gotAnException ); } } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage.java index 2ba07507548..8715b4525ed 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage.java @@ -18,6 +18,8 @@ * *********************************************************************** */ package org.matsim.contrib.emissions.example; +import static org.junit.jupiter.api.Assertions.fail; + import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -28,8 +30,6 @@ import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; -import static org.junit.Assert.fail; - /** * @author nagel * diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java index 8ebcee11237..62e8af5a78e 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java @@ -18,8 +18,8 @@ * *********************************************************************** */ package org.matsim.contrib.emissions.example; -import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -28,8 +28,6 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.testcases.MatsimTestUtils; -import static org.junit.Assert.fail; - /** * @author nagel * @@ -58,7 +56,7 @@ final void testDetailed_vehTypeV2() { } catch (Exception ee ) { gotAnException = true ; } - Assert.assertTrue( gotAnException ); + Assertions.assertTrue( gotAnException ); } } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage.java index 346f29f433c..ef667425698 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage.java @@ -18,6 +18,8 @@ * *********************************************************************** */ package org.matsim.contrib.emissions.example; +import static org.junit.jupiter.api.Assertions.fail; + import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -29,8 +31,6 @@ import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; -import static org.junit.Assert.fail; - /** * @author nagel * diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/utils/EmissionUtilsTest.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/utils/EmissionUtilsTest.java index 6fdf91cdb46..4f20dfbf78f 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/utils/EmissionUtilsTest.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/utils/EmissionUtilsTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.emissions.utils; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -124,15 +124,15 @@ final void testSumUpEmissions() { Double pmv = sum.get( PM ); Double sov = sum.get(SO2); - Assert.assertEquals("Value of CO should be " + (wcov + ccov), cov, wcov + ccov, MatsimTestUtils.EPSILON); - Assert.assertEquals("Value of CO2_TOTAL should be " + wc2v, c2v, wc2v, MatsimTestUtils.EPSILON); - Assert.assertEquals("Value of FC should be " + (wfcv + cfcv), fcv, wfcv + cfcv, MatsimTestUtils.EPSILON); - Assert.assertEquals("Value of HC should be " + (whcv + chcv), hcv, whcv + chcv, MatsimTestUtils.EPSILON); - Assert.assertEquals("Value of NMHC should be " + (wnmv + cnmv), nmv, wnmv + cnmv, MatsimTestUtils.EPSILON); - Assert.assertEquals("Value of NO2 should be " + (wn2v + cn2v), n2v, wn2v + cn2v, MatsimTestUtils.EPSILON); - Assert.assertEquals("Value of NOx should be " + (wnxv + cnxv), nxv, wnxv + cnxv, MatsimTestUtils.EPSILON); - Assert.assertEquals("Value of PM should be ." + (wpmv + cpmv), pmv, wpmv + cpmv, MatsimTestUtils.EPSILON); - Assert.assertEquals("Value of SO2 should be " + wsov, sov, wsov, MatsimTestUtils.EPSILON); + Assertions.assertEquals(cov, wcov + ccov, MatsimTestUtils.EPSILON, "Value of CO should be " + (wcov + ccov)); + Assertions.assertEquals(c2v, wc2v, MatsimTestUtils.EPSILON, "Value of CO2_TOTAL should be " + wc2v); + Assertions.assertEquals(fcv, wfcv + cfcv, MatsimTestUtils.EPSILON, "Value of FC should be " + (wfcv + cfcv)); + Assertions.assertEquals(hcv, whcv + chcv, MatsimTestUtils.EPSILON, "Value of HC should be " + (whcv + chcv)); + Assertions.assertEquals(nmv, wnmv + cnmv, MatsimTestUtils.EPSILON, "Value of NMHC should be " + (wnmv + cnmv)); + Assertions.assertEquals(n2v, wn2v + cn2v, MatsimTestUtils.EPSILON, "Value of NO2 should be " + (wn2v + cn2v)); + Assertions.assertEquals(nxv, wnxv + cnxv, MatsimTestUtils.EPSILON, "Value of NOx should be " + (wnxv + cnxv)); + Assertions.assertEquals(pmv, wpmv + cpmv, MatsimTestUtils.EPSILON, "Value of PM should be ." + (wpmv + cpmv)); + Assertions.assertEquals(sov, wsov, MatsimTestUtils.EPSILON, "Value of SO2 should be " + wsov); } @Test @@ -235,25 +235,25 @@ final void testSumUpEmissionsPerId() { double a2so = sums.get(Id.create("id2", Person.class)).get(SO2); //assures simultaneously that persons/ids are distinguished correctly - Assert.assertEquals("CO value of person 1 should be" +e1co +"but is ", e1co, a1co, MatsimTestUtils.EPSILON); - Assert.assertEquals("CO2 value of person 1 should be" + e1c2 + "but is ", e1c2, a1c2, MatsimTestUtils.EPSILON); - Assert.assertEquals("FC value of person 1 should be" + e1fc + "but is ", e1fc, a1fc, MatsimTestUtils.EPSILON); - Assert.assertEquals("HC value of person 1 should be" + e1hc + "but is ", e1hc, a1hc, MatsimTestUtils.EPSILON); - Assert.assertEquals("NMHC value of person 1 should be" + e1nm + "but is ", e1nm, a1nm, MatsimTestUtils.EPSILON); - Assert.assertEquals("NO2 value of person 1 should be" + e1n2 + "but is ", e1n2, a1n2, MatsimTestUtils.EPSILON); - Assert.assertEquals("NOx value of person 1 should be" + e1nx + "but is ", e1nx, a1nx, MatsimTestUtils.EPSILON); - Assert.assertEquals("PM value of person 1 should be" + e1pm + "but is ", e1pm, a1pm, MatsimTestUtils.EPSILON); - Assert.assertEquals("SO value of person 1 should be" + e1so + "but is ", e1so, a1so, MatsimTestUtils.EPSILON); - - Assert.assertEquals("CO value of person 2 should be" + e2co + "but is ", e2co, a2co, MatsimTestUtils.EPSILON); - Assert.assertEquals("CO2 value of person 2 should be" + e2c2 + "but is ", e2c2, a2c2, MatsimTestUtils.EPSILON); - Assert.assertEquals("FC value of person 2 should be" + e2fc + "but is ", e2fc, a2fc, MatsimTestUtils.EPSILON); - Assert.assertEquals("HC value of person 2 should be" + e2hc + "but is ", e2hc, a2hc, MatsimTestUtils.EPSILON); - Assert.assertEquals("NMHC value of person 2 should be" + e2nm + "but is ", e2nm, a2nm, MatsimTestUtils.EPSILON); - Assert.assertEquals("NO2 value of person 2 should be" + e2n2 + "but is ", e2n2, a2n2, MatsimTestUtils.EPSILON); - Assert.assertEquals("NOx value of person 2 should be" + e2nx + "but is ", e2nx, a2nx, MatsimTestUtils.EPSILON); - Assert.assertEquals("PM value of person 2 should be" + e2pm + "but is ", e2pm, a2pm, MatsimTestUtils.EPSILON); - Assert.assertEquals("SO value of person 2 should be" + e2so + "but is ", e2so, a2so, MatsimTestUtils.EPSILON); + Assertions.assertEquals(e1co, a1co, MatsimTestUtils.EPSILON, "CO value of person 1 should be" +e1co +"but is "); + Assertions.assertEquals(e1c2, a1c2, MatsimTestUtils.EPSILON, "CO2 value of person 1 should be" + e1c2 + "but is "); + Assertions.assertEquals(e1fc, a1fc, MatsimTestUtils.EPSILON, "FC value of person 1 should be" + e1fc + "but is "); + Assertions.assertEquals(e1hc, a1hc, MatsimTestUtils.EPSILON, "HC value of person 1 should be" + e1hc + "but is "); + Assertions.assertEquals(e1nm, a1nm, MatsimTestUtils.EPSILON, "NMHC value of person 1 should be" + e1nm + "but is "); + Assertions.assertEquals(e1n2, a1n2, MatsimTestUtils.EPSILON, "NO2 value of person 1 should be" + e1n2 + "but is "); + Assertions.assertEquals(e1nx, a1nx, MatsimTestUtils.EPSILON, "NOx value of person 1 should be" + e1nx + "but is "); + Assertions.assertEquals(e1pm, a1pm, MatsimTestUtils.EPSILON, "PM value of person 1 should be" + e1pm + "but is "); + Assertions.assertEquals(e1so, a1so, MatsimTestUtils.EPSILON, "SO value of person 1 should be" + e1so + "but is "); + + Assertions.assertEquals(e2co, a2co, MatsimTestUtils.EPSILON, "CO value of person 2 should be" + e2co + "but is "); + Assertions.assertEquals(e2c2, a2c2, MatsimTestUtils.EPSILON, "CO2 value of person 2 should be" + e2c2 + "but is "); + Assertions.assertEquals(e2fc, a2fc, MatsimTestUtils.EPSILON, "FC value of person 2 should be" + e2fc + "but is "); + Assertions.assertEquals(e2hc, a2hc, MatsimTestUtils.EPSILON, "HC value of person 2 should be" + e2hc + "but is "); + Assertions.assertEquals(e2nm, a2nm, MatsimTestUtils.EPSILON, "NMHC value of person 2 should be" + e2nm + "but is "); + Assertions.assertEquals(e2n2, a2n2, MatsimTestUtils.EPSILON, "NO2 value of person 2 should be" + e2n2 + "but is "); + Assertions.assertEquals(e2nx, a2nx, MatsimTestUtils.EPSILON, "NOx value of person 2 should be" + e2nx + "but is "); + Assertions.assertEquals(e2pm, a2pm, MatsimTestUtils.EPSILON, "PM value of person 2 should be" + e2pm + "but is "); + Assertions.assertEquals(e2so, a2so, MatsimTestUtils.EPSILON, "SO value of person 2 should be" + e2so + "but is "); } @@ -263,7 +263,7 @@ final void testGetTotalEmissions_nullInput() { @SuppressWarnings("ConstantConditions") SortedMap totalEmissions = EmissionUtils.getTotalEmissions(null); - Assert.fail("Expected NullPointerException, got none."); + Assertions.fail("Expected NullPointerException, got none."); }); @@ -278,7 +278,7 @@ final void testGetTotalEmissions_emptyList() { //test empty list as input totalEmissions = EmissionUtils.getTotalEmissions(persons2emissions); - Assert.assertEquals("this map should be empty", 0, totalEmissions.size()); + Assertions.assertEquals(0, totalEmissions.size(), "this map should be empty"); } @Test @@ -342,22 +342,22 @@ final void testGetTotalEmissions_completeData() { persons2emissions.put(p3Id, allEmissionsp3); totalEmissions = EmissionUtils.getTotalEmissions(persons2emissions); - Assert.assertEquals(CO + " values are not correct", p1co + p2co + p3co, totalEmissions.get(CO), MatsimTestUtils.EPSILON); - Assert.assertEquals(CO2_TOTAL + " values are not correct", p1c2 + p2c2 + p3c2, totalEmissions.get(CO2_TOTAL), MatsimTestUtils.EPSILON); - Assert.assertEquals(FC + " values are not correct", p1fc + p2fc + p3fc, totalEmissions.get(FC), MatsimTestUtils.EPSILON); - Assert.assertEquals(HC + " values are not correct", p1hc + p2hc + p3hc, totalEmissions.get(HC), MatsimTestUtils.EPSILON); - Assert.assertEquals(NMHC + " values are not correct", p1nm + p2nm + p3nm, totalEmissions.get(NMHC), MatsimTestUtils.EPSILON); - Assert.assertEquals(NO2 + " values are not correct", p1n2 + p2n2 + p3n2, totalEmissions.get(NO2), MatsimTestUtils.EPSILON); - Assert.assertEquals(NOx + " values are not correct", p1nx + p2nx + p3nx, totalEmissions.get(NOx), MatsimTestUtils.EPSILON); - Assert.assertEquals(PM + " values are not correct", p1pm + p2pm + p3pm, totalEmissions.get(PM), MatsimTestUtils.EPSILON); - Assert.assertEquals(SO2 + " values are not correct", p1so + p2so + p3so, totalEmissions.get(SO2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(p1co + p2co + p3co, totalEmissions.get(CO), MatsimTestUtils.EPSILON, CO + " values are not correct"); + Assertions.assertEquals(p1c2 + p2c2 + p3c2, totalEmissions.get(CO2_TOTAL), MatsimTestUtils.EPSILON, CO2_TOTAL + " values are not correct"); + Assertions.assertEquals(p1fc + p2fc + p3fc, totalEmissions.get(FC), MatsimTestUtils.EPSILON, FC + " values are not correct"); + Assertions.assertEquals(p1hc + p2hc + p3hc, totalEmissions.get(HC), MatsimTestUtils.EPSILON, HC + " values are not correct"); + Assertions.assertEquals(p1nm + p2nm + p3nm, totalEmissions.get(NMHC), MatsimTestUtils.EPSILON, NMHC + " values are not correct"); + Assertions.assertEquals(p1n2 + p2n2 + p3n2, totalEmissions.get(NO2), MatsimTestUtils.EPSILON, NO2 + " values are not correct"); + Assertions.assertEquals(p1nx + p2nx + p3nx, totalEmissions.get(NOx), MatsimTestUtils.EPSILON, NOx + " values are not correct"); + Assertions.assertEquals(p1pm + p2pm + p3pm, totalEmissions.get(PM), MatsimTestUtils.EPSILON, PM + " values are not correct"); + Assertions.assertEquals(p1so + p2so + p3so, totalEmissions.get(SO2), MatsimTestUtils.EPSILON, SO2 + " values are not correct"); // assume that all maps are complete for (Pollutant emission : pollsFromEU) { - Assert.assertTrue(totalEmissions.containsKey(emission)); + Assertions.assertTrue(totalEmissions.containsKey(emission)); } // nothing else in the list - Assert.assertEquals("this list should be as long as number of pollutants", totalEmissions.keySet().size(), pollsFromEU.size()); + Assertions.assertEquals(totalEmissions.keySet().size(), pollsFromEU.size(), "this list should be as long as number of pollutants"); } @@ -421,52 +421,51 @@ final void testSetNonCalculatedEmissionsForPopulation_completeData(){ Map, SortedMap> finalMap = EmissionUtils.setNonCalculatedEmissionsForPopulation(pop, totalEmissions, pollsFromEU); //check: all persons added to the population are contained in the finalMap - Assert.assertTrue("the calculated map should contain person 1", finalMap.containsKey(idp1)); - Assert.assertTrue("the calculated map should contain person 2", finalMap.containsKey(idp2)); + Assertions.assertTrue(finalMap.containsKey(idp1), "the calculated map should contain person 1"); + Assertions.assertTrue(finalMap.containsKey(idp2), "the calculated map should contain person 2"); //nothing else in the finalMap - Assert.assertEquals("the calculated map should contain two persons but contains "+ - finalMap.size() + "persons." ,pop.getPersons().keySet().size(), finalMap.size()); + Assertions.assertEquals(pop.getPersons().keySet().size(), finalMap.size(), "the calculated map should contain two persons but contains "+ + finalMap.size() + "persons."); //check: all values for person 1 and 2 are not null or zero // and of type double for(Object id : finalMap.keySet()) { - Assert.assertTrue(id instanceof Id); + Assertions.assertTrue(id instanceof Id); for (Object pollutant : finalMap.get(id).values()) { - Assert.assertSame(pollutant.getClass(), Double.class); - Assert.assertNotSame(0.0, pollutant); - Assert.assertNotNull(pollutant); + Assertions.assertSame(pollutant.getClass(), Double.class); + Assertions.assertNotSame(0.0, pollutant); + Assertions.assertNotNull(pollutant); } //check: all emission types appear for (Pollutant emission : pollsFromEU) { - Assert.assertTrue(finalMap.get(id).containsKey(emission)); + Assertions.assertTrue(finalMap.get(id).containsKey(emission)); } //nothing else in the list int numOfPolls = pollsFromEU.size(); - Assert.assertEquals("the number of pullutants is " + finalMap.get(id).keySet().size() + " but should be" + numOfPolls, - numOfPolls, finalMap.get(id).keySet().size()); + Assertions.assertEquals(numOfPolls, finalMap.get(id).keySet().size(), "the number of pullutants is " + finalMap.get(id).keySet().size() + " but should be" + numOfPolls); } //check: values for all emissions are correct -person 1 - Assert.assertEquals("CO value for person 1 is not correct", cov1, finalMap.get(idp1).get( CO ), MatsimTestUtils.EPSILON ); - Assert.assertEquals("CO2 value for person 1 is not correct", c2v1, finalMap.get(idp1).get( CO2_TOTAL ), MatsimTestUtils.EPSILON ); - Assert.assertEquals("FC value for person 1 is not correct", fcv1, finalMap.get(idp1).get( FC ), MatsimTestUtils.EPSILON ); - Assert.assertEquals("HC value for person 1 is not correct", hcv1, finalMap.get(idp1).get( HC ), MatsimTestUtils.EPSILON ); - Assert.assertEquals("NMHC value for person 1 is not correct", nmv1, finalMap.get(idp1).get( NMHC ), MatsimTestUtils.EPSILON ); - Assert.assertEquals("NO2 value for person 1 is not correct", n2v1, finalMap.get(idp1).get( NO2 ), MatsimTestUtils.EPSILON ); - Assert.assertEquals("NOx value for person 1 is not correct", nxv1, finalMap.get(idp1).get( NOx ), MatsimTestUtils.EPSILON ); - Assert.assertEquals("PM value for person 1 is not correct", pmv1, finalMap.get(idp1).get( PM ), MatsimTestUtils.EPSILON ); - Assert.assertEquals("SO value for person 1 is not correct", sov1, finalMap.get(idp1).get( SO2 ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(cov1, finalMap.get(idp1).get( CO ), MatsimTestUtils.EPSILON, "CO value for person 1 is not correct" ); + Assertions.assertEquals(c2v1, finalMap.get(idp1).get( CO2_TOTAL ), MatsimTestUtils.EPSILON, "CO2 value for person 1 is not correct" ); + Assertions.assertEquals(fcv1, finalMap.get(idp1).get( FC ), MatsimTestUtils.EPSILON, "FC value for person 1 is not correct" ); + Assertions.assertEquals(hcv1, finalMap.get(idp1).get( HC ), MatsimTestUtils.EPSILON, "HC value for person 1 is not correct" ); + Assertions.assertEquals(nmv1, finalMap.get(idp1).get( NMHC ), MatsimTestUtils.EPSILON, "NMHC value for person 1 is not correct" ); + Assertions.assertEquals(n2v1, finalMap.get(idp1).get( NO2 ), MatsimTestUtils.EPSILON, "NO2 value for person 1 is not correct" ); + Assertions.assertEquals(nxv1, finalMap.get(idp1).get( NOx ), MatsimTestUtils.EPSILON, "NOx value for person 1 is not correct" ); + Assertions.assertEquals(pmv1, finalMap.get(idp1).get( PM ), MatsimTestUtils.EPSILON, "PM value for person 1 is not correct" ); + Assertions.assertEquals(sov1, finalMap.get(idp1).get( SO2 ), MatsimTestUtils.EPSILON, "SO value for person 1 is not correct" ); //check: values for all emissions are correct -person 2 - Assert.assertEquals("CO value for person 2 is not correct", cov2, finalMap.get(idp2).get( CO ), MatsimTestUtils.EPSILON ); - Assert.assertEquals("CO2 value for person 2 is not correct", c2v2, finalMap.get(idp2).get( CO2_TOTAL ), MatsimTestUtils.EPSILON ); - Assert.assertEquals("FC value for person 2 is not correct", fcv2, finalMap.get(idp2).get( FC ), MatsimTestUtils.EPSILON ); - Assert.assertEquals("HC value for person 2 is not correct", hcv2, finalMap.get(idp2).get( HC ), MatsimTestUtils.EPSILON ); - Assert.assertEquals("NMHC value for person 2 is not correct", nmv2, finalMap.get(idp2).get( NMHC ), MatsimTestUtils.EPSILON ); - Assert.assertEquals("NO2 value for person 2 is not correct", n2v2, finalMap.get(idp2).get( NO2 ), MatsimTestUtils.EPSILON ); - Assert.assertEquals("NOx value for person 2 is not correct", nxv2, finalMap.get(idp2).get( NOx ), MatsimTestUtils.EPSILON ); - Assert.assertEquals("PM value for person 2 is not correct", pmv2, finalMap.get(idp2).get( PM ), MatsimTestUtils.EPSILON ); - Assert.assertEquals("SO value for person 2 is not correct", sov2, finalMap.get(idp2).get( SO2 ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(cov2, finalMap.get(idp2).get( CO ), MatsimTestUtils.EPSILON, "CO value for person 2 is not correct" ); + Assertions.assertEquals(c2v2, finalMap.get(idp2).get( CO2_TOTAL ), MatsimTestUtils.EPSILON, "CO2 value for person 2 is not correct" ); + Assertions.assertEquals(fcv2, finalMap.get(idp2).get( FC ), MatsimTestUtils.EPSILON, "FC value for person 2 is not correct" ); + Assertions.assertEquals(hcv2, finalMap.get(idp2).get( HC ), MatsimTestUtils.EPSILON, "HC value for person 2 is not correct" ); + Assertions.assertEquals(nmv2, finalMap.get(idp2).get( NMHC ), MatsimTestUtils.EPSILON, "NMHC value for person 2 is not correct" ); + Assertions.assertEquals(n2v2, finalMap.get(idp2).get( NO2 ), MatsimTestUtils.EPSILON, "NO2 value for person 2 is not correct" ); + Assertions.assertEquals(nxv2, finalMap.get(idp2).get( NOx ), MatsimTestUtils.EPSILON, "NOx value for person 2 is not correct" ); + Assertions.assertEquals(pmv2, finalMap.get(idp2).get( PM ), MatsimTestUtils.EPSILON, "PM value for person 2 is not correct" ); + Assertions.assertEquals(sov2, finalMap.get(idp2).get( SO2 ), MatsimTestUtils.EPSILON, "SO value for person 2 is not correct" ); } @@ -482,25 +481,25 @@ final void testSetNonCalculatedEmissionsForPopulation_missingMap() { Map, SortedMap> finalMap = EmissionUtils.setNonCalculatedEmissionsForPopulation(pop, totalEmissions, pollsFromEU); //check: person 3 is contained in the finalMap - Assert.assertTrue("the calculated map should contain person 3", finalMap.containsKey(idp3)); + Assertions.assertTrue(finalMap.containsKey(idp3), "the calculated map should contain person 3"); //nothing else in the finalMap message = "the calculated map should contain " + pop.getPersons().size() + " person(s) but contains " + finalMap.keySet().size() + "person(s)."; - Assert.assertEquals(message, pop.getPersons().keySet().size(), finalMap.keySet().size()); + Assertions.assertEquals(pop.getPersons().keySet().size(), finalMap.keySet().size(), message); //check: all values for the this person are zero and of type double for (Object pollutant : finalMap.get(idp3).values()) { - Assert.assertSame(pollutant.getClass(), Double.class); - Assert.assertEquals(0.0, (Double) pollutant, MatsimTestUtils.EPSILON); - Assert.assertNotNull(pollutant); + Assertions.assertSame(pollutant.getClass(), Double.class); + Assertions.assertEquals(0.0, (Double) pollutant, MatsimTestUtils.EPSILON); + Assertions.assertNotNull(pollutant); } //check: all types of emissions appear for (Pollutant emission : pollsFromEU) { - Assert.assertTrue(finalMap.get(idp3).containsKey(emission)); + Assertions.assertTrue(finalMap.get(idp3).containsKey(emission)); } //nothing else in the list int numOfPolls = pollsFromEU.size(); message = "the number of pullutants is " + finalMap.get(idp3).keySet().size() + " but should be" + numOfPolls; - Assert.assertEquals(message, numOfPolls, finalMap.get(idp3).keySet().size()); + Assertions.assertEquals(numOfPolls, finalMap.get(idp3).keySet().size(), message); } @@ -542,10 +541,10 @@ final void testSetNonCalculatedEmissionsForPopulation_missingPerson() { Map, SortedMap> finalMap = EmissionUtils.setNonCalculatedEmissionsForPopulation(pop, totalEmissions, pollsFromEU); //check: all persons added to the population are contained in the finalMap - Assert.assertFalse("the calculated map should not contain person 4", finalMap.containsKey(idp4)); + Assertions.assertFalse(finalMap.containsKey(idp4), "the calculated map should not contain person 4"); //nothing else in the finalMap message = "the calculated map should contain " + pop.getPersons().size() + " person(s) but contains " + finalMap.keySet().size() + "person(s)."; - Assert.assertEquals(message, pop.getPersons().keySet().size(), finalMap.keySet().size()); + Assertions.assertEquals(pop.getPersons().keySet().size(), finalMap.keySet().size(), message); } @@ -568,7 +567,7 @@ final void testSetNonCalculatedEmissionsForPopulation_nullEmissions(){ } catch (NullPointerException e) { nullPointerEx = true; } - Assert.assertTrue(nullPointerEx); + Assertions.assertTrue(nullPointerEx); } @Test @@ -598,7 +597,7 @@ final void testSetNonCalculatedEmissionsForPopulation_emptyPopulation(){ //nothing in the finalMap message = "the calculated map should contain " + pop.getPersons().size() + " person(s) but contains " + finalMap.keySet().size() + "person(s)."; - Assert.assertEquals(message, pop.getPersons().keySet().size(), finalMap.keySet().size()); + Assertions.assertEquals(pop.getPersons().keySet().size(), finalMap.keySet().size(), message); } @@ -618,28 +617,26 @@ final void testSetNonCalculatedEmissionsForPopulation_emptyEmissionMap() { Map, SortedMap> finalMap = EmissionUtils.setNonCalculatedEmissionsForPopulation(pop, totalEmissions, pollsFromEU); //check: all persons added to the population are contained in the finalMap - Assert.assertTrue("the calculated map should contain person 5", finalMap.containsKey(idp5)); - Assert.assertTrue("the calculated map should contain person 6", finalMap.containsKey(idp6)); + Assertions.assertTrue(finalMap.containsKey(idp5), "the calculated map should contain person 5"); + Assertions.assertTrue(finalMap.containsKey(idp6), "the calculated map should contain person 6"); //nothing else in the finalMap message = "the calculated map should contain " + pop.getPersons().size() + " person(s) but contains " + finalMap.keySet().size() + "person(s)."; - Assert.assertEquals(message, pop.getPersons().keySet().size(), finalMap.keySet().size()); + Assertions.assertEquals(pop.getPersons().keySet().size(), finalMap.keySet().size(), message); //check: all values for all persons are zero and of type double for (Id id : finalMap.keySet()) { for (Object pollutant : finalMap.get(id).values()) { - Assert.assertSame(pollutant.getClass(), Double.class); - Assert.assertEquals("map of pollutants was missing. Therefore all values should be set to zero.", - 0.0, (Double) pollutant, MatsimTestUtils.EPSILON); - Assert.assertNotNull(pollutant); + Assertions.assertSame(pollutant.getClass(), Double.class); + Assertions.assertEquals(0.0, (Double) pollutant, MatsimTestUtils.EPSILON, "map of pollutants was missing. Therefore all values should be set to zero."); + Assertions.assertNotNull(pollutant); } //check: alle types of emissions appear for (Pollutant emission : pollsFromEU) { - Assert.assertTrue(finalMap.get(id).containsKey(emission)); + Assertions.assertTrue(finalMap.get(id).containsKey(emission)); } //nothing else in the list int numOfPolls = pollsFromEU.size(); - Assert.assertEquals("the number of pullutants is " + finalMap.get(id).keySet().size() + " but should be" + numOfPolls, - numOfPolls, finalMap.get(id).keySet().size()); + Assertions.assertEquals(numOfPolls, finalMap.get(id).keySet().size(), "the number of pullutants is " + finalMap.get(id).keySet().size() + " but should be" + numOfPolls); } @@ -732,64 +729,64 @@ final void testSetNonCalculatedEmissionsForNetwork() { Id linkId = link.getId(); - Assert.assertTrue(totalEmissionsFilled.containsKey(linkId)); + Assertions.assertTrue(totalEmissionsFilled.containsKey(linkId)); SortedMap emissionMapForLink = totalEmissionsFilled.get(linkId); for (Pollutant pollutant : pollsFromEU) { System.out.println("pollutant: " + pollutant + "; linkId: " + linkId); - Assert.assertTrue(pollutant + "not found for link " + linkId.toString(), - emissionMapForLink.containsKey(pollutant)); - Assert.assertEquals(Double.class, emissionMapForLink.get(pollutant).getClass()); + Assertions.assertTrue(emissionMapForLink.containsKey(pollutant), + pollutant + "not found for link " + linkId.toString()); + Assertions.assertEquals(Double.class, emissionMapForLink.get(pollutant).getClass()); } } //check values //link 12 and 13 - Assert.assertEquals(totalEmissionsFilled.get(link12id).get( CO2_TOTAL ), c2link12v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link12id).get( CO ), colink12v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link12id).get( FC ), fclink12v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link12id).get( HC ), hclink12v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link12id).get( NMHC ), nmlink12v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link12id).get( NO2 ), n2link12v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link12id).get( NOx ), nxlink12v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link12id).get( PM ), pmlink12v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link12id).get( SO2 ), solink12v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link13id).get( CO2_TOTAL ), c2link13v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link13id).get( CO ), colink13v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link13id).get( FC ), fclink13v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link13id).get( HC ), hclink13v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link13id).get( NMHC ), nmlink13v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link13id).get( NO2 ), n2link13v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link13id).get( NOx ), nxlink13v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link13id).get( PM ), pmlink13v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link13id).get( SO2 ), solink13v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link12id).get( CO2_TOTAL ), c2link12v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link12id).get( CO ), colink12v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link12id).get( FC ), fclink12v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link12id).get( HC ), hclink12v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link12id).get( NMHC ), nmlink12v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link12id).get( NO2 ), n2link12v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link12id).get( NOx ), nxlink12v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link12id).get( PM ), pmlink12v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link12id).get( SO2 ), solink12v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link13id).get( CO2_TOTAL ), c2link13v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link13id).get( CO ), colink13v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link13id).get( FC ), fclink13v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link13id).get( HC ), hclink13v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link13id).get( NMHC ), nmlink13v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link13id).get( NO2 ), n2link13v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link13id).get( NOx ), nxlink13v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link13id).get( PM ), pmlink13v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link13id).get( SO2 ), solink13v, MatsimTestUtils.EPSILON ); //link 14 and 34 for(Pollutant pollutant: pollsFromEU){ - Assert.assertEquals(totalEmissionsFilled.get(link14id).get(pollutant), .0, MatsimTestUtils.EPSILON); - Assert.assertEquals(totalEmissionsFilled.get(link34id).get(pollutant), .0, MatsimTestUtils.EPSILON); + Assertions.assertEquals(totalEmissionsFilled.get(link14id).get(pollutant), .0, MatsimTestUtils.EPSILON); + Assertions.assertEquals(totalEmissionsFilled.get(link34id).get(pollutant), .0, MatsimTestUtils.EPSILON); } //link 23 - partial - Assert.assertEquals(totalEmissionsFilled.get(link23id).get( CO2_TOTAL ), .0, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link23id).get( CO ), .0, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link23id).get( FC ), .0, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link23id).get( HC ), .0, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link23id).get( NMHC ), .0, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link23id).get( NO2 ), .0, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link23id).get( NOx ), nxlink23v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link23id).get( PM ), pmlink23v, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link23id).get( SO2 ), solink23v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link23id).get( CO2_TOTAL ), .0, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link23id).get( CO ), .0, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link23id).get( FC ), .0, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link23id).get( HC ), .0, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link23id).get( NMHC ), .0, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link23id).get( NO2 ), .0, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link23id).get( NOx ), nxlink23v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link23id).get( PM ), pmlink23v, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link23id).get( SO2 ), solink23v, MatsimTestUtils.EPSILON ); //link 24 - empty - Assert.assertEquals(totalEmissionsFilled.get(link24id).get( CO2_TOTAL ), .0, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link24id).get( CO ), .0, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link24id).get( FC ), .0, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link24id).get( HC ), .0, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link24id).get( NMHC ), .0, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link24id).get( NO2 ), .0, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link24id).get( NOx ), .0, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link24id).get( PM ), .0, MatsimTestUtils.EPSILON ); - Assert.assertEquals(totalEmissionsFilled.get(link24id).get( SO2 ), .0, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link24id).get( CO2_TOTAL ), .0, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link24id).get( CO ), .0, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link24id).get( FC ), .0, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link24id).get( HC ), .0, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link24id).get( NMHC ), .0, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link24id).get( NO2 ), .0, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link24id).get( NOx ), .0, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link24id).get( PM ), .0, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(totalEmissionsFilled.get(link24id).get( SO2 ), .0, MatsimTestUtils.EPSILON ); } public static Map createEmissions() { diff --git a/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleWithLTHConsumptionModelTest.java b/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleWithLTHConsumptionModelTest.java index 0fe8353c9d8..ffc5f81e296 100644 --- a/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleWithLTHConsumptionModelTest.java +++ b/contribs/ev/src/test/java/org/matsim/contrib/ev/example/RunEvExampleWithLTHConsumptionModelTest.java @@ -2,7 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.population.Population; @@ -38,20 +38,20 @@ void runTest(){ PopulationUtils.readPopulation( actual, utils.getOutputDirectory() + "/output_plans.xml.gz" ); boolean result = PopulationUtils.comparePopulations( expected, actual ); - Assert.assertTrue( result ); + Assertions.assertTrue( result ); } { String expected = utils.getInputDirectory() + "/output_events.xml.gz" ; String actual = utils.getOutputDirectory() + "/output_events.xml.gz" ; EventsFileComparator.Result result = EventsUtils.compareEventsFiles( expected, actual ); - Assert.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result ); + Assertions.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result ); } } catch ( Exception ee ) { log.fatal("there was an exception: \n" + ee ) ; // if one catches an exception, then one needs to explicitly fail the test: - Assert.fail(); + Assertions.fail(); } } diff --git a/contribs/ev/src/test/java/org/matsim/contrib/ev/temperature/TemperatureChangeModuleIntegrationTest.java b/contribs/ev/src/test/java/org/matsim/contrib/ev/temperature/TemperatureChangeModuleIntegrationTest.java index dbd13c7a8b6..f686d7d95d4 100644 --- a/contribs/ev/src/test/java/org/matsim/contrib/ev/temperature/TemperatureChangeModuleIntegrationTest.java +++ b/contribs/ev/src/test/java/org/matsim/contrib/ev/temperature/TemperatureChangeModuleIntegrationTest.java @@ -20,8 +20,7 @@ package org.matsim.contrib.ev.temperature; import jakarta.inject.Inject; - -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -71,10 +70,10 @@ static class TemperatureTestEventHandler implements PersonDepartureEventHandler @Override public void handleEvent(PersonDepartureEvent event) { if (event.getLinkId().equals(Id.createLinkId("link1"))) { - Assert.assertEquals(temperatureService.getCurrentTemperature(event.getLinkId()), -10.0, 0.001); + Assertions.assertEquals(temperatureService.getCurrentTemperature(event.getLinkId()), -10.0, 0.001); } if (event.getLinkId().equals(Id.createLinkId("link2"))) { - Assert.assertEquals(temperatureService.getCurrentTemperature(event.getLinkId()), 30.0, 0.001); + Assertions.assertEquals(temperatureService.getCurrentTemperature(event.getLinkId()), 30.0, 0.001); } } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java index 89a1108290d..bf1cb7be9a6 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java @@ -20,7 +20,7 @@ package org.matsim.freight.carriers; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -96,7 +96,7 @@ void testWriteReadServiceBasedEvents() { .readStream(new ByteArrayInputStream(outputStream.toByteArray()), ControllerConfigGroup.EventsFileFormat.xml); eventsManager2.finishProcessing(); - Assert.assertEquals(collector1.getEvents(), collector2.getEvents()); + Assertions.assertEquals(collector1.getEvents(), collector2.getEvents()); } @@ -114,8 +114,8 @@ void testReadServiceBasedEvents() { .readFile(utils.getClassInputDirectory() + "serviceBasedEvents.xml"); eventsManager.finishProcessing(); - Assert.assertEquals("Number of tour related carrier events is not correct", 4 , eventHandlerTours.handledEvents.size()); - Assert.assertEquals("Number of service related carrier events is not correct", 14 , eventHandlerServices.handledEvents.size()); + Assertions.assertEquals(4 , eventHandlerTours.handledEvents.size(), "Number of tour related carrier events is not correct"); + Assertions.assertEquals(14 , eventHandlerServices.handledEvents.size(), "Number of service related carrier events is not correct"); } @Test @@ -142,7 +142,7 @@ void testWriteReadShipmentBasedEvents() { .readStream(new ByteArrayInputStream(outputStream.toByteArray()), ControllerConfigGroup.EventsFileFormat.xml); eventsManager2.finishProcessing(); - Assert.assertEquals(collector1.getEvents(), collector2.getEvents()); + Assertions.assertEquals(collector1.getEvents(), collector2.getEvents()); } @Test @@ -159,8 +159,8 @@ void testReadShipmentBasedEvents() { .readFile(utils.getClassInputDirectory() + "shipmentBasedEvents.xml"); eventsManager.finishProcessing(); - Assert.assertEquals("Number of tour related carrier events is not correct", 2 , eventHandlerTours.handledEvents.size()); - Assert.assertEquals("Number of shipments related carrier events is not correct", 20 , testEventHandlerShipments.handledEvents.size()); + Assertions.assertEquals(2 , eventHandlerTours.handledEvents.size(), "Number of tour related carrier events is not correct"); + Assertions.assertEquals(20 , testEventHandlerShipments.handledEvents.size(), "Number of shipments related carrier events is not correct"); } @@ -196,7 +196,7 @@ void testReader() { handledEvents.addAll(eventHandlerShipments.handledEvents); //Please note: This test is sensitive to the order of events as they are added in carrierEvents (input) and the resukts of the handler... - Assert.assertArrayEquals(carrierEvents.toArray(), handledEvents.toArray()); + Assertions.assertArrayEquals(carrierEvents.toArray(), handledEvents.toArray()); } private static class TestEventHandlerTours diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanReaderV1Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanReaderV1Test.java index 9a8bfba14f9..1be22630df2 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanReaderV1Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanReaderV1Test.java @@ -21,7 +21,7 @@ package org.matsim.freight.carriers; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -52,7 +52,7 @@ void testCarrierPlanReaderDoesSomething() { Carriers carriers = new Carriers(); CarrierPlanReaderV1 carrierPlanReaderV1 = new CarrierPlanReaderV1(carriers, carrierVehicleTypes ); carrierPlanReaderV1.readFile(utils.getClassInputDirectory() + "carrierPlansEquils.xml"); - Assert.assertEquals(1, carriers.getCarriers().size()); + Assertions.assertEquals(1, carriers.getCarriers().size()); } @Test @@ -66,18 +66,18 @@ void testReaderReadsCorrectly() { Carriers carriers = new Carriers(); CarrierPlanReaderV1 carrierPlanReaderV1 = new CarrierPlanReaderV1(carriers, carrierVehicleTypes ); carrierPlanReaderV1.readFile(utils.getClassInputDirectory() + "carrierPlansEquils.xml"); - Assert.assertEquals(1, carriers.getCarriers().size()); + Assertions.assertEquals(1, carriers.getCarriers().size()); Carrier carrier = carriers.getCarriers().values().iterator().next(); - Assert.assertEquals(1, carrier.getSelectedPlan().getScheduledTours().size()); + Assertions.assertEquals(1, carrier.getSelectedPlan().getScheduledTours().size()); Leg leg = (Leg) carrier.getSelectedPlan().getScheduledTours() .iterator().next().getTour().getTourElements().get(0); NetworkRoute route = (NetworkRoute) leg.getRoute(); - Assert.assertEquals(3, route.getLinkIds().size()); - Assert.assertEquals("23", route.getStartLinkId().toString()); - Assert.assertEquals("2", route.getLinkIds().get(0).toString()); - Assert.assertEquals("3", route.getLinkIds().get(1).toString()); - Assert.assertEquals("4", route.getLinkIds().get(2).toString()); - Assert.assertEquals("15", route.getEndLinkId().toString()); + Assertions.assertEquals(3, route.getLinkIds().size()); + Assertions.assertEquals("23", route.getStartLinkId().toString()); + Assertions.assertEquals("2", route.getLinkIds().get(0).toString()); + Assertions.assertEquals("3", route.getLinkIds().get(1).toString()); + Assertions.assertEquals("4", route.getLinkIds().get(2).toString()); + Assertions.assertEquals("15", route.getEndLinkId().toString()); } @Test @@ -92,9 +92,9 @@ void testReaderReadsScoreAndSelectedPlanCorrectly() { CarrierPlanReaderV1 carrierPlanReaderV1 = new CarrierPlanReaderV1(carriers, carrierVehicleTypes ); carrierPlanReaderV1.readFile(utils.getClassInputDirectory() + "carrierPlansEquils.xml"); Carrier carrier = carriers.getCarriers().values().iterator().next(); - Assert.assertNotNull(carrier.getSelectedPlan()); - Assert.assertEquals(-100.0, carrier.getSelectedPlan().getScore(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2,carrier.getPlans().size()); + Assertions.assertNotNull(carrier.getSelectedPlan()); + Assertions.assertEquals(-100.0, carrier.getSelectedPlan().getScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2,carrier.getPlans().size()); } @Test @@ -109,8 +109,8 @@ void testReaderReadsUnScoredAndUnselectedPlanCorrectly() { CarrierPlanReaderV1 carrierPlanReaderV1 = new CarrierPlanReaderV1(carriers, carrierVehicleTypes ); carrierPlanReaderV1.readFile(utils.getClassInputDirectory() + "carrierPlansEquils_unscored_unselected.xml"); Carrier carrier = carriers.getCarriers().values().iterator().next(); - Assert.assertNull(carrier.getSelectedPlan()); - Assert.assertEquals(2,carrier.getPlans().size()); + Assertions.assertNull(carrier.getSelectedPlan()); + Assertions.assertEquals(2,carrier.getPlans().size()); } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2Test.java index 8d2c910226d..0c918cf4616 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2Test.java @@ -21,8 +21,8 @@ package org.matsim.freight.carriers; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -62,7 +62,7 @@ public void setUp() throws Exception{ @Test void test_whenReadingServices_nuOfServicesIsCorrect(){ - Assert.assertEquals(3,testCarrier.getServices().size()); + Assertions.assertEquals(3,testCarrier.getServices().size()); } @Test @@ -70,43 +70,43 @@ void test_whenReadingCarrier_itReadsTypeIdsCorrectly(){ CarrierVehicle light = CarriersUtils.getCarrierVehicle(testCarrier, Id.createVehicleId("lightVehicle")); Gbl.assertNotNull(light); - Assert.assertEquals("light",light.getVehicleTypeId().toString()); + Assertions.assertEquals("light",light.getVehicleTypeId().toString()); CarrierVehicle medium = CarriersUtils.getCarrierVehicle(testCarrier, Id.createVehicleId("mediumVehicle")); Gbl.assertNotNull(medium); - Assert.assertEquals("medium",medium.getVehicleTypeId().toString()); + Assertions.assertEquals("medium",medium.getVehicleTypeId().toString()); CarrierVehicle heavy = CarriersUtils.getCarrierVehicle(testCarrier, Id.createVehicleId("heavyVehicle")); Gbl.assertNotNull(heavy); - Assert.assertEquals("heavy",heavy.getVehicleTypeId().toString()); + Assertions.assertEquals("heavy",heavy.getVehicleTypeId().toString()); } @Test void test_whenReadingCarrier_itReadsVehiclesCorrectly(){ Map, CarrierVehicle> carrierVehicles = testCarrier.getCarrierCapabilities().getCarrierVehicles(); - Assert.assertEquals(3,carrierVehicles.size()); - Assert.assertTrue(exactlyTheseVehiclesAreInVehicleCollection(Arrays.asList(Id.create("lightVehicle", Vehicle.class), + Assertions.assertEquals(3,carrierVehicles.size()); + Assertions.assertTrue(exactlyTheseVehiclesAreInVehicleCollection(Arrays.asList(Id.create("lightVehicle", Vehicle.class), Id.create("mediumVehicle", Vehicle.class),Id.create("heavyVehicle", Vehicle.class)),carrierVehicles.values())); } @Test void test_whenReadingCarrier_itReadsFleetSizeCorrectly(){ - Assert.assertEquals(FleetSize.INFINITE, testCarrier.getCarrierCapabilities().getFleetSize()); + Assertions.assertEquals(FleetSize.INFINITE, testCarrier.getCarrierCapabilities().getFleetSize()); } @Test void test_whenReadingCarrier_itReadsShipmentsCorrectly(){ - Assert.assertEquals(2, testCarrier.getShipments().size()); + Assertions.assertEquals(2, testCarrier.getShipments().size()); } @Test void test_whenReadingCarrier_itReadsPlansCorrectly(){ - Assert.assertEquals(3, testCarrier.getPlans().size()); + Assertions.assertEquals(3, testCarrier.getPlans().size()); } @Test void test_whenReadingCarrier_itSelectsPlansCorrectly(){ - Assert.assertNotNull(testCarrier.getSelectedPlan()); + Assertions.assertNotNull(testCarrier.getSelectedPlan()); } @Test @@ -118,15 +118,15 @@ void test_whenReadingCarrierWithFiniteFleet_itSetsFleetSizeCorrectly(){ Carriers carriers = new Carriers(); String classInputDirectory = utils.getClassInputDirectory(); new CarrierPlanXmlReader(carriers, carrierVehicleTypes ).readFile(classInputDirectory + "carrierPlansEquilsFiniteFleet.xml" ); - Assert.assertEquals(FleetSize.FINITE, carriers.getCarriers().get(Id.create("testCarrier", Carrier.class)).getCarrierCapabilities().getFleetSize()); + Assertions.assertEquals(FleetSize.FINITE, carriers.getCarriers().get(Id.create("testCarrier", Carrier.class)).getCarrierCapabilities().getFleetSize()); } @Test void test_whenReadingPlans_nuOfToursIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); - Assert.assertEquals(1, plans.get(0).getScheduledTours().size()); - Assert.assertEquals(1, plans.get(1).getScheduledTours().size()); - Assert.assertEquals(1, plans.get(2).getScheduledTours().size()); + Assertions.assertEquals(1, plans.get(0).getScheduledTours().size()); + Assertions.assertEquals(1, plans.get(1).getScheduledTours().size()); + Assertions.assertEquals(1, plans.get(2).getScheduledTours().size()); } @Test @@ -134,7 +134,7 @@ void test_whenReadingToursOfPlan1_nuOfActivitiesIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); CarrierPlan plan1 = plans.get(0); ScheduledTour tour1 = plan1.getScheduledTours().iterator().next(); - Assert.assertEquals(5,tour1.getTour().getTourElements().size()); + Assertions.assertEquals(5,tour1.getTour().getTourElements().size()); } @Test @@ -142,7 +142,7 @@ void test_whenReadingToursOfPlan2_nuOfActivitiesIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); CarrierPlan plan2 = plans.get(1); ScheduledTour tour1 = plan2.getScheduledTours().iterator().next(); - Assert.assertEquals(9,tour1.getTour().getTourElements().size()); + Assertions.assertEquals(9,tour1.getTour().getTourElements().size()); } @Test @@ -150,7 +150,7 @@ void test_whenReadingToursOfPlan3_nuOfActivitiesIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); CarrierPlan plan3 = plans.get(2); ScheduledTour tour1 = plan3.getScheduledTours().iterator().next(); - Assert.assertEquals(9,tour1.getTour().getTourElements().size()); + Assertions.assertEquals(9,tour1.getTour().getTourElements().size()); } @@ -163,18 +163,18 @@ private boolean exactlyTheseVehiclesAreInVehicleCollection(List> asL @Test void test_CarrierHasAttributes(){ - Assert.assertEquals((TransportMode.drt), CarriersUtils.getCarrierMode(testCarrier)); - Assert.assertEquals(50, CarriersUtils.getJspritIterations(testCarrier)); + Assertions.assertEquals((TransportMode.drt), CarriersUtils.getCarrierMode(testCarrier)); + Assertions.assertEquals(50, CarriersUtils.getJspritIterations(testCarrier)); } @Test void test_ServicesAndShipmentsHaveAttributes(){ Object serviceCustomerAtt = testCarrier.getServices().get(Id.create("serv1", CarrierService.class)).getAttributes().getAttribute("customer"); - Assert.assertNotNull(serviceCustomerAtt); - Assert.assertEquals("someRandomCustomer", serviceCustomerAtt); + Assertions.assertNotNull(serviceCustomerAtt); + Assertions.assertEquals("someRandomCustomer", serviceCustomerAtt); Object shipmentCustomerAtt = testCarrier.getShipments().get(Id.create("s1",CarrierShipment.class)).getAttributes().getAttribute("customer"); - Assert.assertNotNull(shipmentCustomerAtt); - Assert.assertEquals("someRandomCustomer", shipmentCustomerAtt); + Assertions.assertNotNull(shipmentCustomerAtt); + Assertions.assertEquals("someRandomCustomer", shipmentCustomerAtt); } @Test @@ -210,7 +210,7 @@ void test_readStream() { new CarrierPlanXmlReader(carriers, carrierVehicleTypes ).readStream(is ); - Assert.assertEquals(1, carriers.getCarriers().size()); + Assertions.assertEquals(1, carriers.getCarriers().size()); } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java index 32b3dd45307..0532c455bd7 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java @@ -21,9 +21,9 @@ package org.matsim.freight.carriers; -import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -57,7 +57,7 @@ public void setUp() throws Exception{ @Test @Ignore void test_whenReadingServices_nuOfServicesIsCorrect(){ - Assert.assertEquals(3,testCarrier.getServices().size()); + Assertions.assertEquals(3,testCarrier.getServices().size()); } @Test @@ -65,48 +65,48 @@ void test_whenReadingCarrier_itReadsTypeIdsCorrectly(){ CarrierVehicle light = CarriersUtils.getCarrierVehicle(testCarrier, Id.createVehicleId("lightVehicle")); Gbl.assertNotNull(light); - Assert.assertEquals("light",light.getVehicleTypeId().toString()); + Assertions.assertEquals("light",light.getVehicleTypeId().toString()); CarrierVehicle medium = CarriersUtils.getCarrierVehicle(testCarrier, Id.createVehicleId("mediumVehicle")); Gbl.assertNotNull(medium); - Assert.assertEquals("medium",medium.getVehicleTypeId().toString()); + Assertions.assertEquals("medium",medium.getVehicleTypeId().toString()); CarrierVehicle heavy = CarriersUtils.getCarrierVehicle(testCarrier, Id.createVehicleId("heavyVehicle")); Gbl.assertNotNull(heavy); - Assert.assertEquals("heavy",heavy.getVehicleTypeId().toString()); + Assertions.assertEquals("heavy",heavy.getVehicleTypeId().toString()); } @Test @Ignore void test_whenReadingCarrier_itReadsVehiclesCorrectly(){ Map, CarrierVehicle> carrierVehicles = testCarrier.getCarrierCapabilities().getCarrierVehicles(); - Assert.assertEquals(3,carrierVehicles.size()); - Assert.assertTrue(exactlyTheseVehiclesAreInVehicleCollection(Arrays.asList(Id.create("lightVehicle", Vehicle.class), + Assertions.assertEquals(3,carrierVehicles.size()); + Assertions.assertTrue(exactlyTheseVehiclesAreInVehicleCollection(Arrays.asList(Id.create("lightVehicle", Vehicle.class), Id.create("mediumVehicle", Vehicle.class),Id.create("heavyVehicle", Vehicle.class)),carrierVehicles.values())); } @Test @Ignore void test_whenReadingCarrier_itReadsFleetSizeCorrectly(){ - Assert.assertEquals(FleetSize.INFINITE, testCarrier.getCarrierCapabilities().getFleetSize()); + Assertions.assertEquals(FleetSize.INFINITE, testCarrier.getCarrierCapabilities().getFleetSize()); } @Test @Ignore void test_whenReadingCarrier_itReadsShipmentsCorrectly(){ - Assert.assertEquals(2, testCarrier.getShipments().size()); + Assertions.assertEquals(2, testCarrier.getShipments().size()); } @Test @Ignore void test_whenReadingCarrier_itReadsPlansCorrectly(){ - Assert.assertEquals(3, testCarrier.getPlans().size()); + Assertions.assertEquals(3, testCarrier.getPlans().size()); } @Test @Ignore void test_whenReadingCarrier_itSelectsPlansCorrectly(){ - Assert.assertNotNull(testCarrier.getSelectedPlan()); + Assertions.assertNotNull(testCarrier.getSelectedPlan()); } @Test @@ -118,16 +118,16 @@ void test_whenReadingCarrierWithFiniteFleet_itSetsFleetSizeCorrectly(){ Carriers carriers = new Carriers(); String classInputDirectory = utils.getClassInputDirectory(); new CarrierPlanXmlReader(carriers, carrierVehicleTypes ).readFile(classInputDirectory + "carrierPlansEquilsFiniteFleetWithDtd.xml" ); - Assert.assertEquals(FleetSize.FINITE, carriers.getCarriers().get(Id.create("testCarrier", Carrier.class)).getCarrierCapabilities().getFleetSize()); + Assertions.assertEquals(FleetSize.FINITE, carriers.getCarriers().get(Id.create("testCarrier", Carrier.class)).getCarrierCapabilities().getFleetSize()); } @Test @Ignore void test_whenReadingPlans_nuOfToursIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); - Assert.assertEquals(1, plans.get(0).getScheduledTours().size()); - Assert.assertEquals(1, plans.get(1).getScheduledTours().size()); - Assert.assertEquals(1, plans.get(2).getScheduledTours().size()); + Assertions.assertEquals(1, plans.get(0).getScheduledTours().size()); + Assertions.assertEquals(1, plans.get(1).getScheduledTours().size()); + Assertions.assertEquals(1, plans.get(2).getScheduledTours().size()); } @Test @@ -136,7 +136,7 @@ void test_whenReadingToursOfPlan1_nuOfActivitiesIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); CarrierPlan plan1 = plans.get(0); ScheduledTour tour1 = plan1.getScheduledTours().iterator().next(); - Assert.assertEquals(5,tour1.getTour().getTourElements().size()); + Assertions.assertEquals(5,tour1.getTour().getTourElements().size()); } @Test @@ -144,7 +144,7 @@ void test_whenReadingToursOfPlan2_nuOfActivitiesIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); CarrierPlan plan2 = plans.get(1); ScheduledTour tour1 = plan2.getScheduledTours().iterator().next(); - Assert.assertEquals(9,tour1.getTour().getTourElements().size()); + Assertions.assertEquals(9,tour1.getTour().getTourElements().size()); } @Test @@ -153,7 +153,7 @@ void test_whenReadingToursOfPlan3_nuOfActivitiesIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); CarrierPlan plan3 = plans.get(2); ScheduledTour tour1 = plan3.getScheduledTours().iterator().next(); - Assert.assertEquals(9,tour1.getTour().getTourElements().size()); + Assertions.assertEquals(9,tour1.getTour().getTourElements().size()); } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test.java index c6a5c2f42b1..a5617f9a1d2 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test.java @@ -33,7 +33,7 @@ import java.util.*; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class CarrierPlanXmlWriterV2Test { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1Test.java index 315570c91a2..9f2d701bf0a 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1Test.java @@ -33,7 +33,7 @@ import java.util.*; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class CarrierPlanXmlWriterV2_1Test { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest.java index 6f6a002f19c..7efefd4ce40 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest.java @@ -21,8 +21,8 @@ package org.matsim.freight.carriers; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -54,16 +54,16 @@ void test_whenLoadingTypes_allAssignmentsInLightVehicleAreCorrectly(){ CarrierVehicle v = CarriersUtils.getCarrierVehicle(testCarrier,Id.createVehicleId("lightVehicle")); VehicleType vehicleTypeLoaded = v.getType(); - Assert.assertNotNull(vehicleTypeLoaded); + Assertions.assertNotNull(vehicleTypeLoaded); - Assert.assertEquals("light", vehicleTypeLoaded.getId().toString()); - Assert.assertEquals(15, vehicleTypeLoaded.getCapacity().getOther(), MatsimTestUtils.EPSILON); - Assert.assertEquals(20, vehicleTypeLoaded.getCostInformation().getFixedCosts(), MatsimTestUtils.EPSILON); - Assert.assertEquals(0.35, vehicleTypeLoaded.getCostInformation().getCostsPerMeter(), MatsimTestUtils.EPSILON); - Assert.assertEquals(30, vehicleTypeLoaded.getCostInformation().getCostsPerSecond(), MatsimTestUtils.EPSILON); + Assertions.assertEquals("light", vehicleTypeLoaded.getId().toString()); + Assertions.assertEquals(15, vehicleTypeLoaded.getCapacity().getOther(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(20, vehicleTypeLoaded.getCostInformation().getFixedCosts(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.35, vehicleTypeLoaded.getCostInformation().getCostsPerMeter(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(30, vehicleTypeLoaded.getCostInformation().getCostsPerSecond(), MatsimTestUtils.EPSILON); - Assert.assertEquals("gasoline", vehicleTypeLoaded.getEngineInformation().getFuelType().toString()); - Assert.assertEquals(0.02, VehicleUtils.getFuelConsumption(vehicleTypeLoaded), MatsimTestUtils.EPSILON); + Assertions.assertEquals("gasoline", vehicleTypeLoaded.getEngineInformation().getFuelType().toString()); + Assertions.assertEquals(0.02, VehicleUtils.getFuelConsumption(vehicleTypeLoaded), MatsimTestUtils.EPSILON); } @Test @@ -73,16 +73,16 @@ void test_whenLoadingTypes_allAssignmentsInMediumVehicleAreCorrectly(){ CarrierVehicle v = CarriersUtils.getCarrierVehicle(testCarrier,Id.createVehicleId("mediumVehicle")); VehicleType vehicleTypeLoaded = v.getType(); - Assert.assertNotNull(vehicleTypeLoaded); + Assertions.assertNotNull(vehicleTypeLoaded); - Assert.assertEquals("medium", vehicleTypeLoaded.getId().toString()); - Assert.assertEquals(30, vehicleTypeLoaded.getCapacity().getOther(), MatsimTestUtils.EPSILON); - Assert.assertEquals(50, vehicleTypeLoaded.getCostInformation().getFixedCosts(), MatsimTestUtils.EPSILON); - Assert.assertEquals(0.4, vehicleTypeLoaded.getCostInformation().getCostsPerMeter(), MatsimTestUtils.EPSILON); - Assert.assertEquals(30, vehicleTypeLoaded.getCostInformation().getCostsPerSecond(), MatsimTestUtils.EPSILON); + Assertions.assertEquals("medium", vehicleTypeLoaded.getId().toString()); + Assertions.assertEquals(30, vehicleTypeLoaded.getCapacity().getOther(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(50, vehicleTypeLoaded.getCostInformation().getFixedCosts(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.4, vehicleTypeLoaded.getCostInformation().getCostsPerMeter(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(30, vehicleTypeLoaded.getCostInformation().getCostsPerSecond(), MatsimTestUtils.EPSILON); - Assert.assertEquals("gasoline", vehicleTypeLoaded.getEngineInformation().getFuelType().toString()); - Assert.assertEquals(0.02, VehicleUtils.getFuelConsumption(vehicleTypeLoaded), MatsimTestUtils.EPSILON); + Assertions.assertEquals("gasoline", vehicleTypeLoaded.getEngineInformation().getFuelType().toString()); + Assertions.assertEquals(0.02, VehicleUtils.getFuelConsumption(vehicleTypeLoaded), MatsimTestUtils.EPSILON); } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest.java index 5801d07e523..c7a740a1a31 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest.java @@ -30,8 +30,8 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.VehicleType; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CarrierVehicleTypeReaderTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeTest.java index 080ea93de26..74152387942 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeTest.java @@ -21,8 +21,8 @@ package org.matsim.freight.carriers; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -86,102 +86,102 @@ public void setUp() throws Exception{ @Test void test_whenCreatingTypeMedium_itCreatesDescriptionCorrectly(){ VehicleType medium = types.getVehicleTypes().get(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ); - Assert.assertEquals("Medium Vehicle", medium.getDescription()); + Assertions.assertEquals("Medium Vehicle", medium.getDescription()); } @Test void test_whenCreatingTypeMedium_itCreatesCapacityCorrectly(){ VehicleType medium = types.getVehicleTypes().get(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ); - Assert.assertEquals(30., medium.getCapacity().getWeightInTons(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(30., medium.getCapacity().getWeightInTons(), MatsimTestUtils.EPSILON ); } @Test void test_whenCreatingTypeMedium_itCreatesCostInfoCorrectly(){ VehicleType medium = types.getVehicleTypes().get(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ); - Assert.assertEquals(50.0, medium.getCostInformation().getFixedCosts(),0.01 ); - Assert.assertEquals(1.0, medium.getCostInformation().getCostsPerMeter(),0.01 ); - Assert.assertEquals(0.5, medium.getCostInformation().getCostsPerSecond(),0.01 ); + Assertions.assertEquals(50.0, medium.getCostInformation().getFixedCosts(),0.01 ); + Assertions.assertEquals(1.0, medium.getCostInformation().getCostsPerMeter(),0.01 ); + Assertions.assertEquals(0.5, medium.getCostInformation().getCostsPerSecond(),0.01 ); } @Test void test_whenCreatingTypeMedium_itCreatesEngineInfoCorrectly(){ VehicleType medium = types.getVehicleTypes().get(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ); - Assert.assertEquals(0.02, medium.getEngineInformation().getFuelConsumption(),0.001); - Assert.assertEquals(FuelType.diesel, medium.getEngineInformation().getFuelType()); + Assertions.assertEquals(0.02, medium.getEngineInformation().getFuelConsumption(),0.001); + Assertions.assertEquals(FuelType.diesel, medium.getEngineInformation().getFuelType()); } @Test void test_whenCreatingTypeMedium_itCreatesMaxVelocityCorrectly(){ VehicleType medium = types.getVehicleTypes().get(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ); - Assert.assertEquals(13.89, medium.getMaximumVelocity(), 0.01); + Assertions.assertEquals(13.89, medium.getMaximumVelocity(), 0.01); } //Now testing the copy @Test void test_whenCopyingTypeMedium_itCopiesDescriptionCorrectly(){ VehicleType medium2 = types.getVehicleTypes().get(Id.create("medium2", org.matsim.vehicles.VehicleType.class ) ); - Assert.assertEquals("Medium Vehicle", medium2.getDescription()); + Assertions.assertEquals("Medium Vehicle", medium2.getDescription()); } @Test void test_whenCopyingTypeMedium_itCopiesCapacityCorrectly(){ VehicleType medium2 = types.getVehicleTypes().get(Id.create("medium2", org.matsim.vehicles.VehicleType.class ) ); - Assert.assertEquals(30., medium2.getCapacity().getWeightInTons(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(30., medium2.getCapacity().getWeightInTons(), MatsimTestUtils.EPSILON ); } @Test void test_whenCopyingTypeMedium_itCopiesCostInfoCorrectly(){ VehicleType medium2 = types.getVehicleTypes().get(Id.create("medium2", org.matsim.vehicles.VehicleType.class ) ); - Assert.assertEquals(50.0, medium2.getCostInformation().getFixedCosts(),0.01 ); - Assert.assertEquals(1.0, medium2.getCostInformation().getCostsPerMeter(),0.01 ); - Assert.assertEquals(0.5, medium2.getCostInformation().getCostsPerSecond(),0.01 ); + Assertions.assertEquals(50.0, medium2.getCostInformation().getFixedCosts(),0.01 ); + Assertions.assertEquals(1.0, medium2.getCostInformation().getCostsPerMeter(),0.01 ); + Assertions.assertEquals(0.5, medium2.getCostInformation().getCostsPerSecond(),0.01 ); } @Test void test_whenCopyingTypeMedium_itCopiesEngineInfoCorrectly(){ VehicleType medium2 = types.getVehicleTypes().get(Id.create("medium2", org.matsim.vehicles.VehicleType.class ) ); - Assert.assertEquals(0.02, medium2.getEngineInformation().getFuelConsumption(),0.001); - Assert.assertEquals(FuelType.diesel, medium2.getEngineInformation().getFuelType()); + Assertions.assertEquals(0.02, medium2.getEngineInformation().getFuelConsumption(),0.001); + Assertions.assertEquals(FuelType.diesel, medium2.getEngineInformation().getFuelType()); } @Test void test_whenCopyingTypeMedium_itCopiesMaxVelocityCorrectly(){ VehicleType medium2 = types.getVehicleTypes().get(Id.create("medium2", org.matsim.vehicles.VehicleType.class ) ); - Assert.assertEquals(13.89, medium2.getMaximumVelocity(), 0.01); + Assertions.assertEquals(13.89, medium2.getMaximumVelocity(), 0.01); } //Now testing the modified type. @Test void test_whenModifyingTypeSmall_itModifiesDescriptionCorrectly(){ VehicleType small = types.getVehicleTypes().get(Id.create("small", org.matsim.vehicles.VehicleType.class ) ); - Assert.assertEquals("Small Vehicle", small.getDescription()); + Assertions.assertEquals("Small Vehicle", small.getDescription()); } @Test void test_whenModifyingTypeSmall_itModifiesCapacityCorrectly(){ VehicleType small = types.getVehicleTypes().get(Id.create("small", org.matsim.vehicles.VehicleType.class ) ); - Assert.assertEquals(16., small.getCapacity().getWeightInTons(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(16., small.getCapacity().getWeightInTons(), MatsimTestUtils.EPSILON ); } @Test void test_whenModifyingTypeSmall_itModifiesCostInfoCorrectly(){ VehicleType small = types.getVehicleTypes().get(Id.create("small", org.matsim.vehicles.VehicleType.class ) ); - Assert.assertEquals(25.0, small.getCostInformation().getFixedCosts(),0.01 ); - Assert.assertEquals(0.75, small.getCostInformation().getCostsPerMeter(),0.01 ); - Assert.assertEquals(0.25, small.getCostInformation().getCostsPerSecond(),0.01 ); + Assertions.assertEquals(25.0, small.getCostInformation().getFixedCosts(),0.01 ); + Assertions.assertEquals(0.75, small.getCostInformation().getCostsPerMeter(),0.01 ); + Assertions.assertEquals(0.25, small.getCostInformation().getCostsPerSecond(),0.01 ); } @Test void test_whenModifyingTypeSmall_itModifiesEngineInfoCorrectly(){ VehicleType small = types.getVehicleTypes().get(Id.create("small", org.matsim.vehicles.VehicleType.class ) ); - Assert.assertEquals(0.015, small.getEngineInformation().getFuelConsumption(),0.001); - Assert.assertEquals(FuelType.gasoline, small.getEngineInformation().getFuelType()); + Assertions.assertEquals(0.015, small.getEngineInformation().getFuelConsumption(),0.001); + Assertions.assertEquals(FuelType.gasoline, small.getEngineInformation().getFuelType()); } @Test void test_whenModifyingTypeSmall_itModifiesMaxVelocityCorrectly(){ VehicleType small = types.getVehicleTypes().get(Id.create("small", org.matsim.vehicles.VehicleType.class ) ); - Assert.assertEquals(10.0, small.getMaximumVelocity(), 0.01); + Assertions.assertEquals(10.0, small.getMaximumVelocity(), 0.01); } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java index a70e13239eb..b57f9d7b884 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java @@ -21,7 +21,7 @@ package org.matsim.freight.carriers; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -48,16 +48,16 @@ void testAddAndGetVehicleToCarrier() { //add Vehicle CarriersUtils.addCarrierVehicle(carrier, carrierVehicle); - Assert.assertEquals(1, carrier.getCarrierCapabilities().getCarrierVehicles().size()); + Assertions.assertEquals(1, carrier.getCarrierCapabilities().getCarrierVehicles().size()); CarrierVehicle cv = (CarrierVehicle) carrier.getCarrierCapabilities().getCarrierVehicles().values().toArray()[0]; - Assert.assertEquals(VehicleUtils.getDefaultVehicleType(), cv.getType()); - Assert.assertEquals(Id.createLinkId("link0"), cv.getLinkId() ); + Assertions.assertEquals(VehicleUtils.getDefaultVehicleType(), cv.getType()); + Assertions.assertEquals(Id.createLinkId("link0"), cv.getLinkId() ); //get Vehicle CarrierVehicle carrierVehicle1 = CarriersUtils.getCarrierVehicle(carrier, testVehicleId ); - Assert.assertEquals(testVehicleId, carrierVehicle1.getId()); - Assert.assertEquals(VehicleUtils.getDefaultVehicleType(), carrierVehicle1.getType()); - Assert.assertEquals(Id.createLinkId("link0"), carrierVehicle1.getLinkId() ); + Assertions.assertEquals(testVehicleId, carrierVehicle1.getId()); + Assertions.assertEquals(VehicleUtils.getDefaultVehicleType(), carrierVehicle1.getType()); + Assertions.assertEquals(Id.createLinkId("link0"), carrierVehicle1.getLinkId() ); } @Test @@ -69,17 +69,17 @@ void testAddAndGetServiceToCarrier() { //add Service CarriersUtils.addService(carrier, service1); - Assert.assertEquals(1, carrier.getServices().size()); + Assertions.assertEquals(1, carrier.getServices().size()); CarrierService cs1a = (CarrierService) carrier.getServices().values().toArray()[0]; - Assert.assertEquals(service1, cs1a); - Assert.assertEquals(Id.createLinkId("link0"), cs1a.getLocationLinkId()); + Assertions.assertEquals(service1, cs1a); + Assertions.assertEquals(Id.createLinkId("link0"), cs1a.getLocationLinkId()); //get Service CarrierService cs1b = CarriersUtils.getService(carrier, serviceId ); - Assert.assertEquals(serviceId, cs1b.getId()); - Assert.assertEquals(service1.getId(), cs1b.getId()); - Assert.assertEquals(Id.createLinkId("link0"), cs1b.getLocationLinkId()); - Assert.assertEquals(30, cs1b.getServiceDuration(), EPSILON); + Assertions.assertEquals(serviceId, cs1b.getId()); + Assertions.assertEquals(service1.getId(), cs1b.getId()); + Assertions.assertEquals(Id.createLinkId("link0"), cs1b.getLocationLinkId()); + Assertions.assertEquals(30, cs1b.getServiceDuration(), EPSILON); } @Test @@ -90,27 +90,27 @@ void testAddAndGetShipmentToCarrier() { //add Shipment CarriersUtils.addShipment(carrier, service1); - Assert.assertEquals(1, carrier.getShipments().size()); + Assertions.assertEquals(1, carrier.getShipments().size()); CarrierShipment carrierShipment1a = (CarrierShipment) carrier.getShipments().values().toArray()[0]; - Assert.assertEquals(service1, carrierShipment1a); - Assert.assertEquals(Id.createLinkId("link0"), carrierShipment1a.getFrom()); + Assertions.assertEquals(service1, carrierShipment1a); + Assertions.assertEquals(Id.createLinkId("link0"), carrierShipment1a.getFrom()); //get Shipment CarrierShipment carrierShipment1b = CarriersUtils.getShipment(carrier, shipmentId ); - Assert.assertEquals(shipmentId, carrierShipment1b.getId()); - Assert.assertEquals(service1.getId(), carrierShipment1b.getId()); - Assert.assertEquals(Id.createLinkId("link0"), carrierShipment1b.getFrom()); - Assert.assertEquals(20, carrierShipment1b.getSize(), EPSILON); + Assertions.assertEquals(shipmentId, carrierShipment1b.getId()); + Assertions.assertEquals(service1.getId(), carrierShipment1b.getId()); + Assertions.assertEquals(Id.createLinkId("link0"), carrierShipment1b.getFrom()); + Assertions.assertEquals(20, carrierShipment1b.getSize(), EPSILON); } @Test void testGetSetJspritIteration(){ Carrier carrier = new CarrierImpl(Id.create("carrier", Carrier.class)); //jspirtIterations is not set. should return Integer.Min_Value (null is not possible because returning (int) - Assert.assertEquals(Integer.MIN_VALUE, CarriersUtils.getJspritIterations(carrier) ); + Assertions.assertEquals(Integer.MIN_VALUE, CarriersUtils.getJspritIterations(carrier) ); CarriersUtils.setJspritIterations(carrier, 125); - Assert.assertEquals(125, CarriersUtils.getJspritIterations(carrier) ); + Assertions.assertEquals(125, CarriersUtils.getJspritIterations(carrier) ); } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/FreightCarriersConfigGroupTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/FreightCarriersConfigGroupTest.java index a56f1fce3aa..6113348707b 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/FreightCarriersConfigGroupTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/FreightCarriersConfigGroupTest.java @@ -21,7 +21,7 @@ package org.matsim.freight.carriers; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigReader; @@ -43,11 +43,11 @@ void test_allParametersAreWrittenToXml() { FreightCarriersConfigGroup freight = new FreightCarriersConfigGroup(); Map params = freight.getParams(); - Assert.assertTrue(params.containsKey(FreightCarriersConfigGroup.CARRIERS_FILE)); - Assert.assertTrue(params.containsKey(FreightCarriersConfigGroup.CARRIERS_VEHICLE_TYPE)); - Assert.assertTrue(params.containsKey(FreightCarriersConfigGroup.VEHICLE_ROUTING_ALGORITHM)); - Assert.assertTrue(params.containsKey(FreightCarriersConfigGroup.TRAVEL_TIME_SLICE_WIDTH)); - Assert.assertTrue(params.containsKey(FreightCarriersConfigGroup.USE_DISTANCE_CONSTRAINT)); + Assertions.assertTrue(params.containsKey(FreightCarriersConfigGroup.CARRIERS_FILE)); + Assertions.assertTrue(params.containsKey(FreightCarriersConfigGroup.CARRIERS_VEHICLE_TYPE)); + Assertions.assertTrue(params.containsKey(FreightCarriersConfigGroup.VEHICLE_ROUTING_ALGORITHM)); + Assertions.assertTrue(params.containsKey(FreightCarriersConfigGroup.TRAVEL_TIME_SLICE_WIDTH)); + Assertions.assertTrue(params.containsKey(FreightCarriersConfigGroup.USE_DISTANCE_CONSTRAINT)); } @Test @@ -71,11 +71,11 @@ void test_configXmlCanBeParsed() { new ConfigReader(config).parse(is); - Assert.assertEquals("/path/to/carriers.xml", freight.getCarriersFile()); - Assert.assertEquals("/path/to/carriersVehicleTypes.xml", freight.getCarriersVehicleTypesFile()); - Assert.assertEquals("/path/to/carriersRoutingAlgorithm.xml", freight.getVehicleRoutingAlgorithmFile()); - Assert.assertEquals(3600.0, freight.getTravelTimeSliceWidth(), 1e-8); - Assert.assertEquals(UseDistanceConstraintForTourPlanning.basedOnEnergyConsumption, freight.getUseDistanceConstraintForTourPlanning()); + Assertions.assertEquals("/path/to/carriers.xml", freight.getCarriersFile()); + Assertions.assertEquals("/path/to/carriersVehicleTypes.xml", freight.getCarriersVehicleTypesFile()); + Assertions.assertEquals("/path/to/carriersRoutingAlgorithm.xml", freight.getVehicleRoutingAlgorithmFile()); + Assertions.assertEquals(3600.0, freight.getTravelTimeSliceWidth(), 1e-8); + Assertions.assertEquals(UseDistanceConstraintForTourPlanning.basedOnEnergyConsumption, freight.getUseDistanceConstraintForTourPlanning()); } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java index c073356e1f0..507326c6e2b 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java @@ -21,8 +21,8 @@ package org.matsim.freight.carriers.controler; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -98,10 +98,10 @@ public void install() { controler.run(); Carrier carrier1 = controler.getInjector().getInstance(Carriers.class).getCarriers().get(Id.create("carrier1", Carrier.class)); - Assert.assertEquals(-170000.0, carrier1.getSelectedPlan().getScore(), 0.0 ); + Assertions.assertEquals(-170000.0, carrier1.getSelectedPlan().getScore(), 0.0 ); Carrier carrier2 = controler.getInjector().getInstance(Carriers.class).getCarriers().get(Id.create("carrier2", Carrier.class)); - Assert.assertEquals(-85000.0, carrier2.getSelectedPlan().getScore(), 0.0 ); + Assertions.assertEquals(-85000.0, carrier2.getSelectedPlan().getScore(), 0.0 ); } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT.java index e82e956b9da..83f1dd9e021 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT.java @@ -23,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -115,10 +115,10 @@ public void install() { controler.run(); Carrier carrier1 = CarriersUtils.getCarriers(controler.getScenario()).getCarriers().get(Id.create("carrier1", Carrier.class)); - Assert.assertEquals(-170000.0, carrier1.getSelectedPlan().getScore(), 0.0 ); + Assertions.assertEquals(-170000.0, carrier1.getSelectedPlan().getScore(), 0.0 ); Carrier carrier2 = CarriersUtils.getCarriers(controler.getScenario()).getCarriers().get(Id.create("carrier2", Carrier.class)); - Assert.assertEquals(-85000.0, carrier2.getSelectedPlan().getScore(), 0.0 ); + Assertions.assertEquals(-85000.0, carrier2.getSelectedPlan().getScore(), 0.0 ); } @Test @@ -141,10 +141,10 @@ public void install() { controler.run(); Carrier carrier1 = CarriersUtils.getCarriers(controler.getScenario()).getCarriers().get(Id.create("carrier1", Carrier.class)); - Assert.assertEquals(-240.0, carrier1.getSelectedPlan().getScore(), 2.0); + Assertions.assertEquals(-240.0, carrier1.getSelectedPlan().getScore(), 2.0); Carrier carrier2 = CarriersUtils.getCarriers(controler.getScenario()).getCarriers().get(Id.create("carrier2", Carrier.class)); - Assert.assertEquals(0.0, carrier2.getSelectedPlan().getScore(), 0.0 ); + Assertions.assertEquals(0.0, carrier2.getSelectedPlan().getScore(), 0.0 ); } @@ -169,10 +169,10 @@ public void install() { controler.run(); Carrier carrier1 = CarriersUtils.getCarriers(controler.getScenario()).getCarriers().get(Id.create("carrier1", Carrier.class)); - Assert.assertEquals(-4873.0, carrier1.getSelectedPlan().getScore(), 2.0); + Assertions.assertEquals(-4873.0, carrier1.getSelectedPlan().getScore(), 2.0); Carrier carrier2 = CarriersUtils.getCarriers(controler.getScenario()).getCarriers().get(Id.create("carrier2", Carrier.class)); - Assert.assertEquals(0.0, carrier2.getSelectedPlan().getScore(), 0.0 ); + Assertions.assertEquals(0.0, carrier2.getSelectedPlan().getScore(), 0.0 ); } @@ -197,7 +197,7 @@ public void install() { controler.run(); Carrier carrier1 = CarriersUtils.getCarriers(controler.getScenario()).getCarriers().get(Id.create("carrier1", Carrier.class)); - Assert.assertEquals(-4871.0, carrier1.getSelectedPlan().getScore(), 2.0); + Assertions.assertEquals(-4871.0, carrier1.getSelectedPlan().getScore(), 2.0); } @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java index 7879f26e03d..d7329adc924 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -111,23 +111,26 @@ final void CarrierSmallBatteryTest_Version1() throws ExecutionException, Interru CarriersUtils.runJsprit(scenario); - Assert.assertEquals("Not the correct amout of scheduled tours", 1, - carrierV1.getSelectedPlan().getScheduledTours().size()); + Assertions.assertEquals(1, + carrierV1.getSelectedPlan().getScheduledTours().size(), + "Not the correct amout of scheduled tours"); VehicleType vehicleType_SmallV1 = vehicleTypes.getVehicleTypes().get(Id.create("SmallBattery_V1", VehicleType.class)); VehicleType vehicleType_LargeV1 = vehicleTypes.getVehicleTypes().get(Id.create("LargeBattery_V1", VehicleType.class)); - Assert.assertEquals(vehicleType_SmallV1.getId(), ((Vehicle) carrierV1.getSelectedPlan().getScheduledTours().iterator().next() + Assertions.assertEquals(vehicleType_SmallV1.getId(), ((Vehicle) carrierV1.getSelectedPlan().getScheduledTours().iterator().next() .getVehicle()).getType().getId()); double maxDistance_vehicleType_LargeV1 = VehicleUtils.getEnergyCapacity(vehicleType_LargeV1.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_LargeV1.getEngineInformation()); double maxDistance_vehicleType_SmallV1 = VehicleUtils.getEnergyCapacity(vehicleType_SmallV1.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_SmallV1.getEngineInformation()); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_LargeV1, - MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_SmallV1, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(30000, maxDistance_vehicleType_LargeV1, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); + Assertions.assertEquals(30000, maxDistance_vehicleType_SmallV1, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); double distanceTour = 0.0; List elements = carrierV1.getSelectedPlan().getScheduledTours().iterator().next().getTour() @@ -140,8 +143,9 @@ final void CarrierSmallBatteryTest_Version1() throws ExecutionException, Interru scenario.getNetwork()); } } - Assert.assertEquals("The schedulded tour has a non expected distance", 24000, distanceTour, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(24000, distanceTour, + MatsimTestUtils.EPSILON, + "The schedulded tour has a non expected distance"); } /** @@ -185,23 +189,26 @@ final void CarrierLargeBatteryTest_Version2() throws ExecutionException, Interru CarriersUtils.runJsprit(scenario); - Assert.assertEquals("Not the correct amout of scheduled tours", 1, - carrierV2.getSelectedPlan().getScheduledTours().size()); + Assertions.assertEquals(1, + carrierV2.getSelectedPlan().getScheduledTours().size(), + "Not the correct amout of scheduled tours"); VehicleType vehicleType_SmallV2 = vehicleTypes.getVehicleTypes().get(Id.create("SmallBattery_V2", VehicleType.class)); VehicleType vehicleType_LargeV2 = vehicleTypes.getVehicleTypes().get(Id.create("LargeBattery_V2", VehicleType.class)); - Assert.assertEquals(vehicleType_LargeV2.getId(), carrierV2.getSelectedPlan().getScheduledTours().iterator().next() + Assertions.assertEquals(vehicleType_LargeV2.getId(), carrierV2.getSelectedPlan().getScheduledTours().iterator().next() .getVehicle().getType().getId()); double maxDistance_vehicleType_LargeV2 = VehicleUtils.getEnergyCapacity(vehicleType_LargeV2.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_LargeV2.getEngineInformation()); double maxDistance_vehicleType_SmallV2 = VehicleUtils.getEnergyCapacity(vehicleType_SmallV2.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_SmallV2.getEngineInformation()); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_LargeV2, - MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 15000, maxDistance_vehicleType_SmallV2, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(30000, maxDistance_vehicleType_LargeV2, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); + Assertions.assertEquals(15000, maxDistance_vehicleType_SmallV2, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); double distanceTour = 0.0; List elements = carrierV2.getSelectedPlan().getScheduledTours().iterator().next().getTour() @@ -214,8 +221,9 @@ final void CarrierLargeBatteryTest_Version2() throws ExecutionException, Interru scenario.getNetwork()); } } - Assert.assertEquals("The schedulded tour has a non expected distance", 24000, distanceTour, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(24000, distanceTour, + MatsimTestUtils.EPSILON, + "The schedulded tour has a non expected distance"); } @@ -259,8 +267,9 @@ final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, Interr CarriersUtils.runJsprit(scenario); - Assert.assertEquals("Not the correct amout of scheduled tours", 2, - carrierV3.getSelectedPlan().getScheduledTours().size()); + Assertions.assertEquals(2, + carrierV3.getSelectedPlan().getScheduledTours().size(), + "Not the correct amout of scheduled tours"); VehicleType vehicleType_SmallV3 = vehicleTypes.getVehicleTypes().get(Id.create("SmallBattery_V3", VehicleType.class)); VehicleType vehicleType_LargeV3 = vehicleTypes.getVehicleTypes().get(Id.create("LargeBattery_V3", VehicleType.class)); @@ -270,11 +279,13 @@ final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, Interr double maxDistance_vehicleType_SmallV3 = VehicleUtils.getEnergyCapacity(vehicleType_SmallV3.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_SmallV3.getEngineInformation()); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_LargeV3, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(30000, maxDistance_vehicleType_LargeV3, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_SmallV3, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(30000, maxDistance_vehicleType_SmallV3, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); for (ScheduledTour scheduledTour : carrierV3.getSelectedPlan().getScheduledTours()) { @@ -289,13 +300,15 @@ final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, Interr 0, scenario.getNetwork()); } } - Assert.assertEquals(vehicleType_SmallV3.getId(), scheduledTour.getVehicle().getType().getId()); + Assertions.assertEquals(vehicleType_SmallV3.getId(), scheduledTour.getVehicle().getType().getId()); if (distanceTour == 12000) - Assert.assertEquals("The schedulded tour has a non expected distance", 12000, distanceTour, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(12000, distanceTour, + MatsimTestUtils.EPSILON, + "The schedulded tour has a non expected distance"); else - Assert.assertEquals("The schedulded tour has a non expected distance", 20000, distanceTour, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(20000, distanceTour, + MatsimTestUtils.EPSILON, + "The schedulded tour has a non expected distance"); } } @@ -341,8 +354,9 @@ final void CarrierWithAdditionalDieselVehicleTest_Version4() throws ExecutionExc CarriersUtils.runJsprit(scenario); - Assert.assertEquals("Not the correct amount of scheduled tours", 2, - carrierV4.getSelectedPlan().getScheduledTours().size()); + Assertions.assertEquals(2, + carrierV4.getSelectedPlan().getScheduledTours().size(), + "Not the correct amount of scheduled tours"); VehicleType vehicleType_SmallV4 = vehicleTypes.getVehicleTypes().get(Id.create("SmallBattery_V4", VehicleType.class)); VehicleType vehicleType_LargeV4 = vehicleTypes.getVehicleTypes().get(Id.create("LargeBattery_V4", VehicleType.class)); @@ -352,11 +366,13 @@ final void CarrierWithAdditionalDieselVehicleTest_Version4() throws ExecutionExc double maxDistance_vehicleType_SmallV4 = VehicleUtils.getEnergyCapacity(vehicleType_SmallV4.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_SmallV4.getEngineInformation()); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_Large4, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(30000, maxDistance_vehicleType_Large4, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_SmallV4, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(30000, maxDistance_vehicleType_SmallV4, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); for (ScheduledTour scheduledTour : carrierV4.getSelectedPlan().getScheduledTours()) { @@ -372,13 +388,15 @@ final void CarrierWithAdditionalDieselVehicleTest_Version4() throws ExecutionExc } } if (thisTypeId.equals("SmallBattery_V4")) - Assert.assertEquals("The schedulded tour has a non expected distance", 24000, distanceTour, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(24000, distanceTour, + MatsimTestUtils.EPSILON, + "The schedulded tour has a non expected distance"); else if (thisTypeId.equals("DieselVehicle")) - Assert.assertEquals("The schedulded tour has a non expected distance", 36000, distanceTour, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(36000, distanceTour, + MatsimTestUtils.EPSILON, + "The schedulded tour has a non expected distance"); else - Assert.fail("Wrong vehicleType used"); + Assertions.fail("Wrong vehicleType used"); } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java index f84e547bb14..16c42c7286c 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -121,20 +121,23 @@ final void CarrierSmallBatteryTest_Version1() throws ExecutionException, Interru CarriersUtils.runJsprit(scenario); - Assert.assertEquals("Not the correct amout of scheduled tours", 1, - carrierV1.getSelectedPlan().getScheduledTours().size()); + Assertions.assertEquals(1, + carrierV1.getSelectedPlan().getScheduledTours().size(), + "Not the correct amout of scheduled tours"); - Assert.assertEquals(vehicleType_SmallV1.getId(), ((Vehicle) carrierV1.getSelectedPlan().getScheduledTours().iterator().next() + Assertions.assertEquals(vehicleType_SmallV1.getId(), ((Vehicle) carrierV1.getSelectedPlan().getScheduledTours().iterator().next() .getVehicle()).getType().getId()); double maxDistance_vehicleType_LargeV1 = VehicleUtils.getEnergyCapacity(vehicleType_LargeV1.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_LargeV1.getEngineInformation()); double maxDistance_vehicleType_SmallV1 = VehicleUtils.getEnergyCapacity(vehicleType_SmallV1.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_SmallV1.getEngineInformation()); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_LargeV1, - MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_SmallV1, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(30000, maxDistance_vehicleType_LargeV1, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); + Assertions.assertEquals(30000, maxDistance_vehicleType_SmallV1, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); double distanceTour = 0.0; List elements = carrierV1.getSelectedPlan().getScheduledTours().iterator().next().getTour() @@ -147,8 +150,9 @@ final void CarrierSmallBatteryTest_Version1() throws ExecutionException, Interru scenario.getNetwork()); } } - Assert.assertEquals("The schedulded tour has a non expected distance", 24000, distanceTour, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(24000, distanceTour, + MatsimTestUtils.EPSILON, + "The schedulded tour has a non expected distance"); } /** @@ -201,20 +205,23 @@ final void CarrierLargeBatteryTest_Version2() throws ExecutionException, Interru CarriersUtils.runJsprit(scenario); - Assert.assertEquals("Not the correct amout of scheduled tours", 1, - carrierV2.getSelectedPlan().getScheduledTours().size()); + Assertions.assertEquals(1, + carrierV2.getSelectedPlan().getScheduledTours().size(), + "Not the correct amout of scheduled tours"); - Assert.assertEquals(vehicleType_LargeV2.getId(), carrierV2.getSelectedPlan().getScheduledTours().iterator().next() + Assertions.assertEquals(vehicleType_LargeV2.getId(), carrierV2.getSelectedPlan().getScheduledTours().iterator().next() .getVehicle().getType().getId()); double maxDistance_vehicleType_LargeV2 = VehicleUtils.getEnergyCapacity(vehicleType_LargeV2.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_LargeV2.getEngineInformation()); double maxDistance_vehicleType_SmallV2 = VehicleUtils.getEnergyCapacity(vehicleType_SmallV2.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_SmallV2.getEngineInformation()); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_LargeV2, - MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 15000, maxDistance_vehicleType_SmallV2, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(30000, maxDistance_vehicleType_LargeV2, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); + Assertions.assertEquals(15000, maxDistance_vehicleType_SmallV2, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); double distanceTour = 0.0; List elements = carrierV2.getSelectedPlan().getScheduledTours().iterator().next().getTour() @@ -227,8 +234,9 @@ final void CarrierLargeBatteryTest_Version2() throws ExecutionException, Interru scenario.getNetwork()); } } - Assert.assertEquals("The schedulded tour has a non expected distance", 24000, distanceTour, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(24000, distanceTour, + MatsimTestUtils.EPSILON, + "The schedulded tour has a non expected distance"); } @@ -284,19 +292,22 @@ final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, Interr CarriersUtils.runJsprit(scenario); - Assert.assertEquals("Not the correct amout of scheduled tours", 2, - carrierV3.getSelectedPlan().getScheduledTours().size()); + Assertions.assertEquals(2, + carrierV3.getSelectedPlan().getScheduledTours().size(), + "Not the correct amout of scheduled tours"); double maxDistance_vehicleType_LargeV3 = VehicleUtils.getEnergyCapacity(vehicleType_LargeV3.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_LargeV3.getEngineInformation()); double maxDistance_vehicleType_SmallV3 = VehicleUtils.getEnergyCapacity(vehicleType_SmallV3.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_SmallV3.getEngineInformation()); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_LargeV3, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(30000, maxDistance_vehicleType_LargeV3, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_SmallV3, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(30000, maxDistance_vehicleType_SmallV3, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); for (ScheduledTour scheduledTour : carrierV3.getSelectedPlan().getScheduledTours()) { @@ -311,13 +322,15 @@ final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, Interr 0, scenario.getNetwork()); } } - Assert.assertEquals(vehicleType_SmallV3.getId(), scheduledTour.getVehicle().getType().getId()); + Assertions.assertEquals(vehicleType_SmallV3.getId(), scheduledTour.getVehicle().getType().getId()); if (distanceTour == 12000) - Assert.assertEquals("The schedulded tour has a non expected distance", 12000, distanceTour, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(12000, distanceTour, + MatsimTestUtils.EPSILON, + "The schedulded tour has a non expected distance"); else - Assert.assertEquals("The schedulded tour has a non expected distance", 20000, distanceTour, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(20000, distanceTour, + MatsimTestUtils.EPSILON, + "The schedulded tour has a non expected distance"); } } @@ -379,19 +392,22 @@ final void CarrierWithAdditionalDieselVehicleTest_Version4() throws ExecutionExc CarriersUtils.runJsprit(scenario); - Assert.assertEquals("Not the correct amout of scheduled tours", 2, - carrierV4.getSelectedPlan().getScheduledTours().size()); + Assertions.assertEquals(2, + carrierV4.getSelectedPlan().getScheduledTours().size(), + "Not the correct amout of scheduled tours"); double maxDistance_vehicleType_Large4 = VehicleUtils.getEnergyCapacity(vehicleType_LargeV4.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_LargeV4.getEngineInformation()); double maxDistance_vehicleType_SmallV4 = VehicleUtils.getEnergyCapacity(vehicleType_SmallV4.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_SmallV4.getEngineInformation()); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_Large4, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(30000, maxDistance_vehicleType_Large4, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_SmallV4, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(30000, maxDistance_vehicleType_SmallV4, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); for (ScheduledTour scheduledTour : carrierV4.getSelectedPlan().getScheduledTours()) { @@ -407,13 +423,15 @@ final void CarrierWithAdditionalDieselVehicleTest_Version4() throws ExecutionExc } } if (thisTypeId.equals("SmallBattery_V4")) - Assert.assertEquals("The schedulded tour has a non expected distance", 24000, distanceTour, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(24000, distanceTour, + MatsimTestUtils.EPSILON, + "The schedulded tour has a non expected distance"); else if (thisTypeId.equals("DieselVehicle")) - Assert.assertEquals("The schedulded tour has a non expected distance", 36000, distanceTour, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(36000, distanceTour, + MatsimTestUtils.EPSILON, + "The schedulded tour has a non expected distance"); else - Assert.fail("Wrong vehicleType used"); + Assertions.fail("Wrong vehicleType used"); } } @@ -463,16 +481,18 @@ final void CarrierWithShipmentsMidSizeBatteryTest_Version5() throws ExecutionExc CarriersUtils.runJsprit(scenario); //We need two tours, due to reloading both shipments must be transported one after the other - Assert.assertEquals("Not the correct amout of scheduled tours", 2, - carrierV5.getSelectedPlan().getScheduledTours().size()); + Assertions.assertEquals(2, + carrierV5.getSelectedPlan().getScheduledTours().size(), + "Not the correct amout of scheduled tours"); - Assert.assertEquals(vehicleType_MidSizeV5.getId(), carrierV5.getSelectedPlan().getScheduledTours().iterator().next() + Assertions.assertEquals(vehicleType_MidSizeV5.getId(), carrierV5.getSelectedPlan().getScheduledTours().iterator().next() .getVehicle().getType().getId()); double maxDistance_vehicleType_LargeV5 = VehicleUtils.getEnergyCapacity(vehicleType_MidSizeV5.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_MidSizeV5.getEngineInformation()); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 20000, maxDistance_vehicleType_LargeV5, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(20000, maxDistance_vehicleType_LargeV5, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); ArrayList distancesOfTours = new ArrayList(); for (ScheduledTour scheduledTour: carrierV5.getSelectedPlan().getScheduledTours()) { @@ -489,11 +509,11 @@ final void CarrierWithShipmentsMidSizeBatteryTest_Version5() throws ExecutionExc distancesOfTours.add(distanceTour); } - Assert.assertEquals("There must be two entry for tour distances", 2, distancesOfTours.size()); + Assertions.assertEquals(2, distancesOfTours.size(), "There must be two entry for tour distances"); //One tour has distance of 12000m - Assert.assertTrue("The schedulded tour has a non expected distance", distancesOfTours.contains(12000.0)); + Assertions.assertTrue(distancesOfTours.contains(12000.0), "The schedulded tour has a non expected distance"); //The other tour has distance of 20000m - Assert.assertTrue("The schedulded tour has a non expected distance", distancesOfTours.contains(20000.0)); + Assertions.assertTrue(distancesOfTours.contains(20000.0), "The schedulded tour has a non expected distance"); } /** @@ -543,16 +563,18 @@ final void CarrierWithShipmentsLargeBatteryTest_Version6() throws ExecutionExcep //We need two tours, due to reloading both shipments must be transported one after the other - Assert.assertEquals("Not the correct amout of scheduled tours", 1, - carrierV5.getSelectedPlan().getScheduledTours().size()); + Assertions.assertEquals(1, + carrierV5.getSelectedPlan().getScheduledTours().size(), + "Not the correct amout of scheduled tours"); - Assert.assertEquals(vehicleType_LargeV5.getId(), carrierV5.getSelectedPlan().getScheduledTours().iterator().next() + Assertions.assertEquals(vehicleType_LargeV5.getId(), carrierV5.getSelectedPlan().getScheduledTours().iterator().next() .getVehicle().getType().getId()); double maxDistance_vehicleType_LargeV5 = VehicleUtils.getEnergyCapacity(vehicleType_LargeV5.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_LargeV5.getEngineInformation()); - Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_LargeV5, - MatsimTestUtils.EPSILON); + Assertions.assertEquals(30000, maxDistance_vehicleType_LargeV5, + MatsimTestUtils.EPSILON, + "Wrong maximum distance of the tour of this vehicleType"); ArrayList distancesOfTours = new ArrayList(); for (ScheduledTour scheduledTour: carrierV5.getSelectedPlan().getScheduledTours()) { @@ -569,9 +591,9 @@ final void CarrierWithShipmentsLargeBatteryTest_Version6() throws ExecutionExcep distancesOfTours.add(distanceTour); } - Assert.assertEquals("There must be one entry for tour distances", 1, distancesOfTours.size()); + Assertions.assertEquals(1, distancesOfTours.size(), "There must be one entry for tour distances"); //This tour has distance of 24000m - Assert.assertTrue("The schedulded tour has a non expected distance", distancesOfTours.contains(24000.0)); + Assertions.assertTrue(distancesOfTours.contains(24000.0), "The schedulded tour has a non expected distance"); } /** diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java index a0001daba4b..d9aeaf17ef7 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java @@ -29,8 +29,8 @@ import com.graphhopper.jsprit.core.util.Solutions; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -188,7 +188,7 @@ public void setUp() throws Exception { @Test final void test_carrier1CostsAreCorrectly() { - Assert.assertEquals(-44, carriersPlannedAndRouted.getCarriers().get(Id.create("carrier1", Carrier.class)).getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-44, carriersPlannedAndRouted.getCarriers().get(Id.create("carrier1", Carrier.class)).getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); } /* @@ -196,7 +196,7 @@ final void test_carrier1CostsAreCorrectly() { */ @Test final void test_carrier2CostsAreCorrectly() { - Assert.assertEquals(-20.44, carriersPlannedAndRouted.getCarriers().get(Id.create("carrier2", Carrier.class)).getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-20.44, carriersPlannedAndRouted.getCarriers().get(Id.create("carrier2", Carrier.class)).getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); } /* @@ -205,7 +205,7 @@ final void test_carrier2CostsAreCorrectly() { */ @Test final void test_carrier3CostsAreCorrectly() { - Assert.assertEquals(-18.36, carriersPlannedAndRouted.getCarriers().get(Id.create("carrier3", Carrier.class)).getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-18.36, carriersPlannedAndRouted.getCarriers().get(Id.create("carrier3", Carrier.class)).getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); } private static CarrierService createMatsimService(String id, String to, int size) { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/IntegrationIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/IntegrationIT.java index 5131d83904d..9aa5504cdf7 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/IntegrationIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/IntegrationIT.java @@ -27,7 +27,7 @@ import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution; import com.graphhopper.jsprit.core.reporting.SolutionPrinter; import com.graphhopper.jsprit.core.util.Solutions; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -77,7 +77,7 @@ void testJsprit() throws ExecutionException, InterruptedException { scoreWithRunJsprit = scoreWithRunJsprit + carrier.getSelectedPlan().getJspritScore(); } double scoreRunWithOldStructure = generateCarrierPlans(scenario.getNetwork(), CarriersUtils.getCarriers(scenario), CarriersUtils.getCarrierVehicleTypes(scenario)); - Assert.assertEquals("The score of both runs are not the same", scoreWithRunJsprit, scoreRunWithOldStructure, MatsimTestUtils.EPSILON); + Assertions.assertEquals(scoreWithRunJsprit, scoreRunWithOldStructure, MatsimTestUtils.EPSILON, "The score of both runs are not the same"); } private static double generateCarrierPlans(Network network, Carriers carriers, CarrierVehicleTypes vehicleTypes) { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java index ec82034c573..a3e187a4fe2 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java @@ -50,7 +50,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class MatsimTransformerTest { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/NetworkBasedTransportCostsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/NetworkBasedTransportCostsTest.java index b1c1e3a83f5..ccdb7095162 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/NetworkBasedTransportCostsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/NetworkBasedTransportCostsTest.java @@ -24,7 +24,7 @@ import com.graphhopper.jsprit.core.problem.Location; import com.graphhopper.jsprit.core.problem.driver.Driver; import com.graphhopper.jsprit.core.problem.vehicle.Vehicle; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -78,10 +78,10 @@ void test_whenAddingTwoDifferentVehicleTypes_itMustAccountForThem(){ when(vehicle2.getType()).thenReturn(type2); when(vehicle2.getId()).thenReturn("vehicle2"); - Assert.assertEquals(20000.0, c.getTransportCost(Location.newInstance("20"), Location.newInstance("21"), 0.0, mock(Driver.class), vehicle1), 0.01); - Assert.assertEquals(40000.0, c.getTransportCost(Location.newInstance("20"), Location.newInstance("21"), 0.0, mock(Driver.class), vehicle2), 0.01); - Assert.assertEquals(20000.0, c.getDistance(Location.newInstance("6"), Location.newInstance("21"), 0.0, vehicle1), 0.01); - Assert.assertEquals(20000.0, c.getDistance(Location.newInstance("6"), Location.newInstance("21"), 0.0, vehicle2), 0.01); + Assertions.assertEquals(20000.0, c.getTransportCost(Location.newInstance("20"), Location.newInstance("21"), 0.0, mock(Driver.class), vehicle1), 0.01); + Assertions.assertEquals(40000.0, c.getTransportCost(Location.newInstance("20"), Location.newInstance("21"), 0.0, mock(Driver.class), vehicle2), 0.01); + Assertions.assertEquals(20000.0, c.getDistance(Location.newInstance("6"), Location.newInstance("21"), 0.0, vehicle1), 0.01); + Assertions.assertEquals(20000.0, c.getDistance(Location.newInstance("6"), Location.newInstance("21"), 0.0, vehicle2), 0.01); } @Test @@ -108,7 +108,7 @@ void test_whenVehicleTypeNotKnow_throwException(){ try{ c.getTransportCost(Location.newInstance("20"), Location.newInstance("21"), 0.0, mock(Driver.class), vehicle2); } - catch(IllegalStateException e){ Assert.assertTrue(true); } + catch(IllegalStateException e){ Assertions.assertTrue(true); } } @@ -153,10 +153,10 @@ void test_whenAddingTwoVehicleTypesViaConstructor_itMustAccountForThat(){ when(vehicle2.getType()).thenReturn(type2); when(vehicle2.getId()).thenReturn("vehicle2"); - Assert.assertEquals(20000.0, networkBasedTransportCosts.getTransportCost(Location.newInstance("20"), Location.newInstance("21"), 0.0, mock(Driver.class), vehicle1), 0.01); - Assert.assertEquals(40000.0, networkBasedTransportCosts.getTransportCost(Location.newInstance("20"), Location.newInstance("21"), 0.0, mock(Driver.class), vehicle2), 0.01); - Assert.assertEquals(20000.0, networkBasedTransportCosts.getDistance(Location.newInstance("6"), Location.newInstance("21"), 0.0, vehicle1), 0.01); - Assert.assertEquals(20000.0, networkBasedTransportCosts.getDistance(Location.newInstance("6"), Location.newInstance("21"), 0.0, vehicle2), 0.01); + Assertions.assertEquals(20000.0, networkBasedTransportCosts.getTransportCost(Location.newInstance("20"), Location.newInstance("21"), 0.0, mock(Driver.class), vehicle1), 0.01); + Assertions.assertEquals(40000.0, networkBasedTransportCosts.getTransportCost(Location.newInstance("20"), Location.newInstance("21"), 0.0, mock(Driver.class), vehicle2), 0.01); + Assertions.assertEquals(20000.0, networkBasedTransportCosts.getDistance(Location.newInstance("6"), Location.newInstance("21"), 0.0, vehicle1), 0.01); + Assertions.assertEquals(20000.0, networkBasedTransportCosts.getDistance(Location.newInstance("6"), Location.newInstance("21"), 0.0, vehicle2), 0.01); } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java index ed4ab348dd4..ad24848b155 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java @@ -26,7 +26,7 @@ import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution; import com.graphhopper.jsprit.core.reporting.SolutionPrinter; import com.graphhopper.jsprit.core.util.Solutions; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -55,10 +55,10 @@ void testJspritWithDifferentSkillsRequired() { solutionWithDifferentSkills = generateCarrierPlans(scenario); } catch (Exception e) { e.printStackTrace(); - Assert.fail("Should run integration test without exception."); + Assertions.fail("Should run integration test without exception."); } - Assert.assertEquals("Wrong number of vehicles.", 2L, solutionWithDifferentSkills.getRoutes().size()); - Assert.assertEquals("Wrong carrier score.", 2086.9971014492755, solutionWithDifferentSkills.getCost(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2L, solutionWithDifferentSkills.getRoutes().size(), "Wrong number of vehicles."); + Assertions.assertEquals(2086.9971014492755, solutionWithDifferentSkills.getCost(), MatsimTestUtils.EPSILON, "Wrong carrier score."); } @Test @@ -71,10 +71,10 @@ void testJspritWithSameSkillsRequired(){ solutionWithSameSkills = generateCarrierPlans(scenario); } catch (Exception e) { e.printStackTrace(); - Assert.fail("Should run integration test without exception."); + Assertions.fail("Should run integration test without exception."); } - Assert.assertEquals("Wrong number of vehicles.", 1L, solutionWithSameSkills.getRoutes().size()); - Assert.assertEquals("Wrong carrier score.", 1044.0985507246377, solutionWithSameSkills.getCost(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1L, solutionWithSameSkills.getRoutes().size(), "Wrong number of vehicles."); + Assertions.assertEquals(1044.0985507246377, solutionWithSameSkills.getCost(), MatsimTestUtils.EPSILON, "Wrong carrier score."); } private VehicleRoutingProblemSolution generateCarrierPlans(Scenario scenario) { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunChessboardIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunChessboardIT.java index f93f457f58e..ced181d3172 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunChessboardIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunChessboardIT.java @@ -21,7 +21,7 @@ package org.matsim.freight.carriers.usecases.chessboard; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.population.Population; @@ -55,17 +55,17 @@ void runChessboard() { PopulationUtils.readPopulation( actual, utils.getOutputDirectory() + "/output_plans.xml.gz" ); PopulationComparison.Result result = new PopulationComparison().compare(expected, actual); - Assert.assertSame(PopulationComparison.Result.equal, result); + Assertions.assertSame(PopulationComparison.Result.equal, result); } { String expected = utils.getInputDirectory() + "/output_events.xml.gz" ; String actual = utils.getOutputDirectory() + "/output_events.xml.gz" ; EventsFileComparator.Result result = EventsUtils.compareEventsFiles( expected, actual ); - Assert.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result ); + Assertions.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result ); } } catch (Exception ee ) { ee.printStackTrace(); - Assert.fail("something went wrong"); + Assertions.fail("something went wrong"); } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunPassengerAlongWithCarriersIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunPassengerAlongWithCarriersIT.java index 82e0f4a99e6..bcb56fdaf35 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunPassengerAlongWithCarriersIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/usecases/chessboard/RunPassengerAlongWithCarriersIT.java @@ -21,7 +21,7 @@ package org.matsim.freight.carriers.usecases.chessboard; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.config.Config; @@ -44,7 +44,7 @@ void runChessboard() { abc.run(); } catch (Exception ee ) { ee.printStackTrace(); - Assert.fail("something went wrong: " + ee.getMessage()); + Assertions.fail("something went wrong: " + ee.getMessage()); } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsIT.java index 1c19c0cde0d..3cdf13513c1 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsIT.java @@ -26,8 +26,8 @@ import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution; import com.graphhopper.jsprit.core.util.Solutions; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -179,10 +179,10 @@ public void setUp() { @Test void numberOfToursIsCorrect() { - Assert.assertEquals(2, carrierWServices.getSelectedPlan().getScheduledTours().size()); - Assert.assertEquals(1, carrierWShipments.getSelectedPlan().getScheduledTours().size()); - Assert.assertEquals(1, carrierWShipmentsOnlyFromCarrierWServices.getSelectedPlan().getScheduledTours().size()); - Assert.assertEquals(1, carrierWShipmentsOnlyFromCarrierWShipments.getSelectedPlan().getScheduledTours().size()); + Assertions.assertEquals(2, carrierWServices.getSelectedPlan().getScheduledTours().size()); + Assertions.assertEquals(1, carrierWShipments.getSelectedPlan().getScheduledTours().size()); + Assertions.assertEquals(1, carrierWShipmentsOnlyFromCarrierWServices.getSelectedPlan().getScheduledTours().size()); + Assertions.assertEquals(1, carrierWShipmentsOnlyFromCarrierWShipments.getSelectedPlan().getScheduledTours().size()); } @@ -191,7 +191,7 @@ void numberOfToursIsCorrect() { */ @Test void toursInitialCarrierWServicesIsCorrect() { - Assert.assertEquals(-270.462, carrierWServices.getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); //Note: In score waiting and serviceDurationTime are not includes by now -> May fail, when fixed. KMT Okt/18 + Assertions.assertEquals(-270.462, carrierWServices.getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); //Note: In score waiting and serviceDurationTime are not includes by now -> May fail, when fixed. KMT Okt/18 // double tourDurationSum = 0; // for (ScheduledTour scheduledTour: carrierWServices.getSelectedPlan().getScheduledTours()){ // tourDurationSum += scheduledTour.getTour().getEnd().getExpectedArrival() - scheduledTour.getDeparture(); @@ -213,7 +213,7 @@ void toursInitialCarrierWServicesIsCorrect() { */ @Test void toursInitialCarrierWShipmentsIsCorrect() { - Assert.assertEquals(-136.87, carrierWShipments.getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); //Note: In score waiting and serviceDurationTime are not includes by now -> May fail, when fixed. KMT Okt/18 + Assertions.assertEquals(-136.87, carrierWShipments.getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); //Note: In score waiting and serviceDurationTime are not includes by now -> May fail, when fixed. KMT Okt/18 // double tourDurationSum = 0; // for (ScheduledTour scheduledTour: carrierWShipments.getSelectedPlan().getScheduledTours()){ @@ -237,7 +237,7 @@ void toursInitialCarrierWShipmentsIsCorrect() { */ @Test void toursCarrierWShipmentsOnlyFromCarrierWServicesIsCorrect() { - Assert.assertEquals(-140.462, carrierWShipmentsOnlyFromCarrierWServices.getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); //Note: In score waiting and serviceDurationTime are not includes by now -> May fail, when fixed. KMT Okt/18 + Assertions.assertEquals(-140.462, carrierWShipmentsOnlyFromCarrierWServices.getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); //Note: In score waiting and serviceDurationTime are not includes by now -> May fail, when fixed. KMT Okt/18 // double tourDurationSum = 0; // for (ScheduledTour scheduledTour: carrierWShipmentsOnlyFromCarrierWServices.getSelectedPlan().getScheduledTours()){ @@ -263,7 +263,7 @@ void toursCarrierWShipmentsOnlyFromCarrierWServicesIsCorrect() { */ @Test void toursCarrierWShipmentsOnlyFromCarrierWShipmentsIsCorrect() { - Assert.assertEquals(-136.87, carrierWShipmentsOnlyFromCarrierWShipments.getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); //Note: In score waiting and serviceDurationTime are not includes by now -> May fail, when fixed. KMT Okt/18 + Assertions.assertEquals(-136.87, carrierWShipmentsOnlyFromCarrierWShipments.getSelectedPlan().getJspritScore(), MatsimTestUtils.EPSILON); //Note: In score waiting and serviceDurationTime are not includes by now -> May fail, when fixed. KMT Okt/18 // double tourDurationSum = 0; // for (ScheduledTour scheduledTour: carrierWShipmentsOnlyFromCarrierWShipments.getSelectedPlan().getScheduledTours()){ diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java index 7465db5d3d8..143a2a45a6b 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java @@ -30,7 +30,6 @@ import com.graphhopper.jsprit.core.util.Solutions; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.Before; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -169,78 +168,78 @@ public void setUp() { //Should only have Services @Test void numberOfInitalServicesIsCorrect() { - Assert.assertEquals(2, carrierWServices.getServices().size()); + Assertions.assertEquals(2, carrierWServices.getServices().size()); int demandServices = 0; for (CarrierService carrierService : carrierWServices.getServices().values()) { demandServices += carrierService.getCapacityDemand(); } - Assert.assertEquals(4, demandServices); + Assertions.assertEquals(4, demandServices); - Assert.assertEquals(0, carrierWServices.getShipments().size()); + Assertions.assertEquals(0, carrierWServices.getShipments().size()); } //Should only have Shipments @Test void numberOfInitialShipmentsIsCorrect() { - Assert.assertEquals(0, carrierWShipments.getServices().size()); + Assertions.assertEquals(0, carrierWShipments.getServices().size()); - Assert.assertEquals(2, carrierWShipments.getShipments().size()); + Assertions.assertEquals(2, carrierWShipments.getShipments().size()); int demandShipments = 0; for (CarrierShipment carrierShipment : carrierWShipments.getShipments().values()) { demandShipments += carrierShipment.getSize(); } - Assert.assertEquals(3, demandShipments); + Assertions.assertEquals(3, demandShipments); } @Test void numberOfShipmentsFromCopiedShipmentsIsCorrect() { - Assert.assertEquals(0, carrierWShipmentsOnlyFromCarrierWShipments.getServices().size()); + Assertions.assertEquals(0, carrierWShipmentsOnlyFromCarrierWShipments.getServices().size()); - Assert.assertEquals(2, carrierWShipmentsOnlyFromCarrierWShipments.getShipments().size()); + Assertions.assertEquals(2, carrierWShipmentsOnlyFromCarrierWShipments.getShipments().size()); int demandShipments = 0; for (CarrierShipment carrierShipment : carrierWShipmentsOnlyFromCarrierWServices.getShipments().values()) { demandShipments += carrierShipment.getSize(); } - Assert.assertEquals(4, demandShipments); + Assertions.assertEquals(4, demandShipments); } @Test void numberOfShipmentsFromConvertedServicesIsCorrect() { - Assert.assertEquals(0, carrierWShipmentsOnlyFromCarrierWServices.getServices().size()); + Assertions.assertEquals(0, carrierWShipmentsOnlyFromCarrierWServices.getServices().size()); - Assert.assertEquals(2, carrierWShipmentsOnlyFromCarrierWServices.getShipments().size()); + Assertions.assertEquals(2, carrierWShipmentsOnlyFromCarrierWServices.getShipments().size()); int demandShipments = 0; for (CarrierShipment carrierShipment : carrierWShipmentsOnlyFromCarrierWServices.getShipments().values()) { demandShipments += carrierShipment.getSize(); } - Assert.assertEquals(4, demandShipments); + Assertions.assertEquals(4, demandShipments); } @Test void fleetAvailableAfterConvertingIsCorrect() { - Assert.assertEquals(FleetSize.INFINITE, carrierWShipmentsOnlyFromCarrierWServices.getCarrierCapabilities().getFleetSize()); - Assert.assertEquals(1, carrierWShipmentsOnlyFromCarrierWServices.getCarrierCapabilities().getVehicleTypes().size()); + Assertions.assertEquals(FleetSize.INFINITE, carrierWShipmentsOnlyFromCarrierWServices.getCarrierCapabilities().getFleetSize()); + Assertions.assertEquals(1, carrierWShipmentsOnlyFromCarrierWServices.getCarrierCapabilities().getVehicleTypes().size()); for ( VehicleType carrierVehicleType : carrierWShipmentsOnlyFromCarrierWServices.getCarrierCapabilities().getVehicleTypes()){ - Assert.assertEquals(3., carrierVehicleType.getCapacity().getOther(), Double.MIN_VALUE ); - Assert.assertEquals(130, carrierVehicleType.getCostInformation().getFixedCosts(), 0.0 ); - Assert.assertEquals(0.0001, carrierVehicleType.getCostInformation().getCostsPerMeter(), 0.0 ); - Assert.assertEquals(0.001, carrierVehicleType.getCostInformation().getCostsPerSecond(), 0.0 ); - Assert.assertEquals(10, carrierVehicleType.getMaximumVelocity(), 0.0); - Assert.assertEquals("diesel", VehicleUtils.getHbefaTechnology(carrierVehicleType.getEngineInformation())); - Assert.assertEquals(0.015, VehicleUtils.getFuelConsumption(carrierVehicleType), 0.0); + Assertions.assertEquals(3., carrierVehicleType.getCapacity().getOther(), Double.MIN_VALUE ); + Assertions.assertEquals(130, carrierVehicleType.getCostInformation().getFixedCosts(), 0.0 ); + Assertions.assertEquals(0.0001, carrierVehicleType.getCostInformation().getCostsPerMeter(), 0.0 ); + Assertions.assertEquals(0.001, carrierVehicleType.getCostInformation().getCostsPerSecond(), 0.0 ); + Assertions.assertEquals(10, carrierVehicleType.getMaximumVelocity(), 0.0); + Assertions.assertEquals("diesel", VehicleUtils.getHbefaTechnology(carrierVehicleType.getEngineInformation())); + Assertions.assertEquals(0.015, VehicleUtils.getFuelConsumption(carrierVehicleType), 0.0); } - Assert.assertEquals(FleetSize.INFINITE, carrierWShipmentsOnlyFromCarrierWShipments.getCarrierCapabilities().getFleetSize()); - Assert.assertEquals(1, carrierWShipmentsOnlyFromCarrierWShipments.getCarrierCapabilities().getVehicleTypes().size()); + Assertions.assertEquals(FleetSize.INFINITE, carrierWShipmentsOnlyFromCarrierWShipments.getCarrierCapabilities().getFleetSize()); + Assertions.assertEquals(1, carrierWShipmentsOnlyFromCarrierWShipments.getCarrierCapabilities().getVehicleTypes().size()); for ( VehicleType carrierVehicleType : carrierWShipmentsOnlyFromCarrierWShipments.getCarrierCapabilities().getVehicleTypes()){ - Assert.assertEquals(3., carrierVehicleType.getCapacity().getOther(), Double.MIN_VALUE ); - Assert.assertEquals(130, carrierVehicleType.getCostInformation().getFixedCosts(), 0.0 ); - Assert.assertEquals(0.0001, carrierVehicleType.getCostInformation().getCostsPerMeter(), 0.0 ); - Assert.assertEquals(0.001, carrierVehicleType.getCostInformation().getCostsPerSecond(), 0.0 ); - Assert.assertEquals(10, carrierVehicleType.getMaximumVelocity(), 0.0); - Assert.assertEquals("diesel", VehicleUtils.getHbefaTechnology(carrierVehicleType.getEngineInformation())); - Assert.assertEquals(0.015, VehicleUtils.getFuelConsumption(carrierVehicleType), 0.0); } + Assertions.assertEquals(3., carrierVehicleType.getCapacity().getOther(), Double.MIN_VALUE ); + Assertions.assertEquals(130, carrierVehicleType.getCostInformation().getFixedCosts(), 0.0 ); + Assertions.assertEquals(0.0001, carrierVehicleType.getCostInformation().getCostsPerMeter(), 0.0 ); + Assertions.assertEquals(0.001, carrierVehicleType.getCostInformation().getCostsPerSecond(), 0.0 ); + Assertions.assertEquals(10, carrierVehicleType.getMaximumVelocity(), 0.0); + Assertions.assertEquals("diesel", VehicleUtils.getHbefaTechnology(carrierVehicleType.getEngineInformation())); + Assertions.assertEquals(0.015, VehicleUtils.getFuelConsumption(carrierVehicleType), 0.0); } } @Test @@ -252,33 +251,33 @@ void copiingOfShipmentsIsDoneCorrectly() { if (carrierShipment1.getId() == Id.create("shipment1", CarrierShipment.class)) { System.out.println("Found Shipment1"); foundShipment1 = true; - Assert.assertEquals(Id.createLinkId("i(1,0)"), carrierShipment1.getFrom()); - Assert.assertEquals(Id.createLinkId("i(7,6)R"), carrierShipment1.getTo()); - Assert.assertEquals(1, carrierShipment1.getSize()); - Assert.assertEquals(30.0, carrierShipment1.getDeliveryServiceTime(), 0); - Assert.assertEquals(3600.0, carrierShipment1.getDeliveryTimeWindow().getStart(), 0); - Assert.assertEquals(36000.0, carrierShipment1.getDeliveryTimeWindow().getEnd(), 0); - Assert.assertEquals(5.0, carrierShipment1.getPickupServiceTime(), 0); - Assert.assertEquals(0.0, carrierShipment1.getPickupTimeWindow().getStart(), 0); - Assert.assertEquals(7200.0, carrierShipment1.getPickupTimeWindow().getEnd(), 0); + Assertions.assertEquals(Id.createLinkId("i(1,0)"), carrierShipment1.getFrom()); + Assertions.assertEquals(Id.createLinkId("i(7,6)R"), carrierShipment1.getTo()); + Assertions.assertEquals(1, carrierShipment1.getSize()); + Assertions.assertEquals(30.0, carrierShipment1.getDeliveryServiceTime(), 0); + Assertions.assertEquals(3600.0, carrierShipment1.getDeliveryTimeWindow().getStart(), 0); + Assertions.assertEquals(36000.0, carrierShipment1.getDeliveryTimeWindow().getEnd(), 0); + Assertions.assertEquals(5.0, carrierShipment1.getPickupServiceTime(), 0); + Assertions.assertEquals(0.0, carrierShipment1.getPickupTimeWindow().getStart(), 0); + Assertions.assertEquals(7200.0, carrierShipment1.getPickupTimeWindow().getEnd(), 0); } CarrierShipment carrierShipment2 = CarriersUtils.getShipment(carrierWShipmentsOnlyFromCarrierWShipments, Id.create("shipment2", CarrierShipment.class)); assert carrierShipment2 != null; if (carrierShipment2.getId() == Id.create("shipment2", CarrierShipment.class)) { System.out.println("Found Shipment2"); foundShipment2 = true; - Assert.assertEquals(Id.createLinkId("i(3,0)"), carrierShipment2.getFrom()); - Assert.assertEquals(Id.createLinkId("i(3,7)"), carrierShipment2.getTo()); - Assert.assertEquals(2, carrierShipment2.getSize()); - Assert.assertEquals(30.0, carrierShipment2.getDeliveryServiceTime(), 0); - Assert.assertEquals(3600.0, carrierShipment2.getDeliveryTimeWindow().getStart(), 0); - Assert.assertEquals(36000.0, carrierShipment2.getDeliveryTimeWindow().getEnd(), 0); - Assert.assertEquals(5.0, carrierShipment2.getPickupServiceTime(), 0); - Assert.assertEquals(0.0, carrierShipment2.getPickupTimeWindow().getStart(), 0); - Assert.assertEquals(7200.0, carrierShipment2.getPickupTimeWindow().getEnd(), 0); + Assertions.assertEquals(Id.createLinkId("i(3,0)"), carrierShipment2.getFrom()); + Assertions.assertEquals(Id.createLinkId("i(3,7)"), carrierShipment2.getTo()); + Assertions.assertEquals(2, carrierShipment2.getSize()); + Assertions.assertEquals(30.0, carrierShipment2.getDeliveryServiceTime(), 0); + Assertions.assertEquals(3600.0, carrierShipment2.getDeliveryTimeWindow().getStart(), 0); + Assertions.assertEquals(36000.0, carrierShipment2.getDeliveryTimeWindow().getEnd(), 0); + Assertions.assertEquals(5.0, carrierShipment2.getPickupServiceTime(), 0); + Assertions.assertEquals(0.0, carrierShipment2.getPickupTimeWindow().getStart(), 0); + Assertions.assertEquals(7200.0, carrierShipment2.getPickupTimeWindow().getEnd(), 0); } - Assert.assertTrue("Not found Shipment1 after copiing", foundShipment1); - Assert.assertTrue("Not found Shipment2 after copiing", foundShipment2); + Assertions.assertTrue(foundShipment1, "Not found Shipment1 after copiing"); + Assertions.assertTrue(foundShipment2, "Not found Shipment2 after copiing"); } @@ -290,32 +289,32 @@ void convertionOfServicesIsDoneCorrectly() { assert carrierShipment1 != null; if (carrierShipment1.getId() == Id.create("Service1", CarrierShipment.class)) { foundSercice1 = true; - Assert.assertEquals(Id.createLinkId("i(6,0)"), carrierShipment1.getFrom()); - Assert.assertEquals(Id.createLinkId("i(3,9)"), carrierShipment1.getTo()); - Assert.assertEquals(2, carrierShipment1.getSize()); - Assert.assertEquals(31.0, carrierShipment1.getDeliveryServiceTime(), 0); - Assert.assertEquals(3601.0, carrierShipment1.getDeliveryTimeWindow().getStart(), 0); - Assert.assertEquals(36001.0, carrierShipment1.getDeliveryTimeWindow().getEnd(), 0); - Assert.assertEquals(0.0, carrierShipment1.getPickupServiceTime(), 0); - Assert.assertEquals(0.0, carrierShipment1.getPickupTimeWindow().getStart(), 0); - Assert.assertEquals(36001.0, carrierShipment1.getPickupTimeWindow().getEnd(), 0); + Assertions.assertEquals(Id.createLinkId("i(6,0)"), carrierShipment1.getFrom()); + Assertions.assertEquals(Id.createLinkId("i(3,9)"), carrierShipment1.getTo()); + Assertions.assertEquals(2, carrierShipment1.getSize()); + Assertions.assertEquals(31.0, carrierShipment1.getDeliveryServiceTime(), 0); + Assertions.assertEquals(3601.0, carrierShipment1.getDeliveryTimeWindow().getStart(), 0); + Assertions.assertEquals(36001.0, carrierShipment1.getDeliveryTimeWindow().getEnd(), 0); + Assertions.assertEquals(0.0, carrierShipment1.getPickupServiceTime(), 0); + Assertions.assertEquals(0.0, carrierShipment1.getPickupTimeWindow().getStart(), 0); + Assertions.assertEquals(36001.0, carrierShipment1.getPickupTimeWindow().getEnd(), 0); } CarrierShipment carrierShipment2 = CarriersUtils.getShipment(carrierWShipmentsOnlyFromCarrierWServices, Id.create("Service2", CarrierShipment.class)); assert carrierShipment2 != null; if (carrierShipment2.getId() == Id.create("Service2", CarrierShipment.class)) { foundService2 = true; - Assert.assertEquals(Id.createLinkId("i(6,0)"), carrierShipment2.getFrom()); - Assert.assertEquals(Id.createLinkId("i(4,9)"), carrierShipment2.getTo()); - Assert.assertEquals(2, carrierShipment2.getSize()); - Assert.assertEquals(31.0, carrierShipment2.getDeliveryServiceTime(), 0); - Assert.assertEquals(3601.0, carrierShipment2.getDeliveryTimeWindow().getStart(), 0); - Assert.assertEquals(36001.0, carrierShipment2.getDeliveryTimeWindow().getEnd(), 0); - Assert.assertEquals(0.0, carrierShipment2.getPickupServiceTime(), 0); - Assert.assertEquals(0.0, carrierShipment2.getPickupTimeWindow().getStart(), 0); - Assert.assertEquals(36001.0, carrierShipment2.getPickupTimeWindow().getEnd(), 0); + Assertions.assertEquals(Id.createLinkId("i(6,0)"), carrierShipment2.getFrom()); + Assertions.assertEquals(Id.createLinkId("i(4,9)"), carrierShipment2.getTo()); + Assertions.assertEquals(2, carrierShipment2.getSize()); + Assertions.assertEquals(31.0, carrierShipment2.getDeliveryServiceTime(), 0); + Assertions.assertEquals(3601.0, carrierShipment2.getDeliveryTimeWindow().getStart(), 0); + Assertions.assertEquals(36001.0, carrierShipment2.getDeliveryTimeWindow().getEnd(), 0); + Assertions.assertEquals(0.0, carrierShipment2.getPickupServiceTime(), 0); + Assertions.assertEquals(0.0, carrierShipment2.getPickupTimeWindow().getStart(), 0); + Assertions.assertEquals(36001.0, carrierShipment2.getPickupTimeWindow().getEnd(), 0); } - Assert.assertTrue("Not found converted Service1 after converting", foundSercice1); - Assert.assertTrue("Not found converted Service2 after converting", foundService2); + Assertions.assertTrue(foundSercice1, "Not found converted Service1 after converting"); + Assertions.assertTrue(foundService2, "Not found converted Service2 after converting"); } /*Note: This test can be removed / modified when jsprit works properly with a combined Service and Shipment VRP. @@ -370,15 +369,15 @@ private static CarrierService createMatsimService(String id, String to, int size void testAddVehicleTypeSkill(){ VehiclesFactory factory = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getVehicles().getFactory(); VehicleType type = factory.createVehicleType(Id.create("test", VehicleType.class)); - Assert.assertFalse("Should not have skill.", CarriersUtils.hasSkill(type, "testSkill")); + Assertions.assertFalse(CarriersUtils.hasSkill(type, "testSkill"), "Should not have skill."); CarriersUtils.addSkill(type, "testSkillOne"); - Assert.assertTrue("Should have skill 'testSkillOne'.", CarriersUtils.hasSkill(type, "testSkillOne")); + Assertions.assertTrue(CarriersUtils.hasSkill(type, "testSkillOne"), "Should have skill 'testSkillOne'."); CarriersUtils.addSkill(type, "testSkillTwo"); - Assert.assertTrue("Should have skill 'testSkillOne'.", CarriersUtils.hasSkill(type, "testSkillOne")); - Assert.assertTrue("Should have skill 'testSkillTwo'.", CarriersUtils.hasSkill(type, "testSkillTwo")); + Assertions.assertTrue(CarriersUtils.hasSkill(type, "testSkillOne"), "Should have skill 'testSkillOne'."); + Assertions.assertTrue(CarriersUtils.hasSkill(type, "testSkillTwo"), "Should have skill 'testSkillTwo'."); } @Test @@ -386,15 +385,15 @@ void testAddShipmentSkill(){ CarrierShipment shipment = CarrierShipment.Builder.newInstance( Id.create("testShipment", CarrierShipment.class), Id.createLinkId("1"), Id.createLinkId("2"), 1) .build(); - Assert.assertFalse("Should not have skill.", CarriersUtils.hasSkill(shipment, "testSkill")); + Assertions.assertFalse(CarriersUtils.hasSkill(shipment, "testSkill"), "Should not have skill."); CarriersUtils.addSkill(shipment, "testSkillOne"); - Assert.assertTrue("Should have skill 'testSkillOne'.", CarriersUtils.hasSkill(shipment, "testSkillOne")); + Assertions.assertTrue(CarriersUtils.hasSkill(shipment, "testSkillOne"), "Should have skill 'testSkillOne'."); CarriersUtils.addSkill(shipment, "testSkillTwo"); - Assert.assertTrue("Should have skill 'testSkillOne'.", CarriersUtils.hasSkill(shipment, "testSkillOne")); - Assert.assertTrue("Should have skill 'testSkillTwo'.", CarriersUtils.hasSkill(shipment, "testSkillTwo")); + Assertions.assertTrue(CarriersUtils.hasSkill(shipment, "testSkillOne"), "Should have skill 'testSkillOne'."); + Assertions.assertTrue(CarriersUtils.hasSkill(shipment, "testSkillTwo"), "Should have skill 'testSkillTwo'."); } @Test @@ -402,15 +401,15 @@ void testAddServiceSkill(){ CarrierService service = CarrierService.Builder.newInstance( Id.create("testShipment", CarrierService.class), Id.createLinkId("2")) .build(); - Assert.assertFalse("Should not have skill.", CarriersUtils.hasSkill(service, "testSkill")); + Assertions.assertFalse(CarriersUtils.hasSkill(service, "testSkill"), "Should not have skill."); CarriersUtils.addSkill(service, "testSkillOne"); - Assert.assertTrue("Should have skill 'testSkillOne'.", CarriersUtils.hasSkill(service, "testSkillOne")); + Assertions.assertTrue(CarriersUtils.hasSkill(service, "testSkillOne"), "Should have skill 'testSkillOne'."); CarriersUtils.addSkill(service, "testSkillTwo"); - Assert.assertTrue("Should have skill 'testSkillOne'.", CarriersUtils.hasSkill(service, "testSkillOne")); - Assert.assertTrue("Should have skill 'testSkillTwo'.", CarriersUtils.hasSkill(service, "testSkillTwo")); + Assertions.assertTrue(CarriersUtils.hasSkill(service, "testSkillOne"), "Should have skill 'testSkillOne'."); + Assertions.assertTrue(CarriersUtils.hasSkill(service, "testSkillTwo"), "Should have skill 'testSkillTwo'."); } @Test @@ -433,10 +432,10 @@ void testRunJsprit_allInformationGiven(){ CarriersUtils.runJsprit(scenario); } catch (Exception e) { e.printStackTrace(); - Assert.fail(); + Assertions.fail(); } - Assert.assertEquals(vraFile, ConfigUtils.addOrGetModule( controler.getConfig(), FreightCarriersConfigGroup.class ).getVehicleRoutingAlgorithmFile()); + Assertions.assertEquals(vraFile, ConfigUtils.addOrGetModule( controler.getConfig(), FreightCarriersConfigGroup.class ).getVehicleRoutingAlgorithmFile()); } /** @@ -474,9 +473,9 @@ void testRunJsprit_NoAlgortihmFileGiven(){ try { CarriersUtils.runJsprit(scenario); } catch (Exception e) { - Assert.fail(); + Assertions.fail(); } - Assert.assertNull(ConfigUtils.addOrGetModule(scenario.getConfig(), FreightCarriersConfigGroup.class).getVehicleRoutingAlgorithmFile()); + Assertions.assertNull(ConfigUtils.addOrGetModule(scenario.getConfig(), FreightCarriersConfigGroup.class).getVehicleRoutingAlgorithmFile()); } private Config prepareConfig(){ diff --git a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiverCostAllocationFixedTest.java b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiverCostAllocationFixedTest.java index bdb2f256853..8faf02fd1c0 100644 --- a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiverCostAllocationFixedTest.java +++ b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiverCostAllocationFixedTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.freightreceiver; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.testcases.MatsimTestUtils; @@ -8,6 +8,6 @@ public class ReceiverCostAllocationFixedTest { @Test void getScore() { - Assert.assertEquals("Wrong cost.", -20.0, new ReceiverCostAllocationFixed(20.0).getScore(null, null), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-20.0, new ReceiverCostAllocationFixed(20.0).getScore(null, null), MatsimTestUtils.EPSILON, "Wrong cost."); } } diff --git a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiverPlanTest.java b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiverPlanTest.java index 7c3a1691412..9933bda39d7 100644 --- a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiverPlanTest.java +++ b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiverPlanTest.java @@ -17,9 +17,9 @@ * *********************************************************************** */ package org.matsim.contrib.freightreceiver; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; -import org.junit.Assert; public class ReceiverPlanTest { @@ -30,8 +30,8 @@ void testBuilderTwo() { Receiver receiver = ReceiverUtils.newInstance( Id.create( "1", Receiver.class ) ); ReceiverPlan.Builder builder = ReceiverPlan.Builder.newInstance(receiver, true); ReceiverPlan plan = builder.build(); - Assert.assertEquals("Wrong receiver Id", Id.create("1", Receiver.class), plan.getReceiver().getId()); - Assert.assertNull("Score should be null", plan.getScore()); + Assertions.assertEquals(Id.create("1", Receiver.class), plan.getReceiver().getId(), "Wrong receiver Id"); + Assertions.assertNull(plan.getScore(), "Score should be null"); } /* TODO Add tests to check ReceiverOrders */ diff --git a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversReaderTest.java b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversReaderTest.java index 70112f0895f..970641df24e 100644 --- a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversReaderTest.java +++ b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversReaderTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.freightreceiver; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -47,15 +47,15 @@ void testBasicV2(){ new ReceiversReader(receivers).readFile(utils.getClassInputDirectory() + "receivers_v2_basic.xml"); } catch (Exception e) { e.printStackTrace(); - Assert.fail("Should read without exception."); + Assertions.fail("Should read without exception."); } /* Check one product type completely. */ ProductType p1 = receivers.getProductType(Id.create("P1", ProductType.class)); - Assert.assertNotNull("Product type should exists", p1); - Assert.assertEquals("Wrong origin link Id", Id.createLinkId("j(1,7)"), p1.getOriginLinkId()); - Assert.assertTrue("Wrong ProductType description", p1.getDescription().equalsIgnoreCase("Product 1")); - Assert.assertEquals("Wrong capacity.", 1.0, p1.getRequiredCapacity(), MatsimTestUtils.EPSILON); + Assertions.assertNotNull(p1, "Product type should exists"); + Assertions.assertEquals(Id.createLinkId("j(1,7)"), p1.getOriginLinkId(), "Wrong origin link Id"); + Assertions.assertTrue(p1.getDescription().equalsIgnoreCase("Product 1"), "Wrong ProductType description"); + Assertions.assertEquals(1.0, p1.getRequiredCapacity(), MatsimTestUtils.EPSILON, "Wrong capacity."); } @Test @@ -65,75 +65,75 @@ void testV2() { new ReceiversReader(receivers).readFile(utils.getClassInputDirectory() + "receivers_v2_full.xml"); } catch (Exception e) { e.printStackTrace(); - Assert.fail("Should read without exception."); + Assertions.fail("Should read without exception."); } /* Receivers */ - Assert.assertTrue("Wrong description.", "Chessboard".equalsIgnoreCase(receivers.getDescription())); + Assertions.assertTrue("Chessboard".equalsIgnoreCase(receivers.getDescription()), "Wrong description."); Object r = receivers.getAttributes().getAttribute("date"); - Assert.assertNotNull("No attribute", r); + Assertions.assertNotNull(r, "No attribute"); /* Product types */ - Assert.assertEquals("Wrong number of product types.", 2L, receivers.getAllProductTypes().size()); + Assertions.assertEquals(2L, receivers.getAllProductTypes().size(), "Wrong number of product types."); ProductType pt1 = receivers.getProductType(Id.create("P1", ProductType.class)); - Assert.assertNotNull("Could not find ProductType \"P1\"", pt1); - Assert.assertNotNull("Could not find ProductType \"P2\"", receivers.getProductType(Id.create("P2", ProductType.class))); + Assertions.assertNotNull(pt1, "Could not find ProductType \"P1\""); + Assertions.assertNotNull(receivers.getProductType(Id.create("P2", ProductType.class)), "Could not find ProductType \"P2\""); - Assert.assertTrue("Wrong ProductType description", pt1.getDescription().equalsIgnoreCase("Product 1")); - Assert.assertEquals("Wrong capacity.", 1.0, pt1.getRequiredCapacity(), MatsimTestUtils.EPSILON); + Assertions.assertTrue(pt1.getDescription().equalsIgnoreCase("Product 1"), "Wrong ProductType description"); + Assertions.assertEquals(1.0, pt1.getRequiredCapacity(), MatsimTestUtils.EPSILON, "Wrong capacity."); /* Receiver */ - Assert.assertEquals("Wrong number of receivers.", 5, receivers.getReceivers().size()); + Assertions.assertEquals(5, receivers.getReceivers().size(), "Wrong number of receivers."); Receiver r1 = receivers.getReceivers().get(Id.create("1", Receiver.class)); - Assert.assertNotNull("Should find receiver '1'", r1); + Assertions.assertNotNull(r1, "Should find receiver '1'"); /* Receiver attributes. */ - Assert.assertFalse("Attributes should not be empty.", r1.getAttributes().isEmpty()); - Assert.assertNotNull("Should find attribute '" + CollaborationUtils.ATTR_GRANDCOALITION_MEMBER + "'", r1.getAttributes().getAttribute(CollaborationUtils.ATTR_GRANDCOALITION_MEMBER)); - Assert.assertNotNull("Should find attribute '" + CollaborationUtils.ATTR_COLLABORATION_STATUS + "'", r1.getAttributes().getAttribute(CollaborationUtils.ATTR_COLLABORATION_STATUS)); - Assert.assertNotNull("Should find attribute '" + ReceiverUtils.ATTR_RECEIVER_SCORE + "'", r1.getAttributes().getAttribute(ReceiverUtils.ATTR_RECEIVER_SCORE)); + Assertions.assertFalse(r1.getAttributes().isEmpty(), "Attributes should not be empty."); + Assertions.assertNotNull(r1.getAttributes().getAttribute(CollaborationUtils.ATTR_GRANDCOALITION_MEMBER), "Should find attribute '" + CollaborationUtils.ATTR_GRANDCOALITION_MEMBER + "'"); + Assertions.assertNotNull(r1.getAttributes().getAttribute(CollaborationUtils.ATTR_COLLABORATION_STATUS), "Should find attribute '" + CollaborationUtils.ATTR_COLLABORATION_STATUS + "'"); + Assertions.assertNotNull(r1.getAttributes().getAttribute(ReceiverUtils.ATTR_RECEIVER_SCORE), "Should find attribute '" + ReceiverUtils.ATTR_RECEIVER_SCORE + "'"); /* Time window */ - Assert.assertEquals("Wrong number of time windows.", 2, r1.getSelectedPlan().getTimeWindows().size()); + Assertions.assertEquals(2, r1.getSelectedPlan().getTimeWindows().size(), "Wrong number of time windows."); TimeWindow t1 = r1.getSelectedPlan().getTimeWindows().get(0); - Assert.assertEquals("Wrong time window start time.", Time.parseTime("06:00:00"), t1.getStart(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong time window end time.", Time.parseTime("10:00:00"), t1.getEnd(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(Time.parseTime("06:00:00"), t1.getStart(), MatsimTestUtils.EPSILON, "Wrong time window start time."); + Assertions.assertEquals(Time.parseTime("10:00:00"), t1.getEnd(), MatsimTestUtils.EPSILON, "Wrong time window end time."); TimeWindow t2 = r1.getSelectedPlan().getTimeWindows().get(1); - Assert.assertEquals("Wrong time window start time.", Time.parseTime("15:00:00"), t2.getStart(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong time window end time.", Time.parseTime("18:00:00"), t2.getEnd(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(Time.parseTime("15:00:00"), t2.getStart(), MatsimTestUtils.EPSILON, "Wrong time window start time."); + Assertions.assertEquals(Time.parseTime("18:00:00"), t2.getEnd(), MatsimTestUtils.EPSILON, "Wrong time window end time."); - Assert.assertEquals("Wrong number of products.", 2, r1.getProducts().size()); + Assertions.assertEquals(2, r1.getProducts().size(), "Wrong number of products."); /* Receiver product */ ReceiverProduct rp1 = r1.getProduct(Id.create("P1", ProductType.class)); - Assert.assertNotNull("Could not find receiver product \"P1\"", rp1); - Assert.assertEquals("Wrong stock on hand.", 0.0, rp1.getStockOnHand(), MatsimTestUtils.EPSILON); + Assertions.assertNotNull(rp1, "Could not find receiver product \"P1\""); + Assertions.assertEquals(0.0, rp1.getStockOnHand(), MatsimTestUtils.EPSILON, "Wrong stock on hand."); /* Reorder policy */ ReorderPolicy policy = rp1.getReorderPolicy(); - Assert.assertNotNull("Could not find reorder policy.", policy); - Assert.assertTrue("Wrong policy type", policy instanceof SSReorderPolicy); - Assert.assertTrue("Wrong policy name.", policy.getPolicyName().equalsIgnoreCase("(s,S)")); - Assert.assertNotNull("Could not find attribute 's'", policy.getAttributes().getAttribute("s")); - Assert.assertNotNull("Could not find attribute 'S'", policy.getAttributes().getAttribute("S")); + Assertions.assertNotNull(policy, "Could not find reorder policy."); + Assertions.assertTrue(policy instanceof SSReorderPolicy, "Wrong policy type"); + Assertions.assertTrue(policy.getPolicyName().equalsIgnoreCase("(s,S)"), "Wrong policy name."); + Assertions.assertNotNull(policy.getAttributes().getAttribute("s"), "Could not find attribute 's'"); + Assertions.assertNotNull(policy.getAttributes().getAttribute("S"), "Could not find attribute 'S'"); /* (Receiver)Orders */ - Assert.assertEquals("Wrong number of orders/plans", 5, r1.getPlans().size()); + Assertions.assertEquals(5, r1.getPlans().size(), "Wrong number of orders/plans"); ReceiverPlan plan = r1.getSelectedPlan(); ReceiverOrder ro = plan.getReceiverOrder(Id.create("Carrier1", Carrier.class)); - Assert.assertNotNull("Should find ReceiverOrder.", ro); + Assertions.assertNotNull(ro, "Should find ReceiverOrder."); - Assert.assertEquals("Wrong carrier", ro.getCarrierId(), Id.create("Carrier1", Carrier.class)); - Assert.assertEquals("Wrong receiver", ro.getReceiverId(), Id.create("1", Receiver.class)); - Assert.assertNull("Should not have score now", ro.getScore()); + Assertions.assertEquals(ro.getCarrierId(), Id.create("Carrier1", Carrier.class), "Wrong carrier"); + Assertions.assertEquals(ro.getReceiverId(), Id.create("1", Receiver.class), "Wrong receiver"); + Assertions.assertNull(ro.getScore(), "Should not have score now"); /* Order (items) */ - Assert.assertEquals("Wrong number of order (items)", 2, ro.getReceiverProductOrders().size()); + Assertions.assertEquals(2, ro.getReceiverProductOrders().size(), "Wrong number of order (items)"); Order o = ro.getReceiverProductOrders().iterator().next(); - Assert.assertEquals("Wrong order id.", o.getId(), Id.create("Order11", Order.class)); - Assert.assertEquals("Wrong order quantity.", 5000, o.getOrderQuantity(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong product type.", o.getProduct().getProductType().getId(), Id.create("P1", ProductType.class)); - Assert.assertEquals("Wrong receiver.", o.getReceiver().getId(), Id.create("1", Receiver.class)); - Assert.assertEquals("Wrong service duration.", Time.parseTime("03:00:00"), o.getServiceDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(o.getId(), Id.create("Order11", Order.class), "Wrong order id."); + Assertions.assertEquals(5000, o.getOrderQuantity(), MatsimTestUtils.EPSILON, "Wrong order quantity."); + Assertions.assertEquals(o.getProduct().getProductType().getId(), Id.create("P1", ProductType.class), "Wrong product type."); + Assertions.assertEquals(o.getReceiver().getId(), Id.create("1", Receiver.class), "Wrong receiver."); + Assertions.assertEquals(Time.parseTime("03:00:00"), o.getServiceDuration(), MatsimTestUtils.EPSILON, "Wrong service duration."); } } diff --git a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversTest.java b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversTest.java index ca5a5f02009..35dbed33c31 100644 --- a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversTest.java +++ b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.freightreceiver; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -29,7 +29,7 @@ void testSetupReceivers() { Receivers receivers = setupReceivers(); } catch (Exception e) { e.printStackTrace(); - Assert.fail("Cannot set up test case"); + Assertions.fail("Cannot set up test case"); } } @@ -37,14 +37,14 @@ void testSetupReceivers() { void getReceivers() { Receivers receivers = setupReceivers(); Map, Receiver> map = receivers.getReceivers(); - Assert.assertNotNull("Map must exist.", map); - Assert.assertEquals("Wrong number of receivers.", 5, map.size()); + Assertions.assertNotNull(map, "Map must exist."); + Assertions.assertEquals(5, map.size(), "Wrong number of receivers."); /* Map must be unmodifiable. */ Receiver newReceiver = ReceiverUtils.newInstance(Id.create("dummy", Receiver.class)); try { map.put(newReceiver.getId(), newReceiver); - Assert.fail("Map must be unmodifiable."); + Assertions.fail("Map must be unmodifiable."); } catch (UnsupportedOperationException e) { e.printStackTrace(); } @@ -54,22 +54,22 @@ void getReceivers() { void getReceiver() { Receivers receivers = setupReceivers(); Receiver receiverExists = receivers.getReceiver(Id.create("1", Receiver.class)); - Assert.assertNotNull("Should find receiver.", receiverExists); + Assertions.assertNotNull(receiverExists, "Should find receiver."); Receiver receiverDoesNotExist = receivers.getReceiver(Id.create("dummy", Receiver.class)); - Assert.assertNull("Should not find receiver.", receiverDoesNotExist); + Assertions.assertNull(receiverDoesNotExist, "Should not find receiver."); } @Test void addReceiver() { Receivers receivers = setupReceivers(); - Assert.assertEquals("Wrong number of receivers.", 5, receivers.getReceivers().size()); + Assertions.assertEquals(5, receivers.getReceivers().size(), "Wrong number of receivers."); Receiver newReceiver = ReceiverUtils.newInstance(Id.create("dummy", Receiver.class)); receivers.addReceiver(newReceiver); - Assert.assertEquals("Receivers should increase.", 6, receivers.getReceivers().size()); + Assertions.assertEquals(6, receivers.getReceivers().size(), "Receivers should increase."); receivers.addReceiver(newReceiver); - Assert.assertEquals("Receivers should not increase.", 6, receivers.getReceivers().size()); + Assertions.assertEquals(6, receivers.getReceivers().size(), "Receivers should not increase."); /*TODO Should we maybe check if a receiver is NOT overwritten? */ } @@ -77,11 +77,11 @@ void addReceiver() { @Test void createAndAddProductType() { Receivers receivers = setupReceivers(); - Assert.assertEquals("Wrong number of product types.", 2, receivers.getAllProductTypes().size()); + Assertions.assertEquals(2, receivers.getAllProductTypes().size(), "Wrong number of product types."); ProductType test = ReceiverUtils.createAndGetProductType(receivers, Id.create("test", ProductType.class), Id.createLinkId("j(1,7)")); - Assert.assertEquals("Wrong number of product types.", 3, receivers.getAllProductTypes().size()); - Assert.assertTrue("Should contain new product types", receivers.getAllProductTypes().contains(test)); + Assertions.assertEquals(3, receivers.getAllProductTypes().size(), "Wrong number of product types."); + Assertions.assertTrue(receivers.getAllProductTypes().contains(test), "Should contain new product types"); } @Test @@ -89,15 +89,15 @@ void getProductType() { Receivers receivers = setupReceivers(); try { ProductType p1 = receivers.getProductType(Id.create("P1", ProductType.class)); - Assert.assertNotNull("Should find P1", p1); + Assertions.assertNotNull(p1, "Should find P1"); } catch (Exception e) { - Assert.fail("Should find P1"); + Assertions.fail("Should find P1"); } try { @SuppressWarnings("unused") ProductType dummy = receivers.getProductType(Id.create("dummy", ProductType.class)); - Assert.fail("Should crash when product type is not available."); + Assertions.fail("Should crash when product type is not available."); } catch (Exception e){ e.printStackTrace(); } @@ -107,45 +107,45 @@ void getProductType() { void getAllProductTypes() { Receivers receivers = setupReceivers(); Collection types = receivers.getAllProductTypes(); - Assert.assertNotNull("Must have product types.", types); - Assert.assertEquals("Wrong number of product types.", 2, types.size()); + Assertions.assertNotNull(types, "Must have product types."); + Assertions.assertEquals(2, types.size(), "Wrong number of product types."); List list = List.copyOf(types); ProductType p1 = list.get(0); - Assert.assertTrue("Should contain P1", p1.getId().toString().equalsIgnoreCase("P1")); - Assert.assertTrue("Wrong description", p1.getDescription().equalsIgnoreCase("Product 1")); - Assert.assertEquals("Wrong origin Id", Id.createLinkId("j(4,3)R"), p1.getOriginLinkId()); - Assert.assertEquals("Wrong capacity", 1.0, p1.getRequiredCapacity(), MatsimTestUtils.EPSILON); + Assertions.assertTrue(p1.getId().toString().equalsIgnoreCase("P1"), "Should contain P1"); + Assertions.assertTrue(p1.getDescription().equalsIgnoreCase("Product 1"), "Wrong description"); + Assertions.assertEquals(Id.createLinkId("j(4,3)R"), p1.getOriginLinkId(), "Wrong origin Id"); + Assertions.assertEquals(1.0, p1.getRequiredCapacity(), MatsimTestUtils.EPSILON, "Wrong capacity"); ProductType p2 = list.get(1); - Assert.assertTrue("Should contain P2", p2.getId().toString().equalsIgnoreCase("P2")); - Assert.assertTrue("Wrong description", p2.getDescription().equalsIgnoreCase("Product 2")); - Assert.assertEquals("Wrong origin Id", Id.createLinkId("j(4,3)R"), p2.getOriginLinkId()); - Assert.assertEquals("Wrong capacity", 2.0, p2.getRequiredCapacity(), MatsimTestUtils.EPSILON); + Assertions.assertTrue(p2.getId().toString().equalsIgnoreCase("P2"), "Should contain P2"); + Assertions.assertTrue(p2.getDescription().equalsIgnoreCase("Product 2"), "Wrong description"); + Assertions.assertEquals(Id.createLinkId("j(4,3)R"), p2.getOriginLinkId(), "Wrong origin Id"); + Assertions.assertEquals(2.0, p2.getRequiredCapacity(), MatsimTestUtils.EPSILON, "Wrong capacity"); } @Test void getAttributes() { Receivers receivers = setupReceivers(); - Assert.assertNotNull("Should find attributed.", receivers.getAttributes()); - Assert.assertEquals("Wrong number of attributes.", 0, receivers.getAttributes().size()); + Assertions.assertNotNull(receivers.getAttributes(), "Should find attributed."); + Assertions.assertEquals(0, receivers.getAttributes().size(), "Wrong number of attributes."); receivers.getAttributes().putAttribute("dummy", 123.4); - Assert.assertEquals("Wrong number of attributes.", 1, receivers.getAttributes().size()); + Assertions.assertEquals(1, receivers.getAttributes().size(), "Wrong number of attributes."); } @Test void setDescription() { Receivers receivers = setupReceivers(); - Assert.assertEquals("Wrong description.", "Chessboard", receivers.getDescription()); + Assertions.assertEquals("Chessboard", receivers.getDescription(), "Wrong description."); receivers.setDescription("Dummy"); - Assert.assertEquals("Wrong description.", "Dummy", receivers.getDescription()); + Assertions.assertEquals("Dummy", receivers.getDescription(), "Wrong description."); } @Test void getDescription() { Receivers receivers = setupReceivers(); - Assert.assertEquals("Wrong description.", "Chessboard", receivers.getDescription()); + Assertions.assertEquals("Chessboard", receivers.getDescription(), "Wrong description."); } private Receivers setupReceivers() { diff --git a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversWriterTest.java b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversWriterTest.java index 972ebf6e200..34a66898d68 100644 --- a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversWriterTest.java +++ b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/ReceiversWriterTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.freightreceiver; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -46,10 +46,10 @@ void testV1() { new ReceiversWriter( ReceiverUtils.getReceivers( sc ) ).writeV1(utils.getOutputDirectory() + "receivers_v1.xml"); } catch (Exception e) { e.printStackTrace(); - Assert.fail("Should write without exception."); + Assertions.fail("Should write without exception."); } - Assert.assertTrue("File should exist.", new File(utils.getOutputDirectory() + "receivers_v1.xml").exists()); + Assertions.assertTrue(new File(utils.getOutputDirectory() + "receivers_v1.xml").exists(), "File should exist."); } @Test @@ -63,10 +63,10 @@ void testV2() { new ReceiversWriter( ReceiverUtils.getReceivers( sc ) ).writeV2(utils.getOutputDirectory() + "receivers_v2.xml"); } catch (Exception e) { e.printStackTrace(); - Assert.fail("Should write without exception."); + Assertions.fail("Should write without exception."); } - Assert.assertTrue("File should exist.", new File(utils.getOutputDirectory() + "receivers_v2.xml").exists()); + Assertions.assertTrue(new File(utils.getOutputDirectory() + "receivers_v2.xml").exists(), "File should exist."); } } diff --git a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/SSReorderPolicyTest.java b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/SSReorderPolicyTest.java index 9f51534e124..1841ae963fc 100644 --- a/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/SSReorderPolicyTest.java +++ b/contribs/freightreceiver/src/test/java/org/matsim/contrib/freightreceiver/SSReorderPolicyTest.java @@ -21,7 +21,7 @@ package org.matsim.contrib.freightreceiver; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.testcases.MatsimTestUtils; @@ -30,9 +30,9 @@ public class SSReorderPolicyTest { @Test void testCalculateOrderQuantity() { ReorderPolicy policy = ReceiverUtils.createSSReorderPolicy(5.0, 10.0); - Assert.assertEquals("Wrong reorder quantity", 0.0, policy.calculateOrderQuantity(6.0), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong reorder quantity", 5.0, policy.calculateOrderQuantity(5.0), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong reorder quantity", 6.0, policy.calculateOrderQuantity(4.0), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, policy.calculateOrderQuantity(6.0), MatsimTestUtils.EPSILON, "Wrong reorder quantity"); + Assertions.assertEquals(5.0, policy.calculateOrderQuantity(5.0), MatsimTestUtils.EPSILON, "Wrong reorder quantity"); + Assertions.assertEquals(6.0, policy.calculateOrderQuantity(4.0), MatsimTestUtils.EPSILON, "Wrong reorder quantity"); } } diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedSubtourConstraintTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedSubtourConstraintTest.java index 30153229e58..3be3bbb887a 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedSubtourConstraintTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedSubtourConstraintTest.java @@ -14,7 +14,7 @@ import java.util.Arrays; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class RelaxedSubtourConstraintTest { diff --git a/contribs/integration/src/test/java/org/matsim/integration/daily/SomeDailyTest.java b/contribs/integration/src/test/java/org/matsim/integration/daily/SomeDailyTest.java index 2cf8b0c6d75..c19b95b9385 100644 --- a/contribs/integration/src/test/java/org/matsim/integration/daily/SomeDailyTest.java +++ b/contribs/integration/src/test/java/org/matsim/integration/daily/SomeDailyTest.java @@ -1,6 +1,6 @@ package org.matsim.integration.daily; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class SomeDailyTest { @@ -10,7 +10,7 @@ void doTest() { System.out.println("RUN TEST DAILY"); System.out.println("available ram: " + (Runtime.getRuntime().maxMemory() / 1024/1024)); - Assert.assertTrue(true); + Assertions.assertTrue(true); } } diff --git a/contribs/integration/src/test/java/org/matsim/integration/weekly/SomeWeeklyTest.java b/contribs/integration/src/test/java/org/matsim/integration/weekly/SomeWeeklyTest.java index 87c4be20dac..74db99859ba 100644 --- a/contribs/integration/src/test/java/org/matsim/integration/weekly/SomeWeeklyTest.java +++ b/contribs/integration/src/test/java/org/matsim/integration/weekly/SomeWeeklyTest.java @@ -1,6 +1,6 @@ package org.matsim.integration.weekly; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class SomeWeeklyTest { @@ -8,6 +8,6 @@ public class SomeWeeklyTest { void doTest() { System.out.println("RUN TEST WEEKLY"); System.out.println("available ram: " + (Runtime.getRuntime().maxMemory() / 1024/1024)); - Assert.assertTrue(true); + Assertions.assertTrue(true); } } diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java index 3ea1d36e21b..4f39e4a0b72 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java @@ -20,7 +20,7 @@ package org.matsim.contrib.locationchoice; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import jakarta.inject.Provider; import org.junit.jupiter.api.Test; @@ -133,7 +133,7 @@ public PlanStrategy get() { // Secondly, I need to give it two facilities to choose from, because a choice set of size 1 is treated specially // (it is assumed that the one element is the one I'm already on, so nothing is done). // I tricked it. :-) michaz - assertEquals("number of plans in person.", 2, person.getPlans().size()); + assertEquals(2, person.getPlans().size(), "number of plans in person."); Plan newPlan = person.getSelectedPlan(); Activity newWork = (Activity) newPlan.getPlanElements().get(2); if (!config.routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FacilityPenaltyTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FacilityPenaltyTest.java index eac967476eb..4ae55db30cc 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FacilityPenaltyTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FacilityPenaltyTest.java @@ -3,7 +3,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.contrib.locationchoice.DestinationChoiceConfigGroup; import org.matsim.testcases.MatsimTestUtils; @@ -13,7 +13,7 @@ public class FacilityPenaltyTest { @Test void testGetPenalty() { FacilityPenalty facilitypenalty = new FacilityPenalty(0.0, new DestinationChoiceConfigGroup()); - Assert.assertEquals(facilitypenalty.getCapacityPenaltyFactor(0.0, 1.0), 0.0, MatsimTestUtils.EPSILON); + Assertions.assertEquals(facilitypenalty.getCapacityPenaltyFactor(0.0, 1.0), 0.0, MatsimTestUtils.EPSILON); } @Test @@ -26,6 +26,6 @@ void testcalculateCapPenaltyFactor() throws SecurityException, NoSuchMethodExcep method = facilitypenalty.getClass().getDeclaredMethod("calculateCapPenaltyFactor", new Class[]{int.class, int.class}); method.setAccessible(true); Double val = (Double)method.invoke(facilitypenalty, new Object[]{0, 1}); - Assert.assertTrue(Math.abs(val.doubleValue()) < 0.000000001); + Assertions.assertTrue(Math.abs(val.doubleValue()) < 0.000000001); } } diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java index dbbac69569f..bea0571d4e5 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java @@ -1,6 +1,6 @@ package org.matsim.contrib.locationchoice.frozenepsilons; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import static org.matsim.contrib.locationchoice.LocationChoiceIT.localCreatePopWOnePerson; import static org.matsim.contrib.locationchoice.frozenepsilons.FrozenTastesConfigGroup.Algotype; import static org.matsim.contrib.locationchoice.frozenepsilons.FrozenTastesConfigGroup.Algotype.bestResponse; @@ -14,7 +14,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -153,7 +153,7 @@ public void install() { // run: controler.run(); - assertEquals("number of plans in person.", 2, person.getPlans().size()); + assertEquals(2, person.getPlans().size(), "number of plans in person."); Plan newPlan = person.getSelectedPlan(); System.err.println( " newPlan: " + newPlan ) ; Activity newWork = (Activity) newPlan.getPlanElements().get(2 ); @@ -218,7 +218,7 @@ public void install() { controler.run(); - assertEquals("number of plans in person.", 2, person.getPlans().size()); + assertEquals(2, person.getPlans().size(), "number of plans in person."); Plan newPlan = person.getSelectedPlan(); System.err.println( " newPlan: " + newPlan ) ; Activity newWork = (Activity) newPlan.getPlanElements().get(2); @@ -429,7 +429,7 @@ int binFromVal( double val ) { } void check( double val, double actual ){ - Assert.assertEquals( val, actual, 2.*Math.max( 5, Math.sqrt( val ) ) ); + Assertions.assertEquals( val, actual, 2.*Math.max( 5, Math.sqrt( val ) ) ); } } ); diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/SamplerTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/SamplerTest.java index 268466e0215..df26aac50ab 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/SamplerTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/SamplerTest.java @@ -22,6 +22,8 @@ package org.matsim.contrib.locationchoice.frozenepsilons; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.junit.Before; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -34,8 +36,6 @@ import org.matsim.facilities.ActivityFacility; import org.matsim.testcases.MatsimTestUtils; -import static org.junit.Assert.assertTrue; - public class SamplerTest { @RegisterExtension diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/ScoringPenaltyTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/ScoringPenaltyTest.java index 5a4ce413fb9..7ee67877aff 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/ScoringPenaltyTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/ScoringPenaltyTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.locationchoice.frozenepsilons; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.contrib.locationchoice.DestinationChoiceConfigGroup; import org.matsim.testcases.MatsimTestUtils; @@ -11,6 +11,6 @@ public class ScoringPenaltyTest { void testGetPenalty() { FacilityPenalty facilityPenalty = new FacilityPenalty(0.0, new DestinationChoiceConfigGroup()); ScoringPenalty scoringpenalty = new ScoringPenalty(0.0, 1.0, facilityPenalty, 1.0); - Assert.assertEquals(scoringpenalty.getPenalty(), 0.0, MatsimTestUtils.EPSILON); + Assertions.assertEquals(scoringpenalty.getPenalty(), 0.0, MatsimTestUtils.EPSILON); } } diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/LocationMutatorwChoiceSetTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/LocationMutatorwChoiceSetTest.java index c17601dbc4b..6b6a02d29ee 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/LocationMutatorwChoiceSetTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/LocationMutatorwChoiceSetTest.java @@ -19,12 +19,12 @@ package org.matsim.contrib.locationchoice.timegeography; -import static org.junit.Assert.assertEquals; - import java.util.List; import java.util.Random; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/ManageSubchainsTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/ManageSubchainsTest.java index 1085935abf6..3dbbeac305a 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/ManageSubchainsTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/ManageSubchainsTest.java @@ -19,7 +19,7 @@ package org.matsim.contrib.locationchoice.timegeography; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/SubChainTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/SubChainTest.java index c13f5995a67..6284827abc7 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/SubChainTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/timegeography/SubChainTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.locationchoice.timegeography; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/contribs/locationchoice/src/test/java/org/matsim/core/router/BackwardFastMultiNodeTest.java b/contribs/locationchoice/src/test/java/org/matsim/core/router/BackwardFastMultiNodeTest.java index beb768be82e..11e7c5e4d92 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/core/router/BackwardFastMultiNodeTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/core/router/BackwardFastMultiNodeTest.java @@ -20,7 +20,7 @@ package org.matsim.core.router; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -75,38 +75,38 @@ private void runTestBackwardsFastMultiNodeDijkstra_OneToOne(boolean searchAllEnd */ Path path = dijkstra.calcLeastCostPath(fromNode, toNode, 3600.0, null, null); - Assert.assertEquals(1.0, path.travelCost, 0.0); - Assert.assertEquals(300.0, path.travelTime, 0.0); + Assertions.assertEquals(1.0, path.travelCost, 0.0); + Assertions.assertEquals(300.0, path.travelTime, 0.0); - Assert.assertEquals(4, path.nodes.size()); - Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(4, path.nodes.size()); + Assertions.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(3, path.links.size()); - Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(3, path.links.size()); + Assertions.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); /* * test constructPath method which uses data from the previous routing operation */ path = dijkstra.constructPath(fromNode, toNode, 3600.0); - Assert.assertEquals(1.0, path.travelCost, 0.0); - Assert.assertEquals(300.0, path.travelTime, 0.0); + Assertions.assertEquals(1.0, path.travelCost, 0.0); + Assertions.assertEquals(300.0, path.travelTime, 0.0); - Assert.assertEquals(4, path.nodes.size()); - Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(4, path.nodes.size()); + Assertions.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(3, path.links.size()); - Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(3, path.links.size()); + Assertions.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); } /* @@ -142,64 +142,64 @@ void testBackwardsFastMultiNodeDijkstra_OneToMany() { */ Path path = dijkstra.calcLeastCostPath(fromNode, toNode, 3600.0, null, null); - Assert.assertEquals(1.0, path.travelCost, 0.0); - Assert.assertEquals(300.0, path.travelTime, 0.0); + Assertions.assertEquals(1.0, path.travelCost, 0.0); + Assertions.assertEquals(300.0, path.travelTime, 0.0); - Assert.assertEquals(4, path.nodes.size()); - Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(4, path.nodes.size()); + Assertions.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(3, path.links.size()); - Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(3, path.links.size()); + Assertions.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); /* * test constructPath method which uses data from the previous routing operation - toNode1 */ path = dijkstra.constructPath(fromNode, toNode1, 3600.0); - Assert.assertEquals(1.0, path.travelCost, 0.0); - Assert.assertEquals(300.0, path.travelTime, 0.0); + Assertions.assertEquals(1.0, path.travelCost, 0.0); + Assertions.assertEquals(300.0, path.travelTime, 0.0); - Assert.assertEquals(4, path.nodes.size()); - Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(4, path.nodes.size()); + Assertions.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(3, path.links.size()); - Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(3, path.links.size()); + Assertions.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); /* * test constructPath method which uses data from the previous routing operation - toNode2 */ path = dijkstra.constructPath(fromNode, toNode2, 3600.0); - Assert.assertEquals(1.333, path.travelCost, 0.001); - Assert.assertEquals(400.0, path.travelTime, 0.0); + Assertions.assertEquals(1.333, path.travelCost, 0.001); + Assertions.assertEquals(400.0, path.travelTime, 0.0); - Assert.assertEquals(4, path.nodes.size()); - Assert.assertEquals(Id.create("n4", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(4, path.nodes.size()); + Assertions.assertEquals(Id.create("n4", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(3, path.links.size()); - Assert.assertEquals(Id.create("l3", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(3, path.links.size()); + Assertions.assertEquals(Id.create("l3", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); /* * test constructPath method which uses data from the previous routing operation - toNode3 */ path = dijkstra.constructPath(fromNode, toNode3, 3600.0); - Assert.assertNull(null); + Assertions.assertNull(null); } @Test @@ -232,78 +232,78 @@ void testBackwardsFastMultiNodeDijkstra_OneToMany_SearchAllNodes() { */ Path path = dijkstra.calcLeastCostPath(fromNode, toNode, 3600.0, null, null); - Assert.assertEquals(1.0, path.travelCost, 0.0); - Assert.assertEquals(300.0, path.travelTime, 0.0); + Assertions.assertEquals(1.0, path.travelCost, 0.0); + Assertions.assertEquals(300.0, path.travelTime, 0.0); - Assert.assertEquals(4, path.nodes.size()); - Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(4, path.nodes.size()); + Assertions.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(3, path.links.size()); - Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(3, path.links.size()); + Assertions.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); /* * test constructPath method which uses data from the previous routing operation - toNode1 */ path = dijkstra.constructPath(fromNode, toNode1, 3600.0); - Assert.assertEquals(1.0, path.travelCost, 0.0); - Assert.assertEquals(300.0, path.travelTime, 0.0); + Assertions.assertEquals(1.0, path.travelCost, 0.0); + Assertions.assertEquals(300.0, path.travelTime, 0.0); - Assert.assertEquals(4, path.nodes.size()); - Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(4, path.nodes.size()); + Assertions.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(3, path.links.size()); - Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(3, path.links.size()); + Assertions.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); /* * test constructPath method which uses data from the previous routing operation - toNode2 */ path = dijkstra.constructPath(fromNode, toNode2, 3600.0); - Assert.assertEquals(1.333, path.travelCost, 0.001); - Assert.assertEquals(400.0, path.travelTime, 0.0); + Assertions.assertEquals(1.333, path.travelCost, 0.001); + Assertions.assertEquals(400.0, path.travelTime, 0.0); - Assert.assertEquals(4, path.nodes.size()); - Assert.assertEquals(Id.create("n4", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(4, path.nodes.size()); + Assertions.assertEquals(Id.create("n4", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(3, path.links.size()); - Assert.assertEquals(Id.create("l3", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(3, path.links.size()); + Assertions.assertEquals(Id.create("l3", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); /* * test constructPath method which uses data from the previous routing operation - toNode3 */ path = dijkstra.constructPath(fromNode, toNode3, 3600.0); - Assert.assertEquals(2.0, path.travelCost, 0.0); - Assert.assertEquals(600.0, path.travelTime, 0.0); - - Assert.assertEquals(5, path.nodes.size()); - Assert.assertEquals(Id.create("n5", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n4", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(4).getId()); - - Assert.assertEquals(4, path.links.size()); - Assert.assertEquals(Id.create("l4", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l3", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(2).getId()); - Assert.assertEquals(Id.create("l2", Link.class), path.links.get(3).getId()); + Assertions.assertEquals(2.0, path.travelCost, 0.0); + Assertions.assertEquals(600.0, path.travelTime, 0.0); + + Assertions.assertEquals(5, path.nodes.size()); + Assertions.assertEquals(Id.create("n5", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n4", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(Id.create("n3", Node.class), path.nodes.get(4).getId()); + + Assertions.assertEquals(4, path.links.size()); + Assertions.assertEquals(Id.create("l4", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l3", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(Id.create("l2", Link.class), path.links.get(3).getId()); } /* diff --git a/contribs/locationchoice/src/test/java/org/matsim/core/router/FastMultiNodeTest.java b/contribs/locationchoice/src/test/java/org/matsim/core/router/FastMultiNodeTest.java index 56c804c9cc9..05abc03159c 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/core/router/FastMultiNodeTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/core/router/FastMultiNodeTest.java @@ -20,7 +20,7 @@ package org.matsim.core.router; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -73,38 +73,38 @@ void testFastMultiNodeDijkstra_OneToOne() { */ Path path = dijkstra.calcLeastCostPath(fromNode, toNode, 3600.0, null, null); - Assert.assertEquals(1.0, path.travelCost, 0.0); - Assert.assertEquals(300.0, path.travelTime, 0.0); + Assertions.assertEquals(1.0, path.travelCost, 0.0); + Assertions.assertEquals(300.0, path.travelTime, 0.0); - Assert.assertEquals(4, path.nodes.size()); - Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(4, path.nodes.size()); + Assertions.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(3, path.links.size()); - Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(3, path.links.size()); + Assertions.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); /* * test constructPath method which uses data from the previous routing operation */ path = dijkstra.constructPath(fromNode, toNode, 3600.0); - Assert.assertEquals(1.0, path.travelCost, 0.0); - Assert.assertEquals(300.0, path.travelTime, 0.0); + Assertions.assertEquals(1.0, path.travelCost, 0.0); + Assertions.assertEquals(300.0, path.travelTime, 0.0); - Assert.assertEquals(4, path.nodes.size()); - Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(4, path.nodes.size()); + Assertions.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(3, path.links.size()); - Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(3, path.links.size()); + Assertions.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); } @Test @@ -138,64 +138,64 @@ void testFastMultiNodeDijkstra_OneToMany() { */ Path path = dijkstra.calcLeastCostPath(fromNode, toNode, 3600.0, null, null); - Assert.assertEquals(1.0, path.travelCost, 0.0); - Assert.assertEquals(300.0, path.travelTime, 0.0); + Assertions.assertEquals(1.0, path.travelCost, 0.0); + Assertions.assertEquals(300.0, path.travelTime, 0.0); - Assert.assertEquals(4, path.nodes.size()); - Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(4, path.nodes.size()); + Assertions.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(3, path.links.size()); - Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(3, path.links.size()); + Assertions.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); /* * test constructPath method which uses data from the previous routing operation - toNode1 */ path = dijkstra.constructPath(fromNode, toNode1, 3600.0); - Assert.assertEquals(1.0, path.travelCost, 0.0); - Assert.assertEquals(300.0, path.travelTime, 0.0); + Assertions.assertEquals(1.0, path.travelCost, 0.0); + Assertions.assertEquals(300.0, path.travelTime, 0.0); - Assert.assertEquals(4, path.nodes.size()); - Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(4, path.nodes.size()); + Assertions.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(3, path.links.size()); - Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(3, path.links.size()); + Assertions.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); /* * test constructPath method which uses data from the previous routing operation - toNode2 */ path = dijkstra.constructPath(fromNode, toNode2, 3600.0); - Assert.assertEquals(1.333, path.travelCost, 0.001); - Assert.assertEquals(400.0, path.travelTime, 0.0); + Assertions.assertEquals(1.333, path.travelCost, 0.001); + Assertions.assertEquals(400.0, path.travelTime, 0.0); - Assert.assertEquals(4, path.nodes.size()); - Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n4", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(4, path.nodes.size()); + Assertions.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n4", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(3, path.links.size()); - Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l3", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(3, path.links.size()); + Assertions.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l3", Link.class), path.links.get(2).getId()); /* * test constructPath method which uses data from the previous routing operation - toNode3 */ path = dijkstra.constructPath(fromNode, toNode3, 3600.0); - Assert.assertNull(path); + Assertions.assertNull(path); } @Test @@ -229,78 +229,78 @@ void testFastMultiNodeDijkstra_OneToMany_SearchAllNodes() { */ Path path = dijkstra.calcLeastCostPath(fromNode, toNode, 3600.0, null, null); - Assert.assertEquals(1.0, path.travelCost, 0.0); - Assert.assertEquals(300.0, path.travelTime, 0.0); + Assertions.assertEquals(1.0, path.travelCost, 0.0); + Assertions.assertEquals(300.0, path.travelTime, 0.0); - Assert.assertEquals(4, path.nodes.size()); - Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(4, path.nodes.size()); + Assertions.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(3, path.links.size()); - Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(3, path.links.size()); + Assertions.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); /* * test constructPath method which uses data from the previous routing operation - toNode1 */ path = dijkstra.constructPath(fromNode, toNode1, 3600.0); - Assert.assertEquals(1.0, path.travelCost, 0.0); - Assert.assertEquals(300.0, path.travelTime, 0.0); + Assertions.assertEquals(1.0, path.travelCost, 0.0); + Assertions.assertEquals(300.0, path.travelTime, 0.0); - Assert.assertEquals(4, path.nodes.size()); - Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(4, path.nodes.size()); + Assertions.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(3, path.links.size()); - Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(3, path.links.size()); + Assertions.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); /* * test constructPath method which uses data from the previous routing operation - toNode2 */ path = dijkstra.constructPath(fromNode, toNode2, 3600.0); - Assert.assertEquals(1.333, path.travelCost, 0.001); - Assert.assertEquals(400.0, path.travelTime, 0.0); + Assertions.assertEquals(1.333, path.travelCost, 0.001); + Assertions.assertEquals(400.0, path.travelTime, 0.0); - Assert.assertEquals(4, path.nodes.size()); - Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n4", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(4, path.nodes.size()); + Assertions.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n4", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(3, path.links.size()); - Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l3", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(3, path.links.size()); + Assertions.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l3", Link.class), path.links.get(2).getId()); /* * test constructPath method which uses data from the previous routing operation - toNode3 */ path = dijkstra.constructPath(fromNode, toNode3, 3600.0); - Assert.assertEquals(2.0, path.travelCost, 0.0); - Assert.assertEquals(600.0, path.travelTime, 0.0); - - Assert.assertEquals(5, path.nodes.size()); - Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); - Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); - Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); - Assert.assertEquals(Id.create("n4", Node.class), path.nodes.get(3).getId()); - Assert.assertEquals(Id.create("n5", Node.class), path.nodes.get(4).getId()); - - Assert.assertEquals(4, path.links.size()); - Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); - Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); - Assert.assertEquals(Id.create("l3", Link.class), path.links.get(2).getId()); - Assert.assertEquals(Id.create("l4", Link.class), path.links.get(3).getId()); + Assertions.assertEquals(2.0, path.travelCost, 0.0); + Assertions.assertEquals(600.0, path.travelTime, 0.0); + + Assertions.assertEquals(5, path.nodes.size()); + Assertions.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); + Assertions.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); + Assertions.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); + Assertions.assertEquals(Id.create("n4", Node.class), path.nodes.get(3).getId()); + Assertions.assertEquals(Id.create("n5", Node.class), path.nodes.get(4).getId()); + + Assertions.assertEquals(4, path.links.size()); + Assertions.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); + Assertions.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); + Assertions.assertEquals(Id.create("l3", Link.class), path.links.get(2).getId()); + Assertions.assertEquals(Id.create("l4", Link.class), path.links.get(3).getId()); } /* diff --git a/contribs/locationchoice/src/test/java/org/matsim/core/router/MultiNodeDijkstraTest.java b/contribs/locationchoice/src/test/java/org/matsim/core/router/MultiNodeDijkstraTest.java index 283b90b0218..fd40e25d1f1 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/core/router/MultiNodeDijkstraTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/core/router/MultiNodeDijkstraTest.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -88,31 +88,31 @@ public void testMultipleStarts(boolean fastRouter) { Path p = createPath(dijkstra, fromNode, toNode); - Assert.assertNotNull("no path found!", p); - Assert.assertEquals(3, p.links.size()); - Assert.assertEquals("1", p.links.get(0).getId().toString()); - Assert.assertEquals("7", p.links.get(1).getId().toString()); - Assert.assertEquals("5", p.links.get(2).getId().toString()); + Assertions.assertNotNull(p, "no path found!"); + Assertions.assertEquals(3, p.links.size()); + Assertions.assertEquals("1", p.links.get(0).getId().toString()); + Assertions.assertEquals("7", p.links.get(1).getId().toString()); + Assertions.assertEquals("5", p.links.get(2).getId().toString()); // change costs tc.setData(Id.create(1, Link.class), 2.0, 5.0); p = createPath(dijkstra, fromNode, toNode); - Assert.assertNotNull("no path found!", p); - Assert.assertEquals(3, p.links.size()); - Assert.assertEquals("2", p.links.get(0).getId().toString()); - Assert.assertEquals("7", p.links.get(1).getId().toString()); - Assert.assertEquals("5", p.links.get(2).getId().toString()); + Assertions.assertNotNull(p, "no path found!"); + Assertions.assertEquals(3, p.links.size()); + Assertions.assertEquals("2", p.links.get(0).getId().toString()); + Assertions.assertEquals("7", p.links.get(1).getId().toString()); + Assertions.assertEquals("5", p.links.get(2).getId().toString()); // change costs again tc.setData(Id.create(1, Link.class), 2.0, 1.0); p = createPath(dijkstra, fromNode, toNode); - Assert.assertNotNull("no path found!", p); - Assert.assertEquals(3, p.links.size()); - Assert.assertEquals("1", p.links.get(0).getId().toString()); - Assert.assertEquals("7", p.links.get(1).getId().toString()); - Assert.assertEquals("5", p.links.get(2).getId().toString()); + Assertions.assertNotNull(p, "no path found!"); + Assertions.assertEquals(3, p.links.size()); + Assertions.assertEquals("1", p.links.get(0).getId().toString()); + Assertions.assertEquals("7", p.links.get(1).getId().toString()); + Assertions.assertEquals("5", p.links.get(2).getId().toString()); } @Test @@ -146,31 +146,31 @@ public void testMultipleEnds(boolean fastRouter) { Path p = createPath(dijkstra, fromNode, toNode); - Assert.assertNotNull("no path found!", p); - Assert.assertEquals(3, p.links.size()); - Assert.assertEquals("2", p.links.get(0).getId().toString()); - Assert.assertEquals("7", p.links.get(1).getId().toString()); - Assert.assertEquals("5", p.links.get(2).getId().toString()); + Assertions.assertNotNull(p, "no path found!"); + Assertions.assertEquals(3, p.links.size()); + Assertions.assertEquals("2", p.links.get(0).getId().toString()); + Assertions.assertEquals("7", p.links.get(1).getId().toString()); + Assertions.assertEquals("5", p.links.get(2).getId().toString()); // change costs tc.setData(Id.create(4, Link.class), 3.0, 1.0); p = createPath(dijkstra, fromNode, toNode); - Assert.assertNotNull("no path found!", p); - Assert.assertEquals(3, p.links.size()); - Assert.assertEquals("2", p.links.get(0).getId().toString()); - Assert.assertEquals("7", p.links.get(1).getId().toString()); - Assert.assertEquals("4", p.links.get(2).getId().toString()); + Assertions.assertNotNull(p, "no path found!"); + Assertions.assertEquals(3, p.links.size()); + Assertions.assertEquals("2", p.links.get(0).getId().toString()); + Assertions.assertEquals("7", p.links.get(1).getId().toString()); + Assertions.assertEquals("4", p.links.get(2).getId().toString()); // change costs again tc.setData(Id.create(6, Link.class), 7.0, 3.0); p = createPath(dijkstra, fromNode, toNode); - Assert.assertNotNull("no path found!", p); - Assert.assertEquals(3, p.links.size()); - Assert.assertEquals("2", p.links.get(0).getId().toString()); - Assert.assertEquals("7", p.links.get(1).getId().toString()); - Assert.assertEquals("6", p.links.get(2).getId().toString()); + Assertions.assertNotNull(p, "no path found!"); + Assertions.assertEquals(3, p.links.size()); + Assertions.assertEquals("2", p.links.get(0).getId().toString()); + Assertions.assertEquals("7", p.links.get(1).getId().toString()); + Assertions.assertEquals("6", p.links.get(2).getId().toString()); } @Test @@ -205,33 +205,33 @@ public void testMultipleStartsAndEnds(boolean fastRouter) { Path p = createPath(dijkstra, fromNode, toNode); - Assert.assertNotNull("no path found!", p); - Assert.assertEquals(3, p.links.size()); - Assert.assertEquals("2", p.links.get(0).getId().toString()); - Assert.assertEquals("7", p.links.get(1).getId().toString()); - Assert.assertEquals("5", p.links.get(2).getId().toString()); + Assertions.assertNotNull(p, "no path found!"); + Assertions.assertEquals(3, p.links.size()); + Assertions.assertEquals("2", p.links.get(0).getId().toString()); + Assertions.assertEquals("7", p.links.get(1).getId().toString()); + Assertions.assertEquals("5", p.links.get(2).getId().toString()); // change costs tc.setData(Id.create(3, Link.class), 3.0, 1.0); tc.setData(Id.create(4, Link.class), 3.0, 1.0); p = createPath(dijkstra, fromNode, toNode); - Assert.assertNotNull("no path found!", p); - Assert.assertEquals(3, p.links.size()); - Assert.assertEquals("3", p.links.get(0).getId().toString()); - Assert.assertEquals("7", p.links.get(1).getId().toString()); - Assert.assertEquals("4", p.links.get(2).getId().toString()); + Assertions.assertNotNull(p, "no path found!"); + Assertions.assertEquals(3, p.links.size()); + Assertions.assertEquals("3", p.links.get(0).getId().toString()); + Assertions.assertEquals("7", p.links.get(1).getId().toString()); + Assertions.assertEquals("4", p.links.get(2).getId().toString()); // change costs again tc.setData(Id.create(3, Link.class), 3.0, 4.0); tc.setData(Id.create(6, Link.class), 7.0, 3.0); p = createPath(dijkstra, fromNode, toNode); - Assert.assertNotNull("no path found!", p); - Assert.assertEquals(3, p.links.size()); - Assert.assertEquals("2", p.links.get(0).getId().toString()); - Assert.assertEquals("7", p.links.get(1).getId().toString()); - Assert.assertEquals("6", p.links.get(2).getId().toString()); + Assertions.assertNotNull(p, "no path found!"); + Assertions.assertEquals(3, p.links.size()); + Assertions.assertEquals("2", p.links.get(0).getId().toString()); + Assertions.assertEquals("7", p.links.get(1).getId().toString()); + Assertions.assertEquals("6", p.links.get(2).getId().toString()); } @Test @@ -270,11 +270,11 @@ public void testStartViaFaster(boolean fastRouter) { Path p = createPath(dijkstra, fromNode, toNode); - Assert.assertNotNull("no path found!", p); - Assert.assertEquals(3, p.links.size()); - Assert.assertEquals("1", p.links.get(0).getId().toString()); - Assert.assertEquals("7", p.links.get(1).getId().toString()); - Assert.assertEquals("5", p.links.get(2).getId().toString()); + Assertions.assertNotNull(p, "no path found!"); + Assertions.assertEquals(3, p.links.size()); + Assertions.assertEquals("1", p.links.get(0).getId().toString()); + Assertions.assertEquals("7", p.links.get(1).getId().toString()); + Assertions.assertEquals("5", p.links.get(2).getId().toString()); } @Test @@ -315,11 +315,11 @@ public void testEndViaFaster(boolean fastRouter) { // toNodes.put(f.network.getNodes().get(Id.create(5)), new InitialNode(1.0, 1.0)); // // Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - Assert.assertNotNull("no path found!", p); - Assert.assertEquals(3, p.links.size()); - Assert.assertEquals("2", p.links.get(0).getId().toString()); - Assert.assertEquals("7", p.links.get(1).getId().toString()); - Assert.assertEquals("5", p.links.get(2).getId().toString()); + Assertions.assertNotNull(p, "no path found!"); + Assertions.assertEquals(3, p.links.size()); + Assertions.assertEquals("2", p.links.get(0).getId().toString()); + Assertions.assertEquals("7", p.links.get(1).getId().toString()); + Assertions.assertEquals("5", p.links.get(2).getId().toString()); } @Test @@ -351,10 +351,10 @@ public void testOnlyFromToSameNode(boolean fastRouter) { Path p = createPath(dijkstra, fromNode, toNode); - Assert.assertNotNull("no path found!", p); - Assert.assertEquals(0, p.links.size()); - Assert.assertEquals(1, p.nodes.size()); - Assert.assertEquals("2", p.nodes.get(0).getId().toString()); + Assertions.assertNotNull(p, "no path found!"); + Assertions.assertEquals(0, p.links.size()); + Assertions.assertEquals(1, p.nodes.size()); + Assertions.assertEquals("2", p.nodes.get(0).getId().toString()); } @Test @@ -393,10 +393,10 @@ public void testSameNodeInFromToSetCheapest(boolean fastRouter) { Path p = createPath(dijkstra, fromNode, toNode); - Assert.assertNotNull("no path found!", p); - Assert.assertEquals(0, p.links.size()); - Assert.assertEquals(1, p.nodes.size()); - Assert.assertEquals("4", p.nodes.get(0).getId().toString()); + Assertions.assertNotNull(p, "no path found!"); + Assertions.assertEquals(0, p.links.size()); + Assertions.assertEquals(1, p.nodes.size()); + Assertions.assertEquals("4", p.nodes.get(0).getId().toString()); } @Test @@ -435,11 +435,11 @@ public void testSameNodeInFromToSetNotCheapest(boolean fastRouter) { Path p = createPath(dijkstra, fromNode, toNode); - Assert.assertNotNull("no path found!", p); - Assert.assertEquals(3, p.links.size()); - Assert.assertEquals("2", p.links.get(0).getId().toString()); - Assert.assertEquals("7", p.links.get(1).getId().toString()); - Assert.assertEquals("6", p.links.get(2).getId().toString()); + Assertions.assertNotNull(p, "no path found!"); + Assertions.assertEquals(3, p.links.size()); + Assertions.assertEquals("2", p.links.get(0).getId().toString()); + Assertions.assertEquals("7", p.links.get(1).getId().toString()); + Assertions.assertEquals("6", p.links.get(2).getId().toString()); } @Test @@ -476,11 +476,11 @@ public void testSomeEndNodesNotReachable(boolean fastRouter) { Path p = createPath(dijkstra, fromNode, toNode); - Assert.assertNotNull("no path found!", p); - Assert.assertEquals(3, p.links.size()); - Assert.assertEquals("2", p.links.get(0).getId().toString()); - Assert.assertEquals("7", p.links.get(1).getId().toString()); - Assert.assertEquals("5", p.links.get(2).getId().toString()); + Assertions.assertNotNull(p, "no path found!"); + Assertions.assertEquals(3, p.links.size()); + Assertions.assertEquals("2", p.links.get(0).getId().toString()); + Assertions.assertEquals("7", p.links.get(1).getId().toString()); + Assertions.assertEquals("5", p.links.get(2).getId().toString()); } @Test @@ -517,11 +517,11 @@ public void testSomeStartNodesNotUseable(boolean fastRouter) { Path p = createPath(dijkstra, fromNode, toNode); - Assert.assertNotNull("no path found!", p); - Assert.assertEquals(3, p.links.size()); - Assert.assertEquals("2", p.links.get(0).getId().toString()); - Assert.assertEquals("7", p.links.get(1).getId().toString()); - Assert.assertEquals("5", p.links.get(2).getId().toString()); + Assertions.assertNotNull(p, "no path found!"); + Assertions.assertEquals(3, p.links.size()); + Assertions.assertEquals("2", p.links.get(0).getId().toString()); + Assertions.assertEquals("7", p.links.get(1).getId().toString()); + Assertions.assertEquals("5", p.links.get(2).getId().toString()); } @Test @@ -553,7 +553,7 @@ public void testImpossibleRoute(boolean fastRouter) { Path p = createPath(dijkstra, fromNode, toNode); - Assert.assertNull("wow, impossible path found!", p); + Assertions.assertNull(p, "wow, impossible path found!"); } /* @@ -589,9 +589,9 @@ public void testInitialValuesCorrection(boolean fastRouter) { Path p = createPath(dijkstra, fromNode, toNode); - Assert.assertNotNull(p); - Assert.assertEquals(300.0, p.travelTime, 0.0); - Assert.assertEquals(600.0, p.travelCost, 0.0); + Assertions.assertNotNull(p); + Assertions.assertEquals(300.0, p.travelTime, 0.0); + Assertions.assertEquals(600.0, p.travelCost, 0.0); } /*package*/ static Path createPath(Dijkstra dijsktra, Node fromNode, Node toNode) { diff --git a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java index 9f56650dc64..029bc07e9ed 100644 --- a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java +++ b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java @@ -25,7 +25,7 @@ import java.io.File; import java.io.IOException; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.io.TempDir; @@ -129,7 +129,7 @@ void testIntegration() throws IOException { double actualTtime = ((Leg)person.getSelectedPlan().getPlanElements().get(1)).getTravelTime().seconds(); //compare computed and actual travel time - Assert.assertEquals(ttime, actualTtime, 0); + Assertions.assertEquals(ttime, actualTtime, 0); } diff --git a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java index 39a0ba2fa6c..f1cfe36973c 100644 --- a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java +++ b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java @@ -26,11 +26,10 @@ import java.io.IOException; import java.util.List; -import org.junit.Assert; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.io.TempDir; @@ -138,8 +137,8 @@ void testPtMatrixStops() throws IOException{ // the agents will walk 50 m to the nearest pt stop and 50 m back to their origin facility, so the total travel distance have to be 100 m. if(origin == destination){ - Assert.assertTrue(totalTravelTime == 100./defaultWalkSpeed); - Assert.assertTrue(totalTravelDistance == 100.); + Assertions.assertTrue(totalTravelTime == 100./defaultWalkSpeed); + Assertions.assertTrue(totalTravelDistance == 100.); } // test travel time and distance for neighboring origins and destinations @@ -147,13 +146,13 @@ else if( (origin + 1) % 4 == destination || (origin + 3) % 4 == destination){ // test total walk travel distance and time // in the test network the total walk distance always is 100 m, because the euclidean distance between a facility and its nearest pt stop always is 50 m - Assert.assertTrue(walkTravelDistance == 100.); - Assert.assertTrue(walkTravelTime == 100./defaultWalkSpeed); + Assertions.assertTrue(walkTravelDistance == 100.); + Assertions.assertTrue(walkTravelTime == 100./defaultWalkSpeed); // test pt travel distance and time // in the test network the euclidean distance between neighboring pt stops always is 180 m - Assert.assertTrue(ptTravelDistance == 180.*beelineDistanceFactor); - Assert.assertTrue(ptTravelTime == (180./defaultPtSpeed)*beelineDistanceFactor); + Assertions.assertTrue(ptTravelDistance == 180.*beelineDistanceFactor); + Assertions.assertTrue(ptTravelTime == (180./defaultPtSpeed)*beelineDistanceFactor); } // test travel times and distances for diagonal origin destination pairs @@ -166,16 +165,16 @@ else if( (origin + 1) % 4 == destination || (origin + 3) % 4 == destination){ // test total walk travel distance and time // in the test network the total walk distance always is 100 m, because the euclidean distance between a facility and its nearest pt stop always is 50 m - Assert.assertTrue(walkTravelDistance == 100.); - Assert.assertTrue(walkTravelTime == 100./defaultWalkSpeed); + Assertions.assertTrue(walkTravelDistance == 100.); + Assertions.assertTrue(walkTravelTime == 100./defaultWalkSpeed); // test upper bounds for pt travel distance and time (as described above) - Assert.assertTrue(ptTravelDistance <= euclideanDistance*beelineDistanceFactor); - Assert.assertTrue(ptTravelTime <= (euclideanDistance/defaultPtSpeed)*beelineDistanceFactor); + Assertions.assertTrue(ptTravelDistance <= euclideanDistance*beelineDistanceFactor); + Assertions.assertTrue(ptTravelTime <= (euclideanDistance/defaultPtSpeed)*beelineDistanceFactor); // test lower bounds for pt travel distance and time (as described above) - Assert.assertTrue(ptTravelDistance >= 180.*beelineDistanceFactor); - Assert.assertTrue(ptTravelTime >= (180./defaultPtSpeed)*beelineDistanceFactor); + Assertions.assertTrue(ptTravelDistance >= 180.*beelineDistanceFactor); + Assertions.assertTrue(ptTravelTime >= (180./defaultPtSpeed)*beelineDistanceFactor); } } } @@ -246,8 +245,8 @@ void testPtMatrixTimesAndDistances() throws IOException{ // the agents will walk 50 m to the nearest pt stop and 50 m back to their origin facility, so the total travel distance have to be 100 m. if(origin == destination){ - Assert.assertTrue(totalTravelDistance == 100.); - Assert.assertTrue(totalTravelTime == 100./defaultWalkSpeed); + Assertions.assertTrue(totalTravelDistance == 100.); + Assertions.assertTrue(totalTravelTime == 100./defaultWalkSpeed); } // test travel time and distance for different origins and destinations @@ -255,13 +254,13 @@ void testPtMatrixTimesAndDistances() throws IOException{ // test total walk travel distance and time // in the test network the total walk distance always is 100 m, because the euclidean distance between a facility and its nearest pt stop always is 50 m - Assert.assertTrue(walkTravelDistance == 100.); - Assert.assertTrue(walkTravelTime == 100./defaultWalkSpeed); + Assertions.assertTrue(walkTravelDistance == 100.); + Assertions.assertTrue(walkTravelTime == 100./defaultWalkSpeed); // test pt travel distance and time // in the csv-file the pt travel distance is given as 100 m; the pt travel time as 100 min - Assert.assertTrue(ptTravelDistance == 100.); - Assert.assertTrue(ptTravelTime == 100. * 60); // multiplied by 60 to convert minutes to seconds (csv-files are saved in minutes; matsim works with seconds) + Assertions.assertTrue(ptTravelDistance == 100.); + Assertions.assertTrue(ptTravelTime == 100. * 60); // multiplied by 60 to convert minutes to seconds (csv-files are saved in minutes; matsim works with seconds) } } } diff --git a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/TestQuadTree.java b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/TestQuadTree.java index fb284ae2911..22786b5a95c 100644 --- a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/TestQuadTree.java +++ b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/TestQuadTree.java @@ -25,7 +25,7 @@ import java.util.Collection; import java.util.Iterator; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.collections.QuadTree; @@ -106,7 +106,7 @@ private void determineNearestPtStation(){ strb.append( ' ' ); } System.out.println( strb ); - Assert.assertEquals( "pt1a pt2a pt3a ", strb.toString() ); + Assertions.assertEquals( "pt1a pt2a pt3a ", strb.toString() ); } { Collection ptColWork = qTree.getDisk(work.getX(), work.getY(), distance); @@ -118,7 +118,7 @@ private void determineNearestPtStation(){ strb.append( ' ') ; } System.out.println( strb ); - Assert.assertEquals( "pt3b ", strb.toString() ); + Assertions.assertEquals( "pt3b ", strb.toString() ); } } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/genericUtils/TerminusStopFinderTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/genericUtils/TerminusStopFinderTest.java index 9e13c9d134d..0809f0e6bf3 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/genericUtils/TerminusStopFinderTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/genericUtils/TerminusStopFinderTest.java @@ -20,6 +20,7 @@ package org.matsim.contrib.minibus.genericUtils; import java.util.ArrayList; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.core.config.ConfigUtils; @@ -29,7 +30,6 @@ import org.matsim.pt.transitSchedule.api.TransitScheduleFactory; import org.matsim.pt.transitSchedule.api.TransitStopFacility; -import org.junit.Assert; import org.junit.Before; /** @@ -56,7 +56,7 @@ void testFindSecondTerminusStop() { stops.add(getOrCreateStopAtCoord(40, 0)); int indexSecondTerminusStop = TerminusStopFinder.findSecondTerminusStop(stops); - Assert.assertEquals(2, indexSecondTerminusStop); + Assertions.assertEquals(2, indexSecondTerminusStop); /* * rectangular line @@ -74,7 +74,7 @@ void testFindSecondTerminusStop() { stops.add(getOrCreateStopAtCoord(0, 10)); indexSecondTerminusStop = TerminusStopFinder.findSecondTerminusStop(stops); - Assert.assertEquals(2, indexSecondTerminusStop); + Assertions.assertEquals(2, indexSecondTerminusStop); /* * triangular line both candidate stops at same distance from first terminus @@ -91,7 +91,7 @@ void testFindSecondTerminusStop() { stops.add(getOrCreateStopAtCoord(0, 10)); indexSecondTerminusStop = TerminusStopFinder.findSecondTerminusStop(stops); - Assert.assertEquals(1, indexSecondTerminusStop); + Assertions.assertEquals(1, indexSecondTerminusStop); /* * triangular line many stops @@ -112,7 +112,7 @@ void testFindSecondTerminusStop() { stops.add(getOrCreateStopAtCoord(0, 20)); indexSecondTerminusStop = TerminusStopFinder.findSecondTerminusStop(stops); - Assert.assertEquals(5, indexSecondTerminusStop); + Assertions.assertEquals(5, indexSecondTerminusStop); /* * TODO: Currently failing, would require a more elaborate algorithm to determine the terminus stop diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/PControlerTestIT.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/PControlerTestIT.java index 85b2ae5dc77..915d8919073 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/PControlerTestIT.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/PControlerTestIT.java @@ -24,7 +24,7 @@ import java.util.LinkedList; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -102,7 +102,7 @@ final void testPControler() { for (String filename : filesToCheckFor) { File f = new File(filename); - Assert.assertEquals(filename + " does not exist", true, f.exists() && !f.isDirectory()); + Assertions.assertEquals(true, f.exists() && !f.isDirectory(), filename + " does not exist"); } @@ -114,32 +114,32 @@ final void testPControler() { new TabularFileParser().parse(tabFileParserConfig, this); - Assert.assertEquals("There a less than the expected number of " + (numberOfIterations + 2) + " lines in " + filenameOfpStats, 12, this.pStatsResults.size()); + Assertions.assertEquals(12, this.pStatsResults.size(), "There a less than the expected number of " + (numberOfIterations + 2) + " lines in " + filenameOfpStats); // Check first iteration - Assert.assertEquals("Number of coops (first iteration)", "1", this.pStatsResults.get(1)[1]); - Assert.assertEquals("Number of routes (first iteration)", "1", this.pStatsResults.get(1)[3]); - Assert.assertEquals("Number of pax (first iteration)", "3092", this.pStatsResults.get(1)[5]); - Assert.assertEquals("Number of veh (first iteration)", "3", this.pStatsResults.get(1)[7]); - Assert.assertEquals("Number of budget (first iteration)", "-149.4493333333", this.pStatsResults.get(1)[9]); - - Assert.assertEquals("Number of +coops (first iteration)", "0", this.pStatsResults.get(1)[2]); - Assert.assertEquals("Number of +routes (first iteration)", "0", this.pStatsResults.get(1)[4]); - Assert.assertEquals("Number of +pax (first iteration)", "0", this.pStatsResults.get(1)[6]); - Assert.assertEquals("Number of +veh (first iteration)", "0", this.pStatsResults.get(1)[8]); - Assert.assertEquals("Number of +budget (first iteration)", "NaN", this.pStatsResults.get(1)[10]); - - Assert.assertEquals("Number of coops (last iteration)", "3", this.pStatsResults.get(11)[1]); - Assert.assertEquals("Number of routes (last iteration)", "3", this.pStatsResults.get(11)[3]); - Assert.assertEquals("Number of pax (last iteration)", "6728", this.pStatsResults.get(11)[5]); - Assert.assertEquals("Number of veh (last iteration)", "10", this.pStatsResults.get(11)[7]); - Assert.assertEquals("Number of budget (last iteration)", "68.7117037037", this.pStatsResults.get(11)[9]); - - Assert.assertEquals("Number of +coops (last iteration)", "2", this.pStatsResults.get(11)[2]); - Assert.assertEquals("Number of +routes (last iteration)", "2", this.pStatsResults.get(11)[4]); - Assert.assertEquals("Number of +pax (last iteration)", "6508", this.pStatsResults.get(11)[6]); - Assert.assertEquals("Number of +veh (last iteration)", "7", this.pStatsResults.get(11)[8]); - Assert.assertEquals("Number of +budget (last iteration)", "113.2005555555", this.pStatsResults.get(11)[10]); + Assertions.assertEquals("1", this.pStatsResults.get(1)[1], "Number of coops (first iteration)"); + Assertions.assertEquals("1", this.pStatsResults.get(1)[3], "Number of routes (first iteration)"); + Assertions.assertEquals("3092", this.pStatsResults.get(1)[5], "Number of pax (first iteration)"); + Assertions.assertEquals("3", this.pStatsResults.get(1)[7], "Number of veh (first iteration)"); + Assertions.assertEquals("-149.4493333333", this.pStatsResults.get(1)[9], "Number of budget (first iteration)"); + + Assertions.assertEquals("0", this.pStatsResults.get(1)[2], "Number of +coops (first iteration)"); + Assertions.assertEquals("0", this.pStatsResults.get(1)[4], "Number of +routes (first iteration)"); + Assertions.assertEquals("0", this.pStatsResults.get(1)[6], "Number of +pax (first iteration)"); + Assertions.assertEquals("0", this.pStatsResults.get(1)[8], "Number of +veh (first iteration)"); + Assertions.assertEquals("NaN", this.pStatsResults.get(1)[10], "Number of +budget (first iteration)"); + + Assertions.assertEquals("3", this.pStatsResults.get(11)[1], "Number of coops (last iteration)"); + Assertions.assertEquals("3", this.pStatsResults.get(11)[3], "Number of routes (last iteration)"); + Assertions.assertEquals("6728", this.pStatsResults.get(11)[5], "Number of pax (last iteration)"); + Assertions.assertEquals("10", this.pStatsResults.get(11)[7], "Number of veh (last iteration)"); + Assertions.assertEquals("68.7117037037", this.pStatsResults.get(11)[9], "Number of budget (last iteration)"); + + Assertions.assertEquals("2", this.pStatsResults.get(11)[2], "Number of +coops (last iteration)"); + Assertions.assertEquals("2", this.pStatsResults.get(11)[4], "Number of +routes (last iteration)"); + Assertions.assertEquals("6508", this.pStatsResults.get(11)[6], "Number of +pax (last iteration)"); + Assertions.assertEquals("7", this.pStatsResults.get(11)[8], "Number of +veh (last iteration)"); + Assertions.assertEquals("113.2005555555", this.pStatsResults.get(11)[10], "Number of +budget (last iteration)"); } @Override diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java index e83d57955aa..2050a1ad87c 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java @@ -24,8 +24,8 @@ import java.util.LinkedList; import java.util.List; -import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -91,7 +91,7 @@ final void testDefaultPControler() { for (String filename : filesToCheckFor) { File f = new File(filename); - Assert.assertEquals(filename + " does not exist", true, f.exists() && !f.isDirectory()); + Assertions.assertEquals(true, f.exists() && !f.isDirectory(), filename + " does not exist"); } // Check pStats @@ -103,16 +103,16 @@ final void testDefaultPControler() { new TabularFileParser().parse(tabFileParserConfig, this); // Check final iteration - Assert.assertEquals("Number of coops (final iteration)", "10", this.pStatsResults.get(31)[1]); - Assert.assertEquals("Number of routes (final iteration)", "13", this.pStatsResults.get(31)[3]); - Assert.assertEquals("Number of pax (final iteration)", "17163", this.pStatsResults.get(31)[5]); - Assert.assertEquals("Number of veh (final iteration)", "583", this.pStatsResults.get(31)[7]); - Assert.assertEquals("Number of budget (final iteration)", "-7123.2705000000", this.pStatsResults.get(31)[9]); - - Assert.assertEquals("Number of +coops (final iteration)", "4", this.pStatsResults.get(31)[2]); - Assert.assertEquals("Number of +routes (final iteration)", "6", this.pStatsResults.get(31)[4]); - Assert.assertEquals("Number of +pax (final iteration)", "3610", this.pStatsResults.get(31)[6]); - Assert.assertEquals("Number of +veh (final iteration)", "16", this.pStatsResults.get(31)[8]); + Assertions.assertEquals("10", this.pStatsResults.get(31)[1], "Number of coops (final iteration)"); + Assertions.assertEquals("13", this.pStatsResults.get(31)[3], "Number of routes (final iteration)"); + Assertions.assertEquals("17163", this.pStatsResults.get(31)[5], "Number of pax (final iteration)"); + Assertions.assertEquals("583", this.pStatsResults.get(31)[7], "Number of veh (final iteration)"); + Assertions.assertEquals("-7123.2705000000", this.pStatsResults.get(31)[9], "Number of budget (final iteration)"); + + Assertions.assertEquals("4", this.pStatsResults.get(31)[2], "Number of +coops (final iteration)"); + Assertions.assertEquals("6", this.pStatsResults.get(31)[4], "Number of +routes (final iteration)"); + Assertions.assertEquals("3610", this.pStatsResults.get(31)[6], "Number of +pax (final iteration)"); + Assertions.assertEquals("16", this.pStatsResults.get(31)[8], "Number of +veh (final iteration)"); } @Ignore @@ -153,7 +153,7 @@ final void testSubsidyPControler() { for (String filename : filesToCheckFor) { File f = new File(filename); - Assert.assertEquals(filename + " does not exist", true, f.exists() && !f.isDirectory()); + Assertions.assertEquals(true, f.exists() && !f.isDirectory(), filename + " does not exist"); } @@ -166,16 +166,16 @@ final void testSubsidyPControler() { new TabularFileParser().parse(tabFileParserConfig, this); // Check final iteration - Assert.assertEquals("Number of coops (final iteration)", "10", this.pStatsResults.get(31)[1]); - Assert.assertEquals("Number of routes (final iteration)", "62", this.pStatsResults.get(31)[3]); - Assert.assertEquals("Number of pax (final iteration)", "17210", this.pStatsResults.get(31)[5]); - Assert.assertEquals("Number of veh (final iteration)", "761", this.pStatsResults.get(31)[7]); - Assert.assertEquals("Number of budget (final iteration)", "-1876.5780555555", this.pStatsResults.get(31)[9]); - - Assert.assertEquals("Number of +coops (final iteration)", "4", this.pStatsResults.get(31)[2]); - Assert.assertEquals("Number of +routes (final iteration)", "51", this.pStatsResults.get(31)[4]); - Assert.assertEquals("Number of +pax (final iteration)", "9951", this.pStatsResults.get(31)[6]); - Assert.assertEquals("Number of +veh (final iteration)", "260", this.pStatsResults.get(31)[8]); + Assertions.assertEquals("10", this.pStatsResults.get(31)[1], "Number of coops (final iteration)"); + Assertions.assertEquals("62", this.pStatsResults.get(31)[3], "Number of routes (final iteration)"); + Assertions.assertEquals("17210", this.pStatsResults.get(31)[5], "Number of pax (final iteration)"); + Assertions.assertEquals("761", this.pStatsResults.get(31)[7], "Number of veh (final iteration)"); + Assertions.assertEquals("-1876.5780555555", this.pStatsResults.get(31)[9], "Number of budget (final iteration)"); + + Assertions.assertEquals("4", this.pStatsResults.get(31)[2], "Number of +coops (final iteration)"); + Assertions.assertEquals("51", this.pStatsResults.get(31)[4], "Number of +routes (final iteration)"); + Assertions.assertEquals("9951", this.pStatsResults.get(31)[6], "Number of +pax (final iteration)"); + Assertions.assertEquals("260", this.pStatsResults.get(31)[8], "Number of +veh (final iteration)"); } @Override diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyTestIT.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyTestIT.java index 07e2e05c0e7..0b42a8231d0 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyTestIT.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyTestIT.java @@ -24,7 +24,7 @@ import java.util.LinkedList; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -91,7 +91,7 @@ final void testSubsidyPControler() { for (String filename : filesToCheckFor) { File f = new File(filename); - Assert.assertEquals(filename + " does not exist", true, f.exists() && !f.isDirectory()); + Assertions.assertEquals(true, f.exists() && !f.isDirectory(), filename + " does not exist"); } // Check pStats @@ -105,7 +105,7 @@ final void testSubsidyPControler() { // Check final iteration String actual = this.pStatsResults.get(2)[9]; // flaky (non-deterministic) test... allow multiple results - Assert.assertEquals("Number of budget (final iteration)", 174413625.6, Double.parseDouble(actual), 1); + Assertions.assertEquals(174413625.6, Double.parseDouble(actual), 1, "Number of budget (final iteration)"); } @Override diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/EndRouteExtensionTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/EndRouteExtensionTest.java index f0d42a75dd7..1242c346766 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/EndRouteExtensionTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/EndRouteExtensionTest.java @@ -19,7 +19,7 @@ package org.matsim.contrib.minibus.replanning; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.contrib.minibus.PConstants; @@ -50,15 +50,15 @@ final void testRun() { PPlan testPlan = null; - Assert.assertEquals("Compare number of vehicles", 1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start stop", "p_2111", coop.getBestPlan().getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare end stop", "p_2333", coop.getBestPlan().getStopsToBeServed().get(1).getId().toString()); - Assert.assertNull("Test plan should be null", testPlan); + Assertions.assertEquals(1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals("p_2111", coop.getBestPlan().getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_2333", coop.getBestPlan().getStopsToBeServed().get(1).getId().toString(), "Compare end stop"); + Assertions.assertNull(testPlan, "Test plan should be null"); // buffer too small testPlan = strat.run(coop); - Assert.assertNull("Test plan should be null", testPlan); + Assertions.assertNull(testPlan, "Test plan should be null"); parameter = new ArrayList<>(); parameter.add("1000.0"); @@ -68,11 +68,11 @@ final void testRun() { testPlan = strat.run(coop); - Assert.assertNotNull("Test plan should not be null", testPlan); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); - Assert.assertEquals("Compare start stop", "p_2111", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare start stop", "p_2333", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3343", testPlan.getStopsToBeServed().get(2).getId().toString()); + Assertions.assertEquals("p_2111", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_2333", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3343", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare end stop"); parameter = new ArrayList<>(); @@ -83,17 +83,17 @@ final void testRun() { testPlan = strat.run(coop); - Assert.assertNotNull("Test plan should not be null", testPlan); - Assert.assertEquals("Compare start stop", "p_2111", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare start stop", "p_2333", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3334", testPlan.getStopsToBeServed().get(2).getId().toString()); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); + Assertions.assertEquals("p_2111", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_2333", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3334", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare end stop"); coop.getBestPlan().setStopsToBeServed(testPlan.getStopsToBeServed()); testPlan = strat.run(coop); // remaining stops are covered now by the buffer of the otherwise wiggly route - Assert.assertNull("Test plan should be null", testPlan); + Assertions.assertNull(testPlan, "Test plan should be null"); } @@ -111,17 +111,17 @@ final void testRunVShapedRoute() { PPlan testPlan = null; - Assert.assertEquals("Compare number of vehicles", 1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start stop", "p_2111", coop.getBestPlan().getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare middle stop", "p_3141", coop.getBestPlan().getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3222", coop.getBestPlan().getStopsToBeServed().get(2).getId().toString()); - Assert.assertEquals("Compare middle stop", "p_3141", coop.getBestPlan().getStopsToBeServed().get(3).getId().toString()); - Assert.assertNull("Test plan should be null", testPlan); + Assertions.assertEquals(1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals("p_2111", coop.getBestPlan().getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3141", coop.getBestPlan().getStopsToBeServed().get(1).getId().toString(), "Compare middle stop"); + Assertions.assertEquals("p_3222", coop.getBestPlan().getStopsToBeServed().get(2).getId().toString(), "Compare end stop"); + Assertions.assertEquals("p_3141", coop.getBestPlan().getStopsToBeServed().get(3).getId().toString(), "Compare middle stop"); + Assertions.assertNull(testPlan, "Test plan should be null"); // buffer too small testPlan = strat.run(coop); - Assert.assertNull("Test plan should be null", testPlan); + Assertions.assertNull(testPlan, "Test plan should be null"); parameter = new ArrayList<>(); parameter.add("1000.0"); @@ -133,13 +133,13 @@ final void testRunVShapedRoute() { testPlan = strat.run(coop); - Assert.assertNotNull("Test plan should not be null", testPlan); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); - Assert.assertEquals("Compare start stop", "p_2111", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare most distant stop in between", "p_3141", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare former end stop", "p_3222", testPlan.getStopsToBeServed().get(2).getId().toString()); - Assert.assertEquals("Compare new end stop", "p_2223", testPlan.getStopsToBeServed().get(3).getId().toString()); - Assert.assertEquals("Compare most distant stop in between", "p_3141", testPlan.getStopsToBeServed().get(4).getId().toString()); + Assertions.assertEquals("p_2111", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3141", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare most distant stop in between"); + Assertions.assertEquals("p_3222", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare former end stop"); + Assertions.assertEquals("p_2223", testPlan.getStopsToBeServed().get(3).getId().toString(), "Compare new end stop"); + Assertions.assertEquals("p_3141", testPlan.getStopsToBeServed().get(4).getId().toString(), "Compare most distant stop in between"); parameter = new ArrayList<>(); parameter.add("1000.0"); @@ -151,12 +151,12 @@ final void testRunVShapedRoute() { testPlan = strat.run(coop); - Assert.assertNotNull("Test plan should not be null", testPlan); - Assert.assertEquals("Compare start stop", "p_2111", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare most distant stop in between", "p_3141", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare former end stop", "p_3222", testPlan.getStopsToBeServed().get(2).getId().toString()); - Assert.assertEquals("Compare new end stop", "p_1323", testPlan.getStopsToBeServed().get(3).getId().toString()); - Assert.assertEquals("Compare most distant stop in between", "p_3141", testPlan.getStopsToBeServed().get(4).getId().toString()); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); + Assertions.assertEquals("p_2111", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3141", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare most distant stop in between"); + Assertions.assertEquals("p_3222", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare former end stop"); + Assertions.assertEquals("p_1323", testPlan.getStopsToBeServed().get(3).getId().toString(), "Compare new end stop"); + Assertions.assertEquals("p_3141", testPlan.getStopsToBeServed().get(4).getId().toString(), "Compare most distant stop in between"); parameter = new ArrayList<>(); parameter.add("1500.0"); @@ -168,12 +168,12 @@ final void testRunVShapedRoute() { testPlan = strat.run(coop); - Assert.assertNotNull("Test plan should not be null", testPlan); - Assert.assertEquals("Compare start stop", "p_2111", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare most distant stop in between", "p_3141", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare former end stop", "p_3222", testPlan.getStopsToBeServed().get(2).getId().toString()); - Assert.assertEquals("Compare new end stop", "p_1413", testPlan.getStopsToBeServed().get(3).getId().toString()); - Assert.assertEquals("Compare most distant stop in between", "p_3141", testPlan.getStopsToBeServed().get(4).getId().toString()); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); + Assertions.assertEquals("p_2111", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3141", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare most distant stop in between"); + Assertions.assertEquals("p_3222", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare former end stop"); + Assertions.assertEquals("p_1413", testPlan.getStopsToBeServed().get(3).getId().toString(), "Compare new end stop"); + Assertions.assertEquals("p_3141", testPlan.getStopsToBeServed().get(4).getId().toString(), "Compare most distant stop in between"); coop.getBestPlan().setStopsToBeServed(testPlan.getStopsToBeServed()); coop.getBestPlan().setLine(testPlan.getLine()); @@ -181,13 +181,13 @@ final void testRunVShapedRoute() { testPlan = strat.run(coop); // Adds stop 2414 - Assert.assertEquals("Compare new end stop", "p_2414", testPlan.getStopsToBeServed().get(4).getId().toString()); + Assertions.assertEquals("p_2414", testPlan.getStopsToBeServed().get(4).getId().toString(), "Compare new end stop"); coop.getBestPlan().setStopsToBeServed(testPlan.getStopsToBeServed()); coop.getBestPlan().setLine(testPlan.getLine()); testPlan = strat.run(coop); // remaining stops are covered now by the buffer of the otherwise wiggly route - Assert.assertNull("Test plan should be null", testPlan); + Assertions.assertNull(testPlan, "Test plan should be null"); } } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomEndTimeAllocatorTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomEndTimeAllocatorTest.java index dfae9e35570..15ac5a236ac 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomEndTimeAllocatorTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomEndTimeAllocatorTest.java @@ -19,7 +19,7 @@ package org.matsim.contrib.minibus.replanning; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.contrib.minibus.hook.Operator; @@ -46,20 +46,20 @@ final void testRun() { coop.getBestPlan().setEndTime(40000.0); - Assert.assertEquals("Compare number of vehicles", 1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare end time", 40000.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON); - Assert.assertNull("Test plan should be null", testPlan); + Assertions.assertEquals(1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals(40000.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON, "Compare end time"); + Assertions.assertNull(testPlan, "Test plan should be null"); coop.getBestPlan().setNVehicles(2); // enough vehicles for testing, but mutation range 0 testPlan = strat.run(coop); - Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare end time", 40000.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON); - Assert.assertNotNull("Test plan should be not null", testPlan); - Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare end time", 40000.0, testPlan.getEndTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals(40000.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON, "Compare end time"); + Assertions.assertNotNull(testPlan, "Test plan should be not null"); + Assertions.assertEquals(1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON, "There should be one vehicle bought"); + Assertions.assertEquals(40000.0, testPlan.getEndTime(), MatsimTestUtils.EPSILON, "Compare end time"); param = new ArrayList<>(); param.add("900"); @@ -70,10 +70,10 @@ final void testRun() { // enough vehicles for testing testPlan = strat.run(coop); - Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 40000.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON); - Assert.assertNotNull("Test plan should be not null", testPlan); - Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare end time", 40070.0, testPlan.getEndTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals(40000.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON, "Compare start time"); + Assertions.assertNotNull(testPlan, "Test plan should be not null"); + Assertions.assertEquals(1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON, "There should be one vehicle bought"); + Assertions.assertEquals(40070.0, testPlan.getEndTime(), MatsimTestUtils.EPSILON, "Compare end time"); } } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomStartTimeAllocatorTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomStartTimeAllocatorTest.java index 0c51695020c..a32498bf0b3 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomStartTimeAllocatorTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/MaxRandomStartTimeAllocatorTest.java @@ -19,7 +19,7 @@ package org.matsim.contrib.minibus.replanning; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.contrib.minibus.hook.Operator; @@ -47,20 +47,20 @@ final void testRun() { coop.getBestPlan().setStartTime(12000.0); coop.getBestPlan().setEndTime(36000.0); - Assert.assertEquals("Compare number of vehicles", 1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 12000.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON); - Assert.assertNull("Test plan should be null", testPlan); + Assertions.assertEquals(1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals(12000.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON, "Compare start time"); + Assertions.assertNull(testPlan, "Test plan should be null"); coop.getBestPlan().setNVehicles(2); // run strategy - time mutation is zero, thus no change testPlan = strat.run(coop); - Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 12000.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON); - Assert.assertNotNull("Test plan should be not null", testPlan); - Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 12000.0, testPlan.getStartTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals(12000.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON, "Compare start time"); + Assertions.assertNotNull(testPlan, "Test plan should be not null"); + Assertions.assertEquals(1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON, "There should be one vehicle bought"); + Assertions.assertEquals(12000.0, testPlan.getStartTime(), MatsimTestUtils.EPSILON, "Compare start time"); param = new ArrayList<>(); param.add("900"); @@ -71,10 +71,10 @@ final void testRun() { // enough vehicles for testing testPlan = strat.run(coop); - Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 12000.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON); - Assert.assertNotNull("Test plan should be not null", testPlan); - Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 11920.0, testPlan.getStartTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals(12000.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON, "Compare start time"); + Assertions.assertNotNull(testPlan, "Test plan should be not null"); + Assertions.assertEquals(1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON, "There should be one vehicle bought"); + Assertions.assertEquals(11920.0, testPlan.getStartTime(), MatsimTestUtils.EPSILON, "Compare start time"); } } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/SidewaysRouteExtensionTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/SidewaysRouteExtensionTest.java index d9a58f4ce0b..93da904e378 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/SidewaysRouteExtensionTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/SidewaysRouteExtensionTest.java @@ -19,7 +19,7 @@ package org.matsim.contrib.minibus.replanning; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.contrib.minibus.PConstants; @@ -62,15 +62,15 @@ final void testRun() { PPlan testPlan = null; - Assert.assertEquals("Compare number of vehicles", 1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start stop", "p_2414", coop.getBestPlan().getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3444", coop.getBestPlan().getStopsToBeServed().get(1).getId().toString()); - Assert.assertNull("Test plan should be null", testPlan); + Assertions.assertEquals(1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals("p_2414", coop.getBestPlan().getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3444", coop.getBestPlan().getStopsToBeServed().get(1).getId().toString(), "Compare end stop"); + Assertions.assertNull(testPlan, "Test plan should be null"); // buffer too small testPlan = strat.run(coop); - Assert.assertNull("Test plan should be null", testPlan); + Assertions.assertNull(testPlan, "Test plan should be null"); parameter = new ArrayList<>(); parameter.add("100.0"); @@ -82,12 +82,12 @@ final void testRun() { testPlan = strat.run(coop); // enough buffer to add a stop located directly at the beeline - Assert.assertNotNull("Test plan should not be null", testPlan); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); - Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare start stop", "p_2324", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); - Assert.assertEquals("Compare end stop", "p_2324", testPlan.getStopsToBeServed().get(3).getId().toString()); + Assertions.assertEquals("p_2414", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_2324", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3444", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare end stop"); + Assertions.assertEquals("p_2324", testPlan.getStopsToBeServed().get(3).getId().toString(), "Compare end stop"); parameter = new ArrayList<>(); @@ -100,11 +100,11 @@ final void testRun() { testPlan = strat.run(coop); // enough buffer 0.5 * 3000m = 1500m - Assert.assertNotNull("Test plan should not be null", testPlan); - Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare start stop", "p_2223", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare start stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); - Assert.assertEquals("Compare end stop", "p_2223", testPlan.getStopsToBeServed().get(3).getId().toString()); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); + Assertions.assertEquals("p_2414", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_2223", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3444", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_2223", testPlan.getStopsToBeServed().get(3).getId().toString(), "Compare end stop"); coop.getBestPlan().setStopsToBeServed(testPlan.getStopsToBeServed()); coop.getBestPlan().setLine(coop.getRouteProvider().createTransitLineFromOperatorPlan(coop.getId(), testPlan)); @@ -112,13 +112,13 @@ final void testRun() { testPlan = strat.run(coop); // and again stacking - therefore, enlarging the effective buffer - Assert.assertNotNull("Test plan should not be null", testPlan); - Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare start stop", "p_2212", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare start stop", "p_2223", testPlan.getStopsToBeServed().get(2).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(3).getId().toString()); - Assert.assertEquals("Compare start stop", "p_2212", testPlan.getStopsToBeServed().get(4).getId().toString()); - Assert.assertEquals("Compare end stop", "p_2223", testPlan.getStopsToBeServed().get(5).getId().toString()); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); + Assertions.assertEquals("p_2414", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_2212", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_2223", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3444", testPlan.getStopsToBeServed().get(3).getId().toString(), "Compare end stop"); + Assertions.assertEquals("p_2212", testPlan.getStopsToBeServed().get(4).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_2223", testPlan.getStopsToBeServed().get(5).getId().toString(), "Compare end stop"); parameter = new ArrayList<>(); parameter.add("4000.0"); @@ -131,74 +131,74 @@ final void testRun() { testPlan = strat.run(coop); // quite a lot buffer covering all nodes - Assert.assertNotNull("Test plan should not be null", testPlan); - Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare start stop", "p_2324", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); - Assert.assertEquals("Compare end stop", "p_2324", testPlan.getStopsToBeServed().get(3).getId().toString()); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); + Assertions.assertEquals("p_2414", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_2324", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3444", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare end stop"); + Assertions.assertEquals("p_2324", testPlan.getStopsToBeServed().get(3).getId().toString(), "Compare end stop"); testPlan = strat.run(coop); // quite a lot buffer covering all nodes - Assert.assertNotNull("Test plan should not be null", testPlan); - Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare start stop", "p_2223", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); - Assert.assertEquals("Compare end stop", "p_2223", testPlan.getStopsToBeServed().get(3).getId().toString()); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); + Assertions.assertEquals("p_2414", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_2223", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3444", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare end stop"); + Assertions.assertEquals("p_2223", testPlan.getStopsToBeServed().get(3).getId().toString(), "Compare end stop"); testPlan = strat.run(coop); // quite a lot buffer covering all nodes - Assert.assertNotNull("Test plan should not be null", testPlan); - Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare start stop", "p_2223", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); - Assert.assertEquals("Compare end stop", "p_2223", testPlan.getStopsToBeServed().get(3).getId().toString()); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); + Assertions.assertEquals("p_2414", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_2223", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3444", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare end stop"); + Assertions.assertEquals("p_2223", testPlan.getStopsToBeServed().get(3).getId().toString(), "Compare end stop"); testPlan = strat.run(coop); // quite a lot buffer covering all nodes - Assert.assertNotNull("Test plan should not be null", testPlan); - Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare start stop", "p_3323", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3323", testPlan.getStopsToBeServed().get(3).getId().toString()); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); + Assertions.assertEquals("p_2414", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3323", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3444", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare end stop"); + Assertions.assertEquals("p_3323", testPlan.getStopsToBeServed().get(3).getId().toString(), "Compare end stop"); testPlan = strat.run(coop); // quite a lot buffer covering all nodes - Assert.assertNotNull("Test plan should not be null", testPlan); - Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare start stop", "p_3433", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3433", testPlan.getStopsToBeServed().get(3).getId().toString()); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); + Assertions.assertEquals("p_2414", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3433", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3444", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare end stop"); + Assertions.assertEquals("p_3433", testPlan.getStopsToBeServed().get(3).getId().toString(), "Compare end stop"); testPlan = strat.run(coop); // quite a lot buffer covering all nodes - Assert.assertNotNull("Test plan should not be null", testPlan); - Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare start stop", "p_2423", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); - Assert.assertEquals("Compare end stop", "p_2423", testPlan.getStopsToBeServed().get(3).getId().toString()); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); + Assertions.assertEquals("p_2414", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_2423", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3444", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare end stop"); + Assertions.assertEquals("p_2423", testPlan.getStopsToBeServed().get(3).getId().toString(), "Compare end stop"); testPlan = strat.run(coop); // quite a lot buffer covering all nodes - Assert.assertNotNull("Test plan should not be null", testPlan); - Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare start stop", "p_2322", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); - Assert.assertEquals("Compare end stop", "p_2322", testPlan.getStopsToBeServed().get(3).getId().toString()); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); + Assertions.assertEquals("p_2414", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_2322", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3444", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare end stop"); + Assertions.assertEquals("p_2322", testPlan.getStopsToBeServed().get(3).getId().toString(), "Compare end stop"); testPlan = strat.run(coop); // quite a lot buffer covering all nodes - Assert.assertNotNull("Test plan should not be null", testPlan); - Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare start stop", "p_2221", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); - Assert.assertEquals("Compare end stop", "p_2221", testPlan.getStopsToBeServed().get(3).getId().toString()); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); + Assertions.assertEquals("p_2414", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_2221", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3444", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare end stop"); + Assertions.assertEquals("p_2221", testPlan.getStopsToBeServed().get(3).getId().toString(), "Compare end stop"); parameter = new ArrayList<>(); parameter.add("100.0"); @@ -211,20 +211,20 @@ final void testRun() { testPlan = strat.run(coop); // can now choose among stops at the outer edges - Assert.assertNotNull("Test plan should not be null", testPlan); - Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare start stop", "p_2324", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); - Assert.assertEquals("Compare end stop", "p_2324", testPlan.getStopsToBeServed().get(3).getId().toString()); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); + Assertions.assertEquals("p_2414", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_2324", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3444", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare end stop"); + Assertions.assertEquals("p_2324", testPlan.getStopsToBeServed().get(3).getId().toString(), "Compare end stop"); testPlan = strat.run(coop); // can now choose among stops at the outer edges - Assert.assertNotNull("Test plan should not be null", testPlan); - Assert.assertEquals("Compare start stop", "p_2414", testPlan.getStopsToBeServed().get(0).getId().toString()); - Assert.assertEquals("Compare start stop", "p_B", testPlan.getStopsToBeServed().get(1).getId().toString()); - Assert.assertEquals("Compare end stop", "p_3444", testPlan.getStopsToBeServed().get(2).getId().toString()); - Assert.assertEquals("Compare end stop", "p_B", testPlan.getStopsToBeServed().get(3).getId().toString()); + Assertions.assertNotNull(testPlan, "Test plan should not be null"); + Assertions.assertEquals("p_2414", testPlan.getStopsToBeServed().get(0).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_B", testPlan.getStopsToBeServed().get(1).getId().toString(), "Compare start stop"); + Assertions.assertEquals("p_3444", testPlan.getStopsToBeServed().get(2).getId().toString(), "Compare end stop"); + Assertions.assertEquals("p_B", testPlan.getStopsToBeServed().get(3).getId().toString(), "Compare end stop"); } } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/TimeProviderTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/TimeProviderTest.java index d4cda9b24d9..279199989e0 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/TimeProviderTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/TimeProviderTest.java @@ -21,7 +21,7 @@ import java.io.File; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -52,7 +52,7 @@ final void testGetRandomTimeInIntervalOneTimeSlot() { double startTime = 3600.0; double endTime = startTime; - Assert.assertEquals("New time (There is only one slot, thus time is zero)", 0.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON, "New time (There is only one slot, thus time is zero)"); } @Test @@ -69,7 +69,7 @@ final void testGetRandomTimeInIntervalOneSameStartEndTime() { double startTime = 3600.0; double endTime = startTime; - Assert.assertEquals("Same start and end time. Should return start time", 3600.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3600.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON, "Same start and end time. Should return start time"); } @Test @@ -86,8 +86,8 @@ final void testGetRandomTimeInIntervalDifferentStartEndTime() { double startTime = 7500.0; double endTime = 19400.0; - Assert.assertEquals("Check time", 7200.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON); - Assert.assertEquals("Check time", 11700.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON); + Assertions.assertEquals(7200.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON, "Check time"); + Assertions.assertEquals(11700.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON, "Check time"); Id agentId = Id.create("id", Person.class); Id linkId = Id.create("id", Link.class); @@ -96,11 +96,11 @@ final void testGetRandomTimeInIntervalDifferentStartEndTime() { tP.handleEvent(new ActivityEndEvent(500.0 * i, agentId, linkId, facilityId, "type")); } - Assert.assertEquals("Check time", 9000.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON); - Assert.assertEquals("Check time", 10800.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON); + Assertions.assertEquals(9000.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON, "Check time"); + Assertions.assertEquals(10800.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON, "Check time"); tP.reset(1); - Assert.assertEquals("Check time", 11700.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON); - Assert.assertEquals("Check time", 9900.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON); + Assertions.assertEquals(11700.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON, "Check time"); + Assertions.assertEquals(9900.0, tP.getRandomTimeInInterval(startTime, endTime), MatsimTestUtils.EPSILON, "Check time"); } } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedEndTimeExtensionTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedEndTimeExtensionTest.java index 9ece4bc8d4a..929d07a2dbd 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedEndTimeExtensionTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedEndTimeExtensionTest.java @@ -22,7 +22,7 @@ import java.io.File; import java.util.ArrayList; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -62,29 +62,29 @@ final void testRun() { coop.getBestPlan().setEndTime(19500.0); - Assert.assertEquals("Compare number of vehicles", 1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON); - Assert.assertNull("Test plan should be null", testPlan); + Assertions.assertEquals(1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals(19500.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON, "Compare start time"); + Assertions.assertNull(testPlan, "Test plan should be null"); coop.getBestPlan().setNVehicles(2); // enough vehicles for testing testPlan = strat.run(coop); - Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON); - Assert.assertNotNull("Test plan should be not null", testPlan); - Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 50400.0, testPlan.getEndTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals(19500.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON, "Compare start time"); + Assertions.assertNotNull(testPlan, "Test plan should be not null"); + Assertions.assertEquals(1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON, "There should be one vehicle bought"); + Assertions.assertEquals(50400.0, testPlan.getEndTime(), MatsimTestUtils.EPSILON, "Compare start time"); // enough vehicles for testing testPlan = strat.run(coop); - Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON); - Assert.assertNotNull("Test plan should be not null", testPlan); - Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 24300.0, testPlan.getEndTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals(19500.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON, "Compare start time"); + Assertions.assertNotNull(testPlan, "Test plan should be not null"); + Assertions.assertEquals(1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON, "There should be one vehicle bought"); + Assertions.assertEquals(24300.0, testPlan.getEndTime(), MatsimTestUtils.EPSILON, "Compare start time"); // Now same with acts Id agentId = Id.create("id", Person.class); @@ -97,19 +97,19 @@ final void testRun() { testPlan = strat.run(coop); - Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON); - Assert.assertNotNull("Test plan should be not null", testPlan); - Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 36000.0, testPlan.getEndTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals(19500.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON, "Compare start time"); + Assertions.assertNotNull(testPlan, "Test plan should be not null"); + Assertions.assertEquals(1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON, "There should be one vehicle bought"); + Assertions.assertEquals(36000.0, testPlan.getEndTime(), MatsimTestUtils.EPSILON, "Compare start time"); tP.reset(1); testPlan = strat.run(coop); - Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON); - Assert.assertNotNull("Test plan should be not null", testPlan); - Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 47700.0, testPlan.getEndTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals(19500.0, coop.getBestPlan().getEndTime(), MatsimTestUtils.EPSILON, "Compare start time"); + Assertions.assertNotNull(testPlan, "Test plan should be not null"); + Assertions.assertEquals(1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON, "There should be one vehicle bought"); + Assertions.assertEquals(47700.0, testPlan.getEndTime(), MatsimTestUtils.EPSILON, "Compare start time"); } } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedStartTimeExtensionTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedStartTimeExtensionTest.java index 38505c684cc..fe86892a6d6 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedStartTimeExtensionTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/replanning/WeightedStartTimeExtensionTest.java @@ -22,7 +22,7 @@ import java.io.File; import java.util.ArrayList; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -62,29 +62,29 @@ final void testRun() { coop.getBestPlan().setStartTime(19500.0); - Assert.assertEquals("Compare number of vehicles", 1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON); - Assert.assertNull("Test plan should be null", testPlan); + Assertions.assertEquals(1.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals(19500.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON, "Compare start time"); + Assertions.assertNull(testPlan, "Test plan should be null"); coop.getBestPlan().setNVehicles(2); // enough vehicles for testing testPlan = strat.run(coop); - Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON); - Assert.assertNotNull("Test plan should be not null", testPlan); - Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 9000.0, testPlan.getStartTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals(19500.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON, "Compare start time"); + Assertions.assertNotNull(testPlan, "Test plan should be not null"); + Assertions.assertEquals(1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON, "There should be one vehicle bought"); + Assertions.assertEquals(9000.0, testPlan.getStartTime(), MatsimTestUtils.EPSILON, "Compare start time"); // enough vehicles for testing testPlan = strat.run(coop); - Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON); - Assert.assertNotNull("Test plan should be not null", testPlan); - Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 900.0, testPlan.getStartTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals(19500.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON, "Compare start time"); + Assertions.assertNotNull(testPlan, "Test plan should be not null"); + Assertions.assertEquals(1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON, "There should be one vehicle bought"); + Assertions.assertEquals(900.0, testPlan.getStartTime(), MatsimTestUtils.EPSILON, "Compare start time"); // Now same with acts Id agentId = Id.create("id", Person.class); @@ -97,19 +97,19 @@ final void testRun() { testPlan = strat.run(coop); - Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON); - Assert.assertNotNull("Test plan should be not null", testPlan); - Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 9000.0, testPlan.getStartTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals(19500.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON, "Compare start time"); + Assertions.assertNotNull(testPlan, "Test plan should be not null"); + Assertions.assertEquals(1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON, "There should be one vehicle bought"); + Assertions.assertEquals(9000.0, testPlan.getStartTime(), MatsimTestUtils.EPSILON, "Compare start time"); tP.reset(1); testPlan = strat.run(coop); - Assert.assertEquals("Compare number of vehicles", 2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 19500.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON); - Assert.assertNotNull("Test plan should be not null", testPlan); - Assert.assertEquals("There should be one vehicle bought", 1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Compare start time", 8100.0, testPlan.getStartTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, coop.getBestPlan().getNVehicles(), MatsimTestUtils.EPSILON, "Compare number of vehicles"); + Assertions.assertEquals(19500.0, coop.getBestPlan().getStartTime(), MatsimTestUtils.EPSILON, "Compare start time"); + Assertions.assertNotNull(testPlan, "Test plan should be not null"); + Assertions.assertEquals(1.0, testPlan.getNVehicles(), MatsimTestUtils.EPSILON, "There should be one vehicle bought"); + Assertions.assertEquals(8100.0, testPlan.getStartTime(), MatsimTestUtils.EPSILON, "Compare start time"); } } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/ComplexCircleScheduleProviderTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/ComplexCircleScheduleProviderTest.java index 173983379c2..b35559eeab5 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/ComplexCircleScheduleProviderTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/ComplexCircleScheduleProviderTest.java @@ -21,7 +21,7 @@ import java.util.ArrayList; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -77,27 +77,27 @@ final void testCreateTransitLineLikeSimpleCircleScheduleProvider() { TransitLine line = prov.createTransitLineFromOperatorPlan(lineId, plan); - Assert.assertEquals("Transit line ids have to be the same", Id.create(lineId, TransitLine.class), line.getId()); + Assertions.assertEquals(Id.create(lineId, TransitLine.class), line.getId(), "Transit line ids have to be the same"); for (TransitRoute route : line.getRoutes().values()) { - Assert.assertEquals("Route id have to be the same", Id.create(lineId + "-" + routeId, TransitRoute.class), route.getId()); - Assert.assertEquals("Number of departures", 14.0, route.getDepartures().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(Id.create(lineId + "-" + routeId, TransitRoute.class), route.getId(), "Route id have to be the same"); + Assertions.assertEquals(14.0, route.getDepartures().size(), MatsimTestUtils.EPSILON, "Number of departures"); // check links - Assert.assertEquals("Start link id has to be the same", refIds.get(0), route.getRoute().getStartLinkId()); + Assertions.assertEquals(refIds.get(0), route.getRoute().getStartLinkId(), "Start link id has to be the same"); int i = 1; for (Id linkId : route.getRoute().getLinkIds()) { - Assert.assertEquals("Route link ids have to be the same", refIds.get(i), linkId); + Assertions.assertEquals(refIds.get(i), linkId, "Route link ids have to be the same"); i++; } - Assert.assertEquals("End link id has to be the same", refIds.get(refIds.size() - 1), route.getRoute().getEndLinkId()); + Assertions.assertEquals(refIds.get(refIds.size() - 1), route.getRoute().getEndLinkId(), "End link id has to be the same"); // check stops i = 0; for (TransitRouteStop stop : route.getStops()) { - Assert.assertEquals("Route stop ids have to be the same", Id.create(pC.getPIdentifier() + refIds.get(i), TransitStopFacility.class), stop.getStopFacility().getId()); + Assertions.assertEquals(Id.create(pC.getPIdentifier() + refIds.get(i), TransitStopFacility.class), stop.getStopFacility().getId(), "Route stop ids have to be the same"); i++; } } @@ -144,30 +144,30 @@ final void testCreateTransitLineWithMoreStops() { TransitLine line = prov.createTransitLineFromOperatorPlan(lineId, plan); - Assert.assertEquals("Transit line ids have to be the same", Id.create(lineId, TransitLine.class), line.getId()); + Assertions.assertEquals(Id.create(lineId, TransitLine.class), line.getId(), "Transit line ids have to be the same"); for (TransitRoute route : line.getRoutes().values()) { - Assert.assertEquals("Route id have to be the same", Id.create(lineId + "-" + routeId, TransitRoute.class), route.getId()); + Assertions.assertEquals(Id.create(lineId + "-" + routeId, TransitRoute.class), route.getId(), "Route id have to be the same"); // check links - Assert.assertEquals("Start link id has to be the same", refIds.get(0), route.getRoute().getStartLinkId()); + Assertions.assertEquals(refIds.get(0), route.getRoute().getStartLinkId(), "Start link id has to be the same"); int i = 1; for (Id linkId : route.getRoute().getLinkIds()) { - Assert.assertEquals("Route link ids have to be the same", refIds.get(i), linkId); + Assertions.assertEquals(refIds.get(i), linkId, "Route link ids have to be the same"); i++; } - Assert.assertEquals("End link id has to be the same", refIds.get(refIds.size() - 1), route.getRoute().getEndLinkId()); + Assertions.assertEquals(refIds.get(refIds.size() - 1), route.getRoute().getEndLinkId(), "End link id has to be the same"); // check stops i = 0; for (TransitRouteStop stop : route.getStops()) { - Assert.assertEquals("Route stop ids have to be the same", Id.create(pC.getPIdentifier() + refIds.get(i), TransitStopFacility.class), stop.getStopFacility().getId()); + Assertions.assertEquals(Id.create(pC.getPIdentifier() + refIds.get(i), TransitStopFacility.class), stop.getStopFacility().getId(), "Route stop ids have to be the same"); i++; } - Assert.assertEquals("Number of departures", 11.0, route.getDepartures().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(11.0, route.getDepartures().size(), MatsimTestUtils.EPSILON, "Number of departures"); } } @@ -183,7 +183,7 @@ final void testGetRandomTransitStop() { for (int i = 0; i < 5; i++) { TransitStopFacility stop1 = prov.getRandomTransitStop(0); TransitStopFacility stop2 = prov.getRandomTransitStop(0); - Assert.assertNotSame("Stop should not be the same", stop1.getId(), stop2.getId()); + Assertions.assertNotSame(stop1.getId(), stop2.getId(), "Stop should not be the same"); } } @@ -198,6 +198,6 @@ final void testCreateEmptyLine() { SimpleCircleScheduleProvider prov = new SimpleCircleScheduleProvider(pC.getPIdentifier(), scenario.getTransitSchedule(), scenario.getNetwork(), null, pC.getVehicleMaximumVelocity(), pC.getDriverRestTime(), pC.getMode()); TransitLine line = prov.createEmptyLineFromOperator(lineId); - Assert.assertEquals("Transit line ids have to be the same", Id.create(lineId, TransitLine.class), line.getId()); + Assertions.assertEquals(Id.create(lineId, TransitLine.class), line.getId(), "Transit line ids have to be the same"); } } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/SimpleCircleScheduleProviderTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/SimpleCircleScheduleProviderTest.java index 5d73e3a7e8d..b71c023add2 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/SimpleCircleScheduleProviderTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/routeProvider/SimpleCircleScheduleProviderTest.java @@ -21,7 +21,7 @@ import java.util.ArrayList; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -77,29 +77,29 @@ final void testCreateTransitLine() { TransitLine line = prov.createTransitLineFromOperatorPlan(Id.create(lineId, Operator.class), plan); - Assert.assertEquals("Transit line ids have to be the same", Id.create(lineId, TransitLine.class), line.getId()); + Assertions.assertEquals(Id.create(lineId, TransitLine.class), line.getId(), "Transit line ids have to be the same"); for (TransitRoute route : line.getRoutes().values()) { - Assert.assertEquals("Route id have to be the same", Id.create(lineId + "-" + routeId, TransitRoute.class), route.getId()); - Assert.assertEquals("Number of departures", 14.0, route.getDepartures().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(Id.create(lineId + "-" + routeId, TransitRoute.class), route.getId(), "Route id have to be the same"); + Assertions.assertEquals(14.0, route.getDepartures().size(), MatsimTestUtils.EPSILON, "Number of departures"); // check stops int i = 0; for (TransitRouteStop stop : route.getStops()) { - Assert.assertEquals("Route stop ids have to be the same", Id.create(pC.getPIdentifier() + refIds.get(i), TransitStopFacility.class), stop.getStopFacility().getId()); + Assertions.assertEquals(Id.create(pC.getPIdentifier() + refIds.get(i), TransitStopFacility.class), stop.getStopFacility().getId(), "Route stop ids have to be the same"); i++; } // check links - Assert.assertEquals("Start link id has to be the same", refIds.get(0), route.getRoute().getStartLinkId()); + Assertions.assertEquals(refIds.get(0), route.getRoute().getStartLinkId(), "Start link id has to be the same"); i = 1; for (Id linkId : route.getRoute().getLinkIds()) { - Assert.assertEquals("Route link ids have to be the same", refIds.get(i), linkId); + Assertions.assertEquals(refIds.get(i), linkId, "Route link ids have to be the same"); i++; } - Assert.assertEquals("End link id has to be the same", refIds.get(refIds.size() - 1), route.getRoute().getEndLinkId()); + Assertions.assertEquals(refIds.get(refIds.size() - 1), route.getRoute().getEndLinkId(), "End link id has to be the same"); } } @@ -115,7 +115,7 @@ final void testGetRandomTransitStop() { for (int i = 0; i < 5; i++) { TransitStopFacility stop1 = prov.getRandomTransitStop(0); TransitStopFacility stop2 = prov.getRandomTransitStop(0); - Assert.assertNotSame("Stop should not be the same", stop1.getId(), stop2.getId()); + Assertions.assertNotSame(stop1.getId(), stop2.getId(), "Stop should not be the same"); } } @@ -130,6 +130,6 @@ final void testCreateEmptyLine() { SimpleCircleScheduleProvider prov = new SimpleCircleScheduleProvider(pC.getPIdentifier(), scenario.getTransitSchedule(), scenario.getNetwork(), null, pC.getVehicleMaximumVelocity(), pC.getDriverRestTime(), pC.getMode()); TransitLine line = prov.createEmptyLineFromOperator(lineId); - Assert.assertEquals("Transit line ids have to be the same", Id.create(lineId, TransitLine.class), line.getId()); + Assertions.assertEquals(Id.create(lineId, TransitLine.class), line.getId(), "Transit line ids have to be the same"); } } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreatePStopsOnJunctionApproachesAndBetweenJunctionsTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreatePStopsOnJunctionApproachesAndBetweenJunctionsTest.java index 8c174734f6f..6cfd313655a 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreatePStopsOnJunctionApproachesAndBetweenJunctionsTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreatePStopsOnJunctionApproachesAndBetweenJunctionsTest.java @@ -19,7 +19,7 @@ package org.matsim.contrib.minibus.schedule; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -69,12 +69,12 @@ final void testPScenarioHelperTestNetwork() { } /* 4 inner junctions with 4 approaches + 8 outer junctions with 3 approaches + 4 corners without junctions = 40 approach links */ - Assert.assertEquals("All 40 junction approach links got a paratransit stop", 40, numberOfParaStops, MatsimTestUtils.EPSILON); + Assertions.assertEquals(40, numberOfParaStops, MatsimTestUtils.EPSILON, "All 40 junction approach links got a paratransit stop"); /* Check whether these links are included as specified in the config */ - Assert.assertNotNull("Paratransit stop at link without real pt stop", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + realPtStopLink, TransitStopFacility.class))); - Assert.assertNotNull("Paratransit stop at link with small capacity", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + tooLowCapacityLink, TransitStopFacility.class))); - Assert.assertNotNull("Paratransit stop at link with high freespeed", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + tooHighFreespeedLink, TransitStopFacility.class))); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + realPtStopLink, TransitStopFacility.class)), "Paratransit stop at link without real pt stop"); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + tooLowCapacityLink, TransitStopFacility.class)), "Paratransit stop at link with small capacity"); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + tooHighFreespeedLink, TransitStopFacility.class)), "Paratransit stop at link with high freespeed"); TransitScheduleFactoryImpl tSF = new TransitScheduleFactoryImpl(); @@ -97,11 +97,11 @@ final void testPScenarioHelperTestNetwork() { } } - Assert.assertEquals("All car links minus one stop from formal transit got a paratransit stop", 40 - 3, numberOfParaStops, MatsimTestUtils.EPSILON); + Assertions.assertEquals(40 - 3, numberOfParaStops, MatsimTestUtils.EPSILON, "All car links minus one stop from formal transit got a paratransit stop"); - Assert.assertNull("No paratransit stop at link with real pt stop", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + realPtStopLink, TransitStopFacility.class))); - Assert.assertNull("No paratransit stop at link with too small capacity", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + tooLowCapacityLink, TransitStopFacility.class))); - Assert.assertNull("No paratransit stop at link with too high freespeed", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + tooHighFreespeedLink, TransitStopFacility.class))); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + realPtStopLink, TransitStopFacility.class)), "No paratransit stop at link with real pt stop"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + tooLowCapacityLink, TransitStopFacility.class)), "No paratransit stop at link with too small capacity"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + tooHighFreespeedLink, TransitStopFacility.class)), "No paratransit stop at link with too high freespeed"); } @@ -123,76 +123,76 @@ final void testComplexIntersection() { } } - Assert.assertEquals("Check number of paratransit stops", 16, numberOfParaStops, MatsimTestUtils.EPSILON); + Assertions.assertEquals(16, numberOfParaStops, MatsimTestUtils.EPSILON, "Check number of paratransit stops"); /* approaches to (unclustered) dead-ends */ - Assert.assertNotNull("Should find paratransit stop 'p_2_1'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "2_1", TransitStopFacility.class))); - Assert.assertNotNull("Should find paratransit stop 'p_4_3'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "4_3", TransitStopFacility.class))); - Assert.assertNotNull("Should find paratransit stop 'p_9_10'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "9_10", TransitStopFacility.class))); - Assert.assertNotNull("Should find paratransit stop 'p_30_31'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "30_31", TransitStopFacility.class))); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "2_1", TransitStopFacility.class)), "Should find paratransit stop 'p_2_1'"); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "4_3", TransitStopFacility.class)), "Should find paratransit stop 'p_4_3'"); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "9_10", TransitStopFacility.class)), "Should find paratransit stop 'p_9_10'"); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "30_31", TransitStopFacility.class)), "Should find paratransit stop 'p_30_31'"); /* left junction: clustered nodes 5-6-7-8 */ - Assert.assertNotNull("Should find junction approach paratransit stop 'p_2_5'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "2_5", TransitStopFacility.class))); - Assert.assertNotNull("Should find junction approach paratransit stop 'p_4_6'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "4_6", TransitStopFacility.class))); - Assert.assertNotNull("Should find junction approach paratransit stop 'p_19_8'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "19_8", TransitStopFacility.class))); - Assert.assertNotNull("Should find junction approach paratransit stop 'p_9_7'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "9_7", TransitStopFacility.class))); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "2_5", TransitStopFacility.class)), "Should find junction approach paratransit stop 'p_2_5'"); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "4_6", TransitStopFacility.class)), "Should find junction approach paratransit stop 'p_4_6'"); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "19_8", TransitStopFacility.class)), "Should find junction approach paratransit stop 'p_19_8'"); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "9_7", TransitStopFacility.class)), "Should find junction approach paratransit stop 'p_9_7'"); - Assert.assertNull("Should NOT find paratransit stop at link in junction '5_6'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "5_6", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '6_8'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "6_8", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '8_7'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "8_7", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '7_5'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "7_5", TransitStopFacility.class))); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "5_6", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '5_6'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "6_8", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '6_8'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "8_7", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '8_7'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "7_5", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '7_5'"); /* clustered nodes 11-12: dead-end, therefore only one stop approaching */ - Assert.assertNotNull("Should find junction approach paratransit stop 'p_13_12'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "13_12", TransitStopFacility.class))); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "13_12", TransitStopFacility.class)), "Should find junction approach paratransit stop 'p_13_12'"); /* right junction: clustered nodes 13-14-15-16-17-18-19-20-21-22-23-24 */ - Assert.assertNotNull("Should find junction approach paratransit stop 'p_6_15'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "6_15", TransitStopFacility.class))); - Assert.assertNotNull("Should find junction approach paratransit stop 'p_12_14'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "12_14", TransitStopFacility.class))); - Assert.assertNotNull("Should find junction approach paratransit stop 'p_27_22'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "27_22", TransitStopFacility.class))); - Assert.assertNotNull("Should find junction approach paratransit stop 'p_25_23'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "25_23", TransitStopFacility.class))); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "6_15", TransitStopFacility.class)), "Should find junction approach paratransit stop 'p_6_15'"); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "12_14", TransitStopFacility.class)), "Should find junction approach paratransit stop 'p_12_14'"); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "27_22", TransitStopFacility.class)), "Should find junction approach paratransit stop 'p_27_22'"); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "25_23", TransitStopFacility.class)), "Should find junction approach paratransit stop 'p_25_23'"); // in-junction links // east-west, north-south - Assert.assertNull("Should NOT find paratransit stop at link in junction '15_16'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "15_16", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '16_17'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "16_17", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '17_18'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "17_18", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '14_17'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "14_17", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '17_21'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "17_21", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '21_24'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "21_24", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '22_21'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "22_21", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '21_20'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "21_20", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '20_19'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "20_19", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '23_20'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "23_20", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '20_16'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "20_16", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '16_13'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "16_13", TransitStopFacility.class))); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "15_16", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '15_16'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "16_17", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '16_17'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "17_18", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '17_18'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "14_17", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '14_17'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "17_21", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '17_21'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "21_24", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '21_24'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "22_21", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '22_21'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "21_20", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '21_20'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "20_19", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '20_19'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "23_20", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '23_20'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "20_16", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '20_16'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "16_13", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '16_13'"); // outer avoidance links - Assert.assertNull("Should NOT find paratransit stop at link in junction '15_13'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "15_13", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '14_18'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "14_18", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '22_24'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "22_24", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '23_19'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "23_19", TransitStopFacility.class))); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "15_13", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '15_13'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "14_18", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '14_18'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "22_24", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '22_24'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "23_19", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '23_19'"); // crossing - Assert.assertNull("Should NOT find paratransit stop at link in junction '17_20'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "17_20", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '20_17'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "20_17", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '16_21'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "16_21", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link in junction '21_16'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "21_16", TransitStopFacility.class))); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "17_20", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '17_20'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "20_17", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '20_17'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "16_21", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '16_21'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "21_16", TransitStopFacility.class)), "Should NOT find paratransit stop at link in junction '21_16'"); /* clustered nodes 25-26: dead-end, therefore only one stop approaching */ - Assert.assertNotNull("Should find junction approach paratransit stop 'p_24_25'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "24_25", TransitStopFacility.class))); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "24_25", TransitStopFacility.class)), "Should find junction approach paratransit stop 'p_24_25'"); /* links exiting junctions (towards dead-ends) */ - Assert.assertNull("Should NOT find paratransit stop at link exiting junction '7_2'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "7_2", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link exiting junction '5_4'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "5_4", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link exiting junction '8_9'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "8_9", TransitStopFacility.class))); - Assert.assertNull("Should NOT find paratransit stop at link exiting junction '18_19'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "7_2", TransitStopFacility.class))); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "7_2", TransitStopFacility.class)), "Should NOT find paratransit stop at link exiting junction '7_2'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "5_4", TransitStopFacility.class)), "Should NOT find paratransit stop at link exiting junction '5_4'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "8_9", TransitStopFacility.class)), "Should NOT find paratransit stop at link exiting junction '8_9'"); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "7_2", TransitStopFacility.class)), "Should NOT find paratransit stop at link exiting junction '18_19'"); /* Infill Stops between junctions / dead-ends */ - Assert.assertNotNull("Should find infill paratransit stop 'p_30_29'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "30_29", TransitStopFacility.class))); - Assert.assertNotNull("Should find infill paratransit stop 'p_27_28'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "27_28", TransitStopFacility.class))); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "30_29", TransitStopFacility.class)), "Should find infill paratransit stop 'p_30_29'"); + Assertions.assertNotNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "27_28", TransitStopFacility.class)), "Should find infill paratransit stop 'p_27_28'"); /* Check whether CalcTopoTypes is considered (type 8 : intersections only) */ pC.addParam("TopoTypesForStops", "8"); transitSchedule = CreatePStopsOnJunctionApproachesAndBetweenJunctions.createPStops(network, pC, new NetworkConfigGroup()); - Assert.assertNull("Should NOT find paratransit stop at link with wrong topo type (not an intersection) '30_31'", transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "30_31", TransitStopFacility.class))); + Assertions.assertNull(transitSchedule.getFacilities().get(Id.create(pC.getPIdentifier() + "30_31", TransitStopFacility.class)), "Should NOT find paratransit stop at link with wrong topo type (not an intersection) '30_31'"); } /** diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreateStopsForAllCarLinksTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreateStopsForAllCarLinksTest.java index 38a447f0a74..d4fae5d5c8e 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreateStopsForAllCarLinksTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/schedule/CreateStopsForAllCarLinksTest.java @@ -19,7 +19,7 @@ package org.matsim.contrib.minibus.schedule; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -60,7 +60,7 @@ final void testCreateStopsForAllCarLinks() { } } - Assert.assertEquals("All car links got a paratransit stop", numberOfCarLinks, numberOfParaStops, MatsimTestUtils.EPSILON); + Assertions.assertEquals(numberOfCarLinks, numberOfParaStops, MatsimTestUtils.EPSILON, "All car links got a paratransit stop"); TransitScheduleFactoryImpl tSF = new TransitScheduleFactoryImpl(); @@ -78,7 +78,7 @@ final void testCreateStopsForAllCarLinks() { } } - Assert.assertEquals("All car links minus one stop from formal transit got a paratransit stop", numberOfCarLinks - 1, numberOfParaStops, MatsimTestUtils.EPSILON); + Assertions.assertEquals(numberOfCarLinks - 1, numberOfParaStops, MatsimTestUtils.EPSILON, "All car links minus one stop from formal transit got a paratransit stop"); } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/AreaBtwLinksVsTerminiBeelinePenaltyTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/AreaBtwLinksVsTerminiBeelinePenaltyTest.java index 8c4e676cfeb..c4a80910840 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/AreaBtwLinksVsTerminiBeelinePenaltyTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/AreaBtwLinksVsTerminiBeelinePenaltyTest.java @@ -22,8 +22,8 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -133,7 +133,7 @@ void testRectangularLine() { double actual = penalty.getScore(pPlan1, route1); // area 10 x 10 = 100; beeline termini ({0,0}, {10,0}) = 10 double expected = -1 * ((10.0 * 10.0 / 10.0) - 1); - Assert.assertEquals(expected, actual, 0.001); + Assertions.assertEquals(expected, actual, 0.001); } private TransitStopFacility getOrCreateStopAtCoord(int x, int y) { diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/RouteDesignScoringManagerTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/RouteDesignScoringManagerTest.java index 1cd63090a0e..bd2ee9230a3 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/RouteDesignScoringManagerTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/RouteDesignScoringManagerTest.java @@ -22,8 +22,8 @@ import java.util.ArrayList; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -107,7 +107,7 @@ void testRectangularLine() { double actual = manager1.scoreRouteDesign(pPlan1); // 6 stop->stop distances of 10 units each in the stops (not stopsToBeServed) double expected = -1 * ((6 * 10 / (10 * Math.sqrt(2))) - 1); - Assert.assertEquals(expected, actual, 0.001); + Assertions.assertEquals(expected, actual, 0.001); /* option StopListToEvaluate.pPlanStopsToBeServed */ stop2stopVsBeeline.setStopListToEvaluate(StopListToEvaluate.pPlanStopsToBeServed); @@ -117,7 +117,7 @@ void testRectangularLine() { actual = manager1.scoreRouteDesign(pPlan1); // 4 stop->stop distances of 10 units each in the stops expected = -1 * ((4 * 10 / (10 * Math.sqrt(2))) - 1); - Assert.assertEquals(expected, actual, 0.001); + Assertions.assertEquals(expected, actual, 0.001); pConfig.removeRouteDesignScoreParams(RouteDesignScoreFunctionName.stop2StopVsBeelinePenalty); @@ -135,7 +135,7 @@ void testRectangularLine() { actual = manager1.scoreRouteDesign(pPlan1); // x=[-10,10], y=[0,10] -> 20 X 10 expected = -1 * ((20 * 10 / (10 * Math.sqrt(2))) - 1); - Assert.assertEquals(expected, actual, 0.001); + Assertions.assertEquals(expected, actual, 0.001); /* option StopListToEvaluate.pPlanStopsToBeServed */ areaVsBeeline.setStopListToEvaluate(StopListToEvaluate.pPlanStopsToBeServed); @@ -145,7 +145,7 @@ void testRectangularLine() { actual = manager1.scoreRouteDesign(pPlan1); // x=[0,10], y=[0,10] -> 10 X 10 expected = -1 * ((10 * 10 / (10 * Math.sqrt(2))) - 1); - Assert.assertEquals(expected, actual, 0.001); + Assertions.assertEquals(expected, actual, 0.001); /* check summing up of both */ pConfig.addRouteDesignScoreParams(stop2stopVsBeeline); @@ -155,7 +155,7 @@ void testRectangularLine() { actual = manager1.scoreRouteDesign(pPlan1); // x=[0,10], y=[0,10] -> 10 X 10 ; 4 stop->stop distances of 10 units each in the stops expected = -1 * ((10 * 10 / (10 * Math.sqrt(2))) - 1) + (-1) * ((4 * 10 / (10 * Math.sqrt(2))) - 1); - Assert.assertEquals(expected, actual, 0.001); + Assertions.assertEquals(expected, actual, 0.001); /* Check route with only two stops */ stopsToBeServed = new ArrayList<>(); @@ -181,7 +181,7 @@ void testRectangularLine() { actual = manager1.scoreRouteDesign(pPlan2); // would be positive expected = -1; - Assert.assertEquals(expected, actual, 0.001); + Assertions.assertEquals(expected, actual, 0.001); /* check that no subsidy emerges (no positive route design score) */ // high valueToStartScoring -> all scores below would be positive, check that they are capped at 0 @@ -205,7 +205,7 @@ void testRectangularLine() { actual = manager1.scoreRouteDesign(pPlan3); // would be positive expected = 0; - Assert.assertEquals(expected, actual, 0.001); + Assertions.assertEquals(expected, actual, 0.001); } private TransitStopFacility getOrCreateStopAtCoord(int x, int y) { diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/StopServedMultipleTimesPenaltyTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/StopServedMultipleTimesPenaltyTest.java index 88c2217c9a6..1a5d848bfe1 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/StopServedMultipleTimesPenaltyTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/StopServedMultipleTimesPenaltyTest.java @@ -21,8 +21,8 @@ import java.util.ArrayList; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -95,7 +95,7 @@ void testRouteServingSameStopTwice() { double actual = penalty.getScore(pPlan1, route1); // 4 stops served, but only 3 different stop ids double expected = -1 * ((4.0 / 3) - 1); - Assert.assertEquals(expected, actual, 0.001); + Assertions.assertEquals(expected, actual, 0.001); } private TransitStopFacility getOrCreateStopAtCoord(int x, int y) { diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsApproxContainerTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsApproxContainerTest.java index 5d7d6647979..5d643653006 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsApproxContainerTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsApproxContainerTest.java @@ -19,7 +19,7 @@ package org.matsim.contrib.minibus.stats; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.contrib.minibus.stats.RecursiveStatsApproxContainer; @@ -35,45 +35,45 @@ final void testRecursiveStatsContainer() { RecursiveStatsApproxContainer stats = new RecursiveStatsApproxContainer(0.1, 3); stats.handleNewEntry(1.0, 4.0, 2.0, 3.0); - Assert.assertEquals("mean coop", 1.0, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean route", 4.0, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean pax", 2.0, stats.getArithmeticMeanPax(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean veh", 3.0, stats.getArithmeticMeanVeh(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev coop", Double.NaN, stats.getStdDevOperators(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev route", Double.NaN, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev pax", Double.NaN, stats.getStdDevPax(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev veh", Double.NaN, stats.getStdDevVeh(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1.0, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON, "mean coop"); + Assertions.assertEquals(4.0, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON, "mean route"); + Assertions.assertEquals(2.0, stats.getArithmeticMeanPax(), MatsimTestUtils.EPSILON, "mean pax"); + Assertions.assertEquals(3.0, stats.getArithmeticMeanVeh(), MatsimTestUtils.EPSILON, "mean veh"); + Assertions.assertEquals(Double.NaN, stats.getStdDevOperators(), MatsimTestUtils.EPSILON, "std dev coop"); + Assertions.assertEquals(Double.NaN, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON, "std dev route"); + Assertions.assertEquals(Double.NaN, stats.getStdDevPax(), MatsimTestUtils.EPSILON, "std dev pax"); + Assertions.assertEquals(Double.NaN, stats.getStdDevVeh(), MatsimTestUtils.EPSILON, "std dev veh"); stats.handleNewEntry(2.0, 3.0, 3.0, 1.0); - Assert.assertEquals("mean coop", 1.5, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean route", 3.5, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean pax", 2.5, stats.getArithmeticMeanPax(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean veh", 2.0, stats.getArithmeticMeanVeh(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev coop", 0.7071067811865476, stats.getStdDevOperators(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev route", 0.7071067811865476, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev pax", 0.7071067811865476, stats.getStdDevPax(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev veh", 1.4142135623730951, stats.getStdDevVeh(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1.5, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON, "mean coop"); + Assertions.assertEquals(3.5, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON, "mean route"); + Assertions.assertEquals(2.5, stats.getArithmeticMeanPax(), MatsimTestUtils.EPSILON, "mean pax"); + Assertions.assertEquals(2.0, stats.getArithmeticMeanVeh(), MatsimTestUtils.EPSILON, "mean veh"); + Assertions.assertEquals(0.7071067811865476, stats.getStdDevOperators(), MatsimTestUtils.EPSILON, "std dev coop"); + Assertions.assertEquals(0.7071067811865476, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON, "std dev route"); + Assertions.assertEquals(0.7071067811865476, stats.getStdDevPax(), MatsimTestUtils.EPSILON, "std dev pax"); + Assertions.assertEquals(1.4142135623730951, stats.getStdDevVeh(), MatsimTestUtils.EPSILON, "std dev veh"); stats.handleNewEntry(3.0, 2.0, 1.0, 2.0); - Assert.assertEquals("mean coop", 2.0, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean route", 3.0, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean pax", 2.0, stats.getArithmeticMeanPax(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean veh", 2.0, stats.getArithmeticMeanVeh(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev coop", 1.0, stats.getStdDevOperators(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev route", 1.0, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev pax", 1.0, stats.getStdDevPax(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev veh", 1.0, stats.getStdDevVeh(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON, "mean coop"); + Assertions.assertEquals(3.0, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON, "mean route"); + Assertions.assertEquals(2.0, stats.getArithmeticMeanPax(), MatsimTestUtils.EPSILON, "mean pax"); + Assertions.assertEquals(2.0, stats.getArithmeticMeanVeh(), MatsimTestUtils.EPSILON, "mean veh"); + Assertions.assertEquals(1.0, stats.getStdDevOperators(), MatsimTestUtils.EPSILON, "std dev coop"); + Assertions.assertEquals(1.0, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON, "std dev route"); + Assertions.assertEquals(1.0, stats.getStdDevPax(), MatsimTestUtils.EPSILON, "std dev pax"); + Assertions.assertEquals(1.0, stats.getStdDevVeh(), MatsimTestUtils.EPSILON, "std dev veh"); stats.handleNewEntry(1.0, 4.0, 2.0, 3.0); stats.handleNewEntry(2.0, 3.0, 3.0, 1.0); stats.handleNewEntry(12.0, 12345.0, 123.0, 1234.0); - Assert.assertEquals("mean coop", 2.9190000000000005, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean route", 1237.281, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean pax", 14.190000000000001, stats.getArithmeticMeanPax(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean veh", 125.191, stats.getArithmeticMeanVeh(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev coop", 1.7181000000000002, stats.getStdDevOperators(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev route", 1111.5819000000001, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev pax", 11.691, stats.getStdDevPax(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev veh", 111.7719, stats.getStdDevVeh(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.9190000000000005, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON, "mean coop"); + Assertions.assertEquals(1237.281, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON, "mean route"); + Assertions.assertEquals(14.190000000000001, stats.getArithmeticMeanPax(), MatsimTestUtils.EPSILON, "mean pax"); + Assertions.assertEquals(125.191, stats.getArithmeticMeanVeh(), MatsimTestUtils.EPSILON, "mean veh"); + Assertions.assertEquals(1.7181000000000002, stats.getStdDevOperators(), MatsimTestUtils.EPSILON, "std dev coop"); + Assertions.assertEquals(1111.5819000000001, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON, "std dev route"); + Assertions.assertEquals(11.691, stats.getStdDevPax(), MatsimTestUtils.EPSILON, "std dev pax"); + Assertions.assertEquals(111.7719, stats.getStdDevVeh(), MatsimTestUtils.EPSILON, "std dev veh"); } } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsContainerTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsContainerTest.java index 60afd38171d..4544e36e4f7 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsContainerTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/stats/RecursiveStatsContainerTest.java @@ -19,7 +19,7 @@ package org.matsim.contrib.minibus.stats; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.contrib.minibus.stats.RecursiveStatsContainer; @@ -35,45 +35,45 @@ final void testRecursiveStatsContainer() { RecursiveStatsContainer stats = new RecursiveStatsContainer(); stats.handleNewEntry(1.0, 4.0, 2.0, 3.0); - Assert.assertEquals("mean coop", 1.0, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean route", 4.0, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean pax", 2.0, stats.getArithmeticMeanPax(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean veh", 3.0, stats.getArithmeticMeanVeh(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev coop", Double.NaN, stats.getStdDevOperators(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev route", Double.NaN, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev pax", Double.NaN, stats.getStdDevPax(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev veh", Double.NaN, stats.getStdDevVeh(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1.0, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON, "mean coop"); + Assertions.assertEquals(4.0, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON, "mean route"); + Assertions.assertEquals(2.0, stats.getArithmeticMeanPax(), MatsimTestUtils.EPSILON, "mean pax"); + Assertions.assertEquals(3.0, stats.getArithmeticMeanVeh(), MatsimTestUtils.EPSILON, "mean veh"); + Assertions.assertEquals(Double.NaN, stats.getStdDevOperators(), MatsimTestUtils.EPSILON, "std dev coop"); + Assertions.assertEquals(Double.NaN, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON, "std dev route"); + Assertions.assertEquals(Double.NaN, stats.getStdDevPax(), MatsimTestUtils.EPSILON, "std dev pax"); + Assertions.assertEquals(Double.NaN, stats.getStdDevVeh(), MatsimTestUtils.EPSILON, "std dev veh"); stats.handleNewEntry(2.0, 3.0, 3.0, 1.0); - Assert.assertEquals("mean coop", 1.5, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean route", 3.5, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean pax", 2.5, stats.getArithmeticMeanPax(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean veh", 2.0, stats.getArithmeticMeanVeh(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev coop", 0.7071067811865476, stats.getStdDevOperators(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev route", 0.7071067811865476, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev pax", 0.7071067811865476, stats.getStdDevPax(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev veh", 1.4142135623730951, stats.getStdDevVeh(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1.5, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON, "mean coop"); + Assertions.assertEquals(3.5, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON, "mean route"); + Assertions.assertEquals(2.5, stats.getArithmeticMeanPax(), MatsimTestUtils.EPSILON, "mean pax"); + Assertions.assertEquals(2.0, stats.getArithmeticMeanVeh(), MatsimTestUtils.EPSILON, "mean veh"); + Assertions.assertEquals(0.7071067811865476, stats.getStdDevOperators(), MatsimTestUtils.EPSILON, "std dev coop"); + Assertions.assertEquals(0.7071067811865476, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON, "std dev route"); + Assertions.assertEquals(0.7071067811865476, stats.getStdDevPax(), MatsimTestUtils.EPSILON, "std dev pax"); + Assertions.assertEquals(1.4142135623730951, stats.getStdDevVeh(), MatsimTestUtils.EPSILON, "std dev veh"); stats.handleNewEntry(3.0, 2.0, 1.0, 2.0); - Assert.assertEquals("mean coop", 2.0, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean route", 3.0, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean pax", 2.0, stats.getArithmeticMeanPax(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean veh", 2.0, stats.getArithmeticMeanVeh(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev coop", 1.0, stats.getStdDevOperators(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev route", 1.0, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev pax", 1.0, stats.getStdDevPax(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev veh", 1.0, stats.getStdDevVeh(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON, "mean coop"); + Assertions.assertEquals(3.0, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON, "mean route"); + Assertions.assertEquals(2.0, stats.getArithmeticMeanPax(), MatsimTestUtils.EPSILON, "mean pax"); + Assertions.assertEquals(2.0, stats.getArithmeticMeanVeh(), MatsimTestUtils.EPSILON, "mean veh"); + Assertions.assertEquals(1.0, stats.getStdDevOperators(), MatsimTestUtils.EPSILON, "std dev coop"); + Assertions.assertEquals(1.0, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON, "std dev route"); + Assertions.assertEquals(1.0, stats.getStdDevPax(), MatsimTestUtils.EPSILON, "std dev pax"); + Assertions.assertEquals(1.0, stats.getStdDevVeh(), MatsimTestUtils.EPSILON, "std dev veh"); stats.handleNewEntry(1.0, 4.0, 2.0, 3.0); stats.handleNewEntry(2.0, 3.0, 3.0, 1.0); stats.handleNewEntry(12.0, 12345.0, 123.0, 1234.0); - Assert.assertEquals("mean coop", 3.5, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean route", 2060.1666666666665, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean pax", 22.33333333333, stats.getArithmeticMeanPax(), MatsimTestUtils.EPSILON); - Assert.assertEquals("mean veh", 207.33333333333, stats.getArithmeticMeanVeh(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev coop", 4.230839160261236, stats.getStdDevOperators(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev route", 5038.518806818793, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev pax", 49.32207078648124, stats.getStdDevPax(), MatsimTestUtils.EPSILON); - Assert.assertEquals("std dev veh", 502.962689139728, stats.getStdDevVeh(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3.5, stats.getArithmeticMeanOperators(), MatsimTestUtils.EPSILON, "mean coop"); + Assertions.assertEquals(2060.1666666666665, stats.getArithmeticMeanRoutes(), MatsimTestUtils.EPSILON, "mean route"); + Assertions.assertEquals(22.33333333333, stats.getArithmeticMeanPax(), MatsimTestUtils.EPSILON, "mean pax"); + Assertions.assertEquals(207.33333333333, stats.getArithmeticMeanVeh(), MatsimTestUtils.EPSILON, "mean veh"); + Assertions.assertEquals(4.230839160261236, stats.getStdDevOperators(), MatsimTestUtils.EPSILON, "std dev coop"); + Assertions.assertEquals(5038.518806818793, stats.getStdDevRoutes(), MatsimTestUtils.EPSILON, "std dev route"); + Assertions.assertEquals(49.32207078648124, stats.getStdDevPax(), MatsimTestUtils.EPSILON, "std dev pax"); + Assertions.assertEquals(502.962689139728, stats.getStdDevVeh(), MatsimTestUtils.EPSILON, "std dev veh"); } } diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java index 158a897f8d9..995516bba38 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java @@ -25,8 +25,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -181,10 +181,10 @@ static void runSimpleScenario(int numberOfThreads) { controler.run(); // assume that the number of arrival events is correct - Assert.assertEquals(4, linkModeChecker.arrivalCount); + Assertions.assertEquals(4, linkModeChecker.arrivalCount); // assume that the number of link left events is correct - Assert.assertEquals(8, linkModeChecker.linkLeftCount); + Assertions.assertEquals(8, linkModeChecker.linkLeftCount); } @Ignore("Due to bugfixes in slow flowCap accumulation in QueueWithBuffer")//by michalm @@ -288,23 +288,16 @@ public void install() { int carCount = linkModeChecker.leftCountPerMode.get(TransportMode.car); int bikeCount = linkModeChecker.leftCountPerMode.get(TransportMode.bike); int walkCount = linkModeChecker.leftCountPerMode.get(TransportMode.walk); - Assert.assertEquals( - "unexpected number of link leave events for mode car with number of threads "+numberOfThreads, -// 513445, carCount); - 692259, carCount); - Assert.assertEquals( - "unexpected number of link leave events for mode bike with number of threads "+numberOfThreads, - 4577, bikeCount); - Assert.assertEquals( - "unexpected number of link leave events for mode walk with number of threads "+numberOfThreads, -// 5834, walkCount); - 7970, walkCount); + Assertions.assertEquals( + 692259, carCount, "unexpected number of link leave events for mode car with number of threads "+numberOfThreads); + Assertions.assertEquals( + 4577, bikeCount, "unexpected number of link leave events for mode bike with number of threads "+numberOfThreads); + Assertions.assertEquals( + 7970, walkCount, "unexpected number of link leave events for mode walk with number of threads "+numberOfThreads); // check the total number of link left events - Assert.assertEquals( - "unexpected total number of link leave events with number of threads "+numberOfThreads, -// 523856, linkModeChecker.linkLeftCount); - 704806, linkModeChecker.linkLeftCount); + Assertions.assertEquals( + 704806, linkModeChecker.linkLeftCount, "unexpected total number of link leave events with number of threads "+numberOfThreads); // check the total mode travel times double carTravelTime = linkModeChecker.travelTimesPerMode.get(TransportMode.car); @@ -314,23 +307,16 @@ public void install() { LogManager.getLogger( this.getClass() ).warn( "bikeTravelTime: " + bikeTravelTime ) ; LogManager.getLogger( this.getClass() ).warn( "walkTravelTime: " + walkTravelTime ) ; if ( !config.routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { - Assert.assertEquals( - "unexpected total travel time for car mode with number of threads "+numberOfThreads, - 1.1186864E8, carTravelTime, MatsimTestUtils.EPSILON); + Assertions.assertEquals( + 1.1186864E8, carTravelTime, MatsimTestUtils.EPSILON, "unexpected total travel time for car mode with number of threads "+numberOfThreads); } else { - Assert.assertEquals( - "unexpected total travel time for car mode with number of threads "+numberOfThreads, -// 5.7263255E7, carTravelTime, MatsimTestUtils.EPSILON); - 1.11881636E8, carTravelTime, MatsimTestUtils.EPSILON); + Assertions.assertEquals( + 1.11881636E8, carTravelTime, MatsimTestUtils.EPSILON, "unexpected total travel time for car mode with number of threads "+numberOfThreads); } - Assert.assertEquals( - "unexpected total travel time for bike mode with number of threads "+numberOfThreads, -// 480275.0, bikeTravelTime, MatsimTestUtils.EPSILON); - 480275.0, bikeTravelTime, MatsimTestUtils.EPSILON); - Assert.assertEquals( - "unexpected total travel time for walk mode with number of threads "+numberOfThreads, -// 3259757.0, walkTravelTime, MatsimTestUtils.EPSILON); - 3885025.0, walkTravelTime, MatsimTestUtils.EPSILON); + Assertions.assertEquals( + 480275.0, bikeTravelTime, MatsimTestUtils.EPSILON, "unexpected total travel time for bike mode with number of threads "+numberOfThreads); + Assertions.assertEquals( + 3885025.0, walkTravelTime, MatsimTestUtils.EPSILON, "unexpected total travel time for walk mode with number of threads "+numberOfThreads); } private static Person createPerson(Scenario scenario, String id, String mode) { @@ -416,7 +402,7 @@ public void handleEvent(LinkLeaveEvent event) { } // assume that the agent is allowed to travel on the link - Assert.assertEquals(true, link.getAllowedModes().contains(mode)); + Assertions.assertEquals(true, link.getAllowedModes().contains(mode)); if ( mode.contains(TransportMode.non_network_walk ) || mode.contains(TransportMode.non_network_walk ) ) { return ; diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalTripRouterTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalTripRouterTest.java index f7edb1a21c8..a939cb76327 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalTripRouterTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalTripRouterTest.java @@ -21,7 +21,7 @@ package org.matsim.contrib.multimodal; import com.google.inject.name.Names; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -200,7 +200,7 @@ private void checkRoute(Leg leg, Network network) { break; } } - Assert.assertTrue(validMode); + Assertions.assertTrue(validMode); } } diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/RunMultimodalExampleTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/RunMultimodalExampleTest.java index 7e2f7edc25f..3a3c2101c9a 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/RunMultimodalExampleTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/RunMultimodalExampleTest.java @@ -2,7 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.utils.io.IOUtils; @@ -27,7 +27,7 @@ void main(){ RunMultimodalExample.main( args ); } catch ( Exception ee ) { ee.printStackTrace(); - Assert.fail(); + Assertions.fail(); } } diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java index 3b224c976f0..ca3a78fce35 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -130,13 +130,13 @@ void testMultiModalPtCombination() { * "home-transit_walk-pt_interact-pt-pt_interact-transit_walk-home" */ Plan ptPlan = ptPerson.getSelectedPlan(); - Assert.assertEquals(ptPlan.getPlanElements().toString(), 7, ptPlan.getPlanElements().size()); + Assertions.assertEquals(7, ptPlan.getPlanElements().size(), ptPlan.getPlanElements().toString()); Plan walkPlan = walkPerson.getSelectedPlan(); if ( !config.routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { - Assert.assertEquals(walkPlan.getPlanElements().toString(), 7, walkPlan.getPlanElements().size()); + Assertions.assertEquals(7, walkPlan.getPlanElements().size(), walkPlan.getPlanElements().toString()); } else { - Assert.assertEquals(walkPlan.getPlanElements().toString(), 3, walkPlan.getPlanElements().size()); + Assertions.assertEquals(3, walkPlan.getPlanElements().size(), walkPlan.getPlanElements().toString()); } /* @@ -203,7 +203,7 @@ public void handleEvent(LinkLeaveEvent event) { } // assume that the agent is allowed to travel on the link - Assert.assertEquals(true, link.getAllowedModes().contains(this.modes.get(driverId))); + Assertions.assertEquals(true, link.getAllowedModes().contains(this.modes.get(driverId))); String mode = this.modes.get(driverId); int count = this.leftCountPerMode.get(mode); diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeTest.java index a8d88a3b193..c5a53f49b34 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeTest.java @@ -20,14 +20,14 @@ package org.matsim.contrib.multimodal.router.util; -import static org.junit.Assert.assertTrue; - import java.util.HashMap; import java.util.Map; import org.apache.logging.log4j.LogManager; + +import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -95,7 +95,7 @@ void testLinkTravelTimeCalculation() { expectedTravelTime = link.getLength() / speed; printInfo(person, expectedTravelTime, calculatedTravelTime, slope); assertTrue(Math.abs(expectedTravelTime - calculatedTravelTime) < MatsimTestUtils.EPSILON); - Assert.assertEquals(calculatedTravelTime - 0.09368418280727171, 0.0, 0); + Assertions.assertEquals(calculatedTravelTime - 0.09368418280727171, 0.0, 0); // increase age PersonUtils.setAge(person, 80); @@ -105,7 +105,7 @@ void testLinkTravelTimeCalculation() { expectedTravelTime = link.getLength() / speed; printInfo(person, expectedTravelTime, calculatedTravelTime, slope); assertTrue(Math.abs(expectedTravelTime - calculatedTravelTime) < MatsimTestUtils.EPSILON); - Assert.assertEquals(calculatedTravelTime - 0.2206463555843433, 0.0, 0); + Assertions.assertEquals(calculatedTravelTime - 0.2206463555843433, 0.0, 0); // change gender PersonUtils.setSex(person, "f"); @@ -115,7 +115,7 @@ void testLinkTravelTimeCalculation() { expectedTravelTime = link.getLength() / speed; printInfo(person, expectedTravelTime, calculatedTravelTime, slope); assertTrue(Math.abs(expectedTravelTime - calculatedTravelTime) < MatsimTestUtils.EPSILON); - Assert.assertEquals(calculatedTravelTime - 0.24496957588497956, 0.0, 0); + Assertions.assertEquals(calculatedTravelTime - 0.24496957588497956, 0.0, 0); // change slope from 0% to 10% h2 = 0.1; @@ -130,7 +130,7 @@ void testLinkTravelTimeCalculation() { expectedTravelTime = link.getLength() / speed; printInfo(person, expectedTravelTime, calculatedTravelTime, slope); assertTrue(Math.abs(expectedTravelTime - calculatedTravelTime) < MatsimTestUtils.EPSILON); - Assert.assertEquals(calculatedTravelTime - 0.7332007724445855, 0.0, 0); + Assertions.assertEquals(calculatedTravelTime - 0.7332007724445855, 0.0, 0); // change slope from 10% to -10% h2 = -0.1; @@ -145,7 +145,7 @@ void testLinkTravelTimeCalculation() { expectedTravelTime = link.getLength() / speed; printInfo(person, expectedTravelTime, calculatedTravelTime, slope); assertTrue(Math.abs(expectedTravelTime - calculatedTravelTime) < MatsimTestUtils.EPSILON); - Assert.assertEquals(calculatedTravelTime - 0.40547153706106515, 0.0, 0); + Assertions.assertEquals(calculatedTravelTime - 0.40547153706106515, 0.0, 0); // on very steep links bike speed should equals walk speed - set slope to 25% h2 = 0.25; @@ -158,7 +158,7 @@ void testLinkTravelTimeCalculation() { expectedTravelTime = walkTravelTime.getLinkTravelTime(link, 0.0, person, null); printInfo(person, expectedTravelTime, calculatedTravelTime, slope); assertTrue(Math.abs(expectedTravelTime - calculatedTravelTime) < MatsimTestUtils.EPSILON); - Assert.assertEquals(calculatedTravelTime - 1.7305194978040106, 0.0, 0); + Assertions.assertEquals(calculatedTravelTime - 1.7305194978040106, 0.0, 0); } private void printInfo(Person p, double expected, double calculated, double slope) { diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeTest.java index b5ec67bb8a5..2d5abb0fff1 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeTest.java @@ -20,14 +20,14 @@ package org.matsim.contrib.multimodal.router.util; -import static org.junit.Assert.assertTrue; - import java.util.HashMap; import java.util.Map; import org.apache.logging.log4j.LogManager; + +import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -92,7 +92,7 @@ void testLinkTravelTimeCalculation() { printInfo(person, expectedTravelTime, calculatedTravelTime, slope); assertTrue(Math.abs(expectedTravelTime - calculatedTravelTime) < MatsimTestUtils.EPSILON); - Assert.assertEquals(calculatedTravelTime - 0.42018055124753945, 0.0, 0); + Assertions.assertEquals(calculatedTravelTime - 0.42018055124753945, 0.0, 0); // increase age PersonUtils.setAge(person, 80); @@ -102,7 +102,7 @@ void testLinkTravelTimeCalculation() { expectedTravelTime = link.getLength() / speed; printInfo(person, expectedTravelTime, calculatedTravelTime, slope); assertTrue(Math.abs(expectedTravelTime - calculatedTravelTime) < MatsimTestUtils.EPSILON); - Assert.assertEquals(calculatedTravelTime - 0.9896153709417187, 0.0, 0); + Assertions.assertEquals(calculatedTravelTime - 0.9896153709417187, 0.0, 0); // change gender PersonUtils.setSex(person, "f"); @@ -112,7 +112,7 @@ void testLinkTravelTimeCalculation() { expectedTravelTime = link.getLength() / speed; printInfo(person, expectedTravelTime, calculatedTravelTime, slope); assertTrue(Math.abs(expectedTravelTime - calculatedTravelTime) < MatsimTestUtils.EPSILON); - Assert.assertEquals(calculatedTravelTime - 1.0987068291557665, 0.0, 0); + Assertions.assertEquals(calculatedTravelTime - 1.0987068291557665, 0.0, 0); // change slope from 0% to -10% h2 = -0.1; @@ -126,7 +126,7 @@ void testLinkTravelTimeCalculation() { expectedTravelTime = link.getLength() / speed; printInfo(person, expectedTravelTime, calculatedTravelTime, slope); assertTrue(Math.abs(expectedTravelTime - calculatedTravelTime) < MatsimTestUtils.EPSILON); - Assert.assertEquals(calculatedTravelTime - 1.0489849428640121, 0.0, 0); + Assertions.assertEquals(calculatedTravelTime - 1.0489849428640121, 0.0, 0); // change slope from -10% to 10% h2 = 0.1; @@ -139,7 +139,7 @@ void testLinkTravelTimeCalculation() { expectedTravelTime = link.getLength() / speed; printInfo(person, expectedTravelTime, calculatedTravelTime, slope); assertTrue(Math.abs(expectedTravelTime - calculatedTravelTime) < MatsimTestUtils.EPSILON); - Assert.assertEquals(calculatedTravelTime - 1.2397955643824945, 0.0, 0); + Assertions.assertEquals(calculatedTravelTime - 1.2397955643824945, 0.0, 0); } private void printInfo(Person p, double expected, double calculated, double slope) { diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java index 082b470276f..790922dd590 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -170,8 +170,8 @@ void testStuckEvents() { } } - Assert.assertEquals(2, stuckBeforeSimulationEnd); - Assert.assertEquals(4, stuckCnt); + Assertions.assertEquals(2, stuckBeforeSimulationEnd); + Assertions.assertEquals(4, stuckCnt); } private Person createPerson(Scenario scenario, String id, String mode, Route route, double departureTime) { diff --git a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseConfigGroupIT.java b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseConfigGroupIT.java index 2e28c957bdb..d5b61b0b590 100644 --- a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseConfigGroupIT.java +++ b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseConfigGroupIT.java @@ -22,7 +22,7 @@ */ package org.matsim.contrib.noise; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -53,22 +53,22 @@ final void test0(){ NoiseConfigGroup noiseParameters = (NoiseConfigGroup) config.getModule("noise"); // test the config parameters - Assert.assertEquals("wrong config parameter", 12345., noiseParameters.getReceiverPointGap(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(12345., noiseParameters.getReceiverPointGap(), MatsimTestUtils.EPSILON, "wrong config parameter"); String actForRecPtGrid = noiseParameters.getConsideredActivitiesForReceiverPointGridArray()[0] + "," + noiseParameters.getConsideredActivitiesForReceiverPointGridArray()[1] + "," + noiseParameters.getConsideredActivitiesForReceiverPointGridArray()[2]; - Assert.assertEquals("wrong config parameter", "home,sleep,eat", actForRecPtGrid); + Assertions.assertEquals("home,sleep,eat", actForRecPtGrid, "wrong config parameter"); String actForSpatFct = noiseParameters.getConsideredActivitiesForDamageCalculationArray()[0] + "," + noiseParameters.getConsideredActivitiesForDamageCalculationArray()[1] + "," + noiseParameters.getConsideredActivitiesForDamageCalculationArray()[2]; - Assert.assertEquals("wrong config parameter", "work,leisure,other", actForSpatFct); + Assertions.assertEquals("work,leisure,other", actForSpatFct, "wrong config parameter"); - Assert.assertEquals("wrong config parameter", 12345789., noiseParameters.getRelevantRadius(), MatsimTestUtils.EPSILON); - Assert.assertFalse("wrong config parameter", noiseParameters.isComputeNoiseDamages()); + Assertions.assertEquals(12345789., noiseParameters.getRelevantRadius(), MatsimTestUtils.EPSILON, "wrong config parameter"); + Assertions.assertFalse(noiseParameters.isComputeNoiseDamages(), "wrong config parameter"); String hgvIdPrefixes = noiseParameters.getHgvIdPrefixesArray()[0] + "," + noiseParameters.getHgvIdPrefixesArray()[1] + "," + noiseParameters.getHgvIdPrefixesArray()[2] + "," + noiseParameters.getHgvIdPrefixesArray()[3]; - Assert.assertEquals("wrong config parameter", "lkw,LKW,HGV,hgv", hgvIdPrefixes); + Assertions.assertEquals("lkw,LKW,HGV,hgv", hgvIdPrefixes, "wrong config parameter"); String tunnelLinkIds = noiseParameters.getTunnelLinkIDsSet().toArray()[0] + "," + noiseParameters.getTunnelLinkIDsSet().toArray()[1]; - Assert.assertEquals("wrong config parameter", "link1,link2", tunnelLinkIds); + Assertions.assertEquals("link1,link2", tunnelLinkIds, "wrong config parameter"); } @Test @@ -91,7 +91,7 @@ final void test1(){ Config outputConfig = ConfigUtils.loadConfig(controler.getConfig().controller().getOutputDirectory() + "/output_config.xml", new NoiseConfigGroup()); NoiseConfigGroup outputNoiseParameters = (NoiseConfigGroup) outputConfig.getModule("noise"); - Assert.assertEquals("input and output config parameters are not the same", noiseParameters.toString(), outputNoiseParameters.toString()); + Assertions.assertEquals(noiseParameters.toString(), outputNoiseParameters.toString(), "input and output config parameters are not the same"); } } diff --git a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java index 50b7321388a..e8aa97a3ab3 100644 --- a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java +++ b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java @@ -29,7 +29,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -106,17 +106,17 @@ final void test1(){ NoiseContext noiseContext = injector.getInstance( NoiseContext.class ) ; // test the grid of receiver points - Assert.assertEquals("wrong number of receiver points", 16, noiseContext.getReceiverPoints().size(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong coord for receiver point Id '10'", new Coord((double) 500, (double) 100).toString(), noiseContext.getReceiverPoints().get(Id.create(10, ReceiverPoint.class)).getCoord().toString()); + Assertions.assertEquals(16, noiseContext.getReceiverPoints().size(), MatsimTestUtils.EPSILON, "wrong number of receiver points"); + Assertions.assertEquals(new Coord((double) 500, (double) 100).toString(), noiseContext.getReceiverPoints().get(Id.create(10, ReceiverPoint.class)).getCoord().toString(), "wrong coord for receiver point Id '10'"); // test the allocation of activity coordinates to the nearest receiver point - Assert.assertEquals("wrong nearest receiver point Id for coord 300/300 (x/y)", "5", noiseContext.getGrid().getActivityCoord2receiverPointId().get(new Coord((double) 300, (double) 300)).toString()); - Assert.assertEquals("wrong nearest receiver point Id for coord 150/150 (x/y)", "9", noiseContext.getGrid().getActivityCoord2receiverPointId().get(new Coord((double) 150, (double) 150)).toString()); - Assert.assertEquals("wrong nearest receiver point Id for coord 100/100 (x/y)", "8", noiseContext.getGrid().getActivityCoord2receiverPointId().get(new Coord((double) 100, (double) 100)).toString()); - Assert.assertEquals("wrong nearest receiver point Id for coord 500/500 (x/y)", "2", noiseContext.getGrid().getActivityCoord2receiverPointId().get(new Coord((double) 500, (double) 500)).toString()); + Assertions.assertEquals("5", noiseContext.getGrid().getActivityCoord2receiverPointId().get(new Coord((double) 300, (double) 300)).toString(), "wrong nearest receiver point Id for coord 300/300 (x/y)"); + Assertions.assertEquals("9", noiseContext.getGrid().getActivityCoord2receiverPointId().get(new Coord((double) 150, (double) 150)).toString(), "wrong nearest receiver point Id for coord 150/150 (x/y)"); + Assertions.assertEquals("8", noiseContext.getGrid().getActivityCoord2receiverPointId().get(new Coord((double) 100, (double) 100)).toString(), "wrong nearest receiver point Id for coord 100/100 (x/y)"); + Assertions.assertEquals("2", noiseContext.getGrid().getActivityCoord2receiverPointId().get(new Coord((double) 500, (double) 500)).toString(), "wrong nearest receiver point Id for coord 500/500 (x/y)"); // test the allocation of relevant links to the receiver point - Assert.assertEquals("wrong relevant link for receiver point Id '15'", 3, noiseContext.getReceiverPoints().get(Id.create("15", Link.class)).getRelevantLinks().size()); + Assertions.assertEquals(3, noiseContext.getReceiverPoints().get(Id.create("15", Link.class)).getRelevantLinks().size(), "wrong relevant link for receiver point Id '15'"); // Assert.assertEquals("wrong relevant link for receiver point Id '15'", 3, noiseContext.getReceiverPoints().get(Id.create("15", Link.class)).getLinkId2angleCorrection().size()); // test the distance correction term @@ -406,7 +406,7 @@ else if(event.getActType().equals("work")){ double durationInThisIntervalMethod = actInfo.getDurationWithinInterval(currentTimeSlot, noiseParameters.getTimeBinSizeNoiseComputation()); - Assert.assertEquals("Durations of activities do not match!", durationInThisIntervalMethod, durationInThisInterval, MatsimTestUtils.EPSILON); + Assertions.assertEquals(durationInThisIntervalMethod, durationInThisInterval, MatsimTestUtils.EPSILON, "Durations of activities do not match!"); double unitsThisPersonActivityInfo = durationInThisInterval / noiseParameters.getTimeBinSizeNoiseComputation(); affectedPersons = ( unitsThisPersonActivityInfo * noiseParameters.getScaleFactor() ); @@ -442,17 +442,17 @@ else if(event.getActType().equals("work")){ if(currentTimeSlot == endTime){ if ( !runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("Wrong number of affected persons at receiver point 16", 2.3447222222222224, - affectedPersonsPerReceiverPointTest.get(Id.create("16", ReceiverPoint.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.3447222222222224, + affectedPersonsPerReceiverPointTest.get(Id.create("16", ReceiverPoint.class)), MatsimTestUtils.EPSILON, "Wrong number of affected persons at receiver point 16"); // result changed after changing where agents are walking to in access/egress (July 20) - Assert.assertEquals("Wrong number of affected persons at receiver point 0", 0.479722222222222, - affectedPersonsPerReceiverPointTest.get(Id.create("0", ReceiverPoint.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.479722222222222, + affectedPersonsPerReceiverPointTest.get(Id.create("0", ReceiverPoint.class)), MatsimTestUtils.EPSILON, "Wrong number of affected persons at receiver point 0"); } else { - Assert.assertEquals("Wrong number of affected persons at receiver point 16", 2.35305555555555, - affectedPersonsPerReceiverPointTest.get(Id.create("16", ReceiverPoint.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong number of affected persons at receiver point 0", 0.479722222222222, - affectedPersonsPerReceiverPointTest.get(Id.create("0", ReceiverPoint.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.35305555555555, + affectedPersonsPerReceiverPointTest.get(Id.create("16", ReceiverPoint.class)), MatsimTestUtils.EPSILON, "Wrong number of affected persons at receiver point 16"); + Assertions.assertEquals(0.479722222222222, + affectedPersonsPerReceiverPointTest.get(Id.create("0", ReceiverPoint.class)), MatsimTestUtils.EPSILON, "Wrong number of affected persons at receiver point 0"); } } @@ -475,9 +475,9 @@ else if(event.getActType().equals("work")){ log.warn( "affected:" + list ) ; } if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("Wrong number of affected persons", expected, actual, MatsimTestUtils.EPSILON); + Assertions.assertEquals(expected, actual, MatsimTestUtils.EPSILON, "Wrong number of affected persons"); } else { - Assert.assertEquals("Wrong number of affected persons", expected, actual, MatsimTestUtils.EPSILON); + Assertions.assertEquals(expected, actual, MatsimTestUtils.EPSILON, "Wrong number of affected persons"); } } @@ -562,14 +562,14 @@ else if(event.getActType().equals("work")){ double Dv = RLS90NoiseEmission.calculateGeschwindigkeitskorrekturDv(vCar, vHdv, p); double noiseEmission = mittelungspegel + Dv; - Assert.assertEquals("Wrong amount of emission!", noiseEmission, emissionsPerLink.get(linkId), MatsimTestUtils.EPSILON); + Assertions.assertEquals(noiseEmission, emissionsPerLink.get(linkId), MatsimTestUtils.EPSILON, "Wrong amount of emission!"); noiseEmissionsPerLink.put(linkId, noiseEmission); } - Assert.assertEquals("Wrong amount of emission!", 56.4418948379387, noiseEmissionsPerLink.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong amount of emission!", 86.4302864851097, noiseEmissionsPerLink.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong amount of emission!", 0., noiseEmissionsPerLink.get(Id.create("link4", Link.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(56.4418948379387, noiseEmissionsPerLink.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON, "Wrong amount of emission!"); + Assertions.assertEquals(86.4302864851097, noiseEmissionsPerLink.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON, "Wrong amount of emission!"); + Assertions.assertEquals(0., noiseEmissionsPerLink.get(Id.create("link4", Link.class)), MatsimTestUtils.EPSILON, "Wrong amount of emission!"); // ############################################ @@ -631,13 +631,13 @@ else if(event.getActType().equals("work")){ } - Assert.assertEquals("Wrong amount of immission!", rls90NoiseImmission.calculateResultingNoiseImmission(linkId2IsolatedImmission.values()), immissionPerReceiverPointId.get(rp.getId()), MatsimTestUtils.EPSILON); + Assertions.assertEquals(rls90NoiseImmission.calculateResultingNoiseImmission(linkId2IsolatedImmission.values()), immissionPerReceiverPointId.get(rp.getId()), MatsimTestUtils.EPSILON, "Wrong amount of immission!"); } - Assert.assertEquals("Wrong amount of immission!", 77.25915342419277, immissionPerReceiverPointId.get(Id.create("15", ReceiverPoint.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong amount of immission!", 67.9561670074151, immissionPerReceiverPointId.get(Id.create("31", ReceiverPoint.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong amount of immission!", 0., immissionPerReceiverPointId.get(Id.create("0", ReceiverPoint.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(77.25915342419277, immissionPerReceiverPointId.get(Id.create("15", ReceiverPoint.class)), MatsimTestUtils.EPSILON, "Wrong amount of immission!"); + Assertions.assertEquals(67.9561670074151, immissionPerReceiverPointId.get(Id.create("31", ReceiverPoint.class)), MatsimTestUtils.EPSILON, "Wrong amount of immission!"); + Assertions.assertEquals(0., immissionPerReceiverPointId.get(Id.create("0", ReceiverPoint.class)), MatsimTestUtils.EPSILON, "Wrong amount of immission!"); // ############################################ // test damages per receiver point and time @@ -681,19 +681,19 @@ else if(event.getActType().equals("work")){ double noiseImmission = immissionPerReceiverPointId.get(rp.getId()); double affectedAgentUnits = consideredAgentsPerReceiverPoint.get(rp.getId()).get(1); - Assert.assertEquals("Wrong damage!", NoiseDamageCalculation.calculateDamageCosts(noiseImmission, affectedAgentUnits, endTime, noiseParameters.getAnnualCostRate(), noiseParameters.getTimeBinSizeNoiseComputation()), damagesPerReceiverPointId.get(rp.getId()), MatsimTestUtils.EPSILON); + Assertions.assertEquals(NoiseDamageCalculation.calculateDamageCosts(noiseImmission, affectedAgentUnits, endTime, noiseParameters.getAnnualCostRate(), noiseParameters.getTimeBinSizeNoiseComputation()), damagesPerReceiverPointId.get(rp.getId()), MatsimTestUtils.EPSILON, "Wrong damage!"); } if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("Wrong damage!", 0.0664164095284536, - damagesPerReceiverPointId.get(Id.create("16", ReceiverPoint.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0664164095284536, + damagesPerReceiverPointId.get(Id.create("16", ReceiverPoint.class)), MatsimTestUtils.EPSILON, "Wrong damage!"); } else { - Assert.assertEquals("Wrong damage!", 0.06618119616706872 , - damagesPerReceiverPointId.get(Id.create("16", ReceiverPoint.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.06618119616706872 , + damagesPerReceiverPointId.get(Id.create("16", ReceiverPoint.class)), MatsimTestUtils.EPSILON, "Wrong damage!"); // result changed after changing walk distances } - Assert.assertEquals("Wrong damage!", 0., damagesPerReceiverPointId.get(Id.create("0", ReceiverPoint.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0., damagesPerReceiverPointId.get(Id.create("0", ReceiverPoint.class)), MatsimTestUtils.EPSILON, "Wrong damage!"); // ############################################ // test average damages per link and time @@ -740,17 +740,17 @@ else if(event.getActType().equals("work")){ } if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("Wrong link's damage contribution!", 0.00079854651258, - damagesPerlinkId.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong link's damage contribution!", 0.06561786301587, - damagesPerlinkId.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.00079854651258, + damagesPerlinkId.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON, "Wrong link's damage contribution!"); + Assertions.assertEquals(0.06561786301587, + damagesPerlinkId.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON, "Wrong link's damage contribution!"); } else { - Assert.assertEquals("Wrong link's damage contribution!", 7.957184286235844E-4, - damagesPerlinkId.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong link's damage contribution!", 0.06538547773844494, - damagesPerlinkId.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(7.957184286235844E-4, + damagesPerlinkId.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON, "Wrong link's damage contribution!"); + Assertions.assertEquals(0.06538547773844494, + damagesPerlinkId.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON, "Wrong link's damage contribution!"); } - Assert.assertEquals("Wrong link's damage contribution!", 0., damagesPerlinkId.get(Id.create("linkB5", Link.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0., damagesPerlinkId.get(Id.create("linkB5", Link.class)), MatsimTestUtils.EPSILON, "Wrong link's damage contribution!"); // ############################################ // test average damages per link, car and time @@ -790,18 +790,18 @@ else if(event.getActType().equals("work")){ } if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("Wrong damage per car per link!", 0.00079854651258 / 2.0, - damagesPerCar.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong damage per car per link!", 0.06561786301587 / 2.0, - damagesPerCar.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.00079854651258 / 2.0, + damagesPerCar.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON, "Wrong damage per car per link!"); + Assertions.assertEquals(0.06561786301587 / 2.0, + damagesPerCar.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON, "Wrong damage per car per link!"); } else { - Assert.assertEquals("Wrong damage per car per link!", 3.978592143117922E-4, - damagesPerCar.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong damage per car per link!", 0.03269273886922247, - damagesPerCar.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3.978592143117922E-4, + damagesPerCar.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON, "Wrong damage per car per link!"); + Assertions.assertEquals(0.03269273886922247, + damagesPerCar.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON, "Wrong damage per car per link!"); } - Assert.assertEquals("Wrong damage per car per link!", 0., - damagesPerCar.get(Id.create("linkB5", Link.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0., + damagesPerCar.get(Id.create("linkB5", Link.class)), MatsimTestUtils.EPSILON, "Wrong damage per car per link!"); line = null; @@ -837,19 +837,19 @@ else if(event.getActType().equals("work")){ } if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("Wrong damage per car per link!", 0.00011994155845965193, - marginaldamagesPerCar.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong damage per car per link!", 0.008531432493391652, - marginaldamagesPerCar.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong damage per car per link!", 3.440988380343235E-8, - marginaldamagesPerCar.get(Id.create("linkB5", Link.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.00011994155845965193, + marginaldamagesPerCar.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON, "Wrong damage per car per link!"); + Assertions.assertEquals(0.008531432493391652, + marginaldamagesPerCar.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON, "Wrong damage per car per link!"); + Assertions.assertEquals(3.440988380343235E-8, + marginaldamagesPerCar.get(Id.create("linkB5", Link.class)), MatsimTestUtils.EPSILON, "Wrong damage per car per link!"); } else { - Assert.assertEquals("Wrong damage per car per link!", 1.1951678071236982E-4, - marginaldamagesPerCar.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong damage per car per link!", 0.008501218474617364, - marginaldamagesPerCar.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong damage per car per link!", 3.428802136662412E-8, - marginaldamagesPerCar.get(Id.create("linkB5", Link.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1.1951678071236982E-4, + marginaldamagesPerCar.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON, "Wrong damage per car per link!"); + Assertions.assertEquals(0.008501218474617364, + marginaldamagesPerCar.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON, "Wrong damage per car per link!"); + Assertions.assertEquals(3.428802136662412E-8, + marginaldamagesPerCar.get(Id.create("linkB5", Link.class)), MatsimTestUtils.EPSILON, "Wrong damage per car per link!"); } // ############################################ @@ -863,47 +863,47 @@ else if(event.getActType().equals("work")){ if (event.getTimeBinEndTime() == 11 * 3600. && event.getLinkId().toString().equals(Id.create("linkA5", Link.class).toString()) && event.getCausingVehicleId().toString().equals((Id.create("person_car_test1", Vehicle.class).toString()))) { if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.0328089315079348, - event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0328089315079348, + event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); } else { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.03269273886922247, - event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.03269273886922247, + event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); } counter++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getLinkId().toString().equals(Id.create("linkA5", Link.class).toString()) && event.getCausingVehicleId().toString().equals((Id.create("person_car_test2", Vehicle.class).toString()))) { if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.0328089315079348, - event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0328089315079348, + event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); } else { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.03269273886922247, - event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.03269273886922247, + event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); } counter++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getLinkId().toString().equals(Id.create("link2", Link.class).toString()) && event.getCausingVehicleId().toString().equals((Id.create("person_car_test1", Vehicle.class).toString()))) { if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 3.992732562920194E-4, - event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3.992732562920194E-4, + event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); } else { - Assert.assertEquals("wrong cost per car for the given link and time interval", 3.978592143117922E-4, - event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3.978592143117922E-4, + event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); } counter++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getLinkId().toString().equals(Id.create("link2", Link.class).toString()) && event.getCausingVehicleId().toString().equals((Id.create("person_car_test2", Vehicle.class).toString()))) { if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 3.992732562920194E-4, - event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3.992732562920194E-4, + event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); } else { - Assert.assertEquals("wrong cost per car for the given link and time interval", 3.978592143117922E-4, - event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3.978592143117922E-4, + event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); } counter++; } else { log.warn(event.toString()); - Assert.assertEquals("There should either be no further events, or the amount should be zero.", 0., event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0., event.getAmount(), MatsimTestUtils.EPSILON, "There should either be no further events, or the amount should be zero."); } } - Assert.assertTrue("No event found to be tested.", tested); - Assert.assertEquals("Wrong number of total events.", 4, counter, MatsimTestUtils.EPSILON); + Assertions.assertTrue(tested, "No event found to be tested."); + Assertions.assertEquals(4, counter, MatsimTestUtils.EPSILON, "Wrong number of total events."); boolean tested2 = false; int counter2 = 0; @@ -912,38 +912,38 @@ else if(event.getActType().equals("work")){ if (event.getTimeBinEndTime() == 11 * 3600. && event.getrReceiverPointId().toString().equals(Id.create("16", ReceiverPoint.class).toString()) && event.getAffectedAgentId().toString().equals((Id.create("person_car_test1", Person.class).toString())) && event.getActType().equals("work") ) { if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.020745817449213576, - event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.020745817449213576, + event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); } else { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.02062821077070937, - event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.02062821077070937, + event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); } counter2++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getrReceiverPointId().toString().equals(Id.create("16", ReceiverPoint.class).toString()) && event.getAffectedAgentId().toString().equals((Id.create("person_car_test2", Person.class).toString())) && event.getActType().equals("work")) { if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.017444990107520864, - event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.017444990107520864, + event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); } else { - Assert.assertEquals("wrong cost per car for the given link and time interval",0.017327383429596242, - event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.017327383429596242, + event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); } counter2++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getrReceiverPointId().toString().equals(Id.create("16", ReceiverPoint.class).toString()) && event.getAffectedAgentId().toString().equals((Id.create("person_car_test3", Person.class).toString())) && event.getActType().equals("home")) { if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.028225601971719153, - event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.028225601971719153, + event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); } else { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.028225601971719153, - event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.028225601971719153, + event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); } counter2++; } else { - Assert.assertEquals("There should either be no further events, or the amount should be zero.", 0., event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0., event.getAmount(), MatsimTestUtils.EPSILON, "There should either be no further events, or the amount should be zero."); } } - Assert.assertTrue("No event found to be tested.", tested2); - Assert.assertEquals("Wrong number of total events.", 3, counter2, MatsimTestUtils.EPSILON); + Assertions.assertTrue(tested2, "No event found to be tested."); + Assertions.assertEquals(3, counter2, MatsimTestUtils.EPSILON, "Wrong number of total events."); } @@ -1004,23 +1004,23 @@ final void test2b(){ tested = true; if (event.getTimeBinEndTime() == 11 * 3600. && event.getLinkId().toString().equals(Id.create("linkA5", Link.class).toString()) && event.getCausingVehicleId().toString().equals((Id.create("person_car_test1", Vehicle.class).toString()))) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.008531432493391652, event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.008531432493391652, event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); counter++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getLinkId().toString().equals(Id.create("linkA5", Link.class).toString()) && event.getCausingVehicleId().toString().equals((Id.create("person_car_test2", Vehicle.class).toString()))) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.008531432493391652, event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.008531432493391652, event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); counter++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getLinkId().toString().equals(Id.create("link2", Link.class).toString()) && event.getCausingVehicleId().toString().equals((Id.create("person_car_test1", Vehicle.class).toString()))) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.00011994155845965193, event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.00011994155845965193, event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); counter++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getLinkId().toString().equals(Id.create("link2", Link.class).toString()) && event.getCausingVehicleId().toString().equals((Id.create("person_car_test2", Vehicle.class).toString()))) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.00011994155845965193, event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.00011994155845965193, event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); counter++; } else { - Assert.assertEquals("There should either be no further events, or the amount should be zero.", 0., event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0., event.getAmount(), MatsimTestUtils.EPSILON, "There should either be no further events, or the amount should be zero."); } } - Assert.assertTrue("No event found to be tested.", tested); - Assert.assertEquals("Wrong number of total events.", 4, counter, MatsimTestUtils.EPSILON); + Assertions.assertTrue(tested, "No event found to be tested."); + Assertions.assertEquals(4, counter, MatsimTestUtils.EPSILON, "Wrong number of total events."); boolean tested2 = false; int counter2 = 0; @@ -1028,21 +1028,21 @@ final void test2b(){ tested2 = true; if (event.getTimeBinEndTime() == 11 * 3600. && event.getrReceiverPointId().toString().equals(Id.create("16", ReceiverPoint.class).toString()) && event.getAffectedAgentId().toString().equals((Id.create("person_car_test1", Person.class).toString())) && event.getActType().equals("work") ) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.020745817449213576, event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.020745817449213576, event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); counter2++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getrReceiverPointId().toString().equals(Id.create("16", ReceiverPoint.class).toString()) && event.getAffectedAgentId().toString().equals((Id.create("person_car_test2", Person.class).toString())) && event.getActType().equals("work")) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.017444990107520864, event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.017444990107520864, event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); counter2++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getrReceiverPointId().toString().equals(Id.create("16", ReceiverPoint.class).toString()) && event.getAffectedAgentId().toString().equals((Id.create("person_car_test3", Person.class).toString())) && event.getActType().equals("home")) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.028225601971719153, event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.028225601971719153, event.getAmount(), MatsimTestUtils.EPSILON, "wrong cost per car for the given link and time interval"); counter2++; } else { - Assert.assertEquals("There should either be no further events, or the amount should be zero.", 0., event.getAmount(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0., event.getAmount(), MatsimTestUtils.EPSILON, "There should either be no further events, or the amount should be zero."); } } - Assert.assertTrue("No event found to be tested.", tested2); - Assert.assertEquals("Wrong number of total events.", 3, counter2, MatsimTestUtils.EPSILON); + Assertions.assertTrue(tested2, "No event found to be tested."); + Assertions.assertEquals(3, counter2, MatsimTestUtils.EPSILON, "Wrong number of total events."); } @@ -1164,9 +1164,9 @@ public void handleEvent(ActivityEndEvent event) { } - Assert.assertEquals("Wrong amount of emission!", 56.4418948379387, emissionsPerLink.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong amount of emission!", 77.3994680630406, emissionsPerLink.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong amount of emission!", 0., emissionsPerLink.get(Id.create("link4", Link.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(56.4418948379387, emissionsPerLink.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON, "Wrong amount of emission!"); + Assertions.assertEquals(77.3994680630406, emissionsPerLink.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON, "Wrong amount of emission!"); + Assertions.assertEquals(0., emissionsPerLink.get(Id.create("link4", Link.class)), MatsimTestUtils.EPSILON, "Wrong amount of emission!"); } catch (IOException e) { e.printStackTrace(); @@ -1189,12 +1189,12 @@ final void test3(){ double expectedEcar = 37.2424250943932; double expectedEhgv = 48.1; - Assert.assertEquals("Error in deviation term for speed correction (car)", expectedEcar, eCar, MatsimTestUtils.EPSILON); - Assert.assertEquals("Error in deviation term for speed correction (car)", expectedEcar, RLS90NoiseEmission.calculateLCar(vCar), MatsimTestUtils.EPSILON); - Assert.assertEquals("Error in deviation term for speed correction (hgv)", expectedEhgv, eHgv, MatsimTestUtils.EPSILON); - Assert.assertEquals("Error in deviation term for speed correction (hgv)", expectedEhgv, RLS90NoiseEmission.calculateLHdv(vHgv), MatsimTestUtils.EPSILON); + Assertions.assertEquals(expectedEcar, eCar, MatsimTestUtils.EPSILON, "Error in deviation term for speed correction (car)"); + Assertions.assertEquals(expectedEcar, RLS90NoiseEmission.calculateLCar(vCar), MatsimTestUtils.EPSILON, "Error in deviation term for speed correction (car)"); + Assertions.assertEquals(expectedEhgv, eHgv, MatsimTestUtils.EPSILON, "Error in deviation term for speed correction (hgv)"); + Assertions.assertEquals(expectedEhgv, RLS90NoiseEmission.calculateLHdv(vHgv), MatsimTestUtils.EPSILON, "Error in deviation term for speed correction (hgv)"); - Assert.assertTrue("Error in deviation term for speed correction (eCar > eHgv)", eCar < eHgv); + Assertions.assertTrue(eCar < eHgv, "Error in deviation term for speed correction (eCar > eHgv)"); // test mittelungspegel and speed correction @@ -1230,8 +1230,8 @@ else if( nHgvs == 2){ } } - Assert.assertEquals("Error while calculating Mittelungspegel for " + nCars + " car(s) and " + nHgvs + " hgv(s)!", expectedMittelungspegel, mittelungspegel, MatsimTestUtils.EPSILON); - Assert.assertEquals("Error while calculating Mittelungspegel for " + nCars + " car(s) and " + nHgvs + " hgv(s)!", expectedMittelungspegel, RLS90NoiseEmission.calculateMittelungspegelLm(n, p), MatsimTestUtils.EPSILON); + Assertions.assertEquals(expectedMittelungspegel, mittelungspegel, MatsimTestUtils.EPSILON, "Error while calculating Mittelungspegel for " + nCars + " car(s) and " + nHgvs + " hgv(s)!"); + Assertions.assertEquals(expectedMittelungspegel, RLS90NoiseEmission.calculateMittelungspegelLm(n, p), MatsimTestUtils.EPSILON, "Error while calculating Mittelungspegel for " + nCars + " car(s) and " + nHgvs + " hgv(s)!"); //test speed correction double speedCorrection = expectedEcar - 37.3 + 10 * Math.log10( (100 + ( Math.pow(10, 0.1*(expectedEhgv - expectedEcar)) - 1 ) * pInPercent ) / (100 + 8.23*pInPercent) ); @@ -1243,8 +1243,8 @@ else if( nHgvs == 2){ else if(p == 2./3.) expectedSpeedCorrection = 1.09354779994927; else if( p == 1) expectedSpeedCorrection = 1.14798298974089; - Assert.assertEquals("Error while calculating speed correction term for p = " + p + "!", expectedSpeedCorrection, speedCorrection, MatsimTestUtils.EPSILON); - Assert.assertEquals("Error while calculating speed correction term for p = " + p + "!", expectedSpeedCorrection, RLS90NoiseEmission.calculateGeschwindigkeitskorrekturDv(vCar, vHgv, p), MatsimTestUtils.EPSILON); + Assertions.assertEquals(expectedSpeedCorrection, speedCorrection, MatsimTestUtils.EPSILON, "Error while calculating speed correction term for p = " + p + "!"); + Assertions.assertEquals(expectedSpeedCorrection, RLS90NoiseEmission.calculateGeschwindigkeitskorrekturDv(vCar, vHgv, p), MatsimTestUtils.EPSILON, "Error while calculating speed correction term for p = " + p + "!"); } @@ -1262,8 +1262,8 @@ else if( nHgvs == 2){ else if(distance == 95) expectedDistanceCorrection = -4.8327746143211; else if(distance == 140) expectedDistanceCorrection = -6.87412053759382; - Assert.assertEquals("Error while calculating distance correction term!", expectedDistanceCorrection, distanceCorrection, MatsimTestUtils.EPSILON); - Assert.assertEquals("Error while calculating distance correction term!", expectedDistanceCorrection, RLS90NoiseImmission.calculateDistanceCorrection(distance), MatsimTestUtils.EPSILON); + Assertions.assertEquals(expectedDistanceCorrection, distanceCorrection, MatsimTestUtils.EPSILON, "Error while calculating distance correction term!"); + Assertions.assertEquals(expectedDistanceCorrection, RLS90NoiseImmission.calculateDistanceCorrection(distance), MatsimTestUtils.EPSILON, "Error while calculating distance correction term!"); } @@ -1283,8 +1283,8 @@ else if( nHgvs == 2){ else if(angle == 315) expectedAngleCorrection = 2.43038048686294; else if(angle == 360) expectedAngleCorrection = 3.01029995663981; - Assert.assertEquals("Error while calculating angle correction term!", expectedAngleCorrection, angleCorrection, MatsimTestUtils.EPSILON); - Assert.assertEquals("Error while calculating angle correction term!", expectedAngleCorrection, RLS90NoiseImmission.calculateAngleCorrection(angle), MatsimTestUtils.EPSILON); + Assertions.assertEquals(expectedAngleCorrection, angleCorrection, MatsimTestUtils.EPSILON, "Error while calculating angle correction term!"); + Assertions.assertEquals(expectedAngleCorrection, RLS90NoiseImmission.calculateAngleCorrection(angle), MatsimTestUtils.EPSILON, "Error while calculating angle correction term!"); } @@ -1326,7 +1326,7 @@ else if( nHgvs == 2){ double resultingNoiseImmission = 10*Math.log10(tmp); double expectedResultingNoiseImmission = 41.279204220881; - Assert.assertEquals("Error in noise immission calculation!", expectedResultingNoiseImmission, resultingNoiseImmission, MatsimTestUtils.EPSILON); + Assertions.assertEquals(expectedResultingNoiseImmission, resultingNoiseImmission, MatsimTestUtils.EPSILON, "Error in noise immission calculation!"); double resultingNoiseImmission1 = 0.; if (((Collection) immissions).size() > 0) { @@ -1341,7 +1341,7 @@ else if( nHgvs == 2){ resultingNoiseImmission1 = 0.; } } - Assert.assertEquals("Error in noise immission calculation!", expectedResultingNoiseImmission, resultingNoiseImmission1, MatsimTestUtils.EPSILON); + Assertions.assertEquals(expectedResultingNoiseImmission, resultingNoiseImmission1, MatsimTestUtils.EPSILON, "Error in noise immission calculation!"); //test noise damage double annualCostRate = (85.0/(1.95583)) * (Math.pow(1.02, (2014-1995))); @@ -1360,12 +1360,12 @@ else if( nHgvs == 2){ double expectedCostsEvening = 0.; double expectedCostsNight = 0.031590380365211; - Assert.assertEquals("Error in damage calculation!", expectedCostsDay, costsDay , MatsimTestUtils.EPSILON); - Assert.assertEquals("Error in damage calculation!", expectedCostsDay, NoiseDamageCalculation.calculateDamageCosts(resultingNoiseImmission, nPersons, 7.*3600, annualCostRate, 3600.) , MatsimTestUtils.EPSILON); - Assert.assertEquals("Error in damage calculation!", expectedCostsEvening, costsEvening, MatsimTestUtils.EPSILON); - Assert.assertEquals("Error in damage calculation!", expectedCostsEvening, NoiseDamageCalculation.calculateDamageCosts(resultingNoiseImmission, nPersons, 19.*3600, annualCostRate, 3600.), MatsimTestUtils.EPSILON); - Assert.assertEquals("Error in damage calculation!", expectedCostsNight, costsNight, MatsimTestUtils.EPSILON); - Assert.assertEquals("Error in damage calculation!", expectedCostsNight, NoiseDamageCalculation.calculateDamageCosts(resultingNoiseImmission, nPersons, 23.*3600, annualCostRate, 3600.), MatsimTestUtils.EPSILON); + Assertions.assertEquals(expectedCostsDay, costsDay , MatsimTestUtils.EPSILON, "Error in damage calculation!"); + Assertions.assertEquals(expectedCostsDay, NoiseDamageCalculation.calculateDamageCosts(resultingNoiseImmission, nPersons, 7.*3600, annualCostRate, 3600.) , MatsimTestUtils.EPSILON, "Error in damage calculation!"); + Assertions.assertEquals(expectedCostsEvening, costsEvening, MatsimTestUtils.EPSILON, "Error in damage calculation!"); + Assertions.assertEquals(expectedCostsEvening, NoiseDamageCalculation.calculateDamageCosts(resultingNoiseImmission, nPersons, 19.*3600, annualCostRate, 3600.), MatsimTestUtils.EPSILON, "Error in damage calculation!"); + Assertions.assertEquals(expectedCostsNight, costsNight, MatsimTestUtils.EPSILON, "Error in damage calculation!"); + Assertions.assertEquals(expectedCostsNight, NoiseDamageCalculation.calculateDamageCosts(resultingNoiseImmission, nPersons, 23.*3600, annualCostRate, 3600.), MatsimTestUtils.EPSILON, "Error in damage calculation!"); } // tests the static methods within class "noiseEquations" @@ -1382,19 +1382,19 @@ final void test4(){ double p = ( (double) nHGV / (double) (nCar + nHGV)); double mittelungspegel = RLS90NoiseEmission.calculateMittelungspegelLm(n, p); - Assert.assertEquals("Wrong mittelungspegel for n="+ n + " and p=" + p + "!", 69.22567453336540, mittelungspegel, MatsimTestUtils.EPSILON); + Assertions.assertEquals(69.22567453336540, mittelungspegel, MatsimTestUtils.EPSILON, "Wrong mittelungspegel for n="+ n + " and p=" + p + "!"); double lCar = RLS90NoiseEmission.calculateLCar(vCar); - Assert.assertEquals("Wrong LCar for vCar="+ vCar + "!", 27.70000000425900, lCar, MatsimTestUtils.EPSILON); + Assertions.assertEquals(27.70000000425900, lCar, MatsimTestUtils.EPSILON, "Wrong LCar for vCar="+ vCar + "!"); double lHGV = RLS90NoiseEmission.calculateLHdv(vHGV); - Assert.assertEquals("Wrong LHGV for vHGV="+ vHGV + "!", 6.60145932205085, lHGV, MatsimTestUtils.EPSILON); + Assertions.assertEquals(6.60145932205085, lHGV, MatsimTestUtils.EPSILON, "Wrong LHGV for vHGV="+ vHGV + "!"); double dV = RLS90NoiseEmission.calculateGeschwindigkeitskorrekturDv(vCar, vHGV, p); - Assert.assertEquals("Wrong Dv!", -10.772415234056300, dV, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-10.772415234056300, dV, MatsimTestUtils.EPSILON, "Wrong Dv!"); double emission = mittelungspegel + dV; - Assert.assertEquals("Wrong emission!", 58.453259299309124, emission, MatsimTestUtils.EPSILON); + Assertions.assertEquals(58.453259299309124, emission, MatsimTestUtils.EPSILON, "Wrong emission!"); // plus one car @@ -1403,7 +1403,7 @@ final void test4(){ double mittelungspegelPlusOneCar = RLS90NoiseEmission.calculateMittelungspegelLm(nPlusOneCar, pPlusOneCar); double dVPlusOneCar = RLS90NoiseEmission.calculateGeschwindigkeitskorrekturDv(vCar, vHGV, pPlusOneCar); double emissionPlusOneCar = mittelungspegelPlusOneCar + dVPlusOneCar; - Assert.assertEquals("Wrong emission!", 58.4896140186478, emissionPlusOneCar, MatsimTestUtils.EPSILON); + Assertions.assertEquals(58.4896140186478, emissionPlusOneCar, MatsimTestUtils.EPSILON, "Wrong emission!"); // plus one HGV @@ -1412,7 +1412,7 @@ final void test4(){ double mittelungspegelPlusOneHGV = RLS90NoiseEmission.calculateMittelungspegelLm(nPlusOneHGV, pPlusOneHGV); double dVPlusOneHGV = RLS90NoiseEmission.calculateGeschwindigkeitskorrekturDv(vCar, vHGV, pPlusOneHGV); double emissionPlusOneHGV = mittelungspegelPlusOneHGV + dVPlusOneHGV; - Assert.assertEquals("Wrong emission!", 58.4529399949061, emissionPlusOneHGV, MatsimTestUtils.EPSILON); + Assertions.assertEquals(58.4529399949061, emissionPlusOneHGV, MatsimTestUtils.EPSILON, "Wrong emission!"); } @@ -1430,19 +1430,19 @@ final void test5(){ double p = ( (double) nHGV / (double) (nCar + nHGV)); double mittelungspegel = RLS90NoiseEmission.calculateMittelungspegelLm(n, p); - Assert.assertEquals("Wrong mittelungspegel for n="+ n + " and p=" + p + "!", 69.22567453336540, mittelungspegel, MatsimTestUtils.EPSILON); + Assertions.assertEquals(69.22567453336540, mittelungspegel, MatsimTestUtils.EPSILON, "Wrong mittelungspegel for n="+ n + " and p=" + p + "!"); double lCar = RLS90NoiseEmission.calculateLCar(vCar); - Assert.assertEquals("Wrong LCar for vCar="+ vCar + "!", 28.54933574936720, lCar, MatsimTestUtils.EPSILON); + Assertions.assertEquals(28.54933574936720, lCar, MatsimTestUtils.EPSILON, "Wrong LCar for vCar="+ vCar + "!"); double lHGV = RLS90NoiseEmission.calculateLHdv(vHGV); - Assert.assertEquals("Wrong LHGV for vHGV="+ vHGV + "!", 41.56401568399580, lHGV, MatsimTestUtils.EPSILON); + Assertions.assertEquals(41.56401568399580, lHGV, MatsimTestUtils.EPSILON, "Wrong LHGV for vHGV="+ vHGV + "!"); double dV = RLS90NoiseEmission.calculateGeschwindigkeitskorrekturDv(vCar, vHGV, p); - Assert.assertEquals("Wrong Dv!", -7.689390421466860, dV, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-7.689390421466860, dV, MatsimTestUtils.EPSILON, "Wrong Dv!"); double emission = mittelungspegel + dV; - Assert.assertEquals("Wrong emission!", 61.5362841118986, emission, MatsimTestUtils.EPSILON); + Assertions.assertEquals(61.5362841118986, emission, MatsimTestUtils.EPSILON, "Wrong emission!"); // plus one car @@ -1451,7 +1451,7 @@ final void test5(){ double mittelungspegelPlusOneCar = RLS90NoiseEmission.calculateMittelungspegelLm(nPlusOneCar, pPlusOneCar); double dVPlusOneCar = RLS90NoiseEmission.calculateGeschwindigkeitskorrekturDv(vCar, vHGV, pPlusOneCar); double emissionPlusOneCar = mittelungspegelPlusOneCar + dVPlusOneCar; - Assert.assertEquals("Wrong emission!", 61.5580658162266, emissionPlusOneCar, MatsimTestUtils.EPSILON); + Assertions.assertEquals(61.5580658162266, emissionPlusOneCar, MatsimTestUtils.EPSILON, "Wrong emission!"); // plus one HGV @@ -1460,6 +1460,6 @@ final void test5(){ double mittelungspegelPlusOneHGV = RLS90NoiseEmission.calculateMittelungspegelLm(nPlusOneHGV, pPlusOneHGV); double dVPlusOneHGV = RLS90NoiseEmission.calculateGeschwindigkeitskorrekturDv(vCar, vHGV, pPlusOneHGV); double emissionPlusOneHGV = mittelungspegelPlusOneHGV + dVPlusOneHGV; - Assert.assertEquals("Wrong emission!", 61.9518310976080, emissionPlusOneHGV, MatsimTestUtils.EPSILON); + Assertions.assertEquals(61.9518310976080, emissionPlusOneHGV, MatsimTestUtils.EPSILON, "Wrong emission!"); } } diff --git a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseOnlineExampleIT.java b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseOnlineExampleIT.java index 969ec85aef0..58218c5fa2b 100644 --- a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseOnlineExampleIT.java +++ b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseOnlineExampleIT.java @@ -25,7 +25,7 @@ import com.google.inject.multibindings.Multibinder; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.analysis.XYTRecord; @@ -169,13 +169,13 @@ final void testOnTheFlyAggregationTerms() { //check whether on the fly caluclation equals file based aggregation terms for(Map.Entry, Double> entry: ldenByRp.entrySet()) { - Assert.assertEquals(entry.getValue(), nrps.get(entry.getKey()).getLden(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(entry.getValue(), nrps.get(entry.getKey()).getLden(), MatsimTestUtils.EPSILON); } for(Map.Entry, Double> entry: l69ByRp.entrySet()) { - Assert.assertEquals(entry.getValue(), nrps.get(entry.getKey()).getL69(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(entry.getValue(), nrps.get(entry.getKey()).getL69(), MatsimTestUtils.EPSILON); } for(Map.Entry, Double> entry: l1619ByRp.entrySet()) { - Assert.assertEquals(entry.getValue(), nrps.get(entry.getKey()).getL1619(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(entry.getValue(), nrps.get(entry.getKey()).getL1619(), MatsimTestUtils.EPSILON); } } diff --git a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseRLS19IT.java b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseRLS19IT.java index 41c3ebb8836..a3e8bc91d45 100644 --- a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseRLS19IT.java +++ b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseRLS19IT.java @@ -22,7 +22,7 @@ */ package org.matsim.contrib.noise; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.locationtech.jts.geom.Coordinate; @@ -58,8 +58,8 @@ void testShielding() { final RLS19ShieldingCorrection shieldingCorrection = new RLS19ShieldingCorrection(); - Assert.assertEquals("Wrong shielding value z!", 34.463933081239965, - shieldingCorrection.calculateShieldingCorrection(10,15,15,15), MatsimTestUtils.EPSILON); + Assertions.assertEquals(34.463933081239965, + shieldingCorrection.calculateShieldingCorrection(10,15,15,15), MatsimTestUtils.EPSILON, "Wrong shielding value z!"); Config config = ConfigUtils.createConfig(); NoiseConfigGroup noiseConfigGroup = ConfigUtils.addOrGetModule(config, NoiseConfigGroup.class); @@ -89,8 +89,8 @@ void testShielding() { link.getFromNode().getCoord(), link.getToNode().getCoord(), rp.getCoord()); final double v = context.determineShieldingValue(rp, link, coord); - Assert.assertEquals("Wrong shielding correction!", 30.78517993490919, - v, MatsimTestUtils.EPSILON); + Assertions.assertEquals(30.78517993490919, + v, MatsimTestUtils.EPSILON, "Wrong shielding correction!"); } @@ -107,24 +107,24 @@ void testEmission() { RLS19NoiseEmission emission = new RLS19NoiseEmission(scenario, new RoadSurfaceContext(network), new DEMContextImpl(scenario.getConfig())); final double basePkwEmission = emission.calculateBaseVehicleTypeEmission(RLS19VehicleType.pkw, 40); - Assert.assertEquals("Wrong base pkw emission!", 97.70334139531323, basePkwEmission, MatsimTestUtils.EPSILON); + Assertions.assertEquals(97.70334139531323, basePkwEmission, MatsimTestUtils.EPSILON, "Wrong base pkw emission!"); double singleVehicleEmission = emission.calculateSingleVehicleEmission(noiseLink, RLS19VehicleType.pkw, 40); - Assert.assertEquals("Wrong single pkw emission!", 97.70334139531323, singleVehicleEmission, MatsimTestUtils.EPSILON); + Assertions.assertEquals(97.70334139531323, singleVehicleEmission, MatsimTestUtils.EPSILON, "Wrong single pkw emission!"); final double vehicleTypePart = emission.calculateVehicleTypeNoise(1, 40, singleVehicleEmission); - Assert.assertEquals("Wrong pkw emission sum part!", 1.4732421924637252E8, vehicleTypePart, MatsimTestUtils.EPSILON); + Assertions.assertEquals(1.4732421924637252E8, vehicleTypePart, MatsimTestUtils.EPSILON, "Wrong pkw emission sum part!"); final double noiseLinkEmission = emission.calculateEmission(noiseLink, 40, 40, 40, 1800, 0, 0); - Assert.assertEquals("Wrong noise link emission!", 84.23546653306667, noiseLinkEmission, MatsimTestUtils.EPSILON); + Assertions.assertEquals(84.23546653306667, noiseLinkEmission, MatsimTestUtils.EPSILON, "Wrong noise link emission!"); for (int i = 0; i < 1800; i++) { noiseLink.addEnteringAgent(RLS19VehicleType.pkw); } emission.calculateEmission(noiseLink); - Assert.assertEquals("Wrong final noise link emission!", 84.23546653306667, noiseLink.getEmission(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(84.23546653306667, noiseLink.getEmission(), MatsimTestUtils.EPSILON, "Wrong final noise link emission!"); } @Test @@ -177,7 +177,7 @@ void testImmission() { emission.calculateEmission(noiseLink); emission.calculateEmission(noiseLink2); - Assert.assertEquals("Wrong final noise link emission!", 84.23546653306667, noiseLink.getEmission(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(84.23546653306667, noiseLink.getEmission(), MatsimTestUtils.EPSILON, "Wrong final noise link emission!"); NoiseReceiverPoint rp = new NoiseReceiverPoint(Id.create("a", ReceiverPoint.class), new Coord(0,0)); @@ -193,7 +193,7 @@ void testImmission() { immission.calculateImmission(rp, 8*3600); final double currentImmission = rp.getCurrentImmission(); - Assert.assertEquals("Wrong immission!", 73.77467715144601, - currentImmission, MatsimTestUtils.EPSILON); + Assertions.assertEquals(73.77467715144601, + currentImmission, MatsimTestUtils.EPSILON, "Wrong immission!"); } } diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/LinkPropertiesTest.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/LinkPropertiesTest.java index 30e886f88d8..6576ff30bb9 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/LinkPropertiesTest.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/LinkPropertiesTest.java @@ -1,10 +1,10 @@ package org.matsim.contrib.osm.networkReader; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.network.Link; -import static org.junit.Assert.assertEquals; - public class LinkPropertiesTest { @Test diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderTest.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderTest.java index 788c58bf779..cbe253f63dd 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderTest.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmBicycleReaderTest.java @@ -19,7 +19,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class OsmBicycleReaderTest { diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmNetworkParserTest.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmNetworkParserTest.java index ec2aadb4cc5..be16614ebf8 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmNetworkParserTest.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmNetworkParserTest.java @@ -18,8 +18,8 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class OsmNetworkParserTest { private final ExecutorService executor = Executors.newSingleThreadExecutor(); diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmSignalsParserTest.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmSignalsParserTest.java index 9aed196716b..96a13bec584 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmSignalsParserTest.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmSignalsParserTest.java @@ -21,8 +21,8 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class OsmSignalsParserTest { diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderTest.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderTest.java index 0a8771b6649..7d4793481e7 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderTest.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/SupersonicOsmNetworkReaderTest.java @@ -30,7 +30,7 @@ import java.util.*; import java.util.function.Predicate; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class SupersonicOsmNetworkReaderTest { diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/Utils.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/Utils.java index 90eeba92a48..e9ba1daa961 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/Utils.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/Utils.java @@ -11,7 +11,7 @@ import de.topobyte.osm4j.pbf.seq.PbfWriter; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.utils.geometry.CoordinateTransformation; @@ -23,8 +23,8 @@ import java.nio.file.Path; import java.util.*; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class Utils { @@ -196,13 +196,13 @@ static void assertEquals(Network expected, Network actual) { private static void testLinksAreEqual(Link expected, Link actual) { expected.getAllowedModes().forEach(mode -> assertTrue(actual.getAllowedModes().contains(mode))); - Assert.assertEquals(expected.getCapacity(), actual.getCapacity(), 0.001); - Assert.assertEquals(expected.getFlowCapacityPerSec(), actual.getFlowCapacityPerSec(), 0.001); - Assert.assertEquals(expected.getFreespeed(), actual.getFreespeed(), 0.001); - Assert.assertEquals(expected.getLength(), actual.getLength(), 0.001); - Assert.assertEquals(expected.getNumberOfLanes(), actual.getNumberOfLanes(), 0.001); - Assert.assertEquals(expected.getFromNode().getId(), actual.getFromNode().getId()); - Assert.assertEquals(expected.getToNode().getId(), actual.getToNode().getId()); + Assertions.assertEquals(expected.getCapacity(), actual.getCapacity(), 0.001); + Assertions.assertEquals(expected.getFlowCapacityPerSec(), actual.getFlowCapacityPerSec(), 0.001); + Assertions.assertEquals(expected.getFreespeed(), actual.getFreespeed(), 0.001); + Assertions.assertEquals(expected.getLength(), actual.getLength(), 0.001); + Assertions.assertEquals(expected.getNumberOfLanes(), actual.getNumberOfLanes(), 0.001); + Assertions.assertEquals(expected.getFromNode().getId(), actual.getFromNode().getId()); + Assertions.assertEquals(expected.getToNode().getId(), actual.getToNode().getId()); } private static void testNodesAreEqual(org.matsim.api.core.v01.network.Node expected, org.matsim.api.core.v01.network.Node actual) { @@ -210,10 +210,10 @@ private static void testNodesAreEqual(org.matsim.api.core.v01.network.Node expec // test x and y separately, so that we can have a delta. // In java version >=11 Assert.assertEquals(expected.getCoord(), actual.getCoord()) also works // keep this in as long as we use java-8 - Assert.assertEquals(expected.getCoord().getX(), actual.getCoord().getX(), 0.00000001); - Assert.assertEquals(expected.getCoord().getY(), actual.getCoord().getY(), 0.00000001); - expected.getOutLinks().forEach((id, link) -> Assert.assertEquals(link.getId(), actual.getOutLinks().get(id).getId())); - expected.getInLinks().forEach((id, link) -> Assert.assertEquals(link.getId(), actual.getInLinks().get(id).getId())); + Assertions.assertEquals(expected.getCoord().getX(), actual.getCoord().getX(), 0.00000001); + Assertions.assertEquals(expected.getCoord().getY(), actual.getCoord().getY(), 0.00000001); + expected.getOutLinks().forEach((id, link) -> Assertions.assertEquals(link.getId(), actual.getOutLinks().get(id).getId())); + expected.getInLinks().forEach((id, link) -> Assertions.assertEquals(link.getId(), actual.getInLinks().get(id).getId())); } static class OsmData { diff --git a/contribs/osm/src/test/java/otherPackage/SupersonicOsmNetworkReaderBuilderTest.java b/contribs/osm/src/test/java/otherPackage/SupersonicOsmNetworkReaderBuilderTest.java index e408f441573..15ffb2602f8 100644 --- a/contribs/osm/src/test/java/otherPackage/SupersonicOsmNetworkReaderBuilderTest.java +++ b/contribs/osm/src/test/java/otherPackage/SupersonicOsmNetworkReaderBuilderTest.java @@ -1,11 +1,11 @@ package otherPackage; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import org.junit.jupiter.api.Test; import org.matsim.contrib.osm.networkReader.SupersonicOsmNetworkReader; import org.matsim.core.utils.geometry.transformations.IdentityTransformation; -import static org.junit.Assert.assertNotNull; - public class SupersonicOsmNetworkReaderBuilderTest { @Test diff --git a/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java b/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java index d54fb3ef32e..c24c225fe3b 100644 --- a/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java +++ b/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java @@ -23,7 +23,7 @@ */ package org.matsim.contrib.otfvis; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.config.Config; @@ -61,7 +61,7 @@ void testConvert() { OTFVis.main(args); File f = new File(mviFilename); - Assert.assertTrue("No mvi file written!", f.exists()); + Assertions.assertTrue(f.exists(), "No mvi file written!"); } @Test @@ -83,9 +83,9 @@ void testOTFVisSnapshotWriterOnQSim() { controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); - Assert.assertTrue(new File(controler.getControlerIO().getIterationFilename(0, "otfvis.mvi")).exists()); - Assert.assertTrue(new File(controler.getControlerIO().getIterationFilename(1, "otfvis.mvi")).exists()); - Assert.assertTrue(new File(controler.getControlerIO().getIterationFilename(2, "otfvis.mvi")).exists()); + Assertions.assertTrue(new File(controler.getControlerIO().getIterationFilename(0, "otfvis.mvi")).exists()); + Assertions.assertTrue(new File(controler.getControlerIO().getIterationFilename(1, "otfvis.mvi")).exists()); + Assertions.assertTrue(new File(controler.getControlerIO().getIterationFilename(2, "otfvis.mvi")).exists()); } } diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/GeneralLibTest.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/GeneralLibTest.java index 23663b17e77..db32de7e1e3 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/GeneralLibTest.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/GeneralLibTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.parking.lib; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; import org.matsim.contrib.parking.parkingchoice.lib.GeneralLib; diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/obj/DoubleValueHashMapTest.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/obj/DoubleValueHashMapTest.java index 896c5cd8849..607ea846b72 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/obj/DoubleValueHashMapTest.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/obj/DoubleValueHashMapTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.parking.lib.obj; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.matsim.contrib.parking.parkingchoice.lib.obj.DoubleValueHashMap; diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/obj/LinkedListValueHashMapTest.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/obj/LinkedListValueHashMapTest.java index 99f18824563..d99c1b6195b 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/obj/LinkedListValueHashMapTest.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/lib/obj/LinkedListValueHashMapTest.java @@ -1,10 +1,10 @@ package org.matsim.contrib.parking.lib.obj; -import static org.junit.Assert.assertEquals; - import java.util.HashMap; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.matsim.contrib.parking.parkingchoice.lib.obj.HashMapInverter; import org.matsim.contrib.parking.parkingchoice.lib.obj.LinkedListValueHashMap; diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/ParkingCostVehicleTrackerTest.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/ParkingCostVehicleTrackerTest.java index ba933fa274b..0cbb0de9f99 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/ParkingCostVehicleTrackerTest.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/ParkingCostVehicleTrackerTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.parking.parkingcost.eventhandling; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -78,53 +78,53 @@ void testParkingCostEvents() { f.events.processEvent(new VehicleEntersTrafficEvent(7.00 * 3600, personId, linkHome, vehicleId, "car", 1.0)); f.events.processEvent(new VehicleLeavesTrafficEvent(7.25 * 3600, personId, linkWork, vehicleId, "car", 1.0)); f.events.processEvent(new ActivityStartEvent(7.25 * 3600, personId, linkWork, null, "work", null)); - Assert.assertEquals(3, collector.getEvents().size()); + Assertions.assertEquals(3, collector.getEvents().size()); f.events.processEvent(new VehicleEntersTrafficEvent(12.00 * 3600, personId, linkWork, vehicleId, "car", 1.0)); - Assert.assertEquals(5, collector.getEvents().size()); + Assertions.assertEquals(5, collector.getEvents().size()); - Assert.assertEquals(PersonMoneyEvent.class, collector.getEvents().get(3).getClass()); + Assertions.assertEquals(PersonMoneyEvent.class, collector.getEvents().get(3).getClass()); PersonMoneyEvent parkingEvent1 = (PersonMoneyEvent) collector.getEvents().get(3); - Assert.assertEquals(personId, parkingEvent1.getPersonId()); - Assert.assertEquals(12.00 * 3600, parkingEvent1.getTime(), 1e-8); - Assert.assertEquals((12 - 7.25) * hourlyParkingCostWork, -parkingEvent1.getAmount(), 1e-8); + Assertions.assertEquals(personId, parkingEvent1.getPersonId()); + Assertions.assertEquals(12.00 * 3600, parkingEvent1.getTime(), 1e-8); + Assertions.assertEquals((12 - 7.25) * hourlyParkingCostWork, -parkingEvent1.getAmount(), 1e-8); f.events.processEvent(new VehicleLeavesTrafficEvent(12.25 * 3600, personId, linkShop, vehicleId, "car", 1.0)); f.events.processEvent(new ActivityStartEvent(12.25 * 3600, personId, linkShop, null, "shop", null)); - Assert.assertEquals(7, collector.getEvents().size()); + Assertions.assertEquals(7, collector.getEvents().size()); f.events.processEvent(new VehicleEntersTrafficEvent(13.00 * 3600, personId, linkShop, vehicleId, "car", 1.0)); - Assert.assertEquals(9, collector.getEvents().size()); + Assertions.assertEquals(9, collector.getEvents().size()); - Assert.assertEquals(PersonMoneyEvent.class, collector.getEvents().get(7).getClass()); + Assertions.assertEquals(PersonMoneyEvent.class, collector.getEvents().get(7).getClass()); PersonMoneyEvent parkingEvent2 = (PersonMoneyEvent) collector.getEvents().get(7); - Assert.assertEquals(personId, parkingEvent2.getPersonId()); - Assert.assertEquals(13.00 * 3600, parkingEvent2.getTime(), 1e-8); - Assert.assertEquals((13 - 12.25) * hourlyParkingCostShop, -parkingEvent2.getAmount(), 1e-8); + Assertions.assertEquals(personId, parkingEvent2.getPersonId()); + Assertions.assertEquals(13.00 * 3600, parkingEvent2.getTime(), 1e-8); + Assertions.assertEquals((13 - 12.25) * hourlyParkingCostShop, -parkingEvent2.getAmount(), 1e-8); f.events.processEvent(new VehicleLeavesTrafficEvent(13.25 * 3600, personId, linkHome, vehicleId, "car", 1.0)); f.events.processEvent(new ActivityStartEvent(13.25 * 3600, personId, linkHome, null, "home", null)); - Assert.assertEquals(11, collector.getEvents().size()); + Assertions.assertEquals(11, collector.getEvents().size()); f.events.processEvent(new VehicleEntersTrafficEvent(15.00 * 3600, personId, linkShop, vehicleId, "car", 1.0)); - Assert.assertEquals(12, collector.getEvents().size()); // there should be no parking cost event at home + Assertions.assertEquals(12, collector.getEvents().size()); // there should be no parking cost event at home f.events.processEvent(new VehicleLeavesTrafficEvent(15.25 * 3600, personId, linkWork, vehicleId, "car", 1.0)); f.events.processEvent(new ActivityStartEvent(13.25 * 3600, personId, linkWork, null, "shop", null)); - Assert.assertEquals(14, collector.getEvents().size()); + Assertions.assertEquals(14, collector.getEvents().size()); f.events.processEvent(new VehicleEntersTrafficEvent(18.00 * 3600, personId, linkWork, vehicleId, "car", 1.0)); - Assert.assertEquals(16, collector.getEvents().size()); + Assertions.assertEquals(16, collector.getEvents().size()); - Assert.assertEquals(PersonMoneyEvent.class, collector.getEvents().get(14).getClass()); + Assertions.assertEquals(PersonMoneyEvent.class, collector.getEvents().get(14).getClass()); PersonMoneyEvent parkingEvent3 = (PersonMoneyEvent) collector.getEvents().get(14); - Assert.assertEquals(personId, parkingEvent3.getPersonId()); - Assert.assertEquals(18.00 * 3600, parkingEvent3.getTime(), 1e-8); - Assert.assertEquals((18 - 15.25) * hourlyParkingCostWork, -parkingEvent3.getAmount(), 1e-8); + Assertions.assertEquals(personId, parkingEvent3.getPersonId()); + Assertions.assertEquals(18.00 * 3600, parkingEvent3.getTime(), 1e-8); + Assertions.assertEquals((18 - 15.25) * hourlyParkingCostWork, -parkingEvent3.getAmount(), 1e-8); f.events.processEvent(new VehicleLeavesTrafficEvent(18.50 * 3600, personId, linkHome, vehicleId, "car", 1.0)); f.events.processEvent(new ActivityStartEvent(18.00 * 3600, personId, linkHome, null, "shop", null)); - Assert.assertEquals(18, collector.getEvents().size()); + Assertions.assertEquals(18, collector.getEvents().size()); } /** diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/RideParkingCostTrackerTest.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/RideParkingCostTrackerTest.java index 98e4f56a9b7..20bdf69263f 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/RideParkingCostTrackerTest.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingcost/eventhandling/RideParkingCostTrackerTest.java @@ -19,7 +19,7 @@ package org.matsim.contrib.parking.parkingcost.eventhandling; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -74,53 +74,53 @@ void testPersonMoneyEvents() { f.scenario.getNetwork().getLinks().get(linkShop).getAttributes().putAttribute("pc_ride", hourlyParkingCostShop); f.events.processEvent(new PersonArrivalEvent(7.25 * 3600, personId, linkWork, "ride")); f.events.processEvent(new ActivityStartEvent(7.25 * 3600, personId, linkWork, null, "work", null)); - Assert.assertEquals(2, collector.getEvents().size()); + Assertions.assertEquals(2, collector.getEvents().size()); f.events.processEvent(new ActivityEndEvent(12.00 * 3600, personId, linkWork, null, "work", new Coord(0, 0))); - Assert.assertEquals(4, collector.getEvents().size()); + Assertions.assertEquals(4, collector.getEvents().size()); - Assert.assertEquals(PersonMoneyEvent.class, collector.getEvents().get(2).getClass()); + Assertions.assertEquals(PersonMoneyEvent.class, collector.getEvents().get(2).getClass()); PersonMoneyEvent parkingEvent1 = (PersonMoneyEvent) collector.getEvents().get(2); - Assert.assertEquals(personId, parkingEvent1.getPersonId()); - Assert.assertEquals(12.00 * 3600, parkingEvent1.getTime(), 1e-8); - Assert.assertEquals((12 - 7.25) * hourlyParkingCostWork, -parkingEvent1.getAmount(), 1e-8); + Assertions.assertEquals(personId, parkingEvent1.getPersonId()); + Assertions.assertEquals(12.00 * 3600, parkingEvent1.getTime(), 1e-8); + Assertions.assertEquals((12 - 7.25) * hourlyParkingCostWork, -parkingEvent1.getAmount(), 1e-8); f.events.processEvent(new PersonArrivalEvent(12.25 * 3600, personId, linkShop, "ride")); f.events.processEvent(new ActivityStartEvent(12.25 * 3600, personId, linkShop, null, "shop", null)); - Assert.assertEquals(6, collector.getEvents().size()); + Assertions.assertEquals(6, collector.getEvents().size()); f.events.processEvent(new ActivityEndEvent(13.00 * 3600, personId, linkShop, null, "shop", new Coord(0, 0))); - Assert.assertEquals(8, collector.getEvents().size()); + Assertions.assertEquals(8, collector.getEvents().size()); - Assert.assertEquals(PersonMoneyEvent.class, collector.getEvents().get(6).getClass()); + Assertions.assertEquals(PersonMoneyEvent.class, collector.getEvents().get(6).getClass()); PersonMoneyEvent parkingEvent2 = (PersonMoneyEvent) collector.getEvents().get(6); - Assert.assertEquals(personId, parkingEvent2.getPersonId()); - Assert.assertEquals(13.00 * 3600, parkingEvent2.getTime(), 1e-8); - Assert.assertEquals((13 - 12.25) * hourlyParkingCostShop, -parkingEvent2.getAmount(), 1e-8); + Assertions.assertEquals(personId, parkingEvent2.getPersonId()); + Assertions.assertEquals(13.00 * 3600, parkingEvent2.getTime(), 1e-8); + Assertions.assertEquals((13 - 12.25) * hourlyParkingCostShop, -parkingEvent2.getAmount(), 1e-8); f.events.processEvent(new PersonArrivalEvent(13.25 * 3600, personId, linkHome, "ride")); f.events.processEvent(new ActivityStartEvent(13.25 * 3600, personId, linkHome, null, "home", null)); - Assert.assertEquals(10, collector.getEvents().size()); + Assertions.assertEquals(10, collector.getEvents().size()); f.events.processEvent(new ActivityEndEvent(15.00 * 3600, personId, linkShop, null, "home", new Coord(0, 0))); - Assert.assertEquals(11, collector.getEvents().size()); // there should be no parking cost event at home + Assertions.assertEquals(11, collector.getEvents().size()); // there should be no parking cost event at home f.events.processEvent(new PersonArrivalEvent(15.25 * 3600, personId, linkWork, "ride")); f.events.processEvent(new ActivityStartEvent(13.25 * 3600, personId, linkWork, null, "shop", null)); - Assert.assertEquals(13, collector.getEvents().size()); + Assertions.assertEquals(13, collector.getEvents().size()); f.events.processEvent(new ActivityEndEvent(18.00 * 3600, personId, linkWork, null, "shop", new Coord(0, 0))); - Assert.assertEquals(15, collector.getEvents().size()); + Assertions.assertEquals(15, collector.getEvents().size()); - Assert.assertEquals(PersonMoneyEvent.class, collector.getEvents().get(13).getClass()); + Assertions.assertEquals(PersonMoneyEvent.class, collector.getEvents().get(13).getClass()); PersonMoneyEvent parkingEvent3 = (PersonMoneyEvent) collector.getEvents().get(13); - Assert.assertEquals(personId, parkingEvent3.getPersonId()); - Assert.assertEquals(18.00 * 3600, parkingEvent3.getTime(), 1e-8); - Assert.assertEquals((18 - 15.25) * hourlyParkingCostWork, -parkingEvent3.getAmount(), 1e-8); + Assertions.assertEquals(personId, parkingEvent3.getPersonId()); + Assertions.assertEquals(18.00 * 3600, parkingEvent3.getTime(), 1e-8); + Assertions.assertEquals((18 - 15.25) * hourlyParkingCostWork, -parkingEvent3.getAmount(), 1e-8); f.events.processEvent(new PersonArrivalEvent(18.50 * 3600, personId, linkHome, "ride")); f.events.processEvent(new ActivityStartEvent(18.00 * 3600, personId, linkHome, null, "shop", null)); - Assert.assertEquals(17, collector.getEvents().size()); + Assertions.assertEquals(17, collector.getEvents().size()); } /** diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingSearchScenarioIT.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingSearchScenarioIT.java index d614a1edd4c..d6feb304be0 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingSearchScenarioIT.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingSearchScenarioIT.java @@ -19,7 +19,7 @@ package org.matsim.contrib.parking.run; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -57,7 +57,7 @@ void testRunParkingBenesonStrategy() { } catch (Exception e) { e.printStackTrace(); - Assert.fail("something went wrong"); + Assertions.fail("something went wrong"); } } @@ -75,7 +75,7 @@ void testRunParkingRandomStrategy() { new RunParkingSearchExample().run(config, false); } catch (Exception e) { e.printStackTrace(); - Assert.fail("something went wrong"); + Assertions.fail("something went wrong"); } } @@ -101,7 +101,7 @@ void testRunParkingDistanceMemoryStrategy() { for (Id personId : expected.getPersons().keySet()) { double scoreReference = expected.getPersons().get(personId).getSelectedPlan().getScore(); double scoreCurrent = actual.getPersons().get(personId).getSelectedPlan().getScore(); - Assert.assertEquals("Scores of person=" + personId + " are different", scoreReference, scoreCurrent, MatsimTestUtils.EPSILON); + Assertions.assertEquals(scoreReference, scoreCurrent, MatsimTestUtils.EPSILON, "Scores of person=" + personId + " are different"); } } @@ -109,11 +109,11 @@ void testRunParkingDistanceMemoryStrategy() { String expected = utils.getInputDirectory() + "/output_events.xml.gz"; String actual = utils.getOutputDirectory() + "/output_events.xml.gz"; EventsFileComparator.Result result = EventsUtils.compareEventsFiles(expected, actual); - Assert.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, result); + Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, result); } } catch (Exception e) { e.printStackTrace(); - Assert.fail("something went wrong"); + Assertions.fail("something went wrong"); } } @@ -139,7 +139,7 @@ void testRunParkingNearestParkingSpotStrategy() { for (Id personId : expected.getPersons().keySet()) { double scoreReference = expected.getPersons().get(personId).getSelectedPlan().getScore(); double scoreCurrent = actual.getPersons().get(personId).getSelectedPlan().getScore(); - Assert.assertEquals("Scores of person=" + personId + " are different", scoreReference, scoreCurrent, MatsimTestUtils.EPSILON); + Assertions.assertEquals(scoreReference, scoreCurrent, MatsimTestUtils.EPSILON, "Scores of person=" + personId + " are different"); } } @@ -147,11 +147,11 @@ void testRunParkingNearestParkingSpotStrategy() { String expected = utils.getInputDirectory() + "/output_events.xml.gz"; String actual = utils.getOutputDirectory() + "/output_events.xml.gz"; EventsFileComparator.Result result = EventsUtils.compareEventsFiles(expected, actual); - Assert.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, result); + Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, result); } } catch (Exception e) { e.printStackTrace(); - Assert.fail("something went wrong"); + Assertions.fail("something went wrong"); } } } diff --git a/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java b/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java index 98b6c1fa889..12c258a2d6e 100644 --- a/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java +++ b/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java @@ -3,8 +3,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.FixMethodOrder; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.runners.MethodSorters; @@ -103,7 +103,7 @@ public void install() { Population popActual = PopulationUtils.createPopulation( config ); PopulationUtils.readPopulation( popActual, outDir + "/output_plans.xml.gz" ); new PopulationComparison().compare( popExpected, popActual ) ; - Assert.assertEquals("RunPsim score changed.", 138.86084460860525, psimScore, MatsimTestUtils.EPSILON); + Assertions.assertEquals(138.86084460860525, psimScore, MatsimTestUtils.EPSILON, "RunPsim score changed."); } @@ -129,7 +129,7 @@ void testB() { double qsimScore = execScoreTracker.executedScore; logger.info("Default controler score was " + qsimScore ); // Assert.assertEquals("Default controler score changed.", 131.84309487251033d, qsimScore, MatsimTestUtils.EPSILON); - Assert.assertEquals("Default controler score changed.", 131.8303325803256, qsimScore, MatsimTestUtils.EPSILON); + Assertions.assertEquals(131.8303325803256, qsimScore, MatsimTestUtils.EPSILON, "Default controler score changed."); } class ExecScoreTracker implements ShutdownListener { diff --git a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java index ec938145c09..6a61f5d0f16 100644 --- a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java +++ b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java @@ -22,7 +22,7 @@ import ch.sbb.matsim.contrib.railsim.RailsimModule; import ch.sbb.matsim.contrib.railsim.events.RailsimTrainStateEvent; import ch.sbb.matsim.contrib.railsim.qsimengine.RailsimQSimModule; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -289,7 +289,7 @@ void testMicroSimpleUniDirectionalTrack() { if (vehicleArrivesEvent.getVehicleId().toString().equals("train1") && vehicleArrivesEvent.getFacilityId().toString() .equals("stop_3-4")) { - Assert.assertEquals("The arrival time of train1 at stop_3-4 has changed.", 29594., event.getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(29594., event.getTime(), MatsimTestUtils.EPSILON, "The arrival time of train1 at stop_3-4 has changed."); } } } @@ -428,17 +428,17 @@ private void assertTrainState(double time, double speed, double targetSpeed, dou for (RailsimTrainStateEvent event : events) { if (event.getTime() > Math.ceil(time)) { - Assert.fail( + Assertions.fail( String.format("No matching event found for time %f, speed %f pos %f, Closest event is%s", time, speed, headPosition, prev)); } // If all assertions are true, returns successfully try { - Assert.assertEquals(Math.ceil(time), event.getTime(), 1e-7); - Assert.assertEquals(speed, event.getSpeed(), 1e-5); - Assert.assertEquals(targetSpeed, event.getTargetSpeed(), 1e-7); - Assert.assertEquals(acceleration, event.getAcceleration(), 1e-5); - Assert.assertEquals(headPosition, event.getHeadPosition(), 1e-5); + Assertions.assertEquals(Math.ceil(time), event.getTime(), 1e-7); + Assertions.assertEquals(speed, event.getSpeed(), 1e-5); + Assertions.assertEquals(targetSpeed, event.getTargetSpeed(), 1e-7); + Assertions.assertEquals(acceleration, event.getAcceleration(), 1e-5); + Assertions.assertEquals(headPosition, event.getHeadPosition(), 1e-5); return; } catch (AssertionError e) { // Check further events in loop diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/AvoidTolledRouteTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/AvoidTolledRouteTest.java index d7661de699c..383dbc7c9f0 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/AvoidTolledRouteTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/AvoidTolledRouteTest.java @@ -23,9 +23,9 @@ package org.matsim.contrib.roadpricing; import java.util.HashMap; -import java.util.Map; - -import org.junit.Assert; +import java.util.Map; + +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -120,8 +120,8 @@ public void handleEvent(LinkLeaveEvent event) { controler2.getConfig().controller().setCreateGraphs(false); controler2.run(); - Assert.assertEquals("Base Case: all agents should use the faster route.", 3, (Integer) linkId2demand1.get(Id.createLinkId("link_4_5")), 0); - Assert.assertEquals("Pricing: all agents should use the slow but untolled route.", 3, linkId2demand2.get(Id.createLinkId("link_1_2")), 0); + Assertions.assertEquals(3, (Integer) linkId2demand1.get(Id.createLinkId("link_4_5")), 0, "Base Case: all agents should use the faster route."); + Assertions.assertEquals(3, linkId2demand2.get(Id.createLinkId("link_1_2")), 0, "Pricing: all agents should use the slow but untolled route."); } } diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/CalcPaidTollTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/CalcPaidTollTest.java index 63ac002412e..85c90cb3e79 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/CalcPaidTollTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/CalcPaidTollTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -196,7 +196,7 @@ private void compareScores(final double scoreWithoutToll, final double scoreWith log.info("score without toll: " + scoreWithoutToll); log.info("score with toll: " + scoreWithToll); log.info("expected toll: " + expectedToll); - Assert.assertEquals(expectedToll, scoreWithoutToll - scoreWithToll, 1e-8); + Assertions.assertEquals(expectedToll, scoreWithoutToll - scoreWithToll, 1e-8); } /** @@ -212,7 +212,7 @@ private Population runTollSimulation(final String tollFile, final String tollTyp RoadPricingSchemeImpl scheme = RoadPricingUtils.addOrGetMutableRoadPricingScheme(scenario ); RoadPricingReaderXMLv1 reader = new RoadPricingReaderXMLv1(scheme); reader.readFile(tollFile); - Assert.assertEquals(tollType, scheme.getType()); + Assertions.assertEquals(tollType, scheme.getType()); RoadPricingTestUtils.createPopulation1(scenario); runTollSimulation(scenario, scheme); diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingConfigGroupTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingConfigGroupTest.java index a22f0d46b39..4211519005b 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingConfigGroupTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingConfigGroupTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.roadpricing; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -14,7 +14,7 @@ public class RoadPricingConfigGroupTest { @Test void getTollLinksFile() { RoadPricingConfigGroup cg = new RoadPricingConfigGroup(); - Assert.assertNull("Default roadpricing file is not set.", cg.getTollLinksFile()); + Assertions.assertNull(cg.getTollLinksFile(), "Default roadpricing file is not set."); } @Test @@ -22,17 +22,17 @@ void setTollLinksFile() { String file = "./test.xml.gz"; RoadPricingConfigGroup cg = new RoadPricingConfigGroup(); cg.setTollLinksFile(file); - Assert.assertEquals("Wrong input file.", file, cg.getTollLinksFile()); + Assertions.assertEquals(file, cg.getTollLinksFile(), "Wrong input file."); } @Test void getEnforcementProbability() { RoadPricingConfigGroup cg = new RoadPricingConfigGroup(); - Assert.assertEquals("Default probability should be 1.0", 1.0, cg.getEnforcementProbability(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1.0, cg.getEnforcementProbability(), MatsimTestUtils.EPSILON, "Default probability should be 1.0"); double prob = 0.9; cg.setEnforcementProbability(prob); - Assert.assertEquals("Didn't get the adjusted probability.", prob, cg.getEnforcementProbability(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(prob, cg.getEnforcementProbability(), MatsimTestUtils.EPSILON, "Didn't get the adjusted probability."); } @Test @@ -40,7 +40,7 @@ void setEnforcementProbability() { RoadPricingConfigGroup cg = new RoadPricingConfigGroup(); try{ cg.setEnforcementProbability(1.2); - Assert.fail("Should not accept probability > 1.0"); + Assertions.fail("Should not accept probability > 1.0"); } catch (Exception e){ e.printStackTrace(); } diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingControlerIT.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingControlerIT.java index 98260925936..250ef1758fe 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingControlerIT.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingControlerIT.java @@ -20,7 +20,7 @@ package org.matsim.contrib.roadpricing; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -73,7 +73,7 @@ void testPaidTollsEndUpInScores() { double scoreTollcase = controler2.getScenario().getPopulation().getPersons().get(Id.create("1", Person.class)).getPlans().get(0).getScore(); // there should be a score difference - Assert.assertEquals(3.0, scoreBasecase - scoreTollcase, MatsimTestUtils.EPSILON); // toll amount: 10000*0.00020 + 5000*0.00020 + Assertions.assertEquals(3.0, scoreBasecase - scoreTollcase, MatsimTestUtils.EPSILON); // toll amount: 10000*0.00020 + 5000*0.00020 } } diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingIOTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingIOTest.java index 012e8117b2d..abf55722642 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingIOTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingIOTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.roadpricing; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.io.File; import java.util.Iterator; diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingTestUtils.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingTestUtils.java index b299a872a7c..2065ee627c8 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingTestUtils.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingTestUtils.java @@ -22,7 +22,7 @@ import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -274,9 +274,9 @@ protected static Population createReferencePopulation1(final Config config) { } protected static void compareRoutes(final String expectedRoute, final NetworkRoute realRoute) { - Assert.assertNotNull(expectedRoute) ; - Assert.assertNotNull(realRoute); - Assert.assertNotNull(realRoute.getLinkIds()) ; + Assertions.assertNotNull(expectedRoute) ; + Assertions.assertNotNull(realRoute); + Assertions.assertNotNull(realRoute.getLinkIds()) ; StringBuilder strBuilder = new StringBuilder(); @@ -285,6 +285,6 @@ protected static void compareRoutes(final String expectedRoute, final NetworkRou strBuilder.append(' '); } String route = strBuilder.toString(); - Assert.assertEquals(expectedRoute + " ", route); + Assertions.assertEquals(expectedRoute + " ", route); } } diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java index 8f41e3d40ab..84052e33d8c 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java @@ -20,8 +20,8 @@ package org.matsim.contrib.roadpricing; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import java.util.List; diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RoadPricingByConfigfileTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RoadPricingByConfigfileTest.java index 1869561d3b8..70b4bc9344d 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RoadPricingByConfigfileTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RoadPricingByConfigfileTest.java @@ -18,9 +18,11 @@ * *********************************************************************** */ package org.matsim.contrib.roadpricing.run; +import static org.junit.jupiter.api.Assertions.fail; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.population.Population; @@ -32,8 +34,6 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.utils.eventsfilecomparison.EventsFileComparator; -import static org.junit.Assert.fail; - /** * @author vsp-gleich * @@ -55,14 +55,14 @@ final void testMain() { { String expected = utils.getInputDirectory() + "/output_events.xml.gz" ; String actual = utils.getOutputDirectory() + "/output_events.xml.gz" ; - Assert.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, EventsUtils.compareEventsFiles( expected, actual )); + Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, EventsUtils.compareEventsFiles( expected, actual )); } { final Population expected = PopulationUtils.createPopulation( ConfigUtils.createConfig() ); PopulationUtils.readPopulation( expected, utils.getInputDirectory() + "/output_plans.xml.gz" ); final Population actual = PopulationUtils.createPopulation( ConfigUtils.createConfig() ); PopulationUtils.readPopulation( actual, utils.getOutputDirectory() + "/output_plans.xml.gz" ); - Assert.assertTrue("Populations are different", PopulationUtils.comparePopulations( expected, actual )); + Assertions.assertTrue(PopulationUtils.comparePopulations( expected, actual ), "Populations are different"); } diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingExampleIT.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingExampleIT.java index 263b07483bd..fc9f4870876 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingExampleIT.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingExampleIT.java @@ -1,6 +1,6 @@ package org.matsim.contrib.roadpricing.run; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -19,7 +19,7 @@ void testRunToadPricingExample() { RunRoadPricingExample.main(args); } catch (Exception e) { e.printStackTrace(); - Assert.fail("Example should run without exceptions."); + Assertions.fail("Example should run without exceptions."); } } } diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingFromCodeIT.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingFromCodeIT.java index 6f29178e7e8..d22d577c3ac 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingFromCodeIT.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingFromCodeIT.java @@ -2,7 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.io.File; @@ -19,7 +19,7 @@ void testRunRoadPricingFromCode(){ RunRoadPricingFromCode.main(args); } catch (Exception e){ e.printStackTrace(); - Assert.fail("Example should run without exception."); + Assertions.fail("Example should run without exception."); } } } \ No newline at end of file diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingUsingTollFactorExampleIT.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingUsingTollFactorExampleIT.java index 6431c4dab75..2b5e05ae84e 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingUsingTollFactorExampleIT.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/run/RunRoadPricingUsingTollFactorExampleIT.java @@ -1,6 +1,6 @@ package org.matsim.contrib.roadpricing.run; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class RunRoadPricingUsingTollFactorExampleIT { @@ -13,7 +13,7 @@ void testRunRoadPRicingUsingTollFactorExample() { RunRoadPricingUsingTollFactorExample.main(args); } catch (Exception e) { e.printStackTrace(); - Assert.fail("Example should run without exceptions."); + Assertions.fail("Example should run without exceptions."); } } } \ No newline at end of file diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/FloatMatrixIOTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/FloatMatrixIOTest.java index 8ee80d8a82b..689f88c2381 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/FloatMatrixIOTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/FloatMatrixIOTest.java @@ -24,7 +24,8 @@ import java.io.IOException; import java.util.HashSet; import java.util.Set; -import org.junit.Assert; + +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -60,14 +61,14 @@ void testIO() throws IOException { inStream.close(); float epsilon = 1e-6f; - Assert.assertEquals(2.0f, matrix2.get("un", "un"), epsilon); - Assert.assertEquals(3.0f, matrix2.get("un", "dos"), epsilon); - Assert.assertEquals(4.0f, matrix2.get("un", "tres"), epsilon); - Assert.assertEquals(4.0f, matrix2.get("dos", "un"), epsilon); - Assert.assertEquals(9.0f, matrix2.get("dos", "dos"), epsilon); - Assert.assertEquals(16.0f, matrix2.get("dos", "tres"), epsilon); - Assert.assertEquals(8.0f, matrix2.get("tres", "un"), epsilon); - Assert.assertEquals(27.0f, matrix2.get("tres", "dos"), epsilon); - Assert.assertEquals(64.0f, matrix2.get("tres", "tres"), epsilon); + Assertions.assertEquals(2.0f, matrix2.get("un", "un"), epsilon); + Assertions.assertEquals(3.0f, matrix2.get("un", "dos"), epsilon); + Assertions.assertEquals(4.0f, matrix2.get("un", "tres"), epsilon); + Assertions.assertEquals(4.0f, matrix2.get("dos", "un"), epsilon); + Assertions.assertEquals(9.0f, matrix2.get("dos", "dos"), epsilon); + Assertions.assertEquals(16.0f, matrix2.get("dos", "tres"), epsilon); + Assertions.assertEquals(8.0f, matrix2.get("tres", "un"), epsilon); + Assertions.assertEquals(27.0f, matrix2.get("tres", "dos"), epsilon); + Assertions.assertEquals(64.0f, matrix2.get("tres", "tres"), epsilon); } } diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/RooftopUtilsTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/RooftopUtilsTest.java index 77d95e9430a..6ec46f26396 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/RooftopUtilsTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/RooftopUtilsTest.java @@ -20,10 +20,11 @@ package ch.sbb.matsim.analysis.skims; import ch.sbb.matsim.analysis.skims.RooftopUtils.ODConnection; +import org.junit.jupiter.api.Assertions; + import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.junit.Assert; import org.junit.jupiter.api.Test; import org.matsim.core.utils.misc.Time; @@ -57,12 +58,12 @@ void testSortAndFilterConnections() { // connection 5 (dep 10900) should be dominated by connection 2 (dep 11000) // connection 1 (dep 12700) should be dominated by connection 6 (dep 12600) - Assert.assertEquals(5, connections.size()); - Assert.assertEquals(0, connections.get(0).transferCount, 0.0); - Assert.assertEquals(2, connections.get(1).transferCount, 0.0); - Assert.assertEquals(3, connections.get(2).transferCount, 0.0); - Assert.assertEquals(6, connections.get(3).transferCount, 0.0); - Assert.assertEquals(4, connections.get(4).transferCount, 0.0); + Assertions.assertEquals(5, connections.size()); + Assertions.assertEquals(0, connections.get(0).transferCount, 0.0); + Assertions.assertEquals(2, connections.get(1).transferCount, 0.0); + Assertions.assertEquals(3, connections.get(2).transferCount, 0.0); + Assertions.assertEquals(6, connections.get(3).transferCount, 0.0); + Assertions.assertEquals(4, connections.get(4).transferCount, 0.0); } @Test @@ -79,7 +80,7 @@ void testCalcAverageAdaptionTime_1() { double adaptionTime = RooftopUtils.calcAverageAdaptionTime(connections, Time.parseTime("08:00:00"), Time.parseTime("09:00:00")); // there is a departure every 900 seconds, max adaption time would be 450, average of that would be 225.0. - Assert.assertEquals(225, adaptionTime, 1e-7); + Assertions.assertEquals(225, adaptionTime, 1e-7); // the frequency would be 3600 / 225 / 4 = 4.0 // two special, fast courses @@ -87,22 +88,22 @@ void testCalcAverageAdaptionTime_1() { connections.add(new ODConnection(Time.parseTime("08:48:00"), 300, 60, 150, 0, null)); connections = RooftopUtils.sortAndFilterConnections(connections, 9 * 3600); - Assert.assertEquals(6, connections.size()); + Assertions.assertEquals(6, connections.size()); // there should now be departures at 08:05, 08:22, 08:35, 08:48, 09:05 // resulting in a slightly higher adaption time adaptionTime = RooftopUtils.calcAverageAdaptionTime(connections, Time.parseTime("08:00:00"), Time.parseTime("09:00:00")); - Assert.assertEquals(254, adaptionTime, 1e-7); + Assertions.assertEquals(254, adaptionTime, 1e-7); // the frequency would be 3600 / 254 / 4 = 3.5433 connections.add(new ODConnection(Time.parseTime("08:15:00"), 300, 60, 150, 0, null)); connections = RooftopUtils.sortAndFilterConnections(connections, 9 * 3600); - Assert.assertEquals(7, connections.size()); + Assertions.assertEquals(7, connections.size()); adaptionTime = RooftopUtils.calcAverageAdaptionTime(connections, Time.parseTime("08:00:00"), Time.parseTime("09:00:00")); - Assert.assertEquals(219, adaptionTime, 1e-7); + Assertions.assertEquals(219, adaptionTime, 1e-7); // the frequency would be 3600 / 219 / 4 = 4.1096 } @@ -120,7 +121,7 @@ void testCalcAverageAdaptionTime_2() { double adaptionTime = RooftopUtils.calcAverageAdaptionTime(connections, Time.parseTime("08:00:00"), Time.parseTime("09:00:00")); // there is a departure every 900 seconds, max adaption time would be 450, average of that would be 225.0. - Assert.assertEquals(225, adaptionTime, 1e-7); + Assertions.assertEquals(225, adaptionTime, 1e-7); // the frequency would be 3600 / 225 / 4 = 4.0 } @@ -140,7 +141,7 @@ void testCalcAverageAdaptionTime_noEarlierDeparture() { // average adaption time should be: 20min between 7:00 and 7:40, and 10min between 7:40 and 8:00 // ==> 40*20 + 20*10 = 800 + 200 = 1000 --> 1000 / 60 = 16.666min = 1000 seconds - Assert.assertEquals(1000.0, adaptionTime, 1e-7); + Assertions.assertEquals(1000.0, adaptionTime, 1e-7); } @Test @@ -157,7 +158,7 @@ void testCalcAverageAdaptionTime_noLaterDeparture() { // average adaption time should be: 25min between 7:00 and 7:10, 15min between 7:10 and 7:40, 10min between 7:40 and 8:00 // ==> 25*10 + 15*30 + 10*20 = 250 + 450 + 200 = 900 --> 900 seconds - Assert.assertEquals(900.0, adaptionTime, 1e-7); + Assertions.assertEquals(900.0, adaptionTime, 1e-7); } @Test @@ -174,7 +175,7 @@ void testCalcAverageAdaptionTime_noDepartureInRange() { // average adaption time should be: 40min between 7:00 and 7:40, 50min between 7:40 and 8:00 // ==> 40*40 + 50*20 = 1600 + 1000 = 2600 --> 2600 seconds - Assert.assertEquals(2600.0, adaptionTime, 1e-7); + Assertions.assertEquals(2600.0, adaptionTime, 1e-7); } @Test @@ -190,7 +191,7 @@ void testCalcAverageAdaptionTime_singleDepartureEarly() { // average adaption time should be: 80min between 7:00 and 8:00 // ==> 80*60 = 4800 --> 4800 seconds - Assert.assertEquals(4800.0, adaptionTime, 1e-7); + Assertions.assertEquals(4800.0, adaptionTime, 1e-7); } @Test @@ -206,7 +207,7 @@ void testCalcAverageAdaptionTime_singleDepartureInRange() { // average adaption time should be: 5min between 7:00 and 7:10, 25min between 7:10 and 8:00 // ==> 5*10 + 25*50 = 50 + 1250 = 1300 --> 1300 seconds - Assert.assertEquals(1300.0, adaptionTime, 1e-7); + Assertions.assertEquals(1300.0, adaptionTime, 1e-7); } @Test @@ -222,7 +223,7 @@ void testCalcAverageAdaptionTime_singleDepartureLate() { // average adaption time should be: 40min between 7:00 and 8:00 // ==> 40*60 = 2400 --> 2400 seconds - Assert.assertEquals(2400.0, adaptionTime, 1e-7); + Assertions.assertEquals(2400.0, adaptionTime, 1e-7); } @Test @@ -241,46 +242,46 @@ void testCalcConnectionShares() { Map shares = RooftopUtils.calcConnectionShares(connections, Time.parseTime("08:00:00"), Time.parseTime("09:00:00")); // there is a departure every 900 seconds, max adaption time would be 450, average of that would be 225.0. // every connection should have the same share, i.e. 1/4th = 0.25, but the first and the last only cover part of the time, so they have less - Assert.assertEquals(6, shares.size()); - Assert.assertEquals(0.0 / 60.0, shares.get(c0), 1e-7); - Assert.assertEquals(11.5 / 60.0, shares.get(c1), 1e-7); - Assert.assertEquals(15.0 / 60.0, shares.get(c2), 1e-7); - Assert.assertEquals(15.0 / 60.0, shares.get(c3), 1e-7); - Assert.assertEquals(15.0 / 60.0, shares.get(c4), 1e-7); - Assert.assertEquals(3.5 / 60.0, shares.get(c5), 1e-7); + Assertions.assertEquals(6, shares.size()); + Assertions.assertEquals(0.0 / 60.0, shares.get(c0), 1e-7); + Assertions.assertEquals(11.5 / 60.0, shares.get(c1), 1e-7); + Assertions.assertEquals(15.0 / 60.0, shares.get(c2), 1e-7); + Assertions.assertEquals(15.0 / 60.0, shares.get(c3), 1e-7); + Assertions.assertEquals(15.0 / 60.0, shares.get(c4), 1e-7); + Assertions.assertEquals(3.5 / 60.0, shares.get(c5), 1e-7); // two special, fast courses connections.add(c6 = new ODConnection(Time.parseTime("08:22:00"), 300, 60, 150, 0, null)); connections.add(c7 = new ODConnection(Time.parseTime("08:48:00"), 300, 60, 150, 0, null)); connections = RooftopUtils.sortAndFilterConnections(connections, 9 * 3600); - Assert.assertEquals(6, connections.size()); + Assertions.assertEquals(6, connections.size()); // there should now be departures at 08:05, 08:22, 08:35, 08:48, 09:05 shares = RooftopUtils.calcConnectionShares(connections, Time.parseTime("08:00:00"), Time.parseTime("09:00:00")); - Assert.assertEquals(6, shares.size()); - Assert.assertEquals(10.0 / 60.0, shares.get(c1), 1e-7); - Assert.assertEquals(20.0 / 60.0, shares.get(c6), 1e-7); - Assert.assertEquals(8.0 / 60.0, shares.get(c3), 1e-7); - Assert.assertEquals(20.0 / 60.0, shares.get(c7), 1e-7); - Assert.assertEquals(2.0 / 60.0, shares.get(c5), 1e-7); + Assertions.assertEquals(6, shares.size()); + Assertions.assertEquals(10.0 / 60.0, shares.get(c1), 1e-7); + Assertions.assertEquals(20.0 / 60.0, shares.get(c6), 1e-7); + Assertions.assertEquals(8.0 / 60.0, shares.get(c3), 1e-7); + Assertions.assertEquals(20.0 / 60.0, shares.get(c7), 1e-7); + Assertions.assertEquals(2.0 / 60.0, shares.get(c5), 1e-7); connections.add(c8 = new ODConnection(Time.parseTime("08:15:00"), 300, 60, 150, 0, null)); connections = RooftopUtils.sortAndFilterConnections(connections, 9 * 3600); - Assert.assertEquals(7, connections.size()); + Assertions.assertEquals(7, connections.size()); // there should now be departures at 08:05, 08:15, 08:22, 08:35, 08:48, 09:05 shares = RooftopUtils.calcConnectionShares(connections, Time.parseTime("08:00:00"), Time.parseTime("09:00:00")); - Assert.assertEquals(7, shares.size()); - Assert.assertEquals(6.5 / 60.0, shares.get(c1), 1e-7); - Assert.assertEquals(11.0 / 60.0, shares.get(c8), 1e-7); - Assert.assertEquals(12.5 / 60.0, shares.get(c6), 1e-7); - Assert.assertEquals(8.0 / 60.0, shares.get(c3), 1e-7); - Assert.assertEquals(20.0 / 60.0, shares.get(c7), 1e-7); - Assert.assertEquals(2.0 / 60.0, shares.get(c5), 1e-7); + Assertions.assertEquals(7, shares.size()); + Assertions.assertEquals(6.5 / 60.0, shares.get(c1), 1e-7); + Assertions.assertEquals(11.0 / 60.0, shares.get(c8), 1e-7); + Assertions.assertEquals(12.5 / 60.0, shares.get(c6), 1e-7); + Assertions.assertEquals(8.0 / 60.0, shares.get(c3), 1e-7); + Assertions.assertEquals(20.0 / 60.0, shares.get(c7), 1e-7); + Assertions.assertEquals(2.0 / 60.0, shares.get(c5), 1e-7); } @Test @@ -304,10 +305,10 @@ void testCalculationShares_noEarlierDeparture() { System.out.println(Time.writeTime(c.departureTime) + " --> " + share); } - Assert.assertEquals(1.0, sum, 1e-7); + Assertions.assertEquals(1.0, sum, 1e-7); - Assert.assertEquals(1.0, shares.get(c0), 1e-7); - Assert.assertEquals(0.0, shares.get(c1), 1e-7); + Assertions.assertEquals(1.0, shares.get(c0), 1e-7); + Assertions.assertEquals(0.0, shares.get(c1), 1e-7); } @Test @@ -333,10 +334,10 @@ void testCalculationShares_noEarlierDeparture2() { System.out.println(Time.writeTime(c.departureTime) + " --> " + share); } - Assert.assertEquals(1.0, sum, 1e-7); + Assertions.assertEquals(1.0, sum, 1e-7); - Assert.assertEquals(2.0 / 3.0, shares.get(c0), 1e-7); - Assert.assertEquals(1.0 / 3.0, shares.get(c1), 1e-7); + Assertions.assertEquals(2.0 / 3.0, shares.get(c0), 1e-7); + Assertions.assertEquals(1.0 / 3.0, shares.get(c1), 1e-7); } @Test @@ -362,10 +363,10 @@ void testCalculationShares_noLaterDeparture() { System.out.println(Time.writeTime(c.departureTime) + " --> " + share); } - Assert.assertEquals(1.0, sum, 1e-7); + Assertions.assertEquals(1.0, sum, 1e-7); - Assert.assertEquals(1.0 / 6.0, shares.get(c0), 1e-7); - Assert.assertEquals(5.0 / 6.0, shares.get(c1), 1e-7); + Assertions.assertEquals(1.0 / 6.0, shares.get(c0), 1e-7); + Assertions.assertEquals(5.0 / 6.0, shares.get(c1), 1e-7); } @Test @@ -391,10 +392,10 @@ void testCalculationShares_noDepartureInRange() { System.out.println(Time.writeTime(c.departureTime) + " --> " + share); } - Assert.assertEquals(1.0, sum, 1e-7); + Assertions.assertEquals(1.0, sum, 1e-7); - Assert.assertEquals(2.0 / 3.0, shares.get(c0), 1e-7); - Assert.assertEquals(1.0 / 3.0, shares.get(c1), 1e-7); + Assertions.assertEquals(2.0 / 3.0, shares.get(c0), 1e-7); + Assertions.assertEquals(1.0 / 3.0, shares.get(c1), 1e-7); } @Test @@ -405,7 +406,7 @@ void testCalculationShares_singleDepartureEarly() { connections.add(c0 = new ODConnection(Time.parseTime("06:15:00"), 16080, 245, 125, 5, null)); Map shares = RooftopUtils.calcConnectionShares(connections, Time.parseTime("07:00:00"), Time.parseTime("08:00:00")); - Assert.assertEquals(1.0, shares.get(c0), 1e-7); + Assertions.assertEquals(1.0, shares.get(c0), 1e-7); } @Test @@ -416,7 +417,7 @@ void testCalculationShares_singleDepartureInRange() { connections.add(c0 = new ODConnection(Time.parseTime("07:15:00"), 16080, 245, 125, 5, null)); Map shares = RooftopUtils.calcConnectionShares(connections, Time.parseTime("07:00:00"), Time.parseTime("08:00:00")); - Assert.assertEquals(1.0, shares.get(c0), 1e-7); + Assertions.assertEquals(1.0, shares.get(c0), 1e-7); } @Test @@ -427,6 +428,6 @@ void testCalculationShares_singleDepartureLate() { connections.add(c0 = new ODConnection(Time.parseTime("08:15:00"), 16080, 245, 125, 5, null)); Map shares = RooftopUtils.calcConnectionShares(connections, Time.parseTime("07:00:00"), Time.parseTime("08:00:00")); - Assert.assertEquals(1.0, shares.get(c0), 1e-7); + Assertions.assertEquals(1.0, shares.get(c0), 1e-7); } } diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/config/SBBTransitConfigGroupTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/config/SBBTransitConfigGroupTest.java index e78c20f85e2..c2ac906d1b1 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/config/SBBTransitConfigGroupTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/config/SBBTransitConfigGroupTest.java @@ -23,7 +23,7 @@ import java.io.ByteArrayOutputStream; import java.io.OutputStreamWriter; import java.util.Collections; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigReader; @@ -55,8 +55,8 @@ void testConfigIO() { ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); new ConfigReader(config2).parse(input); - Assert.assertEquals(1, ptConfig2.getDeterministicServiceModes().size()); - Assert.assertTrue(ptConfig2.getDeterministicServiceModes().contains("schienenfahrzeug")); - Assert.assertEquals(4, ptConfig2.getCreateLinkEventsInterval()); + Assertions.assertEquals(1, ptConfig2.getDeterministicServiceModes().size()); + Assertions.assertTrue(ptConfig2.getDeterministicServiceModes().contains("schienenfahrzeug")); + Assertions.assertEquals(4, ptConfig2.getCreateLinkEventsInterval()); } } diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java index 5c0b3452454..3484f72f2f3 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java @@ -24,8 +24,8 @@ import com.google.inject.Provides; import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -95,7 +95,7 @@ QSimComponentsConfig provideQSimComponentsConfig() { // this test mostly checks that no exception occurred - Assert.assertTrue(config.getModules().get(SBBTransitConfigGroup.GROUP_NAME) instanceof SBBTransitConfigGroup); + Assertions.assertTrue(config.getModules().get(SBBTransitConfigGroup.GROUP_NAME) instanceof SBBTransitConfigGroup); } } diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java index 7a06e85d0ed..c60a6c91a02 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java @@ -24,7 +24,7 @@ import java.util.Set; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.controler.Controler; @@ -58,13 +58,13 @@ void testIntegration() { controler.run(); Mobsim mobsim = controler.getInjector().getInstance(Mobsim.class); - Assert.assertNotNull(mobsim); - Assert.assertEquals(QSim.class, mobsim.getClass()); + Assertions.assertNotNull(mobsim); + Assertions.assertEquals(QSim.class, mobsim.getClass()); QSim qsim = (QSim) mobsim; QSimComponentsConfig components = qsim.getChildInjector().getInstance(QSimComponentsConfig.class); - Assert.assertTrue(components.hasNamedComponent(SBBTransitEngineQSimModule.COMPONENT_NAME)); - Assert.assertFalse(components.hasNamedComponent(TransitEngineModule.TRANSIT_ENGINE_NAME)); + Assertions.assertTrue(components.hasNamedComponent(SBBTransitEngineQSimModule.COMPONENT_NAME)); + Assertions.assertFalse(components.hasNamedComponent(TransitEngineModule.TRANSIT_ENGINE_NAME)); } @Test @@ -86,9 +86,9 @@ void testIntegration_misconfiguration() { try { controler.run(); - Assert.fail("Expected exception, got none."); + Assertions.fail("Expected exception, got none."); } catch (RuntimeException e) { - Assert.assertTrue(e.getMessage().endsWith("This will not work! common modes = train")); + Assertions.assertTrue(e.getMessage().endsWith("This will not work! common modes = train")); } } diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineTest.java index f176c763bd0..04f2a54a88e 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineTest.java @@ -23,7 +23,7 @@ import java.util.Map; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; @@ -65,8 +65,8 @@ public class SBBTransitQSimEngineTest { private static final Logger log = LogManager.getLogger(SBBTransitQSimEngineTest.class); private static void assertEqualEvent(Class eventClass, double time, Event event) { - Assert.assertTrue(event.getClass().isAssignableFrom(event.getClass())); - Assert.assertEquals(time, event.getTime(), 1e-7); + Assertions.assertTrue(event.getClass().isAssignableFrom(event.getClass())); + Assertions.assertEquals(time, event.getTime(), 1e-7); } @Test @@ -81,9 +81,9 @@ void testDriver() { trEngine.insertAgentsIntoMobsim(); Map, MobsimAgent> agents = qSim.getAgents(); - Assert.assertEquals("Expected one driver as agent.", 1, agents.size()); + Assertions.assertEquals(1, agents.size(), "Expected one driver as agent."); MobsimAgent agent = agents.values().iterator().next(); - Assert.assertTrue(agent instanceof SBBTransitDriverAgent); + Assertions.assertTrue(agent instanceof SBBTransitDriverAgent); SBBTransitDriverAgent driver = (SBBTransitDriverAgent) agent; TransitRoute route = driver.getTransitRoute(); List stops = route.getStops(); @@ -95,7 +95,7 @@ void testDriver() { assertNextStop(driver, stops.get(3), depTime); assertNextStop(driver, stops.get(4), depTime); - Assert.assertNull(driver.getNextRouteStop()); + Assertions.assertNull(driver.getNextRouteStop()); } private void assertNextStop(SBBTransitDriverAgent driver, TransitRouteStop stop, double routeDepTime) { @@ -103,7 +103,7 @@ private void assertNextStop(SBBTransitDriverAgent driver, TransitRouteStop stop, double depOffset = stop.getDepartureOffset().or(stop.getArrivalOffset()).seconds(); TransitStopFacility f = stop.getStopFacility(); - Assert.assertEquals(stop, driver.getNextRouteStop()); + Assertions.assertEquals(stop, driver.getNextRouteStop()); driver.arrive(stop, routeDepTime + arrOffset); double stopTimeSum = 0.0; @@ -112,8 +112,8 @@ private void assertNextStop(SBBTransitDriverAgent driver, TransitRouteStop stop, stopTime = driver.handleTransitStop(f, routeDepTime + arrOffset + stopTimeSum); stopTimeSum += stopTime; } while (stopTime > 0); - Assert.assertEquals(depOffset - arrOffset, stopTimeSum, 1e-7); - Assert.assertEquals("last stop time should have been 0.0", 0.0, stopTime, 1e-7); + Assertions.assertEquals(depOffset - arrOffset, stopTimeSum, 1e-7); + Assertions.assertEquals(0.0, stopTime, 1e-7, "last stop time should have been 0.0"); driver.depart(f, routeDepTime + depOffset); } @@ -141,7 +141,7 @@ void testEvents_withoutPassengers_withoutLinks() { System.out.println(event.toString()); } - Assert.assertEquals("wrong number of events.", 15, allEvents.size()); + Assertions.assertEquals(15, allEvents.size(), "wrong number of events."); assertEqualEvent(TransitDriverStartsEvent.class, 30000, allEvents.get(0)); assertEqualEvent(PersonDepartureEvent.class, 30000, allEvents.get(1)); assertEqualEvent(PersonEntersVehicleEvent.class, 30000, allEvents.get(2)); @@ -189,7 +189,7 @@ void testEvents_withPassengers_withoutLinks() { System.out.println(event.toString()); } - Assert.assertEquals("wrong number of events.", 22, allEvents.size()); + Assertions.assertEquals(22, allEvents.size(), "wrong number of events."); assertEqualEvent(ActivityEndEvent.class, 29500, allEvents.get(0)); // passenger assertEqualEvent(PersonDepartureEvent.class, 29500, allEvents.get(1)); // passenger assertEqualEvent(AgentWaitingForPtEvent.class, 29500, allEvents.get(2)); // passenger @@ -241,7 +241,7 @@ void testEvents_withThreePassengers_withoutLinks() { System.out.println(event.toString()); } - Assert.assertEquals("wrong number of events.", 36, allEvents.size()); + Assertions.assertEquals(36, allEvents.size(), "wrong number of events."); assertEqualEvent(ActivityEndEvent.class, 29500, allEvents.get(0)); // passenger 1 assertEqualEvent(ActivityEndEvent.class, 29500, allEvents.get(1)); // passenger 2 assertEqualEvent(ActivityEndEvent.class, 29500, allEvents.get(2)); // passenger 3 @@ -305,7 +305,7 @@ void testEvents_withoutPassengers_withLinks() { System.out.println(event.toString()); } - Assert.assertEquals("wrong number of events.", 23, allEvents.size()); + Assertions.assertEquals(23, allEvents.size(), "wrong number of events."); assertEqualEvent(TransitDriverStartsEvent.class, 30000, allEvents.get(0)); assertEqualEvent(PersonDepartureEvent.class, 30000, allEvents.get(1)); assertEqualEvent(PersonEntersVehicleEvent.class, 30000, allEvents.get(2)); @@ -357,7 +357,7 @@ void testEvents_withoutPassengers_withLinks_Sesselbahn() { System.out.println(event.toString()); } - Assert.assertEquals("wrong number of events.", 13, allEvents.size()); + Assertions.assertEquals(13, allEvents.size(), "wrong number of events."); assertEqualEvent(TransitDriverStartsEvent.class, 35000, allEvents.get(0)); assertEqualEvent(PersonDepartureEvent.class, 35000, allEvents.get(1)); assertEqualEvent(PersonEntersVehicleEvent.class, 35000, allEvents.get(2)); @@ -404,7 +404,7 @@ void testEvents_withoutPassengers_withLinks_SesselbahnMalformed() { System.out.println(event.toString()); } - Assert.assertEquals("wrong number of events.", 13, allEvents.size()); + Assertions.assertEquals(13, allEvents.size(), "wrong number of events."); assertEqualEvent(TransitDriverStartsEvent.class, 35000, allEvents.get(0)); assertEqualEvent(PersonDepartureEvent.class, 35000, allEvents.get(1)); assertEqualEvent(PersonEntersVehicleEvent.class, 35000, allEvents.get(2)); @@ -450,7 +450,7 @@ void testEvents_withoutPassengers_withLinks_DelayedFirstDeparture() { System.out.println(event.toString()); } - Assert.assertEquals("wrong number of events.", 23, allEvents.size()); + Assertions.assertEquals(23, allEvents.size(), "wrong number of events."); assertEqualEvent(TransitDriverStartsEvent.class, 30000, allEvents.get(0)); assertEqualEvent(PersonDepartureEvent.class, 30000, allEvents.get(1)); assertEqualEvent(PersonEntersVehicleEvent.class, 30000, allEvents.get(2)); @@ -505,7 +505,7 @@ void testEvents_withoutPassengers_withLinks_FromToLoopLink() { System.out.println(event.toString()); } - Assert.assertEquals("wrong number of events.", 23, allEvents.size()); + Assertions.assertEquals(23, allEvents.size(), "wrong number of events."); assertEqualEvent(TransitDriverStartsEvent.class, 30000, allEvents.get(0)); assertEqualEvent(PersonDepartureEvent.class, 30000, allEvents.get(1)); assertEqualEvent(PersonEntersVehicleEvent.class, 30000, allEvents.get(2)); @@ -550,7 +550,7 @@ void testMisconfiguration() { try { qSim.run(); - Assert.fail("Expected a RuntimeException due misconfiguration, but got none."); + Assertions.fail("Expected a RuntimeException due misconfiguration, but got none."); } catch (RuntimeException e) { log.info("Caught expected exception, all is fine.", e); } @@ -586,7 +586,7 @@ void testCreateEventsInterval() { if (iteration == 0 || iteration == 3 || iteration == 6 || iteration == 9) { expectedEventsCount = 23; } - Assert.assertEquals("wrong number of events in iteration " + iteration, expectedEventsCount, collector.getEvents().size()); + Assertions.assertEquals(expectedEventsCount, collector.getEvents().size(), "wrong number of events in iteration " + iteration); } } } diff --git a/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java b/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java index 5e6a5d0cd48..007d4ff73b1 100644 --- a/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java +++ b/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.events.handler.PersonDepartureEventHandler; import org.matsim.contrib.shared_mobility.run.SharingConfigGroup; @@ -157,30 +157,30 @@ final void test() throws UncheckedIOException, ConfigurationException, URISyntax OutputData data = countLegs(controller.getControlerIO().getOutputPath() + "/output_events.xml.gz"); - Assert.assertEquals(82629, (long) data.counts.get("car")); - Assert.assertEquals(29739, (long) data.counts.get("walk")); - Assert.assertEquals(31, (long) data.counts.get("bike")); - Assert.assertEquals(19029, (long) data.counts.get("pt")); + Assertions.assertEquals(82629, (long) data.counts.get("car")); + Assertions.assertEquals(29739, (long) data.counts.get("walk")); + Assertions.assertEquals(31, (long) data.counts.get("bike")); + Assertions.assertEquals(19029, (long) data.counts.get("pt")); - Assert.assertEquals(21, (long) data.pickupCounts.get("wheels")); - Assert.assertEquals(2, (long) data.pickupCounts.get("mobility")); - Assert.assertEquals(10, (long) data.pickupCounts.get("velib")); + Assertions.assertEquals(21, (long) data.pickupCounts.get("wheels")); + Assertions.assertEquals(2, (long) data.pickupCounts.get("mobility")); + Assertions.assertEquals(10, (long) data.pickupCounts.get("velib")); - Assert.assertEquals(21, (long) data.dropoffCounts.get("wheels")); - Assert.assertEquals(0, (long) data.dropoffCounts.getOrDefault("mobility", 0L)); - Assert.assertEquals(10, (long) data.dropoffCounts.get("velib")); + Assertions.assertEquals(21, (long) data.dropoffCounts.get("wheels")); + Assertions.assertEquals(0, (long) data.dropoffCounts.getOrDefault("mobility", 0L)); + Assertions.assertEquals(10, (long) data.dropoffCounts.get("velib")); - Assert.assertEquals(0, (long) data.failedPickupCounts.getOrDefault("wheels",0L)); - Assert.assertEquals(0, (long) data.failedPickupCounts.getOrDefault("mobility",0L)); - Assert.assertEquals(0, (long) data.failedPickupCounts.getOrDefault("velib",0L)); + Assertions.assertEquals(0, (long) data.failedPickupCounts.getOrDefault("wheels",0L)); + Assertions.assertEquals(0, (long) data.failedPickupCounts.getOrDefault("mobility",0L)); + Assertions.assertEquals(0, (long) data.failedPickupCounts.getOrDefault("velib",0L)); - Assert.assertEquals(0, (long) data.failedDropoffCounts.getOrDefault("wheels", 0L)); - Assert.assertEquals(0, (long) data.failedDropoffCounts.getOrDefault("mobility", 0L)); - Assert.assertEquals(0, (long) data.failedDropoffCounts.getOrDefault("velib", 0L)); + Assertions.assertEquals(0, (long) data.failedDropoffCounts.getOrDefault("wheels", 0L)); + Assertions.assertEquals(0, (long) data.failedDropoffCounts.getOrDefault("mobility", 0L)); + Assertions.assertEquals(0, (long) data.failedDropoffCounts.getOrDefault("velib", 0L)); - Assert.assertEquals(2, (long) data.vehicleCounts.get("wheels")); - Assert.assertEquals(2, (long) data.vehicleCounts.get("mobility")); - Assert.assertEquals(2, (long) data.vehicleCounts.get("velib")); + Assertions.assertEquals(2, (long) data.vehicleCounts.get("wheels")); + Assertions.assertEquals(2, (long) data.vehicleCounts.get("mobility")); + Assertions.assertEquals(2, (long) data.vehicleCounts.get("velib")); } static class OutputData { diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateIntergreensExampleTest.java b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateIntergreensExampleTest.java index f49b8bb8cca..4d5296fe17a 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateIntergreensExampleTest.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateIntergreensExampleTest.java @@ -23,7 +23,7 @@ import java.io.IOException; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.utils.misc.CRCChecksum; @@ -46,12 +46,12 @@ void testIntergreenExample(){ CreateIntergreensExample.main(args); } catch (IOException e) { e.printStackTrace(); - Assert.fail("something went wrong") ; + Assertions.fail("something went wrong") ; } // compare intergreen output - Assert.assertEquals("different intergreen files", - CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "intergreens.xml"), - CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "intergreens.xml")); + Assertions.assertEquals(CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "intergreens.xml"), + CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "intergreens.xml"), + "different intergreen files"); } } diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleTest.java b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleTest.java index bd97d5c2c26..1bfd33ff1f3 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleTest.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleTest.java @@ -24,8 +24,8 @@ import java.io.IOException; import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.utils.misc.CRCChecksum; @@ -48,7 +48,7 @@ void testCreateSignalInputExample(){ (new CreateSignalInputExample()).run(testUtils.getOutputDirectory()); } catch (IOException e) { e.printStackTrace(); - Assert.fail("something went wrong") ; + Assertions.fail("something went wrong") ; } // compare signal output { @@ -56,16 +56,16 @@ void testCreateSignalInputExample(){ final String referenceFilename = DIR_TO_COMPARE_WITH + "signal_systems.xml"; log.info( "outputFilename=" + outputFilename ) ; log.info( "referenceFilename=" + referenceFilename ) ; - Assert.assertEquals("different signal system files", - CRCChecksum.getCRCFromFile(outputFilename), - CRCChecksum.getCRCFromFile(referenceFilename)); + Assertions.assertEquals(CRCChecksum.getCRCFromFile(outputFilename), + CRCChecksum.getCRCFromFile(referenceFilename), + "different signal system files"); } - Assert.assertEquals("different signal group files", - CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "signal_groups.xml"), - CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "signal_groups.xml")); - Assert.assertEquals("different signal control files", - CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "signal_groups.xml"), - CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "signal_groups.xml")); + Assertions.assertEquals(CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "signal_groups.xml"), + CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "signal_groups.xml"), + "different signal group files"); + Assertions.assertEquals(CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "signal_groups.xml"), + CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "signal_groups.xml"), + "different signal control files"); } } diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleWithLanesTest.java b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleWithLanesTest.java index f76efe99da2..38eb9821c37 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleWithLanesTest.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/CreateSignalInputExampleWithLanesTest.java @@ -23,7 +23,7 @@ import java.io.IOException; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.utils.misc.CRCChecksum; @@ -45,21 +45,21 @@ void testCreateSignalInputExampleWithLanes(){ (new CreateSignalInputWithLanesExample()).run(testUtils.getOutputDirectory()); } catch (IOException e) { e.printStackTrace(); - Assert.fail("something went wrong") ; + Assertions.fail("something went wrong") ; } // compare signal output - Assert.assertEquals("different signal system files", - CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "signal_systems.xml"), - CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "signal_systems.xml")); - Assert.assertEquals("different signal group files", - CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "signal_groups.xml"), - CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "signal_groups.xml")); - Assert.assertEquals("different signal control files", - CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "signal_groups.xml"), - CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "signal_groups.xml")); - Assert.assertEquals("different lane files", - CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "lane_definitions_v2.0.xml"), - CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "lane_definitions_v2.0.xml")); + Assertions.assertEquals(CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "signal_systems.xml"), + CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "signal_systems.xml"), + "different signal system files"); + Assertions.assertEquals(CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "signal_groups.xml"), + CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "signal_groups.xml"), + "different signal group files"); + Assertions.assertEquals(CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "signal_groups.xml"), + CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "signal_groups.xml"), + "different signal control files"); + Assertions.assertEquals(CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "lane_definitions_v2.0.xml"), + CRCChecksum.getCRCFromFile(DIR_TO_COMPARE_WITH + "lane_definitions_v2.0.xml"), + "different lane files"); } } diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleTest.java b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleTest.java index 9da52c5d00a..52438c7aa96 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleTest.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleTest.java @@ -18,7 +18,7 @@ * *********************************************************************** */ package org.matsim.codeexamples.fixedTimeSignals; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.config.Config; @@ -41,7 +41,7 @@ final void testExampleWithHoles() { RunSignalSystemsExampleWithHoles.run(usingOTFVis); } catch (Exception ee ) { ee.printStackTrace(); - Assert.fail("something went wrong: " + ee.getMessage()) ; + Assertions.fail("something went wrong: " + ee.getMessage()) ; } } @@ -56,7 +56,7 @@ final void testMinimalExample() { RunSignalSystemsExample.run(config, false); } catch (Exception ee ) { ee.printStackTrace(); - Assert.fail("something went wrong: " + ee.getMessage()) ; + Assertions.fail("something went wrong: " + ee.getMessage()) ; } } diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunVisualizeSignalScenarioWithLanesGUITest.java b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunVisualizeSignalScenarioWithLanesGUITest.java index c40f531b26f..552be371b31 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunVisualizeSignalScenarioWithLanesGUITest.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunVisualizeSignalScenarioWithLanesGUITest.java @@ -1,6 +1,6 @@ package org.matsim.codeexamples.fixedTimeSignals; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -22,7 +22,7 @@ public static void main(String[] args) { VisualizeSignalScenarioWithLanes.run(startOtfvis); } catch (Exception ee ) { ee.printStackTrace(); - Assert.fail("something went wrong") ; + Assertions.fail("something went wrong") ; } } @@ -38,7 +38,7 @@ void testSignalExampleVisualizationWoLanes(){ VisualizeSignalScenario.run(false); } catch (Exception ee) { ee.printStackTrace(); - Assert.fail("something went wrong"); + Assertions.fail("something went wrong"); } } diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/FixResponsiveSignalResultsIT.java b/contribs/signals/src/test/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/FixResponsiveSignalResultsIT.java index ce1989f66de..3e4c472ffb2 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/FixResponsiveSignalResultsIT.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/FixResponsiveSignalResultsIT.java @@ -24,8 +24,8 @@ import java.util.SortedMap; import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -66,10 +66,10 @@ void testOneCrossingExample() { LOG.info("SignalGroup1: onset " + group1Setting.getOnset() + ", dropping " + group1Setting.getDropping()); LOG.info("SignalGroup2: onset " + group2Setting.getOnset() + ", dropping " + group2Setting.getDropping()); - Assert.assertEquals(0, group1Setting.getOnset()); - Assert.assertEquals(25, group1Setting.getDropping()); - Assert.assertEquals(30, group2Setting.getOnset()); - Assert.assertEquals(55, group2Setting.getDropping()); + Assertions.assertEquals(0, group1Setting.getOnset()); + Assertions.assertEquals(25, group1Setting.getDropping()); + Assertions.assertEquals(30, group2Setting.getOnset()); + Assertions.assertEquals(55, group2Setting.getDropping()); } } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/io/MatsimFileTypeGuesserSignalsTest.java b/contribs/signals/src/test/java/org/matsim/contrib/io/MatsimFileTypeGuesserSignalsTest.java index 7bd326a50b0..e74c5396807 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/io/MatsimFileTypeGuesserSignalsTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/io/MatsimFileTypeGuesserSignalsTest.java @@ -19,9 +19,7 @@ * *********************************************************************** */ package org.matsim.contrib.io; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.*; import java.io.IOException; diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/CalculateAngleTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/CalculateAngleTest.java index 196d6674661..e822de14af0 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/CalculateAngleTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/CalculateAngleTest.java @@ -4,8 +4,8 @@ import java.util.TreeMap; import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -43,22 +43,21 @@ void testGetLeftLane() { MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(conf); new MatsimNetworkReader(scenario.getNetwork()).parse(conf.network().getInputFileURL(conf.getContext())); - Assert.assertEquals("Has to be 'null', since there is no other way back but Link 11.", - null, NetworkUtils.getLeftmostTurnExcludingU(scenario.getNetwork().getLinks().get(Id.create("1", Link.class)))); + Assertions.assertEquals(null, NetworkUtils.getLeftmostTurnExcludingU(scenario.getNetwork().getLinks().get(Id.create("1", Link.class))), "Has to be 'null', since there is no other way back but Link 11."); - Assert.assertEquals( + Assertions.assertEquals( scenario.getNetwork().getLinks().get(Id.create("2", Link.class)), NetworkUtils.getLeftmostTurnExcludingU(scenario.getNetwork().getLinks().get(Id.create("11", Link.class)))); - Assert.assertEquals( + Assertions.assertEquals( scenario.getNetwork().getLinks().get(Id.create("3", Link.class)), NetworkUtils.getLeftmostTurnExcludingU(scenario.getNetwork().getLinks().get(Id.create("22", Link.class)))); - Assert.assertEquals( + Assertions.assertEquals( scenario.getNetwork().getLinks().get(Id.create("4", Link.class)), NetworkUtils.getLeftmostTurnExcludingU(scenario.getNetwork().getLinks().get(Id.create("33", Link.class)))); - Assert.assertEquals( + Assertions.assertEquals( scenario.getNetwork().getLinks().get(Id.create("1", Link.class)), NetworkUtils.getLeftmostTurnExcludingU(scenario.getNetwork().getLinks().get(Id.create("44", Link.class)))); - Assert.assertEquals( + Assertions.assertEquals( scenario.getNetwork().getLinks().get(Id.create("5", Link.class)), NetworkUtils.getLeftmostTurnExcludingU(scenario.getNetwork().getLinks().get(Id.create("3", Link.class)))); } @@ -77,14 +76,14 @@ void testGetOutLinksSortedByAngle(){ Network net = scenario.getNetwork(); TreeMap m = NetworkUtils.getOutLinksSortedClockwiseByAngle(net.getLinks().get(Id.create(1, Link.class))); Entry entry = m.firstEntry(); - Assert.assertEquals("For angle " + angle + "CalculateAngle returns not the correct order of outlinks", Id.create(2, Link.class), entry.getValue().getId()); + Assertions.assertEquals(Id.create(2, Link.class), entry.getValue().getId(), "For angle " + angle + "CalculateAngle returns not the correct order of outlinks"); entry = m.higherEntry(entry.getKey()); - Assert.assertEquals("For angle " + angle + "CalculateAngle returns not the correct order of outlinks", Id.create(3, Link.class), entry.getValue().getId()); + Assertions.assertEquals(Id.create(3, Link.class), entry.getValue().getId(), "For angle " + angle + "CalculateAngle returns not the correct order of outlinks"); entry = m.higherEntry(entry.getKey()); - Assert.assertEquals("For angle " + angle + "CalculateAngle returns not the correct order of outlinks", Id.create(4, Link.class), entry.getValue().getId()); + Assertions.assertEquals(Id.create(4, Link.class), entry.getValue().getId(), "For angle " + angle + "CalculateAngle returns not the correct order of outlinks"); Link leftLane = NetworkUtils.getLeftmostTurnExcludingU(net.getLinks().get(Id.create(1, Link.class))); - Assert.assertEquals(Id.create(2, Link.class), leftLane.getId()); + Assertions.assertEquals(Id.create(2, Link.class), leftLane.getId()); } } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/SignalUtilsTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/SignalUtilsTest.java index 69a06a655fd..26e7d9b4cb2 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/SignalUtilsTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/SignalUtilsTest.java @@ -21,7 +21,7 @@ import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.contrib.signals.data.SignalsDataImpl; @@ -60,21 +60,21 @@ final void testCreateAndAddSignalGroups4Signals() { SignalUtils.createAndAddSignalGroups4Signals(groups, system); Map, SignalGroupData> system1Groups = groups.getSignalGroupDataBySignalSystemId().get(id1); - Assert.assertNotNull(system1Groups); - Assert.assertEquals(2, system1Groups.size()); + Assertions.assertNotNull(system1Groups); + Assertions.assertEquals(2, system1Groups.size()); - Assert.assertTrue(system1Groups.containsKey(idSg1)); + Assertions.assertTrue(system1Groups.containsKey(idSg1)); SignalGroupData group4sys = system1Groups.get(idSg1); - Assert.assertNotNull(group4sys); - Assert.assertEquals(idSg1, group4sys.getId()); - Assert.assertNotNull(group4sys.getSignalIds()); - Assert.assertEquals(idS1, group4sys.getSignalIds().iterator().next()); + Assertions.assertNotNull(group4sys); + Assertions.assertEquals(idSg1, group4sys.getId()); + Assertions.assertNotNull(group4sys.getSignalIds()); + Assertions.assertEquals(idS1, group4sys.getSignalIds().iterator().next()); group4sys = system1Groups.get(idSg3); - Assert.assertNotNull(group4sys); - Assert.assertEquals(idSg3, group4sys.getId()); - Assert.assertNotNull(group4sys.getSignalIds()); - Assert.assertEquals(idS3, group4sys.getSignalIds().iterator().next()); + Assertions.assertNotNull(group4sys); + Assertions.assertEquals(idSg3, group4sys.getId()); + Assertions.assertNotNull(group4sys.getSignalIds()); + Assertions.assertEquals(idS3, group4sys.getSignalIds().iterator().next()); } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/analysis/DelayAnalysisToolTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/analysis/DelayAnalysisToolTest.java index a733aaac266..22c34ad8ddc 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/analysis/DelayAnalysisToolTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/analysis/DelayAnalysisToolTest.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -88,7 +88,7 @@ public void handleEvent(Event event) { PrepareForSimUtils.createDefaultPrepareForSim(scenario).run(); new QSimBuilder(scenario.getConfig()).useDefaults().build(scenario, events).run(); - Assert.assertEquals("Total Delay of one agent is not correct", 0.0, handler.getTotalDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, handler.getTotalDelay(), MatsimTestUtils.EPSILON, "Total Delay of one agent is not correct"); if(WRITE_OUTPUT){ generateOutput(scenario, eventslist); } @@ -125,7 +125,7 @@ public void handleEvent(Event event) { for(int i=0; i eventslist) { diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/QSimSignalTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/QSimSignalTest.java index d46a231d78e..663d9076e37 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/QSimSignalTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/QSimSignalTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -123,7 +123,7 @@ void testIntergreensAbortOneAgentDriving() { runQSimWithSignals(scenario, false); // if this code is reached, no exception has been thrown - Assert.fail("The simulation should abort because of intergreens violation."); + Assertions.fail("The simulation should abort because of intergreens violation."); }); } @@ -162,7 +162,7 @@ void testConflictingDirectionsAbortOneAgentDriving() { runQSimWithSignals(scenario, false); // if this code is reached, no exception has been thrown - Assert.fail("The simulation should abort because of intergreens violation."); + Assertions.fail("The simulation should abort because of intergreens violation."); }); } @@ -236,10 +236,10 @@ private void runQSimWithSignals(final Scenario scenario, boolean handleEvents) t public void handleEvent(LinkEnterEvent e) { log.info("Link id: " + e.getLinkId().toString() + " enter time: " + e.getTime()); if (e.getLinkId().equals( fixture.linkId1 )){ - Assert.assertEquals(1.0, e.getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1.0, e.getTime(), MatsimTestUtils.EPSILON); } else if (e.getLinkId().equals( fixture.linkId2 )){ - Assert.assertEquals(this.link2EnterTime, e.getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(this.link2EnterTime, e.getTime(), MatsimTestUtils.EPSILON); } } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeFourWaysTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeFourWaysTest.java index 30c81f963c2..9e341d444a6 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeFourWaysTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeFourWaysTest.java @@ -20,7 +20,7 @@ package org.matsim.contrib.signals.builder; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -125,7 +125,7 @@ private void runQSimWithSignals(final Scenario scenario) { eventsXmlWriter.closeFile(); // Assert.assertEquals("different events files", EventsFileComparator.compareAndReturnInt(this.testUtils.getInputDirectory() + EVENTSFILE, eventsOut), 0); - Assert.assertEquals( Result.FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( this.testUtils.getInputDirectory() + EVENTSFILE, eventsOut ) ); + Assertions.assertEquals( Result.FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( this.testUtils.getInputDirectory() + EVENTSFILE, eventsOut ) ); } } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeOneWayTestIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeOneWayTestIT.java index 958b2b252c4..436a2470b1c 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeOneWayTestIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeOneWayTestIT.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -138,14 +138,14 @@ private static void runAndCompareAllGreenWithNoSignals(final Scenario scenario) log.debug("tF = 60s, " + resultsWoSignals.numberOfVehPassedDuringTimeToMeasure + ", " + resultsWoSignals.numberOfVehPassed + ", " + resultsWoSignals.firstVehPassTime_s + ", " + resultsWoSignals.lastVehPassTime_s); } else { - Assert.fail("seems like no LinkEnterEvent was handled, as this.beginningOfLink2 is not set."); + Assertions.fail("seems like no LinkEnterEvent was handled, as this.beginningOfLink2 is not set."); } // compare values - Assert.assertEquals(5000.0, resultsWithSignals.numberOfVehPassed, MatsimTestUtils.EPSILON); - Assert.assertEquals(resultsWithSignals.firstVehPassTime_s, resultsWoSignals.firstVehPassTime_s, MatsimTestUtils.EPSILON); - Assert.assertEquals(resultsWithSignals.numberOfVehPassed, resultsWoSignals.numberOfVehPassed, MatsimTestUtils.EPSILON); - Assert.assertEquals(resultsWithSignals.numberOfVehPassedDuringTimeToMeasure, resultsWoSignals.numberOfVehPassedDuringTimeToMeasure, MatsimTestUtils.EPSILON); + Assertions.assertEquals(5000.0, resultsWithSignals.numberOfVehPassed, MatsimTestUtils.EPSILON); + Assertions.assertEquals(resultsWithSignals.firstVehPassTime_s, resultsWoSignals.firstVehPassTime_s, MatsimTestUtils.EPSILON); + Assertions.assertEquals(resultsWithSignals.numberOfVehPassed, resultsWoSignals.numberOfVehPassed, MatsimTestUtils.EPSILON); + Assertions.assertEquals(resultsWithSignals.numberOfVehPassedDuringTimeToMeasure, resultsWoSignals.numberOfVehPassedDuringTimeToMeasure, MatsimTestUtils.EPSILON); } private static void runAndTestDifferentGreensplitSignals(final Scenario scenario) { @@ -167,8 +167,8 @@ private static void runAndTestDifferentGreensplitSignals(final Scenario scenario log.debug("circulationTime: " + circulationTime); log.debug("dropping : " + dropping); - Assert.assertEquals((dropping * linkCapacity / circulationTime), stubLinkEnterEventHandler.beginningOfLink2.numberOfVehPassedDuringTimeToMeasure, 1.0); - Assert.assertEquals(5000.0, stubLinkEnterEventHandler.beginningOfLink2.numberOfVehPassed, MatsimTestUtils.EPSILON); + Assertions.assertEquals((dropping * linkCapacity / circulationTime), stubLinkEnterEventHandler.beginningOfLink2.numberOfVehPassedDuringTimeToMeasure, 1.0); + Assertions.assertEquals(5000.0, stubLinkEnterEventHandler.beginningOfLink2.numberOfVehPassed, MatsimTestUtils.EPSILON); } } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java index 8fc875966e6..e5f7d325967 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -98,14 +98,14 @@ void test2SequentialPlansCompleteDay(){ log.info("First cycle time after 0am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(0)); log.info("First cycle time after 1am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(1)); // test time when signal plans are switched on and off - Assert.assertEquals("First signal state event unexpected.", 0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON, "First signal state event unexpected."); // Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); // Assert.assertEquals("Time when last plan starts is wrong.", 3600*1, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); - Assert.assertNull("There was an unexpected event that switches off signals.", signalAnalyzer.getLastSignalOffEventTime()); - Assert.assertEquals("Number of signal off events is wrong.", 0, signalAnalyzer.getNumberOfOffEvents()); + Assertions.assertNull(signalAnalyzer.getLastSignalOffEventTime(), "There was an unexpected event that switches off signals."); + Assertions.assertEquals(0, signalAnalyzer.getNumberOfOffEvents(), "Number of signal off events is wrong."); // test if signal plans are both running - Assert.assertEquals("Cycle time of first signal plan wrong.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); - Assert.assertEquals("Cycle time of second signal plan wrong.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON, "Cycle time of first signal plan wrong."); + Assertions.assertEquals(60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON, "Cycle time of second signal plan wrong."); } @Test @@ -122,18 +122,18 @@ void test2SequentialPlansUncompleteDayEnd(){ log.info("First cycle time after 2am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(2)); log.info("Number of signal events after 2am " + signalAnalyzer.getNumberOfSignalEventsInHour(2)); // test time when signal plans are switched on and off - Assert.assertEquals("First signal state event unexpected.", 0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON, "First signal state event unexpected."); // Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); // Assert.assertEquals("Time when last plan starts is wrong.", 3600*1, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Time when signals are finally switched off is wrong.", 3600*2, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON); + Assertions.assertEquals(3600*2, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON, "Time when signals are finally switched off is wrong."); /* "5 + " because there is SignalSystemImpl.SWITCH_OFF_SEQUENCE_LENGTH of 5 seconds that is added to each signal plans end time as buffer */ - Assert.assertEquals("Number of signal off events is wrong.", 1, signalAnalyzer.getNumberOfOffEvents()); - Assert.assertEquals("Signals where unexpectedly switched on after 2am.", 0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(2), MatsimTestUtils.EPSILON); - Assert.assertTrue("Signals where unexpectedly switched on after 2am.", 3 > signalAnalyzer.getNumberOfSignalEventsInHour(2)); + Assertions.assertEquals(1, signalAnalyzer.getNumberOfOffEvents(), "Number of signal off events is wrong."); + Assertions.assertEquals(0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(2), MatsimTestUtils.EPSILON, "Signals where unexpectedly switched on after 2am."); + Assertions.assertTrue(3 > signalAnalyzer.getNumberOfSignalEventsInHour(2), "Signals where unexpectedly switched on after 2am."); /* "3 >" because last signal switches of the second plan are allowed at 2am and switch off is only after 5 seconds (in 2:00:05 am) */ // test if signal plans are both running - Assert.assertEquals("Cycle time of first signal plan wrong.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); - Assert.assertEquals("Cycle time of second signal plan wrong.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON, "Cycle time of first signal plan wrong."); + Assertions.assertEquals(60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON, "Cycle time of second signal plan wrong."); } @Test @@ -150,18 +150,18 @@ void test2SequentialPlansUncompleteDayStart(){ log.info("First cycle time after 2am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(2)); log.info("Number of signal events between 0am and 1am " + signalAnalyzer.getNumberOfSignalEventsInHour(0)); // test time when signal plans are switched on and off - Assert.assertEquals("First signal state event unexpected.", 3600*1, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3600*1, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON, "First signal state event unexpected."); // Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); // Assert.assertEquals("Time when last plan starts is wrong.", 3600*2, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); - Assert.assertNull("There was an unexpected event that switches off signals.", signalAnalyzer.getLastSignalOffEventTime()); - Assert.assertEquals("Number of signal off events is wrong.", 0, signalAnalyzer.getNumberOfOffEvents()); + Assertions.assertNull(signalAnalyzer.getLastSignalOffEventTime(), "There was an unexpected event that switches off signals."); + Assertions.assertEquals(0, signalAnalyzer.getNumberOfOffEvents(), "Number of signal off events is wrong."); // test if first hour is simulated correctly without signals - Assert.assertEquals("Signals where unexpectedly switched on between 0am and 1am.", 0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); - Assert.assertTrue("Signals where unexpectedly switched on between 0am and 1am.", 1 > signalAnalyzer.getNumberOfSignalEventsInHour(0)); + Assertions.assertEquals(0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON, "Signals where unexpectedly switched on between 0am and 1am."); + Assertions.assertTrue(1 > signalAnalyzer.getNumberOfSignalEventsInHour(0), "Signals where unexpectedly switched on between 0am and 1am."); /* "1 > " because the first signal event should be at 1am, i.e. outside (after) this count interval */ // test if signal plans are both running - Assert.assertEquals("Cycle time of first signal plan wrong.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON); - Assert.assertEquals("Cycle time of second signal plan wrong.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON, "Cycle time of first signal plan wrong."); + Assertions.assertEquals(60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(2), MatsimTestUtils.EPSILON, "Cycle time of second signal plan wrong."); } @Test @@ -178,14 +178,14 @@ void test2SequentialPlans1SecGap(){ log.info("First cycle time after 0am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(0)); log.info("First cycle time after 1am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(1)); // test time when signal plans are switched on and off - Assert.assertEquals("First signal state event unexpected.", 0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON, "First signal state event unexpected."); // Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); // Assert.assertEquals("Time when last plan starts is wrong.", 3600*1+1, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); - Assert.assertNull("There was an unexpected event that switches off signals.", signalAnalyzer.getLastSignalOffEventTime()); - Assert.assertEquals("Number of signal off events is wrong.", 0, signalAnalyzer.getNumberOfOffEvents()); + Assertions.assertNull(signalAnalyzer.getLastSignalOffEventTime(), "There was an unexpected event that switches off signals."); + Assertions.assertEquals(0, signalAnalyzer.getNumberOfOffEvents(), "Number of signal off events is wrong."); // test if signal plans are both running - Assert.assertEquals("Cycle time of first signal plan wrong.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); - Assert.assertEquals("Cycle time of second signal plan wrong.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON, "Cycle time of first signal plan wrong."); + Assertions.assertEquals(60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON, "Cycle time of second signal plan wrong."); } @Test @@ -202,19 +202,19 @@ void test2SequentialPlans1HourGap(){ log.info("First cycle time after 2am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(2)); log.info("Number of signal events between 1am and 2am " + signalAnalyzer.getNumberOfSignalEventsInHour(1)); // test time when signal plans are switched on and off - Assert.assertEquals("First signal state event unexpected.", 0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON, "First signal state event unexpected."); // Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); // Assert.assertEquals("Time when last plan starts is wrong.", 3600*2, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Time when signals are finally switched off is wrong.", 3600*1, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON); + Assertions.assertEquals(3600*1, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON, "Time when signals are finally switched off is wrong."); /* "5 + " because there is SignalSystemImpl.SWITCH_OFF_SEQUENCE_LENGTH of 5 seconds that is added to each signal plans end time as buffer */ - Assert.assertEquals("Number of signal off events is wrong.", 1, signalAnalyzer.getNumberOfOffEvents()); + Assertions.assertEquals(1, signalAnalyzer.getNumberOfOffEvents(), "Number of signal off events is wrong."); // test if break between signal plans is simulated correctly - Assert.assertEquals("Signals where unexpectedly switched on between the signal plans.", 0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON); - Assert.assertTrue("Signals where unexpectedly switched on between the signal plans.", 3 > signalAnalyzer.getNumberOfSignalEventsInHour(1)); + Assertions.assertEquals(0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON, "Signals where unexpectedly switched on between the signal plans."); + Assertions.assertTrue(3 > signalAnalyzer.getNumberOfSignalEventsInHour(1), "Signals where unexpectedly switched on between the signal plans."); /* "3 >" because last signal switches of the first plan are allowed at 1am and switch off is only after 5 seconds (in 1:00:05 am) */ // test if signal plans are both running - Assert.assertEquals("Cycle time of first signal plan wrong.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); - Assert.assertEquals("Cycle time of second signal plan wrong.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON, "Cycle time of first signal plan wrong."); + Assertions.assertEquals(60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(2), MatsimTestUtils.EPSILON, "Cycle time of second signal plan wrong."); } @Test @@ -235,19 +235,19 @@ void test2SequentialPlans1HourGap2TimesOff(){ log.info("Number of signal events between 1am and 2am " + signalAnalyzer.getNumberOfSignalEventsInHour(1)); log.info("Number of signal events after 3am " + signalAnalyzer.getNumberOfSignalEventsInHour(3)); // test time when signal plans are switched on and off - Assert.assertEquals("First signal state event unexpected.", 0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Time when signals are finally switched off is wrong.", 3600*3, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON, "First signal state event unexpected."); + Assertions.assertEquals(3600*3, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON, "Time when signals are finally switched off is wrong."); /* "5 + " because there is SignalSystemImpl.SWITCH_OFF_SEQUENCE_LENGTH of 5 seconds that is added to each signal plans end time as buffer */ - Assert.assertEquals("Number of signal off events is wrong.", 2, signalAnalyzer.getNumberOfOffEvents()); - Assert.assertEquals("Signals where unexpectedly switched on between the signal plans.", 0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON); - Assert.assertTrue("Signals where unexpectedly switched on between the signal plans.", 3 > signalAnalyzer.getNumberOfSignalEventsInHour(1)); + Assertions.assertEquals(2, signalAnalyzer.getNumberOfOffEvents(), "Number of signal off events is wrong."); + Assertions.assertEquals(0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON, "Signals where unexpectedly switched on between the signal plans."); + Assertions.assertTrue(3 > signalAnalyzer.getNumberOfSignalEventsInHour(1), "Signals where unexpectedly switched on between the signal plans."); /* "3 >" because last signal switches of the first plan are allowed at 1am and switch off is only after 5 seconds (in 1:00:05 am) */ - Assert.assertEquals("Signals where unexpectedly switched on after the last signal plan.", 0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(3), MatsimTestUtils.EPSILON); - Assert.assertTrue("Signals where unexpectedly switched on after 3am.", 3 > signalAnalyzer.getNumberOfSignalEventsInHour(3)); + Assertions.assertEquals(0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(3), MatsimTestUtils.EPSILON, "Signals where unexpectedly switched on after the last signal plan."); + Assertions.assertTrue(3 > signalAnalyzer.getNumberOfSignalEventsInHour(3), "Signals where unexpectedly switched on after 3am."); /* "3 >" because last signal switches of the second plan are allowed at 3am and switch off is only after 5 seconds (in 3:00:05 am) */ // test if signal plans are both running - Assert.assertEquals("Cycle time of first signal plan wrong.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); - Assert.assertEquals("Cycle time of second signal plan wrong.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON, "Cycle time of first signal plan wrong."); + Assertions.assertEquals(60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(2), MatsimTestUtils.EPSILON, "Cycle time of second signal plan wrong."); } @Test @@ -262,14 +262,14 @@ void test2SequentialPlansOverMidnight(){ log.info("First cycle time after 0am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(0)); log.info("First cycle time after 1am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(1)); // test time when signal plans are switched on and off - Assert.assertEquals("First signal state event unexpected.", 0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON, "First signal state event unexpected."); // Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); // Assert.assertEquals("Time when last plan starts is wrong.", 3600*1, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); - Assert.assertNull("There was an unexpected event that switches off signals.", signalAnalyzer.getLastSignalOffEventTime()); - Assert.assertEquals("Number of signal off events is wrong.", 0, signalAnalyzer.getNumberOfOffEvents()); + Assertions.assertNull(signalAnalyzer.getLastSignalOffEventTime(), "There was an unexpected event that switches off signals."); + Assertions.assertEquals(0, signalAnalyzer.getNumberOfOffEvents(), "Number of signal off events is wrong."); // test if signal plans are both running - Assert.assertEquals("Cycle time of first signal plan wrong.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); - Assert.assertEquals("Cycle time of second signal plan wrong.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON); + Assertions.assertEquals(120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON, "Cycle time of first signal plan wrong."); + Assertions.assertEquals(60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON, "Cycle time of second signal plan wrong."); } @Test @@ -287,17 +287,17 @@ void test1SignalPlanUncompleteDay(){ log.info("Number of signal events between 0am and 1am " + signalAnalyzer.getNumberOfSignalEventsInHour(0)); log.info("Number of signal events after 2am " + signalAnalyzer.getNumberOfSignalEventsInHour(2)); // test time when signal plan is switched on and off - Assert.assertEquals("First signal state event unexpected.", 3600.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3600.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON, "First signal state event unexpected."); // Assert.assertEquals("Number of plan start events is wrong.", 1, signalAnalyzer.getNumberOfPlanStartEvents()); // Assert.assertEquals("Time when last plan starts is wrong.", 3600*1, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Time when signals are finally switched off is wrong.", 3600*2, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON); - Assert.assertEquals("Number of signal off events is wrong.", 1, signalAnalyzer.getNumberOfOffEvents()); - Assert.assertEquals("Signals where unexpectedly switched on before 1am.", 0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); - Assert.assertTrue("Signals where unexpectedly switched on before 1am.", 1 > signalAnalyzer.getNumberOfSignalEventsInHour(0)); + Assertions.assertEquals(3600*2, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON, "Time when signals are finally switched off is wrong."); + Assertions.assertEquals(1, signalAnalyzer.getNumberOfOffEvents(), "Number of signal off events is wrong."); + Assertions.assertEquals(0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON, "Signals where unexpectedly switched on before 1am."); + Assertions.assertTrue(1 > signalAnalyzer.getNumberOfSignalEventsInHour(0), "Signals where unexpectedly switched on before 1am."); /* "1 > " because the first signal event should be at 1am, i.e. outside (after) this count interval */ - Assert.assertEquals("Signal plan is not active between 1am and 2am.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON); - Assert.assertEquals("Signals where unexpectedly switched on after 2am.", 0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(2), MatsimTestUtils.EPSILON); - Assert.assertTrue("Signals where unexpectedly switched on after 2am.", 3 > signalAnalyzer.getNumberOfSignalEventsInHour(2)); + Assertions.assertEquals(120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON, "Signal plan is not active between 1am and 2am."); + Assertions.assertEquals(0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(2), MatsimTestUtils.EPSILON, "Signals where unexpectedly switched on after 2am."); + Assertions.assertTrue(3 > signalAnalyzer.getNumberOfSignalEventsInHour(2), "Signals where unexpectedly switched on after 2am."); /* "3 >" because last signal switches of the first plan are allowed at 2am and switch off is only after 5 seconds (in 2:00:05 am) */ } @@ -320,14 +320,14 @@ void test1AllDaySignalPlanOverMidnightLateStart(){ log.info("First cycle time after 0am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(23)); log.info("First cycle time after 0am next day " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(24)); // test time when signal plan is switched on and off - Assert.assertEquals("First signal state event unexpected.", 3600*23, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3600*23, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON, "First signal state event unexpected."); // Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); // Assert.assertEquals("Time when last plan starts is wrong.", 3600*24, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); - Assert.assertNull("There was an unexpected event that switches off signals.", signalAnalyzer.getLastSignalOffEventTime()); - Assert.assertEquals("Number of signal off events is wrong.", 0, signalAnalyzer.getNumberOfOffEvents()); + Assertions.assertNull(signalAnalyzer.getLastSignalOffEventTime(), "There was an unexpected event that switches off signals."); + Assertions.assertEquals(0, signalAnalyzer.getNumberOfOffEvents(), "Number of signal off events is wrong."); // test if signal plan is running for more than 24h - Assert.assertEquals("Signal plan is not active between 11pmam and 12pm.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(23), MatsimTestUtils.EPSILON); - Assert.assertEquals("Signal plan is not active anymore after 0am next day.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(24), MatsimTestUtils.EPSILON); + Assertions.assertEquals(120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(23), MatsimTestUtils.EPSILON, "Signal plan is not active between 11pmam and 12pm."); + Assertions.assertEquals(120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(24), MatsimTestUtils.EPSILON, "Signal plan is not active anymore after 0am next day."); } /** @@ -346,13 +346,13 @@ void test1AllDaySignalPlanMidnightStart(){ log.info("Number of signal off events " + signalAnalyzer.getNumberOfOffEvents()); log.info("First cycle time after 0am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(0)); // test time when signal plan is switched on and off - Assert.assertEquals("First signal state event unexpected.", 0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON, "First signal state event unexpected."); // Assert.assertEquals("Number of plan start events is wrong.", 1, signalAnalyzer.getNumberOfPlanStartEvents()); // Assert.assertEquals("Time when last plan starts is wrong.", 0.0, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); - Assert.assertNull("There was an unexpected event that switches off signals.", signalAnalyzer.getLastSignalOffEventTime()); - Assert.assertEquals("Number of signal off events is wrong.", 0, signalAnalyzer.getNumberOfOffEvents()); + Assertions.assertNull(signalAnalyzer.getLastSignalOffEventTime(), "There was an unexpected event that switches off signals."); + Assertions.assertEquals(0, signalAnalyzer.getNumberOfOffEvents(), "Number of signal off events is wrong."); // test if signal plan is running for more than 24h - Assert.assertEquals("Signal plan is not active between 0am and 1am.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); + Assertions.assertEquals(120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON, "Signal plan is not active between 0am and 1am."); } @Test @@ -370,15 +370,15 @@ void test2SignalPlanFor25h(){ log.info("First cycle time after 12am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(12)); log.info("First cycle time after 0am next day " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(24)); // test time when signal plans are switched on and off - Assert.assertEquals("First signal state event unexpected.", 0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON, "First signal state event unexpected."); // Assert.assertEquals("Number of plan start events is wrong.", 3, signalAnalyzer.getNumberOfPlanStartEvents()); // Assert.assertEquals("Time when last plan starts is wrong.", 3600*24, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); - Assert.assertNull("There was an unexpected event that switches off signals.", signalAnalyzer.getLastSignalOffEventTime()); - Assert.assertEquals("Number of signal off events is wrong.", 0, signalAnalyzer.getNumberOfOffEvents()); + Assertions.assertNull(signalAnalyzer.getLastSignalOffEventTime(), "There was an unexpected event that switches off signals."); + Assertions.assertEquals(0, signalAnalyzer.getNumberOfOffEvents(), "Number of signal off events is wrong."); // test if signal plans are correctly running for more than 24h - Assert.assertEquals("First signal plan is not active between 0am and 1am.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); - Assert.assertEquals("Second signal plan is not active between 12am and 1pm.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(12), MatsimTestUtils.EPSILON); - Assert.assertEquals("First signal plan is not active again after 0am next day.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(24), MatsimTestUtils.EPSILON); + Assertions.assertEquals(120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON, "First signal plan is not active between 0am and 1am."); + Assertions.assertEquals(60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(12), MatsimTestUtils.EPSILON, "Second signal plan is not active between 12am and 1pm."); + Assertions.assertEquals(120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(24), MatsimTestUtils.EPSILON, "First signal plan is not active again after 0am next day."); } @Test @@ -400,18 +400,18 @@ void testSimStartAfterFirstDayPlan(){ log.info("Number of signal events before 11pm " + signalAnalyzer.getNumberOfSignalEventsInHour(22)); log.info("Number of signal events after 1am next day " + signalAnalyzer.getNumberOfSignalEventsInHour(25)); // test time when signal plans are switched on and off - Assert.assertEquals("First signal state event unexpected.", 23*3600, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(23*3600, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON, "First signal state event unexpected."); // Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); // Assert.assertEquals("Time when last plan starts is wrong.", 3600*24, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Time when signals are finally switched off is wrong.", 3600*25, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON); - Assert.assertEquals("Number of signal off events is wrong.", 1, signalAnalyzer.getNumberOfOffEvents()); - Assert.assertEquals("Signals where unexpectedly switched on before 11pm.", 0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(22), MatsimTestUtils.EPSILON); - Assert.assertTrue("Signals where unexpectedly switched on before 11pm.", 1 > signalAnalyzer.getNumberOfSignalEventsInHour(22)); - Assert.assertEquals("Signals where unexpectedly switched on after 1am next day.", 0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(25), MatsimTestUtils.EPSILON); - Assert.assertTrue("Signals where unexpectedly switched on after 1am next day.", 3 > signalAnalyzer.getNumberOfSignalEventsInHour(25)); + Assertions.assertEquals(3600*25, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON, "Time when signals are finally switched off is wrong."); + Assertions.assertEquals(1, signalAnalyzer.getNumberOfOffEvents(), "Number of signal off events is wrong."); + Assertions.assertEquals(0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(22), MatsimTestUtils.EPSILON, "Signals where unexpectedly switched on before 11pm."); + Assertions.assertTrue(1 > signalAnalyzer.getNumberOfSignalEventsInHour(22), "Signals where unexpectedly switched on before 11pm."); + Assertions.assertEquals(0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(25), MatsimTestUtils.EPSILON, "Signals where unexpectedly switched on after 1am next day."); + Assertions.assertTrue(3 > signalAnalyzer.getNumberOfSignalEventsInHour(25), "Signals where unexpectedly switched on after 1am next day."); // test if signal plans are correctly running - Assert.assertEquals("Second signal plan is not active between 11pm and 12pm.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(23), MatsimTestUtils.EPSILON); - Assert.assertEquals("First signal plan is not active between 0am and 1pm next day.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(24), MatsimTestUtils.EPSILON); + Assertions.assertEquals(60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(23), MatsimTestUtils.EPSILON, "Second signal plan is not active between 11pm and 12pm."); + Assertions.assertEquals(120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(24), MatsimTestUtils.EPSILON, "First signal plan is not active between 0am and 1pm next day."); } /** @@ -424,10 +424,10 @@ void test2PlansSameTimesUncompleteDay(){ try{ (new ScenarioRunner(0.0, 1.0, 0.0, 1.0)).run(); - Assert.fail("The simulation has not stopped with an exception although the signal plans overlap."); + Assertions.fail("The simulation has not stopped with an exception although the signal plans overlap."); } catch (UnsupportedOperationException e) { log.info("Exception message: " + e.getMessage()); - Assert.assertEquals("Wrong exception message.", exceptionMessageOverlapping21, e.getMessage()); + Assertions.assertEquals(exceptionMessageOverlapping21, e.getMessage(), "Wrong exception message."); } } @@ -443,10 +443,10 @@ void test2PlansSameTimesCompleteDay(){ try{ (new ScenarioRunner(0.0, 0.0, 0.0, 0.0)).run(); // (new ScenarioRunner(1.0, 1.0, 1.0, 1.0)).run(); // alternativ. produces same results - Assert.fail("The simulation has not stopped with an exception although multiple signal plans exist and at least one of them covers the hole day (i.e. they overlap)."); + Assertions.fail("The simulation has not stopped with an exception although multiple signal plans exist and at least one of them covers the hole day (i.e. they overlap)."); } catch (UnsupportedOperationException e) { log.info("Exception message: " + e.getMessage()); - Assert.assertEquals("Wrong exception message.", exceptionMessageHoleDay, e.getMessage()); + Assertions.assertEquals(exceptionMessageHoleDay, e.getMessage(), "Wrong exception message."); } } @@ -456,10 +456,10 @@ void test2OverlappingPlans(){ try{ (new ScenarioRunner(0.0, 2.0, 1.0, 3.0)).run(); - Assert.fail("The simulation has not stopped with an exception although the signal plans overlap."); + Assertions.fail("The simulation has not stopped with an exception although the signal plans overlap."); } catch (UnsupportedOperationException e) { log.info("Exception message: " + e.getMessage()); - Assert.assertEquals("Wrong exception message.", exceptionMessageOverlapping12, e.getMessage()); + Assertions.assertEquals(exceptionMessageOverlapping12, e.getMessage(), "Wrong exception message."); } } @@ -474,8 +474,8 @@ void testNegativeOffset() { // in this case, the first event should be a RED-switch at second 57 log.info("Offset " + offset1 + " leads to the first signal event at second: " + signalAnalyzer.getFirstSignalEventTime()); - Assert.assertEquals("The first signal event should be at the first second after simulation start corresponding to offset, " - + "cycle time and plan start time. Also if the offset is negative!", 60+offset1 , signalAnalyzer.getFirstSignalEventTime() , MatsimTestUtils.EPSILON); + Assertions.assertEquals(60+offset1 , signalAnalyzer.getFirstSignalEventTime() , MatsimTestUtils.EPSILON, "The first signal event should be at the first second after simulation start corresponding to offset, " + + "cycle time and plan start time. Also if the offset is negative!"); } @Test @@ -489,8 +489,8 @@ void testNegativeOffsetEqualCycleTime() { // in this case, the first event should be a GREEN-switch at second 0 log.info("Offset " + offset1 + " leads to the first signal event at second: " + signalAnalyzer.getFirstSignalEventTime()); - Assert.assertEquals("The first signal event should be at the first second after simulation start corresponding to offset, " - + "cycle time and plan start time. Also if the offset is negative!", 120+offset1 , signalAnalyzer.getFirstSignalEventTime() , MatsimTestUtils.EPSILON); + Assertions.assertEquals(120+offset1 , signalAnalyzer.getFirstSignalEventTime() , MatsimTestUtils.EPSILON, "The first signal event should be at the first second after simulation start corresponding to offset, " + + "cycle time and plan start time. Also if the offset is negative!"); } @Test @@ -511,8 +511,8 @@ void testTwoPlansWithNegativeOffsets(){ // in this case, the first event should be a RED-switch at second 3625 log.info("Offsets " + offset1 + " and " + offset2 + " with a simulation start at second " + simStart_s + " lead to the first signal event at second: " + signalAnalyzer.getFirstSignalEventTime()); - Assert.assertEquals("The first signal event should be at the first second after simulation start corresponding to offset, " - + "cycle time and plan start time. Also if the offset is negative!", simStart_s+30+offset2 , signalAnalyzer.getFirstSignalEventTime() , MatsimTestUtils.EPSILON); + Assertions.assertEquals(simStart_s+30+offset2 , signalAnalyzer.getFirstSignalEventTime() , MatsimTestUtils.EPSILON, "The first signal event should be at the first second after simulation start corresponding to offset, " + + "cycle time and plan start time. Also if the offset is negative!"); } @Test @@ -533,8 +533,8 @@ void testTwoPlansWithNegativeOffsetsEqualCycleTime(){ // in this case, the first event should be a GREEN-switch at second 3600 log.info("Offsets " + offset1 + " and " + offset2 + " with a simulation start at second " + simStart_s + " lead to the first signal event at second: " + signalAnalyzer.getFirstSignalEventTime()); - Assert.assertEquals("The first signal event should be at the first second after simulation start corresponding to offset, " - + "cycle time and plan start time. Also if the offset is negative!", simStart_s+60+offset2 , signalAnalyzer.getFirstSignalEventTime() , MatsimTestUtils.EPSILON); + Assertions.assertEquals(simStart_s+60+offset2 , signalAnalyzer.getFirstSignalEventTime() , MatsimTestUtils.EPSILON, "The first signal event should be at the first second after simulation start corresponding to offset, " + + "cycle time and plan start time. Also if the offset is negative!"); } private class ScenarioRunner{ diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java index 8ce61447ac4..a0691c83396 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -97,9 +97,9 @@ void testSingleCrossingScenarioDemandNS() { log.info("avg cycle time per system: " + avgCycleTimePerSystem.get(signalSystemId)); log.info("avg delay per link: " + avgDelayWE + ", " + avgDelayNS); - Assert.assertNull("signal group 1 should show no green", avgSignalGreenTimePerCycle.get(signalGroupId1)); - Assert.assertNotNull("signal group 2 should show green", avgSignalGreenTimePerCycle.get(signalGroupId2)); - Assert.assertEquals("avg delay at NS-direction should be zero", 0.0, avgDelayNS, MatsimTestUtils.EPSILON); + Assertions.assertNull(avgSignalGreenTimePerCycle.get(signalGroupId1), "signal group 1 should show no green"); + Assertions.assertNotNull(avgSignalGreenTimePerCycle.get(signalGroupId2), "signal group 2 should show green"); + Assertions.assertEquals(0.0, avgDelayNS, MatsimTestUtils.EPSILON, "avg delay at NS-direction should be zero"); } /** @@ -125,14 +125,13 @@ void testSingleCrossingScenarioLowVsHighDemandWithMinG(){ log.info("avg cycle time per system: " + avgCycleTimePerSystem.get(signalSystemId)); log.info("avg delay per link: " + avgDelayWE + ", " + avgDelayNS); - Assert.assertTrue("total signal green time of WE-direction should be higher than NS-direction", - totalSignalGreenTimes.get(signalGroupId1)-totalSignalGreenTimes.get(signalGroupId2) > 0); - Assert.assertTrue("avg signal green time per cycle of WE-direction should be higher than NS-direction", - avgSignalGreenTimePerCycle.get(signalGroupId1)-avgSignalGreenTimePerCycle.get(signalGroupId2) > 0); - Assert.assertEquals("avg signal green time per cycle of NS-direction should be the minimum green time of 5 seconds", - 5.0, avgSignalGreenTimePerCycle.get(signalGroupId2), MatsimTestUtils.EPSILON); - Assert.assertTrue("cycle time should stay below 90 seconds", avgCycleTimePerSystem.get(signalSystemId) <= 90); - Assert.assertTrue("avg delay per vehicle on WS-direction should be less than on NS-direction", avgDelayWE 0, + "total signal green time of WE-direction should be higher than NS-direction"); + Assertions.assertTrue(avgSignalGreenTimePerCycle.get(signalGroupId1)-avgSignalGreenTimePerCycle.get(signalGroupId2) > 0, + "avg signal green time per cycle of WE-direction should be higher than NS-direction"); + Assertions.assertEquals(5.0, avgSignalGreenTimePerCycle.get(signalGroupId2), MatsimTestUtils.EPSILON, "avg signal green time per cycle of NS-direction should be the minimum green time of 5 seconds"); + Assertions.assertTrue(avgCycleTimePerSystem.get(signalSystemId) <= 90, "cycle time should stay below 90 seconds"); + Assertions.assertTrue(avgDelayWE 0); - Assert.assertTrue("avg signal green time per cycle of WE-direction should be higher than NS-direction", - avgSignalGreenTimePerCycle.get(signalGroupId1)-avgSignalGreenTimePerCycle.get(signalGroupId2) > 0); - Assert.assertTrue("avg signal green time per cycle of NS-direction should be less than 5 seconds", avgSignalGreenTimePerCycle.get(signalGroupId2) < 5.0); - Assert.assertTrue("cycle time should stay below 90 seconds", avgCycleTimePerSystem.get(signalSystemId) <= 90); - Assert.assertTrue("avg delay per vehicle on WS-direction should be less than on NS-direction", avgDelayWE 0, + "total signal green time of WE-direction should be higher than NS-direction"); + Assertions.assertTrue(avgSignalGreenTimePerCycle.get(signalGroupId1)-avgSignalGreenTimePerCycle.get(signalGroupId2) > 0, + "avg signal green time per cycle of WE-direction should be higher than NS-direction"); + Assertions.assertTrue(avgSignalGreenTimePerCycle.get(signalGroupId2) < 5.0, "avg signal green time per cycle of NS-direction should be less than 5 seconds"); + Assertions.assertTrue(avgCycleTimePerSystem.get(signalSystemId) <= 90, "cycle time should stay below 90 seconds"); + Assertions.assertTrue(avgDelayWE linkId : avgDelayPerLinkStab.keySet()) { - Assert.assertTrue("stab: avg delay per link should be below a threshold (i.e. still stable)", avgDelayPerLinkStab.get(linkId) < maxCycleTime); + Assertions.assertTrue(avgDelayPerLinkStab.get(linkId) < maxCycleTime, "stab: avg delay per link should be below a threshold (i.e. still stable)"); } - Assert.assertTrue("stab: total delay should be higher than for the other regimes", generalAnalyzerStab.getTotalDelay() > generalAnalyzerOpt.getTotalDelay()); - Assert.assertTrue("stab: total delay should be higher than for the other regimes", generalAnalyzerStab.getTotalDelay() > generalAnalyzerComb.getTotalDelay()); - Assert.assertTrue("the stabilizing regime should satisfy the maximum cycle time", avgCycleTimePerSystemStab.get(signalSystemId) < maxCycleTime); + Assertions.assertTrue(generalAnalyzerStab.getTotalDelay() > generalAnalyzerOpt.getTotalDelay(), "stab: total delay should be higher than for the other regimes"); + Assertions.assertTrue(generalAnalyzerStab.getTotalDelay() > generalAnalyzerComb.getTotalDelay(), "stab: total delay should be higher than for the other regimes"); + Assertions.assertTrue(avgCycleTimePerSystemStab.get(signalSystemId) < maxCycleTime, "the stabilizing regime should satisfy the maximum cycle time"); // stabilizing regime only shows green when number of vehicles beyond a critical number, i.e. some of the cycle time is given away (all signals show red) - Assert.assertTrue("stab: sum of green times per cycle plus 10 seconds intergreen time should be more than 10 seconds less than the avg cycle time", - avgSignalGreenTimePerCycleStab.get(signalGroupId1) + avgSignalGreenTimePerCycleStab.get(signalGroupId2) + cycleIntergreenTime - < avgCycleTimePerSystemStab.get(signalSystemId) - 10); + Assertions.assertTrue(avgSignalGreenTimePerCycleStab.get(signalGroupId1) + avgSignalGreenTimePerCycleStab.get(signalGroupId2) + cycleIntergreenTime + < avgCycleTimePerSystemStab.get(signalSystemId) - 10, + "stab: sum of green times per cycle plus 10 seconds intergreen time should be more than 10 seconds less than the avg cycle time"); // Test Optimizing Regime: for (Id linkId : avgDelayPerLinkOpt.keySet()) { - Assert.assertTrue("opt: avg delay per link should be below a threshold (i.e. still stable)", avgDelayPerLinkOpt.get(linkId) < maxCycleTime); + Assertions.assertTrue(avgDelayPerLinkOpt.get(linkId) < maxCycleTime, "opt: avg delay per link should be below a threshold (i.e. still stable)"); } - Assert.assertEquals("sum of green times per cycle plus 10 seconds intergreen time should be more or less equal to the avg cycle time", - avgCycleTimePerSystemOpt.get(signalSystemId), + Assertions.assertEquals(avgCycleTimePerSystemOpt.get(signalSystemId), avgSignalGreenTimePerCycleOpt.get(signalGroupId1) + avgSignalGreenTimePerCycleOpt.get(signalGroupId2) + cycleIntergreenTime, - 2); - Assert.assertTrue("for this demand, the cycle time of the optimizing regime should be still reasonable, i.e. below a threshold", - avgCycleTimePerSystemOpt.get(signalSystemId) < maxCycleTime); + 2, + "sum of green times per cycle plus 10 seconds intergreen time should be more or less equal to the avg cycle time"); + Assertions.assertTrue(avgCycleTimePerSystemOpt.get(signalSystemId) < maxCycleTime, + "for this demand, the cycle time of the optimizing regime should be still reasonable, i.e. below a threshold"); // Test Combined Regime: for (Id linkId : avgDelayPerLinkComb.keySet()) { - Assert.assertTrue("avg delay per link should be below a threshold (i.e. still stable)", avgDelayPerLinkComb.get(linkId) < maxCycleTime); + Assertions.assertTrue(avgDelayPerLinkComb.get(linkId) < maxCycleTime, "avg delay per link should be below a threshold (i.e. still stable)"); } - Assert.assertEquals("comb: sum of green times per cycle plus 10 seconds intergreen time should be more or less equal to the avg cycle time", - avgCycleTimePerSystemComb.get(signalSystemId), + Assertions.assertEquals(avgCycleTimePerSystemComb.get(signalSystemId), avgSignalGreenTimePerCycleComb.get(signalGroupId1) + avgSignalGreenTimePerCycleComb.get(signalGroupId2) + cycleIntergreenTime, - 2); - Assert.assertTrue("the combined regime should satisfy the maximum cycle time", avgCycleTimePerSystemComb.get(signalSystemId) < maxCycleTime); - Assert.assertTrue("total delay with the combined regime should be the lowest", generalAnalyzerOpt.getTotalDelay() > generalAnalyzerComb.getTotalDelay()); + 2, + "comb: sum of green times per cycle plus 10 seconds intergreen time should be more or less equal to the avg cycle time"); + Assertions.assertTrue(avgCycleTimePerSystemComb.get(signalSystemId) < maxCycleTime, "the combined regime should satisfy the maximum cycle time"); + Assertions.assertTrue(generalAnalyzerOpt.getTotalDelay() > generalAnalyzerComb.getTotalDelay(), "total delay with the combined regime should be the lowest"); } /** @@ -341,31 +339,31 @@ void testSingleCrossingScenarioStabilizingVsOptimizingRegimeHighDemand(){ // Test Stabilizing Regime: for (Id linkId : avgDelayPerLinkStab.keySet()) { - Assert.assertTrue("stab: avg delay per link should be below a threshold (i.e. still stable)", avgDelayPerLinkStab.get(linkId) < maxCycleTime); + Assertions.assertTrue(avgDelayPerLinkStab.get(linkId) < maxCycleTime, "stab: avg delay per link should be below a threshold (i.e. still stable)"); } - Assert.assertTrue("the stabilizing regime should satisfy the maximum cycle time", avgCycleTimePerSystemStab.get(signalSystemId) < maxCycleTime); + Assertions.assertTrue(avgCycleTimePerSystemStab.get(signalSystemId) < maxCycleTime, "the stabilizing regime should satisfy the maximum cycle time"); // stabilizing regime only shows green when number of vehicles beyond a critical number, i.e. some of the cycle time is given away (all signals show red) - Assert.assertTrue("stab: sum of green times per cycle plus 10 seconds intergreen time should be more than 9 seconds less than the avg cycle time", - avgSignalGreenTimePerCycleStab.get(signalGroupId1) + avgSignalGreenTimePerCycleStab.get(signalGroupId2) + cycleIntergreenTime - < avgCycleTimePerSystemStab.get(signalSystemId) - 9); + Assertions.assertTrue(avgSignalGreenTimePerCycleStab.get(signalGroupId1) + avgSignalGreenTimePerCycleStab.get(signalGroupId2) + cycleIntergreenTime + < avgCycleTimePerSystemStab.get(signalSystemId) - 9, + "stab: sum of green times per cycle plus 10 seconds intergreen time should be more than 9 seconds less than the avg cycle time"); // Test Optimizing Regime: - Assert.assertTrue("avg delay for NS-direction should be very high for the optimizing regime with high demand", avgDelayPerLinkOpt.get(Id.createLinkId("7_3")) > maxCycleTime); - Assert.assertTrue("total delay of optimizing regime should be the highest", generalAnalyzerStab.getTotalDelay() < generalAnalyzerOpt.getTotalDelay()); - Assert.assertTrue("for this demand, the cycle time of the optimizing regime should be very high, i.e. not stable anymore", - avgCycleTimePerSystemOpt.get(signalSystemId) > 10*maxCycleTime); + Assertions.assertTrue(avgDelayPerLinkOpt.get(Id.createLinkId("7_3")) > maxCycleTime, "avg delay for NS-direction should be very high for the optimizing regime with high demand"); + Assertions.assertTrue(generalAnalyzerStab.getTotalDelay() < generalAnalyzerOpt.getTotalDelay(), "total delay of optimizing regime should be the highest"); + Assertions.assertTrue(avgCycleTimePerSystemOpt.get(signalSystemId) > 10*maxCycleTime, + "for this demand, the cycle time of the optimizing regime should be very high, i.e. not stable anymore"); // Test Combined Regime: for (Id linkId : avgDelayPerLinkComb.keySet()) { - Assert.assertTrue("avg delay per link should be below a threshold (i.e. still stable)", avgDelayPerLinkComb.get(linkId) < maxCycleTime); + Assertions.assertTrue(avgDelayPerLinkComb.get(linkId) < maxCycleTime, "avg delay per link should be below a threshold (i.e. still stable)"); } - Assert.assertEquals("comb: sum of green times per cycle plus 10 seconds intergreen time should be more or less equal to the avg cycle time", - avgCycleTimePerSystemComb.get(signalSystemId), + Assertions.assertEquals(avgCycleTimePerSystemComb.get(signalSystemId), avgSignalGreenTimePerCycleComb.get(signalGroupId1) + avgSignalGreenTimePerCycleComb.get(signalGroupId2) + cycleIntergreenTime, - 2); - Assert.assertTrue("the combined regime should satisfy the maximum cycle time", avgCycleTimePerSystemComb.get(signalSystemId) < maxCycleTime); - Assert.assertTrue("total delay with the combined regime should be the lowest", generalAnalyzerOpt.getTotalDelay() > generalAnalyzerComb.getTotalDelay()); - Assert.assertTrue("total delay with the combined regime should be the lowest", generalAnalyzerStab.getTotalDelay() > generalAnalyzerComb.getTotalDelay()); + 2, + "comb: sum of green times per cycle plus 10 seconds intergreen time should be more or less equal to the avg cycle time"); + Assertions.assertTrue(avgCycleTimePerSystemComb.get(signalSystemId) < maxCycleTime, "the combined regime should satisfy the maximum cycle time"); + Assertions.assertTrue(generalAnalyzerOpt.getTotalDelay() > generalAnalyzerComb.getTotalDelay(), "total delay with the combined regime should be the lowest"); + Assertions.assertTrue(generalAnalyzerStab.getTotalDelay() > generalAnalyzerComb.getTotalDelay(), "total delay with the combined regime should be the lowest"); } /** @@ -410,21 +408,19 @@ void testSingleCrossingScenarioWithDifferentFlowCapacityFactors(){ log.info("avg delay per link: " + avgDelayPerLinkFlowCap1.get(Id.createLinkId("2_3")) + ", " + avgDelayPerLinkFlowCap1.get(Id.createLinkId("7_3"))); log.info("Total delay: " + generalAnalyzerFlowCap1.getTotalDelay()); - Assert.assertEquals("total signal green times should not differ", 1, - totalSignalGreenTimesFlowCap1.get(signalGroupId1)/totalSignalGreenTimesFlowCap2.get(signalGroupId1), 0.01); - Assert.assertEquals("total signal green times should not differ", 1, - totalSignalGreenTimesFlowCap1.get(signalGroupId2)/totalSignalGreenTimesFlowCap2.get(signalGroupId2), 0.01); - Assert.assertEquals("avg signal green times per cycle should not differ", avgSignalGreenTimePerCycleFlowCap1.get(signalGroupId1), - avgSignalGreenTimePerCycleFlowCap2.get(signalGroupId1), 0.1); - Assert.assertEquals("avg signal green times per cycle should not differ", avgSignalGreenTimePerCycleFlowCap1.get(signalGroupId2), - avgSignalGreenTimePerCycleFlowCap2.get(signalGroupId2), 0.1); - Assert.assertEquals("avg cycle time should not differ", avgCycleTimePerSystemFlowCap1.get(signalSystemId), - avgCycleTimePerSystemFlowCap2.get(signalSystemId), 0.1); - Assert.assertEquals("avg delay per vehicle per link should not differ", - avgDelayPerLinkFlowCap1.get(Id.createLinkId("2_3")), avgDelayPerLinkFlowCap2.get(Id.createLinkId("2_3")), 0.1); - Assert.assertEquals("avg delay per vehicle per link should not differ", - avgDelayPerLinkFlowCap1.get(Id.createLinkId("7_3")), avgDelayPerLinkFlowCap2.get(Id.createLinkId("7_3")), 2); - Assert.assertEquals("total delay for doubled demand should be doubled", 2, generalAnalyzerFlowCap2.getTotalDelay()/generalAnalyzerFlowCap1.getTotalDelay(), 0.1); + Assertions.assertEquals(1, + totalSignalGreenTimesFlowCap1.get(signalGroupId1)/totalSignalGreenTimesFlowCap2.get(signalGroupId1), 0.01, "total signal green times should not differ"); + Assertions.assertEquals(1, + totalSignalGreenTimesFlowCap1.get(signalGroupId2)/totalSignalGreenTimesFlowCap2.get(signalGroupId2), 0.01, "total signal green times should not differ"); + Assertions.assertEquals(avgSignalGreenTimePerCycleFlowCap1.get(signalGroupId1), + avgSignalGreenTimePerCycleFlowCap2.get(signalGroupId1), 0.1, "avg signal green times per cycle should not differ"); + Assertions.assertEquals(avgSignalGreenTimePerCycleFlowCap1.get(signalGroupId2), + avgSignalGreenTimePerCycleFlowCap2.get(signalGroupId2), 0.1, "avg signal green times per cycle should not differ"); + Assertions.assertEquals(avgCycleTimePerSystemFlowCap1.get(signalSystemId), + avgCycleTimePerSystemFlowCap2.get(signalSystemId), 0.1, "avg cycle time should not differ"); + Assertions.assertEquals(avgDelayPerLinkFlowCap1.get(Id.createLinkId("2_3")), avgDelayPerLinkFlowCap2.get(Id.createLinkId("2_3")), 0.1, "avg delay per vehicle per link should not differ"); + Assertions.assertEquals(avgDelayPerLinkFlowCap1.get(Id.createLinkId("7_3")), avgDelayPerLinkFlowCap2.get(Id.createLinkId("7_3")), 2, "avg delay per vehicle per link should not differ"); + Assertions.assertEquals(2, generalAnalyzerFlowCap2.getTotalDelay()/generalAnalyzerFlowCap1.getTotalDelay(), 0.1, "total delay for doubled demand should be doubled"); } /** @@ -475,19 +471,19 @@ void testMultipleIterations() { log.info("avg delay per link in itertion 1: " + avgDelayWE1It + ", " + avgDelayNS1It); - Assert.assertEquals("total green time of signal group 1 should be the same as in the first iteration", totalSignalGreenTimes0It.get(signalGroupId1), totalSignalGreenTimes1It.get(signalGroupId1), MatsimTestUtils.EPSILON); - Assert.assertEquals("total green time of signal group 1l should be the same as in the first iteration", totalSignalGreenTimes0It.get(signalGroupId1l), totalSignalGreenTimes1It.get(signalGroupId1l), MatsimTestUtils.EPSILON); - Assert.assertEquals("total green time of signal group 2 should be the same as in the first iteration", totalSignalGreenTimes0It.get(signalGroupId2), totalSignalGreenTimes1It.get(signalGroupId2), MatsimTestUtils.EPSILON); - Assert.assertEquals("avg green time of signal group 1 should be the same as in the first iteration", avgSignalGreenTimePerCycle0It.get(signalGroupId1), avgSignalGreenTimePerCycle1It.get(signalGroupId1), .01); - Assert.assertEquals("avg green time of signal group 1l should be the same as in the first iteration", avgSignalGreenTimePerCycle0It.get(signalGroupId1l), avgSignalGreenTimePerCycle1It.get(signalGroupId1l), .01); - Assert.assertEquals("avg green time of signal group 2 should be the same as in the first iteration", avgSignalGreenTimePerCycle0It.get(signalGroupId2), avgSignalGreenTimePerCycle1It.get(signalGroupId2), .01); - Assert.assertEquals("avg cycle time should be the same as in the first iteration", avgCycleTimePerSystem0It.get(signalSystemId), avgCycleTimePerSystem1It.get(signalSystemId), .01); - Assert.assertEquals("avg delay in direction WE should be the same as in the first iteration", avgDelayWE0It, avgDelayWE1It, .01); - Assert.assertEquals("avg delay in direction NS should be the same as in the first iteration", avgDelayNS0It, avgDelayNS1It, .01); + Assertions.assertEquals(totalSignalGreenTimes0It.get(signalGroupId1), totalSignalGreenTimes1It.get(signalGroupId1), MatsimTestUtils.EPSILON, "total green time of signal group 1 should be the same as in the first iteration"); + Assertions.assertEquals(totalSignalGreenTimes0It.get(signalGroupId1l), totalSignalGreenTimes1It.get(signalGroupId1l), MatsimTestUtils.EPSILON, "total green time of signal group 1l should be the same as in the first iteration"); + Assertions.assertEquals(totalSignalGreenTimes0It.get(signalGroupId2), totalSignalGreenTimes1It.get(signalGroupId2), MatsimTestUtils.EPSILON, "total green time of signal group 2 should be the same as in the first iteration"); + Assertions.assertEquals(avgSignalGreenTimePerCycle0It.get(signalGroupId1), avgSignalGreenTimePerCycle1It.get(signalGroupId1), .01, "avg green time of signal group 1 should be the same as in the first iteration"); + Assertions.assertEquals(avgSignalGreenTimePerCycle0It.get(signalGroupId1l), avgSignalGreenTimePerCycle1It.get(signalGroupId1l), .01, "avg green time of signal group 1l should be the same as in the first iteration"); + Assertions.assertEquals(avgSignalGreenTimePerCycle0It.get(signalGroupId2), avgSignalGreenTimePerCycle1It.get(signalGroupId2), .01, "avg green time of signal group 2 should be the same as in the first iteration"); + Assertions.assertEquals(avgCycleTimePerSystem0It.get(signalSystemId), avgCycleTimePerSystem1It.get(signalSystemId), .01, "avg cycle time should be the same as in the first iteration"); + Assertions.assertEquals(avgDelayWE0It, avgDelayWE1It, .01, "avg delay in direction WE should be the same as in the first iteration"); + Assertions.assertEquals(avgDelayNS0It, avgDelayNS1It, .01, "avg delay in direction NS should be the same as in the first iteration"); // compare signal event files long checksum_it0 = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "ITERS/it.0/signalEvents2Via.csv"); long checksum_itLast = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "ITERS/it."+lastIt+"/signalEvents2Via.csv"); - Assert.assertEquals("Signal events are different", checksum_it0, checksum_itLast); + Assertions.assertEquals(checksum_it0, checksum_itLast, "Signal events are different"); } // TODO test stochasticity (laemmer better than fixed-time; different than for constant demand) diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java index 21c110b666a..195082ff66a 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -118,12 +118,12 @@ void testDemandABPrioA() { log.info("total signal green times: " + totalSignalGreenTimes.get(signalGroupId1) + ", " + totalSignalGreenTimes.get(signalGroupId2)); log.info("avg signal green times per cycle: " + avgSignalGreenTimePerCycle.get(signalGroupId1) + ", " + avgSignalGreenTimePerCycle.get(signalGroupId2)); log.info("avg cycle time per system: " + avgCycleTimePerSystem.get(signalSystemId)); - Assert.assertEquals("total signal green time of signal group 1 is wrong", 2900, totalSignalGreenTimes.get(signalGroupId1), 50); - Assert.assertEquals("total signal green time of signal group 2 is wrong", 2000, totalSignalGreenTimes.get(signalGroupId2), 50); - Assert.assertEquals("avg green time per cycle of signal group 1 is wrong", 30, avgSignalGreenTimePerCycle.get(signalGroupId1), 1); - Assert.assertEquals("avg green time per cycle of signal group 2 is wrong", 20, avgSignalGreenTimePerCycle.get(signalGroupId2), 1); + Assertions.assertEquals(2900, totalSignalGreenTimes.get(signalGroupId1), 50, "total signal green time of signal group 1 is wrong"); + Assertions.assertEquals(2000, totalSignalGreenTimes.get(signalGroupId2), 50, "total signal green time of signal group 2 is wrong"); + Assertions.assertEquals(30, avgSignalGreenTimePerCycle.get(signalGroupId1), 1, "avg green time per cycle of signal group 1 is wrong"); + Assertions.assertEquals(20, avgSignalGreenTimePerCycle.get(signalGroupId2), 1, "avg green time per cycle of signal group 2 is wrong"); // can differ from the fixed cycle length because the analysis is quit after the last activity start event - Assert.assertEquals("avg cycle time of the system is wrong", 60, avgCycleTimePerSystem.get(signalSystemId), 1); + Assertions.assertEquals(60, avgCycleTimePerSystem.get(signalSystemId), 1, "avg cycle time of the system is wrong"); } /** @@ -157,12 +157,12 @@ void testDemandABPrioB() { log.info("total signal green times: " + totalSignalGreenTimes.get(signalGroupId1) + ", " + totalSignalGreenTimes.get(signalGroupId2)); log.info("avg signal green times per cycle: " + avgSignalGreenTimePerCycle.get(signalGroupId1) + ", " + avgSignalGreenTimePerCycle.get(signalGroupId2)); log.info("avg cycle time per system: " + avgCycleTimePerSystem.get(signalSystemId)); - Assert.assertEquals("total signal green time of signal group 2 is wrong", 2900, totalSignalGreenTimes.get(signalGroupId2), 50); - Assert.assertEquals("total signal green time of signal group 1 is wrong", 2000, totalSignalGreenTimes.get(signalGroupId1), 50); - Assert.assertEquals("avg green time per cycle of signal group 2 is wrong", 30, avgSignalGreenTimePerCycle.get(signalGroupId2), 1); - Assert.assertEquals("avg green time per cycle of signal group 1 is wrong", 20, avgSignalGreenTimePerCycle.get(signalGroupId1), 1); + Assertions.assertEquals(2900, totalSignalGreenTimes.get(signalGroupId2), 50, "total signal green time of signal group 2 is wrong"); + Assertions.assertEquals(2000, totalSignalGreenTimes.get(signalGroupId1), 50, "total signal green time of signal group 1 is wrong"); + Assertions.assertEquals(30, avgSignalGreenTimePerCycle.get(signalGroupId2), 1, "avg green time per cycle of signal group 2 is wrong"); + Assertions.assertEquals(20, avgSignalGreenTimePerCycle.get(signalGroupId1), 1, "avg green time per cycle of signal group 1 is wrong"); // can differ from the fixed cycle length because the analysis is quit after the last activity start event - Assert.assertEquals("avg cycle time of the system is wrong", 60, avgCycleTimePerSystem.get(signalSystemId), 1); + Assertions.assertEquals(60, avgCycleTimePerSystem.get(signalSystemId), 1, "avg cycle time of the system is wrong"); } /** @@ -184,11 +184,11 @@ void testDemandA() { log.info("total signal green times: " + totalSignalGreenTimes.get(signalGroupId1) + ", " + totalSignalGreenTimes.get(signalGroupId2)); log.info("avg signal green times per cycle: " + avgSignalGreenTimePerCycle.get(signalGroupId1) + ", " + avgSignalGreenTimePerCycle.get(signalGroupId2)); log.info("avg cycle time per system: " + avgCycleTimePerSystem.get(signalSystemId)); - Assert.assertTrue("total signal green time of group 1 is not bigger than of group 2", totalSignalGreenTimes.get(signalGroupId1) > totalSignalGreenTimes.get(signalGroupId2)); - Assert.assertEquals("avg green time per cycle of signal group 1 is wrong", 45, avgSignalGreenTimePerCycle.get(signalGroupId1), 5); - Assert.assertEquals("avg green time per cycle of signal group 2 is wrong", 5, avgSignalGreenTimePerCycle.get(signalGroupId2), 5); + Assertions.assertTrue(totalSignalGreenTimes.get(signalGroupId1) > totalSignalGreenTimes.get(signalGroupId2), "total signal green time of group 1 is not bigger than of group 2"); + Assertions.assertEquals(45, avgSignalGreenTimePerCycle.get(signalGroupId1), 5, "avg green time per cycle of signal group 1 is wrong"); + Assertions.assertEquals(5, avgSignalGreenTimePerCycle.get(signalGroupId2), 5, "avg green time per cycle of signal group 2 is wrong"); // can differ from the fixed cycle length because the analysis is quit after the last activity start event - Assert.assertEquals("avg cycle time of the system is wrong", 60, avgCycleTimePerSystem.get(signalSystemId), 1); + Assertions.assertEquals(60, avgCycleTimePerSystem.get(signalSystemId), 1, "avg cycle time of the system is wrong"); } private SignalAnalysisTool runScenario(double[] noPersons, int offset) { diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/ambertimes/v10/AmberTimesData10ReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/ambertimes/v10/AmberTimesData10ReaderWriterTest.java index 55e3b0ff974..522ae6a08b9 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/ambertimes/v10/AmberTimesData10ReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/ambertimes/v10/AmberTimesData10ReaderWriterTest.java @@ -21,7 +21,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -82,21 +82,21 @@ void testWriter() throws JAXBException, SAXException, ParserConfigurationExcepti private void checkContent(AmberTimesData ats) { // global defaults - Assert.assertNotNull(ats); - Assert.assertEquals(0.3, ats.getDefaultAmberTimeGreen(), 1e-7); - Assert.assertEquals(1, ats.getDefaultRedAmber().intValue()); - Assert.assertEquals(4, ats.getDefaultAmber().intValue()); + Assertions.assertNotNull(ats); + Assertions.assertEquals(0.3, ats.getDefaultAmberTimeGreen(), 1e-7); + Assertions.assertEquals(1, ats.getDefaultRedAmber().intValue()); + Assertions.assertEquals(4, ats.getDefaultAmber().intValue()); // system id1 defaults AmberTimeData atdata = ats.getAmberTimeDataBySystemId().get(Id.create(1, SignalSystem.class)); - Assert.assertNotNull(atdata); - Assert.assertEquals(1, atdata.getDefaultRedAmber().intValue()); - Assert.assertEquals(4, atdata.getDefaultAmber().intValue()); + Assertions.assertNotNull(atdata); + Assertions.assertEquals(1, atdata.getDefaultRedAmber().intValue()); + Assertions.assertEquals(4, atdata.getDefaultAmber().intValue()); // Signal 1 defaults - Assert.assertNotNull(atdata.getAmberOfSignal(Id.create(1, Signal.class))); - Assert.assertNotNull(atdata.getSignalAmberMap()); - Assert.assertNotNull(atdata.getSignalRedAmberMap()); - Assert.assertEquals(4, atdata.getAmberOfSignal(Id.create(1, Signal.class)).intValue()); - Assert.assertEquals(2, atdata.getRedAmberOfSignal(Id.create(1, Signal.class)).intValue()); + Assertions.assertNotNull(atdata.getAmberOfSignal(Id.create(1, Signal.class))); + Assertions.assertNotNull(atdata.getSignalAmberMap()); + Assertions.assertNotNull(atdata.getSignalRedAmberMap()); + Assertions.assertEquals(4, atdata.getAmberOfSignal(Id.create(1, Signal.class)).intValue()); + Assertions.assertEquals(2, atdata.getRedAmberOfSignal(Id.create(1, Signal.class)).intValue()); } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/SignalConflictDataReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/SignalConflictDataReaderWriterTest.java index 295e85c40eb..835b9502513 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/SignalConflictDataReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/SignalConflictDataReaderWriterTest.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -63,32 +63,32 @@ void testReaderAndWriter() { } private void compare(ConflictData conflictData1, ConflictData conflictData2) { - Assert.assertEquals("not the same number of intersections", conflictData1.getConflictsPerNode().size(), conflictData2.getConflictsPerNode().size()); + Assertions.assertEquals(conflictData1.getConflictsPerNode().size(), conflictData2.getConflictsPerNode().size(), "not the same number of intersections"); for (IntersectionDirections intersection1 : conflictData1.getConflictsPerSignalSystem().values()) { IntersectionDirections intersection2 = conflictData2.getConflictsPerSignalSystem().get(intersection1.getSignalSystemId()); - Assert.assertNotNull("no conflict data exists for signal system " + intersection1.getSignalSystemId(), intersection2); - Assert.assertEquals("not the same node, but the same signal system " + intersection1.getSignalSystemId(), intersection1.getNodeId(), intersection2.getNodeId()); - Assert.assertEquals("not the same number of direction at node " + intersection1.getNodeId(), intersection1.getDirections().size(), intersection2.getDirections().size()); + Assertions.assertNotNull(intersection2, "no conflict data exists for signal system " + intersection1.getSignalSystemId()); + Assertions.assertEquals(intersection1.getNodeId(), intersection2.getNodeId(), "not the same node, but the same signal system " + intersection1.getSignalSystemId()); + Assertions.assertEquals(intersection1.getDirections().size(), intersection2.getDirections().size(), "not the same number of direction at node " + intersection1.getNodeId()); for (Direction dir1 : intersection1.getDirections().values()) { Direction dir2 = intersection2.getDirections().get(dir1.getId()); - Assert.assertNotNull("no direction exists for id " + dir1.getId(), dir2); - Assert.assertEquals("direction " + dir1.getId() + " has not the same from link", dir1.getFromLink(), dir2.getFromLink()); - Assert.assertEquals("direction " + dir1.getId() + " has not the same to link", dir1.getToLink(), dir2.getToLink()); - Assert.assertEquals("not the same number of conflicting directions for direction " + dir1.getId(), dir1.getConflictingDirections().size(), dir2.getConflictingDirections().size()); - Assert.assertEquals("not the same number of directions with right of way for direction " + dir1.getId(), dir1.getDirectionsWithRightOfWay().size(), dir2.getDirectionsWithRightOfWay().size()); - Assert.assertEquals("not the same number of directions which must yield for direction " + dir1.getId(), dir1.getDirectionsWhichMustYield().size(), dir2.getDirectionsWhichMustYield().size()); - Assert.assertEquals("not the same number of non-conflicting directions for direction " + dir1.getId(), dir1.getNonConflictingDirections().size(), dir2.getNonConflictingDirections().size()); + Assertions.assertNotNull(dir2, "no direction exists for id " + dir1.getId()); + Assertions.assertEquals(dir1.getFromLink(), dir2.getFromLink(), "direction " + dir1.getId() + " has not the same from link"); + Assertions.assertEquals(dir1.getToLink(), dir2.getToLink(), "direction " + dir1.getId() + " has not the same to link"); + Assertions.assertEquals(dir1.getConflictingDirections().size(), dir2.getConflictingDirections().size(), "not the same number of conflicting directions for direction " + dir1.getId()); + Assertions.assertEquals(dir1.getDirectionsWithRightOfWay().size(), dir2.getDirectionsWithRightOfWay().size(), "not the same number of directions with right of way for direction " + dir1.getId()); + Assertions.assertEquals(dir1.getDirectionsWhichMustYield().size(), dir2.getDirectionsWhichMustYield().size(), "not the same number of directions which must yield for direction " + dir1.getId()); + Assertions.assertEquals(dir1.getNonConflictingDirections().size(), dir2.getNonConflictingDirections().size(), "not the same number of non-conflicting directions for direction " + dir1.getId()); for (Id conflDir1 : dir1.getConflictingDirections()) { - Assert.assertTrue("direction " + conflDir1 + " is not a conflicting direction for " + dir1.getId(), dir2.getConflictingDirections().contains(conflDir1)); + Assertions.assertTrue(dir2.getConflictingDirections().contains(conflDir1), "direction " + conflDir1 + " is not a conflicting direction for " + dir1.getId()); } for (Id conflDir1 : dir1.getDirectionsWithRightOfWay()) { - Assert.assertTrue("direction " + conflDir1 + " is not a direction with right of way for " + dir1.getId(), dir2.getDirectionsWithRightOfWay().contains(conflDir1)); + Assertions.assertTrue(dir2.getDirectionsWithRightOfWay().contains(conflDir1), "direction " + conflDir1 + " is not a direction with right of way for " + dir1.getId()); } for (Id conflDir1 : dir1.getDirectionsWhichMustYield()) { - Assert.assertTrue("direction " + conflDir1 + " is not a direction which must yield for " + dir1.getId(), dir2.getDirectionsWhichMustYield().contains(conflDir1)); + Assertions.assertTrue(dir2.getDirectionsWhichMustYield().contains(conflDir1), "direction " + conflDir1 + " is not a direction which must yield for " + dir1.getId()); } for (Id conflDir1 : dir1.getNonConflictingDirections()) { - Assert.assertTrue("direction " + conflDir1 + " is not a non-conflicting direction for " + dir1.getId(), dir2.getNonConflictingDirections().contains(conflDir1)); + Assertions.assertTrue(dir2.getNonConflictingDirections().contains(conflDir1), "direction " + conflDir1 + " is not a non-conflicting direction for " + dir1.getId()); } } } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/UnprotectedLeftTurnLogicTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/UnprotectedLeftTurnLogicTest.java index e1c44259dab..4dc256cf370 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/UnprotectedLeftTurnLogicTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/UnprotectedLeftTurnLogicTest.java @@ -20,7 +20,7 @@ */ package org.matsim.contrib.signals.data.conflicts; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -57,10 +57,10 @@ void testSingleIntersectionScenarioWithLeftTurns() { System.out.println("delay wTurn: " + leftTurnDelayWTurnRestriction); System.out.println("delay w/oTurn: " + leftTurnDelayWoTurnRestriction); System.out.println("delay w/oLogic: " + leftTurnDelayWithoutLogic); - Assert.assertTrue("Delay without restriction should be less than with restricted left turns.", 2 * leftTurnDelayWoTurnRestriction < leftTurnDelayWTurnRestriction); - Assert.assertEquals("Delay without turn restriction should be equal to the case without conflicting data.", leftTurnDelayWoTurnRestriction, leftTurnDelayWithoutLogic, MatsimTestUtils.EPSILON); - Assert.assertEquals("Delay value for the case without turn restrictions is not as expected!", 21120, leftTurnDelayWoTurnRestriction, MatsimTestUtils.EPSILON); - Assert.assertEquals("Delay value for the case with turn restrictions is not as expected!", 80845, leftTurnDelayWTurnRestriction, MatsimTestUtils.EPSILON); + Assertions.assertTrue(2 * leftTurnDelayWoTurnRestriction < leftTurnDelayWTurnRestriction, "Delay without restriction should be less than with restricted left turns."); + Assertions.assertEquals(leftTurnDelayWoTurnRestriction, leftTurnDelayWithoutLogic, MatsimTestUtils.EPSILON, "Delay without turn restriction should be equal to the case without conflicting data."); + Assertions.assertEquals(21120, leftTurnDelayWoTurnRestriction, MatsimTestUtils.EPSILON, "Delay value for the case without turn restrictions is not as expected!"); + Assertions.assertEquals(80845, leftTurnDelayWTurnRestriction, MatsimTestUtils.EPSILON, "Delay value for the case with turn restrictions is not as expected!"); } private AnalyzeSingleIntersectionLeftTurnDelays runSimulation(IntersectionLogic intersectionLogic) { diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/intergreens/v10/IntergreenTimesData10ReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/intergreens/v10/IntergreenTimesData10ReaderWriterTest.java index 9ac1b9ff35e..0d103e94553 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/intergreens/v10/IntergreenTimesData10ReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/intergreens/v10/IntergreenTimesData10ReaderWriterTest.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -88,22 +88,22 @@ void testWriter() throws JAXBException, SAXException, ParserConfigurationExcepti } private void checkContent(IntergreenTimesData itd) { - Assert.assertNotNull(itd); - Assert.assertNotNull(itd.getIntergreensForSignalSystemDataMap()); - Assert.assertEquals(2, itd.getIntergreensForSignalSystemDataMap().size()); + Assertions.assertNotNull(itd); + Assertions.assertNotNull(itd.getIntergreensForSignalSystemDataMap()); + Assertions.assertEquals(2, itd.getIntergreensForSignalSystemDataMap().size()); IntergreensForSignalSystemData ig23 = itd.getIntergreensForSignalSystemDataMap().get(systemId23); - Assert.assertNotNull(ig23); - Assert.assertEquals(Integer.valueOf(5), ig23.getIntergreenTime(groupId1, groupId2)); - Assert.assertEquals(Integer.valueOf(3), ig23.getIntergreenTime(groupId1, groupId3)); - Assert.assertEquals(Integer.valueOf(3), ig23.getIntergreenTime(groupId1, groupId4)); - Assert.assertNull(ig23.getIntergreenTime(groupId2, groupId3)); + Assertions.assertNotNull(ig23); + Assertions.assertEquals(Integer.valueOf(5), ig23.getIntergreenTime(groupId1, groupId2)); + Assertions.assertEquals(Integer.valueOf(3), ig23.getIntergreenTime(groupId1, groupId3)); + Assertions.assertEquals(Integer.valueOf(3), ig23.getIntergreenTime(groupId1, groupId4)); + Assertions.assertNull(ig23.getIntergreenTime(groupId2, groupId3)); IntergreensForSignalSystemData ig42 = itd.getIntergreensForSignalSystemDataMap().get(systemId42); - Assert.assertNotNull(ig42); - Assert.assertEquals(Integer.valueOf(5), ig42.getIntergreenTime(groupId1, groupId2)); - Assert.assertEquals(Integer.valueOf(3), ig42.getIntergreenTime(groupId2, groupId1)); - Assert.assertNull(ig42.getIntergreenTime(groupId1, groupId3)); - Assert.assertNull(ig42.getIntergreenTime(groupId1, groupId1)); + Assertions.assertNotNull(ig42); + Assertions.assertEquals(Integer.valueOf(5), ig42.getIntergreenTime(groupId1, groupId2)); + Assertions.assertEquals(Integer.valueOf(3), ig42.getIntergreenTime(groupId2, groupId1)); + Assertions.assertNull(ig42.getIntergreenTime(groupId1, groupId3)); + Assertions.assertNull(ig42.getIntergreenTime(groupId1, groupId1)); } } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalcontrol/v20/SignalControlData20ReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalcontrol/v20/SignalControlData20ReaderWriterTest.java index 283af98f161..43d3c4bc250 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalcontrol/v20/SignalControlData20ReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalcontrol/v20/SignalControlData20ReaderWriterTest.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -95,41 +95,41 @@ void testWriter() throws JAXBException, SAXException, ParserConfigurationExcepti private void checkContent(SignalControlData controlData) { - Assert.assertNotNull(controlData); - Assert.assertEquals(2, controlData.getSignalSystemControllerDataBySystemId().size()); + Assertions.assertNotNull(controlData); + Assertions.assertEquals(2, controlData.getSignalSystemControllerDataBySystemId().size()); //first controller SignalSystemControllerData systemController = controlData.getSignalSystemControllerDataBySystemId().get(systemId42); - Assert.assertNotNull(systemController); - Assert.assertNotNull(systemController.getControllerIdentifier()); - Assert.assertEquals("DefaultPlanbasedSignalSystemController", systemController.getControllerIdentifier()); - Assert.assertNotNull(systemController.getSignalPlanData()); + Assertions.assertNotNull(systemController); + Assertions.assertNotNull(systemController.getControllerIdentifier()); + Assertions.assertEquals("DefaultPlanbasedSignalSystemController", systemController.getControllerIdentifier()); + Assertions.assertNotNull(systemController.getSignalPlanData()); SignalPlanData plan = systemController.getSignalPlanData().get(signalPlanId8); - Assert.assertNotNull(plan); + Assertions.assertNotNull(plan); double startTime = plan.getStartTime(); - Assert.assertEquals(0.0, startTime, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, startTime, MatsimTestUtils.EPSILON); double stopTime = plan.getEndTime(); - Assert.assertEquals(0.0, stopTime, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, stopTime, MatsimTestUtils.EPSILON); Integer cycleTime = plan.getCycleTime(); - Assert.assertNotNull(cycleTime); - Assert.assertEquals(Integer.valueOf(60), cycleTime); - Assert.assertEquals(3, plan.getOffset()); + Assertions.assertNotNull(cycleTime); + Assertions.assertEquals(Integer.valueOf(60), cycleTime); + Assertions.assertEquals(3, plan.getOffset()); - Assert.assertNotNull(plan.getSignalGroupSettingsDataByGroupId()); + Assertions.assertNotNull(plan.getSignalGroupSettingsDataByGroupId()); SignalGroupSettingsData signalGroupSettings = plan.getSignalGroupSettingsDataByGroupId().get(groupId23); - Assert.assertNotNull(signalGroupSettings); - Assert.assertEquals(groupId23, signalGroupSettings.getSignalGroupId()); - Assert.assertNotNull(signalGroupSettings.getOnset()); - Assert.assertEquals(0, signalGroupSettings.getOnset()); - Assert.assertNotNull(signalGroupSettings.getDropping()); - Assert.assertEquals(45, signalGroupSettings.getDropping()); + Assertions.assertNotNull(signalGroupSettings); + Assertions.assertEquals(groupId23, signalGroupSettings.getSignalGroupId()); + Assertions.assertNotNull(signalGroupSettings.getOnset()); + Assertions.assertEquals(0, signalGroupSettings.getOnset()); + Assertions.assertNotNull(signalGroupSettings.getDropping()); + Assertions.assertEquals(45, signalGroupSettings.getDropping()); //second controller systemController = controlData.getSignalSystemControllerDataBySystemId().get(systemId43); - Assert.assertNotNull(systemController); - Assert.assertNotNull(systemController.getControllerIdentifier()); - Assert.assertEquals("logicbasedActuatedController", systemController.getControllerIdentifier()); - Assert.assertNull(systemController.getSignalPlanData()); + Assertions.assertNotNull(systemController); + Assertions.assertNotNull(systemController.getControllerIdentifier()); + Assertions.assertEquals("logicbasedActuatedController", systemController.getControllerIdentifier()); + Assertions.assertNull(systemController.getSignalPlanData()); } } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalgroups/v20/SignalGroups20ReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalgroups/v20/SignalGroups20ReaderWriterTest.java index 1086d595d2a..c789f80118c 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalgroups/v20/SignalGroups20ReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalgroups/v20/SignalGroups20ReaderWriterTest.java @@ -29,7 +29,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -97,28 +97,28 @@ void testWriter() throws JAXBException, SAXException, ParserConfigurationExcepti private void checkContent(SignalGroupsData sgd) { - Assert.assertNotNull(sgd); - Assert.assertNotNull(sgd.getSignalGroupDataBySignalSystemId()); - Assert.assertNotNull(sgd.getSignalGroupDataBySystemId(id23)); + Assertions.assertNotNull(sgd); + Assertions.assertNotNull(sgd.getSignalGroupDataBySignalSystemId()); + Assertions.assertNotNull(sgd.getSignalGroupDataBySystemId(id23)); //sg23 Map,SignalGroupData> ss23 = sgd.getSignalGroupDataBySystemId(id23); - Assert.assertEquals(id23,ss23.get(idSg1).getSignalSystemId()); + Assertions.assertEquals(id23,ss23.get(idSg1).getSignalSystemId()); Set> sg = ss23.get(idSg1).getSignalIds(); - Assert.assertTrue(sg.contains(id1)); + Assertions.assertTrue(sg.contains(id1)); //sg42 - Assert.assertNotNull(sgd.getSignalGroupDataBySystemId(id42)); + Assertions.assertNotNull(sgd.getSignalGroupDataBySystemId(id42)); Map,SignalGroupData> ss42 = sgd.getSignalGroupDataBySystemId(id42); - Assert.assertEquals(id42,ss42.get(idSg1).getSignalSystemId()); + Assertions.assertEquals(id42,ss42.get(idSg1).getSignalSystemId()); sg = ss42.get(idSg1).getSignalIds(); - Assert.assertTrue(sg.contains(id1)); + Assertions.assertTrue(sg.contains(id1)); sg = ss42.get(idSg2).getSignalIds(); - Assert.assertTrue(sg.contains(id1)); - Assert.assertTrue(sg.contains(id4)); - Assert.assertTrue(sg.contains(id5)); + Assertions.assertTrue(sg.contains(id1)); + Assertions.assertTrue(sg.contains(id4)); + Assertions.assertTrue(sg.contains(id5)); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalsystems/v20/SignalSystemsData20ReaderWriterTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalsystems/v20/SignalSystemsData20ReaderWriterTest.java index 1fb40b18f1b..a3388a46d6e 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalsystems/v20/SignalSystemsData20ReaderWriterTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/signalsystems/v20/SignalSystemsData20ReaderWriterTest.java @@ -24,7 +24,7 @@ import jakarta.xml.bind.JAXBException; import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -98,48 +98,48 @@ void testWriter() throws JAXBException, SAXException, ParserConfigurationExcepti private void checkContent(SignalSystemsData ss) { //system id 1 SignalSystemData ssdata = ss.getSignalSystemData().get(systemId1); - Assert.assertNotNull(ssdata); - Assert.assertEquals(2, ssdata.getSignalData().size()); + Assertions.assertNotNull(ssdata); + Assertions.assertEquals(2, ssdata.getSignalData().size()); SignalData signaldata = ssdata.getSignalData().get(signalId1); - Assert.assertNotNull(signaldata); - Assert.assertEquals(signalId1, signaldata.getId()); - Assert.assertEquals(linkId1, signaldata.getLinkId()); - Assert.assertNull(signaldata.getLaneIds()); - Assert.assertNull(signaldata.getTurningMoveRestrictions()); + Assertions.assertNotNull(signaldata); + Assertions.assertEquals(signalId1, signaldata.getId()); + Assertions.assertEquals(linkId1, signaldata.getLinkId()); + Assertions.assertNull(signaldata.getLaneIds()); + Assertions.assertNull(signaldata.getTurningMoveRestrictions()); signaldata = ssdata.getSignalData().get(signalId2); - Assert.assertNotNull(signaldata); - Assert.assertEquals(signalId2, signaldata.getId()); - Assert.assertEquals(linkId2, signaldata.getLinkId()); - Assert.assertNotNull(signaldata.getTurningMoveRestrictions()); - Assert.assertEquals(1, signaldata.getTurningMoveRestrictions().size()); - Assert.assertEquals(linkId3, signaldata.getTurningMoveRestrictions().iterator().next()); - Assert.assertNull(signaldata.getLaneIds()); + Assertions.assertNotNull(signaldata); + Assertions.assertEquals(signalId2, signaldata.getId()); + Assertions.assertEquals(linkId2, signaldata.getLinkId()); + Assertions.assertNotNull(signaldata.getTurningMoveRestrictions()); + Assertions.assertEquals(1, signaldata.getTurningMoveRestrictions().size()); + Assertions.assertEquals(linkId3, signaldata.getTurningMoveRestrictions().iterator().next()); + Assertions.assertNull(signaldata.getLaneIds()); //system id 2 ssdata = ss.getSignalSystemData().get(systemId2); - Assert.assertNotNull(ssdata); + Assertions.assertNotNull(ssdata); signaldata = ssdata.getSignalData().get(signalId1); - Assert.assertNotNull(signaldata); - Assert.assertEquals(signalId1, signaldata.getId()); - Assert.assertEquals(linkId3, signaldata.getLinkId()); - Assert.assertNotNull(signaldata.getLaneIds()); - Assert.assertEquals(laneId1, signaldata.getLaneIds().iterator().next()); - Assert.assertNull(signaldata.getTurningMoveRestrictions()); + Assertions.assertNotNull(signaldata); + Assertions.assertEquals(signalId1, signaldata.getId()); + Assertions.assertEquals(linkId3, signaldata.getLinkId()); + Assertions.assertNotNull(signaldata.getLaneIds()); + Assertions.assertEquals(laneId1, signaldata.getLaneIds().iterator().next()); + Assertions.assertNull(signaldata.getTurningMoveRestrictions()); signaldata = ssdata.getSignalData().get(signalId2); - Assert.assertNotNull(signaldata); - Assert.assertEquals(signalId2, signaldata.getId()); - Assert.assertEquals(linkId4, signaldata.getLinkId()); - Assert.assertNotNull(signaldata.getLaneIds()); - Assert.assertEquals(2, signaldata.getLaneIds().size()); - Assert.assertTrue(signaldata.getLaneIds().contains(laneId1)); - Assert.assertTrue(signaldata.getLaneIds().contains(laneId2)); - Assert.assertNotNull(signaldata.getTurningMoveRestrictions()); - Assert.assertEquals(1, signaldata.getTurningMoveRestrictions().size()); - Assert.assertTrue(signaldata.getTurningMoveRestrictions().contains(linkId3)); + Assertions.assertNotNull(signaldata); + Assertions.assertEquals(signalId2, signaldata.getId()); + Assertions.assertEquals(linkId4, signaldata.getLinkId()); + Assertions.assertNotNull(signaldata.getLaneIds()); + Assertions.assertEquals(2, signaldata.getLaneIds().size()); + Assertions.assertTrue(signaldata.getLaneIds().contains(laneId1)); + Assertions.assertTrue(signaldata.getLaneIds().contains(laneId2)); + Assertions.assertNotNull(signaldata.getTurningMoveRestrictions()); + Assertions.assertEquals(1, signaldata.getTurningMoveRestrictions().size()); + Assertions.assertTrue(signaldata.getTurningMoveRestrictions().contains(linkId3)); } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/SignalSystemsIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/SignalSystemsIT.java index 3091d160258..49e8af1f140 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/SignalSystemsIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/SignalSystemsIT.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.contrib.signals.integration; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -88,10 +88,10 @@ void testSignalSystems() { //iteration 0 String iterationOutput = controlerOutputDir + "ITERS/it.0/"; - Assert.assertEquals("different events files after iteration 0 ", - EventsFileComparator.Result.FILES_ARE_EQUAL, + Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( inputDirectory + "0.events.xml.gz", - iterationOutput + "0.events.xml.gz") + iterationOutput + "0.events.xml.gz"), + "different events files after iteration 0 " ); Scenario expectedPopulation = ScenarioUtils.createScenario(c.getConfig()); @@ -107,15 +107,15 @@ void testSignalSystems() { new org.matsim.api.core.v01.population.PopulationWriter(expectedPopulation.getPopulation()).write(testUtils.getOutputDirectory()+"/expected_plans_it0.xml.gz"); new org.matsim.api.core.v01.population.PopulationWriter(actualPopulation.getPopulation()).write(testUtils.getOutputDirectory()+"/actual_plans_it0.xml.gz"); } - Assert.assertTrue("different population files after iteration 0 ", works); + Assertions.assertTrue(works, "different population files after iteration 0 "); } { //iteration 10 String iterationOutput = controlerOutputDir + "ITERS/it.10/"; - Assert.assertEquals("different event files after iteration 10", - EventsFileComparator.Result.FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( inputDirectory + "10.events.xml.gz", iterationOutput + "10.events.xml.gz" ) + Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( inputDirectory + "10.events.xml.gz", iterationOutput + "10.events.xml.gz" ), + "different event files after iteration 10" ); Scenario expectedPopulation = ScenarioUtils.createScenario(c.getConfig()); @@ -131,19 +131,19 @@ void testSignalSystems() { new org.matsim.api.core.v01.population.PopulationWriter(expectedPopulation.getPopulation()).write(testUtils.getOutputDirectory()+"/expected_plans_it10.xml.gz"); new org.matsim.api.core.v01.population.PopulationWriter(actualPopulation.getPopulation()).write(testUtils.getOutputDirectory()+"/actual_plans_it10.xml.gz"); } - Assert.assertTrue("different population files after iteration 10 ", works); + Assertions.assertTrue(works, "different population files after iteration 10 "); } SignalsScenarioWriter writer = new SignalsScenarioWriter(c.getControlerIO()); File file = new File(writer.getSignalSystemsOutputFilename()); - Assert.assertTrue(file.exists()); + Assertions.assertTrue(file.exists()); file = new File(writer.getSignalGroupsOutputFilename()); - Assert.assertTrue(file.exists()); + Assertions.assertTrue(file.exists()); file = new File(writer.getSignalControlOutputFilename()); - Assert.assertTrue(file.exists()); + Assertions.assertTrue(file.exists()); file = new File(writer.getAmberTimesOutputFilename()); - Assert.assertTrue(file.exists()); + Assertions.assertTrue(file.exists()); file = new File(writer.getIntergreenTimesOutputFilename()); - Assert.assertTrue(file.exists()); + Assertions.assertTrue(file.exists()); } @@ -181,10 +181,10 @@ void testSignalSystemsWTryEndTimeThenDuration() { //iteration 0 String iterationOutput = controlerOutputDir + "ITERS/it.0/"; - Assert.assertEquals("different events files after iteration 0 ", - EventsFileComparator.Result.FILES_ARE_EQUAL, + Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( inputDirectory + "0.events.xml.gz", - iterationOutput + "0.events.xml.gz") + iterationOutput + "0.events.xml.gz"), + "different events files after iteration 0 " ); Scenario expectedPopulation = ScenarioUtils.createScenario(c.getConfig()); @@ -200,15 +200,15 @@ void testSignalSystemsWTryEndTimeThenDuration() { new org.matsim.api.core.v01.population.PopulationWriter(expectedPopulation.getPopulation()).write(testUtils.getOutputDirectory()+"/expected_plans_it0.xml.gz"); new org.matsim.api.core.v01.population.PopulationWriter(actualPopulation.getPopulation()).write(testUtils.getOutputDirectory()+"/actual_plans_it0.xml.gz"); } - Assert.assertTrue("different population files after iteration 0 ", works); + Assertions.assertTrue(works, "different population files after iteration 0 "); } { //iteration 10 String iterationOutput = controlerOutputDir + "ITERS/it.10/"; - Assert.assertEquals("different event files after iteration 10", - EventsFileComparator.Result.FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( inputDirectory + "10.events.xml.gz", iterationOutput + "10.events.xml.gz") + Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( inputDirectory + "10.events.xml.gz", iterationOutput + "10.events.xml.gz"), + "different event files after iteration 10" ); @@ -225,19 +225,19 @@ void testSignalSystemsWTryEndTimeThenDuration() { new org.matsim.api.core.v01.population.PopulationWriter(expectedPopulation.getPopulation()).write(testUtils.getOutputDirectory()+"/expected_plans_it10.xml.gz"); new org.matsim.api.core.v01.population.PopulationWriter(actualPopulation.getPopulation()).write(testUtils.getOutputDirectory()+"/actual_plans_it10.xml.gz"); } - Assert.assertTrue("different population files after iteration 10 ", works); + Assertions.assertTrue(works, "different population files after iteration 10 "); } SignalsScenarioWriter writer = new SignalsScenarioWriter(c.getControlerIO()); File file = new File(writer.getSignalSystemsOutputFilename()); - Assert.assertTrue(file.exists()); + Assertions.assertTrue(file.exists()); file = new File(writer.getSignalGroupsOutputFilename()); - Assert.assertTrue(file.exists()); + Assertions.assertTrue(file.exists()); file = new File(writer.getSignalControlOutputFilename()); - Assert.assertTrue(file.exists()); + Assertions.assertTrue(file.exists()); file = new File(writer.getAmberTimesOutputFilename()); - Assert.assertTrue(file.exists()); + Assertions.assertTrue(file.exists()); file = new File(writer.getIntergreenTimesOutputFilename()); - Assert.assertTrue(file.exists()); + Assertions.assertTrue(file.exists()); } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/invertednetworks/InvertedNetworksSignalsIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/invertednetworks/InvertedNetworksSignalsIT.java index 3cbb0e162d2..72d7dcab19c 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/invertednetworks/InvertedNetworksSignalsIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/invertednetworks/InvertedNetworksSignalsIT.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.contrib.signals.integration.invertednetworks; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -63,7 +63,7 @@ public void notifyStartup(StartupEvent event) { } }); c.run(); - Assert.assertTrue("No traffic on link", testHandler.hadTrafficOnLink25); + Assertions.assertTrue(testHandler.hadTrafficOnLink25, "No traffic on link"); } @Test @@ -91,7 +91,7 @@ public void notifyStartup(StartupEvent event) { } }); c.run(); - Assert.assertTrue("No traffic on link", testHandler.hadTrafficOnLink25); + Assertions.assertTrue(testHandler.hadTrafficOnLink25, "No traffic on link"); } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java index 297db365105..6860c74bd76 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java @@ -13,7 +13,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.runner.RunWith; @@ -209,9 +209,9 @@ void singleJunction(){ signalReader.parse(file.toAbsolutePath().toString()); - Assert.assertEquals("Assert number of nodes", 5, network.getNodes().size()); - Assert.assertEquals("Assert number of links", 8, network.getLinks().size()); - Assert.assertEquals("Assert number of Systems", 1, signalsData.getSignalSystemsData().getSignalSystemData().size()); + Assertions.assertEquals(5, network.getNodes().size(), "Assert number of nodes"); + Assertions.assertEquals(8, network.getLinks().size(), "Assert number of links"); + Assertions.assertEquals(1, signalsData.getSignalSystemsData().getSignalSystemData().size(), "Assert number of Systems"); Coord junctionCoord = new Coord(osmData.nodes.get(1).getLatitude(), osmData.nodes.get(1).getLongitude()); @@ -224,21 +224,19 @@ void singleJunction(){ if (shouldHave4Lanes){ //Note: 3 lanes and one original lane - Assert.assertEquals("Number of Lanes on InLink of SignalisedJunction incorrect", - 4, scenario.getLanes().getLanesToLinkAssignments().get(link).getLanes().size()); + Assertions.assertEquals(4, scenario.getLanes().getLanesToLinkAssignments().get(link).getLanes().size(), "Number of Lanes on InLink of SignalisedJunction incorrect"); } else { - Assert.assertEquals("Number of Lanes on InLink of SignalisedJunction incorrect", - 2, scenario.getLanes().getLanesToLinkAssignments().get(link).getLanes().size()); + Assertions.assertEquals(2, scenario.getLanes().getLanesToLinkAssignments().get(link).getLanes().size(), "Number of Lanes on InLink of SignalisedJunction incorrect"); } } Id systemId = signalsData.getSignalSystemsData().getSignalSystemData().keySet().iterator().next(); int groups = signalsData.getSignalGroupsData().getSignalGroupDataBySignalSystemId().get(systemId).size(); - Assert.assertEquals("Assert number of Signalgroups", 4, groups); + Assertions.assertEquals(4, groups, "Assert number of Signalgroups"); int signals = signalsData.getSignalSystemsData().getSignalSystemData().get(systemId).getSignalData().size(); - Assert.assertEquals("Assert number of Signals", 8, signals); + Assertions.assertEquals(8, signals, "Assert number of Signals"); } @Test @@ -275,9 +273,9 @@ void singleJunctionWithBoundingBox(){ signalReader.parse(file.toAbsolutePath().toString()); - Assert.assertEquals("Assert number of nodes", 5, network.getNodes().size()); - Assert.assertEquals("Assert number of links", 8, network.getLinks().size()); - Assert.assertEquals("Assert number of Systems", 1, signalsData.getSignalSystemsData().getSignalSystemData().size()); + Assertions.assertEquals(5, network.getNodes().size(), "Assert number of nodes"); + Assertions.assertEquals(8, network.getLinks().size(), "Assert number of links"); + Assertions.assertEquals(1, signalsData.getSignalSystemsData().getSignalSystemData().size(), "Assert number of Systems"); Coord junctionCoord = new Coord(osmData.nodes.get(1).getLatitude(), osmData.nodes.get(1).getLongitude()); @@ -290,21 +288,19 @@ void singleJunctionWithBoundingBox(){ if (shouldHave4Lanes){ //Note: 3 lanes and one original lane - Assert.assertEquals("Number of Lanes on InLink of SignalisedJunction incorrect", - 4, scenario.getLanes().getLanesToLinkAssignments().get(link).getLanes().size()); + Assertions.assertEquals(4, scenario.getLanes().getLanesToLinkAssignments().get(link).getLanes().size(), "Number of Lanes on InLink of SignalisedJunction incorrect"); } else { - Assert.assertEquals("Number of Lanes on InLink of SignalisedJunction incorrect", - 2, scenario.getLanes().getLanesToLinkAssignments().get(link).getLanes().size()); + Assertions.assertEquals(2, scenario.getLanes().getLanesToLinkAssignments().get(link).getLanes().size(), "Number of Lanes on InLink of SignalisedJunction incorrect"); } } Id systemId = signalsData.getSignalSystemsData().getSignalSystemData().keySet().iterator().next(); int groups = signalsData.getSignalGroupsData().getSignalGroupDataBySignalSystemId().get(systemId).size(); - Assert.assertEquals("Assert number of Signalgroups", 4, groups); + Assertions.assertEquals(4, groups, "Assert number of Signalgroups"); int signals = signalsData.getSignalSystemsData().getSignalSystemData().get(systemId).getSignalData().size(); - Assert.assertEquals("Assert number of Signals", 8, signals); + Assertions.assertEquals(8, signals, "Assert number of Signals"); } @Test @@ -341,9 +337,9 @@ void singleJunctionBadBoundingBox(){ signalReader.parse(file.toAbsolutePath().toString()); - Assert.assertEquals("Assert number of nodes", 5, network.getNodes().size()); - Assert.assertEquals("Assert number of links", 8, network.getLinks().size()); - Assert.assertEquals("Assert number of Systems", 0, signalsData.getSignalSystemsData().getSignalSystemData().size()); + Assertions.assertEquals(5, network.getNodes().size(), "Assert number of nodes"); + Assertions.assertEquals(8, network.getLinks().size(), "Assert number of links"); + Assertions.assertEquals(0, signalsData.getSignalSystemsData().getSignalSystemData().size(), "Assert number of Systems"); Coord junctionCoord = new Coord(osmData.nodes.get(1).getLatitude(), osmData.nodes.get(1).getLongitude()); @@ -356,11 +352,9 @@ void singleJunctionBadBoundingBox(){ if (shouldHave4Lanes){ //Note: 3 lanes and one original lane - Assert.assertEquals("Number of Lanes on InLink of SignalisedJunction incorrect", - 4, scenario.getLanes().getLanesToLinkAssignments().get(link).getLanes().size()); + Assertions.assertEquals(4, scenario.getLanes().getLanesToLinkAssignments().get(link).getLanes().size(), "Number of Lanes on InLink of SignalisedJunction incorrect"); } else { - Assert.assertEquals("Number of Lanes on InLink of SignalisedJunction incorrect", - 2, scenario.getLanes().getLanesToLinkAssignments().get(link).getLanes().size()); + Assertions.assertEquals(2, scenario.getLanes().getLanesToLinkAssignments().get(link).getLanes().size(), "Number of Lanes on InLink of SignalisedJunction incorrect"); } } @@ -438,75 +432,75 @@ void berlinSnippet(){ if (setMakePedestrianSignals && setAllowUTurnAtLeftLaneOnly && setMergeOnewaySignalSystems){ - Assert.assertEquals("Assert number of nodes", 322, network.getNodes().size()); - Assert.assertEquals("Assert number of links", 658, network.getLinks().size()); - Assert.assertEquals("Assert number of Systems", 65, signalsData.getSignalSystemsData().getSignalSystemData().size()); - Assert.assertEquals("Assert number of total SignalGroups", 136, noSignalGroups); - Assert.assertEquals("Assert number of total Signals", 266, noSignals); - Assert.assertEquals("Assert no of links with lanes",128,scenario.getLanes().getLanesToLinkAssignments().size()); + Assertions.assertEquals(322, network.getNodes().size(), "Assert number of nodes"); + Assertions.assertEquals(658, network.getLinks().size(), "Assert number of links"); + Assertions.assertEquals(65, signalsData.getSignalSystemsData().getSignalSystemData().size(), "Assert number of Systems"); + Assertions.assertEquals(136, noSignalGroups, "Assert number of total SignalGroups"); + Assertions.assertEquals(266, noSignals, "Assert number of total Signals"); + Assertions.assertEquals(128,scenario.getLanes().getLanesToLinkAssignments().size(),"Assert no of links with lanes"); } if (setMakePedestrianSignals && setAllowUTurnAtLeftLaneOnly && !setMergeOnewaySignalSystems){ - Assert.assertEquals("Assert number of nodes", 339, network.getNodes().size()); - Assert.assertEquals("Assert number of links", 692, network.getLinks().size()); - Assert.assertEquals("Assert number of Systems", 82, signalsData.getSignalSystemsData().getSignalSystemData().size()); - Assert.assertEquals("Assert number of total SignalGroups", 157, noSignalGroups); - Assert.assertEquals("Assert number of total Signals", 302, noSignals); - Assert.assertEquals("Assert no of links with lanes",137,scenario.getLanes().getLanesToLinkAssignments().size()); + Assertions.assertEquals(339, network.getNodes().size(), "Assert number of nodes"); + Assertions.assertEquals(692, network.getLinks().size(), "Assert number of links"); + Assertions.assertEquals(82, signalsData.getSignalSystemsData().getSignalSystemData().size(), "Assert number of Systems"); + Assertions.assertEquals(157, noSignalGroups, "Assert number of total SignalGroups"); + Assertions.assertEquals(302, noSignals, "Assert number of total Signals"); + Assertions.assertEquals(137,scenario.getLanes().getLanesToLinkAssignments().size(),"Assert no of links with lanes"); } if (setMakePedestrianSignals && !setAllowUTurnAtLeftLaneOnly && setMergeOnewaySignalSystems){ - Assert.assertEquals("Assert number of nodes", 322, network.getNodes().size()); - Assert.assertEquals("Assert number of links", 658, network.getLinks().size()); - Assert.assertEquals("Assert number of Systems", 65, signalsData.getSignalSystemsData().getSignalSystemData().size()); - Assert.assertEquals("Assert number of total SignalGroups", 136, noSignalGroups); - Assert.assertEquals("Assert number of total Signals", 265, noSignals); - Assert.assertEquals("Assert no of links with lanes",128,scenario.getLanes().getLanesToLinkAssignments().size()); + Assertions.assertEquals(322, network.getNodes().size(), "Assert number of nodes"); + Assertions.assertEquals(658, network.getLinks().size(), "Assert number of links"); + Assertions.assertEquals(65, signalsData.getSignalSystemsData().getSignalSystemData().size(), "Assert number of Systems"); + Assertions.assertEquals(136, noSignalGroups, "Assert number of total SignalGroups"); + Assertions.assertEquals(265, noSignals, "Assert number of total Signals"); + Assertions.assertEquals(128,scenario.getLanes().getLanesToLinkAssignments().size(),"Assert no of links with lanes"); } if (!setMakePedestrianSignals && setAllowUTurnAtLeftLaneOnly && setMergeOnewaySignalSystems){ - Assert.assertEquals("Assert number of nodes", 296, network.getNodes().size()); - Assert.assertEquals("Assert number of links", 623, network.getLinks().size()); - Assert.assertEquals("Assert number of Systems", 41, signalsData.getSignalSystemsData().getSignalSystemData().size()); - Assert.assertEquals("Assert number of total SignalGroups", 112, noSignalGroups); - Assert.assertEquals("Assert number of total Signals", 223, noSignals); - Assert.assertEquals("Assert no of links with lanes",115,scenario.getLanes().getLanesToLinkAssignments().size()); + Assertions.assertEquals(296, network.getNodes().size(), "Assert number of nodes"); + Assertions.assertEquals(623, network.getLinks().size(), "Assert number of links"); + Assertions.assertEquals(41, signalsData.getSignalSystemsData().getSignalSystemData().size(), "Assert number of Systems"); + Assertions.assertEquals(112, noSignalGroups, "Assert number of total SignalGroups"); + Assertions.assertEquals(223, noSignals, "Assert number of total Signals"); + Assertions.assertEquals(115,scenario.getLanes().getLanesToLinkAssignments().size(),"Assert no of links with lanes"); } if (setMakePedestrianSignals && !setAllowUTurnAtLeftLaneOnly && !setMergeOnewaySignalSystems){ - Assert.assertEquals("Assert number of nodes", 339, network.getNodes().size()); - Assert.assertEquals("Assert number of links", 692, network.getLinks().size()); - Assert.assertEquals("Assert number of Systems", 82, signalsData.getSignalSystemsData().getSignalSystemData().size()); - Assert.assertEquals("Assert number of total SignalGroups", 157, noSignalGroups); - Assert.assertEquals("Assert number of total Signals", 301, noSignals); - Assert.assertEquals("Assert no of links with lanes",137,scenario.getLanes().getLanesToLinkAssignments().size()); + Assertions.assertEquals(339, network.getNodes().size(), "Assert number of nodes"); + Assertions.assertEquals(692, network.getLinks().size(), "Assert number of links"); + Assertions.assertEquals(82, signalsData.getSignalSystemsData().getSignalSystemData().size(), "Assert number of Systems"); + Assertions.assertEquals(157, noSignalGroups, "Assert number of total SignalGroups"); + Assertions.assertEquals(301, noSignals, "Assert number of total Signals"); + Assertions.assertEquals(137,scenario.getLanes().getLanesToLinkAssignments().size(),"Assert no of links with lanes"); } if (!setMakePedestrianSignals && setAllowUTurnAtLeftLaneOnly && !setMergeOnewaySignalSystems){ - Assert.assertEquals("Assert number of nodes", 314, network.getNodes().size()); - Assert.assertEquals("Assert number of links", 658, network.getLinks().size()); - Assert.assertEquals("Assert number of Systems", 56, signalsData.getSignalSystemsData().getSignalSystemData().size()); - Assert.assertEquals("Assert number of total SignalGroups", 131, noSignalGroups); - Assert.assertEquals("Assert number of total Signals", 252, noSignals); - Assert.assertEquals("Assert no of links with lanes",122,scenario.getLanes().getLanesToLinkAssignments().size()); + Assertions.assertEquals(314, network.getNodes().size(), "Assert number of nodes"); + Assertions.assertEquals(658, network.getLinks().size(), "Assert number of links"); + Assertions.assertEquals(56, signalsData.getSignalSystemsData().getSignalSystemData().size(), "Assert number of Systems"); + Assertions.assertEquals(131, noSignalGroups, "Assert number of total SignalGroups"); + Assertions.assertEquals(252, noSignals, "Assert number of total Signals"); + Assertions.assertEquals(122,scenario.getLanes().getLanesToLinkAssignments().size(),"Assert no of links with lanes"); } if (!setMakePedestrianSignals && !setAllowUTurnAtLeftLaneOnly && setMergeOnewaySignalSystems){ - Assert.assertEquals("Assert number of nodes", 296, network.getNodes().size()); - Assert.assertEquals("Assert number of links", 623, network.getLinks().size()); - Assert.assertEquals("Assert number of Systems", 41, signalsData.getSignalSystemsData().getSignalSystemData().size()); - Assert.assertEquals("Assert number of total SignalGroups", 112, noSignalGroups); - Assert.assertEquals("Assert number of total Signals", 222, noSignals); - Assert.assertEquals("Assert no of links with lanes",115,scenario.getLanes().getLanesToLinkAssignments().size()); + Assertions.assertEquals(296, network.getNodes().size(), "Assert number of nodes"); + Assertions.assertEquals(623, network.getLinks().size(), "Assert number of links"); + Assertions.assertEquals(41, signalsData.getSignalSystemsData().getSignalSystemData().size(), "Assert number of Systems"); + Assertions.assertEquals(112, noSignalGroups, "Assert number of total SignalGroups"); + Assertions.assertEquals(222, noSignals, "Assert number of total Signals"); + Assertions.assertEquals(115,scenario.getLanes().getLanesToLinkAssignments().size(),"Assert no of links with lanes"); } if (!setMakePedestrianSignals && !setAllowUTurnAtLeftLaneOnly && !setMergeOnewaySignalSystems){ - Assert.assertEquals("Assert number of nodes", 314, network.getNodes().size()); - Assert.assertEquals("Assert number of links", 658, network.getLinks().size()); - Assert.assertEquals("Assert number of Systems", 56, signalsData.getSignalSystemsData().getSignalSystemData().size()); - Assert.assertEquals("Assert number of total SignalGroups", 131, noSignalGroups); - Assert.assertEquals("Assert number of total Signals", 251, noSignals); - Assert.assertEquals("Assert no of links with lanes",122,scenario.getLanes().getLanesToLinkAssignments().size()); + Assertions.assertEquals(314, network.getNodes().size(), "Assert number of nodes"); + Assertions.assertEquals(658, network.getLinks().size(), "Assert number of links"); + Assertions.assertEquals(56, signalsData.getSignalSystemsData().getSignalSystemData().size(), "Assert number of Systems"); + Assertions.assertEquals(131, noSignalGroups, "Assert number of total SignalGroups"); + Assertions.assertEquals(251, noSignals, "Assert number of total Signals"); + Assertions.assertEquals(122,scenario.getLanes().getLanesToLinkAssignments().size(),"Assert no of links with lanes"); } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/ControlerTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/ControlerTest.java index 79d7a09eb7c..31f7e100544 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/ControlerTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/ControlerTest.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.contrib.signals.oneagent; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -120,10 +120,10 @@ public void reset(int i) {} @Override public void handleEvent(SignalGroupStateChangedEvent e) { if (e.getNewState().equals(SignalGroupState.RED)){ - Assert.assertEquals(0.0, e.getTime(), 1e-7); + Assertions.assertEquals(0.0, e.getTime(), 1e-7); } else if (e.getNewState().equals(SignalGroupState.GREEN)) { - Assert.assertEquals(100.0, e.getTime(), 1e-7); + Assertions.assertEquals(100.0, e.getTime(), 1e-7); } } } @@ -137,7 +137,7 @@ public void reset(int i) {} @Override public void handleEvent(LinkEnterEvent e){ if (e.getLinkId().equals(linkId2)) { - Assert.assertEquals(link2EnterTime, e.getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(link2EnterTime, e.getTime(), MatsimTestUtils.EPSILON); } } } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/sensor/LaneSensorTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/sensor/LaneSensorTest.java index 837ae251427..2f54084b699 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/sensor/LaneSensorTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/sensor/LaneSensorTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.signals.sensor; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; import org.matsim.core.api.experimental.events.LaneEnterEvent; diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/sensor/LinkSensorTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/sensor/LinkSensorTest.java index 66e78addeb7..c29b1c71ae9 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/sensor/LinkSensorTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/sensor/LinkSensorTest.java @@ -1,9 +1,9 @@ package org.matsim.contrib.signals.sensor; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -155,7 +155,7 @@ void testSensorNumberOfCarsMonitoring(){ Link link = sc.getNetwork().getLinks().get(Id.create(1, Link.class)); LinkSensor sensor = new LinkSensor(link); int numberOfCars = sensor.getNumberOfCarsOnLink(); - Assert.assertEquals(0, numberOfCars); + Assertions.assertEquals(0, numberOfCars); Id agId2 = Id.createPersonId(2); Id vehId1 = Id.create(1, Vehicle.class); @@ -164,7 +164,7 @@ void testSensorNumberOfCarsMonitoring(){ LinkEnterEvent enterEvent = new LinkEnterEvent(0.0, vehId1, link.getId()); sensor.handleEvent(enterEvent); numberOfCars = sensor.getNumberOfCarsOnLink(); - Assert.assertEquals(1, numberOfCars); + Assertions.assertEquals(1, numberOfCars); //expect NullPointerException as feature is still switched of NullPointerException e = null; try { @@ -173,32 +173,32 @@ void testSensorNumberOfCarsMonitoring(){ catch (NullPointerException ex){ e = ex; } - Assert.assertNotNull(e); + Assertions.assertNotNull(e); LinkEnterEvent enterEvent2 = new LinkEnterEvent(10.0, vehId2, link.getId()); sensor.handleEvent(enterEvent2); numberOfCars = sensor.getNumberOfCarsOnLink(); - Assert.assertEquals(2, numberOfCars); + Assertions.assertEquals(2, numberOfCars); LinkLeaveEvent leaveEvent = new LinkLeaveEvent(100.0, vehId1, link.getId()); sensor.handleEvent(leaveEvent); numberOfCars = sensor.getNumberOfCarsOnLink(); - Assert.assertEquals(1, numberOfCars); + Assertions.assertEquals(1, numberOfCars); VehicleLeavesTrafficEvent link2WaitEvent = new VehicleLeavesTrafficEvent(110.0, agId2, link.getId(), vehId2, TransportMode.car, 1.0); sensor.handleEvent(link2WaitEvent); numberOfCars = sensor.getNumberOfCarsOnLink(); - Assert.assertEquals(0, numberOfCars); + Assertions.assertEquals(0, numberOfCars); PersonEntersVehicleEvent enterVehEvent = new PersonEntersVehicleEvent(120., agId2, vehId2); sensor.handleEvent(enterVehEvent); numberOfCars = sensor.getNumberOfCarsOnLink(); - Assert.assertEquals(1, numberOfCars); + Assertions.assertEquals(1, numberOfCars); leaveEvent = new LinkLeaveEvent(120.0, vehId2, link.getId()); sensor.handleEvent(leaveEvent); numberOfCars = sensor.getNumberOfCarsOnLink(); - Assert.assertEquals(0, numberOfCars); + Assertions.assertEquals(0, numberOfCars); } @Test @@ -208,9 +208,9 @@ void testSensorDistanceMonitoring(){ LinkSensor sensor = new LinkSensor(link); sensor.registerDistanceToMonitor(100.0); int numberOfCars = sensor.getNumberOfCarsOnLink(); - Assert.assertEquals(0, numberOfCars); + Assertions.assertEquals(0, numberOfCars); int numberOfCarsInDistance = sensor.getNumberOfCarsInDistance(100.0, 0.0); - Assert.assertEquals(0, numberOfCarsInDistance); + Assertions.assertEquals(0, numberOfCarsInDistance); Id agId2 = Id.createPersonId(2); Id vehId1 = Id.create(1, Vehicle.class); @@ -219,12 +219,12 @@ void testSensorDistanceMonitoring(){ LinkEnterEvent enterEvent = new LinkEnterEvent(0.0, vehId1, link.getId()); sensor.handleEvent(enterEvent); numberOfCars = sensor.getNumberOfCarsOnLink(); - Assert.assertEquals(1, numberOfCars); + Assertions.assertEquals(1, numberOfCars); enterEvent = new LinkEnterEvent(1.0, vehId2, link.getId()); sensor.handleEvent(enterEvent); numberOfCars = sensor.getNumberOfCarsOnLink(); - Assert.assertEquals(2, numberOfCars); + Assertions.assertEquals(2, numberOfCars); //expect NullPointerException as feature is not switched on for distance 500.0 m NullPointerException e = null; @@ -234,43 +234,43 @@ void testSensorDistanceMonitoring(){ catch (NullPointerException ex){ e = ex; } - Assert.assertNotNull(e); + Assertions.assertNotNull(e); numberOfCarsInDistance = sensor.getNumberOfCarsInDistance(100.0, 10.0); - Assert.assertEquals(0, numberOfCarsInDistance); + Assertions.assertEquals(0, numberOfCarsInDistance); numberOfCarsInDistance = sensor.getNumberOfCarsInDistance(100.0, 83.0); - Assert.assertEquals(0, numberOfCarsInDistance); + Assertions.assertEquals(0, numberOfCarsInDistance); numberOfCarsInDistance = sensor.getNumberOfCarsInDistance(100.0, 84.0); - Assert.assertEquals(1, numberOfCarsInDistance); + Assertions.assertEquals(1, numberOfCarsInDistance); numberOfCarsInDistance = sensor.getNumberOfCarsInDistance(100.0, 85.0); - Assert.assertEquals(2, numberOfCarsInDistance); + Assertions.assertEquals(2, numberOfCarsInDistance); LinkLeaveEvent leaveEvent = new LinkLeaveEvent(100.0, vehId1, link.getId()); sensor.handleEvent(leaveEvent); numberOfCarsInDistance = sensor.getNumberOfCarsInDistance(100.0, 100.0); - Assert.assertEquals(1, numberOfCarsInDistance); + Assertions.assertEquals(1, numberOfCarsInDistance); VehicleLeavesTrafficEvent link2WaitEvent = new VehicleLeavesTrafficEvent(101.0, agId2, link.getId(), vehId2, TransportMode.car, 1.0); sensor.handleEvent(link2WaitEvent); numberOfCarsInDistance = sensor.getNumberOfCarsInDistance(100.0, 101.0); - Assert.assertEquals(0, numberOfCarsInDistance); + Assertions.assertEquals(0, numberOfCarsInDistance); PersonEntersVehicleEvent enterVehEvent = new PersonEntersVehicleEvent(120., agId2, vehId2); sensor.handleEvent(enterVehEvent); numberOfCarsInDistance = sensor.getNumberOfCarsInDistance(100.0, 120.0); - Assert.assertEquals(1, numberOfCarsInDistance); + Assertions.assertEquals(1, numberOfCarsInDistance); leaveEvent = new LinkLeaveEvent(120.0, vehId2, link.getId()); sensor.handleEvent(leaveEvent); numberOfCarsInDistance = sensor.getNumberOfCarsInDistance(100.0, 120.0); - Assert.assertEquals(0, numberOfCarsInDistance); + Assertions.assertEquals(0, numberOfCarsInDistance); } diff --git a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/DefaultAnnealingAcceptorTest.java b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/DefaultAnnealingAcceptorTest.java index 0fc9099c9b0..6ad7ebd5208 100644 --- a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/DefaultAnnealingAcceptorTest.java +++ b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/DefaultAnnealingAcceptorTest.java @@ -9,7 +9,7 @@ package org.matsim.contrib.simulatedannealing; import org.apache.commons.lang3.mutable.MutableInt; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.core.controler.IterationCounter; import org.matsim.contrib.simulatedannealing.acceptor.DefaultAnnealingAcceptor; @@ -37,27 +37,27 @@ void testAcceptor() { TemperatureFunction.DefaultFunctions temperatureFunction = TemperatureFunction.DefaultFunctions.exponentialMultiplicative; boolean accept = acceptor.accept(currentSolution, acceptedSolution, temperature(iteration)); - Assert.assertTrue(accept); + Assertions.assertTrue(accept); currentSolution = new SimulatedAnnealing.Solution<>("current", 15); - Assert.assertTrue(acceptor.accept(currentSolution, acceptedSolution, temperature(iteration))); + Assertions.assertTrue(acceptor.accept(currentSolution, acceptedSolution, temperature(iteration))); currentSolution = new SimulatedAnnealing.Solution<>("current", 20); - Assert.assertTrue(acceptor.accept(currentSolution, acceptedSolution, temperature(iteration))); + Assertions.assertTrue(acceptor.accept(currentSolution, acceptedSolution, temperature(iteration))); iteration.setValue(10); - Assert.assertTrue(acceptor.accept(currentSolution, acceptedSolution, temperature(iteration))); + Assertions.assertTrue(acceptor.accept(currentSolution, acceptedSolution, temperature(iteration))); iteration.setValue(1000); - Assert.assertFalse(acceptor.accept(currentSolution, acceptedSolution, temperature(iteration))); + Assertions.assertFalse(acceptor.accept(currentSolution, acceptedSolution, temperature(iteration))); currentSolution = new SimulatedAnnealing.Solution<>("current", 10); - Assert.assertTrue(acceptor.accept(currentSolution, acceptedSolution, temperature(iteration))); + Assertions.assertTrue(acceptor.accept(currentSolution, acceptedSolution, temperature(iteration))); - Assert.assertThrows(RuntimeException.class, () -> acceptor.accept(null, null, temperature(iteration))); - Assert.assertThrows(RuntimeException.class, () -> acceptor.accept(new SimulatedAnnealing.Solution<>("notnull"), null, temperature(iteration))); - Assert.assertThrows(RuntimeException.class, () -> acceptor.accept(new SimulatedAnnealing.Solution<>("notnull"), new SimulatedAnnealing.Solution<>("notnull"), temperature(iteration))); + Assertions.assertThrows(RuntimeException.class, () -> acceptor.accept(null, null, temperature(iteration))); + Assertions.assertThrows(RuntimeException.class, () -> acceptor.accept(new SimulatedAnnealing.Solution<>("notnull"), null, temperature(iteration))); + Assertions.assertThrows(RuntimeException.class, () -> acceptor.accept(new SimulatedAnnealing.Solution<>("notnull"), new SimulatedAnnealing.Solution<>("notnull"), temperature(iteration))); } private double temperature(MutableInt iteration) { diff --git a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingConfigGroupTest.java b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingConfigGroupTest.java index 4596d83435c..7b5ac7bfb78 100644 --- a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingConfigGroupTest.java +++ b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingConfigGroupTest.java @@ -8,7 +8,7 @@ */ package org.matsim.contrib.simulatedannealing; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.io.TempDir; @@ -59,9 +59,9 @@ void loadConfigGroupTest() throws IOException { Config config = ConfigUtils.createConfig(); ConfigUtils.loadConfig(config, configFile.toString()); SimulatedAnnealingConfigGroup loadedCfg = ConfigUtils.addOrGetModule(config, SimulatedAnnealingConfigGroup.class); - Assert.assertEquals(42., loadedCfg.alpha, MatsimTestUtils.EPSILON); - Assert.assertEquals(42., loadedCfg.initialTemperature, MatsimTestUtils.EPSILON); - Assert.assertEquals(TemperatureFunction.DefaultFunctions.exponentialAdditive, loadedCfg.coolingSchedule); + Assertions.assertEquals(42., loadedCfg.alpha, MatsimTestUtils.EPSILON); + Assertions.assertEquals(42., loadedCfg.initialTemperature, MatsimTestUtils.EPSILON); + Assertions.assertEquals(TemperatureFunction.DefaultFunctions.exponentialAdditive, loadedCfg.coolingSchedule); } @@ -70,7 +70,7 @@ void perturbationParamsTest() { Config config = createConfig(); SimulatedAnnealingConfigGroup saConfig = ConfigUtils.addOrGetModule(config, SimulatedAnnealingConfigGroup.class); - Assert.assertTrue(saConfig.getPerturbationParams().isEmpty()); + Assertions.assertTrue(saConfig.getPerturbationParams().isEmpty()); saConfig.addPerturbationParams(new SimulatedAnnealingConfigGroup.PerturbationParams("perturb", 1.) { @Override @@ -79,9 +79,9 @@ public Map getComments() { } }); - Assert.assertFalse(saConfig.getPerturbationParams().isEmpty()); - Assert.assertTrue(saConfig.getPerturbationParamsPerType().containsKey("perturb")); - Assert.assertEquals(1., saConfig.getPerturbationParamsPerType().get("perturb").weight, MatsimTestUtils.EPSILON); + Assertions.assertFalse(saConfig.getPerturbationParams().isEmpty()); + Assertions.assertTrue(saConfig.getPerturbationParamsPerType().containsKey("perturb")); + Assertions.assertEquals(1., saConfig.getPerturbationParamsPerType().get("perturb").weight, MatsimTestUtils.EPSILON); } } diff --git a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingTest.java b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingTest.java index 020a184d6ef..ae3594ac1d4 100644 --- a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingTest.java +++ b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingTest.java @@ -16,7 +16,7 @@ import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.core.config.Configuration; import org.apache.logging.log4j.core.config.LoggerConfig; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.contrib.simulatedannealing.acceptor.Acceptor; import org.matsim.contrib.simulatedannealing.acceptor.DefaultAnnealingAcceptor; @@ -62,7 +62,7 @@ void testSimulatedAnnealing() { simulatedAnnealing.notifyAfterMobsim(new AfterMobsimEvent(null, i, false)); } - Assert.assertEquals("matsim", simulatedAnnealing.getCurrentState().get().accepted().get()); + Assertions.assertEquals("matsim", simulatedAnnealing.getCurrentState().get().accepted().get()); } private PerturbatorFactory perturbatorFactory() { diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/events/CourtesyEventsTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/events/CourtesyEventsTest.java index 63c5ecc5a71..4ddee30e796 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/events/CourtesyEventsTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/events/CourtesyEventsTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; @@ -241,10 +241,10 @@ public void handleEvent( Event event ) { eventManager.finishProcessing(); - Assert.assertEquals( - "wrong number of events in "+collected, + Assertions.assertEquals( expectedCourtesy, - collected.size() ); + collected.size(), + "wrong number of events in "+collected ); } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanFactoryTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanFactoryTest.java index 6e2bd112d94..bc5d946d0df 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanFactoryTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanFactoryTest.java @@ -19,12 +19,12 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.framework.population; -import static org.junit.Assert.assertEquals; - import java.util.LinkedHashMap; import java.util.Map; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; @@ -53,14 +53,14 @@ void testAddAtIndividualLevel() throws Exception { new JointPlanFactory().createJointPlan( jp , true ); assertEquals( - "unexpected number of plans for first person", 1, - person1.getPlans().size()); + person1.getPlans().size(), + "unexpected number of plans for first person"); assertEquals( - "unexpected number of plans for second person", 1, - person2.getPlans().size()); + person2.getPlans().size(), + "unexpected number of plans for second person"); } @Test @@ -82,14 +82,14 @@ void testDoNotAddAtIndividualLevel() throws Exception { new JointPlanFactory().createJointPlan( jp , false ); assertEquals( - "unexpected number of plans for first person", 0, - person1.getPlans().size()); + person1.getPlans().size(), + "unexpected number of plans for first person"); assertEquals( - "unexpected number of plans for second person", 0, - person2.getPlans().size()); + person2.getPlans().size(), + "unexpected number of plans for second person"); } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanIOTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanIOTest.java index cf248036757..d1b1a8d9889 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanIOTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlanIOTest.java @@ -26,7 +26,7 @@ import java.util.Queue; import java.util.Random; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -70,25 +70,25 @@ void testDumpAndRead() throws Exception { final JointPlan read = reReadJointPlans.getJointPlan( plan ); if ( dumped == null ) { - Assert.assertNull( - "dumped is null but read is not", - read ); + Assertions.assertNull( + read, + "dumped is null but read is not" ); continue; } - Assert.assertNotNull( - "dumped is not null but read is", - read ); + Assertions.assertNotNull( + read, + "dumped is not null but read is" ); - Assert.assertEquals( - "dumped has not the same size as read", + Assertions.assertEquals( dumped.getIndividualPlans().size(), - read.getIndividualPlans().size() ); + read.getIndividualPlans().size(), + "dumped has not the same size as read" ); - Assert.assertTrue( - "plans in dumped and read do not match", + Assertions.assertTrue( dumped.getIndividualPlans().values().containsAll( - read.getIndividualPlans().values() ) ); + read.getIndividualPlans().values() ), + "plans in dumped and read do not match" ); } } } @@ -115,11 +115,11 @@ void testPlansOrderIsStableInCoreIO() throws Exception { final Iterator readPlans = readPerson.getPlans().iterator(); while( dumpedPlans.hasNext() ) { // score are set different for every plan in the sequence - Assert.assertEquals( - "order of plans have changed through IO", + Assertions.assertEquals( dumpedPlans.next().getScore(), readPlans.next().getScore(), - MatsimTestUtils.EPSILON ); + MatsimTestUtils.EPSILON, + "order of plans have changed through IO" ); } } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlansTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlansTest.java index b8898723c03..5aeecce937d 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlansTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/JointPlansTest.java @@ -22,7 +22,7 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -68,9 +68,9 @@ private static void testExceptionAdd( final boolean withCache ) throws Exception gotException = true; } - Assert.assertTrue( - "got no exception when associating two joint plans to one individual plan", - gotException); + Assertions.assertTrue( + gotException, + "got no exception when associating two joint plans to one individual plan"); } @Test @@ -109,9 +109,9 @@ private static void testExceptionRemove( final boolean withCache ) throws Except gotException = true; } - Assert.assertTrue( - "got no exception when associating two joint plans to one individual plan", - gotException); + Assertions.assertTrue( + gotException, + "got no exception when associating two joint plans to one individual plan"); } @Test @@ -152,50 +152,50 @@ private static void testAddAndGetSeveralInstances( final boolean withCache ) { final JointPlan jointPlan5 = jointPlans5.getFactory().createJointPlan( jp ); jointPlans5.addJointPlan( jointPlan5 ); - Assert.assertSame( - "wrong joint plan 1 for person 1", + Assertions.assertSame( jointPlan1, - jointPlans1.getJointPlan( p1 ) ); - Assert.assertSame( - "wrong joint plan 1 for person 2", + jointPlans1.getJointPlan( p1 ), + "wrong joint plan 1 for person 1" ); + Assertions.assertSame( jointPlan1, - jointPlans1.getJointPlan( p2 ) ); + jointPlans1.getJointPlan( p2 ), + "wrong joint plan 1 for person 2" ); - Assert.assertSame( - "wrong joint plan 2 for person 1", + Assertions.assertSame( jointPlan2, - jointPlans2.getJointPlan( p1 ) ); - Assert.assertSame( - "wrong joint plan 2 for person 2", + jointPlans2.getJointPlan( p1 ), + "wrong joint plan 2 for person 1" ); + Assertions.assertSame( jointPlan2, - jointPlans2.getJointPlan( p2 ) ); + jointPlans2.getJointPlan( p2 ), + "wrong joint plan 2 for person 2" ); - Assert.assertSame( - "wrong joint plan 3 for person 1", + Assertions.assertSame( jointPlan3, - jointPlans3.getJointPlan( p1 ) ); - Assert.assertSame( - "wrong joint plan 3 for person 2", + jointPlans3.getJointPlan( p1 ), + "wrong joint plan 3 for person 1" ); + Assertions.assertSame( jointPlan3, - jointPlans3.getJointPlan( p2 ) ); + jointPlans3.getJointPlan( p2 ), + "wrong joint plan 3 for person 2" ); - Assert.assertSame( - "wrong joint plan 4 for person 1", + Assertions.assertSame( jointPlan4, - jointPlans4.getJointPlan( p1 ) ); - Assert.assertSame( - "wrong joint plan 4 for person 2", + jointPlans4.getJointPlan( p1 ), + "wrong joint plan 4 for person 1" ); + Assertions.assertSame( jointPlan4, - jointPlans4.getJointPlan( p2 ) ); + jointPlans4.getJointPlan( p2 ), + "wrong joint plan 4 for person 2" ); - Assert.assertSame( - "wrong joint plan 5 for person 1", + Assertions.assertSame( jointPlan5, - jointPlans5.getJointPlan( p1 ) ); - Assert.assertSame( - "wrong joint plan 5 for person 2", + jointPlans5.getJointPlan( p1 ), + "wrong joint plan 5 for person 1" ); + Assertions.assertSame( jointPlan5, - jointPlans5.getJointPlan( p2 ) ); + jointPlans5.getJointPlan( p2 ), + "wrong joint plan 5 for person 2" ); } @@ -221,14 +221,14 @@ private static void testClear( final boolean withCache ) { jointPlans.addJointPlan( jointPlans.getFactory().createJointPlan( jp1 ) ); - Assert.assertNotNull( - "joint plan was not added???", - jointPlans.getJointPlan( p1 ) ); + Assertions.assertNotNull( + jointPlans.getJointPlan( p1 ), + "joint plan was not added???" ); jointPlans.clear(); - Assert.assertNull( - "still a joint plan after clear...", - jointPlans.getJointPlan( p1 ) ); + Assertions.assertNull( + jointPlans.getJointPlan( p1 ), + "still a joint plan after clear..." ); } private static Plan createPlan( final Person person , final boolean withCache ) { diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkIOTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkIOTest.java index 0a44ae0fd97..4ba6ec658e8 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkIOTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkIOTest.java @@ -24,7 +24,7 @@ import java.util.Random; import java.util.Set; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -64,20 +64,20 @@ private void testReinput(final boolean isReflective) { final SocialNetwork input = (SocialNetwork) sc.getScenarioElement( SocialNetwork.ELEMENT_NAME ); - Assert.assertEquals( - "unexpected reflectiveness", + Assertions.assertEquals( output.isReflective(), - input.isReflective() ); + input.isReflective(), + "unexpected reflectiveness" ); - Assert.assertEquals( - "unexpected number of egos", + Assertions.assertEquals( output.getEgos().size(), - input.getEgos().size() ); + input.getEgos().size(), + "unexpected number of egos" ); - Assert.assertEquals( - "different ego ids", + Assertions.assertEquals( output.getEgos(), - input.getEgos() ); + input.getEgos(), + "different ego ids" ); final Counter c = new Counter( "Test alters of ego # " ); for ( Id ego : output.getEgos() ) { @@ -85,21 +85,21 @@ private void testReinput(final boolean isReflective) { final Set> expectedAlters = output.getAlters( ego ); final Set> actualAlters = input.getAlters( ego ); - Assert.assertEquals( - "unexpected number of alters for ego "+ego, + Assertions.assertEquals( expectedAlters.size(), - actualAlters.size() ); + actualAlters.size(), + "unexpected number of alters for ego "+ego ); - Assert.assertEquals( - "unexpected alters for ego "+ego, + Assertions.assertEquals( expectedAlters, - actualAlters ); + actualAlters, + "unexpected alters for ego "+ego ); } - Assert.assertEquals( - "different metadata", + Assertions.assertEquals( output.getMetadata(), - input.getMetadata() ); + input.getMetadata(), + "different metadata" ); c.printCounter(); } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkTest.java index 4728c8d94fb..71aa36c301f 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/population/SocialNetworkTest.java @@ -23,7 +23,7 @@ import java.util.Collections; import java.util.HashSet; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; @@ -52,20 +52,20 @@ void testMonodirectionalTie() { sn.addEgo( alter ); sn.addMonodirectionalTie( ego , alter ); - Assert.assertEquals( - "unexpected egos", + Assertions.assertEquals( new HashSet>( Arrays.asList( ego , alter ) ), - sn.getEgos() ); + sn.getEgos(), + "unexpected egos" ); - Assert.assertEquals( - "unexpected alters of ego", + Assertions.assertEquals( Collections.singleton( alter ), - sn.getAlters( ego ) ); + sn.getAlters( ego ), + "unexpected alters of ego" ); - Assert.assertEquals( - "unexpected alters of alter", + Assertions.assertEquals( Collections.>emptySet(), - sn.getAlters( alter ) ); + sn.getAlters( alter ), + "unexpected alters of alter" ); } @Test @@ -78,20 +78,20 @@ void testBidirectionalTie() { sn.addEgo( alter ); sn.addBidirectionalTie( ego , alter ); - Assert.assertEquals( - "unexpected egos", + Assertions.assertEquals( new HashSet>( Arrays.asList( ego , alter ) ), - sn.getEgos() ); + sn.getEgos(), + "unexpected egos" ); - Assert.assertEquals( - "unexpected alters of ego", + Assertions.assertEquals( Collections.singleton( alter ), - sn.getAlters( ego ) ); + sn.getAlters( ego ), + "unexpected alters of ego" ); - Assert.assertEquals( - "unexpected alters of alter", + Assertions.assertEquals( Collections.singleton( ego ), - sn.getAlters( alter ) ); + sn.getAlters( alter ), + "unexpected alters of alter" ); } @Test @@ -136,34 +136,34 @@ void testRemoveEgo() { } sn.removeEgo( ego ); - Assert.assertFalse( - "ego still in social network", - sn.getEgos().contains( ego ) ); + Assertions.assertFalse( + sn.getEgos().contains( ego ), + "ego still in social network" ); for ( Id alter : new Id[]{ a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 } ) { - Assert.assertFalse( - "ego still in network of agent "+alter, - sn.getAlters( alter ).contains( ego ) ); + Assertions.assertFalse( + sn.getAlters( alter ).contains( ego ), + "ego still in network of agent "+alter ); } for ( Id alter : new Id[]{ a1 , a2 , a3 , a4 , a5 } ) { - Assert.assertEquals( - "wrong network size for "+alter, + Assertions.assertEquals( 0, - sn.getAlters( alter ).size() ); + sn.getAlters( alter ).size(), + "wrong network size for "+alter ); } for ( Id alter : new Id[]{ a7 , a8 , a9 , a10 } ) { - Assert.assertEquals( - "wrong network size for "+alter, + Assertions.assertEquals( 1, - sn.getAlters( alter ).size() ); + sn.getAlters( alter ).size(), + "wrong network size for "+alter ); } - Assert.assertEquals( - "wrong network size for "+a6, + Assertions.assertEquals( 4, - sn.getAlters( a6 ).size() ); + sn.getAlters( a6 ).size(), + "wrong network size for "+a6 ); } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/DynamicGroupIdentifierTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/DynamicGroupIdentifierTest.java index 1b992c0a25b..59fe40fda96 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/DynamicGroupIdentifierTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/DynamicGroupIdentifierTest.java @@ -23,7 +23,7 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -198,18 +198,18 @@ private void test( final Fixture fixture ) { final GroupIdentifier testee = new DynamicGroupIdentifier( fixture.scenario ); final Collection groups = testee.identifyGroups( fixture.scenario.getPopulation() ); - Assert.assertEquals( - "unexpected number of groups", + Assertions.assertEquals( fixture.expectedNGroups, - groups.size() ); + groups.size(), + "unexpected number of groups" ); int n = 0; for ( ReplanningGroup g : groups ) n += g.getPersons().size(); - Assert.assertEquals( - "unexpected number of persons in groups", + Assertions.assertEquals( fixture.scenario.getPopulation().getPersons().size(), - n ); + n, + "unexpected number of persons in groups" ); } private static class Fixture { diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/FixedGroupsIT.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/FixedGroupsIT.java index 8e521b385ec..171278bea52 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/FixedGroupsIT.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/FixedGroupsIT.java @@ -19,6 +19,8 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.framework.replanning.grouping; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -40,8 +42,6 @@ import java.util.Iterator; import java.util.Random; -import static org.junit.Assert.assertEquals; - /** * @author thibautd */ @@ -79,9 +79,9 @@ private static void assertIterationOrder( final Collection expected, final Collection actual) { assertEquals( - "not the same number of groups", expected.size(), - actual.size()); + actual.size(), + "not the same number of groups"); final Iterator expectedIter = expected.iterator(); final Iterator actualIter = actual.iterator(); @@ -95,10 +95,10 @@ private static void assertIterationOrder( final Iterator actualGroupIterator = actualGroup.getPersons().iterator(); for (Person expectedPerson : expectedGroup.getPersons()) { assertEquals( - "groups "+expectedGroup+" and "+actualGroup+" in position "+ - c+" are not equal or do not present the persons in the same order", expectedPerson.getId(), - actualGroupIterator.next().getId()); + actualGroupIterator.next().getId(), + "groups "+expectedGroup+" and "+actualGroup+" in position "+ + c+" are not equal or do not present the persons in the same order"); } } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/GroupPlansTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/GroupPlansTest.java index 3893c8cb2ba..bb64b0ae091 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/GroupPlansTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/GroupPlansTest.java @@ -19,9 +19,7 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.framework.replanning.grouping; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotSame; +import static org.junit.jupiter.api.Assertions.*; import java.util.ArrayList; import java.util.Collections; @@ -117,19 +115,19 @@ void testGetters() throws Exception { final GroupPlans testee = new GroupPlans( jointPlans , indivPlans ); assertEquals( - "wrong number of individual plans", indivPlans.size(), - testee.getIndividualPlans().size()); + testee.getIndividualPlans().size(), + "wrong number of individual plans"); assertEquals( - "wrong number of joint plans", jointPlans.size(), - testee.getJointPlans().size()); + testee.getJointPlans().size(), + "wrong number of joint plans"); assertEquals( - "wrong total number of indiv plans", indivPlans.size() + nIndivInJoints, - testee.getAllIndividualPlans().size()); + testee.getAllIndividualPlans().size(), + "wrong total number of indiv plans"); } @Test @@ -138,14 +136,14 @@ void testCopyLooksValid() throws Exception { GroupPlans copy = GroupPlans.copyPlans( factory , plans ); assertEquals( - "wrong number of individual plans in copy", plans.getIndividualPlans().size(), - copy.getIndividualPlans().size()); + copy.getIndividualPlans().size(), + "wrong number of individual plans in copy"); assertEquals( - "wrong number of joint plans in copy", plans.getJointPlans().size(), - copy.getJointPlans().size()); + copy.getJointPlans().size(), + "wrong number of joint plans in copy"); } } @@ -155,20 +153,20 @@ void testCopyIsNotSame() throws Exception { GroupPlans copy = GroupPlans.copyPlans( factory , plans ); assertNotSame( - "copy is the same instance", plans, - copy); + copy, + "copy is the same instance"); for (Plan p : plans.getIndividualPlans()) { assertFalse( - "the copy contains references from the copied", - copy.getIndividualPlans().contains( p )); + copy.getIndividualPlans().contains( p ), + "the copy contains references from the copied"); } for (JointPlan copiedJointPlan : plans.getJointPlans()) { assertFalse( - "the copy contains references from the copied", - copy.getJointPlans().contains( copiedJointPlan )); + copy.getJointPlans().contains( copiedJointPlan ), + "the copy contains references from the copied"); JointPlan copyJointPlan = getCopy( copiedJointPlan , copy ); for (Plan copyIndivPlan : copyJointPlan.getIndividualPlans().values()) { @@ -179,8 +177,8 @@ void testCopyIsNotSame() throws Exception { // JointPlanFactory.getPlanLinks().getJointPlan( copyIndivPlan )); assertFalse( - "individual plans were not copied when copying joint plan", - copiedJointPlan.getIndividualPlans().values().contains( copyIndivPlan )); + copiedJointPlan.getIndividualPlans().values().contains( copyIndivPlan ), + "individual plans were not copied when copying joint plan"); } } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/ActivitySequenceMutatorAlgorithmTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/ActivitySequenceMutatorAlgorithmTest.java index 2b80b22c47e..00050977cf3 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/ActivitySequenceMutatorAlgorithmTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/ActivitySequenceMutatorAlgorithmTest.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.framework.replanning.modules; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -54,18 +54,18 @@ void testTwoActivities() throws Exception { StageActivityHandling.StagesAsNormalActivities ); testee.run( plan ); - Assert.assertEquals( - "unexpected size of plan "+plan.getPlanElements(), + Assertions.assertEquals( plan.getPlanElements().size(), - 7 ); - Assert.assertEquals( - "unexpected type of first in-plan activity", + 7, + "unexpected size of plan "+plan.getPlanElements() ); + Assertions.assertEquals( ((Activity) plan.getPlanElements().get( 2 )).getType(), - "l" ); - Assert.assertEquals( - "unexpected type of second in-plan activity", + "l", + "unexpected type of first in-plan activity" ); + Assertions.assertEquals( ((Activity) plan.getPlanElements().get( 4 )).getType(), - "w" ); + "w", + "unexpected type of second in-plan activity" ); } @Test @@ -84,14 +84,14 @@ void testOneActivities() throws Exception { StageActivityHandling.StagesAsNormalActivities ); testee.run( plan ); - Assert.assertEquals( - "unexpected size of plan "+plan.getPlanElements(), + Assertions.assertEquals( plan.getPlanElements().size(), - 5 ); - Assert.assertEquals( - "unexpected type of first in-plan activity", + 5, + "unexpected size of plan "+plan.getPlanElements() ); + Assertions.assertEquals( ((Activity) plan.getPlanElements().get( 2 )).getType(), - "w" ); + "w", + "unexpected type of first in-plan activity" ); } @Test @@ -108,10 +108,10 @@ void testZeroActivities() throws Exception { StageActivityHandling.StagesAsNormalActivities ); testee.run( plan ); - Assert.assertEquals( - "unexpected size of plan "+plan.getPlanElements(), + Assertions.assertEquals( plan.getPlanElements().size(), - 3 ); + 3, + "unexpected size of plan "+plan.getPlanElements() ); } @Test @@ -134,22 +134,22 @@ void testStage() throws Exception { StageActivityHandling.ExcludeStageActivities ); testee.run( plan ); - Assert.assertEquals( - "unexpected size of plan "+plan.getPlanElements(), + Assertions.assertEquals( plan.getPlanElements().size(), - 9 ); - Assert.assertEquals( - "unexpected type of first in-plan activity", + 9, + "unexpected size of plan "+plan.getPlanElements() ); + Assertions.assertEquals( ((Activity) plan.getPlanElements().get( 2 )).getType(), - "stage" ); - Assert.assertEquals( - "unexpected type of second in-plan activity", + "stage", + "unexpected type of first in-plan activity" ); + Assertions.assertEquals( ((Activity) plan.getPlanElements().get( 4 )).getType(), - "l" ); - Assert.assertEquals( - "unexpected type of third in-plan activity", + "l", + "unexpected type of second in-plan activity" ); + Assertions.assertEquals( ((Activity) plan.getPlanElements().get( 6 )).getType(), - "w" ); + "w", + "unexpected type of third in-plan activity" ); } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/MergingTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/MergingTest.java index 93de284d592..51f2365c46f 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/MergingTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/MergingTest.java @@ -19,8 +19,6 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.framework.replanning.modules; -import static org.junit.Assert.assertEquals; - import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -29,6 +27,8 @@ import java.util.Random; import org.junit.After; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.Before; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; @@ -100,17 +100,17 @@ void testProbOne() throws Exception { int nplans = countPlans( gp ); algo.run( gp ); assertEquals( - "unexpected number of joint plans", 1, - gp.getJointPlans().size()); + gp.getJointPlans().size(), + "unexpected number of joint plans"); assertEquals( - "unexpected number of individual plans", 0, - gp.getIndividualPlans().size()); + gp.getIndividualPlans().size(), + "unexpected number of individual plans"); assertEquals( - "unexpected overall number of plans", nplans, - countPlans( gp )); + countPlans( gp ), + "unexpected overall number of plans"); } } @@ -129,17 +129,17 @@ void testProbZero() throws Exception { int njointplans = gp.getJointPlans().size(); algo.run( gp ); assertEquals( - "unexpected number of joint plans", njointplans, - gp.getJointPlans().size()); + gp.getJointPlans().size(), + "unexpected number of joint plans"); assertEquals( - "unexpected number of individual plans", nindivplans, - gp.getIndividualPlans().size()); + gp.getIndividualPlans().size(), + "unexpected number of individual plans"); assertEquals( - "unexpected overall number of plans", nplans, - countPlans( gp )); + countPlans( gp ), + "unexpected overall number of plans"); } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/TourModeUnifierAlgorithmTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/TourModeUnifierAlgorithmTest.java index d76f7cb58f8..ce3606c7c18 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/TourModeUnifierAlgorithmTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/TourModeUnifierAlgorithmTest.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -120,20 +120,20 @@ void testPlanWithOneSingleTour() throws Exception { new MainModeIdentifierImpl() ); testee.run( plan ); - Assert.assertEquals( - "unexpected plan size", + Assertions.assertEquals( 2 * nActs - 1, - plan.getPlanElements().size() ); + plan.getPlanElements().size(), + "unexpected plan size" ); for ( Trip trip : TripStructureUtils.getTrips( plan , TripStructureUtils::isStageActivityType ) ) { - Assert.assertEquals( - "unexpected size of trip "+trip, + Assertions.assertEquals( 1, - trip.getTripElements().size() ); + trip.getTripElements().size(), + "unexpected size of trip "+trip ); - Assert.assertEquals( - "unexpected mode of trip "+trip, + Assertions.assertEquals( mode, - ((Leg) trip.getTripElements().get( 0 )).getMode() ); + ((Leg) trip.getTripElements().get( 0 )).getMode(), + "unexpected mode of trip "+trip ); } } @@ -193,47 +193,47 @@ void testPlanWithTwoToursOnOpenTour() throws Exception { new MainModeIdentifierImpl() ); testee.run( plan ); - Assert.assertEquals( - "unexpected plan size", + Assertions.assertEquals( 31, - plan.getPlanElements().size() ); + plan.getPlanElements().size(), + "unexpected plan size" ); final List trips = TripStructureUtils.getTrips( plan , TripStructureUtils::isStageActivityType ); - Assert.assertEquals( - "unexpected number of trips", + Assertions.assertEquals( 13, - trips.size() ); + trips.size(), + "unexpected number of trips" ); for ( int tripNr : new int[]{0,1,6,11,12} ) { - Assert.assertEquals( - "unexpected mode for trip "+tripNr, + Assertions.assertEquals( modeOfOpenTour, - trips.get( tripNr ).getLegsOnly().get( 0 ).getMode() ); + trips.get( tripNr ).getLegsOnly().get( 0 ).getMode(), + "unexpected mode for trip "+tripNr ); } for ( int tripNr : new int[]{2,3,3,4,5} ) { - Assert.assertEquals( - "unexpected length for trip "+tripNr, + Assertions.assertEquals( 1, - trips.get( tripNr ).getLegsOnly().size() ); + trips.get( tripNr ).getLegsOnly().size(), + "unexpected length for trip "+tripNr ); - Assert.assertEquals( - "unexpected mode for trip "+tripNr, + Assertions.assertEquals( mode1, - trips.get( tripNr ).getLegsOnly().get( 0 ).getMode() ); + trips.get( tripNr ).getLegsOnly().get( 0 ).getMode(), + "unexpected mode for trip "+tripNr ); } for ( int tripNr : new int[]{7,8,9,10} ) { - Assert.assertEquals( - "unexpected length for trip "+tripNr, + Assertions.assertEquals( 1, - trips.get( tripNr ).getLegsOnly().size() ); + trips.get( tripNr ).getLegsOnly().size(), + "unexpected length for trip "+tripNr ); - Assert.assertEquals( - "unexpected mode for trip "+tripNr, + Assertions.assertEquals( mode2, - trips.get( tripNr ).getLegsOnly().get( 0 ).getMode() ); + trips.get( tripNr ).getLegsOnly().get( 0 ).getMode(), + "unexpected mode for trip "+tripNr ); } } @@ -271,7 +271,7 @@ void testPlanWithTwoHomeBasedTours() throws Exception { final List activities = TripStructureUtils.getActivities( plan, StageActivityHandling.ExcludeStageActivities ); final int nActs = activities.size(); - Assert.assertEquals( 9, nActs ); + Assertions.assertEquals( 9, nActs ); final PlanAlgorithm testee = new TourModeUnifierAlgorithm( @@ -279,40 +279,40 @@ void testPlanWithTwoHomeBasedTours() throws Exception { new MainModeIdentifierImpl() ); testee.run( plan ); - Assert.assertEquals( - "unexpected plan size", + Assertions.assertEquals( 2 * nActs - 1, - plan.getPlanElements().size() ); + plan.getPlanElements().size(), + "unexpected plan size" ); final List trips = TripStructureUtils.getTrips( plan , TripStructureUtils::isStageActivityType ); - Assert.assertEquals( - "unexpected number of trips", + Assertions.assertEquals( 8, - trips.size() ); + trips.size(), + "unexpected number of trips" ); for ( int tripNr : new int[]{0,1,2,3} ) { - Assert.assertEquals( - "unexpected length for trip "+tripNr, + Assertions.assertEquals( 1, - trips.get( tripNr ).getLegsOnly().size() ); + trips.get( tripNr ).getLegsOnly().size(), + "unexpected length for trip "+tripNr ); - Assert.assertEquals( - "unexpected mode for trip "+tripNr, + Assertions.assertEquals( mode1, - trips.get( tripNr ).getLegsOnly().get( 0 ).getMode() ); + trips.get( tripNr ).getLegsOnly().get( 0 ).getMode(), + "unexpected mode for trip "+tripNr ); } for ( int tripNr : new int[]{4,5,6,7} ) { - Assert.assertEquals( - "unexpected length for trip "+tripNr, + Assertions.assertEquals( 1, - trips.get( tripNr ).getLegsOnly().size() ); + trips.get( tripNr ).getLegsOnly().size(), + "unexpected length for trip "+tripNr ); - Assert.assertEquals( - "unexpected mode for trip "+tripNr, + Assertions.assertEquals( mode2, - trips.get( tripNr ).getLegsOnly().get( 0 ).getMode() ); + trips.get( tripNr ).getLegsOnly().get( 0 ).getMode(), + "unexpected mode for trip "+tripNr ); } } private static void printPlan( Plan plan ){ diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/removers/LexicographicRemoverTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/removers/LexicographicRemoverTest.java index 84a31fab439..98c821ace65 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/removers/LexicographicRemoverTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/removers/LexicographicRemoverTest.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -173,13 +173,13 @@ private static void test(final Fixture f) { for ( Person p : f.group.getPersons() ) { final Plan expectedRemoved = f.expectedRemovedPlans.get( p.getId() ); - Assert.assertFalse( - expectedRemoved+" not removed for person "+p, - p.getPlans().contains( expectedRemoved ) ); + Assertions.assertFalse( + p.getPlans().contains( expectedRemoved ), + expectedRemoved+" not removed for person "+p ); - Assert.assertNull( - "MEMORY LEAK: There is still a joint plan associated to removed plan "+expectedRemoved, - f.jointPlans.getJointPlan( expectedRemoved ) ); + Assertions.assertNull( + f.jointPlans.getJointPlan( expectedRemoved ), + "MEMORY LEAK: There is still a joint plan associated to removed plan "+expectedRemoved ); } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/FullExplorationVsCuttoffTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/FullExplorationVsCuttoffTest.java index e541b2ac672..2bf1b4d1c99 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/FullExplorationVsCuttoffTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/FullExplorationVsCuttoffTest.java @@ -22,8 +22,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.population.Plan; @@ -98,13 +98,13 @@ private void testFullExplorationVsCuttoff( final double scoreFull = calcScore( fullResult ); // allow different results, as long as the scores are identical - Assert.assertEquals( + Assertions.assertEquals( + fastResult, + fullResult, "different solutions with both exploration types."+ " full score: "+scoreFull+ " fast: "+scoreFast+ - " ", - fastResult, - fullResult); + " "); if ( fastResult == null ) countNull++; } count.printCounter(); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/HighestWeightSelectorTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/HighestWeightSelectorTest.java index a1a9b606c00..41316c90707 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/HighestWeightSelectorTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/HighestWeightSelectorTest.java @@ -31,8 +31,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -1268,16 +1268,16 @@ void testNoSideEffects() throws Exception { fixture.jointPlans, fixture.group ); - Assert.assertEquals( - "unexpected change in group size for fixture "+fixture.name, + Assertions.assertEquals( initialGroupSize, - fixture.group.getPersons().size() ); + fixture.group.getPersons().size(), + "unexpected change in group size for fixture "+fixture.name ); for (Person p : fixture.group.getPersons()) { - Assert.assertEquals( - "unexpected change in the number of plans for agent "+p.getId()+" in fixture "+fixture.name, + Assertions.assertEquals( planCounts.get( p.getId() ).intValue(), - p.getPlans().size() ); + p.getPlans().size(), + "unexpected change in the number of plans for agent "+p.getId()+" in fixture "+fixture.name ); } } @@ -1307,10 +1307,10 @@ private void testSelectedPlans( (forbidding ? fixture.expectedSelectedPlansWhenForbidding : fixture.expectedSelectedPlans); - Assert.assertEquals( - "unexpected selected plan in test instance <<"+fixture.name+">> ", + Assertions.assertEquals( expected, - selected); + selected, + "unexpected selected plan in test instance <<"+fixture.name+">> "); } private static class CollectionBasedPlanForbidderFactory implements IncompatiblePlansIdentifierFactory { diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/RandomSelectorsTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/RandomSelectorsTest.java index 13628424eaa..deeb0b00ed6 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/RandomSelectorsTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/RandomSelectorsTest.java @@ -19,12 +19,14 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.framework.replanning.selectors; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.After; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -45,8 +47,6 @@ import java.util.Map; import java.util.Random; -import static org.junit.Assert.assertEquals; - /** * @author thibautd */ @@ -402,9 +402,9 @@ void testDeterminism() throws Exception { jointPlans , group ); if (previous != null) { assertEquals( - "different results with the same random seed", previous, - selected); + selected, + "different results with the same random seed"); } if (selected == null) throw new NullPointerException( "test is useless if the selector returns null" ); @@ -432,9 +432,9 @@ void testNoFailuresWithVariousSeeds() throws Exception { if (selected == null) throw new NullPointerException( "test is useless if the selector returns null" ); - Assert.assertEquals( "unexpected selected plan size" , - selected.getAllIndividualPlans().size(), - group.getPersons().size() ); + Assertions.assertEquals( selected.getAllIndividualPlans().size(), + group.getPersons().size(), + "unexpected selected plan size" ); } } groupCount.printCounter(); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/CoalitionSelectorTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/CoalitionSelectorTest.java index f9215f4ac9c..2209f10164b 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/CoalitionSelectorTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/CoalitionSelectorTest.java @@ -27,7 +27,7 @@ import java.util.List; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -227,10 +227,10 @@ void testSelectedPlans() { final GroupPlans expected = fixture.expectedSelectedPlans; - Assert.assertEquals( - "unexpected selected plan in test instance <<"+fixture.name+">> ", + Assertions.assertEquals( expected, - selected); + selected, + "unexpected selected plan in test instance <<"+fixture.name+">> "); } catch (Exception e) { throw new RuntimeException( "exception thrown for instance <<"+fixture.name+">>", e ); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/LeastAverageWeightJointPlanPruningConflictSolverTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/LeastAverageWeightJointPlanPruningConflictSolverTest.java index dc1a38d25bf..46c66cb8560 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/LeastAverageWeightJointPlanPruningConflictSolverTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/LeastAverageWeightJointPlanPruningConflictSolverTest.java @@ -22,7 +22,7 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -125,14 +125,14 @@ private static void test(final ConflictSolverTestsFixture fixture) { for ( PlanRecord r : fixture.allRecords ) { if ( fixture.expectedUnfeasiblePlans.contains( r.getPlan() ) ) { - Assert.assertFalse( - "plan "+r.getPlan()+" unexpectedly feasible", - r.isFeasible() ); + Assertions.assertFalse( + r.isFeasible(), + "plan "+r.getPlan()+" unexpectedly feasible" ); } else { - Assert.assertTrue( - "plan "+r.getPlan()+" unexpectedly unfeasible", - r.isFeasible() ); + Assertions.assertTrue( + r.isFeasible(), + "plan "+r.getPlan()+" unexpectedly unfeasible" ); } } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/LeastPointedPlanPruningConflictSolverTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/LeastPointedPlanPruningConflictSolverTest.java index 0626ebe295c..47898a3669e 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/LeastPointedPlanPruningConflictSolverTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/LeastPointedPlanPruningConflictSolverTest.java @@ -21,7 +21,7 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -120,14 +120,14 @@ private static void test(final ConflictSolverTestsFixture fixture) { for ( PlanRecord r : fixture.allRecords ) { if ( fixture.expectedUnfeasiblePlans.contains( r.getPlan() ) ) { - Assert.assertFalse( - "plan "+r.getPlan()+" unexpectedly feasible", - r.isFeasible() ); + Assertions.assertFalse( + r.isFeasible(), + "plan "+r.getPlan()+" unexpectedly feasible" ); } else { - Assert.assertTrue( - "plan "+r.getPlan()+" unexpectedly unfeasible", - r.isFeasible() ); + Assertions.assertTrue( + r.isFeasible(), + "plan "+r.getPlan()+" unexpectedly unfeasible" ); } } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/whoisthebossselector/WhoIsTheBossSelectorTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/whoisthebossselector/WhoIsTheBossSelectorTest.java index fbbbfe0018c..50823516b3e 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/whoisthebossselector/WhoIsTheBossSelectorTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/whoisthebossselector/WhoIsTheBossSelectorTest.java @@ -31,9 +31,9 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -83,17 +83,17 @@ void testOnePlanSelectedForEachAgent() throws Exception { } else { countNonNull++; - Assert.assertEquals( - "unexpected number of plans in selected plan", + Assertions.assertEquals( group.getPersons().size(), - selected.getAllIndividualPlans().size() ); + selected.getAllIndividualPlans().size(), + "unexpected number of plans in selected plan" ); final Set groupIds = getGroupIds( group ); final Set selectedIds = getPlanIds( selected ); - Assert.assertEquals( - "unexpected agent ids in selected plan", + Assertions.assertEquals( groupIds, - selectedIds ); + selectedIds, + "unexpected agent ids in selected plan" ); } } counter.printCounter(); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/scoring/GroupCompositionPenalizerTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/scoring/GroupCompositionPenalizerTest.java index b653e3a7ec9..e341cb726ae 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/scoring/GroupCompositionPenalizerTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/scoring/GroupCompositionPenalizerTest.java @@ -21,8 +21,8 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -142,11 +142,11 @@ public ScoringFunction createNewScoringFunction( final Person person ) { eventsToScore.finish(); final double score = penalizer.getScore(); - Assert.assertEquals( - "unexpected score", + Assertions.assertEquals( calcExpectedScore( times1[ 0 ] , times1[ times1.length - 1 ] , times2[ 0 ] , times2[ times2.length - 1 ]), score, - 1E-9 ); + 1E-9, + "unexpected score" ); } private double calcExpectedScore( final double start1, final double end1, final double start2, final double end2 ) { diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointactivities/replanning/modules/RecomposeJointPlanAlgorithmTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointactivities/replanning/modules/RecomposeJointPlanAlgorithmTest.java index 9551650254f..bcda672c647 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointactivities/replanning/modules/RecomposeJointPlanAlgorithmTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointactivities/replanning/modules/RecomposeJointPlanAlgorithmTest.java @@ -19,8 +19,8 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.jointactivities.replanning.modules; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.Collection; @@ -286,32 +286,32 @@ private static void test( final Fixture fixture ) { algo.run( fixture.groupPlans ); assertEquals( - "unexpected number of plans", initialNPlans, - fixture.groupPlans.getAllIndividualPlans().size()); + fixture.groupPlans.getAllIndividualPlans().size(), + "unexpected number of plans"); assertEquals( - "unexpected number of joint plans", fixture.expectedNJointPlans, - fixture.groupPlans.getJointPlans().size()); + fixture.groupPlans.getJointPlans().size(), + "unexpected number of joint plans"); for (JointPlan jp : fixture.groupPlans.getJointPlans()) { final Set> ids = jp.getIndividualPlans().keySet(); assertTrue( - "unexpected joint plan "+ids+": not in "+fixture.expectedJointPlanStructure, - fixture.expectedJointPlanStructure.contains( ids )); + fixture.expectedJointPlanStructure.contains( ids ), + "unexpected joint plan "+ids+": not in "+fixture.expectedJointPlanStructure); } assertEquals( - "unexpected number of individual plans", fixture.expectedNIndivPlans, - fixture.groupPlans.getIndividualPlans().size()); + fixture.groupPlans.getIndividualPlans().size(), + "unexpected number of individual plans"); for (Plan p : fixture.groupPlans.getIndividualPlans()) { final Set> ids = Collections.singleton( p.getPerson().getId() ); assertTrue( - "unexpected individual plan "+ids+": not in "+fixture.expectedJointPlanStructure, - fixture.expectedJointPlanStructure.contains( ids )); + fixture.expectedJointPlanStructure.contains( ids ), + "unexpected individual plan "+ids+": not in "+fixture.expectedJointPlanStructure); } } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointactivities/replanning/modules/randomlocationchoice/RandomJointLocationChoiceTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointactivities/replanning/modules/randomlocationchoice/RandomJointLocationChoiceTest.java index e6cab996be9..0139237b886 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointactivities/replanning/modules/randomlocationchoice/RandomJointLocationChoiceTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointactivities/replanning/modules/randomlocationchoice/RandomJointLocationChoiceTest.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Random; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -216,10 +216,10 @@ void testFacilityRetrieval() { f.angle, f.distance ); - Assert.assertEquals( - "wrong facility for fixture "+f, + Assertions.assertEquals( f.expectedFacility, - fac.getId() ); + fac.getId(), + "wrong facility for fixture "+f ); } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/JointTravelUtilsTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/JointTravelUtilsTest.java index 5943c16f8f6..5d5f3ecea96 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/JointTravelUtilsTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/JointTravelUtilsTest.java @@ -20,8 +20,8 @@ package org.matsim.contrib.socnetsim.jointtrips; import org.junit.After; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -806,12 +806,12 @@ void testExtractJointTrips() throws Exception { for ( Fixture f : fixtures ) { JointTravelStructure struct = JointTravelUtils.analyseJointTravel(f.plan); - Assert.assertEquals( + Assertions.assertEquals( + f.structure, + struct, "wrong structure for fixture "+f.name+ " of size "+f.structure.getJointTrips().size()+ - " compared to result of size "+struct.getJointTrips().size(), - f.structure, - struct); + " compared to result of size "+struct.getJointTrips().size()); } } @@ -820,14 +820,14 @@ void testParseDriverTrips() throws Exception { for ( Fixture f : fixtures ) { List trips = JointTravelUtils.parseDriverTrips(f.plan); - Assert.assertEquals( - "wrong number of driver trips: "+f.driverTrips+" is the target, got "+trips, + Assertions.assertEquals( f.driverTrips.size(), - trips.size()); + trips.size(), + "wrong number of driver trips: "+f.driverTrips+" is the target, got "+trips); - Assert.assertTrue( - "wrong driver trips: "+f.driverTrips+" is the target, got "+trips, - trips.containsAll( f.driverTrips )); + Assertions.assertTrue( + trips.containsAll( f.driverTrips ), + "wrong driver trips: "+f.driverTrips+" is the target, got "+trips); } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/qsim/JointTravelingSimulationIntegrationTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/qsim/JointTravelingSimulationIntegrationTest.java index 395e7cce92b..07393fe6d22 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/qsim/JointTravelingSimulationIntegrationTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/qsim/JointTravelingSimulationIntegrationTest.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -214,16 +214,16 @@ public void handleEvent(final PersonArrivalEvent event) { } arrCount.incrementAndGet(); - Assert.assertEquals( - "run "+scNr+": unexpected joint arrival time", + Assertions.assertEquals( arrival, event.getTime(), - MatsimTestUtils.EPSILON); + MatsimTestUtils.EPSILON, + "run "+scNr+": unexpected joint arrival time"); - Assert.assertEquals( - "run "+scNr+": unexpected arrival location for mode "+mode, + Assertions.assertEquals( fixture.doLink, - event.getLinkId() ); + event.getLinkId(), + "run "+scNr+": unexpected arrival location for mode "+mode ); } } }); @@ -257,15 +257,15 @@ public void handleEvent(final ActivityStartEvent event) { // for easier tracking of test failures logFinalQSimState( qsim ); - Assert.assertEquals( - "run "+i+": unexpected number of joint arrivals", + Assertions.assertEquals( N_LAPS * 3, - arrCount.get()); + arrCount.get(), + "run "+i+": unexpected number of joint arrivals"); - Assert.assertEquals( - "run "+i+": unexpected number of agents arriving at destination", + Assertions.assertEquals( N_LAPS * sc.getPopulation().getPersons().size(), - atDestCount.get()); + atDestCount.get(), + "run "+i+": unexpected number of agents arriving at destination"); } } @@ -328,10 +328,10 @@ public void handleEvent(final PersonLeavesVehicleEvent event) { final JointQSimFactory factory = new JointQSimFactory( ); factory.createMobsim( sc , events ).run(); - Assert.assertEquals( - "not as many leave events as enter events", + Assertions.assertEquals( enterCount.get(), - leaveCount.get()); + leaveCount.get(), + "not as many leave events as enter events"); } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIgnoranceBehaviorTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIgnoranceBehaviorTest.java index 9e55848cf9a..83420c9ea39 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIgnoranceBehaviorTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIgnoranceBehaviorTest.java @@ -19,6 +19,8 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.jointtrips.replanning.modules; +import static org.junit.jupiter.api.Assertions.assertNull; + import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -47,8 +49,6 @@ import java.util.Map; import java.util.Random; -import static org.junit.Assert.assertNull; - /** * @author thibautd */ @@ -72,8 +72,8 @@ void testRemoverIgnorance() throws Exception { JointPlan jointPlan = createPlanWithJointTrips(); assertNull( - "unexpected removed trips", - algo.run( jointPlan , jointPlan.getIndividualPlans().keySet() ) ); + algo.run( jointPlan , jointPlan.getIndividualPlans().keySet() ), + "unexpected removed trips" ); } @@ -89,8 +89,8 @@ void testInsertorIgnorance() throws Exception { JointPlan jointPlan = createPlanWithoutJointTrips(); assertNull( - "unexpected removed trips", - algo.run( jointPlan , jointPlan.getIndividualPlans().keySet() ) ); + algo.run( jointPlan , jointPlan.getIndividualPlans().keySet() ), + "unexpected removed trips" ); } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIterativeActionTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIterativeActionTest.java index 01b85aa8a57..fe45fa49200 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIterativeActionTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIterativeActionTest.java @@ -19,16 +19,15 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.jointtrips.replanning.modules; -import static org.junit.Assert.assertEquals; - import java.util.HashMap; import java.util.Map; import java.util.Random; import org.apache.logging.log4j.Level; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.Before; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -99,18 +98,18 @@ void testNonIterativeRemoval() throws Exception { final String finalPlanDescr = jointPlan.toString(); assertEquals( + N_COUPLES - 1, + d, "unexpected number of driver trips when passing from plan " +initialPlanDescr+" to plan " - +finalPlanDescr, - N_COUPLES - 1, - d); + +finalPlanDescr); assertEquals( + N_COUPLES - 1, + p, "unexpected number of passenger trips when passing from plan " +initialPlanDescr+" to plan " - +finalPlanDescr, - N_COUPLES - 1, - p); + +finalPlanDescr); } @Test @@ -142,18 +141,18 @@ void testIterativeRemoval() throws Exception { final String finalPlanDescr = jointPlan.toString(); assertEquals( + 0, + d, "unexpected number of driver trips when passing from plan " +initialPlanDescr+" to plan " - +finalPlanDescr, - 0, - d); + +finalPlanDescr); assertEquals( + 0, + p, "unexpected number of passenger trips when passing from plan " +initialPlanDescr+" to plan " - +finalPlanDescr, - 0, - p); + +finalPlanDescr); } @Test @@ -178,21 +177,21 @@ void testNonIterativeInsertion() throws Exception { final Leg l = (Leg) pe; final String mode = l.getMode(); if ( JointActingTypes.DRIVER.equals( mode ) ) { - Assert.assertNotNull( - "route must not be null", - l.getRoute() ); - Assert.assertTrue( - "unexpected route type "+l.getRoute().getClass().getName(), - l.getRoute() instanceof DriverRoute ); + Assertions.assertNotNull( + l.getRoute(), + "route must not be null" ); + Assertions.assertTrue( + l.getRoute() instanceof DriverRoute, + "unexpected route type "+l.getRoute().getClass().getName() ); d++; } if ( JointActingTypes.PASSENGER.equals( mode ) ) { - Assert.assertNotNull( - "route must not be null", - l.getRoute() ); - Assert.assertTrue( - "unexpected route type "+l.getRoute().getClass().getName(), - l.getRoute() instanceof PassengerRoute ); + Assertions.assertNotNull( + l.getRoute(), + "route must not be null" ); + Assertions.assertTrue( + l.getRoute() instanceof PassengerRoute, + "unexpected route type "+l.getRoute().getClass().getName() ); p++; } } @@ -201,18 +200,18 @@ void testNonIterativeInsertion() throws Exception { final String finalPlanDescr = jointPlan.toString(); assertEquals( + 1, + d, "unexpected number of driver trips when passing from plan " +initialPlanDescr+" to plan " - +finalPlanDescr, - 1, - d); + +finalPlanDescr); assertEquals( + 1, + p, "unexpected number of passenger trips when passing from plan " +initialPlanDescr+" to plan " - +finalPlanDescr, - 1, - p); + +finalPlanDescr); } @Test @@ -237,21 +236,21 @@ void testIterativeInsertion() throws Exception { final Leg l = (Leg) pe; final String mode = l.getMode(); if ( JointActingTypes.DRIVER.equals( mode ) ) { - Assert.assertNotNull( - "route must not be null", - l.getRoute() ); - Assert.assertTrue( - "unexpected route type "+l.getRoute().getClass().getName(), - l.getRoute() instanceof DriverRoute ); + Assertions.assertNotNull( + l.getRoute(), + "route must not be null" ); + Assertions.assertTrue( + l.getRoute() instanceof DriverRoute, + "unexpected route type "+l.getRoute().getClass().getName() ); d++; } if ( JointActingTypes.PASSENGER.equals( mode ) ) { - Assert.assertNotNull( - "route must not be null", - l.getRoute() ); - Assert.assertTrue( - "unexpected route type "+l.getRoute().getClass().getName(), - l.getRoute() instanceof PassengerRoute ); + Assertions.assertNotNull( + l.getRoute(), + "route must not be null" ); + Assertions.assertTrue( + l.getRoute() instanceof PassengerRoute, + "unexpected route type "+l.getRoute().getClass().getName() ); p++; } } @@ -260,18 +259,18 @@ void testIterativeInsertion() throws Exception { final String finalPlanDescr = jointPlan.toString(); assertEquals( + N_COUPLES, + d, "unexpected number of driver trips when passing from plan " +initialPlanDescr+" to plan " - +finalPlanDescr, - N_COUPLES, - d); + +finalPlanDescr); assertEquals( + N_COUPLES, + p, "unexpected number of passenger trips when passing from plan " +initialPlanDescr+" to plan " - +finalPlanDescr, - N_COUPLES, - p); + +finalPlanDescr); } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripInsertionWithSocialNetworkTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripInsertionWithSocialNetworkTest.java index 45ece5211d0..d67580b7692 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripInsertionWithSocialNetworkTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripInsertionWithSocialNetworkTest.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -90,9 +90,9 @@ void testJointTripsGeneratedOnlyAlongSocialTies() { agentsToIgnore.add( actedUpon.getDriverId() ); agentsToIgnore.add( actedUpon.getPassengerId() ); - Assert.assertTrue( - "passenger not alter of driver!", - sn.getAlters( actedUpon.getDriverId() ).contains( actedUpon.getPassengerId() ) ); + Assertions.assertTrue( + sn.getAlters( actedUpon.getDriverId() ).contains( actedUpon.getPassengerId() ), + "passenger not alter of driver!" ); } log.info( "there were "+agentsToIgnore.size()+" agents handled" ); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripRemoverAlgorithmTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripRemoverAlgorithmTest.java index bc43d9c3a50..34cd73df76f 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripRemoverAlgorithmTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripRemoverAlgorithmTest.java @@ -19,9 +19,7 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.jointtrips.replanning.modules; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; import java.util.ArrayList; import java.util.Arrays; @@ -983,9 +981,9 @@ private void assertChainsMatch( final List expected, final List actual) { assertEquals( - fixtureName+": sizes do not match "+expected+" and "+actual, expected.size(), - actual.size()); + actual.size(), + fixtureName+": sizes do not match "+expected+" and "+actual); Iterator expectedIter = expected.iterator(); Iterator actualIter = actual.iterator(); @@ -1021,43 +1019,43 @@ private void assertChainsMatch( private void assertLegsMatch(final Leg exp,final Leg act) { assertEquals( - "wrong mode", exp.getMode(), - act.getMode()); + act.getMode(), + "wrong mode"); if ( exp.getMode().equals( JointActingTypes.DRIVER ) ) { Collection> expIds = ((DriverRoute) exp.getRoute()).getPassengersIds(); Collection> actIds = ((DriverRoute) act.getRoute()).getPassengersIds(); assertEquals( - "wrong number of passengers", expIds.size(), - actIds.size()); + actIds.size(), + "wrong number of passengers"); assertTrue( - "wrong passenger ids", - actIds.containsAll( expIds )); + actIds.containsAll( expIds ), + "wrong passenger ids"); } else if ( exp.getMode().equals( JointActingTypes.PASSENGER ) ) { Id expId = ((PassengerRoute) exp.getRoute()).getDriverId(); Id actId = ((PassengerRoute) act.getRoute()).getDriverId(); assertEquals( - "wrong driver Id", expId, - actId); + actId, + "wrong driver Id"); } } private void assertActivitiesMatch(final Activity exp, final Activity act) { assertEquals( - "wrong type", exp.getType(), - act.getType()); + act.getType(), + "wrong type"); assertEquals( - "wrong link", exp.getLinkId(), - act.getLinkId()); + act.getLinkId(), + "wrong link"); } // ///////////////////////////////////////////////////////////////////////// diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/SynchronizeCoTravelerPlansAlgorithmTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/SynchronizeCoTravelerPlansAlgorithmTest.java index acce4c6faef..d5f974964b5 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/SynchronizeCoTravelerPlansAlgorithmTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/SynchronizeCoTravelerPlansAlgorithmTest.java @@ -25,8 +25,8 @@ import java.util.Map; import org.junit.After; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -331,16 +331,16 @@ void testDepartureTimes() throws Exception { final Double endTime = fixture.expectedEndTimes.remove( activity ); if ( endTime == null ) continue; - Assert.assertEquals( - "unexpected end time for "+activity, + Assertions.assertEquals( endTime.doubleValue(), activity.getEndTime().seconds(), - MatsimTestUtils.EPSILON); + MatsimTestUtils.EPSILON, + "unexpected end time for "+activity); } } - Assert.assertTrue( - "some activities were not found: "+fixture.expectedEndTimes.keySet(), - fixture.expectedEndTimes.isEmpty() ); + Assertions.assertTrue( + fixture.expectedEndTimes.isEmpty(), + "some activities were not found: "+fixture.expectedEndTimes.keySet() ); } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointPlanRouterTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointPlanRouterTest.java index 28203a5ed4a..ec2b5100847 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointPlanRouterTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointPlanRouterTest.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.jointtrips.router; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.Arrays; import java.util.Collection; @@ -93,21 +93,21 @@ void testDriverIdIsKept() throws Exception { final Leg newLeg = (Leg) plan.getPlanElements().get( 1 ); assertNotSame( - "leg not replaced", leg, - newLeg); + newLeg, + "leg not replaced"); final PassengerRoute newRoute = (PassengerRoute) leg.getRoute(); assertNotNull( - "new passenger route is null", + newRoute, - newRoute); + "new passenger route is null"); assertEquals( - "driver id not kept correctly", driverId, - newRoute.getDriverId()); + newRoute.getDriverId(), + "driver id not kept correctly"); } @Test @@ -150,25 +150,25 @@ void testPassengerIdIsKept() throws Exception { final Leg newLeg = (Leg) plan.getPlanElements().get( 1 ); assertNotSame( - "leg not replaced", leg, - newLeg); + newLeg, + "leg not replaced"); final DriverRoute newRoute = (DriverRoute) leg.getRoute(); assertNotNull( - "new driver route is null", - newRoute); + newRoute, + "new driver route is null"); final Collection> passengers = Arrays.asList( passengerId1 , passengerId2 ); assertEquals( - "not the right number of passenger ids in "+newRoute.getPassengersIds(), passengers.size(), - newRoute.getPassengersIds().size()); + newRoute.getPassengersIds().size(), + "not the right number of passenger ids in "+newRoute.getPassengersIds()); assertTrue( - "not the right ids in "+newRoute.getPassengersIds(), passengers.containsAll( - newRoute.getPassengersIds() )); + newRoute.getPassengersIds() ), + "not the right ids in "+newRoute.getPassengersIds()); } private static TripRouter createTripRouter(final PopulationFactory populationFactory, Config config) { diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointTripRouterFactoryTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointTripRouterFactoryTest.java index dbad52eb7e5..d3e427f262c 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointTripRouterFactoryTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointTripRouterFactoryTest.java @@ -26,8 +26,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -227,10 +227,10 @@ void testPassengerRoute() throws Exception { if ( pe instanceof Leg && ((Leg) pe).getMode().equals( JointActingTypes.PASSENGER ) ) { final Id actualDriver = ((PassengerRoute) ((Leg) pe).getRoute()).getDriverId(); - Assert.assertEquals( - "wrong driver Id", + Assertions.assertEquals( driver, - actualDriver); + actualDriver, + "wrong driver Id"); } } @@ -264,14 +264,14 @@ void testDriverRoute() throws Exception { if ( pe instanceof Leg && ((Leg) pe).getMode().equals( JointActingTypes.DRIVER ) ) { final Collection> actualPassengers = ((DriverRoute) ((Leg) pe).getRoute()).getPassengersIds(); - Assert.assertEquals( - "wrong number of passengers", + Assertions.assertEquals( passengerIds.size(), - actualPassengers.size()); + actualPassengers.size(), + "wrong number of passengers"); - Assert.assertTrue( - "wrong passengers ids: "+actualPassengers+" is not "+passengerIds, - passengerIds.containsAll( actualPassengers )); + Assertions.assertTrue( + passengerIds.containsAll( actualPassengers ), + "wrong passengers ids: "+actualPassengers+" is not "+passengerIds); } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/HouseholdBasedVehicleRessourcesTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/HouseholdBasedVehicleRessourcesTest.java index eaf2b1b5e08..58f912152ee 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/HouseholdBasedVehicleRessourcesTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/HouseholdBasedVehicleRessourcesTest.java @@ -19,14 +19,14 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.sharedvehicles; -import static org.junit.Assert.assertEquals; - import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Set; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.households.Household; @@ -50,9 +50,9 @@ void testVehiclesIdsAreCorrect() throws Exception { for (Id person : household.getMemberIds()) { final Set> actual = testee.identifyVehiclesUsableForAgent( person ); assertEquals( - "unexpected vehicles for agent "+person, expected, - actual); + actual, + "unexpected vehicles for agent "+person); } } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/PlanRouterWithVehicleRessourcesTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/PlanRouterWithVehicleRessourcesTest.java index a05a6cf60eb..fa2e7c679dd 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/PlanRouterWithVehicleRessourcesTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/PlanRouterWithVehicleRessourcesTest.java @@ -19,13 +19,13 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.sharedvehicles; -import static org.junit.Assert.assertEquals; - import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -93,9 +93,9 @@ void testVehicleIdsAreKeptIfSomething() throws Exception { for ( Trip trip : TripStructureUtils.getTrips( plan ) ) { for (Leg l : trip.getLegsOnly()) { assertEquals( - "unexpected vehicle id", vehicleId, - ((NetworkRoute) l.getRoute()).getVehicleId()); + ((NetworkRoute) l.getRoute()).getVehicleId(), + "unexpected vehicle id"); } } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/qsim/PopulationAgentSourceWithVehiclesTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/qsim/PopulationAgentSourceWithVehiclesTest.java index dad937c6e08..a35023b69a8 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/qsim/PopulationAgentSourceWithVehiclesTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/qsim/PopulationAgentSourceWithVehiclesTest.java @@ -19,8 +19,8 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.sharedvehicles.qsim; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Collections; @@ -118,8 +118,8 @@ void testFailsIfOnlySomeRoutesHaveAVehicle() throws Exception { } assertTrue( - "did not get an exception with inconsistent setting", - gotException); + gotException, + "did not get an exception with inconsistent setting"); } @Test @@ -199,8 +199,8 @@ public void testNoFail(final boolean vehicles) throws Exception { } assertFalse( - "got an exception with consistent setting", - gotException); + gotException, + "got an exception with consistent setting"); } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/AllocateVehicleToPlansInGroupPlanAlgorithmTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/AllocateVehicleToPlansInGroupPlanAlgorithmTest.java index 37f66567b28..5ba2aa6069a 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/AllocateVehicleToPlansInGroupPlanAlgorithmTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/AllocateVehicleToPlansInGroupPlanAlgorithmTest.java @@ -31,7 +31,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -139,9 +139,9 @@ void testEnoughVehiclesForEverybody() { final Set allocated = new HashSet(); for ( Plan p : testPlan.getAllIndividualPlans() ) { final Id v = assertSingleVehicleAndGetVehicleId( p ); - Assert.assertTrue( - "vehicle "+v+" already allocated", - v == null || allocated.add( v ) ); + Assertions.assertTrue( + v == null || allocated.add( v ), + "vehicle "+v+" already allocated" ); } } } @@ -174,9 +174,9 @@ void testOneVehiclePerTwoPersons() { } final int max = Collections.max( counts.values() ); - Assert.assertTrue( - "one vehicle was allocated "+max+" times while maximum expected was 2 in "+counts, - max <= 2 ); + Assertions.assertTrue( + max <= 2, + "one vehicle was allocated "+max+" times while maximum expected was 2 in "+counts ); } } @@ -215,10 +215,10 @@ else if ( !oldV.equals( v ) ) { } } - Assert.assertEquals( - "unexpected number of agents having got several vehicles", + Assertions.assertEquals( allocations.size(), - agentsWithSeveralVehicles.size() ); + agentsWithSeveralVehicles.size(), + "unexpected number of agents having got several vehicles" ); } @Test @@ -254,10 +254,10 @@ else if ( !oldV.equals( v ) ) { } } - Assert.assertEquals( - "unexpected number of agents having got several vehicles", + Assertions.assertEquals( 0, - agentsWithSeveralVehicles.size() ); + agentsWithSeveralVehicles.size(), + "unexpected number of agents having got several vehicles" ); } private static Id assertSingleVehicleAndGetVehicleId(final Plan p) { @@ -270,13 +270,13 @@ private static Id assertSingleVehicleAndGetVehicleId(final Plan p) { if ( !MODE.equals( leg.getMode() ) ) continue; final NetworkRoute r = (NetworkRoute) leg.getRoute(); - Assert.assertNotNull( - "null vehicle id in route", - r.getVehicleId() ); + Assertions.assertNotNull( + r.getVehicleId(), + "null vehicle id in route" ); - Assert.assertTrue( - "vehicle "+r.getVehicleId()+" not the same as "+v, - v == null || r.getVehicleId().equals( v ) ); + Assertions.assertTrue( + v == null || r.getVehicleId().equals( v ), + "vehicle "+r.getVehicleId()+" not the same as "+v ); v = r.getVehicleId(); } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/OptimizeVehicleAllocationAtTourLevelTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/OptimizeVehicleAllocationAtTourLevelTest.java index a5b3a7367bc..20514741157 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/OptimizeVehicleAllocationAtTourLevelTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/OptimizeVehicleAllocationAtTourLevelTest.java @@ -26,8 +26,8 @@ import java.util.Random; import java.util.Set; -import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -137,9 +137,9 @@ void testCannotFindBetterAllocationRandomly() throws Exception { false, false).run( randomized ); final double randomizedOverlap = algo.calcOverlap( randomized ); - Assert.assertTrue( - "["+i+","+j+"] found better solution than optimized one: "+randomizedOverlap+" < "+optimizedOverlap, - optimizedOverlap <= randomizedOverlap ); + Assertions.assertTrue( + optimizedOverlap <= randomizedOverlap, + "["+i+","+j+"] found better solution than optimized one: "+randomizedOverlap+" < "+optimizedOverlap ); } counter.printCounter(); } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/GroupPlanStrategyTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/GroupPlanStrategyTest.java index 203bec54de6..08ff8da07ce 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/GroupPlanStrategyTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/GroupPlanStrategyTest.java @@ -19,9 +19,7 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.usage.replanning; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; import java.util.ArrayList; import java.util.Arrays; @@ -75,13 +73,13 @@ void testNewPlanIsSelected() throws Exception { if ( PersonUtils.isSelected(plan) ) { // new plan: selection status inverted assertFalse( - "old plan still selected", - selectedPlans.contains( plan )); + selectedPlans.contains( plan ), + "old plan still selected"); } else { assertTrue( - "old plan still selected", - selectedPlans.contains( plan )); + selectedPlans.contains( plan ), + "old plan still selected"); } } } @@ -100,9 +98,9 @@ void testNumberOfPlans() throws Exception { strategy.run( createContext() , jointPlans , Arrays.asList( group ) ); assertEquals( - "group size changed by strategy!", groupSize, - group.getPersons().size()); + group.getPersons().size(), + "group size changed by strategy!"); } @Test @@ -130,13 +128,13 @@ void testNumberOfSelectedJointPlans() throws Exception { } assertEquals( - "wrong number of selected plans in joint plans", N_INITIALLY_INDIV_PLANS, - countSelectedJoint ); + countSelectedJoint, + "wrong number of selected plans in joint plans" ); assertEquals( - "wrong number of selected plans in individual plans", N_INITIALLY_JOINT_PLANS, - countSelectedIndiv ); + countSelectedIndiv, + "wrong number of selected plans in individual plans" ); } @Test @@ -164,13 +162,13 @@ void testNumberOfNonSelectedJointPlans() throws Exception { } assertEquals( - "wrong number of non selected plans in joint plans", N_INITIALLY_JOINT_PLANS, - countNonSelectedJoint ); + countNonSelectedJoint, + "wrong number of non selected plans in joint plans" ); assertEquals( - "wrong number of non selected plans in individual plans", N_INITIALLY_INDIV_PLANS, - countNonSelectedIndiv ); + countNonSelectedIndiv, + "wrong number of non selected plans in individual plans" ); } private ReplanningGroup createTestGroup(final JointPlans jointPlans) { diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/JoinableActivitiesPlanLinkIdentifierTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/JoinableActivitiesPlanLinkIdentifierTest.java index 67e5fe79763..6aaf3ac370e 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/JoinableActivitiesPlanLinkIdentifierTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/JoinableActivitiesPlanLinkIdentifierTest.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.usage.replanning; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -52,9 +52,9 @@ void testOpenPlansSamePlaceSameType() { final Plan plan2 = createOpenPlan( Id.create( 2 , Person.class ) , type , facility ); final PlanLinkIdentifier testee = new JoinableActivitiesPlanLinkIdentifier( type ); - Assert.assertTrue( - "plans with activities of good type at the same place the whole day should be joint", - testee.areLinked( plan1 , plan2 ) ); + Assertions.assertTrue( + testee.areLinked( plan1 , plan2 ), + "plans with activities of good type at the same place the whole day should be joint" ); } @Test @@ -66,13 +66,13 @@ void testOpenPlansSamePlaceDifferentType() { final Plan plan2 = createOpenPlan( Id.create( 2 , Person.class ) , "other type" , facility ); final PlanLinkIdentifier testee = new JoinableActivitiesPlanLinkIdentifier( type ); - Assert.assertEquals( - "inconsistency!", + Assertions.assertEquals( + testee.areLinked( plan1 , plan2 ), + testee.areLinked( plan2 , plan1 ), + "inconsistency!" ); + Assertions.assertFalse( testee.areLinked( plan1 , plan2 ), - testee.areLinked( plan2 , plan1 ) ); - Assert.assertFalse( - "plans with activities of different types should not be joined", - testee.areLinked( plan1 , plan2 ) ); + "plans with activities of different types should not be joined" ); } @Test @@ -85,13 +85,13 @@ void testOpenPlansDifferentPlaceSameType() { final Plan plan2 = createOpenPlan( Id.create( 2 , Person.class ) , type , facility2 ); final PlanLinkIdentifier testee = new JoinableActivitiesPlanLinkIdentifier( type ); - Assert.assertEquals( - "inconsistency!", + Assertions.assertEquals( testee.areLinked( plan1 , plan2 ), - testee.areLinked( plan2 , plan1 ) ); - Assert.assertFalse( - "plans with activities at different locations should not be joined", - testee.areLinked( plan1 , plan2 ) ); + testee.areLinked( plan2 , plan1 ), + "inconsistency!" ); + Assertions.assertFalse( + testee.areLinked( plan1 , plan2 ), + "plans with activities at different locations should not be joined" ); } @Test @@ -103,13 +103,13 @@ void testOpenPlansSamePlaceSameWrongType() { final Plan plan2 = createOpenPlan( Id.create( 2 , Person.class ) , type , facility ); final PlanLinkIdentifier testee = new JoinableActivitiesPlanLinkIdentifier( "other type" ); - Assert.assertEquals( - "inconsistency!", + Assertions.assertEquals( + testee.areLinked( plan1 , plan2 ), + testee.areLinked( plan2 , plan1 ), + "inconsistency!" ); + Assertions.assertFalse( testee.areLinked( plan1 , plan2 ), - testee.areLinked( plan2 , plan1 ) ); - Assert.assertFalse( - "plans with activities of non joinable types should not be joined", - testee.areLinked( plan1 , plan2 ) ); + "plans with activities of non joinable types should not be joined" ); } private static Plan createOpenPlan( @@ -148,13 +148,13 @@ void testSingleTourOverlaping() { final PlanLinkIdentifier testee = new JoinableActivitiesPlanLinkIdentifier( type ); - Assert.assertEquals( - "inconsistency!", + Assertions.assertEquals( testee.areLinked( plan1 , plan2 ), - testee.areLinked( plan2 , plan1 ) ); - Assert.assertTrue( - "plans with overlaping activities should be joint", - testee.areLinked( plan1 , plan2 ) ); + testee.areLinked( plan2 , plan1 ), + "inconsistency!" ); + Assertions.assertTrue( + testee.areLinked( plan1 , plan2 ), + "plans with overlaping activities should be joint" ); } @Test @@ -180,13 +180,13 @@ void testSingleTourPlansNonOverlaping() { final PlanLinkIdentifier testee = new JoinableActivitiesPlanLinkIdentifier( type ); - Assert.assertEquals( - "inconsistency!", + Assertions.assertEquals( + testee.areLinked( plan1 , plan2 ), + testee.areLinked( plan2 , plan1 ), + "inconsistency!" ); + Assertions.assertFalse( testee.areLinked( plan1 , plan2 ), - testee.areLinked( plan2 , plan1 ) ); - Assert.assertFalse( - "plans with non overlaping activities should not be joint", - testee.areLinked( plan1 , plan2 ) ); + "plans with non overlaping activities should not be joint" ); } @Test @@ -212,13 +212,13 @@ void testSingleTourPlansZeroDurationAct() { final PlanLinkIdentifier testee = new JoinableActivitiesPlanLinkIdentifier( type ); - Assert.assertEquals( - "inconsistency!", + Assertions.assertEquals( testee.areLinked( plan1 , plan2 ), - testee.areLinked( plan2 , plan1 ) ); - Assert.assertTrue( - "plans with zero-length overlaping activities should be joint", - testee.areLinked( plan1 , plan2 ) ); + testee.areLinked( plan2 , plan1 ), + "inconsistency!" ); + Assertions.assertTrue( + testee.areLinked( plan1 , plan2 ), + "plans with zero-length overlaping activities should be joint" ); } @Test @@ -243,10 +243,10 @@ void testSingleTourPlansZeroDurationBegin() { 40); final PlanLinkIdentifier testee = new JoinableActivitiesPlanLinkIdentifier( type ); - Assert.assertEquals( - "inconsistency!", + Assertions.assertEquals( testee.areLinked( plan1 , plan2 ), - testee.areLinked( plan2 , plan1 ) ); + testee.areLinked( plan2 , plan1 ), + "inconsistency!" ); // actual result irrelevant for this border case, as long as consistent //Assert.assertTrue( // "plans with zero-length overlaping activities should be joint", @@ -275,10 +275,10 @@ void testSingleTourPlansZeroDurationEnd() { 40); final PlanLinkIdentifier testee = new JoinableActivitiesPlanLinkIdentifier( type ); - Assert.assertEquals( - "inconsistency!", + Assertions.assertEquals( testee.areLinked( plan1 , plan2 ), - testee.areLinked( plan2 , plan1 ) ); + testee.areLinked( plan2 , plan1 ), + "inconsistency!" ); // actual result irrelevant for this border case, as long as consistent //Assert.assertTrue( // "plans with zero-length overlaping activities should be joint", @@ -311,10 +311,10 @@ void testDoubleTourPlansZeroDurationEnd() { final PlanLinkIdentifier testee = new JoinableActivitiesPlanLinkIdentifier( type ); - Assert.assertEquals( - "inconsistency!", + Assertions.assertEquals( testee.areLinked( plan1 , plan2 ), - testee.areLinked( plan2 , plan1 ) ); + testee.areLinked( plan2 , plan1 ), + "inconsistency!" ); // whether plans are linked or not on this border case is irrelevant, // but the result should be consistent. //Assert.assertTrue( @@ -347,13 +347,13 @@ void testSingleTourPlansInconsistentDurationAct() { final PlanLinkIdentifier testee = new JoinableActivitiesPlanLinkIdentifier( type ); - Assert.assertEquals( - "inconsistency!", + Assertions.assertEquals( + testee.areLinked( plan1 , plan2 ), + testee.areLinked( plan2 , plan1 ), + "inconsistency!" ); + Assertions.assertFalse( testee.areLinked( plan1 , plan2 ), - testee.areLinked( plan2 , plan1 ) ); - Assert.assertFalse( - "plans with inconsistent duration not handled correctly", - testee.areLinked( plan1 , plan2 ) ); + "plans with inconsistent duration not handled correctly" ); } private static Plan createDoubleTripPlan( diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/VehicularPlanLinkIdentifierTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/VehicularPlanLinkIdentifierTest.java index 9cdb9bd5e83..198a2642fab 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/VehicularPlanLinkIdentifierTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/VehicularPlanLinkIdentifierTest.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.usage.replanning; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -48,9 +48,9 @@ void testNotLinkedWhenNoVehicleDefined() { final PlanLinkIdentifier testee = new VehicularPlanBasedIdentifier(); - Assert.assertFalse( - "plans without vehicle allocated are considered linked", - testee.areLinked( plan1 , plan2 ) ); + Assertions.assertFalse( + testee.areLinked( plan1 , plan2 ), + "plans without vehicle allocated are considered linked" ); } @Test @@ -59,9 +59,9 @@ void testDifferentVehiclesAreNotLinked() { final Plan plan2 = createVehicularPlan( Id.create( 2 , Person.class ) , Id.create( 2 , Vehicle.class ) ); final PlanLinkIdentifier testee = new VehicularPlanBasedIdentifier(); - Assert.assertFalse( - "plans with different vehicle allocated are considered linked", - testee.areLinked( plan1 , plan2 ) ); + Assertions.assertFalse( + testee.areLinked( plan1 , plan2 ), + "plans with different vehicle allocated are considered linked" ); } @Test @@ -70,9 +70,9 @@ void testSameVehiclesAreLinked() { final Plan plan2 = createVehicularPlan( Id.create( 2 , Person.class ) , Id.create( "car" , Vehicle.class ) ); final PlanLinkIdentifier testee = new VehicularPlanBasedIdentifier(); - Assert.assertTrue( - "plans with same vehicle allocated are not considered linked", - testee.areLinked( plan1 , plan2 ) ); + Assertions.assertTrue( + testee.areLinked( plan1 , plan2 ), + "plans with same vehicle allocated are not considered linked" ); } // TODO test joint trips diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/JointScenarioUtilsTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/JointScenarioUtilsTest.java index 96cd50a3de0..71aa02e2b0e 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/JointScenarioUtilsTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/JointScenarioUtilsTest.java @@ -19,11 +19,11 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.utils; -import static org.junit.Assert.assertEquals; - import java.util.Collection; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -63,9 +63,9 @@ void testJointTripsImport() throws Exception { final Population loadedPopulation = loadedScenario.getPopulation(); assertEquals( - "read pop is not the same size as dumped", dumpedPopulation.getPersons().size(), - loadedPopulation.getPersons().size()); + loadedPopulation.getPersons().size(), + "read pop is not the same size as dumped"); for (Person person : loadedPopulation.getPersons().values()) { final Person dumpedPerson = dumpedPopulation.getPersons().get( person.getId() ); @@ -74,40 +74,40 @@ void testJointTripsImport() throws Exception { final Plan loadedPlan = person.getPlans().get( 0 ); assertEquals( - "incompatible plan sizes", dumpedPlan.getPlanElements().size(), - loadedPlan.getPlanElements().size()); + loadedPlan.getPlanElements().size(), + "incompatible plan sizes"); final Leg dumpedLeg = (Leg) dumpedPlan.getPlanElements().get( 1 ); final Leg loadedLeg = (Leg) loadedPlan.getPlanElements().get( 1 ); if (dumpedLeg.getMode().equals( JointActingTypes.DRIVER )) { assertEquals( - "wrong route class", DriverRoute.class, - loadedLeg.getRoute().getClass()); + loadedLeg.getRoute().getClass(), + "wrong route class"); final Collection> dumpedPassengers = ((DriverRoute) dumpedLeg.getRoute()).getPassengersIds(); final Collection> loadedPassengers = ((DriverRoute) loadedLeg.getRoute()).getPassengersIds(); assertEquals( - "unexpected passenger ids", dumpedPassengers, - loadedPassengers); + loadedPassengers, + "unexpected passenger ids"); } else { assertEquals( - "wrong route class", PassengerRoute.class, - loadedLeg.getRoute().getClass()); + loadedLeg.getRoute().getClass(), + "wrong route class"); final Id dumpedDriver = ((PassengerRoute) dumpedLeg.getRoute()).getDriverId(); final Id loadedDriver = ((PassengerRoute) loadedLeg.getRoute()).getDriverId(); assertEquals( - "unexpected passenger ids", dumpedDriver, - loadedDriver); + loadedDriver, + "unexpected passenger ids"); } } } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/ObjectPoolTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/ObjectPoolTest.java index 22dcdc2bd7e..71757798351 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/ObjectPoolTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/ObjectPoolTest.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.utils; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; @@ -35,27 +35,27 @@ void testInstanceIsPooled() throws Exception { final String instance2 = new String( "jojo" ); final String instance3 = new String( "jojo" ); - assertTrue("the two variables should be different objects", instance1 != instance2); + assertTrue(instance1 != instance2, "the two variables should be different objects"); assertSame( - "first instance not returned when pooled", instance1, - pool.getPooledInstance( instance1 )); + pool.getPooledInstance( instance1 ), + "first instance not returned when pooled"); assertNotSame( - "second instance returned instead of first", instance2, - pool.getPooledInstance( instance2 )); + pool.getPooledInstance( instance2 ), + "second instance returned instead of first"); assertSame( - "first instance not returned while pooled", instance1, - pool.getPooledInstance( instance2 )); + pool.getPooledInstance( instance2 ), + "first instance not returned while pooled"); assertSame( - "first instance not returned while pooled", instance1, - pool.getPooledInstance( instance3 )); + pool.getPooledInstance( instance3 ), + "first instance not returned while pooled"); } // TODO test forgetting diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/QuadTreeRebuilderTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/QuadTreeRebuilderTest.java index f8f8da6d46c..54c58779a6f 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/QuadTreeRebuilderTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/utils/QuadTreeRebuilderTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.socnetsim.utils; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.collections.QuadTree; @@ -10,33 +10,33 @@ public class QuadTreeRebuilderTest { void testGrowingQuadTree() { final QuadTreeRebuilder rebuilder = new QuadTreeRebuilder<>(); - Assert.assertEquals( - "unexpected quadtree size", + Assertions.assertEquals( 0, - rebuilder.getQuadTree().size()); + rebuilder.getQuadTree().size(), + "unexpected quadtree size"); rebuilder.put(new Coord(0, 0), new Object()); - Assert.assertEquals( - "unexpected quadtree size", + Assertions.assertEquals( 1, - rebuilder.getQuadTree().size()); + rebuilder.getQuadTree().size(), + "unexpected quadtree size"); rebuilder.put(new Coord(100, 100), new Object()); - Assert.assertEquals( - "unexpected quadtree size", + Assertions.assertEquals( 2, - rebuilder.getQuadTree().size()); + rebuilder.getQuadTree().size(), + "unexpected quadtree size"); - Assert.assertEquals( - "unexpected number of elements around origin", + Assertions.assertEquals( 1, - rebuilder.getQuadTree().getDisk(0, 0, 1).size()); + rebuilder.getQuadTree().getDisk(0, 0, 1).size(), + "unexpected number of elements around origin"); - Assert.assertEquals( - "unexpected number of elements far from origin", + Assertions.assertEquals( 2, - rebuilder.getQuadTree().getDisk(0, 0, 1000).size()); + rebuilder.getQuadTree().getDisk(0, 0, 1000).size(), + "unexpected number of elements far from origin"); } } diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiScenarioIT.java b/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiScenarioIT.java index 12572b18dcc..c086adedc50 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiScenarioIT.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/etaxi/run/RunETaxiScenarioIT.java @@ -18,7 +18,7 @@ package org.matsim.contrib.etaxi.run; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -68,13 +68,13 @@ private void runScenario(String configPath) { PopulationUtils.readPopulation(actual, utils.getOutputDirectory() + "/output_plans.xml.gz"); boolean result = PopulationUtils.comparePopulations(expected, actual); - Assert.assertTrue(result); + Assertions.assertTrue(result); } { String expected = utils.getInputDirectory() + "/output_events.xml.gz"; String actual = utils.getOutputDirectory() + "/output_events.xml.gz"; EventsFileComparator.Result result = EventsUtils.compareEventsFiles(expected, actual); - Assert.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, result); + Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, result); } } } diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/TaxiOptimizerTests.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/TaxiOptimizerTests.java index f92b30ee28a..ca985585f82 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/TaxiOptimizerTests.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/TaxiOptimizerTests.java @@ -22,7 +22,7 @@ import java.net.URL; import java.util.Optional; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Population; import org.matsim.contrib.dvrp.run.DvrpConfigGroup; @@ -65,13 +65,13 @@ public static void runBenchmark(boolean vehicleDiversion, AbstractTaxiOptimizerP PopulationUtils.readPopulation(actual, utils.getOutputDirectory() + "/output_plans.xml.gz"); boolean result = PopulationUtils.comparePopulations(expected, actual); - Assert.assertTrue(result); + Assertions.assertTrue(result); } { String expected = utils.getInputDirectory() + "/output_events.xml.gz"; String actual = utils.getOutputDirectory() + "/output_events.xml.gz"; EventsFileComparator.Result result = EventsUtils.compareEventsFiles(expected, actual); - Assert.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, result); + Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, result); } } } diff --git a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesIT.java b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesIT.java index 26908ea89bc..93e9146f31a 100644 --- a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesIT.java +++ b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesIT.java @@ -19,7 +19,7 @@ package org.matsim.core.scoring.functions; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -80,10 +80,9 @@ public void install() { double personSpecificModeConstant = Double.parseDouble(PersonUtils.getModeConstants(person).get(TransportMode.car)); // each person has 3 legs -> score should 3 x personSpecificModeConstant since all other scoring parameters are 0 - Assert.assertEquals("Score deviates from what is expected given the personSpecificModeConstant.", - personSpecificModeConstant, score / 3, MatsimTestUtils.EPSILON); - Assert.assertTrue("personSpecificModeConstant has value 0 or higher, this should never happen with log normal distribution for given mean -1 and sigma 1", - personSpecificModeConstant < 0.0d); + Assertions.assertEquals(personSpecificModeConstant, score / 3, MatsimTestUtils.EPSILON, "Score deviates from what is expected given the personSpecificModeConstant."); + Assertions.assertTrue(personSpecificModeConstant < 0.0d, + "personSpecificModeConstant has value 0 or higher, this should never happen with log normal distribution for given mean -1 and sigma 1"); } } } diff --git a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java index 70434051a10..57fcaa18660 100644 --- a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java +++ b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java @@ -19,8 +19,8 @@ package org.matsim.core.scoring.functions; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -144,8 +144,8 @@ void testPersonWithLowIncomeLowCarAsc(){ Id id = Id.createPersonId("lowIncomeLowCarAsc"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssertMarginalUtilityOfMoneyAndPtWait(params, 0.5d, 0.5d); - Assert.assertEquals(-0.1d, params.modeParams.get(TransportMode.car).constant, MatsimTestUtils.EPSILON); - Assert.assertEquals(-0.001d, params.modeParams.get(TransportMode.car).marginalUtilityOfTraveling_s, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.1d, params.modeParams.get(TransportMode.car).constant, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.001d, params.modeParams.get(TransportMode.car).marginalUtilityOfTraveling_s, MatsimTestUtils.EPSILON); } @Test @@ -153,8 +153,8 @@ void testPersonWithHighIncomeLowCarAsc(){ Id id = Id.createPersonId("highIncomeLowCarAsc"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssertMarginalUtilityOfMoneyAndPtWait(params, 1.5d, 0.5d); - Assert.assertEquals(-0.1d, params.modeParams.get(TransportMode.car).constant, MatsimTestUtils.EPSILON); - Assert.assertEquals(-0.001d, params.modeParams.get(TransportMode.car).marginalUtilityOfTraveling_s, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.1d, params.modeParams.get(TransportMode.car).constant, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.001d, params.modeParams.get(TransportMode.car).marginalUtilityOfTraveling_s, MatsimTestUtils.EPSILON); } @Test @@ -162,9 +162,9 @@ void testPersonWithMediumIncomeHighCarAsc(){ Id id = Id.createPersonId("mediumIncomeHighCarAsc"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssertMarginalUtilityOfMoneyAndPtWait(params, 1d, 0.5d); - Assert.assertEquals(-2.1d, params.modeParams.get(TransportMode.car).constant, MatsimTestUtils.EPSILON); - Assert.assertEquals(-50.0d, params.modeParams.get(TransportMode.bike).constant, MatsimTestUtils.EPSILON); - Assert.assertEquals(-0.001d, params.modeParams.get(TransportMode.car).marginalUtilityOfTraveling_s, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-2.1d, params.modeParams.get(TransportMode.car).constant, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-50.0d, params.modeParams.get(TransportMode.bike).constant, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.001d, params.modeParams.get(TransportMode.car).marginalUtilityOfTraveling_s, MatsimTestUtils.EPSILON); } @Test @@ -172,14 +172,14 @@ void testMoneyScore(){ ScoringParameters paramsRich = personScoringParams.getScoringParameters(population.getPersons().get(Id.createPersonId("highIncomeLowCarAsc"))); CharyparNagelMoneyScoring moneyScoringRich = new CharyparNagelMoneyScoring(paramsRich); moneyScoringRich.addMoney(100); - Assert.assertEquals("for the rich person, 100 money units should be equal to a score of 66.66", 1./1.5 * 100, moneyScoringRich.getScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1./1.5 * 100, moneyScoringRich.getScore(), MatsimTestUtils.EPSILON, "for the rich person, 100 money units should be equal to a score of 66.66"); ScoringParameters paramsPoor = personScoringParams.getScoringParameters(population.getPersons().get(Id.createPersonId("lowIncomeLowCarAsc"))); CharyparNagelMoneyScoring moneyScoringPoor = new CharyparNagelMoneyScoring(paramsPoor); moneyScoringPoor.addMoney(100); - Assert.assertEquals("for the poor person, 100 money units should be equal to a score of 200.00", 1./0.5 * 100, moneyScoringPoor.getScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1./0.5 * 100, moneyScoringPoor.getScore(), MatsimTestUtils.EPSILON, "for the poor person, 100 money units should be equal to a score of 200.00"); - Assert.assertTrue("100 money units should worth more for a poor person than for a rich person", moneyScoringPoor.getScore() > moneyScoringRich.getScore()); + Assertions.assertTrue(moneyScoringPoor.getScore() > moneyScoringRich.getScore(), "100 money units should worth more for a poor person than for a rich person"); } @Test @@ -189,27 +189,23 @@ void testPersonSpecificAscScoring(){ Leg carLegZeroDistanceTenSeconds = createLeg(TransportMode.car, 0.0d, 10.0d ); legScoringRichCarLeg.handleLeg(carLegZeroDistanceTenSeconds); - Assert.assertEquals("for the rich person with low car asc, a 0 meter and 10s car trip should be equal to a score of ", - -0.1d -0.001d * 10 -7.5*1./1.5 -0.3, legScoringRichCarLeg.getScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.1d -0.001d * 10 -7.5*1./1.5 -0.3, legScoringRichCarLeg.getScore(), MatsimTestUtils.EPSILON, "for the rich person with low car asc, a 0 meter and 10s car trip should be equal to a score of "); ScoringParameters paramsMediumIncomeHighCarAsc = personScoringParams.getScoringParameters(population.getPersons().get(Id.createPersonId("mediumIncomeHighCarAsc"))); CharyparNagelLegScoring legScoringMediumIncomeHighCarAsc = new CharyparNagelLegScoring(paramsMediumIncomeHighCarAsc, NetworkUtils.createNetwork(), Set.of(TransportMode.pt)); legScoringMediumIncomeHighCarAsc.handleLeg(carLegZeroDistanceTenSeconds); - Assert.assertEquals("for the medium person with high car asc, a 0 meter and 10s car trip should be equal to a score of ", - -2.1d -0.001d * 10 -7.5*1./1.0 -0.3, legScoringMediumIncomeHighCarAsc.getScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-2.1d -0.001d * 10 -7.5*1./1.0 -0.3, legScoringMediumIncomeHighCarAsc.getScore(), MatsimTestUtils.EPSILON, "for the medium person with high car asc, a 0 meter and 10s car trip should be equal to a score of "); // bike has no person specific asc for high income person and is not affected CharyparNagelLegScoring legScoringRichBikeLeg = new CharyparNagelLegScoring(paramsRich, NetworkUtils.createNetwork(), Set.of(TransportMode.pt)); Leg bikeLegZeroDistanceZeroSeconds = createLeg(TransportMode.bike, 0.0d, 0.0d ); legScoringRichBikeLeg.handleLeg(bikeLegZeroDistanceZeroSeconds); - Assert.assertEquals("for the rich person with low car asc, a 0 meter and 0s bike trip should be equal to a score of ", - -0.55d, legScoringRichBikeLeg.getScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.55d, legScoringRichBikeLeg.getScore(), MatsimTestUtils.EPSILON, "for the rich person with low car asc, a 0 meter and 0s bike trip should be equal to a score of "); // bike has a person specific asc for the medium income person CharyparNagelLegScoring legScoringMediumIncomeBikeLeg = new CharyparNagelLegScoring(paramsMediumIncomeHighCarAsc, NetworkUtils.createNetwork(), Set.of(TransportMode.pt)); legScoringMediumIncomeBikeLeg.handleLeg(bikeLegZeroDistanceZeroSeconds); - Assert.assertEquals("for the medium income person with high car asc, a 0 meter and 0s bike trip should be equal to a score of ", - -50.0d, legScoringMediumIncomeBikeLeg.getScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-50.0d, legScoringMediumIncomeBikeLeg.getScore(), MatsimTestUtils.EPSILON, "for the medium income person with high car asc, a 0 meter and 0s bike trip should be equal to a score of "); } private static Leg createLeg(String mode, double distance, double travelTime) { @@ -223,8 +219,8 @@ private static Leg createLeg(String mode, double distance, double travelTime) { } private void makeAssertMarginalUtilityOfMoneyAndPtWait(ScoringParameters params, double income, double marginalUtilityOfWaitingPt_s){ - Assert.assertEquals("marginalUtilityOfMoney is wrong", 1 / income , params.marginalUtilityOfMoney, 0.); - Assert.assertEquals("marginalUtilityOfWaitingPt_s is wrong", marginalUtilityOfWaitingPt_s , params.marginalUtilityOfWaitingPt_s, 0.); + Assertions.assertEquals(1 / income , params.marginalUtilityOfMoney, 0., "marginalUtilityOfMoney is wrong"); + Assertions.assertEquals(marginalUtilityOfWaitingPt_s , params.marginalUtilityOfWaitingPt_s, 0., "marginalUtilityOfWaitingPt_s is wrong"); } diff --git a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java index 9ead6090cb8..69d5bb6835f 100644 --- a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java +++ b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java @@ -19,8 +19,8 @@ package org.matsim.core.scoring.functions; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -166,8 +166,8 @@ void testPersonWithLowIncomeLowCarAsc(){ Id id = Id.createPersonId("lowIncomeLowCarAsc"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssertMarginalUtilityOfMoneyAndPtWait(params, 0.5d, 0.5d); - Assert.assertEquals(-0.1d, params.modeParams.get(TransportMode.car).constant, MatsimTestUtils.EPSILON); - Assert.assertEquals(-0.001d, params.modeParams.get(TransportMode.car).marginalUtilityOfTraveling_s, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.1d, params.modeParams.get(TransportMode.car).constant, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.001d, params.modeParams.get(TransportMode.car).marginalUtilityOfTraveling_s, MatsimTestUtils.EPSILON); } @Test @@ -175,8 +175,8 @@ void testPersonWithHighIncomeLowCarAsc(){ Id id = Id.createPersonId("highIncomeLowCarAsc"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssertMarginalUtilityOfMoneyAndPtWait(params, 1.5d, 0.5d); - Assert.assertEquals(-0.1d, params.modeParams.get(TransportMode.car).constant, MatsimTestUtils.EPSILON); - Assert.assertEquals(-0.001d, params.modeParams.get(TransportMode.car).marginalUtilityOfTraveling_s, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.1d, params.modeParams.get(TransportMode.car).constant, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.001d, params.modeParams.get(TransportMode.car).marginalUtilityOfTraveling_s, MatsimTestUtils.EPSILON); } @Test @@ -184,9 +184,9 @@ void testPersonWithMediumIncomeHighCarAsc(){ Id id = Id.createPersonId("mediumIncomeHighCarAsc"); ScoringParameters params = personScoringParams.getScoringParameters(population.getPersons().get(id)); makeAssertMarginalUtilityOfMoneyAndPtWait(params, 1d, 0.5d); - Assert.assertEquals(-2.1d, params.modeParams.get(TransportMode.car).constant, MatsimTestUtils.EPSILON); - Assert.assertEquals(-50.0d, params.modeParams.get(TransportMode.bike).constant, MatsimTestUtils.EPSILON); - Assert.assertEquals(-0.001d, params.modeParams.get(TransportMode.car).marginalUtilityOfTraveling_s, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-2.1d, params.modeParams.get(TransportMode.car).constant, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-50.0d, params.modeParams.get(TransportMode.bike).constant, MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.001d, params.modeParams.get(TransportMode.car).marginalUtilityOfTraveling_s, MatsimTestUtils.EPSILON); } @Test @@ -212,14 +212,14 @@ void testMoneyScore(){ ScoringParameters paramsRich = personScoringParams.getScoringParameters(population.getPersons().get(Id.createPersonId("highIncomeLowCarAsc"))); CharyparNagelMoneyScoring moneyScoringRich = new CharyparNagelMoneyScoring(paramsRich); moneyScoringRich.addMoney(100); - Assert.assertEquals("for the rich person, 100 money units should be equal to a score of 66.66", 1./1.5 * 100, moneyScoringRich.getScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1./1.5 * 100, moneyScoringRich.getScore(), MatsimTestUtils.EPSILON, "for the rich person, 100 money units should be equal to a score of 66.66"); ScoringParameters paramsPoor = personScoringParams.getScoringParameters(population.getPersons().get(Id.createPersonId("lowIncomeLowCarAsc"))); CharyparNagelMoneyScoring moneyScoringPoor = new CharyparNagelMoneyScoring(paramsPoor); moneyScoringPoor.addMoney(100); - Assert.assertEquals("for the poor person, 100 money units should be equal to a score of 200.00", 1./0.5 * 100, moneyScoringPoor.getScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1./0.5 * 100, moneyScoringPoor.getScore(), MatsimTestUtils.EPSILON, "for the poor person, 100 money units should be equal to a score of 200.00"); - Assert.assertTrue("100 money units should worth more for a poor person than for a rich person", moneyScoringPoor.getScore() > moneyScoringRich.getScore()); + Assertions.assertTrue(moneyScoringPoor.getScore() > moneyScoringRich.getScore(), "100 money units should worth more for a poor person than for a rich person"); } @Test @@ -229,27 +229,23 @@ void testPersonSpecificAscScoring(){ Leg carLegZeroDistanceTenSeconds = createLeg(TransportMode.car, 0.0d, 10.0d ); legScoringRichCarLeg.handleLeg(carLegZeroDistanceTenSeconds); - Assert.assertEquals("for the rich person with low car asc, a 0 meter and 10s car trip should be equal to a score of ", - -0.1d -0.001d * 10 -7.5*1./1.5 -0.3, legScoringRichCarLeg.getScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.1d -0.001d * 10 -7.5*1./1.5 -0.3, legScoringRichCarLeg.getScore(), MatsimTestUtils.EPSILON, "for the rich person with low car asc, a 0 meter and 10s car trip should be equal to a score of "); ScoringParameters paramsMediumIncomeHighCarAsc = personScoringParams.getScoringParameters(population.getPersons().get(Id.createPersonId("mediumIncomeHighCarAsc"))); CharyparNagelLegScoring legScoringMediumIncomeHighCarAsc = new CharyparNagelLegScoring(paramsMediumIncomeHighCarAsc, NetworkUtils.createNetwork(), Set.of(TransportMode.pt)); legScoringMediumIncomeHighCarAsc.handleLeg(carLegZeroDistanceTenSeconds); - Assert.assertEquals("for the medium person with high car asc, a 0 meter and 10s car trip should be equal to a score of ", - -2.1d -0.001d * 10 -7.5*1./1.0 -0.3, legScoringMediumIncomeHighCarAsc.getScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-2.1d -0.001d * 10 -7.5*1./1.0 -0.3, legScoringMediumIncomeHighCarAsc.getScore(), MatsimTestUtils.EPSILON, "for the medium person with high car asc, a 0 meter and 10s car trip should be equal to a score of "); // bike has no person specific asc for high income person and is not affected CharyparNagelLegScoring legScoringRichBikeLeg = new CharyparNagelLegScoring(paramsRich, NetworkUtils.createNetwork(), Set.of(TransportMode.pt)); Leg bikeLegZeroDistanceZeroSeconds = createLeg(TransportMode.bike, 0.0d, 0.0d ); legScoringRichBikeLeg.handleLeg(bikeLegZeroDistanceZeroSeconds); - Assert.assertEquals("for the rich person with low car asc, a 0 meter and 0s bike trip should be equal to a score of ", - -0.55d, legScoringRichBikeLeg.getScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-0.55d, legScoringRichBikeLeg.getScore(), MatsimTestUtils.EPSILON, "for the rich person with low car asc, a 0 meter and 0s bike trip should be equal to a score of "); // bike has a person specific asc for the medium income person CharyparNagelLegScoring legScoringMediumIncomeBikeLeg = new CharyparNagelLegScoring(paramsMediumIncomeHighCarAsc, NetworkUtils.createNetwork(), Set.of(TransportMode.pt)); legScoringMediumIncomeBikeLeg.handleLeg(bikeLegZeroDistanceZeroSeconds); - Assert.assertEquals("for the medium income person with high car asc, a 0 meter and 0s bike trip should be equal to a score of ", - -50.0d, legScoringMediumIncomeBikeLeg.getScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(-50.0d, legScoringMediumIncomeBikeLeg.getScore(), MatsimTestUtils.EPSILON, "for the medium income person with high car asc, a 0 meter and 0s bike trip should be equal to a score of "); } private static Leg createLeg(String mode, double distance, double travelTime) { @@ -263,8 +259,8 @@ private static Leg createLeg(String mode, double distance, double travelTime) { } private void makeAssertMarginalUtilityOfMoneyAndPtWait(ScoringParameters params, double income, double marginalUtilityOfWaitingPt_s){ - Assert.assertEquals("marginalUtilityOfMoney is wrong", 1 / income , params.marginalUtilityOfMoney, 0.); - Assert.assertEquals("marginalUtilityOfWaitingPt_s is wrong", marginalUtilityOfWaitingPt_s , params.marginalUtilityOfWaitingPt_s, 0.); + Assertions.assertEquals(1 / income , params.marginalUtilityOfMoney, 0., "marginalUtilityOfMoney is wrong"); + Assertions.assertEquals(marginalUtilityOfWaitingPt_s , params.marginalUtilityOfWaitingPt_s, 0., "marginalUtilityOfWaitingPt_s is wrong"); } diff --git a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java index 5839ac4e77c..b64c9eca7a8 100644 --- a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java +++ b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java @@ -21,8 +21,8 @@ package org.matsim.freight.carriers.analysis; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -115,13 +115,13 @@ void runVehicleTrackerTest(){ if(key.equals(lightVehicle_0)){ Id vehicleType = Id.create( "light", VehicleType.class ); Id driverId_0 = Id.create( "freight_carrier1_veh_carrier_19_lightVehicle_0", Person.class ); - Assert.assertEquals("Road time is not as expected ",Double.valueOf(6195.0),tracker.get(key).roadTime); - Assert.assertEquals("Cost is not as expected ",Double.valueOf(50.88999999999996),tracker.get(key).cost); - Assert.assertEquals("Travel distance is not as expected ",Double.valueOf(35000.0),tracker.get(key).travelDistance); - Assert.assertEquals("Usage time is not as expected ",Double.valueOf(6689.0),tracker.get(key).usageTime); - Assert.assertEquals("Driver Id is not as expected ",driverId_0,tracker.get(key).lastDriverId); - Assert.assertEquals("Vehicle type is not as expected ",vehicleType,tracker.get(key).vehicleType.getId()); - Assert.assertEquals("No: of trips is not as expected ",6,tracker.get(key).tripHistory.size()); + Assertions.assertEquals(Double.valueOf(6195.0),tracker.get(key).roadTime,"Road time is not as expected "); + Assertions.assertEquals(Double.valueOf(50.88999999999996),tracker.get(key).cost,"Cost is not as expected "); + Assertions.assertEquals(Double.valueOf(35000.0),tracker.get(key).travelDistance,"Travel distance is not as expected "); + Assertions.assertEquals(Double.valueOf(6689.0),tracker.get(key).usageTime,"Usage time is not as expected "); + Assertions.assertEquals(driverId_0,tracker.get(key).lastDriverId,"Driver Id is not as expected "); + Assertions.assertEquals(vehicleType,tracker.get(key).vehicleType.getId(),"Vehicle type is not as expected "); + Assertions.assertEquals(6,tracker.get(key).tripHistory.size(),"No: of trips is not as expected "); //trip history LinkedHashSet tripHistory = tracker.get(key).tripHistory; @@ -132,46 +132,46 @@ void runVehicleTrackerTest(){ history.put(i, tripHistoryItr.next()); i++; } - Assert.assertEquals("cost is not as expected ",Double.valueOf(-6.0200000000000005),history.get(0).cost); - Assert.assertEquals("travelDistance is not as expected ",Double.valueOf(10000.0),history.get(0).travelDistance); - Assert.assertEquals("travelTime is not as expected ",Double.valueOf(-1340.0),history.get(0).travelTime); - Assert.assertEquals("driverId is not as expected ",driverId_0,history.get(0).driverId); - - Assert.assertEquals("cost is not as expected ",Double.valueOf(-5.417999999999999),history.get(1).cost); - Assert.assertEquals("travelDistance is not as expected ",Double.valueOf(5000.0),history.get(1).travelDistance); - Assert.assertEquals("travelTime is not as expected ",Double.valueOf(-971.0),history.get(1).travelTime); - Assert.assertEquals("driverId is not as expected ",driverId_0,history.get(1).driverId); - - Assert.assertEquals("cost is not as expected ",Double.valueOf(-4.214),history.get(2).cost); - Assert.assertEquals("travelDistance is not as expected ",Double.valueOf(3000.0),history.get(2).travelDistance); - Assert.assertEquals("travelTime is not as expected ",Double.valueOf(-703.0),history.get(2).travelTime); - Assert.assertEquals("driverId is not as expected ",driverId_0,history.get(2).driverId); - - Assert.assertEquals("cost is not as expected ",Double.valueOf(-4.816),history.get(3).cost); - Assert.assertEquals("travelDistance is not as expected ",Double.valueOf(4000.0),history.get(3).travelDistance); - Assert.assertEquals("travelTime is not as expected ",Double.valueOf(-837.0),history.get(3).travelTime); - Assert.assertEquals("driverId is not as expected ",driverId_0,history.get(3).driverId); - - Assert.assertEquals("cost is not as expected ",Double.valueOf(-4.816),history.get(4).cost); - Assert.assertEquals("travelDistance is not as expected ",Double.valueOf(4000.0),history.get(4).travelDistance); - Assert.assertEquals("travelTime is not as expected ",Double.valueOf(-837.0),history.get(4).travelTime); - Assert.assertEquals("driverId is not as expected ",driverId_0,history.get(4).driverId); - - Assert.assertEquals("cost is not as expected ",Double.valueOf(-7.826000000000001),history.get(5).cost); - Assert.assertEquals("travelDistance is not as expected ",Double.valueOf(9000.0),history.get(5).travelDistance); - Assert.assertEquals("travelTime is not as expected ",Double.valueOf(-1507.0),history.get(5).travelTime); - Assert.assertEquals("driverId is not as expected ",driverId_0,history.get(5).driverId); + Assertions.assertEquals(Double.valueOf(-6.0200000000000005),history.get(0).cost,"cost is not as expected "); + Assertions.assertEquals(Double.valueOf(10000.0),history.get(0).travelDistance,"travelDistance is not as expected "); + Assertions.assertEquals(Double.valueOf(-1340.0),history.get(0).travelTime,"travelTime is not as expected "); + Assertions.assertEquals(driverId_0,history.get(0).driverId,"driverId is not as expected "); + + Assertions.assertEquals(Double.valueOf(-5.417999999999999),history.get(1).cost,"cost is not as expected "); + Assertions.assertEquals(Double.valueOf(5000.0),history.get(1).travelDistance,"travelDistance is not as expected "); + Assertions.assertEquals(Double.valueOf(-971.0),history.get(1).travelTime,"travelTime is not as expected "); + Assertions.assertEquals(driverId_0,history.get(1).driverId,"driverId is not as expected "); + + Assertions.assertEquals(Double.valueOf(-4.214),history.get(2).cost,"cost is not as expected "); + Assertions.assertEquals(Double.valueOf(3000.0),history.get(2).travelDistance,"travelDistance is not as expected "); + Assertions.assertEquals(Double.valueOf(-703.0),history.get(2).travelTime,"travelTime is not as expected "); + Assertions.assertEquals(driverId_0,history.get(2).driverId,"driverId is not as expected "); + + Assertions.assertEquals(Double.valueOf(-4.816),history.get(3).cost,"cost is not as expected "); + Assertions.assertEquals(Double.valueOf(4000.0),history.get(3).travelDistance,"travelDistance is not as expected "); + Assertions.assertEquals(Double.valueOf(-837.0),history.get(3).travelTime,"travelTime is not as expected "); + Assertions.assertEquals(driverId_0,history.get(3).driverId,"driverId is not as expected "); + + Assertions.assertEquals(Double.valueOf(-4.816),history.get(4).cost,"cost is not as expected "); + Assertions.assertEquals(Double.valueOf(4000.0),history.get(4).travelDistance,"travelDistance is not as expected "); + Assertions.assertEquals(Double.valueOf(-837.0),history.get(4).travelTime,"travelTime is not as expected "); + Assertions.assertEquals(driverId_0,history.get(4).driverId,"driverId is not as expected "); + + Assertions.assertEquals(Double.valueOf(-7.826000000000001),history.get(5).cost,"cost is not as expected "); + Assertions.assertEquals(Double.valueOf(9000.0),history.get(5).travelDistance,"travelDistance is not as expected "); + Assertions.assertEquals(Double.valueOf(-1507.0),history.get(5).travelTime,"travelTime is not as expected "); + Assertions.assertEquals(driverId_0,history.get(5).driverId,"driverId is not as expected "); } else if(key.equals(lightVehicle_1)){ Id vehicleType = Id.create( "light", VehicleType.class ); Id driverId_1 = Id.create( "freight_carrier1_veh_carrier_19_lightVehicle_1", Person.class ); - Assert.assertEquals("Road time is not as expected ",Double.valueOf(3684.0),tracker.get(key).roadTime); - Assert.assertEquals("Cost is not as expected ",Double.valueOf(65.33799999999991),tracker.get(key).cost); - Assert.assertEquals("Travel distance is not as expected ",Double.valueOf(23000.0),tracker.get(key).travelDistance); - Assert.assertEquals("Usage time is not as expected ",Double.valueOf(3818.0),tracker.get(key).usageTime); - Assert.assertEquals("Driver Id is not as expected ",driverId_1,tracker.get(key).lastDriverId); - Assert.assertEquals("Vehicle type is not as expected ",vehicleType,tracker.get(key).vehicleType.getId()); - Assert.assertEquals("No: of trips is not as expected ",3,tracker.get(key).tripHistory.size()); + Assertions.assertEquals(Double.valueOf(3684.0),tracker.get(key).roadTime,"Road time is not as expected "); + Assertions.assertEquals(Double.valueOf(65.33799999999991),tracker.get(key).cost,"Cost is not as expected "); + Assertions.assertEquals(Double.valueOf(23000.0),tracker.get(key).travelDistance,"Travel distance is not as expected "); + Assertions.assertEquals(Double.valueOf(3818.0),tracker.get(key).usageTime,"Usage time is not as expected "); + Assertions.assertEquals(driverId_1,tracker.get(key).lastDriverId,"Driver Id is not as expected "); + Assertions.assertEquals(vehicleType,tracker.get(key).vehicleType.getId(),"Vehicle type is not as expected "); + Assertions.assertEquals(3,tracker.get(key).tripHistory.size(),"No: of trips is not as expected "); //trip history LinkedHashSet tripHistory = tracker.get(key).tripHistory; @@ -182,20 +182,20 @@ void runVehicleTrackerTest(){ history.put(i, tripHistoryItr.next()); i++; } - Assert.assertEquals("cost is not as expected ",Double.valueOf(-3.6120000000000005),history.get(0).cost); - Assert.assertEquals("travelDistance is not as expected ",Double.valueOf(6000.0),history.get(0).travelDistance); - Assert.assertEquals("travelTime is not as expected ",Double.valueOf(-804.0),history.get(0).travelTime); - Assert.assertEquals("driverId is not as expected ",driverId_1,history.get(0).driverId); + Assertions.assertEquals(Double.valueOf(-3.6120000000000005),history.get(0).cost,"cost is not as expected "); + Assertions.assertEquals(Double.valueOf(6000.0),history.get(0).travelDistance,"travelDistance is not as expected "); + Assertions.assertEquals(Double.valueOf(-804.0),history.get(0).travelTime,"travelTime is not as expected "); + Assertions.assertEquals(driverId_1,history.get(0).driverId,"driverId is not as expected "); - Assert.assertEquals("cost is not as expected ",Double.valueOf(-6.622000000000001),history.get(1).cost); - Assert.assertEquals("travelDistance is not as expected ",Double.valueOf(7000.0),history.get(1).travelDistance); - Assert.assertEquals("travelTime is not as expected ",Double.valueOf(-1239.0),history.get(1).travelTime); - Assert.assertEquals("driverId is not as expected ",driverId_1,history.get(1).driverId); + Assertions.assertEquals(Double.valueOf(-6.622000000000001),history.get(1).cost,"cost is not as expected "); + Assertions.assertEquals(Double.valueOf(7000.0),history.get(1).travelDistance,"travelDistance is not as expected "); + Assertions.assertEquals(Double.valueOf(-1239.0),history.get(1).travelTime,"travelTime is not as expected "); + Assertions.assertEquals(driverId_1,history.get(1).driverId,"driverId is not as expected "); - Assert.assertEquals("cost is not as expected ",Double.valueOf(-8.428),history.get(2).cost); - Assert.assertEquals("travelDistance is not as expected ",Double.valueOf(10000.0),history.get(2).travelDistance); - Assert.assertEquals("travelTime is not as expected ",Double.valueOf(-1641.0),history.get(2).travelTime); - Assert.assertEquals("driverId is not as expected ",driverId_1,history.get(2).driverId); + Assertions.assertEquals(Double.valueOf(-8.428),history.get(2).cost,"cost is not as expected "); + Assertions.assertEquals(Double.valueOf(10000.0),history.get(2).travelDistance,"travelDistance is not as expected "); + Assertions.assertEquals(Double.valueOf(-1641.0),history.get(2).travelTime,"travelTime is not as expected "); + Assertions.assertEquals(driverId_1,history.get(2).driverId,"driverId is not as expected "); } } @@ -254,40 +254,40 @@ void runServiceTrackerTest(){ if(key.equals(carrierId)){ ServiceTracker.CarrierServiceTracker serviceTracker = carrierServiceTracker.get(key); System.out.println(serviceTracker.serviceTrackers.get(carrierServiceId1).calculatedArrival); - Assert.assertEquals("tourETA is not as expected ",Double.valueOf(24032.0),serviceTracker.serviceTrackers.get(carrierServiceId1).calculatedArrival); - Assert.assertEquals("arrivalTime is not as expected ",Double.valueOf(24405.0),serviceTracker.serviceTrackers.get(carrierServiceId1).arrivalTimeGuess); - Assert.assertEquals("driverId is not as expected ",person_0,serviceTracker.serviceTrackers.get(carrierServiceId1).driverIdGuess); - Assert.assertEquals("serviceETA is not as expected ", Double.valueOf(0.0), Double.valueOf(serviceTracker.serviceTrackers.get(carrierServiceId1).expectedArrival)); - - Assert.assertEquals("tourETA is not as expected ",Double.valueOf(23766.0),serviceTracker.serviceTrackers.get(carrierServiceId11).calculatedArrival); - Assert.assertEquals("arrivalTime is not as expected ",Double.valueOf(23777.0),serviceTracker.serviceTrackers.get(carrierServiceId11).arrivalTimeGuess); - Assert.assertEquals("driverId is not as expected ",person_1,serviceTracker.serviceTrackers.get(carrierServiceId11).driverIdGuess); - Assert.assertEquals("serviceETA is not as expected ", Double.valueOf(0.0), Double.valueOf(serviceTracker.serviceTrackers.get(carrierServiceId11).expectedArrival)); - - Assert.assertEquals("tourETA is not as expected ",Double.valueOf(25566.0),serviceTracker.serviceTrackers.get(carrierServiceId12).calculatedArrival); - Assert.assertEquals("arrivalTime is not as expected ",Double.valueOf(25945.0),serviceTracker.serviceTrackers.get(carrierServiceId12).arrivalTimeGuess); - Assert.assertEquals("driverId is not as expected ",person_0,serviceTracker.serviceTrackers.get(carrierServiceId12).driverIdGuess); - Assert.assertEquals("serviceETA is not as expected ", Double.valueOf(0.0), Double.valueOf(serviceTracker.serviceTrackers.get(carrierServiceId12).expectedArrival)); - - Assert.assertEquals("tourETA is not as expected ",Double.valueOf(22533.0),serviceTracker.serviceTrackers.get(carrierServiceId13).calculatedArrival); - Assert.assertEquals("arrivalTime is not as expected ",Double.valueOf(22538.0),serviceTracker.serviceTrackers.get(carrierServiceId13).arrivalTimeGuess); - Assert.assertEquals("driverId is not as expected ",person_1,serviceTracker.serviceTrackers.get(carrierServiceId13).driverIdGuess); - Assert.assertEquals("serviceETA is not as expected ", Double.valueOf(0.0), Double.valueOf(serviceTracker.serviceTrackers.get(carrierServiceId13).expectedArrival)); - - Assert.assertEquals("tourETA is not as expected ",Double.valueOf(23066.0),serviceTracker.serviceTrackers.get(carrierServiceId14).calculatedArrival); - Assert.assertEquals("arrivalTime is not as expected ",Double.valueOf(23434.0),serviceTracker.serviceTrackers.get(carrierServiceId14).arrivalTimeGuess); - Assert.assertEquals("driverId is not as expected ",person_0,serviceTracker.serviceTrackers.get(carrierServiceId14).driverIdGuess); - Assert.assertEquals("serviceETA is not as expected ", Double.valueOf(0.0), Double.valueOf(serviceTracker.serviceTrackers.get(carrierServiceId14).expectedArrival)); - - Assert.assertEquals("tourETA is not as expected ",Double.valueOf(26399.0),serviceTracker.serviceTrackers.get(carrierServiceId15).calculatedArrival); - Assert.assertEquals("arrivalTime is not as expected ",Double.valueOf(26782.0),serviceTracker.serviceTrackers.get(carrierServiceId15).arrivalTimeGuess); - Assert.assertEquals("driverId is not as expected ",person_0,serviceTracker.serviceTrackers.get(carrierServiceId15).driverIdGuess); - Assert.assertEquals("serviceETA is not as expected ", Double.valueOf(0.0), Double.valueOf(serviceTracker.serviceTrackers.get(carrierServiceId15).expectedArrival)); - - Assert.assertEquals("tourETA is not as expected ",Double.valueOf(24732.0),serviceTracker.serviceTrackers.get(carrierServiceId16).calculatedArrival); - Assert.assertEquals("arrivalTime is not as expected ",Double.valueOf(25108.0),serviceTracker.serviceTrackers.get(carrierServiceId16).arrivalTimeGuess); - Assert.assertEquals("driverId is not as expected ",person_0,serviceTracker.serviceTrackers.get(carrierServiceId16).driverIdGuess); - Assert.assertEquals("serviceETA is not as expected ", Double.valueOf(0.0), Double.valueOf(serviceTracker.serviceTrackers.get(carrierServiceId16).expectedArrival)); + Assertions.assertEquals(Double.valueOf(24032.0),serviceTracker.serviceTrackers.get(carrierServiceId1).calculatedArrival,"tourETA is not as expected "); + Assertions.assertEquals(Double.valueOf(24405.0),serviceTracker.serviceTrackers.get(carrierServiceId1).arrivalTimeGuess,"arrivalTime is not as expected "); + Assertions.assertEquals(person_0,serviceTracker.serviceTrackers.get(carrierServiceId1).driverIdGuess,"driverId is not as expected "); + Assertions.assertEquals(Double.valueOf(0.0), Double.valueOf(serviceTracker.serviceTrackers.get(carrierServiceId1).expectedArrival), "serviceETA is not as expected "); + + Assertions.assertEquals(Double.valueOf(23766.0),serviceTracker.serviceTrackers.get(carrierServiceId11).calculatedArrival,"tourETA is not as expected "); + Assertions.assertEquals(Double.valueOf(23777.0),serviceTracker.serviceTrackers.get(carrierServiceId11).arrivalTimeGuess,"arrivalTime is not as expected "); + Assertions.assertEquals(person_1,serviceTracker.serviceTrackers.get(carrierServiceId11).driverIdGuess,"driverId is not as expected "); + Assertions.assertEquals(Double.valueOf(0.0), Double.valueOf(serviceTracker.serviceTrackers.get(carrierServiceId11).expectedArrival), "serviceETA is not as expected "); + + Assertions.assertEquals(Double.valueOf(25566.0),serviceTracker.serviceTrackers.get(carrierServiceId12).calculatedArrival,"tourETA is not as expected "); + Assertions.assertEquals(Double.valueOf(25945.0),serviceTracker.serviceTrackers.get(carrierServiceId12).arrivalTimeGuess,"arrivalTime is not as expected "); + Assertions.assertEquals(person_0,serviceTracker.serviceTrackers.get(carrierServiceId12).driverIdGuess,"driverId is not as expected "); + Assertions.assertEquals(Double.valueOf(0.0), Double.valueOf(serviceTracker.serviceTrackers.get(carrierServiceId12).expectedArrival), "serviceETA is not as expected "); + + Assertions.assertEquals(Double.valueOf(22533.0),serviceTracker.serviceTrackers.get(carrierServiceId13).calculatedArrival,"tourETA is not as expected "); + Assertions.assertEquals(Double.valueOf(22538.0),serviceTracker.serviceTrackers.get(carrierServiceId13).arrivalTimeGuess,"arrivalTime is not as expected "); + Assertions.assertEquals(person_1,serviceTracker.serviceTrackers.get(carrierServiceId13).driverIdGuess,"driverId is not as expected "); + Assertions.assertEquals(Double.valueOf(0.0), Double.valueOf(serviceTracker.serviceTrackers.get(carrierServiceId13).expectedArrival), "serviceETA is not as expected "); + + Assertions.assertEquals(Double.valueOf(23066.0),serviceTracker.serviceTrackers.get(carrierServiceId14).calculatedArrival,"tourETA is not as expected "); + Assertions.assertEquals(Double.valueOf(23434.0),serviceTracker.serviceTrackers.get(carrierServiceId14).arrivalTimeGuess,"arrivalTime is not as expected "); + Assertions.assertEquals(person_0,serviceTracker.serviceTrackers.get(carrierServiceId14).driverIdGuess,"driverId is not as expected "); + Assertions.assertEquals(Double.valueOf(0.0), Double.valueOf(serviceTracker.serviceTrackers.get(carrierServiceId14).expectedArrival), "serviceETA is not as expected "); + + Assertions.assertEquals(Double.valueOf(26399.0),serviceTracker.serviceTrackers.get(carrierServiceId15).calculatedArrival,"tourETA is not as expected "); + Assertions.assertEquals(Double.valueOf(26782.0),serviceTracker.serviceTrackers.get(carrierServiceId15).arrivalTimeGuess,"arrivalTime is not as expected "); + Assertions.assertEquals(person_0,serviceTracker.serviceTrackers.get(carrierServiceId15).driverIdGuess,"driverId is not as expected "); + Assertions.assertEquals(Double.valueOf(0.0), Double.valueOf(serviceTracker.serviceTrackers.get(carrierServiceId15).expectedArrival), "serviceETA is not as expected "); + + Assertions.assertEquals(Double.valueOf(24732.0),serviceTracker.serviceTrackers.get(carrierServiceId16).calculatedArrival,"tourETA is not as expected "); + Assertions.assertEquals(Double.valueOf(25108.0),serviceTracker.serviceTrackers.get(carrierServiceId16).arrivalTimeGuess,"arrivalTime is not as expected "); + Assertions.assertEquals(person_0,serviceTracker.serviceTrackers.get(carrierServiceId16).driverIdGuess,"driverId is not as expected "); + Assertions.assertEquals(Double.valueOf(0.0), Double.valueOf(serviceTracker.serviceTrackers.get(carrierServiceId16).expectedArrival), "serviceETA is not as expected "); } } } diff --git a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisWithShipmentTest.java b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisWithShipmentTest.java index c96930e1f1f..45ec87629d4 100644 --- a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisWithShipmentTest.java +++ b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisWithShipmentTest.java @@ -21,7 +21,7 @@ package org.matsim.freight.carriers.analysis; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -93,12 +93,12 @@ void runShipmentTrackerTest(){ System.out.println("from "+fromLinkId+" to "+toLinkId+" distance is "+dist); } - Assert.assertEquals("Beeline distance is not as expected for shipment 1",Double.valueOf(10816.653826391968),beelineDistance.get(Id.create( "1", CarrierShipment.class ))); - Assert.assertEquals("Beeline distance is not as expected for shipment 11",Double.valueOf(6000.0),beelineDistance.get(Id.create( "11", CarrierShipment.class ))); - Assert.assertEquals("Beeline distance is not as expected for shipment 12",Double.valueOf(7106.335201775948),beelineDistance.get(Id.create( "12", CarrierShipment.class ))); - Assert.assertEquals("Beeline distance is not as expected for shipment 13",Double.valueOf(4123.105625617661),beelineDistance.get(Id.create( "13", CarrierShipment.class ))); - Assert.assertEquals("Beeline distance is not as expected for shipment 14",Double.valueOf(9055.385138137417),beelineDistance.get(Id.create( "14", CarrierShipment.class ))); - Assert.assertEquals("Beeline distance is not as expected for shipment 15",Double.valueOf(6964.19413859206),beelineDistance.get(Id.create( "15", CarrierShipment.class ))); - Assert.assertEquals("Beeline distance is not as expected for shipment 16",Double.valueOf(9192.388155425118),beelineDistance.get(Id.create( "16", CarrierShipment.class ))); + Assertions.assertEquals(Double.valueOf(10816.653826391968),beelineDistance.get(Id.create( "1", CarrierShipment.class )),"Beeline distance is not as expected for shipment 1"); + Assertions.assertEquals(Double.valueOf(6000.0),beelineDistance.get(Id.create( "11", CarrierShipment.class )),"Beeline distance is not as expected for shipment 11"); + Assertions.assertEquals(Double.valueOf(7106.335201775948),beelineDistance.get(Id.create( "12", CarrierShipment.class )),"Beeline distance is not as expected for shipment 12"); + Assertions.assertEquals(Double.valueOf(4123.105625617661),beelineDistance.get(Id.create( "13", CarrierShipment.class )),"Beeline distance is not as expected for shipment 13"); + Assertions.assertEquals(Double.valueOf(9055.385138137417),beelineDistance.get(Id.create( "14", CarrierShipment.class )),"Beeline distance is not as expected for shipment 14"); + Assertions.assertEquals(Double.valueOf(6964.19413859206),beelineDistance.get(Id.create( "15", CarrierShipment.class )),"Beeline distance is not as expected for shipment 15"); + Assertions.assertEquals(Double.valueOf(9192.388155425118),beelineDistance.get(Id.create( "16", CarrierShipment.class )),"Beeline distance is not as expected for shipment 16"); } } diff --git a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java index 8bd5209f135..89d9446b529 100644 --- a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java +++ b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java @@ -9,8 +9,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -469,9 +469,9 @@ public void install() { .filter(pe -> pe instanceof Leg) .map(pe -> (Leg)pe) .collect(toList()); - Assert.assertTrue("Incorrect Mode, case 1", planLegCase1.get(0).getMode().contains("walk")); - Assert.assertTrue("Incorrect Mode, case 1", planLegCase1.get(1).getMode().equals("pt")); - Assert.assertTrue("Incorrect Mode, case 1", planLegCase1.get(2).getMode().contains("walk")); + Assertions.assertTrue(planLegCase1.get(0).getMode().contains("walk"), "Incorrect Mode, case 1"); + Assertions.assertTrue(planLegCase1.get(1).getMode().equals("pt"), "Incorrect Mode, case 1"); + Assertions.assertTrue(planLegCase1.get(2).getMode().contains("walk"), "Incorrect Mode, case 1"); /** * Case 2a: Agent starts at Link "50-51". This is within the drt service area. Agent is expected use drt as @@ -488,11 +488,11 @@ public void install() { .filter(pe -> pe instanceof Leg) .map(pe -> (Leg)pe) .collect(toList()); - Assert.assertTrue("Incorrect Mode, case 2a", planLegCase2a.get(0).getMode().contains("walk")); - Assert.assertTrue("Incorrect Mode, case 2a", planLegCase2a.get(1).getMode().equals("drt")); - Assert.assertTrue("Incorrect Mode, case 2a", planLegCase2a.get(2).getMode().contains("walk")); - Assert.assertTrue("Incorrect Mode, case 2a", planLegCase2a.get(3).getMode().equals("pt")); - Assert.assertTrue("Incorrect Mode, case 2a", planLegCase2a.get(4).getMode().contains("walk")); + Assertions.assertTrue(planLegCase2a.get(0).getMode().contains("walk"), "Incorrect Mode, case 2a"); + Assertions.assertTrue(planLegCase2a.get(1).getMode().equals("drt"), "Incorrect Mode, case 2a"); + Assertions.assertTrue(planLegCase2a.get(2).getMode().contains("walk"), "Incorrect Mode, case 2a"); + Assertions.assertTrue(planLegCase2a.get(3).getMode().equals("pt"), "Incorrect Mode, case 2a"); + Assertions.assertTrue(planLegCase2a.get(4).getMode().contains("walk"), "Incorrect Mode, case 2a"); /** * Case 2b: Agent starts at Link "300-301". This is within the drt service area. Agent is expected use drt as @@ -508,11 +508,11 @@ public void install() { .filter(pe -> pe instanceof Leg) .map(pe -> (Leg)pe) .collect(toList()); - Assert.assertTrue("Incorrect Mode, case 2b", planLegCase2b.get(0).getMode().contains("walk")); - Assert.assertTrue("Incorrect Mode, case 2b", planLegCase2b.get(1).getMode().equals("drt")); - Assert.assertTrue("Incorrect Mode, case 2b", planLegCase2b.get(2).getMode().contains("walk")); - Assert.assertTrue("Incorrect Mode, case 2b", planLegCase2b.get(3).getMode().equals("pt")); - Assert.assertTrue("Incorrect Mode, case 2b", planLegCase2b.get(4).getMode().contains("walk")); + Assertions.assertTrue(planLegCase2b.get(0).getMode().contains("walk"), "Incorrect Mode, case 2b"); + Assertions.assertTrue(planLegCase2b.get(1).getMode().equals("drt"), "Incorrect Mode, case 2b"); + Assertions.assertTrue(planLegCase2b.get(2).getMode().contains("walk"), "Incorrect Mode, case 2b"); + Assertions.assertTrue(planLegCase2b.get(3).getMode().equals("pt"), "Incorrect Mode, case 2b"); + Assertions.assertTrue(planLegCase2b.get(4).getMode().contains("walk"), "Incorrect Mode, case 2b"); /** * Case 2c: Agent starts at Link "550-551". This is within the drt3 service area. Agent is expected use drt3 as @@ -528,11 +528,11 @@ public void install() { .filter(pe -> pe instanceof Leg) .map(pe -> (Leg)pe) .collect(toList()); - Assert.assertTrue("Incorrect Mode, case 2c", planLegCase2c.get(0).getMode().contains("walk")); - Assert.assertTrue("Incorrect Mode, case 2c", planLegCase2c.get(1).getMode().equals("drt3")); - Assert.assertTrue("Incorrect Mode, case 2c", planLegCase2c.get(2).getMode().contains("walk")); - Assert.assertTrue("Incorrect Mode, case 2c", planLegCase2c.get(3).getMode().equals("pt")); - Assert.assertTrue("Incorrect Mode, case 2c", planLegCase2c.get(4).getMode().contains("walk")); + Assertions.assertTrue(planLegCase2c.get(0).getMode().contains("walk"), "Incorrect Mode, case 2c"); + Assertions.assertTrue(planLegCase2c.get(1).getMode().equals("drt3"), "Incorrect Mode, case 2c"); + Assertions.assertTrue(planLegCase2c.get(2).getMode().contains("walk"), "Incorrect Mode, case 2c"); + Assertions.assertTrue(planLegCase2c.get(3).getMode().equals("pt"), "Incorrect Mode, case 2c"); + Assertions.assertTrue(planLegCase2c.get(4).getMode().contains("walk"), "Incorrect Mode, case 2c"); /** * Case 3a: Agent starts at Link "690-691". This is not within any drt service areas. Agent is expected to use @@ -548,7 +548,7 @@ public void install() { .filter(pe -> pe instanceof Leg) .map(pe -> (Leg)pe) .collect(toList()); - Assert.assertTrue("Incorrect Mode, case 3a", planLegCase3a.get(0).getMode().equals("walk")); + Assertions.assertTrue(planLegCase3a.get(0).getMode().equals("walk"), "Incorrect Mode, case 3a"); /** * Case 3b: Agent starts at Link "800-801". This is within the drt2 service area. Agent is NOT expected to utilize @@ -565,7 +565,7 @@ public void install() { .filter(pe -> pe instanceof Leg) .map(pe -> (Leg)pe) .collect(toList()); - Assert.assertTrue("Incorrect Mode, case 3b", planLegCase3b.get(0).getMode().equals("walk")); + Assertions.assertTrue(planLegCase3b.get(0).getMode().equals("walk"), "Incorrect Mode, case 3b"); } @@ -727,7 +727,7 @@ public void notifyIterationEnds(IterationEndsEvent event) { break; } } - Assert.assertFalse(problem); + Assertions.assertFalse(problem); } } diff --git a/contribs/vsp/src/test/java/playground/vsp/airPollution/flatEmissions/EmissionCostFactorsTest.java b/contribs/vsp/src/test/java/playground/vsp/airPollution/flatEmissions/EmissionCostFactorsTest.java index ed62c664a9f..f81f2ac9990 100644 --- a/contribs/vsp/src/test/java/playground/vsp/airPollution/flatEmissions/EmissionCostFactorsTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/airPollution/flatEmissions/EmissionCostFactorsTest.java @@ -1,7 +1,7 @@ package playground.vsp.airPollution.flatEmissions; -import static org.junit.Assert.fail; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; import static playground.vsp.airPollution.flatEmissions.EmissionCostFactors.NOx; import org.junit.jupiter.api.Test; diff --git a/contribs/vsp/src/test/java/playground/vsp/analysis/modules/emissions/TestColdEmissionHandler.java b/contribs/vsp/src/test/java/playground/vsp/analysis/modules/emissions/TestColdEmissionHandler.java index a0c00826bc0..b3b4eca91ca 100644 --- a/contribs/vsp/src/test/java/playground/vsp/analysis/modules/emissions/TestColdEmissionHandler.java +++ b/contribs/vsp/src/test/java/playground/vsp/analysis/modules/emissions/TestColdEmissionHandler.java @@ -23,7 +23,7 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -112,20 +112,18 @@ final void testEmissionPerPersonColdEventHandler(){ actualPM2 = cepp.get( Id.create("v2", Person.class ) ).get( Pollutant.PM ); // assert that values were set correctly - Assert.assertEquals("CO of vehicle 1 should be 17.1 but was "+actualCO1, new Double(17.1), actualCO1, MatsimTestUtils.EPSILON); - Assert.assertEquals("NOx of vehicle 1 should be 44.1 but was "+actualNOx1, new Double(44.1), actualNOx1, MatsimTestUtils.EPSILON); - Assert.assertEquals("PM of vehicle 1 should be 0 but was " +actualPM1, new Double(0.0), actualPM1, MatsimTestUtils.EPSILON); - Assert.assertEquals("CO of vehicle 2 should be 23.9 but was " +actualCO2, new Double(23.9), actualCO2, MatsimTestUtils.EPSILON); - Assert.assertEquals("NOx of vehicle 2 should be 0 but was " +actualNOx2 , new Double(0.0), actualNOx2, MatsimTestUtils.EPSILON); - Assert.assertEquals("PM of vehicle 2 should be 18.1 but was " +actualPM2, new Double(18.1), actualPM2, MatsimTestUtils.EPSILON); + Assertions.assertEquals(new Double(17.1), actualCO1, MatsimTestUtils.EPSILON, "CO of vehicle 1 should be 17.1 but was "+actualCO1); + Assertions.assertEquals(new Double(44.1), actualNOx1, MatsimTestUtils.EPSILON, "NOx of vehicle 1 should be 44.1 but was "+actualNOx1); + Assertions.assertEquals(new Double(0.0), actualPM1, MatsimTestUtils.EPSILON, "PM of vehicle 1 should be 0 but was " +actualPM1); + Assertions.assertEquals(new Double(23.9), actualCO2, MatsimTestUtils.EPSILON, "CO of vehicle 2 should be 23.9 but was " +actualCO2); + Assertions.assertEquals(new Double(0.0), actualNOx2, MatsimTestUtils.EPSILON, "NOx of vehicle 2 should be 0 but was " +actualNOx2); + Assertions.assertEquals(new Double(18.1), actualPM2, MatsimTestUtils.EPSILON, "PM of vehicle 2 should be 18.1 but was " +actualPM2); // nothing else in the map - Assert.assertEquals("There should be two types of emissions in this map but " + - "there were " + cepp.get(Id.create("v1", Person.class)).size()+".", - 2, cepp.get(Id.create("v1", Person.class)).keySet().size()); - Assert.assertEquals("There should be two types of emissions in this map but " + - "there were " + cepp.get(Id.create("v2", Person.class)).size()+".", - 2, cepp.get(Id.create("v2", Person.class)).keySet().size()); + Assertions.assertEquals(2, cepp.get(Id.create("v1", Person.class)).keySet().size(), "There should be two types of emissions in this map but " + + "there were " + cepp.get(Id.create("v1", Person.class)).size()+"."); + Assertions.assertEquals(2, cepp.get(Id.create("v2", Person.class)).keySet().size(), "There should be two types of emissions in this map but " + + "there were " + cepp.get(Id.create("v2", Person.class)).size()+"."); } } diff --git a/contribs/vsp/src/test/java/playground/vsp/analysis/modules/emissions/TestWarmEmissionHandler.java b/contribs/vsp/src/test/java/playground/vsp/analysis/modules/emissions/TestWarmEmissionHandler.java index de5e284c121..e09f1e3642b 100644 --- a/contribs/vsp/src/test/java/playground/vsp/analysis/modules/emissions/TestWarmEmissionHandler.java +++ b/contribs/vsp/src/test/java/playground/vsp/analysis/modules/emissions/TestWarmEmissionHandler.java @@ -23,7 +23,7 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -107,56 +107,56 @@ final void testEmissionPerPersonWarmEventHandler(){ if(wepp.get(Id.create("v1", Person.class)).containsKey( Pollutant.CO )){ // return key; Double actualCO1 = wepp.get(Id.create("v1", Person.class)).get( Pollutant.CO ); - Assert.assertEquals("CO of vehicle 1 should be 17.1 but was "+actualCO1, 17.1, actualCO1, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(17.1, actualCO1, MatsimTestUtils.EPSILON, "CO of vehicle 1 should be 17.1 but was "+actualCO1 ); }else{ - Assert.fail("No CO values for car 1 found."); + Assertions.fail("No CO values for car 1 found."); } //NOx vehicle 1 // return key; if(wepp.get(Id.create("v1", Person.class)).containsKey( Pollutant.NOx )){ // return key; Double actualNOx1 = wepp.get(Id.create("v1", Person.class)).get( Pollutant.NOx ); - Assert.assertEquals("NOx of vehicle 1 should be 44.1 but was "+actualNOx1, 44.1, actualNOx1, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(44.1, actualNOx1, MatsimTestUtils.EPSILON, "NOx of vehicle 1 should be 44.1 but was "+actualNOx1 ); }else{ - Assert.fail("No NOx values for car 1 found."); + Assertions.fail("No NOx values for car 1 found."); } //PM vehicle 1 // return key; if(wepp.get(Id.create("v1", Person.class)).containsKey( Pollutant.PM )){ - Assert.fail("There should be no PM values for car 1."); + Assertions.fail("There should be no PM values for car 1."); }else{ // return key; - Assert.assertNull("PM of vehicle 1 should be null.",wepp.get(Id.create("v1", Person.class)).get( Pollutant.PM ) ); + Assertions.assertNull(wepp.get(Id.create("v1", Person.class)).get( Pollutant.PM ),"PM of vehicle 1 should be null." ); } //CO vehicle 2 // return key; if(wepp.get(Id.create("v2", Person.class)).containsKey( Pollutant.CO )){ // return key; Double actualCO2 = wepp.get(Id.create("v2", Person.class)).get( Pollutant.CO ); - Assert.assertEquals("CO of vehicle 2 should be 23.9", 23.9, actualCO2, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(23.9, actualCO2, MatsimTestUtils.EPSILON, "CO of vehicle 2 should be 23.9" ); }else{ - Assert.fail("No CO values for car 2 found."); + Assertions.fail("No CO values for car 2 found."); } //NOx vehicle 2 // return key; if(wepp.get(Id.create("v2", Person.class)).containsKey( Pollutant.NOx )){ - Assert.fail("There should be no NOx values for car 2."); + Assertions.fail("There should be no NOx values for car 2."); }else{ // return key; - Assert.assertNull(wepp.get(Id.create("v2", Person.class)).get( Pollutant.NOx ) ); + Assertions.assertNull(wepp.get(Id.create("v2", Person.class)).get( Pollutant.NOx ) ); } //PM vehicle 2 // return key; if(wepp.get(Id.create("v2", Person.class)).containsKey( Pollutant.PM )){ // return key; Double actualPM2 = wepp.get(Id.create("v2", Person.class)).get( Pollutant.PM ); - Assert.assertEquals("PM of vehicle 2 should be 18.1", 18.1, actualPM2, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(18.1, actualPM2, MatsimTestUtils.EPSILON, "PM of vehicle 2 should be 18.1" ); }else{ - Assert.fail("No PM values for car 2 found."); + Assertions.fail("No PM values for car 2 found."); } //FC // return key; - Assert.assertNull(wepp.get(Id.create("v1", Person.class)).get( Pollutant.FC ) ); + Assertions.assertNull(wepp.get(Id.create("v1", Person.class)).get( Pollutant.FC ) ); } } diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2DepartureDelayAtStopMapDataTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2DepartureDelayAtStopMapDataTest.java index f63bcbb2fd4..f76c55e41b6 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2DepartureDelayAtStopMapDataTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2DepartureDelayAtStopMapDataTest.java @@ -1,6 +1,6 @@ package playground.vsp.andreas.bvgAna.level1; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -36,8 +36,8 @@ void testAgentId2DepartureDelayAtStopMapData() { // run tests for 1 event each, can be expanded later if needed - Assert.assertEquals((Double)event3.getTime(), data.getAgentDepartsPTInteraction().get(0)); - Assert.assertEquals((Double)event1.getTime(), data.getAgentEntersVehicle().get(0)); + Assertions.assertEquals((Double)event3.getTime(), data.getAgentDepartsPTInteraction().get(0)); + Assertions.assertEquals((Double)event1.getTime(), data.getAgentEntersVehicle().get(0)); diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2DepartureDelayAtStopMapTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2DepartureDelayAtStopMapTest.java index c50c5e0c285..cab543e4e4a 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2DepartureDelayAtStopMapTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2DepartureDelayAtStopMapTest.java @@ -3,7 +3,7 @@ import java.util.Set; import java.util.TreeSet; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -49,11 +49,11 @@ void testAgentId2DepartureDelayAtStopMap() { // run tests - Assert.assertTrue(handler.getStopId2DelayAtStopMap().containsKey(persId1)); - Assert.assertEquals(event3.getTime(), handler.getStopId2DelayAtStopMap().get(persId1).getAgentEntersVehicle().get(0), 0); + Assertions.assertTrue(handler.getStopId2DelayAtStopMap().containsKey(persId1)); + Assertions.assertEquals(event3.getTime(), handler.getStopId2DelayAtStopMap().get(persId1).getAgentEntersVehicle().get(0), 0); - Assert.assertTrue(handler.getStopId2DelayAtStopMap().containsKey(persId2)); - Assert.assertEquals(event4.getTime(), handler.getStopId2DelayAtStopMap().get(persId2).getAgentEntersVehicle().get(0), 0); + Assertions.assertTrue(handler.getStopId2DelayAtStopMap().containsKey(persId2)); + Assertions.assertEquals(event4.getTime(), handler.getStopId2DelayAtStopMap().get(persId2).getAgentEntersVehicle().get(0), 0); } diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2EnterLeaveVehicleEventHandlerTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2EnterLeaveVehicleEventHandlerTest.java index e82f75ca5ec..bab302aa082 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2EnterLeaveVehicleEventHandlerTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2EnterLeaveVehicleEventHandlerTest.java @@ -3,7 +3,7 @@ import java.util.Set; import java.util.TreeSet; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonEntersVehicleEvent; @@ -55,12 +55,12 @@ void testAgentId2EnterLeaveVehicleEventHandler() { // run tests - Assert.assertSame(event1, handler.getAgentId2EnterEventMap().get(persId1).get(0)); - Assert.assertSame(event2, handler.getAgentId2EnterEventMap().get(persId2).get(0)); - Assert.assertSame(event3, handler.getAgentId2EnterEventMap().get(persId3).get(0)); - Assert.assertSame(event4, handler.getAgentId2LeaveEventMap().get(persId1).get(0)); - Assert.assertSame(event5, handler.getAgentId2LeaveEventMap().get(persId2).get(0)); - Assert.assertSame(event6, handler.getAgentId2LeaveEventMap().get(persId3).get(0)); + Assertions.assertSame(event1, handler.getAgentId2EnterEventMap().get(persId1).get(0)); + Assertions.assertSame(event2, handler.getAgentId2EnterEventMap().get(persId2).get(0)); + Assertions.assertSame(event3, handler.getAgentId2EnterEventMap().get(persId3).get(0)); + Assertions.assertSame(event4, handler.getAgentId2LeaveEventMap().get(persId1).get(0)); + Assertions.assertSame(event5, handler.getAgentId2LeaveEventMap().get(persId2).get(0)); + Assertions.assertSame(event6, handler.getAgentId2LeaveEventMap().get(persId3).get(0)); } diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2PtTripTravelTimeMapDataTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2PtTripTravelTimeMapDataTest.java index 3559c2d3082..6930924b935 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2PtTripTravelTimeMapDataTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2PtTripTravelTimeMapDataTest.java @@ -22,7 +22,7 @@ import java.util.Set; import java.util.TreeSet; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -71,9 +71,9 @@ void testAgentId2PtTripTravelTimeMapData() { System.out.println("Number of Transfers should be: 1 and are: "+test.getNumberOfTransfers()); System.out.println("Total travel time should be: "+(event6.getTime()-event5.getTime()+event4.getTime()-event3.getTime())+" and is: "+test.getTotalTripTravelTime()); - Assert.assertEquals(event6.getTime()-event5.getTime()+event4.getTime()-event3.getTime(), test.getTotalTripTravelTime(), 0.); + Assertions.assertEquals(event6.getTime()-event5.getTime()+event4.getTime()-event3.getTime(), test.getTotalTripTravelTime(), 0.); - Assert.assertEquals(1, test.getNumberOfTransfers()); + Assertions.assertEquals(1, test.getNumberOfTransfers()); diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2PtTripTravelTimeMapTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2PtTripTravelTimeMapTest.java index 2adbd8450ef..579a4684a1f 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2PtTripTravelTimeMapTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/AgentId2PtTripTravelTimeMapTest.java @@ -5,7 +5,7 @@ import java.util.TreeMap; import java.util.TreeSet; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -68,7 +68,7 @@ void testAgentId2PtTripTravelTimeMap() { // first tests, this works - Assert.assertEquals(event4.getTime()-event3.getTime(), test.getAgentId2PtTripTravelTimeMap().get(agentId1).get(0).getTotalTripTravelTime(), 0.); + Assertions.assertEquals(event4.getTime()-event3.getTime(), test.getAgentId2PtTripTravelTimeMap().get(agentId1).get(0).getTotalTripTravelTime(), 0.); } diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/PersonEnterLeaveVehicle2ActivityHandlerTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/PersonEnterLeaveVehicle2ActivityHandlerTest.java index 58f13965d0d..cfd4af07243 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/PersonEnterLeaveVehicle2ActivityHandlerTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/PersonEnterLeaveVehicle2ActivityHandlerTest.java @@ -3,7 +3,7 @@ import java.util.Set; import java.util.TreeSet; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; import org.matsim.api.core.v01.events.ActivityStartEvent; @@ -56,7 +56,7 @@ public void testPersonEnterLeaveVehicle2ActivityHandler() { test.handleEvent(event6); test.handleEvent(event7); - Assert.assertEquals(event0, test.getPersonEntersVehicleEvent2ActivityEndEvent().get(event1)); + Assertions.assertEquals(event0, test.getPersonEntersVehicleEvent2ActivityEndEvent().get(event1)); System.out.println(test.getPersonEntersVehicleEvent2ActivityEndEvent().toString()); diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2LineId2PulkTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2LineId2PulkTest.java index 5160fbce497..1b4a71190da 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2LineId2PulkTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2LineId2PulkTest.java @@ -1,7 +1,7 @@ package playground.vsp.andreas.bvgAna.level1; -import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.TransitDriverStartsEvent; @@ -57,7 +57,7 @@ void testStopId2LineId2Pulk() { * */ - Assert.assertEquals(event2, test.getStopId2LineId2PulkDataList().get(event2.getFacilityId()).get(event2.getVehicleId())); + Assertions.assertEquals(event2, test.getStopId2LineId2PulkDataList().get(event2.getFacilityId()).get(event2.getVehicleId())); System.out.println(test.getStopId2LineId2PulkDataList().get(event2.getFacilityId()).get(event2.getVehicleId())); System.out.println(event2.getVehicleId()); diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2RouteId2DelayAtStopMapTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2RouteId2DelayAtStopMapTest.java index 6205ab72888..0fed35941f5 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2RouteId2DelayAtStopMapTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2RouteId2DelayAtStopMapTest.java @@ -1,6 +1,6 @@ package playground.vsp.andreas.bvgAna.level1; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.TransitDriverStartsEvent; @@ -57,11 +57,11 @@ void testStopId2RouteId2DelayAtStopMap() { // // System.out.println(test.getStopId2RouteId2DelayAtStopMap().get(event1.getFacilityId()).get(transitRouteId1).getLineId()); - Assert.assertEquals(transitLineId1, test.getStopId2RouteId2DelayAtStopMap().get(event1.getFacilityId()).get(transitRouteId1).getLineId()); + Assertions.assertEquals(transitLineId1, test.getStopId2RouteId2DelayAtStopMap().get(event1.getFacilityId()).get(transitRouteId1).getLineId()); - Assert.assertEquals(transitRouteId1, test.getStopId2RouteId2DelayAtStopMap().get(event1.getFacilityId()).get(transitRouteId1).getRouteId()); + Assertions.assertEquals(transitRouteId1, test.getStopId2RouteId2DelayAtStopMap().get(event1.getFacilityId()).get(transitRouteId1).getRouteId()); - Assert.assertEquals(1, test.getStopId2RouteId2DelayAtStopMap().get(event1.getFacilityId()).get(transitRouteId1).getRealizedDepartures().size()); + Assertions.assertEquals(1, test.getStopId2RouteId2DelayAtStopMap().get(event1.getFacilityId()).get(transitRouteId1).getRealizedDepartures().size()); diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2DelayAtStopMapDataTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2DelayAtStopMapDataTest.java index 720bf61b615..878dd29fa66 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2DelayAtStopMapDataTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2DelayAtStopMapDataTest.java @@ -1,6 +1,6 @@ package playground.vsp.andreas.bvgAna.level1; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.TransitDriverStartsEvent; @@ -39,7 +39,7 @@ void testVehId2DelayAtStopMapData() { // testing - Assert.assertNotNull(mapData); + Assertions.assertNotNull(mapData); diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2DelayAtStopMapTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2DelayAtStopMapTest.java index 3621a8081cd..83c89e0e04b 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2DelayAtStopMapTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2DelayAtStopMapTest.java @@ -3,7 +3,7 @@ import java.util.LinkedList; import java.util.TreeMap; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.TransitDriverStartsEvent; @@ -92,11 +92,11 @@ void testVehId2DelayAtStopMap() { // testing if first and last entries match - Assert.assertEquals(data.get(vehId1).getFirst().toString(), testMap.getVehId2DelayAtStopMap().get(vehId1).getFirst().toString()); - Assert.assertEquals(data.get(vehId2).getFirst().toString(), testMap.getVehId2DelayAtStopMap().get(vehId2).getFirst().toString()); + Assertions.assertEquals(data.get(vehId1).getFirst().toString(), testMap.getVehId2DelayAtStopMap().get(vehId1).getFirst().toString()); + Assertions.assertEquals(data.get(vehId2).getFirst().toString(), testMap.getVehId2DelayAtStopMap().get(vehId2).getFirst().toString()); - Assert.assertEquals(data.get(vehId1).getLast().toString(), testMap.getVehId2DelayAtStopMap().get(vehId1).getLast().toString()); - Assert.assertEquals(data.get(vehId2).getLast().toString(), testMap.getVehId2DelayAtStopMap().get(vehId2).getLast().toString()); + Assertions.assertEquals(data.get(vehId1).getLast().toString(), testMap.getVehId2DelayAtStopMap().get(vehId1).getLast().toString()); + Assertions.assertEquals(data.get(vehId2).getLast().toString(), testMap.getVehId2DelayAtStopMap().get(vehId2).getLast().toString()); } diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2OccupancyHandlerTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2OccupancyHandlerTest.java index de708843b22..2b368ad22be 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2OccupancyHandlerTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2OccupancyHandlerTest.java @@ -1,8 +1,8 @@ package playground.vsp.andreas.bvgAna.level1; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import playground.vsp.andreas.bvgAna.level1.VehId2OccupancyHandler; @@ -15,7 +15,7 @@ void testVehId2OccupancyHandler() { // to be implemented - Assert.assertNotNull(test); + Assertions.assertNotNull(test); } diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2PersonEnterLeaveVehicleMapTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2PersonEnterLeaveVehicleMapTest.java index 26a36b3e80b..4a2fcc748bd 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2PersonEnterLeaveVehicleMapTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/VehId2PersonEnterLeaveVehicleMapTest.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.TreeMap; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.PersonEntersVehicleEvent; @@ -59,17 +59,17 @@ void testVehId2PersonEnterLeaveVehicleMap() { // test // Assert.assertEquals(enter.get(vehId1).get(0), test.getVehId2PersonEnterEventMap().get(vehId1).get(0)); - Assert.assertEquals(event1.getTime(), test.getVehId2PersonEnterEventMap().get(vehId1).get(0).getTime(), 0.); + Assertions.assertEquals(event1.getTime(), test.getVehId2PersonEnterEventMap().get(vehId1).get(0).getTime(), 0.); // Assert.assertEquals(enter.get(vehId1).get(1), test.getVehId2PersonEnterEventMap().get(vehId1).get(1)); - Assert.assertEquals(event2.getTime(), test.getVehId2PersonEnterEventMap().get(vehId1).get(1).getTime(), 0.); + Assertions.assertEquals(event2.getTime(), test.getVehId2PersonEnterEventMap().get(vehId1).get(1).getTime(), 0.); // Assert.assertEquals(leave.get(vehId2).get(0), test.getVehId2PersonLeaveEventMap().get(vehId2).get(0)); - Assert.assertEquals(event3.getTime(), test.getVehId2PersonLeaveEventMap().get(vehId2).get(0).getTime(), 0.); + Assertions.assertEquals(event3.getTime(), test.getVehId2PersonLeaveEventMap().get(vehId2).get(0).getTime(), 0.); // Assert.assertEquals(leave.get(vehId2).get(1), test.getVehId2PersonLeaveEventMap().get(vehId2).get(1)); - Assert.assertEquals(event4.getTime(), test.getVehId2PersonLeaveEventMap().get(vehId2).get(1).getTime(), 0.); + Assertions.assertEquals(event4.getTime(), test.getVehId2PersonLeaveEventMap().get(vehId2).get(1).getTime(), 0.); diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/osmBB/PTCountsNetworkSimplifierTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/osmBB/PTCountsNetworkSimplifierTest.java index e2eb11c4d0b..d93292adc2e 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/osmBB/PTCountsNetworkSimplifierTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/osmBB/PTCountsNetworkSimplifierTest.java @@ -23,7 +23,7 @@ import java.util.Set; import java.util.TreeSet; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -74,11 +74,11 @@ void testSimplifyEmptyNetwork(){ Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile(outNetwork); - Assert.assertEquals(21, network.getLinks().size()); - Assert.assertEquals(10, network.getNodes().size()); + Assertions.assertEquals(21, network.getLinks().size()); + Assertions.assertEquals(10, network.getNodes().size()); - Assert.assertNull(network.getLinks().get(Id.create("1201_1202", Link.class))); - Assert.assertNull(network.getNodes().get(Id.create("1101", Node.class))); + Assertions.assertNull(network.getLinks().get(Id.create("1201_1202", Link.class))); + Assertions.assertNull(network.getNodes().get(Id.create("1101", Node.class))); } /** @@ -114,15 +114,15 @@ void testSimplifyPTNetwork(){ Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile(outNetwork); - Assert.assertEquals(26, network.getLinks().size()); - Assert.assertEquals(14, network.getNodes().size()); + Assertions.assertEquals(26, network.getLinks().size()); + Assertions.assertEquals(14, network.getNodes().size()); - Assert.assertNotNull(network.getLinks().get(Id.create("1103_1104", Link.class))); - Assert.assertNotNull(network.getLinks().get(Id.create("1203_1204", Link.class))); - Assert.assertNotNull(network.getLinks().get(Id.create("1303_1304", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1103_1104", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1203_1204", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1303_1304", Link.class))); - Assert.assertNull(network.getLinks().get(Id.create("1201_1202", Link.class))); - Assert.assertNull(network.getNodes().get(Id.create("1101", Node.class))); + Assertions.assertNull(network.getLinks().get(Id.create("1201_1202", Link.class))); + Assertions.assertNull(network.getNodes().get(Id.create("1101", Node.class))); } /** @@ -162,13 +162,13 @@ void testSimplifyCountsNetwork(){ Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile(outNetwork); - Assert.assertEquals(23, network.getLinks().size()); - Assert.assertEquals(12, network.getNodes().size()); + Assertions.assertEquals(23, network.getLinks().size()); + Assertions.assertEquals(12, network.getNodes().size()); - Assert.assertNotNull(network.getLinks().get(Id.create("1101_1102", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1101_1102", Link.class))); - Assert.assertNull(network.getLinks().get(Id.create("1103_1104", Link.class))); - Assert.assertNull(network.getNodes().get(Id.create("1103", Node.class))); + Assertions.assertNull(network.getLinks().get(Id.create("1103_1104", Link.class))); + Assertions.assertNull(network.getNodes().get(Id.create("1103", Node.class))); } /** @@ -208,16 +208,16 @@ void testSimplifyPTCountsNetwork(){ Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile(outNetwork); - Assert.assertEquals(28, network.getLinks().size()); - Assert.assertEquals(16, network.getNodes().size()); + Assertions.assertEquals(28, network.getLinks().size()); + Assertions.assertEquals(16, network.getNodes().size()); - Assert.assertNotNull(network.getLinks().get(Id.create("1101_1102", Link.class))); - Assert.assertNotNull(network.getLinks().get(Id.create("1103_1104", Link.class))); - Assert.assertNotNull(network.getLinks().get(Id.create("1203_1204", Link.class))); - Assert.assertNotNull(network.getLinks().get(Id.create("1303_1304", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1101_1102", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1103_1104", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1203_1204", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1303_1304", Link.class))); - Assert.assertNull(network.getLinks().get(Id.create("1201_1202", Link.class))); - Assert.assertNull(network.getNodes().get(Id.create("1201", Node.class))); + Assertions.assertNull(network.getLinks().get(Id.create("1201_1202", Link.class))); + Assertions.assertNull(network.getNodes().get(Id.create("1201", Node.class))); } /** @@ -259,17 +259,17 @@ void testSimplifyElseNetwork(){ Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile(outNetwork); - Assert.assertEquals(29, network.getLinks().size()); - Assert.assertEquals(16, network.getNodes().size()); + Assertions.assertEquals(29, network.getLinks().size()); + Assertions.assertEquals(16, network.getNodes().size()); - Assert.assertNotNull(network.getLinks().get(Id.create("1101_1102", Link.class))); - Assert.assertNotNull(network.getLinks().get(Id.create("1201_1202", Link.class))); - Assert.assertNotNull(network.getLinks().get(Id.create("1301_1302", Link.class))); - Assert.assertNotNull(network.getLinks().get(Id.create("1204_1203", Link.class))); - Assert.assertNotNull(network.getLinks().get(Id.create("1314_1313", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1101_1102", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1201_1202", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1301_1302", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1204_1203", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1314_1313", Link.class))); - Assert.assertNull(network.getLinks().get(Id.create("1103_1104", Link.class))); - Assert.assertNull(network.getNodes().get(Id.create("1103", Node.class))); + Assertions.assertNull(network.getLinks().get(Id.create("1103_1104", Link.class))); + Assertions.assertNull(network.getNodes().get(Id.create("1103", Node.class))); } @@ -315,21 +315,21 @@ void testSimplifyAllNetwork(){ Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile(outNetwork); - Assert.assertEquals(32, network.getLinks().size()); - Assert.assertEquals(18, network.getNodes().size()); + Assertions.assertEquals(32, network.getLinks().size()); + Assertions.assertEquals(18, network.getNodes().size()); - Assert.assertNotNull(network.getLinks().get(Id.create("1101_1102", Link.class))); - Assert.assertNotNull(network.getLinks().get(Id.create("1103_1104", Link.class))); - Assert.assertNotNull(network.getLinks().get(Id.create("1203_1204", Link.class))); - Assert.assertNotNull(network.getLinks().get(Id.create("1303_1304", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1101_1102", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1103_1104", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1203_1204", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1303_1304", Link.class))); - Assert.assertNotNull(network.getLinks().get(Id.create("1101_1102", Link.class))); - Assert.assertNotNull(network.getLinks().get(Id.create("1201_1202", Link.class))); - Assert.assertNotNull(network.getLinks().get(Id.create("1301_1302", Link.class))); - Assert.assertNotNull(network.getLinks().get(Id.create("1204_1203", Link.class))); - Assert.assertNotNull(network.getLinks().get(Id.create("1314_1313", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1101_1102", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1201_1202", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1301_1302", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1204_1203", Link.class))); + Assertions.assertNotNull(network.getLinks().get(Id.create("1314_1313", Link.class))); - Assert.assertNull(network.getLinks().get(Id.create("1202_1201", Link.class))); + Assertions.assertNull(network.getLinks().get(Id.create("1202_1201", Link.class))); } } diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java index 104fcd8f336..64755202e05 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java @@ -38,8 +38,8 @@ import jakarta.inject.Inject; import java.util.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; @RunWith(Parameterized.class) public class ModalDistanceAndCountsCadytsIT { @@ -349,8 +349,8 @@ public ScoringFunction createNewScoringFunction(Person person) { assertEquals(400, modalDistanceCount.get("bike_2050.0"), 80); assertEquals(400, modalDistanceCount.get("bike_2150.0"), 80); } else if (this.modalDistanceWeight == 0 && this.countsWeight > 0) { - assertTrue("expected more than 500 car trips on the long route but the number of trips was " + modalDistanceCount.get("car_2250.0"), - modalDistanceCount.get("car_2250.0") > 500); // don't know. one would assume a stronger impact when only running the cadyts count correction but there isn't + assertTrue(modalDistanceCount.get("car_2250.0") > 500, + "expected more than 500 car trips on the long route but the number of trips was " + modalDistanceCount.get("car_2250.0")); // don't know. one would assume a stronger impact when only running the cadyts count correction but there isn't } else if (this.modalDistanceWeight > 0 && this.countsWeight > 0) { /* This assumes that counts have a higher impact than distance distributions * (because counts request 1000 on car_2250 and the distance distribution requests 100 on car_2050 and car_2150 but 0 on car_2250). diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java index 90a70f545a2..796380440ad 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java @@ -34,13 +34,13 @@ import org.matsim.vehicles.VehicleType; import jakarta.inject.Inject; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import static org.junit.Assert.assertEquals; - public class ModalDistanceCadytsMultipleDistancesIT { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java index c2dfaf70610..2a7f0fdc897 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java @@ -48,13 +48,13 @@ import org.matsim.vehicles.VehicleType; import jakarta.inject.Inject; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; import java.util.HashSet; import java.util.Map; import java.util.stream.Collectors; -import static org.junit.Assert.assertEquals; - public class ModalDistanceCadytsSingleDistanceIT { @RegisterExtension diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java index 8cccb793c66..70ee30d5232 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java @@ -23,8 +23,8 @@ import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; public class TripEventHandlerTest { diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java b/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java index 12089da0739..23a66584d87 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java @@ -27,8 +27,7 @@ import jakarta.inject.Inject; import jakarta.inject.Provider; - -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -104,7 +103,7 @@ final void test0a(){ activity1.setEndTime(16 * 3600.); double delay1 = 0 * 3600.; double activityDelayDisutility1 = marginaSumScoringFunction.getNormalActivityDelayDisutility(activity1, delay1); - Assert.assertEquals("Wrong disutility from starting an activity with a delay (arriving later at the activity location).", 0., activityDelayDisutility1, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0., activityDelayDisutility1, MatsimTestUtils.EPSILON, "Wrong disutility from starting an activity with a delay (arriving later at the activity location)."); // test if a delay results in zero activity delay disutility if the agent would have arrived to late at the activity location anyway Activity activity2 = PopulationUtils.createActivityFromLinkId("work", linkId); @@ -112,7 +111,7 @@ final void test0a(){ activity2.setEndTime(20 * 3600.); double delay2 = 0.5 * 3600.; double activityDelayDisutility2 = marginaSumScoringFunction.getNormalActivityDelayDisutility(activity2, delay2); - Assert.assertEquals("Wrong disutility from starting an activity with a delay (arriving later at the activity location).", 0., activityDelayDisutility2, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0., activityDelayDisutility2, MatsimTestUtils.EPSILON, "Wrong disutility from starting an activity with a delay (arriving later at the activity location)."); // test if a delay results in zero activity delay disutility if the agent would have arrived to early at the activity location anyway Activity activity3 = PopulationUtils.createActivityFromLinkId("work", linkId); @@ -120,7 +119,7 @@ final void test0a(){ activity3.setEndTime(5 * 3600.); double delay3 = 0.5 * 3600.; double activityDelayDisutility3 = marginaSumScoringFunction.getNormalActivityDelayDisutility(activity3, delay3); - Assert.assertEquals("Wrong disutility from starting an activity with a delay (arriving later at the activity location).", 0., activityDelayDisutility3, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0., activityDelayDisutility3, MatsimTestUtils.EPSILON, "Wrong disutility from starting an activity with a delay (arriving later at the activity location)."); // test if a delay results in the right activity delay disutility if the agent would have had more time to perform the activity Activity activity4 = PopulationUtils.createActivityFromLinkId("work", linkId); @@ -130,13 +129,13 @@ final void test0a(){ double activityDelayDisutility4 = marginaSumScoringFunction.getNormalActivityDelayDisutility(activity4, delay4); // 6 hours --> 65.549424473781 utils // 5 hours --> 60 utils - Assert.assertEquals("Wrong disutility from starting an activity with a delay (arriving later at the activity location).", 5.549424473781310, activityDelayDisutility4, MatsimTestUtils.EPSILON); + Assertions.assertEquals(5.549424473781310, activityDelayDisutility4, MatsimTestUtils.EPSILON, "Wrong disutility from starting an activity with a delay (arriving later at the activity location)."); // repeat the previous test: test if a delay results in the right activity delay disutility if the agent would have had more time to perform the activity double activityDelayDisutility4b = marginaSumScoringFunction.getNormalActivityDelayDisutility(activity4, delay4); // 6 hours --> 65.549424473781 utils // 5 hours --> 60 utils - Assert.assertEquals("Wrong disutility from starting an activity with a delay (arriving later at the activity location).", 5.549424473781310, activityDelayDisutility4b, MatsimTestUtils.EPSILON); + Assertions.assertEquals(5.549424473781310, activityDelayDisutility4b, MatsimTestUtils.EPSILON, "Wrong disutility from starting an activity with a delay (arriving later at the activity location)."); } // test overnight activities with first and last activity of the same type @@ -171,20 +170,20 @@ final void test0b(){ double activityDelayDisutility1 = marginaSumScoringFunction.getOvernightActivityDelayDisutility(activity1, activity2, delay1); // 6 + 7 hours --> 65.763074952494600 utils // 6 + 7 hours --> 65.763074952494600 utils - Assert.assertEquals("Wrong disutility from starting an activity with a delay (arriving later at the activity location).", 0., activityDelayDisutility1, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0., activityDelayDisutility1, MatsimTestUtils.EPSILON, "Wrong disutility from starting an activity with a delay (arriving later at the activity location)."); // test if a delay results in the right activity delay disutility double delay2 = 1 * 3600.; double activityDelayDisutility2 = marginaSumScoringFunction.getOvernightActivityDelayDisutility(activity1, activity2, delay2); // 6 + 7 hours --> 65.763074952494600 utils // 7 + 7 hours --> 71.098848947562600 utils - Assert.assertEquals("Wrong disutility from starting an activity with a delay (arriving later at the activity location).", 5.335773995067980, activityDelayDisutility2, MatsimTestUtils.EPSILON); + Assertions.assertEquals(5.335773995067980, activityDelayDisutility2, MatsimTestUtils.EPSILON, "Wrong disutility from starting an activity with a delay (arriving later at the activity location)."); // repeat the previous test: test if a delay results in the right activity delay disutility double activityDelayDisutility2b = marginaSumScoringFunction.getOvernightActivityDelayDisutility(activity1, activity2, delay2); // 6 + 7 hours --> 65.763074952494600 utils // 7 + 7 hours --> 71.098848947562600 utils - Assert.assertEquals("Wrong disutility from starting an activity with a delay (arriving later at the activity location).", 5.335773995067980, activityDelayDisutility2b, MatsimTestUtils.EPSILON); + Assertions.assertEquals(5.335773995067980, activityDelayDisutility2b, MatsimTestUtils.EPSILON, "Wrong disutility from starting an activity with a delay (arriving later at the activity location)."); } // test overnight activities with first and last activity of different types @@ -224,14 +223,14 @@ final void test0c(){ double activityDelayDisutility1 = marginaSumScoringFunction.getOvernightActivityDelayDisutility(activity1, activity2, delay1); // 6 --> 10.0934029996839 utils + 7 --> 21.1922519472465 utils = 31.285654946930 utils // 6 --> 10.0934029996839 utils + 7 --> 21.1922519472465 utils = 31.285654946930 utils - Assert.assertEquals("Wrong disutility from starting an activity with a delay (arriving later at the activity location).", 0., activityDelayDisutility1, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0., activityDelayDisutility1, MatsimTestUtils.EPSILON, "Wrong disutility from starting an activity with a delay (arriving later at the activity location)."); // test if a delay results in the right activity delay disutility double delay2 = 1 * 3600.; double activityDelayDisutility2 = marginaSumScoringFunction.getOvernightActivityDelayDisutility(activity1, activity2, delay2); // 6 --> 10.0934029996839 utils + 7 --> 21.1922519472465 utils = 31.285654946930 utils // 7 --> 21.1922519472465 utils + 7 --> 21.1922519472465 utils = 42.3845038944931 utils - Assert.assertEquals("Wrong disutility from starting an activity with a delay (arriving later at the activity location).", 11.0988489475631, activityDelayDisutility2, MatsimTestUtils.EPSILON); + Assertions.assertEquals(11.0988489475631, activityDelayDisutility2, MatsimTestUtils.EPSILON, "Wrong disutility from starting an activity with a delay (arriving later at the activity location)."); } // test if the delayed arrival at a normal activity (not the first or last activity) results in the right monetary amount @@ -300,12 +299,12 @@ public ControlerListener get() { controler.run(); // test if there is only one congestion event and only one money event - Assert.assertEquals("Wrong number of congestion events.", 1, congestionEvents.size()); - Assert.assertEquals("Wrong number of money events.", 1, moneyEvents.size()); + Assertions.assertEquals(1, congestionEvents.size(), "Wrong number of congestion events."); + Assertions.assertEquals(1, moneyEvents.size(), "Wrong number of money events."); // test if the delay is 2 seconds double delay = congestionEvents.get(0).getDelay(); - Assert.assertEquals("Wrong delay.", 2.0, delay, MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, delay, MatsimTestUtils.EPSILON, "Wrong delay."); double amountFromEvent = moneyEvents.get(0).getAmount(); double tripDelayDisutility = delay / 3600. * controler.getConfig().scoring().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() * (-1); @@ -313,7 +312,7 @@ public ControlerListener get() { // without delay --> 70.573360291244900 double activityDelayDisutility = 70.573360291244900 - 70.570685898554200; double amount = (-1) * (activityDelayDisutility + tripDelayDisutility) / controler.getConfig().scoring().getMarginalUtilityOfMoney(); - Assert.assertEquals("Wrong amount.", amount, amountFromEvent, MatsimTestUtils.EPSILON); + Assertions.assertEquals(amount, amountFromEvent, MatsimTestUtils.EPSILON, "Wrong amount."); } // test if a delayed arrival at the last activity results in the right monetary amount @@ -380,12 +379,12 @@ public ControlerListener get() { controler.run(); // test if there is only one congestion event and only one money event - Assert.assertEquals("Wrong number of congestion events.", 1, congestionEvents.size()); - Assert.assertEquals("Wrong number of money events.", 1, moneyEvents.size()); + Assertions.assertEquals(1, congestionEvents.size(), "Wrong number of congestion events."); + Assertions.assertEquals(1, moneyEvents.size(), "Wrong number of money events."); // test if the delay is 2 seconds double delay = congestionEvents.get(0).getDelay(); - Assert.assertEquals("Wrong delay.", 2.0, delay, MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, delay, MatsimTestUtils.EPSILON, "Wrong delay."); double amountFromEvent = moneyEvents.get(0).getAmount(); double tripDelayDisutility = delay / 3600. * controler.getConfig().scoring().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() * (-1); @@ -399,7 +398,7 @@ public ControlerListener get() { double activityDelayDisutility = 80.584243964094500 - 80.581739442040600; double amount = (-1) * (activityDelayDisutility + tripDelayDisutility) / controler.getConfig().scoring().getMarginalUtilityOfMoney(); - Assert.assertEquals("Wrong amount.", amount, amountFromEvent, MatsimTestUtils.EPSILON); + Assertions.assertEquals(amount, amountFromEvent, MatsimTestUtils.EPSILON, "Wrong amount."); } // test if the right number of money events are thrown @@ -466,8 +465,8 @@ public ControlerListener get() { controler.run(); // test if there are three congestion events and three money events - Assert.assertEquals("Wrong number of congestion events.", 3, congestionEvents.size()); - Assert.assertEquals("Wrong number of money events.", 3, moneyEvents.size()); + Assertions.assertEquals(3, congestionEvents.size(), "Wrong number of congestion events."); + Assertions.assertEquals(3, moneyEvents.size(), "Wrong number of money events."); } // test if the right number of money events are thrown @@ -534,7 +533,7 @@ public ControlerListener get() { controler.run(); // test if there are three congestion events and three money events - Assert.assertEquals("Wrong number of congestion events.", 3, congestionEvents.size()); - Assert.assertEquals("Wrong number of money events.", 3, moneyEvents.size()); + Assertions.assertEquals(3, congestionEvents.size(), "Wrong number of congestion events."); + Assertions.assertEquals(3, moneyEvents.size(), "Wrong number of money events."); } } diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/CombinedFlowAndStorageDelayTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/CombinedFlowAndStorageDelayTest.java index a7406ecae28..755df67d97d 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/CombinedFlowAndStorageDelayTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/CombinedFlowAndStorageDelayTest.java @@ -21,7 +21,7 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -85,12 +85,12 @@ final void implV4Test(){ for(CongestionEvent e : congestionEvents){ if(e.getAffectedAgentId().equals(Id.createPersonId("2")) && e.getCausingAgentId().equals(Id.createPersonId("1"))){ - Assert.assertEquals("Delay caused by agent 2 is not correct.", 100, e.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(100, e.getDelay(), MatsimTestUtils.EPSILON, "Delay caused by agent 2 is not correct."); // this is not captured by only leaving agents list. } } - Assert.assertEquals("Number of congestion events are not correct.", 4, congestionEvents.size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(4, congestionEvents.size(), MatsimTestUtils.EPSILON, "Number of congestion events are not correct."); } // @Test @@ -104,11 +104,11 @@ public final void implV6Test(){ for(CongestionEvent e : congestionEvents){ if(e.getAffectedAgentId().equals(Id.createPersonId("2")) && e.getLinkId().equals(Id.createLinkId("2"))){ - Assert.assertEquals("Wrong causing agent", Id.createPersonId("1"), e.getCausingAgentId()); + Assertions.assertEquals(Id.createPersonId("1"), e.getCausingAgentId(), "Wrong causing agent"); // this is not captured by only leaving agents list. } } - Assert.assertEquals("Number of congestion events are not correct.", 3, congestionEvents.size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, congestionEvents.size(), MatsimTestUtils.EPSILON, "Number of congestion events are not correct."); } private List getAffectedPersonId2Delays(String congestionPricingImpl){ diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/CorridorNetworkTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/CorridorNetworkTest.java index e583e5441de..ae8f04f18a4 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/CorridorNetworkTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/CorridorNetworkTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -71,24 +71,24 @@ void v3Test(){ List v3_events = getCongestionEvents("v3", sc); - Assert.assertEquals("wrong number of congestion events", 6, v3_events.size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(6, v3_events.size(), MatsimTestUtils.EPSILON, "wrong number of congestion events"); for ( CongestionEvent event : v3_events ){ if(event.getAffectedAgentId().equals(Id.createPersonId(2))){ // agent 2 is delayed on link 2 (bottleneck link) due to agent 1 - Assert.assertEquals("wrong causing agent", "1", event.getCausingAgentId().toString()); - Assert.assertEquals("wrong delay", 3, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals("1", event.getCausingAgentId().toString(), "wrong causing agent"); + Assertions.assertEquals(3, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } else if ( event.getAffectedAgentId().equals(Id.createPersonId(3)) ) { // agent 3 is delayed on link 2 due to agent 2, 1 if(event.getCausingAgentId().equals(Id.createPersonId(2))) { - Assert.assertEquals("wrong delay", 4, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(4, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } else { - Assert.assertEquals("wrong delay", 2, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } @@ -96,16 +96,16 @@ void v3Test(){ if(event.getCausingAgentId().equals(Id.createPersonId(3))){ - Assert.assertEquals("wrong delay", 4, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(4, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } else if (event.getCausingAgentId().equals(Id.createPersonId(2))){ - Assert.assertEquals("wrong delay", 4, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(4, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } else { - Assert.assertEquals("wrong causing agent", "1", event.getCausingAgentId().toString()); - Assert.assertEquals("wrong delay", 1, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals("1", event.getCausingAgentId().toString(), "wrong causing agent"); + Assertions.assertEquals(1, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } } } @@ -118,24 +118,24 @@ void v4Test(){ List v4_events = getCongestionEvents("v4", sc); - Assert.assertEquals("wrong number of congestion events", 6, v4_events.size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(6, v4_events.size(), MatsimTestUtils.EPSILON, "wrong number of congestion events"); for ( CongestionEvent event : v4_events ){ if(event.getAffectedAgentId().equals(Id.createPersonId(2))){ // agent 2 is delayed on link 2 (bottleneck link) due to agent 1 - Assert.assertEquals("wrong causing agent", "1", event.getCausingAgentId().toString()); - Assert.assertEquals("wrong delay", 3, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals("1", event.getCausingAgentId().toString(), "wrong causing agent"); + Assertions.assertEquals(3, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } else if ( event.getAffectedAgentId().equals(Id.createPersonId(3)) ) { // agent 3 is delayed on link 2 due to agent 2, 1 if(event.getCausingAgentId().equals(Id.createPersonId(2))) { - Assert.assertEquals("wrong delay", 4, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(4, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } else { - Assert.assertEquals("wrong delay", 2, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } @@ -144,19 +144,19 @@ void v4Test(){ if(event.getCausingAgentId().equals(Id.createPersonId(3)) ){ if ( event.getTime() == 10.0 ) { - Assert.assertEquals("wrong delay", 3, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } else { - Assert.assertEquals("wrong congestion event time", 18.0, event.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong delay", 4, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(18.0, event.getTime(), MatsimTestUtils.EPSILON, "wrong congestion event time"); + Assertions.assertEquals(4, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } } else { - Assert.assertEquals("wrong causing agent", "2", event.getCausingAgentId().toString()); - Assert.assertEquals("wrong delay", 2, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals("2", event.getCausingAgentId().toString(), "wrong causing agent"); + Assertions.assertEquals(2, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } } diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowQueueQsimTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowQueueQsimTest.java index b34e2adbf6d..94c1f09f388 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowQueueQsimTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowQueueQsimTest.java @@ -27,7 +27,7 @@ import java.util.List; import java.util.Set; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -128,11 +128,11 @@ public void handleEvent(CongestionEvent event) { sim.run(); for (CongestionEvent event : congestionEvents) { - Assert.assertEquals("here the delay should be equal to the inverse of the flow capacity", 3., event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3., event.getDelay(), MatsimTestUtils.EPSILON, "here the delay should be equal to the inverse of the flow capacity"); } - Assert.assertEquals("wrong total delay", 9., congestionHandler.getTotalDelay(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong total internalized delay", 9., congestionHandler.getTotalInternalizedDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(9., congestionHandler.getTotalDelay(), MatsimTestUtils.EPSILON, "wrong total delay"); + Assertions.assertEquals(9., congestionHandler.getTotalInternalizedDelay(), MatsimTestUtils.EPSILON, "wrong total internalized delay"); } @@ -168,23 +168,23 @@ public void handleEvent(CongestionEvent event) { for (CongestionEvent event : congestionEvents) { if (event.getCausingAgentId().toString().equals("agentC") && event.getAffectedAgentId().toString().equals("agentB")) { - Assert.assertEquals("wrong delay", 3., event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3., event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } if (event.getCausingAgentId().toString().equals("agentC") && event.getAffectedAgentId().toString().equals("agentA")) { - Assert.assertEquals("wrong delay", 6., event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(6., event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } if (event.getCausingAgentId().toString().equals("agentB") && event.getAffectedAgentId().toString().equals("agentA")) { - Assert.assertEquals("wrong delay", 6., event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(6., event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } } - Assert.assertEquals("wrong total delay", 9., congestionHandler.getTotalDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(9., congestionHandler.getTotalDelay(), MatsimTestUtils.EPSILON, "wrong total delay"); // the second agent is 3 sec delayed and charges the first agent with these 3 sec // the third agent is 6 sec delayed and charges the first and the second agent with each 6 sec - Assert.assertEquals("wrong total internalized delay", 15., congestionHandler.getTotalInternalizedDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(15., congestionHandler.getTotalInternalizedDelay(), MatsimTestUtils.EPSILON, "wrong total internalized delay"); } /** @@ -219,23 +219,23 @@ public void handleEvent(CongestionEvent event) { for (CongestionEvent event : congestionEvents) { if (event.getCausingAgentId().toString().equals("agentC") && event.getAffectedAgentId().toString().equals("agentB")) { - Assert.assertEquals("wrong delay", 3., event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3., event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } if (event.getCausingAgentId().toString().equals("agentC") && event.getAffectedAgentId().toString().equals("agentA")) { - Assert.assertEquals("wrong delay", 3., event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3., event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } if (event.getCausingAgentId().toString().equals("agentB") && event.getAffectedAgentId().toString().equals("agentA")) { - Assert.assertEquals("wrong delay", 3., event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3., event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay"); } } - Assert.assertEquals("wrong total delay", 9., congestionHandler.getTotalDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(9., congestionHandler.getTotalDelay(), MatsimTestUtils.EPSILON, "wrong total delay"); // the second agent is 3 sec delayed and charges the first agent with these 3 sec // the third agent is 6 sec delayed and charges the first and the second agent with each 6 sec - Assert.assertEquals("wrong total internalized delay", 9., congestionHandler.getTotalInternalizedDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(9., congestionHandler.getTotalInternalizedDelay(), MatsimTestUtils.EPSILON, "wrong total internalized delay"); } private void setPopulation1(Scenario scenario) { diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java index 3029eda9921..c2f58a3cc25 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java @@ -32,8 +32,8 @@ import jakarta.inject.Inject; import jakarta.inject.Provider; -import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -162,11 +162,11 @@ public void handleEvent(CongestionEvent event) { System.out.println(event.toString()); if (event.getCausingAgentId().toString().equals(this.testAgent1.toString()) && event.getAffectedAgentId().toString().equals(this.testAgent2.toString())) { - Assert.assertEquals("wrong delay.", 10.0, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10.0, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay."); } else if ((event.getCausingAgentId().toString().equals(this.testAgent2.toString())) && (event.getAffectedAgentId().toString().equals(this.testAgent3.toString())) && (event.getTime() == 116.0)) { - Assert.assertEquals("wrong delay.", 10.0, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10.0, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay."); } else if ((event.getCausingAgentId().toString().equals(this.testAgent1.toString())) && (event.getAffectedAgentId().toString().equals(this.testAgent3.toString())) && (event.getTime() == 126.0)) { - Assert.assertEquals("wrong delay.", 9.0, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(9.0, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay."); } } @@ -210,7 +210,7 @@ public void handleEvent(CongestionEvent event) { System.out.println(event.toString()); totalDelay += event.getDelay(); } - Assert.assertEquals("wrong total delay.", 50.0, totalDelay, MatsimTestUtils.EPSILON); + Assertions.assertEquals(50.0, totalDelay, MatsimTestUtils.EPSILON, "wrong total delay."); } @@ -251,7 +251,7 @@ public void handleEvent(CongestionEvent event) { System.out.println(event.toString()); totalDelay += event.getDelay(); } - Assert.assertEquals("wrong total delay.", 30.0, totalDelay, MatsimTestUtils.EPSILON); + Assertions.assertEquals(30.0, totalDelay, MatsimTestUtils.EPSILON, "wrong total delay."); } @@ -292,7 +292,7 @@ public void handleEvent(CongestionEvent event) { System.out.println(event.toString()); totalDelay += event.getDelay(); } - Assert.assertEquals("wrong total delay.", 32.0, totalDelay, MatsimTestUtils.EPSILON); + Assertions.assertEquals(32.0, totalDelay, MatsimTestUtils.EPSILON, "wrong total delay."); } @@ -424,10 +424,10 @@ else if(((event.getServices().getConfig().controller().getLastIteration())-(even controler.run(); { // controlling and showing the conditions of the test: - Assert.assertEquals("entering agents in timeBin1.", 3.0, enterCounter.get(timeBin1), MatsimTestUtils.EPSILON); - Assert.assertEquals("entering agents in timeBin2.", 3.0, enterCounter.get(timeBin2), MatsimTestUtils.EPSILON); - Assert.assertEquals("leaving agents in timeBin1.", 1.0, leaveCounter.get(timeBin1), MatsimTestUtils.EPSILON); - Assert.assertEquals("leaving agents in timeBin1.", 5.0, leaveCounter.get(timeBin2), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3.0, enterCounter.get(timeBin1), MatsimTestUtils.EPSILON, "entering agents in timeBin1."); + Assertions.assertEquals(3.0, enterCounter.get(timeBin2), MatsimTestUtils.EPSILON, "entering agents in timeBin2."); + Assertions.assertEquals(1.0, leaveCounter.get(timeBin1), MatsimTestUtils.EPSILON, "leaving agents in timeBin1."); + Assertions.assertEquals(5.0, leaveCounter.get(timeBin2), MatsimTestUtils.EPSILON, "leaving agents in timeBin1."); } // for both time-bins ("28800-29700" and "29700-30600") @@ -436,15 +436,15 @@ else if(((event.getServices().getConfig().controller().getLastIteration())-(even // the congestion effects of each 3 cars are the same, // the fact that 2 of the first 3 cars leave the link in the next time-bin should be irrelevant - Assert.assertEquals("avgValue1 == avgValue2", avgValue1, avgValue2, MatsimTestUtils.EPSILON); - Assert.assertEquals("avgValue3 == avgValue3", avgValue3, avgValue4, MatsimTestUtils.EPSILON); - Assert.assertEquals("avgValue1 == avgValue3", avgValue1, avgValue3, MatsimTestUtils.EPSILON); + Assertions.assertEquals(avgValue1, avgValue2, MatsimTestUtils.EPSILON, "avgValue1 == avgValue2"); + Assertions.assertEquals(avgValue3, avgValue4, MatsimTestUtils.EPSILON, "avgValue3 == avgValue3"); + Assertions.assertEquals(avgValue1, avgValue3, MatsimTestUtils.EPSILON, "avgValue1 == avgValue3"); - Assert.assertEquals("avgOldValue1 == avgOldValue2", avgOldValue1, avgOldValue2, MatsimTestUtils.EPSILON); - Assert.assertEquals("avgOldValue3 == avgOldValue3", avgOldValue3, avgOldValue4, MatsimTestUtils.EPSILON); - Assert.assertEquals("avgOldValue1 == avgOldValue3", avgOldValue1, avgOldValue3, MatsimTestUtils.EPSILON); + Assertions.assertEquals(avgOldValue1, avgOldValue2, MatsimTestUtils.EPSILON, "avgOldValue1 == avgOldValue2"); + Assertions.assertEquals(avgOldValue3, avgOldValue4, MatsimTestUtils.EPSILON, "avgOldValue3 == avgOldValue3"); + Assertions.assertEquals(avgOldValue1, avgOldValue3, MatsimTestUtils.EPSILON, "avgOldValue1 == avgOldValue3"); - Assert.assertEquals("avgValue1 == avgOldValue1", avgValue1, avgOldValue1, MatsimTestUtils.EPSILON); + Assertions.assertEquals(avgValue1, avgOldValue1, MatsimTestUtils.EPSILON, "avgValue1 == avgOldValue1"); } @@ -493,15 +493,15 @@ public void handleEvent(LinkLeaveEvent event) { } - Assert.assertEquals("numberOfCongestionEvents", congestionEvents.size(), 3, MatsimTestUtils.EPSILON); + Assertions.assertEquals(congestionEvents.size(), 3, MatsimTestUtils.EPSILON, "numberOfCongestionEvents"); for(CongestionEvent mce : congestionEvents){ if((mce.getCausingAgentId().equals(testAgent1))&&(mce.getAffectedAgentId().equals(testAgent2))){ - Assert.assertEquals("delay", 10., mce.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10., mce.getDelay(), MatsimTestUtils.EPSILON, "delay"); }else if((mce.getCausingAgentId().equals(testAgent2))&&(mce.getAffectedAgentId().equals(testAgent3))){ - Assert.assertEquals("delay", 10., mce.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10., mce.getDelay(), MatsimTestUtils.EPSILON, "delay"); }else if((mce.getCausingAgentId().equals(testAgent1))&&(mce.getAffectedAgentId().equals(testAgent3))){ - Assert.assertEquals("delay", 4., mce.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(4., mce.getDelay(), MatsimTestUtils.EPSILON, "delay"); } } } @@ -552,15 +552,15 @@ public void handleEvent(LinkLeaveEvent event) { } - Assert.assertEquals("numberOfCongestionEvents", congestionEvents.size(), 3, MatsimTestUtils.EPSILON); + Assertions.assertEquals(congestionEvents.size(), 3, MatsimTestUtils.EPSILON, "numberOfCongestionEvents"); for(CongestionEvent mce : congestionEvents){ if((mce.getCausingAgentId().equals(testAgent1))&&(mce.getAffectedAgentId().equals(testAgent3))){ - Assert.assertEquals("delay", 4., mce.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(4., mce.getDelay(), MatsimTestUtils.EPSILON, "delay"); }else if((mce.getCausingAgentId().equals(testAgent3))&&(mce.getAffectedAgentId().equals(testAgent2))){ - Assert.assertEquals("delay", 10., mce.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10., mce.getDelay(), MatsimTestUtils.EPSILON, "delay"); }else if((mce.getCausingAgentId().equals(testAgent1))&&(mce.getAffectedAgentId().equals(testAgent2))){ - Assert.assertEquals("delay", 10., mce.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10., mce.getDelay(), MatsimTestUtils.EPSILON, "delay"); } } @@ -613,15 +613,15 @@ public void handleEvent(LinkLeaveEvent event) { } - Assert.assertEquals("numberOfCongestionEvents", congestionEvents.size(), 3, MatsimTestUtils.EPSILON); + Assertions.assertEquals(congestionEvents.size(), 3, MatsimTestUtils.EPSILON, "numberOfCongestionEvents"); for(CongestionEvent mce : congestionEvents){ if((mce.getCausingAgentId().equals(testAgent1))&&(mce.getAffectedAgentId().equals(testAgent2))){ - Assert.assertEquals("delay", 5., mce.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(5., mce.getDelay(), MatsimTestUtils.EPSILON, "delay"); }else if((mce.getCausingAgentId().equals(testAgent2))&&(mce.getAffectedAgentId().equals(testAgent3))){ - Assert.assertEquals("delay", 10., mce.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10., mce.getDelay(), MatsimTestUtils.EPSILON, "delay"); }else if((mce.getCausingAgentId().equals(testAgent1))&&(mce.getAffectedAgentId().equals(testAgent3))){ - Assert.assertEquals("delay", 8., mce.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(8., mce.getDelay(), MatsimTestUtils.EPSILON, "delay"); } } @@ -682,11 +682,11 @@ public void handleEvent(LinkEnterEvent event) { System.out.println(event.toString()); if (event.getCausingAgentId().toString().equals(this.testAgent1.toString()) && event.getAffectedAgentId().toString().equals(this.testAgent2.toString())) { - Assert.assertEquals("wrong delay.", 10.0, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10.0, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay."); } else if ((event.getCausingAgentId().toString().equals(this.testAgent2.toString())) && (event.getAffectedAgentId().toString().equals(this.testAgent3.toString())) && (event.getTime() == 116.0)) { - Assert.assertEquals("wrong delay.", 10.0, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10.0, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay."); } else if ((event.getCausingAgentId().toString().equals(this.testAgent1.toString())) && (event.getAffectedAgentId().toString().equals(this.testAgent3.toString())) && (event.getTime() == 126.0)) { - Assert.assertEquals("wrong delay.", 9.0, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(9.0, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay."); } } diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java index c43f9c44301..1f70380e3de 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java @@ -29,8 +29,7 @@ import jakarta.inject.Inject; import jakarta.inject.Provider; - -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -138,11 +137,11 @@ public void install() { double outflowRate = 3.; // 1200 veh / h --> 1 veh every 3 sec double inflowRate = 1.; // 1 veh every 1 sec int demand = 20; - Assert.assertEquals("wrong total delay", (outflowRate - inflowRate) * (demand * demand - demand) / 2, totalDelay, MatsimTestUtils.EPSILON); + Assertions.assertEquals((outflowRate - inflowRate) * (demand * demand - demand) / 2, totalDelay, MatsimTestUtils.EPSILON, "wrong total delay"); // assert - Assert.assertEquals("wrong values for testAgent7", 38.0, personId2causedDelay.get(Id.create("testAgent7", Person.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong values for testAgent7", 12.0, personId2affectedDelay.get(Id.create("testAgent7", Person.class)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(38.0, personId2causedDelay.get(Id.create("testAgent7", Person.class)), MatsimTestUtils.EPSILON, "wrong values for testAgent7"); + Assertions.assertEquals(12.0, personId2affectedDelay.get(Id.create("testAgent7", Person.class)), MatsimTestUtils.EPSILON, "wrong values for testAgent7"); // ... } } diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionPricingTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionPricingTest.java index ae8e105e244..a398d462e77 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionPricingTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionPricingTest.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Set; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -104,7 +104,7 @@ public void handleEvent(CongestionEvent event) { PrepareForSimUtils.createDefaultPrepareForSim(sc).run(); new QSimBuilder(sc.getConfig()).useDefaults().build(sc, events).run(); - Assert.assertEquals("wrong number of congestion events" , 15, congestionEvents.size()); + Assertions.assertEquals(15, congestionEvents.size(), "wrong number of congestion events"); Set affectedPersons = new HashSet<>(); Set causingPersons = new HashSet<>(); @@ -127,33 +127,33 @@ public void handleEvent(CongestionEvent event) { if(event.getLinkId().equals(Id.createLinkId("3"))){ if (event.getCausingAgentId().toString().equals("0") && event.getAffectedAgentId().toString().equals("2")) { - Assert.assertEquals("wrong delay.", 8, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(8, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay."); // Assert.assertEquals("wrong delay.", 9, event.getDelay(), MatsimTestUtils.EPSILON);//1 sec change is caused due to the change in the flow accumulation approach (can go to -ive). Amit Jan 17 link3Delays++; } else if (event.getCausingAgentId().toString().equals("2") && event.getAffectedAgentId().toString().equals("4")) { - Assert.assertEquals("wrong delay.", 10, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay."); link3Delays++; } else if (event.getCausingAgentId().toString().equals("0") && event.getAffectedAgentId().toString().equals("4")) { - Assert.assertEquals("wrong delay.", 6, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(6, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay."); // Assert.assertEquals("wrong delay.", 7, event.getDelay(), MatsimTestUtils.EPSILON); link3Delays++; } else if (event.getCausingAgentId().toString().equals("4") && event.getAffectedAgentId().toString().equals("6")) { // delays 10,5 person6Delay+=event.getDelay(); if(repetationPerson6Count>0){ - Assert.assertEquals("wrong delay.", 15, person6Delay, MatsimTestUtils.EPSILON); + Assertions.assertEquals(15, person6Delay, MatsimTestUtils.EPSILON, "wrong delay."); // Assert.assertEquals("wrong delay.", 16, person6Delay, MatsimTestUtils.EPSILON); } repetationPerson6Count++; link3Delays++; } else if (event.getCausingAgentId().toString().equals("2") && event.getAffectedAgentId().toString().equals("6")) { - Assert.assertEquals("wrong delay.", 9, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(9, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay."); link3Delays++; } else if (event.getCausingAgentId().toString().equals("6") && event.getAffectedAgentId().toString().equals("8")) { // delays are 10, 10 person8_6Delay+=event.getDelay(); if(repetationPerson8_6Count>0){ - Assert.assertEquals("wrong delay.", 20, person8_6Delay, MatsimTestUtils.EPSILON); + Assertions.assertEquals(20, person8_6Delay, MatsimTestUtils.EPSILON, "wrong delay."); } repetationPerson8_6Count++; link3Delays++; @@ -161,20 +161,20 @@ public void handleEvent(CongestionEvent event) { // delays are 3,9 person8_4Delay+=event.getDelay(); if(repetationPerson8_4Count>0){ - Assert.assertEquals("wrong delay.", 12, person8_4Delay, MatsimTestUtils.EPSILON); + Assertions.assertEquals(12, person8_4Delay, MatsimTestUtils.EPSILON, "wrong delay."); // Assert.assertEquals("wrong delay.", 13, person8_4Delay, MatsimTestUtils.EPSILON); } repetationPerson8_4Count++; link3Delays++; } else if (event.getCausingAgentId().toString().equals("6") && event.getAffectedAgentId().toString().equals("9")) { - Assert.assertEquals("wrong delay.", 2, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay."); // Assert.assertEquals("wrong delay.", 3, event.getDelay(), MatsimTestUtils.EPSILON); link3Delays++; } else if (event.getCausingAgentId().toString().equals("8") && event.getAffectedAgentId().toString().equals("9")) { - Assert.assertEquals("wrong delay.", 10, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay."); link3Delays++; } else if (event.getCausingAgentId().toString().equals("6") && event.getAffectedAgentId().toString().equals("7")) { - Assert.assertEquals("wrong delay.", 4, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(4, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay."); // Assert.assertEquals("wrong delay.", 5, event.getDelay(), MatsimTestUtils.EPSILON); //1 sec change is caused due to the change in the flow accumulation approach (can go to -ive). Amit Jan 17 link3Delays++; } @@ -182,10 +182,10 @@ public void handleEvent(CongestionEvent event) { } else if(event.getLinkId().equals(Id.createLinkId("2"))){ if (event.getCausingAgentId().toString().equals("6") && event.getAffectedAgentId().toString().equals("7")) { - Assert.assertEquals("wrong delay.", 1, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay."); link2Delays++; } else if (event.getCausingAgentId().toString().equals("8") && event.getAffectedAgentId().toString().equals("9")) { - Assert.assertEquals("wrong delay.", 1, event.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, event.getDelay(), MatsimTestUtils.EPSILON, "wrong delay."); link2Delays++; } @@ -193,15 +193,15 @@ public void handleEvent(CongestionEvent event) { } // affected persons are 2,4,6,8 on link3 and 6,7,8,9 on link 2. - Assert.assertEquals("wrong number of affected persons" , 6, affectedPersons.size()); + Assertions.assertEquals(6, affectedPersons.size(), "wrong number of affected persons"); //causing agents set should not have any one from 1,3,5,7,9 for(int id :causingPersons){ - Assert.assertEquals("Wrong causing person", 0, id%2); + Assertions.assertEquals(0, id%2, "Wrong causing person"); } - Assert.assertEquals("some events are not checked on link 2" , 2, link2Delays); - Assert.assertEquals("some events are not checked on link 3" , 13, link3Delays); + Assertions.assertEquals(2, link2Delays, "some events are not checked on link 2"); + Assertions.assertEquals(13, link3Delays, "some events are not checked on link 3"); } /** diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MultipleSpillbackCausingLinksTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MultipleSpillbackCausingLinksTest.java index ff9518ca966..5ddadecf44c 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MultipleSpillbackCausingLinksTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MultipleSpillbackCausingLinksTest.java @@ -21,7 +21,7 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -87,7 +87,7 @@ final void multipleSpillBackTest(){ for(CongestionEvent e : congestionEvents){ if(e.getAffectedAgentId().equals(Id.createPersonId("2"))&&e.getLinkId().equals(Id.createLinkId("2")) && index ==1){ // first next link in the route is link 2 - Assert.assertEquals("Delay on first next link in the route is not correct.", 9.0, e.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(9.0, e.getDelay(), MatsimTestUtils.EPSILON, "Delay on first next link in the route is not correct."); // Assert.assertEquals("Delay on first next link in the route is not correct.", 10.0, e.getDelay(), MatsimTestUtils.EPSILON); //1 sec change (1 time on link2) is caused due to the change in the flow accumulation approach (can go to -ive). Amit Jan 17 eventTimes.add(e.getTime()); index ++; @@ -98,9 +98,9 @@ final void multipleSpillBackTest(){ // route is link 6 // agent 3 and 4 leave prior to agent 2 during home work (trip3) if(e.getCausingAgentId().equals(Id.createPersonId("3"))){ - Assert.assertEquals("Delay on second next link in the route is not correct.", 10.0, e.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10.0, e.getDelay(), MatsimTestUtils.EPSILON, "Delay on second next link in the route is not correct."); } else if (e.getCausingAgentId().equals(Id.createPersonId("4"))){ - Assert.assertEquals("Delay on second next link in the route is not correct.", 10.0, e.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10.0, e.getDelay(), MatsimTestUtils.EPSILON, "Delay on second next link in the route is not correct."); } eventTimes.add(e.getTime()); index ++; @@ -109,7 +109,7 @@ final void multipleSpillBackTest(){ if(e.getAffectedAgentId().equals(Id.createPersonId("2"))&&e.getLinkId().equals(Id.createLinkId("2")) && index ==4){ // first next link in the route is link 2 // multiple spill back causing link - Assert.assertEquals("Delay on first next link in the route due to multiple spill back is not correct.", 4.0, e.getDelay(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(4.0, e.getDelay(), MatsimTestUtils.EPSILON, "Delay on first next link in the route due to multiple spill back is not correct."); // Assert.assertEquals("Delay on first next link in the route due to multiple spill back is not correct.", 6.0, e.getDelay(), MatsimTestUtils.EPSILON); //1 sec change (two times on link2 and link6) is caused due to the change in the flow accumulation approach (can go to -ive). Amit Jan 17 eventTimes.add(e.getTime()); index ++; @@ -117,10 +117,10 @@ final void multipleSpillBackTest(){ } // now check, for agent 2, first link in the route (trip1) is occur first and rest later time i.e. during index ==1. - Assert.assertFalse("Congestion event for first next link in the route should occur first.", eventTimes.get(0) > eventTimes.get(1)); + Assertions.assertFalse(eventTimes.get(0) > eventTimes.get(1), "Congestion event for first next link in the route should occur first."); // all other congestion event for agent 2 while leaving link 1 should occur at the same time. - Assert.assertFalse("Congestion event for multiple spill back causing links should occur at the same time.", eventTimes.get(1) == eventTimes.get(2) && eventTimes.get(2) == eventTimes.get(3)); + Assertions.assertFalse(eventTimes.get(1) == eventTimes.get(2) && eventTimes.get(2) == eventTimes.get(3), "Congestion event for multiple spill back causing links should occur at the same time."); } diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/TestForEmergenceTime.java b/contribs/vsp/src/test/java/playground/vsp/congestion/TestForEmergenceTime.java index 46cbb7a5ebc..9cdfa5b37b1 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/TestForEmergenceTime.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/TestForEmergenceTime.java @@ -21,7 +21,7 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -72,8 +72,8 @@ final void emergenceTimeTest_v4(){ List congestionEvents = getAffectedPersonId2Delays(impl); for(CongestionEvent event : congestionEvents){ if(event.getCausingAgentId().equals(Id.createPersonId("21"))){ - Assert.assertEquals("wrong emergence time", 8*3600+55, event.getEmergenceTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong linkId", Id.createLinkId("3"), event.getLinkId()); + Assertions.assertEquals(8*3600+55, event.getEmergenceTime(), MatsimTestUtils.EPSILON, "wrong emergence time"); + Assertions.assertEquals(Id.createLinkId("3"), event.getLinkId(), "wrong linkId"); } } } diff --git a/contribs/vsp/src/test/java/playground/vsp/ev/TransferFinalSocToNextIterTest.java b/contribs/vsp/src/test/java/playground/vsp/ev/TransferFinalSocToNextIterTest.java index 28fca80e271..71039834a90 100644 --- a/contribs/vsp/src/test/java/playground/vsp/ev/TransferFinalSocToNextIterTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/ev/TransferFinalSocToNextIterTest.java @@ -23,7 +23,7 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -63,18 +63,18 @@ void test() { controler.run(); // testInitialEnergyInIter0 - Assert.assertEquals(INITIAL_SOC, handler.iterationInitialSOC.get(0), 0.0); + Assertions.assertEquals(INITIAL_SOC, handler.iterationInitialSOC.get(0), 0.0); // testSOCIsDumpedIntoVehicleType //agent has driven the car so SOC should have changed and should be dumped into the vehicle type var vehicle = scenario.getVehicles().getVehicles().get(Id.create("Triple Charger_car", Vehicle.class)); var evSpec = ElectricFleetUtils.createElectricVehicleSpecificationDefaultImpl(vehicle ); - Assert.assertNotEquals(evSpec.getInitialSoc(), INITIAL_SOC); - Assert.assertEquals(0.7273605127621898, evSpec.getInitialSoc(), MatsimTestUtils.EPSILON); //should not be fully charged + Assertions.assertNotEquals(evSpec.getInitialSoc(), INITIAL_SOC); + Assertions.assertEquals(0.7273605127621898, evSpec.getInitialSoc(), MatsimTestUtils.EPSILON); //should not be fully charged // testSOCisTransferredToNextIteration for (int i = 0; i < LAST_ITERATION; i++) { - Assert.assertEquals(handler.iterationEndSOC.get(i), handler.iterationInitialSOC.get(i + 1)); + Assertions.assertEquals(handler.iterationEndSOC.get(i), handler.iterationInitialSOC.get(i + 1)); } } diff --git a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVIT.java b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVIT.java index c267b09bb17..9f470684027 100644 --- a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVIT.java @@ -1,7 +1,7 @@ package playground.vsp.ev; import org.apache.logging.log4j.LogManager; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.population.Population; @@ -37,20 +37,20 @@ void run() { PopulationUtils.readPopulation( actual, utils.getOutputDirectory() + "/output_plans.xml.gz" ); boolean result = PopulationUtils.comparePopulations( expected, actual ); - Assert.assertTrue( result ); + Assertions.assertTrue( result ); } { String expected = utils.getInputDirectory() + "/output_events.xml.gz" ; String actual = utils.getOutputDirectory() + "/output_events.xml.gz" ; EventsFileComparator.Result result = EventsUtils.compareEventsFiles( expected, actual ); - Assert.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result ); + Assertions.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result ); } } catch ( Exception ee ) { LogManager.getLogger(this.getClass() ).fatal("there was an exception: \n" + ee ) ; // if one catches an exception, then one needs to explicitly fail the test: - Assert.fail(); + Assertions.fail(); } diff --git a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java index 2611efa158e..15bd18ad185 100644 --- a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java +++ b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java @@ -6,8 +6,8 @@ import java.util.Map; import java.util.stream.Collectors; -import org.junit.Assert; import org.junit.BeforeClass; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -118,71 +118,71 @@ void testAgentsExecuteSameNumberOfActsAsPlanned() { + " activities"; } } - Assert.assertFalse("the following persons do not execute the same amount of activities as they plan to:" + personsWithDifferingActCount, - fail); + Assertions.assertFalse(fail, + "the following persons do not execute the same amount of activities as they plan to:" + personsWithDifferingActCount); } @Test void testCarAndBikeAgent() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Charge during leisure + bike"), List.of()); - Assert.assertEquals(1, plugins.size(), 0); + Assertions.assertEquals(1, plugins.size(), 0); //charges at during leisure(12)-bike-leisure(13)-bike-leisure(14) ActivityStartEvent pluginActStart2 = plugins.get(0); //agent travels 5 links between precedent work activity which end at 11. each link takes 99 seconds - Assert.assertEquals("wrong charging start time", 11 * 3600 + 5 * 99, pluginActStart2.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging start location", "90", pluginActStart2.getLinkId().toString()); + Assertions.assertEquals(11 * 3600 + 5 * 99, pluginActStart2.getTime(), MatsimTestUtils.EPSILON, "wrong charging start time"); + Assertions.assertEquals("90", pluginActStart2.getLinkId().toString(), "wrong charging start location"); List plugouts = this.handler.plugOutCntPerPerson.getOrDefault(Id.createPersonId("Charge during leisure + bike"), List.of()); - Assert.assertEquals(1, plugouts.size(), 0); + Assertions.assertEquals(1, plugouts.size(), 0); ActivityEndEvent plugoutActStart = plugouts.get(0); - Assert.assertEquals("wrong charging end time", 14 * 3600, plugoutActStart.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging end location", "90", plugoutActStart.getLinkId().toString()); + Assertions.assertEquals(14 * 3600, plugoutActStart.getTime(), MatsimTestUtils.EPSILON, "wrong charging end time"); + Assertions.assertEquals("90", plugoutActStart.getLinkId().toString(), "wrong charging end location"); } @Test void testTripleCharger() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Triple Charger"), List.of()); - Assert.assertEquals(plugins.size(), 3., 0); + Assertions.assertEquals(plugins.size(), 3., 0); ActivityStartEvent pluginActStart = plugins.get(0); - Assert.assertEquals("wrong charging start time", 1490d, pluginActStart.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging start location", "90", pluginActStart.getLinkId().toString()); + Assertions.assertEquals(1490d, pluginActStart.getTime(), MatsimTestUtils.EPSILON, "wrong charging start time"); + Assertions.assertEquals("90", pluginActStart.getLinkId().toString(), "wrong charging start location"); ActivityStartEvent pluginActStart2 = plugins.get(1); - Assert.assertEquals("wrong charging start time", 25580d, pluginActStart2.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging start location", "90", pluginActStart2.getLinkId().toString()); + Assertions.assertEquals(25580d, pluginActStart2.getTime(), MatsimTestUtils.EPSILON, "wrong charging start time"); + Assertions.assertEquals("90", pluginActStart2.getLinkId().toString(), "wrong charging start location"); ActivityStartEvent pluginActStart3 = plugins.get(2); - Assert.assertEquals("wrong charging start time", 45724d, pluginActStart3.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging start location", "95", pluginActStart3.getLinkId().toString()); + Assertions.assertEquals(45724d, pluginActStart3.getTime(), MatsimTestUtils.EPSILON, "wrong charging start time"); + Assertions.assertEquals("95", pluginActStart3.getLinkId().toString(), "wrong charging start location"); List plugouts = this.handler.plugOutCntPerPerson.getOrDefault(Id.createPersonId("Triple Charger"), List.of()); - Assert.assertEquals(plugouts.size(), 2, 0); + Assertions.assertEquals(plugouts.size(), 2, 0); ActivityEndEvent plugoutActStart = plugouts.get(0); - Assert.assertEquals("wrong charging end time", 3179d, plugoutActStart.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging end location", "90", plugoutActStart.getLinkId().toString()); + Assertions.assertEquals(3179d, plugoutActStart.getTime(), MatsimTestUtils.EPSILON, "wrong charging end time"); + Assertions.assertEquals("90", plugoutActStart.getLinkId().toString(), "wrong charging end location"); ActivityEndEvent plugoutActStart2 = plugouts.get(1); - Assert.assertEquals("wrong charging end time", 26608d, plugoutActStart2.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging end location", "90", plugoutActStart2.getLinkId().toString()); + Assertions.assertEquals(26608d, plugoutActStart2.getTime(), MatsimTestUtils.EPSILON, "wrong charging end time"); + Assertions.assertEquals("90", plugoutActStart2.getLinkId().toString(), "wrong charging end location"); } @Test void testChargerSelectionShopping() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Charging during shopping"), List.of()); - Assert.assertEquals(1, plugins.size(), 0); + Assertions.assertEquals(1, plugins.size(), 0); ActivityStartEvent pluginActStart = plugins.get(0); //starts at 10am at work and travels 8 links à 99s - Assert.assertEquals("wrong charging start time", 10 * 3600 + 8 * 99, pluginActStart.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging start location", "172", pluginActStart.getLinkId().toString()); + Assertions.assertEquals(10 * 3600 + 8 * 99, pluginActStart.getTime(), MatsimTestUtils.EPSILON, "wrong charging start time"); + Assertions.assertEquals("172", pluginActStart.getLinkId().toString(), "wrong charging start location"); List plugouts = this.handler.plugOutCntPerPerson.getOrDefault(Id.createPersonId("Charging during shopping"), List.of()); - Assert.assertEquals(1, plugouts.size(), 0); + Assertions.assertEquals(1, plugouts.size(), 0); ActivityEndEvent plugoutActStart = plugouts.get(0); - Assert.assertEquals("wrong charging end time", 11 * 3600 + 23 * 60 + 27, plugoutActStart.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging end location", "172", plugoutActStart.getLinkId().toString()); + Assertions.assertEquals(11 * 3600 + 23 * 60 + 27, plugoutActStart.getTime(), MatsimTestUtils.EPSILON, "wrong charging end time"); + Assertions.assertEquals("172", plugoutActStart.getLinkId().toString(), "wrong charging end location"); } @@ -190,66 +190,66 @@ void testChargerSelectionShopping() { void testLongDistance() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Charger Selection long distance leg"), List.of()); - Assert.assertEquals(1, plugins.size(), 0); + Assertions.assertEquals(1, plugins.size(), 0); ActivityStartEvent pluginActStart = plugins.get(0); //starts at 8 am and travels 19 links à 99s + 3s waiting time to enter traffic - Assert.assertEquals("wrong charging start time", 8 * 3600 + 19 * 99 + 3, pluginActStart.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging start location", "89", pluginActStart.getLinkId().toString()); + Assertions.assertEquals(8 * 3600 + 19 * 99 + 3, pluginActStart.getTime(), MatsimTestUtils.EPSILON, "wrong charging start time"); + Assertions.assertEquals("89", pluginActStart.getLinkId().toString(), "wrong charging start location"); List plugouts = this.handler.plugOutCntPerPerson.getOrDefault(Id.createPersonId("Charger Selection long distance leg"), List.of()); - Assert.assertEquals(1, plugouts.size(), 0); + Assertions.assertEquals(1, plugouts.size(), 0); ActivityEndEvent plugoutActStart = plugouts.get(0); //needs to walk for 26 minutes - Assert.assertEquals("wrong charging end time", 10 * 3600 + 26 * 60, plugoutActStart.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging end location", "89", plugoutActStart.getLinkId().toString()); + Assertions.assertEquals(10 * 3600 + 26 * 60, plugoutActStart.getTime(), MatsimTestUtils.EPSILON, "wrong charging end time"); + Assertions.assertEquals("89", plugoutActStart.getLinkId().toString(), "wrong charging end location"); } @Test void testTwin() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Charger Selection long distance twin"), List.of()); - Assert.assertEquals(1, plugins.size(), 0); + Assertions.assertEquals(1, plugins.size(), 0); ActivityStartEvent pluginActStart = plugins.get(0); //starts at 8:00:40 am and travels 19 links à 99s - Assert.assertEquals("wrong charging start time", 8 * 3605 + 19 * 99, pluginActStart.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging start location", "89", pluginActStart.getLinkId().toString()); + Assertions.assertEquals(8 * 3605 + 19 * 99, pluginActStart.getTime(), MatsimTestUtils.EPSILON, "wrong charging start time"); + Assertions.assertEquals("89", pluginActStart.getLinkId().toString(), "wrong charging start location"); List plugouts = this.handler.plugOutCntPerPerson.getOrDefault(Id.createPersonId("Charger Selection long distance twin"), List.of()); - Assert.assertEquals(1, plugouts.size(), 0); + Assertions.assertEquals(1, plugouts.size(), 0); ActivityEndEvent plugoutActStart = plugouts.get(0); - Assert.assertEquals("wrong charging end time", 10 * 3600, plugoutActStart.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging end location", "89", plugoutActStart.getLinkId().toString()); + Assertions.assertEquals(10 * 3600, plugoutActStart.getTime(), MatsimTestUtils.EPSILON, "wrong charging end time"); + Assertions.assertEquals("89", plugoutActStart.getLinkId().toString(), "wrong charging end location"); } @Test void testDoubleCharger() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Double Charger"), List.of()); - Assert.assertEquals(1, plugins.size(), 0); + Assertions.assertEquals(1, plugins.size(), 0); ActivityStartEvent pluginActStart = plugins.get(0); //starts at 6 am and travels 17 links à 99s - Assert.assertEquals("wrong charging start time", 6 * 3600 + 17 * 99, pluginActStart.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging start location", "90", pluginActStart.getLinkId().toString()); + Assertions.assertEquals(6 * 3600 + 17 * 99, pluginActStart.getTime(), MatsimTestUtils.EPSILON, "wrong charging start time"); + Assertions.assertEquals("90", pluginActStart.getLinkId().toString(), "wrong charging start location"); List plugouts = this.handler.plugOutCntPerPerson.getOrDefault(Id.createPersonId("Double Charger"), List.of()); - Assert.assertEquals(1, plugouts.size(), 0); + Assertions.assertEquals(1, plugouts.size(), 0); ActivityEndEvent plugoutActStart = plugouts.get(0); - Assert.assertEquals("wrong charging end time", 28783d, plugoutActStart.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging end location", "90", plugoutActStart.getLinkId().toString()); + Assertions.assertEquals(28783d, plugoutActStart.getTime(), MatsimTestUtils.EPSILON, "wrong charging end time"); + Assertions.assertEquals("90", plugoutActStart.getLinkId().toString(), "wrong charging end location"); } @Test void testNotEnoughTimeCharger() { //TODO this test succeeds if the corresponding agents is deleted List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Not enough time so no charge"), List.of()); - Assert.assertTrue(plugins.isEmpty()); + Assertions.assertTrue(plugins.isEmpty()); List plugouts = this.handler.plugOutCntPerPerson.getOrDefault(Id.createPersonId("Not enough time so no charge"), List.of()); - Assert.assertTrue(plugins.isEmpty()); + Assertions.assertTrue(plugins.isEmpty()); } @Test @@ -258,33 +258,33 @@ void testEarlyCharger() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Not enough time so charging early"), List.of()); - Assert.assertEquals(1, plugins.size(), 0); + Assertions.assertEquals(1, plugins.size(), 0); ActivityStartEvent pluginActStart = plugins.get(0); //starts at 6 am and travels 18 links à 99s + 3s waiting time to enter traffic - Assert.assertEquals("wrong charging start time", 6 * 3600 + 18 * 99 + 3, pluginActStart.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging start location", "90", pluginActStart.getLinkId().toString()); + Assertions.assertEquals(6 * 3600 + 18 * 99 + 3, pluginActStart.getTime(), MatsimTestUtils.EPSILON, "wrong charging start time"); + Assertions.assertEquals("90", pluginActStart.getLinkId().toString(), "wrong charging start location"); List plugouts = this.handler.plugOutCntPerPerson.getOrDefault(Id.createPersonId("Not enough time so charging early"), List.of()); - Assert.assertEquals(1, plugouts.size(), 0); + Assertions.assertEquals(1, plugouts.size(), 0); ActivityEndEvent plugoutActStart = plugouts.get(0); - Assert.assertEquals("wrong charging end time", 7 * 3600 + 27 * 60 + 49, plugoutActStart.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging end location", "90", plugoutActStart.getLinkId().toString()); + Assertions.assertEquals(7 * 3600 + 27 * 60 + 49, plugoutActStart.getTime(), MatsimTestUtils.EPSILON, "wrong charging end time"); + Assertions.assertEquals("90", plugoutActStart.getLinkId().toString(), "wrong charging end location"); } @Test void testHomeCharger() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Home Charger"), List.of()); - Assert.assertEquals(1, plugins.size(), 0); + Assertions.assertEquals(1, plugins.size(), 0); ActivityStartEvent pluginActStart = plugins.get(0); //starts return to home trip at 8am and travels 10 links à 99s + 3s waiting time - Assert.assertEquals("wrong charging start time", 8 * 3600 + 10 * 99, pluginActStart.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging start location", pluginActStart.getLinkId().toString(), "95"); + Assertions.assertEquals(8 * 3600 + 10 * 99, pluginActStart.getTime(), MatsimTestUtils.EPSILON, "wrong charging start time"); + Assertions.assertEquals(pluginActStart.getLinkId().toString(), "95", "wrong charging start location"); List plugouts = this.handler.plugOutCntPerPerson.getOrDefault(Id.createPersonId("Home Charger"), List.of()); - Assert.assertTrue("Home charger should not have a plug out interaction", plugouts.isEmpty()); + Assertions.assertTrue(plugouts.isEmpty(), "Home charger should not have a plug out interaction"); } @Test @@ -293,31 +293,31 @@ void testNoRoundTripSoNoHomeCharge() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("No Round Trip So No Home Charge"), List.of()); - Assert.assertTrue(plugins.isEmpty()); + Assertions.assertTrue(plugins.isEmpty()); List plugouts = this.handler.plugOutCntPerPerson.getOrDefault(Id.createPersonId("No Round Trip So No Home Charge"), List.of()); - Assert.assertTrue("Home charger should not have a plug out interaction", plugouts.isEmpty()); + Assertions.assertTrue(plugouts.isEmpty(), "Home charger should not have a plug out interaction"); } @Test void testDoubleChargerHomeCharger() { List plugins = this.handler.plugInCntPerPerson.getOrDefault(Id.createPersonId("Double Charger Home Charger"), List.of()); - Assert.assertEquals(plugins.size(), 2, 0); + Assertions.assertEquals(plugins.size(), 2, 0); ActivityStartEvent pluginActStart = plugins.get(0); - Assert.assertEquals("wrong charging start time", 5 * 3600 + 13 * 99, pluginActStart.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging start location", "95", pluginActStart.getLinkId().toString()); + Assertions.assertEquals(5 * 3600 + 13 * 99, pluginActStart.getTime(), MatsimTestUtils.EPSILON, "wrong charging start time"); + Assertions.assertEquals("95", pluginActStart.getLinkId().toString(), "wrong charging start location"); //drives back home at 17 pm and travels 18 links ActivityStartEvent pluginActStart2 = plugins.get(1); - Assert.assertEquals("wrong charging start time", 17 * 3600 + 18 * 99, pluginActStart2.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging start location", "90", pluginActStart2.getLinkId().toString()); + Assertions.assertEquals(17 * 3600 + 18 * 99, pluginActStart2.getTime(), MatsimTestUtils.EPSILON, "wrong charging start time"); + Assertions.assertEquals("90", pluginActStart2.getLinkId().toString(), "wrong charging start location"); List plugouts = this.handler.plugOutCntPerPerson.getOrDefault(Id.createPersonId("Double Charger Home Charger"), List.of()); ActivityEndEvent plugoutActStart = plugouts.get(0); - Assert.assertEquals("wrong charging end time", 33242d, plugoutActStart.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong charging end location", "95", plugoutActStart.getLinkId().toString()); - Assert.assertEquals("Should plug out exactly once (as second plugin is for home charge)", 1, plugouts.size()); + Assertions.assertEquals(33242d, plugoutActStart.getTime(), MatsimTestUtils.EPSILON, "wrong charging end time"); + Assertions.assertEquals("95", plugoutActStart.getLinkId().toString(), "wrong charging end location"); + Assertions.assertEquals(1, plugouts.size(), "Should plug out exactly once (as second plugin is for home charge)"); } private static void overridePopulation(Scenario scenario) { @@ -924,8 +924,9 @@ public void handleEvent(ActivityEndEvent event) { ActivityStartEvent correspondingPlugin = this.plugInCntPerPerson.get(event.getPersonId()) .get(this.plugInCntPerPerson.get(event.getPersonId()).size() - 1); - Assert.assertEquals("plugin and plugout location seem not to match. event=" + event, correspondingPlugin.getLinkId(), - event.getLinkId()); + Assertions.assertEquals(correspondingPlugin.getLinkId(), + event.getLinkId(), + "plugin and plugout location seem not to match. event=" + event); } } @@ -959,8 +960,7 @@ public void handleEvent(ChargingEndEvent event) { ChargingStartEvent correspondingStart = this.chargingStarts.get(event.getVehicleId()) .get(this.chargingStarts.get(event.getVehicleId()).size() - 1); - Assert.assertEquals("chargingEnd and chargingStart do not seem not to take place at the same charger. event=" + event, - correspondingStart.getChargerId(), event.getChargerId()); + Assertions.assertEquals(correspondingStart.getChargerId(), event.getChargerId(), "chargingEnd and chargingStart do not seem not to take place at the same charger. event=" + event); } @Override diff --git a/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java b/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java index 07a9345c92c..2eeae6af2fe 100644 --- a/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java @@ -1,8 +1,8 @@ package playground.vsp.flowEfficiency; import com.google.inject.Provides; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -68,17 +68,17 @@ public class HierarchicalFLowEfficiencyCalculatorTest { @Test void testThatDrtAVMoveFaster(){ - Assert.assertTrue(handler.lastArrivalsPerLink.get(Id.createLinkId(258)) > handler.lastArrivalsPerLink.get(Id.createLinkId(259))); - Assert.assertTrue(handler.lastArrivalsPerLink.get(Id.createLinkId(258)) > handler.lastArrivalsPerLink.get(Id.createLinkId(260))); - Assert.assertTrue(handler.lastArrivalsPerLink.get(Id.createLinkId(260)) > handler.lastArrivalsPerLink.get(Id.createLinkId(259))); + Assertions.assertTrue(handler.lastArrivalsPerLink.get(Id.createLinkId(258)) > handler.lastArrivalsPerLink.get(Id.createLinkId(259))); + Assertions.assertTrue(handler.lastArrivalsPerLink.get(Id.createLinkId(258)) > handler.lastArrivalsPerLink.get(Id.createLinkId(260))); + Assertions.assertTrue(handler.lastArrivalsPerLink.get(Id.createLinkId(260)) > handler.lastArrivalsPerLink.get(Id.createLinkId(259))); - Assert.assertEquals(7238, handler.lastArrivalsPerLink.get(Id.createLinkId(258)), MatsimTestUtils.EPSILON); //car drivers - Assert.assertEquals(1845, handler.lastArrivalsPerLink.get(Id.createLinkId(259)), MatsimTestUtils.EPSILON); //drt drivers - Assert.assertEquals(5440, handler.lastArrivalsPerLink.get(Id.createLinkId(260)), MatsimTestUtils.EPSILON); //mixed (car - drt -car - drt - ....) + Assertions.assertEquals(7238, handler.lastArrivalsPerLink.get(Id.createLinkId(258)), MatsimTestUtils.EPSILON); //car drivers + Assertions.assertEquals(1845, handler.lastArrivalsPerLink.get(Id.createLinkId(259)), MatsimTestUtils.EPSILON); //drt drivers + Assertions.assertEquals(5440, handler.lastArrivalsPerLink.get(Id.createLinkId(260)), MatsimTestUtils.EPSILON); //mixed (car - drt -car - drt - ....) - Assert.assertEquals(1800, handler.nrOfArrivalsPerLink.get(Id.createLinkId(258)), MatsimTestUtils.EPSILON); - Assert.assertEquals(1800, handler.nrOfArrivalsPerLink.get(Id.createLinkId(259)), MatsimTestUtils.EPSILON); - Assert.assertEquals(1800, handler.nrOfArrivalsPerLink.get(Id.createLinkId(260)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1800, handler.nrOfArrivalsPerLink.get(Id.createLinkId(258)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1800, handler.nrOfArrivalsPerLink.get(Id.createLinkId(259)), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1800, handler.nrOfArrivalsPerLink.get(Id.createLinkId(260)), MatsimTestUtils.EPSILON); } diff --git a/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreatorTest.java b/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreatorTest.java index 56816559ba1..7d115d579a6 100644 --- a/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreatorTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/cemdap/input/SynPopCreatorTest.java @@ -1,6 +1,6 @@ package playground.vsp.openberlinscenario.cemdap.input; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.population.Person; @@ -93,9 +93,9 @@ void TestGenerateDemand() { //assert // Assert.assertEquals("Wrong municipality", "12060034", householdId.toString().substring(0,8)); if (!employed) { - Assert.assertEquals("Wrong locationOfWork", "-99", locationOfWork); + Assertions.assertEquals("-99", locationOfWork, "Wrong locationOfWork"); } else if (locationOfWork.length() != 6) { - Assert.assertTrue("Wrong locationOfWork", possibleLocationsOfWork.contains(locationOfWork)); + Assertions.assertTrue(possibleLocationsOfWork.contains(locationOfWork), "Wrong locationOfWork"); } if (gender == Gender.male) { if (isBetween(age, 18, 24)) male18_24++; @@ -113,27 +113,27 @@ void TestGenerateDemand() { if (isBetween(age, 50, 64)) female50_64++; if (isBetween(age, 65, 74)) female65_74++; if (age > 74) female75Plus++; - } else Assert.fail("Wrong gender"); + } else Assertions.fail("Wrong gender"); } //System.out.println("Persons size: " + pop.getPersons().values().size()); - Assert.assertEquals("Wrong male18_24 count", male18_24Ref, male18_24); - Assert.assertEquals("Wrong male25_29 count", male25_29Ref, male25_29); - Assert.assertEquals("Wrong male30_39 count", male30_39Ref, male30_39); - Assert.assertEquals("Wrong male40_49 count", male40_49Ref, male40_49); - Assert.assertEquals("Wrong male50_64 count", male50_64Ref, male50_64); - Assert.assertEquals("Wrong male75Plus count", male75PlusRef, male75Plus); - Assert.assertEquals("Wrong female18_24 count", female18_24Ref, female18_24); - Assert.assertEquals("Wrong female25_29 count", female25_29Ref, female25_29); - Assert.assertEquals("Wrong female30_39 count", female30_39Ref, female30_39); - Assert.assertEquals("Wrong female40_49 count", female40_49Ref, female40_49); - Assert.assertEquals("Wrong female50_64 count", female50_64Ref, female50_64); - Assert.assertEquals("Wrong female65_74 count", female65_74Ref, female65_74); - Assert.assertEquals("Wrong female75Plus count", female75PlusRef, female75Plus); - Assert.assertEquals("Wrong male65_74 count", male65_74Ref, male65_74); - - Assert.assertTrue("", new File(utils.getOutputDirectory() + "persons1.dat.gz").exists()); + Assertions.assertEquals(male18_24Ref, male18_24, "Wrong male18_24 count"); + Assertions.assertEquals(male25_29Ref, male25_29, "Wrong male25_29 count"); + Assertions.assertEquals(male30_39Ref, male30_39, "Wrong male30_39 count"); + Assertions.assertEquals(male40_49Ref, male40_49, "Wrong male40_49 count"); + Assertions.assertEquals(male50_64Ref, male50_64, "Wrong male50_64 count"); + Assertions.assertEquals(male75PlusRef, male75Plus, "Wrong male75Plus count"); + Assertions.assertEquals(female18_24Ref, female18_24, "Wrong female18_24 count"); + Assertions.assertEquals(female25_29Ref, female25_29, "Wrong female25_29 count"); + Assertions.assertEquals(female30_39Ref, female30_39, "Wrong female30_39 count"); + Assertions.assertEquals(female40_49Ref, female40_49, "Wrong female40_49 count"); + Assertions.assertEquals(female50_64Ref, female50_64, "Wrong female50_64 count"); + Assertions.assertEquals(female65_74Ref, female65_74, "Wrong female65_74 count"); + Assertions.assertEquals(female75PlusRef, female75Plus, "Wrong female75Plus count"); + Assertions.assertEquals(male65_74Ref, male65_74, "Wrong male65_74 count"); + + Assertions.assertTrue(new File(utils.getOutputDirectory() + "persons1.dat.gz").exists(), ""); } diff --git a/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java b/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java index 7f96e4d5879..d6d72219e1d 100644 --- a/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java @@ -2,8 +2,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -67,9 +67,9 @@ void testSelectionProbability() { LOG.info("selection probability: " + SELECTION_PROBABILITY); LOG.info("real selection probability: " + ((double)modifiedPopulationCase1.getPersons().size()/ originalPopulationCase.getPersons().size())); - Assert.assertEquals("Selection probability was not correctly applied", - 11, modifiedPopulationCase1.getPersons().size(), - MatsimTestUtils.EPSILON); + Assertions.assertEquals(11, modifiedPopulationCase1.getPersons().size(), + MatsimTestUtils.EPSILON, + "Selection probability was not correctly applied"); } @Test @@ -77,8 +77,8 @@ void testEveryPersonCopiedExistsInOriginal() { for (Person copy : modifiedPopulationCase1.getPersons().values()) { Person original = originalPopulationCase.getPersons().get(copy.getId()); - Assert.assertTrue("Person " + copy.getId() + " does not exist in the original file", - original != null); + Assertions.assertTrue(original != null, + "Person " + copy.getId() + " does not exist in the original file"); } } @@ -87,7 +87,7 @@ void testOnlyTransferSelectedPlan() { for (Person copy : modifiedPopulationCase2.getPersons().values()) { Person original = originalPopulationCase.getPersons().get(copy.getId()); - Assert.assertEquals("More than 1 plan", 1, copy.getPlans().size()); + Assertions.assertEquals(1, copy.getPlans().size(), "More than 1 plan"); comparePlansWithoutRoutes(original.getSelectedPlan(), copy.getSelectedPlan()); } } @@ -98,8 +98,7 @@ void testNotOnlyTransferSelectedPlan() { for (Person copy : modifiedPopulationCase1.getPersons().values()) { Person original = originalPopulationCase.getPersons().get(copy.getId()); - Assert.assertEquals("Not the same amount of plans", - original.getPlans().size(), copy.getPlans().size()); + Assertions.assertEquals(original.getPlans().size(), copy.getPlans().size(), "Not the same amount of plans"); comparePlans(original.getSelectedPlan(), copy.getSelectedPlan()); for (int i = 0; i < original.getPlans().size(); i++) { Plan originalPlan = original.getPlans().get(i); @@ -117,15 +116,15 @@ void testConsiderHomeStayingAgents() { if (copy.getSelectedPlan().getPlanElements().size() == 1) atLeastOneHomeStayingPerson = true; } - Assert.assertTrue("No home staying person found", atLeastOneHomeStayingPerson); + Assertions.assertTrue(atLeastOneHomeStayingPerson, "No home staying person found"); } @Test void testNotConsiderHomeStayingAgents() { for (Person copy : modifiedPopulationCase1.getPersons().values()) { - Assert.assertTrue("No home staying agents allowed", - copy.getSelectedPlan().getPlanElements().size() > 1); + Assertions.assertTrue(copy.getSelectedPlan().getPlanElements().size() > 1, + "No home staying agents allowed"); } } @@ -138,7 +137,7 @@ void testIncludeStayHomePlans() { if (plan.getPlanElements().size() <= 1) atLeastOneHomeStayingPlan = true; } - Assert.assertTrue("No home staying plan found", atLeastOneHomeStayingPlan); + Assertions.assertTrue(atLeastOneHomeStayingPlan, "No home staying plan found"); } @Test @@ -147,8 +146,8 @@ void testNotIncludeStayHomePlans() { for (Person copy : modifiedPopulationCase2.getPersons().values()) { for (Plan plan : copy.getPlans()) if (!plan.equals(copy.getSelectedPlan())) - Assert.assertTrue("No home staying plans allowed", - plan.getPlanElements().size() > 1); + Assertions.assertTrue(plan.getPlanElements().size() > 1, + "No home staying plans allowed"); } } @@ -159,8 +158,8 @@ void testOnlyConsiderPeopleAlwaysGoingByCar() { for (Plan plan : copy.getPlans()) for (PlanElement planElement : plan.getPlanElements()) { if (planElement instanceof Leg) { - Assert.assertTrue("No other mode than car allowed", - (((Leg) planElement).getMode().equals(TransportMode.car))); + Assertions.assertTrue((((Leg) planElement).getMode().equals(TransportMode.car)), + "No other mode than car allowed"); } } } @@ -178,7 +177,7 @@ void testNotOnlyConsiderPeopleAlwaysGoingByCar() { } } } - Assert.assertTrue("There should be other modes than car", otherModeThanCarConsidered); + Assertions.assertTrue(otherModeThanCarConsidered, "There should be other modes than car"); } @Test @@ -188,8 +187,8 @@ void testRemoveLinksAndRoutes() { for (Plan plan : copy.getPlans()) for (PlanElement planElement : plan.getPlanElements()) { if (planElement instanceof Leg) { - Assert.assertTrue("There should not be a route left", - (((Leg) planElement).getRoute() == null)); + Assertions.assertTrue((((Leg) planElement).getRoute() == null), + "There should not be a route left"); } } } @@ -207,21 +206,22 @@ void testNotRemoveLinksAndRoutes() { } } } - Assert.assertTrue("There should be at minimum one route left", routeFound); + Assertions.assertTrue(routeFound, "There should be at minimum one route left"); } private void comparePlans(Plan original, Plan copy) { - Assert.assertEquals("Plans are not the same", original.toString(), copy.toString()); + Assertions.assertEquals(original.toString(), copy.toString(), "Plans are not the same"); for (int i = 0; i < original.getPlanElements().size(); i++) { - Assert.assertEquals("PlanElements are not the same", original.getPlanElements().get(i).toString(), - copy.getPlanElements().get(i).toString()); + Assertions.assertEquals(original.getPlanElements().get(i).toString(), + copy.getPlanElements().get(i).toString(), + "PlanElements are not the same"); } } private void comparePlansWithoutRoutes(Plan original, Plan copy) { - Assert.assertEquals("Plans are not the same", original.toString(), copy.toString()); + Assertions.assertEquals(original.toString(), copy.toString(), "Plans are not the same"); } private static Population readPopulationFromFile(String populationFile) { diff --git a/contribs/vsp/src/test/java/playground/vsp/pt/ptdisturbances/EditTripsTest.java b/contribs/vsp/src/test/java/playground/vsp/pt/ptdisturbances/EditTripsTest.java index 8ea37d7d2df..4678d019243 100644 --- a/contribs/vsp/src/test/java/playground/vsp/pt/ptdisturbances/EditTripsTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/pt/ptdisturbances/EditTripsTest.java @@ -21,8 +21,8 @@ package playground.vsp.pt.ptdisturbances; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.net.URL; import java.util.ArrayList; @@ -133,16 +133,16 @@ void testAgentStaysAtStop() { double travelTime = arrivalTimes.get(person.getId()) - activityEndTime; List trip = trips.get(person.getId()); - assertEquals("Travel time has changed", 1490.0, travelTime, MatsimTestUtils.EPSILON); - assertEquals("Number of trip elements has changed", 7 ,trip.size()); + assertEquals(1490.0, travelTime, MatsimTestUtils.EPSILON, "Travel time has changed"); + assertEquals(7 ,trip.size(),"Number of trip elements has changed"); - assertEquals("Trip element has changed", "dummy@car_17bOut", trip.get(0)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(1)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(2)); - assertEquals("Trip element has changed", "tr_334", trip.get(3)); - assertEquals("Trip element has changed", "pt interaction@pt8", trip.get(4)); - assertEquals("Trip element has changed", "pt interaction@pt8", trip.get(5)); - assertEquals("Trip element has changed", "dummy@work0", trip.get(6)); + assertEquals("dummy@car_17bOut", trip.get(0), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(1), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(2), "Trip element has changed"); + assertEquals("tr_334", trip.get(3), "Trip element has changed"); + assertEquals("pt interaction@pt8", trip.get(4), "Trip element has changed"); + assertEquals("pt interaction@pt8", trip.get(5), "Trip element has changed"); + assertEquals("dummy@work0", trip.get(6), "Trip element has changed"); } @@ -169,16 +169,16 @@ void testAgentLeavesStop() { double travelTime = arrivalTimes.get(person.getId()) - activityEndTime; List trip = trips.get(person.getId()); - assertEquals("Travel time has changed", 1344.0, travelTime, MatsimTestUtils.EPSILON); - assertEquals("Number of trip elements has changed", 7 ,trip.size()); + assertEquals(1344.0, travelTime, MatsimTestUtils.EPSILON, "Travel time has changed"); + assertEquals(7 ,trip.size(),"Number of trip elements has changed"); - assertEquals("Trip element has changed", "dummy@car_17bOut", trip.get(0)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(1)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(2)); - assertEquals("Trip element has changed", "tr_333", trip.get(3)); - assertEquals("Trip element has changed", "pt interaction@pt8", trip.get(4)); - assertEquals("Trip element has changed", "pt interaction@pt8", trip.get(5)); - assertEquals("Trip element has changed", "dummy@work0", trip.get(6)); + assertEquals("dummy@car_17bOut", trip.get(0), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(1), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(2), "Trip element has changed"); + assertEquals("tr_333", trip.get(3), "Trip element has changed"); + assertEquals("pt interaction@pt8", trip.get(4), "Trip element has changed"); + assertEquals("pt interaction@pt8", trip.get(5), "Trip element has changed"); + assertEquals("dummy@work0", trip.get(6), "Trip element has changed"); } @@ -205,16 +205,16 @@ void testAgentStaysInVehicle() { double travelTime = arrivalTimes.get(person.getId()) - activityEndTime; List trip = trips.get(person.getId()); - assertEquals("Travel time has changed", 1044.0, travelTime, MatsimTestUtils.EPSILON); - assertEquals("Number of trip elements has changed", 7 ,trip.size()); + assertEquals(1044.0, travelTime, MatsimTestUtils.EPSILON, "Travel time has changed"); + assertEquals(7 ,trip.size(),"Number of trip elements has changed"); - assertEquals("Trip element has changed", "dummy@car_17bOut", trip.get(0)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(1)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(2)); - assertEquals("Trip element has changed", "tr_332", trip.get(3)); - assertEquals("Trip element has changed", "pt interaction@pt8", trip.get(4)); - assertEquals("Trip element has changed", "pt interaction@pt8", trip.get(5)); - assertEquals("Trip element has changed", "dummy@work0", trip.get(6)); + assertEquals("dummy@car_17bOut", trip.get(0), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(1), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(2), "Trip element has changed"); + assertEquals("tr_332", trip.get(3), "Trip element has changed"); + assertEquals("pt interaction@pt8", trip.get(4), "Trip element has changed"); + assertEquals("pt interaction@pt8", trip.get(5), "Trip element has changed"); + assertEquals("dummy@work0", trip.get(6), "Trip element has changed"); } @@ -241,21 +241,21 @@ void testAgentLeavesVehicleAtNextStop() { double travelTime = arrivalTimes.get(person.getId()) - activityEndTime; List trip = trips.get(person.getId()); - assertEquals("Travel time has changed", 1077.0, travelTime, MatsimTestUtils.EPSILON); - assertEquals("Number of trip elements has changed", 12 ,trip.size()); + assertEquals(1077.0, travelTime, MatsimTestUtils.EPSILON, "Travel time has changed"); + assertEquals(12 ,trip.size(),"Number of trip elements has changed"); - assertEquals("Trip element has changed", "dummy@car_17bOut", trip.get(0)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(1)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(2)); - assertEquals("Trip element has changed", "tr_333", trip.get(3)); - assertEquals("Trip element has changed", "pt interaction@pt7", trip.get(4)); - assertEquals("Trip element has changed", "pt interaction@pt7", trip.get(5)); - assertEquals("Trip element has changed", "pt interaction@pt1", trip.get(6)); - assertEquals("Trip element has changed", "pt interaction@pt1", trip.get(7)); - assertEquals("Trip element has changed", "tr_45", trip.get(8)); - assertEquals("Trip element has changed", "pt interaction@pt8", trip.get(9)); - assertEquals("Trip element has changed", "pt interaction@pt8", trip.get(10)); - assertEquals("Trip element has changed", "dummy@work0", trip.get(11)); + assertEquals("dummy@car_17bOut", trip.get(0), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(1), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(2), "Trip element has changed"); + assertEquals("tr_333", trip.get(3), "Trip element has changed"); + assertEquals("pt interaction@pt7", trip.get(4), "Trip element has changed"); + assertEquals("pt interaction@pt7", trip.get(5), "Trip element has changed"); + assertEquals("pt interaction@pt1", trip.get(6), "Trip element has changed"); + assertEquals("pt interaction@pt1", trip.get(7), "Trip element has changed"); + assertEquals("tr_45", trip.get(8), "Trip element has changed"); + assertEquals("pt interaction@pt8", trip.get(9), "Trip element has changed"); + assertEquals("pt interaction@pt8", trip.get(10), "Trip element has changed"); + assertEquals("dummy@work0", trip.get(11), "Trip element has changed"); } @@ -283,18 +283,18 @@ void testAgentIsAtTeleportLegAndLeavesStop() { double travelTime = arrivalTimes.get(person.getId()) - activityEndTime; List trip = trips.get(person.getId()); - assertEquals("Travel time has changed", 2570.0, travelTime, MatsimTestUtils.EPSILON); - assertEquals("Number of trip elements has changed", 9 ,trip.size()); + assertEquals(2570.0, travelTime, MatsimTestUtils.EPSILON, "Travel time has changed"); + assertEquals(9 ,trip.size(),"Number of trip elements has changed"); - assertEquals("Trip element has changed", "dummy@car_17bOut", trip.get(0)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(1)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(2)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(3)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(4)); - assertEquals("Trip element has changed", "tr_334", trip.get(5)); - assertEquals("Trip element has changed", "pt interaction@pt8", trip.get(6)); - assertEquals("Trip element has changed", "pt interaction@pt8", trip.get(7)); - assertEquals("Trip element has changed", "dummy@work0", trip.get(8)); + assertEquals("dummy@car_17bOut", trip.get(0), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(1), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(2), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(3), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(4), "Trip element has changed"); + assertEquals("tr_334", trip.get(5), "Trip element has changed"); + assertEquals("pt interaction@pt8", trip.get(6), "Trip element has changed"); + assertEquals("pt interaction@pt8", trip.get(7), "Trip element has changed"); + assertEquals("dummy@work0", trip.get(8), "Trip element has changed"); } @@ -325,18 +325,18 @@ void testAgentIsAtTeleportLegAndWaitsAtStop_walkUnattractive() { double travelTime = arrivalTimes.get(person.getId()) - activityEndTime; List trip = trips.get(person.getId()); - assertEquals("Travel time has changed", 2570.0, travelTime, MatsimTestUtils.EPSILON); - assertEquals("Number of trip elements has changed", 9 ,trip.size()); + assertEquals(2570.0, travelTime, MatsimTestUtils.EPSILON, "Travel time has changed"); + assertEquals(9 ,trip.size(),"Number of trip elements has changed"); - assertEquals("Trip element has changed", "dummy@car_17bOut", trip.get(0)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(1)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(2)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(3)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(4)); - assertEquals("Trip element has changed", "tr_334", trip.get(5)); - assertEquals("Trip element has changed", "pt interaction@pt8", trip.get(6)); - assertEquals("Trip element has changed", "pt interaction@pt8", trip.get(7)); - assertEquals("Trip element has changed", "dummy@work0", trip.get(8)); + assertEquals("dummy@car_17bOut", trip.get(0), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(1), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(2), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(3), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(4), "Trip element has changed"); + assertEquals("tr_334", trip.get(5), "Trip element has changed"); + assertEquals("pt interaction@pt8", trip.get(6), "Trip element has changed"); + assertEquals("pt interaction@pt8", trip.get(7), "Trip element has changed"); + assertEquals("dummy@work0", trip.get(8), "Trip element has changed"); } @@ -361,18 +361,18 @@ void testAgentIsAtTeleportLegAndWaitsAtStop() { double travelTime = arrivalTimes.get(person.getId()) - activityEndTime; List trip = trips.get(person.getId()); - assertEquals("Travel time has changed", 2570.0, travelTime, MatsimTestUtils.EPSILON); - assertEquals("Number of trip elements has changed", 9 ,trip.size()); + assertEquals(2570.0, travelTime, MatsimTestUtils.EPSILON, "Travel time has changed"); + assertEquals(9 ,trip.size(),"Number of trip elements has changed"); - assertEquals("Trip element has changed", "dummy@car_17bOut", trip.get(0)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(1)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(2)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(3)); - assertEquals("Trip element has changed", "pt interaction@pt6c", trip.get(4)); - assertEquals("Trip element has changed", "tr_334", trip.get(5)); - assertEquals("Trip element has changed", "pt interaction@pt8", trip.get(6)); - assertEquals("Trip element has changed", "pt interaction@pt8", trip.get(7)); - assertEquals("Trip element has changed", "dummy@work0", trip.get(8)); + assertEquals("dummy@car_17bOut", trip.get(0), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(1), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(2), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(3), "Trip element has changed"); + assertEquals("pt interaction@pt6c", trip.get(4), "Trip element has changed"); + assertEquals("tr_334", trip.get(5), "Trip element has changed"); + assertEquals("pt interaction@pt8", trip.get(6), "Trip element has changed"); + assertEquals("pt interaction@pt8", trip.get(7), "Trip element has changed"); + assertEquals("dummy@work0", trip.get(8), "Trip element has changed"); } @@ -411,7 +411,7 @@ void testOneAgentEveryFourSeconds() { numberOfUsedLines++; } } - assertTrue("Number of used lines ist not plausible", numberOfUsedLines == 1 || numberOfUsedLines == 2); + assertTrue(numberOfUsedLines == 1 || numberOfUsedLines == 2, "Number of used lines ist not plausible"); } System.out.println(config.controller().getOutputDirectory()); } diff --git a/contribs/vsp/src/test/java/playground/vsp/pt/transitRouteTrimmer/TransitRouteTrimmerTest.java b/contribs/vsp/src/test/java/playground/vsp/pt/transitRouteTrimmer/TransitRouteTrimmerTest.java index def2f9bebad..81bd2b2b013 100644 --- a/contribs/vsp/src/test/java/playground/vsp/pt/transitRouteTrimmer/TransitRouteTrimmerTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/pt/transitRouteTrimmer/TransitRouteTrimmerTest.java @@ -21,8 +21,8 @@ package playground.vsp.pt.transitRouteTrimmer; import javafx.util.Pair; -import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.locationtech.jts.geom.prep.PreparedGeometry; import org.matsim.api.core.v01.Id; @@ -45,7 +45,7 @@ import java.util.*; import java.util.stream.Collectors; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; /** * TODO: reduce size of input files: either cut files to only include relevant TransitLines or use different scenario @@ -118,8 +118,8 @@ void test_AllIn() { } } - assertEquals("There should be no stops outside of zone", 0, stopsOutsideZoneCnt); - assertEquals("All stops should be inside the zone", stopsTotal, stopsInZoneCnt); + assertEquals(0, stopsOutsideZoneCnt, "There should be no stops outside of zone"); + assertEquals(stopsTotal, stopsInZoneCnt, "All stops should be inside the zone"); } /** @@ -143,8 +143,8 @@ void test_HalfIn() { Id firstStopId = transitRoute.getStops().get(0).getStopFacility().getId(); Id lastStopId = transitRoute.getStops().get(sizeOld - 1).getStopFacility().getId(); - assertNotEquals("The Route should not be entirely inside of the zone", sizeOld, inCnt); - assertNotEquals("The Route should not be entirely outside of the zone", sizeOld, outCnt); + assertNotEquals(sizeOld, inCnt, "The Route should not be entirely inside of the zone"); + assertNotEquals(sizeOld, outCnt, "The Route should not be entirely outside of the zone"); assertFalse(stopsInZone.contains(firstStopId)); assertTrue(stopsInZone.contains(lastStopId)); @@ -171,8 +171,8 @@ void test_MiddleIn() { Id firstStopId = transitRoute.getStops().get(0).getStopFacility().getId(); Id lastStopId = transitRoute.getStops().get(sizeOld - 1).getStopFacility().getId(); - assertNotEquals("The Route should not be entirely inside of the zone", sizeOld, inCnt); - assertNotEquals("The Route should not be entirely outside of the zone", sizeOld, outCnt); + assertNotEquals(sizeOld, inCnt, "The Route should not be entirely inside of the zone"); + assertNotEquals(sizeOld, outCnt, "The Route should not be entirely outside of the zone"); assertFalse(stopsInZone.contains(firstStopId)); assertFalse(stopsInZone.contains(lastStopId)); @@ -205,16 +205,15 @@ void testDeleteRoutesEntirelyInsideZone_AllIn() { // After Trim TransitSchedule transitScheduleNew = results.getKey(); - assertTrue("Schedule should include empty transit line", - transitScheduleNew.getTransitLines().containsKey(transitLineId)); - assertEquals("transitLine should no longer contain any routes", - transitScheduleNew.getTransitLines().get(transitLineId).getRoutes().size(), 0); + assertTrue(transitScheduleNew.getTransitLines().containsKey(transitLineId), + "Schedule should include empty transit line"); + assertEquals(transitScheduleNew.getTransitLines().get(transitLineId).getRoutes().size(), 0, "transitLine should no longer contain any routes"); // Test vehicles Set> vehiclesUsedInTransitSchedule = getVehiclesUsedInTransitSchedule(transitScheduleNew); Set> vehiclesInVehiclesNew = results.getValue().getVehicles().keySet(); - Assert.assertTrue("TransitVehicles should contain all vehicles used in new TransitSchedule", - vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); + Assertions.assertTrue(vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule), + "TransitVehicles should contain all vehicles used in new TransitSchedule"); } @@ -246,23 +245,22 @@ void testDeleteRoutesEntirelyInsideZone_HalfIn() { // After trim TransitSchedule transitScheduleNew = results.getKey(); - assertTrue("Schedule should include transit line", - transitScheduleNew.getTransitLines().containsKey(transitLineId)); + assertTrue(transitScheduleNew.getTransitLines().containsKey(transitLineId), + "Schedule should include transit line"); TransitLine transitLine = transitScheduleNew.getTransitLines().get(transitLineId); - assertTrue("Schedule should include transit route", - transitLine.getRoutes().containsKey(transitRouteId)); + assertTrue(transitLine.getRoutes().containsKey(transitRouteId), + "Schedule should include transit route"); TransitRoute transitRoute = transitLine.getRoutes().get(transitRouteId); int stopCntNew = transitRoute.getStops().size(); - assertEquals("transitRoute should contain same number of stops as before modification", - stopCntOld, stopCntNew); + assertEquals(stopCntOld, stopCntNew, "transitRoute should contain same number of stops as before modification"); // Test vehicles Set> vehiclesUsedInTransitSchedule = getVehiclesUsedInTransitSchedule(transitScheduleNew); Set> vehiclesInVehiclesNew = results.getValue().getVehicles().keySet(); - Assert.assertTrue("TransitVehicles should contain all vehicles used in new TransitSchedule", - vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); + Assertions.assertTrue(vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule), + "TransitVehicles should contain all vehicles used in new TransitSchedule"); } @@ -294,23 +292,22 @@ void testDeleteRoutesEntirelyInsideZone_MiddleIn() { // After trim TransitSchedule transitScheduleNew = results.getKey(); - assertTrue("Schedule should include transit line", - transitScheduleNew.getTransitLines().containsKey(transitLineId)); + assertTrue(transitScheduleNew.getTransitLines().containsKey(transitLineId), + "Schedule should include transit line"); TransitLine transitLine = transitScheduleNew.getTransitLines().get(transitLineId); - assertTrue("Schedule should include transit route", - transitLine.getRoutes().containsKey(transitRouteId)); + assertTrue(transitLine.getRoutes().containsKey(transitRouteId), + "Schedule should include transit route"); TransitRoute transitRoute = transitLine.getRoutes().get(transitRouteId); int stopCntNew = transitRoute.getStops().size(); - assertEquals("transitRoute should contain same number of stops as before modification", - stopCntOld, stopCntNew); + assertEquals(stopCntOld, stopCntNew, "transitRoute should contain same number of stops as before modification"); // Test vehicles Set> vehiclesUsedInTransitSchedule = getVehiclesUsedInTransitSchedule(transitScheduleNew); Set> vehiclesInVehiclesNew = results.getValue().getVehicles().keySet(); - Assert.assertTrue("TransitVehicles should contain all vehicles used in new TransitSchedule", - vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); + Assertions.assertTrue(vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule), + "TransitVehicles should contain all vehicles used in new TransitSchedule"); } @@ -336,16 +333,15 @@ void testTrimEnds_AllIn() { // After trim TransitSchedule transitScheduleNew = results.getKey(); - assertTrue("schedule should include empty transit line", - transitScheduleNew.getTransitLines().containsKey(transitLineId)); - assertEquals("transitLine should no longer contain any routes", - transitScheduleNew.getTransitLines().get(transitLineId).getRoutes().size(), 0); + assertTrue(transitScheduleNew.getTransitLines().containsKey(transitLineId), + "schedule should include empty transit line"); + assertEquals(transitScheduleNew.getTransitLines().get(transitLineId).getRoutes().size(), 0, "transitLine should no longer contain any routes"); // Test vehicles Set> vehiclesUsedInTransitSchedule = getVehiclesUsedInTransitSchedule(transitScheduleNew); Set> vehiclesInVehiclesNew = results.getValue().getVehicles().keySet(); - Assert.assertTrue("TransitVehicles should contain all vehicles used in new TransitSchedule", - vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); + Assertions.assertTrue(vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule), + "TransitVehicles should contain all vehicles used in new TransitSchedule"); } @@ -388,22 +384,18 @@ void testTrimEnds_HalfIn() { Id firstStopNew = transitRouteNew.getStops().get(0).getStopFacility().getId(); Id lastStopNew = transitRouteNew.getStops().get(sizeNew - 1).getStopFacility().getId(); - Assert.assertTrue("modified route should have less stops as original route", - sizeOld > sizeNew); - assertEquals("there should be no stops within the zone", - 0, inCntNew); - assertEquals("number of stops outside of zone should remain same", - outCntOld, outCntNew); - assertEquals("first stop of old and new route should be same", - firstStopOld, firstStopNew); - assertNotEquals("last stop of old and new route should be different", - lastStopOld, lastStopNew); + Assertions.assertTrue(sizeOld > sizeNew, + "modified route should have less stops as original route"); + assertEquals(0, inCntNew, "there should be no stops within the zone"); + assertEquals(outCntOld, outCntNew, "number of stops outside of zone should remain same"); + assertEquals(firstStopOld, firstStopNew, "first stop of old and new route should be same"); + assertNotEquals(lastStopOld, lastStopNew, "last stop of old and new route should be different"); // Test vehicles Set> vehiclesUsedInTransitSchedule = getVehiclesUsedInTransitSchedule(transitScheduleNew); Set> vehiclesInVehiclesNew = results.getValue().getVehicles().keySet(); - Assert.assertTrue("TransitVehicles should contain all vehicles used in new TransitSchedule", - vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); + Assertions.assertTrue(vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule), + "TransitVehicles should contain all vehicles used in new TransitSchedule"); } /** @@ -439,18 +431,16 @@ void testTrimEnds_MiddleIn() { int numStopsNew = routeNew.getStops().size(); int numLinksNew = routeNew.getRoute().getLinkIds().size(); - Assert.assertTrue("line should still exist", - transitScheduleNew.getTransitLines().containsKey(transitLineId)); - Assert.assertEquals("new route should contain same number of stops as old one", - numStopsOld, numStopsNew); - Assert.assertEquals("new route should contain same number of links as old one", - numLinksOld, numLinksNew); + Assertions.assertTrue(transitScheduleNew.getTransitLines().containsKey(transitLineId), + "line should still exist"); + Assertions.assertEquals(numStopsOld, numStopsNew, "new route should contain same number of stops as old one"); + Assertions.assertEquals(numLinksOld, numLinksNew, "new route should contain same number of links as old one"); // Test vehicles Set> vehiclesUsedInTransitSchedule = getVehiclesUsedInTransitSchedule(transitScheduleNew); Set> vehiclesInVehiclesNew = results.getValue().getVehicles().keySet(); - Assert.assertTrue("TransitVehicles should contain all vehicles used in new TransitSchedule", - vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); + Assertions.assertTrue(vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule), + "TransitVehicles should contain all vehicles used in new TransitSchedule"); } @@ -475,14 +465,14 @@ void testSkipStops_AllIn() { // After trim TransitSchedule transitScheduleNew = results.getKey(); - assertTrue("sched should include empty transit line", transitScheduleNew.getTransitLines().containsKey(transitLineId)); - assertEquals("transitLine should not longer contain any routes", transitScheduleNew.getTransitLines().get(transitLineId).getRoutes().size(), 0); + assertTrue(transitScheduleNew.getTransitLines().containsKey(transitLineId), "sched should include empty transit line"); + assertEquals(transitScheduleNew.getTransitLines().get(transitLineId).getRoutes().size(), 0, "transitLine should not longer contain any routes"); // Test vehicles Set> vehiclesUsedInTransitSchedule = getVehiclesUsedInTransitSchedule(transitScheduleNew); Set> vehiclesInVehiclesNew = results.getValue().getVehicles().keySet(); - Assert.assertTrue("TransitVehicles should contain all vehicles used in new TransitSchedule", - vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); + Assertions.assertTrue(vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule), + "TransitVehicles should contain all vehicles used in new TransitSchedule"); } @@ -520,20 +510,18 @@ void testSkipStops_HalfIn() { int outCntNew = countStopsOutsideZone(transitRouteNew, stopsInZone); int numLinksNew = transitRouteNew.getRoute().getLinkIds().size(); - Assert.assertTrue("there should be less stops after the modification", - sizeOld > sizeNew); - assertTrue("new route should have less links than old route", - numLinksNew < numLinksOld); - assertEquals("there should only be one stop within the zone", - 1, inCntNew); - assertEquals("the number of stops outside of zone should remain same", - outCntOld, outCntNew); + Assertions.assertTrue(sizeOld > sizeNew, + "there should be less stops after the modification"); + assertTrue(numLinksNew < numLinksOld, + "new route should have less links than old route"); + assertEquals(1, inCntNew, "there should only be one stop within the zone"); + assertEquals(outCntOld, outCntNew, "the number of stops outside of zone should remain same"); // Test vehicles Set> vehiclesUsedInTransitSchedule = getVehiclesUsedInTransitSchedule(transitScheduleNew); Set> vehiclesInVehiclesNew = results.getValue().getVehicles().keySet(); - Assert.assertTrue("TransitVehicles should contain all vehicles used in new TransitSchedule", - vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); + Assertions.assertTrue(vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule), + "TransitVehicles should contain all vehicles used in new TransitSchedule"); } @@ -571,21 +559,18 @@ void testSkipStops_MiddleIn() { int numLinksNew = transitRouteNew.getRoute().getLinkIds().size(); int inCntNew = countStopsInZone(transitRouteNew, stopsInZone); - Assert.assertTrue("line should still exist", - transitScheduleNew.getTransitLines().containsKey(transitLineId)); - Assert.assertNotEquals("new route should NOT contain same number of stops as old one", - numStopsOld, numStopsNew); - Assert.assertEquals("new route should contain same number of links as old one", - numLinksOld, numLinksNew); - Assert.assertEquals("new route should only have two stops within zone, one per zone entrance/exit", - 2, inCntNew); + Assertions.assertTrue(transitScheduleNew.getTransitLines().containsKey(transitLineId), + "line should still exist"); + Assertions.assertNotEquals(numStopsOld, numStopsNew, "new route should NOT contain same number of stops as old one"); + Assertions.assertEquals(numLinksOld, numLinksNew, "new route should contain same number of links as old one"); + Assertions.assertEquals(2, inCntNew, "new route should only have two stops within zone, one per zone entrance/exit"); // Test vehicles Set> vehiclesUsedInTransitSchedule = getVehiclesUsedInTransitSchedule(transitScheduleNew); Set> vehiclesInVehiclesNew = results.getValue().getVehicles().keySet(); - Assert.assertTrue("TransitVehicles should contain all vehicles used in new TransitSchedule", - vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); + Assertions.assertTrue(vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule), + "TransitVehicles should contain all vehicles used in new TransitSchedule"); } /** @@ -611,16 +596,15 @@ void testSplitRoutes_AllIn() { // After trim TransitSchedule transitScheduleNew = results.getKey(); - assertTrue("schedule should include empty transit line", - transitScheduleNew.getTransitLines().containsKey(transitLineId)); - assertEquals("transitLine should not longer contain any routes", - 0, transitScheduleNew.getTransitLines().get(transitLineId).getRoutes().size()); + assertTrue(transitScheduleNew.getTransitLines().containsKey(transitLineId), + "schedule should include empty transit line"); + assertEquals(0, transitScheduleNew.getTransitLines().get(transitLineId).getRoutes().size(), "transitLine should not longer contain any routes"); // Test vehicles Set> vehiclesUsedInTransitSchedule = getVehiclesUsedInTransitSchedule(transitScheduleNew); Set> vehiclesInVehiclesNew = results.getValue().getVehicles().keySet(); - Assert.assertTrue("TransitVehicles should contain all vehicles used in new TransitSchedule", - vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); + Assertions.assertTrue(vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule), + "TransitVehicles should contain all vehicles used in new TransitSchedule"); } /** @@ -660,18 +644,16 @@ void testSplitRoutes_HalfIn() { int inCntNew = countStopsInZone(transitRouteNew, stopsInZone); int outCntNew = countStopsOutsideZone(transitRouteNew, stopsInZone); - assertTrue("new route should have less stops than old route", - sizeOld > sizeNew); - assertEquals("there should only be one stop within the zone", - 1, inCntNew); - assertEquals("# of stops outside of zone should remain same", - outCntOld, outCntNew); + assertTrue(sizeOld > sizeNew, + "new route should have less stops than old route"); + assertEquals(1, inCntNew, "there should only be one stop within the zone"); + assertEquals(outCntOld, outCntNew, "# of stops outside of zone should remain same"); // Test vehicles Set> vehiclesUsedInTransitSchedule = getVehiclesUsedInTransitSchedule(transitScheduleNew); Set> vehiclesInVehiclesNew = results.getValue().getVehicles().keySet(); - Assert.assertTrue("TransitVehicles should contain all vehicles used in new TransitSchedule", - vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); + Assertions.assertTrue(vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule), + "TransitVehicles should contain all vehicles used in new TransitSchedule"); } /** @@ -701,7 +683,7 @@ void testSplitRoutes_MiddleIn() { // After trim TransitSchedule transitScheduleNew = results.getKey(); - assertTrue("line should still exist", transitScheduleNew.getTransitLines().containsKey(transitLineId)); + assertTrue(transitScheduleNew.getTransitLines().containsKey(transitLineId), "line should still exist"); TransitLine transitLineNew = transitScheduleNew.getTransitLines().get(transitLineId); assertTrue(transitLineNew.getRoutes().containsKey(Id.create("161---17326_700_22_split1", TransitRoute.class))); @@ -720,14 +702,14 @@ void testSplitRoutes_MiddleIn() { int inCntNew1 = countStopsInZone(transitRouteNew1, stopsInZone); int inCntNew2 = countStopsInZone(transitRouteNew2, stopsInZone); - Assert.assertEquals("new route #1 should only have one stop within zone", 1, inCntNew1); - Assert.assertEquals("new route #2 should only have one stop within zone", 1, inCntNew2); + Assertions.assertEquals(1, inCntNew1, "new route #1 should only have one stop within zone"); + Assertions.assertEquals(1, inCntNew2, "new route #2 should only have one stop within zone"); // Test vehicles Set> vehiclesUsedInTransitSchedule = getVehiclesUsedInTransitSchedule(transitScheduleNew); Set> vehiclesInVehiclesNew = results.getValue().getVehicles().keySet(); - Assert.assertTrue("TransitVehicles should contain all vehicles used in new TransitSchedule", - vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); + Assertions.assertTrue(vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule), + "TransitVehicles should contain all vehicles used in new TransitSchedule"); } @@ -779,7 +761,7 @@ void testSplitRoutes_MiddleIn_Hub_ValidateReach() { // After trim TransitSchedule transitScheduleNew = results.getKey(); - assertTrue("line should still exist", transitScheduleNew.getTransitLines().containsKey(transitLineId)); + assertTrue(transitScheduleNew.getTransitLines().containsKey(transitLineId), "line should still exist"); TransitLine transitLineNew = transitScheduleNew.getTransitLines().get(transitLineId); assertTrue(transitLineNew.getRoutes().containsKey(Id.create("161---17326_700_22_split1", TransitRoute.class))); @@ -798,14 +780,14 @@ void testSplitRoutes_MiddleIn_Hub_ValidateReach() { int inCntNew1 = countStopsInZone(transitRouteNew1, stopsInZone); int inCntNew2 = countStopsInZone(transitRouteNew2, stopsInZone); - assertEquals("new route #1 should have three stop within zone", 3, inCntNew1); - assertEquals("new route #2 should have one stop within zone", 1, inCntNew2); + assertEquals(3, inCntNew1, "new route #1 should have three stop within zone"); + assertEquals(1, inCntNew2, "new route #2 should have one stop within zone"); // Test vehicles Set> vehiclesUsedInTransitSchedule = getVehiclesUsedInTransitSchedule(transitScheduleNew); Set> vehiclesInVehiclesNew = results.getValue().getVehicles().keySet(); - Assert.assertTrue("TransitVehicles should contain all vehicles used in new TransitSchedule", - vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); + Assertions.assertTrue(vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule), + "TransitVehicles should contain all vehicles used in new TransitSchedule"); } /** @@ -847,7 +829,7 @@ void testSplitRoutes_MiddleIn_Hub_IncludeFirstHubInZone() { // After trim TransitSchedule transitScheduleNew = results.getKey(); - assertTrue("line should still exist", transitScheduleNew.getTransitLines().containsKey(transitLineId)); + assertTrue(transitScheduleNew.getTransitLines().containsKey(transitLineId), "line should still exist"); TransitLine transitLineNew = transitScheduleNew.getTransitLines().get(transitLineId); assertTrue(transitLineNew.getRoutes().containsKey(Id.create("161---17326_700_22_split1", TransitRoute.class))); @@ -867,23 +849,19 @@ void testSplitRoutes_MiddleIn_Hub_IncludeFirstHubInZone() { int inCntNew2 = countStopsInZone(transitRouteNew2, stopsInZone); - assertEquals("new route #1 should have three stops within zone", - 3, inCntNew1); - assertEquals("new route #2 should have four stops within zone", - 4, inCntNew2); + assertEquals(3, inCntNew1, "new route #1 should have three stops within zone"); + assertEquals(4, inCntNew2, "new route #2 should have four stops within zone"); Id idRoute1 = transitRouteNew1.getStops().get(transitRouteNew1.getStops().size() - 1).getStopFacility().getId(); - assertEquals("last stop of route #1 should be the left hub", - facIdLeft, idRoute1); + assertEquals(facIdLeft, idRoute1, "last stop of route #1 should be the left hub"); Id idRoute2 = transitRouteNew2.getStops().get(0).getStopFacility().getId(); - assertEquals("first stop of route #2 should be the right hub", - facIdRight, idRoute2); + assertEquals(facIdRight, idRoute2, "first stop of route #2 should be the right hub"); // Test vehicles Set> vehiclesUsedInTransitSchedule = getVehiclesUsedInTransitSchedule(transitScheduleNew); Set> vehiclesInVehiclesNew = results.getValue().getVehicles().keySet(); - Assert.assertTrue("TransitVehicles should contain all vehicles used in new TransitSchedule", - vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule)); + Assertions.assertTrue(vehiclesInVehiclesNew.containsAll(vehiclesUsedInTransitSchedule), + "TransitVehicles should contain all vehicles used in new TransitSchedule"); } /** @@ -930,7 +908,7 @@ void testSplitRoutes_MiddleIn_Hub_MultipleHubs() { // After trim TransitSchedule transitScheduleNew = results.getKey(); - assertTrue("line should still exist", transitScheduleNew.getTransitLines().containsKey(transitLineId)); + assertTrue(transitScheduleNew.getTransitLines().containsKey(transitLineId), "line should still exist"); TransitLine transitLineNew = transitScheduleNew.getTransitLines().get(transitLineId); assertTrue(transitLineNew.getRoutes().containsKey(Id.create("161---17326_700_22_split1", TransitRoute.class))); @@ -949,8 +927,8 @@ void testSplitRoutes_MiddleIn_Hub_MultipleHubs() { int inCntNew1 = countStopsInZone(transitRouteNew1, stopsInZone); int inCntNew2 = countStopsInZone(transitRouteNew2, stopsInZone); - assertEquals("new route #1 should have five stop within zone", 5, inCntNew1); - assertEquals("new route #2 should have one stop within zone", 1, inCntNew2); + assertEquals(5, inCntNew1, "new route #1 should have five stop within zone"); + assertEquals(1, inCntNew2, "new route #2 should have one stop within zone"); } @@ -987,7 +965,7 @@ void testSplitRoutes_MiddleIn_Hub_OverlapRoutes() { // After trim TransitSchedule transitScheduleNew = results.getKey(); - assertTrue("line should still exist", transitScheduleNew.getTransitLines().containsKey(transitLineId)); + assertTrue(transitScheduleNew.getTransitLines().containsKey(transitLineId), "line should still exist"); TransitLine transitLineNew = transitScheduleNew.getTransitLines().get(transitLineId); assertTrue(transitLineNew.getRoutes().containsKey(Id.create("161---17326_700_22_split1", TransitRoute.class))); @@ -1001,7 +979,7 @@ void testSplitRoutes_MiddleIn_Hub_OverlapRoutes() { assertEquals(transitRouteOld.getStops().size(), transitRouteNew1.getStops().size()); int inCntNew1 = countStopsInZone(transitRouteNew1, stopsInZone); - assertEquals("new route #1 should have 19 stops within zone", 19, inCntNew1); + assertEquals(19, inCntNew1, "new route #1 should have 19 stops within zone"); } @@ -1038,7 +1016,7 @@ void testSplitRoutes_MiddleIn_AllowableStopsWithin() { // After trim TransitSchedule transitScheduleNew = results.getKey(); - assertTrue("line should still exist", transitScheduleNew.getTransitLines().containsKey(transitLineId)); + assertTrue(transitScheduleNew.getTransitLines().containsKey(transitLineId), "line should still exist"); TransitLine transitLineNew = transitScheduleNew.getTransitLines().get(transitLineId); assertTrue(transitLineNew.getRoutes().containsKey(Id.create("161---17326_700_22_split1", TransitRoute.class))); @@ -1054,7 +1032,7 @@ void testSplitRoutes_MiddleIn_AllowableStopsWithin() { int inCntNew1 = countStopsInZone(routeNew1, stopsInZone); - assertEquals("new route #1 should have 19 stops within zone", 19, inCntNew1); + assertEquals(19, inCntNew1, "new route #1 should have 19 stops within zone"); } @@ -1085,7 +1063,7 @@ void testDeparturesAndOffsetsAndDescription() { // After trim TransitSchedule transitScheduleNew = results.getKey(); - assertTrue("line should still exist", transitScheduleNew.getTransitLines().containsKey(transitLineId)); + assertTrue(transitScheduleNew.getTransitLines().containsKey(transitLineId), "line should still exist"); TransitLine transitLineNew = transitScheduleNew.getTransitLines().get(transitLineId); assertTrue(transitLineNew.getRoutes().containsKey(Id.create("161---17326_700_22_split1", TransitRoute.class))); @@ -1102,15 +1080,15 @@ void testDeparturesAndOffsetsAndDescription() { //Start of left route TransitRouteStop routeNew1Start = transitRouteNew1.getStops().get(0); - Assert.assertEquals(0., routeNew1Start.getDepartureOffset().seconds(),0.); - Assert.assertEquals(0., routeNew1Start.getArrivalOffset().seconds(), 0.); + Assertions.assertEquals(0., routeNew1Start.getDepartureOffset().seconds(),0.); + Assertions.assertEquals(0., routeNew1Start.getArrivalOffset().seconds(), 0.); //End of first route TransitRouteStop routeNew1End = transitRouteNew1.getStops().get(routeNew1size - 1); TransitRouteStop routeOld1End = transitRouteOld.getStops().get(routeNew1size - 1); - Assert.assertEquals(routeOld1End.getDepartureOffset(), routeNew1End.getDepartureOffset()); - Assert.assertEquals(routeOld1End.getArrivalOffset(), routeNew1End.getArrivalOffset()); + Assertions.assertEquals(routeOld1End.getDepartureOffset(), routeNew1End.getDepartureOffset()); + Assertions.assertEquals(routeOld1End.getArrivalOffset(), routeNew1End.getArrivalOffset()); //Start of second route TransitRouteStop routeNew2Start = transitRouteNew2.getStops().get(0); @@ -1118,44 +1096,44 @@ void testDeparturesAndOffsetsAndDescription() { double deltaSeconds = routeOld2Start.getArrivalOffset().seconds(); - Assert.assertEquals(0., routeNew2Start.getDepartureOffset().seconds(), 0.); - Assert.assertEquals(0., routeNew2Start.getArrivalOffset().seconds(), 0.); + Assertions.assertEquals(0., routeNew2Start.getDepartureOffset().seconds(), 0.); + Assertions.assertEquals(0., routeNew2Start.getArrivalOffset().seconds(), 0.); //End of second route TransitRouteStop routeNew2End = transitRouteNew2.getStops().get(routeNew2Size - 1); TransitRouteStop routeOld2End = transitRouteOld.getStops().get(routeOldSize - 1); - Assert.assertEquals(routeOld2End.getDepartureOffset().seconds() - deltaSeconds, routeNew2End.getDepartureOffset().seconds(), 0.); - Assert.assertEquals(routeOld2End.getArrivalOffset().seconds() - deltaSeconds, routeNew2End.getArrivalOffset().seconds(), 0.); + Assertions.assertEquals(routeOld2End.getDepartureOffset().seconds() - deltaSeconds, routeNew2End.getDepartureOffset().seconds(), 0.); + Assertions.assertEquals(routeOld2End.getArrivalOffset().seconds() - deltaSeconds, routeNew2End.getArrivalOffset().seconds(), 0.); // Check Departures - Assert.assertEquals(transitRouteOld.getDepartures().size(), transitRouteNew1.getDepartures().size()); - Assert.assertEquals(transitRouteOld.getDepartures().size(), transitRouteNew2.getDepartures().size()); + Assertions.assertEquals(transitRouteOld.getDepartures().size(), transitRouteNew1.getDepartures().size()); + Assertions.assertEquals(transitRouteOld.getDepartures().size(), transitRouteNew2.getDepartures().size()); for (Departure departureOld : transitRouteOld.getDepartures().values()) { Id idOld = departureOld.getId(); double departureTimeOld = departureOld.getDepartureTime(); Id vehicleIdOld = departureOld.getVehicleId(); Id idNew1 = Id.create(idOld.toString() + "_split1", Departure.class); - Assert.assertTrue(transitRouteNew1.getDepartures().containsKey(idNew1)); + Assertions.assertTrue(transitRouteNew1.getDepartures().containsKey(idNew1)); Departure departureNew1 = transitRouteNew1.getDepartures().get(idNew1); - Assert.assertEquals(vehicleIdOld.toString() + "_split1", departureNew1.getVehicleId().toString()); - Assert.assertEquals(departureTimeOld, departureNew1.getDepartureTime(), 0.); + Assertions.assertEquals(vehicleIdOld.toString() + "_split1", departureNew1.getVehicleId().toString()); + Assertions.assertEquals(departureTimeOld, departureNew1.getDepartureTime(), 0.); Id idNew2 = Id.create(idOld.toString() + "_split2", Departure.class); - Assert.assertTrue(transitRouteNew2.getDepartures().containsKey(idNew2)); + Assertions.assertTrue(transitRouteNew2.getDepartures().containsKey(idNew2)); Departure departureNew2 = transitRouteNew2.getDepartures().get(idNew2); - Assert.assertEquals(vehicleIdOld.toString() + "_split2", departureNew2.getVehicleId().toString()); - Assert.assertEquals(departureTimeOld + deltaSeconds, departureNew2.getDepartureTime(), 0.); + Assertions.assertEquals(vehicleIdOld.toString() + "_split2", departureNew2.getVehicleId().toString()); + Assertions.assertEquals(departureTimeOld + deltaSeconds, departureNew2.getDepartureTime(), 0.); } - Assert.assertEquals("test123", transitRouteNew1.getDescription()); - Assert.assertEquals("test123", transitRouteNew2.getDescription()); + Assertions.assertEquals("test123", transitRouteNew1.getDescription()); + Assertions.assertEquals("test123", transitRouteNew2.getDescription()); - Assert.assertEquals(transitRouteOld.getTransportMode(), transitRouteNew1.getTransportMode()); - Assert.assertEquals(transitRouteOld.getTransportMode(), transitRouteNew2.getTransportMode()); + Assertions.assertEquals(transitRouteOld.getTransportMode(), transitRouteNew1.getTransportMode()); + Assertions.assertEquals(transitRouteOld.getTransportMode(), transitRouteNew2.getTransportMode()); // transitScheduleNew.getAttributes(); diff --git a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java index ba7aac9976a..dc39db4c237 100644 --- a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java @@ -1,7 +1,7 @@ package playground.vsp.scoring; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -116,19 +116,19 @@ void testMoneyScore(){ ScoringParameters paramsRich = personScoringParams.getScoringParameters(population.getPersons().get(Id.createPersonId("highIncome"))); CharyparNagelMoneyScoring moneyScoringRich = new CharyparNagelMoneyScoring(paramsRich); moneyScoringRich.addMoney(100); - Assert.assertEquals("for the rich person, 100 money units should be equal to a score of ", 20 * 1./1.5 * 100, moneyScoringRich.getScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(20 * 1./1.5 * 100, moneyScoringRich.getScore(), MatsimTestUtils.EPSILON, "for the rich person, 100 money units should be equal to a score of "); ScoringParameters paramsPoor = personScoringParams.getScoringParameters(population.getPersons().get(Id.createPersonId("lowIncome"))); CharyparNagelMoneyScoring moneyScoringPoor = new CharyparNagelMoneyScoring(paramsPoor); moneyScoringPoor.addMoney(100); - Assert.assertEquals("for the poor person, 100 money units should be equal to a score of ", 20 * 1./0.5 * 100, moneyScoringPoor.getScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(20 * 1./0.5 * 100, moneyScoringPoor.getScore(), MatsimTestUtils.EPSILON, "for the poor person, 100 money units should be equal to a score of "); - Assert.assertTrue("100 money units should worth more for a poor person than for a rich person", moneyScoringPoor.getScore() > moneyScoringRich.getScore()); + Assertions.assertTrue(moneyScoringPoor.getScore() > moneyScoringRich.getScore(), "100 money units should worth more for a poor person than for a rich person"); } private void makeAssert(ScoringParameters params, double income, double marginalUtilityOfWaitingPt_s){ - Assert.assertEquals("marginalUtilityOfMoney is wrong", 20 * 1 / income , params.marginalUtilityOfMoney, 0.); - Assert.assertEquals("marginalUtilityOfWaitingPt_s is wrong", marginalUtilityOfWaitingPt_s , params.marginalUtilityOfWaitingPt_s, 0.); + Assertions.assertEquals(20 * 1 / income , params.marginalUtilityOfMoney, 0., "marginalUtilityOfMoney is wrong"); + Assertions.assertEquals(marginalUtilityOfWaitingPt_s , params.marginalUtilityOfWaitingPt_s, 0., "marginalUtilityOfWaitingPt_s is wrong"); } diff --git a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java index a6c9cdbb8d0..35fa3d927ba 100644 --- a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java @@ -1,7 +1,7 @@ package playground.vsp.scoring; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -156,19 +156,19 @@ void testMoneyScore(){ ScoringParameters paramsRich = personScoringParams.getScoringParameters(population.getPersons().get(Id.createPersonId("highIncome"))); CharyparNagelMoneyScoring moneyScoringRich = new CharyparNagelMoneyScoring(paramsRich); moneyScoringRich.addMoney(100); - Assert.assertEquals("for the rich person, 100 money units should be equal to a score of 66.66", 1./1.5 * 100, moneyScoringRich.getScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1./1.5 * 100, moneyScoringRich.getScore(), MatsimTestUtils.EPSILON, "for the rich person, 100 money units should be equal to a score of 66.66"); ScoringParameters paramsPoor = personScoringParams.getScoringParameters(population.getPersons().get(Id.createPersonId("lowIncome"))); CharyparNagelMoneyScoring moneyScoringPoor = new CharyparNagelMoneyScoring(paramsPoor); moneyScoringPoor.addMoney(100); - Assert.assertEquals("for the poor person, 100 money units should be equal to a score of 200.00", 1./0.5 * 100, moneyScoringPoor.getScore(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1./0.5 * 100, moneyScoringPoor.getScore(), MatsimTestUtils.EPSILON, "for the poor person, 100 money units should be equal to a score of 200.00"); - Assert.assertTrue("100 money units should worth more for a poor person than for a rich person", moneyScoringPoor.getScore() > moneyScoringRich.getScore()); + Assertions.assertTrue(moneyScoringPoor.getScore() > moneyScoringRich.getScore(), "100 money units should worth more for a poor person than for a rich person"); } private void makeAssert(ScoringParameters params, double income, double marginalUtilityOfWaitingPt_s){ - Assert.assertEquals("marginalUtilityOfMoney is wrong", 1 / income , params.marginalUtilityOfMoney, 0.); - Assert.assertEquals("marginalUtilityOfWaitingPt_s is wrong", marginalUtilityOfWaitingPt_s , params.marginalUtilityOfWaitingPt_s, 0.); + Assertions.assertEquals(1 / income , params.marginalUtilityOfMoney, 0., "marginalUtilityOfMoney is wrong"); + Assertions.assertEquals(marginalUtilityOfWaitingPt_s , params.marginalUtilityOfWaitingPt_s, 0., "marginalUtilityOfWaitingPt_s is wrong"); } diff --git a/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java b/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java index eb432ad08a5..b9b49e15c95 100644 --- a/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java @@ -25,8 +25,8 @@ import ch.sbb.matsim.config.SwissRailRaptorConfigGroup.RouteSelectorParameterSet; import ch.sbb.matsim.routing.pt.raptor.RaptorStopFinder.Direction; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.core.config.Config; @@ -63,10 +63,10 @@ void testConfigIO_general() { SwissRailRaptorConfigGroup config2 = writeRead(config1); // do checks - Assert.assertTrue(config2.isUseRangeQuery()); - Assert.assertTrue(config2.isUseIntermodalAccessEgress()); - Assert.assertTrue(config2.isUseModeMappingForPassengers()); - Assert.assertEquals(0.0031 * 3600, config2.getTransferPenaltyCostPerTravelTimeHour(), 0.0); + Assertions.assertTrue(config2.isUseRangeQuery()); + Assertions.assertTrue(config2.isUseIntermodalAccessEgress()); + Assertions.assertTrue(config2.isUseModeMappingForPassengers()); + Assertions.assertEquals(0.0031 * 3600, config2.getTransferPenaltyCostPerTravelTimeHour(), 0.0); } @Test @@ -92,20 +92,20 @@ void testConfigIO_rangeQuery() { SwissRailRaptorConfigGroup config2 = writeRead(config1); // do checks - Assert.assertTrue(config2.isUseRangeQuery()); + Assertions.assertTrue(config2.isUseRangeQuery()); RangeQuerySettingsParameterSet range1 = config2.getRangeQuerySettings(null); - Assert.assertNotNull(range1); - Assert.assertEquals(0, range1.getSubpopulations().size()); - Assert.assertEquals(10*60, range1.getMaxEarlierDeparture()); - Assert.assertEquals(59*60, range1.getMaxLaterDeparture()); + Assertions.assertNotNull(range1); + Assertions.assertEquals(0, range1.getSubpopulations().size()); + Assertions.assertEquals(10*60, range1.getMaxEarlierDeparture()); + Assertions.assertEquals(59*60, range1.getMaxLaterDeparture()); RangeQuerySettingsParameterSet range2 = config2.getRangeQuerySettings("inflexible"); - Assert.assertNotNull(range2); - Assert.assertEquals(1, range2.getSubpopulations().size()); - Assert.assertEquals("inflexible", range2.getSubpopulations().iterator().next()); - Assert.assertEquals(60, range2.getMaxEarlierDeparture()); - Assert.assertEquals(15*60, range2.getMaxLaterDeparture()); + Assertions.assertNotNull(range2); + Assertions.assertEquals(1, range2.getSubpopulations().size()); + Assertions.assertEquals("inflexible", range2.getSubpopulations().iterator().next()); + Assertions.assertEquals(60, range2.getMaxEarlierDeparture()); + Assertions.assertEquals(15*60, range2.getMaxLaterDeparture()); } @Test @@ -133,21 +133,21 @@ void testConfigIO_routeSelector() { SwissRailRaptorConfigGroup config2 = writeRead(config1); // do checks - Assert.assertTrue(config2.isUseRangeQuery()); + Assertions.assertTrue(config2.isUseRangeQuery()); RouteSelectorParameterSet selector1 = config2.getRouteSelector(null); - Assert.assertNotNull(selector1); - Assert.assertEquals(0, selector1.getSubpopulations().size()); - Assert.assertEquals(600, selector1.getBetaTransfers(), 0.0); - Assert.assertEquals(1.6, selector1.getBetaDepartureTime(), 0.0); - Assert.assertEquals(1.3, selector1.getBetaTravelTime(), 0.0); + Assertions.assertNotNull(selector1); + Assertions.assertEquals(0, selector1.getSubpopulations().size()); + Assertions.assertEquals(600, selector1.getBetaTransfers(), 0.0); + Assertions.assertEquals(1.6, selector1.getBetaDepartureTime(), 0.0); + Assertions.assertEquals(1.3, selector1.getBetaTravelTime(), 0.0); RouteSelectorParameterSet selector2 = config2.getRouteSelector("inflexible"); - Assert.assertNotNull(selector2); - Assert.assertEquals(1, selector2.getSubpopulations().size()); - Assert.assertEquals(500, selector2.getBetaTransfers(), 0.0); - Assert.assertEquals(5, selector2.getBetaDepartureTime(), 0.0); - Assert.assertEquals(1.2, selector2.getBetaTravelTime(), 0.0); + Assertions.assertNotNull(selector2); + Assertions.assertEquals(1, selector2.getSubpopulations().size()); + Assertions.assertEquals(500, selector2.getBetaTransfers(), 0.0); + Assertions.assertEquals(5, selector2.getBetaDepartureTime(), 0.0); + Assertions.assertEquals(1.2, selector2.getBetaTravelTime(), 0.0); } @Test @@ -184,35 +184,35 @@ void testConfigIO_intermodalAccessEgress() { SwissRailRaptorConfigGroup config2 = writeRead(config1); // do checks - Assert.assertTrue(config2.isUseIntermodalAccessEgress()); + Assertions.assertTrue(config2.isUseIntermodalAccessEgress()); List parameterSets = config2.getIntermodalAccessEgressParameterSets(); - Assert.assertNotNull(parameterSets); - Assert.assertEquals("wrong number of parameter sets",2, parameterSets.size()); + Assertions.assertNotNull(parameterSets); + Assertions.assertEquals(2, parameterSets.size(), "wrong number of parameter sets"); IntermodalAccessEgressParameterSet paramSet1 = parameterSets.get(0); - Assert.assertEquals(TransportMode.bike, paramSet1.getMode()); - Assert.assertEquals(2000, paramSet1.getMaxRadius(), 0.0); - Assert.assertEquals(1500, paramSet1.getInitialSearchRadius(), 0.0); - Assert.assertEquals(1000, paramSet1.getSearchExtensionRadius(), 0.0); - Assert.assertEquals(0.01, paramSet1.getShareTripSearchRadius(), 0.0); - Assert.assertNull(paramSet1.getPersonFilterAttribute()); - Assert.assertNull(paramSet1.getPersonFilterValue()); - Assert.assertNull(paramSet1.getLinkIdAttribute()); - Assert.assertEquals("bikeAndRail", paramSet1.getStopFilterAttribute()); - Assert.assertEquals("true", paramSet1.getStopFilterValue()); + Assertions.assertEquals(TransportMode.bike, paramSet1.getMode()); + Assertions.assertEquals(2000, paramSet1.getMaxRadius(), 0.0); + Assertions.assertEquals(1500, paramSet1.getInitialSearchRadius(), 0.0); + Assertions.assertEquals(1000, paramSet1.getSearchExtensionRadius(), 0.0); + Assertions.assertEquals(0.01, paramSet1.getShareTripSearchRadius(), 0.0); + Assertions.assertNull(paramSet1.getPersonFilterAttribute()); + Assertions.assertNull(paramSet1.getPersonFilterValue()); + Assertions.assertNull(paramSet1.getLinkIdAttribute()); + Assertions.assertEquals("bikeAndRail", paramSet1.getStopFilterAttribute()); + Assertions.assertEquals("true", paramSet1.getStopFilterValue()); IntermodalAccessEgressParameterSet paramSet2 = parameterSets.get(1); - Assert.assertEquals("sff", paramSet2.getMode()); - Assert.assertEquals(5000, paramSet2.getMaxRadius(), 0.0); - Assert.assertEquals(3000, paramSet2.getInitialSearchRadius(), 0.0); - Assert.assertEquals(2000, paramSet2.getSearchExtensionRadius(), 0.0); - Assert.assertEquals(Double.POSITIVE_INFINITY, paramSet2.getShareTripSearchRadius(), 0.0); - Assert.assertEquals("sff_user", paramSet2.getPersonFilterAttribute()); - Assert.assertEquals("true", paramSet2.getPersonFilterValue()); - Assert.assertEquals("linkId_sff", paramSet2.getLinkIdAttribute()); - Assert.assertEquals("stop-type", paramSet2.getStopFilterAttribute()); - Assert.assertEquals("hub", paramSet2.getStopFilterValue()); + Assertions.assertEquals("sff", paramSet2.getMode()); + Assertions.assertEquals(5000, paramSet2.getMaxRadius(), 0.0); + Assertions.assertEquals(3000, paramSet2.getInitialSearchRadius(), 0.0); + Assertions.assertEquals(2000, paramSet2.getSearchExtensionRadius(), 0.0); + Assertions.assertEquals(Double.POSITIVE_INFINITY, paramSet2.getShareTripSearchRadius(), 0.0); + Assertions.assertEquals("sff_user", paramSet2.getPersonFilterAttribute()); + Assertions.assertEquals("true", paramSet2.getPersonFilterValue()); + Assertions.assertEquals("linkId_sff", paramSet2.getLinkIdAttribute()); + Assertions.assertEquals("stop-type", paramSet2.getStopFilterAttribute()); + Assertions.assertEquals("hub", paramSet2.getStopFilterValue()); } @Test @@ -241,25 +241,25 @@ void testConfigIO_modeMappings() { SwissRailRaptorConfigGroup config2 = writeRead(config1); // do checks - Assert.assertTrue(config2.isUseModeMappingForPassengers()); + Assertions.assertTrue(config2.isUseModeMappingForPassengers()); ModeMappingForPassengersParameterSet trainMapping = config2.getModeMappingForPassengersParameterSet("train"); - Assert.assertNotNull(trainMapping); - Assert.assertEquals("train", trainMapping.getRouteMode()); - Assert.assertEquals("rail", trainMapping.getPassengerMode()); + Assertions.assertNotNull(trainMapping); + Assertions.assertEquals("train", trainMapping.getRouteMode()); + Assertions.assertEquals("rail", trainMapping.getPassengerMode()); ModeMappingForPassengersParameterSet tramMapping = config2.getModeMappingForPassengersParameterSet("tram"); - Assert.assertNotNull(tramMapping); - Assert.assertEquals("tram", tramMapping.getRouteMode()); - Assert.assertEquals("rail", tramMapping.getPassengerMode()); + Assertions.assertNotNull(tramMapping); + Assertions.assertEquals("tram", tramMapping.getRouteMode()); + Assertions.assertEquals("rail", tramMapping.getPassengerMode()); ModeMappingForPassengersParameterSet busMapping = config2.getModeMappingForPassengersParameterSet("bus"); - Assert.assertNotNull(busMapping); - Assert.assertEquals("bus", busMapping.getRouteMode()); - Assert.assertEquals("road", busMapping.getPassengerMode()); + Assertions.assertNotNull(busMapping); + Assertions.assertEquals("bus", busMapping.getRouteMode()); + Assertions.assertEquals("road", busMapping.getPassengerMode()); - Assert.assertNull(config2.getModeMappingForPassengersParameterSet("road")); - Assert.assertNull(config2.getModeMappingForPassengersParameterSet("ship")); + Assertions.assertNull(config2.getModeMappingForPassengersParameterSet("road")); + Assertions.assertNull(config2.getModeMappingForPassengersParameterSet("ship")); } private SwissRailRaptorConfigGroup writeRead(SwissRailRaptorConfigGroup config) { diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/CapacityDependentScoringTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/CapacityDependentScoringTest.java index 0518b08dcf2..5ea67dc3642 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/CapacityDependentScoringTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/CapacityDependentScoringTest.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -91,8 +91,8 @@ void testScoring() { // in the normal case, it's a 15min trips at full cost, so it should be -6 * (1/4) = -1.5 // in the capacity dependent case, the vehicle is empty plus the passenger => occupancy = 0.2, thus the cost should only be 0.8 * original cost => -1.2 - Assert.assertEquals(-1.5, normalScore, 1e-7); - Assert.assertEquals(-1.2, capDepScore, 1e-7); + Assertions.assertEquals(-1.5, normalScore, 1e-7); + Assertions.assertEquals(-1.2, capDepScore, 1e-7); } private double calcScore(Fixture f, boolean capacityDependent) { diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/OccupancyTrackerTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/OccupancyTrackerTest.java index 809f316a4bd..9e362705b7a 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/OccupancyTrackerTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/OccupancyTrackerTest.java @@ -20,7 +20,7 @@ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.routing.pt.raptor.OccupancyData.DepartureData; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -67,67 +67,67 @@ void testGetNextDeparture() { DepartureData data; data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("06:45:00")); // before there is any vehicle - Assert.assertEquals(f.dep0, data.departureId); + Assertions.assertEquals(f.dep0, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("06:55:00")); // before we have any pax observations - Assert.assertEquals(f.dep0, data.departureId); + Assertions.assertEquals(f.dep0, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:00:00")); - Assert.assertEquals(f.dep0, data.departureId); + Assertions.assertEquals(f.dep0, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:00:30")); - Assert.assertEquals(f.dep0, data.departureId); + Assertions.assertEquals(f.dep0, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:00:31")); - Assert.assertEquals(f.dep1, data.departureId); + Assertions.assertEquals(f.dep1, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:05:00")); - Assert.assertEquals(f.dep1, data.departureId); + Assertions.assertEquals(f.dep1, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:06:00")); - Assert.assertEquals(f.dep1, data.departureId); + Assertions.assertEquals(f.dep1, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:06:01")); - Assert.assertEquals(f.dep2, data.departureId); + Assertions.assertEquals(f.dep2, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:11:00")); - Assert.assertEquals(f.dep2, data.departureId); + Assertions.assertEquals(f.dep2, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:11:01")); - Assert.assertEquals(f.dep3, data.departureId); + Assertions.assertEquals(f.dep3, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:18:00")); - Assert.assertEquals(f.dep3, data.departureId); + Assertions.assertEquals(f.dep3, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:18:05")); - Assert.assertEquals(f.dep3, data.departureId); + Assertions.assertEquals(f.dep3, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:22:00")); - Assert.assertEquals(f.dep3, data.departureId); + Assertions.assertEquals(f.dep3, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:24:00")); - Assert.assertEquals(f.dep3, data.departureId); + Assertions.assertEquals(f.dep3, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:24:03")); - Assert.assertEquals(f.dep5, data.departureId); + Assertions.assertEquals(f.dep5, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:29:00")); - Assert.assertEquals(f.dep5, data.departureId); + Assertions.assertEquals(f.dep5, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:35:00")); - Assert.assertEquals(f.dep5, data.departureId); + Assertions.assertEquals(f.dep5, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:40:00")); - Assert.assertEquals(f.dep5, data.departureId); + Assertions.assertEquals(f.dep5, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:50:00")); - Assert.assertEquals(f.dep5, data.departureId); + Assertions.assertEquals(f.dep5, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:50:05")); - Assert.assertEquals(f.dep5, data.departureId); + Assertions.assertEquals(f.dep5, data.departureId); data = occData.getNextAvailableDeparture(f.line1, f.route1, f.stop1, Time.parseTime("07:50:30")); - Assert.assertNull(data); + Assertions.assertNull(data); } @Test @@ -144,22 +144,22 @@ void testGetDepartureData() { DepartureData data; data = occData.getDepartureData(f.line1, f.route1, f.stop1, f.dep0); - Assert.assertEquals(0, data.paxCountAtDeparture); + Assertions.assertEquals(0, data.paxCountAtDeparture); data = occData.getDepartureData(f.line1, f.route1, f.stop1, f.dep1); - Assert.assertEquals(2, data.paxCountAtDeparture); + Assertions.assertEquals(2, data.paxCountAtDeparture); data = occData.getDepartureData(f.line1, f.route1, f.stop1, f.dep2); - Assert.assertEquals(2, data.paxCountAtDeparture); + Assertions.assertEquals(2, data.paxCountAtDeparture); data = occData.getDepartureData(f.line1, f.route1, f.stop1, f.dep3); - Assert.assertEquals(3, data.paxCountAtDeparture); + Assertions.assertEquals(3, data.paxCountAtDeparture); data = occData.getDepartureData(f.line1, f.route1, f.stop1, f.dep4); - Assert.assertEquals(0, data.paxCountAtDeparture); + Assertions.assertEquals(0, data.paxCountAtDeparture); data = occData.getDepartureData(f.line1, f.route1, f.stop1, f.dep5); - Assert.assertEquals(1, data.paxCountAtDeparture); + Assertions.assertEquals(1, data.paxCountAtDeparture); } private static class Fixture { diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java index 1fe325b7801..1fad2beca84 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java @@ -20,7 +20,7 @@ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -104,7 +104,7 @@ void testDefaultStopFinder_EmptyInitialSearchRadius() { List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(this.fromFac, this.toFac, 7 * 3600, f0.dummyPerson)); - Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); + Assertions.assertNull(legs, "The router should not find a route and return null, but did return something else."); } @@ -135,19 +135,19 @@ void testDefaultStopFinder_EmptyInitialSearchRadius() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -179,19 +179,19 @@ void testDefaultStopFinder_EmptyInitialSearchRadius() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("DD", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("DD", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("DD", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("DD", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } } @@ -233,7 +233,7 @@ void testDefaultStopFinder_EmptyInitialSearchRadius_StopFilterAttributes() { List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(this.fromFac, this.toFac, 7 * 3600, f0.dummyPerson)); - Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); + Assertions.assertNull(legs, "The router should not find a route and return null, but did return something else."); } @@ -270,19 +270,19 @@ void testDefaultStopFinder_EmptyInitialSearchRadius_StopFilterAttributes() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -321,19 +321,19 @@ void testDefaultStopFinder_EmptyInitialSearchRadius_StopFilterAttributes() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -376,19 +376,19 @@ Initial_Search_Radius includes B (not "walkAccessible") System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("DD", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("DD", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("DD", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("DD", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } } @@ -421,7 +421,7 @@ void testRandomAccessEgressModeRaptorStopFinder_EmptyInitialSearchRadius() { List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(this.fromFac, this.toFac, 7 * 3600, f0.dummyPerson)); - Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); + Assertions.assertNull(legs, "The router should not find a route and return null, but did return something else."); } @@ -453,19 +453,19 @@ void testRandomAccessEgressModeRaptorStopFinder_EmptyInitialSearchRadius() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -497,19 +497,19 @@ void testRandomAccessEgressModeRaptorStopFinder_EmptyInitialSearchRadius() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("DD", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("DD", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("DD", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("DD", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } } @@ -551,7 +551,7 @@ void testRandomAccessEgressModeRaptorStopFinder_EmptyInitialSearchRadius_StopFil List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(this.fromFac, this.toFac, 7 * 3600, f0.dummyPerson)); - Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); + Assertions.assertNull(legs, "The router should not find a route and return null, but did return something else."); } @@ -589,19 +589,19 @@ void testRandomAccessEgressModeRaptorStopFinder_EmptyInitialSearchRadius_StopFil System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -641,19 +641,19 @@ void testRandomAccessEgressModeRaptorStopFinder_EmptyInitialSearchRadius_StopFil System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -697,19 +697,19 @@ Initial_Search_Radius includes B (not "walkAccessible") System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("DD", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("DD", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("DD", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("DD", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } } @@ -758,19 +758,19 @@ void testDefaultStopFinder_HalfFullInitialSearchRadius() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -803,19 +803,19 @@ void testDefaultStopFinder_HalfFullInitialSearchRadius() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -848,19 +848,19 @@ void testDefaultStopFinder_HalfFullInitialSearchRadius() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } } @@ -902,19 +902,19 @@ void testDefaultStopFinder_HalfFullInitialSearchRadius_StopFilterAttributes() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -954,19 +954,19 @@ void testDefaultStopFinder_HalfFullInitialSearchRadius_StopFilterAttributes() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } } @@ -1002,19 +1002,19 @@ void testRandomAccessEgressModeRaptorStopFinder_HalfFullInitialSearchRadius() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -1048,19 +1048,19 @@ void testRandomAccessEgressModeRaptorStopFinder_HalfFullInitialSearchRadius() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -1094,19 +1094,19 @@ void testRandomAccessEgressModeRaptorStopFinder_HalfFullInitialSearchRadius() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } } @@ -1149,19 +1149,19 @@ void testRandomAccessEgressModeRaptorStopFinder_HalfFullInitialSearchRadius_Stop System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -1202,19 +1202,19 @@ void testRandomAccessEgressModeRaptorStopFinder_HalfFullInitialSearchRadius_Stop System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } } @@ -1265,19 +1265,19 @@ void testDefaultStopFinder_FullInitialSearchRadius() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -1312,19 +1312,19 @@ void testDefaultStopFinder_FullInitialSearchRadius() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } } @@ -1370,19 +1370,19 @@ void testDefaultStopFinder_FullInitialSearchRadius_StopFilterAttributes() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -1425,19 +1425,19 @@ void testDefaultStopFinder_FullInitialSearchRadius_StopFilterAttributes() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -1477,19 +1477,19 @@ void testRandomAccessEgressModeRaptorStopFinder_FullInitialSearchRadius() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -1525,19 +1525,19 @@ void testRandomAccessEgressModeRaptorStopFinder_FullInitialSearchRadius() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } } @@ -1584,19 +1584,19 @@ void testRandomAccessEgressModeRaptorStopFinder_FullInitialSearchRadius_StopFilt System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -1640,19 +1640,19 @@ void testRandomAccessEgressModeRaptorStopFinder_FullInitialSearchRadius_StopFilt System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("CC", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -1713,19 +1713,19 @@ void testDefaultStopFinder_testMultipleModes() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals("zoomer", leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("DD", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals("zoomer", leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("DD", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("DD", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("DD", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -1779,19 +1779,19 @@ void testDefaultStopFinder_testMultipleModes() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals("zoomer", leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("DD", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals("zoomer", leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("DD", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("DD", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("DD", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); } @@ -1841,15 +1841,15 @@ void testDefaultStopFinder_testMultipleModes() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.bike, leg.getMode()); - Assert.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.bike, leg.getMode()); + Assertions.assertEquals(Id.create("AA", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("BB", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("XX", Link.class), leg.getRoute().getEndLinkId()); // leg = legs.get(2); // Assert.assertEquals(TransportMode.bike, leg.getMode()); // Assert.assertEquals(Id.create("XX", Link.class), leg.getRoute().getStartLinkId()); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtilsTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtilsTest.java index d401ec3ba52..6033cbdfdbd 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtilsTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtilsTest.java @@ -20,8 +20,8 @@ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigGroup; @@ -63,24 +63,24 @@ void testConfigLoading() { // first checks ConfigGroup srrConfig2 = config2.getModules().get(SwissRailRaptorConfigGroup.GROUP); - Assert.assertNotNull(srrConfig2); - Assert.assertEquals(ConfigGroup.class, srrConfig2.getClass()); + Assertions.assertNotNull(srrConfig2); + Assertions.assertEquals(ConfigGroup.class, srrConfig2.getClass()); // create RaptorConfig, test if SwissRailRaptorConfigGroup got created RaptorParameters raptorParams = RaptorUtils.createParameters(config2); srrConfig2 = config2.getModules().get(SwissRailRaptorConfigGroup.GROUP); - Assert.assertNotNull(srrConfig2); - Assert.assertEquals(SwissRailRaptorConfigGroup.class, srrConfig2.getClass()); + Assertions.assertNotNull(srrConfig2); + Assertions.assertEquals(SwissRailRaptorConfigGroup.class, srrConfig2.getClass()); - Assert.assertNotNull(raptorParams.getConfig()); - Assert.assertEquals(srrConfig2, raptorParams.getConfig()); + Assertions.assertNotNull(raptorParams.getConfig()); + Assertions.assertEquals(srrConfig2, raptorParams.getConfig()); RaptorParameters raptorParams2 = RaptorUtils.createParameters(config2); - Assert.assertEquals("the same config object should be returned in subsequent calls.", srrConfig2, raptorParams2.getConfig()); + Assertions.assertEquals(srrConfig2, raptorParams2.getConfig(), "the same config object should be returned in subsequent calls."); // check that the config is actually what we configured - Assert.assertTrue(raptorParams2.getConfig().isUseRangeQuery()); - Assert.assertTrue(raptorParams2.getConfig().isUseIntermodalAccessEgress()); - Assert.assertFalse(raptorParams2.getConfig().isUseModeMappingForPassengers()); + Assertions.assertTrue(raptorParams2.getConfig().isUseRangeQuery()); + Assertions.assertTrue(raptorParams2.getConfig().isUseIntermodalAccessEgress()); + Assertions.assertFalse(raptorParams2.getConfig().isUseModeMappingForPassengers()); } } diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCapacitiesTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCapacitiesTest.java index eaa6c0ddfc6..7ad33007806 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCapacitiesTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCapacitiesTest.java @@ -20,7 +20,7 @@ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -89,23 +89,23 @@ void testUseSlowerAlternative() { Facility toFacility = new FakeFacility(new Coord(7100, 1100), Id.create("cd", Link.class)); List route1 = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFacility, toFacility, Time.parseTime("07:00:00"), null)); - Assert.assertNotNull(route1); + Assertions.assertNotNull(route1); System.out.println("uncongested route:"); for (PlanElement leg : route1) { System.out.println(leg.toString() + " > " + ((Leg)leg).getRoute().getRouteDescription()); } - Assert.assertEquals(3, route1.size()); + Assertions.assertEquals(3, route1.size()); Leg leg1 = (Leg) route1.get(0); - Assert.assertEquals("walk", leg1.getMode()); + Assertions.assertEquals("walk", leg1.getMode()); Leg leg2 = (Leg) route1.get(1); - Assert.assertEquals("pt", leg2.getMode()); + Assertions.assertEquals("pt", leg2.getMode()); TransitPassengerRoute paxRoute1 = (TransitPassengerRoute) leg2.getRoute(); - Assert.assertEquals(f.fastLineId, paxRoute1.getLineId()); + Assertions.assertEquals(f.fastLineId, paxRoute1.getLineId()); Leg leg3 = (Leg) route1.get(2); - Assert.assertEquals("walk", leg3.getMode()); + Assertions.assertEquals("walk", leg3.getMode()); // with delays at entering @@ -192,23 +192,23 @@ void testUseSlowerAlternative() { tracker.handleEvent(new VehicleDepartsAtFacilityEvent(Time.parseTime("07:20:30"), vehicle3, f.stopAId, 0)); List route2 = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFacility, toFacility, Time.parseTime("07:00:00"), null)); - Assert.assertNotNull(route2); + Assertions.assertNotNull(route2); System.out.println("congested route:"); for (PlanElement leg : route2) { System.out.println(leg.toString() + " > " + ((Leg)leg).getRoute().getRouteDescription()); } - Assert.assertEquals(3, route2.size()); + Assertions.assertEquals(3, route2.size()); leg1 = (Leg) route2.get(0); - Assert.assertEquals("walk", leg1.getMode()); + Assertions.assertEquals("walk", leg1.getMode()); leg2 = (Leg) route2.get(1); - Assert.assertEquals("pt", leg2.getMode()); + Assertions.assertEquals("pt", leg2.getMode()); TransitPassengerRoute paxRoute2 = (TransitPassengerRoute) leg2.getRoute(); - Assert.assertEquals(f.slowLineId, paxRoute2.getLineId()); + Assertions.assertEquals(f.slowLineId, paxRoute2.getLineId()); leg3 = (Leg) route2.get(2); - Assert.assertEquals("walk", leg3.getMode()); + Assertions.assertEquals("walk", leg3.getMode()); } private static class Fixture { diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorDataTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorDataTest.java index 6fbd90145a8..e28bd02ea2f 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorDataTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorDataTest.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.pt.transitSchedule.api.TransitStopFacility; @@ -47,7 +47,7 @@ void testTransfersFromSchedule() { TransitStopFacility fromStop = data.routeStops[t.fromRouteStop].routeStop.getStopFacility(); TransitStopFacility toStop = data.routeStops[t.toRouteStop].routeStop.getStopFacility(); if (fromStop.getId().equals(stopId19) && toStop.getId().equals(stopId9)) { - Assert.fail("There should not be any transfer between stop facilities 19 and 9."); + Assertions.fail("There should not be any transfer between stop facilities 19 and 9."); } } @@ -63,8 +63,8 @@ void testTransfersFromSchedule() { foundTransferCount++; } } - Assert.assertEquals("wrong number of transfers between stop facilities 19 and 9.", 1, foundTransferCount); - Assert.assertEquals("number of transfers should have incrased.", data.transfers.length + 1, data2.transfers.length); + Assertions.assertEquals(1, foundTransferCount, "wrong number of transfers between stop facilities 19 and 9."); + Assertions.assertEquals(data.transfers.length + 1, data2.transfers.length, "number of transfers should have incrased."); // assign a high transfer time to a "default" transfer f.schedule.getMinimalTransferTimes().set(stopId5, stopId18, 456); @@ -74,12 +74,12 @@ void testTransfersFromSchedule() { TransitStopFacility fromStop = data3.routeStops[t.fromRouteStop].routeStop.getStopFacility(); TransitStopFacility toStop = data3.routeStops[t.toRouteStop].routeStop.getStopFacility(); if (fromStop.getId().equals(stopId5) && toStop.getId().equals(stopId18)) { - Assert.assertEquals("transfer has wrong transfer time.", 456, t.transferTime); + Assertions.assertEquals(456, t.transferTime, "transfer has wrong transfer time."); foundCorrectTransfer = true; } } - Assert.assertTrue("did not find overwritten transfer", foundCorrectTransfer); - Assert.assertEquals("number of transfers should have stayed the same.", data2.transfers.length, data3.transfers.length); + Assertions.assertTrue(foundCorrectTransfer, "did not find overwritten transfer"); + Assertions.assertEquals(data2.transfers.length, data3.transfers.length, "number of transfers should have stayed the same."); // assign a low transfer time to a "default" transfer f.schedule.getMinimalTransferTimes().set(stopId5, stopId18, 0.2); @@ -89,12 +89,12 @@ void testTransfersFromSchedule() { TransitStopFacility fromStop = data4.routeStops[t.fromRouteStop].routeStop.getStopFacility(); TransitStopFacility toStop = data4.routeStops[t.toRouteStop].routeStop.getStopFacility(); if (fromStop.getId().equals(stopId5) && toStop.getId().equals(stopId18)) { - Assert.assertEquals("transfer has wrong transfer time.", 1, t.transferTime); // transferTime gets rounded up to int vlues + Assertions.assertEquals(1, t.transferTime, "transfer has wrong transfer time."); // transferTime gets rounded up to int vlues foundCorrectTransfer = true; } } - Assert.assertTrue("did not find overwritten transfer", foundCorrectTransfer); - Assert.assertEquals("number of transfers should have stayed the same.", data2.transfers.length, data4.transfers.length); + Assertions.assertTrue(foundCorrectTransfer, "did not find overwritten transfer"); + Assertions.assertEquals(data2.transfers.length, data4.transfers.length, "number of transfers should have stayed the same."); } } diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorInVehicleCostTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorInVehicleCostTest.java index 05aa44fe5d2..846b4ee2cbe 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorInVehicleCostTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorInVehicleCostTest.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -142,25 +142,25 @@ private void runTest(Fixture f, RaptorInVehicleCostCalculator inVehCostCalcualto Facility toFacility = new FakeFacility(new Coord(7100, 1100), Id.create("cd", Link.class)); List route1 = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFacility, toFacility, Time.parseTime("07:00:00"), null)); - Assert.assertNotNull(route1); + Assertions.assertNotNull(route1); System.out.println("calculated route:"); for (PlanElement leg : route1) { System.out.println(leg.toString() + " > " + ((Leg)leg).getRoute().getRouteDescription()); } - Assert.assertEquals(3, route1.size()); + Assertions.assertEquals(3, route1.size()); Leg leg1 = (Leg) route1.get(0); - Assert.assertEquals("walk", leg1.getMode()); + Assertions.assertEquals("walk", leg1.getMode()); Leg leg2 = (Leg) route1.get(1); - Assert.assertEquals("pt", leg2.getMode()); + Assertions.assertEquals("pt", leg2.getMode()); TransitPassengerRoute paxRoute1 = (TransitPassengerRoute) leg2.getRoute(); - Assert.assertEquals(expectedTransitLine, paxRoute1.getLineId()); + Assertions.assertEquals(expectedTransitLine, paxRoute1.getLineId()); Leg leg3 = (Leg) route1.get(2); - Assert.assertEquals("walk", leg3.getMode()); + Assertions.assertEquals("walk", leg3.getMode()); } private void fillExecutionTracker(Fixture f, OccupancyTracker tracker) { diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java index 61ddb4ba6de..919dbbc9b4b 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java @@ -21,7 +21,7 @@ import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup.IntermodalAccessEgressParameterSet; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -110,27 +110,27 @@ void testIntermodalTrip() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 5, legs.size()); + Assertions.assertEquals(5, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.bike, leg.getMode()); - Assert.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("bike_3", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.bike, leg.getMode()); + Assertions.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("bike_3", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("bike_3", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("bike_3", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(3); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("bike_5", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("bike_5", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(4); - Assert.assertEquals(TransportMode.bike, leg.getMode()); - Assert.assertEquals(Id.create("bike_5", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.bike, leg.getMode()); + Assertions.assertEquals(Id.create("bike_5", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } @Test @@ -186,32 +186,32 @@ void testIntermodalTrip_TripRouterIntegration() { System.out.println(pe); } - Assert.assertEquals("wrong number of PlanElements.", 9, planElements.size()); - Assert.assertTrue(planElements.get(0) instanceof Leg); - Assert.assertTrue(planElements.get(1) instanceof Activity); - Assert.assertTrue(planElements.get(2) instanceof Leg); - Assert.assertTrue(planElements.get(3) instanceof Activity); - Assert.assertTrue(planElements.get(4) instanceof Leg); - Assert.assertTrue(planElements.get(5) instanceof Activity); - Assert.assertTrue(planElements.get(6) instanceof Leg); - Assert.assertTrue(planElements.get(7) instanceof Activity); - Assert.assertTrue(planElements.get(8) instanceof Leg); - - Assert.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(1)).getType()); - Assert.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(3)).getType()); - Assert.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(5)).getType()); - Assert.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(7)).getType()); - - Assert.assertEquals(TransportMode.bike, ((Leg) planElements.get(0)).getMode()); - Assert.assertEquals(TransportMode.walk, ((Leg) planElements.get(2)).getMode()); - Assert.assertEquals(TransportMode.pt, ((Leg) planElements.get(4)).getMode()); - Assert.assertEquals(TransportMode.walk, ((Leg) planElements.get(6)).getMode()); - Assert.assertEquals(TransportMode.bike, ((Leg) planElements.get(8)).getMode()); - - Assert.assertEquals(0.0, ((Activity)planElements.get(1)).getMaximumDuration().seconds(), 0.0); - Assert.assertEquals(0.0, ((Activity)planElements.get(3)).getMaximumDuration().seconds(), 0.0); - Assert.assertEquals(0.0, ((Activity)planElements.get(5)).getMaximumDuration().seconds(), 0.0); - Assert.assertEquals(0.0, ((Activity)planElements.get(7)).getMaximumDuration().seconds(), 0.0); + Assertions.assertEquals(9, planElements.size(), "wrong number of PlanElements."); + Assertions.assertTrue(planElements.get(0) instanceof Leg); + Assertions.assertTrue(planElements.get(1) instanceof Activity); + Assertions.assertTrue(planElements.get(2) instanceof Leg); + Assertions.assertTrue(planElements.get(3) instanceof Activity); + Assertions.assertTrue(planElements.get(4) instanceof Leg); + Assertions.assertTrue(planElements.get(5) instanceof Activity); + Assertions.assertTrue(planElements.get(6) instanceof Leg); + Assertions.assertTrue(planElements.get(7) instanceof Activity); + Assertions.assertTrue(planElements.get(8) instanceof Leg); + + Assertions.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(1)).getType()); + Assertions.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(3)).getType()); + Assertions.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(5)).getType()); + Assertions.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(7)).getType()); + + Assertions.assertEquals(TransportMode.bike, ((Leg) planElements.get(0)).getMode()); + Assertions.assertEquals(TransportMode.walk, ((Leg) planElements.get(2)).getMode()); + Assertions.assertEquals(TransportMode.pt, ((Leg) planElements.get(4)).getMode()); + Assertions.assertEquals(TransportMode.walk, ((Leg) planElements.get(6)).getMode()); + Assertions.assertEquals(TransportMode.bike, ((Leg) planElements.get(8)).getMode()); + + Assertions.assertEquals(0.0, ((Activity)planElements.get(1)).getMaximumDuration().seconds(), 0.0); + Assertions.assertEquals(0.0, ((Activity)planElements.get(3)).getMaximumDuration().seconds(), 0.0); + Assertions.assertEquals(0.0, ((Activity)planElements.get(5)).getMaximumDuration().seconds(), 0.0); + Assertions.assertEquals(0.0, ((Activity)planElements.get(7)).getMaximumDuration().seconds(), 0.0); } @Test @@ -247,19 +247,19 @@ void testIntermodalTrip_walkOnlyNoSubpop() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_2", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_2", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("pt_2", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("pt_2", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } /** @@ -299,7 +299,7 @@ void testIntermodalTrip_withoutPt() { List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac, toFac, 7*3600, f.dummyPerson)); - Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); + Assertions.assertNull(legs, "The router should not find a route and return null, but did return something else."); } @Test @@ -352,11 +352,11 @@ void testDirectWalkFactor() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 1, legs.size()); + Assertions.assertEquals(1, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); // direct walk factor on f.config.transitRouter().setDirectWalkFactor(Double.POSITIVE_INFINITY); @@ -369,27 +369,27 @@ void testDirectWalkFactor() { System.out.println(leg1); } - Assert.assertEquals("wrong number of legs.", 5, legs.size()); + Assertions.assertEquals(5, legs.size(), "wrong number of legs."); leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.bike, leg.getMode()); - Assert.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("bike_0", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.bike, leg.getMode()); + Assertions.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("bike_0", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("bike_0", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_0", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("bike_0", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_0", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("pt_0", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("pt_0", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(3); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("bike_3", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("bike_3", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(4); - Assert.assertEquals(TransportMode.bike, leg.getMode()); - Assert.assertEquals(Id.create("bike_3", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.bike, leg.getMode()); + Assertions.assertEquals(Id.create("bike_3", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } @Test @@ -449,39 +449,39 @@ void testAccessEgressModeFasterThanPt() { //returnNull data.config.setIntermodalLegOnlyHandling(SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling.returnNull); List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac, toFac, 7*3600, f.dummyPerson)); - Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); + Assertions.assertNull(legs, "The router should not find a route and return null, but did return something else."); legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac2, toFac2, 7*3600, f.dummyPerson)); - Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); + Assertions.assertNull(legs, "The router should not find a route and return null, but did return something else."); //forbid data.config.setIntermodalLegOnlyHandling(SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling.forbid); legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac, toFac, 7*3600, f.dummyPerson)); - Assert.assertNotNull("The router should find a pt route and not return null, but did return null", legs); - Assert.assertTrue( legs.stream().filter(Leg.class::isInstance).anyMatch(planElement -> ((Leg) planElement).getMode().equals(TransportMode.pt))); + Assertions.assertNotNull(legs, "The router should find a pt route and not return null, but did return null"); + Assertions.assertTrue( legs.stream().filter(Leg.class::isInstance).anyMatch(planElement -> ((Leg) planElement).getMode().equals(TransportMode.pt))); legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac2, toFac2, 7*3600, f.dummyPerson)); - Assert.assertNull("The router should not find a pt route and return null, but did return something else", legs); + Assertions.assertNull(legs, "The router should not find a pt route and return null, but did return something else"); //avoid data.config.setIntermodalLegOnlyHandling(SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling.avoid); legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac, toFac, 7*3600, f.dummyPerson)); - Assert.assertNotNull("The router should find a pt route and not return null, but did return null", legs); - Assert.assertTrue( legs.stream().filter(Leg.class::isInstance).anyMatch(planElement -> ((Leg) planElement).getMode().equals(TransportMode.pt))); + Assertions.assertNotNull(legs, "The router should find a pt route and not return null, but did return null"); + Assertions.assertTrue( legs.stream().filter(Leg.class::isInstance).anyMatch(planElement -> ((Leg) planElement).getMode().equals(TransportMode.pt))); legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac2, toFac2, 7*3600, f.dummyPerson)); - Assert.assertNotNull("The router should find a pt route and not return null, but did return null", legs); - Assert.assertFalse( legs.stream().filter(Leg.class::isInstance).anyMatch(planElement -> ((Leg) planElement).getMode().equals(TransportMode.pt))); + Assertions.assertNotNull(legs, "The router should find a pt route and not return null, but did return null"); + Assertions.assertFalse( legs.stream().filter(Leg.class::isInstance).anyMatch(planElement -> ((Leg) planElement).getMode().equals(TransportMode.pt))); //allow data.config.setIntermodalLegOnlyHandling(SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling.allow); legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac, toFac, 7*3600, f.dummyPerson)); - Assert.assertFalse( legs.stream().filter(Leg.class::isInstance).anyMatch(planElement -> ((Leg) planElement).getMode().equals(TransportMode.pt))); - Assert.assertNotNull("The router should find a pt route and not return null, but did return something else.", legs); + Assertions.assertFalse( legs.stream().filter(Leg.class::isInstance).anyMatch(planElement -> ((Leg) planElement).getMode().equals(TransportMode.pt))); + Assertions.assertNotNull(legs, "The router should find a pt route and not return null, but did return something else."); legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac2, toFac2, 7*3600, f.dummyPerson)); - Assert.assertNotNull("The router should find a pt route and not return null, but did return null", legs); - Assert.assertFalse( legs.stream().filter(Leg.class::isInstance).anyMatch(planElement -> ((Leg) planElement).getMode().equals(TransportMode.pt))); + Assertions.assertNotNull(legs, "The router should find a pt route and not return null, but did return null"); + Assertions.assertFalse( legs.stream().filter(Leg.class::isInstance).anyMatch(planElement -> ((Leg) planElement).getMode().equals(TransportMode.pt))); } @@ -533,19 +533,19 @@ void testIntermodalTrip_competingAccess() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.bike, leg.getMode()); - Assert.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.bike, leg.getMode()); + Assertions.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.bike, leg.getMode()); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.bike, leg.getMode()); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } // second check: decrease bike speed, walk should be the better option @@ -563,19 +563,19 @@ void testIntermodalTrip_competingAccess() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } } @@ -638,19 +638,19 @@ void testIntermodalTrip_RandomAccessEgressModeRaptorStopFinder() { { // Test 1: Checks whether the amount of legs is correct, whether the legs have the correct modes, // and whether the legs start and end on the correct links - Assert.assertEquals("wrong number of legs.", 3, legs.size()); + Assertions.assertEquals(3, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertTrue((leg.getMode().equals(TransportMode.bike)) || (leg.getMode().equals(TransportMode.walk))); - Assert.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertTrue((leg.getMode().equals(TransportMode.bike)) || (leg.getMode().equals(TransportMode.walk))); + Assertions.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("pt_3", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertTrue((leg.getMode().equals(TransportMode.bike)) || (leg.getMode().equals(TransportMode.walk))); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertTrue((leg.getMode().equals(TransportMode.bike)) || (leg.getMode().equals(TransportMode.walk))); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } { // Test 2: Counts all different access/egress mode combinations. The assertions occur later. @@ -671,11 +671,11 @@ else if ((((Leg)(legs.get(0))).getMode().equals(TransportMode.bike)) && (((Leg)l { // Test 2: Tests whether Router chooses all 4 combinations of walk and bike. Also checks that no other // combination is present. - Assert.assertTrue(numWalkWalk > 0); - Assert.assertTrue(numWalkBike > 0); - Assert.assertTrue(numBikeWalk > 0); - Assert.assertTrue(numBikeBike > 0); - Assert.assertEquals(0, numOther); + Assertions.assertTrue(numWalkWalk > 0); + Assertions.assertTrue(numWalkBike > 0); + Assertions.assertTrue(numBikeWalk > 0); + Assertions.assertTrue(numBikeBike > 0); + Assertions.assertEquals(0, numOther); } } @@ -702,32 +702,32 @@ void testIntermodalTrip_accessTransfer() { System.out.println(leg); } - Assert.assertEquals(5, legs.size()); + Assertions.assertEquals(5, legs.size()); Leg legBike = (Leg) legs.get(0); - Assert.assertEquals("bike", legBike.getMode()); - Assert.assertEquals("from", legBike.getRoute().getStartLinkId().toString()); - Assert.assertEquals("bike_B", legBike.getRoute().getEndLinkId().toString()); + Assertions.assertEquals("bike", legBike.getMode()); + Assertions.assertEquals("from", legBike.getRoute().getStartLinkId().toString()); + Assertions.assertEquals("bike_B", legBike.getRoute().getEndLinkId().toString()); Leg legTransfer = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.walk, legTransfer.getMode()); - Assert.assertEquals("bike_B", legTransfer.getRoute().getStartLinkId().toString()); - Assert.assertEquals("BB", legTransfer.getRoute().getEndLinkId().toString()); + Assertions.assertEquals(TransportMode.walk, legTransfer.getMode()); + Assertions.assertEquals("bike_B", legTransfer.getRoute().getStartLinkId().toString()); + Assertions.assertEquals("BB", legTransfer.getRoute().getEndLinkId().toString()); Leg legTransfer2 = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, legTransfer2.getMode()); - Assert.assertEquals("BB", legTransfer2.getRoute().getStartLinkId().toString()); - Assert.assertEquals("CC", legTransfer2.getRoute().getEndLinkId().toString()); + Assertions.assertEquals(TransportMode.walk, legTransfer2.getMode()); + Assertions.assertEquals("BB", legTransfer2.getRoute().getStartLinkId().toString()); + Assertions.assertEquals("CC", legTransfer2.getRoute().getEndLinkId().toString()); Leg legPT = (Leg) legs.get(3); - Assert.assertEquals("pt", legPT.getMode()); - Assert.assertEquals("CC", legPT.getRoute().getStartLinkId().toString()); - Assert.assertEquals("DD", legPT.getRoute().getEndLinkId().toString()); + Assertions.assertEquals("pt", legPT.getMode()); + Assertions.assertEquals("CC", legPT.getRoute().getStartLinkId().toString()); + Assertions.assertEquals("DD", legPT.getRoute().getEndLinkId().toString()); Leg legAccess = (Leg) legs.get(4); - Assert.assertEquals(TransportMode.walk, legAccess.getMode()); - Assert.assertEquals("DD", legAccess.getRoute().getStartLinkId().toString()); - Assert.assertEquals("to", legAccess.getRoute().getEndLinkId().toString()); + Assertions.assertEquals(TransportMode.walk, legAccess.getMode()); + Assertions.assertEquals("DD", legAccess.getRoute().getStartLinkId().toString()); + Assertions.assertEquals("to", legAccess.getRoute().getEndLinkId().toString()); } /** @@ -757,22 +757,22 @@ void testIntermodalTrip_singleReachableStop() { System.out.println(leg); } - Assert.assertEquals(3, legs.size()); + Assertions.assertEquals(3, legs.size()); Leg legAccess = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, legAccess.getMode()); - Assert.assertEquals("from", legAccess.getRoute().getStartLinkId().toString()); - Assert.assertEquals("EE", legAccess.getRoute().getEndLinkId().toString()); + Assertions.assertEquals(TransportMode.walk, legAccess.getMode()); + Assertions.assertEquals("from", legAccess.getRoute().getStartLinkId().toString()); + Assertions.assertEquals("EE", legAccess.getRoute().getEndLinkId().toString()); Leg legPT = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.pt, legPT.getMode()); - Assert.assertEquals("EE", legPT.getRoute().getStartLinkId().toString()); - Assert.assertEquals("FF", legPT.getRoute().getEndLinkId().toString()); + Assertions.assertEquals(TransportMode.pt, legPT.getMode()); + Assertions.assertEquals("EE", legPT.getRoute().getStartLinkId().toString()); + Assertions.assertEquals("FF", legPT.getRoute().getEndLinkId().toString()); Leg legEgress = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, legEgress.getMode()); - Assert.assertEquals("FF", legEgress.getRoute().getStartLinkId().toString()); - Assert.assertEquals("to", legEgress.getRoute().getEndLinkId().toString()); + Assertions.assertEquals(TransportMode.walk, legEgress.getMode()); + Assertions.assertEquals("FF", legEgress.getRoute().getStartLinkId().toString()); + Assertions.assertEquals("to", legEgress.getRoute().getEndLinkId().toString()); } @@ -792,32 +792,32 @@ void testIntermodalTrip_egressTransfer() { System.out.println(leg); } - Assert.assertEquals(5, legs.size()); + Assertions.assertEquals(5, legs.size()); Leg legAccess = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, legAccess.getMode()); - Assert.assertEquals("from", legAccess.getRoute().getStartLinkId().toString()); - Assert.assertEquals("DD", legAccess.getRoute().getEndLinkId().toString()); + Assertions.assertEquals(TransportMode.walk, legAccess.getMode()); + Assertions.assertEquals("from", legAccess.getRoute().getStartLinkId().toString()); + Assertions.assertEquals("DD", legAccess.getRoute().getEndLinkId().toString()); Leg legPT = (Leg) legs.get(1); - Assert.assertEquals("pt", legPT.getMode()); - Assert.assertEquals("DD", legPT.getRoute().getStartLinkId().toString()); - Assert.assertEquals("CC", legPT.getRoute().getEndLinkId().toString()); + Assertions.assertEquals("pt", legPT.getMode()); + Assertions.assertEquals("DD", legPT.getRoute().getStartLinkId().toString()); + Assertions.assertEquals("CC", legPT.getRoute().getEndLinkId().toString()); Leg legTransfer = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.walk, legTransfer.getMode()); - Assert.assertEquals("CC", legTransfer.getRoute().getStartLinkId().toString()); - Assert.assertEquals("BB", legTransfer.getRoute().getEndLinkId().toString()); + Assertions.assertEquals(TransportMode.walk, legTransfer.getMode()); + Assertions.assertEquals("CC", legTransfer.getRoute().getStartLinkId().toString()); + Assertions.assertEquals("BB", legTransfer.getRoute().getEndLinkId().toString()); Leg legTransfer2 = (Leg) legs.get(3); - Assert.assertEquals(TransportMode.walk, legTransfer2.getMode()); - Assert.assertEquals("BB", legTransfer2.getRoute().getStartLinkId().toString()); - Assert.assertEquals("bike_B", legTransfer2.getRoute().getEndLinkId().toString()); + Assertions.assertEquals(TransportMode.walk, legTransfer2.getMode()); + Assertions.assertEquals("BB", legTransfer2.getRoute().getStartLinkId().toString()); + Assertions.assertEquals("bike_B", legTransfer2.getRoute().getEndLinkId().toString()); Leg legBike = (Leg) legs.get(4); - Assert.assertEquals("bike", legBike.getMode()); - Assert.assertEquals("bike_B", legBike.getRoute().getStartLinkId().toString()); - Assert.assertEquals("to", legBike.getRoute().getEndLinkId().toString()); + Assertions.assertEquals("bike", legBike.getMode()); + Assertions.assertEquals("bike_B", legBike.getRoute().getStartLinkId().toString()); + Assertions.assertEquals("to", legBike.getRoute().getEndLinkId().toString()); } /** @@ -839,7 +839,7 @@ void testIntermodalTrip_noPtStopsInRadius() { List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac, toFac, 7.5 * 3600, f.dummyPerson)); - Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); + Assertions.assertNull(legs, "The router should not find a route and return null, but did return something else."); } /** @@ -875,27 +875,27 @@ void testIntermodalTrip_accessModeRouterReturnsNull() { System.out.println(leg); } - Assert.assertEquals(4, legs.size()); + Assertions.assertEquals(4, legs.size()); Leg legBike = (Leg) legs.get(0); - Assert.assertEquals("bike", legBike.getMode()); - Assert.assertEquals("from", legBike.getRoute().getStartLinkId().toString()); - Assert.assertEquals("bike_B", legBike.getRoute().getEndLinkId().toString()); + Assertions.assertEquals("bike", legBike.getMode()); + Assertions.assertEquals("from", legBike.getRoute().getStartLinkId().toString()); + Assertions.assertEquals("bike_B", legBike.getRoute().getEndLinkId().toString()); Leg legTransfer = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.walk, legTransfer.getMode()); - Assert.assertEquals("bike_B", legTransfer.getRoute().getStartLinkId().toString()); - Assert.assertEquals("BB", legTransfer.getRoute().getEndLinkId().toString()); + Assertions.assertEquals(TransportMode.walk, legTransfer.getMode()); + Assertions.assertEquals("bike_B", legTransfer.getRoute().getStartLinkId().toString()); + Assertions.assertEquals("BB", legTransfer.getRoute().getEndLinkId().toString()); Leg legTransfer2 = (Leg) legs.get(2); - Assert.assertEquals("pt", legTransfer2.getMode()); - Assert.assertEquals("BB", legTransfer2.getRoute().getStartLinkId().toString()); - Assert.assertEquals("AA", legTransfer2.getRoute().getEndLinkId().toString()); + Assertions.assertEquals("pt", legTransfer2.getMode()); + Assertions.assertEquals("BB", legTransfer2.getRoute().getStartLinkId().toString()); + Assertions.assertEquals("AA", legTransfer2.getRoute().getEndLinkId().toString()); Leg legAccess = (Leg) legs.get(3); - Assert.assertEquals(TransportMode.walk, legAccess.getMode()); - Assert.assertEquals("AA", legAccess.getRoute().getStartLinkId().toString()); - Assert.assertEquals("to", legAccess.getRoute().getEndLinkId().toString()); + Assertions.assertEquals(TransportMode.walk, legAccess.getMode()); + Assertions.assertEquals("AA", legAccess.getRoute().getStartLinkId().toString()); + Assertions.assertEquals("to", legAccess.getRoute().getEndLinkId().toString()); // Part 2: Change bike router to return null. @@ -916,7 +916,7 @@ public List calcRoute(RoutingRequest request) { List legs2 = raptor2.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac, toFac, 8 * 3600 - 900, f.dummyPerson)); - Assert.assertNull("The router should not find a route and return null, but did return something else.", legs2); + Assertions.assertNull(legs2, "The router should not find a route and return null, but did return something else."); } /** @@ -972,27 +972,27 @@ void testIntermodalTrip_tripLengthShare() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 5, legs.size()); + Assertions.assertEquals(5, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.bike, leg.getMode()); - Assert.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("bike_0", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.bike, leg.getMode()); + Assertions.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("bike_0", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("bike_0", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_0", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("bike_0", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_0", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("pt_0", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("pt_0", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(3); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("bike_5", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("bike_5", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(4); - Assert.assertEquals(TransportMode.bike, leg.getMode()); - Assert.assertEquals(Id.create("bike_5", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.bike, leg.getMode()); + Assertions.assertEquals(Id.create("bike_5", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } @Test @@ -1082,32 +1082,32 @@ public List calcRoute(RoutingRequest request) { for (PlanElement leg : legs) { System.out.println(leg); } - Assert.assertEquals("wrong number of segments.", 6, legs.size()); + Assertions.assertEquals(6, legs.size(), "wrong number of segments."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_1", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_1", Link.class), leg.getRoute().getEndLinkId()); Activity act = (Activity)legs.get(1); - Assert.assertEquals("bike interaction", act.getType()); - Assert.assertEquals(1.0, act.getMaximumDuration().seconds(), 0.01); + Assertions.assertEquals("bike interaction", act.getType()); + Assertions.assertEquals(1.0, act.getMaximumDuration().seconds(), 0.01); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.bike, leg.getMode()); - Assert.assertEquals(Id.create("pt_1", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("bike_0", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.bike, leg.getMode()); + Assertions.assertEquals(Id.create("pt_1", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("bike_0", Link.class), leg.getRoute().getEndLinkId()); double arrivalTime = leg.getDepartureTime().seconds() + leg.getTravelTime().seconds(); leg = (Leg) legs.get(3); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("bike_0", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_0", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("bike_0", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_0", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(4); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("pt_0", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); - Assert.assertTrue((int)leg.getDepartureTime().seconds() >= (int)arrivalTime ); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("pt_0", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertTrue((int)leg.getDepartureTime().seconds() >= (int)arrivalTime ); leg = (Leg) legs.get(5); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } /** @@ -1205,36 +1205,36 @@ public List calcRoute(RoutingRequest request) { System.out.println(leg); } - Assert.assertEquals("wrong number of segments.", 9, legs.size()); + Assertions.assertEquals(9, legs.size(), "wrong number of segments."); Leg leg = (Leg) legs.get(0); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_1", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_1", Link.class), leg.getRoute().getEndLinkId()); Activity act = (Activity)legs.get(1); - Assert.assertEquals("bike interaction", act.getType()); - Assert.assertEquals(bikeInteractionDuration, act.getMaximumDuration().seconds(), 0.01); + Assertions.assertEquals("bike interaction", act.getType()); + Assertions.assertEquals(bikeInteractionDuration, act.getMaximumDuration().seconds(), 0.01); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.bike, leg.getMode()); - Assert.assertEquals(Id.create("pt_1", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("bike_0", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.bike, leg.getMode()); + Assertions.assertEquals(Id.create("pt_1", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("bike_0", Link.class), leg.getRoute().getEndLinkId()); act = (Activity)legs.get(3); - Assert.assertEquals("pt interaction", act.getType()); + Assertions.assertEquals("pt interaction", act.getType()); leg = (Leg) legs.get(4); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("bike_0", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_0", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("bike_0", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_0", Link.class), leg.getRoute().getEndLinkId()); act = (Activity)legs.get(5); - Assert.assertEquals("pt interaction", act.getType()); + Assertions.assertEquals("pt interaction", act.getType()); leg = (Leg) legs.get(6); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("pt_0", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("pt_0", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); act = (Activity)legs.get(7); - Assert.assertEquals("pt interaction", act.getType()); + Assertions.assertEquals("pt interaction", act.getType()); leg = (Leg) legs.get(8); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } @Test @@ -1279,25 +1279,25 @@ void testIntermodalTripWithAccessAndEgressTimesAtStops() { System.out.println(leg); } - Assert.assertEquals("wrong number of legs.", 5, legs.size()); + Assertions.assertEquals(5, legs.size(), "wrong number of legs."); Leg leg = (Leg) legs.get(1); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("pt_2", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_2", Link.class), leg.getRoute().getEndLinkId()); - Assert.assertEquals(120.0,leg.getTravelTime().seconds(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("pt_2", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_2", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(120.0,leg.getTravelTime().seconds(), MatsimTestUtils.EPSILON); leg = (Leg) legs.get(2); - Assert.assertEquals(TransportMode.pt, leg.getMode()); - Assert.assertEquals(Id.create("pt_2", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.pt, leg.getMode()); + Assertions.assertEquals(Id.create("pt_2", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); leg = (Leg) legs.get(3); - Assert.assertEquals(TransportMode.walk, leg.getMode()); - Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("bike_5", Link.class), leg.getRoute().getEndLinkId()); - Assert.assertEquals(120.0,leg.getTravelTime().seconds(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TransportMode.walk, leg.getMode()); + Assertions.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("bike_5", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(120.0,leg.getTravelTime().seconds(), MatsimTestUtils.EPSILON); leg = (Leg) legs.get(4); - Assert.assertEquals(TransportMode.bike, leg.getMode()); - Assert.assertEquals(Id.create("bike_5", Link.class), leg.getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); + Assertions.assertEquals(TransportMode.bike, leg.getMode()); + Assertions.assertEquals(Id.create("bike_5", Link.class), leg.getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java index f043d8bbc77..5085ec806b2 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java @@ -23,8 +23,8 @@ import java.util.Arrays; import java.util.List; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -114,7 +114,7 @@ public void install() { // this test mostly checks that no exception occurred RoutingModule module = tripRouter.getRoutingModule(TransportMode.pt); - Assert.assertTrue(module instanceof SwissRailRaptorRoutingModule); + Assertions.assertTrue(module instanceof SwissRailRaptorRoutingModule); } @Test @@ -190,7 +190,7 @@ public void install() { // test that swiss rail raptor was used TripRouter tripRouter = controler.getInjector().getInstance(TripRouter.class); RoutingModule module = tripRouter.getRoutingModule(TransportMode.pt); - Assert.assertTrue(module instanceof SwissRailRaptorRoutingModule); + Assertions.assertTrue(module instanceof SwissRailRaptorRoutingModule); // also test that our one agent got correctly routed with intermodal access List planElements = plan.getPlanElements(); @@ -198,41 +198,41 @@ public void install() { System.out.println(pe); } - Assert.assertEquals("wrong number of PlanElements.", 11, planElements.size()); - Assert.assertTrue(planElements.get(0) instanceof Activity); - Assert.assertTrue(planElements.get(1) instanceof Leg); - Assert.assertTrue(planElements.get(2) instanceof Activity); - Assert.assertTrue(planElements.get(3) instanceof Leg); - Assert.assertTrue(planElements.get(4) instanceof Activity); - Assert.assertTrue(planElements.get(5) instanceof Leg); - Assert.assertTrue(planElements.get(6) instanceof Activity); - Assert.assertTrue(planElements.get(7) instanceof Leg); - Assert.assertTrue(planElements.get(8) instanceof Activity); - Assert.assertTrue(planElements.get(9) instanceof Leg); - Assert.assertTrue(planElements.get(10) instanceof Activity); - - Assert.assertEquals("home", ((Activity) planElements.get(0)).getType()); - Assert.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(2)).getType()); - Assert.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(4)).getType()); - Assert.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(6)).getType()); - Assert.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(8)).getType()); - Assert.assertEquals("work", ((Activity) planElements.get(10)).getType()); - - Assert.assertEquals(TransportMode.bike, ((Leg) planElements.get(1)).getMode()); - Assert.assertEquals(TransportMode.walk, ((Leg) planElements.get(3)).getMode()); - Assert.assertEquals(TransportMode.pt, ((Leg) planElements.get(5)).getMode()); - Assert.assertEquals(TransportMode.walk, ((Leg) planElements.get(7)).getMode()); - Assert.assertEquals(TransportMode.bike, ((Leg) planElements.get(9)).getMode()); - - Assert.assertEquals(0.0, ((Activity) planElements.get(2)).getMaximumDuration().seconds(), 0.0); - Assert.assertEquals(0.0, ((Activity) planElements.get(4)).getMaximumDuration().seconds(), 0.0); - Assert.assertEquals(0.0, ((Activity) planElements.get(6)).getMaximumDuration().seconds(), 0.0); - Assert.assertEquals(0.0, ((Activity) planElements.get(8)).getMaximumDuration().seconds(), 0.0); - - Assert.assertTrue( ((Activity) planElements.get(2)).getEndTime().isUndefined() ); - Assert.assertTrue( ((Activity) planElements.get(4)).getEndTime().isUndefined() ); - Assert.assertTrue( ((Activity) planElements.get(6)).getEndTime().isUndefined() ); - Assert.assertTrue( ((Activity) planElements.get(8)).getEndTime().isUndefined() ); + Assertions.assertEquals(11, planElements.size(), "wrong number of PlanElements."); + Assertions.assertTrue(planElements.get(0) instanceof Activity); + Assertions.assertTrue(planElements.get(1) instanceof Leg); + Assertions.assertTrue(planElements.get(2) instanceof Activity); + Assertions.assertTrue(planElements.get(3) instanceof Leg); + Assertions.assertTrue(planElements.get(4) instanceof Activity); + Assertions.assertTrue(planElements.get(5) instanceof Leg); + Assertions.assertTrue(planElements.get(6) instanceof Activity); + Assertions.assertTrue(planElements.get(7) instanceof Leg); + Assertions.assertTrue(planElements.get(8) instanceof Activity); + Assertions.assertTrue(planElements.get(9) instanceof Leg); + Assertions.assertTrue(planElements.get(10) instanceof Activity); + + Assertions.assertEquals("home", ((Activity) planElements.get(0)).getType()); + Assertions.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(2)).getType()); + Assertions.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(4)).getType()); + Assertions.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(6)).getType()); + Assertions.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(8)).getType()); + Assertions.assertEquals("work", ((Activity) planElements.get(10)).getType()); + + Assertions.assertEquals(TransportMode.bike, ((Leg) planElements.get(1)).getMode()); + Assertions.assertEquals(TransportMode.walk, ((Leg) planElements.get(3)).getMode()); + Assertions.assertEquals(TransportMode.pt, ((Leg) planElements.get(5)).getMode()); + Assertions.assertEquals(TransportMode.walk, ((Leg) planElements.get(7)).getMode()); + Assertions.assertEquals(TransportMode.bike, ((Leg) planElements.get(9)).getMode()); + + Assertions.assertEquals(0.0, ((Activity) planElements.get(2)).getMaximumDuration().seconds(), 0.0); + Assertions.assertEquals(0.0, ((Activity) planElements.get(4)).getMaximumDuration().seconds(), 0.0); + Assertions.assertEquals(0.0, ((Activity) planElements.get(6)).getMaximumDuration().seconds(), 0.0); + Assertions.assertEquals(0.0, ((Activity) planElements.get(8)).getMaximumDuration().seconds(), 0.0); + + Assertions.assertTrue( ((Activity) planElements.get(2)).getEndTime().isUndefined() ); + Assertions.assertTrue( ((Activity) planElements.get(4)).getEndTime().isUndefined() ); + Assertions.assertTrue( ((Activity) planElements.get(6)).getEndTime().isUndefined() ); + Assertions.assertTrue( ((Activity) planElements.get(8)).getEndTime().isUndefined() ); // MM started filling the times of the swiss rail raptor pt interaction activities with content and so the above (evidently) started failing. I am // fixing it here: @@ -307,7 +307,7 @@ public void install() { // test that swiss rail raptor was used TripRouter tripRouter = controler.getInjector().getInstance(TripRouter.class); RoutingModule module = tripRouter.getRoutingModule(TransportMode.pt); - Assert.assertTrue(module instanceof SwissRailRaptorRoutingModule); + Assertions.assertTrue(module instanceof SwissRailRaptorRoutingModule); // Check routed plan List planElements = p1.getSelectedPlan().getPlanElements(); @@ -315,28 +315,28 @@ public void install() { System.out.println(pe); } - Assert.assertEquals("wrong number of PlanElements.", 7, planElements.size()); - Assert.assertTrue(planElements.get(0) instanceof Activity); - Assert.assertTrue(planElements.get(1) instanceof Leg); - Assert.assertTrue(planElements.get(2) instanceof Activity); - Assert.assertTrue(planElements.get(3) instanceof Leg); - Assert.assertTrue(planElements.get(4) instanceof Activity); - Assert.assertTrue(planElements.get(5) instanceof Leg); - Assert.assertTrue(planElements.get(6) instanceof Activity); + Assertions.assertEquals(7, planElements.size(), "wrong number of PlanElements."); + Assertions.assertTrue(planElements.get(0) instanceof Activity); + Assertions.assertTrue(planElements.get(1) instanceof Leg); + Assertions.assertTrue(planElements.get(2) instanceof Activity); + Assertions.assertTrue(planElements.get(3) instanceof Leg); + Assertions.assertTrue(planElements.get(4) instanceof Activity); + Assertions.assertTrue(planElements.get(5) instanceof Leg); + Assertions.assertTrue(planElements.get(6) instanceof Activity); - Assert.assertEquals("home", ((Activity) planElements.get(0)).getType()); - Assert.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(2)).getType()); - Assert.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(4)).getType()); - Assert.assertEquals("work", ((Activity) planElements.get(6)).getType()); + Assertions.assertEquals("home", ((Activity) planElements.get(0)).getType()); + Assertions.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(2)).getType()); + Assertions.assertEquals(PtConstants.TRANSIT_ACTIVITY_TYPE, ((Activity) planElements.get(4)).getType()); + Assertions.assertEquals("work", ((Activity) planElements.get(6)).getType()); - Assert.assertEquals(TransportMode.walk, ((Leg) planElements.get(1)).getMode()); - Assert.assertEquals(TransportMode.pt, ((Leg) planElements.get(3)).getMode()); - Assert.assertEquals(TransportMode.walk, ((Leg) planElements.get(5)).getMode()); + Assertions.assertEquals(TransportMode.walk, ((Leg) planElements.get(1)).getMode()); + Assertions.assertEquals(TransportMode.pt, ((Leg) planElements.get(3)).getMode()); + Assertions.assertEquals(TransportMode.walk, ((Leg) planElements.get(5)).getMode()); // Check route: should return one of the added lines although the removed green line would be faster Leg ptLeg = (Leg) planElements.get(3); TransitPassengerRoute ptRoute = (TransitPassengerRoute) ptLeg.getRoute(); - Assert.assertEquals(Id.create("AddedLine" + 1, TransitLine.class), ptRoute.getLineId()); + Assertions.assertEquals(Id.create("AddedLine" + 1, TransitLine.class), ptRoute.getLineId()); } /** @@ -378,8 +378,8 @@ void testRaptorParametersForPerson() { RaptorParametersForPerson parameters = controller.getInjector().getInstance(RaptorParametersForPerson.class); - Assert.assertEquals(-80.0, parameters.getRaptorParameters(personA).getMarginalUtilityOfWaitingPt_utl_s(), 1e-3); - Assert.assertEquals(-60.0, parameters.getRaptorParameters(personB).getMarginalUtilityOfWaitingPt_utl_s(), 1e-3); + Assertions.assertEquals(-80.0, parameters.getRaptorParameters(personA).getMarginalUtilityOfWaitingPt_utl_s(), 1e-3); + Assertions.assertEquals(-60.0, parameters.getRaptorParameters(personB).getMarginalUtilityOfWaitingPt_utl_s(), 1e-3); } private static class ScheduleModifierControlerListener implements StartupListener, IterationStartsListener { diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java index e37985287b6..559a2970bf2 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java @@ -21,7 +21,7 @@ import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptor.Builder; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -68,8 +68,8 @@ import java.util.List; import java.util.function.Supplier; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Most of these tests were copied from org.matsim.pt.router.TransitRouterImplTest @@ -98,7 +98,7 @@ void testSingleLine() { assertEquals(TransportMode.walk, ((Leg)legs.get(0)).getMode()); assertEquals(TransportMode.pt, ((Leg)legs.get(1)).getMode()); assertEquals(TransportMode.walk, ((Leg)legs.get(2)).getMode()); - assertTrue("expected TransitRoute in leg.", ((Leg)legs.get(1)).getRoute() instanceof TransitPassengerRoute); + assertTrue(((Leg)legs.get(1)).getRoute() instanceof TransitPassengerRoute, "expected TransitRoute in leg."); TransitPassengerRoute ptRoute = (TransitPassengerRoute) ((Leg)legs.get(1)).getRoute(); assertEquals(Id.create("0", TransitStopFacility.class), ptRoute.getAccessStopId()); assertEquals(Id.create("6", TransitStopFacility.class), ptRoute.getEgressStopId()); @@ -134,7 +134,7 @@ void testSingleLine_linkIds() { assertEquals(TransportMode.pt, ((Leg)legs.get(1)).getMode()); assertEquals(TransportMode.walk, ((Leg)legs.get(2)).getMode()); assertEquals(toLinkId, ((Leg)legs.get(2)).getRoute().getEndLinkId()); - assertTrue("expected TransitRoute in leg.", ((Leg)legs.get(1)).getRoute() instanceof TransitPassengerRoute); + assertTrue(((Leg)legs.get(1)).getRoute() instanceof TransitPassengerRoute, "expected TransitRoute in leg."); TransitPassengerRoute ptRoute = (TransitPassengerRoute) ((Leg)legs.get(1)).getRoute(); assertEquals(Id.create("0", TransitStopFacility.class), ptRoute.getAccessStopId()); assertEquals(Id.create("6", TransitStopFacility.class), ptRoute.getEgressStopId()); @@ -229,7 +229,7 @@ void testFromToSameStop() { Coord toCoord = new Coord(4100, 5050); List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(fromCoord), new FakeFacility(toCoord), 5.0*3600, null)); - Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); + Assertions.assertNull(legs, "The router should not find a route and return null, but did return something else."); } @@ -303,7 +303,7 @@ void testSingleLine_DifferentWaitingTime() { actualTravelTime += ((Leg)leg).getTravelTime().seconds(); } double waitingTime = ((46 - min) % 20) * 60; // departures at *:06 and *:26 and *:46 - assertEquals("expected different waiting time at 05:"+min, waitingTime, actualTravelTime - inVehicleTime, MatsimTestUtils.EPSILON); + assertEquals(waitingTime, actualTravelTime - inVehicleTime, MatsimTestUtils.EPSILON, "expected different waiting time at 05:"+min); } } @@ -322,13 +322,13 @@ void testLineChange() { assertEquals(TransportMode.walk, ((Leg)legs.get(2)).getMode()); assertEquals(TransportMode.pt, ((Leg)legs.get(3)).getMode()); assertEquals(TransportMode.walk, ((Leg)legs.get(4)).getMode()); - assertTrue("expected TransitRoute in leg.", ((Leg)legs.get(1)).getRoute() instanceof TransitPassengerRoute); + assertTrue(((Leg)legs.get(1)).getRoute() instanceof TransitPassengerRoute, "expected TransitRoute in leg."); TransitPassengerRoute ptRoute = (TransitPassengerRoute) ((Leg)legs.get(1)).getRoute(); assertEquals(Id.create("0", TransitStopFacility.class), ptRoute.getAccessStopId()); assertEquals(Id.create("4", TransitStopFacility.class), ptRoute.getEgressStopId()); assertEquals(f.blueLine.getId(), ptRoute.getLineId()); assertEquals(Id.create("blue A > I", TransitRoute.class), ptRoute.getRouteId()); - assertTrue("expected TransitRoute in leg.", ((Leg)legs.get(3)).getRoute() instanceof TransitPassengerRoute); + assertTrue(((Leg)legs.get(3)).getRoute() instanceof TransitPassengerRoute, "expected TransitRoute in leg."); ptRoute = (TransitPassengerRoute) ((Leg)legs.get(3)).getRoute(); assertEquals(Id.create("18", TransitStopFacility.class), ptRoute.getAccessStopId()); assertEquals(Id.create("19", TransitStopFacility.class), ptRoute.getEgressStopId()); @@ -358,19 +358,19 @@ void testFasterAlternative() { TransitRouter router = createTransitRouter(f.schedule, f.config, f.network); Coord toCoord = new Coord(28100, 4950); List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility( new Coord(3800, 5100)), new FakeFacility(toCoord), 5.0*3600 + 40.0*60, null)); - assertEquals("wrong number of legs", 5, legs.size()); + assertEquals(5, legs.size(), "wrong number of legs"); assertEquals(TransportMode.walk, ((Leg)legs.get(0)).getMode()); assertEquals(TransportMode.pt, ((Leg)legs.get(1)).getMode()); assertEquals(TransportMode.walk, ((Leg)legs.get(2)).getMode()); assertEquals(TransportMode.pt, ((Leg)legs.get(3)).getMode()); assertEquals(TransportMode.walk, ((Leg)legs.get(4)).getMode()); - assertTrue("expected TransitRoute in leg.", ((Leg)legs.get(1)).getRoute() instanceof TransitPassengerRoute); + assertTrue(((Leg)legs.get(1)).getRoute() instanceof TransitPassengerRoute, "expected TransitRoute in leg."); TransitPassengerRoute ptRoute = (TransitPassengerRoute) ((Leg)legs.get(1)).getRoute(); assertEquals(Id.create("0", TransitStopFacility.class), ptRoute.getAccessStopId()); assertEquals(Id.create("4", TransitStopFacility.class), ptRoute.getEgressStopId()); assertEquals(f.blueLine.getId(), ptRoute.getLineId()); assertEquals(Id.create("blue A > I", TransitRoute.class), ptRoute.getRouteId()); - assertTrue("expected TransitRoute in leg.", ((Leg)legs.get(3)).getRoute() instanceof TransitPassengerRoute); + assertTrue(((Leg)legs.get(3)).getRoute() instanceof TransitPassengerRoute, "expected TransitRoute in leg."); ptRoute = (TransitPassengerRoute) ((Leg)legs.get(3)).getRoute(); assertEquals(Id.create("4", TransitStopFacility.class), ptRoute.getAccessStopId()); assertEquals(Id.create("12", TransitStopFacility.class), ptRoute.getEgressStopId()); @@ -401,7 +401,7 @@ void testTransferWeights() { RaptorParameters raptorParams = RaptorUtils.createParameters(f.config); TransitRouter router = createTransitRouter(f.schedule, f.config, f.network); List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(new Coord(11900, 5100)), new FakeFacility(new Coord(24100, 4950)), 6.0*3600 - 5.0*60, null)); - assertEquals("wrong number of legs", 5, legs.size()); + assertEquals(5, legs.size(), "wrong number of legs"); assertEquals(TransportMode.walk, ((Leg)legs.get(0)).getMode()); assertEquals(TransportMode.pt, ((Leg)legs.get(1)).getMode()); assertEquals(f.redLine.getId(), ((TransitPassengerRoute) ((Leg)legs.get(1)).getRoute()).getLineId()); @@ -414,7 +414,7 @@ void testTransferWeights() { double transferUtility = 300.0 * raptorParams.getMarginalUtilityOfTravelTime_utl_s(TransportMode.pt); // corresponds to 5 minutes transit travel time config.scoring().setUtilityOfLineSwitch(transferUtility); raptorParams = RaptorUtils.createParameters(config); - Assert.assertEquals(-transferUtility, raptorParams.getTransferPenaltyFixCostPerTransfer(), 0.0); + Assertions.assertEquals(-transferUtility, raptorParams.getTransferPenaltyFixCostPerTransfer(), 0.0); router = createTransitRouter(f.schedule, config, f.network); legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(new Coord(11900, 5100)), new FakeFacility(new Coord(24100, 4950)), 6.0*3600 - 5.0*60, null)); assertEquals(3, legs.size()); @@ -440,7 +440,7 @@ void testTransferTime() { f.config.transitRouter().setAdditionalTransferTime(0); TransitRouter router = createTransitRouter(f.schedule, f.config, f.network); List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(new Coord(11900, 5100)), new FakeFacility(new Coord(24100, 4950)), 6.0*3600 - 5.0*60, null)); - assertEquals("wrong number of legs",5, legs.size()); + assertEquals(5, legs.size(), "wrong number of legs"); assertEquals(TransportMode.walk, ((Leg)legs.get(0)).getMode()); assertEquals(TransportMode.pt, ((Leg)legs.get(1)).getMode()); assertEquals(f.redLine.getId(), ((TransitPassengerRoute) ((Leg)legs.get(1)).getRoute()).getLineId()); @@ -453,7 +453,7 @@ void testTransferTime() { config.transitRouter().setAdditionalTransferTime(3*60 + 1); router = createTransitRouter(f.schedule, config, f.network); // this is necessary to update the router for any change in config. legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(new Coord(11900, 5100)), new FakeFacility(new Coord(24100, 4950)), 6.0*3600 - 5.0*60, null)); - assertEquals("wrong number of legs",3, legs.size()); + assertEquals(3, legs.size(), "wrong number of legs"); assertEquals(TransportMode.walk, ((Leg)legs.get(0)).getMode()); assertEquals(TransportMode.pt, ((Leg)legs.get(1)).getMode()); assertEquals(f.blueLine.getId(), ((TransitPassengerRoute) ((Leg)legs.get(1)).getRoute()).getLineId()); @@ -473,7 +473,7 @@ void testAfterMidnight() { Coord toCoord = new Coord(16100, 5050); List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(fromCoord), new FakeFacility(toCoord), 25.0*3600, null)); - Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); + Assertions.assertNull(legs, "The router should not find a route and return null, but did return something else."); } @Test @@ -488,7 +488,7 @@ void testCoordFarAway() { assertEquals(TransportMode.walk, ((Leg)legs.get(0)).getMode()); assertEquals(TransportMode.pt, ((Leg)legs.get(1)).getMode()); assertEquals(TransportMode.walk, ((Leg)legs.get(2)).getMode()); - assertTrue("expected TransitRoute in leg.", ((Leg)legs.get(1)).getRoute() instanceof TransitPassengerRoute); + assertTrue(((Leg)legs.get(1)).getRoute() instanceof TransitPassengerRoute, "expected TransitRoute in leg."); TransitPassengerRoute ptRoute = (TransitPassengerRoute) ((Leg)legs.get(1)).getRoute(); assertEquals(Id.create("0", TransitStopFacility.class), ptRoute.getAccessStopId()); assertEquals(Id.create("16", TransitStopFacility.class), ptRoute.getEgressStopId()); @@ -508,7 +508,7 @@ void testSingleWalkOnly() { TransitRouter router = createTransitRouter(f.schedule, f.scenario.getConfig(), f.scenario.getNetwork()); List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(f.coord2), new FakeFacility(f.coord4), 990, null)); - Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); + Assertions.assertNull(legs, "The router should not find a route and return null, but did return something else."); } @@ -527,7 +527,7 @@ void testDoubleWalkOnly() { TransitRouter router = createTransitRouter(f.schedule, f.scenario.getConfig(), f.scenario.getNetwork()); List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(f.coord2), new FakeFacility(f.coord6), 990, null)); - Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); + Assertions.assertNull(legs, "The router should not find a route and return null, but did return something else."); } @SuppressWarnings("unchecked") @@ -541,14 +541,14 @@ void testLongTransferTime_withTransitRouterWrapper() { Coord toCoord = f.toFacility.getCoord(); List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(fromCoord), new FakeFacility(toCoord), 7.0 * 3600 + 50 * 60, null)); double legDuration = calcTripDuration(new ArrayList<>(legs)); - Assert.assertEquals(5, legs.size()); - Assert.assertEquals(100, ((Leg)legs.get(0)).getTravelTime().seconds(), 0.0); // 0.1km with 1m/s walk speed -> 100s; arrival at 07:51:40 - Assert.assertEquals(800, ((Leg)legs.get(1)).getTravelTime().seconds(), 0.0); // 8m 20s waiting for pt departure and 5m pt travel time -> 500s + 300s = 800s; arrival at 08:05:00 - Assert.assertEquals(295, ((Leg)legs.get(2)).getTravelTime().seconds(), + Assertions.assertEquals(5, legs.size()); + Assertions.assertEquals(100, ((Leg)legs.get(0)).getTravelTime().seconds(), 0.0); // 0.1km with 1m/s walk speed -> 100s; arrival at 07:51:40 + Assertions.assertEquals(800, ((Leg)legs.get(1)).getTravelTime().seconds(), 0.0); // 8m 20s waiting for pt departure and 5m pt travel time -> 500s + 300s = 800s; arrival at 08:05:00 + Assertions.assertEquals(295, ((Leg)legs.get(2)).getTravelTime().seconds(), 0.0); // 0.004km with 1m/s walk speed, but minimal waiting time -> max(4s, 300s) = 300s -5 seconds margin; arrival at 08:10:00 - Assert.assertEquals(600, ((Leg)legs.get(3)).getTravelTime().seconds(), 0.0); // 5m 00s waiting for pt departure and 5m pt travel time -> 300s + 300s = 600s; arrival at 08:15:00 - Assert.assertEquals(100, ((Leg)legs.get(4)).getTravelTime().seconds(), 0.0); // 0.1km with 1m/s walk speed -> 100s - Assert.assertEquals(1895.0, legDuration, 0.0); + Assertions.assertEquals(600, ((Leg)legs.get(3)).getTravelTime().seconds(), 0.0); // 5m 00s waiting for pt departure and 5m pt travel time -> 300s + 300s = 600s; arrival at 08:15:00 + Assertions.assertEquals(100, ((Leg)legs.get(4)).getTravelTime().seconds(), 0.0); // 0.1km with 1m/s walk speed -> 100s + Assertions.assertEquals(1895.0, legDuration, 0.0); RoutingModule walkRoutingModule = DefaultRoutingModules.createTeleportationRouter(TransportMode.transit_walk, f.scenario, f.config.routing().getModeRoutingParams().get(TransportMode.walk)); @@ -561,14 +561,14 @@ void testLongTransferTime_withTransitRouterWrapper() { List planElements = (List) wrapper.calcRoute(DefaultRoutingRequest.withoutAttributes(f.fromFacility, f.toFacility, 7.0 * 3600 + 50 * 60, null)); double tripDuration = calcTripDuration(planElements); - Assert.assertEquals(9, planElements.size()); - Assert.assertEquals(100, ((Leg) planElements.get(0)).getTravelTime().seconds(), 0.0); // 0.1km with 1m/s walk speed -> 100s; arrival at 07:51:40 - Assert.assertEquals(800, ((Leg) planElements.get(2)).getTravelTime().seconds(), 0.0); // 8m 20s waiting for pt departure and 5m pt travel time -> 500s + 300s = 800s; arrival at 08:05:00 - Assert.assertEquals(295, ((Leg) planElements.get(4)).getTravelTime().seconds(), + Assertions.assertEquals(9, planElements.size()); + Assertions.assertEquals(100, ((Leg) planElements.get(0)).getTravelTime().seconds(), 0.0); // 0.1km with 1m/s walk speed -> 100s; arrival at 07:51:40 + Assertions.assertEquals(800, ((Leg) planElements.get(2)).getTravelTime().seconds(), 0.0); // 8m 20s waiting for pt departure and 5m pt travel time -> 500s + 300s = 800s; arrival at 08:05:00 + Assertions.assertEquals(295, ((Leg) planElements.get(4)).getTravelTime().seconds(), 0.0); // 0.004km with 1m/s walk speed, but minimal waiting time -> max(4s, 300s) = 300s; arrival at 08:10:00 - Assert.assertEquals(600, ((Leg) planElements.get(6)).getTravelTime().seconds(), 0.0); // 5m 00s waiting for pt departure and 5m pt travel time -> 300s + 300s = 600s; arrival at 08:15:00 - Assert.assertEquals(100, ((Leg) planElements.get(8)).getTravelTime().seconds(), 0.0); // 0.1km with 1m/s walk speed -> 100s - Assert.assertEquals(1895.0, tripDuration, 0.0); + Assertions.assertEquals(600, ((Leg) planElements.get(6)).getTravelTime().seconds(), 0.0); // 5m 00s waiting for pt departure and 5m pt travel time -> 300s + 300s = 600s; arrival at 08:15:00 + Assertions.assertEquals(100, ((Leg) planElements.get(8)).getTravelTime().seconds(), 0.0); // 0.1km with 1m/s walk speed -> 100s + Assertions.assertEquals(1895.0, tripDuration, 0.0); } // 65 minutes additional transfer time - miss one departure @@ -580,13 +580,13 @@ void testLongTransferTime_withTransitRouterWrapper() { Coord toCoord = f.toFacility.getCoord(); List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(fromCoord), new FakeFacility(toCoord), 7.0*3600 + 50*60, null)); double legDuration = calcTripDuration(new ArrayList<>(legs)); - Assert.assertEquals(5, legs.size()); - Assert.assertEquals(100, ((Leg)legs.get(0)).getTravelTime().seconds(), 0.0); // 0.1km with 1m/s walk speed -> 100s; arrival at 07:51:40 - Assert.assertEquals(800, ((Leg)legs.get(1)).getTravelTime().seconds(), 0.0); // 8m 20s waiting for pt departure and 5m pt travel time -> 500s + 300s = 800s; arrival at 08:05:00 - Assert.assertEquals(3900, ((Leg)legs.get(2)).getTravelTime().seconds(), 0.0); // 0.004km with 1m/s walk speed, but minimal waiting time -> max(4s, 300s) = 300s; arrival at 08:10:00 - Assert.assertEquals(600, ((Leg)legs.get(3)).getTravelTime().seconds(), 0.0); // 5m 00s waiting for pt departure and 5m pt travel time -> 300s + 300s = 600s; arrival at 08:15:00 - Assert.assertEquals(100, ((Leg)legs.get(4)).getTravelTime().seconds(), 0.0); // 0.1km with 1m/s walk speed -> 100s - Assert.assertEquals(5500.0, legDuration, 0.0); + Assertions.assertEquals(5, legs.size()); + Assertions.assertEquals(100, ((Leg)legs.get(0)).getTravelTime().seconds(), 0.0); // 0.1km with 1m/s walk speed -> 100s; arrival at 07:51:40 + Assertions.assertEquals(800, ((Leg)legs.get(1)).getTravelTime().seconds(), 0.0); // 8m 20s waiting for pt departure and 5m pt travel time -> 500s + 300s = 800s; arrival at 08:05:00 + Assertions.assertEquals(3900, ((Leg)legs.get(2)).getTravelTime().seconds(), 0.0); // 0.004km with 1m/s walk speed, but minimal waiting time -> max(4s, 300s) = 300s; arrival at 08:10:00 + Assertions.assertEquals(600, ((Leg)legs.get(3)).getTravelTime().seconds(), 0.0); // 5m 00s waiting for pt departure and 5m pt travel time -> 300s + 300s = 600s; arrival at 08:15:00 + Assertions.assertEquals(100, ((Leg)legs.get(4)).getTravelTime().seconds(), 0.0); // 0.1km with 1m/s walk speed -> 100s + Assertions.assertEquals(5500.0, legDuration, 0.0); RoutingModule walkRoutingModule = DefaultRoutingModules.createTeleportationRouter(TransportMode.transit_walk, f.scenario, f.config.routing().getModeRoutingParams().get(TransportMode.walk)); @@ -599,13 +599,13 @@ void testLongTransferTime_withTransitRouterWrapper() { List planElements = (List) wrapper.calcRoute(DefaultRoutingRequest.withoutAttributes(f.fromFacility, f.toFacility, 7.0*3600 + 50*60, null)); double tripDuration = calcTripDuration(planElements); - Assert.assertEquals(9, planElements.size()); - Assert.assertEquals(100, ((Leg)planElements.get(0)).getTravelTime().seconds(), 0.0); // 0.1km with 1m/s walk speed -> 100s; arrival at 07:51:40 - Assert.assertEquals(800, ((Leg)planElements.get(2)).getTravelTime().seconds(), 0.0); // 8m 20s waiting for pt departure and 5m pt travel time -> 500s + 300s = 800s; arrival at 08:05:00 - Assert.assertEquals(3900, ((Leg)planElements.get(4)).getTravelTime().seconds(), 0.0); // 0.004km with 1m/s walk speed, but minimal waiting time -> max(4s, 300s) = 300s; arrival at 08:10:00 - Assert.assertEquals(600, ((Leg)planElements.get(6)).getTravelTime().seconds(), 0.0); // 5m 00s waiting for pt departure and 5m pt travel time -> 300s + 300s = 600s; arrival at 08:15:00 - Assert.assertEquals(100, ((Leg)planElements.get(8)).getTravelTime().seconds(), 0.0); // 0.1km with 1m/s walk speed -> 100s - Assert.assertEquals(5500.0, tripDuration, 0.0); + Assertions.assertEquals(9, planElements.size()); + Assertions.assertEquals(100, ((Leg)planElements.get(0)).getTravelTime().seconds(), 0.0); // 0.1km with 1m/s walk speed -> 100s; arrival at 07:51:40 + Assertions.assertEquals(800, ((Leg)planElements.get(2)).getTravelTime().seconds(), 0.0); // 8m 20s waiting for pt departure and 5m pt travel time -> 500s + 300s = 800s; arrival at 08:05:00 + Assertions.assertEquals(3900, ((Leg)planElements.get(4)).getTravelTime().seconds(), 0.0); // 0.004km with 1m/s walk speed, but minimal waiting time -> max(4s, 300s) = 300s; arrival at 08:10:00 + Assertions.assertEquals(600, ((Leg)planElements.get(6)).getTravelTime().seconds(), 0.0); // 5m 00s waiting for pt departure and 5m pt travel time -> 300s + 300s = 600s; arrival at 08:15:00 + Assertions.assertEquals(100, ((Leg)planElements.get(8)).getTravelTime().seconds(), 0.0); // 0.1km with 1m/s walk speed -> 100s + Assertions.assertEquals(5500.0, tripDuration, 0.0); } // 600 minutes additional transfer time - miss all departures @@ -615,7 +615,7 @@ void testLongTransferTime_withTransitRouterWrapper() { Coord fromCoord = f.fromFacility.getCoord(); Coord toCoord = f.toFacility.getCoord(); List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(fromCoord), new FakeFacility(toCoord), 7.0*3600 + 50*60, null)); - Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); + Assertions.assertNull(legs, "The router should not find a route and return null, but did return something else."); RoutingModule walkRoutingModule = DefaultRoutingModules.createTeleportationRouter(TransportMode.transit_walk, f.scenario, f.config.routing().getModeRoutingParams().get(TransportMode.walk)); @@ -628,7 +628,7 @@ void testLongTransferTime_withTransitRouterWrapper() { TransitRouterWrapper wrapper = new TransitRouterWrapper(router, f.schedule, f.scenario.getNetwork(), routingModule); List planElements = (List) wrapper.calcRoute(DefaultRoutingRequest.withoutAttributes(f.fromFacility, f.toFacility, 7.0*3600 + 50*60, null)); - Assert.assertNull("The router should not find a route and return null, but did return something else.", planElements); + Assertions.assertNull(planElements, "The router should not find a route and return null, but did return something else."); } } @@ -666,17 +666,17 @@ void testNightBus() { assertEquals(TransportMode.walk, ((Leg)legs.get(4)).getMode()); assertEquals(TransportMode.pt, ((Leg)legs.get(5)).getMode()); assertEquals(TransportMode.walk, ((Leg)legs.get(6)).getMode()); - assertTrue("expected TransitRoute in leg.", ((Leg)legs.get(1)).getRoute() instanceof TransitPassengerRoute); + assertTrue(((Leg)legs.get(1)).getRoute() instanceof TransitPassengerRoute, "expected TransitRoute in leg."); TransitPassengerRoute ptRoute = (TransitPassengerRoute) ((Leg)legs.get(1)).getRoute(); assertEquals(f.stop0.getId(), ptRoute.getAccessStopId()); assertEquals(f.stop1.getId(), ptRoute.getEgressStopId()); assertEquals(f.lineId0, ptRoute.getLineId()); - assertTrue("expected TransitRoute in leg.", ((Leg)legs.get(3)).getRoute() instanceof TransitPassengerRoute); + assertTrue(((Leg)legs.get(3)).getRoute() instanceof TransitPassengerRoute, "expected TransitRoute in leg."); ptRoute = (TransitPassengerRoute) ((Leg)legs.get(3)).getRoute(); assertEquals(f.stop1.getId(), ptRoute.getAccessStopId()); assertEquals(f.stop2.getId(), ptRoute.getEgressStopId()); assertEquals(f.lineId1, ptRoute.getLineId()); - assertTrue("expected TransitRoute in leg.", ((Leg)legs.get(5)).getRoute() instanceof TransitPassengerRoute); + assertTrue(((Leg)legs.get(5)).getRoute() instanceof TransitPassengerRoute, "expected TransitRoute in leg."); ptRoute = (TransitPassengerRoute) ((Leg)legs.get(5)).getRoute(); assertEquals(f.stop2.getId(), ptRoute.getAccessStopId()); assertEquals(f.stop3.getId(), ptRoute.getEgressStopId()); @@ -699,17 +699,17 @@ void testCircularLine() { System.out.println(leg); } - Assert.assertEquals(5, legs.size()); - Assert.assertEquals(TransportMode.walk, ((Leg)legs.get(0)).getMode()); - Assert.assertEquals(TransportMode.pt, ((Leg)legs.get(1)).getMode()); - Assert.assertEquals(TransportMode.walk, ((Leg)legs.get(2)).getMode()); - Assert.assertEquals(TransportMode.pt, ((Leg)legs.get(3)).getMode()); - Assert.assertEquals(TransportMode.walk, ((Leg)legs.get(4)).getMode()); - - Assert.assertEquals(f.greenLine.getId(), ((TransitPassengerRoute) ((Leg)legs.get(1)).getRoute()).getLineId()); - Assert.assertEquals(Id.create(23, TransitStopFacility.class), ((TransitPassengerRoute) ((Leg)legs.get(1)).getRoute()).getAccessStopId()); - Assert.assertEquals(f.greenLine.getId(), ((TransitPassengerRoute) ((Leg)legs.get(3)).getRoute()).getLineId()); - Assert.assertEquals(Id.create(20, TransitStopFacility.class), ((TransitPassengerRoute) ((Leg)legs.get(3)).getRoute()).getEgressStopId()); + Assertions.assertEquals(5, legs.size()); + Assertions.assertEquals(TransportMode.walk, ((Leg)legs.get(0)).getMode()); + Assertions.assertEquals(TransportMode.pt, ((Leg)legs.get(1)).getMode()); + Assertions.assertEquals(TransportMode.walk, ((Leg)legs.get(2)).getMode()); + Assertions.assertEquals(TransportMode.pt, ((Leg)legs.get(3)).getMode()); + Assertions.assertEquals(TransportMode.walk, ((Leg)legs.get(4)).getMode()); + + Assertions.assertEquals(f.greenLine.getId(), ((TransitPassengerRoute) ((Leg)legs.get(1)).getRoute()).getLineId()); + Assertions.assertEquals(Id.create(23, TransitStopFacility.class), ((TransitPassengerRoute) ((Leg)legs.get(1)).getRoute()).getAccessStopId()); + Assertions.assertEquals(f.greenLine.getId(), ((TransitPassengerRoute) ((Leg)legs.get(3)).getRoute()).getLineId()); + Assertions.assertEquals(Id.create(20, TransitStopFacility.class), ((TransitPassengerRoute) ((Leg)legs.get(3)).getRoute()).getEgressStopId()); } @Test @@ -728,7 +728,7 @@ void testRangeQuery() { System.out.println(i + " depTime = " + Time.writeTime(route.getDepartureTime()) + " arrTime = " + Time.writeTime(route.getDepartureTime() + route.getTravelTime()) + " # transfers = " + route.getNumberOfTransfers() + " costs = " + route.getTotalCosts()); } - Assert.assertEquals(6, routes.size()); + Assertions.assertEquals(6, routes.size()); assertRaptorRoute(routes.get(0), "05:40:12", "06:30:56", 0, 10.1466666); assertRaptorRoute(routes.get(1), "06:00:12", "06:50:56", 0, 10.1466666); @@ -739,10 +739,10 @@ void testRangeQuery() { } private void assertRaptorRoute(RaptorRoute route, String depTime, String arrTime, int expectedTransfers, double expectedCost) { - Assert.assertEquals("wrong number of transfers", expectedTransfers, route.getNumberOfTransfers()); - Assert.assertEquals("wrong departure time", Time.parseTime(depTime), route.getDepartureTime(), 0.99); - Assert.assertEquals("wrong arrival time", Time.parseTime(arrTime), route.getDepartureTime() + route.getTravelTime(), 0.99); - Assert.assertEquals("wrong cost", expectedCost, route.getTotalCosts(), 1e-5); + Assertions.assertEquals(expectedTransfers, route.getNumberOfTransfers(), "wrong number of transfers"); + Assertions.assertEquals(Time.parseTime(depTime), route.getDepartureTime(), 0.99, "wrong departure time"); + Assertions.assertEquals(Time.parseTime(arrTime), route.getDepartureTime() + route.getTravelTime(), 0.99, "wrong arrival time"); + Assertions.assertEquals(expectedCost, route.getTotalCosts(), 1e-5, "wrong cost"); } /** test for https://github.com/SchweizerischeBundesbahnen/matsim-sbb-extensions/issues/1 @@ -773,7 +773,7 @@ void testUnusedTransitStop() { double depTime = 5.0 * 3600 + 50 * 60; List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(fromCoord), new FakeFacility(toCoord), depTime, null)); // this test mostly checks that there are no Exceptions. - Assert.assertEquals(3, legs.size()); + Assertions.assertEquals(3, legs.size()); } @Test @@ -788,7 +788,7 @@ void testTravelTimeDependentTransferCosts() { Coord toCoord = new Coord(20000, 100); double depTime = 6.0 * 3600; List routes = raptor.calcRoutes(new FakeFacility(fromCoord), new FakeFacility(toCoord), depTime - 300, depTime, depTime + 300, null, new AttributesImpl()); - Assert.assertEquals(1, routes.size()); + Assertions.assertEquals(1, routes.size()); RaptorRoute route1 = routes.get(0); RaptorParameters params = RaptorUtils.createParameters(config); @@ -797,7 +797,7 @@ void testTravelTimeDependentTransferCosts() { double expectedAccessEgressTime = 2 * 100; // 2 * 100 meters at 1m/s beeline walk speed (beeline factor included) double expectedCost = (expectedTravelTime + expectedAccessEgressTime) * -params.getMarginalUtilityOfTravelTime_utl_s(TransportMode.pt); - Assert.assertEquals(expectedCost, route1.getTotalCosts(), 1e-7); + Assertions.assertEquals(expectedCost, route1.getTotalCosts(), 1e-7); } { // test 2 + 0 * tt @@ -808,7 +808,7 @@ void testTravelTimeDependentTransferCosts() { Coord toCoord = new Coord(20000, 100); double depTime = 6.0 * 3600; List routes = raptor.calcRoutes(new FakeFacility(fromCoord), new FakeFacility(toCoord), depTime - 300, depTime, depTime + 300, null, new AttributesImpl()); - Assert.assertEquals(1, routes.size()); + Assertions.assertEquals(1, routes.size()); RaptorRoute route1 = routes.get(0); RaptorParameters params = RaptorUtils.createParameters(config); @@ -817,7 +817,7 @@ void testTravelTimeDependentTransferCosts() { double expectedAccessEgressTime = 2 * 100; // 2 * 100 meters at 1m/s double expectedCost = (expectedTravelTime + expectedAccessEgressTime) * -params.getMarginalUtilityOfTravelTime_utl_s(TransportMode.pt) + 2; - Assert.assertEquals(expectedCost, route1.getTotalCosts(), 1e-7); + Assertions.assertEquals(expectedCost, route1.getTotalCosts(), 1e-7); } { // test 2 + 9 * tt[h] @@ -828,7 +828,7 @@ void testTravelTimeDependentTransferCosts() { Coord toCoord = new Coord(20000, 100); double depTime = 6.0 * 3600; List routes = raptor.calcRoutes(new FakeFacility(fromCoord), new FakeFacility(toCoord), depTime - 300, depTime, depTime + 300, null, new AttributesImpl()); - Assert.assertEquals(1, routes.size()); + Assertions.assertEquals(1, routes.size()); RaptorRoute route1 = routes.get(0); RaptorParameters params = RaptorUtils.createParameters(config); @@ -837,7 +837,7 @@ void testTravelTimeDependentTransferCosts() { double expectedAccessEgressTime = 2 * 100; // 2 * 100 meters at 1m/s double expectedCost = (expectedTravelTime + expectedAccessEgressTime) * -params.getMarginalUtilityOfTravelTime_utl_s(TransportMode.pt) + 2 + 0.0025 * expectedTravelTime; - Assert.assertEquals(expectedCost, route1.getTotalCosts(), 1e-7); + Assertions.assertEquals(expectedCost, route1.getTotalCosts(), 1e-7); } { // test 2 + 9 * tt[h], longer trip @@ -848,7 +848,7 @@ void testTravelTimeDependentTransferCosts() { Coord toCoord = new Coord(40000, 100); double depTime = 6.0 * 3600; List routes = raptor.calcRoutes(new FakeFacility(fromCoord), new FakeFacility(toCoord), depTime - 300, depTime, depTime + 300, null, new AttributesImpl()); - Assert.assertEquals(1, routes.size()); + Assertions.assertEquals(1, routes.size()); RaptorRoute route1 = routes.get(0); RaptorParameters params = RaptorUtils.createParameters(config); @@ -857,7 +857,7 @@ void testTravelTimeDependentTransferCosts() { double expectedAccessEgressTime = 2 * 100; // 2 * 100 meters at 1m/s double expectedCost = (expectedTravelTime + expectedAccessEgressTime) * -params.getMarginalUtilityOfTravelTime_utl_s(TransportMode.pt) + 2 + 0.0025 * expectedTravelTime; - Assert.assertEquals(expectedCost, route1.getTotalCosts(), 1e-7); + Assertions.assertEquals(expectedCost, route1.getTotalCosts(), 1e-7); } } @@ -891,7 +891,7 @@ public double calcTransferCost(Supplier transfer, RaptorParameters rap for (PlanElement leg : legs) { System.out.println(leg); } - Assert.assertTrue("TransferCost function must have been called at least once.", transferCount[0] > 0); + Assertions.assertTrue(transferCount[0] > 0, "TransferCost function must have been called at least once."); } private Config prepareConfig(double transferFixedCost, double transferRelativeCostFactor) { @@ -1059,7 +1059,7 @@ void testDepartureAfterLastBus(){ List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(fromCoord), new FakeFacility(toCoord), 11.0*3600, null)); - Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); + Assertions.assertNull(legs, "The router should not find a route and return null, but did return something else."); } /** diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTreeTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTreeTest.java index a380bd4ebca..a027ef2c909 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTreeTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTreeTest.java @@ -20,7 +20,7 @@ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorCore.TravelInfo; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -55,7 +55,7 @@ void testSingleStop_dep0740atN_optimized() { double depTime = 7*3600 + 40*60; Map, TravelInfo> map = raptor.calcTree(fromStop, depTime, raptorParams, null); - Assert.assertEquals("wrong number of reached stops.", f.schedule.getFacilities().size(), map.size()); + Assertions.assertEquals(f.schedule.getFacilities().size(), map.size(), "wrong number of reached stops."); assertTravelInfo(map, 0 , "23", 1, "07:41:00", "08:14:07"); // transfer at C, 7:50/8:02 blue, walk at A assertTravelInfo(map, 1 , "23", 1, "07:41:00", "08:14:00"); // transfer at C, 7:50/8:02 blue @@ -98,11 +98,11 @@ void testSingleStop_dep0740atN_unoptimized() { double depTime = 7*3600 + 40*60; Map, TravelInfo> map = raptor.calcTree(fromStop, depTime, raptorParams, null); - Assert.assertEquals("wrong number of reached stops.", 20, map.size()); + Assertions.assertEquals(20, map.size(), "wrong number of reached stops."); - Assert.assertNull(map.get(Id.create(0, TransitStopFacility.class))); // unreachable + Assertions.assertNull(map.get(Id.create(0, TransitStopFacility.class))); // unreachable assertTravelInfo(map, 1 , "23", 1, "07:41:00", "08:14:00"); // transfer at C, 7:50/8:02 blue - Assert.assertNull(map.get(Id.create(2, TransitStopFacility.class))); // unreachable + Assertions.assertNull(map.get(Id.create(2, TransitStopFacility.class))); // unreachable assertTravelInfo(map, 3 , "23", 1, "07:41:00", "08:09:00"); // transfer at C, 7:50/8:02 blue assertTravelInfo(map, 4 , "23", 0, "07:41:00", "07:50:04"); // transfer at C, 7:50, walk 3.12 (-> 4) seconds (2.6 meters) assertTravelInfo(map, 5 , "23", 0, "07:41:00", "07:50:04"); // transfer at C, 7:50, walk 3.12 (-> 4) seconds (2.6 meters) @@ -115,9 +115,9 @@ void testSingleStop_dep0740atN_unoptimized() { assertTravelInfo(map, 12, "23", 1, "07:41:00", "08:09:00"); // transfer at C, 7:50/8:00 red assertTravelInfo(map, 13, "23", 1, "07:41:00", "08:09:07"); // transfer at C, 7:50/8:00 red, walk 4 meters / 7 seconds assertTravelInfo(map, 14, "23", 2, "07:41:00", "08:19:00"); // transfer at C, 7:50/8:00 red, transfer at G, 8:09/8:12 - Assert.assertNull(map.get(Id.create(15, TransitStopFacility.class))); // unreachable + Assertions.assertNull(map.get(Id.create(15, TransitStopFacility.class))); // unreachable assertTravelInfo(map, 16, "23", 2, "07:41:00", "08:24:00"); // transfer at C, 7:50/8:00 red, transfer at G, 8:09/8:12 - Assert.assertNull(map.get(Id.create(17, TransitStopFacility.class))); // unreachable + Assertions.assertNull(map.get(Id.create(17, TransitStopFacility.class))); // unreachable assertTravelInfo(map, 18, "23", 0, "07:41:00", "07:50:00"); // directly reachable assertTravelInfo(map, 19, "23", 1, "07:41:00", "08:01:00"); // transfer at C, 7:50/7:51 green assertTravelInfo(map, 20, "23", 1, "07:41:00", "08:11:00"); // transfer at C, 7:50/7:51 green @@ -144,7 +144,7 @@ void testSingleStop_dep0750atN_optimized() { Map, TravelInfo> map = raptor.calcTree(fromStop, depTime, raptorParams, null); // latest departure on green line is at 07:51, so we'll miss some stops! - Assert.assertEquals("wrong number of reached stops.", 21, map.size()); + Assertions.assertEquals(21, map.size(), "wrong number of reached stops."); assertTravelInfo(map, 0 , "23", 1, "07:51:00", "08:14:07"); // same as [1], then walk assertTravelInfo(map, 1 , "23", 1, "07:51:00", "08:14:00"); // transfer at C, 8:00/8:02 blue @@ -165,10 +165,10 @@ void testSingleStop_dep0750atN_optimized() { assertTravelInfo(map, 16, "23", 1, "07:51:00", "08:44:00"); // transfer at C, 8:00/8:02 blue assertTravelInfo(map, 17, "23", 1, "07:51:00", "08:44:07"); // same as [16], then walk assertTravelInfo(map, 18, "23", 0, "07:51:00", "08:00:00"); // directly reachable - Assert.assertNull(map.get(Id.create(19, TransitStopFacility.class))); // unreachable - Assert.assertNull(map.get(Id.create(20, TransitStopFacility.class))); + Assertions.assertNull(map.get(Id.create(19, TransitStopFacility.class))); // unreachable + Assertions.assertNull(map.get(Id.create(20, TransitStopFacility.class))); assertTravelInfo(map, 21, "23", 1, "07:51:00", "08:28:04"); // transfer at C, 8:00/8:01 green, walk 2 meters / 3.12 (-> 4) seconds - Assert.assertNull(map.get(Id.create(22, TransitStopFacility.class))); + Assertions.assertNull(map.get(Id.create(22, TransitStopFacility.class))); assertTravelInfo(map, 23, "23", 0, "07:50:00", "07:50:00"); // our start location } @@ -188,31 +188,31 @@ void testSingleStop_dep0750atN_unoptimized() { Map, TravelInfo> map = raptor.calcTree(fromStop, depTime, raptorParams, null); // latest departure on green line is at 07:51, so we'll miss some stops! - Assert.assertEquals("wrong number of reached stops.", 14, map.size()); + Assertions.assertEquals(14, map.size(), "wrong number of reached stops."); - Assert.assertNull(map.get(Id.create(0, TransitStopFacility.class))); // unreachable + Assertions.assertNull(map.get(Id.create(0, TransitStopFacility.class))); // unreachable assertTravelInfo(map, 1 , "23", 1, "07:51:00", "08:14:00"); // transfer at C, 8:00/8:02 blue - Assert.assertNull(map.get(Id.create(2, TransitStopFacility.class))); // unreachable + Assertions.assertNull(map.get(Id.create(2, TransitStopFacility.class))); // unreachable assertTravelInfo(map, 3 , "23", 1, "07:51:00", "08:09:00"); // transfer at C, 8:00/8:02 blue assertTravelInfo(map, 4 , "23", 0, "07:51:00", "08:00:04"); // transfer at C, 8:00, walk 3.12 (-> 4) seconds (2.6 meters) assertTravelInfo(map, 5 , "23", 0, "07:51:00", "08:00:04"); // transfer at C, 8:00, walk 3.12 (-> 4) seconds (2.6 meters) assertTravelInfo(map, 6 , "23", 1, "07:51:00", "08:09:00"); // transfer at C, 8:00/8:02 blue - Assert.assertNull(map.get(Id.create(7, TransitStopFacility.class))); // unreachable, no more departures at C(red) or G(blue) + Assertions.assertNull(map.get(Id.create(7, TransitStopFacility.class))); // unreachable, no more departures at C(red) or G(blue) assertTravelInfo(map, 8 , "23", 1, "07:51:00", "08:16:00"); // transfer at C, 8:00/8:02 blue - Assert.assertNull(map.get(Id.create(9, TransitStopFacility.class))); // unreachable, no more departures at C(red) or G(blue) + Assertions.assertNull(map.get(Id.create(9, TransitStopFacility.class))); // unreachable, no more departures at C(red) or G(blue) assertTravelInfo(map, 10, "23", 1, "07:51:00", "08:23:00"); // transfer at C, 8:00/8:02 blue - Assert.assertNull(map.get(Id.create(11, TransitStopFacility.class))); // unreachable, no more departures at C(red) or G(blue) + Assertions.assertNull(map.get(Id.create(11, TransitStopFacility.class))); // unreachable, no more departures at C(red) or G(blue) assertTravelInfo(map, 12, "23", 1, "07:51:00", "08:28:00"); // transfer at C, 8:00/8:02 blue assertTravelInfo(map, 13, "23", 1, "07:51:00", "08:28:07"); // transfer at C, 8:00/8:02 blue, walk (4 meters) (transfer to red line is allowed) assertTravelInfo(map, 14, "23", 1, "07:51:00", "08:39:00"); // transfer at C, 8:00/8:02 blue - Assert.assertNull(map.get(Id.create(15, TransitStopFacility.class))); // unreachable + Assertions.assertNull(map.get(Id.create(15, TransitStopFacility.class))); // unreachable assertTravelInfo(map, 16, "23", 1, "07:51:00", "08:44:00"); // transfer at C, 8:00/8:02 blue - Assert.assertNull(map.get(Id.create(17, TransitStopFacility.class))); // unreachable + Assertions.assertNull(map.get(Id.create(17, TransitStopFacility.class))); // unreachable assertTravelInfo(map, 18, "23", 0, "07:51:00", "08:00:00"); // directly reachable - Assert.assertNull(map.get(Id.create(19, TransitStopFacility.class))); // unreachable - Assert.assertNull(map.get(Id.create(20, TransitStopFacility.class))); + Assertions.assertNull(map.get(Id.create(19, TransitStopFacility.class))); // unreachable + Assertions.assertNull(map.get(Id.create(20, TransitStopFacility.class))); assertTravelInfo(map, 21, "23", 1, "07:51:00", "08:28:04"); // transfer at C, 8:00/8:01 green, walk 2.6 meters / 4 seconds - Assert.assertNull(map.get(Id.create(22, TransitStopFacility.class))); + Assertions.assertNull(map.get(Id.create(22, TransitStopFacility.class))); assertTravelInfo(map, 23, "23", 0, "07:50:00", "07:50:00"); // our start location } @@ -237,7 +237,7 @@ void testMultipleStops_optimized() { fromStops.add(fromStopH); Map, TravelInfo> map = raptor.calcTree(fromStops, depTime, raptorParams, null); - Assert.assertEquals("wrong number of reached stops.", f.schedule.getFacilities().size(), map.size()); + Assertions.assertEquals(f.schedule.getFacilities().size(), map.size(), "wrong number of reached stops."); assertTravelInfo(map, 0 , "2", 0, "07:49:00", "07:54:07"); // initial transfer at B (not counted), walk at A assertTravelInfo(map, 1 , "2", 0, "07:49:00", "07:54:00"); // initial transfer at B (not counted) @@ -284,9 +284,9 @@ void testMultipleStops_unoptimized() { fromStops.add(fromStopH); Map, TravelInfo> map = raptor.calcTree(fromStops, depTime, raptorParams, null); - Assert.assertEquals("wrong number of reached stops.", 22, map.size()); + Assertions.assertEquals(22, map.size(), "wrong number of reached stops."); - Assert.assertNull(map.get(Id.create(0, TransitStopFacility.class))); // unreachable + Assertions.assertNull(map.get(Id.create(0, TransitStopFacility.class))); // unreachable assertTravelInfo(map, 1 , "15", 0, "07:43:00", "08:34:00"); // from H, directly reachable assertTravelInfo(map, 2 , "2", 0, "07:30:00", "07:30:00"); // from B, we started here assertTravelInfo(map, 3 , "15", 0, "07:43:00", "08:29:00"); // from H, directly reachable @@ -303,7 +303,7 @@ void testMultipleStops_unoptimized() { assertTravelInfo(map, 14, "2", 0, "07:33:00", "08:19:00"); // from B, directly reachable assertTravelInfo(map, 15, "15", 0, "07:30:00", "07:30:00"); // from H, we started here assertTravelInfo(map, 16, "2", 0, "07:33:00", "08:24:00"); // from B, directly reachable - Assert.assertNull(map.get(Id.create(17, TransitStopFacility.class))); // unreachable + Assertions.assertNull(map.get(Id.create(17, TransitStopFacility.class))); // unreachable assertTravelInfo(map, 18, "2", 0, "07:33:00", "07:38:04"); // from B, transfer at C, 7:38 (walk 2.6m) assertTravelInfo(map, 19, "2", 1, "07:33:00", "07:51:00"); // from B, transfer at C, 7:38/7:41 green assertTravelInfo(map, 20, "2", 1, "07:33:00", "08:01:00"); // from B, transfer at C, 7:38/7:41 green @@ -334,15 +334,15 @@ void testSingleStop_costs_dep0740atN_optimized() { TravelInfo info0740 = map.get(stop19id); TravelInfo info0739 = raptor.calcTree(fromStop, 7*3600 + 39*60, raptorParams, null).get(stop19id); - Assert.assertEquals("departure time should be the same.", info0740.ptDepartureTime, info0739.ptDepartureTime, 0.0); - Assert.assertEquals("arrival time should be the same.", info0740.ptArrivalTime, info0739.ptArrivalTime, 0.0); - Assert.assertEquals("travel time should be the same.", info0740.ptTravelTime, info0739.ptTravelTime, 0.0); - Assert.assertEquals("access time should be independent of waiting time.", info0740.accessTime, info0739.accessTime, 0.0); - Assert.assertEquals("access cost should be independent of waiting time.", info0740.accessCost, info0739.accessCost, 0.0); - Assert.assertEquals("travel cost should be independent of waiting time.", info0740.travelCost, info0739.travelCost, 0.0); + Assertions.assertEquals(info0740.ptDepartureTime, info0739.ptDepartureTime, 0.0, "departure time should be the same."); + Assertions.assertEquals(info0740.ptArrivalTime, info0739.ptArrivalTime, 0.0, "arrival time should be the same."); + Assertions.assertEquals(info0740.ptTravelTime, info0739.ptTravelTime, 0.0, "travel time should be the same."); + Assertions.assertEquals(info0740.accessTime, info0739.accessTime, 0.0, "access time should be independent of waiting time."); + Assertions.assertEquals(info0740.accessCost, info0739.accessCost, 0.0, "access cost should be independent of waiting time."); + Assertions.assertEquals(info0740.travelCost, info0739.travelCost, 0.0, "travel cost should be independent of waiting time."); - Assert.assertEquals("waiting time should differ by 1 minute", info0740.waitingTime, info0739.waitingTime - 60, 0.0); - Assert.assertTrue("waiting cost should differ", info0740.waitingCost < info0739.waitingCost); + Assertions.assertEquals(info0740.waitingTime, info0739.waitingTime - 60, 0.0, "waiting time should differ by 1 minute"); + Assertions.assertTrue(info0740.waitingCost < info0739.waitingCost, "waiting cost should differ"); } @Test @@ -367,13 +367,13 @@ void testSingleStop_raptorroute_dep0740atN_optimized() { TravelInfo info = map.get(stop2id); RaptorRoute route = info.getRaptorRoute(); - Assert.assertNotNull(route); + Assertions.assertNotNull(route); List parts = new ArrayList<>(); for (RaptorRoute.RoutePart part : route.getParts()) { parts.add(part); } - Assert.assertEquals(5, parts.size()); + Assertions.assertEquals(5, parts.size()); RaptorRoute.RoutePart stage1 = parts.get(0); RaptorRoute.RoutePart stage2 = parts.get(1); RaptorRoute.RoutePart stage3 = parts.get(2); @@ -381,32 +381,32 @@ void testSingleStop_raptorroute_dep0740atN_optimized() { RaptorRoute.RoutePart stage5 = parts.get(4); - Assert.assertNull(stage1.line); // access walk - Assert.assertEquals(0, stage1.distance, 0.0); - Assert.assertEquals(0, stage1.arrivalTime - stage1.depTime, 0.0); + Assertions.assertNull(stage1.line); // access walk + Assertions.assertEquals(0, stage1.distance, 0.0); + Assertions.assertEquals(0, stage1.arrivalTime - stage1.depTime, 0.0); - Assert.assertEquals("green", stage2.line.getId().toString()); - Assert.assertEquals(TransportMode.pt, stage2.mode); - Assert.assertEquals(540, stage2.arrivalTime - stage2.boardingTime, 1e-7); - Assert.assertEquals(10000, stage2.distance, 1e-7); + Assertions.assertEquals("green", stage2.line.getId().toString()); + Assertions.assertEquals(TransportMode.pt, stage2.mode); + Assertions.assertEquals(540, stage2.arrivalTime - stage2.boardingTime, 1e-7); + Assertions.assertEquals(10000, stage2.distance, 1e-7); - Assert.assertNull(stage3.line); // transfer + Assertions.assertNull(stage3.line); // transfer - Assert.assertEquals("blue", stage4.line.getId().toString()); - Assert.assertEquals(TransportMode.pt, stage4.mode); - Assert.assertEquals(660, stage4.arrivalTime - stage4.boardingTime, 1e-7); - Assert.assertEquals(5000, stage4.distance, 1e-7); + Assertions.assertEquals("blue", stage4.line.getId().toString()); + Assertions.assertEquals(TransportMode.pt, stage4.mode); + Assertions.assertEquals(660, stage4.arrivalTime - stage4.boardingTime, 1e-7); + Assertions.assertEquals(5000, stage4.distance, 1e-7); - Assert.assertNull(stage5.line); // egress_walk + Assertions.assertNull(stage5.line); // egress_walk } private void assertTravelInfo(Map, TravelInfo> map, int stopId, String expectedDepartureStop, int expectedTransfers, String expectedDepartureTime, String expectedArrivalTime) { TravelInfo info = map.get(Id.create(stopId, TransitStopFacility.class)); - Assert.assertNotNull("Stop " + stopId + " is not reachable.", info); - Assert.assertEquals("wrong departure stop", expectedDepartureStop, info.departureStop.toString()); - Assert.assertEquals("wrong number of transfers", expectedTransfers, info.transferCount); - Assert.assertEquals("unexpected arrival time: " + Time.writeTime(info.ptArrivalTime), Time.parseTime(expectedArrivalTime), Math.floor(info.ptArrivalTime), 0.0); - Assert.assertEquals("unexpected departure time: " + Time.writeTime(info.ptDepartureTime), Time.parseTime(expectedDepartureTime), Math.floor(info.ptDepartureTime), 0.0); + Assertions.assertNotNull(info, "Stop " + stopId + " is not reachable."); + Assertions.assertEquals(expectedDepartureStop, info.departureStop.toString(), "wrong departure stop"); + Assertions.assertEquals(expectedTransfers, info.transferCount, "wrong number of transfers"); + Assertions.assertEquals(Time.parseTime(expectedArrivalTime), Math.floor(info.ptArrivalTime), 0.0, "unexpected arrival time: " + Time.writeTime(info.ptArrivalTime)); + Assertions.assertEquals(Time.parseTime(expectedDepartureTime), Math.floor(info.ptDepartureTime), 0.0, "unexpected departure time: " + Time.writeTime(info.ptDepartureTime)); } } diff --git a/matsim/src/test/java/org/matsim/analysis/CalcAverageTripLengthTest.java b/matsim/src/test/java/org/matsim/analysis/CalcAverageTripLengthTest.java index 05d463b8b0c..b6017637f1e 100644 --- a/matsim/src/test/java/org/matsim/analysis/CalcAverageTripLengthTest.java +++ b/matsim/src/test/java/org/matsim/analysis/CalcAverageTripLengthTest.java @@ -22,6 +22,8 @@ package org.matsim.analysis; import java.util.ArrayList; + +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -42,9 +44,7 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.testcases.MatsimTestUtils; -import org.junit.Assert; - - public class CalcAverageTripLengthTest { + public class CalcAverageTripLengthTest { @Test void testWithRoute() { @@ -89,9 +89,9 @@ void testWithRoute() { // test simple route, startLink should not be included, endLink should CalcAverageTripLength catl = new CalcAverageTripLength(network); - Assert.assertEquals(0.0, catl.getAverageTripLength(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, catl.getAverageTripLength(), MatsimTestUtils.EPSILON); catl.run(plan); - Assert.assertEquals(300.0, catl.getAverageTripLength(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(300.0, catl.getAverageTripLength(), MatsimTestUtils.EPSILON); // extend route by one link, test again linkIds.add(l3.getId()); @@ -100,7 +100,7 @@ void testWithRoute() { catl = new CalcAverageTripLength(network); catl.run(plan); - Assert.assertEquals(700.0, catl.getAverageTripLength(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(700.0, catl.getAverageTripLength(), MatsimTestUtils.EPSILON); // don't reset catl, modify route, test average linkIds.remove(1); @@ -108,7 +108,7 @@ void testWithRoute() { ((Activity) act2).setLinkId(l3.getId()); catl.run(plan); - Assert.assertEquals(500.0, catl.getAverageTripLength(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(500.0, catl.getAverageTripLength(), MatsimTestUtils.EPSILON); } @Test @@ -145,7 +145,7 @@ void testWithRoute_OneLinkRoute() { // test simple route, startLink should not be included, endLink should be CalcAverageTripLength catl = new CalcAverageTripLength(network); catl.run(plan); - Assert.assertEquals(100.0, catl.getAverageTripLength(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(100.0, catl.getAverageTripLength(), MatsimTestUtils.EPSILON); } @Test @@ -178,7 +178,7 @@ void testWithRoute_StartEndOnSameLink() { // test simple route, none of the links should be included, as there is no real traffic CalcAverageTripLength catl = new CalcAverageTripLength(network); catl.run(plan); - Assert.assertEquals(0.0, catl.getAverageTripLength(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, catl.getAverageTripLength(), MatsimTestUtils.EPSILON); } } diff --git a/matsim/src/test/java/org/matsim/analysis/CalcLegTimesTest.java b/matsim/src/test/java/org/matsim/analysis/CalcLegTimesTest.java index 88e253fa21b..d2b5219d8b5 100644 --- a/matsim/src/test/java/org/matsim/analysis/CalcLegTimesTest.java +++ b/matsim/src/test/java/org/matsim/analysis/CalcLegTimesTest.java @@ -24,8 +24,8 @@ import java.io.IOException; import org.junit.After; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -167,7 +167,7 @@ private void runTest( CalcLegTimes calcLegTimes ) throws IOException { calcLegTimes.writeStats(utils.getOutputDirectory() + CalcLegTimesTest.BASE_FILE_NAME); - Assert.assertEquals(readResult(utils.getInputDirectory() + CalcLegTimesTest.BASE_FILE_NAME), + Assertions.assertEquals(readResult(utils.getInputDirectory() + CalcLegTimesTest.BASE_FILE_NAME), readResult(utils.getOutputDirectory() + CalcLegTimesTest.BASE_FILE_NAME)); } diff --git a/matsim/src/test/java/org/matsim/analysis/CalcLinkStatsTest.java b/matsim/src/test/java/org/matsim/analysis/CalcLinkStatsTest.java index 06e85721459..d147c947e34 100644 --- a/matsim/src/test/java/org/matsim/analysis/CalcLinkStatsTest.java +++ b/matsim/src/test/java/org/matsim/analysis/CalcLinkStatsTest.java @@ -21,7 +21,7 @@ import java.io.File; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -86,10 +86,10 @@ void testAddData() { cls.addData(analyzer, ttimes); - Assert.assertEquals(3.0, cls.getAvgLinkVolumes(link1.getId())[0], 1e-8); - Assert.assertEquals(1.0, cls.getAvgLinkVolumes(link2.getId())[0], 1e-8); - Assert.assertEquals(1.0, cls.getAvgLinkVolumes(link1.getId())[1], 1e-8); - Assert.assertEquals(4.0, cls.getAvgLinkVolumes(link2.getId())[1], 1e-8); + Assertions.assertEquals(3.0, cls.getAvgLinkVolumes(link1.getId())[0], 1e-8); + Assertions.assertEquals(1.0, cls.getAvgLinkVolumes(link2.getId())[0], 1e-8); + Assertions.assertEquals(1.0, cls.getAvgLinkVolumes(link1.getId())[1], 1e-8); + Assertions.assertEquals(4.0, cls.getAvgLinkVolumes(link2.getId())[1], 1e-8); analyzer.reset(1); // generate some pseudo traffic for hour 0: 4 veh on link 1; 3 veh on link 2 @@ -111,15 +111,15 @@ void testAddData() { cls.addData(analyzer, ttimes); - Assert.assertEquals(3.5, cls.getAvgLinkVolumes(link1.getId())[0], 1e-8); - Assert.assertEquals(2.0, cls.getAvgLinkVolumes(link2.getId())[0], 1e-8); - Assert.assertEquals(2.5, cls.getAvgLinkVolumes(link1.getId())[1], 1e-8); - Assert.assertEquals(3.0, cls.getAvgLinkVolumes(link2.getId())[1], 1e-8); + Assertions.assertEquals(3.5, cls.getAvgLinkVolumes(link1.getId())[0], 1e-8); + Assertions.assertEquals(2.0, cls.getAvgLinkVolumes(link2.getId())[0], 1e-8); + Assertions.assertEquals(2.5, cls.getAvgLinkVolumes(link1.getId())[1], 1e-8); + Assertions.assertEquals(3.0, cls.getAvgLinkVolumes(link2.getId())[1], 1e-8); cls.reset(); - Assert.assertEquals(0, cls.getAvgLinkVolumes(link1.getId()).length); - Assert.assertEquals(0, cls.getAvgLinkVolumes(link2.getId()).length); + Assertions.assertEquals(0, cls.getAvgLinkVolumes(link1.getId()).length); + Assertions.assertEquals(0, cls.getAvgLinkVolumes(link2.getId()).length); } /** @@ -196,22 +196,22 @@ void testAddDataObservedTravelTime() { cls.addData(analyzer, ttimes); // volumes - Assert.assertEquals(3.0, cls.getAvgLinkVolumes(link1.getId())[0], 1e-8); - Assert.assertEquals(1.0, cls.getAvgLinkVolumes(link2.getId())[0], 1e-8); - Assert.assertEquals(1.0, cls.getAvgLinkVolumes(link1.getId())[1], 1e-8); - Assert.assertEquals(4.0, cls.getAvgLinkVolumes(link2.getId())[1], 1e-8); + Assertions.assertEquals(3.0, cls.getAvgLinkVolumes(link1.getId())[0], 1e-8); + Assertions.assertEquals(1.0, cls.getAvgLinkVolumes(link2.getId())[0], 1e-8); + Assertions.assertEquals(1.0, cls.getAvgLinkVolumes(link1.getId())[1], 1e-8); + Assertions.assertEquals(4.0, cls.getAvgLinkVolumes(link2.getId())[1], 1e-8); // travel times - Assert.assertEquals( 1530/3., cls.getAvgTravelTimes(link1.getId())[0], 1e-8 ); - Assert.assertEquals( 30./1., cls.getAvgTravelTimes(link2.getId())[0], 1e-8 ); - Assert.assertEquals( 200./1., cls.getAvgTravelTimes(link1.getId())[1], 1e-8 ); - Assert.assertEquals( 100./4., cls.getAvgTravelTimes(link2.getId())[1], 1e-8 ); - Assert.assertEquals( link2.getLength() / link2.getFreespeed(), cls.getAvgTravelTimes(link2.getId())[3], 1e-8 ); + Assertions.assertEquals( 1530/3., cls.getAvgTravelTimes(link1.getId())[0], 1e-8 ); + Assertions.assertEquals( 30./1., cls.getAvgTravelTimes(link2.getId())[0], 1e-8 ); + Assertions.assertEquals( 200./1., cls.getAvgTravelTimes(link1.getId())[1], 1e-8 ); + Assertions.assertEquals( 100./4., cls.getAvgTravelTimes(link2.getId())[1], 1e-8 ); + Assertions.assertEquals( link2.getLength() / link2.getFreespeed(), cls.getAvgTravelTimes(link2.getId())[3], 1e-8 ); cls.reset(); - Assert.assertEquals(0, cls.getAvgLinkVolumes(link1.getId()).length); - Assert.assertEquals(0, cls.getAvgLinkVolumes(link2.getId()).length); + Assertions.assertEquals(0, cls.getAvgLinkVolumes(link1.getId()).length); + Assertions.assertEquals(0, cls.getAvgLinkVolumes(link2.getId()).length); } @Test @@ -273,13 +273,13 @@ void testWriteRead() { String filename = this.util.getOutputDirectory() + "linkstats.txt"; cls.writeFile(filename); - Assert.assertTrue(new File(filename).exists()); + Assertions.assertTrue(new File(filename).exists()); CalcLinkStats cls2 = new CalcLinkStats(network); cls2.readFile(filename); - Assert.assertEquals(3.5, cls2.getAvgLinkVolumes(link1.getId())[0], 1e-8); - Assert.assertEquals(2.0, cls2.getAvgLinkVolumes(link2.getId())[0], 1e-8); - Assert.assertEquals(2.5, cls2.getAvgLinkVolumes(link1.getId())[1], 1e-8); - Assert.assertEquals(3.0, cls2.getAvgLinkVolumes(link2.getId())[1], 1e-8); + Assertions.assertEquals(3.5, cls2.getAvgLinkVolumes(link1.getId())[0], 1e-8); + Assertions.assertEquals(2.0, cls2.getAvgLinkVolumes(link2.getId())[0], 1e-8); + Assertions.assertEquals(2.5, cls2.getAvgLinkVolumes(link1.getId())[1], 1e-8); + Assertions.assertEquals(3.0, cls2.getAvgLinkVolumes(link2.getId())[1], 1e-8); } } diff --git a/matsim/src/test/java/org/matsim/analysis/IterationTravelStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/IterationTravelStatsControlerListenerTest.java index 4d16738191e..1757e6a3f99 100644 --- a/matsim/src/test/java/org/matsim/analysis/IterationTravelStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/IterationTravelStatsControlerListenerTest.java @@ -10,7 +10,7 @@ import java.io.Reader; import java.util.zip.GZIPInputStream; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -149,12 +149,14 @@ private void readAndValidateValues(Scenario scenario) { Person personInScenario = scenario.getPopulation().getPersons().get(personId); Activity firstActivity = identifyFirstActivity(personInScenario); - Assert.assertEquals("wrong score", personInScenario.getSelectedPlan().getScore(), Double.valueOf(column[executed_score]), MatsimTestUtils.EPSILON); - Assert.assertEquals("x coordinate does not match", firstActivity.getCoord().getX(), x, - MatsimTestUtils.EPSILON); - Assert.assertEquals("y coordinate does not match", firstActivity.getCoord().getY(), y, - MatsimTestUtils.EPSILON); - Assert.assertEquals("type of first activity does not match", firstActivity.getType(), column[first_act_type]); + Assertions.assertEquals(personInScenario.getSelectedPlan().getScore(), Double.valueOf(column[executed_score]), MatsimTestUtils.EPSILON, "wrong score"); + Assertions.assertEquals(firstActivity.getCoord().getX(), x, + MatsimTestUtils.EPSILON, + "x coordinate does not match"); + Assertions.assertEquals(firstActivity.getCoord().getY(), y, + MatsimTestUtils.EPSILON, + "y coordinate does not match"); + Assertions.assertEquals(firstActivity.getType(), column[first_act_type], "type of first activity does not match"); break; } diff --git a/matsim/src/test/java/org/matsim/analysis/LegHistogramTest.java b/matsim/src/test/java/org/matsim/analysis/LegHistogramTest.java index e29dfc0af55..6735136a654 100644 --- a/matsim/src/test/java/org/matsim/analysis/LegHistogramTest.java +++ b/matsim/src/test/java/org/matsim/analysis/LegHistogramTest.java @@ -20,7 +20,7 @@ package org.matsim.analysis; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.Set; @@ -181,7 +181,7 @@ void testReset() { histo.reset(1); modes = histo.getLegModes(); - assertEquals("After reset, there should be 0 known leg-modes", 0, modes.size()); + assertEquals(0, modes.size(), "After reset, there should be 0 known leg-modes"); assertFalse(modes.contains(TransportMode.car)); } } diff --git a/matsim/src/test/java/org/matsim/analysis/LinkStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/LinkStatsControlerListenerTest.java index 214b7fffb9b..8ec2fb9f37d 100644 --- a/matsim/src/test/java/org/matsim/analysis/LinkStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/LinkStatsControlerListenerTest.java @@ -20,7 +20,7 @@ package org.matsim.analysis; import com.google.inject.*; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -102,210 +102,210 @@ public void install() { config.linkStats().setWriteLinkStatsInterval(10); // test defaults - Assert.assertEquals(10, config.linkStats().getWriteLinkStatsInterval()); - Assert.assertEquals(5, config.linkStats().getAverageLinkStatsOverIterations()); + Assertions.assertEquals(10, config.linkStats().getWriteLinkStatsInterval()); + Assertions.assertEquals(5, config.linkStats().getAverageLinkStatsOverIterations()); // now the real tests - Assert.assertFalse(lscl.useVolumesOfIteration(0, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(1, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(2, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(3, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(4, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(5, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(6, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(7, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(8, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(9, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(10, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(11, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(12, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(13, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(14, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(15, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(16, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(17, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(18, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(19, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(20, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(21, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(0, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(1, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(2, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(3, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(4, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(5, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(6, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(7, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(8, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(9, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(10, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(11, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(12, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(13, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(14, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(15, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(16, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(17, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(18, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(19, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(20, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(21, 0)); // change some values config.linkStats().setWriteLinkStatsInterval(8); config.linkStats().setAverageLinkStatsOverIterations(2); - Assert.assertFalse(lscl.useVolumesOfIteration(0, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(1, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(2, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(3, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(4, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(5, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(6, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(7, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(8, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(9, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(10, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(11, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(12, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(13, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(14, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(15, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(16, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(17, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(18, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(19, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(20, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(21, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(0, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(1, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(2, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(3, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(4, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(5, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(6, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(7, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(8, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(9, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(10, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(11, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(12, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(13, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(14, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(15, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(16, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(17, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(18, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(19, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(20, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(21, 0)); // change some values: averaging = 1 config.linkStats().setWriteLinkStatsInterval(5); config.linkStats().setAverageLinkStatsOverIterations(1); - Assert.assertTrue(lscl.useVolumesOfIteration(0, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(1, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(2, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(3, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(4, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(5, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(6, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(7, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(8, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(9, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(10, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(11, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(12, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(13, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(14, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(15, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(16, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(17, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(18, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(19, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(20, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(21, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(0, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(1, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(2, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(3, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(4, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(5, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(6, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(7, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(8, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(9, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(10, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(11, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(12, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(13, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(14, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(15, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(16, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(17, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(18, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(19, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(20, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(21, 0)); // change some values: averaging = 0 config.linkStats().setWriteLinkStatsInterval(5); config.linkStats().setAverageLinkStatsOverIterations(0); - Assert.assertTrue(lscl.useVolumesOfIteration(0, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(1, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(2, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(3, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(4, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(5, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(6, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(7, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(8, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(9, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(10, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(11, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(12, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(13, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(14, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(15, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(16, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(17, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(18, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(19, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(20, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(21, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(0, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(1, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(2, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(3, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(4, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(5, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(6, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(7, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(8, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(9, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(10, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(11, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(12, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(13, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(14, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(15, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(16, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(17, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(18, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(19, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(20, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(21, 0)); // change some values: interval = 0 config.linkStats().setWriteLinkStatsInterval(0); config.linkStats().setAverageLinkStatsOverIterations(2); - Assert.assertFalse(lscl.useVolumesOfIteration(0, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(1, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(2, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(3, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(4, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(5, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(6, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(7, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(8, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(9, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(10, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(11, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(12, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(13, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(14, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(15, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(16, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(17, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(18, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(19, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(20, 0)); - Assert.assertFalse(lscl.useVolumesOfIteration(21, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(0, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(1, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(2, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(3, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(4, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(5, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(6, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(7, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(8, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(9, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(10, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(11, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(12, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(13, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(14, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(15, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(16, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(17, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(18, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(19, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(20, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(21, 0)); // change some values: interval equal averaging config.linkStats().setWriteLinkStatsInterval(5); config.linkStats().setAverageLinkStatsOverIterations(5); - Assert.assertFalse(lscl.useVolumesOfIteration(0, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(1, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(2, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(3, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(4, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(5, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(6, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(7, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(8, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(9, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(10, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(11, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(12, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(13, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(14, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(15, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(16, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(17, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(18, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(19, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(20, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(21, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(0, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(1, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(2, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(3, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(4, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(5, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(6, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(7, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(8, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(9, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(10, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(11, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(12, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(13, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(14, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(15, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(16, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(17, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(18, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(19, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(20, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(21, 0)); // change some values: averaging > interval config.linkStats().setWriteLinkStatsInterval(5); config.linkStats().setAverageLinkStatsOverIterations(6); - Assert.assertFalse(lscl.useVolumesOfIteration(0, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(1, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(2, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(3, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(4, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(5, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(6, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(7, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(8, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(9, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(10, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(11, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(12, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(13, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(14, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(15, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(16, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(17, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(18, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(19, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(20, 0)); - Assert.assertTrue(lscl.useVolumesOfIteration(21, 0)); + Assertions.assertFalse(lscl.useVolumesOfIteration(0, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(1, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(2, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(3, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(4, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(5, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(6, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(7, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(8, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(9, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(10, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(11, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(12, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(13, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(14, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(15, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(16, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(17, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(18, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(19, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(20, 0)); + Assertions.assertTrue(lscl.useVolumesOfIteration(21, 0)); // change some values: different firstIteration config.linkStats().setWriteLinkStatsInterval(5); config.linkStats().setAverageLinkStatsOverIterations(3); - Assert.assertFalse(lscl.useVolumesOfIteration(4, 4)); - Assert.assertFalse(lscl.useVolumesOfIteration(5, 4)); - Assert.assertFalse(lscl.useVolumesOfIteration(6, 4)); - Assert.assertFalse(lscl.useVolumesOfIteration(7, 4)); - Assert.assertTrue(lscl.useVolumesOfIteration(8, 4)); - Assert.assertTrue(lscl.useVolumesOfIteration(9, 4)); - Assert.assertTrue(lscl.useVolumesOfIteration(10, 4)); - Assert.assertFalse(lscl.useVolumesOfIteration(11, 4)); - Assert.assertFalse(lscl.useVolumesOfIteration(12, 4)); - Assert.assertTrue(lscl.useVolumesOfIteration(13, 4)); - Assert.assertTrue(lscl.useVolumesOfIteration(14, 4)); - Assert.assertTrue(lscl.useVolumesOfIteration(15, 4)); - Assert.assertFalse(lscl.useVolumesOfIteration(16, 4)); - Assert.assertFalse(lscl.useVolumesOfIteration(17, 4)); - Assert.assertTrue(lscl.useVolumesOfIteration(18, 4)); - Assert.assertTrue(lscl.useVolumesOfIteration(19, 4)); - Assert.assertTrue(lscl.useVolumesOfIteration(20, 4)); - Assert.assertFalse(lscl.useVolumesOfIteration(21, 4)); + Assertions.assertFalse(lscl.useVolumesOfIteration(4, 4)); + Assertions.assertFalse(lscl.useVolumesOfIteration(5, 4)); + Assertions.assertFalse(lscl.useVolumesOfIteration(6, 4)); + Assertions.assertFalse(lscl.useVolumesOfIteration(7, 4)); + Assertions.assertTrue(lscl.useVolumesOfIteration(8, 4)); + Assertions.assertTrue(lscl.useVolumesOfIteration(9, 4)); + Assertions.assertTrue(lscl.useVolumesOfIteration(10, 4)); + Assertions.assertFalse(lscl.useVolumesOfIteration(11, 4)); + Assertions.assertFalse(lscl.useVolumesOfIteration(12, 4)); + Assertions.assertTrue(lscl.useVolumesOfIteration(13, 4)); + Assertions.assertTrue(lscl.useVolumesOfIteration(14, 4)); + Assertions.assertTrue(lscl.useVolumesOfIteration(15, 4)); + Assertions.assertFalse(lscl.useVolumesOfIteration(16, 4)); + Assertions.assertFalse(lscl.useVolumesOfIteration(17, 4)); + Assertions.assertTrue(lscl.useVolumesOfIteration(18, 4)); + Assertions.assertTrue(lscl.useVolumesOfIteration(19, 4)); + Assertions.assertTrue(lscl.useVolumesOfIteration(20, 4)); + Assertions.assertFalse(lscl.useVolumesOfIteration(21, 4)); } @Test @@ -335,14 +335,14 @@ public void install() { config.controller().setWritePlansInterval(0); controler.run(); - Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.0/0.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.1/1.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.2/2.linkstats.txt.gz").exists()); - Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.3/3.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.4/4.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.5/5.linkstats.txt.gz").exists()); - Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.6/6.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.7/7.linkstats.txt.gz").exists()); + Assertions.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.0/0.linkstats.txt.gz").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.1/1.linkstats.txt.gz").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.2/2.linkstats.txt.gz").exists()); + Assertions.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.3/3.linkstats.txt.gz").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.4/4.linkstats.txt.gz").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.5/5.linkstats.txt.gz").exists()); + Assertions.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.6/6.linkstats.txt.gz").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.7/7.linkstats.txt.gz").exists()); } @Test @@ -378,23 +378,23 @@ public void install() { controler.getConfig().controller().setWriteEventsInterval(0); controler.run(); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.0/0.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.1/1.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.2/2.linkstats.txt.gz").exists()); - Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.3/3.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.4/4.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.5/5.linkstats.txt.gz").exists()); - Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.6/6.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.7/7.linkstats.txt.gz").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.0/0.linkstats.txt.gz").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.1/1.linkstats.txt.gz").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.2/2.linkstats.txt.gz").exists()); + Assertions.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.3/3.linkstats.txt.gz").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.4/4.linkstats.txt.gz").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.5/5.linkstats.txt.gz").exists()); + Assertions.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.6/6.linkstats.txt.gz").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.7/7.linkstats.txt.gz").exists()); double[] volumes = getVolumes(config.controller().getOutputDirectory() + "ITERS/it.3/3.linkstats.txt"); - Assert.assertEquals(3, volumes[0], 1e-8); - Assert.assertEquals(3.5, volumes[1], 1e-8); - Assert.assertEquals(4, volumes[2], 1e-8); + Assertions.assertEquals(3, volumes[0], 1e-8); + Assertions.assertEquals(3.5, volumes[1], 1e-8); + Assertions.assertEquals(4, volumes[2], 1e-8); volumes = getVolumes(config.controller().getOutputDirectory() + "ITERS/it.6/6.linkstats.txt"); - Assert.assertEquals(6, volumes[0], 1e-8); - Assert.assertEquals(6.5, volumes[1], 1e-8); - Assert.assertEquals(7, volumes[2], 1e-8); + Assertions.assertEquals(6, volumes[0], 1e-8); + Assertions.assertEquals(6.5, volumes[1], 1e-8); + Assertions.assertEquals(7, volumes[2], 1e-8); } private double[] getVolumes(final String filename) throws IOException { diff --git a/matsim/src/test/java/org/matsim/analysis/ModeChoiceCoverageControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/ModeChoiceCoverageControlerListenerTest.java index 51f97e29a64..8fc4eb25898 100644 --- a/matsim/src/test/java/org/matsim/analysis/ModeChoiceCoverageControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/ModeChoiceCoverageControlerListenerTest.java @@ -1,6 +1,6 @@ package org.matsim.analysis; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -58,10 +58,8 @@ void testChangePlanModes() { modeCC.notifyIterationEnds(new IterationEndsEvent(null, 0,false)); Map>> modeChoiceCoverageHistory = modeCC.getModeChoiceCoverageHistory(); - Assert.assertEquals( "There should only be one mode in the mode modeCCHistory", - 1, modeChoiceCoverageHistory.get(1).keySet().size()); - Assert.assertEquals( "Since all trips were completed with walk, mcc for walk should be 1.0 (or 100%)", - (Double) 1.0, modeChoiceCoverageHistory.get(1).get(TransportMode.walk).get(0)); + Assertions.assertEquals( 1, modeChoiceCoverageHistory.get(1).keySet().size(), "There should only be one mode in the mode modeCCHistory"); + Assertions.assertEquals( (Double) 1.0, modeChoiceCoverageHistory.get(1).get(TransportMode.walk).get(0), "Since all trips were completed with walk, mcc for walk should be 1.0 (or 100%)"); // Iteration 1: walk - bike Plan plan2 = makePlan(person, TransportMode.walk, TransportMode.bike); @@ -69,14 +67,10 @@ void testChangePlanModes() { person.setSelectedPlan(plan2); modeCC.notifyIterationEnds(new IterationEndsEvent(null, 1,false)); - Assert.assertEquals( "There should now be two modes in modeCCHistory", - 2, modeChoiceCoverageHistory.get(1).keySet().size()); - Assert.assertEquals( "Since all trips were completed with walk (in previous iterations), mcc for walk should be 1.0 (or 100%)", - (Double) 1.0, modeChoiceCoverageHistory.get(1).get(TransportMode.walk).get(1)); - Assert.assertEquals( "The mcc for bike from the 0th iteration should be 0.0, since bike only showed up in this iteration", - (Double) 0.0, modeChoiceCoverageHistory.get(1).get(TransportMode.bike).get(0)); - Assert.assertEquals( "Since 1 of 2 trips were completed with bike, mcc for bike should be 0.5 (or 50%)", - (Double) 0.5, modeChoiceCoverageHistory.get(1).get(TransportMode.bike).get(1)); + Assertions.assertEquals( 2, modeChoiceCoverageHistory.get(1).keySet().size(), "There should now be two modes in modeCCHistory"); + Assertions.assertEquals( (Double) 1.0, modeChoiceCoverageHistory.get(1).get(TransportMode.walk).get(1), "Since all trips were completed with walk (in previous iterations), mcc for walk should be 1.0 (or 100%)"); + Assertions.assertEquals( (Double) 0.0, modeChoiceCoverageHistory.get(1).get(TransportMode.bike).get(0), "The mcc for bike from the 0th iteration should be 0.0, since bike only showed up in this iteration"); + Assertions.assertEquals( (Double) 0.5, modeChoiceCoverageHistory.get(1).get(TransportMode.bike).get(1), "Since 1 of 2 trips were completed with bike, mcc for bike should be 0.5 (or 50%)"); // Iteration 3: bike - walk Plan plan3 = makePlan(person, TransportMode.bike, TransportMode.walk); @@ -84,12 +78,9 @@ void testChangePlanModes() { person.setSelectedPlan(plan3); modeCC.notifyIterationEnds(new IterationEndsEvent(null, 2,false)); - Assert.assertEquals( "There should still be two modes in modeCCHistory", - 2, modeChoiceCoverageHistory.get(1).keySet().size()); - Assert.assertEquals( "Since all trips were completed with walk (in previous iterations), mcc for walk should be 1.0 (or 100%)", - (Double) 1.0, modeChoiceCoverageHistory.get(1).get(TransportMode.walk).get(2)); - Assert.assertEquals( "Since all trips were completed with bike (in previous iterations), mcc for bike should be 1.0 (or 100%)", - (Double) 1.0, modeChoiceCoverageHistory.get(1).get(TransportMode.bike).get(2)); + Assertions.assertEquals( 2, modeChoiceCoverageHistory.get(1).keySet().size(), "There should still be two modes in modeCCHistory"); + Assertions.assertEquals( (Double) 1.0, modeChoiceCoverageHistory.get(1).get(TransportMode.walk).get(2), "Since all trips were completed with walk (in previous iterations), mcc for walk should be 1.0 (or 100%)"); + Assertions.assertEquals( (Double) 1.0, modeChoiceCoverageHistory.get(1).get(TransportMode.bike).get(2), "Since all trips were completed with bike (in previous iterations), mcc for bike should be 1.0 (or 100%)"); } @Test @@ -122,10 +113,8 @@ void testTwoAgents() { modeCC.notifyIterationEnds(new IterationEndsEvent(null, 0,false)); Map>> modeChoiceCoverageHistory = modeCC.getModeChoiceCoverageHistory(); - Assert.assertEquals( "There should only be one mode in the mode modeCCHistory", - 1, modeChoiceCoverageHistory.get(1).keySet().size()); - Assert.assertEquals( "Since all trips were completed with walk, mcc for walk should be 1.0 (or 100%)", - (Double) 1.0, modeChoiceCoverageHistory.get(1).get(TransportMode.walk).get(0)); + Assertions.assertEquals( 1, modeChoiceCoverageHistory.get(1).keySet().size(), "There should only be one mode in the mode modeCCHistory"); + Assertions.assertEquals( (Double) 1.0, modeChoiceCoverageHistory.get(1).get(TransportMode.walk).get(0), "Since all trips were completed with walk, mcc for walk should be 1.0 (or 100%)"); // Iteration 1: p1: walk - bike, p2: walk - walk Plan person1plan2 = makePlan(person1, TransportMode.walk, TransportMode.bike); @@ -137,12 +126,9 @@ void testTwoAgents() { person2.setSelectedPlan(person2plan2); modeCC.notifyIterationEnds(new IterationEndsEvent(null, 1,false)); - Assert.assertEquals( "There should now be two modes in modeCCHistory", - 2, modeChoiceCoverageHistory.get(1).keySet().size()); - Assert.assertEquals( "Since all trips were completed with walk (in previous iterations), mcc for walk should be 1.0 (or 100%)", - (Double) 1.0, modeChoiceCoverageHistory.get(1).get(TransportMode.walk).get(1)); - Assert.assertEquals( "Since 1 of 4 trips were completed with bike, mcc for bike should be 0.25 (or 25%)", - (Double) 0.25, modeChoiceCoverageHistory.get(1).get(TransportMode.bike).get(1)); + Assertions.assertEquals( 2, modeChoiceCoverageHistory.get(1).keySet().size(), "There should now be two modes in modeCCHistory"); + Assertions.assertEquals( (Double) 1.0, modeChoiceCoverageHistory.get(1).get(TransportMode.walk).get(1), "Since all trips were completed with walk (in previous iterations), mcc for walk should be 1.0 (or 100%)"); + Assertions.assertEquals( (Double) 0.25, modeChoiceCoverageHistory.get(1).get(TransportMode.bike).get(1), "Since 1 of 4 trips were completed with bike, mcc for bike should be 0.25 (or 25%)"); // Iteration 3: p1: walk - walk, p2: bike - bike Plan person1plan3 = makePlan(person1, TransportMode.walk, TransportMode.walk); @@ -154,12 +140,9 @@ void testTwoAgents() { person2.setSelectedPlan(person2plan3); modeCC.notifyIterationEnds(new IterationEndsEvent(null, 2,false)); - Assert.assertEquals( "There should still be two modes in modeCCHistory", - 2, modeChoiceCoverageHistory.get(1).keySet().size()); - Assert.assertEquals( "Since all trips were completed with walk (in previous iterations), mcc for walk should be 1.0 (or 100%)", - (Double) 1.0, modeChoiceCoverageHistory.get(1).get(TransportMode.walk).get(2)); - Assert.assertEquals( "Since 3 of 4 trips were completed with bike (in previous iterations), mcc for bike should be 0.75 (or 75%)", - (Double) 0.75, modeChoiceCoverageHistory.get(1).get(TransportMode.bike).get(2)); + Assertions.assertEquals( 2, modeChoiceCoverageHistory.get(1).keySet().size(), "There should still be two modes in modeCCHistory"); + Assertions.assertEquals( (Double) 1.0, modeChoiceCoverageHistory.get(1).get(TransportMode.walk).get(2), "Since all trips were completed with walk (in previous iterations), mcc for walk should be 1.0 (or 100%)"); + Assertions.assertEquals( (Double) 0.75, modeChoiceCoverageHistory.get(1).get(TransportMode.bike).get(2), "Since 3 of 4 trips were completed with bike (in previous iterations), mcc for bike should be 0.75 (or 75%)"); } @Test @@ -186,12 +169,9 @@ void testDifferentLevels() { modeCC.notifyIterationEnds(new IterationEndsEvent(null, 0,false)); Map>> modeChoiceCoverageHistory = modeCC.getModeChoiceCoverageHistory(); - Assert.assertEquals("1x threshold should be met after 1 iteration", - (Double) 1.0, modeChoiceCoverageHistory.get(1).get("walk").get(0)); - Assert.assertEquals("5x threshold should NOT be met after 1 iteration", - (Double) 0.0, modeChoiceCoverageHistory.get(5).get("walk").get(0)); - Assert.assertEquals("10x threshold should NOT be met after 1 iteration", - (Double) 0.0, modeChoiceCoverageHistory.get(10).get("walk").get(0)); + Assertions.assertEquals((Double) 1.0, modeChoiceCoverageHistory.get(1).get("walk").get(0), "1x threshold should be met after 1 iteration"); + Assertions.assertEquals((Double) 0.0, modeChoiceCoverageHistory.get(5).get("walk").get(0), "5x threshold should NOT be met after 1 iteration"); + Assertions.assertEquals((Double) 0.0, modeChoiceCoverageHistory.get(10).get("walk").get(0), "10x threshold should NOT be met after 1 iteration"); // After 5 iterations @@ -199,24 +179,18 @@ void testDifferentLevels() { modeCC.notifyIterationEnds(new IterationEndsEvent(null, i,false)); } - Assert.assertEquals("1x threshold should be met after 5 iterations", - (Double) 1.0, modeChoiceCoverageHistory.get(1).get("walk").get(4)); - Assert.assertEquals("5x threshold should be met after 5 iterations", - (Double) 1.0, modeChoiceCoverageHistory.get(5).get("walk").get(4)); - Assert.assertEquals("10x threshold should NOT be met after 5 iterations", - (Double) 0.0, modeChoiceCoverageHistory.get(10).get("walk").get(4)); + Assertions.assertEquals((Double) 1.0, modeChoiceCoverageHistory.get(1).get("walk").get(4), "1x threshold should be met after 5 iterations"); + Assertions.assertEquals((Double) 1.0, modeChoiceCoverageHistory.get(5).get("walk").get(4), "5x threshold should be met after 5 iterations"); + Assertions.assertEquals((Double) 0.0, modeChoiceCoverageHistory.get(10).get("walk").get(4), "10x threshold should NOT be met after 5 iterations"); // After 10 iterations for (int i = 5; i < 10; i++) { modeCC.notifyIterationEnds(new IterationEndsEvent(null, i,false)); } - Assert.assertEquals("1x threshold should be met after 10 iterations", - (Double) 1.0, modeChoiceCoverageHistory.get(1).get("walk").get(9)); - Assert.assertEquals("5x threshold should be met after 10 iterations", - (Double) 1.0, modeChoiceCoverageHistory.get(5).get("walk").get(9)); - Assert.assertEquals("10x threshold should be met after 10 iterations", - (Double) 1.0, modeChoiceCoverageHistory.get(10).get("walk").get(9)); + Assertions.assertEquals((Double) 1.0, modeChoiceCoverageHistory.get(1).get("walk").get(9), "1x threshold should be met after 10 iterations"); + Assertions.assertEquals((Double) 1.0, modeChoiceCoverageHistory.get(5).get("walk").get(9), "5x threshold should be met after 10 iterations"); + Assertions.assertEquals((Double) 1.0, modeChoiceCoverageHistory.get(10).get("walk").get(9), "10x threshold should be met after 10 iterations"); } diff --git a/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java index 400c0b270f8..a98645be213 100644 --- a/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java @@ -10,7 +10,7 @@ import java.util.HashMap; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -436,25 +436,19 @@ private void readAndcompareValues(HashMap modes, int itr) { : 0; double othervalue = (other > 0) ? Double.parseDouble(column[other]) : 0; double ridevalue = (ride > 0) ? Double.parseDouble(column[ride]) : 0; - Assert.assertEquals("car mode has an unexpected score", - (modes.get(TransportMode.car).doubleValue() / totalTrips), carvalue, 0); - Assert.assertEquals("walk mode has an unexpected score", - (modes.get(TransportMode.walk).doubleValue() / totalTrips), walkvalue, 0); - Assert.assertEquals("pt mode has an unexpected score", - (modes.get(TransportMode.pt).doubleValue() / totalTrips), ptvalue, 0); - Assert.assertEquals("bike mode has an unexpected score", - (modes.get(TransportMode.bike).doubleValue() / totalTrips), bikevalue, 0); - Assert.assertEquals("non_network_walk mode has an unexpected score", - (modes.get(TransportMode.non_network_walk).doubleValue() / totalTrips), - non_network_walkvalue, 0); - Assert.assertEquals("other mode has an unexpected score", - (modes.get(TransportMode.other).doubleValue() / totalTrips), othervalue, 0); - Assert.assertEquals("ride mode has an unexpected score", - (modes.get(TransportMode.ride).doubleValue() / totalTrips), ridevalue, 0); - - Assert.assertEquals("sum of the scores of all modes in not equal to 1", 1.0, + Assertions.assertEquals((modes.get(TransportMode.car).doubleValue() / totalTrips), carvalue, 0, "car mode has an unexpected score"); + Assertions.assertEquals((modes.get(TransportMode.walk).doubleValue() / totalTrips), walkvalue, 0, "walk mode has an unexpected score"); + Assertions.assertEquals((modes.get(TransportMode.pt).doubleValue() / totalTrips), ptvalue, 0, "pt mode has an unexpected score"); + Assertions.assertEquals((modes.get(TransportMode.bike).doubleValue() / totalTrips), bikevalue, 0, "bike mode has an unexpected score"); + Assertions.assertEquals((modes.get(TransportMode.non_network_walk).doubleValue() / totalTrips), + non_network_walkvalue, 0, "non_network_walk mode has an unexpected score"); + Assertions.assertEquals((modes.get(TransportMode.other).doubleValue() / totalTrips), othervalue, 0, "other mode has an unexpected score"); + Assertions.assertEquals((modes.get(TransportMode.ride).doubleValue() / totalTrips), ridevalue, 0, "ride mode has an unexpected score"); + + Assertions.assertEquals(1.0, carvalue + walkvalue + ptvalue + bikevalue + non_network_walkvalue + othervalue + ridevalue, - 0.01); + 0.01, + "sum of the scores of all modes in not equal to 1"); break; } diff --git a/matsim/src/test/java/org/matsim/analysis/PHbyModeCalculatorTest.java b/matsim/src/test/java/org/matsim/analysis/PHbyModeCalculatorTest.java index 38e5bec0a4e..3344b3405e1 100644 --- a/matsim/src/test/java/org/matsim/analysis/PHbyModeCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/analysis/PHbyModeCalculatorTest.java @@ -8,8 +8,9 @@ import java.io.IOException; import java.util.HashMap; import java.util.Iterator; -import java.util.List; -import org.junit.Assert; +import java.util.List; + +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -179,16 +180,16 @@ private void readAndValidateValues(int itr, IdMap map) { double pt_wait_value = Double.parseDouble(column[pt_wait]); double stageActivity_wait_value = Double.parseDouble(column[stageActivity_wait]); - Assert.assertEquals("car_travel hour does not match", Math.round(modeValues.get("car") / 3600.0), - car_travel_value, 0); - Assert.assertEquals("pt_travel hour score does not match", Math.round(modeValues.get("pt") / 3600.0), - pt_travel_value, 0); - Assert.assertEquals("walk_travel hour does not match", Math.round(modeValues.get("walk") / 3600.0), - walk_travel_value, 0); - Assert.assertEquals("pt_wait hour does not match", Math.round(modeValues.get("pt_wait") / 3600.0), - pt_wait_value, 0); - Assert.assertEquals("stageActivity_wait hour does not match", Math.round(modeValues.get("stageActivity_wait") / 3600.0), - stageActivity_wait_value, 0); + Assertions.assertEquals(Math.round(modeValues.get("car") / 3600.0), + car_travel_value, 0, "car_travel hour does not match"); + Assertions.assertEquals(Math.round(modeValues.get("pt") / 3600.0), + pt_travel_value, 0, "pt_travel hour score does not match"); + Assertions.assertEquals(Math.round(modeValues.get("walk") / 3600.0), + walk_travel_value, 0, "walk_travel hour does not match"); + Assertions.assertEquals(Math.round(modeValues.get("pt_wait") / 3600.0), + pt_wait_value, 0, "pt_wait hour does not match"); + Assertions.assertEquals(Math.round(modeValues.get("stageActivity_wait") / 3600.0), + stageActivity_wait_value, 0, "stageActivity_wait hour does not match"); break; } diff --git a/matsim/src/test/java/org/matsim/analysis/PKMbyModeCalculatorTest.java b/matsim/src/test/java/org/matsim/analysis/PKMbyModeCalculatorTest.java index b2153471206..00398f6e1d2 100644 --- a/matsim/src/test/java/org/matsim/analysis/PKMbyModeCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/analysis/PKMbyModeCalculatorTest.java @@ -8,7 +8,8 @@ import java.io.IOException; import java.util.HashMap; import java.util.stream.Collectors; -import org.junit.Assert; + +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -217,9 +218,9 @@ private void readAndValidateValues(int itr, Double totalCar, Double totalPt, Dou double ptStat = (pt > 0) ? Double.parseDouble(column[pt]) : 0; double walkStat = (walk > 0) ? Double.parseDouble(column[walk]) : 0; - Assert.assertEquals("Car stats score does not match", Math.round((totalCar / 1000)), carStat, 0); - Assert.assertEquals("PT stats score does not match", Math.round((totalPt / 1000)), ptStat, 0); - Assert.assertEquals("Walk stats score does not match", Math.round((totalWalk / 1000)), walkStat, 0); + Assertions.assertEquals(Math.round((totalCar / 1000)), carStat, 0, "Car stats score does not match"); + Assertions.assertEquals(Math.round((totalPt / 1000)), ptStat, 0, "PT stats score does not match"); + Assertions.assertEquals(Math.round((totalWalk / 1000)), walkStat, 0, "Walk stats score does not match"); break; } iteration++; diff --git a/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java index 1fb5b7900f9..1a25c737c17 100644 --- a/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java @@ -6,7 +6,7 @@ import java.util.ListIterator; import org.assertj.core.api.Assertions; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -543,14 +543,18 @@ private void readAndValidateValues(String outDir, int itr, Population populatio double avgBest = (avgbest > 0) ? Double.parseDouble(column[avgbest]) : 0; double avgAverage = (avgaverage > 0) ? Double.parseDouble(column[avgaverage]) : 0; - Assert.assertEquals("avg. executed score does not match", (getScore(population, "avgexecuted")/(4-itr)), avgExecuted, - 0); - Assert.assertEquals("avg. worst score does not match", (getScore(population, "avgworst")/(4-itr)), avgWorst, - 0); - Assert.assertEquals("avg. best score does not match", (getScore(population, "avgbest")/(4-itr)), avgBest, - 0); - Assert.assertEquals("avg average score does not match", (getScore(population, "avgaverage")/getNoOfPlans(population)), avgAverage, - 0); + Assertions.assertEquals((getScore(population, "avgexecuted")/(4-itr)), avgExecuted, + 0, + "avg. executed score does not match"); + Assertions.assertEquals((getScore(population, "avgworst")/(4-itr)), avgWorst, + 0, + "avg. worst score does not match"); + Assertions.assertEquals((getScore(population, "avgbest")/(4-itr)), avgBest, + 0, + "avg. best score does not match"); + Assertions.assertEquals((getScore(population, "avgaverage")/getNoOfPlans(population)), avgAverage, + 0, + "avg average score does not match"); } iteration++; } diff --git a/matsim/src/test/java/org/matsim/analysis/TransportPlanningMainModeIdentifierTest.java b/matsim/src/test/java/org/matsim/analysis/TransportPlanningMainModeIdentifierTest.java index 0ed11f63558..574b827fa39 100644 --- a/matsim/src/test/java/org/matsim/analysis/TransportPlanningMainModeIdentifierTest.java +++ b/matsim/src/test/java/org/matsim/analysis/TransportPlanningMainModeIdentifierTest.java @@ -4,9 +4,9 @@ package org.matsim.analysis; import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; +import java.util.List; + +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.TransportMode; @@ -98,6 +98,6 @@ private String identifyMainMode(List planElements) { private void validateValues(Plan plan, String mainMode) { String mainModeIdentified = identifyMainMode(plan.getPlanElements()); - Assert.assertEquals(mainModeIdentified, mainMode); + Assertions.assertEquals(mainModeIdentified, mainMode); } } diff --git a/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java b/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java index a98fef56fbf..40db8e0ba7f 100644 --- a/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java +++ b/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java @@ -9,7 +9,7 @@ import java.util.HashMap; import java.util.stream.Collectors; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -376,10 +376,12 @@ private void readAndValidateValues(int itr, Double legSum, int totalTrip, long t double avgLegvalue = (avglegdis > 0) ? Double.parseDouble(column[avglegdis]) : 0; double avgTripvalue = (avgtripdis > 0) ? Double.parseDouble(column[avgtripdis]) : 0; - Assert.assertEquals("avg. Average Trip distance does not match", (legSum / totalTrip), avgTripvalue, - 0); - Assert.assertEquals("avg. Average Leg distance does not match", (legSum / totalLeg), avgLegvalue, - 0); + Assertions.assertEquals((legSum / totalTrip), avgTripvalue, + 0, + "avg. Average Trip distance does not match"); + Assertions.assertEquals((legSum / totalLeg), avgLegvalue, + 0, + "avg. Average Leg distance does not match"); break; } diff --git a/matsim/src/test/java/org/matsim/analysis/TripsAndLegsCSVWriterTest.java b/matsim/src/test/java/org/matsim/analysis/TripsAndLegsCSVWriterTest.java index e5eccd66e12..3f3a03411eb 100644 --- a/matsim/src/test/java/org/matsim/analysis/TripsAndLegsCSVWriterTest.java +++ b/matsim/src/test/java/org/matsim/analysis/TripsAndLegsCSVWriterTest.java @@ -20,7 +20,7 @@ package org.matsim.analysis; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.analysis.TripsAndLegsCSVWriter.NoLegsWriterExtension; @@ -422,27 +422,27 @@ private void readAndValidateLegs(ArrayList legsfromplan, String legFile) while ((line = br.readLine()) != null && legItr.hasNext()) { String[] column = line.split(";", -1); Map nextleg = (Map) legItr.next(); - Assert.assertEquals("dep_time is not as expected", String.valueOf(nextleg.get("dep_time")) , column[dep_time]); - Assert.assertEquals("trav_time is not as expected", String.valueOf(nextleg.get("trav_time")) , column[trav_time]); - Assert.assertEquals("wait_time is not as expected", String.valueOf(nextleg.get("wait_time")) , column[wait_time]); - Assert.assertEquals("Distance is not as expected", String.valueOf(nextleg.get("distance")) , column[distance]); - Assert.assertEquals("mode is not as expected", String.valueOf(nextleg.get("mode")) , column[mode]); - Assert.assertEquals("start_link is not as expected", String.valueOf(nextleg.get("start_link")) , column[start_link]); - Assert.assertEquals("start_x is not as expected", String.valueOf(nextleg.get("start_x")) , column[start_x]); - Assert.assertEquals("start_y is not as expected", String.valueOf(nextleg.get("start_y")) , column[start_y]); - Assert.assertEquals("End link is not as expected", String.valueOf(nextleg.get("end_link")) , column[end_link]); - Assert.assertEquals("end_x is not as expected", String.valueOf(nextleg.get("end_x")) , column[end_x]); - Assert.assertEquals("end_y is not as expected", String.valueOf(nextleg.get("end_y")) , column[end_y]); - Assert.assertEquals("person is not as expected", String.valueOf(nextleg.get("person")) , column[person]); - Assert.assertEquals("trip_id is not as expected", String.valueOf(nextleg.get("trip_id")) , column[trip_id]); - Assert.assertEquals("access_stop_id is not as expected", String.valueOf(nextleg.get("access_stop_id")) , column[access_stop_id] != null ? column[access_stop_id] : ""); - Assert.assertEquals("egress_stop_id is not as expected", String.valueOf(nextleg.get("egress_stop_id")) , column[egress_stop_id] != null ? column[egress_stop_id] : ""); - Assert.assertEquals("transit_line is not as expected", String.valueOf(nextleg.get("transit_line")) , column[transit_line] != null ? column[transit_line] : ""); - Assert.assertEquals("transit_route is not as expected", String.valueOf(nextleg.get("transit_route")) , column[transit_route] != null ? column[transit_route] : ""); - Assert.assertEquals("vehicleId is not as expected", String.valueOf(nextleg.get("vehicle_id")) , column[vehicle_id] != null ? column[vehicle_id] : ""); + Assertions.assertEquals(String.valueOf(nextleg.get("dep_time")) , column[dep_time], "dep_time is not as expected"); + Assertions.assertEquals(String.valueOf(nextleg.get("trav_time")) , column[trav_time], "trav_time is not as expected"); + Assertions.assertEquals(String.valueOf(nextleg.get("wait_time")) , column[wait_time], "wait_time is not as expected"); + Assertions.assertEquals(String.valueOf(nextleg.get("distance")) , column[distance], "Distance is not as expected"); + Assertions.assertEquals(String.valueOf(nextleg.get("mode")) , column[mode], "mode is not as expected"); + Assertions.assertEquals(String.valueOf(nextleg.get("start_link")) , column[start_link], "start_link is not as expected"); + Assertions.assertEquals(String.valueOf(nextleg.get("start_x")) , column[start_x], "start_x is not as expected"); + Assertions.assertEquals(String.valueOf(nextleg.get("start_y")) , column[start_y], "start_y is not as expected"); + Assertions.assertEquals(String.valueOf(nextleg.get("end_link")) , column[end_link], "End link is not as expected"); + Assertions.assertEquals(String.valueOf(nextleg.get("end_x")) , column[end_x], "end_x is not as expected"); + Assertions.assertEquals(String.valueOf(nextleg.get("end_y")) , column[end_y], "end_y is not as expected"); + Assertions.assertEquals(String.valueOf(nextleg.get("person")) , column[person], "person is not as expected"); + Assertions.assertEquals(String.valueOf(nextleg.get("trip_id")) , column[trip_id], "trip_id is not as expected"); + Assertions.assertEquals(String.valueOf(nextleg.get("access_stop_id")) , column[access_stop_id] != null ? column[access_stop_id] : "", "access_stop_id is not as expected"); + Assertions.assertEquals(String.valueOf(nextleg.get("egress_stop_id")) , column[egress_stop_id] != null ? column[egress_stop_id] : "", "egress_stop_id is not as expected"); + Assertions.assertEquals(String.valueOf(nextleg.get("transit_line")) , column[transit_line] != null ? column[transit_line] : "", "transit_line is not as expected"); + Assertions.assertEquals(String.valueOf(nextleg.get("transit_route")) , column[transit_route] != null ? column[transit_route] : "", "transit_route is not as expected"); + Assertions.assertEquals(String.valueOf(nextleg.get("vehicle_id")) , column[vehicle_id] != null ? column[vehicle_id] : "", "vehicleId is not as expected"); if (isIntermodalWalkPt >= 0) { // column from CustomLegsWriterExtension is present - Assert.assertEquals("isIntermodalWalkPt is not as expected", String.valueOf(nextleg.get("isIntermodalWalkPt")) , column[isIntermodalWalkPt]); + Assertions.assertEquals(String.valueOf(nextleg.get("isIntermodalWalkPt")) , column[isIntermodalWalkPt], "isIntermodalWalkPt is not as expected"); } } }catch (IOException e) { @@ -467,41 +467,45 @@ private void readAndValidateTrips(Map persontrips, String tripFi String[] column = line.split(";"); String trip_id_value = column[trip_id]; Map tripvalues = (Map) persontrips.get(trip_id_value); - Assert.assertEquals("Departure time is not as expected", String.valueOf(tripvalues.get("departureTime")), column[dep_time]); - Assert.assertEquals("Travel time is not as expected", String.valueOf(tripvalues.get("travelTime")), column[trav_time]); - Assert.assertEquals("Travel distance is not as expected", String.valueOf(tripvalues.get("traveled_distance")), - column[traveled_distance]); - Assert.assertEquals("Euclidean distance is not as expected", tripvalues.get("euclideanDistance"), - Integer.parseInt(column[euclidean_distance])); - Assert.assertEquals("Main mode is not as expected", - tripvalues.get("main_mode"), column[main_mode]); - Assert.assertEquals("Longest distance mode is not as expected", - tripvalues.get("longest_distance_mode"), column[longest_distance_mode]); - Assert.assertEquals("Modes is not as expected", String.valueOf(tripvalues.get("modes")), column[modes]); - Assert.assertEquals("Start activity type is not as expected", String.valueOf(tripvalues.get("start_activity_type")), - column[start_activity_type]); - Assert.assertEquals("End activity type is not as expected", String.valueOf(tripvalues.get("end_activity_type")), - column[end_activity_type]); - Assert.assertEquals("Start facility id is not as expected", String.valueOf(tripvalues.get("start_facility_id")), - column[start_facility_id]); - Assert.assertEquals("Start link is not as expected", String.valueOf(tripvalues.get("start_link")), column[start_link]); - Assert.assertEquals("Start x is not as expected", String.valueOf(tripvalues.get("start_x")), column[start_x]); - Assert.assertEquals("Start y is not as expected", String.valueOf(tripvalues.get("start_y")), column[start_y]); - Assert.assertEquals("End facility id is not as expected", String.valueOf(tripvalues.get("end_facility_id")), - column[end_facility_id]); - Assert.assertEquals("End link is not as expected", String.valueOf(tripvalues.get("end_link")), column[end_link]); - Assert.assertEquals("End x is not as expected", String.valueOf(tripvalues.get("end_x")), column[end_x]); - Assert.assertEquals("End y is not as expected", String.valueOf(tripvalues.get("end_y")), column[end_y]); - Assert.assertEquals("waiting_time is not as expected", String.valueOf(tripvalues.get("waiting_time")), column[wait_time]); - Assert.assertEquals("person is not as expected", String.valueOf(tripvalues.get("person")), column[person]); - Assert.assertEquals("trip_number is not as expected", String.valueOf(tripvalues.get("trip_number")), column[trip_number]); - Assert.assertEquals("trip_id is not as expected", String.valueOf(tripvalues.get("trip_id")), column[trip_id]); + Assertions.assertEquals(String.valueOf(tripvalues.get("departureTime")), column[dep_time], "Departure time is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("travelTime")), column[trav_time], "Travel time is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("traveled_distance")), + column[traveled_distance], + "Travel distance is not as expected"); + Assertions.assertEquals(tripvalues.get("euclideanDistance"), + Integer.parseInt(column[euclidean_distance]), + "Euclidean distance is not as expected"); + Assertions.assertEquals(tripvalues.get("main_mode"), column[main_mode], "Main mode is not as expected"); + Assertions.assertEquals(tripvalues.get("longest_distance_mode"), column[longest_distance_mode], "Longest distance mode is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("modes")), column[modes], "Modes is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("start_activity_type")), + column[start_activity_type], + "Start activity type is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("end_activity_type")), + column[end_activity_type], + "End activity type is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("start_facility_id")), + column[start_facility_id], + "Start facility id is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("start_link")), column[start_link], "Start link is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("start_x")), column[start_x], "Start x is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("start_y")), column[start_y], "Start y is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("end_facility_id")), + column[end_facility_id], + "End facility id is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("end_link")), column[end_link], "End link is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("end_x")), column[end_x], "End x is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("end_y")), column[end_y], "End y is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("waiting_time")), column[wait_time], "waiting_time is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("person")), column[person], "person is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("trip_number")), column[trip_number], "trip_number is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("trip_id")), column[trip_id], "trip_id is not as expected"); if(column.length > 21) { - Assert.assertEquals("first_pt_boarding_stop is not as expected", String.valueOf(tripvalues.get("first_pt_boarding_stop")), column[first_pt_boarding_stop]); - Assert.assertEquals("last_pt_egress_stop is not as expected", String.valueOf(tripvalues.get("last_pt_egress_stop")), column[last_pt_egress_stop]); + Assertions.assertEquals(String.valueOf(tripvalues.get("first_pt_boarding_stop")), column[first_pt_boarding_stop], "first_pt_boarding_stop is not as expected"); + Assertions.assertEquals(String.valueOf(tripvalues.get("last_pt_egress_stop")), column[last_pt_egress_stop], "last_pt_egress_stop is not as expected"); } if(column.length > 23) { - Assert.assertEquals("transitStopsVisited is not as expected", String.valueOf(tripvalues.get("transitStopsVisited")), column[transitStopsVisited]); + Assertions.assertEquals(String.valueOf(tripvalues.get("transitStopsVisited")), column[transitStopsVisited], "transitStopsVisited is not as expected"); } } } catch (IOException e) { diff --git a/matsim/src/test/java/org/matsim/analysis/VolumesAnalyzerTest.java b/matsim/src/test/java/org/matsim/analysis/VolumesAnalyzerTest.java index 511778fce7c..cbc860120e0 100644 --- a/matsim/src/test/java/org/matsim/analysis/VolumesAnalyzerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/VolumesAnalyzerTest.java @@ -3,7 +3,7 @@ */ package org.matsim.analysis; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -103,14 +103,14 @@ void performTest() { double[] volume = analyzer.getVolumesPerHourForLink(link1); int[] volumeForLink = analyzer.getVolumesForLink(link1); - Assert.assertEquals(volume[1], 2.0, 0); - Assert.assertEquals(volume[2], 3.0, 0); - Assert.assertEquals(volume[3], 2.0, 0); - Assert.assertEquals(volume[6], 5.0, 0); - Assert.assertEquals(volumeForLink[1], 2, 0); - Assert.assertEquals(volumeForLink[2], 3, 0); - Assert.assertEquals(volumeForLink[3], 2, 0); - Assert.assertEquals(volumeForLink[6], 5, 0); + Assertions.assertEquals(volume[1], 2.0, 0); + Assertions.assertEquals(volume[2], 3.0, 0); + Assertions.assertEquals(volume[3], 2.0, 0); + Assertions.assertEquals(volume[6], 5.0, 0); + Assertions.assertEquals(volumeForLink[1], 2, 0); + Assertions.assertEquals(volumeForLink[2], 3, 0); + Assertions.assertEquals(volumeForLink[3], 2, 0); + Assertions.assertEquals(volumeForLink[6], 5, 0); VolumesAnalyzer analyzerBike = new VolumesAnalyzer(3600, 86400, network, true); @@ -128,8 +128,8 @@ void performTest() { double[] volumeBike = analyzerBike.getVolumesPerHourForLink(link2, TransportMode.bike); int[] volumeForLinkBike = analyzerBike.getVolumesForLink(link2, TransportMode.bike); - Assert.assertEquals(volumeBike[6], 3.0, 0); - Assert.assertEquals(volumeForLinkBike[6], 3, 0); + Assertions.assertEquals(volumeBike[6], 3.0, 0); + Assertions.assertEquals(volumeForLinkBike[6], 3, 0); } } diff --git a/matsim/src/test/java/org/matsim/analysis/linkPaxVolumes/LinkPaxVolumesAnalysisTest.java b/matsim/src/test/java/org/matsim/analysis/linkPaxVolumes/LinkPaxVolumesAnalysisTest.java index e8686cd7cf4..e8703896826 100644 --- a/matsim/src/test/java/org/matsim/analysis/linkPaxVolumes/LinkPaxVolumesAnalysisTest.java +++ b/matsim/src/test/java/org/matsim/analysis/linkPaxVolumes/LinkPaxVolumesAnalysisTest.java @@ -22,7 +22,7 @@ import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.analysis.linkpaxvolumes.LinkPaxVolumesAnalysis; @@ -331,12 +331,12 @@ void testLinkPaxVolumes() { List allDayRecordList = parser.getRecords(); List allDayRecordListLink2 = allDayRecordList.stream().filter(record -> record.get(parser.getHeaderMap().get("link")).equals("link2")).collect(Collectors.toList()); - Assert.assertEquals("Either no record or more than one record",1, allDayRecordListLink2.size()); - Assert.assertEquals("Wrong PassengerInclDriver on Link2",8, Double.parseDouble(allDayRecordListLink2.get(0).get(2)),MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, allDayRecordListLink2.size(), "Either no record or more than one record"); + Assertions.assertEquals(8, Double.parseDouble(allDayRecordListLink2.get(0).get(2)),MatsimTestUtils.EPSILON,"Wrong PassengerInclDriver on Link2"); List allDayRecordListLink2b = allDayRecordList.stream().filter(record -> record.get(parser.getHeaderMap().get("link")).equals("link2b")).collect(Collectors.toList()); - Assert.assertEquals("Either no record or more than one record",1, allDayRecordListLink2b.size()); - Assert.assertEquals("Wrong amount of Vehicles on Link2b",3, Double.parseDouble(allDayRecordListLink2b.get(0).get(1)),MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, allDayRecordListLink2b.size(), "Either no record or more than one record"); + Assertions.assertEquals(3, Double.parseDouble(allDayRecordListLink2b.get(0).get(1)),MatsimTestUtils.EPSILON,"Wrong amount of Vehicles on Link2b"); } catch (FileNotFoundException e) { e.printStackTrace(); @@ -353,20 +353,20 @@ void testLinkPaxVolumes() { List networkModePerHourRecordList = parser.getRecords(); List networkModePerHourRecordListLink2 = networkModePerHourRecordList.stream().filter(record -> record.get(parser.getHeaderMap().get("link")).equals("link2") && record.get(parser.getHeaderMap().get("networkMode")).equals("car") && record.get(parser.getHeaderMap().get("hour")).equals("0")).collect(Collectors.toList()); - Assert.assertEquals("Either no record or more than one record",1, networkModePerHourRecordListLink2.size()); - Assert.assertEquals("Wrong PassengerInclDriver on Link2",3, Double.parseDouble(networkModePerHourRecordListLink2.get(0).get("passengersInclDriver")),MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, networkModePerHourRecordListLink2.size(), "Either no record or more than one record"); + Assertions.assertEquals(3, Double.parseDouble(networkModePerHourRecordListLink2.get(0).get("passengersInclDriver")),MatsimTestUtils.EPSILON,"Wrong PassengerInclDriver on Link2"); List networkModePerHourRecordListLink2b = networkModePerHourRecordList.stream().filter(record -> record.get(parser.getHeaderMap().get("link")).equals("link2b") && record.get(parser.getHeaderMap().get("networkMode")).equals("car") && record.get(parser.getHeaderMap().get("hour")).equals("0")).collect(Collectors.toList()); - Assert.assertEquals("Either no record or more than one record",1, networkModePerHourRecordListLink2b.size()); - Assert.assertEquals("Wrong amount of Vehicles on Link2b",2, Double.parseDouble(networkModePerHourRecordListLink2b.get(0).get("vehicles")),MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, networkModePerHourRecordListLink2b.size(), "Either no record or more than one record"); + Assertions.assertEquals(2, Double.parseDouble(networkModePerHourRecordListLink2b.get(0).get("vehicles")),MatsimTestUtils.EPSILON,"Wrong amount of Vehicles on Link2b"); List networkModePerHourRecordListLink2Pt = networkModePerHourRecordList.stream().filter(record -> record.get(parser.getHeaderMap().get("link")).equals("link2") && record.get(parser.getHeaderMap().get("networkMode")).equals("train") && record.get(parser.getHeaderMap().get("hour")).equals("1")).collect(Collectors.toList()); - Assert.assertEquals("Either no record or more than one record",1, networkModePerHourRecordListLink2Pt.size()); - Assert.assertEquals("Wrong amount of passengersInclDriver on Link2",5, Double.parseDouble(networkModePerHourRecordListLink2Pt.get(0).get("passengersInclDriver")),MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, networkModePerHourRecordListLink2Pt.size(), "Either no record or more than one record"); + Assertions.assertEquals(5, Double.parseDouble(networkModePerHourRecordListLink2Pt.get(0).get("passengersInclDriver")),MatsimTestUtils.EPSILON,"Wrong amount of passengersInclDriver on Link2"); List networkModePerHourRecordListLink4b = networkModePerHourRecordList.stream().filter(record -> record.get(parser.getHeaderMap().get("link")).equals("link4b") && record.get(parser.getHeaderMap().get("networkMode")).equals("car") && record.get(parser.getHeaderMap().get("hour")).equals("10")).collect(Collectors.toList()); - Assert.assertEquals("Either no record or more than one record",1, networkModePerHourRecordListLink4b.size()); - Assert.assertEquals("Wrong amount of Vehicles on Link4b",0, Double.parseDouble(networkModePerHourRecordListLink4b.get(0).get("vehicles")),MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, networkModePerHourRecordListLink4b.size(), "Either no record or more than one record"); + Assertions.assertEquals(0, Double.parseDouble(networkModePerHourRecordListLink4b.get(0).get("vehicles")),MatsimTestUtils.EPSILON,"Wrong amount of Vehicles on Link4b"); } catch (FileNotFoundException e) { e.printStackTrace(); @@ -383,12 +383,12 @@ void testLinkPaxVolumes() { List vehicleTypePerHourRecordList = parser.getRecords(); List vehicleTypePerHourRecordListLink2 = vehicleTypePerHourRecordList.stream().filter(record -> record.get(parser.getHeaderMap().get("link")).equals("link2") && record.get(parser.getHeaderMap().get("vehicleType")).equals("vehiclesType1") && record.get(parser.getHeaderMap().get("hour")).equals("0")).collect(Collectors.toList()); - Assert.assertEquals("Either no record or more than one record",1, vehicleTypePerHourRecordListLink2.size()); - Assert.assertEquals("Wrong PassengerInclDriver on Link2",3, Double.parseDouble(vehicleTypePerHourRecordListLink2.get(0).get(4)),MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, vehicleTypePerHourRecordListLink2.size(), "Either no record or more than one record"); + Assertions.assertEquals(3, Double.parseDouble(vehicleTypePerHourRecordListLink2.get(0).get(4)),MatsimTestUtils.EPSILON,"Wrong PassengerInclDriver on Link2"); List vehicleTypePerHourRecordListLink2b = vehicleTypePerHourRecordList.stream().filter(record -> record.get(parser.getHeaderMap().get("link")).equals("link2b") && record.get(parser.getHeaderMap().get("vehicleType")).equals("transitVehicleType") && record.get(parser.getHeaderMap().get("hour")).equals("1")).collect(Collectors.toList()); - Assert.assertEquals("Either no record or more than one record",1, vehicleTypePerHourRecordListLink2b.size()); - Assert.assertEquals("Wrong amount of Vehicles on Link2b",1, Double.parseDouble(vehicleTypePerHourRecordListLink2b.get(0).get(3)),MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, vehicleTypePerHourRecordListLink2b.size(), "Either no record or more than one record"); + Assertions.assertEquals(1, Double.parseDouble(vehicleTypePerHourRecordListLink2b.get(0).get(3)),MatsimTestUtils.EPSILON,"Wrong amount of Vehicles on Link2b"); } catch (FileNotFoundException e) { e.printStackTrace(); @@ -404,14 +404,14 @@ void testLinkPaxVolumes() { List perPassengerModeRecordList = parser.getRecords(); List perPassengerModeRecordListLink4b = perPassengerModeRecordList.stream().filter(record -> record.get(parser.getHeaderMap().get("link")).equals("link4b") && record.get(parser.getHeaderMap().get("passengerMode")).equals("pt") && record.get(parser.getHeaderMap().get("hour")).equals("1")).collect(Collectors.toList()); - Assert.assertEquals("Either no record or more than one record",1, perPassengerModeRecordListLink4b.size()); - Assert.assertEquals("Wrong amount of Vehicles on Link4b",1, Double.parseDouble(perPassengerModeRecordListLink4b.get(0).get("vehicles")),MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong amount of passengersPossiblyInclDriver on Link4b",3, Double.parseDouble(perPassengerModeRecordListLink4b.get(0).get("passengersPossiblyInclDriver")),MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, perPassengerModeRecordListLink4b.size(), "Either no record or more than one record"); + Assertions.assertEquals(1, Double.parseDouble(perPassengerModeRecordListLink4b.get(0).get("vehicles")),MatsimTestUtils.EPSILON,"Wrong amount of Vehicles on Link4b"); + Assertions.assertEquals(3, Double.parseDouble(perPassengerModeRecordListLink4b.get(0).get("passengersPossiblyInclDriver")),MatsimTestUtils.EPSILON,"Wrong amount of passengersPossiblyInclDriver on Link4b"); List perPassengerModeRecordListLink2 = perPassengerModeRecordList.stream().filter(record -> record.get(parser.getHeaderMap().get("link")).equals("link2") && record.get(parser.getHeaderMap().get("passengerMode")).equals("car") && record.get(parser.getHeaderMap().get("hour")).equals("0")).collect(Collectors.toList()); - Assert.assertEquals("Either no record or more than one record",1, perPassengerModeRecordListLink2.size()); - Assert.assertEquals("Wrong amount of Vehicles on Link2b",1, Double.parseDouble(perPassengerModeRecordListLink2.get(0).get("vehicles")),MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong amount of passengersPossiblyInclDriver on Link4b",2, Double.parseDouble(perPassengerModeRecordListLink2.get(0).get("passengersPossiblyInclDriver")),MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, perPassengerModeRecordListLink2.size(), "Either no record or more than one record"); + Assertions.assertEquals(1, Double.parseDouble(perPassengerModeRecordListLink2.get(0).get("vehicles")),MatsimTestUtils.EPSILON,"Wrong amount of Vehicles on Link2b"); + Assertions.assertEquals(2, Double.parseDouble(perPassengerModeRecordListLink2.get(0).get("passengersPossiblyInclDriver")),MatsimTestUtils.EPSILON,"Wrong amount of passengersPossiblyInclDriver on Link4b"); } catch (FileNotFoundException e) { e.printStackTrace(); @@ -427,14 +427,14 @@ void testLinkPaxVolumes() { List statsPerVehicleTypeRecordList = parser.getRecords(); List statsPerVehicleTypeRecordListVehiclesType1 = statsPerVehicleTypeRecordList.stream().filter(record -> record.get(parser.getHeaderMap().get("vehicleType")).equals("vehiclesType1")).collect(Collectors.toList()); - Assert.assertEquals("Either no record or more than one record",1, statsPerVehicleTypeRecordListVehiclesType1.size()); - Assert.assertEquals("Wrong sum of passengerKm",0.6, Double.parseDouble(statsPerVehicleTypeRecordListVehiclesType1.get(0).get("passengerKm")),MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong sum of vehicleKm",0.2, Double.parseDouble(statsPerVehicleTypeRecordListVehiclesType1.get(0).get("vehicleKm")),MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, statsPerVehicleTypeRecordListVehiclesType1.size(), "Either no record or more than one record"); + Assertions.assertEquals(0.6, Double.parseDouble(statsPerVehicleTypeRecordListVehiclesType1.get(0).get("passengerKm")),MatsimTestUtils.EPSILON,"Wrong sum of passengerKm"); + Assertions.assertEquals(0.2, Double.parseDouble(statsPerVehicleTypeRecordListVehiclesType1.get(0).get("vehicleKm")),MatsimTestUtils.EPSILON,"Wrong sum of vehicleKm"); List statsPerVehicleTypeRecordListTransitVehicleType = statsPerVehicleTypeRecordList.stream().filter(record -> record.get(parser.getHeaderMap().get("vehicleType")).equals("transitVehicleType")).collect(Collectors.toList()); - Assert.assertEquals("Wrong sum of passengerKm",3.1, Double.parseDouble(statsPerVehicleTypeRecordListTransitVehicleType.get(0).get("passengerKm")),MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong sum of vehicleKm",0.7, Double.parseDouble(statsPerVehicleTypeRecordListTransitVehicleType.get(0).get("vehicleKm")),MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong vehicleHoursOnNetwork",0.0125, Double.parseDouble(statsPerVehicleTypeRecordListTransitVehicleType.get(0).get("vehicleHoursOnNetwork")),MatsimTestUtils.EPSILON); + Assertions.assertEquals(3.1, Double.parseDouble(statsPerVehicleTypeRecordListTransitVehicleType.get(0).get("passengerKm")),MatsimTestUtils.EPSILON,"Wrong sum of passengerKm"); + Assertions.assertEquals(0.7, Double.parseDouble(statsPerVehicleTypeRecordListTransitVehicleType.get(0).get("vehicleKm")),MatsimTestUtils.EPSILON,"Wrong sum of vehicleKm"); + Assertions.assertEquals(0.0125, Double.parseDouble(statsPerVehicleTypeRecordListTransitVehicleType.get(0).get("vehicleHoursOnNetwork")),MatsimTestUtils.EPSILON,"Wrong vehicleHoursOnNetwork"); } catch (FileNotFoundException e) { e.printStackTrace(); diff --git a/matsim/src/test/java/org/matsim/analysis/personMoney/PersonMoneyEventAggregatorTest.java b/matsim/src/test/java/org/matsim/analysis/personMoney/PersonMoneyEventAggregatorTest.java index 4e1e6b20caf..a973c4a7e58 100644 --- a/matsim/src/test/java/org/matsim/analysis/personMoney/PersonMoneyEventAggregatorTest.java +++ b/matsim/src/test/java/org/matsim/analysis/personMoney/PersonMoneyEventAggregatorTest.java @@ -22,7 +22,7 @@ import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; import org.apache.commons.lang3.mutable.MutableDouble; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -98,20 +98,20 @@ public void reset(int iteration) { List csvRecordListA = csvRecordList.stream().filter(record -> record.get(parser.getHeaderMap().get("transactionPartner")).equals(drt_A) && record.get(parser.getHeaderMap().get("purpose")).equals("drtFare")).collect(Collectors.toList()); - Assert.assertEquals("Either no record or more than one record",1, csvRecordListA.size()); - Assert.assertEquals("Wrong personMoneyAmountSum for drt_A",19.07, Double.parseDouble(csvRecordListA.get(0).get(2)),MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, csvRecordListA.size(), "Either no record or more than one record"); + Assertions.assertEquals(19.07, Double.parseDouble(csvRecordListA.get(0).get(2)),MatsimTestUtils.EPSILON,"Wrong personMoneyAmountSum for drt_A"); List csvRecordList0 = csvRecordList.stream().filter(record -> record.get(parser.getHeaderMap().get("transactionPartner")).equals("DrtA") && record.get(parser.getHeaderMap().get("purpose")).equals("DrtFare")).collect(Collectors.toList()); - Assert.assertEquals("Either no record or more than one record",1, csvRecordList0.size()); - Assert.assertEquals("Wrong personMoneyAmountSum for empty purpose",4.1, Double.parseDouble(csvRecordList0.get(0).get(2)),MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, csvRecordList0.size(), "Either no record or more than one record"); + Assertions.assertEquals(4.1, Double.parseDouble(csvRecordList0.get(0).get(2)),MatsimTestUtils.EPSILON,"Wrong personMoneyAmountSum for empty purpose"); List csvRecordListB = csvRecordList.stream().filter(record -> record.get(parser.getHeaderMap().get("transactionPartner")).equals(drt_B) && record.get(parser.getHeaderMap().get("purpose")).equals("drtFare")).collect(Collectors.toList()); - Assert.assertEquals("Either no record or more than one record",1, csvRecordListB.size()); - Assert.assertEquals("Wrong personMoneyAmountSum for drt_B",16, Double.parseDouble(csvRecordListB.get(0).get(2)),MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, csvRecordListB.size(), "Either no record or more than one record"); + Assertions.assertEquals(16, Double.parseDouble(csvRecordListB.get(0).get(2)),MatsimTestUtils.EPSILON,"Wrong personMoneyAmountSum for drt_B"); List csvRecordListC = csvRecordList.stream().filter(record -> record.get(parser.getHeaderMap().get("transactionPartner")).equals(drt_C) && record.get(parser.getHeaderMap().get("purpose")).equals("drtFare")).collect(Collectors.toList()); - Assert.assertEquals("Either no record or more than one record for drt_C",1, csvRecordListC.size()); - Assert.assertEquals("Wrong personMoneyAmountSum",2.5, Double.parseDouble(csvRecordListC.get(0).get(2)),MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, csvRecordListC.size(), "Either no record or more than one record for drt_C"); + Assertions.assertEquals(2.5, Double.parseDouble(csvRecordListC.get(0).get(2)),MatsimTestUtils.EPSILON,"Wrong personMoneyAmountSum"); } catch (FileNotFoundException e) { e.printStackTrace(); diff --git a/matsim/src/test/java/org/matsim/analysis/pt/stop2stop/PtStop2StopAnalysisTest.java b/matsim/src/test/java/org/matsim/analysis/pt/stop2stop/PtStop2StopAnalysisTest.java index dc39adf4358..88e5fb60349 100644 --- a/matsim/src/test/java/org/matsim/analysis/pt/stop2stop/PtStop2StopAnalysisTest.java +++ b/matsim/src/test/java/org/matsim/analysis/pt/stop2stop/PtStop2StopAnalysisTest.java @@ -19,7 +19,7 @@ package org.matsim.analysis.pt.stop2stop; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -145,30 +145,30 @@ void testPtStop2StopAnalysisSingle() { && entry.departureId.equals(departureId_bus1_route1_dep1) && entry.stopId.equals(transitStopFacilityId1) && entry.stopSequence == 0).collect(Collectors.toList()); System.out.println(line1_route1_dep1_stop1.size()); - Assert.assertEquals("Either no entry or more than entry for " + transitLineId_bus1 + ", " + transitRouteId_bus1_route1 + ", " + departureId_bus1_route1_dep1 + ", " + departureId_bus1_route1_dep1 + ", " + transitStopFacilityId1 + ", 0",1, line1_route1_dep1_stop1.size()); - Assert.assertNull("There should be no previous stop, but there was", line1_route1_dep1_stop1.get(0).stopPreviousId); - Assert.assertEquals("Wrong arrivalTimeScheduled", 1.0, line1_route1_dep1_stop1.get(0).arrivalTimeScheduled, MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong arrivalDelay", 0.0, line1_route1_dep1_stop1.get(0).arrivalDelay, MatsimTestUtils.EPSILON); - Assert.assertEquals(3.0, line1_route1_dep1_stop1.get(0).departureTimeScheduled, MatsimTestUtils.EPSILON); - Assert.assertEquals(0.0, line1_route1_dep1_stop1.get(0).departureDelay, MatsimTestUtils.EPSILON); - Assert.assertEquals(0.0, line1_route1_dep1_stop1.get(0).passengersAtArrival, MatsimTestUtils.EPSILON); - Assert.assertEquals(veh_bus1.getType().getCapacity().getSeats() + veh_bus1.getType().getCapacity().getStandingRoom(), line1_route1_dep1_stop1.get(0).totalVehicleCapacity, MatsimTestUtils.EPSILON); - Assert.assertEquals(0.0, line1_route1_dep1_stop1.get(0).passengersAlighting, MatsimTestUtils.EPSILON); - Assert.assertEquals(2.0, line1_route1_dep1_stop1.get(0).passengersBoarding, MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, line1_route1_dep1_stop1.size(), "Either no entry or more than entry for " + transitLineId_bus1 + ", " + transitRouteId_bus1_route1 + ", " + departureId_bus1_route1_dep1 + ", " + departureId_bus1_route1_dep1 + ", " + transitStopFacilityId1 + ", 0"); + Assertions.assertNull(line1_route1_dep1_stop1.get(0).stopPreviousId, "There should be no previous stop, but there was"); + Assertions.assertEquals(1.0, line1_route1_dep1_stop1.get(0).arrivalTimeScheduled, MatsimTestUtils.EPSILON, "Wrong arrivalTimeScheduled"); + Assertions.assertEquals(0.0, line1_route1_dep1_stop1.get(0).arrivalDelay, MatsimTestUtils.EPSILON, "Wrong arrivalDelay"); + Assertions.assertEquals(3.0, line1_route1_dep1_stop1.get(0).departureTimeScheduled, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, line1_route1_dep1_stop1.get(0).departureDelay, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, line1_route1_dep1_stop1.get(0).passengersAtArrival, MatsimTestUtils.EPSILON); + Assertions.assertEquals(veh_bus1.getType().getCapacity().getSeats() + veh_bus1.getType().getCapacity().getStandingRoom(), line1_route1_dep1_stop1.get(0).totalVehicleCapacity, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, line1_route1_dep1_stop1.get(0).passengersAlighting, MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, line1_route1_dep1_stop1.get(0).passengersBoarding, MatsimTestUtils.EPSILON); List> linkList = new ArrayList<>(); linkList.add(linkId1); - Assert.assertEquals("Wrong links", linkList, line1_route1_dep1_stop1.get(0).linkIdsSincePreviousStop); + Assertions.assertEquals(linkList, line1_route1_dep1_stop1.get(0).linkIdsSincePreviousStop, "Wrong links"); List line1_route1_dep1_stop3 = ptStop2StopAnalysis.getStop2StopEntriesByDeparture().stream() .filter(entry -> entry.transitLineId.equals(transitLineId_bus1) && entry.transitRouteId.equals(transitRouteId_bus1_route1) && entry.departureId.equals(departureId_bus1_route1_dep1) && entry.stopId.equals(transitStopFacilityId3) && entry.stopSequence == 2).collect(Collectors.toList()); - Assert.assertEquals("Either no entry or more than entry for " + transitLineId_bus1 + ", " + transitRouteId_bus1_route1 + ", " + departureId_bus1_route1_dep1 + ", " + departureId_bus1_route1_dep1 + ", " + transitStopFacilityId3 + ", 0",1, line1_route1_dep1_stop3.size()); - Assert.assertEquals("There is no previous stop", transitStopFacilityId2, line1_route1_dep1_stop3.get(0).stopPreviousId); - Assert.assertEquals(12.0, line1_route1_dep1_stop3.get(0).departureTimeScheduled, MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong arrivalTimeScheduled", 12.0, line1_route1_dep1_stop3.get(0).arrivalTimeScheduled, MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong arrival delay", -1.0, line1_route1_dep1_stop3.get(0).arrivalDelay, MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong departure delay", 1.0, line1_route1_dep1_stop3.get(0).departureDelay, MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, line1_route1_dep1_stop3.size(), "Either no entry or more than entry for " + transitLineId_bus1 + ", " + transitRouteId_bus1_route1 + ", " + departureId_bus1_route1_dep1 + ", " + departureId_bus1_route1_dep1 + ", " + transitStopFacilityId3 + ", 0"); + Assertions.assertEquals(transitStopFacilityId2, line1_route1_dep1_stop3.get(0).stopPreviousId, "There is no previous stop"); + Assertions.assertEquals(12.0, line1_route1_dep1_stop3.get(0).departureTimeScheduled, MatsimTestUtils.EPSILON); + Assertions.assertEquals(12.0, line1_route1_dep1_stop3.get(0).arrivalTimeScheduled, MatsimTestUtils.EPSILON, "Wrong arrivalTimeScheduled"); + Assertions.assertEquals(-1.0, line1_route1_dep1_stop3.get(0).arrivalDelay, MatsimTestUtils.EPSILON, "Wrong arrival delay"); + Assertions.assertEquals(1.0, line1_route1_dep1_stop3.get(0).departureDelay, MatsimTestUtils.EPSILON, "Wrong departure delay"); } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -445,53 +445,53 @@ void testPtStop2StopAnalysisMulti() { // Tests List bus1_dep1_stop1 = ptStop2StopAnalysis.getStop2StopEntriesByDeparture().stream().filter(entry -> entry.transitLineId.equals(transitLineId_bus1) && entry.transitRouteId.equals(transitRouteId_bus1_route1) && entry.departureId.equals(departureId_bus1_dep1) && entry.stopId.equals(transitStopFacilityId1) && entry.stopSequence == 0).collect(Collectors.toList()); - Assert.assertEquals("Either no entry or more than entry for " + transitLineId_bus1 + ", " + transitRouteId_bus1_route1 + ", " + departureId_bus1_dep1 + ", " + departureId_bus1_dep1 + ", " + transitStopFacilityId1 + ", 0",1, bus1_dep1_stop1.size()); - Assert.assertNull("There should be no previous stop, but there was", bus1_dep1_stop1.get(0).stopPreviousId); - Assert.assertEquals("Wrong arrivalTimeScheduled", 1.0, bus1_dep1_stop1.get(0).arrivalTimeScheduled, MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong arrivalDelay", 0.0, bus1_dep1_stop1.get(0).arrivalDelay, MatsimTestUtils.EPSILON); - Assert.assertEquals(3.0, bus1_dep1_stop1.get(0).departureTimeScheduled, MatsimTestUtils.EPSILON); - Assert.assertEquals(0.0, bus1_dep1_stop1.get(0).departureDelay, MatsimTestUtils.EPSILON); - Assert.assertEquals(0.0, bus1_dep1_stop1.get(0).passengersAtArrival, MatsimTestUtils.EPSILON); - Assert.assertEquals(veh_bus1_dep1.getType().getCapacity().getSeats() + veh_bus1_dep1.getType().getCapacity().getStandingRoom(), bus1_dep1_stop1.get(0).totalVehicleCapacity, MatsimTestUtils.EPSILON); - Assert.assertEquals(0.0, bus1_dep1_stop1.get(0).passengersAlighting, MatsimTestUtils.EPSILON); - Assert.assertEquals(2.0, bus1_dep1_stop1.get(0).passengersBoarding, MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, bus1_dep1_stop1.size(), "Either no entry or more than entry for " + transitLineId_bus1 + ", " + transitRouteId_bus1_route1 + ", " + departureId_bus1_dep1 + ", " + departureId_bus1_dep1 + ", " + transitStopFacilityId1 + ", 0"); + Assertions.assertNull(bus1_dep1_stop1.get(0).stopPreviousId, "There should be no previous stop, but there was"); + Assertions.assertEquals(1.0, bus1_dep1_stop1.get(0).arrivalTimeScheduled, MatsimTestUtils.EPSILON, "Wrong arrivalTimeScheduled"); + Assertions.assertEquals(0.0, bus1_dep1_stop1.get(0).arrivalDelay, MatsimTestUtils.EPSILON, "Wrong arrivalDelay"); + Assertions.assertEquals(3.0, bus1_dep1_stop1.get(0).departureTimeScheduled, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, bus1_dep1_stop1.get(0).departureDelay, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, bus1_dep1_stop1.get(0).passengersAtArrival, MatsimTestUtils.EPSILON); + Assertions.assertEquals(veh_bus1_dep1.getType().getCapacity().getSeats() + veh_bus1_dep1.getType().getCapacity().getStandingRoom(), bus1_dep1_stop1.get(0).totalVehicleCapacity, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, bus1_dep1_stop1.get(0).passengersAlighting, MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, bus1_dep1_stop1.get(0).passengersBoarding, MatsimTestUtils.EPSILON); List> linkList = new ArrayList<>(); linkList.add(linkId1); - Assert.assertEquals("Wrong links", linkList, bus1_dep1_stop1.get(0).linkIdsSincePreviousStop); + Assertions.assertEquals(linkList, bus1_dep1_stop1.get(0).linkIdsSincePreviousStop, "Wrong links"); List bus1_dep1_stop3 = ptStop2StopAnalysis.getStop2StopEntriesByDeparture().stream().filter(entry -> entry.transitLineId.equals(transitLineId_bus1) && entry.transitRouteId.equals(transitRouteId_bus1_route1) && entry.departureId.equals(departureId_bus1_dep1) && entry.stopId.equals(transitStopFacilityId4) && entry.stopSequence == 2).collect(Collectors.toList()); System.out.println(bus1_dep1_stop3.isEmpty()); - Assert.assertEquals("Either no entry or more than entry for " + transitLineId_bus1 + ", " + transitRouteId_bus1_route1 + ", " + departureId_bus1_dep1 + ", " + departureId_bus1_dep1 + ", " + transitStopFacilityId4 + ", 0",1, bus1_dep1_stop3.size()); - Assert.assertEquals("Wrong arrivalDelay", 0.0, bus1_dep1_stop3.get(0).arrivalDelay, MatsimTestUtils.EPSILON); - Assert.assertEquals(15.0, bus1_dep1_stop3.get(0).departureTimeScheduled, MatsimTestUtils.EPSILON); - Assert.assertEquals(0.0, bus1_dep1_stop3.get(0).departureDelay, MatsimTestUtils.EPSILON); - Assert.assertEquals(3.0, bus1_dep1_stop3.get(0).passengersAtArrival, MatsimTestUtils.EPSILON); - Assert.assertEquals(veh_bus1_dep1.getType().getCapacity().getSeats() + veh_bus1_dep1.getType().getCapacity().getStandingRoom(), bus1_dep1_stop1.get(0).totalVehicleCapacity, MatsimTestUtils.EPSILON); - Assert.assertEquals(3.0, bus1_dep1_stop3.get(0).passengersAlighting, MatsimTestUtils.EPSILON); - Assert.assertEquals(0.0, bus1_dep1_stop3.get(0).passengersBoarding, MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, bus1_dep1_stop3.size(), "Either no entry or more than entry for " + transitLineId_bus1 + ", " + transitRouteId_bus1_route1 + ", " + departureId_bus1_dep1 + ", " + departureId_bus1_dep1 + ", " + transitStopFacilityId4 + ", 0"); + Assertions.assertEquals(0.0, bus1_dep1_stop3.get(0).arrivalDelay, MatsimTestUtils.EPSILON, "Wrong arrivalDelay"); + Assertions.assertEquals(15.0, bus1_dep1_stop3.get(0).departureTimeScheduled, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, bus1_dep1_stop3.get(0).departureDelay, MatsimTestUtils.EPSILON); + Assertions.assertEquals(3.0, bus1_dep1_stop3.get(0).passengersAtArrival, MatsimTestUtils.EPSILON); + Assertions.assertEquals(veh_bus1_dep1.getType().getCapacity().getSeats() + veh_bus1_dep1.getType().getCapacity().getStandingRoom(), bus1_dep1_stop1.get(0).totalVehicleCapacity, MatsimTestUtils.EPSILON); + Assertions.assertEquals(3.0, bus1_dep1_stop3.get(0).passengersAlighting, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, bus1_dep1_stop3.get(0).passengersBoarding, MatsimTestUtils.EPSILON); List bus1_dep1_stop4 = ptStop2StopAnalysis.getStop2StopEntriesByDeparture().stream().filter(entry -> entry.transitLineId.equals(transitLineId_bus1) && entry.transitRouteId.equals(transitRouteId_bus1_route2) && entry.departureId.equals(departureId_bus1_dep1) && entry.stopId.equals(transitStopFacilityId2) && entry.stopSequence == 1).collect(Collectors.toList()); - Assert.assertEquals("Either no entry or more than entry for " + transitLineId_bus1 + ", " + transitRouteId_bus1_route2 + ", " + departureId_bus1_dep1 + ", " + departureId_bus1_dep1 + ", " + transitStopFacilityId2 + ", 0",1, bus1_dep1_stop4.size()); - Assert.assertEquals("Wrong arrivalTimeScheduled", 28.0, bus1_dep1_stop4.get(0).arrivalTimeScheduled, MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong arrivalDelay", 0.0, bus1_dep1_stop4.get(0).arrivalDelay, MatsimTestUtils.EPSILON); - Assert.assertEquals(29.0, bus1_dep1_stop4.get(0).departureTimeScheduled, MatsimTestUtils.EPSILON); - Assert.assertEquals(0.0, bus1_dep1_stop4.get(0).departureDelay, MatsimTestUtils.EPSILON); - Assert.assertEquals(5.0, bus1_dep1_stop4.get(0).passengersAtArrival, MatsimTestUtils.EPSILON); - Assert.assertEquals(veh_bus1_dep1.getType().getCapacity().getSeats() + veh_bus1_dep1.getType().getCapacity().getStandingRoom(), bus1_dep1_stop1.get(0).totalVehicleCapacity, MatsimTestUtils.EPSILON); - Assert.assertEquals(2.0, bus1_dep1_stop4.get(0).passengersAlighting, MatsimTestUtils.EPSILON); - Assert.assertEquals(2.0, bus1_dep1_stop4.get(0).passengersBoarding, MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, bus1_dep1_stop4.size(), "Either no entry or more than entry for " + transitLineId_bus1 + ", " + transitRouteId_bus1_route2 + ", " + departureId_bus1_dep1 + ", " + departureId_bus1_dep1 + ", " + transitStopFacilityId2 + ", 0"); + Assertions.assertEquals(28.0, bus1_dep1_stop4.get(0).arrivalTimeScheduled, MatsimTestUtils.EPSILON, "Wrong arrivalTimeScheduled"); + Assertions.assertEquals(0.0, bus1_dep1_stop4.get(0).arrivalDelay, MatsimTestUtils.EPSILON, "Wrong arrivalDelay"); + Assertions.assertEquals(29.0, bus1_dep1_stop4.get(0).departureTimeScheduled, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, bus1_dep1_stop4.get(0).departureDelay, MatsimTestUtils.EPSILON); + Assertions.assertEquals(5.0, bus1_dep1_stop4.get(0).passengersAtArrival, MatsimTestUtils.EPSILON); + Assertions.assertEquals(veh_bus1_dep1.getType().getCapacity().getSeats() + veh_bus1_dep1.getType().getCapacity().getStandingRoom(), bus1_dep1_stop1.get(0).totalVehicleCapacity, MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, bus1_dep1_stop4.get(0).passengersAlighting, MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.0, bus1_dep1_stop4.get(0).passengersBoarding, MatsimTestUtils.EPSILON); List train1_dep1_stop4 = ptStop2StopAnalysis.getStop2StopEntriesByDeparture().stream().filter(entry -> entry.transitLineId.equals(transitLineId_train1) && entry.transitRouteId.equals(transitRouteId_train1_route1) && entry.departureId.equals(departureId_train1_dep1) && entry.stopId.equals(transitStopFacilityId6) && entry.stopSequence == 3).collect(Collectors.toList()); - Assert.assertEquals("Either no entry or more than entry for " + transitLineId_train1 + ", " + transitRouteId_train1_route1 + ", " + departureId_train1_dep1 + ", " + transitStopFacilityId6 + ", 0",1, train1_dep1_stop4.size()); - Assert.assertEquals("Wrong arrivalTimeScheduled", 19.0, train1_dep1_stop4.get(0).arrivalTimeScheduled, MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong arrivalDelay", 0.0, train1_dep1_stop4.get(0).arrivalDelay, MatsimTestUtils.EPSILON); - Assert.assertEquals(21.0, train1_dep1_stop4.get(0).departureTimeScheduled, MatsimTestUtils.EPSILON); - Assert.assertEquals(0.0, train1_dep1_stop4.get(0).departureDelay, MatsimTestUtils.EPSILON); - Assert.assertEquals(6.0, train1_dep1_stop4.get(0).passengersAtArrival, MatsimTestUtils.EPSILON); - Assert.assertEquals(veh_bus1_dep1.getType().getCapacity().getSeats() + veh_bus1_dep1.getType().getCapacity().getStandingRoom(), bus1_dep1_stop1.get(0).totalVehicleCapacity, MatsimTestUtils.EPSILON); - Assert.assertEquals(4.0, train1_dep1_stop4.get(0).passengersAlighting, MatsimTestUtils.EPSILON); - Assert.assertEquals(1.0, train1_dep1_stop4.get(0).passengersBoarding, MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, train1_dep1_stop4.size(), "Either no entry or more than entry for " + transitLineId_train1 + ", " + transitRouteId_train1_route1 + ", " + departureId_train1_dep1 + ", " + transitStopFacilityId6 + ", 0"); + Assertions.assertEquals(19.0, train1_dep1_stop4.get(0).arrivalTimeScheduled, MatsimTestUtils.EPSILON, "Wrong arrivalTimeScheduled"); + Assertions.assertEquals(0.0, train1_dep1_stop4.get(0).arrivalDelay, MatsimTestUtils.EPSILON, "Wrong arrivalDelay"); + Assertions.assertEquals(21.0, train1_dep1_stop4.get(0).departureTimeScheduled, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, train1_dep1_stop4.get(0).departureDelay, MatsimTestUtils.EPSILON); + Assertions.assertEquals(6.0, train1_dep1_stop4.get(0).passengersAtArrival, MatsimTestUtils.EPSILON); + Assertions.assertEquals(veh_bus1_dep1.getType().getCapacity().getSeats() + veh_bus1_dep1.getType().getCapacity().getStandingRoom(), bus1_dep1_stop1.get(0).totalVehicleCapacity, MatsimTestUtils.EPSILON); + Assertions.assertEquals(4.0, train1_dep1_stop4.get(0).passengersAlighting, MatsimTestUtils.EPSILON); + Assertions.assertEquals(1.0, train1_dep1_stop4.get(0).passengersBoarding, MatsimTestUtils.EPSILON); } } \ No newline at end of file diff --git a/matsim/src/test/java/org/matsim/api/core/v01/CoordTest.java b/matsim/src/test/java/org/matsim/api/core/v01/CoordTest.java index 8a9e0264d4b..30e2646fb26 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/CoordTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/CoordTest.java @@ -20,7 +20,7 @@ package org.matsim.api.core.v01; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; import org.matsim.testcases.MatsimTestUtils; @@ -63,22 +63,22 @@ void testCoord3D() { void testGetX() { // 2D Coord c2 = new Coord(0.0, 1.0); - assertEquals("Wrong x-value.", 0.0, c2.getX(), MatsimTestUtils.EPSILON); + assertEquals(0.0, c2.getX(), MatsimTestUtils.EPSILON, "Wrong x-value."); // 3D Coord c3 = new Coord(0.0, 1.0, 2.0); - assertEquals("Wrong x-value.", 0.0, c3.getX(), MatsimTestUtils.EPSILON); + assertEquals(0.0, c3.getX(), MatsimTestUtils.EPSILON, "Wrong x-value."); } @Test void testGetY() { // 2D Coord c2 = new Coord(0.0, 1.0); - assertEquals("Wrong y-value.", 1.0, c2.getY(), MatsimTestUtils.EPSILON); + assertEquals(1.0, c2.getY(), MatsimTestUtils.EPSILON, "Wrong y-value."); // 3D Coord c3 = new Coord(0.0, 1.0, 2.0); - assertEquals("Wrong y-value.", 1.0, c3.getY(), MatsimTestUtils.EPSILON); + assertEquals(1.0, c3.getY(), MatsimTestUtils.EPSILON, "Wrong y-value."); } @Test @@ -95,7 +95,7 @@ void testGetZ() { // 3D Coord c3 = new Coord(0.0, 1.0, 2.0); - assertEquals("Wrong z-value.", 2.0, c3.getZ(), MatsimTestUtils.EPSILON); + assertEquals(2.0, c3.getZ(), MatsimTestUtils.EPSILON, "Wrong z-value."); } @Test @@ -110,15 +110,15 @@ void testEqualsObject() { Coord c3b = new Coord(0.0, 1.0, 2.0); Coord c3c = new Coord(0.0, 1.0, 3.0); - assertFalse("Coordinates should not be equal.", c2a.equals(dummy)); - assertTrue("Coordinates should not be equal.", c2a.equals(c2b)); - assertFalse("Coordinates should not be equal.", c2a.equals(c2c)); - assertFalse("2D coordinate should not be equal to 3D coordinate.", c2a.equals(c3a)); + assertFalse(c2a.equals(dummy), "Coordinates should not be equal."); + assertTrue(c2a.equals(c2b), "Coordinates should not be equal."); + assertFalse(c2a.equals(c2c), "Coordinates should not be equal."); + assertFalse(c2a.equals(c3a), "2D coordinate should not be equal to 3D coordinate."); - assertFalse("Coordinates should not be equal.", c3a.equals(dummy)); - assertTrue("Coordinates should not be equal.", c3a.equals(c3b)); - assertFalse("Coordinates should not be equal.", c3a.equals(c3c)); - assertFalse("3D coordinate should not be equal to 2D coordinate.", c3a.equals(c2a)); + assertFalse(c3a.equals(dummy), "Coordinates should not be equal."); + assertTrue(c3a.equals(c3b), "Coordinates should not be equal."); + assertFalse(c3a.equals(c3c), "Coordinates should not be equal."); + assertFalse(c3a.equals(c2a), "3D coordinate should not be equal to 2D coordinate."); } @Test diff --git a/matsim/src/test/java/org/matsim/api/core/v01/DemandGenerationTest.java b/matsim/src/test/java/org/matsim/api/core/v01/DemandGenerationTest.java index b92c50d4c4d..7c026b15ca4 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/DemandGenerationTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/DemandGenerationTest.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.api.core.v01; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.io.File; diff --git a/matsim/src/test/java/org/matsim/api/core/v01/IdAnnotationsTest.java b/matsim/src/test/java/org/matsim/api/core/v01/IdAnnotationsTest.java index f2e82c6ecdb..ac679f3d593 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/IdAnnotationsTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/IdAnnotationsTest.java @@ -2,7 +2,7 @@ import java.util.Objects; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.IdAnnotations.JsonId; import org.matsim.api.core.v01.network.Link; @@ -29,9 +29,9 @@ void testRecordJsonIds() throws JsonProcessingException { String s = objectMapper.writeValueAsString(recordWithIds1); RecordWithIds recordWithIds2 = objectMapper.readValue(s, RecordWithIds.class); - Assert.assertEquals(recordWithIds1, recordWithIds2); - Assert.assertEquals(personId, recordWithIds2.personId); - Assert.assertSame(personId, recordWithIds2.personId); + Assertions.assertEquals(recordWithIds1, recordWithIds2); + Assertions.assertEquals(personId, recordWithIds2.personId); + Assertions.assertSame(personId, recordWithIds2.personId); } @Test @@ -42,9 +42,9 @@ void testRecordJsonIdsWithNull() throws JsonProcessingException { String s = objectMapper.writeValueAsString(recordWithIds1); RecordWithIds recordWithIds2 = objectMapper.readValue(s, RecordWithIds.class); - Assert.assertEquals(recordWithIds1, recordWithIds2); - Assert.assertEquals(personId, recordWithIds2.personId); - Assert.assertSame(personId, recordWithIds2.personId); + Assertions.assertEquals(recordWithIds1, recordWithIds2); + Assertions.assertEquals(personId, recordWithIds2.personId); + Assertions.assertSame(personId, recordWithIds2.personId); } @Test @@ -58,9 +58,9 @@ void testClassJsonIds() throws JsonProcessingException { String s = objectMapper.writeValueAsString(classWithIds1); ClassWithIds classWithIds2 = objectMapper.readValue(s, ClassWithIds.class); - Assert.assertEquals(classWithIds1, classWithIds2); - Assert.assertEquals(personId, classWithIds2.personId); - Assert.assertSame(personId, classWithIds2.personId); + Assertions.assertEquals(classWithIds1, classWithIds2); + Assertions.assertEquals(personId, classWithIds2.personId); + Assertions.assertSame(personId, classWithIds2.personId); } @Test @@ -71,9 +71,9 @@ void testClassJsonIdsWithNull() throws JsonProcessingException { String s = objectMapper.writeValueAsString(classWithIds1); ClassWithIds classWithIds2 = objectMapper.readValue(s, ClassWithIds.class); - Assert.assertEquals(classWithIds1, classWithIds2); - Assert.assertEquals(personId, classWithIds2.personId); - Assert.assertSame(personId, classWithIds2.personId); + Assertions.assertEquals(classWithIds1, classWithIds2); + Assertions.assertEquals(personId, classWithIds2.personId); + Assertions.assertSame(personId, classWithIds2.personId); } @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) diff --git a/matsim/src/test/java/org/matsim/api/core/v01/IdDeSerializationModuleTest.java b/matsim/src/test/java/org/matsim/api/core/v01/IdDeSerializationModuleTest.java index 2562a5798c8..04c48fcafe8 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/IdDeSerializationModuleTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/IdDeSerializationModuleTest.java @@ -3,8 +3,8 @@ import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.network.Link; @@ -48,7 +48,7 @@ void testMapKey() { throw new RuntimeException(e); } System.out.println(s); - Assert.assertEquals("{\"0\":\"a\",\"1\":\"b\"}", s); + Assertions.assertEquals("{\"0\":\"a\",\"1\":\"b\"}", s); // deserialize Map, String> map1; @@ -57,10 +57,10 @@ void testMapKey() { } catch (JsonProcessingException e) { throw new RuntimeException(e); } - Assert.assertEquals(map0, map1); - Assert.assertEquals(linkId0, + Assertions.assertEquals(map0, map1); + Assertions.assertEquals(linkId0, map1.keySet().stream().filter(lId -> lId.equals(linkId0)).findFirst().orElseThrow()); - Assert.assertSame(linkId0, + Assertions.assertSame(linkId0, map1.keySet().stream().filter(lId -> lId.equals(linkId0)).findFirst().orElseThrow()); } @@ -86,7 +86,7 @@ void testMapValue() { throw new RuntimeException(e); } System.out.println(s); - Assert.assertEquals("{\"a\":\"0\",\"b\":\"1\"}", s); + Assertions.assertEquals("{\"a\":\"0\",\"b\":\"1\"}", s); // deserialize Map> map1; @@ -95,9 +95,9 @@ void testMapValue() { } catch (JsonProcessingException e) { throw new RuntimeException(e); } - Assert.assertEquals(map0, map1); - Assert.assertEquals(linkId0, map1.get("a")); - Assert.assertSame(linkId0, map1.get("a")); + Assertions.assertEquals(map0, map1); + Assertions.assertEquals(linkId0, map1.get("a")); + Assertions.assertSame(linkId0, map1.get("a")); } } diff --git a/matsim/src/test/java/org/matsim/api/core/v01/IdMapTest.java b/matsim/src/test/java/org/matsim/api/core/v01/IdMapTest.java index f57550f3272..37460662068 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/IdMapTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/IdMapTest.java @@ -1,6 +1,6 @@ package org.matsim.api.core.v01; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.population.Person; import org.matsim.core.utils.collections.Tuple; @@ -17,36 +17,36 @@ public class IdMapTest { void testPutGetRemoveSize() { IdMap map = new IdMap<>(Person.class, 10); - Assert.assertEquals(0, map.size()); - Assert.assertTrue(map.isEmpty()); + Assertions.assertEquals(0, map.size()); + Assertions.assertTrue(map.isEmpty()); - Assert.assertNull(map.put(Id.create(1, Person.class), "one")); + Assertions.assertNull(map.put(Id.create(1, Person.class), "one")); - Assert.assertEquals(1, map.size()); - Assert.assertFalse(map.isEmpty()); + Assertions.assertEquals(1, map.size()); + Assertions.assertFalse(map.isEmpty()); - Assert.assertNull(map.put(Id.create(2, Person.class), "two")); + Assertions.assertNull(map.put(Id.create(2, Person.class), "two")); - Assert.assertEquals(2, map.size()); - Assert.assertFalse(map.isEmpty()); + Assertions.assertEquals(2, map.size()); + Assertions.assertFalse(map.isEmpty()); - Assert.assertEquals("one", map.put(Id.create(1, Person.class), "also-one")); - Assert.assertEquals(2, map.size()); + Assertions.assertEquals("one", map.put(Id.create(1, Person.class), "also-one")); + Assertions.assertEquals(2, map.size()); - Assert.assertNull(map.put(Id.create(3, Person.class), "three")); - Assert.assertEquals(3, map.size()); + Assertions.assertNull(map.put(Id.create(3, Person.class), "three")); + Assertions.assertEquals(3, map.size()); - Assert.assertNull(map.put(Id.create(4, Person.class), null)); - Assert.assertEquals(3, map.size()); + Assertions.assertNull(map.put(Id.create(4, Person.class), null)); + Assertions.assertEquals(3, map.size()); - Assert.assertEquals("also-one", map.get(Id.create(1, Person.class))); - Assert.assertEquals("two", map.get(Id.create(2, Person.class))); - Assert.assertEquals("three", map.get(Id.create(3, Person.class))); - Assert.assertNull(map.get(Id.create(4, Person.class))); + Assertions.assertEquals("also-one", map.get(Id.create(1, Person.class))); + Assertions.assertEquals("two", map.get(Id.create(2, Person.class))); + Assertions.assertEquals("three", map.get(Id.create(3, Person.class))); + Assertions.assertNull(map.get(Id.create(4, Person.class))); - Assert.assertEquals("two", map.remove(Id.create(2, Person.class))); - Assert.assertEquals(2, map.size()); - Assert.assertNull(map.get(Id.create(2, Person.class))); + Assertions.assertEquals("two", map.remove(Id.create(2, Person.class))); + Assertions.assertEquals(2, map.size()); + Assertions.assertNull(map.get(Id.create(2, Person.class))); } @Test @@ -62,19 +62,19 @@ void testIterable() { int i = 0; for (String data : map) { if (i == 0) { - Assert.assertEquals("one", data); + Assertions.assertEquals("one", data); } else if (i == 1) { - Assert.assertEquals("two", data); + Assertions.assertEquals("two", data); } else if (i == 2) { - Assert.assertEquals("four", data); + Assertions.assertEquals("four", data); } else if (i == 3) { - Assert.assertEquals("five", data); + Assertions.assertEquals("five", data); } else { throw new RuntimeException("unexpected element: " + data); } i++; } - Assert.assertEquals(4, i); + Assertions.assertEquals(4, i); } @Test @@ -91,17 +91,17 @@ void testForEach() { map.forEach((k, v) -> data.add(new Tuple<>(k, v))); - Assert.assertEquals(Id.create(1, Person.class), data.get(0).getFirst()); - Assert.assertEquals("one", data.get(0).getSecond()); + Assertions.assertEquals(Id.create(1, Person.class), data.get(0).getFirst()); + Assertions.assertEquals("one", data.get(0).getSecond()); - Assert.assertEquals(Id.create(2, Person.class), data.get(1).getFirst()); - Assert.assertEquals("two", data.get(1).getSecond()); + Assertions.assertEquals(Id.create(2, Person.class), data.get(1).getFirst()); + Assertions.assertEquals("two", data.get(1).getSecond()); - Assert.assertEquals(Id.create(4, Person.class), data.get(2).getFirst()); - Assert.assertEquals("four", data.get(2).getSecond()); + Assertions.assertEquals(Id.create(4, Person.class), data.get(2).getFirst()); + Assertions.assertEquals("four", data.get(2).getSecond()); - Assert.assertEquals(Id.create(5, Person.class), data.get(3).getFirst()); - Assert.assertEquals("five", data.get(3).getSecond()); + Assertions.assertEquals(Id.create(5, Person.class), data.get(3).getFirst()); + Assertions.assertEquals("five", data.get(3).getSecond()); } @Test @@ -114,26 +114,26 @@ void testContainsKey() { map.put(Id.create(4, Person.class), "four"); map.put(Id.create(5, Person.class), "five"); - Assert.assertTrue(map.containsKey(Id.create(1, Person.class))); - Assert.assertTrue(map.containsKey(Id.create(2, Person.class))); - Assert.assertFalse(map.containsKey(Id.create(3, Person.class))); - Assert.assertTrue(map.containsKey(Id.create(4, Person.class))); - Assert.assertTrue(map.containsKey(Id.create(5, Person.class))); - Assert.assertFalse(map.containsKey(Id.create(6, Person.class))); - - Assert.assertTrue(map.containsKey(Id.create(1, Person.class).index())); - Assert.assertTrue(map.containsKey(Id.create(2, Person.class).index())); - Assert.assertFalse(map.containsKey(Id.create(3, Person.class).index())); - Assert.assertTrue(map.containsKey(Id.create(4, Person.class).index())); - Assert.assertTrue(map.containsKey(Id.create(5, Person.class).index())); - Assert.assertFalse(map.containsKey(Id.create(6, Person.class).index())); - - Assert.assertTrue(map.containsKey((Object) Id.create(1, Person.class))); - Assert.assertTrue(map.containsKey((Object) Id.create(2, Person.class))); - Assert.assertFalse(map.containsKey((Object) Id.create(3, Person.class))); - Assert.assertTrue(map.containsKey((Object) Id.create(4, Person.class))); - Assert.assertTrue(map.containsKey((Object) Id.create(5, Person.class))); - Assert.assertFalse(map.containsKey((Object) Id.create(6, Person.class))); + Assertions.assertTrue(map.containsKey(Id.create(1, Person.class))); + Assertions.assertTrue(map.containsKey(Id.create(2, Person.class))); + Assertions.assertFalse(map.containsKey(Id.create(3, Person.class))); + Assertions.assertTrue(map.containsKey(Id.create(4, Person.class))); + Assertions.assertTrue(map.containsKey(Id.create(5, Person.class))); + Assertions.assertFalse(map.containsKey(Id.create(6, Person.class))); + + Assertions.assertTrue(map.containsKey(Id.create(1, Person.class).index())); + Assertions.assertTrue(map.containsKey(Id.create(2, Person.class).index())); + Assertions.assertFalse(map.containsKey(Id.create(3, Person.class).index())); + Assertions.assertTrue(map.containsKey(Id.create(4, Person.class).index())); + Assertions.assertTrue(map.containsKey(Id.create(5, Person.class).index())); + Assertions.assertFalse(map.containsKey(Id.create(6, Person.class).index())); + + Assertions.assertTrue(map.containsKey((Object) Id.create(1, Person.class))); + Assertions.assertTrue(map.containsKey((Object) Id.create(2, Person.class))); + Assertions.assertFalse(map.containsKey((Object) Id.create(3, Person.class))); + Assertions.assertTrue(map.containsKey((Object) Id.create(4, Person.class))); + Assertions.assertTrue(map.containsKey((Object) Id.create(5, Person.class))); + Assertions.assertFalse(map.containsKey((Object) Id.create(6, Person.class))); } @Test @@ -146,12 +146,12 @@ void testContainsValue() { map.put(Id.create(4, Person.class), "four"); map.put(Id.create(5, Person.class), "five"); - Assert.assertTrue(map.containsValue("one")); - Assert.assertTrue(map.containsValue("two")); - Assert.assertFalse(map.containsValue("three")); - Assert.assertTrue(map.containsValue("four")); - Assert.assertTrue(map.containsValue("five")); - Assert.assertFalse(map.containsValue("six")); + Assertions.assertTrue(map.containsValue("one")); + Assertions.assertTrue(map.containsValue("two")); + Assertions.assertFalse(map.containsValue("three")); + Assertions.assertTrue(map.containsValue("four")); + Assertions.assertTrue(map.containsValue("five")); + Assertions.assertFalse(map.containsValue("six")); } @Test @@ -167,13 +167,13 @@ void testPutAll_IdMap() { map.putAll(map2); - Assert.assertEquals(4, map.size()); + Assertions.assertEquals(4, map.size()); - Assert.assertEquals("one", map.get(Id.create(1, Person.class))); - Assert.assertEquals("two", map.get(Id.create(2, Person.class))); - Assert.assertNull(map.get(Id.create(3, Person.class))); - Assert.assertEquals("four", map.get(Id.create(4, Person.class))); - Assert.assertEquals("five", map.get(Id.create(5, Person.class))); + Assertions.assertEquals("one", map.get(Id.create(1, Person.class))); + Assertions.assertEquals("two", map.get(Id.create(2, Person.class))); + Assertions.assertNull(map.get(Id.create(3, Person.class))); + Assertions.assertEquals("four", map.get(Id.create(4, Person.class))); + Assertions.assertEquals("five", map.get(Id.create(5, Person.class))); } @Test @@ -189,13 +189,13 @@ void testPutAll_GenericMap() { map.putAll(map2); - Assert.assertEquals(4, map.size()); + Assertions.assertEquals(4, map.size()); - Assert.assertEquals("one", map.get(Id.create(1, Person.class))); - Assert.assertEquals("two", map.get(Id.create(2, Person.class))); - Assert.assertNull(map.get(Id.create(3, Person.class))); - Assert.assertEquals("four", map.get(Id.create(4, Person.class))); - Assert.assertEquals("five", map.get(Id.create(5, Person.class))); + Assertions.assertEquals("one", map.get(Id.create(1, Person.class))); + Assertions.assertEquals("two", map.get(Id.create(2, Person.class))); + Assertions.assertNull(map.get(Id.create(3, Person.class))); + Assertions.assertEquals("four", map.get(Id.create(4, Person.class))); + Assertions.assertEquals("five", map.get(Id.create(5, Person.class))); } @Test @@ -208,17 +208,17 @@ void testClear() { map.put(Id.create(4, Person.class), "four"); map.put(Id.create(5, Person.class), "five"); - Assert.assertEquals(4, map.size()); + Assertions.assertEquals(4, map.size()); map.clear(); - Assert.assertEquals(0, map.size()); + Assertions.assertEquals(0, map.size()); - Assert.assertNull(map.get(Id.create(1, Person.class))); - Assert.assertNull(map.get(Id.create(2, Person.class))); - Assert.assertNull(map.get(Id.create(3, Person.class))); + Assertions.assertNull(map.get(Id.create(1, Person.class))); + Assertions.assertNull(map.get(Id.create(2, Person.class))); + Assertions.assertNull(map.get(Id.create(3, Person.class))); - Assert.assertFalse(map.containsKey(Id.create(1, Person.class))); + Assertions.assertFalse(map.containsKey(Id.create(1, Person.class))); } @Test @@ -232,28 +232,28 @@ void testValues() { map.put(Id.create(5, Person.class), "five"); Collection coll = map.values(); - Assert.assertEquals(4, coll.size()); + Assertions.assertEquals(4, coll.size()); map.put(Id.create(6, Person.class), "six"); - Assert.assertEquals(5, coll.size()); + Assertions.assertEquals(5, coll.size()); - Assert.assertTrue(coll.remove("one")); - Assert.assertFalse(coll.remove("null")); + Assertions.assertTrue(coll.remove("one")); + Assertions.assertFalse(coll.remove("null")); - Assert.assertFalse(map.containsValue("one")); - Assert.assertTrue(map.containsValue("two")); + Assertions.assertFalse(map.containsValue("one")); + Assertions.assertTrue(map.containsValue("two")); - Assert.assertTrue(coll.contains("two")); - Assert.assertFalse(coll.contains("one")); + Assertions.assertTrue(coll.contains("two")); + Assertions.assertFalse(coll.contains("one")); Set values = new HashSet<>(); coll.forEach(v -> values.add(v)); - Assert.assertEquals(4, values.size()); - Assert.assertTrue(values.contains("two")); - Assert.assertTrue(values.contains("four")); - Assert.assertTrue(values.contains("five")); - Assert.assertTrue(values.contains("six")); + Assertions.assertEquals(4, values.size()); + Assertions.assertTrue(values.contains("two")); + Assertions.assertTrue(values.contains("four")); + Assertions.assertTrue(values.contains("five")); + Assertions.assertTrue(values.contains("six")); } @Test @@ -273,28 +273,28 @@ void testKeySet() { map.put(id5, "five"); Set> set = map.keySet(); - Assert.assertEquals(4, set.size()); + Assertions.assertEquals(4, set.size()); map.put(id6, "six"); - Assert.assertEquals(5, set.size()); + Assertions.assertEquals(5, set.size()); - Assert.assertTrue(set.remove(id1)); - Assert.assertFalse(set.remove(id3)); + Assertions.assertTrue(set.remove(id1)); + Assertions.assertFalse(set.remove(id3)); - Assert.assertFalse(map.containsKey(id1)); - Assert.assertTrue(map.containsKey(id2)); + Assertions.assertFalse(map.containsKey(id1)); + Assertions.assertTrue(map.containsKey(id2)); - Assert.assertTrue(set.contains(id2)); - Assert.assertFalse(set.contains(id1)); + Assertions.assertTrue(set.contains(id2)); + Assertions.assertFalse(set.contains(id1)); Set> keys = new HashSet<>(); set.forEach(k -> keys.add(k)); - Assert.assertEquals(4, keys.size()); - Assert.assertTrue(keys.contains(id2)); - Assert.assertTrue(keys.contains(id4)); - Assert.assertTrue(keys.contains(id5)); - Assert.assertTrue(keys.contains(id6)); + Assertions.assertEquals(4, keys.size()); + Assertions.assertTrue(keys.contains(id2)); + Assertions.assertTrue(keys.contains(id4)); + Assertions.assertTrue(keys.contains(id5)); + Assertions.assertTrue(keys.contains(id6)); } @Test @@ -314,10 +314,10 @@ void testEntrySet() { map.put(id5, "five"); Set, String>> set = map.entrySet(); - Assert.assertEquals(4, set.size()); + Assertions.assertEquals(4, set.size()); map.put(id6, "six"); - Assert.assertEquals(5, set.size()); + Assertions.assertEquals(5, set.size()); Map, Map.Entry, String>> entries = new HashMap<>(); @@ -325,30 +325,30 @@ void testEntrySet() { entries.put(e.getKey(), e); } - Assert.assertEquals(id1, entries.get(id1).getKey()); - Assert.assertEquals("one", entries.get(id1).getValue()); - Assert.assertEquals("two", entries.get(id2).getValue()); - Assert.assertEquals("four", entries.get(id4).getValue()); - Assert.assertEquals("five", entries.get(id5).getValue()); + Assertions.assertEquals(id1, entries.get(id1).getKey()); + Assertions.assertEquals("one", entries.get(id1).getValue()); + Assertions.assertEquals("two", entries.get(id2).getValue()); + Assertions.assertEquals("four", entries.get(id4).getValue()); + Assertions.assertEquals("five", entries.get(id5).getValue()); - Assert.assertTrue(set.remove(entries.get(id1))); - Assert.assertFalse(set.remove(new Object())); + Assertions.assertTrue(set.remove(entries.get(id1))); + Assertions.assertFalse(set.remove(new Object())); - Assert.assertFalse(map.containsKey(id1)); - Assert.assertTrue(map.containsKey(id2)); + Assertions.assertFalse(map.containsKey(id1)); + Assertions.assertTrue(map.containsKey(id2)); - Assert.assertTrue(set.contains(entries.get(id2))); - Assert.assertFalse(set.contains(entries.get(id1))); + Assertions.assertTrue(set.contains(entries.get(id2))); + Assertions.assertFalse(set.contains(entries.get(id1))); // test forEach Set, String>> es = new HashSet<>(); set.forEach(k -> es.add(k)); - Assert.assertEquals(4, es.size()); - Assert.assertTrue(es.contains(entries.get(id2))); - Assert.assertTrue(es.contains(entries.get(id4))); - Assert.assertTrue(es.contains(entries.get(id5))); - Assert.assertTrue(es.contains(entries.get(id6))); + Assertions.assertEquals(4, es.size()); + Assertions.assertTrue(es.contains(entries.get(id2))); + Assertions.assertTrue(es.contains(entries.get(id4))); + Assertions.assertTrue(es.contains(entries.get(id5))); + Assertions.assertTrue(es.contains(entries.get(id6))); } @Test @@ -368,28 +368,28 @@ void testIterator_iterate() { map.put(id5, "five"); Iterator iter = map.iterator(); - Assert.assertNotNull(iter); + Assertions.assertNotNull(iter); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("one", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("one", iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("two", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("two", iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("four", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("four", iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("five", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("five", iter.next()); - Assert.assertFalse(iter.hasNext()); + Assertions.assertFalse(iter.hasNext()); try { iter.next(); - Assert.fail("Expected exception, got none."); + Assertions.fail("Expected exception, got none."); } catch (NoSuchElementException ignore) { } - Assert.assertFalse(iter.hasNext()); + Assertions.assertFalse(iter.hasNext()); } @Test @@ -409,24 +409,24 @@ void testIterator_remove() { map.put(id5, "five"); Iterator iter = map.iterator(); - Assert.assertNotNull(iter); + Assertions.assertNotNull(iter); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("one", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("one", iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("two", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("two", iter.next()); iter.remove(); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("four", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("four", iter.next()); - Assert.assertEquals(3, map.size()); - Assert.assertTrue(map.containsValue("one")); - Assert.assertFalse(map.containsValue("two")); - Assert.assertTrue(map.containsValue("four")); - Assert.assertTrue(map.containsValue("five")); + Assertions.assertEquals(3, map.size()); + Assertions.assertTrue(map.containsValue("one")); + Assertions.assertFalse(map.containsValue("two")); + Assertions.assertTrue(map.containsValue("four")); + Assertions.assertTrue(map.containsValue("five")); } @Test @@ -446,10 +446,10 @@ void testKeySetToArray() { map.put(id5, "five"); Id[] array = (Id[]) map.keySet().toArray(); - Assert.assertEquals(id1, array[0]); - Assert.assertEquals(id2, array[1]); - Assert.assertEquals(id4, array[2]); - Assert.assertEquals(id5, array[3]); + Assertions.assertEquals(id1, array[0]); + Assertions.assertEquals(id2, array[1]); + Assertions.assertEquals(id4, array[2]); + Assertions.assertEquals(id5, array[3]); } @@ -466,37 +466,37 @@ void testEqualsAndHashCode() { IdMap mapB = new IdMap<>(Person.class, 4); IdMap mapC = new IdMap<>(Person.class, 10); - Assert.assertEquals(mapA, mapA); - Assert.assertEquals(mapA, mapB); - Assert.assertEquals(mapA, mapC); - Assert.assertEquals(mapA.hashCode(), mapB.hashCode()); - Assert.assertEquals(mapA.hashCode(), mapC.hashCode()); + Assertions.assertEquals(mapA, mapA); + Assertions.assertEquals(mapA, mapB); + Assertions.assertEquals(mapA, mapC); + Assertions.assertEquals(mapA.hashCode(), mapB.hashCode()); + Assertions.assertEquals(mapA.hashCode(), mapC.hashCode()); mapA.put(id1, "one"); mapB.put(id1, "one"); - Assert.assertEquals(mapA, mapA); - Assert.assertEquals(mapA, mapB); - Assert.assertNotEquals(mapA, mapC); - Assert.assertEquals(mapA.hashCode(), mapB.hashCode()); - Assert.assertNotEquals(mapA.hashCode(), mapC.hashCode()); + Assertions.assertEquals(mapA, mapA); + Assertions.assertEquals(mapA, mapB); + Assertions.assertNotEquals(mapA, mapC); + Assertions.assertEquals(mapA.hashCode(), mapB.hashCode()); + Assertions.assertNotEquals(mapA.hashCode(), mapC.hashCode()); mapC.put(id1, "one"); - Assert.assertEquals(mapA, mapC); - Assert.assertEquals(mapA.hashCode(), mapC.hashCode()); + Assertions.assertEquals(mapA, mapC); + Assertions.assertEquals(mapA.hashCode(), mapC.hashCode()); mapA.put(id2, "two"); mapB.put(id3, "three"); - Assert.assertNotEquals(mapA, mapB); - Assert.assertNotEquals(mapA.hashCode(), mapB.hashCode()); + Assertions.assertNotEquals(mapA, mapB); + Assertions.assertNotEquals(mapA.hashCode(), mapB.hashCode()); mapA.put(id3, "three"); mapB.put(id2, "two"); - Assert.assertEquals(mapA, mapB); - Assert.assertEquals(mapA.hashCode(), mapB.hashCode()); + Assertions.assertEquals(mapA, mapB); + Assertions.assertEquals(mapA.hashCode(), mapB.hashCode()); mapA.put(id4, "four"); mapA.put(id5, "five"); @@ -505,39 +505,39 @@ void testEqualsAndHashCode() { mapA.remove(id5, "five"); mapA.remove(id6, "six"); - Assert.assertEquals(mapA, mapB); - Assert.assertEquals(mapA.hashCode(), mapB.hashCode()); + Assertions.assertEquals(mapA, mapB); + Assertions.assertEquals(mapA.hashCode(), mapB.hashCode()); - Assert.assertEquals(mapA.entrySet(), mapB.entrySet()); - Assert.assertEquals(mapA.entrySet().hashCode(), mapB.entrySet().hashCode()); - Assert.assertEquals(mapA.keySet(), mapB.keySet()); - Assert.assertEquals(mapA.keySet().hashCode(), mapB.keySet().hashCode()); + Assertions.assertEquals(mapA.entrySet(), mapB.entrySet()); + Assertions.assertEquals(mapA.entrySet().hashCode(), mapB.entrySet().hashCode()); + Assertions.assertEquals(mapA.keySet(), mapB.keySet()); + Assertions.assertEquals(mapA.keySet().hashCode(), mapB.keySet().hashCode()); mapA.put(id4, "four"); mapB.put(id4, "DifferentFour"); - Assert.assertNotEquals(mapA, mapB); - Assert.assertNotEquals(mapA.hashCode(), mapB.hashCode()); + Assertions.assertNotEquals(mapA, mapB); + Assertions.assertNotEquals(mapA.hashCode(), mapB.hashCode()); - Assert.assertNotEquals(mapA.entrySet(), mapB.entrySet()); - Assert.assertNotEquals(mapA.entrySet().hashCode(), mapB.entrySet().hashCode()); - Assert.assertEquals(mapA.keySet(), mapB.keySet()); - Assert.assertEquals(mapA.keySet().hashCode(), mapB.keySet().hashCode()); + Assertions.assertNotEquals(mapA.entrySet(), mapB.entrySet()); + Assertions.assertNotEquals(mapA.entrySet().hashCode(), mapB.entrySet().hashCode()); + Assertions.assertEquals(mapA.keySet(), mapB.keySet()); + Assertions.assertEquals(mapA.keySet().hashCode(), mapB.keySet().hashCode()); HashMap, String> hMapA = new HashMap, String>(mapA); // The commented out tests will fail right now because the hashCode of IdImpl is based on the id, not the index - Assert.assertEquals(hMapA, mapA); + Assertions.assertEquals(hMapA, mapA); // Assert.assertEquals(hMapA.hashCode(), mapA.hashCode()); - Assert.assertEquals(hMapA.entrySet(), mapA.entrySet()); + Assertions.assertEquals(hMapA.entrySet(), mapA.entrySet()); // Assert.assertEquals(hMapA.entrySet().hashCode(), mapA.entrySet().hashCode()); - Assert.assertEquals(hMapA.keySet(), mapA.keySet()); + Assertions.assertEquals(hMapA.keySet(), mapA.keySet()); // Assert.assertEquals(hMapA.keySet().hashCode(), mapA.keySet().hashCode()); - Assert.assertNotEquals(hMapA, mapB); - Assert.assertNotEquals(hMapA.hashCode(), mapB.hashCode()); - Assert.assertNotEquals(hMapA.entrySet(), mapB.entrySet()); - Assert.assertNotEquals(hMapA.entrySet().hashCode(), mapB.entrySet().hashCode()); - Assert.assertEquals(hMapA.keySet(), mapB.keySet()); + Assertions.assertNotEquals(hMapA, mapB); + Assertions.assertNotEquals(hMapA.hashCode(), mapB.hashCode()); + Assertions.assertNotEquals(hMapA.entrySet(), mapB.entrySet()); + Assertions.assertNotEquals(hMapA.entrySet().hashCode(), mapB.entrySet().hashCode()); + Assertions.assertEquals(hMapA.keySet(), mapB.keySet()); // Assert.assertEquals(hMapA.keySet().hashCode(), mapB.keySet().hashCode()); // Best way I could think of to explicitly test the equals() of Entry (i.e. not inside the EntrySet) @@ -545,11 +545,11 @@ void testEqualsAndHashCode() { while (iter.hasNext()) { Entry, String> e = iter.next(); if (e.getKey() != id4) { - Assert.assertTrue(mapB.entrySet().contains(e)); + Assertions.assertTrue(mapB.entrySet().contains(e)); } else { - Assert.assertFalse(mapB.entrySet().contains(e)); + Assertions.assertFalse(mapB.entrySet().contains(e)); } - Assert.assertTrue(hMapA.entrySet().contains(e)); + Assertions.assertTrue(hMapA.entrySet().contains(e)); } } diff --git a/matsim/src/test/java/org/matsim/api/core/v01/IdSetTest.java b/matsim/src/test/java/org/matsim/api/core/v01/IdSetTest.java index 63bee1c218d..02629f3f0dc 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/IdSetTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/IdSetTest.java @@ -1,6 +1,6 @@ package org.matsim.api.core.v01; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; @@ -23,36 +23,36 @@ void testAddContainsRemoveSize() { Id id3 = Id.create("3", Person.class); Id id4 = Id.create("4", Person.class); - Assert.assertEquals(0, set.size()); - Assert.assertTrue(set.isEmpty()); - - Assert.assertTrue(set.add(id1)); - Assert.assertEquals(1, set.size()); - Assert.assertFalse(set.isEmpty()); - Assert.assertTrue(set.contains(id1)); - Assert.assertFalse(set.contains(id2)); - Assert.assertTrue(set.contains(id1.index())); - Assert.assertFalse(set.contains(id2.index())); - - Assert.assertFalse(set.add(id1)); - Assert.assertEquals(1, set.size()); - - Assert.assertTrue(set.add(id3)); - Assert.assertEquals(2, set.size()); - Assert.assertTrue(set.contains(id1)); - Assert.assertFalse(set.contains(id2)); - Assert.assertTrue(set.contains(id3)); - Assert.assertTrue(set.contains(id1.index())); - Assert.assertFalse(set.contains(id2.index())); - Assert.assertTrue(set.contains(id3.index())); - - Assert.assertFalse(set.remove(id4)); - Assert.assertEquals(2, set.size()); - - Assert.assertTrue(set.remove(id1)); - Assert.assertEquals(1, set.size()); - Assert.assertFalse(set.remove(id1)); - Assert.assertEquals(1, set.size()); + Assertions.assertEquals(0, set.size()); + Assertions.assertTrue(set.isEmpty()); + + Assertions.assertTrue(set.add(id1)); + Assertions.assertEquals(1, set.size()); + Assertions.assertFalse(set.isEmpty()); + Assertions.assertTrue(set.contains(id1)); + Assertions.assertFalse(set.contains(id2)); + Assertions.assertTrue(set.contains(id1.index())); + Assertions.assertFalse(set.contains(id2.index())); + + Assertions.assertFalse(set.add(id1)); + Assertions.assertEquals(1, set.size()); + + Assertions.assertTrue(set.add(id3)); + Assertions.assertEquals(2, set.size()); + Assertions.assertTrue(set.contains(id1)); + Assertions.assertFalse(set.contains(id2)); + Assertions.assertTrue(set.contains(id3)); + Assertions.assertTrue(set.contains(id1.index())); + Assertions.assertFalse(set.contains(id2.index())); + Assertions.assertTrue(set.contains(id3.index())); + + Assertions.assertFalse(set.remove(id4)); + Assertions.assertEquals(2, set.size()); + + Assertions.assertTrue(set.remove(id1)); + Assertions.assertEquals(1, set.size()); + Assertions.assertFalse(set.remove(id1)); + Assertions.assertEquals(1, set.size()); } @Test @@ -69,17 +69,17 @@ void testIterator() { set.add(id1); Iterator> iter = set.iterator(); - Assert.assertNotNull(iter); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals(id1, iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals(id2, iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals(id4, iter.next()); - Assert.assertFalse(iter.hasNext()); + Assertions.assertNotNull(iter); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals(id1, iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals(id2, iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals(id4, iter.next()); + Assertions.assertFalse(iter.hasNext()); try { iter.next(); - Assert.fail("expected NoSuchElementException, got none."); + Assertions.fail("expected NoSuchElementException, got none."); } catch (NoSuchElementException ignore) { } } @@ -99,14 +99,14 @@ void testClear() { set.add(id1); set.add(id4); - Assert.assertEquals(3, set.size()); + Assertions.assertEquals(3, set.size()); set.clear(); - Assert.assertEquals(0, set.size()); - Assert.assertTrue(set.isEmpty()); + Assertions.assertEquals(0, set.size()); + Assertions.assertTrue(set.isEmpty()); - Assert.assertFalse(set.iterator().hasNext()); + Assertions.assertFalse(set.iterator().hasNext()); } @Test @@ -129,16 +129,16 @@ void testAddAll() { set2.add(id4); set2.add(id5); - Assert.assertTrue(set1.addAll(set2)); + Assertions.assertTrue(set1.addAll(set2)); - Assert.assertTrue(set1.contains(id1)); - Assert.assertTrue(set1.contains(id3)); - Assert.assertTrue(set1.contains(id4)); - Assert.assertTrue(set1.contains(id5)); - Assert.assertTrue(set1.contains(id6)); - Assert.assertEquals(5, set1.size()); + Assertions.assertTrue(set1.contains(id1)); + Assertions.assertTrue(set1.contains(id3)); + Assertions.assertTrue(set1.contains(id4)); + Assertions.assertTrue(set1.contains(id5)); + Assertions.assertTrue(set1.contains(id6)); + Assertions.assertEquals(5, set1.size()); - Assert.assertFalse(set1.addAll(set2)); + Assertions.assertFalse(set1.addAll(set2)); } @Test @@ -161,15 +161,15 @@ void testRemoveAll() { set2.add(id4); set2.add(id5); - Assert.assertTrue(set1.removeAll(set2)); + Assertions.assertTrue(set1.removeAll(set2)); - Assert.assertTrue(set1.contains(id1)); - Assert.assertFalse(set1.contains(id2)); - Assert.assertTrue(set1.contains(id3)); - Assert.assertFalse(set1.contains(id4)); - Assert.assertFalse(set1.contains(id5)); - Assert.assertFalse(set1.contains(id6)); - Assert.assertEquals(2, set1.size()); + Assertions.assertTrue(set1.contains(id1)); + Assertions.assertFalse(set1.contains(id2)); + Assertions.assertTrue(set1.contains(id3)); + Assertions.assertFalse(set1.contains(id4)); + Assertions.assertFalse(set1.contains(id5)); + Assertions.assertFalse(set1.contains(id6)); + Assertions.assertEquals(2, set1.size()); } @Test @@ -192,16 +192,16 @@ void testRetainAll() { set2.add(id4); set2.add(id5); - Assert.assertTrue(set1.retainAll(set2)); + Assertions.assertTrue(set1.retainAll(set2)); - Assert.assertFalse(set1.contains(id1)); - Assert.assertFalse(set1.contains(id2)); - Assert.assertFalse(set1.contains(id3)); - Assert.assertTrue(set1.contains(id4)); - Assert.assertFalse(set1.contains(id5)); - Assert.assertFalse(set1.contains(id6)); + Assertions.assertFalse(set1.contains(id1)); + Assertions.assertFalse(set1.contains(id2)); + Assertions.assertFalse(set1.contains(id3)); + Assertions.assertTrue(set1.contains(id4)); + Assertions.assertFalse(set1.contains(id5)); + Assertions.assertFalse(set1.contains(id6)); - Assert.assertEquals(1, set1.size()); + Assertions.assertEquals(1, set1.size()); } @Test @@ -224,12 +224,12 @@ void testContainsAll() { set2.add(id4); set2.add(id5); - Assert.assertFalse(set1.containsAll(set2)); + Assertions.assertFalse(set1.containsAll(set2)); set1.add(id5); set1.add(id6); - Assert.assertTrue(set1.containsAll(set2)); + Assertions.assertTrue(set1.containsAll(set2)); } @Test @@ -249,22 +249,22 @@ void testToArray() { Id[] array1 = set.toArray(); - Assert.assertEquals(3, array1.length); + Assertions.assertEquals(3, array1.length); Id tmp = array1[0]; for (int i = 1; i < array1.length; i++) { if (tmp.index() > array1[i].index()) { - Assert.fail(); + Assertions.fail(); } else { tmp = array1[i]; } } Id[] array2 = set.toArray((Id[]) new Id[3]); - Assert.assertEquals(3, array2.length); + Assertions.assertEquals(3, array2.length); tmp = array2[0]; for (int i = 1; i < array2.length; i++) { if (tmp.index() > array2[i].index()) { - Assert.fail(); + Assertions.fail(); } else { tmp = array2[i]; } @@ -277,24 +277,24 @@ void testToArray() { tmpArray[3] = id2; tmpArray[4] = id1; Id[] array3 = set.toArray(tmpArray); - Assert.assertEquals(5, array3.length); + Assertions.assertEquals(5, array3.length); tmp = array3[0]; for (int i = 1; i < array1.length; i++) { if (tmp.index() > array3[i].index()) { - Assert.fail(); + Assertions.fail(); } else { tmp = array3[i]; } } - Assert.assertNull(array3[3]); - Assert.assertNull(array3[4]); + Assertions.assertNull(array3[3]); + Assertions.assertNull(array3[4]); Id[] array4 = set.toArray((Id[]) new Id[1]); // too small - Assert.assertEquals(3, array4.length); + Assertions.assertEquals(3, array4.length); tmp = array4[0]; for (int i = 1; i < array4.length; i++) { if (tmp.index() > array4[i].index()) { - Assert.fail(); + Assertions.fail(); } else { tmp = array4[i]; } @@ -314,33 +314,33 @@ void testEqualsAndHashCode() { IdSet setB = new IdSet<>(Person.class, 4); IdSet setWrongType = new IdSet<>(Link.class, 4); - Assert.assertEquals(setA, setA); - Assert.assertEquals(setA, setB); - Assert.assertNotEquals(setA, setWrongType); + Assertions.assertEquals(setA, setA); + Assertions.assertEquals(setA, setB); + Assertions.assertNotEquals(setA, setWrongType); setA.add(id1); - Assert.assertEquals(setA, setA); - Assert.assertNotEquals(setA, setB); - Assert.assertEquals(setA.hashCode(), setA.hashCode()); - Assert.assertNotEquals(setA.hashCode(), setB.hashCode()); + Assertions.assertEquals(setA, setA); + Assertions.assertNotEquals(setA, setB); + Assertions.assertEquals(setA.hashCode(), setA.hashCode()); + Assertions.assertNotEquals(setA.hashCode(), setB.hashCode()); setB.add(id1); - Assert.assertEquals(setA, setB); - Assert.assertEquals(setA.hashCode(), setB.hashCode()); + Assertions.assertEquals(setA, setB); + Assertions.assertEquals(setA.hashCode(), setB.hashCode()); setA.add(id2); setA.add(id3); - Assert.assertNotEquals(setA, setB); - Assert.assertNotEquals(setA.hashCode(), setB.hashCode()); + Assertions.assertNotEquals(setA, setB); + Assertions.assertNotEquals(setA.hashCode(), setB.hashCode()); setB.add(id3); setB.add(id2); - Assert.assertEquals(setA, setB); - Assert.assertEquals(setA.hashCode(), setB.hashCode()); + Assertions.assertEquals(setA, setB); + Assertions.assertEquals(setA.hashCode(), setB.hashCode()); setA.add(id4); setA.add(id5); @@ -349,16 +349,16 @@ void testEqualsAndHashCode() { setA.remove(id5); setA.remove(id6); - Assert.assertEquals(setA, setB); - Assert.assertEquals(setA.hashCode(), setB.hashCode()); + Assertions.assertEquals(setA, setB); + Assertions.assertEquals(setA.hashCode(), setB.hashCode()); setA.add(id4); HashSet> hSetA = new HashSet>(setA); - Assert.assertEquals(hSetA, setA); - Assert.assertNotEquals(hSetA, setB); + Assertions.assertEquals(hSetA, setA); + Assertions.assertNotEquals(hSetA, setB); // Assert.assertEquals(hSetA.hashCode(), setA.hashCode()); // this does not work yet because the hashCode() of IdImpl still uses id instead of index - Assert.assertNotEquals(hSetA.hashCode(), setB.hashCode()); + Assertions.assertNotEquals(hSetA.hashCode(), setB.hashCode()); } } diff --git a/matsim/src/test/java/org/matsim/api/core/v01/IdTest.java b/matsim/src/test/java/org/matsim/api/core/v01/IdTest.java index 77bc2676621..1b52880e52d 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/IdTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/IdTest.java @@ -22,14 +22,14 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.core.utils.collections.Tuple; import java.util.ArrayList; import java.util.List; - public class IdTest { + public class IdTest { private final static Logger LOG = LogManager.getLogger(IdTest.class); @@ -38,8 +38,8 @@ void testConstructor() { Id linkId1 = Id.create("1", TLink.class); Id linkId2 = Id.create("2", TLink.class); - Assert.assertEquals("1", linkId1.toString()); - Assert.assertEquals("2", linkId2.toString()); + Assertions.assertEquals("1", linkId1.toString()); + Assertions.assertEquals("2", linkId2.toString()); } @Test @@ -47,13 +47,13 @@ void testIdConstructor() { Id nodeId1 = Id.create("1", TNode.class); Id linkId1 = Id.create(nodeId1, TLink.class); - Assert.assertEquals("1", linkId1.toString()); + Assertions.assertEquals("1", linkId1.toString()); } @Test void testIdConstructor_Null() { Id linkId1 = Id.create((Id) null, TLink.class); - Assert.assertNull(linkId1); + Assertions.assertNull(linkId1); } @Test @@ -62,8 +62,8 @@ void testObjectIdentity_cache() { Id linkId2 = Id.create("2", TLink.class); Id linkId1again = Id.create("1", TLink.class); - Assert.assertTrue(linkId1 == linkId1again); - Assert.assertFalse(linkId1 == linkId2); + Assertions.assertTrue(linkId1 == linkId1again); + Assertions.assertFalse(linkId1 == linkId2); } @Test @@ -71,7 +71,7 @@ void testObjectIdentity_types() { Id linkId1 = Id.create("1", TLink.class); Id nodeId1 = Id.create("1", TNode.class); - Assert.assertFalse((Id) linkId1 == (Id) nodeId1); + Assertions.assertFalse((Id) linkId1 == (Id) nodeId1); } @Test @@ -81,10 +81,10 @@ void testCompareTo() { Id linkId1again = Id.create("1", TLink.class); Id nodeId1 = Id.create("1", TNode.class); - Assert.assertTrue(linkId1.compareTo(linkId2) < 0); - Assert.assertTrue(linkId1.compareTo(linkId1) == 0); - Assert.assertTrue(linkId1.compareTo(linkId1again) == 0); - Assert.assertTrue(linkId2.compareTo(linkId1) > 0); + Assertions.assertTrue(linkId1.compareTo(linkId2) < 0); + Assertions.assertTrue(linkId1.compareTo(linkId1) == 0); + Assertions.assertTrue(linkId1.compareTo(linkId1again) == 0); + Assertions.assertTrue(linkId2.compareTo(linkId1) > 0); // try { // Assert.assertTrue(linkId1.compareTo((Id) nodeId1) == 0); @@ -99,20 +99,20 @@ void testResetCaches() { Id.create("1", TLink.class); Id.create("2", TLink.class); int count = Id.getNumberOfIds(TLink.class); - Assert.assertTrue(count > 0); // it might be > 2 if other tests have run before creating Ids of this class + Assertions.assertTrue(count > 0); // it might be > 2 if other tests have run before creating Ids of this class Id.resetCaches(); - Assert.assertEquals(0, Id.getNumberOfIds(TLink.class)); + Assertions.assertEquals(0, Id.getNumberOfIds(TLink.class)); Id.create("1", TLink.class); Id.create("2", TLink.class); Id.create("3", TLink.class); - Assert.assertEquals(3, Id.getNumberOfIds(TLink.class)); + Assertions.assertEquals(3, Id.getNumberOfIds(TLink.class)); } @Test void testResetCaches_onlyFromJUnit() throws InterruptedException { Id.create("1", TLink.class); int countBefore = Id.getNumberOfIds(TLink.class); - Assert.assertTrue(countBefore > 0); + Assertions.assertTrue(countBefore > 0); Runnable runnable = () -> { Id.resetCaches(); @@ -129,9 +129,9 @@ void testResetCaches_onlyFromJUnit() throws InterruptedException { LOG.info("Caught exception: " + t.getSecond().getMessage()); } - Assert.assertFalse("There should have be an exception!", caughtExceptions.isEmpty()); + Assertions.assertFalse(caughtExceptions.isEmpty(), "There should have be an exception!"); int countAfter = Id.getNumberOfIds(TLink.class); - Assert.assertEquals("The number of created Ids should not have changed.", countBefore, countAfter); + Assertions.assertEquals(countBefore, countAfter, "The number of created Ids should not have changed."); } private static class TLink {} diff --git a/matsim/src/test/java/org/matsim/api/core/v01/NetworkCreationTest.java b/matsim/src/test/java/org/matsim/api/core/v01/NetworkCreationTest.java index c6e62203b22..4900e6a3ae9 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/NetworkCreationTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/NetworkCreationTest.java @@ -19,8 +19,8 @@ * *********************************************************************** */ package org.matsim.api.core.v01; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/api/core/v01/network/AbstractNetworkTest.java b/matsim/src/test/java/org/matsim/api/core/v01/network/AbstractNetworkTest.java index 0e52b8b0594..c0dc3f0f4ef 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/network/AbstractNetworkTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/network/AbstractNetworkTest.java @@ -21,7 +21,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -41,57 +41,57 @@ public abstract class AbstractNetworkTest { void removeLink() { Fixture f = new Fixture(getEmptyTestNetwork()); - Assert.assertTrue(f.network.getLinks().containsKey(f.linkIds[1])); - Assert.assertEquals(1, f.network.getNodes().get(f.nodeIds[1]).getInLinks().size()); + Assertions.assertTrue(f.network.getLinks().containsKey(f.linkIds[1])); + Assertions.assertEquals(1, f.network.getNodes().get(f.nodeIds[1]).getInLinks().size()); f.network.removeLink(f.linkIds[1]); - Assert.assertFalse(f.network.getLinks().containsKey(f.linkIds[1])); - Assert.assertEquals(0, f.network.getNodes().get(f.nodeIds[1]).getInLinks().size()); - Assert.assertEquals(1, f.network.getNodes().get(f.nodeIds[1]).getOutLinks().size()); + Assertions.assertFalse(f.network.getLinks().containsKey(f.linkIds[1])); + Assertions.assertEquals(0, f.network.getNodes().get(f.nodeIds[1]).getInLinks().size()); + Assertions.assertEquals(1, f.network.getNodes().get(f.nodeIds[1]).getOutLinks().size()); - Assert.assertTrue(f.network.getLinks().containsKey(f.linkIds[2])); + Assertions.assertTrue(f.network.getLinks().containsKey(f.linkIds[2])); f.network.removeLink(f.linkIds[2]); - Assert.assertFalse(f.network.getLinks().containsKey(f.linkIds[2])); + Assertions.assertFalse(f.network.getLinks().containsKey(f.linkIds[2])); - Assert.assertTrue(f.network.getNodes().containsKey(f.nodeIds[1])); - Assert.assertEquals(0, f.network.getNodes().get(f.nodeIds[1]).getOutLinks().size()); + Assertions.assertTrue(f.network.getNodes().containsKey(f.nodeIds[1])); + Assertions.assertEquals(0, f.network.getNodes().get(f.nodeIds[1]).getOutLinks().size()); - Assert.assertEquals(2, f.network.getNodes().get(f.nodeIds[5]).getOutLinks().size()); - Assert.assertEquals(2, f.network.getNodes().get(f.nodeIds[8]).getInLinks().size()); + Assertions.assertEquals(2, f.network.getNodes().get(f.nodeIds[5]).getOutLinks().size()); + Assertions.assertEquals(2, f.network.getNodes().get(f.nodeIds[8]).getInLinks().size()); f.network.removeLink(f.linkIds[10]); - Assert.assertEquals(1, f.network.getNodes().get(f.nodeIds[5]).getOutLinks().size()); - Assert.assertEquals(1, f.network.getNodes().get(f.nodeIds[8]).getInLinks().size()); + Assertions.assertEquals(1, f.network.getNodes().get(f.nodeIds[5]).getOutLinks().size()); + Assertions.assertEquals(1, f.network.getNodes().get(f.nodeIds[8]).getInLinks().size()); } @Test void removeNode() { Fixture f = new Fixture(getEmptyTestNetwork()); - Assert.assertEquals(8, f.network.getNodes().size()); - Assert.assertEquals(12, f.network.getLinks().size()); - Assert.assertTrue(f.network.getLinks().containsKey(f.linkIds[1])); - Assert.assertTrue(f.network.getLinks().containsKey(f.linkIds[2])); - Assert.assertTrue(f.network.getNodes().containsKey(f.nodeIds[1])); + Assertions.assertEquals(8, f.network.getNodes().size()); + Assertions.assertEquals(12, f.network.getLinks().size()); + Assertions.assertTrue(f.network.getLinks().containsKey(f.linkIds[1])); + Assertions.assertTrue(f.network.getLinks().containsKey(f.linkIds[2])); + Assertions.assertTrue(f.network.getNodes().containsKey(f.nodeIds[1])); f.network.removeNode(f.nodeIds[1]); - Assert.assertEquals(7, f.network.getNodes().size()); - Assert.assertEquals(10, f.network.getLinks().size()); - Assert.assertFalse(f.network.getLinks().containsKey(f.linkIds[1])); - Assert.assertFalse(f.network.getLinks().containsKey(f.linkIds[2])); - Assert.assertFalse(f.network.getNodes().containsKey(f.nodeIds[1])); - Assert.assertFalse(f.network.getNodes().get(f.nodeIds[4]).getOutLinks().containsKey(f.linkIds[1])); - Assert.assertTrue(f.network.getNodes().get(f.nodeIds[4]).getOutLinks().containsKey(f.linkIds[5])); - Assert.assertTrue(f.network.getNodes().get(f.nodeIds[4]).getOutLinks().containsKey(f.linkIds[7])); + Assertions.assertEquals(7, f.network.getNodes().size()); + Assertions.assertEquals(10, f.network.getLinks().size()); + Assertions.assertFalse(f.network.getLinks().containsKey(f.linkIds[1])); + Assertions.assertFalse(f.network.getLinks().containsKey(f.linkIds[2])); + Assertions.assertFalse(f.network.getNodes().containsKey(f.nodeIds[1])); + Assertions.assertFalse(f.network.getNodes().get(f.nodeIds[4]).getOutLinks().containsKey(f.linkIds[1])); + Assertions.assertTrue(f.network.getNodes().get(f.nodeIds[4]).getOutLinks().containsKey(f.linkIds[5])); + Assertions.assertTrue(f.network.getNodes().get(f.nodeIds[4]).getOutLinks().containsKey(f.linkIds[7])); f.network.removeNode(f.nodeIds[8]); - Assert.assertEquals(6, f.network.getNodes().size()); - Assert.assertEquals(6, f.network.getLinks().size()); - Assert.assertFalse(f.network.getLinks().containsKey(f.linkIds[8])); - Assert.assertFalse(f.network.getLinks().containsKey(f.linkIds[9])); - Assert.assertFalse(f.network.getNodes().containsKey(f.nodeIds[10])); - Assert.assertFalse(f.network.getNodes().containsKey(f.nodeIds[11])); - Assert.assertFalse(f.network.getNodes().get(f.nodeIds[5]).getOutLinks().containsKey(f.linkIds[10])); - Assert.assertTrue(f.network.getNodes().get(f.nodeIds[5]).getOutLinks().containsKey(f.linkIds[6])); - Assert.assertFalse(f.network.getNodes().get(f.nodeIds[5]).getInLinks().containsKey(f.linkIds[9])); - Assert.assertTrue(f.network.getNodes().get(f.nodeIds[5]).getInLinks().containsKey(f.linkIds[3])); + Assertions.assertEquals(6, f.network.getNodes().size()); + Assertions.assertEquals(6, f.network.getLinks().size()); + Assertions.assertFalse(f.network.getLinks().containsKey(f.linkIds[8])); + Assertions.assertFalse(f.network.getLinks().containsKey(f.linkIds[9])); + Assertions.assertFalse(f.network.getNodes().containsKey(f.nodeIds[10])); + Assertions.assertFalse(f.network.getNodes().containsKey(f.nodeIds[11])); + Assertions.assertFalse(f.network.getNodes().get(f.nodeIds[5]).getOutLinks().containsKey(f.linkIds[10])); + Assertions.assertTrue(f.network.getNodes().get(f.nodeIds[5]).getOutLinks().containsKey(f.linkIds[6])); + Assertions.assertFalse(f.network.getNodes().get(f.nodeIds[5]).getInLinks().containsKey(f.linkIds[9])); + Assertions.assertTrue(f.network.getNodes().get(f.nodeIds[5]).getInLinks().containsKey(f.linkIds[3])); } /** diff --git a/matsim/src/test/java/org/matsim/core/config/CommandLineTest.java b/matsim/src/test/java/org/matsim/core/config/CommandLineTest.java index 8a5ea4b5d90..860317a57de 100644 --- a/matsim/src/test/java/org/matsim/core/config/CommandLineTest.java +++ b/matsim/src/test/java/org/matsim/core/config/CommandLineTest.java @@ -2,7 +2,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -27,7 +27,7 @@ void testStandardUsage() { Config config = ConfigUtils.loadConfig( args ) ; CommandLine cmd = ConfigUtils.getCommandLine( args ); - Assert.assertEquals( "abc", cmd.getOption( "something" ).get() ); + Assertions.assertEquals( "abc", cmd.getOption( "something" ).get() ); } @@ -45,7 +45,7 @@ void testTypo() { Config config = ConfigUtils.loadConfig(args) ; CommandLine cmd = ConfigUtils.getCommandLine(args); - Assert.assertEquals("abc", cmd.getOption("someting").get()); + Assertions.assertEquals("abc", cmd.getOption("someting").get()); }); @@ -67,7 +67,7 @@ void testAdditionalConfigGroup() { String[] args = {configFilename, "--config:mockConfigGroup.abc=28"}; Config config = ConfigUtils.loadConfig( args ); MockConfigGroup mcg = ConfigUtils.addOrGetModule( config, MockConfigGroup.class ) ; - Assert.assertEquals( 28., mcg.getAbc(), 0. ); + Assertions.assertEquals( 28., mcg.getAbc(), 0. ); } } @@ -92,9 +92,9 @@ void testSetParameterInAllParameterSets() { String[] args = { configFilename, "--config:mockConfigGroup.mockSet[*=*].test=c" }; Config config = ConfigUtils.loadConfig(args); MockConfigGroup mockConfigGroup = ConfigUtils.addOrGetModule(config, MockConfigGroup.class); - Assert.assertEquals(2, mockConfigGroup.getParameterSets(MockParameterSet.SET_TYPE).size()); + Assertions.assertEquals(2, mockConfigGroup.getParameterSets(MockParameterSet.SET_TYPE).size()); for (ConfigGroup parameterSet : mockConfigGroup.getParameterSets(MockParameterSet.SET_TYPE)) { - Assert.assertEquals("c", ((MockParameterSet) parameterSet).test); + Assertions.assertEquals("c", ((MockParameterSet) parameterSet).test); } } } @@ -129,7 +129,7 @@ void testFixNotYetExistingAdditionalConfigGroup() { String[] args = {configFilename, "--config:mockConfigGroup.abc=28"}; Config config = ConfigUtils.loadConfig( args, new MockConfigGroup() ); MockConfigGroup mcg = ConfigUtils.addOrGetModule( config, MockConfigGroup.class ) ; - Assert.assertEquals( 28., mcg.getAbc(), 0. ); + Assertions.assertEquals( 28., mcg.getAbc(), 0. ); } } diff --git a/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java b/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java index 89bf12288d9..87f1f6e53fd 100644 --- a/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java +++ b/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java @@ -1,6 +1,6 @@ package org.matsim.core.config; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.core.config.groups.ControllerConfigGroup; @@ -33,7 +33,7 @@ void testModuleNameAlias() { r2.getConfigAliases().addAlias("theController", ControllerConfigGroup.GROUP_NAME); r2.readStream(bais); - Assert.assertEquals(27, config.controller().getLastIteration()); + Assertions.assertEquals(27, config.controller().getLastIteration()); } @Test @@ -54,8 +54,8 @@ void testModuleNameAlias_noOldModules() { r2.readStream(bais); - Assert.assertEquals(27, config.controller().getLastIteration()); - Assert.assertNull(config.getModules().get("controler")); + Assertions.assertEquals(27, config.controller().getLastIteration()); + Assertions.assertNull(config.getModules().get("controler")); } @Test @@ -77,7 +77,7 @@ void testParamNameAlias() { r2.getConfigAliases().addAlias("theLastIteration", "lastIteration"); r2.readStream(bais); - Assert.assertEquals(23, config.controller().getLastIteration()); + Assertions.assertEquals(23, config.controller().getLastIteration()); } @Test @@ -100,7 +100,7 @@ void testModuleAndParamNameAlias() { r2.getConfigAliases().addAlias("theLastIteration", "lastIteration"); r2.readStream(bais); - Assert.assertEquals(23, config.controller().getLastIteration()); + Assertions.assertEquals(23, config.controller().getLastIteration()); } /** @@ -132,8 +132,8 @@ void testConditionalParamNameAliasWithModuleRenaming() { r2.getConfigAliases().addAlias("input", "inputPlansFile", "plans"); r2.readStream(bais); - Assert.assertEquals("my_network.xml.gz", config.network().getInputFile()); - Assert.assertEquals("my_plans.xml.gz", config.plans().getInputFile()); + Assertions.assertEquals("my_network.xml.gz", config.network().getInputFile()); + Assertions.assertEquals("my_plans.xml.gz", config.plans().getInputFile()); } /** @@ -163,8 +163,8 @@ void testConditionalParamNameAlias() { r2.getConfigAliases().addAlias("input", "inputPlansFile", "plans"); r2.readStream(bais); - Assert.assertEquals("my_network.xml.gz", config.network().getInputFile()); - Assert.assertEquals("my_plans.xml.gz", config.plans().getInputFile()); + Assertions.assertEquals("my_network.xml.gz", config.network().getInputFile()); + Assertions.assertEquals("my_plans.xml.gz", config.plans().getInputFile()); } /** @@ -192,8 +192,8 @@ void testConditionalParamNameAlias2() { r2.getConfigAliases().addAlias("inputNetworkFile", "inputPlansFile", "plans"); r2.readStream(bais); - Assert.assertEquals("my_network.xml.gz", config.network().getInputFile()); - Assert.assertEquals("my_plans.xml.gz", config.plans().getInputFile()); + Assertions.assertEquals("my_network.xml.gz", config.network().getInputFile()); + Assertions.assertEquals("my_plans.xml.gz", config.plans().getInputFile()); } /** @@ -218,7 +218,7 @@ void testConditionalParamNameAlias3() { r2.getConfigAliases().addAlias("inputPlansFile", "input", "inexistant"); r2.readStream(bais); // if the alias were matched, it should produce an exception, as "input" is not known - Assert.assertEquals("my_plans.xml.gz", config.plans().getInputFile()); + Assertions.assertEquals("my_plans.xml.gz", config.plans().getInputFile()); } /** @@ -243,7 +243,7 @@ void testConditionalParamNameAlias4() { r2.getConfigAliases().addAlias("inputPlansFile", "input", "plans", "inexistant"); r2.readStream(bais); // if the alias were matched, it should produce an exception, as "input" is not known - Assert.assertEquals("my_plans.xml.gz", config.plans().getInputFile()); + Assertions.assertEquals("my_plans.xml.gz", config.plans().getInputFile()); } @@ -289,7 +289,7 @@ void testAliasWithParamSets() { r2.getConfigAliases().addAlias("theMode", "mode", "scoring", "scoringParameters", "modeParams"); r2.readStream(bais); - Assert.assertEquals(-5.6, config.scoring().getModes().get("car").getMarginalUtilityOfTraveling(), 1e-7); - Assert.assertEquals(-8.7, config.scoring().getModes().get("unicycle").getMarginalUtilityOfTraveling(), 1e-7); + Assertions.assertEquals(-5.6, config.scoring().getModes().get("car").getMarginalUtilityOfTraveling(), 1e-7); + Assertions.assertEquals(-8.7, config.scoring().getModes().get("unicycle").getMarginalUtilityOfTraveling(), 1e-7); } } diff --git a/matsim/src/test/java/org/matsim/core/config/ConfigTest.java b/matsim/src/test/java/org/matsim/core/config/ConfigTest.java index 07c481b7935..93dac756f89 100644 --- a/matsim/src/test/java/org/matsim/core/config/ConfigTest.java +++ b/matsim/src/test/java/org/matsim/core/config/ConfigTest.java @@ -21,7 +21,7 @@ import java.io.ByteArrayInputStream; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -36,8 +36,8 @@ void testAddModule_beforeLoading() { config.addModule(group); - Assert.assertNull(group.getA()); - Assert.assertNull(group.getB()); + Assertions.assertNull(group.getA()); + Assertions.assertNull(group.getB()); String str = "\n" + "\n" + @@ -49,8 +49,8 @@ void testAddModule_beforeLoading() { ""; new ConfigReader(config).parse(new ByteArrayInputStream(str.getBytes())); - Assert.assertEquals("aaa", group.getA()); - Assert.assertEquals("bbb", group.getB()); + Assertions.assertEquals("aaa", group.getA()); + Assertions.assertEquals("bbb", group.getB()); } @Test @@ -58,8 +58,8 @@ void testAddModule_afterLoading() { Config config = new Config(); ConfigTestGroup group = new ConfigTestGroup(); - Assert.assertNull(group.getA()); - Assert.assertNull(group.getB()); + Assertions.assertNull(group.getA()); + Assertions.assertNull(group.getB()); String str = "\n" + "\n" + @@ -71,15 +71,15 @@ void testAddModule_afterLoading() { ""; new ConfigReader(config).parse(new ByteArrayInputStream(str.getBytes())); - Assert.assertEquals("aaa", config.getParam("ctg", "a")); - Assert.assertEquals("bbb", config.getParam("ctg", "b")); - Assert.assertNull(group.getA()); - Assert.assertNull(group.getB()); + Assertions.assertEquals("aaa", config.getParam("ctg", "a")); + Assertions.assertEquals("bbb", config.getParam("ctg", "b")); + Assertions.assertNull(group.getA()); + Assertions.assertNull(group.getB()); config.addModule(group); - Assert.assertEquals("aaa", group.getA()); - Assert.assertEquals("bbb", group.getB()); + Assertions.assertEquals("aaa", group.getA()); + Assertions.assertEquals("bbb", group.getB()); } private static class ConfigTestGroup extends ConfigGroup { diff --git a/matsim/src/test/java/org/matsim/core/config/MaterializeConfigTest.java b/matsim/src/test/java/org/matsim/core/config/MaterializeConfigTest.java index 0bdd7443ea7..7961e195c2c 100644 --- a/matsim/src/test/java/org/matsim/core/config/MaterializeConfigTest.java +++ b/matsim/src/test/java/org/matsim/core/config/MaterializeConfigTest.java @@ -2,7 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -27,9 +27,8 @@ final void testMaterializeAfterReadParameterSets() { configGroup.addParameterSet(set); } - Assert.assertEquals( - "unexpected number of parameter sets in initial config group", - 2, configGroup.getParameterSets("blabla").size()); + Assertions.assertEquals( + 2, configGroup.getParameterSets("blabla").size(), "unexpected number of parameter sets in initial config group"); ConfigUtils.writeConfig(config, utils.getOutputDirectory() + "ad-hoc-config.xml"); } @@ -40,9 +39,8 @@ final void testMaterializeAfterReadParameterSets() { { ConfigGroup configGroup = config.getModule(TestConfigGroup.GROUP_NAME); - Assert.assertEquals( - "unexpected number of parameter sets in non materialized config group", - 2, configGroup.getParameterSets("blabla").size()); + Assertions.assertEquals( + 2, configGroup.getParameterSets("blabla").size(), "unexpected number of parameter sets in non materialized config group"); } // materialize the config group @@ -50,13 +48,12 @@ final void testMaterializeAfterReadParameterSets() { TestConfigGroup.class); // this should have two parameter sets here - Assert.assertEquals( - "unexpected number of parameter sets in materialized config group", - 2, configGroup.getParameterSets("blabla").size()); + Assertions.assertEquals( + 2, configGroup.getParameterSets("blabla").size(), "unexpected number of parameter sets in materialized config group"); // check if you are getting back the values from the config file: for (TestParameterSet set : (Iterable) configGroup.getParameterSets("blabla")) { - Assert.assertEquals("unexpected value for parameter in parameter set", "life is wonderful", set.getParameter()); + Assertions.assertEquals("life is wonderful", set.getParameter(), "unexpected value for parameter in parameter set"); } } diff --git a/matsim/src/test/java/org/matsim/core/config/ReflectiveConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/ReflectiveConfigGroupTest.java index 45243363ca7..49632ba3bd9 100644 --- a/matsim/src/test/java/org/matsim/core/config/ReflectiveConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/ReflectiveConfigGroupTest.java @@ -31,8 +31,7 @@ import java.util.List; import java.util.Map; import java.util.Set; - -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.extension.RegisterExtension; @@ -363,7 +362,7 @@ public Object getStuff() { final String param = "my unknown param"; final String value = "my val"; testee.addParam(param, value); - Assert.assertEquals("unexpected stored value", value, testee.getValue(param)); + Assertions.assertEquals(value, testee.getValue(param), "unexpected stored value"); } @Test diff --git a/matsim/src/test/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImplTest.java b/matsim/src/test/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImplTest.java index 1e996282944..476b05c265b 100644 --- a/matsim/src/test/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImplTest.java +++ b/matsim/src/test/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImplTest.java @@ -20,7 +20,7 @@ package org.matsim.core.config.consistency; import org.apache.logging.log4j.Level; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.core.config.Config; @@ -46,7 +46,7 @@ void testCheckPlanCalcScore_DefaultsOk() { try { logger.activate(); ConfigConsistencyCheckerImpl.checkPlanCalcScore(config); - Assert.assertEquals(0, logger.getWarnCount()); + Assertions.assertEquals(0, logger.getWarnCount()); } finally { // make sure counter is deactivated at the end logger.deactivate(); @@ -64,7 +64,7 @@ void testCheckPlanCalcScore_Traveling() { try { logger.activate(); ConfigConsistencyCheckerImpl.checkPlanCalcScore(config); - Assert.assertEquals(1, logger.getWarnCount()); + Assertions.assertEquals(1, logger.getWarnCount()); } finally { // make sure counter is deactivated at the end logger.deactivate(); @@ -82,7 +82,7 @@ void testCheckPlanCalcScore_TravelingPt() { try { logger.activate(); ConfigConsistencyCheckerImpl.checkPlanCalcScore(config); - Assert.assertEquals(1, logger.getWarnCount()); + Assertions.assertEquals(1, logger.getWarnCount()); } finally { // make sure counter is deactivated at the end logger.deactivate(); @@ -100,7 +100,7 @@ void testCheckPlanCalcScore_TravelingBike() { try { logger.activate(); ConfigConsistencyCheckerImpl.checkPlanCalcScore(config); - Assert.assertEquals(1, logger.getWarnCount()); + Assertions.assertEquals(1, logger.getWarnCount()); } finally { // make sure counter is deactivated at the end logger.deactivate(); @@ -118,7 +118,7 @@ void testCheckPlanCalcScore_TravelingWalk() { try { logger.activate(); ConfigConsistencyCheckerImpl.checkPlanCalcScore(config); - Assert.assertEquals(1, logger.getWarnCount()); + Assertions.assertEquals(1, logger.getWarnCount()); } finally { // make sure counter is deactivated at the end logger.deactivate(); @@ -136,7 +136,7 @@ void testCheckPlanCalcScore_PtInteractionActivity() { try { ConfigConsistencyCheckerImpl.checkPlanCalcScore(config); - Assert.assertEquals(0,1) ; // should never get here + Assertions.assertEquals(0,1) ; // should never get here } catch ( Exception ee ){ System.out.println("expected exception") ; @@ -147,7 +147,7 @@ void testCheckPlanCalcScore_PtInteractionActivity() { try { ConfigConsistencyCheckerImpl.checkPlanCalcScore(config ); } catch ( Exception ee ){ - Assert.assertEquals(0,1) ; // should never get here + Assertions.assertEquals(0,1) ; // should never get here } } @@ -162,7 +162,7 @@ void checkConsistencyBetweenRouterAndTravelTimeCalculatorTest(){ config.travelTimeCalculator().setSeparateModes( false ); { boolean problem = ConfigConsistencyCheckerImpl.checkConsistencyBetweenRouterAndTravelTimeCalculator( config ); - Assert.assertFalse( problem ); + Assertions.assertFalse( problem ); } { Set modes = new LinkedHashSet<>( config.routing().getNetworkModes() ); @@ -170,7 +170,7 @@ void checkConsistencyBetweenRouterAndTravelTimeCalculatorTest(){ config.routing().setNetworkModes( modes ); boolean problem = ConfigConsistencyCheckerImpl.checkConsistencyBetweenRouterAndTravelTimeCalculator( config ); - Assert.assertFalse( problem ); + Assertions.assertFalse( problem ); } { Set modes = new LinkedHashSet<>( config.travelTimeCalculator().getAnalyzedModes() ); @@ -178,7 +178,7 @@ void checkConsistencyBetweenRouterAndTravelTimeCalculatorTest(){ config.travelTimeCalculator().setAnalyzedModes( modes ); boolean problem = ConfigConsistencyCheckerImpl.checkConsistencyBetweenRouterAndTravelTimeCalculator( config ); - Assert.assertFalse( problem ); + Assertions.assertFalse( problem ); } { Set modes = new LinkedHashSet<>( config.travelTimeCalculator().getAnalyzedModes() ); @@ -186,7 +186,7 @@ void checkConsistencyBetweenRouterAndTravelTimeCalculatorTest(){ config.travelTimeCalculator().setAnalyzedModes( modes ); boolean problem = ConfigConsistencyCheckerImpl.checkConsistencyBetweenRouterAndTravelTimeCalculator( config ); - Assert.assertFalse( problem ); + Assertions.assertFalse( problem ); } } { @@ -214,7 +214,7 @@ void checkConsistencyBetweenRouterAndTravelTimeCalculatorTest(){ config.travelTimeCalculator().setAnalyzedModes( modes ); boolean problem = ConfigConsistencyCheckerImpl.checkConsistencyBetweenRouterAndTravelTimeCalculator( config ); - Assert.assertFalse( problem ); + Assertions.assertFalse( problem ); } { Set modes = new LinkedHashSet<>( config.travelTimeCalculator().getAnalyzedModes() ); @@ -222,7 +222,7 @@ void checkConsistencyBetweenRouterAndTravelTimeCalculatorTest(){ config.travelTimeCalculator().setAnalyzedModes( modes ); boolean problem = ConfigConsistencyCheckerImpl.checkConsistencyBetweenRouterAndTravelTimeCalculator( config ); - Assert.assertFalse( problem ); + Assertions.assertFalse( problem ); } } diff --git a/matsim/src/test/java/org/matsim/core/config/groups/ControllerConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/ControllerConfigGroupTest.java index 26499157749..bde1b7346d9 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/ControllerConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/ControllerConfigGroupTest.java @@ -23,7 +23,7 @@ import java.util.EnumSet; import java.util.Set; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.core.config.groups.ControllerConfigGroup.EventsFileFormat; @@ -41,42 +41,42 @@ void testEventsFileFormat() { Set formats; // test initial value formats = cg.getEventsFileFormats(); - Assert.assertEquals(1, formats.size()); - Assert.assertTrue(formats.contains(EventsFileFormat.xml)); - Assert.assertEquals("xml", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); + Assertions.assertEquals(1, formats.size()); + Assertions.assertTrue(formats.contains(EventsFileFormat.xml)); + Assertions.assertEquals("xml", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); // test setting with setEventsFileFormat cg.setEventsFileFormats(EnumSet.of(EventsFileFormat.xml)); formats = cg.getEventsFileFormats(); - Assert.assertEquals(1, formats.size()); - Assert.assertTrue(formats.contains(EventsFileFormat.xml)); - Assert.assertEquals("xml", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); + Assertions.assertEquals(1, formats.size()); + Assertions.assertTrue(formats.contains(EventsFileFormat.xml)); + Assertions.assertEquals("xml", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); // test setting to none cg.setEventsFileFormats(EnumSet.noneOf(EventsFileFormat.class)); formats = cg.getEventsFileFormats(); - Assert.assertEquals(0, formats.size()); - Assert.assertEquals("", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); + Assertions.assertEquals(0, formats.size()); + Assertions.assertEquals("", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); // test setting with addParam cg.addParam(ControllerConfigGroup.EVENTS_FILE_FORMAT, "xml"); formats = cg.getEventsFileFormats(); - Assert.assertEquals(1, formats.size()); - Assert.assertTrue(formats.contains(EventsFileFormat.xml)); - Assert.assertEquals("xml", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); + Assertions.assertEquals(1, formats.size()); + Assertions.assertTrue(formats.contains(EventsFileFormat.xml)); + Assertions.assertEquals("xml", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); // test setting to none cg.addParam(ControllerConfigGroup.EVENTS_FILE_FORMAT, ""); formats = cg.getEventsFileFormats(); - Assert.assertEquals(0, formats.size()); - Assert.assertEquals("", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); + Assertions.assertEquals(0, formats.size()); + Assertions.assertEquals("", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); // test setting with non-conform formatting cg.addParam(ControllerConfigGroup.EVENTS_FILE_FORMAT, " xml\t\t "); formats = cg.getEventsFileFormats(); - Assert.assertEquals(1, formats.size()); - Assert.assertTrue(formats.contains(EventsFileFormat.xml)); - Assert.assertEquals("xml", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); + Assertions.assertEquals(1, formats.size()); + Assertions.assertTrue(formats.contains(EventsFileFormat.xml)); + Assertions.assertEquals("xml", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); // test setting to non-conform none cg.addParam(ControllerConfigGroup.EVENTS_FILE_FORMAT, " \t "); formats = cg.getEventsFileFormats(); - Assert.assertEquals(0, formats.size()); - Assert.assertEquals("", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); + Assertions.assertEquals(0, formats.size()); + Assertions.assertEquals("", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); } /** @@ -89,16 +89,16 @@ void testEventsFileFormat() { void testMobsim() { ControllerConfigGroup cg = new ControllerConfigGroup(); // test initial value - Assert.assertEquals("qsim", cg.getMobsim()); - Assert.assertEquals("qsim", cg.getValue(ControllerConfigGroup.MOBSIM)); + Assertions.assertEquals("qsim", cg.getMobsim()); + Assertions.assertEquals("qsim", cg.getValue(ControllerConfigGroup.MOBSIM)); // test setting to null cg.setMobsim(null); - Assert.assertNull(cg.getMobsim()); - Assert.assertNull(cg.getValue(ControllerConfigGroup.MOBSIM)); + Assertions.assertNull(cg.getMobsim()); + Assertions.assertNull(cg.getValue(ControllerConfigGroup.MOBSIM)); // test setting with addParam cg.addParam(ControllerConfigGroup.MOBSIM, "queueSimulation"); - Assert.assertEquals("queueSimulation", cg.getMobsim()); - Assert.assertEquals("queueSimulation", cg.getValue(ControllerConfigGroup.MOBSIM)); + Assertions.assertEquals("queueSimulation", cg.getMobsim()); + Assertions.assertEquals("queueSimulation", cg.getValue(ControllerConfigGroup.MOBSIM)); } /** @@ -111,13 +111,13 @@ void testMobsim() { void testWritePlansInterval() { ControllerConfigGroup cg = new ControllerConfigGroup(); // test initial value - Assert.assertEquals(50, cg.getWritePlansInterval()); + Assertions.assertEquals(50, cg.getWritePlansInterval()); // test setting with setMobsim cg.setWritePlansInterval(4); - Assert.assertEquals(4, cg.getWritePlansInterval()); + Assertions.assertEquals(4, cg.getWritePlansInterval()); // test setting with addParam cg.addParam("writePlansInterval", "2"); - Assert.assertEquals(2, cg.getWritePlansInterval()); + Assertions.assertEquals(2, cg.getWritePlansInterval()); } /** @@ -128,19 +128,19 @@ void testWritePlansInterval() { void testLink2LinkRouting(){ ControllerConfigGroup cg = new ControllerConfigGroup(); //initial value - Assert.assertFalse(cg.isLinkToLinkRoutingEnabled()); + Assertions.assertFalse(cg.isLinkToLinkRoutingEnabled()); //modify by string cg.addParam("enableLinkToLinkRouting", "true"); - Assert.assertTrue(cg.isLinkToLinkRoutingEnabled()); + Assertions.assertTrue(cg.isLinkToLinkRoutingEnabled()); cg.addParam("enableLinkToLinkRouting", "false"); - Assert.assertFalse(cg.isLinkToLinkRoutingEnabled()); + Assertions.assertFalse(cg.isLinkToLinkRoutingEnabled()); //modify by boolean cg.setLinkToLinkRoutingEnabled(true); - Assert.assertTrue(cg.isLinkToLinkRoutingEnabled()); - Assert.assertEquals("true", cg.getValue("enableLinkToLinkRouting")); + Assertions.assertTrue(cg.isLinkToLinkRoutingEnabled()); + Assertions.assertEquals("true", cg.getValue("enableLinkToLinkRouting")); cg.setLinkToLinkRoutingEnabled(false); - Assert.assertFalse(cg.isLinkToLinkRoutingEnabled()); - Assert.assertEquals("false", cg.getValue("enableLinkToLinkRouting")); + Assertions.assertFalse(cg.isLinkToLinkRoutingEnabled()); + Assertions.assertEquals("false", cg.getValue("enableLinkToLinkRouting")); } /** @@ -151,14 +151,14 @@ void testLink2LinkRouting(){ void testWriteSnapshotInterval(){ ControllerConfigGroup cg = new ControllerConfigGroup(); //initial value - Assert.assertEquals(1, cg.getWriteSnapshotsInterval()); + Assertions.assertEquals(1, cg.getWriteSnapshotsInterval()); //modify by string cg.addParam("writeSnapshotsInterval", "10"); - Assert.assertEquals(10, cg.getWriteSnapshotsInterval()); + Assertions.assertEquals(10, cg.getWriteSnapshotsInterval()); //modify by boolean cg.setWriteSnapshotsInterval(42); - Assert.assertEquals("42", cg.getValue("writeSnapshotsInterval")); - Assert.assertEquals(42, cg.getWriteSnapshotsInterval()); + Assertions.assertEquals("42", cg.getValue("writeSnapshotsInterval")); + Assertions.assertEquals(42, cg.getWriteSnapshotsInterval()); } diff --git a/matsim/src/test/java/org/matsim/core/config/groups/CountsConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/CountsConfigGroupTest.java index f1c2fdf7276..84c2cacaa03 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/CountsConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/CountsConfigGroupTest.java @@ -19,7 +19,7 @@ package org.matsim.core.config.groups; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -31,44 +31,44 @@ public class CountsConfigGroupTest { void testWriteCountsInterval() { CountsConfigGroup cg = new CountsConfigGroup(); // test initial value - Assert.assertEquals(10, cg.getWriteCountsInterval()); - Assert.assertEquals("10", cg.getValue("writeCountsInterval")); + Assertions.assertEquals(10, cg.getWriteCountsInterval()); + Assertions.assertEquals("10", cg.getValue("writeCountsInterval")); // test setting with setMobsim cg.setWriteCountsInterval(4); - Assert.assertEquals(4, cg.getWriteCountsInterval()); - Assert.assertEquals("4", cg.getValue("writeCountsInterval")); + Assertions.assertEquals(4, cg.getWriteCountsInterval()); + Assertions.assertEquals("4", cg.getValue("writeCountsInterval")); // test setting with addParam cg.addParam("writeCountsInterval", "2"); - Assert.assertEquals(2, cg.getWriteCountsInterval()); - Assert.assertEquals("2", cg.getValue("writeCountsInterval")); + Assertions.assertEquals(2, cg.getWriteCountsInterval()); + Assertions.assertEquals("2", cg.getValue("writeCountsInterval")); } @Test void testGetParams_writeCountsInterval() { CountsConfigGroup cg = new CountsConfigGroup(); - Assert.assertNotNull(cg.getParams().get("writeCountsInterval")); + Assertions.assertNotNull(cg.getParams().get("writeCountsInterval")); } @Test void testWriteAverageOverIterations() { CountsConfigGroup cg = new CountsConfigGroup(); // test initial value - Assert.assertEquals(5, cg.getAverageCountsOverIterations()); - Assert.assertEquals("5", cg.getValue("averageCountsOverIterations")); + Assertions.assertEquals(5, cg.getAverageCountsOverIterations()); + Assertions.assertEquals("5", cg.getValue("averageCountsOverIterations")); // test setting with setMobsim cg.setAverageCountsOverIterations(4); - Assert.assertEquals(4, cg.getAverageCountsOverIterations()); - Assert.assertEquals("4", cg.getValue("averageCountsOverIterations")); + Assertions.assertEquals(4, cg.getAverageCountsOverIterations()); + Assertions.assertEquals("4", cg.getValue("averageCountsOverIterations")); // test setting with addParam cg.addParam("averageCountsOverIterations", "2"); - Assert.assertEquals(2, cg.getAverageCountsOverIterations()); - Assert.assertEquals("2", cg.getValue("averageCountsOverIterations")); + Assertions.assertEquals(2, cg.getAverageCountsOverIterations()); + Assertions.assertEquals("2", cg.getValue("averageCountsOverIterations")); } @Test void testGetParams_averageCountsOverIterations() { CountsConfigGroup cg = new CountsConfigGroup(); - Assert.assertNotNull(cg.getParams().get("averageCountsOverIterations")); + Assertions.assertNotNull(cg.getParams().get("averageCountsOverIterations")); } } diff --git a/matsim/src/test/java/org/matsim/core/config/groups/LinkStatsConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/LinkStatsConfigGroupTest.java index 363c5eca282..a5355580a77 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/LinkStatsConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/LinkStatsConfigGroupTest.java @@ -19,7 +19,7 @@ package org.matsim.core.config.groups; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -31,44 +31,44 @@ public class LinkStatsConfigGroupTest { void testWriteLinkStatsInterval() { LinkStatsConfigGroup cg = new LinkStatsConfigGroup(); // test initial value - Assert.assertEquals(50, cg.getWriteLinkStatsInterval()); - Assert.assertEquals("50", cg.getValue("writeLinkStatsInterval")); + Assertions.assertEquals(50, cg.getWriteLinkStatsInterval()); + Assertions.assertEquals("50", cg.getValue("writeLinkStatsInterval")); // test setting with setMobsim cg.setWriteLinkStatsInterval(4); - Assert.assertEquals(4, cg.getWriteLinkStatsInterval()); - Assert.assertEquals("4", cg.getValue("writeLinkStatsInterval")); + Assertions.assertEquals(4, cg.getWriteLinkStatsInterval()); + Assertions.assertEquals("4", cg.getValue("writeLinkStatsInterval")); // test setting with addParam cg.addParam("writeLinkStatsInterval", "2"); - Assert.assertEquals(2, cg.getWriteLinkStatsInterval()); - Assert.assertEquals("2", cg.getValue("writeLinkStatsInterval")); + Assertions.assertEquals(2, cg.getWriteLinkStatsInterval()); + Assertions.assertEquals("2", cg.getValue("writeLinkStatsInterval")); } @Test void testGetParams_writeLinkStatsInterval() { LinkStatsConfigGroup cg = new LinkStatsConfigGroup(); - Assert.assertNotNull(cg.getParams().get("writeLinkStatsInterval")); + Assertions.assertNotNull(cg.getParams().get("writeLinkStatsInterval")); } @Test void testWriteAverageOverIterations() { LinkStatsConfigGroup cg = new LinkStatsConfigGroup(); // test initial value - Assert.assertEquals(5, cg.getAverageLinkStatsOverIterations()); - Assert.assertEquals("5", cg.getValue("averageLinkStatsOverIterations")); + Assertions.assertEquals(5, cg.getAverageLinkStatsOverIterations()); + Assertions.assertEquals("5", cg.getValue("averageLinkStatsOverIterations")); // test setting with setMobsim cg.setAverageLinkStatsOverIterations(4); - Assert.assertEquals(4, cg.getAverageLinkStatsOverIterations()); - Assert.assertEquals("4", cg.getValue("averageLinkStatsOverIterations")); + Assertions.assertEquals(4, cg.getAverageLinkStatsOverIterations()); + Assertions.assertEquals("4", cg.getValue("averageLinkStatsOverIterations")); // test setting with addParam cg.addParam("averageLinkStatsOverIterations", "2"); - Assert.assertEquals(2, cg.getAverageLinkStatsOverIterations()); - Assert.assertEquals("2", cg.getValue("averageLinkStatsOverIterations")); + Assertions.assertEquals(2, cg.getAverageLinkStatsOverIterations()); + Assertions.assertEquals("2", cg.getValue("averageLinkStatsOverIterations")); } @Test void testGetParams_averageLinkStatsOverIterations() { LinkStatsConfigGroup cg = new LinkStatsConfigGroup(); - Assert.assertNotNull(cg.getParams().get("averageLinkStatsOverIterations")); + Assertions.assertNotNull(cg.getParams().get("averageLinkStatsOverIterations")); } } diff --git a/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java index ba0ff07c5f3..3109c603b79 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java @@ -20,8 +20,8 @@ package org.matsim.core.config.groups; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.util.Map; @@ -68,8 +68,8 @@ void testParamNames() { log.info("Catched IllegalArgumentException, as expected: " + e.getMessage()); } - assertEquals("unexpected number of strategy settings", 1, configGroup - .getStrategySettings().size()); + assertEquals(1, configGroup + .getStrategySettings().size(), "unexpected number of strategy settings"); } /** @@ -177,40 +177,40 @@ private void assertIdentical( final ReplanningConfigGroup initialGroup, final ReplanningConfigGroup inputConfigGroup) { assertEquals( - "wrong config template for "+msg, initialGroup.getExternalExeConfigTemplate(), - inputConfigGroup.getExternalExeConfigTemplate() ); + inputConfigGroup.getExternalExeConfigTemplate(), + "wrong config template for "+msg ); assertEquals( - "wrong ExternalExeTimeOut for "+msg, initialGroup.getExternalExeTimeOut(), - inputConfigGroup.getExternalExeTimeOut() ); + inputConfigGroup.getExternalExeTimeOut(), + "wrong ExternalExeTimeOut for "+msg ); assertEquals( - "wrong ExternalExeTmpFileRootDir for "+msg, initialGroup.getExternalExeTmpFileRootDir(), - inputConfigGroup.getExternalExeTmpFileRootDir() ); + inputConfigGroup.getExternalExeTmpFileRootDir(), + "wrong ExternalExeTmpFileRootDir for "+msg ); assertEquals( - "wrong FractionOfIterationsToDisableInnovation for "+msg, initialGroup.getFractionOfIterationsToDisableInnovation(), inputConfigGroup.getFractionOfIterationsToDisableInnovation(), - MatsimTestUtils.EPSILON ); + MatsimTestUtils.EPSILON, + "wrong FractionOfIterationsToDisableInnovation for "+msg ); assertEquals( - "wrong MaxAgentPlanMemorySize for "+msg, initialGroup.getMaxAgentPlanMemorySize(), - inputConfigGroup.getMaxAgentPlanMemorySize() ); + inputConfigGroup.getMaxAgentPlanMemorySize(), + "wrong MaxAgentPlanMemorySize for "+msg ); assertEquals( - "wrong PlanSelectorForRemoval for "+msg, initialGroup.getPlanSelectorForRemoval(), - inputConfigGroup.getPlanSelectorForRemoval() ); + inputConfigGroup.getPlanSelectorForRemoval(), + "wrong PlanSelectorForRemoval for "+msg ); assertEquals( - "wrong number of StrategySettings for "+msg, initialGroup.getStrategySettings().size(), - inputConfigGroup.getStrategySettings().size() ); + inputConfigGroup.getStrategySettings().size(), + "wrong number of StrategySettings for "+msg ); } private ConfigGroup toUnderscoredModule(final ReplanningConfigGroup initialGroup) { diff --git a/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java index 45f9c4e335c..aa4b8641b71 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java @@ -26,7 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.TransportMode; @@ -52,7 +52,7 @@ void testAddModeParamsTwice() { { Config config = ConfigUtils.createConfig(); RoutingConfigGroup group = config.routing(); - Assert.assertEquals( N_MODE_ROUTING_PARAMS_DEFAULT, group.getModeRoutingParams().size() ); + Assertions.assertEquals( N_MODE_ROUTING_PARAMS_DEFAULT, group.getModeRoutingParams().size() ); group.clearModeRoutingParams(); // group.setTeleportedModeSpeed( TransportMode.bike, 1. ); // Assert.assertEquals( 1, group.getModeRoutingParams().size() ); @@ -66,7 +66,7 @@ void testAddModeParamsTwice() { { Config config = ConfigUtils.loadConfig( filename ) ; RoutingConfigGroup group = config.routing(); - Assert.assertEquals( 0, group.getModeRoutingParams().size() ); + Assertions.assertEquals( 0, group.getModeRoutingParams().size() ); } } @@ -77,21 +77,21 @@ void testClearParamsWriteRead() { { Config config = ConfigUtils.createConfig(); RoutingConfigGroup group = config.routing(); - Assert.assertEquals( N_MODE_ROUTING_PARAMS_DEFAULT, group.getModeRoutingParams().size() ); + Assertions.assertEquals( N_MODE_ROUTING_PARAMS_DEFAULT, group.getModeRoutingParams().size() ); group.clearModeRoutingParams(); group.setTeleportedModeSpeed( TransportMode.bike, 1. ); - Assert.assertEquals( 1, group.getModeRoutingParams().size() ); + Assertions.assertEquals( 1, group.getModeRoutingParams().size() ); group.setTeleportedModeSpeed( "abc", 1. ); - Assert.assertEquals( 2, group.getModeRoutingParams().size() ); + Assertions.assertEquals( 2, group.getModeRoutingParams().size() ); group.clearModeRoutingParams(); - Assert.assertEquals( 0, group.getModeRoutingParams().size() ); + Assertions.assertEquals( 0, group.getModeRoutingParams().size() ); ConfigUtils.writeConfig( config, filename ); } { Config config = ConfigUtils.loadConfig( filename ) ; RoutingConfigGroup group = config.routing(); - Assert.assertEquals( 0, group.getModeRoutingParams().size() ); + Assertions.assertEquals( 0, group.getModeRoutingParams().size() ); } } @@ -102,22 +102,22 @@ void testRemoveParamsWriteRead() { { Config config = ConfigUtils.createConfig(); RoutingConfigGroup group = config.routing(); - Assert.assertEquals( N_MODE_ROUTING_PARAMS_DEFAULT, group.getModeRoutingParams().size() ); + Assertions.assertEquals( N_MODE_ROUTING_PARAMS_DEFAULT, group.getModeRoutingParams().size() ); group.setTeleportedModeSpeed( TransportMode.bike, 1. ); - Assert.assertEquals( 1, group.getModeRoutingParams().size() ); + Assertions.assertEquals( 1, group.getModeRoutingParams().size() ); group.setTeleportedModeSpeed( "abc", 1. ); - Assert.assertEquals( 2, group.getModeRoutingParams().size() ); + Assertions.assertEquals( 2, group.getModeRoutingParams().size() ); for( String mode : group.getModeRoutingParams().keySet() ){ group.removeModeRoutingParams( mode ); } - Assert.assertEquals( 0, group.getModeRoutingParams().size() ); + Assertions.assertEquals( 0, group.getModeRoutingParams().size() ); ConfigUtils.writeConfig( config, filename ); } { Config config = ConfigUtils.loadConfig( filename ) ; RoutingConfigGroup group = config.routing(); - Assert.assertEquals( 0, group.getModeRoutingParams().size() ); + Assertions.assertEquals( 0, group.getModeRoutingParams().size() ); } } @@ -125,13 +125,13 @@ void testRemoveParamsWriteRead() { void testClearDefaults() { Config config = ConfigUtils.createConfig( ) ; RoutingConfigGroup group = config.routing() ; - Assert.assertEquals( N_MODE_ROUTING_PARAMS_DEFAULT, group.getModeRoutingParams().size() ); + Assertions.assertEquals( N_MODE_ROUTING_PARAMS_DEFAULT, group.getModeRoutingParams().size() ); group.setTeleportedModeSpeed( "def", 1. ); - Assert.assertEquals( 1, group.getModeRoutingParams().size() ); + Assertions.assertEquals( 1, group.getModeRoutingParams().size() ); group.setTeleportedModeSpeed( "abc", 1. ); - Assert.assertEquals( 2, group.getModeRoutingParams().size() ); + Assertions.assertEquals( 2, group.getModeRoutingParams().size() ); group.clearModeRoutingParams( ); - Assert.assertEquals( 0, group.getModeRoutingParams().size() ); + Assertions.assertEquals( 0, group.getModeRoutingParams().size() ); } @Test @@ -156,17 +156,17 @@ void testBackwardsCompatibility() { RoutingConfigGroup group = new RoutingConfigGroup(); // test default - Assert.assertEquals("different default than expected.", 3.0 / 3.6, group.getTeleportedModeSpeeds().get(TransportMode.walk), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3.0 / 3.6, group.getTeleportedModeSpeeds().get(TransportMode.walk), MatsimTestUtils.EPSILON, "different default than expected."); try { group.addParam("walkSpeedFactor", "1.5"); } catch (IllegalArgumentException e) { log.info("catched expected exception: " + e.getMessage()); - Assert.assertFalse("Exception-Message should not be empty.", e.getMessage().isEmpty()); + Assertions.assertFalse(e.getMessage().isEmpty(), "Exception-Message should not be empty."); } - Assert.assertEquals("value should not have changed.", 3.0 / 3.6, group.getTeleportedModeSpeeds().get(TransportMode.walk), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3.0 / 3.6, group.getTeleportedModeSpeeds().get(TransportMode.walk), MatsimTestUtils.EPSILON, "value should not have changed."); group.addParam("walkSpeed", "1.5"); - Assert.assertEquals("value should have changed.", 1.5, group.getTeleportedModeSpeeds().get(TransportMode.walk), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1.5, group.getTeleportedModeSpeeds().get(TransportMode.walk), MatsimTestUtils.EPSILON, "value should have changed."); } @Test @@ -175,10 +175,10 @@ void testDefaultsAreCleared() { // group.clearModeRoutingParams(); group.setTeleportedModeSpeed( "skateboard" , 20 / 3.6 ); group.setTeleportedModeSpeed( "longboard" , 20 / 3.6 ); - Assert.assertEquals( - "unexpected number of modes after adding new mode in "+group.getModeRoutingParams(), + Assertions.assertEquals( 2, - group.getModeRoutingParams().size() ); + group.getModeRoutingParams().size(), + "unexpected number of modes after adding new mode in "+group.getModeRoutingParams() ); } @Test @@ -254,25 +254,23 @@ private static void assertIdentical( final String msg, final RoutingConfigGroup initialGroup, final RoutingConfigGroup inputConfigGroup) { - Assert.assertEquals( - "unexpected beelineDistanceFactor", -// initialGroup.getBeelineDistanceFactor(), -// inputConfigGroup.getBeelineDistanceFactor(), + Assertions.assertEquals( initialGroup.getBeelineDistanceFactors(), - inputConfigGroup.getBeelineDistanceFactors() ) ; + inputConfigGroup.getBeelineDistanceFactors(), + "unexpected beelineDistanceFactor" ) ; // MatsimTestUtils.EPSILON ); - Assert.assertEquals( - "unexpected networkModes", + Assertions.assertEquals( initialGroup.getNetworkModes(), - inputConfigGroup.getNetworkModes() ); - Assert.assertEquals( - "unexpected teleportedModeFreespeedFactors", + inputConfigGroup.getNetworkModes(), + "unexpected networkModes" ); + Assertions.assertEquals( initialGroup.getTeleportedModeFreespeedFactors(), - inputConfigGroup.getTeleportedModeFreespeedFactors() ); - Assert.assertEquals( - "unexpected teleportedModeSpeeds", + inputConfigGroup.getTeleportedModeFreespeedFactors(), + "unexpected teleportedModeFreespeedFactors" ); + Assertions.assertEquals( initialGroup.getTeleportedModeSpeeds(), - inputConfigGroup.getTeleportedModeSpeeds() ); + inputConfigGroup.getTeleportedModeSpeeds(), + "unexpected teleportedModeSpeeds" ); } private static ConfigGroup toUnderscoredModule(final RoutingConfigGroup initialGroup) { diff --git a/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java index 80512022e3f..a745ea1a452 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.TransportMode; @@ -41,7 +41,7 @@ import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; import org.matsim.testcases.MatsimTestUtils; - public class ScoringConfigGroupTest { + public class ScoringConfigGroupTest { private static final Logger log = LogManager.getLogger(ScoringConfigGroupTest.class); @@ -53,16 +53,16 @@ private void testResultsBeforeCheckConsistency( Config config, boolean fullyHier if ( ! fullyHierarchical ){ // mode params are there for default modes: - Assert.assertNotNull( scoringConfig.getModes().get( TransportMode.car ) ); - Assert.assertNotNull( scoringConfig.getModes().get( TransportMode.walk ) ); - Assert.assertNotNull( scoringConfig.getModes().get( TransportMode.bike ) ); - Assert.assertNotNull( scoringConfig.getModes().get( TransportMode.ride ) ); - Assert.assertNotNull( scoringConfig.getModes().get( TransportMode.pt ) ); - Assert.assertNotNull( scoringConfig.getModes().get( TransportMode.other ) ); + Assertions.assertNotNull( scoringConfig.getModes().get( TransportMode.car ) ); + Assertions.assertNotNull( scoringConfig.getModes().get( TransportMode.walk ) ); + Assertions.assertNotNull( scoringConfig.getModes().get( TransportMode.bike ) ); + Assertions.assertNotNull( scoringConfig.getModes().get( TransportMode.ride ) ); + Assertions.assertNotNull( scoringConfig.getModes().get( TransportMode.pt ) ); + Assertions.assertNotNull( scoringConfig.getModes().get( TransportMode.other ) ); // default stage/interaction params are there for pt and drt (as a service): - Assert.assertNotNull( scoringConfig.getActivityParams( createStageActivityType( TransportMode.pt ) ) ); - Assert.assertNotNull( scoringConfig.getActivityParams( createStageActivityType( TransportMode.drt ) ) ); + Assertions.assertNotNull( scoringConfig.getActivityParams( createStageActivityType( TransportMode.pt ) ) ); + Assertions.assertNotNull( scoringConfig.getActivityParams( createStageActivityType( TransportMode.drt ) ) ); } // default stage/interaction params for modes routed on the network are not yet there: // for( String networkMode : config.plansCalcRoute().getNetworkModes() ){ @@ -74,7 +74,7 @@ private void testResultsAfterCheckConsistency( Config config ) { // default stage/interaction params for modes routed on the network are now there: for( String networkMode : config.routing().getNetworkModes() ){ - Assert.assertNotNull( scoringConfig.getActivityParams( createStageActivityType( networkMode ) ) ); + Assertions.assertNotNull( scoringConfig.getActivityParams( createStageActivityType( networkMode ) ) ); } } @@ -140,13 +140,13 @@ void testVersionWoScoringparams() { void testAddActivityParams() { ScoringConfigGroup c = new ScoringConfigGroup(); int originalSize = c.getActivityParams().size(); - Assert.assertNull(c.getActivityParams("type1")); - Assert.assertEquals(originalSize, c.getActivityParams().size()); + Assertions.assertNull(c.getActivityParams("type1")); + Assertions.assertEquals(originalSize, c.getActivityParams().size()); ActivityParams ap = new ActivityParams("type1"); c.addActivityParams(ap); - Assert.assertEquals(ap, c.getActivityParams("type1")); - Assert.assertEquals(originalSize + 1, c.getActivityParams().size()); + Assertions.assertEquals(ap, c.getActivityParams("type1")); + Assertions.assertEquals(originalSize + 1, c.getActivityParams().size()); } @Test @@ -178,183 +178,189 @@ private void assertIdentical( final String msg, final ScoringConfigGroup initialGroup, final ScoringConfigGroup inputConfigGroup) { - Assert.assertEquals( - "wrong brainExpBeta "+msg, + Assertions.assertEquals( initialGroup.getBrainExpBeta(), inputConfigGroup.getBrainExpBeta(), - 1e-7); - Assert.assertEquals( - "wrong constantBike "+msg, + 1e-7, + "wrong brainExpBeta "+msg); + Assertions.assertEquals( initialGroup.getModes().get(TransportMode.bike).getConstant(), inputConfigGroup.getModes().get(TransportMode.bike).getConstant(), - 1e-7); - Assert.assertEquals( - "wrong constantCar "+msg, + 1e-7, + "wrong constantBike "+msg); + Assertions.assertEquals( initialGroup.getModes().get(TransportMode.car).getConstant(), inputConfigGroup.getModes().get(TransportMode.car).getConstant(), - 1e-7); - Assert.assertEquals( - "wrong constantOther "+msg, + 1e-7, + "wrong constantCar "+msg); + Assertions.assertEquals( initialGroup.getModes().get(TransportMode.other).getConstant(), inputConfigGroup.getModes().get(TransportMode.other).getConstant(), - 1e-7); - Assert.assertEquals( - "wrong constantPt "+msg, + 1e-7, + "wrong constantOther "+msg); + Assertions.assertEquals( initialGroup.getModes().get(TransportMode.pt).getConstant(), inputConfigGroup.getModes().get(TransportMode.pt).getConstant(), - 1e-7); - Assert.assertEquals( - "wrong constantWalk "+msg, + 1e-7, + "wrong constantPt "+msg); + Assertions.assertEquals( initialGroup.getModes().get(TransportMode.walk).getConstant(), inputConfigGroup.getModes().get(TransportMode.walk).getConstant(), - 1e-7); - Assert.assertEquals( - "wrong lateArrival_utils_hr "+msg, + 1e-7, + "wrong constantWalk "+msg); + Assertions.assertEquals( initialGroup.getLateArrival_utils_hr(), inputConfigGroup.getLateArrival_utils_hr(), - 1e-7 ); - Assert.assertEquals( - "wrong earlyDeparture_utils_hr "+msg, + 1e-7, + "wrong lateArrival_utils_hr "+msg ); + Assertions.assertEquals( initialGroup.getEarlyDeparture_utils_hr(), inputConfigGroup.getEarlyDeparture_utils_hr(), - 1e-7 ); - Assert.assertEquals( - "wrong learningRate "+msg, + 1e-7, + "wrong earlyDeparture_utils_hr "+msg ); + Assertions.assertEquals( initialGroup.getLearningRate(), inputConfigGroup.getLearningRate(), - 1e-7 ); - Assert.assertEquals( - "wrong marginalUtilityOfMoney "+msg, + 1e-7, + "wrong learningRate "+msg ); + Assertions.assertEquals( initialGroup.getMarginalUtilityOfMoney(), inputConfigGroup.getMarginalUtilityOfMoney() , - 1e-7); - Assert.assertEquals( - "wrong marginalUtlOfDistanceOther "+msg, + 1e-7, + "wrong marginalUtilityOfMoney "+msg); + Assertions.assertEquals( initialGroup.getModes().get(TransportMode.other).getMarginalUtilityOfDistance(), inputConfigGroup.getModes().get(TransportMode.other).getMarginalUtilityOfDistance(), - 1e-7); - Assert.assertEquals( - "wrong marginalUtlOfDistanceWalk "+msg, + 1e-7, + "wrong marginalUtlOfDistanceOther "+msg); + Assertions.assertEquals( initialGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfDistance(), inputConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfDistance(), - 1e-7); - Assert.assertEquals( - "wrong marginalUtlOfWaiting_utils_hr "+msg, + 1e-7, + "wrong marginalUtlOfDistanceWalk "+msg); + Assertions.assertEquals( initialGroup.getMarginalUtlOfWaiting_utils_hr(), inputConfigGroup.getMarginalUtlOfWaiting_utils_hr(), - 1e-7 ); - Assert.assertEquals( - "wrong marginalUtlOfWaitingPt_utils_hr "+msg, + 1e-7, + "wrong marginalUtlOfWaiting_utils_hr "+msg ); + Assertions.assertEquals( initialGroup.getMarginalUtlOfWaitingPt_utils_hr(), inputConfigGroup.getMarginalUtlOfWaitingPt_utils_hr(), - 1e-7 ); - Assert.assertEquals( - "wrong monetaryDistanceCostRateCar "+msg, + 1e-7, + "wrong marginalUtlOfWaitingPt_utils_hr "+msg ); + Assertions.assertEquals( initialGroup.getModes().get(TransportMode.car).getMonetaryDistanceRate(), inputConfigGroup.getModes().get(TransportMode.car).getMonetaryDistanceRate(), - 1e-7); - Assert.assertEquals( - "wrong monetaryDistanceCostRatePt "+msg, + 1e-7, + "wrong monetaryDistanceCostRateCar "+msg); + Assertions.assertEquals( initialGroup.getModes().get(TransportMode.pt).getMonetaryDistanceRate(), inputConfigGroup.getModes().get(TransportMode.pt).getMonetaryDistanceRate(), - 1e-7); - Assert.assertEquals( - "wrong pathSizeLogitBeta "+msg, + 1e-7, + "wrong monetaryDistanceCostRatePt "+msg); + Assertions.assertEquals( initialGroup.getPathSizeLogitBeta(), inputConfigGroup.getPathSizeLogitBeta(), - 1e-7 ); - Assert.assertEquals( - "wrong performing_utils_hr "+msg, + 1e-7, + "wrong pathSizeLogitBeta "+msg ); + Assertions.assertEquals( initialGroup.getPerforming_utils_hr(), inputConfigGroup.getPerforming_utils_hr(), - 1e-7 ); - Assert.assertEquals( - "wrong traveling_utils_hr "+msg, + 1e-7, + "wrong performing_utils_hr "+msg ); + Assertions.assertEquals( initialGroup.getModes().get(TransportMode.car).getMarginalUtilityOfTraveling(), inputConfigGroup.getModes().get(TransportMode.car).getMarginalUtilityOfTraveling(), - 1e-7); - Assert.assertEquals( - "wrong travelingBike_utils_hr "+msg, + 1e-7, + "wrong traveling_utils_hr "+msg); + Assertions.assertEquals( initialGroup.getModes().get(TransportMode.bike).getMarginalUtilityOfTraveling(), inputConfigGroup.getModes().get(TransportMode.bike).getMarginalUtilityOfTraveling(), - 1e-7); - Assert.assertEquals( - "wrong travelingOther_utils_hr "+msg, + 1e-7, + "wrong travelingBike_utils_hr "+msg); + Assertions.assertEquals( initialGroup.getModes().get(TransportMode.other).getMarginalUtilityOfTraveling(), inputConfigGroup.getModes().get(TransportMode.other).getMarginalUtilityOfTraveling(), - 1e-7); - Assert.assertEquals( - "wrong travelingPt_utils_hr "+msg, + 1e-7, + "wrong travelingOther_utils_hr "+msg); + Assertions.assertEquals( initialGroup.getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling(), inputConfigGroup.getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling(), - 1e-7); - Assert.assertEquals( - "wrong travelingWalk_utils_hr "+msg, + 1e-7, + "wrong travelingPt_utils_hr "+msg); + Assertions.assertEquals( initialGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling(), inputConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling(), - 1e-7); - Assert.assertEquals( - "wrong utilityOfLineSwitch "+msg, + 1e-7, + "wrong travelingWalk_utils_hr "+msg); + Assertions.assertEquals( initialGroup.getUtilityOfLineSwitch(), inputConfigGroup.getUtilityOfLineSwitch(), - 1e-7 ); + 1e-7, + "wrong utilityOfLineSwitch "+msg ); for ( ActivityParams initialSettings : initialGroup.getActivityParams() ) { final ActivityParams inputSettings = inputConfigGroup.getActivityParams( initialSettings.getActivityType() ); - Assert.assertEquals( - "wrong type "+msg, + Assertions.assertEquals( initialSettings.getActivityType(), - inputSettings.getActivityType() ); - Assert.assertEquals( - "wrong closingTime "+msg, initialSettings.getClosingTime(), - inputSettings.getClosingTime()); - Assert.assertEquals( - "wrong earliestEndTime "+msg, initialSettings.getEarliestEndTime(), - inputSettings.getEarliestEndTime()); - Assert.assertEquals( - "wrong latestStartTime "+msg, initialSettings.getLatestStartTime(), - inputSettings.getLatestStartTime()); - Assert.assertEquals( - "wrong minimalDuration "+msg, initialSettings.getMinimalDuration(), - inputSettings.getMinimalDuration()); - Assert.assertEquals( - "wrong openingTime "+msg, initialSettings.getOpeningTime(), - inputSettings.getOpeningTime()); - Assert.assertEquals( - "wrong priority "+msg, + inputSettings.getActivityType(), + "wrong type "+msg ); + Assertions.assertEquals( + initialSettings.getClosingTime(), + inputSettings.getClosingTime(), + "wrong closingTime "+msg); + Assertions.assertEquals( + initialSettings.getEarliestEndTime(), + inputSettings.getEarliestEndTime(), + "wrong earliestEndTime "+msg); + Assertions.assertEquals( + initialSettings.getLatestStartTime(), + inputSettings.getLatestStartTime(), + "wrong latestStartTime "+msg); + Assertions.assertEquals( + initialSettings.getMinimalDuration(), + inputSettings.getMinimalDuration(), + "wrong minimalDuration "+msg); + Assertions.assertEquals( + initialSettings.getOpeningTime(), + inputSettings.getOpeningTime(), + "wrong openingTime "+msg); + Assertions.assertEquals( initialSettings.getPriority(), inputSettings.getPriority(), - 1e-7 ); - Assert.assertEquals( - "wrong typicalDuration "+msg, initialSettings.getTypicalDuration(), - inputSettings.getTypicalDuration()); + 1e-7, + "wrong priority "+msg ); + Assertions.assertEquals( + initialSettings.getTypicalDuration(), + inputSettings.getTypicalDuration(), + "wrong typicalDuration "+msg); } for ( ModeParams initialSettings : initialGroup.getModes().values() ) { final String mode = initialSettings.getMode(); final ModeParams inputSettings = inputConfigGroup.getModes().get( mode ); - Assert.assertEquals( - "wrong constant "+msg, + Assertions.assertEquals( initialSettings.getConstant(), inputSettings.getConstant(), - 1e-7 ); - Assert.assertEquals( - "wrong marginalUtilityOfDistance "+msg, + 1e-7, + "wrong constant "+msg ); + Assertions.assertEquals( initialSettings.getMarginalUtilityOfDistance(), inputSettings.getMarginalUtilityOfDistance(), - 1e-7 ); - Assert.assertEquals( - "wrong marginalUtilityOfTraveling "+msg, + 1e-7, + "wrong marginalUtilityOfDistance "+msg ); + Assertions.assertEquals( initialSettings.getMarginalUtilityOfTraveling(), inputSettings.getMarginalUtilityOfTraveling(), - 1e-7 ); - Assert.assertEquals( - "wrong monetaryDistanceRate "+msg, + 1e-7, + "wrong marginalUtilityOfTraveling "+msg ); + Assertions.assertEquals( initialSettings.getMonetaryDistanceRate(), inputSettings.getMonetaryDistanceRate(), - 1e-7 ); + 1e-7, + "wrong monetaryDistanceRate "+msg ); } diff --git a/matsim/src/test/java/org/matsim/core/config/groups/SubtourModeChoiceConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/SubtourModeChoiceConfigGroupTest.java index 77bcf5c5869..3a70bea64d6 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/SubtourModeChoiceConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/SubtourModeChoiceConfigGroupTest.java @@ -19,10 +19,7 @@ * *********************************************************************** */ package org.matsim.core.config.groups; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; @@ -41,40 +38,40 @@ void testModes() throws Exception { SubtourModeChoiceConfigGroup.MODES, "foot,car,balloon" ); assertArrayEquals( - msg, new String[]{"foot", "car", "balloon" }, - group.getModes() ); + group.getModes(), + msg ); assertEquals( - msgString, "foot,car,balloon", group.getValue( - SubtourModeChoiceConfigGroup.MODES )); + SubtourModeChoiceConfigGroup.MODES ), + msgString); group.addParam( SubtourModeChoiceConfigGroup.MODES, " rocket,bike" ); assertArrayEquals( - msg, new String[]{"rocket", "bike" }, - group.getModes() ); + group.getModes(), + msg ); assertEquals( - msgString, "rocket,bike", group.getValue( - SubtourModeChoiceConfigGroup.MODES )); + SubtourModeChoiceConfigGroup.MODES ), + msgString); group.addParam( SubtourModeChoiceConfigGroup.MODES, "skateboard , unicycle " ); assertArrayEquals( - msg, new String[]{"skateboard", "unicycle" }, - group.getModes() ); + group.getModes(), + msg ); assertEquals( - msgString, "skateboard,unicycle", group.getValue( - SubtourModeChoiceConfigGroup.MODES )); + SubtourModeChoiceConfigGroup.MODES ), + msgString); } @Test @@ -87,40 +84,40 @@ void testChainBasedModes() throws Exception { SubtourModeChoiceConfigGroup.CHAINBASEDMODES, "foot,car,balloon" ); assertArrayEquals( - msg, new String[]{"foot", "car", "balloon" }, - group.getChainBasedModes() ); + group.getChainBasedModes(), + msg ); assertEquals( - msgString, "foot,car,balloon", group.getValue( - SubtourModeChoiceConfigGroup.CHAINBASEDMODES)); + SubtourModeChoiceConfigGroup.CHAINBASEDMODES), + msgString); group.addParam( SubtourModeChoiceConfigGroup.CHAINBASEDMODES, " rocket,bike" ); assertArrayEquals( - msg, new String[]{"rocket", "bike" }, - group.getChainBasedModes() ); + group.getChainBasedModes(), + msg ); assertEquals( - msgString, "rocket,bike", group.getValue( - SubtourModeChoiceConfigGroup.CHAINBASEDMODES)); + SubtourModeChoiceConfigGroup.CHAINBASEDMODES), + msgString); group.addParam( SubtourModeChoiceConfigGroup.CHAINBASEDMODES, "skateboard , unicycle " ); assertArrayEquals( - msg, new String[]{"skateboard", "unicycle" }, - group.getChainBasedModes() ); + group.getChainBasedModes(), + msg ); assertEquals( - msgString, "skateboard,unicycle", group.getValue( - SubtourModeChoiceConfigGroup.CHAINBASEDMODES)); + SubtourModeChoiceConfigGroup.CHAINBASEDMODES), + msgString); } @Test @@ -128,18 +125,18 @@ void testCarAvail() throws Exception { SubtourModeChoiceConfigGroup group = new SubtourModeChoiceConfigGroup(); assertFalse( - "default value is not backward compatible", - group.considerCarAvailability() ); + group.considerCarAvailability(), + "default value is not backward compatible" ); group.addParam( SubtourModeChoiceConfigGroup.CARAVAIL, "true" ); - assertTrue( "the value was not set to true" , group.considerCarAvailability() ); + assertTrue( group.considerCarAvailability(), "the value was not set to true" ); group.addParam( SubtourModeChoiceConfigGroup.CARAVAIL, "false" ); - assertFalse( "the value was not set to false" , group.considerCarAvailability() ); + assertFalse( group.considerCarAvailability(), "the value was not set to false" ); } } diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java b/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java index d4b1efc64b6..e889fb576ea 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java @@ -20,8 +20,8 @@ package org.matsim.core.controler; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.ArrayList; import java.util.List; @@ -88,10 +88,10 @@ void testEvents() { controler.run(config); //test for startup events StartupEvent startup = listener.getStartupEvent(); - assertNotNull("No ControlerStartupEvent fired!", startup); + assertNotNull(startup, "No ControlerStartupEvent fired!"); //test for shutdown ShutdownEvent shutdown = listener.getShutdownEvent(); - assertNotNull("No ControlerShutdownEvent fired!", shutdown); + assertNotNull(shutdown, "No ControlerShutdownEvent fired!"); //test for iterations //setup List setupIt = listener.getIterationStartsEvents(); diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java b/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java index b304f34dbd1..88478e19bb8 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java @@ -20,8 +20,7 @@ package org.matsim.core.controler; -import static org.junit.Assert.*; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; import static org.matsim.core.config.groups.ControllerConfigGroup.CompressionType; import static org.matsim.core.config.groups.ControllerConfigGroup.SnapshotFormat; @@ -34,7 +33,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.runner.RunWith; @@ -138,13 +137,13 @@ void testConstructor_EventsManagerTypeImmutable() { MatsimServices controler = new Controler(config); try { controler.getConfig().setParam("eventsManager", "numberOfThreads", "2"); - Assert.fail("Expected exception"); + Assertions.fail("Expected exception"); } catch (Exception e) { log.info("catched expected exception", e); } try { controler.getConfig().setParam("eventsManager", "estimatedNumberOfEvents", "200000"); - Assert.fail("Expected exception"); + Assertions.fail("Expected exception"); } catch (Exception e) { log.info("catched expected exception", e); } @@ -222,8 +221,8 @@ void testTravelTimeCalculation() { // test if the travel time calculator got the right result // the actual result is 151sec, not 150, as each vehicle "loses" 1sec in the buffer - assertEquals("TravelTimeCalculator has wrong result", avgTravelTimeLink2, - controler.getLinkTravelTimes().getLinkTravelTime(f.link2, 7 * 3600, null, null), MatsimTestUtils.EPSILON); + assertEquals(avgTravelTimeLink2, + controler.getLinkTravelTimes().getLinkTravelTime(f.link2, 7 * 3600, null, null), MatsimTestUtils.EPSILON, "TravelTimeCalculator has wrong result"); // now test that the ReRoute-Strategy also knows about these travel times... config.controller().setLastIteration(1); @@ -239,8 +238,8 @@ void testTravelTimeCalculation() { // test that the plans have the correct travel times // (travel time of the plan does not contain first and last link) - assertEquals("ReRoute seems to have wrong travel times.", avgTravelTimeLink2, - ((Leg)(person1.getPlans().get(1).getPlanElements().get(1))).getTravelTime().seconds(), MatsimTestUtils.EPSILON); + assertEquals(avgTravelTimeLink2, + ((Leg)(person1.getPlans().get(1).getPlanElements().get(1))).getTravelTime().seconds(), MatsimTestUtils.EPSILON, "ReRoute seems to have wrong travel times."); } /** @@ -288,8 +287,8 @@ public Mobsim get() { controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); - assertTrue("Custom ScoringFunctionFactory was not set.", - controler.getScoringFunctionFactory() instanceof DummyScoringFunctionFactory); + assertTrue(controler.getScoringFunctionFactory() instanceof DummyScoringFunctionFactory, + "Custom ScoringFunctionFactory was not set."); } /** @@ -372,12 +371,12 @@ public Mobsim get() { // but do not assume that the leg will be the same instance... for (Plan plan : new Plan[]{plan1, plan2}) { assertEquals( - "unexpected plan length in "+plan.getPlanElements(), 3, - plan.getPlanElements().size()); + plan.getPlanElements().size(), + "unexpected plan length in "+plan.getPlanElements()); assertNotNull( - "null route in plan "+plan.getPlanElements(), - ((Leg) plan.getPlanElements().get( 1 )).getRoute()); + ((Leg) plan.getPlanElements().get( 1 )).getRoute(), + "null route in plan "+plan.getPlanElements()); } } @@ -482,16 +481,16 @@ public Mobsim get() { // but do not assume that the leg will be the same instance... for (Plan plan : new Plan[]{plan1, plan2}) { assertEquals( - "unexpected plan length in "+plan.getPlanElements(), expectedPlanLength, - plan.getPlanElements().size()); + plan.getPlanElements().size(), + "unexpected plan length in "+plan.getPlanElements()); assertNotNull( - "null route in plan "+plan.getPlanElements(), - ((Leg) plan.getPlanElements().get( 1 )).getRoute()); + ((Leg) plan.getPlanElements().get( 1 )).getRoute(), + "null route in plan "+plan.getPlanElements()); if ( !f.scenario.getConfig().routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { assertNotNull( - "null route in plan "+plan.getPlanElements(), - ((Leg) plan.getPlanElements().get( 3 )).getRoute()); + ((Leg) plan.getPlanElements().get( 3 )).getRoute(), + "null route in plan "+plan.getPlanElements()); } } } @@ -545,8 +544,8 @@ void testSetWriteEventsInterval() { config.controller().setWritePlansInterval(0); final Controler controler = new Controler(config); - assertFalse("Default for Controler.writeEventsInterval should be different from the interval we plan to use, otherwise it's hard to decide if it works correctly.", - 3 == controler.getConfig().controller().getWriteEventsInterval()); + assertFalse(3 == controler.getConfig().controller().getWriteEventsInterval(), + "Default for Controler.writeEventsInterval should be different from the interval we plan to use, otherwise it's hard to decide if it works correctly."); controler.getConfig().controller().setWriteEventsInterval(3); assertEquals(3, controler.getConfig().controller().getWriteEventsInterval()); @@ -589,8 +588,8 @@ void testSetWriteEventsIntervalConfig() { config.controller().setWritePlansInterval(0); final Controler controler = new Controler(config); - assertFalse("Default for Controler.writeEventsInterval should be different from the interval we plan to use, otherwise it's hard to decide if it works correctly.", - 3 == controler.getConfig().controller().getWriteEventsInterval()); + assertFalse(3 == controler.getConfig().controller().getWriteEventsInterval(), + "Default for Controler.writeEventsInterval should be different from the interval we plan to use, otherwise it's hard to decide if it works correctly."); controler.getConfig().controller().setCreateGraphs(false); controler.addOverridingModule(new AbstractModule() { @Override @@ -630,8 +629,8 @@ void testSetWriteEventsNever() { config.controller().setWritePlansInterval(0); final Controler controler = new Controler(config); - assertFalse("Default for Controler.writeEventsInterval should be different from the interval we plan to use, otherwise it's hard to decide if it works correctly.", - 0 == controler.getConfig().controller().getWriteEventsInterval()); + assertFalse(0 == controler.getConfig().controller().getWriteEventsInterval(), + "Default for Controler.writeEventsInterval should be different from the interval we plan to use, otherwise it's hard to decide if it works correctly."); controler.getConfig().controller().setWriteEventsInterval(0); assertEquals(0, controler.getConfig().controller().getWriteEventsInterval()); controler.getConfig().controller().setCreateGraphs(false); @@ -819,7 +818,7 @@ public Mobsim get() { controler.getConfig().controller().setCreateGraphs(false); controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); - Assert.fail("expected exception, got none."); + Assertions.fail("expected exception, got none."); // note: I moved loadScenario in the controler from run() into the constructor to mirror the loading sequence one has // when calling new Controler(scenario). In consequence, it fails already in the constructor; one could stop after that. @@ -854,7 +853,7 @@ public Mobsim get() { controler.getConfig().controller().setCreateGraphs(false); controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); - Assert.fail("expected exception, got none."); + Assertions.fail("expected exception, got none."); // note: I moved loadScenario in the controler from run() into the constructor to mirror the loading sequence one has // when calling new Controler(scenario). In consequence, it fails already in the constructor; one could stop after that. @@ -889,7 +888,7 @@ public Mobsim get() { controler.getConfig().controller().setCreateGraphs(false); controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); - Assert.fail("expected exception, got none."); + Assertions.fail("expected exception, got none."); // note: I moved loadScenario in the controler from run() into the constructor to mirror the loading sequence one has // when calling new Controler(scenario). In consequence, it fails already in the constructor; one could stop after that. @@ -974,10 +973,10 @@ public void install() { controler.run(); - Assert.assertSame( - "adding a Guice module to the controler from a Guice module is allowed but has no effect", + Assertions.assertSame( replacementScenario, - controler.getScenario()); + controler.getScenario(), + "adding a Guice module to the controler from a Guice module is allowed but has no effect"); }); } diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerListenerManagerImplTest.java b/matsim/src/test/java/org/matsim/core/controler/ControlerListenerManagerImplTest.java index 762a73afc2e..2705f6444af 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerListenerManagerImplTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerListenerManagerImplTest.java @@ -21,7 +21,7 @@ package org.matsim.core.controler; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.core.controler.events.IterationStartsEvent; import org.matsim.core.controler.events.ShutdownEvent; @@ -30,7 +30,7 @@ import org.matsim.core.controler.listener.ShutdownListener; import org.matsim.core.controler.listener.StartupListener; - /** + /** * @author mrieser / senozon */ public class ControlerListenerManagerImplTest { @@ -44,32 +44,32 @@ void testAddControlerListener_ClassHierarchy() { m.addControlerListener(ecl); m.fireControlerStartupEvent(); - Assert.assertEquals(1, ccl.nOfStartups); - Assert.assertEquals(0, ccl.nOfIterStarts); - Assert.assertEquals(1, ecl.nOfStartups); - Assert.assertEquals(0, ecl.nOfIterStarts); - Assert.assertEquals(0, ecl.nOfShutdowns); + Assertions.assertEquals(1, ccl.nOfStartups); + Assertions.assertEquals(0, ccl.nOfIterStarts); + Assertions.assertEquals(1, ecl.nOfStartups); + Assertions.assertEquals(0, ecl.nOfIterStarts); + Assertions.assertEquals(0, ecl.nOfShutdowns); m.fireControlerIterationStartsEvent(0, false); - Assert.assertEquals(1, ccl.nOfStartups); - Assert.assertEquals(1, ccl.nOfIterStarts); - Assert.assertEquals(1, ecl.nOfStartups); - Assert.assertEquals(1, ecl.nOfIterStarts); - Assert.assertEquals(0, ecl.nOfShutdowns); + Assertions.assertEquals(1, ccl.nOfStartups); + Assertions.assertEquals(1, ccl.nOfIterStarts); + Assertions.assertEquals(1, ecl.nOfStartups); + Assertions.assertEquals(1, ecl.nOfIterStarts); + Assertions.assertEquals(0, ecl.nOfShutdowns); m.fireControlerIterationStartsEvent(1, false); - Assert.assertEquals(1, ccl.nOfStartups); - Assert.assertEquals(2, ccl.nOfIterStarts); - Assert.assertEquals(1, ecl.nOfStartups); - Assert.assertEquals(2, ecl.nOfIterStarts); - Assert.assertEquals(0, ecl.nOfShutdowns); + Assertions.assertEquals(1, ccl.nOfStartups); + Assertions.assertEquals(2, ccl.nOfIterStarts); + Assertions.assertEquals(1, ecl.nOfStartups); + Assertions.assertEquals(2, ecl.nOfIterStarts); + Assertions.assertEquals(0, ecl.nOfShutdowns); m.fireControlerShutdownEvent(false, 1); - Assert.assertEquals(1, ccl.nOfStartups); - Assert.assertEquals(2, ccl.nOfIterStarts); - Assert.assertEquals(1, ecl.nOfStartups); - Assert.assertEquals(2, ecl.nOfIterStarts); - Assert.assertEquals(1, ecl.nOfShutdowns); + Assertions.assertEquals(1, ccl.nOfStartups); + Assertions.assertEquals(2, ccl.nOfIterStarts); + Assertions.assertEquals(1, ecl.nOfStartups); + Assertions.assertEquals(2, ecl.nOfIterStarts); + Assertions.assertEquals(1, ecl.nOfShutdowns); } @Test @@ -81,32 +81,32 @@ void testAddCoreControlerListener_ClassHierarchy() { m.addCoreControlerListener(ecl); m.fireControlerStartupEvent(); - Assert.assertEquals(1, ccl.nOfStartups); - Assert.assertEquals(0, ccl.nOfIterStarts); - Assert.assertEquals(1, ecl.nOfStartups); - Assert.assertEquals(0, ecl.nOfIterStarts); - Assert.assertEquals(0, ecl.nOfShutdowns); + Assertions.assertEquals(1, ccl.nOfStartups); + Assertions.assertEquals(0, ccl.nOfIterStarts); + Assertions.assertEquals(1, ecl.nOfStartups); + Assertions.assertEquals(0, ecl.nOfIterStarts); + Assertions.assertEquals(0, ecl.nOfShutdowns); m.fireControlerIterationStartsEvent(0, false); - Assert.assertEquals(1, ccl.nOfStartups); - Assert.assertEquals(1, ccl.nOfIterStarts); - Assert.assertEquals(1, ecl.nOfStartups); - Assert.assertEquals(1, ecl.nOfIterStarts); - Assert.assertEquals(0, ecl.nOfShutdowns); + Assertions.assertEquals(1, ccl.nOfStartups); + Assertions.assertEquals(1, ccl.nOfIterStarts); + Assertions.assertEquals(1, ecl.nOfStartups); + Assertions.assertEquals(1, ecl.nOfIterStarts); + Assertions.assertEquals(0, ecl.nOfShutdowns); m.fireControlerIterationStartsEvent(1, false); - Assert.assertEquals(1, ccl.nOfStartups); - Assert.assertEquals(2, ccl.nOfIterStarts); - Assert.assertEquals(1, ecl.nOfStartups); - Assert.assertEquals(2, ecl.nOfIterStarts); - Assert.assertEquals(0, ecl.nOfShutdowns); + Assertions.assertEquals(1, ccl.nOfStartups); + Assertions.assertEquals(2, ccl.nOfIterStarts); + Assertions.assertEquals(1, ecl.nOfStartups); + Assertions.assertEquals(2, ecl.nOfIterStarts); + Assertions.assertEquals(0, ecl.nOfShutdowns); m.fireControlerShutdownEvent(false, 1); - Assert.assertEquals(1, ccl.nOfStartups); - Assert.assertEquals(2, ccl.nOfIterStarts); - Assert.assertEquals(1, ecl.nOfStartups); - Assert.assertEquals(2, ecl.nOfIterStarts); - Assert.assertEquals(1, ecl.nOfShutdowns); + Assertions.assertEquals(1, ccl.nOfStartups); + Assertions.assertEquals(2, ccl.nOfIterStarts); + Assertions.assertEquals(1, ecl.nOfStartups); + Assertions.assertEquals(2, ecl.nOfIterStarts); + Assertions.assertEquals(1, ecl.nOfShutdowns); } private static class CountingControlerListener implements StartupListener, IterationStartsListener { diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerMobsimIntegrationTest.java b/matsim/src/test/java/org/matsim/core/controler/ControlerMobsimIntegrationTest.java index af2cf20fe23..3659acdf9f6 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerMobsimIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerMobsimIntegrationTest.java @@ -24,7 +24,7 @@ import com.google.inject.Provider; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -69,7 +69,7 @@ public Mobsim get() { c.getConfig().controller().setDumpDataAtEnd(false); c.getConfig().controller().setWriteEventsInterval(0); c.run(); - Assert.assertEquals(1, mf.callCount); + Assertions.assertEquals(1, mf.callCount); } @Test diff --git a/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java b/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java index 1bb0b102e20..79e6db37f10 100644 --- a/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java @@ -21,8 +21,8 @@ package org.matsim.core.controler; -import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.config.Config; @@ -31,7 +31,7 @@ import org.matsim.core.controler.listener.IterationStartsListener; import org.matsim.testcases.MatsimTestUtils; - public class MatsimServicesImplTest { + public class MatsimServicesImplTest { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); @@ -53,7 +53,7 @@ public void install() { @Override public void notifyIterationStarts(IterationStartsEvent event) { - Assert.assertSame(event.getIteration(), event.getServices().getIterationNumber()); + Assertions.assertSame(event.getIteration(), event.getServices().getIterationNumber()); } diff --git a/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java b/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java index 76d790ebe04..5fa3ccb628a 100644 --- a/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java @@ -18,7 +18,7 @@ * *********************************************************************** */ package org.matsim.core.controler; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.config.groups.ControllerConfigGroup; @@ -48,9 +48,9 @@ void testFailureIfDirectoryExists() { OutputDirectoryHierarchy.OverwriteFileSetting.failIfDirectoryExists, ControllerConfigGroup.CompressionType.none); - Assert.assertTrue( - "Directory was not created", - new File( outputDirectory ).exists() ); + Assertions.assertTrue( + new File( outputDirectory ).exists(), + "Directory was not created" ); // put something in the directory try ( final BufferedWriter writer = IOUtils.getBufferedWriter( outputDirectory+"/some_file" ) ) { @@ -70,7 +70,7 @@ void testFailureIfDirectoryExists() { catch ( RuntimeException e ) { return; } - Assert.fail( "no exception thrown when directory exists!" ); + Assertions.fail( "no exception thrown when directory exists!" ); } @Test @@ -84,9 +84,9 @@ void testOverrideIfDirectoryExists() { OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles, ControllerConfigGroup.CompressionType.none); - Assert.assertTrue( - "Directory was not created", - new File( outputDirectory ).exists() ); + Assertions.assertTrue( + new File( outputDirectory ).exists(), + "Directory was not created" ); // put something in the directory try ( final BufferedWriter writer = IOUtils.getBufferedWriter( outputDirectory+"/some_file" ) ) { @@ -102,9 +102,9 @@ void testOverrideIfDirectoryExists() { OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles, ControllerConfigGroup.CompressionType.none); - Assert.assertTrue( - "Directory was cleared", - new File( outputDirectory+"/some_file" ).exists() ); + Assertions.assertTrue( + new File( outputDirectory+"/some_file" ).exists(), + "Directory was cleared" ); } @@ -119,9 +119,9 @@ void testDeleteIfDirectoryExists() { OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists, ControllerConfigGroup.CompressionType.none); - Assert.assertTrue( - "Directory was not created", - new File( outputDirectory ).exists() ); + Assertions.assertTrue( + new File( outputDirectory ).exists(), + "Directory was not created" ); // put something in the directory try ( final BufferedWriter writer = IOUtils.getBufferedWriter( outputDirectory+"/some_file" ) ) { @@ -137,13 +137,13 @@ void testDeleteIfDirectoryExists() { OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists, ControllerConfigGroup.CompressionType.none); - Assert.assertTrue( - "Directory was deleted but not re-created!", - new File( outputDirectory ).exists() ); + Assertions.assertTrue( + new File( outputDirectory ).exists(), + "Directory was deleted but not re-created!" ); - Assert.assertFalse( - "Directory was not cleared", - new File( outputDirectory+"/some_file" ).exists() ); + Assertions.assertFalse( + new File( outputDirectory+"/some_file" ).exists(), + "Directory was not cleared" ); } } diff --git a/matsim/src/test/java/org/matsim/core/controler/OverrideCarTraveltimeTest.java b/matsim/src/test/java/org/matsim/core/controler/OverrideCarTraveltimeTest.java index ff00e8c4fac..941b7e749ee 100644 --- a/matsim/src/test/java/org/matsim/core/controler/OverrideCarTraveltimeTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/OverrideCarTraveltimeTest.java @@ -20,9 +20,7 @@ * *********************************************************************** */ package org.matsim.core.controler; - - -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; @@ -39,7 +37,7 @@ import jakarta.inject.Inject; import java.util.Map; -public class OverrideCarTraveltimeTest { + public class OverrideCarTraveltimeTest { public static void main(String[] args) { final Config config = ConfigUtils.createConfig(); @@ -94,8 +92,8 @@ private static class InterestingControlerListener implements ReplanningListener @Override public void notifyReplanning(ReplanningEvent event) { - Assert.assertEquals(42.0, travelTimes.get(TransportMode.car).getLinkTravelTime(null, 0.0, null, null), 0.0); - Assert.assertEquals(37.0, travelDisutilities.get(TransportMode.car).createTravelDisutility(travelTimes.get(TransportMode.car)).getLinkTravelDisutility(null, 0.0, null, null), 0.0); + Assertions.assertEquals(42.0, travelTimes.get(TransportMode.car).getLinkTravelTime(null, 0.0, null, null), 0.0); + Assertions.assertEquals(37.0, travelDisutilities.get(TransportMode.car).createTravelDisutility(travelTimes.get(TransportMode.car)).getLinkTravelDisutility(null, 0.0, null, null), 0.0); } } } diff --git a/matsim/src/test/java/org/matsim/core/controler/PrepareForSimImplTest.java b/matsim/src/test/java/org/matsim/core/controler/PrepareForSimImplTest.java index 582276839b3..424631dd064 100644 --- a/matsim/src/test/java/org/matsim/core/controler/PrepareForSimImplTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/PrepareForSimImplTest.java @@ -21,7 +21,7 @@ import java.util.*; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -102,8 +102,9 @@ void testSingleLegTripRoutingMode() { prepareForSimImpl.run(); - Assert.assertEquals("wrong routing mode!", TransportMode.pt, - TripStructureUtils.getRoutingMode(leg)); + Assertions.assertEquals(TransportMode.pt, + TripStructureUtils.getRoutingMode(leg), + "wrong routing mode!"); } // test routing mode set, such as after TripsToLegsAlgorithm + replanning strategy @@ -129,8 +130,9 @@ void testSingleLegTripRoutingMode() { prepareForSimImpl.run(); - Assert.assertEquals("wrong routing mode!", TransportMode.pt, - TripStructureUtils.getRoutingMode(leg)); + Assertions.assertEquals(TransportMode.pt, + TripStructureUtils.getRoutingMode(leg), + "wrong routing mode!"); } } @@ -165,9 +167,10 @@ void testSingleFallbackModeLegTrip() { prepareForSimImpl.run(); - Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg.getMode()); - Assert.assertEquals("wrong routing mode!", TransportMode.pt, - TripStructureUtils.getRoutingMode(leg)); + Assertions.assertEquals(TransportMode.walk, leg.getMode(), "wrong leg mode replacement!"); + Assertions.assertEquals(TransportMode.pt, + TripStructureUtils.getRoutingMode(leg), + "wrong routing mode!"); } // test outdated fallback mode single leg trip (arbitrary drt mode) @@ -193,9 +196,10 @@ void testSingleFallbackModeLegTrip() { prepareForSimImpl.run(); - Assert.assertEquals("wrong leg mode replacement", TransportMode.walk, leg.getMode()); - Assert.assertEquals("wrong routing mode!", "drt67", - TripStructureUtils.getRoutingMode(leg)); + Assertions.assertEquals(TransportMode.walk, leg.getMode(), "wrong leg mode replacement"); + Assertions.assertEquals("drt67", + TripStructureUtils.getRoutingMode(leg), + "wrong routing mode!"); } } @@ -242,14 +246,14 @@ void testCorrectTripsRemainUnchanged() { prepareForSimImpl.run(); // Check leg modes remain unchanged - Assert.assertEquals("wrong leg mode!", TransportMode.walk, leg1.getMode()); - Assert.assertEquals("wrong routing mode!", TransportMode.car, leg2.getMode()); - Assert.assertEquals("wrong leg mode!", TransportMode.walk, leg3.getMode()); + Assertions.assertEquals(TransportMode.walk, leg1.getMode(), "wrong leg mode!"); + Assertions.assertEquals(TransportMode.car, leg2.getMode(), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.walk, leg3.getMode(), "wrong leg mode!"); // Check routing mode: - Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg1)); - Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg2)); - Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg3)); + Assertions.assertEquals(TransportMode.car, TripStructureUtils.getRoutingMode(leg1), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.car, TripStructureUtils.getRoutingMode(leg2), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.car, TripStructureUtils.getRoutingMode(leg3), "wrong routing mode!"); } // test complicated intermodal trip with consistent routing modes passes unchanged @@ -339,29 +343,29 @@ void testCorrectTripsRemainUnchanged() { // TODO: Currently all TransportMode.non_network_walk legs are replaced by TransportMode.walk, so we cannot check // the correct handling of them right now. // Assert.assertEquals("wrong routing mode!", TransportMode.non_network_walk, leg1.getMode()); - Assert.assertEquals("wrong leg mode!", TransportMode.walk, leg2.getMode()); + Assertions.assertEquals(TransportMode.walk, leg2.getMode(), "wrong leg mode!"); // Assert.assertEquals("wrong routing mode!", TransportMode.non_network_walk, leg3.getMode()); - Assert.assertEquals("wrong leg mode!", TransportMode.drt, leg4.getMode()); + Assertions.assertEquals(TransportMode.drt, leg4.getMode(), "wrong leg mode!"); // Assert.assertEquals("wrong routing mode!", TransportMode.non_network_walk, leg5.getMode()); - Assert.assertEquals("wrong leg mode!", TransportMode.walk, leg6.getMode()); + Assertions.assertEquals(TransportMode.walk, leg6.getMode(), "wrong leg mode!"); // Assert.assertEquals("wrong routing mode!", TransportMode.non_network_walk, leg7.getMode()); - Assert.assertEquals("wrong leg mode!", TransportMode.pt, leg8.getMode()); + Assertions.assertEquals(TransportMode.pt, leg8.getMode(), "wrong leg mode!"); // Assert.assertEquals("wrong routing mode!", TransportMode.non_network_walk, leg9.getMode()); - Assert.assertEquals("wrong leg mode!", TransportMode.walk, leg10.getMode()); + Assertions.assertEquals(TransportMode.walk, leg10.getMode(), "wrong leg mode!"); // Assert.assertEquals("wrong routing mode!", TransportMode.non_network_walk, leg11.getMode()); // Check routing mode remains unchanged - Assert.assertEquals("wrong routing mode!", "intermodal pt", TripStructureUtils.getRoutingMode(leg1)); - Assert.assertEquals("wrong routing mode!", "intermodal pt", TripStructureUtils.getRoutingMode(leg2)); - Assert.assertEquals("wrong routing mode!", "intermodal pt", TripStructureUtils.getRoutingMode(leg3)); - Assert.assertEquals("wrong routing mode!", "intermodal pt", TripStructureUtils.getRoutingMode(leg4)); - Assert.assertEquals("wrong routing mode!", "intermodal pt", TripStructureUtils.getRoutingMode(leg5)); - Assert.assertEquals("wrong routing mode!", "intermodal pt", TripStructureUtils.getRoutingMode(leg6)); - Assert.assertEquals("wrong routing mode!", "intermodal pt", TripStructureUtils.getRoutingMode(leg7)); - Assert.assertEquals("wrong routing mode!", "intermodal pt", TripStructureUtils.getRoutingMode(leg8)); - Assert.assertEquals("wrong routing mode!", "intermodal pt", TripStructureUtils.getRoutingMode(leg9)); - Assert.assertEquals("wrong routing mode!", "intermodal pt", TripStructureUtils.getRoutingMode(leg10)); - Assert.assertEquals("wrong routing mode!", "intermodal pt", TripStructureUtils.getRoutingMode(leg11)); + Assertions.assertEquals("intermodal pt", TripStructureUtils.getRoutingMode(leg1), "wrong routing mode!"); + Assertions.assertEquals("intermodal pt", TripStructureUtils.getRoutingMode(leg2), "wrong routing mode!"); + Assertions.assertEquals("intermodal pt", TripStructureUtils.getRoutingMode(leg3), "wrong routing mode!"); + Assertions.assertEquals("intermodal pt", TripStructureUtils.getRoutingMode(leg4), "wrong routing mode!"); + Assertions.assertEquals("intermodal pt", TripStructureUtils.getRoutingMode(leg5), "wrong routing mode!"); + Assertions.assertEquals("intermodal pt", TripStructureUtils.getRoutingMode(leg6), "wrong routing mode!"); + Assertions.assertEquals("intermodal pt", TripStructureUtils.getRoutingMode(leg7), "wrong routing mode!"); + Assertions.assertEquals("intermodal pt", TripStructureUtils.getRoutingMode(leg8), "wrong routing mode!"); + Assertions.assertEquals("intermodal pt", TripStructureUtils.getRoutingMode(leg9), "wrong routing mode!"); + Assertions.assertEquals("intermodal pt", TripStructureUtils.getRoutingMode(leg10), "wrong routing mode!"); + Assertions.assertEquals("intermodal pt", TripStructureUtils.getRoutingMode(leg11), "wrong routing mode!"); } } @@ -406,7 +410,7 @@ void testRoutingModeConsistency() { config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); prepareForSimImpl.run(); - Assert.fail("expected Exception, got none."); + Assertions.fail("expected Exception, got none."); } catch (RuntimeException expected) {} } @@ -443,7 +447,7 @@ void testRoutingModeConsistency() { config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); prepareForSimImpl.run(); - Assert.fail("expected Exception, got none."); + Assertions.fail("expected Exception, got none."); } catch (RuntimeException expected) {} } } @@ -492,7 +496,7 @@ void testOutdatedHelperModesReplacement() { config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); prepareForSimImpl.run(); - Assert.fail("expected Exception, got none."); + Assertions.fail("expected Exception, got none."); } catch (RuntimeException expected) {} // Should work with config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier); @@ -504,14 +508,14 @@ void testOutdatedHelperModesReplacement() { prepareForSimImpl.run(); // Check replacement of outdated helper modes. - Assert.assertEquals("wrong leg mode!", TransportMode.walk, leg1.getMode()); - Assert.assertEquals("wrong leg mode!", TransportMode.car, leg2.getMode()); - Assert.assertEquals("wrong leg mode!", TransportMode.walk, leg3.getMode()); + Assertions.assertEquals(TransportMode.walk, leg1.getMode(), "wrong leg mode!"); + Assertions.assertEquals(TransportMode.car, leg2.getMode(), "wrong leg mode!"); + Assertions.assertEquals(TransportMode.walk, leg3.getMode(), "wrong leg mode!"); // Check routing mode: - Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg1)); - Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg2)); - Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg3)); + Assertions.assertEquals(TransportMode.car, TripStructureUtils.getRoutingMode(leg1), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.car, TripStructureUtils.getRoutingMode(leg2), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.car, TripStructureUtils.getRoutingMode(leg3), "wrong routing mode!"); } // test car trip with outdated access/egress walk modes @@ -550,7 +554,7 @@ void testOutdatedHelperModesReplacement() { config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); prepareForSimImpl.run(); - Assert.fail("expected Exception, got none."); + Assertions.fail("expected Exception, got none."); } catch (RuntimeException expected) {} // Should work with config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier); @@ -562,14 +566,14 @@ void testOutdatedHelperModesReplacement() { prepareForSimImpl.run(); // Check replacement of outdated helper modes. - Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg1.getMode()); - Assert.assertEquals("wrong leg mode!", TransportMode.car, leg2.getMode()); - Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg3.getMode()); + Assertions.assertEquals(TransportMode.walk, leg1.getMode(), "wrong leg mode replacement!"); + Assertions.assertEquals(TransportMode.car, leg2.getMode(), "wrong leg mode!"); + Assertions.assertEquals(TransportMode.walk, leg3.getMode(), "wrong leg mode replacement!"); // Check routing mode: - Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg1)); - Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg2)); - Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg3)); + Assertions.assertEquals(TransportMode.car, TripStructureUtils.getRoutingMode(leg1), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.car, TripStructureUtils.getRoutingMode(leg2), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.car, TripStructureUtils.getRoutingMode(leg3), "wrong routing mode!"); } // test complicated intermodal drt+pt trip with outdated access/egress walk modes @@ -632,7 +636,7 @@ void testOutdatedHelperModesReplacement() { config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); prepareForSimImpl.run(); - Assert.fail("expected Exception, got none."); + Assertions.fail("expected Exception, got none."); } catch (RuntimeException expected) {} // Should work with config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier); @@ -644,13 +648,13 @@ void testOutdatedHelperModesReplacement() { prepareForSimImpl.run(); // Check replacement of outdated helper modes. - Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg1.getMode()); - Assert.assertEquals("wrong leg mode!", TransportMode.drt, leg2.getMode()); - Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg3.getMode()); - Assert.assertEquals("wrong leg mode!", TransportMode.pt, leg4.getMode()); - Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg5.getMode()); - Assert.assertEquals("wrong leg mode!", TransportMode.pt, leg6.getMode()); - Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg7.getMode()); + Assertions.assertEquals(TransportMode.walk, leg1.getMode(), "wrong leg mode replacement!"); + Assertions.assertEquals(TransportMode.drt, leg2.getMode(), "wrong leg mode!"); + Assertions.assertEquals(TransportMode.walk, leg3.getMode(), "wrong leg mode replacement!"); + Assertions.assertEquals(TransportMode.pt, leg4.getMode(), "wrong leg mode!"); + Assertions.assertEquals(TransportMode.walk, leg5.getMode(), "wrong leg mode replacement!"); + Assertions.assertEquals(TransportMode.pt, leg6.getMode(), "wrong leg mode!"); + Assertions.assertEquals(TransportMode.walk, leg7.getMode(), "wrong leg mode replacement!"); /* * Check routing mode: @@ -661,13 +665,13 @@ void testOutdatedHelperModesReplacement() { * For the scope of this test it is sufficient, that the MainModeIdentifier is run, returns a main mode * and that this main mode is assigned as routingMode to all legs. */ - Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg1)); - Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg2)); - Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg3)); - Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg4)); - Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg5)); - Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg6)); - Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg7)); + Assertions.assertEquals(TransportMode.drt, TripStructureUtils.getRoutingMode(leg1), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.drt, TripStructureUtils.getRoutingMode(leg2), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.drt, TripStructureUtils.getRoutingMode(leg3), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.drt, TripStructureUtils.getRoutingMode(leg4), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.drt, TripStructureUtils.getRoutingMode(leg5), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.drt, TripStructureUtils.getRoutingMode(leg6), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.drt, TripStructureUtils.getRoutingMode(leg7), "wrong routing mode!"); } } @@ -727,7 +731,7 @@ void testOutdatedFallbackAndHelperModesReplacement() { config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); prepareForSimImpl.run(); - Assert.fail("expected Exception, got none."); + Assertions.fail("expected Exception, got none."); } catch (RuntimeException expected) {} // Should work with config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier); @@ -739,11 +743,11 @@ void testOutdatedFallbackAndHelperModesReplacement() { prepareForSimImpl.run(); // Check replacement of outdated helper modes. - Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg1.getMode()); - Assert.assertEquals("wrong leg mode!", TransportMode.drt, leg2.getMode()); - Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg3.getMode()); - Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg4.getMode()); - Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg5.getMode()); + Assertions.assertEquals(TransportMode.walk, leg1.getMode(), "wrong leg mode replacement!"); + Assertions.assertEquals(TransportMode.drt, leg2.getMode(), "wrong leg mode!"); + Assertions.assertEquals(TransportMode.walk, leg3.getMode(), "wrong leg mode replacement!"); + Assertions.assertEquals(TransportMode.walk, leg4.getMode(), "wrong leg mode replacement!"); + Assertions.assertEquals(TransportMode.walk, leg5.getMode(), "wrong leg mode replacement!"); /* * Check routing mode: @@ -754,11 +758,11 @@ void testOutdatedFallbackAndHelperModesReplacement() { * For the scope of thios test it is sufficient, that the MainModeIdentifier is run, returns a main mode * and that this main mode is assigned as routingMode to all legs. */ - Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg1)); - Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg2)); - Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg3)); - Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg4)); - Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg5)); + Assertions.assertEquals(TransportMode.drt, TripStructureUtils.getRoutingMode(leg1), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.drt, TripStructureUtils.getRoutingMode(leg2), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.drt, TripStructureUtils.getRoutingMode(leg3), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.drt, TripStructureUtils.getRoutingMode(leg4), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.drt, TripStructureUtils.getRoutingMode(leg5), "wrong routing mode!"); } } diff --git a/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java b/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java index cd9a12401fe..bf276c9c0b6 100644 --- a/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java @@ -2,7 +2,7 @@ import java.io.File; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -37,24 +37,24 @@ public class TerminationTest { void testSimulationEndsOnInterval() { prepareExperiment(2, 4, ControllerConfigGroup.CleanIterations.keep).run(); - Assert.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.4/4.events.xml.gz").exists()); - Assert.assertTrue(new File(utils.getOutputDirectory(), "/output_events.xml.gz").exists()); + Assertions.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.4/4.events.xml.gz").exists()); + Assertions.assertTrue(new File(utils.getOutputDirectory(), "/output_events.xml.gz").exists()); long iterationOutput = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + "/ITERS/it.4/4.events.xml.gz"); long mainOutput = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + "/output_events.xml.gz"); - Assert.assertEquals(iterationOutput, mainOutput); + Assertions.assertEquals(iterationOutput, mainOutput); } @Test void testOnlyRunIterationZero() { prepareExperiment(2, 0, ControllerConfigGroup.CleanIterations.keep).run(); - Assert.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.0/0.events.xml.gz").exists()); - Assert.assertTrue(new File(utils.getOutputDirectory(), "/output_events.xml.gz").exists()); + Assertions.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.0/0.events.xml.gz").exists()); + Assertions.assertTrue(new File(utils.getOutputDirectory(), "/output_events.xml.gz").exists()); long iterationOutput = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + "/ITERS/it.0/0.events.xml.gz"); long mainOutput = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + "/output_events.xml.gz"); - Assert.assertEquals(iterationOutput, mainOutput); + Assertions.assertEquals(iterationOutput, mainOutput); } @Test @@ -64,19 +64,19 @@ void testSimulationEndsOffInterval() { prepareExperiment(2, 3, ControllerConfigGroup.CleanIterations.keep).run(); - Assert.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.2/2.events.xml.gz").exists()); - Assert.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.3/3.events.xml.gz").exists()); - Assert.assertTrue(new File(utils.getOutputDirectory(), "/output_events.xml.gz").exists()); + Assertions.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.2/2.events.xml.gz").exists()); + Assertions.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.3/3.events.xml.gz").exists()); + Assertions.assertTrue(new File(utils.getOutputDirectory(), "/output_events.xml.gz").exists()); long iterationOutput = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + "/ITERS/it.3/3.events.xml.gz"); long mainOutput = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + "/output_events.xml.gz"); - Assert.assertEquals(iterationOutput, mainOutput); + Assertions.assertEquals(iterationOutput, mainOutput); } @Test void testSimulationEndDeleteIters() { prepareExperiment(2, 3, ControllerConfigGroup.CleanIterations.delete).run(); - Assert.assertFalse(new File(utils.getOutputDirectory(), "/ITERS").exists()); + Assertions.assertFalse(new File(utils.getOutputDirectory(), "/ITERS").exists()); } private Controler prepareExperiment(int interval, int criterion, ControllerConfigGroup.CleanIterations iters) { @@ -114,14 +114,14 @@ public boolean doTerminate(int iteration) { controller.run(); - Assert.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.2/2.events.xml.gz").exists()); - Assert.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.3/3.events.xml.gz").exists()); - Assert.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.4/4.events.xml.gz").exists()); - Assert.assertTrue(new File(utils.getOutputDirectory(), "/output_events.xml.gz").exists()); + Assertions.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.2/2.events.xml.gz").exists()); + Assertions.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.3/3.events.xml.gz").exists()); + Assertions.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.4/4.events.xml.gz").exists()); + Assertions.assertTrue(new File(utils.getOutputDirectory(), "/output_events.xml.gz").exists()); long iterationOutput = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + "/ITERS/it.4/4.events.xml.gz"); long mainOutput = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + "/output_events.xml.gz"); - Assert.assertEquals(iterationOutput, mainOutput); + Assertions.assertEquals(iterationOutput, mainOutput); } @Test @@ -170,14 +170,14 @@ public void install() { controler.run(); - Assert.assertEquals(12, (int) controler.getIterationNumber()); + Assertions.assertEquals(12, (int) controler.getIterationNumber()); - Assert.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.12/12.events.xml.gz").exists()); - Assert.assertTrue(new File(utils.getOutputDirectory(), "/output_events.xml.gz").exists()); + Assertions.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.12/12.events.xml.gz").exists()); + Assertions.assertTrue(new File(utils.getOutputDirectory(), "/output_events.xml.gz").exists()); long iterationOutput = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + "/ITERS/it.12/12.events.xml.gz"); long mainOutput = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + "/output_events.xml.gz"); - Assert.assertEquals(iterationOutput, mainOutput); + Assertions.assertEquals(iterationOutput, mainOutput); } @Singleton diff --git a/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java b/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java index c2be0f5b584..10d912cfe9d 100644 --- a/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java @@ -20,12 +20,12 @@ package org.matsim.core.controler; -import static org.junit.Assert.assertEquals; - import java.util.ArrayList; import java.util.Collections; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; diff --git a/matsim/src/test/java/org/matsim/core/controler/corelisteners/ListenersInjectionTest.java b/matsim/src/test/java/org/matsim/core/controler/corelisteners/ListenersInjectionTest.java index bf569a37ec6..a7d15e09856 100644 --- a/matsim/src/test/java/org/matsim/core/controler/corelisteners/ListenersInjectionTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/corelisteners/ListenersInjectionTest.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.core.controler.corelisteners; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.analysis.IterationStopWatch; @@ -98,10 +98,10 @@ public void install() { final ControlerListener o1 = injector.getInstance( klass ); final ControlerListener o2 = injector.getInstance( klass ); - Assert.assertSame( - "Two different instances of "+klass.getName()+" returned by injector!", + Assertions.assertSame( o1, - o2 ); + o2, + "Two different instances of "+klass.getName()+" returned by injector!" ); } } diff --git a/matsim/src/test/java/org/matsim/core/controler/corelisteners/PlansDumpingIT.java b/matsim/src/test/java/org/matsim/core/controler/corelisteners/PlansDumpingIT.java index a686c394e77..e1c992d5e45 100644 --- a/matsim/src/test/java/org/matsim/core/controler/corelisteners/PlansDumpingIT.java +++ b/matsim/src/test/java/org/matsim/core/controler/corelisteners/PlansDumpingIT.java @@ -27,8 +27,8 @@ import java.io.File; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author mrieser diff --git a/matsim/src/test/java/org/matsim/core/events/ActEndEventTest.java b/matsim/src/test/java/org/matsim/core/events/ActEndEventTest.java index fe6e6f93cef..b81e448daa3 100644 --- a/matsim/src/test/java/org/matsim/core/events/ActEndEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/ActEndEventTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/events/ActStartEventTest.java b/matsim/src/test/java/org/matsim/core/events/ActStartEventTest.java index c0a64d343d4..ec074cd0fd7 100644 --- a/matsim/src/test/java/org/matsim/core/events/ActStartEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/ActStartEventTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/events/AgentMoneyEventTest.java b/matsim/src/test/java/org/matsim/core/events/AgentMoneyEventTest.java index b0645c6f797..219d9fcec2d 100644 --- a/matsim/src/test/java/org/matsim/core/events/AgentMoneyEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/AgentMoneyEventTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/events/AgentWaitingForPtEventTest.java b/matsim/src/test/java/org/matsim/core/events/AgentWaitingForPtEventTest.java index 0bc24ebe510..b25eafec20c 100644 --- a/matsim/src/test/java/org/matsim/core/events/AgentWaitingForPtEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/AgentWaitingForPtEventTest.java @@ -19,7 +19,7 @@ package org.matsim.core.events; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -44,10 +44,10 @@ void testReadWriteXml() { double time = 5.0 * 3600 + 11.0 + 60; AgentWaitingForPtEvent event = new AgentWaitingForPtEvent(time, person.getId(), waitStopId, destinationStopId); AgentWaitingForPtEvent event2 = XmlEventsTester.testWriteReadXml(helper.getOutputDirectory() + "events.xml", event); - Assert.assertEquals("wrong time of event.", time, event2.getTime(), 1e-8); - Assert.assertEquals("1", event2.getPersonId().toString()); - Assert.assertEquals("1980", event2.getWaitingAtStopId().toString()); - Assert.assertEquals("0511", event2.getDestinationStopId().toString()); + Assertions.assertEquals(time, event2.getTime(), 1e-8, "wrong time of event."); + Assertions.assertEquals("1", event2.getPersonId().toString()); + Assertions.assertEquals("1980", event2.getWaitingAtStopId().toString()); + Assertions.assertEquals("0511", event2.getDestinationStopId().toString()); } } diff --git a/matsim/src/test/java/org/matsim/core/events/BasicEventsHandlerTest.java b/matsim/src/test/java/org/matsim/core/events/BasicEventsHandlerTest.java index 86fd56add98..8ef75877488 100644 --- a/matsim/src/test/java/org/matsim/core/events/BasicEventsHandlerTest.java +++ b/matsim/src/test/java/org/matsim/core/events/BasicEventsHandlerTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -61,7 +61,7 @@ void testLinkEnterEventHandler() { events.processEvent(new LinkEnterEvent(8.0*3600, Id.create("veh", Vehicle.class), link1.getId())); events.finishProcessing(); - assertEquals("expected number of handled events wrong.", 1, handler.counter); + assertEquals(1, handler.counter, "expected number of handled events wrong."); } diff --git a/matsim/src/test/java/org/matsim/core/events/CustomEventTest.java b/matsim/src/test/java/org/matsim/core/events/CustomEventTest.java index bee022f3d97..c7501de96e7 100644 --- a/matsim/src/test/java/org/matsim/core/events/CustomEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/CustomEventTest.java @@ -28,7 +28,7 @@ import java.util.ArrayList; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.Event; @@ -100,12 +100,12 @@ public void reset(int iteration) { Id.createPersonId(event.getAttributes().get("person")))); eventsReaderXMLv1.parse(new ByteArrayInputStream(buf)); eventsManager2.finishProcessing(); - Assert.assertEquals(1, oneEvent.size()); + Assertions.assertEquals(1, oneEvent.size()); Event event = oneEvent.get(0); - Assert.assertTrue(event instanceof RainOnPersonEvent); + Assertions.assertTrue(event instanceof RainOnPersonEvent); RainOnPersonEvent ropEvent = ((RainOnPersonEvent)event); - Assert.assertEquals(0.0, ropEvent.getTime(), 1e-7); - Assert.assertEquals(Id.createPersonId("wurst"), ropEvent.getPersonId()); + Assertions.assertEquals(0.0, ropEvent.getTime(), 1e-7); + Assertions.assertEquals(Id.createPersonId("wurst"), ropEvent.getPersonId()); } @Test @@ -139,12 +139,12 @@ public void reset(int iteration) { Id.createPersonId(event.getAttributes().get("person")))); eventsReader.parse(new ByteArrayInputStream(buf)); eventsManager2.finishProcessing(); - Assert.assertEquals(1, oneEvent.size()); + Assertions.assertEquals(1, oneEvent.size()); Event event = oneEvent.get(0); - Assert.assertTrue(event instanceof RainOnPersonEvent); + Assertions.assertTrue(event instanceof RainOnPersonEvent); RainOnPersonEvent ropEvent = ((RainOnPersonEvent)event); - Assert.assertEquals(0.0, ropEvent.getTime(), 1e-7); - Assert.assertEquals(Id.createPersonId("wurst"), ropEvent.getPersonId()); + Assertions.assertEquals(0.0, ropEvent.getTime(), 1e-7); + Assertions.assertEquals(Id.createPersonId("wurst"), ropEvent.getPersonId()); } } diff --git a/matsim/src/test/java/org/matsim/core/events/EventsHandlerHierarchyTest.java b/matsim/src/test/java/org/matsim/core/events/EventsHandlerHierarchyTest.java index 7bbdfa343bc..34d55f8b32d 100644 --- a/matsim/src/test/java/org/matsim/core/events/EventsHandlerHierarchyTest.java +++ b/matsim/src/test/java/org/matsim/core/events/EventsHandlerHierarchyTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/events/EventsManagerImplTest.java b/matsim/src/test/java/org/matsim/core/events/EventsManagerImplTest.java index 0ea80ab3d12..157a0c73db1 100644 --- a/matsim/src/test/java/org/matsim/core/events/EventsManagerImplTest.java +++ b/matsim/src/test/java/org/matsim/core/events/EventsManagerImplTest.java @@ -21,7 +21,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.events.Event; import org.matsim.core.api.experimental.events.EventsManager; @@ -45,7 +45,7 @@ void testProcessEvent_CustomEventHandler() { manager.initProcessing(); manager.processEvent(new MyEvent(123.45)); manager.finishProcessing(); - Assert.assertEquals("EventHandler was not called.", 1, handler.counter); + Assertions.assertEquals(1, handler.counter, "EventHandler was not called."); } /** @@ -60,12 +60,12 @@ void testProcessEvent_ExceptionInEventHandler() { try { manager.processEvent(new MyEvent(123.45)); manager.finishProcessing(); - Assert.fail("expected exception, but got none."); + Assertions.fail("expected exception, but got none."); } catch (final RuntimeException e) { log.info("Catched expected exception.", e); - Assert.assertEquals(1, handler.counter); - Assert.assertTrue(e.getCause() instanceof ArithmeticException); + Assertions.assertEquals(1, handler.counter); + Assertions.assertTrue(e.getCause() instanceof ArithmeticException); } } diff --git a/matsim/src/test/java/org/matsim/core/events/EventsReadersTest.java b/matsim/src/test/java/org/matsim/core/events/EventsReadersTest.java index ca1a804be6d..3bbf1a1626a 100644 --- a/matsim/src/test/java/org/matsim/core/events/EventsReadersTest.java +++ b/matsim/src/test/java/org/matsim/core/events/EventsReadersTest.java @@ -20,13 +20,13 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; - import java.io.IOException; import javax.xml.parsers.ParserConfigurationException; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; @@ -72,7 +72,7 @@ public void reset(final int iteration) { @Override public void handleEvent(final ActivityEndEvent event) { this.eventCounter++; - assertEquals("expected activity-End-Event to be event #1", 1, this.eventCounter); + assertEquals(1, this.eventCounter, "expected activity-End-Event to be event #1"); assertEquals(21610.0, event.getTime(), 0.0); assertEquals("1", event.getPersonId().toString()); assertEquals(Id.create("2", Link.class), event.getLinkId()); @@ -81,7 +81,7 @@ public void handleEvent(final ActivityEndEvent event) { @Override public void handleEvent(final PersonDepartureEvent event) { this.eventCounter++; - assertEquals("expected agentDeparture-Event to be event #2", 2, this.eventCounter); + assertEquals(2, this.eventCounter, "expected agentDeparture-Event to be event #2"); assertEquals(21620.0, event.getTime(), 0.0); assertEquals("2", event.getPersonId().toString()); assertEquals("3", event.getLinkId().toString()); @@ -90,7 +90,7 @@ public void handleEvent(final PersonDepartureEvent event) { @Override public void handleEvent(final VehicleEntersTrafficEvent event) { this.eventCounter++; - assertEquals("expected wait2link-Event to be event #3", 3, this.eventCounter); + assertEquals(3, this.eventCounter, "expected wait2link-Event to be event #3"); assertEquals(21630.0, event.getTime(), 0.0); assertEquals("3", event.getPersonId().toString()); assertEquals("4", event.getLinkId().toString()); @@ -99,7 +99,7 @@ public void handleEvent(final VehicleEntersTrafficEvent event) { @Override public void handleEvent(final LinkLeaveEvent event) { this.eventCounter++; - assertEquals("expected linkleave-Event to be event #4", 4, this.eventCounter); + assertEquals(4, this.eventCounter, "expected linkleave-Event to be event #4"); assertEquals(21640.0, event.getTime(), 0.0); assertEquals("4", event.getVehicleId().toString()); assertEquals("5", event.getLinkId().toString()); @@ -108,7 +108,7 @@ public void handleEvent(final LinkLeaveEvent event) { @Override public void handleEvent(final LinkEnterEvent event) { this.eventCounter++; - assertEquals("expected linkleave-Event to be event #5", 5, this.eventCounter); + assertEquals(5, this.eventCounter, "expected linkleave-Event to be event #5"); assertEquals(21650.0, event.getTime(), 0.0); assertEquals("5", event.getVehicleId().toString()); assertEquals("6", event.getLinkId().toString()); @@ -117,7 +117,7 @@ public void handleEvent(final LinkEnterEvent event) { @Override public void handleEvent(final PersonArrivalEvent event) { this.eventCounter++; - assertEquals("expected agentArrival-Event to be event #6", 6, this.eventCounter); + assertEquals(6, this.eventCounter, "expected agentArrival-Event to be event #6"); assertEquals(21660.0, event.getTime(), 0.0); assertEquals("6", event.getPersonId().toString()); assertEquals("7", event.getLinkId().toString()); @@ -126,7 +126,7 @@ public void handleEvent(final PersonArrivalEvent event) { @Override public void handleEvent(final ActivityStartEvent event) { this.eventCounter++; - assertEquals("expected activityStart-Event to be event #7", 7, this.eventCounter); + assertEquals(7, this.eventCounter, "expected activityStart-Event to be event #7"); assertEquals(21670.0, event.getTime(), 0.0); assertEquals("7", event.getPersonId().toString()); assertEquals(Id.create("8", Link.class), event.getLinkId()); @@ -135,7 +135,7 @@ public void handleEvent(final ActivityStartEvent event) { @Override public void handleEvent(final PersonStuckEvent event) { this.eventCounter++; - assertEquals("expected agentStuck-Event to be event #8", 8, this.eventCounter); + assertEquals(8, this.eventCounter, "expected agentStuck-Event to be event #8"); assertEquals(21680.0, event.getTime(), 0.0); assertEquals("8", event.getPersonId().toString()); assertEquals("9", event.getLinkId().toString()); @@ -152,7 +152,7 @@ final void testXmlReader() throws SAXException, ParserConfigurationException, IO EventsReaderXMLv1 reader = new EventsReaderXMLv1(events); reader.readFile(utils.getClassInputDirectory() + "events.xml"); events.finishProcessing(); - assertEquals("number of read events", 8, handler.eventCounter); + assertEquals(8, handler.eventCounter, "number of read events"); } @Test @@ -164,6 +164,6 @@ final void testAutoFormatReaderXml() { MatsimEventsReader reader = new MatsimEventsReader(events); reader.readFile(utils.getClassInputDirectory() + "events.xml"); events.finishProcessing(); - assertEquals("number of read events", 8, handler.eventCounter); + assertEquals(8, handler.eventCounter, "number of read events"); } } diff --git a/matsim/src/test/java/org/matsim/core/events/GenericEventTest.java b/matsim/src/test/java/org/matsim/core/events/GenericEventTest.java index 705c6e08aff..bee56a1098e 100644 --- a/matsim/src/test/java/org/matsim/core/events/GenericEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/GenericEventTest.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/events/LinkEnterEventTest.java b/matsim/src/test/java/org/matsim/core/events/LinkEnterEventTest.java index 7a400077bce..9fc85975063 100644 --- a/matsim/src/test/java/org/matsim/core/events/LinkEnterEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/LinkEnterEventTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/events/LinkLeaveEventTest.java b/matsim/src/test/java/org/matsim/core/events/LinkLeaveEventTest.java index 7a9f373ed82..a8a66112726 100644 --- a/matsim/src/test/java/org/matsim/core/events/LinkLeaveEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/LinkLeaveEventTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/events/ParallelEventsManagerTest.java b/matsim/src/test/java/org/matsim/core/events/ParallelEventsManagerTest.java index 373075691ec..24ce9763e4c 100644 --- a/matsim/src/test/java/org/matsim/core/events/ParallelEventsManagerTest.java +++ b/matsim/src/test/java/org/matsim/core/events/ParallelEventsManagerTest.java @@ -5,8 +5,8 @@ import org.matsim.api.core.v01.events.Event; import org.matsim.core.api.experimental.events.EventsManager; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class ParallelEventsManagerTest { diff --git a/matsim/src/test/java/org/matsim/core/events/PersonArrivalEventTest.java b/matsim/src/test/java/org/matsim/core/events/PersonArrivalEventTest.java index 60110acc6ce..81670a0a2bb 100644 --- a/matsim/src/test/java/org/matsim/core/events/PersonArrivalEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/PersonArrivalEventTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/events/PersonDepartureEventTest.java b/matsim/src/test/java/org/matsim/core/events/PersonDepartureEventTest.java index f1372da2f07..60bca5c85e4 100644 --- a/matsim/src/test/java/org/matsim/core/events/PersonDepartureEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/PersonDepartureEventTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/events/PersonEntersVehicleEventTest.java b/matsim/src/test/java/org/matsim/core/events/PersonEntersVehicleEventTest.java index 849a0f7878e..30dd6163dca 100644 --- a/matsim/src/test/java/org/matsim/core/events/PersonEntersVehicleEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/PersonEntersVehicleEventTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -49,7 +49,7 @@ void testReadWriteXml() { Vehicle vehicle = VehicleUtils.createVehicle(Id.create(80, Vehicle.class ), vehicleType ); PersonEntersVehicleEvent event = new PersonEntersVehicleEvent(5.0 * 3600 + 11.0 * 60, person.getId(), vehicle.getId()); PersonEntersVehicleEvent event2 = XmlEventsTester.testWriteReadXml(utils.getOutputDirectory() + "events.xml", event); - assertEquals("wrong time of event.", 5.0 * 3600 + 11.0 * 60, event2.getTime(), MatsimTestUtils.EPSILON); - assertEquals("wrong vehicle id.", "80", event2.getVehicleId().toString()); + assertEquals(5.0 * 3600 + 11.0 * 60, event2.getTime(), MatsimTestUtils.EPSILON, "wrong time of event."); + assertEquals("80", event2.getVehicleId().toString(), "wrong vehicle id."); } } diff --git a/matsim/src/test/java/org/matsim/core/events/PersonLeavesVehicleEventTest.java b/matsim/src/test/java/org/matsim/core/events/PersonLeavesVehicleEventTest.java index 867624642ad..760dbebf652 100644 --- a/matsim/src/test/java/org/matsim/core/events/PersonLeavesVehicleEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/PersonLeavesVehicleEventTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -49,7 +49,7 @@ void testWriteReadXml() { Vehicle vehicle = VehicleUtils.createVehicle(Id.create(80, Vehicle.class ), vehicleType ); PersonLeavesVehicleEvent event = new PersonLeavesVehicleEvent(5.0 * 3600 + 11.0 * 60, person.getId(), vehicle.getId()); PersonLeavesVehicleEvent event2 = XmlEventsTester.testWriteReadXml(utils.getOutputDirectory() + "events.xml", event); - assertEquals("wrong time of event.", 5.0 * 3600 + 11.0 * 60, event2.getTime(), MatsimTestUtils.EPSILON); - assertEquals("wrong vehicle id.", "80", event2.getVehicleId().toString()); + assertEquals(5.0 * 3600 + 11.0 * 60, event2.getTime(), MatsimTestUtils.EPSILON, "wrong time of event."); + assertEquals("80", event2.getVehicleId().toString(), "wrong vehicle id."); } } diff --git a/matsim/src/test/java/org/matsim/core/events/PersonStuckEventTest.java b/matsim/src/test/java/org/matsim/core/events/PersonStuckEventTest.java index b17e124d471..f4511932195 100644 --- a/matsim/src/test/java/org/matsim/core/events/PersonStuckEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/PersonStuckEventTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/events/TransitDriverStartsEventTest.java b/matsim/src/test/java/org/matsim/core/events/TransitDriverStartsEventTest.java index 37d6156086e..c877308fdf4 100644 --- a/matsim/src/test/java/org/matsim/core/events/TransitDriverStartsEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/TransitDriverStartsEventTest.java @@ -19,7 +19,7 @@ package org.matsim.core.events; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -47,11 +47,11 @@ void testWriteReadXml() { Id.create("route-R1", TransitRoute.class), Id.create("departure-D-1", Departure.class)); final TransitDriverStartsEvent event2 = XmlEventsTester.testWriteReadXml(this.utils.getOutputDirectory() + "events.xml", event1); - Assert.assertEquals(event1.getTime(), event2.getTime(), 1.0e-9); - Assert.assertEquals(event1.getDriverId(), event2.getDriverId()); - Assert.assertEquals(event1.getVehicleId(), event2.getVehicleId()); - Assert.assertEquals(event1.getTransitRouteId(), event2.getTransitRouteId()); - Assert.assertEquals(event1.getTransitLineId(), event2.getTransitLineId()); - Assert.assertEquals(event1.getDepartureId(), event2.getDepartureId()); + Assertions.assertEquals(event1.getTime(), event2.getTime(), 1.0e-9); + Assertions.assertEquals(event1.getDriverId(), event2.getDriverId()); + Assertions.assertEquals(event1.getVehicleId(), event2.getVehicleId()); + Assertions.assertEquals(event1.getTransitRouteId(), event2.getTransitRouteId()); + Assertions.assertEquals(event1.getTransitLineId(), event2.getTransitLineId()); + Assertions.assertEquals(event1.getDepartureId(), event2.getDepartureId()); } } diff --git a/matsim/src/test/java/org/matsim/core/events/VehicleAbortsEventTest.java b/matsim/src/test/java/org/matsim/core/events/VehicleAbortsEventTest.java index 15d82589b79..6d62b155c7f 100644 --- a/matsim/src/test/java/org/matsim/core/events/VehicleAbortsEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/VehicleAbortsEventTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/events/VehicleArrivesAtFacilityEventImplTest.java b/matsim/src/test/java/org/matsim/core/events/VehicleArrivesAtFacilityEventImplTest.java index 26d0fa561f8..163cd012116 100644 --- a/matsim/src/test/java/org/matsim/core/events/VehicleArrivesAtFacilityEventImplTest.java +++ b/matsim/src/test/java/org/matsim/core/events/VehicleArrivesAtFacilityEventImplTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/events/VehicleDepartsAtFacilityEventImplTest.java b/matsim/src/test/java/org/matsim/core/events/VehicleDepartsAtFacilityEventImplTest.java index 11e414b40f2..d5c92b87340 100644 --- a/matsim/src/test/java/org/matsim/core/events/VehicleDepartsAtFacilityEventImplTest.java +++ b/matsim/src/test/java/org/matsim/core/events/VehicleDepartsAtFacilityEventImplTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/events/VehicleEntersTrafficEventTest.java b/matsim/src/test/java/org/matsim/core/events/VehicleEntersTrafficEventTest.java index af9686b35bc..20bbccf116e 100644 --- a/matsim/src/test/java/org/matsim/core/events/VehicleEntersTrafficEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/VehicleEntersTrafficEventTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/events/VehicleLeavesTrafficEventTest.java b/matsim/src/test/java/org/matsim/core/events/VehicleLeavesTrafficEventTest.java index 7428df475b5..78269929392 100644 --- a/matsim/src/test/java/org/matsim/core/events/VehicleLeavesTrafficEventTest.java +++ b/matsim/src/test/java/org/matsim/core/events/VehicleLeavesTrafficEventTest.java @@ -20,7 +20,7 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/events/XmlEventsTester.java b/matsim/src/test/java/org/matsim/core/events/XmlEventsTester.java index 2fb45c2ff5a..c68271864bd 100644 --- a/matsim/src/test/java/org/matsim/core/events/XmlEventsTester.java +++ b/matsim/src/test/java/org/matsim/core/events/XmlEventsTester.java @@ -20,8 +20,8 @@ package org.matsim.core.events; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.util.Map; @@ -62,15 +62,14 @@ public static T testWriteReadXml(final String eventsFile, fina new MatsimEventsReader(events).readFile(eventsFile); events.finishProcessing(); - assertEquals("there must be 1 event.", 1, collector.getEvents().size()); + assertEquals(1, collector.getEvents().size(), "there must be 1 event."); Event readEvent = collector.getEvents().iterator().next(); - assertEquals("event has wrong class.", event.getClass(), readEvent.getClass()); + assertEquals(event.getClass(), readEvent.getClass(), "event has wrong class."); Map writtenAttributes = event.getAttributes(); Map readAttributes = readEvent.getAttributes(); for (Map.Entry attribute : writtenAttributes.entrySet()) { - assertEquals("attribute '" + attribute.getKey() + "' is different after reading the event.", - attribute.getValue(), readAttributes.get(attribute.getKey())); + assertEquals(attribute.getValue(), readAttributes.get(attribute.getKey()), "attribute '" + attribute.getKey() + "' is different after reading the event."); } return (T) readEvent; diff --git a/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterJsonTest.java b/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterJsonTest.java index 60a4cc3c49a..4cda0b0cb93 100644 --- a/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterJsonTest.java +++ b/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterJsonTest.java @@ -1,6 +1,6 @@ package org.matsim.core.events.algorithms; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.GenericEvent; @@ -43,15 +43,15 @@ void testSpecialCharacters() { new MatsimEventsReader(events).readStream(bios, ControllerConfigGroup.EventsFileFormat.json); events.finishProcessing(); - Assert.assertEquals("there must be 2 events.", 2, collector.getEvents().size()); + Assertions.assertEquals(2, collector.getEvents().size(), "there must be 2 events."); LinkLeaveEvent event1 = (LinkLeaveEvent) collector.getEvents().get(0); LinkLeaveEvent event2 = (LinkLeaveEvent) collector.getEvents().get(1); - Assert.assertEquals("link<2", event1.getLinkId().toString()); - Assert.assertEquals("vehicle>3", event1.getVehicleId().toString()); + Assertions.assertEquals("link<2", event1.getLinkId().toString()); + Assertions.assertEquals("vehicle>3", event1.getVehicleId().toString()); - Assert.assertEquals("link'3", event2.getLinkId().toString()); - Assert.assertEquals("vehicle\"4", event2.getVehicleId().toString()); + Assertions.assertEquals("link'3", event2.getLinkId().toString()); + Assertions.assertEquals("vehicle\"4", event2.getVehicleId().toString()); } @Test @@ -75,10 +75,10 @@ void testNullAttribute() { new MatsimEventsReader(events).readStream(bios, ControllerConfigGroup.EventsFileFormat.json); events.finishProcessing(); - Assert.assertEquals("there must be 1 event.", 1, collector.getEvents().size()); + Assertions.assertEquals(1, collector.getEvents().size(), "there must be 1 event."); GenericEvent event1 = (GenericEvent) collector.getEvents().get(0); - Assert.assertTrue(event1.getAttributes().containsKey("dummy")); - Assert.assertNull(event1.getAttributes().get("dummy")); + Assertions.assertTrue(event1.getAttributes().containsKey("dummy")); + Assertions.assertNull(event1.getAttributes().get("dummy")); } } diff --git a/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterXMLTest.java b/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterXMLTest.java index 114d27637b1..8ad04f9e371 100644 --- a/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterXMLTest.java +++ b/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterXMLTest.java @@ -21,7 +21,7 @@ import java.io.File; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -54,7 +54,7 @@ void testSpecialCharacters() { writer.handleEvent(new LinkLeaveEvent(3600.0, Id.create("vehicle>3", Vehicle.class), Id.create("link<2", Link.class))); writer.handleEvent(new LinkLeaveEvent(3601.0, Id.create("vehicle\"4", Vehicle.class), Id.create("link'3", Link.class))); writer.closeFile(); - Assert.assertTrue(new File(filename).exists()); + Assertions.assertTrue(new File(filename).exists()); EventsManager events = EventsUtils.createEventsManager(); EventsCollector collector = new EventsCollector(); @@ -64,15 +64,15 @@ void testSpecialCharacters() { new MatsimEventsReader(events).readFile(filename); events.finishProcessing(); - Assert.assertEquals("there must be 2 events.", 2, collector.getEvents().size()); + Assertions.assertEquals(2, collector.getEvents().size(), "there must be 2 events."); LinkLeaveEvent event1 = (LinkLeaveEvent) collector.getEvents().get(0); LinkLeaveEvent event2 = (LinkLeaveEvent) collector.getEvents().get(1); - Assert.assertEquals("link<2", event1.getLinkId().toString()); - Assert.assertEquals("vehicle>3", event1.getVehicleId().toString()); + Assertions.assertEquals("link<2", event1.getLinkId().toString()); + Assertions.assertEquals("vehicle>3", event1.getVehicleId().toString()); - Assert.assertEquals("link'3", event2.getLinkId().toString()); - Assert.assertEquals("vehicle\"4", event2.getVehicleId().toString()); + Assertions.assertEquals("link'3", event2.getLinkId().toString()); + Assertions.assertEquals("vehicle\"4", event2.getVehicleId().toString()); } @Test @@ -84,7 +84,7 @@ void testNullAttribute() { event.getAttributes().put("dummy", null); writer.handleEvent(event); writer.closeFile(); - Assert.assertTrue(new File(filename).exists()); + Assertions.assertTrue(new File(filename).exists()); EventsManager events = EventsUtils.createEventsManager(); EventsCollector collector = new EventsCollector(); @@ -94,6 +94,6 @@ void testNullAttribute() { new MatsimEventsReader(events).readFile(filename); events.finishProcessing(); - Assert.assertEquals("there must be 1 event.", 1, collector.getEvents().size()); + Assertions.assertEquals(1, collector.getEvents().size(), "there must be 1 event."); } } diff --git a/matsim/src/test/java/org/matsim/core/gbl/MatsimRandomTest.java b/matsim/src/test/java/org/matsim/core/gbl/MatsimRandomTest.java index 741469401ff..bbce6168394 100644 --- a/matsim/src/test/java/org/matsim/core/gbl/MatsimRandomTest.java +++ b/matsim/src/test/java/org/matsim/core/gbl/MatsimRandomTest.java @@ -20,8 +20,8 @@ package org.matsim.core.gbl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Random; @@ -131,7 +131,7 @@ void testLocalInstances_distribution() { */ private void assertEqualRandomNumberGenerators(final Random rng1, final Random rng2) { for (int i = 0; i < 10; i++) { - assertEquals("different element at position " + i, rng1.nextDouble(), rng2.nextDouble(), MatsimTestUtils.EPSILON); + assertEquals(rng1.nextDouble(), rng2.nextDouble(), MatsimTestUtils.EPSILON, "different element at position " + i); } } } diff --git a/matsim/src/test/java/org/matsim/core/gbl/MatsimResourceTest.java b/matsim/src/test/java/org/matsim/core/gbl/MatsimResourceTest.java index a47adfa7e6c..46329aa09c4 100644 --- a/matsim/src/test/java/org/matsim/core/gbl/MatsimResourceTest.java +++ b/matsim/src/test/java/org/matsim/core/gbl/MatsimResourceTest.java @@ -20,11 +20,11 @@ package org.matsim.core.gbl; -import static org.junit.Assert.assertEquals; - import java.awt.Image; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/AbstractMobsimModuleTest.java b/matsim/src/test/java/org/matsim/core/mobsim/AbstractMobsimModuleTest.java index 9675beba522..cb9a538bb03 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/AbstractMobsimModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/AbstractMobsimModuleTest.java @@ -23,7 +23,7 @@ import java.util.Collections; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -32,7 +32,7 @@ import com.google.inject.Guice; import com.google.inject.Injector; - public class AbstractMobsimModuleTest { + public class AbstractMobsimModuleTest { @Test void testOverrides() { AbstractMobsimModule moduleA = new AbstractMobsimModule() { @@ -59,9 +59,9 @@ protected void configureMobsim() { Injector injector = Guice.createInjector(composite); - Assert.assertTrue(config.getModules().containsKey("testA")); - Assert.assertTrue(config.getModules().containsKey("testB")); + Assertions.assertTrue(config.getModules().containsKey("testA")); + Assertions.assertTrue(config.getModules().containsKey("testB")); - Assert.assertEquals("testBString", injector.getInstance(String.class)); + Assertions.assertEquals("testBString", injector.getInstance(String.class)); } } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/AgentTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/AgentTest.java index 2a571c61146..4bc46d2d22a 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/AgentTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/AgentTest.java @@ -19,9 +19,10 @@ package org.matsim.core.mobsim.hermes; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.junit.jupiter.api.Test; import org.locationtech.jts.util.Assert; -import static org.junit.Assert.assertEquals; public class AgentTest { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/FlowCapacityTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/FlowCapacityTest.java index 83a4f62d0d4..60ca78d0d54 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/FlowCapacityTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/FlowCapacityTest.java @@ -20,8 +20,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.analysis.VolumesAnalyzer; import org.matsim.api.core.v01.Id; @@ -119,10 +119,10 @@ void testFlowCapacityDriving() { System.out.println("#vehicles 7-8: " + volume[7]); System.out.println("#vehicles 8-9: " + volume[8]); - Assert.assertEquals(0, volume[5], 1); // no vehicles - Assert.assertEquals(3004, volume[6], 1); // we should have half of the maximum flow in this hour - Assert.assertEquals(6000, volume[7], 1); // we should have maximum flow in this hour - Assert.assertEquals(2996, volume[8], 1); // all the rest + Assertions.assertEquals(0, volume[5], 1); // no vehicles + Assertions.assertEquals(3004, volume[6], 1); // we should have half of the maximum flow in this hour + Assertions.assertEquals(6000, volume[7], 1); // we should have maximum flow in this hour + Assertions.assertEquals(2996, volume[8], 1); // all the rest } @@ -176,10 +176,10 @@ void testFlowCapacityDrivingFlowCapacityFactors() { System.out.println("#vehicles 7-8: " + volume[7]); System.out.println("#vehicles 8-9: " + volume[8]); - Assert.assertEquals(0, volume[5], 1); // no vehicles - Assert.assertEquals(301, volume[6], 1); // we should have half of the maximum flow in this hour - Assert.assertEquals(600, volume[7], 1); // we should have maximum flow in this hour - Assert.assertEquals(299, volume[8], 1); // all the rest + Assertions.assertEquals(0, volume[5], 1); // no vehicles + Assertions.assertEquals(301, volume[6], 1); // we should have half of the maximum flow in this hour + Assertions.assertEquals(600, volume[7], 1); // we should have maximum flow in this hour + Assertions.assertEquals(299, volume[8], 1); // all the rest } @@ -241,10 +241,10 @@ void testFlowCapacityDrivingFlowEfficiencyFactors() { System.out.println("#vehicles 8-9: " + volume[8]); - Assert.assertEquals(0, volume[5]); // no vehicles - Assert.assertEquals(4005, volume[6]); // we should have half of the maximum flow in this hour * 1.5, because every second vehicle is super flowy - Assert.assertEquals(7995, volume[7]); // all the rest - Assert.assertEquals(0, volume[8]); // nothing + Assertions.assertEquals(0, volume[5]); // no vehicles + Assertions.assertEquals(4005, volume[6]); // we should have half of the maximum flow in this hour * 1.5, because every second vehicle is super flowy + Assertions.assertEquals(7995, volume[7]); // all the rest + Assertions.assertEquals(0, volume[8]); // nothing } @@ -306,10 +306,10 @@ void testFlowCapacityDrivingFlowEfficiencyFactorsWithDownscaling() { System.out.println("#vehicles 7-8: " + volume[7]); System.out.println("#vehicles 8-9: " + volume[8]); - Assert.assertEquals(0, volume[5], 1); // no vehicles - Assert.assertEquals(401, volume[6], 1); // we should have half of the maximum flow in this hour * 1.3333, because every second vehicle is super flowy - Assert.assertEquals(799, volume[7], 1); // all the rest - Assert.assertEquals(0, volume[8], 1); // nothing + Assertions.assertEquals(0, volume[5], 1); // no vehicles + Assertions.assertEquals(401, volume[6], 1); // we should have half of the maximum flow in this hour * 1.3333, because every second vehicle is super flowy + Assertions.assertEquals(799, volume[7], 1); // all the rest + Assertions.assertEquals(0, volume[8], 1); // nothing } /** @@ -369,11 +369,11 @@ void testFlowCapacityEfficiencyFactorWithLowValueAndDownscaling() { System.out.println("#vehicles 6-7: " + volume[6]); System.out.println("#vehicles 7-8: " + volume[7]); System.out.println("#vehicles 8-9: " + volume[8]); - Assert.assertEquals(0, volume[5], 1); // no vehicles - Assert.assertEquals(201, volume[6], 1); // we should have half of the maximum flow in this hour * 1.3333, because every second vehicle is super flowy - Assert.assertEquals(400, volume[7], 1); - Assert.assertEquals(400, volume[8], 1); - Assert.assertEquals(199, volume[9], 1); + Assertions.assertEquals(0, volume[5], 1); // no vehicles + Assertions.assertEquals(201, volume[6], 1); // we should have half of the maximum flow in this hour * 1.3333, because every second vehicle is super flowy + Assertions.assertEquals(400, volume[7], 1); + Assertions.assertEquals(400, volume[8], 1); + Assertions.assertEquals(199, volume[9], 1); } @@ -425,9 +425,9 @@ void testFlowCapacityDrivingFraction() { /* finish */ int[] volume = vAnalyzer.getVolumesForLink(f.link2.getId()); - Assert.assertEquals(1, volume[7*3600 - 1801]); // First vehicle - Assert.assertEquals(1, volume[7*3600 - 1801 + 4]); // Second vehicle - Assert.assertEquals(1, volume[7*3600 - 1801 + 8]); // Third vehicle + Assertions.assertEquals(1, volume[7*3600 - 1801]); // First vehicle + Assertions.assertEquals(1, volume[7*3600 - 1801 + 4]); // Second vehicle + Assertions.assertEquals(1, volume[7*3600 - 1801 + 8]); // Third vehicle } } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTest.java index 69fc3bfbd3e..8d6dce636f6 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTest.java @@ -26,8 +26,8 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -142,9 +142,9 @@ void testSingleAgent() { sim.run(); /* finish */ - Assert.assertEquals("wrong number of link enter events.", 2, collector.events.size()); - Assert.assertEquals("wrong time in first event.", 6.0*3600, collector.events.get(0).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in second event.", 6.0*3600 + 11, collector.events.get(1).getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, collector.events.size(), "wrong number of link enter events."); + Assertions.assertEquals(6.0*3600, collector.events.get(0).getTime(), MatsimTestUtils.EPSILON, "wrong time in first event."); + Assertions.assertEquals(6.0*3600 + 11, collector.events.get(1).getTime(), MatsimTestUtils.EPSILON, "wrong time in second event."); } @@ -190,9 +190,9 @@ void testSingleAgentWithEndOnLeg() { createHermes(f, events).run(); // // /* finish */ - Assert.assertEquals("wrong number of link enter events.", 2, collector.events.size()); - Assert.assertEquals("wrong time in first event.", 6.0*3600, collector.events.get(0).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in second event.", 6.0*3600 + 11, collector.events.get(1).getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, collector.events.size(), "wrong number of link enter events."); + Assertions.assertEquals(6.0*3600, collector.events.get(0).getTime(), MatsimTestUtils.EPSILON, "wrong time in first event."); + Assertions.assertEquals(6.0*3600 + 11, collector.events.get(1).getTime(), MatsimTestUtils.EPSILON, "wrong time in second event."); } /** @@ -230,11 +230,11 @@ void testTwoAgent() { sim.run(); /* finish */ - Assert.assertEquals("wrong number of link enter events.", 4, collector.events.size()); - Assert.assertEquals("wrong time in first event.", 6.0*3600, collector.events.get(0).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in second event.", 6.0*3600 + 11, collector.events.get(1).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in first event.", 7.0*3600, collector.events.get(2).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in second event.", 7.0*3600 + 11, collector.events.get(3).getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(4, collector.events.size(), "wrong number of link enter events."); + Assertions.assertEquals(6.0*3600, collector.events.get(0).getTime(), MatsimTestUtils.EPSILON, "wrong time in first event."); + Assertions.assertEquals(6.0*3600 + 11, collector.events.get(1).getTime(), MatsimTestUtils.EPSILON, "wrong time in second event."); + Assertions.assertEquals(7.0*3600, collector.events.get(2).getTime(), MatsimTestUtils.EPSILON, "wrong time in first event."); + Assertions.assertEquals(7.0*3600 + 11, collector.events.get(3).getTime(), MatsimTestUtils.EPSILON, "wrong time in second event."); } /** @@ -269,16 +269,16 @@ void testTeleportationSingleAgent() { sim.run(); List allEvents = collector.getEvents(); - Assert.assertEquals("wrong number of events.", 5, collector.getEvents().size()); - Assert.assertEquals("wrong type of event.", ActivityEndEvent.class, allEvents.get(0).getClass()); - Assert.assertEquals("wrong type of event.", PersonDepartureEvent.class, allEvents.get(1).getClass()); - Assert.assertEquals("wrong type of event.", TeleportationArrivalEvent.class, allEvents.get(2).getClass()); - Assert.assertEquals("wrong type of event.", PersonArrivalEvent.class, allEvents.get(3).getClass()); - Assert.assertEquals("wrong type of event.", ActivityStartEvent.class, allEvents.get(4).getClass()); - Assert.assertEquals("wrong time in event.", 6.0 * 3600 + 0, allEvents.get(0).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in event.", 6.0 * 3600 + 0, allEvents.get(1).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in event.", 6.0 * 3600 + 13, allEvents.get(2).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in event.", 6.0 * 3600 + 13, allEvents.get(3).getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(5, collector.getEvents().size(), "wrong number of events."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(0).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(1).getClass(), "wrong type of event."); + Assertions.assertEquals(TeleportationArrivalEvent.class, allEvents.get(2).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(3).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(4).getClass(), "wrong type of event."); + Assertions.assertEquals(6.0 * 3600 + 0, allEvents.get(0).getTime(), MatsimTestUtils.EPSILON, "wrong time in event."); + Assertions.assertEquals(6.0 * 3600 + 0, allEvents.get(1).getTime(), MatsimTestUtils.EPSILON, "wrong time in event."); + Assertions.assertEquals(6.0 * 3600 + 13, allEvents.get(2).getTime(), MatsimTestUtils.EPSILON, "wrong time in event."); + Assertions.assertEquals(6.0 * 3600 + 13, allEvents.get(3).getTime(), MatsimTestUtils.EPSILON, "wrong time in event."); } /** @@ -317,9 +317,9 @@ void testSingleAgentImmediateDeparture() { sim.run(); /* finish */ - Assert.assertEquals("wrong number of link enter events.", 2, collector.events.size()); - Assert.assertEquals("wrong time in first event.", 0.0*3600, collector.events.get(0).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in second event.", 0.0*3600 + 11, collector.events.get(1).getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, collector.events.size(), "wrong number of link enter events."); + Assertions.assertEquals(0.0*3600, collector.events.get(0).getTime(), MatsimTestUtils.EPSILON, "wrong time in first event."); + Assertions.assertEquals(0.0*3600 + 11, collector.events.get(1).getTime(), MatsimTestUtils.EPSILON, "wrong time in second event."); } /** @@ -365,40 +365,44 @@ void testSingleAgent_EmptyRoute() { for (Event event : allEvents) { System.out.println(event); } - Assert.assertEquals("wrong number of events.", 8, allEvents.size()); - - - Assert.assertEquals("wrong type of 1st event.", ActivityEndEvent.class, allEvents.get(0).getClass()); - Assert.assertEquals("wrong type of 2nd event.", PersonDepartureEvent.class, allEvents.get(1).getClass()); - Assert.assertEquals("wrong type of 3rd event.", PersonEntersVehicleEvent.class, allEvents.get(2).getClass()); - Assert.assertEquals("wrong type of 4th event.", VehicleEntersTrafficEvent.class, allEvents.get(3).getClass()); - Assert.assertEquals("wrong type of 5th event.", VehicleLeavesTrafficEvent.class, allEvents.get(4).getClass()); - Assert.assertEquals("wrong type of 6th event.", PersonLeavesVehicleEvent.class, allEvents.get(5).getClass()); - Assert.assertEquals("wrong type of 7th event.", PersonArrivalEvent.class, allEvents.get(6).getClass()); - Assert.assertEquals("wrong type of 8th event.", ActivityStartEvent.class, allEvents.get(7).getClass()); - - - Assert.assertEquals("wrong time in 1st event.", 6.0*3600 + 0, allEvents.get(0).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in 2nd event.", 6.0*3600 + 0, allEvents.get(1).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in 3rd event.", 6.0*3600 + 0, allEvents.get(2).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in 4th event.", 6.0*3600 + 0, allEvents.get(3).getTime(), MatsimTestUtils.EPSILON); - - Assert.assertEquals("wrong time in 5th event.", 6.0 * 3600 + 0, allEvents.get(4).getTime(), - MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in 6th event.", 6.0 * 3600 + 0, allEvents.get(5).getTime(), - MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in 7th event.", 6.0 * 3600 + 0, allEvents.get(6).getTime(), - MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in 8th event.", 6.0 * 3600 + 0, allEvents.get(7).getTime(), - MatsimTestUtils.EPSILON); - - - Assert.assertEquals("wrong link in 1st event.", f.link1.getId(), ((ActivityEndEvent) allEvents.get(0)).getLinkId() ); - Assert.assertEquals("wrong link in 2nd event.", f.link1.getId(), ((PersonDepartureEvent) allEvents.get(1)).getLinkId() ); - Assert.assertEquals("wrong link in 4th event.", f.link1.getId(), ((VehicleEntersTrafficEvent) allEvents.get(3)).getLinkId() ); - Assert.assertEquals("wrong link in 5th event.", f.link1.getId(), ((VehicleLeavesTrafficEvent) allEvents.get(4)).getLinkId() ); - Assert.assertEquals("wrong link in 7th event.", f.link1.getId(), ((PersonArrivalEvent) allEvents.get(6)).getLinkId() ); - Assert.assertEquals("wrong link in 8th event.", f.link1.getId(), ((ActivityStartEvent) allEvents.get(7)).getLinkId() ); + Assertions.assertEquals(8, allEvents.size(), "wrong number of events."); + + + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(0).getClass(), "wrong type of 1st event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(1).getClass(), "wrong type of 2nd event."); + Assertions.assertEquals(PersonEntersVehicleEvent.class, allEvents.get(2).getClass(), "wrong type of 3rd event."); + Assertions.assertEquals(VehicleEntersTrafficEvent.class, allEvents.get(3).getClass(), "wrong type of 4th event."); + Assertions.assertEquals(VehicleLeavesTrafficEvent.class, allEvents.get(4).getClass(), "wrong type of 5th event."); + Assertions.assertEquals(PersonLeavesVehicleEvent.class, allEvents.get(5).getClass(), "wrong type of 6th event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(6).getClass(), "wrong type of 7th event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(7).getClass(), "wrong type of 8th event."); + + + Assertions.assertEquals(6.0*3600 + 0, allEvents.get(0).getTime(), MatsimTestUtils.EPSILON, "wrong time in 1st event."); + Assertions.assertEquals(6.0*3600 + 0, allEvents.get(1).getTime(), MatsimTestUtils.EPSILON, "wrong time in 2nd event."); + Assertions.assertEquals(6.0*3600 + 0, allEvents.get(2).getTime(), MatsimTestUtils.EPSILON, "wrong time in 3rd event."); + Assertions.assertEquals(6.0*3600 + 0, allEvents.get(3).getTime(), MatsimTestUtils.EPSILON, "wrong time in 4th event."); + + Assertions.assertEquals(6.0 * 3600 + 0, allEvents.get(4).getTime(), + MatsimTestUtils.EPSILON, + "wrong time in 5th event."); + Assertions.assertEquals(6.0 * 3600 + 0, allEvents.get(5).getTime(), + MatsimTestUtils.EPSILON, + "wrong time in 6th event."); + Assertions.assertEquals(6.0 * 3600 + 0, allEvents.get(6).getTime(), + MatsimTestUtils.EPSILON, + "wrong time in 7th event."); + Assertions.assertEquals(6.0 * 3600 + 0, allEvents.get(7).getTime(), + MatsimTestUtils.EPSILON, + "wrong time in 8th event."); + + + Assertions.assertEquals(f.link1.getId(), ((ActivityEndEvent) allEvents.get(0)).getLinkId(), "wrong link in 1st event." ); + Assertions.assertEquals(f.link1.getId(), ((PersonDepartureEvent) allEvents.get(1)).getLinkId(), "wrong link in 2nd event." ); + Assertions.assertEquals(f.link1.getId(), ((VehicleEntersTrafficEvent) allEvents.get(3)).getLinkId(), "wrong link in 4th event." ); + Assertions.assertEquals(f.link1.getId(), ((VehicleLeavesTrafficEvent) allEvents.get(4)).getLinkId(), "wrong link in 5th event." ); + Assertions.assertEquals(f.link1.getId(), ((PersonArrivalEvent) allEvents.get(6)).getLinkId(), "wrong link in 7th event." ); + Assertions.assertEquals(f.link1.getId(), ((ActivityStartEvent) allEvents.get(7)).getLinkId(), "wrong link in 8th event." ); } /** @@ -443,21 +447,21 @@ void testSingleAgent_LastLinkIsLoop() { for (Event event : allEvents) { System.out.println(event); } - Assert.assertEquals("wrong number of events.", 14, allEvents.size()); - Assert.assertEquals("wrong type of 1st event.", ActivityEndEvent.class, allEvents.get(0).getClass()); - Assert.assertEquals("wrong type of 2nd event.", PersonDepartureEvent.class, allEvents.get(1).getClass()); - Assert.assertEquals("wrong type of event.", PersonEntersVehicleEvent.class, allEvents.get(2).getClass()); - Assert.assertEquals("wrong type of event.", VehicleEntersTrafficEvent.class, allEvents.get(3).getClass()); - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(4).getClass()); // link 1 - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(5).getClass()); // link 2 - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(6).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(7).getClass()); // link 3 - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(8).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(9).getClass()); // loop link - Assert.assertEquals("wrong type of event.", VehicleLeavesTrafficEvent.class, allEvents.get(10).getClass()); - Assert.assertEquals("wrong type of event.", PersonLeavesVehicleEvent.class, allEvents.get(11).getClass()); - Assert.assertEquals("wrong type of 11th event.", PersonArrivalEvent.class, allEvents.get(12).getClass()); - Assert.assertEquals("wrong type of 12th event.", ActivityStartEvent.class, allEvents.get(13).getClass()); + Assertions.assertEquals(14, allEvents.size(), "wrong number of events."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(0).getClass(), "wrong type of 1st event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(1).getClass(), "wrong type of 2nd event."); + Assertions.assertEquals(PersonEntersVehicleEvent.class, allEvents.get(2).getClass(), "wrong type of event."); + Assertions.assertEquals(VehicleEntersTrafficEvent.class, allEvents.get(3).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(4).getClass(), "wrong type of event."); // link 1 + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(5).getClass(), "wrong type of event."); // link 2 + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(6).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(7).getClass(), "wrong type of event."); // link 3 + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(8).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(9).getClass(), "wrong type of event."); // loop link + Assertions.assertEquals(VehicleLeavesTrafficEvent.class, allEvents.get(10).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonLeavesVehicleEvent.class, allEvents.get(11).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(12).getClass(), "wrong type of 11th event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(13).getClass(), "wrong type of 12th event."); } /*package*/ static class LinkEnterEventCollector implements LinkEnterEventHandler { @@ -496,7 +500,7 @@ void testAgentWithoutLeg() { sim.run(); /* finish */ - Assert.assertEquals("wrong number of link enter events.", 0, collector.events.size()); + Assertions.assertEquals(0, collector.events.size(), "wrong number of link enter events."); } /** @@ -524,7 +528,7 @@ void testAgentWithoutLegWithEndtime() { sim.run(); /* finish */ - Assert.assertEquals("wrong number of link enter events.", 0, collector.events.size()); + Assertions.assertEquals(0, collector.events.size(), "wrong number of link enter events."); } /** @@ -558,7 +562,7 @@ void testAgentWithLastActWithEndtime() { sim.run(); /* finish */ - Assert.assertEquals("wrong number of link enter events.", 0, collector.events.size()); + Assertions.assertEquals(0, collector.events.size(), "wrong number of link enter events."); } /** @@ -597,22 +601,22 @@ void testVehicleTeleportationTrue() { sim.run(); List allEvents = collector.getEvents(); - Assert.assertEquals("wrong number of events.", 15, allEvents.size()); - Assert.assertEquals("wrong type of event.", ActivityEndEvent.class, allEvents.get(0).getClass()); - Assert.assertEquals("wrong type of event.", PersonDepartureEvent.class, allEvents.get(1).getClass()); - Assert.assertEquals("wrong type of event.", TeleportationArrivalEvent.class, allEvents.get(2).getClass()); - Assert.assertEquals("wrong type of event.", PersonArrivalEvent.class, allEvents.get(3).getClass()); - Assert.assertEquals("wrong type of event.", ActivityStartEvent.class, allEvents.get(4).getClass()); - Assert.assertEquals("wrong type of event.", ActivityEndEvent.class, allEvents.get(5).getClass()); - Assert.assertEquals("wrong type of event.", PersonDepartureEvent.class, allEvents.get(6).getClass()); - Assert.assertEquals("wrong type of event.", PersonEntersVehicleEvent.class, allEvents.get(7).getClass()); - Assert.assertEquals("wrong type of event.", VehicleEntersTrafficEvent.class, allEvents.get(8).getClass()); - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(9).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(10).getClass()); - Assert.assertEquals("wrong type of event.", VehicleLeavesTrafficEvent.class, allEvents.get(11).getClass()); - Assert.assertEquals("wrong type of event.", PersonLeavesVehicleEvent.class, allEvents.get(12).getClass()); - Assert.assertEquals("wrong type of event.", PersonArrivalEvent.class, allEvents.get(13).getClass()); - Assert.assertEquals("wrong type of event.", ActivityStartEvent.class, allEvents.get(14).getClass()); + Assertions.assertEquals(15, allEvents.size(), "wrong number of events."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(0).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(1).getClass(), "wrong type of event."); + Assertions.assertEquals(TeleportationArrivalEvent.class, allEvents.get(2).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(3).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(4).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(5).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(6).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonEntersVehicleEvent.class, allEvents.get(7).getClass(), "wrong type of event."); + Assertions.assertEquals(VehicleEntersTrafficEvent.class, allEvents.get(8).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(9).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(10).getClass(), "wrong type of event."); + Assertions.assertEquals(VehicleLeavesTrafficEvent.class, allEvents.get(11).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonLeavesVehicleEvent.class, allEvents.get(12).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(13).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(14).getClass(), "wrong type of event."); } /** @@ -656,23 +660,23 @@ void testCircleAsRoute() { System.out.println(event); } - Assert.assertEquals("wrong number of events.", 16, allEvents.size()); - Assert.assertEquals("wrong type of event.", ActivityEndEvent.class, allEvents.get(0).getClass()); - Assert.assertEquals("wrong type of event.", PersonDepartureEvent.class, allEvents.get(1).getClass()); - Assert.assertEquals("wrong type of event.", PersonEntersVehicleEvent.class, allEvents.get(2).getClass()); - Assert.assertEquals("wrong type of event.", VehicleEntersTrafficEvent.class, allEvents.get(3).getClass()); - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(4).getClass()); // link1 - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(5).getClass()); // link2 - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(6).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(7).getClass()); // link3 - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(8).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(9).getClass()); // link4 - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(10).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(11).getClass()); // link1 again - Assert.assertEquals("wrong type of event.", VehicleLeavesTrafficEvent.class, allEvents.get(12).getClass()); - Assert.assertEquals("wrong type of event.", PersonLeavesVehicleEvent.class, allEvents.get(13).getClass()); - Assert.assertEquals("wrong type of event.", PersonArrivalEvent.class, allEvents.get(14).getClass()); - Assert.assertEquals("wrong type of event.", ActivityStartEvent.class, allEvents.get(15).getClass()); + Assertions.assertEquals(16, allEvents.size(), "wrong number of events."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(0).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(1).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonEntersVehicleEvent.class, allEvents.get(2).getClass(), "wrong type of event."); + Assertions.assertEquals(VehicleEntersTrafficEvent.class, allEvents.get(3).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(4).getClass(), "wrong type of event."); // link1 + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(5).getClass(), "wrong type of event."); // link2 + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(6).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(7).getClass(), "wrong type of event."); // link3 + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(8).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(9).getClass(), "wrong type of event."); // link4 + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(10).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(11).getClass(), "wrong type of event."); // link1 again + Assertions.assertEquals(VehicleLeavesTrafficEvent.class, allEvents.get(12).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonLeavesVehicleEvent.class, allEvents.get(13).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(14).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(15).getClass(), "wrong type of event."); } /** @@ -718,27 +722,27 @@ void testRouteWithEndLinkTwice() { System.out.println(event); } - Assert.assertEquals("wrong number of events.", 20, allEvents.size()); - Assert.assertEquals("wrong type of event.", ActivityEndEvent.class, allEvents.get(0).getClass()); - Assert.assertEquals("wrong type of event.", PersonDepartureEvent.class, allEvents.get(1).getClass()); - Assert.assertEquals("wrong type of event.", PersonEntersVehicleEvent.class, allEvents.get(2).getClass()); - Assert.assertEquals("wrong type of event.", VehicleEntersTrafficEvent.class, allEvents.get(3).getClass()); - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(4).getClass()); // link1 - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(5).getClass()); // link2 - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(6).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(7).getClass()); // link3 - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(8).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(9).getClass()); // link4 - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(10).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(11).getClass()); // link1 again - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(12).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(13).getClass()); // link2 again - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(14).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(15).getClass()); // link3 again - Assert.assertEquals("wrong type of event.", VehicleLeavesTrafficEvent.class, allEvents.get(16).getClass()); - Assert.assertEquals("wrong type of event.", PersonLeavesVehicleEvent.class, allEvents.get(17).getClass()); - Assert.assertEquals("wrong type of event.", PersonArrivalEvent.class, allEvents.get(18).getClass()); - Assert.assertEquals("wrong type of event.", ActivityStartEvent.class, allEvents.get(19).getClass()); + Assertions.assertEquals(20, allEvents.size(), "wrong number of events."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(0).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(1).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonEntersVehicleEvent.class, allEvents.get(2).getClass(), "wrong type of event."); + Assertions.assertEquals(VehicleEntersTrafficEvent.class, allEvents.get(3).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(4).getClass(), "wrong type of event."); // link1 + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(5).getClass(), "wrong type of event."); // link2 + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(6).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(7).getClass(), "wrong type of event."); // link3 + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(8).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(9).getClass(), "wrong type of event."); // link4 + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(10).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(11).getClass(), "wrong type of event."); // link1 again + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(12).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(13).getClass(), "wrong type of event."); // link2 again + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(14).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(15).getClass(), "wrong type of event."); // link3 again + Assertions.assertEquals(VehicleLeavesTrafficEvent.class, allEvents.get(16).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonLeavesVehicleEvent.class, allEvents.get(17).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(18).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(19).getClass(), "wrong type of event."); } /** Prepares miscellaneous data for the testConsistentRoutes() tests: @@ -846,8 +850,8 @@ void testStartAndEndTime() { Hermes sim = createHermes(scenario, events); HermesConfigGroup.SIM_STEPS = 11 * 3600; sim.run(); - Assert.assertEquals(7.0*3600, collector.firstEvent.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals(11.0*3600, collector.lastEvent.getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(7.0*3600, collector.firstEvent.getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(11.0*3600, collector.lastEvent.getTime(), MatsimTestUtils.EPSILON); } /** @@ -940,7 +944,7 @@ void testCleanupSim_EarlyEnd() { Hermes sim = createHermes(scenario, events); HermesConfigGroup.SIM_STEPS = (int) simEndTime; sim.run(); - Assert.assertEquals(simEndTime, collector.lastEvent.getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(simEndTime, collector.lastEvent.getTime(), MatsimTestUtils.EPSILON); // besides this, the important thing is that no (Runtime)Exception is thrown during this test } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTransitTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTransitTest.java index 332dbb4660a..4dfd0d0c319 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTransitTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTransitTest.java @@ -1,7 +1,7 @@ package org.matsim.core.mobsim.hermes; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -190,9 +190,9 @@ void testSuperflousStopFacilities() { } // Not having an Exception here is already good :-) - Assert.assertEquals("wrong number of link enter events.", 2, collector.events.size()); - Assert.assertEquals("wrong link in first event.", f.link2.getId(), collector.events.get(0).getLinkId()); - Assert.assertEquals("wrong link in second event.", f.link3.getId(), collector.events.get(1).getLinkId()); + Assertions.assertEquals(2, collector.events.size(), "wrong number of link enter events."); + Assertions.assertEquals(f.link2.getId(), collector.events.get(0).getLinkId(), "wrong link in first event."); + Assertions.assertEquals(f.link3.getId(), collector.events.get(1).getLinkId(), "wrong link in second event."); } /** @@ -291,9 +291,9 @@ void testRepeatedRouteIds() { /* finish */ // Not having an Exception here is already good :-) - Assert.assertEquals("wrong number of link enter events.", 4, collector.events.size()); - Assert.assertEquals("wrong link in first event.", f.link2.getId(), collector.events.get(0).getLinkId()); - Assert.assertEquals("wrong link in second event.", f.link3.getId(), collector.events.get(1).getLinkId()); + Assertions.assertEquals(4, collector.events.size(), "wrong number of link enter events."); + Assertions.assertEquals(f.link2.getId(), collector.events.get(0).getLinkId(), "wrong link in first event."); + Assertions.assertEquals(f.link3.getId(), collector.events.get(1).getLinkId(), "wrong link in second event."); } /** @@ -377,14 +377,14 @@ void testConsecutiveStopsWithSameLink_1() { } } - Assert.assertEquals("wrong number of link enter events.", 2, collector.events.size()); - Assert.assertEquals("wrong link in first event.", f.link2.getId(), collector.events.get(0).getLinkId()); - Assert.assertEquals("wrong link in second event.", f.link3.getId(), collector.events.get(1).getLinkId()); + Assertions.assertEquals(2, collector.events.size(), "wrong number of link enter events."); + Assertions.assertEquals(f.link2.getId(), collector.events.get(0).getLinkId(), "wrong link in first event."); + Assertions.assertEquals(f.link3.getId(), collector.events.get(1).getLinkId(), "wrong link in second event."); - Assert.assertEquals("wrong number of stops served.", 3, stopArrivalEvents.size()); - Assert.assertEquals("wrong stop id at first stop.", stop1.getId(), stopArrivalEvents.get(0).getFacilityId()); - Assert.assertEquals("wrong stop id at 2nd stop.", stop2.getId(), stopArrivalEvents.get(1).getFacilityId()); - Assert.assertEquals("wrong stop id at 3rd stop.", stop3.getId(), stopArrivalEvents.get(2).getFacilityId()); + Assertions.assertEquals(3, stopArrivalEvents.size(), "wrong number of stops served."); + Assertions.assertEquals(stop1.getId(), stopArrivalEvents.get(0).getFacilityId(), "wrong stop id at first stop."); + Assertions.assertEquals(stop2.getId(), stopArrivalEvents.get(1).getFacilityId(), "wrong stop id at 2nd stop."); + Assertions.assertEquals(stop3.getId(), stopArrivalEvents.get(2).getFacilityId(), "wrong stop id at 3rd stop."); } @@ -474,9 +474,9 @@ void testConsecutiveStopsWithSameLink_2() { // System.out.println(event.toString()); // } - Assert.assertEquals("wrong number of link enter events.", 6, collector.events.size()); - Assert.assertEquals("wrong link in first event.", f.link2.getId(), collector.events.get(0).getLinkId()); - Assert.assertEquals("wrong link in second event.", f.link3.getId(), collector.events.get(1).getLinkId()); + Assertions.assertEquals(6, collector.events.size(), "wrong number of link enter events."); + Assertions.assertEquals(f.link2.getId(), collector.events.get(0).getLinkId(), "wrong link in first event."); + Assertions.assertEquals(f.link3.getId(), collector.events.get(1).getLinkId(), "wrong link in second event."); // Assert.assertEquals("wrong link in second event.", f.linkX.getId(), collector.events.get(2).getLinkId()); // Assert.assertEquals("wrong link in second event.", f.link1.getId(), collector.events.get(3).getLinkId()); // Assert.assertEquals("wrong link in second event.", f.link2.getId(), collector.events.get(4).getLinkId()); @@ -549,8 +549,8 @@ void testEarlyEnd() { } // Not having an Exception here is already good :-) - Assert.assertEquals("wrong number of link enter events.", 1, collector.events.size()); - Assert.assertEquals("wrong link in first event.", f.link2.getId(), collector.events.get(0).getLinkId()); + Assertions.assertEquals(1, collector.events.size(), "wrong number of link enter events."); + Assertions.assertEquals(f.link2.getId(), collector.events.get(0).getLinkId(), "wrong link in first event."); // there should be no more events after that, as at 30:00:00 the simulation should stop } @@ -619,7 +619,7 @@ void testLinksAtRouteStart() { } // Not having an Exception here is already good :-) - Assert.assertEquals("wrong number of link enter events.", 3, collector.events.size()); + Assertions.assertEquals(3, collector.events.size(), "wrong number of link enter events."); // Assert.assertEquals("wrong link in first event.", f.link2.getId(), collector.events.get(0).getLinkId()); // Assert.assertEquals("wrong link in 2nd event.", f.link3.getId(), collector.events.get(1).getLinkId()); } @@ -710,43 +710,43 @@ void testDeterministicCorrectTiming() { if (event instanceof LinkLeaveEvent) linkLeaveEvents.add((LinkLeaveEvent) event); } - Assert.assertEquals("wrong number of transit-driver-starts events.", 1, transitDriverStartsEvents.size()); - Assert.assertEquals("wrong number of link enter events.", 2, linkEnterEvents.size()); - Assert.assertEquals("wrong number of link leave events.", 2, linkLeaveEvents.size()); - Assert.assertEquals("wrong number of VehicleArrivesAtFacilityEvents.", 3, arrivesAtFacilityEvents.size()); - Assert.assertEquals("wrong number of VehicleDepartsAtFacilityEvents.", 3, departsAtFacilityEvents.size()); + Assertions.assertEquals(1, transitDriverStartsEvents.size(), "wrong number of transit-driver-starts events."); + Assertions.assertEquals(2, linkEnterEvents.size(), "wrong number of link enter events."); + Assertions.assertEquals(2, linkLeaveEvents.size(), "wrong number of link leave events."); + Assertions.assertEquals(3, arrivesAtFacilityEvents.size(), "wrong number of VehicleArrivesAtFacilityEvents."); + Assertions.assertEquals(3, departsAtFacilityEvents.size(), "wrong number of VehicleDepartsAtFacilityEvents."); - if (this.isDeterministic) Assert.assertEquals(997.0, transitDriverStartsEvents.get(0).getTime(), 1e-8); + if (this.isDeterministic) Assertions.assertEquals(997.0, transitDriverStartsEvents.get(0).getTime(), 1e-8); - if (this.isDeterministic) Assert.assertEquals(998.0, arrivesAtFacilityEvents.get(0).getTime(), 1e-8); - Assert.assertEquals(stop1.getId(), arrivesAtFacilityEvents.get(0).getFacilityId()); + if (this.isDeterministic) Assertions.assertEquals(998.0, arrivesAtFacilityEvents.get(0).getTime(), 1e-8); + Assertions.assertEquals(stop1.getId(), arrivesAtFacilityEvents.get(0).getFacilityId()); - if (this.isDeterministic) Assert.assertEquals(1000.0, departsAtFacilityEvents.get(0).getTime(), 1e-8); - Assert.assertEquals(stop1.getId(), departsAtFacilityEvents.get(0).getFacilityId()); + if (this.isDeterministic) Assertions.assertEquals(1000.0, departsAtFacilityEvents.get(0).getTime(), 1e-8); + Assertions.assertEquals(stop1.getId(), departsAtFacilityEvents.get(0).getFacilityId()); - if (this.isDeterministic) Assert.assertEquals(1001.0, linkLeaveEvents.get(0).getTime(), 1e-8); - Assert.assertEquals(f.link1.getId(), linkLeaveEvents.get(0).getLinkId()); + if (this.isDeterministic) Assertions.assertEquals(1001.0, linkLeaveEvents.get(0).getTime(), 1e-8); + Assertions.assertEquals(f.link1.getId(), linkLeaveEvents.get(0).getLinkId()); - if (this.isDeterministic) Assert.assertEquals(1001.0, linkEnterEvents.get(0).getTime(), 1e-8); - Assert.assertEquals(f.link2.getId(), linkEnterEvents.get(0).getLinkId()); + if (this.isDeterministic) Assertions.assertEquals(1001.0, linkEnterEvents.get(0).getTime(), 1e-8); + Assertions.assertEquals(f.link2.getId(), linkEnterEvents.get(0).getLinkId()); - if (this.isDeterministic) Assert.assertEquals(1251.0, linkLeaveEvents.get(1).getTime(), 1e-8); - Assert.assertEquals(f.link2.getId(), linkLeaveEvents.get(1).getLinkId()); + if (this.isDeterministic) Assertions.assertEquals(1251.0, linkLeaveEvents.get(1).getTime(), 1e-8); + Assertions.assertEquals(f.link2.getId(), linkLeaveEvents.get(1).getLinkId()); - if (this.isDeterministic) Assert.assertEquals(1251.0, linkEnterEvents.get(1).getTime(), 1e-8); - Assert.assertEquals(f.link3.getId(), linkEnterEvents.get(1).getLinkId()); + if (this.isDeterministic) Assertions.assertEquals(1251.0, linkEnterEvents.get(1).getTime(), 1e-8); + Assertions.assertEquals(f.link3.getId(), linkEnterEvents.get(1).getLinkId()); - if (this.isDeterministic) Assert.assertEquals(1298.0, arrivesAtFacilityEvents.get(1).getTime(), 1e-8); - Assert.assertEquals(stop2.getId(), arrivesAtFacilityEvents.get(1).getFacilityId()); + if (this.isDeterministic) Assertions.assertEquals(1298.0, arrivesAtFacilityEvents.get(1).getTime(), 1e-8); + Assertions.assertEquals(stop2.getId(), arrivesAtFacilityEvents.get(1).getFacilityId()); - if (this.isDeterministic) Assert.assertEquals(1300.0, departsAtFacilityEvents.get(1).getTime(), 1e-8); - Assert.assertEquals(stop2.getId(), departsAtFacilityEvents.get(1).getFacilityId()); + if (this.isDeterministic) Assertions.assertEquals(1300.0, departsAtFacilityEvents.get(1).getTime(), 1e-8); + Assertions.assertEquals(stop2.getId(), departsAtFacilityEvents.get(1).getFacilityId()); - if (this.isDeterministic) Assert.assertEquals(1598.0, arrivesAtFacilityEvents.get(2).getTime(), 1e-8); - Assert.assertEquals(stop3.getId(), arrivesAtFacilityEvents.get(2).getFacilityId()); + if (this.isDeterministic) Assertions.assertEquals(1598.0, arrivesAtFacilityEvents.get(2).getTime(), 1e-8); + Assertions.assertEquals(stop3.getId(), arrivesAtFacilityEvents.get(2).getFacilityId()); - if (this.isDeterministic) Assert.assertEquals(1600.0, departsAtFacilityEvents.get(2).getTime(), 1e-8); - Assert.assertEquals(stop3.getId(), departsAtFacilityEvents.get(2).getFacilityId()); + if (this.isDeterministic) Assertions.assertEquals(1600.0, departsAtFacilityEvents.get(2).getTime(), 1e-8); + Assertions.assertEquals(stop3.getId(), departsAtFacilityEvents.get(2).getFacilityId()); } /** @@ -835,37 +835,37 @@ void testDeterministicCorrectTiming_initialLinks() { if (event instanceof LinkLeaveEvent) linkLeaveEvents.add((LinkLeaveEvent) event); } - Assert.assertEquals("wrong number of transit-driver-starts events.", 1, transitDriverStartsEvents.size()); - Assert.assertEquals("wrong number of link enter events.", 2, linkEnterEvents.size()); - Assert.assertEquals("wrong number of link leave events.", 2, linkLeaveEvents.size()); - Assert.assertEquals("wrong number of VehicleArrivesAtFacilityEvents.", 2, arrivesAtFacilityEvents.size()); - Assert.assertEquals("wrong number of VehicleDepartsAtFacilityEvents.", 2, departsAtFacilityEvents.size()); + Assertions.assertEquals(1, transitDriverStartsEvents.size(), "wrong number of transit-driver-starts events."); + Assertions.assertEquals(2, linkEnterEvents.size(), "wrong number of link enter events."); + Assertions.assertEquals(2, linkLeaveEvents.size(), "wrong number of link leave events."); + Assertions.assertEquals(2, arrivesAtFacilityEvents.size(), "wrong number of VehicleArrivesAtFacilityEvents."); + Assertions.assertEquals(2, departsAtFacilityEvents.size(), "wrong number of VehicleDepartsAtFacilityEvents."); - Assert.assertEquals(1000.0, transitDriverStartsEvents.get(0).getTime(), 1e-8); + Assertions.assertEquals(1000.0, transitDriverStartsEvents.get(0).getTime(), 1e-8); - if (this.isDeterministic) Assert.assertEquals(1001.0, linkLeaveEvents.get(0).getTime(), 1e-8); - Assert.assertEquals(f.link1.getId(), linkLeaveEvents.get(0).getLinkId()); + if (this.isDeterministic) Assertions.assertEquals(1001.0, linkLeaveEvents.get(0).getTime(), 1e-8); + Assertions.assertEquals(f.link1.getId(), linkLeaveEvents.get(0).getLinkId()); - if (this.isDeterministic) Assert.assertEquals(1001.0, linkEnterEvents.get(0).getTime(), 1e-8); - Assert.assertEquals(f.link2.getId(), linkEnterEvents.get(0).getLinkId()); + if (this.isDeterministic) Assertions.assertEquals(1001.0, linkEnterEvents.get(0).getTime(), 1e-8); + Assertions.assertEquals(f.link2.getId(), linkEnterEvents.get(0).getLinkId()); - if (this.isDeterministic) Assert.assertEquals(1058.0, arrivesAtFacilityEvents.get(0).getTime(), 1e-8); - Assert.assertEquals(stop2.getId(), arrivesAtFacilityEvents.get(0).getFacilityId()); + if (this.isDeterministic) Assertions.assertEquals(1058.0, arrivesAtFacilityEvents.get(0).getTime(), 1e-8); + Assertions.assertEquals(stop2.getId(), arrivesAtFacilityEvents.get(0).getFacilityId()); - if (this.isDeterministic) Assert.assertEquals(1060.0, departsAtFacilityEvents.get(0).getTime(), 1e-8); - Assert.assertEquals(stop2.getId(), departsAtFacilityEvents.get(0).getFacilityId()); + if (this.isDeterministic) Assertions.assertEquals(1060.0, departsAtFacilityEvents.get(0).getTime(), 1e-8); + Assertions.assertEquals(stop2.getId(), departsAtFacilityEvents.get(0).getFacilityId()); - if (this.isDeterministic) Assert.assertEquals(1061.0, linkLeaveEvents.get(1).getTime(), 1e-8); - Assert.assertEquals(f.link2.getId(), linkLeaveEvents.get(1).getLinkId()); + if (this.isDeterministic) Assertions.assertEquals(1061.0, linkLeaveEvents.get(1).getTime(), 1e-8); + Assertions.assertEquals(f.link2.getId(), linkLeaveEvents.get(1).getLinkId()); - if (this.isDeterministic) Assert.assertEquals(1061.0, linkEnterEvents.get(1).getTime(), 1e-8); - Assert.assertEquals(f.link3.getId(), linkEnterEvents.get(1).getLinkId()); + if (this.isDeterministic) Assertions.assertEquals(1061.0, linkEnterEvents.get(1).getTime(), 1e-8); + Assertions.assertEquals(f.link3.getId(), linkEnterEvents.get(1).getLinkId()); - if (this.isDeterministic) Assert.assertEquals(1598.0, arrivesAtFacilityEvents.get(1).getTime(), 1e-8); - Assert.assertEquals(stop3.getId(), arrivesAtFacilityEvents.get(1).getFacilityId()); + if (this.isDeterministic) Assertions.assertEquals(1598.0, arrivesAtFacilityEvents.get(1).getTime(), 1e-8); + Assertions.assertEquals(stop3.getId(), arrivesAtFacilityEvents.get(1).getFacilityId()); - if (this.isDeterministic) Assert.assertEquals(1600.0, departsAtFacilityEvents.get(1).getTime(), 1e-8); - Assert.assertEquals(stop3.getId(), departsAtFacilityEvents.get(1).getFacilityId()); + if (this.isDeterministic) Assertions.assertEquals(1600.0, departsAtFacilityEvents.get(1).getTime(), 1e-8); + Assertions.assertEquals(stop3.getId(), departsAtFacilityEvents.get(1).getFacilityId()); } /** @@ -955,45 +955,45 @@ void testTrailingLinksInRoute() { if (event instanceof PersonLeavesVehicleEvent) personLeavesVehicleEvents.add((PersonLeavesVehicleEvent) event); } - Assert.assertEquals("wrong number of transit-driver-starts events.", 1, transitDriverStartsEvents.size()); - Assert.assertEquals("wrong number of link enter events.", 2, linkEnterEvents.size()); - Assert.assertEquals("wrong number of link leave events.", 2, linkLeaveEvents.size()); - Assert.assertEquals("wrong number of VehicleArrivesAtFacilityEvents.", 2, arrivesAtFacilityEvents.size()); - Assert.assertEquals("wrong number of VehicleDepartsAtFacilityEvents.", 2, departsAtFacilityEvents.size()); - Assert.assertEquals("wrong number of PersonLeavesVehicleEvents.", 2, personLeavesVehicleEvents.size()); + Assertions.assertEquals(1, transitDriverStartsEvents.size(), "wrong number of transit-driver-starts events."); + Assertions.assertEquals(2, linkEnterEvents.size(), "wrong number of link enter events."); + Assertions.assertEquals(2, linkLeaveEvents.size(), "wrong number of link leave events."); + Assertions.assertEquals(2, arrivesAtFacilityEvents.size(), "wrong number of VehicleArrivesAtFacilityEvents."); + Assertions.assertEquals(2, departsAtFacilityEvents.size(), "wrong number of VehicleDepartsAtFacilityEvents."); + Assertions.assertEquals(2, personLeavesVehicleEvents.size(), "wrong number of PersonLeavesVehicleEvents."); - if (this.isDeterministic) Assert.assertEquals(997.0, transitDriverStartsEvents.get(0).getTime(), 1e-8); + if (this.isDeterministic) Assertions.assertEquals(997.0, transitDriverStartsEvents.get(0).getTime(), 1e-8); Id transitDriverId = transitDriverStartsEvents.get(0).getDriverId(); - if (this.isDeterministic) Assert.assertEquals(998.0, arrivesAtFacilityEvents.get(0).getTime(), 1e-8); - Assert.assertEquals(stop1.getId(), arrivesAtFacilityEvents.get(0).getFacilityId()); + if (this.isDeterministic) Assertions.assertEquals(998.0, arrivesAtFacilityEvents.get(0).getTime(), 1e-8); + Assertions.assertEquals(stop1.getId(), arrivesAtFacilityEvents.get(0).getFacilityId()); - if (this.isDeterministic) Assert.assertEquals(1000.0, departsAtFacilityEvents.get(0).getTime(), 1e-8); - Assert.assertEquals(stop1.getId(), departsAtFacilityEvents.get(0).getFacilityId()); + if (this.isDeterministic) Assertions.assertEquals(1000.0, departsAtFacilityEvents.get(0).getTime(), 1e-8); + Assertions.assertEquals(stop1.getId(), departsAtFacilityEvents.get(0).getFacilityId()); - if (this.isDeterministic) Assert.assertEquals(1001.0, linkLeaveEvents.get(0).getTime(), 1e-8); - Assert.assertEquals(f.link1.getId(), linkLeaveEvents.get(0).getLinkId()); + if (this.isDeterministic) Assertions.assertEquals(1001.0, linkLeaveEvents.get(0).getTime(), 1e-8); + Assertions.assertEquals(f.link1.getId(), linkLeaveEvents.get(0).getLinkId()); - if (this.isDeterministic) Assert.assertEquals(1001.0, linkEnterEvents.get(0).getTime(), 1e-8); - Assert.assertEquals(f.link2.getId(), linkEnterEvents.get(0).getLinkId()); + if (this.isDeterministic) Assertions.assertEquals(1001.0, linkEnterEvents.get(0).getTime(), 1e-8); + Assertions.assertEquals(f.link2.getId(), linkEnterEvents.get(0).getLinkId()); - if (this.isDeterministic) Assert.assertEquals(1298.0, arrivesAtFacilityEvents.get(1).getTime(), 1e-8); - Assert.assertEquals(stop2.getId(), arrivesAtFacilityEvents.get(1).getFacilityId()); + if (this.isDeterministic) Assertions.assertEquals(1298.0, arrivesAtFacilityEvents.get(1).getTime(), 1e-8); + Assertions.assertEquals(stop2.getId(), arrivesAtFacilityEvents.get(1).getFacilityId()); - if (this.isDeterministic) Assert.assertEquals(1299.0, personLeavesVehicleEvents.get(0).getTime(), 1e-8); - Assert.assertEquals(person.getId(), personLeavesVehicleEvents.get(0).getPersonId()); + if (this.isDeterministic) Assertions.assertEquals(1299.0, personLeavesVehicleEvents.get(0).getTime(), 1e-8); + Assertions.assertEquals(person.getId(), personLeavesVehicleEvents.get(0).getPersonId()); - if (this.isDeterministic) Assert.assertEquals(1300.0, departsAtFacilityEvents.get(1).getTime(), 1e-8); - Assert.assertEquals(stop2.getId(), departsAtFacilityEvents.get(1).getFacilityId()); + if (this.isDeterministic) Assertions.assertEquals(1300.0, departsAtFacilityEvents.get(1).getTime(), 1e-8); + Assertions.assertEquals(stop2.getId(), departsAtFacilityEvents.get(1).getFacilityId()); - if (this.isDeterministic) Assert.assertEquals(1301.0, linkLeaveEvents.get(1).getTime(), 1e-8); - Assert.assertEquals(f.link2.getId(), linkLeaveEvents.get(1).getLinkId()); + if (this.isDeterministic) Assertions.assertEquals(1301.0, linkLeaveEvents.get(1).getTime(), 1e-8); + Assertions.assertEquals(f.link2.getId(), linkLeaveEvents.get(1).getLinkId()); - if (this.isDeterministic) Assert.assertEquals(1301.0, linkEnterEvents.get(1).getTime(), 1e-8); - Assert.assertEquals(f.link3.getId(), linkEnterEvents.get(1).getLinkId()); + if (this.isDeterministic) Assertions.assertEquals(1301.0, linkEnterEvents.get(1).getTime(), 1e-8); + Assertions.assertEquals(f.link3.getId(), linkEnterEvents.get(1).getLinkId()); - if (this.isDeterministic) Assert.assertEquals(1312.0, personLeavesVehicleEvents.get(1).getTime(), 1e-8); - Assert.assertEquals(transitDriverId, personLeavesVehicleEvents.get(1).getPersonId()); + if (this.isDeterministic) Assertions.assertEquals(1312.0, personLeavesVehicleEvents.get(1).getTime(), 1e-8); + Assertions.assertEquals(transitDriverId, personLeavesVehicleEvents.get(1).getPersonId()); } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/StorageCapacityTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/StorageCapacityTest.java index 2f331bc9f8e..fd7958999fb 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/StorageCapacityTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/StorageCapacityTest.java @@ -22,7 +22,8 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.Assert; + +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -101,9 +102,9 @@ void testStorageCapacity() { System.out.println(counter3.currentMax); System.out.println(counter2.currentMax); System.out.println(counter1.currentMax); - Assert.assertEquals(14, counter3.currentMax); // the bottleneck link can store 14 vehicles - Assert.assertEquals(100, counter2.currentMax); //spillback 100 vehicles - Assert.assertEquals(100, counter1.currentMax); // spillback + Assertions.assertEquals(14, counter3.currentMax); // the bottleneck link can store 14 vehicles + Assertions.assertEquals(100, counter2.currentMax); //spillback 100 vehicles + Assertions.assertEquals(100, counter1.currentMax); // spillback } @@ -153,9 +154,9 @@ void testStorageCapacityDownscaling() { System.out.println(counter3.currentMax); System.out.println(counter2.currentMax); System.out.println(counter1.currentMax); - Assert.assertEquals(1, counter3.currentMax); // the bottleneck link can store 14 vehicles, but one vehicle counts for 10, so only 1 works - Assert.assertEquals(10, counter2.currentMax); //spillback 100 vehicles - Assert.assertEquals(10, counter1.currentMax); // spillback + Assertions.assertEquals(1, counter3.currentMax); // the bottleneck link can store 14 vehicles, but one vehicle counts for 10, so only 1 works + Assertions.assertEquals(10, counter2.currentMax); //spillback 100 vehicles + Assertions.assertEquals(10, counter1.currentMax); // spillback } @@ -218,8 +219,8 @@ void testStorageCapacityWithDifferentPCUs() { System.out.println(counter3.currentMax); System.out.println(counter2.currentMax); - Assert.assertEquals(10, counter3.currentMax); // the bottleneck link can store 14 vehicles - Assert.assertEquals(67, counter2.currentMax); //spillback 100 vehicles + Assertions.assertEquals(10, counter3.currentMax); // the bottleneck link can store 14 vehicles + Assertions.assertEquals(67, counter2.currentMax); //spillback 100 vehicles } @@ -303,8 +304,8 @@ void testStorageCapacityWithVaryingPCUs() { System.out.println(counter2.currentMax); System.out.println(counter3pm.currentMax); System.out.println(counter2pm.currentMax); - Assert.assertEquals(14, counter3.currentMax); // the bottleneck link can store 14 cars - Assert.assertEquals(100, counter2.currentMax); //spillback 100 cars + Assertions.assertEquals(14, counter3.currentMax); // the bottleneck link can store 14 cars + Assertions.assertEquals(100, counter2.currentMax); //spillback 100 cars //the following asserts fail on jenkins, but work on appveyor and travis //Assert.assertEquals(7, counter3pm.currentMax); // the bottleneck link can store 7 tractors diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/TravelTimeTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/TravelTimeTest.java index e75676a0ae5..5d8abf8fa14 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/TravelTimeTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/TravelTimeTest.java @@ -22,7 +22,7 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -68,13 +68,13 @@ void testEquilOneAgent() { .run(); Map, Double> travelTimes = agentTravelTimes.get(Id.create("1", Vehicle.class)); - Assert.assertEquals(358.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(180.0, travelTimes.get(Id.create(15, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(358.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(180.0, travelTimes.get(Id.create(15, Link.class)).intValue(), MatsimTestUtils.EPSILON); // this one is NOT a travel time (it includes two activities and a zero-length trip) - Assert.assertEquals(13558.0, travelTimes.get(Id.create(20, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(358.0, travelTimes.get(Id.create(21, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1251.0, travelTimes.get(Id.create(22, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(358.0, travelTimes.get(Id.create(23, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(13558.0, travelTimes.get(Id.create(20, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(358.0, travelTimes.get(Id.create(21, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1251.0, travelTimes.get(Id.create(22, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(358.0, travelTimes.get(Id.create(23, Link.class)).intValue(), MatsimTestUtils.EPSILON); } /** @@ -108,7 +108,7 @@ void testEquilOneAgentTravelTimeRounding() { .run(); Map, Double> travelTimes = agentTravelTimes.get(Id.create("1", Vehicle.class)); - Assert.assertEquals(358.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(358.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); // Travel time 359.9712023038 scenario.getNetwork().getLinks().get(Id.createLinkId("6")).setFreespeed(27.85); @@ -120,7 +120,7 @@ void testEquilOneAgentTravelTimeRounding() { .run(); travelTimes = agentTravelTimes.get(Id.create("1", Vehicle.class)); - Assert.assertEquals(358.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(358.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); // Travel time 359.066427289 scenario.getNetwork().getLinks().get(Id.createLinkId("6")).setFreespeed(27.85); @@ -132,7 +132,7 @@ void testEquilOneAgentTravelTimeRounding() { .run(); travelTimes = agentTravelTimes.get(Id.create("1", Vehicle.class)); - Assert.assertEquals(358.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(358.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); // Travel time 358.4229390681 scenario.getNetwork().getLinks().get(Id.createLinkId("6")).setFreespeed(27.9); @@ -144,7 +144,7 @@ void testEquilOneAgentTravelTimeRounding() { .run(); travelTimes = agentTravelTimes.get(Id.create("1", Vehicle.class)); - Assert.assertEquals(358.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(358.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); // Travel time 360.3603603604 scenario.getNetwork().getLinks().get(Id.createLinkId("6")).setFreespeed(27.75); @@ -156,7 +156,7 @@ void testEquilOneAgentTravelTimeRounding() { .run(); travelTimes = agentTravelTimes.get(Id.create("1", Vehicle.class)); - Assert.assertEquals(358.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(358.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); // Travel time 400.0 scenario.getNetwork().getLinks().get(Id.createLinkId("6")).setLength(10000.0); @@ -169,7 +169,7 @@ void testEquilOneAgentTravelTimeRounding() { .run(); travelTimes = agentTravelTimes.get(Id.create("1", Vehicle.class)); - Assert.assertEquals(401.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(401.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); } @Test @@ -194,23 +194,23 @@ void testEquilTwoAgents() { .run(); Map, Double> travelTimes = agentTravelTimes.get(Id.create("1", Vehicle.class)); - Assert.assertEquals(358.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(180.0, travelTimes.get(Id.create(15, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(358.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(180.0, travelTimes.get(Id.create(15, Link.class)).intValue(), MatsimTestUtils.EPSILON); // this one is NOT a travel time (it includes two activities and a zero-length trip) - Assert.assertEquals(13558.0, travelTimes.get(Id.create(20, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(358.0, travelTimes.get(Id.create(21, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1251.0, travelTimes.get(Id.create(22, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(358.0, travelTimes.get(Id.create(23, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(13558.0, travelTimes.get(Id.create(20, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(358.0, travelTimes.get(Id.create(21, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1251.0, travelTimes.get(Id.create(22, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(358.0, travelTimes.get(Id.create(23, Link.class)).intValue(), MatsimTestUtils.EPSILON); travelTimes = agentTravelTimes.get(Id.create("2", Vehicle.class)); - Assert.assertEquals(358.0, travelTimes.get(Id.create(5, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(180.0, travelTimes.get(Id.create(14, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(358.0, travelTimes.get(Id.create(5, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(180.0, travelTimes.get(Id.create(14, Link.class)).intValue(), MatsimTestUtils.EPSILON); // this one is NOT a travel time (it includes two activities and a zero-length trip) - Assert.assertEquals(13558.0, travelTimes.get(Id.create(20, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(358.0, travelTimes.get(Id.create(21, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1251.0, travelTimes.get(Id.create(22, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(358.0, travelTimes.get(Id.create(23, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(13558.0, travelTimes.get(Id.create(20, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(358.0, travelTimes.get(Id.create(21, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1251.0, travelTimes.get(Id.create(22, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(358.0, travelTimes.get(Id.create(23, Link.class)).intValue(), MatsimTestUtils.EPSILON); } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/AbstractJDEQSimTest.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/AbstractJDEQSimTest.java index cd7c0b8a0da..a9220f145a8 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/AbstractJDEQSimTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/AbstractJDEQSimTest.java @@ -21,7 +21,7 @@ package org.matsim.core.mobsim.jdeqsim; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.ArrayList; import java.util.HashMap; @@ -67,7 +67,7 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; -public abstract class AbstractJDEQSimTest { + public abstract class AbstractJDEQSimTest { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); @@ -228,7 +228,7 @@ protected void compareToDEQSimEvents(final String deqsimEventsFile) { ArrayList deqSimLog=CppEventFileParser.parseFile(deqsimEventsFile); for (int i=0;i 0); + Assertions.assertTrue(value.get() > 0); } @Test @@ -127,8 +127,8 @@ void testOverrideAgentFactoryTwice() { controler.addOverridingQSimModule(new TestQSimModule(value2)); controler.run(); - Assert.assertTrue(value1.get() == 0); - Assert.assertTrue(value2.get() > 0); + Assertions.assertTrue(value1.get() == 0); + Assertions.assertTrue(value2.get() > 0); } private class TestQSimModule extends AbstractQSimModule { @@ -187,7 +187,7 @@ protected void configureQSim() { controler.run(); - Assert.assertTrue(engine.called); + Assertions.assertTrue(engine.called); } static private class TestEngine implements MobsimEngine { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/FlowStorageSpillbackTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/FlowStorageSpillbackTest.java index 5dd21d977ed..7577f729919 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/FlowStorageSpillbackTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/FlowStorageSpillbackTest.java @@ -23,7 +23,8 @@ package org.matsim.core.mobsim.qsim; import java.util.*; -import org.junit.Assert; + +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.runner.RunWith; @@ -136,7 +137,7 @@ public void handleEvent(PersonEntersVehicleEvent event) { if (event.getVehicleId().equals(vehicleOfPerson.get(this.testAgent4)) && event.getLinkId().equals(this.linkId2)) { // if(this.isUsingFastCapacityUpdate) { - Assert.assertEquals("wrong link leave time.", 169., event.getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(169., event.getTime(), MatsimTestUtils.EPSILON, "wrong link leave time."); // } else { // Assert.assertEquals("wrong link leave time.", 170., event.getTime(), MatsimTestCase.EPSILON); // } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/MobsimListenerManagerTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/MobsimListenerManagerTest.java index 1c4930b1271..8637093e879 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/MobsimListenerManagerTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/MobsimListenerManagerTest.java @@ -19,7 +19,7 @@ package org.matsim.core.mobsim.qsim; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.core.mobsim.framework.events.MobsimInitializedEvent; import org.matsim.core.mobsim.framework.listeners.MobsimInitializedListener; @@ -41,10 +41,10 @@ void testAddQueueSimulationListener() { manager.addQueueSimulationListener(extendedListener); manager.addQueueSimulationListener(doubleListener); manager.fireQueueSimulationInitializedEvent(); - Assert.assertEquals(1, simpleListener.count); - Assert.assertEquals(1, subListener.count); - Assert.assertEquals(1, extendedListener.count); - Assert.assertEquals(1, doubleListener.count); + Assertions.assertEquals(1, simpleListener.count); + Assertions.assertEquals(1, subListener.count); + Assertions.assertEquals(1, extendedListener.count); + Assertions.assertEquals(1, doubleListener.count); } @Test @@ -59,20 +59,20 @@ void testRemoveQueueSimulationListener() { manager.addQueueSimulationListener(extendedListener); manager.addQueueSimulationListener(doubleListener); manager.fireQueueSimulationInitializedEvent(); - Assert.assertEquals(1, simpleListener.count); - Assert.assertEquals(1, subListener.count); - Assert.assertEquals(1, extendedListener.count); - Assert.assertEquals(1, doubleListener.count); + Assertions.assertEquals(1, simpleListener.count); + Assertions.assertEquals(1, subListener.count); + Assertions.assertEquals(1, extendedListener.count); + Assertions.assertEquals(1, doubleListener.count); manager.removeQueueSimulationListener(simpleListener); manager.removeQueueSimulationListener(subListener); manager.removeQueueSimulationListener(extendedListener); manager.removeQueueSimulationListener(doubleListener); manager.fireQueueSimulationInitializedEvent(); - Assert.assertEquals(1, simpleListener.count); // should stay at 1 - Assert.assertEquals(1, subListener.count); - Assert.assertEquals(1, extendedListener.count); - Assert.assertEquals(1, doubleListener.count); + Assertions.assertEquals(1, simpleListener.count); // should stay at 1 + Assertions.assertEquals(1, subListener.count); + Assertions.assertEquals(1, extendedListener.count); + Assertions.assertEquals(1, doubleListener.count); } /*package*/ static class TestSimListener implements MobsimInitializedListener { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NetsimRoutingConsistencyTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NetsimRoutingConsistencyTest.java index 94d1ed9b117..1253b79ec74 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NetsimRoutingConsistencyTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NetsimRoutingConsistencyTest.java @@ -25,7 +25,7 @@ import java.util.Collections; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -64,7 +64,7 @@ import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleUtils; - public class NetsimRoutingConsistencyTest { + public class NetsimRoutingConsistencyTest { /* * This test shows that the travel time that is predicted with the * NetworkRoutingModule is NOT equivalent to the travel time that is produced by @@ -202,8 +202,8 @@ void testRoutingVsSimulation() { // +1s per link double adjustedRoutingTravelTime = routingTravelTime + 2.0; - Assert.assertEquals(netsimTravelTime, 303.0, 1e-3); - Assert.assertEquals(adjustedRoutingTravelTime, 202.0, 1e-3); + Assertions.assertEquals(netsimTravelTime, 303.0, 1e-3); + Assertions.assertEquals(adjustedRoutingTravelTime, 202.0, 1e-3); } /* @@ -290,8 +290,8 @@ public void install() { // +1s per link double adjustedRoutingTravelTime = routingTravelTime + 2.0; - Assert.assertEquals(netsimTravelTime, 303.0, 1e-3); - Assert.assertEquals(adjustedRoutingTravelTime, 202.0, 1e-3); + Assertions.assertEquals(netsimTravelTime, 303.0, 1e-3); + Assertions.assertEquals(adjustedRoutingTravelTime, 202.0, 1e-3); } class DepartureArrivalListener implements PersonDepartureEventHandler, PersonArrivalEventHandler { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java index 23711c823b1..ac40a182b9d 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java @@ -26,7 +26,7 @@ import java.util.Map; import java.util.TreeMap; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -133,18 +133,18 @@ void testMergeSituationWithEmptyBufferAfterBufferRandomDistribution() { // test throughput for the first time interval /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. * the commodity on link 6_7 has not begun to send vehicles, i.e. the corresponding throughput should be 0 */ - Assert.assertEquals("Troughput on link 2_7 is wrong", 1, avgThroughputFreeFlow.get(Id.createLinkId("2_7")), MatsimTestUtils.EPSILON); - Assert.assertEquals("Troughput on link 4_7 is wrong", 2, avgThroughputFreeFlow.get(Id.createLinkId("4_7")), MatsimTestUtils.EPSILON); - Assert.assertEquals("Troughput on link 6_7 is wrong", 0, avgThroughputFreeFlow.get(Id.createLinkId("6_7")), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, avgThroughputFreeFlow.get(Id.createLinkId("2_7")), MatsimTestUtils.EPSILON, "Troughput on link 2_7 is wrong"); + Assertions.assertEquals(2, avgThroughputFreeFlow.get(Id.createLinkId("4_7")), MatsimTestUtils.EPSILON, "Troughput on link 4_7 is wrong"); + Assertions.assertEquals(0, avgThroughputFreeFlow.get(Id.createLinkId("6_7")), MatsimTestUtils.EPSILON, "Troughput on link 6_7 is wrong"); // test throughput for the second time interval /* with probability of 2/3 link 4_7 is selected and sends all vehicles from its buffer, i.e. 2; * with probability of 1/3 link 2_7 is selected and sends all vehicles from its buffer, i.e. 1 and afterwards link 4_7 can send the remaining 1. * this means, the expected average throughput of link 2_7 is 1/3 and the expected average throughput of link 4_7 is 2*2/3 + 1/3 = 5/3. */ - Assert.assertEquals("Troughput on link 2_7 is wrong", 1./3, avgThroughputCongestedTwoLinks.get(Id.createLinkId("2_7")), delta); // 0.25384615384615383 - Assert.assertEquals("Troughput on link 4_7 is wrong", 5./3, avgThroughputCongestedTwoLinks.get(Id.createLinkId("4_7")), delta); // 1.7461538461538462 - Assert.assertEquals("Troughput on link 6_7 is wrong", 0, avgThroughputCongestedTwoLinks.get(Id.createLinkId("6_7")), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1./3, avgThroughputCongestedTwoLinks.get(Id.createLinkId("2_7")), delta, "Troughput on link 2_7 is wrong"); // 0.25384615384615383 + Assertions.assertEquals(5./3, avgThroughputCongestedTwoLinks.get(Id.createLinkId("4_7")), delta, "Troughput on link 4_7 is wrong"); // 1.7461538461538462 + Assertions.assertEquals(0, avgThroughputCongestedTwoLinks.get(Id.createLinkId("6_7")), MatsimTestUtils.EPSILON, "Troughput on link 6_7 is wrong"); // test throughput for the third time interval /* with probability of 2/5 link 4_7 is selected and sends all vehicles from its buffer, i.e. 2; @@ -152,9 +152,9 @@ void testMergeSituationWithEmptyBufferAfterBufferRandomDistribution() { * with probability of 1/5 link 2_7 is selected and sends all vehicles from its buffer, i.e. 1 and afterwards link 4_7 or link 6_7 can send the remaining 1. * this means, the expected average throughput of link 2_7 is 1/5 and the expected average throughput of link 4_7 and link 6_7 is 2*2/5 + 1/10 = 9/10. */ - Assert.assertEquals("Troughput on link 2_7 is wrong", 1./5, avgThroughputCongestedThreeLinks.get(Id.createLinkId("2_7")), delta); // 0.17857142857142858 - Assert.assertEquals("Troughput on link 4_7 is wrong", 9./10, avgThroughputCongestedThreeLinks.get(Id.createLinkId("4_7")), delta); // 0.8928571428571429 - Assert.assertEquals("Troughput on link 6_7 is wrong", 9./10, avgThroughputCongestedThreeLinks.get(Id.createLinkId("6_7")), delta); // 0.9285714285714286 + Assertions.assertEquals(1./5, avgThroughputCongestedThreeLinks.get(Id.createLinkId("2_7")), delta, "Troughput on link 2_7 is wrong"); // 0.17857142857142858 + Assertions.assertEquals(9./10, avgThroughputCongestedThreeLinks.get(Id.createLinkId("4_7")), delta, "Troughput on link 4_7 is wrong"); // 0.8928571428571429 + Assertions.assertEquals(9./10, avgThroughputCongestedThreeLinks.get(Id.createLinkId("6_7")), delta, "Troughput on link 6_7 is wrong"); // 0.9285714285714286 } @Test @@ -202,9 +202,9 @@ void testMergeSituationWithMoveVehByVehRandomDistribution() { // test throughput for the first time interval /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. * the commodity on link 6_7 has not begun to send vehicles, i.e. the corresponding throughput should be 0 */ - Assert.assertEquals("Troughput on link 2_7 is wrong", 1, avgThroughputFreeFlow.get(Id.createLinkId("2_7")), MatsimTestUtils.EPSILON); - Assert.assertEquals("Troughput on link 4_7 is wrong", 2, avgThroughputFreeFlow.get(Id.createLinkId("4_7")), MatsimTestUtils.EPSILON); - Assert.assertEquals("Troughput on link 6_7 is wrong", 0, avgThroughputFreeFlow.get(Id.createLinkId("6_7")), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, avgThroughputFreeFlow.get(Id.createLinkId("2_7")), MatsimTestUtils.EPSILON, "Troughput on link 2_7 is wrong"); + Assertions.assertEquals(2, avgThroughputFreeFlow.get(Id.createLinkId("4_7")), MatsimTestUtils.EPSILON, "Troughput on link 4_7 is wrong"); + Assertions.assertEquals(0, avgThroughputFreeFlow.get(Id.createLinkId("6_7")), MatsimTestUtils.EPSILON, "Troughput on link 6_7 is wrong"); // test throughput for the second time interval /* with probability of 2/3 link 4_7 is selected and sends one vehicle; afterwards with probability of 2/3 link 4_7 is allowed to send the second vehicle, with probability 1/3 link 2_7 is allowed to send one. @@ -214,9 +214,9 @@ void testMergeSituationWithMoveVehByVehRandomDistribution() { * the numbers are as follows: the expected average throughput of link 2_7 is 2/3*1/3*1 + 1/3*1 = 5/9 * and the expected average throughput of link 4_7 is 2/3*2/3*2 + 2/3*1/3*1 + 1/3*1 = 13/9 */ - Assert.assertEquals("Troughput on link 2_7 is wrong", 5./9, avgThroughputCongestedTwoLinks.get(Id.createLinkId("2_7")), delta); // 0.5307692307692308 - Assert.assertEquals("Troughput on link 4_7 is wrong", 13./9, avgThroughputCongestedTwoLinks.get(Id.createLinkId("4_7")), delta); // 1.4692307692307693 - Assert.assertEquals("Troughput on link 6_7 is wrong", 0, avgThroughputCongestedTwoLinks.get(Id.createLinkId("6_7")), MatsimTestUtils.EPSILON); + Assertions.assertEquals(5./9, avgThroughputCongestedTwoLinks.get(Id.createLinkId("2_7")), delta, "Troughput on link 2_7 is wrong"); // 0.5307692307692308 + Assertions.assertEquals(13./9, avgThroughputCongestedTwoLinks.get(Id.createLinkId("4_7")), delta, "Troughput on link 4_7 is wrong"); // 1.4692307692307693 + Assertions.assertEquals(0, avgThroughputCongestedTwoLinks.get(Id.createLinkId("6_7")), MatsimTestUtils.EPSILON, "Troughput on link 6_7 is wrong"); // test throughput for the third time interval /* the first vehicle is send by link 2_7 with probability of 1/5 and by one of the other two links with probability 2/5. @@ -227,9 +227,9 @@ void testMergeSituationWithMoveVehByVehRandomDistribution() { * the numbers are as follows: the expected average throughput of link 2_7 is 1/5*1/2*1 + 1/5*1/2*1 + 2/5*1/5*1 + 2/5*1/5*1 = 9/25 = 0.36 * and the expected average throughput of link 4_7 and 6_7 is 1/5*1/2*1 + 2/5*2/5*2 + 2/5*1/5*1 + 2/5*2/5*1 + 2/5*2/5*1 = 41/50 */ - Assert.assertEquals("Troughput on link 2_7 is wrong", 9./25, avgThroughputCongestedThreeLinks.get(Id.createLinkId("2_7")), delta); // 0.34285714285714286 - Assert.assertEquals("Troughput on link 4_7 is wrong", 41./50, avgThroughputCongestedThreeLinks.get(Id.createLinkId("4_7")), delta); // 0.8 - Assert.assertEquals("Troughput on link 6_7 is wrong", 41./50, avgThroughputCongestedThreeLinks.get(Id.createLinkId("6_7")), delta); // 0.8571428571428571 + Assertions.assertEquals(9./25, avgThroughputCongestedThreeLinks.get(Id.createLinkId("2_7")), delta, "Troughput on link 2_7 is wrong"); // 0.34285714285714286 + Assertions.assertEquals(41./50, avgThroughputCongestedThreeLinks.get(Id.createLinkId("4_7")), delta, "Troughput on link 4_7 is wrong"); // 0.8 + Assertions.assertEquals(41./50, avgThroughputCongestedThreeLinks.get(Id.createLinkId("6_7")), delta, "Troughput on link 6_7 is wrong"); // 0.8571428571428571 } @Test @@ -280,25 +280,25 @@ void testMergeSituationWithMoveVehByVehDeterministicPriorities() { // test throughput for the first time interval /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. * the commodity on link 6_7 has not begun to send vehicles, i.e. the corresponding throughput should be 0 */ - Assert.assertEquals("Troughput on link 2_7 is wrong", 1, avgThroughputFreeFlow.get(Id.createLinkId("2_7")), delta); - Assert.assertEquals("Troughput on link 4_7 is wrong", 2, avgThroughputFreeFlow.get(Id.createLinkId("4_7")), delta); - Assert.assertEquals("Troughput on link 6_7 is wrong", 0, avgThroughputFreeFlow.get(Id.createLinkId("6_7")), delta); + Assertions.assertEquals(1, avgThroughputFreeFlow.get(Id.createLinkId("2_7")), delta, "Troughput on link 2_7 is wrong"); + Assertions.assertEquals(2, avgThroughputFreeFlow.get(Id.createLinkId("4_7")), delta, "Troughput on link 4_7 is wrong"); + Assertions.assertEquals(0, avgThroughputFreeFlow.get(Id.createLinkId("6_7")), delta, "Troughput on link 6_7 is wrong"); // test throughput for the second time interval /* the deterministic node transition should distribute the free slots on the downstream link exactly proportional to the outflow capacity of the links, * i.e. 1:2 in this case */ - Assert.assertEquals("Troughput on link 2_7 is wrong", 1./3 * 2, avgThroughputCongestedTwoLinks.get(Id.createLinkId("2_7")), deltaPeriodic); // 0.6692307692307692 - Assert.assertEquals("Troughput on link 4_7 is wrong", 2./3 * 2, avgThroughputCongestedTwoLinks.get(Id.createLinkId("4_7")), deltaPeriodic); // 1.3307692307692307 - Assert.assertEquals("Troughput on link 6_7 is wrong", 0, avgThroughputCongestedTwoLinks.get(Id.createLinkId("6_7")), delta); + Assertions.assertEquals(1./3 * 2, avgThroughputCongestedTwoLinks.get(Id.createLinkId("2_7")), deltaPeriodic, "Troughput on link 2_7 is wrong"); // 0.6692307692307692 + Assertions.assertEquals(2./3 * 2, avgThroughputCongestedTwoLinks.get(Id.createLinkId("4_7")), deltaPeriodic, "Troughput on link 4_7 is wrong"); // 1.3307692307692307 + Assertions.assertEquals(0, avgThroughputCongestedTwoLinks.get(Id.createLinkId("6_7")), delta, "Troughput on link 6_7 is wrong"); // test throughput for the third time interval /* the deterministic node transition should distribute the free slots on the downstream link exactly proportional to the outflow capacity of the links, * i.e. 1:2:2 in this case. */ - Assert.assertEquals("Troughput on link 2_7 is wrong", 1./5 * 2, avgThroughputCongestedThreeLinks.get(Id.createLinkId("2_7")), delta); // 0.4 - Assert.assertEquals("Troughput on link 4_7 is wrong", 2./5 * 2, avgThroughputCongestedThreeLinks.get(Id.createLinkId("4_7")), delta); // 0.8 - Assert.assertEquals("Troughput on link 6_7 is wrong", 2./5 * 2, avgThroughputCongestedThreeLinks.get(Id.createLinkId("6_7")), delta); // 0.8 + Assertions.assertEquals(1./5 * 2, avgThroughputCongestedThreeLinks.get(Id.createLinkId("2_7")), delta, "Troughput on link 2_7 is wrong"); // 0.4 + Assertions.assertEquals(2./5 * 2, avgThroughputCongestedThreeLinks.get(Id.createLinkId("4_7")), delta, "Troughput on link 4_7 is wrong"); // 0.8 + Assertions.assertEquals(2./5 * 2, avgThroughputCongestedThreeLinks.get(Id.createLinkId("6_7")), delta, "Troughput on link 6_7 is wrong"); // 0.8 } @Test @@ -357,18 +357,18 @@ void testBlockedNodeSituationWithEmptyBufferAfterBufferRandomDistribution() { /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be zero here. */ - Assert.assertEquals("Troughput on link 2_5 is wrong", 2, avgThroughputFreeFlow.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON); - Assert.assertEquals("Troughput on link 4_5 is wrong", 1, avgThroughputFreeFlow.get(Id.createLinkId("4_5")), MatsimTestUtils.EPSILON); - Assert.assertEquals("Troughput on link 5_8 is wrong", 0, avgThroughputFreeFlow.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, avgThroughputFreeFlow.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON, "Troughput on link 2_5 is wrong"); + Assertions.assertEquals(1, avgThroughputFreeFlow.get(Id.createLinkId("4_5")), MatsimTestUtils.EPSILON, "Troughput on link 4_5 is wrong"); + Assertions.assertEquals(0, avgThroughputFreeFlow.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON, "Troughput on link 5_8 is wrong"); // test throughput for the second time interval /* with probability 1/3 link 4_5 is selected first and can send all its vehicles from the buffer (i.e. one) before link 2_5 blocks the intersection. * if link 2_5 is selected first the intersection is blocked immediately. * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be zero here. */ - Assert.assertEquals("Troughput on link 2_5 is wrong", 0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON); - Assert.assertEquals("Troughput on link 4_5 is wrong", 1./3, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("4_5")), delta); // 0.36666666666666664 - Assert.assertEquals("Troughput on link 5_8 is wrong", 0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON, "Troughput on link 2_5 is wrong"); + Assertions.assertEquals(1./3, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("4_5")), delta, "Troughput on link 4_5 is wrong"); // 0.36666666666666664 + Assertions.assertEquals(0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON, "Troughput on link 5_8 is wrong"); // test throughput for the third time interval /* with probability 1/3 link 4_5 is selected first and can send all its vehicles from the buffer (i.e. one) before link 2_5 sends its first one and blocks the intersection. @@ -377,9 +377,9 @@ void testBlockedNodeSituationWithEmptyBufferAfterBufferRandomDistribution() { * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be equal to the flow * capacity of link 5_8 here, i.e. 1 veh per time step (=sec). */ - Assert.assertEquals("Troughput on link 2_5 is wrong", 1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON); - Assert.assertEquals("Troughput on link 4_5 is wrong", 1./3, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("4_5")), delta); // 0.3263157894736842 - Assert.assertEquals("Troughput on link 5_8 is wrong", 1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON, "Troughput on link 2_5 is wrong"); + Assertions.assertEquals(1./3, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("4_5")), delta, "Troughput on link 4_5 is wrong"); // 0.3263157894736842 + Assertions.assertEquals(1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON, "Troughput on link 5_8 is wrong"); } @Test @@ -438,18 +438,18 @@ void testBlockedNodeSituationWithMoveVehByVehRandomDistribution() { /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be zero here. */ - Assert.assertEquals("Troughput on link 2_5 is wrong", 2, avgThroughputFreeFlow.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON); - Assert.assertEquals("Troughput on link 4_5 is wrong", 1, avgThroughputFreeFlow.get(Id.createLinkId("4_5")), MatsimTestUtils.EPSILON); - Assert.assertEquals("Troughput on link 5_8 is wrong", 0, avgThroughputFreeFlow.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, avgThroughputFreeFlow.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON, "Troughput on link 2_5 is wrong"); + Assertions.assertEquals(1, avgThroughputFreeFlow.get(Id.createLinkId("4_5")), MatsimTestUtils.EPSILON, "Troughput on link 4_5 is wrong"); + Assertions.assertEquals(0, avgThroughputFreeFlow.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON, "Troughput on link 5_8 is wrong"); // test throughput for the second time interval /* with probability 1/3 link 4_5 is selected first and can send one vehicle before link 2_5 blocks the intersection. * if link 2_5 is selected first the intersection is blocked immediately. * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be zero here. */ - Assert.assertEquals("Troughput on link 2_5 is wrong", 0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON); - Assert.assertEquals("Troughput on link 4_5 is wrong", 1./3, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("4_5")), delta); // 0.3333333333333333 - Assert.assertEquals("Troughput on link 5_8 is wrong", 0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON, "Troughput on link 2_5 is wrong"); + Assertions.assertEquals(1./3, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("4_5")), delta, "Troughput on link 4_5 is wrong"); // 0.3333333333333333 + Assertions.assertEquals(0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON, "Troughput on link 5_8 is wrong"); // test throughput for the third time interval /* with probability 1/3 link 4_5 is selected first and can send one vehicle before link 2_5 sends its first one and blocks the intersection. @@ -459,9 +459,9 @@ void testBlockedNodeSituationWithMoveVehByVehRandomDistribution() { * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be equal to the flow * capacity of link 5_8 here, i.e. 1 veh per time step (=sec). */ - Assert.assertEquals("Troughput on link 2_5 is wrong", 1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON); - Assert.assertEquals("Troughput on link 4_5 is wrong", 5./9, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("4_5")), delta); // 0.5736842105263158 - Assert.assertEquals("Troughput on link 5_8 is wrong", 1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON, "Troughput on link 2_5 is wrong"); + Assertions.assertEquals(5./9, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("4_5")), delta, "Troughput on link 4_5 is wrong"); // 0.5736842105263158 + Assertions.assertEquals(1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON, "Troughput on link 5_8 is wrong"); } @Test @@ -521,9 +521,9 @@ void testBlockedNodeSituationWithMoveVehByVehDeterministicPriorities() { /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be zero here. */ - Assert.assertEquals("Troughput on link 2_5 is wrong", 2, avgThroughputFreeFlow.get(Id.createLinkId("2_5")), delta); - Assert.assertEquals("Troughput on link 4_5 is wrong", 1, avgThroughputFreeFlow.get(Id.createLinkId("4_5")), delta); - Assert.assertEquals("Troughput on link 5_8 is wrong", 0, avgThroughputFreeFlow.get(Id.createLinkId("5_8")), delta); + Assertions.assertEquals(2, avgThroughputFreeFlow.get(Id.createLinkId("2_5")), delta, "Troughput on link 2_5 is wrong"); + Assertions.assertEquals(1, avgThroughputFreeFlow.get(Id.createLinkId("4_5")), delta, "Troughput on link 4_5 is wrong"); + Assertions.assertEquals(0, avgThroughputFreeFlow.get(Id.createLinkId("5_8")), delta, "Troughput on link 5_8 is wrong"); // test throughput for the second time interval /* the deterministic node transition should reduce the outflow of all links by the same percentage with which the outflow of links has to be reduced that lead to congested links. @@ -531,9 +531,9 @@ void testBlockedNodeSituationWithMoveVehByVehDeterministicPriorities() { * this works because the link with downstream congestion has and keeps the minimal priority (i.e. is always selected first) as soon as the move node step is stopped because of downstream congestion. * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be zero here. */ - Assert.assertEquals("Troughput on link 2_5 is wrong", 0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("2_5")), delta); - Assert.assertEquals("Troughput on link 4_5 is wrong", 0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("4_5")), delta); - Assert.assertEquals("Troughput on link 5_8 is wrong", 0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("5_8")), delta); + Assertions.assertEquals(0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("2_5")), delta, "Troughput on link 2_5 is wrong"); + Assertions.assertEquals(0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("4_5")), delta, "Troughput on link 4_5 is wrong"); + Assertions.assertEquals(0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("5_8")), delta, "Troughput on link 5_8 is wrong"); // test throughput for the third time interval /* the deterministic node transition should reduce the outflow of all links by the same percentage with which the outflow of links has to be reduced that lead to congested links. @@ -541,9 +541,9 @@ void testBlockedNodeSituationWithMoveVehByVehDeterministicPriorities() { * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be equal to the flow * capacity of link 5_8 here, i.e. 1 veh per time step (=sec). */ - Assert.assertEquals("Troughput on link 2_5 is wrong", 1./2 * 2, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("2_5")), delta); - Assert.assertEquals("Troughput on link 4_5 is wrong", 1./2 * 1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("4_5")), delta); - Assert.assertEquals("Troughput on link 5_8 is wrong", 1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("5_8")), delta); + Assertions.assertEquals(1./2 * 2, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("2_5")), delta, "Troughput on link 2_5 is wrong"); + Assertions.assertEquals(1./2 * 1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("4_5")), delta, "Troughput on link 4_5 is wrong"); + Assertions.assertEquals(1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("5_8")), delta, "Troughput on link 5_8 is wrong"); } /** @@ -611,18 +611,18 @@ void testNodeTransitionWithTimeStepSizeSmallerOne() { /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be zero here. */ - Assert.assertEquals("Troughput on link 2_5 is wrong", 1, avgThroughputFreeFlow.get(Id.createLinkId("2_5")), delta); - Assert.assertEquals("Troughput on link 4_5 is wrong", 0.5, avgThroughputFreeFlow.get(Id.createLinkId("4_5")), delta); - Assert.assertEquals("Troughput on link 5_8 is wrong", 0.0, avgThroughputFreeFlow.get(Id.createLinkId("5_8")), delta); + Assertions.assertEquals(1, avgThroughputFreeFlow.get(Id.createLinkId("2_5")), delta, "Troughput on link 2_5 is wrong"); + Assertions.assertEquals(0.5, avgThroughputFreeFlow.get(Id.createLinkId("4_5")), delta, "Troughput on link 4_5 is wrong"); + Assertions.assertEquals(0.0, avgThroughputFreeFlow.get(Id.createLinkId("5_8")), delta, "Troughput on link 5_8 is wrong"); // test throughput for the second time interval /* the downstream link of 2_5 is full, i.e. no vehicles can leave 2_5 in this time interval. * link 4_5 is not affected by this, because blockNodeWhenSingleOutlinkFull is set to false. * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be zero here. */ - Assert.assertEquals("Troughput on link 2_5 is wrong", 0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("2_5")), delta); - Assert.assertEquals("Troughput on link 4_5 is wrong", 0.5, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("4_5")), delta); - Assert.assertEquals("Troughput on link 5_8 is wrong", 0.0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("5_8")), delta); + Assertions.assertEquals(0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("2_5")), delta, "Troughput on link 2_5 is wrong"); + Assertions.assertEquals(0.5, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("4_5")), delta, "Troughput on link 4_5 is wrong"); + Assertions.assertEquals(0.0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("5_8")), delta, "Troughput on link 5_8 is wrong"); // test throughput for the third time interval /* the downstream link of 2_5 lets 1 veh in every two time steps, i.e. throughput of link 2_5 should be 0.5 per time step. @@ -630,9 +630,9 @@ void testNodeTransitionWithTimeStepSizeSmallerOne() { * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be equal to the flow * capacity of link 5_8 here, i.e. 0.5 veh per time step. */ - Assert.assertEquals("Troughput on link 2_5 is wrong", 0.5, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("2_5")), delta); - Assert.assertEquals("Troughput on link 4_5 is wrong", 0.5, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("4_5")), delta); - Assert.assertEquals("Troughput on link 5_8 is wrong", 0.5, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("5_8")), delta); + Assertions.assertEquals(0.5, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("2_5")), delta, "Troughput on link 2_5 is wrong"); + Assertions.assertEquals(0.5, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("4_5")), delta, "Troughput on link 4_5 is wrong"); + Assertions.assertEquals(0.5, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("5_8")), delta, "Troughput on link 5_8 is wrong"); } private static final class Fixture { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimTest.java index b27f758dfb3..fcded837c33 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimTest.java @@ -29,7 +29,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -170,9 +170,9 @@ void testSingleAgent() { sim.run(); /* finish */ - Assert.assertEquals("wrong number of link enter events.", 2, collector.events.size()); - Assert.assertEquals("wrong time in first event.", 6.0*3600 + 1, collector.events.get(0).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in second event.", 6.0*3600 + 12, collector.events.get(1).getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, collector.events.size(), "wrong number of link enter events."); + Assertions.assertEquals(6.0*3600 + 1, collector.events.get(0).getTime(), MatsimTestUtils.EPSILON, "wrong time in first event."); + Assertions.assertEquals(6.0*3600 + 12, collector.events.get(1).getTime(), MatsimTestUtils.EPSILON, "wrong time in second event."); } @@ -238,9 +238,9 @@ void testSingleAgentWithEndOnLeg() { } // // /* finish */ - Assert.assertEquals("wrong number of link enter events.", 2, collector.events.size()); - Assert.assertEquals("wrong time in first event.", 6.0*3600 + 1, collector.events.get(0).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in second event.", 6.0*3600 + 12, collector.events.get(1).getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, collector.events.size(), "wrong number of link enter events."); + Assertions.assertEquals(6.0*3600 + 1, collector.events.get(0).getTime(), MatsimTestUtils.EPSILON, "wrong time in first event."); + Assertions.assertEquals(6.0*3600 + 12, collector.events.get(1).getTime(), MatsimTestUtils.EPSILON, "wrong time in second event."); } /** @@ -278,11 +278,11 @@ void testTwoAgent() { sim.run(); /* finish */ - Assert.assertEquals("wrong number of link enter events.", 4, collector.events.size()); - Assert.assertEquals("wrong time in first event.", 6.0*3600 + 1, collector.events.get(0).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in second event.", 6.0*3600 + 12, collector.events.get(1).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in first event.", 7.0*3600 + 1, collector.events.get(2).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in second event.", 7.0*3600 + 12, collector.events.get(3).getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(4, collector.events.size(), "wrong number of link enter events."); + Assertions.assertEquals(6.0*3600 + 1, collector.events.get(0).getTime(), MatsimTestUtils.EPSILON, "wrong time in first event."); + Assertions.assertEquals(6.0*3600 + 12, collector.events.get(1).getTime(), MatsimTestUtils.EPSILON, "wrong time in second event."); + Assertions.assertEquals(7.0*3600 + 1, collector.events.get(2).getTime(), MatsimTestUtils.EPSILON, "wrong time in first event."); + Assertions.assertEquals(7.0*3600 + 12, collector.events.get(3).getTime(), MatsimTestUtils.EPSILON, "wrong time in second event."); } /** @@ -317,16 +317,16 @@ void testTeleportationSingleAgent() { sim.run(); List allEvents = collector.getEvents(); - Assert.assertEquals("wrong number of events.", 5, collector.getEvents().size()); - Assert.assertEquals("wrong type of event.", ActivityEndEvent.class, allEvents.get(0).getClass()); - Assert.assertEquals("wrong type of event.", PersonDepartureEvent.class, allEvents.get(1).getClass()); - Assert.assertEquals("wrong type of event.", TeleportationArrivalEvent.class, allEvents.get(2).getClass()); - Assert.assertEquals("wrong type of event.", PersonArrivalEvent.class, allEvents.get(3).getClass()); - Assert.assertEquals("wrong type of event.", ActivityStartEvent.class, allEvents.get(4).getClass()); - Assert.assertEquals("wrong time in event.", 6.0*3600 + 0, allEvents.get(0).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in event.", 6.0*3600 + 0, allEvents.get(1).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in event.", 6.0*3600 + 15, allEvents.get(2).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in event.", 6.0*3600 + 15, allEvents.get(3).getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(5, collector.getEvents().size(), "wrong number of events."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(0).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(1).getClass(), "wrong type of event."); + Assertions.assertEquals(TeleportationArrivalEvent.class, allEvents.get(2).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(3).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(4).getClass(), "wrong type of event."); + Assertions.assertEquals(6.0*3600 + 0, allEvents.get(0).getTime(), MatsimTestUtils.EPSILON, "wrong time in event."); + Assertions.assertEquals(6.0*3600 + 0, allEvents.get(1).getTime(), MatsimTestUtils.EPSILON, "wrong time in event."); + Assertions.assertEquals(6.0*3600 + 15, allEvents.get(2).getTime(), MatsimTestUtils.EPSILON, "wrong time in event."); + Assertions.assertEquals(6.0*3600 + 15, allEvents.get(3).getTime(), MatsimTestUtils.EPSILON, "wrong time in event."); } /** @@ -365,9 +365,9 @@ void testSingleAgentImmediateDeparture() { sim.run(); /* finish */ - Assert.assertEquals("wrong number of link enter events.", 2, collector.events.size()); - Assert.assertEquals("wrong time in first event.", 0.0*3600 + 1, collector.events.get(0).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in second event.", 0.0*3600 + 12, collector.events.get(1).getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, collector.events.size(), "wrong number of link enter events."); + Assertions.assertEquals(0.0*3600 + 1, collector.events.get(0).getTime(), MatsimTestUtils.EPSILON, "wrong time in first event."); + Assertions.assertEquals(0.0*3600 + 12, collector.events.get(1).getTime(), MatsimTestUtils.EPSILON, "wrong time in second event."); } /** @@ -413,40 +413,44 @@ void testSingleAgent_EmptyRoute() { for (Event event : allEvents) { System.out.println(event); } - Assert.assertEquals("wrong number of events.", 8, allEvents.size()); - - - Assert.assertEquals("wrong type of 1st event.", ActivityEndEvent.class, allEvents.get(0).getClass()); - Assert.assertEquals("wrong type of 2nd event.", PersonDepartureEvent.class, allEvents.get(1).getClass()); - Assert.assertEquals("wrong type of 3rd event.", PersonEntersVehicleEvent.class, allEvents.get(2).getClass()); - Assert.assertEquals("wrong type of 4th event.", VehicleEntersTrafficEvent.class, allEvents.get(3).getClass()); - Assert.assertEquals("wrong type of 5th event.", VehicleLeavesTrafficEvent.class, allEvents.get(4).getClass()); - Assert.assertEquals("wrong type of 6th event.", PersonLeavesVehicleEvent.class, allEvents.get(5).getClass()); - Assert.assertEquals("wrong type of 7th event.", PersonArrivalEvent.class, allEvents.get(6).getClass()); - Assert.assertEquals("wrong type of 8th event.", ActivityStartEvent.class, allEvents.get(7).getClass()); - - - Assert.assertEquals("wrong time in 1st event.", 6.0*3600 + 0, allEvents.get(0).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in 2nd event.", 6.0*3600 + 0, allEvents.get(1).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in 3rd event.", 6.0*3600 + 0, allEvents.get(2).getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in 4th event.", 6.0*3600 + 0, allEvents.get(3).getTime(), MatsimTestUtils.EPSILON); - - Assert.assertEquals("wrong time in 5th event.", 6.0 * 3600 + 0, allEvents.get(4).getTime(), - MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in 6th event.", 6.0 * 3600 + 0, allEvents.get(5).getTime(), - MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in 7th event.", 6.0 * 3600 + 0, allEvents.get(6).getTime(), - MatsimTestUtils.EPSILON); - Assert.assertEquals("wrong time in 8th event.", 6.0 * 3600 + 0, allEvents.get(7).getTime(), - MatsimTestUtils.EPSILON); - - - Assert.assertEquals("wrong link in 1st event.", f.link1.getId(), ((ActivityEndEvent) allEvents.get(0)).getLinkId() ); - Assert.assertEquals("wrong link in 2nd event.", f.link1.getId(), ((PersonDepartureEvent) allEvents.get(1)).getLinkId() ); - Assert.assertEquals("wrong link in 4th event.", f.link1.getId(), ((VehicleEntersTrafficEvent) allEvents.get(3)).getLinkId() ); - Assert.assertEquals("wrong link in 5th event.", f.link1.getId(), ((VehicleLeavesTrafficEvent) allEvents.get(4)).getLinkId() ); - Assert.assertEquals("wrong link in 7th event.", f.link1.getId(), ((PersonArrivalEvent) allEvents.get(6)).getLinkId() ); - Assert.assertEquals("wrong link in 8th event.", f.link1.getId(), ((ActivityStartEvent) allEvents.get(7)).getLinkId() ); + Assertions.assertEquals(8, allEvents.size(), "wrong number of events."); + + + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(0).getClass(), "wrong type of 1st event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(1).getClass(), "wrong type of 2nd event."); + Assertions.assertEquals(PersonEntersVehicleEvent.class, allEvents.get(2).getClass(), "wrong type of 3rd event."); + Assertions.assertEquals(VehicleEntersTrafficEvent.class, allEvents.get(3).getClass(), "wrong type of 4th event."); + Assertions.assertEquals(VehicleLeavesTrafficEvent.class, allEvents.get(4).getClass(), "wrong type of 5th event."); + Assertions.assertEquals(PersonLeavesVehicleEvent.class, allEvents.get(5).getClass(), "wrong type of 6th event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(6).getClass(), "wrong type of 7th event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(7).getClass(), "wrong type of 8th event."); + + + Assertions.assertEquals(6.0*3600 + 0, allEvents.get(0).getTime(), MatsimTestUtils.EPSILON, "wrong time in 1st event."); + Assertions.assertEquals(6.0*3600 + 0, allEvents.get(1).getTime(), MatsimTestUtils.EPSILON, "wrong time in 2nd event."); + Assertions.assertEquals(6.0*3600 + 0, allEvents.get(2).getTime(), MatsimTestUtils.EPSILON, "wrong time in 3rd event."); + Assertions.assertEquals(6.0*3600 + 0, allEvents.get(3).getTime(), MatsimTestUtils.EPSILON, "wrong time in 4th event."); + + Assertions.assertEquals(6.0 * 3600 + 0, allEvents.get(4).getTime(), + MatsimTestUtils.EPSILON, + "wrong time in 5th event."); + Assertions.assertEquals(6.0 * 3600 + 0, allEvents.get(5).getTime(), + MatsimTestUtils.EPSILON, + "wrong time in 6th event."); + Assertions.assertEquals(6.0 * 3600 + 0, allEvents.get(6).getTime(), + MatsimTestUtils.EPSILON, + "wrong time in 7th event."); + Assertions.assertEquals(6.0 * 3600 + 0, allEvents.get(7).getTime(), + MatsimTestUtils.EPSILON, + "wrong time in 8th event."); + + + Assertions.assertEquals(f.link1.getId(), ((ActivityEndEvent) allEvents.get(0)).getLinkId(), "wrong link in 1st event." ); + Assertions.assertEquals(f.link1.getId(), ((PersonDepartureEvent) allEvents.get(1)).getLinkId(), "wrong link in 2nd event." ); + Assertions.assertEquals(f.link1.getId(), ((VehicleEntersTrafficEvent) allEvents.get(3)).getLinkId(), "wrong link in 4th event." ); + Assertions.assertEquals(f.link1.getId(), ((VehicleLeavesTrafficEvent) allEvents.get(4)).getLinkId(), "wrong link in 5th event." ); + Assertions.assertEquals(f.link1.getId(), ((PersonArrivalEvent) allEvents.get(6)).getLinkId(), "wrong link in 7th event." ); + Assertions.assertEquals(f.link1.getId(), ((ActivityStartEvent) allEvents.get(7)).getLinkId(), "wrong link in 8th event." ); } /** @@ -491,21 +495,21 @@ void testSingleAgent_LastLinkIsLoop() { for (Event event : allEvents) { System.out.println(event); } - Assert.assertEquals("wrong number of events.", 14, allEvents.size()); - Assert.assertEquals("wrong type of 1st event.", ActivityEndEvent.class, allEvents.get(0).getClass()); - Assert.assertEquals("wrong type of 2nd event.", PersonDepartureEvent.class, allEvents.get(1).getClass()); - Assert.assertEquals("wrong type of event.", PersonEntersVehicleEvent.class, allEvents.get(2).getClass()); - Assert.assertEquals("wrong type of event.", VehicleEntersTrafficEvent.class, allEvents.get(3).getClass()); - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(4).getClass()); // link 1 - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(5).getClass()); // link 2 - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(6).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(7).getClass()); // link 3 - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(8).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(9).getClass()); // loop link - Assert.assertEquals("wrong type of event.", VehicleLeavesTrafficEvent.class, allEvents.get(10).getClass()); - Assert.assertEquals("wrong type of event.", PersonLeavesVehicleEvent.class, allEvents.get(11).getClass()); - Assert.assertEquals("wrong type of 11th event.", PersonArrivalEvent.class, allEvents.get(12).getClass()); - Assert.assertEquals("wrong type of 12th event.", ActivityStartEvent.class, allEvents.get(13).getClass()); + Assertions.assertEquals(14, allEvents.size(), "wrong number of events."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(0).getClass(), "wrong type of 1st event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(1).getClass(), "wrong type of 2nd event."); + Assertions.assertEquals(PersonEntersVehicleEvent.class, allEvents.get(2).getClass(), "wrong type of event."); + Assertions.assertEquals(VehicleEntersTrafficEvent.class, allEvents.get(3).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(4).getClass(), "wrong type of event."); // link 1 + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(5).getClass(), "wrong type of event."); // link 2 + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(6).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(7).getClass(), "wrong type of event."); // link 3 + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(8).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(9).getClass(), "wrong type of event."); // loop link + Assertions.assertEquals(VehicleLeavesTrafficEvent.class, allEvents.get(10).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonLeavesVehicleEvent.class, allEvents.get(11).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(12).getClass(), "wrong type of 11th event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(13).getClass(), "wrong type of 12th event."); } /*package*/ static class LinkEnterEventCollector implements LinkEnterEventHandler { @@ -544,7 +548,7 @@ void testAgentWithoutLeg() { sim.run(); /* finish */ - Assert.assertEquals("wrong number of link enter events.", 0, collector.events.size()); + Assertions.assertEquals(0, collector.events.size(), "wrong number of link enter events."); } /** @@ -572,7 +576,7 @@ void testAgentWithoutLegWithEndtime() { sim.run(); /* finish */ - Assert.assertEquals("wrong number of link enter events.", 0, collector.events.size()); + Assertions.assertEquals(0, collector.events.size(), "wrong number of link enter events."); } /** @@ -606,7 +610,7 @@ void testAgentWithLastActWithEndtime() { sim.run(); /* finish */ - Assert.assertEquals("wrong number of link enter events.", 0, collector.events.size()); + Assertions.assertEquals(0, collector.events.size(), "wrong number of link enter events."); } /** @@ -663,9 +667,9 @@ void testFlowCapacityDriving() { System.out.println("#vehicles 8-9: " + Integer.toString(volume[8])); // if(this.isUsingFastCapacityUpdate) { - Assert.assertEquals(3001, volume[6]); // we should have half of the maximum flow in this hour - Assert.assertEquals(6000, volume[7]); // we should have maximum flow in this hour - Assert.assertEquals(999, volume[8]); // all the rest + Assertions.assertEquals(3001, volume[6]); // we should have half of the maximum flow in this hour + Assertions.assertEquals(6000, volume[7]); // we should have maximum flow in this hour + Assertions.assertEquals(999, volume[8]); // all the rest // } else { // Assert.assertEquals(3000, volume[6]); // we should have half of the maximum flow in this hour // Assert.assertEquals(6000, volume[7]); // we should have maximum flow in this hour @@ -722,9 +726,9 @@ void testFlowCapacityDrivingFraction() { /* finish */ int[] volume = vAnalyzer.getVolumesForLink(f.link2.getId()); - Assert.assertEquals(1, volume[7*3600 - 1800]); // First vehicle - Assert.assertEquals(1, volume[7*3600 - 1800 + 4]); // Second vehicle - Assert.assertEquals(1, volume[7*3600 - 1800 + 8]); // Third vehicle + Assertions.assertEquals(1, volume[7*3600 - 1800]); // First vehicle + Assertions.assertEquals(1, volume[7*3600 - 1800 + 4]); // Second vehicle + Assertions.assertEquals(1, volume[7*3600 - 1800 + 8]); // Third vehicle } /** @@ -773,9 +777,9 @@ void testFlowCapacityStarting() { System.out.println("#vehicles 8-9: " + Integer.toString(volume[8])); // if(this.isUsingFastCapacityUpdate) { - Assert.assertEquals(3001, volume[6]); // we should have half of the maximum flow in this hour - Assert.assertEquals(6000, volume[7]); // we should have maximum flow in this hour - Assert.assertEquals(999, volume[8]); // all the rest + Assertions.assertEquals(3001, volume[6]); // we should have half of the maximum flow in this hour + Assertions.assertEquals(6000, volume[7]); // we should have maximum flow in this hour + Assertions.assertEquals(999, volume[8]); // all the rest // } else { // Assert.assertEquals(3000, volume[6]); // we should have half of the maximum flow in this hour // Assert.assertEquals(6000, volume[7]); // we should have maximum flow in this hour @@ -842,9 +846,9 @@ void testFlowCapacityMixed() { System.out.println("#vehicles 8-9: " + Integer.toString(volume[8])); // if(this.isUsingFastCapacityUpdate) { - Assert.assertEquals(3001, volume[6]); // we should have half of the maximum flow in this hour - Assert.assertEquals(6000, volume[7]); // we should have maximum flow in this hour - Assert.assertEquals(999, volume[8]); // all the rest + Assertions.assertEquals(3001, volume[6]); // we should have half of the maximum flow in this hour + Assertions.assertEquals(6000, volume[7]); // we should have maximum flow in this hour + Assertions.assertEquals(999, volume[8]); // all the rest // } else { // Assert.assertEquals(3000, volume[6]); // we should have half of the maximum flow in this hour // Assert.assertEquals(6000, volume[7]); // we should have maximum flow in this hour @@ -889,22 +893,22 @@ void testVehicleTeleportationTrue() { sim.run(); List allEvents = collector.getEvents(); - Assert.assertEquals("wrong number of events.", 15, allEvents.size()); - Assert.assertEquals("wrong type of event.", ActivityEndEvent.class, allEvents.get(0).getClass()); - Assert.assertEquals("wrong type of event.", PersonDepartureEvent.class, allEvents.get(1).getClass()); - Assert.assertEquals("wrong type of event.", TeleportationArrivalEvent.class, allEvents.get(2).getClass()); - Assert.assertEquals("wrong type of event.", PersonArrivalEvent.class, allEvents.get(3).getClass()); - Assert.assertEquals("wrong type of event.", ActivityStartEvent.class, allEvents.get(4).getClass()); - Assert.assertEquals("wrong type of event.", ActivityEndEvent.class, allEvents.get(5).getClass()); - Assert.assertEquals("wrong type of event.", PersonDepartureEvent.class, allEvents.get(6).getClass()); - Assert.assertEquals("wrong type of event.", PersonEntersVehicleEvent.class, allEvents.get(7).getClass()); - Assert.assertEquals("wrong type of event.", VehicleEntersTrafficEvent.class, allEvents.get(8).getClass()); - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(9).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(10).getClass()); - Assert.assertEquals("wrong type of event.", VehicleLeavesTrafficEvent.class, allEvents.get(11).getClass()); - Assert.assertEquals("wrong type of event.", PersonLeavesVehicleEvent.class, allEvents.get(12).getClass()); - Assert.assertEquals("wrong type of event.", PersonArrivalEvent.class, allEvents.get(13).getClass()); - Assert.assertEquals("wrong type of event.", ActivityStartEvent.class, allEvents.get(14).getClass()); + Assertions.assertEquals(15, allEvents.size(), "wrong number of events."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(0).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(1).getClass(), "wrong type of event."); + Assertions.assertEquals(TeleportationArrivalEvent.class, allEvents.get(2).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(3).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(4).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(5).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(6).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonEntersVehicleEvent.class, allEvents.get(7).getClass(), "wrong type of event."); + Assertions.assertEquals(VehicleEntersTrafficEvent.class, allEvents.get(8).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(9).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(10).getClass(), "wrong type of event."); + Assertions.assertEquals(VehicleLeavesTrafficEvent.class, allEvents.get(11).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonLeavesVehicleEvent.class, allEvents.get(12).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(13).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(14).getClass(), "wrong type of event."); } @@ -970,37 +974,37 @@ void testWaitingForCar() { for (Event event : allEvents) { System.out.println(event); } - Assert.assertEquals("wrong number of events.", 30, allEvents.size()); - Assert.assertEquals("wrong type of event.", ActivityEndEvent.class, allEvents.get(0).getClass()); - Assert.assertEquals("wrong type of event.", PersonDepartureEvent.class, allEvents.get(1).getClass()); - Assert.assertEquals("wrong type of event.", TeleportationArrivalEvent.class, allEvents.get(2).getClass()); - Assert.assertEquals("wrong type of event.", PersonArrivalEvent.class, allEvents.get(3).getClass()); - Assert.assertEquals("wrong type of event.", ActivityStartEvent.class, allEvents.get(4).getClass()); - Assert.assertEquals("wrong type of event.", ActivityEndEvent.class, allEvents.get(5).getClass()); - Assert.assertEquals("wrong type of event.", PersonDepartureEvent.class, allEvents.get(6).getClass()); - Assert.assertEquals("wrong type of event.", ActivityEndEvent.class, allEvents.get(7).getClass()); - Assert.assertEquals("wrong type of event.", PersonDepartureEvent.class, allEvents.get(8).getClass()); - Assert.assertEquals("wrong type of event.", PersonEntersVehicleEvent.class, allEvents.get(9).getClass()); - Assert.assertEquals("wrong type of event.", VehicleEntersTrafficEvent.class, allEvents.get(10).getClass()); - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(11).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(12).getClass()); - Assert.assertEquals("wrong type of event.", VehicleLeavesTrafficEvent.class, allEvents.get(13).getClass()); - Assert.assertEquals("wrong type of event.", PersonLeavesVehicleEvent.class, allEvents.get(14).getClass()); - Assert.assertEquals("wrong type of event.", PersonArrivalEvent.class, allEvents.get(15).getClass()); - Assert.assertEquals("wrong type of event.", ActivityStartEvent.class, allEvents.get(16).getClass()); - Assert.assertEquals("wrong type of event.", PersonEntersVehicleEvent.class, allEvents.get(17).getClass()); - Assert.assertEquals("wrong type of event.", VehicleEntersTrafficEvent.class, allEvents.get(18).getClass()); - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(19).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(20).getClass()); - Assert.assertEquals("wrong type of event.", VehicleLeavesTrafficEvent.class, allEvents.get(21).getClass()); - Assert.assertEquals("wrong type of event.", PersonLeavesVehicleEvent.class, allEvents.get(22).getClass()); - Assert.assertEquals("wrong type of event.", PersonArrivalEvent.class, allEvents.get(23).getClass()); - Assert.assertEquals("wrong type of event.", ActivityStartEvent.class, allEvents.get(24).getClass()); - Assert.assertEquals("wrong type of event.", ActivityEndEvent.class, allEvents.get(25).getClass()); - Assert.assertEquals("wrong type of event.", PersonDepartureEvent.class, allEvents.get(26).getClass()); - Assert.assertEquals("wrong type of event.", TeleportationArrivalEvent.class, allEvents.get(27).getClass()); - Assert.assertEquals("wrong type of event.", PersonArrivalEvent.class, allEvents.get(28).getClass()); - Assert.assertEquals("wrong type of event.", ActivityStartEvent.class, allEvents.get(29).getClass()); + Assertions.assertEquals(30, allEvents.size(), "wrong number of events."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(0).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(1).getClass(), "wrong type of event."); + Assertions.assertEquals(TeleportationArrivalEvent.class, allEvents.get(2).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(3).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(4).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(5).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(6).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(7).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(8).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonEntersVehicleEvent.class, allEvents.get(9).getClass(), "wrong type of event."); + Assertions.assertEquals(VehicleEntersTrafficEvent.class, allEvents.get(10).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(11).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(12).getClass(), "wrong type of event."); + Assertions.assertEquals(VehicleLeavesTrafficEvent.class, allEvents.get(13).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonLeavesVehicleEvent.class, allEvents.get(14).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(15).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(16).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonEntersVehicleEvent.class, allEvents.get(17).getClass(), "wrong type of event."); + Assertions.assertEquals(VehicleEntersTrafficEvent.class, allEvents.get(18).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(19).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(20).getClass(), "wrong type of event."); + Assertions.assertEquals(VehicleLeavesTrafficEvent.class, allEvents.get(21).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonLeavesVehicleEvent.class, allEvents.get(22).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(23).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(24).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(25).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(26).getClass(), "wrong type of event."); + Assertions.assertEquals(TeleportationArrivalEvent.class, allEvents.get(27).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(28).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(29).getClass(), "wrong type of event."); } /** @@ -1039,20 +1043,20 @@ void testVehicleTeleportationFalse() { QSim sim = createQSim(f, events); try { sim.run(); - Assert.fail("expected RuntimeException, but there was none."); + Assertions.fail("expected RuntimeException, but there was none."); } catch (RuntimeException e) { log.info("catched expected RuntimeException: " + e.getMessage()); } List allEvents = collector.getEvents(); - Assert.assertEquals("wrong number of events.", 7, allEvents.size()); - Assert.assertEquals("wrong type of event.", ActivityEndEvent.class, allEvents.get(0).getClass()); - Assert.assertEquals("wrong type of event.", PersonDepartureEvent.class, allEvents.get(1).getClass()); - Assert.assertEquals("wrong type of event.", TeleportationArrivalEvent.class, allEvents.get(2).getClass()); - Assert.assertEquals("wrong type of event.", PersonArrivalEvent.class, allEvents.get(3).getClass()); - Assert.assertEquals("wrong type of event.", ActivityStartEvent.class, allEvents.get(4).getClass()); - Assert.assertEquals("wrong type of event.", ActivityEndEvent.class, allEvents.get(5).getClass()); - Assert.assertEquals("wrong type of event.", PersonDepartureEvent.class, allEvents.get(6).getClass()); + Assertions.assertEquals(7, allEvents.size(), "wrong number of events."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(0).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(1).getClass(), "wrong type of event."); + Assertions.assertEquals(TeleportationArrivalEvent.class, allEvents.get(2).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(3).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(4).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(5).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(6).getClass(), "wrong type of event."); } /** @@ -1104,12 +1108,12 @@ void testAssignedVehicles() { events.finishProcessing(); Collection vehicles = qlink3.getAllVehicles(); - Assert.assertEquals(1, vehicles.size()); - Assert.assertEquals(Id.create(2, Vehicle.class), vehicles.toArray(new MobsimVehicle[1])[0].getVehicle().getId()); + Assertions.assertEquals(1, vehicles.size()); + Assertions.assertEquals(Id.create(2, Vehicle.class), vehicles.toArray(new MobsimVehicle[1])[0].getVehicle().getId()); // vehicle 1 should still stay on qlink2 vehicles = qlink2.getAllVehicles(); - Assert.assertEquals(1, vehicles.size()); - Assert.assertEquals(Id.create(1, Vehicle.class), vehicles.toArray(new MobsimVehicle[1])[0].getVehicle().getId()); + Assertions.assertEquals(1, vehicles.size()); + Assertions.assertEquals(Id.create(1, Vehicle.class), vehicles.toArray(new MobsimVehicle[1])[0].getVehicle().getId()); } /** @@ -1149,23 +1153,23 @@ void testCircleAsRoute() { /* finish */ List allEvents = collector.getEvents(); - Assert.assertEquals("wrong number of events.", 16, allEvents.size()); - Assert.assertEquals("wrong type of event.", ActivityEndEvent.class, allEvents.get(0).getClass()); - Assert.assertEquals("wrong type of event.", PersonDepartureEvent.class, allEvents.get(1).getClass()); - Assert.assertEquals("wrong type of event.", PersonEntersVehicleEvent.class, allEvents.get(2).getClass()); - Assert.assertEquals("wrong type of event.", VehicleEntersTrafficEvent.class, allEvents.get(3).getClass()); - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(4).getClass()); // link1 - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(5).getClass()); // link2 - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(6).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(7).getClass()); // link3 - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(8).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(9).getClass()); // link4 - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(10).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(11).getClass()); // link1 again - Assert.assertEquals("wrong type of event.", VehicleLeavesTrafficEvent.class, allEvents.get(12).getClass()); - Assert.assertEquals("wrong type of event.", PersonLeavesVehicleEvent.class, allEvents.get(13).getClass()); - Assert.assertEquals("wrong type of event.", PersonArrivalEvent.class, allEvents.get(14).getClass()); - Assert.assertEquals("wrong type of event.", ActivityStartEvent.class, allEvents.get(15).getClass()); + Assertions.assertEquals(16, allEvents.size(), "wrong number of events."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(0).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(1).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonEntersVehicleEvent.class, allEvents.get(2).getClass(), "wrong type of event."); + Assertions.assertEquals(VehicleEntersTrafficEvent.class, allEvents.get(3).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(4).getClass(), "wrong type of event."); // link1 + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(5).getClass(), "wrong type of event."); // link2 + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(6).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(7).getClass(), "wrong type of event."); // link3 + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(8).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(9).getClass(), "wrong type of event."); // link4 + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(10).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(11).getClass(), "wrong type of event."); // link1 again + Assertions.assertEquals(VehicleLeavesTrafficEvent.class, allEvents.get(12).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonLeavesVehicleEvent.class, allEvents.get(13).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(14).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(15).getClass(), "wrong type of event."); } /** @@ -1207,27 +1211,27 @@ void testRouteWithEndLinkTwice() { /* finish */ List allEvents = collector.getEvents(); - Assert.assertEquals("wrong number of events.", 20, allEvents.size()); - Assert.assertEquals("wrong type of event.", ActivityEndEvent.class, allEvents.get(0).getClass()); - Assert.assertEquals("wrong type of event.", PersonDepartureEvent.class, allEvents.get(1).getClass()); - Assert.assertEquals("wrong type of event.", PersonEntersVehicleEvent.class, allEvents.get(2).getClass()); - Assert.assertEquals("wrong type of event.", VehicleEntersTrafficEvent.class, allEvents.get(3).getClass()); - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(4).getClass()); // link1 - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(5).getClass()); // link2 - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(6).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(7).getClass()); // link3 - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(8).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(9).getClass()); // link4 - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(10).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(11).getClass()); // link1 again - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(12).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(13).getClass()); // link2 again - Assert.assertEquals("wrong type of event.", LinkLeaveEvent.class, allEvents.get(14).getClass()); - Assert.assertEquals("wrong type of event.", LinkEnterEvent.class, allEvents.get(15).getClass()); // link3 again - Assert.assertEquals("wrong type of event.", VehicleLeavesTrafficEvent.class, allEvents.get(16).getClass()); - Assert.assertEquals("wrong type of event.", PersonLeavesVehicleEvent.class, allEvents.get(17).getClass()); - Assert.assertEquals("wrong type of event.", PersonArrivalEvent.class, allEvents.get(18).getClass()); - Assert.assertEquals("wrong type of event.", ActivityStartEvent.class, allEvents.get(19).getClass()); + Assertions.assertEquals(20, allEvents.size(), "wrong number of events."); + Assertions.assertEquals(ActivityEndEvent.class, allEvents.get(0).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonDepartureEvent.class, allEvents.get(1).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonEntersVehicleEvent.class, allEvents.get(2).getClass(), "wrong type of event."); + Assertions.assertEquals(VehicleEntersTrafficEvent.class, allEvents.get(3).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(4).getClass(), "wrong type of event."); // link1 + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(5).getClass(), "wrong type of event."); // link2 + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(6).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(7).getClass(), "wrong type of event."); // link3 + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(8).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(9).getClass(), "wrong type of event."); // link4 + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(10).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(11).getClass(), "wrong type of event."); // link1 again + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(12).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(13).getClass(), "wrong type of event."); // link2 again + Assertions.assertEquals(LinkLeaveEvent.class, allEvents.get(14).getClass(), "wrong type of event."); + Assertions.assertEquals(LinkEnterEvent.class, allEvents.get(15).getClass(), "wrong type of event."); // link3 again + Assertions.assertEquals(VehicleLeavesTrafficEvent.class, allEvents.get(16).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonLeavesVehicleEvent.class, allEvents.get(17).getClass(), "wrong type of event."); + Assertions.assertEquals(PersonArrivalEvent.class, allEvents.get(18).getClass(), "wrong type of event."); + Assertions.assertEquals(ActivityStartEvent.class, allEvents.get(19).getClass(), "wrong type of event."); } /** @@ -1242,8 +1246,8 @@ void testConsistentRoutes_WrongRoute() { EnterLinkEventCounter counter = new EnterLinkEventCounter("6"); events.addHandler(counter); LogCounter logger = runConsistentRoutesTestSim("1", "2 3", "5", events); // route should continue on link 4 - Assert.assertEquals(0, counter.getCounter()); // the agent should have been removed from the sim, so nobody travels there - Assert.assertTrue((logger.getWarnCount() + logger.getErrorCount()) > 0); // there should have been at least a warning + Assertions.assertEquals(0, counter.getCounter()); // the agent should have been removed from the sim, so nobody travels there + Assertions.assertTrue((logger.getWarnCount() + logger.getErrorCount()) > 0); // there should have been at least a warning } /** @@ -1258,8 +1262,8 @@ void testConsistentRoutes_WrongStartLink() { EnterLinkEventCounter counter = new EnterLinkEventCounter("6"); events.addHandler(counter); LogCounter logger = runConsistentRoutesTestSim("2", "3 4", "5", events); // first act is on link 1, not 2 - Assert.assertEquals(0, counter.getCounter()); // the agent should have been removed from the sim, so nobody travels there - Assert.assertTrue((logger.getWarnCount() + logger.getErrorCount()) > 0); // there should have been at least a warning + Assertions.assertEquals(0, counter.getCounter()); // the agent should have been removed from the sim, so nobody travels there + Assertions.assertTrue((logger.getWarnCount() + logger.getErrorCount()) > 0); // there should have been at least a warning } /** @@ -1274,8 +1278,8 @@ void testConsistentRoutes_WrongEndLink() { EnterLinkEventCounter counter = new EnterLinkEventCounter("6"); events.addHandler(counter); LogCounter logger = runConsistentRoutesTestSim("1", "2 3", "4", events); // second act is on link 5, not 4 - Assert.assertEquals(0, counter.getCounter()); // the agent should have been removed from the sim, so nobody travels there - Assert.assertTrue((logger.getWarnCount() + logger.getErrorCount()) > 0); // there should have been at least a warning + Assertions.assertEquals(0, counter.getCounter()); // the agent should have been removed from the sim, so nobody travels there + Assertions.assertTrue((logger.getWarnCount() + logger.getErrorCount()) > 0); // there should have been at least a warning } /** @@ -1291,8 +1295,8 @@ void testConsistentRoutes_ImpossibleRoute() { EnterLinkEventCounter counter = new EnterLinkEventCounter("6"); events.addHandler(counter); LogCounter logger = runConsistentRoutesTestSim("1", "2 4", "5", events); // link 3 is missing - Assert.assertEquals(0, counter.getCounter()); // the agent should have been removed from the sim, so nobody travels there - Assert.assertTrue((logger.getWarnCount() + logger.getErrorCount()) > 0); // there should have been at least a warning + Assertions.assertEquals(0, counter.getCounter()); // the agent should have been removed from the sim, so nobody travels there + Assertions.assertTrue((logger.getWarnCount() + logger.getErrorCount()) > 0); // there should have been at least a warning } /** @@ -1307,8 +1311,8 @@ void testConsistentRoutes_MissingRoute() { EnterLinkEventCounter counter = new EnterLinkEventCounter("6"); events.addHandler(counter); LogCounter logger = runConsistentRoutesTestSim("1", "", "5", events); // no links at all - Assert.assertEquals(0, counter.getCounter()); // the agent should have been removed from the sim, so nobody travels there - Assert.assertTrue((logger.getWarnCount() + logger.getErrorCount()) > 0); // there should have been at least a warning + Assertions.assertEquals(0, counter.getCounter()); // the agent should have been removed from the sim, so nobody travels there + Assertions.assertTrue((logger.getWarnCount() + logger.getErrorCount()) > 0); // there should have been at least a warning } /** Prepares miscellaneous data for the testConsistentRoutes() tests: @@ -1417,8 +1421,8 @@ void testStartAndEndTime() { // first test without special settings QSim sim = createQSim(scenario, events); sim.run(); - Assert.assertEquals(act1.getEndTime().seconds(), collector.firstEvent.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals(act1.getEndTime().seconds() + leg.getRoute().getTravelTime().seconds(), collector.lastEvent.getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(act1.getEndTime().seconds(), collector.firstEvent.getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(act1.getEndTime().seconds() + leg.getRoute().getTravelTime().seconds(), collector.lastEvent.getTime(), MatsimTestUtils.EPSILON); collector.reset(0); // second test with special start/end times @@ -1426,8 +1430,8 @@ void testStartAndEndTime() { config.qsim().setEndTime(11.0*3600); sim = createQSim(scenario, events); sim.run(); - Assert.assertEquals(8.0*3600, collector.firstEvent.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals(11.0*3600, collector.lastEvent.getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(8.0*3600, collector.firstEvent.getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(11.0*3600, collector.lastEvent.getTime(), MatsimTestUtils.EPSILON); } /** @@ -1523,7 +1527,7 @@ void testCleanupSim_EarlyEnd() { config.qsim().setEndTime(simEndTime); QSim sim = createQSim(scenario, events); sim.run(); - Assert.assertEquals(simEndTime, collector.lastEvent.getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(simEndTime, collector.lastEvent.getTime(), MatsimTestUtils.EPSILON); // besides this, the important thing is that no (Runtime)Exception is thrown during this test } @@ -1583,8 +1587,8 @@ void testFlowCapacityDrivingKinematicWavesWithFlowReductionCorrectionBehavior() System.out.println("#vehicles 7-8: " + Integer.toString(volume[7])); System.out.println("#vehicles 8-9: " + Integer.toString(volume[8])); - Assert.assertEquals(1920, volume[6]); // because of the kinematic waves and the 'reduce flow capacity behavior' we should have much less than half of the maximum flow in this hour - Assert.assertEquals(3840, volume[7]); // because of the kinematic waves and the 'reduce flow capacity behavior' we should have much less than the maximum flow in this hour + Assertions.assertEquals(1920, volume[6]); // because of the kinematic waves and the 'reduce flow capacity behavior' we should have much less than half of the maximum flow in this hour + Assertions.assertEquals(3840, volume[7]); // because of the kinematic waves and the 'reduce flow capacity behavior' we should have much less than the maximum flow in this hour } /** @@ -1643,8 +1647,8 @@ void testFlowCapacityDrivingKinematicWavesWithLaneIncreaseCorrectionBehavior() { System.out.println("#vehicles 7-8: " + Integer.toString(volume[7])); System.out.println("#vehicles 8-9: " + Integer.toString(volume[8])); - Assert.assertEquals(2979, volume[6]); // because of the kinematic waves and the 'increase lanes behavior' we should only have slightly less than half of the maximum flow in this hour - Assert.assertEquals(5958, volume[7]); // because of the kinematic waves and the 'increase lanes behavior' we should only have slightly less than the maximum flow in this hour + Assertions.assertEquals(2979, volume[6]); // because of the kinematic waves and the 'increase lanes behavior' we should only have slightly less than half of the maximum flow in this hour + Assertions.assertEquals(5958, volume[7]); // because of the kinematic waves and the 'increase lanes behavior' we should only have slightly less than the maximum flow in this hour } /** @@ -1703,8 +1707,8 @@ void testFlowCapacityDrivingKinematicWavesWithInflowEqualToMaxCapForOneLane() { System.out.println("#vehicles 7-8: " + Integer.toString(volume[7])); System.out.println("#vehicles 8-9: " + Integer.toString(volume[8])); - Assert.assertEquals(961, volume[6]); // because of the kinematic waves and the 'use inflow capacity of one lane only behavior' we should have less than a quarter of the maximum flow in this hour - Assert.assertEquals(1920, volume[7]); // because of the kinematic waves and the 'use inflow capacity of one lane only behavior' we should have less than half of the maximum flow in this hour + Assertions.assertEquals(961, volume[6]); // because of the kinematic waves and the 'use inflow capacity of one lane only behavior' we should have less than a quarter of the maximum flow in this hour + Assertions.assertEquals(1920, volume[7]); // because of the kinematic waves and the 'use inflow capacity of one lane only behavior' we should have less than half of the maximum flow in this hour } /** diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/TransitQueueNetworkTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/TransitQueueNetworkTest.java index deb611bbab7..5d4a6fb0072 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/TransitQueueNetworkTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/TransitQueueNetworkTest.java @@ -20,8 +20,6 @@ package org.matsim.core.mobsim.qsim; -import static org.junit.Assert.assertEquals; - import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collection; @@ -29,6 +27,8 @@ import java.util.List; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/TravelTimeTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/TravelTimeTest.java index 6670ac30280..0fbba6e7926 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/TravelTimeTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/TravelTimeTest.java @@ -22,7 +22,7 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -69,13 +69,13 @@ void testEquilOneAgent() { .run(); Map, Double> travelTimes = agentTravelTimes.get(Id.create("1", Vehicle.class)); - Assert.assertEquals(360.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(180.0, travelTimes.get(Id.create(15, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(360.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(180.0, travelTimes.get(Id.create(15, Link.class)).intValue(), MatsimTestUtils.EPSILON); // this one is NOT a travel time (it includes two activities and a zero-length trip) - Assert.assertEquals(13560.0, travelTimes.get(Id.create(20, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(360.0, travelTimes.get(Id.create(21, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1260.0, travelTimes.get(Id.create(22, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(360.0, travelTimes.get(Id.create(23, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(13560.0, travelTimes.get(Id.create(20, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(360.0, travelTimes.get(Id.create(21, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1260.0, travelTimes.get(Id.create(22, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(360.0, travelTimes.get(Id.create(23, Link.class)).intValue(), MatsimTestUtils.EPSILON); } /** @@ -109,7 +109,7 @@ void testEquilOneAgentTravelTimeRounding() { .run(); Map, Double> travelTimes = agentTravelTimes.get(Id.create("1", Vehicle.class)); - Assert.assertEquals(360.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(360.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); // Travel time 359.9712023038 scenario.getNetwork().getLinks().get(Id.createLinkId("6")).setFreespeed(27.85); @@ -121,7 +121,7 @@ void testEquilOneAgentTravelTimeRounding() { .run(); travelTimes = agentTravelTimes.get(Id.create("1", Vehicle.class)); - Assert.assertEquals(360.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(360.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); // Travel time 359.066427289 scenario.getNetwork().getLinks().get(Id.createLinkId("6")).setFreespeed(27.85); @@ -133,7 +133,7 @@ void testEquilOneAgentTravelTimeRounding() { .run(); travelTimes = agentTravelTimes.get(Id.create("1", Vehicle.class)); - Assert.assertEquals(360.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(360.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); // Travel time 358.4229390681 scenario.getNetwork().getLinks().get(Id.createLinkId("6")).setFreespeed(27.9); @@ -145,7 +145,7 @@ void testEquilOneAgentTravelTimeRounding() { .run(); travelTimes = agentTravelTimes.get(Id.create("1", Vehicle.class)); - Assert.assertEquals(359.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(359.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); // Travel time 360.3603603604 scenario.getNetwork().getLinks().get(Id.createLinkId("6")).setFreespeed(27.75); @@ -157,7 +157,7 @@ void testEquilOneAgentTravelTimeRounding() { .run(); travelTimes = agentTravelTimes.get(Id.create("1", Vehicle.class)); - Assert.assertEquals(361.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(361.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); // Travel time 400.0 scenario.getNetwork().getLinks().get(Id.createLinkId("6")).setLength(10000.0); @@ -170,7 +170,7 @@ void testEquilOneAgentTravelTimeRounding() { .run(); travelTimes = agentTravelTimes.get(Id.create("1", Vehicle.class)); - Assert.assertEquals(401.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(401.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); } @Test @@ -196,23 +196,23 @@ void testEquilTwoAgents() { .run(); Map, Double> travelTimes = agentTravelTimes.get(Id.create("1", Vehicle.class)); - Assert.assertEquals(360.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(180.0, travelTimes.get(Id.create(15, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(360.0, travelTimes.get(Id.create(6, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(180.0, travelTimes.get(Id.create(15, Link.class)).intValue(), MatsimTestUtils.EPSILON); // this one is NOT a travel time (it includes two activities and a zero-length trip) - Assert.assertEquals(13560.0, travelTimes.get(Id.create(20, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(360.0, travelTimes.get(Id.create(21, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1260.0, travelTimes.get(Id.create(22, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(360.0, travelTimes.get(Id.create(23, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(13560.0, travelTimes.get(Id.create(20, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(360.0, travelTimes.get(Id.create(21, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1260.0, travelTimes.get(Id.create(22, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(360.0, travelTimes.get(Id.create(23, Link.class)).intValue(), MatsimTestUtils.EPSILON); travelTimes = agentTravelTimes.get(Id.create("2", Vehicle.class)); - Assert.assertEquals(360.0, travelTimes.get(Id.create(5, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(180.0, travelTimes.get(Id.create(14, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(360.0, travelTimes.get(Id.create(5, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(180.0, travelTimes.get(Id.create(14, Link.class)).intValue(), MatsimTestUtils.EPSILON); // this one is NOT a travel time (it includes two activities and a zero-length trip) - Assert.assertEquals(13560.0, travelTimes.get(Id.create(20, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(360.0, travelTimes.get(Id.create(21, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1260.0, travelTimes.get(Id.create(22, Link.class)).intValue(), MatsimTestUtils.EPSILON); - Assert.assertEquals(360.0, travelTimes.get(Id.create(23, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(13560.0, travelTimes.get(Id.create(20, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(360.0, travelTimes.get(Id.create(21, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1260.0, travelTimes.get(Id.create(22, Link.class)).intValue(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(360.0, travelTimes.get(Id.create(23, Link.class)).intValue(), MatsimTestUtils.EPSILON); } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java index 6b84f956f3f..f91acc6e562 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java @@ -18,7 +18,7 @@ * *********************************************************************** */ package org.matsim.core.mobsim.qsim; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.runner.RunWith; @@ -165,9 +165,9 @@ public void install() { } } if ( providingVehiclesInPerson ) { - Assert.assertFalse( expectedException ); + Assertions.assertFalse( expectedException ); } else { - Assert.assertTrue( expectedException ); + Assertions.assertTrue( expectedException ); return ; } @@ -189,12 +189,11 @@ public void install() { switch (this.vehiclesSource ) { case defaultVehicle: // both bike and car are default vehicles (i.e. identical) - Assert.assertEquals("Both car, bike are default vehicles (i.e. identical), thus should have same travel time.", - 0, bikeTravelTime - carTravelTime, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0, bikeTravelTime - carTravelTime, MatsimTestUtils.EPSILON, "Both car, bike are default vehicles (i.e. identical), thus should have same travel time."); break; case modeVehicleTypesFromVehiclesData: case fromVehiclesData: - Assert.assertEquals("Passing is not executed.", 150, bikeTravelTime - carTravelTime, MatsimTestUtils.EPSILON); + Assertions.assertEquals(150, bikeTravelTime - carTravelTime, MatsimTestUtils.EPSILON, "Passing is not executed."); break; default: throw new RuntimeException("not implemented yet."); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/changeeventsengine/NetworkChangeEventsEngineTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/changeeventsengine/NetworkChangeEventsEngineTest.java index 6eb210f684d..1cb8f2e7000 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/changeeventsengine/NetworkChangeEventsEngineTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/changeeventsengine/NetworkChangeEventsEngineTest.java @@ -21,7 +21,7 @@ package org.matsim.core.mobsim.qsim.changeeventsengine; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -46,7 +46,7 @@ import java.util.List; - /** + /** * @author mrieser / Simunto GmbH */ public class NetworkChangeEventsEngineTest { @@ -81,7 +81,7 @@ void testActivation_inactive() { try { engine.addNetworkChangeEvent(changeEvent); - Assert.fail("Expected exception due to links not being time dependent, but got none."); + Assertions.fail("Expected exception due to links not being time dependent, but got none."); } catch (Exception expected) { } } @@ -115,11 +115,11 @@ void testActivation_timedepOnly_freespeed() { changeEvent.addLink(link1); changeEvent.setFreespeedChange(new NetworkChangeEvent.ChangeValue(NetworkChangeEvent.ChangeType.ABSOLUTE_IN_SI_UNITS, 50)); engine.addNetworkChangeEvent(changeEvent); - Assert.assertEquals("it should still be 20 now.", 20, link1.getFreespeed(30), 0); + Assertions.assertEquals(20, link1.getFreespeed(30), 0, "it should still be 20 now."); for (int i = 30; i < 40; i++) { engine.doSimStep(i); } - Assert.assertEquals("it should be 50 now.", 50, link1.getFreespeed(40), 0); + Assertions.assertEquals(50, link1.getFreespeed(40), 0, "it should be 50 now."); } @Test @@ -151,11 +151,11 @@ void testActivation_timedepOnly_capacity() { changeEvent.addLink(link1); changeEvent.setFlowCapacityChange(new NetworkChangeEvent.ChangeValue(NetworkChangeEvent.ChangeType.FACTOR, 2)); engine.addNetworkChangeEvent(changeEvent); - Assert.assertEquals("it should still be 20 now.", 20, link1.getCapacity(30), 0); + Assertions.assertEquals(20, link1.getCapacity(30), 0, "it should still be 20 now."); for (int i = 30; i < 40; i++) { engine.doSimStep(i); } - Assert.assertEquals("it should be 40 now.", 40, link1.getCapacity(40), 0); + Assertions.assertEquals(40, link1.getCapacity(40), 0, "it should be 40 now."); } private static class DummyInternalInterfaceImpl implements InternalInterface { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/QSimComponentsTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/QSimComponentsTest.java index 3e97d857a17..c3355a063ce 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/QSimComponentsTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/QSimComponentsTest.java @@ -31,7 +31,7 @@ import com.google.inject.ProvisionException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.Event; @@ -96,7 +96,7 @@ void testAddComponentViaString() { .build(scenario, eventsManager) // .run(); - Assert.assertTrue( "MockMobsimListener was not added to QSim", handler.hasBeenCalled() ) ; + Assertions.assertTrue( handler.hasBeenCalled(), "MockMobsimListener was not added to QSim" ) ; } /** @@ -139,7 +139,7 @@ void testAddModuleOnly() { .build(scenario, eventsManager) // .run(); - Assert.assertFalse( "MockMobsimListener was added to QSim although it should not have been added", handler.hasBeenCalled() ) ; + Assertions.assertFalse( handler.hasBeenCalled(), "MockMobsimListener was added to QSim although it should not have been added" ) ; } /** @@ -231,7 +231,7 @@ void testAddComponentViaStringTwice() { .build(scenario, eventsManager) // .run(); - Assert.assertTrue( "MockMobsimListener was not added to QSim", handler.hasBeenCalled() ) ; + Assertions.assertTrue( handler.hasBeenCalled(), "MockMobsimListener was not added to QSim" ) ; } @@ -262,7 +262,7 @@ void testGenericAddComponentMethod() { .build(scenario, eventsManager) // .run(); - Assert.assertTrue( handler.hasBeenCalled() ) ; + Assertions.assertTrue( handler.hasBeenCalled() ) ; } @Test @@ -285,7 +285,7 @@ void testGenericAddComponentMethodWithoutConfiguringIt() { .build(scenario, eventsManager) // .run(); - Assert.assertFalse( handler.hasBeenCalled() ) ; + Assertions.assertFalse( handler.hasBeenCalled() ) ; } @Test @@ -311,8 +311,8 @@ protected void configureQSim() { .build(scenario, eventsManager) // .run(); - Assert.assertTrue(mockEngineA.isCalled); - Assert.assertTrue(mockEngineB.isCalled); + Assertions.assertTrue(mockEngineA.isCalled); + Assertions.assertTrue(mockEngineB.isCalled); } @Test @@ -336,7 +336,7 @@ protected void configureQSim() { .build(scenario, eventsManager) // .run(); - Assert.assertTrue(mockEngine.isCalled); + Assertions.assertTrue(mockEngine.isCalled); } @Test @@ -360,7 +360,7 @@ protected void configureQSim() { .build(scenario, eventsManager) // .run(); - Assert.assertTrue(mockEngine.isCalled); + Assertions.assertTrue(mockEngine.isCalled); } @Test @@ -388,7 +388,7 @@ protected void configureQSim() { .build(scenario, eventsManager) // .run(); - Assert.assertTrue(mockEngine.isCalled); + Assertions.assertTrue(mockEngine.isCalled); } // --- diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/guice/ExplicitBindingsRequiredTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/guice/ExplicitBindingsRequiredTest.java index d750d1e2efc..56da02d7c72 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/guice/ExplicitBindingsRequiredTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/guice/ExplicitBindingsRequiredTest.java @@ -20,8 +20,7 @@ * *********************************************************************** */ package org.matsim.core.mobsim.qsim.components.guice; - -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import com.google.inject.AbstractModule; import com.google.inject.CreationException; @@ -29,7 +28,7 @@ import com.google.inject.Inject; import com.google.inject.Injector; - /** + /** * This test shows how Guice works with child injectors and explicit bindings. * In the test there is a ParentScopeObject in a parent injector. Then a child * injector is created which contains a ChildScopeObject, which has the @@ -83,6 +82,6 @@ protected void configure() { exceptionOccured = true; } - Assert.assertTrue(exceptionOccured); + Assertions.assertTrue(exceptionOccured); } } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/guice/MultipleBindingsTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/guice/MultipleBindingsTest.java index b558b40965a..76def156998 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/guice/MultipleBindingsTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/components/guice/MultipleBindingsTest.java @@ -20,8 +20,7 @@ * *********************************************************************** */ package org.matsim.core.mobsim.qsim.components.guice; - -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import com.google.inject.AbstractModule; import com.google.inject.Guice; @@ -29,7 +28,7 @@ import com.google.inject.Key; import com.google.inject.name.Names; - /** + /** * This test shows that Guice creates Singletons solely based on the *class * name*. So as shown in the example one can bind the same class to different * interfaces, even with different names. If the class is declared in the @@ -60,6 +59,6 @@ protected void configure() { InterfaceA implA = injector.getInstance(Key.get(InterfaceA.class, Names.named("abc1"))); InterfaceB implB = injector.getInstance(Key.get(InterfaceB.class, Names.named("abc2"))); - Assert.assertSame(implA, implB); + Assertions.assertSame(implA, implB); } } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/QSimIntegrationTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/QSimIntegrationTest.java index b85534b5e04..25234b89cd0 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/QSimIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/QSimIntegrationTest.java @@ -25,7 +25,7 @@ import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -107,17 +107,17 @@ void test_twoStopsOnFirstLink() throws SAXException, ParserConfigurationExceptio coll.printEvents(); List events = coll.getEvents(); - Assert.assertEquals("wrong number of events", 10, events.size()); - Assert.assertTrue(events.get(0) instanceof TransitDriverStartsEvent); - Assert.assertTrue(events.get(1) instanceof PersonDepartureEvent); - Assert.assertTrue(events.get(2) instanceof VehicleArrivesAtFacilityEvent); // stop 1 - Assert.assertTrue(events.get(3) instanceof VehicleDepartsAtFacilityEvent); // stop 1 - Assert.assertTrue(events.get(4) instanceof VehicleArrivesAtFacilityEvent); // stop 2 - Assert.assertTrue(events.get(5) instanceof VehicleDepartsAtFacilityEvent); // stop 2 - Assert.assertTrue(events.get(6) instanceof LinkEnterEvent); - Assert.assertTrue(events.get(7) instanceof VehicleArrivesAtFacilityEvent); // stop 3 - Assert.assertTrue(events.get(8) instanceof VehicleDepartsAtFacilityEvent); // stop 3 - Assert.assertTrue(events.get(9) instanceof PersonArrivalEvent); + Assertions.assertEquals(10, events.size(), "wrong number of events"); + Assertions.assertTrue(events.get(0) instanceof TransitDriverStartsEvent); + Assertions.assertTrue(events.get(1) instanceof PersonDepartureEvent); + Assertions.assertTrue(events.get(2) instanceof VehicleArrivesAtFacilityEvent); // stop 1 + Assertions.assertTrue(events.get(3) instanceof VehicleDepartsAtFacilityEvent); // stop 1 + Assertions.assertTrue(events.get(4) instanceof VehicleArrivesAtFacilityEvent); // stop 2 + Assertions.assertTrue(events.get(5) instanceof VehicleDepartsAtFacilityEvent); // stop 2 + Assertions.assertTrue(events.get(6) instanceof LinkEnterEvent); + Assertions.assertTrue(events.get(7) instanceof VehicleArrivesAtFacilityEvent); // stop 3 + Assertions.assertTrue(events.get(8) instanceof VehicleDepartsAtFacilityEvent); // stop 3 + Assertions.assertTrue(events.get(9) instanceof PersonArrivalEvent); } @Test @@ -169,18 +169,18 @@ void test_multipleStopsOnFirstLink_singleLinkRoute_noPassengers() throws SAXExce coll.printEvents(); List events = coll.getEvents(); - Assert.assertEquals("wrong number of events", 11, events.size()); - Assert.assertTrue(events.get(0) instanceof TransitDriverStartsEvent); - Assert.assertTrue(events.get(1) instanceof PersonDepartureEvent); - Assert.assertTrue(events.get(2) instanceof VehicleArrivesAtFacilityEvent); // stop 1 - Assert.assertTrue(events.get(3) instanceof VehicleDepartsAtFacilityEvent); // stop 1 - Assert.assertTrue(events.get(4) instanceof VehicleArrivesAtFacilityEvent); // stop 2 - Assert.assertTrue(events.get(5) instanceof VehicleDepartsAtFacilityEvent); // stop 2 - Assert.assertTrue(events.get(6) instanceof VehicleArrivesAtFacilityEvent); // stop 3 - Assert.assertTrue(events.get(7) instanceof VehicleDepartsAtFacilityEvent); // stop 3 - Assert.assertTrue(events.get(8) instanceof VehicleArrivesAtFacilityEvent); // stop 4 - Assert.assertTrue(events.get(9) instanceof VehicleDepartsAtFacilityEvent); // stop 4 - Assert.assertTrue(events.get(10) instanceof PersonArrivalEvent); + Assertions.assertEquals(11, events.size(), "wrong number of events"); + Assertions.assertTrue(events.get(0) instanceof TransitDriverStartsEvent); + Assertions.assertTrue(events.get(1) instanceof PersonDepartureEvent); + Assertions.assertTrue(events.get(2) instanceof VehicleArrivesAtFacilityEvent); // stop 1 + Assertions.assertTrue(events.get(3) instanceof VehicleDepartsAtFacilityEvent); // stop 1 + Assertions.assertTrue(events.get(4) instanceof VehicleArrivesAtFacilityEvent); // stop 2 + Assertions.assertTrue(events.get(5) instanceof VehicleDepartsAtFacilityEvent); // stop 2 + Assertions.assertTrue(events.get(6) instanceof VehicleArrivesAtFacilityEvent); // stop 3 + Assertions.assertTrue(events.get(7) instanceof VehicleDepartsAtFacilityEvent); // stop 3 + Assertions.assertTrue(events.get(8) instanceof VehicleArrivesAtFacilityEvent); // stop 4 + Assertions.assertTrue(events.get(9) instanceof VehicleDepartsAtFacilityEvent); // stop 4 + Assertions.assertTrue(events.get(10) instanceof PersonArrivalEvent); } @Test @@ -247,25 +247,25 @@ void test_multipleStopsOnFirstLink_singleLinkRoute_withPassengersAtFirstStop() t coll.printEvents(); List events = coll.getEvents(); - Assert.assertEquals("wrong number of events", 17, events.size()); + Assertions.assertEquals(17, events.size(), "wrong number of events"); int idx = 0; - Assert.assertTrue(events.get(idx++) instanceof PersonDepartureEvent); // passenger - Assert.assertTrue(events.get(idx++) instanceof TransitDriverStartsEvent); - Assert.assertTrue(events.get(idx++) instanceof PersonDepartureEvent); // pt-driver - Assert.assertTrue(events.get(idx++) instanceof PersonEntersVehicleEvent); // pt-driver - Assert.assertTrue(events.get(idx++) instanceof VehicleArrivesAtFacilityEvent); // stop 1 - Assert.assertTrue(events.get(idx++) instanceof PersonEntersVehicleEvent); - Assert.assertTrue(events.get(idx++) instanceof VehicleDepartsAtFacilityEvent); // stop 1 - Assert.assertTrue(events.get(idx++) instanceof VehicleArrivesAtFacilityEvent); // stop 2 - Assert.assertTrue(events.get(idx++) instanceof VehicleDepartsAtFacilityEvent); // stop 2 - Assert.assertTrue(events.get(idx++) instanceof VehicleArrivesAtFacilityEvent); // stop 3 - Assert.assertTrue(events.get(idx++) instanceof PersonLeavesVehicleEvent); - Assert.assertTrue(events.get(idx++) instanceof PersonArrivalEvent); // passenger - Assert.assertTrue(events.get(idx++) instanceof VehicleDepartsAtFacilityEvent); // stop 3 - Assert.assertTrue(events.get(idx++) instanceof VehicleArrivesAtFacilityEvent); // stop 4 - Assert.assertTrue(events.get(idx++) instanceof VehicleDepartsAtFacilityEvent); // stop 4 - Assert.assertTrue(events.get(idx++) instanceof PersonLeavesVehicleEvent); // pt-driver - Assert.assertTrue(events.get(idx++) instanceof PersonArrivalEvent); + Assertions.assertTrue(events.get(idx++) instanceof PersonDepartureEvent); // passenger + Assertions.assertTrue(events.get(idx++) instanceof TransitDriverStartsEvent); + Assertions.assertTrue(events.get(idx++) instanceof PersonDepartureEvent); // pt-driver + Assertions.assertTrue(events.get(idx++) instanceof PersonEntersVehicleEvent); // pt-driver + Assertions.assertTrue(events.get(idx++) instanceof VehicleArrivesAtFacilityEvent); // stop 1 + Assertions.assertTrue(events.get(idx++) instanceof PersonEntersVehicleEvent); + Assertions.assertTrue(events.get(idx++) instanceof VehicleDepartsAtFacilityEvent); // stop 1 + Assertions.assertTrue(events.get(idx++) instanceof VehicleArrivesAtFacilityEvent); // stop 2 + Assertions.assertTrue(events.get(idx++) instanceof VehicleDepartsAtFacilityEvent); // stop 2 + Assertions.assertTrue(events.get(idx++) instanceof VehicleArrivesAtFacilityEvent); // stop 3 + Assertions.assertTrue(events.get(idx++) instanceof PersonLeavesVehicleEvent); + Assertions.assertTrue(events.get(idx++) instanceof PersonArrivalEvent); // passenger + Assertions.assertTrue(events.get(idx++) instanceof VehicleDepartsAtFacilityEvent); // stop 3 + Assertions.assertTrue(events.get(idx++) instanceof VehicleArrivesAtFacilityEvent); // stop 4 + Assertions.assertTrue(events.get(idx++) instanceof VehicleDepartsAtFacilityEvent); // stop 4 + Assertions.assertTrue(events.get(idx++) instanceof PersonLeavesVehicleEvent); // pt-driver + Assertions.assertTrue(events.get(idx++) instanceof PersonArrivalEvent); } @Test @@ -332,25 +332,25 @@ void test_multipleStopsOnFirstLink_singleLinkRoute_withPassengersAtSecondStop() coll.printEvents(); List events = coll.getEvents(); - Assert.assertEquals("wrong number of events", 17, events.size()); + Assertions.assertEquals(17, events.size(), "wrong number of events"); int idx = 0; - Assert.assertTrue(events.get(idx++) instanceof PersonDepartureEvent); // passenger - Assert.assertTrue(events.get(idx++) instanceof TransitDriverStartsEvent); - Assert.assertTrue(events.get(idx++) instanceof PersonDepartureEvent); // pt-driver - Assert.assertTrue(events.get(idx++) instanceof PersonEntersVehicleEvent); // pt-driver - Assert.assertTrue(events.get(idx++) instanceof VehicleArrivesAtFacilityEvent); // stop 1 - Assert.assertTrue(events.get(idx++) instanceof VehicleDepartsAtFacilityEvent); // stop 1 - Assert.assertTrue(events.get(idx++) instanceof VehicleArrivesAtFacilityEvent); // stop 2 - Assert.assertTrue(events.get(idx++) instanceof PersonEntersVehicleEvent); - Assert.assertTrue(events.get(idx++) instanceof VehicleDepartsAtFacilityEvent); // stop 2 - Assert.assertTrue(events.get(idx++) instanceof VehicleArrivesAtFacilityEvent); // stop 3 - Assert.assertTrue(events.get(idx++) instanceof VehicleDepartsAtFacilityEvent); // stop 3 - Assert.assertTrue(events.get(idx++) instanceof VehicleArrivesAtFacilityEvent); // stop 4 - Assert.assertTrue(events.get(idx++) instanceof PersonLeavesVehicleEvent); - Assert.assertTrue(events.get(idx++) instanceof PersonArrivalEvent); // passenger - Assert.assertTrue(events.get(idx++) instanceof VehicleDepartsAtFacilityEvent); // stop 4 - Assert.assertTrue(events.get(idx++) instanceof PersonLeavesVehicleEvent); // pt-driver - Assert.assertTrue(events.get(idx++) instanceof PersonArrivalEvent); + Assertions.assertTrue(events.get(idx++) instanceof PersonDepartureEvent); // passenger + Assertions.assertTrue(events.get(idx++) instanceof TransitDriverStartsEvent); + Assertions.assertTrue(events.get(idx++) instanceof PersonDepartureEvent); // pt-driver + Assertions.assertTrue(events.get(idx++) instanceof PersonEntersVehicleEvent); // pt-driver + Assertions.assertTrue(events.get(idx++) instanceof VehicleArrivesAtFacilityEvent); // stop 1 + Assertions.assertTrue(events.get(idx++) instanceof VehicleDepartsAtFacilityEvent); // stop 1 + Assertions.assertTrue(events.get(idx++) instanceof VehicleArrivesAtFacilityEvent); // stop 2 + Assertions.assertTrue(events.get(idx++) instanceof PersonEntersVehicleEvent); + Assertions.assertTrue(events.get(idx++) instanceof VehicleDepartsAtFacilityEvent); // stop 2 + Assertions.assertTrue(events.get(idx++) instanceof VehicleArrivesAtFacilityEvent); // stop 3 + Assertions.assertTrue(events.get(idx++) instanceof VehicleDepartsAtFacilityEvent); // stop 3 + Assertions.assertTrue(events.get(idx++) instanceof VehicleArrivesAtFacilityEvent); // stop 4 + Assertions.assertTrue(events.get(idx++) instanceof PersonLeavesVehicleEvent); + Assertions.assertTrue(events.get(idx++) instanceof PersonArrivalEvent); // passenger + Assertions.assertTrue(events.get(idx++) instanceof VehicleDepartsAtFacilityEvent); // stop 4 + Assertions.assertTrue(events.get(idx++) instanceof PersonLeavesVehicleEvent); // pt-driver + Assertions.assertTrue(events.get(idx++) instanceof PersonArrivalEvent); } /** @@ -409,14 +409,14 @@ void test_circularEmptyRoute_singleLinkRoute_noPassengers() throws SAXException, coll.printEvents(); List events = coll.getEvents(); - Assert.assertEquals("wrong number of events", 7, events.size()); - Assert.assertTrue(events.get(0) instanceof TransitDriverStartsEvent); - Assert.assertTrue(events.get(1) instanceof PersonDepartureEvent); - Assert.assertTrue(events.get(2) instanceof VehicleArrivesAtFacilityEvent); // stop 1 - Assert.assertTrue(events.get(3) instanceof VehicleDepartsAtFacilityEvent); // stop 1 - Assert.assertTrue(events.get(4) instanceof VehicleArrivesAtFacilityEvent); // stop 1 - Assert.assertTrue(events.get(5) instanceof VehicleDepartsAtFacilityEvent); // stop 1 - Assert.assertTrue(events.get(6) instanceof PersonArrivalEvent); + Assertions.assertEquals(7, events.size(), "wrong number of events"); + Assertions.assertTrue(events.get(0) instanceof TransitDriverStartsEvent); + Assertions.assertTrue(events.get(1) instanceof PersonDepartureEvent); + Assertions.assertTrue(events.get(2) instanceof VehicleArrivesAtFacilityEvent); // stop 1 + Assertions.assertTrue(events.get(3) instanceof VehicleDepartsAtFacilityEvent); // stop 1 + Assertions.assertTrue(events.get(4) instanceof VehicleArrivesAtFacilityEvent); // stop 1 + Assertions.assertTrue(events.get(5) instanceof VehicleDepartsAtFacilityEvent); // stop 1 + Assertions.assertTrue(events.get(6) instanceof PersonArrivalEvent); } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitAgentTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitAgentTest.java index 6ec86bdcb5b..59c7341e27e 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitAgentTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitAgentTest.java @@ -20,8 +20,8 @@ package org.matsim.core.mobsim.qsim.pt; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import java.util.Collections; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitDriverTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitDriverTest.java index 13b7f743fb8..64219008ac3 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitDriverTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitDriverTest.java @@ -20,7 +20,7 @@ package org.matsim.core.mobsim.qsim.pt; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.ArrayList; import java.util.Collections; @@ -304,16 +304,12 @@ void testHandleStop_EnterPassengers() { assertEquals(stop1, driver.getNextTransitStop()); assertTrue(driver.handleTransitStop(stop1, 50) > 0); assertEquals(2, queueVehicle.getPassengers().size()); - assertEquals("driver must not proceed in stop list when persons entered.", - stop1, driver.getNextTransitStop()); + assertEquals(stop1, driver.getNextTransitStop(), "driver must not proceed in stop list when persons entered."); assertEquals(0, tracker.getAgentsAtFacility(stop1.getId()).size()); - assertEquals("stop time must be 0 when nobody enters or leaves", - 0.0, driver.handleTransitStop(stop1, 60), MatsimTestUtils.EPSILON); + assertEquals(0.0, driver.handleTransitStop(stop1, 60), MatsimTestUtils.EPSILON, "stop time must be 0 when nobody enters or leaves"); assertEquals(2, queueVehicle.getPassengers().size()); - assertEquals("driver must proceed in stop list when no persons entered.", - stop2, driver.getNextTransitStop()); - assertEquals("driver must return same stop again when queried again without handling stop.", - stop2, driver.getNextTransitStop()); + assertEquals(stop2, driver.getNextTransitStop(), "driver must proceed in stop list when no persons entered."); + assertEquals(stop2, driver.getNextTransitStop(), "driver must return same stop again when queried again without handling stop."); tracker.addAgentToStop(100, agent3, stop2.getId()); double stoptime1 = driver.handleTransitStop(stop2, 150); @@ -324,11 +320,10 @@ void testHandleStop_EnterPassengers() { double stoptime2 = driver.handleTransitStop(stop2, 160); assertTrue(stoptime2 > 0); assertEquals(4, queueVehicle.getPassengers().size()); - assertTrue("The first stoptime should be larger as it contains door-opening/closing times as well. stoptime1=" + stoptime1 + " stoptime2=" + stoptime2, - stoptime1 > stoptime2); + assertTrue(stoptime1 > stoptime2, + "The first stoptime should be larger as it contains door-opening/closing times as well. stoptime1=" + stoptime1 + " stoptime2=" + stoptime2); tracker.addAgentToStop(163, agent5, stop2.getId()); - assertEquals("vehicle should have reached capacity, so not more passenger can enter.", - 0.0, driver.handleTransitStop(stop2, 170), MatsimTestUtils.EPSILON); + assertEquals(0.0, driver.handleTransitStop(stop2, 170), MatsimTestUtils.EPSILON, "vehicle should have reached capacity, so not more passenger can enter."); eventsManager.finishProcessing(); assertTrue(handler.isOk); @@ -402,15 +397,11 @@ void testHandleStop_ExitPassengers() { assertEquals(4, queueVehicle.getPassengers().size()); assertEquals(stop1, driver.getNextTransitStop()); assertTrue(driver.handleTransitStop(stop1, 50) > 0); - assertEquals("driver must not proceed in stop list when persons entered.", - stop1, driver.getNextTransitStop()); + assertEquals(stop1, driver.getNextTransitStop(), "driver must not proceed in stop list when persons entered."); assertEquals(2, queueVehicle.getPassengers().size()); - assertEquals("stop time must be 0 when nobody enters or leaves", - 0.0, driver.handleTransitStop(stop1, 60), MatsimTestUtils.EPSILON); - assertEquals("driver must proceed in stop list when no persons entered.", - stop2, driver.getNextTransitStop()); - assertEquals("driver must return same stop again when queried again without handling stop.", - stop2, driver.getNextTransitStop()); + assertEquals(0.0, driver.handleTransitStop(stop1, 60), MatsimTestUtils.EPSILON, "stop time must be 0 when nobody enters or leaves"); + assertEquals(stop2, driver.getNextTransitStop(), "driver must proceed in stop list when no persons entered."); + assertEquals(stop2, driver.getNextTransitStop(), "driver must return same stop again when queried again without handling stop."); assertTrue(driver.handleTransitStop(stop2, 150) > 0); assertEquals(0, queueVehicle.getPassengers().size()); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitQueueSimulationTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitQueueSimulationTest.java index 9424a078021..914190b0228 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitQueueSimulationTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitQueueSimulationTest.java @@ -20,9 +20,7 @@ package org.matsim.core.mobsim.qsim.pt; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; import java.util.ArrayList; import java.util.Collections; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitStopAgentTrackerTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitStopAgentTrackerTest.java index fe957af3ece..de2089883b5 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitStopAgentTrackerTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitStopAgentTrackerTest.java @@ -20,7 +20,7 @@ package org.matsim.core.mobsim.qsim.pt; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitVehicleTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitVehicleTest.java index dcc4082886c..50974030a15 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitVehicleTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/TransitVehicleTest.java @@ -20,7 +20,7 @@ package org.matsim.core.mobsim.qsim.pt; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.ArrayList; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/UmlaufDriverTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/UmlaufDriverTest.java index bf5bd5adb2c..e73ea8ae49f 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/UmlaufDriverTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/UmlaufDriverTest.java @@ -20,7 +20,7 @@ package org.matsim.core.mobsim.qsim.pt; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.ArrayList; import java.util.Collections; @@ -301,16 +301,12 @@ void testHandleStop_EnterPassengers() { assertEquals(stop1, driver.getNextTransitStop()); assertTrue(driver.handleTransitStop(stop1, 50) > 0); assertEquals(2, queueVehicle.getPassengers().size()); - assertEquals("driver must not proceed in stop list when persons entered.", - stop1, driver.getNextTransitStop()); + assertEquals(stop1, driver.getNextTransitStop(), "driver must not proceed in stop list when persons entered."); assertEquals(0, tracker.getAgentsAtFacility(stop1.getId()).size()); - assertEquals("stop time must be 0 when nobody enters or leaves", - 0.0, driver.handleTransitStop(stop1, 60), MatsimTestUtils.EPSILON); + assertEquals(0.0, driver.handleTransitStop(stop1, 60), MatsimTestUtils.EPSILON, "stop time must be 0 when nobody enters or leaves"); assertEquals(2, queueVehicle.getPassengers().size()); - assertEquals("driver must proceed in stop list when no persons entered.", - stop2, driver.getNextTransitStop()); - assertEquals("driver must return same stop again when queried again without handling stop.", - stop2, driver.getNextTransitStop()); + assertEquals(stop2, driver.getNextTransitStop(), "driver must proceed in stop list when no persons entered."); + assertEquals(stop2, driver.getNextTransitStop(), "driver must return same stop again when queried again without handling stop."); tracker.addAgentToStop(110, agent3, stop2.getId()); double stoptime1 = driver.handleTransitStop(stop2, 150); @@ -321,11 +317,10 @@ void testHandleStop_EnterPassengers() { double stoptime2 = driver.handleTransitStop(stop2, 160); assertTrue(stoptime2 > 0); assertEquals(4, queueVehicle.getPassengers().size()); - assertTrue("The first stoptime should be larger as it contains door-opening/closing times as well. stoptime1=" + stoptime1 + " stoptime2=" + stoptime2, - stoptime1 > stoptime2); + assertTrue(stoptime1 > stoptime2, + "The first stoptime should be larger as it contains door-opening/closing times as well. stoptime1=" + stoptime1 + " stoptime2=" + stoptime2); tracker.addAgentToStop(163, agent5, stop2.getId()); - assertEquals("vehicle should have reached capacity, so not more passenger can enter.", - 0.0, driver.handleTransitStop(stop2, 170), MatsimTestUtils.EPSILON); + assertEquals(0.0, driver.handleTransitStop(stop2, 170), MatsimTestUtils.EPSILON, "vehicle should have reached capacity, so not more passenger can enter."); } @Test @@ -381,15 +376,11 @@ void testHandleStop_ExitPassengers() { assertEquals(4, queueVehicle.getPassengers().size()); assertEquals(stop1, driver.getNextTransitStop()); assertTrue(driver.handleTransitStop(stop1, 50) > 0); - assertEquals("driver must not proceed in stop list when persons entered.", - stop1, driver.getNextTransitStop()); + assertEquals(stop1, driver.getNextTransitStop(), "driver must not proceed in stop list when persons entered."); assertEquals(2, queueVehicle.getPassengers().size()); - assertEquals("stop time must be 0 when nobody enters or leaves", - 0.0, driver.handleTransitStop(stop1, 60), MatsimTestUtils.EPSILON); - assertEquals("driver must proceed in stop list when no persons entered.", - stop2, driver.getNextTransitStop()); - assertEquals("driver must return same stop again when queried again without handling stop.", - stop2, driver.getNextTransitStop()); + assertEquals(0.0, driver.handleTransitStop(stop1, 60), MatsimTestUtils.EPSILON, "stop time must be 0 when nobody enters or leaves"); + assertEquals(stop2, driver.getNextTransitStop(), "driver must proceed in stop list when no persons entered."); + assertEquals(stop2, driver.getNextTransitStop(), "driver must return same stop again when queried again without handling stop."); assertTrue(driver.handleTransitStop(stop2, 150) > 0); assertEquals(0, queueVehicle.getPassengers().size()); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/DeparturesOnSameLinkSameTimeTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/DeparturesOnSameLinkSameTimeTest.java index 69911b6e800..e26d72120ad 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/DeparturesOnSameLinkSameTimeTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/DeparturesOnSameLinkSameTimeTest.java @@ -18,7 +18,7 @@ * *********************************************************************** */ package org.matsim.core.mobsim.qsim.qnetsimengine; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -71,16 +71,16 @@ void test4LinkEnterTimeOfCarAndBike() { Map,Map, Double>> carLinkLeaveTime = getLinkEnterTime(TransportMode.car,3600); double diff_carAgents_departureLink_LeaveTimes = carLinkLeaveTime.get(secondAgent).get(departureLink) - carLinkLeaveTime.get(firstAgent).get(departureLink); - Assert.assertEquals("Both car agents should leave at the gap of 1 sec.", 1., Math.abs(diff_carAgents_departureLink_LeaveTimes), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(1., Math.abs(diff_carAgents_departureLink_LeaveTimes), MatsimTestUtils.EPSILON, "Both car agents should leave at the gap of 1 sec." ); double diff_motorbikeAgents_departureLink_LeaveTimes = motorbikeLinkLeaveTime.get(secondAgent).get(departureLink) - motorbikeLinkLeaveTime.get(firstAgent).get(departureLink); - Assert.assertEquals("Both motorbike agents should leave at the same time.", 0., diff_motorbikeAgents_departureLink_LeaveTimes, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(0., diff_motorbikeAgents_departureLink_LeaveTimes, MatsimTestUtils.EPSILON, "Both motorbike agents should leave at the same time." ); // for flow cap more than 3600, both cars also should leave link l_1 at the same time. carLinkLeaveTime = getLinkEnterTime(TransportMode.car,3601); diff_carAgents_departureLink_LeaveTimes = carLinkLeaveTime.get(secondAgent).get(departureLink) - carLinkLeaveTime.get(firstAgent).get(departureLink); - Assert.assertEquals("Both car agents should leave at the same time", 0., diff_carAgents_departureLink_LeaveTimes, MatsimTestUtils.EPSILON ); + Assertions.assertEquals(0., diff_carAgents_departureLink_LeaveTimes, MatsimTestUtils.EPSILON, "Both car agents should leave at the same time" ); } private Map,Map, Double>> getLinkEnterTime (String travelMode, double departureLinkCapacity){ diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/EquiDistAgentSnapshotInfoBuilderTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/EquiDistAgentSnapshotInfoBuilderTest.java index 21566dda480..5af56c62d44 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/EquiDistAgentSnapshotInfoBuilderTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/EquiDistAgentSnapshotInfoBuilderTest.java @@ -28,7 +28,7 @@ import java.util.*; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class EquiDistAgentSnapshotInfoBuilderTest { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowCapacityVariationTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowCapacityVariationTest.java index 644fab1765f..66f3d0000b6 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowCapacityVariationTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowCapacityVariationTest.java @@ -20,7 +20,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -108,8 +108,8 @@ private void vehiclesLeavingSameTime(String travelMode, double linkCapacity){ int linkLeaveTime1 = (int)times1.get(Id.create("2", Link.class))[1]; int linkLeaveTime2 = (int)times2.get(Id.create("2", Link.class))[1]; - Assert.assertEquals(travelMode+ " entered at different time", 0, linkEnterTime1-linkEnterTime2); - Assert.assertEquals(travelMode +" entered at same time but not leaving the link at the same time.", 0, linkLeaveTime1-linkLeaveTime2); + Assertions.assertEquals(0, linkEnterTime1-linkEnterTime2, travelMode+ " entered at different time"); + Assertions.assertEquals(0, linkLeaveTime1-linkLeaveTime2, travelMode +" entered at same time but not leaving the link at the same time."); } private static final class PseudoInputs{ diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowEfficiencyCalculatorTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowEfficiencyCalculatorTest.java index aaf251d8c0d..714d3e0452b 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowEfficiencyCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowEfficiencyCalculatorTest.java @@ -22,7 +22,7 @@ package org.matsim.core.mobsim.qsim.qnetsimengine; import com.google.inject.Provides; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -60,16 +60,16 @@ void testFlowEfficiencyCalculator() { double latestArrivalTime; latestArrivalTime = runTestScenario(Double.POSITIVE_INFINITY); - Assert.assertEquals(1003.0, latestArrivalTime, 1e-3); + Assertions.assertEquals(1003.0, latestArrivalTime, 1e-3); latestArrivalTime = runTestScenario(1.0); - Assert.assertEquals(8195.0, latestArrivalTime, 1e-3); + Assertions.assertEquals(8195.0, latestArrivalTime, 1e-3); latestArrivalTime = runTestScenario(2.0); - Assert.assertEquals(4599.0, latestArrivalTime, 1e-3); + Assertions.assertEquals(4599.0, latestArrivalTime, 1e-3); latestArrivalTime = runTestScenario(0.5); - Assert.assertEquals(15388.0, latestArrivalTime, 1e-3); + Assertions.assertEquals(15388.0, latestArrivalTime, 1e-3); } public double runTestScenario(double factor) { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/JavaRoundingErrorInQsimTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/JavaRoundingErrorInQsimTest.java index bf1b8ee6733..e7342fff755 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/JavaRoundingErrorInQsimTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/JavaRoundingErrorInQsimTest.java @@ -24,7 +24,7 @@ import java.util.Map; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -97,10 +97,10 @@ void testToCheckTravelTime() { .run(); //agent 2 is departed first so will have free speed time = 1000/25 +1 = 41 sec - Assert.assertEquals( "Wrong travel time for on link 2 for vehicle 2" , 41.0 , vehicleLinkTravelTime.get(Id.createVehicleId(2)) , MatsimTestUtils.EPSILON); + Assertions.assertEquals( 41.0 , vehicleLinkTravelTime.get(Id.createVehicleId(2)) , MatsimTestUtils.EPSILON, "Wrong travel time for on link 2 for vehicle 2"); // agent 1 should have 1000/25 +1 + 10 = 51 but, it may be 52 sec sometimes due to rounding errors in java. Rounding errors is eliminated at the moment if accumulating flow to zero instead of one. - Assert.assertEquals( "Wrong travel time for on link 2 for vehicle 1" , 51.0 , vehicleLinkTravelTime.get(Id.createVehicleId(1)) , MatsimTestUtils.EPSILON); + Assertions.assertEquals( 51.0 , vehicleLinkTravelTime.get(Id.createVehicleId(1)) , MatsimTestUtils.EPSILON, "Wrong travel time for on link 2 for vehicle 1"); LogManager.getLogger(JavaRoundingErrorInQsimTest.class).warn("Although the test is passing instead of failing for vehicle 1. This is done intentionally in order to keep this in mind for future."); } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/LinkSpeedCalculatorIntegrationTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/LinkSpeedCalculatorIntegrationTest.java index f72301f3fd0..2a6554df93d 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/LinkSpeedCalculatorIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/LinkSpeedCalculatorIntegrationTest.java @@ -22,7 +22,7 @@ import java.util.*; import jakarta.inject.Inject; import jakarta.inject.Provider; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -74,18 +74,18 @@ void testIntegration_Default() { .run(); List events = collector.getEvents(); - Assert.assertTrue(events.get(5) instanceof LinkEnterEvent); + Assertions.assertTrue(events.get(5) instanceof LinkEnterEvent); LinkEnterEvent lee = (LinkEnterEvent) events.get(5); - Assert.assertEquals("1", lee.getVehicleId().toString()); - Assert.assertEquals("2", lee.getLinkId().toString()); + Assertions.assertEquals("1", lee.getVehicleId().toString()); + Assertions.assertEquals("2", lee.getLinkId().toString()); - Assert.assertTrue(events.get(6) instanceof LinkLeaveEvent); + Assertions.assertTrue(events.get(6) instanceof LinkLeaveEvent); LinkLeaveEvent lle = (LinkLeaveEvent) events.get(6); - Assert.assertEquals("1", lle.getVehicleId().toString()); - Assert.assertEquals("2", lle.getLinkId().toString()); + Assertions.assertEquals("1", lle.getVehicleId().toString()); + Assertions.assertEquals("2", lle.getLinkId().toString()); // by default, the link takes 10 seconds to travel along, plus 1 second in the buffer, makes total of 11 seconds - Assert.assertEquals(11, lle.getTime() - lee.getTime(), 1e-8); + Assertions.assertEquals(11, lle.getTime() - lee.getTime(), 1e-8); } @SuppressWarnings("static-method") @@ -126,18 +126,18 @@ void testIntegration_Slow() { builder.build( scenario, eventsManager ).run() ; List events = collector.getEvents(); - Assert.assertTrue(events.get(5) instanceof LinkEnterEvent); + Assertions.assertTrue(events.get(5) instanceof LinkEnterEvent); LinkEnterEvent lee = (LinkEnterEvent) events.get(5); - Assert.assertEquals("1", lee.getVehicleId().toString()); - Assert.assertEquals("2", lee.getLinkId().toString()); + Assertions.assertEquals("1", lee.getVehicleId().toString()); + Assertions.assertEquals("2", lee.getLinkId().toString()); - Assert.assertTrue(events.get(6) instanceof LinkLeaveEvent); + Assertions.assertTrue(events.get(6) instanceof LinkLeaveEvent); LinkLeaveEvent lle = (LinkLeaveEvent) events.get(6); - Assert.assertEquals("1", lle.getVehicleId().toString()); - Assert.assertEquals("2", lle.getLinkId().toString()); + Assertions.assertEquals("1", lle.getVehicleId().toString()); + Assertions.assertEquals("2", lle.getLinkId().toString()); // with 5 per second, the link takes 20 seconds to travel along, plus 1 second in the buffer, makes total of 21 seconds - Assert.assertEquals(21, lle.getTime() - lee.getTime(), 1e-8); + Assertions.assertEquals(21, lle.getTime() - lee.getTime(), 1e-8); } @SuppressWarnings("static-method") @@ -183,18 +183,18 @@ void testIntegration_Fast() { new QSimBuilder( config ).useDefaults().addOverridingQSimModule( overrides ).build( scenario, eventsManager ).run() ; List events = collector.getEvents(); - Assert.assertTrue(events.get(5) instanceof LinkEnterEvent); + Assertions.assertTrue(events.get(5) instanceof LinkEnterEvent); LinkEnterEvent lee = (LinkEnterEvent) events.get(5); - Assert.assertEquals("1", lee.getVehicleId().toString()); - Assert.assertEquals("2", lee.getLinkId().toString()); + Assertions.assertEquals("1", lee.getVehicleId().toString()); + Assertions.assertEquals("2", lee.getLinkId().toString()); - Assert.assertTrue(events.get(6) instanceof LinkLeaveEvent); + Assertions.assertTrue(events.get(6) instanceof LinkLeaveEvent); LinkLeaveEvent lle = (LinkLeaveEvent) events.get(6); - Assert.assertEquals("1", lle.getVehicleId().toString()); - Assert.assertEquals("2", lle.getLinkId().toString()); + Assertions.assertEquals("1", lle.getVehicleId().toString()); + Assertions.assertEquals("2", lle.getLinkId().toString()); // the link should take 5 seconds to travel along, plus 1 second in the buffer, makes total of 6 seconds - Assert.assertEquals(6, lle.getTime() - lee.getTime(), 1e-8); + Assertions.assertEquals(6, lle.getTime() - lee.getTime(), 1e-8); } static class CustomLinkSpeedCalculator implements LinkSpeedCalculator { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/PassingTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/PassingTest.java index ceac270a514..111b37cc82c 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/PassingTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/PassingTest.java @@ -20,7 +20,7 @@ import java.util.*; import jakarta.inject.Inject; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -119,9 +119,9 @@ void test4PassingInFreeFlowState(){ int bikeTravelTime = travelTime1.get(Id.create("2", Link.class)).intValue(); int carTravelTime = travelTime2.get(Id.create("2", Link.class)).intValue(); - Assert.assertEquals("Wrong car travel time", 51, carTravelTime); - Assert.assertEquals("Wrong bike travel time", 201, bikeTravelTime); - Assert.assertEquals("Passing is not implemented", 150, bikeTravelTime-carTravelTime); + Assertions.assertEquals(51, carTravelTime, "Wrong car travel time"); + Assertions.assertEquals(201, bikeTravelTime, "Wrong bike travel time"); + Assertions.assertEquals(150, bikeTravelTime-carTravelTime, "Passing is not implemented"); } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkLanesTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkLanesTest.java index 76e0c77788b..53794c1f44a 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkLanesTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkLanesTest.java @@ -19,8 +19,8 @@ * *********************************************************************** */ package org.matsim.core.mobsim.qsim.qnetsimengine; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkTest.java index 9ccdd910c12..6bcba7b34bc 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkTest.java @@ -19,7 +19,7 @@ package org.matsim.core.mobsim.qsim.qnetsimengine; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.ArrayList; import java.util.Arrays; @@ -184,7 +184,7 @@ void testGetVehicle_Driving() { f.qlink1.getAcceptingQLane().addFromUpstream(veh); assertTrue(f.qlink1.isNotOfferingVehicle()); assertEquals(1, ((QueueWithBuffer) f.qlink1.getAcceptingQLane()).getAllVehicles().size()); - assertEquals("vehicle not found on link.", veh, f.qlink1.getVehicle(id1)); + assertEquals(veh, f.qlink1.getVehicle(id1), "vehicle not found on link."); assertEquals(1, f.qlink1.getAllVehicles().size()); now = 1. ; @@ -208,7 +208,7 @@ void testGetVehicle_Driving() { assertEquals(veh, f.qlink1.getOfferingQLanes().get(0).popFirstVehicle()); assertTrue(f.qlink1.isNotOfferingVehicle()); // assertEquals(0, ((QueueWithBuffer) f.qlink1.qlane).vehInQueueCount()); - assertNull("vehicle should not be on link anymore.", f.qlink1.getVehicle(id1)); + assertNull(f.qlink1.getVehicle(id1), "vehicle should not be on link anymore."); assertEquals(0, f.qlink1.getAllVehicles().size()); } @@ -239,14 +239,14 @@ void testGetVehicle_Parking() { f.qlink1.addParkedVehicle(veh); assertTrue(f.qlink1.isNotOfferingVehicle()); assertEquals(0, ((QueueWithBuffer) f.qlink1.getAcceptingQLane()).getAllVehicles().size()); // vehicle not on _lane_ - assertEquals("vehicle not found in parking list.", veh, f.qlink1.getVehicle(id1)); + assertEquals(veh, f.qlink1.getVehicle(id1), "vehicle not found in parking list."); assertEquals(1, f.qlink1.getAllVehicles().size()); // vehicle indeed on _link_ assertEquals(veh, f.qlink1.getAllVehicles().iterator().next()); - assertEquals("removed wrong vehicle.", veh, f.qlink1.removeParkedVehicle(veh.getId())); + assertEquals(veh, f.qlink1.removeParkedVehicle(veh.getId()), "removed wrong vehicle."); assertTrue(f.qlink1.isNotOfferingVehicle()); assertEquals(0, ((QueueWithBuffer) f.qlink1.getAcceptingQLane()).getAllVehicles().size()); - assertNull("vehicle not found in parking list.", f.qlink1.getVehicle(id1)); + assertNull(f.qlink1.getVehicle(id1), "vehicle not found in parking list."); assertEquals(0, f.qlink1.getAllVehicles().size()); } @@ -291,7 +291,7 @@ void testGetVehicle_Departing() { f.queueNetwork.simEngine.getNetsimInternalInterface().arrangeNextAgentState(driver) ; // i.e. driver departs, should now be in wait queue assertTrue(f.qlink1.isNotOfferingVehicle()); // veh not in buffer assertEquals(0, ((QueueWithBuffer) f.qlink1.getAcceptingQLane()).getAllVehicles().size()); // veh not on lane - assertEquals("vehicle not found in waiting list.", veh, f.qlink1.getVehicle(id1)); // veh _should_ be on link (in waiting list) + assertEquals(veh, f.qlink1.getVehicle(id1), "vehicle not found in waiting list."); // veh _should_ be on link (in waiting list) assertEquals(1, f.qlink1.getAllVehicles().size()); // dto assertEquals(veh, f.qlink1.getAllVehicles().iterator().next()); // dto @@ -302,7 +302,7 @@ void testGetVehicle_Departing() { f.qlink1.doSimStep(); assertFalse(f.qlink1.isNotOfferingVehicle()); // i.e. is offering the vehicle assertEquals(1, ((QueueWithBuffer) f.qlink1.getAcceptingQLane()).getAllVehicles().size()); // somewhere on lane - assertEquals("vehicle not found in buffer.", veh, f.qlink1.getVehicle(id1)); // somewhere on link + assertEquals(veh, f.qlink1.getVehicle(id1), "vehicle not found in buffer."); // somewhere on link assertEquals(1, f.qlink1.getAllVehicles().size()); // somewhere on link now = 2. ; @@ -312,7 +312,7 @@ void testGetVehicle_Departing() { assertEquals(veh, f.qlink1.getOfferingQLanes().get(0).popFirstVehicle()); assertTrue(f.qlink1.isNotOfferingVehicle()); assertEquals(0, ((QueueWithBuffer) f.qlink1.getAcceptingQLane()).getAllVehicles().size()); - assertNull("vehicle should not be on link anymore.", f.qlink1.getVehicle(id1)); + assertNull(f.qlink1.getVehicle(id1), "vehicle should not be on link anymore."); assertEquals(0, f.qlink1.getAllVehicles().size()); } @@ -479,7 +479,7 @@ void testStorageSpaceDifferentVehicleSizes() { driver5.setVehicle(veh5); driver5.endActivityAndComputeNextState( now ); - assertEquals("wrong initial storage capacity.", 10.0, f.qlink2.getSpaceCap(), MatsimTestUtils.EPSILON); + assertEquals(10.0, f.qlink2.getSpaceCap(), MatsimTestUtils.EPSILON, "wrong initial storage capacity."); f.qlink2.getAcceptingQLane().addFromUpstream(veh5); // used vehicle equivalents: 5 assertTrue(f.qlink2.getAcceptingQLane().isAcceptingFromUpstream()); f.qlink2.getAcceptingQLane().addFromUpstream(veh5); // used vehicle equivalents: 10 diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QueueAgentSnapshotInfoBuilderTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QueueAgentSnapshotInfoBuilderTest.java index 325ef2996c1..b81a8fb91a0 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QueueAgentSnapshotInfoBuilderTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QueueAgentSnapshotInfoBuilderTest.java @@ -1,5 +1,7 @@ package org.matsim.core.mobsim.qsim.qnetsimengine; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -28,8 +30,6 @@ import java.util.*; -import static org.junit.Assert.assertEquals; - public class QueueAgentSnapshotInfoBuilderTest { @Test diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SeepageTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SeepageTest.java index 6a18868b17d..8cfe3e14e1e 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SeepageTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SeepageTest.java @@ -20,7 +20,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -156,9 +156,9 @@ void seepageOfWalkInCongestedRegime(){ int carTravelTime = travelTime2.get(Id.createLinkId("2")).intValue(); // if(this.isUsingFastCapacityUpdate) { - Assert.assertEquals("Wrong car travel time", 115, carTravelTime); - Assert.assertEquals("Wrong walk travel time.", 1009, walkTravelTime); - Assert.assertEquals("Seepage is not implemented", 894, walkTravelTime-carTravelTime); + Assertions.assertEquals(115, carTravelTime, "Wrong car travel time"); + Assertions.assertEquals(1009, walkTravelTime, "Wrong walk travel time."); + Assertions.assertEquals(894, walkTravelTime-carTravelTime, "Seepage is not implemented"); // } else { // Assert.assertEquals("Wrong car travel time", 116, carTravelTime); // Assert.assertEquals("Wrong walk travel time.", 1010, walkTravelTime); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java index 92e225da500..8fc3a972827 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java @@ -21,13 +21,13 @@ */ package org.matsim.core.mobsim.qsim.qnetsimengine; -import static org.junit.Assert.assertEquals; - import java.util.Collections; import java.util.HashMap; import java.util.Map; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SpeedCalculatorTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SpeedCalculatorTest.java index cc4b76d055c..ed394e4bd46 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SpeedCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SpeedCalculatorTest.java @@ -26,8 +26,8 @@ import java.util.UUID; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SpeedCalculatorTest{ // This originally comes from the bicycle contrib. One now needs access to AbstractQLink to properly test this functionality. In contrast, the diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehVsLinkSpeedTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehVsLinkSpeedTest.java index 765d3875106..19f03965a02 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehVsLinkSpeedTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehVsLinkSpeedTest.java @@ -19,7 +19,8 @@ package org.matsim.core.mobsim.qsim.qnetsimengine; import java.util.*; -import org.junit.Assert; + +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -123,8 +124,7 @@ void testVehicleSpeed(){ double carTravelTime = travelTime1.get(desiredLink.getId()); // 1000 / min(25, vehSpeed) double speedUsedInSimulation = Math.round( desiredLink.getLength() / (carTravelTime - 1) ); - Assert.assertEquals("In the simulation minimum of vehicle speed and link speed should be used.", - Math.min(vehSpeed, MAX_SPEED_ON_LINK), speedUsedInSimulation, MatsimTestUtils.EPSILON); + Assertions.assertEquals(Math.min(vehSpeed, MAX_SPEED_ON_LINK), speedUsedInSimulation, MatsimTestUtils.EPSILON, "In the simulation minimum of vehicle speed and link speed should be used."); } private static final class SimpleNetwork{ diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java index b258f338ef5..7a9d4e656ad 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java @@ -22,8 +22,7 @@ package org.matsim.core.mobsim.qsim.qnetsimengine; import java.util.Arrays; - -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -76,20 +75,20 @@ void testVehicleHandler() { Result result; result = runTestScenario(4); - Assert.assertEquals(20203.0, result.latestArrivalTime, 1e-3); - Assert.assertEquals(3, result.initialCount); + Assertions.assertEquals(20203.0, result.latestArrivalTime, 1e-3); + Assertions.assertEquals(3, result.initialCount); result = runTestScenario(3); - Assert.assertEquals(20203.0, result.latestArrivalTime, 1e-3); - Assert.assertEquals(3, result.initialCount); + Assertions.assertEquals(20203.0, result.latestArrivalTime, 1e-3); + Assertions.assertEquals(3, result.initialCount); result = runTestScenario(2); - Assert.assertEquals(23003.0, result.latestArrivalTime, 1e-3); - Assert.assertEquals(3, result.initialCount); + Assertions.assertEquals(23003.0, result.latestArrivalTime, 1e-3); + Assertions.assertEquals(3, result.initialCount); result = runTestScenario(1); - Assert.assertEquals(33003.0, result.latestArrivalTime, 1e-3); - Assert.assertEquals(3, result.initialCount); + Assertions.assertEquals(33003.0, result.latestArrivalTime, 1e-3); + Assertions.assertEquals(3, result.initialCount); } public Result runTestScenario(long capacity) { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleWaitingTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleWaitingTest.java index 133dd1d9ed9..d960b437f88 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleWaitingTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleWaitingTest.java @@ -25,7 +25,7 @@ import java.util.List; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -187,13 +187,13 @@ public void handleEvent(final PersonArrivalEvent event) { .run(); for ( Id id : personIds ) { - Assert.assertNotNull( - "no arrivals for person "+id, - arrivalCounts.get( id ) ); - Assert.assertEquals( - "unexpected number of arrivals for person "+id, + Assertions.assertNotNull( + arrivalCounts.get( id ), + "no arrivals for person "+id ); + Assertions.assertEquals( nLaps * 2, - arrivalCounts.get( id ).intValue()); + arrivalCounts.get( id ).intValue(), + "unexpected number of arrivals for person "+id); } } } diff --git a/matsim/src/test/java/org/matsim/core/network/AbstractNetworkWriterReaderTest.java b/matsim/src/test/java/org/matsim/core/network/AbstractNetworkWriterReaderTest.java index 33464907505..b3c47aecbf7 100644 --- a/matsim/src/test/java/org/matsim/core/network/AbstractNetworkWriterReaderTest.java +++ b/matsim/src/test/java/org/matsim/core/network/AbstractNetworkWriterReaderTest.java @@ -20,7 +20,7 @@ package org.matsim.core.network; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -33,7 +33,7 @@ import java.util.List; import java.util.Set; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -163,10 +163,10 @@ void testNodes_IdSpecialCharacters() { Node nodeA2 = network2.getNodes().get(nodeA1.getId()); Node nodeB2 = network2.getNodes().get(nodeB1.getId()); - Assert.assertNotNull(nodeA2); - Assert.assertNotNull(nodeB2); - Assert.assertNotSame(nodeA1, nodeA2); - Assert.assertNotSame(nodeB1, nodeB2); + Assertions.assertNotNull(nodeA2); + Assertions.assertNotNull(nodeB2); + Assertions.assertNotSame(nodeA1, nodeA2); + Assertions.assertNotSame(nodeB1, nodeB2); } @Test @@ -190,10 +190,10 @@ void testLinks_IdSpecialCharacters() { Link linkA2 = network2.getLinks().get(linkA1.getId()); Link linkB2 = network2.getLinks().get(linkB1.getId()); - Assert.assertNotNull(linkA2); - Assert.assertNotNull(linkB2); - Assert.assertNotSame(linkA1, linkA2); - Assert.assertNotSame(linkB1, linkB2); + Assertions.assertNotNull(linkA2); + Assertions.assertNotNull(linkB2); + Assertions.assertNotSame(linkA1, linkA2); + Assertions.assertNotSame(linkB1, linkB2); // Assert.assertEquals(NetworkUtils.getType(linkA1), NetworkUtils.getType(linkA2)); // type is not supported anymore in v2 // Assert.assertEquals(NetworkUtils.getOrigId(linkB1), NetworkUtils.getOrigId(linkB2)); // origId is not supported anymore in v2 } @@ -216,8 +216,8 @@ void testNetwork_NameSpecialCharacters() { Network network2 = doIOTest(network1); - Assert.assertNotSame(network1, network2); - Assert.assertEquals(network1.getName(), network2.getName()); + Assertions.assertNotSame(network1, network2); + Assertions.assertEquals(network1.getName(), network2.getName()); } private void doTestAllowedModes(final Set modes, final String filename) { @@ -232,19 +232,19 @@ private void doTestAllowedModes(final Set modes, final String filename) writeNetwork(network1, filename); File networkFile = new File(filename); - assertTrue("written network file doesn't exist.", networkFile.exists()); - assertTrue("written network file seems to be empty.", networkFile.length() > 0); + assertTrue(networkFile.exists(), "written network file doesn't exist."); + assertTrue(networkFile.length() > 0, "written network file seems to be empty."); Scenario scenario2 = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network2 = scenario2.getNetwork(); readNetwork(scenario2, filename); Link link1 = network2.getLinks().get(Id.create("1", Link.class)); - assertNotNull("link not found in read-in network.", link1); + assertNotNull(link1, "link not found in read-in network."); Set modes2 = link1.getAllowedModes(); - assertEquals("wrong number of allowed modes.", modes.size(), modes2.size()); - assertTrue("wrong mode.", modes2.containsAll(modes)); + assertEquals(modes.size(), modes2.size(), "wrong number of allowed modes."); + assertTrue(modes2.containsAll(modes), "wrong mode."); } private static Set createHashSet(T... mode) { @@ -262,15 +262,15 @@ private void doTestNodes(List nodes, final String filename) { writeNetwork(network1, filename); File networkFile = new File(filename); - assertTrue("written network file doesn't exist.", networkFile.exists()); - assertTrue("written network file seems to be empty.", networkFile.length() > 0); + assertTrue(networkFile.exists(), "written network file doesn't exist."); + assertTrue(networkFile.length() > 0, "written network file seems to be empty."); Scenario scenario2 = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network2 = scenario2.getNetwork(); readNetwork(scenario2, filename); for(Node n : nodes){ - assertEquals("Coordinates are not equal.", n.getCoord(), network2.getNodes().get(n.getId()).getCoord()); + assertEquals(n.getCoord(), network2.getNodes().get(n.getId()).getCoord(), "Coordinates are not equal."); } } diff --git a/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksTest.java b/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksTest.java index c4e230ce20f..c1c37f3f96e 100644 --- a/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksTest.java +++ b/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksTest.java @@ -7,7 +7,7 @@ import java.util.List; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.io.TempDir; @@ -33,19 +33,19 @@ void testEquals() { dnl0.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"), Id.createLinkId("1"))); dnl1.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"), Id.createLinkId("1"))); - Assert.assertEquals(dnl0, dnl1); - Assert.assertEquals(dnl1, dnl0); + Assertions.assertEquals(dnl0, dnl1); + Assertions.assertEquals(dnl1, dnl0); dnl1.addDisallowedLinkSequence("bike", List.of(Id.createLinkId("0"))); - Assert.assertNotEquals(dnl0, dnl1); - Assert.assertNotEquals(dnl1, dnl0); + Assertions.assertNotEquals(dnl0, dnl1); + Assertions.assertNotEquals(dnl1, dnl0); } @Test void testIsEmpty() { DisallowedNextLinks dnl= new DisallowedNextLinks(); - Assert.assertTrue(dnl.isEmpty()); + Assertions.assertTrue(dnl.isEmpty()); } @Test @@ -58,7 +58,7 @@ void testAdding() { Map>>> map = Map.of( "bike", List.of(List.of(Id.createLinkId("0"))), "car", List.of(List.of(Id.createLinkId("0"), Id.createLinkId("1")), List.of(Id.createLinkId("0")))); - Assert.assertEquals(map, dnl.getAsMap()); + Assertions.assertEquals(map, dnl.getAsMap()); } @Test @@ -72,30 +72,30 @@ void testRemoving() { Map>>> map = Map.of( "car", List.of(List.of(Id.createLinkId("0"), Id.createLinkId("1")), List.of(Id.createLinkId("0")))); - Assert.assertEquals(map, dnl.getAsMap()); + Assertions.assertEquals(map, dnl.getAsMap()); } @Test void testNotAddingDuplicates() { DisallowedNextLinks dnl = new DisallowedNextLinks(); - Assert.assertTrue(dnl.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"), Id.createLinkId("1")))); - Assert.assertFalse(dnl.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"), Id.createLinkId("1")))); - Assert.assertFalse(dnl.addDisallowedLinkSequence("car", Collections.emptyList())); + Assertions.assertTrue(dnl.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"), Id.createLinkId("1")))); + Assertions.assertFalse(dnl.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"), Id.createLinkId("1")))); + Assertions.assertFalse(dnl.addDisallowedLinkSequence("car", Collections.emptyList())); } @Test void testNotAddingEmpty() { DisallowedNextLinks dnl = new DisallowedNextLinks(); - Assert.assertFalse(dnl.addDisallowedLinkSequence("car", Collections.emptyList())); + Assertions.assertFalse(dnl.addDisallowedLinkSequence("car", Collections.emptyList())); } @Test void testNotAddingSequenceWithDuplicates() { DisallowedNextLinks dnl = new DisallowedNextLinks(); - Assert.assertFalse(dnl.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"), Id.createLinkId("0")))); + Assertions.assertFalse(dnl.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"), Id.createLinkId("0")))); } @Test @@ -107,8 +107,8 @@ void testEqualAndHashCode() { dnl1.addDisallowedLinkSequence("car", List.of(Id.createLinkId("4"), Id.createLinkId("5"))); dnl1.addDisallowedLinkSequence("car", List.of(Id.createLinkId("0"), Id.createLinkId("1"))); - Assert.assertEquals(dnl0, dnl1); - Assert.assertEquals(dnl0.hashCode(), dnl1.hashCode()); + Assertions.assertEquals(dnl0, dnl1); + Assertions.assertEquals(dnl0.hashCode(), dnl1.hashCode()); } @Test @@ -122,10 +122,10 @@ void testSerialization() { String s = ac.convertToString(dnl0); DisallowedNextLinks dnl1 = ac.convert(s); - Assert.assertEquals("{\"car\":[[\"0\",\"1\",\"2\"],[\"0\",\"3\"]],\"bike\":[[\"10\",\"11\"]]}", s); - Assert.assertEquals(dnl0, dnl1); - Assert.assertEquals(dnl0.hashCode(), dnl1.hashCode()); - Assert.assertSame(dnl0.getDisallowedLinkSequences("car").get(0).get(0), + Assertions.assertEquals("{\"car\":[[\"0\",\"1\",\"2\"],[\"0\",\"3\"]],\"bike\":[[\"10\",\"11\"]]}", s); + Assertions.assertEquals(dnl0, dnl1); + Assertions.assertEquals(dnl0.hashCode(), dnl1.hashCode()); + Assertions.assertSame(dnl0.getDisallowedLinkSequences("car").get(0).get(0), dnl1.getDisallowedLinkSequences("car").get(0).get(0)); } @@ -143,9 +143,9 @@ void testNetworkWritingAndReading() throws IOException { new MatsimNetworkReader(network).readFile(tempFile.toString()); DisallowedNextLinks dnl1 = NetworkUtils.getDisallowedNextLinks(network.getLinks().get(l1.getId())); - Assert.assertEquals(dnl0, dnl1); - Assert.assertEquals(dnl0.hashCode(), dnl1.hashCode()); - Assert.assertSame(l1.getId(), dnl1.getDisallowedLinkSequences("car").get(0).get(0)); + Assertions.assertEquals(dnl0, dnl1); + Assertions.assertEquals(dnl0.hashCode(), dnl1.hashCode()); + Assertions.assertSame(l1.getId(), dnl1.getDisallowedLinkSequences("car").get(0).get(0)); } static Network createNetwork() { diff --git a/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksUtilsTest.java b/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksUtilsTest.java index 42ea61a6022..41f9a1205ac 100644 --- a/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksUtilsTest.java @@ -3,7 +3,7 @@ import java.util.List; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -15,7 +15,7 @@ public class DisallowedNextLinksUtilsTest { @Test void testNoDisallowedNextLinks() { - Assert.assertTrue(DisallowedNextLinksUtils.isValid(n)); + Assertions.assertTrue(DisallowedNextLinksUtils.isValid(n)); } @Test @@ -28,7 +28,7 @@ void testIsNotValid1() { dnl.addDisallowedLinkSequence("car", List.of(l1.getId(), l3.getId())); dnl.addDisallowedLinkSequence("bike", List.of(l1.getId())); - Assert.assertFalse(DisallowedNextLinksUtils.isValid(n)); + Assertions.assertFalse(DisallowedNextLinksUtils.isValid(n)); } @Test @@ -41,7 +41,7 @@ void testIsNotValid2() { dnl.addDisallowedLinkSequence("car", List.of(l1.getId(), l3.getId())); dnl.addDisallowedLinkSequence("bike", List.of(Id.createLinkId("a"))); - Assert.assertFalse(DisallowedNextLinksUtils.isValid(n)); + Assertions.assertFalse(DisallowedNextLinksUtils.isValid(n)); } @Test @@ -55,6 +55,6 @@ void testIsValid() { dnl.addDisallowedLinkSequence("car", List.of(l3.getId(), l5.getId())); dnl.addDisallowedLinkSequence("bike", List.of(l3.getId())); - Assert.assertTrue(DisallowedNextLinksUtils.isValid(n)); + Assertions.assertTrue(DisallowedNextLinksUtils.isValid(n)); } } diff --git a/matsim/src/test/java/org/matsim/core/network/LinkImplTest.java b/matsim/src/test/java/org/matsim/core/network/LinkImplTest.java index 26257dffe0a..e71bc1c731c 100644 --- a/matsim/src/test/java/org/matsim/core/network/LinkImplTest.java +++ b/matsim/src/test/java/org/matsim/core/network/LinkImplTest.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -85,98 +85,98 @@ void testCalcDistance() { // do the following cases for each link // case 1: point is orthogonal next to link.fromNode, test both sides of link - Assert.assertEquals(10.0, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(10.0, 0.0)), EPSILON); + Assertions.assertEquals(10.0, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(10.0, 0.0)), EPSILON); final double x7 = -12.5; - Assert.assertEquals(12.5, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(x7, 0.0)), EPSILON); - Assert.assertEquals(Math.sqrt(2*65.4*65.4), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(65.4, 1000.0 - 65.4)), EPSILON); + Assertions.assertEquals(12.5, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(x7, 0.0)), EPSILON); + Assertions.assertEquals(Math.sqrt(2*65.4*65.4), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(65.4, 1000.0 - 65.4)), EPSILON); final double x6 = -76.5; - Assert.assertEquals(Math.sqrt(2*76.5*76.5), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(x6, 1000.0 + 76.5)), EPSILON); - Assert.assertEquals(123.987, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(1000.0, 2000.0 - 123.987)), EPSILON); - Assert.assertEquals(23.87, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(1000.0, 2000.0 + 23.87)), EPSILON); - Assert.assertEquals(Math.sqrt(32.4*32.4*1.25), CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(2000.0 + 32.4, 2000 - 32.4 / 2.0)), EPSILON); - Assert.assertEquals(Math.sqrt(56.8*56.8*1.25), CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(2000.0 - 56.8, 2000 + 56.8 / 2.0)), EPSILON); + Assertions.assertEquals(Math.sqrt(2*76.5*76.5), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(x6, 1000.0 + 76.5)), EPSILON); + Assertions.assertEquals(123.987, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(1000.0, 2000.0 - 123.987)), EPSILON); + Assertions.assertEquals(23.87, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(1000.0, 2000.0 + 23.87)), EPSILON); + Assertions.assertEquals(Math.sqrt(32.4*32.4*1.25), CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(2000.0 + 32.4, 2000 - 32.4 / 2.0)), EPSILON); + Assertions.assertEquals(Math.sqrt(56.8*56.8*1.25), CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(2000.0 - 56.8, 2000 + 56.8 / 2.0)), EPSILON); // case 2: point is behind link, but exactly on extension of the link's line final double y6 = -15.0; - Assert.assertEquals(15.0, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(0.0, y6)), EPSILON); + Assertions.assertEquals(15.0, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(0.0, y6)), EPSILON); final double x5 = -5.0; - Assert.assertEquals(Math.sqrt(50.0), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(x5, 995.0)), EPSILON); - Assert.assertEquals(12.35, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(987.65, 2000.0)), EPSILON); - Assert.assertEquals(Math.sqrt(250.0*250.0 + 500.0*500.0), CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(2250.0, 2500.0)), EPSILON); + Assertions.assertEquals(Math.sqrt(50.0), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(x5, 995.0)), EPSILON); + Assertions.assertEquals(12.35, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(987.65, 2000.0)), EPSILON); + Assertions.assertEquals(Math.sqrt(250.0*250.0 + 500.0*500.0), CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(2250.0, 2500.0)), EPSILON); // case 3: point is behind and on the side of link, test both sides of link final double y5 = -15.0; - Assert.assertEquals(Math.sqrt(325.0), CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(10.0, y5)), EPSILON); + Assertions.assertEquals(Math.sqrt(325.0), CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(10.0, y5)), EPSILON); final double x4 = -15.0; final double y4 = -20.0; - Assert.assertEquals(Math.sqrt(625.0), CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(x4, y4)), EPSILON); - Assert.assertEquals(50.5, CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(0.0, 949.5)), EPSILON); + Assertions.assertEquals(Math.sqrt(625.0), CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(x4, y4)), EPSILON); + Assertions.assertEquals(50.5, CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(0.0, 949.5)), EPSILON); final double x3 = -51.5; - Assert.assertEquals(51.5, CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(x3, 1000.0)), EPSILON); - Assert.assertEquals(Math.sqrt(1300.0), CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(970.0, 1980.0)), EPSILON); - Assert.assertEquals(Math.sqrt(1300.0), CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(980.0, 2030.0)), EPSILON); - Assert.assertEquals(145.7, CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(2000.0, 2145.7)), EPSILON); - Assert.assertEquals(89.0, CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(2089.0, 2000.0)), EPSILON); + Assertions.assertEquals(51.5, CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(x3, 1000.0)), EPSILON); + Assertions.assertEquals(Math.sqrt(1300.0), CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(970.0, 1980.0)), EPSILON); + Assertions.assertEquals(Math.sqrt(1300.0), CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(980.0, 2030.0)), EPSILON); + Assertions.assertEquals(145.7, CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(2000.0, 2145.7)), EPSILON); + Assertions.assertEquals(89.0, CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(2089.0, 2000.0)), EPSILON); // case 4: point is orthogonal next to link.toNode, test both sides of link final double x2 = -5.0; - Assert.assertEquals(5.0, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(x2, 1000.0)), EPSILON); - Assert.assertEquals(7.5, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(7.5, 1000.0)), EPSILON); - Assert.assertEquals(Math.sqrt(2*234.5*234.5), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(1234.5, 2000.0 - 234.5)), EPSILON); - Assert.assertEquals(Math.sqrt(2*11.1*11.1), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(1000.0 - 11.1, 2000.0 + 11.1)), EPSILON); - Assert.assertEquals(43.3, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(2000.0, 1956.7)), EPSILON); - Assert.assertEquals(10.3, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(2000.0, 2010.3)), EPSILON); + Assertions.assertEquals(5.0, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(x2, 1000.0)), EPSILON); + Assertions.assertEquals(7.5, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(7.5, 1000.0)), EPSILON); + Assertions.assertEquals(Math.sqrt(2*234.5*234.5), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(1234.5, 2000.0 - 234.5)), EPSILON); + Assertions.assertEquals(Math.sqrt(2*11.1*11.1), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(1000.0 - 11.1, 2000.0 + 11.1)), EPSILON); + Assertions.assertEquals(43.3, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(2000.0, 1956.7)), EPSILON); + Assertions.assertEquals(10.3, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(2000.0, 2010.3)), EPSILON); final double y3 = +22.2; - Assert.assertEquals(Math.sqrt(44.4*44.4*1.25), CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(1000 - 44.4, y3)), EPSILON); + Assertions.assertEquals(Math.sqrt(44.4*44.4*1.25), CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(1000 - 44.4, y3)), EPSILON); final double y2 = -33.3; - Assert.assertEquals(Math.sqrt(66.6*66.6*1.25), CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(1000 + 66.6, y2)), EPSILON); + Assertions.assertEquals(Math.sqrt(66.6*66.6*1.25), CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(1000 + 66.6, y2)), EPSILON); // case 5: point is in front of link, but exactly on extension of the link's line - Assert.assertEquals(23.4, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord((double) 0, 1023.4)), EPSILON); - Assert.assertEquals(Math.sqrt(200.0), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord((double) 1010, 2010.0)), EPSILON); - Assert.assertEquals(987.6, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(2987.6, 2000.0)), EPSILON); + Assertions.assertEquals(23.4, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord((double) 0, 1023.4)), EPSILON); + Assertions.assertEquals(Math.sqrt(200.0), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord((double) 1010, 2010.0)), EPSILON); + Assertions.assertEquals(987.6, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(2987.6, 2000.0)), EPSILON); final double y1 = -500.0; - Assert.assertEquals(Math.sqrt(250.0*250.0 + 500.0*500.0), CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(750.0, y1)), EPSILON); + Assertions.assertEquals(Math.sqrt(250.0*250.0 + 500.0*500.0), CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(750.0, y1)), EPSILON); // case 6: point is in front of link and on side of link, test both sides of link final double x1 = -3.0; - Assert.assertEquals(5.0, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(x1, 1004.0)), EPSILON); - Assert.assertEquals(Math.sqrt(113.0), CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(8.0, 1007.0)), EPSILON); - Assert.assertEquals(Math.sqrt(100.0*100.0+50.0*50.0), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(1100.0, 2050.0)), EPSILON); - Assert.assertEquals(Math.sqrt(50.0*50.0+100.0*100.0), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(1050.0, 2100.0)), EPSILON); - Assert.assertEquals(Math.sqrt(100.0*100.0+50.0*50.0), CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(2100.0, 2050.0)), EPSILON); - Assert.assertEquals(Math.sqrt(50.0*50.0+100.0*100.0), CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(2050.0, 1900.0)), EPSILON); + Assertions.assertEquals(5.0, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(x1, 1004.0)), EPSILON); + Assertions.assertEquals(Math.sqrt(113.0), CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(8.0, 1007.0)), EPSILON); + Assertions.assertEquals(Math.sqrt(100.0*100.0+50.0*50.0), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(1100.0, 2050.0)), EPSILON); + Assertions.assertEquals(Math.sqrt(50.0*50.0+100.0*100.0), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(1050.0, 2100.0)), EPSILON); + Assertions.assertEquals(Math.sqrt(100.0*100.0+50.0*50.0), CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(2100.0, 2050.0)), EPSILON); + Assertions.assertEquals(Math.sqrt(50.0*50.0+100.0*100.0), CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(2050.0, 1900.0)), EPSILON); final double y = -50.0; - Assert.assertEquals(50.0, CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(1000.0, y)), EPSILON); - Assert.assertEquals(49.0, CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(951.0, 0.0)), EPSILON); + Assertions.assertEquals(50.0, CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(1000.0, y)), EPSILON); + Assertions.assertEquals(49.0, CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(951.0, 0.0)), EPSILON); // case 7: point is on the side of link, between from- and to-Node, test both sides of link final double x = -42.0; - Assert.assertEquals(42.0, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(x, 987.65)), EPSILON); - Assert.assertEquals(123.4, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(123.4, 98.765)), EPSILON); - Assert.assertEquals(Math.sqrt(2*125.0*125.0), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(500.0, 1250.0)), EPSILON); - Assert.assertEquals(Math.sqrt(2*250.0*250.0), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(500.0, 2000.0)), EPSILON); - Assert.assertEquals(658.3, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(1234.5, 2000.0 - 658.3)), EPSILON); - Assert.assertEquals(422.1, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(1846.3, 2422.1)), EPSILON); - Assert.assertEquals(Math.sqrt(250.0*250.0+125.0*125.0), CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(2000.0, 1375.0)), EPSILON); - Assert.assertEquals(Math.sqrt(500.0*500.0+250.0*250.0), CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(1000.0, 1250.0)), EPSILON); + Assertions.assertEquals(42.0, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(x, 987.65)), EPSILON); + Assertions.assertEquals(123.4, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(123.4, 98.765)), EPSILON); + Assertions.assertEquals(Math.sqrt(2*125.0*125.0), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(500.0, 1250.0)), EPSILON); + Assertions.assertEquals(Math.sqrt(2*250.0*250.0), CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(500.0, 2000.0)), EPSILON); + Assertions.assertEquals(658.3, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(1234.5, 2000.0 - 658.3)), EPSILON); + Assertions.assertEquals(422.1, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(1846.3, 2422.1)), EPSILON); + Assertions.assertEquals(Math.sqrt(250.0*250.0+125.0*125.0), CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(2000.0, 1375.0)), EPSILON); + Assertions.assertEquals(Math.sqrt(500.0*500.0+250.0*250.0), CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(1000.0, 1250.0)), EPSILON); // case 8: point is *on* the link (exactly on fromnode, exactly on tonode, exactly between somewhere) - Assert.assertEquals("point = link1.fromNode", 0.0, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), link1.getFromNode().getCoord()), EPSILON); - Assert.assertEquals("point = link1.toNode", 0.0, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), link1.getToNode().getCoord()), EPSILON); - Assert.assertEquals("point on link1", 0.0, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(0.0, 135.79)), EPSILON); + Assertions.assertEquals(0.0, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), link1.getFromNode().getCoord()), EPSILON, "point = link1.fromNode"); + Assertions.assertEquals(0.0, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), link1.getToNode().getCoord()), EPSILON, "point = link1.toNode"); + Assertions.assertEquals(0.0, CoordUtils.distancePointLinesegment(link1.getFromNode().getCoord(), link1.getToNode().getCoord(), new Coord(0.0, 135.79)), EPSILON, "point on link1"); - Assert.assertEquals("point = link2.fromNode", 0.0, CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), link2.getFromNode().getCoord()), EPSILON); - Assert.assertEquals("point = link2.toNode", 0.0, CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), link2.getToNode().getCoord()), EPSILON); - Assert.assertEquals("point on link2", 0.0, CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(65.43, 1065.43)), EPSILON); + Assertions.assertEquals(0.0, CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), link2.getFromNode().getCoord()), EPSILON, "point = link2.fromNode"); + Assertions.assertEquals(0.0, CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), link2.getToNode().getCoord()), EPSILON, "point = link2.toNode"); + Assertions.assertEquals(0.0, CoordUtils.distancePointLinesegment(link2.getFromNode().getCoord(), link2.getToNode().getCoord(), new Coord(65.43, 1065.43)), EPSILON, "point on link2"); - Assert.assertEquals("point = link3.fromNode", 0.0, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), link3.getFromNode().getCoord()), EPSILON); - Assert.assertEquals("point = link3.toNode", 0.0, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), link3.getToNode().getCoord()), EPSILON); - Assert.assertEquals("point on link3", 0.0, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(1234.5678, 2000.0)), EPSILON); + Assertions.assertEquals(0.0, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), link3.getFromNode().getCoord()), EPSILON, "point = link3.fromNode"); + Assertions.assertEquals(0.0, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), link3.getToNode().getCoord()), EPSILON, "point = link3.toNode"); + Assertions.assertEquals(0.0, CoordUtils.distancePointLinesegment(link3.getFromNode().getCoord(), link3.getToNode().getCoord(), new Coord(1234.5678, 2000.0)), EPSILON, "point on link3"); - Assert.assertEquals("point = link4.fromNode", 0.0, CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), link4.getFromNode().getCoord()), EPSILON); - Assert.assertEquals("point = link4.toNode", 0.0, CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), link4.getToNode().getCoord()), EPSILON); - Assert.assertEquals("point on link4", 0.0, CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(1750.0, 1500.0)), EPSILON); + Assertions.assertEquals(0.0, CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), link4.getFromNode().getCoord()), EPSILON, "point = link4.fromNode"); + Assertions.assertEquals(0.0, CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), link4.getToNode().getCoord()), EPSILON, "point = link4.toNode"); + Assertions.assertEquals(0.0, CoordUtils.distancePointLinesegment(link4.getFromNode().getCoord(), link4.getToNode().getCoord(), new Coord(1750.0, 1500.0)), EPSILON, "point on link4"); } @Test @@ -188,11 +188,11 @@ void testSetAttributes() { final Node fromNode = node1; final Node toNode = node2; Link link1 = (Link) NetworkUtils.createAndAddLink(network,Id.create(1, Link.class), fromNode, toNode, 500.0, 10.0, 1000.0, 1.0 ); - Assert.assertEquals("wrong freespeed traveltime.", 50.0, NetworkUtils.getFreespeedTravelTime(link1), EPSILON); + Assertions.assertEquals(50.0, NetworkUtils.getFreespeedTravelTime(link1), EPSILON, "wrong freespeed traveltime."); link1.setLength(1000.0); - Assert.assertEquals("wrong freespeed traveltime.", 100.0, NetworkUtils.getFreespeedTravelTime(link1), EPSILON); + Assertions.assertEquals(100.0, NetworkUtils.getFreespeedTravelTime(link1), EPSILON, "wrong freespeed traveltime."); link1.setFreespeed(20.0); - Assert.assertEquals("wrong freespeed traveltime.", 50.0, NetworkUtils.getFreespeedTravelTime(link1), EPSILON); + Assertions.assertEquals(50.0, NetworkUtils.getFreespeedTravelTime(link1), EPSILON, "wrong freespeed traveltime."); } /** @@ -210,13 +210,13 @@ void testAllowedModes() { // test default Set modes = l.getAllowedModes(); - Assert.assertEquals("wrong number of default entries.", 1, modes.size()); - Assert.assertTrue("wrong default.", modes.contains(TransportMode.car)); + Assertions.assertEquals(1, modes.size(), "wrong number of default entries."); + Assertions.assertTrue(modes.contains(TransportMode.car), "wrong default."); // test set/get empty list l.setAllowedModes(new HashSet()); modes = l.getAllowedModes(); - Assert.assertEquals("wrong number of allowed modes.", 0, modes.size()); + Assertions.assertEquals(0, modes.size(), "wrong number of allowed modes."); // test set/get list with entries modes = new HashSet(); @@ -225,10 +225,10 @@ void testAllowedModes() { modes.add(TransportMode.bike); l.setAllowedModes(modes); modes = l.getAllowedModes(); - Assert.assertEquals("wrong number of allowed modes", 3, modes.size()); - Assert.assertTrue(modes.contains(TransportMode.walk)); - Assert.assertTrue(modes.contains(TransportMode.car)); - Assert.assertTrue(modes.contains(TransportMode.bike)); + Assertions.assertEquals(3, modes.size(), "wrong number of allowed modes"); + Assertions.assertTrue(modes.contains(TransportMode.walk)); + Assertions.assertTrue(modes.contains(TransportMode.car)); + Assertions.assertTrue(modes.contains(TransportMode.bike)); } @@ -239,36 +239,36 @@ void testHashSetCache_get_unmodifiable() { s1.add("B"); Set s = HashSetCache.get(s1); - Assert.assertTrue(s != s1); - Assert.assertEquals(2, s.size()); - Assert.assertTrue(s.contains("A")); - Assert.assertTrue(s.contains("B")); - Assert.assertFalse(s.contains("C")); - Assert.assertFalse(s.contains("D")); + Assertions.assertTrue(s != s1); + Assertions.assertEquals(2, s.size()); + Assertions.assertTrue(s.contains("A")); + Assertions.assertTrue(s.contains("B")); + Assertions.assertFalse(s.contains("C")); + Assertions.assertFalse(s.contains("D")); try { s.add("D"); - Assert.fail("Expected Exception, but got none"); + Assertions.fail("Expected Exception, but got none"); } catch (UnsupportedOperationException e) { log.info("catched expected exception.", e); } s1.add("C"); - Assert.assertEquals("the returned set must be independent of the given, original set.", 2, s.size()); + Assertions.assertEquals(2, s.size(), "the returned set must be independent of the given, original set."); } @Test void testHashSetCache_get_null() { Set s = HashSetCache.get((Set) null); - Assert.assertNull(s); + Assertions.assertNull(s); } @Test void testHashSetCache_get_emptySet() { Set s = HashSetCache.get(new TreeSet()); - Assert.assertNotNull(s); - Assert.assertEquals(0, s.size()); + Assertions.assertNotNull(s); + Assertions.assertEquals(0, s.size()); } @@ -287,27 +287,27 @@ void testHashSetCache_get() { s4.add("A"); Set s_1 = HashSetCache.get(s1); - Assert.assertTrue(s_1 != s1); - Assert.assertEquals(2, s_1.size()); - Assert.assertTrue(s_1.contains("A")); - Assert.assertTrue(s_1.contains("B")); - Assert.assertFalse(s_1.contains("C")); - Assert.assertFalse(s_1.contains("D")); + Assertions.assertTrue(s_1 != s1); + Assertions.assertEquals(2, s_1.size()); + Assertions.assertTrue(s_1.contains("A")); + Assertions.assertTrue(s_1.contains("B")); + Assertions.assertFalse(s_1.contains("C")); + Assertions.assertFalse(s_1.contains("D")); Set s_2 = HashSetCache.get(s2); - Assert.assertTrue(s_1 == s_2); + Assertions.assertTrue(s_1 == s_2); Set s_3 = HashSetCache.get(s3); - Assert.assertTrue(s_3 != s3); - Assert.assertEquals(2, s_3.size()); - Assert.assertFalse(s_3.contains("A")); - Assert.assertTrue(s_3.contains("B")); - Assert.assertTrue(s_3.contains("C")); - Assert.assertFalse(s_3.contains("D")); + Assertions.assertTrue(s_3 != s3); + Assertions.assertEquals(2, s_3.size()); + Assertions.assertFalse(s_3.contains("A")); + Assertions.assertTrue(s_3.contains("B")); + Assertions.assertTrue(s_3.contains("C")); + Assertions.assertFalse(s_3.contains("D")); Set s_4 = HashSetCache.get(s4); - Assert.assertTrue(s_4 != s4); - Assert.assertEquals(1, s_4.size()); + Assertions.assertTrue(s_4 != s4); + Assertions.assertEquals(1, s_4.size()); } @@ -325,15 +325,15 @@ void testHashSetCache_get_identicalObjects() { s3.add("A"); Set s_1 = HashSetCache.get(s1); - Assert.assertTrue(s_1 != s1); - Assert.assertEquals(2, s_1.size()); + Assertions.assertTrue(s_1 != s1); + Assertions.assertEquals(2, s_1.size()); Set s_2 = HashSetCache.get(s2); - Assert.assertTrue(s_1 == s_2); + Assertions.assertTrue(s_1 == s_2); Set s_3 = HashSetCache.get(s3); - Assert.assertTrue(s_3 != s3); - Assert.assertEquals(3, s_3.size()); + Assertions.assertTrue(s_3 != s3); + Assertions.assertEquals(3, s_3.size()); } } diff --git a/matsim/src/test/java/org/matsim/core/network/LinkQuadTreeTest.java b/matsim/src/test/java/org/matsim/core/network/LinkQuadTreeTest.java index 897e0d47506..87cab0bfe54 100644 --- a/matsim/src/test/java/org/matsim/core/network/LinkQuadTreeTest.java +++ b/matsim/src/test/java/org/matsim/core/network/LinkQuadTreeTest.java @@ -21,7 +21,7 @@ package org.matsim.core.network; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -32,7 +32,7 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.scenario.ScenarioUtils; - /** + /** * @author mrieser / senozon */ public class LinkQuadTreeTest { @@ -56,16 +56,16 @@ void testGetNearest() { qt.put(b); qt.put(c); - Assert.assertEquals(foo, qt.getNearest(200, 200)); - Assert.assertEquals(foo, qt.getNearest(300, 300)); - Assert.assertEquals(bar, qt.getNearest(390, 300)); - Assert.assertEquals(fbr, qt.getNearest(1000, 1100)); - Assert.assertEquals(foo, qt.getNearest(-50, -50)); - Assert.assertEquals(a, qt.getNearest(1105, 1104)); - Assert.assertEquals(a, qt.getNearest(1105, 1103)); - Assert.assertEquals(b, qt.getNearest(1105, 1102)); - Assert.assertEquals(b, qt.getNearest(1105, 1101)); - Assert.assertEquals(c, qt.getNearest(1205, 1101)); + Assertions.assertEquals(foo, qt.getNearest(200, 200)); + Assertions.assertEquals(foo, qt.getNearest(300, 300)); + Assertions.assertEquals(bar, qt.getNearest(390, 300)); + Assertions.assertEquals(fbr, qt.getNearest(1000, 1100)); + Assertions.assertEquals(foo, qt.getNearest(-50, -50)); + Assertions.assertEquals(a, qt.getNearest(1105, 1104)); + Assertions.assertEquals(a, qt.getNearest(1105, 1103)); + Assertions.assertEquals(b, qt.getNearest(1105, 1102)); + Assertions.assertEquals(b, qt.getNearest(1105, 1101)); + Assertions.assertEquals(c, qt.getNearest(1205, 1101)); } @Test @@ -93,10 +93,10 @@ void testGetNearest_longNear_smallFarAway() { qt.put(a); qt.put(b); - Assert.assertEquals(b, qt.getNearest(600, 0)); - Assert.assertEquals(a, qt.getNearest(600, 210)); - Assert.assertEquals(b, qt.getNearest(300, 210)); // outside of segment (1)-(2), thus (3)-(4) is closer - Assert.assertEquals(a, qt.getNearest(400, 210)); // distance to (1) is smaller than to (3)-(4) + Assertions.assertEquals(b, qt.getNearest(600, 0)); + Assertions.assertEquals(a, qt.getNearest(600, 210)); + Assertions.assertEquals(b, qt.getNearest(300, 210)); // outside of segment (1)-(2), thus (3)-(4) is closer + Assertions.assertEquals(a, qt.getNearest(400, 210)); // distance to (1) is smaller than to (3)-(4) } @Test @@ -141,7 +141,7 @@ void testPut_zeroLengthLink() { qt.put(l34); // mostly check that there is no exception like StackOverflowError - Assert.assertEquals(l13, qt.getNearest(100, 800)); + Assertions.assertEquals(l13, qt.getNearest(100, 800)); } @Test @@ -166,7 +166,7 @@ void testPut_zeroLengthLink_negativeCoords() { qt.put(l34); // mostly check that there is no exception like StackOverflowError - Assert.assertEquals(l13, qt.getNearest(-100, -800)); + Assertions.assertEquals(l13, qt.getNearest(-100, -800)); } @Test @@ -183,10 +183,10 @@ void testRemove() { qt.put(l53); qt.put(l63); - Assert.assertEquals(l13, qt.getNearest(100, 800)); + Assertions.assertEquals(l13, qt.getNearest(100, 800)); qt.remove(l13); - Assert.assertEquals(l23, qt.getNearest(100, 800)); + Assertions.assertEquals(l23, qt.getNearest(100, 800)); } /** @@ -202,10 +202,10 @@ void testRemove_inSubNode() { qt.put(lInTop1); qt.put(lInChildSW1); - Assert.assertEquals(lInChildSW1, qt.getNearest(100, 80)); + Assertions.assertEquals(lInChildSW1, qt.getNearest(100, 80)); qt.remove(lInChildSW1); - Assert.assertEquals(lInTop1, qt.getNearest(100, 80)); + Assertions.assertEquals(lInTop1, qt.getNearest(100, 80)); } private Link createLink(Scenario s, double fromX, double fromY, double toX, double toY) { diff --git a/matsim/src/test/java/org/matsim/core/network/NetworkChangeEventsParserWriterTest.java b/matsim/src/test/java/org/matsim/core/network/NetworkChangeEventsParserWriterTest.java index f3d135ce74e..407d57d09c8 100644 --- a/matsim/src/test/java/org/matsim/core/network/NetworkChangeEventsParserWriterTest.java +++ b/matsim/src/test/java/org/matsim/core/network/NetworkChangeEventsParserWriterTest.java @@ -20,7 +20,7 @@ package org.matsim.core.network; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -38,8 +38,8 @@ import java.util.List; import static org.hamcrest.core.IsCollectionContaining.hasItem; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; public class NetworkChangeEventsParserWriterTest { @@ -116,7 +116,7 @@ void testWriteReadZeroChangeEvents() { new NetworkChangeEventsParser(network, changeEvents2).readFile(fileName); // the main test is that there is no exception - Assert.assertTrue(changeEvents2.isEmpty()); + Assertions.assertTrue(changeEvents2.isEmpty()); } @Test @@ -139,12 +139,12 @@ void testAbsoluteChangeEvents() { List changeEvents2 = new ArrayList<>(); new NetworkChangeEventsParser(network, changeEvents2).readFile(fileName); - Assert.assertFalse(changeEvents2.isEmpty()); - Assert.assertEquals(1, changeEvents2.size()); + Assertions.assertFalse(changeEvents2.isEmpty()); + Assertions.assertEquals(1, changeEvents2.size()); NetworkChangeEvent event2 = changeEvents2.get(0); - Assert.assertEquals(event.getStartTime(), event2.getStartTime(), 0.0); - Assert.assertEquals(NetworkChangeEvent.ChangeType.ABSOLUTE_IN_SI_UNITS, event2.getFlowCapacityChange().getType()); - Assert.assertEquals(event.getFlowCapacityChange().getValue(), event2.getFlowCapacityChange().getValue(), 1e-10); + Assertions.assertEquals(event.getStartTime(), event2.getStartTime(), 0.0); + Assertions.assertEquals(NetworkChangeEvent.ChangeType.ABSOLUTE_IN_SI_UNITS, event2.getFlowCapacityChange().getType()); + Assertions.assertEquals(event.getFlowCapacityChange().getValue(), event2.getFlowCapacityChange().getValue(), 1e-10); } @Test @@ -167,12 +167,12 @@ void testScaleFactorChangeEvents() { List changeEvents2 = new ArrayList<>(); new NetworkChangeEventsParser(network, changeEvents2).readFile(fileName); - Assert.assertFalse(changeEvents2.isEmpty()); - Assert.assertEquals(1, changeEvents2.size()); + Assertions.assertFalse(changeEvents2.isEmpty()); + Assertions.assertEquals(1, changeEvents2.size()); NetworkChangeEvent event2 = changeEvents2.get(0); - Assert.assertEquals(event.getStartTime(), event2.getStartTime(), 0.0); - Assert.assertEquals(NetworkChangeEvent.ChangeType.FACTOR, event2.getLanesChange().getType()); - Assert.assertEquals(event.getLanesChange().getValue(), event2.getLanesChange().getValue(), 1e-10); + Assertions.assertEquals(event.getStartTime(), event2.getStartTime(), 0.0); + Assertions.assertEquals(NetworkChangeEvent.ChangeType.FACTOR, event2.getLanesChange().getType()); + Assertions.assertEquals(event.getLanesChange().getValue(), event2.getLanesChange().getValue(), 1e-10); } @Test @@ -195,12 +195,12 @@ void testPositiveOffsetChangeEvents() { List changeEvents2 = new ArrayList<>(); new NetworkChangeEventsParser(network, changeEvents2).readFile(fileName); - Assert.assertFalse(changeEvents2.isEmpty()); - Assert.assertEquals(1, changeEvents2.size()); + Assertions.assertFalse(changeEvents2.isEmpty()); + Assertions.assertEquals(1, changeEvents2.size()); NetworkChangeEvent event2 = changeEvents2.get(0); - Assert.assertEquals(event.getStartTime(), event2.getStartTime(), 0.0); - Assert.assertEquals(NetworkChangeEvent.ChangeType.OFFSET_IN_SI_UNITS, event2.getFreespeedChange().getType()); - Assert.assertEquals(event.getFreespeedChange().getValue(), event2.getFreespeedChange().getValue(), 1e-10); + Assertions.assertEquals(event.getStartTime(), event2.getStartTime(), 0.0); + Assertions.assertEquals(NetworkChangeEvent.ChangeType.OFFSET_IN_SI_UNITS, event2.getFreespeedChange().getType()); + Assertions.assertEquals(event.getFreespeedChange().getValue(), event2.getFreespeedChange().getValue(), 1e-10); } @Test @@ -223,12 +223,12 @@ void testNegativeOffsetChangeEvents() { List changeEvents2 = new ArrayList<>(); new NetworkChangeEventsParser(network, changeEvents2).readFile(fileName); - Assert.assertFalse(changeEvents2.isEmpty()); - Assert.assertEquals(1, changeEvents2.size()); + Assertions.assertFalse(changeEvents2.isEmpty()); + Assertions.assertEquals(1, changeEvents2.size()); NetworkChangeEvent event2 = changeEvents2.get(0); - Assert.assertEquals(event.getStartTime(), event2.getStartTime(), 0.0); - Assert.assertEquals(NetworkChangeEvent.ChangeType.OFFSET_IN_SI_UNITS, event2.getFreespeedChange().getType()); - Assert.assertEquals(event.getFreespeedChange().getValue(), event2.getFreespeedChange().getValue(), 1e-10); + Assertions.assertEquals(event.getStartTime(), event2.getStartTime(), 0.0); + Assertions.assertEquals(NetworkChangeEvent.ChangeType.OFFSET_IN_SI_UNITS, event2.getFreespeedChange().getType()); + Assertions.assertEquals(event.getFreespeedChange().getValue(), event2.getFreespeedChange().getValue(), 1e-10); } } diff --git a/matsim/src/test/java/org/matsim/core/network/NetworkCollectorTest.java b/matsim/src/test/java/org/matsim/core/network/NetworkCollectorTest.java index 36184ddc30d..ea391caa49c 100644 --- a/matsim/src/test/java/org/matsim/core/network/NetworkCollectorTest.java +++ b/matsim/src/test/java/org/matsim/core/network/NetworkCollectorTest.java @@ -8,8 +8,8 @@ import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class NetworkCollectorTest { diff --git a/matsim/src/test/java/org/matsim/core/network/NetworkImplTest.java b/matsim/src/test/java/org/matsim/core/network/NetworkImplTest.java index 1a4de57b8aa..4eeef809488 100644 --- a/matsim/src/test/java/org/matsim/core/network/NetworkImplTest.java +++ b/matsim/src/test/java/org/matsim/core/network/NetworkImplTest.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -51,9 +51,9 @@ public Network getEmptyTestNetwork() { @Test void testDefaultValues(){ Network net = new NetworkImpl(new LinkFactoryImpl()); - Assert.assertEquals(7.5, net.getEffectiveCellSize(), 0.0); - Assert.assertEquals(3.75, net.getEffectiveLaneWidth(), 0.0); - Assert.assertEquals(3600.0, net.getCapacityPeriod(), 0.0); + Assertions.assertEquals(7.5, net.getEffectiveCellSize(), 0.0); + Assertions.assertEquals(3.75, net.getEffectiveLaneWidth(), 0.0); + Assertions.assertEquals(3600.0, net.getCapacityPeriod(), 0.0); Node node1 = NetworkUtils.createNode(Id.create(1, Node.class), new Coord((double) 0, (double) 0)); Node node2 = NetworkUtils.createNode(Id.create(2, Node.class), new Coord((double) 1000, (double) 0)); @@ -62,8 +62,8 @@ void testDefaultValues(){ final NetworkFactory nf = net.getFactory(); Gbl.assertNotNull(nf); Link link = nf.createLink(Id.create(1, Link.class), node1, node2); - Assert.assertEquals(1, link.getAllowedModes().size()); - Assert.assertEquals("car", link.getAllowedModes().iterator().next()); + Assertions.assertEquals(1, link.getAllowedModes().size()); + Assertions.assertEquals("car", link.getAllowedModes().iterator().next()); } /** @@ -88,19 +88,19 @@ void testAddLink_existingId() { Link link1b = NetworkUtils.createLink(Id.create(1, Link.class), node2, node3, network, 1000, 100.0, 2000.0, 1.0); Link link2 = NetworkUtils.createLink(Id.create(2, Link.class), node2, node4, network, 1000, 100.0, 2000.0, 1.0); network.addLink(link1); - Assert.assertEquals(1, network.getLinks().size()); + Assertions.assertEquals(1, network.getLinks().size()); try { network.addLink(link1b); - Assert.fail("missing exception. Should not be able to add different link with existing id."); + Assertions.fail("missing exception. Should not be able to add different link with existing id."); } catch (IllegalArgumentException e) { log.info("catched expected exception.", e); } - Assert.assertEquals(1, network.getLinks().size()); + Assertions.assertEquals(1, network.getLinks().size()); network.addLink(link2); - Assert.assertEquals(2, network.getLinks().size()); + Assertions.assertEquals(2, network.getLinks().size()); network.addLink(link2); // adding the same link again should just be ignored - Assert.assertEquals(2, network.getLinks().size()); + Assertions.assertEquals(2, network.getLinks().size()); } /** @@ -118,7 +118,7 @@ void testAddLink_noNodes(){ Link ab = n.getFactory().createLink(Id.create("ab", Link.class), a, b); try{ n.addLink(ab); - Assert.fail("Should have thrown exception as fromNode was not in network."); + Assertions.fail("Should have thrown exception as fromNode was not in network."); } catch (IllegalArgumentException e){ log.info("Caught expected exception: fromNode not in network.", e); } @@ -126,7 +126,7 @@ void testAddLink_noNodes(){ n.addNode(a); try{ n.addLink(ab); - Assert.fail("Should have thrown exception as toNode was not in network."); + Assertions.fail("Should have thrown exception as toNode was not in network."); } catch (IllegalArgumentException e){ log.info("Caught expected exception: toNode not in network.", e); } @@ -136,13 +136,13 @@ void testAddLink_noNodes(){ n.addLink(ab); log.info("Link added correctly. Both nodes in the network."); } catch (IllegalArgumentException e){ - Assert.fail("Should not have thrown exception as both nodes are in network."); + Assertions.fail("Should not have thrown exception as both nodes are in network."); } Link ac = n.getFactory().createLink(Id.create("ac", Link.class), a, c); try{ n.addLink(ac); - Assert.fail("Should have thrown exception as toNode was not in network."); + Assertions.fail("Should have thrown exception as toNode was not in network."); } catch (IllegalArgumentException e){ log.info("Caught expected exception: toNode not in network.", e); } @@ -152,7 +152,7 @@ void testAddLink_noNodes(){ n.addLink(ac); log.info("Link added correctly. Both nodes in the network."); } catch (IllegalArgumentException e){ - Assert.fail("Should not have thrown exception as both nodes are in network."); + Assertions.fail("Should not have thrown exception as both nodes are in network."); } } @@ -166,19 +166,19 @@ void testAddNode_existingId() { Node node1b = NetworkUtils.createNode(Id.create(1, Node.class), new Coord((double) 2000, (double) 0)); network.addNode(node1); network.addNode(node2); - Assert.assertEquals(2, network.getNodes().size()); + Assertions.assertEquals(2, network.getNodes().size()); try { network.addNode(node1b); - Assert.fail("missing exception. Should not be able to add different node with existing id."); + Assertions.fail("missing exception. Should not be able to add different node with existing id."); } catch (IllegalArgumentException e) { log.info("catched expected exception.", e); } - Assert.assertEquals(2, network.getNodes().size()); + Assertions.assertEquals(2, network.getNodes().size()); network.addNode(node1); // adding the same node again should just be ignored - Assert.assertEquals(2, network.getNodes().size()); + Assertions.assertEquals(2, network.getNodes().size()); network.addNode(node3); - Assert.assertEquals(3, network.getNodes().size()); + Assertions.assertEquals(3, network.getNodes().size()); } /** @@ -193,15 +193,15 @@ void testAddNode_singleNodeFirstOnly() { Node node2 = NetworkUtils.createNode(Id.create(2, Node.class), new Coord((double) 600, (double) 500)); network.addNode(node1); - Assert.assertEquals(1, network.getNodes().size()); + Assertions.assertEquals(1, network.getNodes().size()); Node n = NetworkUtils.getNearestNode(network,new Coord((double) 550, (double) 450)); - Assert.assertEquals(node1, n); + Assertions.assertEquals(node1, n); network.addNode(node2); - Assert.assertEquals(2, network.getNodes().size()); + Assertions.assertEquals(2, network.getNodes().size()); n = NetworkUtils.getNearestNode(network,new Coord((double) 590, (double) 490)); - Assert.assertEquals(node2, n); + Assertions.assertEquals(node2, n); } /** @@ -216,18 +216,18 @@ void testAddTwoNodes_initializedEmptyQuadtree() { Node node2 = NetworkUtils.createNode(Id.create(2, Node.class), new Coord((double) 600, (double) 500)); Node n = NetworkUtils.getNearestNode(network,new Coord((double) 550, (double) 450)); - Assert.assertNull(n); + Assertions.assertNull(n); network.addNode(node1); - Assert.assertEquals(1, network.getNodes().size()); + Assertions.assertEquals(1, network.getNodes().size()); n = NetworkUtils.getNearestNode(network,new Coord((double) 550, (double) 450)); - Assert.assertEquals(node1, n); + Assertions.assertEquals(node1, n); network.addNode(node2); - Assert.assertEquals(2, network.getNodes().size()); + Assertions.assertEquals(2, network.getNodes().size()); n = NetworkUtils.getNearestNode(network,new Coord((double) 590, (double) 490)); - Assert.assertEquals(node2, n); + Assertions.assertEquals(node2, n); } @Test @@ -246,26 +246,26 @@ void testRemoveLink_alsoInQuadTrees() { network.addLink(link2); network.addLink(link3); - Assert.assertEquals(3, network.getLinks().size()); - Assert.assertEquals(link1, NetworkUtils.getNearestLink(network, new Coord(300, 200))); - Assert.assertEquals(link1, NetworkUtils.getNearestLinkExactly(network, new Coord(300, 200))); + Assertions.assertEquals(3, network.getLinks().size()); + Assertions.assertEquals(link1, NetworkUtils.getNearestLink(network, new Coord(300, 200))); + Assertions.assertEquals(link1, NetworkUtils.getNearestLinkExactly(network, new Coord(300, 200))); network.removeLink(link1.getId()); - Assert.assertEquals(2, network.getLinks().size()); - Assert.assertEquals(link3, NetworkUtils.getNearestLink(network, new Coord(300, 200))); - Assert.assertEquals(link3, NetworkUtils.getNearestLinkExactly(network, new Coord(300, 200))); + Assertions.assertEquals(2, network.getLinks().size()); + Assertions.assertEquals(link3, NetworkUtils.getNearestLink(network, new Coord(300, 200))); + Assertions.assertEquals(link3, NetworkUtils.getNearestLinkExactly(network, new Coord(300, 200))); network.removeLink(link3.getId()); - Assert.assertEquals(1, network.getLinks().size()); - Assert.assertEquals(link2, NetworkUtils.getNearestLinkExactly(network, new Coord(300, 200))); + Assertions.assertEquals(1, network.getLinks().size()); + Assertions.assertEquals(link2, NetworkUtils.getNearestLinkExactly(network, new Coord(300, 200))); network.removeLink(link2.getId()); - Assert.assertEquals(0, network.getLinks().size()); - Assert.assertNull(NetworkUtils.getNearestLink(network, new Coord(300, 200))); - Assert.assertNull(NetworkUtils.getNearestLinkExactly(network, new Coord(300, 200))); + Assertions.assertEquals(0, network.getLinks().size()); + Assertions.assertNull(NetworkUtils.getNearestLink(network, new Coord(300, 200))); + Assertions.assertNull(NetworkUtils.getNearestLinkExactly(network, new Coord(300, 200))); } @Test @@ -284,24 +284,24 @@ void testAddLink_alsoInQuadTrees() { network.addLink(link2); network.addLink(link3); - Assert.assertEquals(2, network.getLinks().size()); - Assert.assertEquals(link3, NetworkUtils.getNearestLink(network, new Coord(300, 200))); - Assert.assertEquals(link3, NetworkUtils.getNearestLinkExactly(network, new Coord(300, 200))); // this will force the LinkQuadTree to be built + Assertions.assertEquals(2, network.getLinks().size()); + Assertions.assertEquals(link3, NetworkUtils.getNearestLink(network, new Coord(300, 200))); + Assertions.assertEquals(link3, NetworkUtils.getNearestLinkExactly(network, new Coord(300, 200))); // this will force the LinkQuadTree to be built network.addLink(link1); - Assert.assertEquals(3, network.getLinks().size()); + Assertions.assertEquals(3, network.getLinks().size()); // check that the quad trees were correctly updated with the new link - Assert.assertEquals(link1, NetworkUtils.getNearestLink(network, new Coord(300, 200))); - Assert.assertEquals(link1, NetworkUtils.getNearestLinkExactly(network, new Coord(300, 200))); // this will force the LinkQuadTree to be built + Assertions.assertEquals(link1, NetworkUtils.getNearestLink(network, new Coord(300, 200))); + Assertions.assertEquals(link1, NetworkUtils.getNearestLinkExactly(network, new Coord(300, 200))); // this will force the LinkQuadTree to be built } @Test void testAddLink_intoEmptyQuadTree() { Network network = new NetworkImpl(new LinkFactoryImpl()); - Assert.assertEquals(0, network.getLinks().size()); - Assert.assertNull(NetworkUtils.getNearestLink(network, new Coord(300, 200))); // this will force the node QuadTree to be built - Assert.assertNull(NetworkUtils.getNearestLinkExactly(network, new Coord(300, 200))); // this will force the LinkQuadTree to be built + Assertions.assertEquals(0, network.getLinks().size()); + Assertions.assertNull(NetworkUtils.getNearestLink(network, new Coord(300, 200))); // this will force the node QuadTree to be built + Assertions.assertNull(NetworkUtils.getNearestLinkExactly(network, new Coord(300, 200))); // this will force the LinkQuadTree to be built Node node1 = NetworkUtils.createNode(Id.create(1, Node.class), new Coord(100, 100)); Node node2 = NetworkUtils.createNode(Id.create(2, Node.class), new Coord(1000, 200)); @@ -317,8 +317,8 @@ void testAddLink_intoEmptyQuadTree() { network.addLink(link2); network.addLink(link3); - Assert.assertEquals(3, network.getLinks().size()); - Assert.assertEquals(link1, NetworkUtils.getNearestLink(network, new Coord(300, 200))); - Assert.assertEquals(link1, NetworkUtils.getNearestLinkExactly(network, new Coord(300, 200))); // this will force the LinkQuadTree to be built + Assertions.assertEquals(3, network.getLinks().size()); + Assertions.assertEquals(link1, NetworkUtils.getNearestLink(network, new Coord(300, 200))); + Assertions.assertEquals(link1, NetworkUtils.getNearestLinkExactly(network, new Coord(300, 200))); // this will force the LinkQuadTree to be built } } diff --git a/matsim/src/test/java/org/matsim/core/network/NetworkUtilsTest.java b/matsim/src/test/java/org/matsim/core/network/NetworkUtilsTest.java index 9144ea61f59..c65497cb5d4 100644 --- a/matsim/src/test/java/org/matsim/core/network/NetworkUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/network/NetworkUtilsTest.java @@ -18,9 +18,11 @@ * *********************************************************************** */ package org.matsim.core.network; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -38,8 +40,6 @@ import java.util.List; import java.util.TreeMap; -import static org.junit.Assert.assertEquals; - /** * @author nagel * @@ -63,7 +63,7 @@ final void testIsMultimodal() { Network network = scenario.getNetwork() ; - Assert.assertTrue( NetworkUtils.isMultimodal( network ) ); + Assertions.assertTrue( NetworkUtils.isMultimodal( network ) ); } @@ -127,7 +127,7 @@ final void getOutLinksSortedByAngleTest() { Link[] actuals = result.values().toArray( new Link[result.size()] ) ; Link[] expecteds = {liNE,liE,liSE,liS,liSW,liW,liNW} ; - Assert.assertArrayEquals(expecteds, actuals); + Assertions.assertArrayEquals(expecteds, actuals); } log.info("==="); @@ -140,7 +140,7 @@ final void getOutLinksSortedByAngleTest() { } Link[] actuals = result.values().toArray( new Link[result.size()] ) ; Link[] expecteds = {liSW,liW,liNW,liN,liNE,liE,liSE} ; - Assert.assertArrayEquals(expecteds, actuals); + Assertions.assertArrayEquals(expecteds, actuals); } log.info("==="); } diff --git a/matsim/src/test/java/org/matsim/core/network/NetworkV2IOTest.java b/matsim/src/test/java/org/matsim/core/network/NetworkV2IOTest.java index a3d9ddb7587..097ebf21c1f 100644 --- a/matsim/src/test/java/org/matsim/core/network/NetworkV2IOTest.java +++ b/matsim/src/test/java/org/matsim/core/network/NetworkV2IOTest.java @@ -21,7 +21,7 @@ package org.matsim.core.network; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -33,7 +33,7 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.testcases.MatsimTestUtils; - /** + /** * @author thibautd */ public class NetworkV2IOTest { @@ -49,9 +49,9 @@ void testNetworkAttributes() { final Scenario read = ScenarioUtils.createScenario( ConfigUtils.createConfig() ); new MatsimNetworkReader( read.getNetwork() ).readFile( utils.getOutputDirectory()+"network.xml" ); - Assert.assertEquals( "unexpected year in network metadata", - sc.getNetwork().getAttributes().getAttribute( "year" ), - read.getNetwork().getAttributes().getAttribute( "year" ) ); + Assertions.assertEquals( sc.getNetwork().getAttributes().getAttribute( "year" ), + read.getNetwork().getAttributes().getAttribute( "year" ), + "unexpected year in network metadata" ); } @Test @@ -65,13 +65,13 @@ void testNodesAttributes() { final Id id = Id.createNodeId( "Zurich" ); - Assert.assertEquals( "unexpected internet attribute in node metadata", - "good", - read.getNetwork().getNodes().get( id ).getAttributes().getAttribute( "Internet" ) ); + Assertions.assertEquals( "good", + read.getNetwork().getNodes().get( id ).getAttributes().getAttribute( "Internet" ), + "unexpected internet attribute in node metadata" ); - Assert.assertEquals( "unexpected meeting attribute in node metadata", - false, - read.getNetwork().getNodes().get( id ).getAttributes().getAttribute( "Developper Meeting" ) ); + Assertions.assertEquals( false, + read.getNetwork().getNodes().get( id ).getAttributes().getAttribute( "Developper Meeting" ), + "unexpected meeting attribute in node metadata" ); } @Test @@ -88,8 +88,8 @@ void testNo3DCoord() { final Coord zhCoord = read.getNetwork().getNodes().get( zh ).getCoord(); - Assert.assertFalse( "did not expect Z", - zhCoord.hasZ() ); + Assertions.assertFalse( zhCoord.hasZ(), + "did not expect Z" ); } @Test @@ -106,13 +106,13 @@ void test3DCoord() { final Coord zhCoord = read.getNetwork().getNodes().get( zh ).getCoord(); - Assert.assertTrue( "did expect Z", - zhCoord.hasZ() ); + Assertions.assertTrue( zhCoord.hasZ(), + "did expect Z" ); - Assert.assertEquals( "unexpected Z value", - 400, + Assertions.assertEquals( 400, zhCoord.getZ() , - MatsimTestUtils.EPSILON ); + MatsimTestUtils.EPSILON, + "unexpected Z value" ); } @Test @@ -126,9 +126,9 @@ void testLinksAttributes() { final Id id = Id.createLinkId( "trip" ); - Assert.assertEquals( "unexpected mode attribute in link metadata", - 3, - read.getNetwork().getLinks().get( id ).getAttributes().getAttribute( "number of modes" ) ); + Assertions.assertEquals( 3, + read.getNetwork().getLinks().get( id ).getAttributes().getAttribute( "number of modes" ), + "unexpected mode attribute in link metadata" ); } private Scenario createTestNetwork( boolean threeD) { diff --git a/matsim/src/test/java/org/matsim/core/network/TimeVariantLinkImplTest.java b/matsim/src/test/java/org/matsim/core/network/TimeVariantLinkImplTest.java index 6ee99a6bbe7..8086bbdea20 100644 --- a/matsim/src/test/java/org/matsim/core/network/TimeVariantLinkImplTest.java +++ b/matsim/src/test/java/org/matsim/core/network/TimeVariantLinkImplTest.java @@ -20,7 +20,7 @@ package org.matsim.core.network; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/network/TravelTimeCalculatorIntegrationTest.java b/matsim/src/test/java/org/matsim/core/network/TravelTimeCalculatorIntegrationTest.java index f7cc016d101..3f6af219ffc 100644 --- a/matsim/src/test/java/org/matsim/core/network/TravelTimeCalculatorIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/network/TravelTimeCalculatorIntegrationTest.java @@ -20,7 +20,7 @@ package org.matsim.core.network; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/CalcBoundingBoxTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/CalcBoundingBoxTest.java index fa57c2fb070..88b089bccc7 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/CalcBoundingBoxTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/CalcBoundingBoxTest.java @@ -19,7 +19,7 @@ package org.matsim.core.network.algorithms; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -64,10 +64,10 @@ void testRun() { CalcBoundingBox bbox = new CalcBoundingBox(); bbox.run(net); - Assert.assertEquals(100, bbox.getMinX(), 1e-9); - Assert.assertEquals(600, bbox.getMaxX(), 1e-9); - Assert.assertEquals(200, bbox.getMinY(), 1e-9); - Assert.assertEquals(700, bbox.getMaxY(), 1e-9); + Assertions.assertEquals(100, bbox.getMinX(), 1e-9); + Assertions.assertEquals(600, bbox.getMaxX(), 1e-9); + Assertions.assertEquals(200, bbox.getMinY(), 1e-9); + Assertions.assertEquals(700, bbox.getMaxY(), 1e-9); } @Test @@ -110,9 +110,9 @@ void testRun_allNegative() { CalcBoundingBox bbox = new CalcBoundingBox(); bbox.run(net); - Assert.assertEquals(-600, bbox.getMinX(), 1e-9); - Assert.assertEquals(-100, bbox.getMaxX(), 1e-9); - Assert.assertEquals(-700, bbox.getMinY(), 1e-9); - Assert.assertEquals(-200, bbox.getMaxY(), 1e-9); + Assertions.assertEquals(-600, bbox.getMinX(), 1e-9); + Assertions.assertEquals(-100, bbox.getMaxX(), 1e-9); + Assertions.assertEquals(-700, bbox.getMinY(), 1e-9); + Assertions.assertEquals(-200, bbox.getMaxY(), 1e-9); } } diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/MultimodalNetworkCleanerTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/MultimodalNetworkCleanerTest.java index 7021557104f..2665b2d4096 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/MultimodalNetworkCleanerTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/MultimodalNetworkCleanerTest.java @@ -23,7 +23,7 @@ import java.util.HashSet; import java.util.Set; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -48,16 +48,16 @@ void testRun_singleMode() { MultimodalNetworkCleaner cleaner = new MultimodalNetworkCleaner(network); cleaner.run(createHashSet(TransportMode.car)); - Assert.assertEquals("wrong number of links.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 6, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); } @Test @@ -76,32 +76,32 @@ void testRun_singleMode_separateLink() { MultimodalNetworkCleaner cleaner = new MultimodalNetworkCleaner(network); cleaner.run(createHashSet(TransportMode.car)); - Assert.assertEquals("wrong number of links.", 9, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 6, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[10]).getAllowedModes()); - Assert.assertNull(network.getLinks().get(f.linkIds[11])); + Assertions.assertEquals(9, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[10]).getAllowedModes()); + Assertions.assertNull(network.getLinks().get(f.linkIds[11])); cleaner.run(createHashSet(TransportMode.walk)); - Assert.assertEquals("wrong number of links.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 6, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); - Assert.assertNull(network.getLinks().get(f.linkIds[10])); - Assert.assertNull(network.getLinks().get(f.linkIds[11])); + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertNull(network.getLinks().get(f.linkIds[10])); + Assertions.assertNull(network.getLinks().get(f.linkIds[11])); } @Test @@ -112,16 +112,16 @@ void testRun_singleInexistantMode() { MultimodalNetworkCleaner cleaner = new MultimodalNetworkCleaner(network); cleaner.run(createHashSet("other")); - Assert.assertEquals("wrong number of links.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 6, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); } @Test @@ -140,41 +140,41 @@ void testRun_singleMode_singleSink() { network.getLinks().get(f.linkIds[11]).setAllowedModes(f.modesW); MultimodalNetworkCleaner cleaner = new MultimodalNetworkCleaner(network); - Assert.assertEquals("wrong number of links.", 10, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 8, network.getNodes().size()); + Assertions.assertEquals(10, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(8, network.getNodes().size(), "wrong number of nodes."); cleaner.run(createHashSet(TransportMode.car)); - Assert.assertEquals("wrong number of links.", 9, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 7, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[11]).getAllowedModes()); - Assert.assertNull(network.getLinks().get(f.linkIds[10])); - - Assert.assertEquals("wrong number of links.", 9, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 7, network.getNodes().size()); + Assertions.assertEquals(9, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(7, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[11]).getAllowedModes()); + Assertions.assertNull(network.getLinks().get(f.linkIds[10])); + + Assertions.assertEquals(9, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(7, network.getNodes().size(), "wrong number of nodes."); cleaner.run(createHashSet(TransportMode.walk)); - Assert.assertEquals("wrong number of links.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 6, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); - Assert.assertNull(network.getLinks().get(f.linkIds[11])); - - Assert.assertEquals("wrong number of links.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 6, network.getNodes().size()); + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertNull(network.getLinks().get(f.linkIds[11])); + + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes."); } @Test @@ -185,38 +185,38 @@ void testRun_singleMode_singleSinkIntegrated() { network.getLinks().get(f.linkIds[8]).setAllowedModes(f.modesCW); MultimodalNetworkCleaner cleaner = new MultimodalNetworkCleaner(network); - Assert.assertEquals("wrong number of links.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 6, network.getNodes().size()); + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes."); cleaner.run(createHashSet(TransportMode.car)); - Assert.assertEquals("wrong number of links.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 6, network.getNodes().size()); - Assert.assertEquals(f.modesCW, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); // only remove mode, not link! - - Assert.assertEquals("wrong number of links.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 6, network.getNodes().size()); + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesCW, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); // only remove mode, not link! + + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes."); cleaner.run(createHashSet(TransportMode.walk)); - Assert.assertEquals("wrong number of links.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 6, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); // only remove mode, not link! - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); - - Assert.assertEquals("wrong number of links.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 6, network.getNodes().size()); + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); // only remove mode, not link! + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes."); } @Test @@ -240,39 +240,39 @@ void testRun_singleMode_doubleSink() { network.getLinks().get(f.linkIds[13]).setAllowedModes(f.modesW); MultimodalNetworkCleaner cleaner = new MultimodalNetworkCleaner(network); - Assert.assertEquals("wrong number of links.", 12, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 8, network.getNodes().size()); + Assertions.assertEquals(12, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(8, network.getNodes().size(), "wrong number of nodes."); cleaner.run(createHashSet(TransportMode.walk)); - Assert.assertEquals("wrong number of links.", 10, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 7, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[10]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[11]).getAllowedModes()); - Assert.assertNull(network.getLinks().get(f.linkIds[12])); - Assert.assertNull(network.getLinks().get(f.linkIds[13])); + Assertions.assertEquals(10, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(7, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[10]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[11]).getAllowedModes()); + Assertions.assertNull(network.getLinks().get(f.linkIds[12])); + Assertions.assertNull(network.getLinks().get(f.linkIds[13])); cleaner.run(createHashSet(TransportMode.car)); - Assert.assertEquals("wrong number of links.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 6, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); - Assert.assertNull(network.getLinks().get(f.linkIds[10])); - Assert.assertNull(network.getLinks().get(f.linkIds[11])); + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertNull(network.getLinks().get(f.linkIds[10])); + Assertions.assertNull(network.getLinks().get(f.linkIds[11])); } @@ -292,41 +292,41 @@ void testRun_singleMode_singleSource() { network.getLinks().get(f.linkIds[11]).setAllowedModes(f.modesW); MultimodalNetworkCleaner cleaner = new MultimodalNetworkCleaner(network); - Assert.assertEquals("wrong number of links.", 10, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 8, network.getNodes().size()); + Assertions.assertEquals(10, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(8, network.getNodes().size(), "wrong number of nodes."); cleaner.run(createHashSet(TransportMode.car)); - Assert.assertEquals("wrong number of links.", 9, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 7, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[11]).getAllowedModes()); - Assert.assertNull(network.getLinks().get(f.linkIds[10])); - - Assert.assertEquals("wrong number of links.", 9, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 7, network.getNodes().size()); + Assertions.assertEquals(9, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(7, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[11]).getAllowedModes()); + Assertions.assertNull(network.getLinks().get(f.linkIds[10])); + + Assertions.assertEquals(9, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(7, network.getNodes().size(), "wrong number of nodes."); cleaner.run(createHashSet(TransportMode.walk)); - Assert.assertEquals("wrong number of links.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 6, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); - Assert.assertNull(network.getLinks().get(f.linkIds[11])); - - Assert.assertEquals("wrong number of links.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 6, network.getNodes().size()); + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertNull(network.getLinks().get(f.linkIds[11])); + + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes."); } @Test @@ -335,18 +335,18 @@ void testRemoveNodesWithoutLinks() { Network network = f.scenario.getNetwork(); network.addNode(network.getFactory().createNode(f.nodeIds[10], new Coord((double) 300, (double) 300))); MultimodalNetworkCleaner cleaner = new MultimodalNetworkCleaner(network); - Assert.assertEquals("wrong number of links.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 7, network.getNodes().size()); + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(7, network.getNodes().size(), "wrong number of nodes."); cleaner.run(createHashSet(TransportMode.walk)); - Assert.assertEquals("wrong number of links after cleaning.", 8, network.getLinks().size()); - Assert.assertEquals("empty node should not be removed by cleaning.", 7, network.getNodes().size()); + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links after cleaning."); + Assertions.assertEquals(7, network.getNodes().size(), "empty node should not be removed by cleaning."); cleaner.removeNodesWithoutLinks(); - Assert.assertEquals("wrong number of links after cleaning.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes after cleaning.", 6, network.getNodes().size()); + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links after cleaning."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes after cleaning."); } @Test @@ -370,39 +370,39 @@ void testRun_singleMode_doubleSource() { network.getLinks().get(f.linkIds[13]).setAllowedModes(f.modesW); MultimodalNetworkCleaner cleaner = new MultimodalNetworkCleaner(network); - Assert.assertEquals("wrong number of links.", 12, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 8, network.getNodes().size()); + Assertions.assertEquals(12, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(8, network.getNodes().size(), "wrong number of nodes."); cleaner.run(createHashSet(TransportMode.walk)); - Assert.assertEquals("wrong number of links.", 10, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 7, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[10]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[11]).getAllowedModes()); - Assert.assertNull(network.getLinks().get(f.linkIds[12])); - Assert.assertNull(network.getLinks().get(f.linkIds[13])); + Assertions.assertEquals(10, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(7, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[10]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[11]).getAllowedModes()); + Assertions.assertNull(network.getLinks().get(f.linkIds[12])); + Assertions.assertNull(network.getLinks().get(f.linkIds[13])); cleaner.run(createHashSet(TransportMode.car)); - Assert.assertEquals("wrong number of links.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 6, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); - Assert.assertNull(network.getLinks().get(f.linkIds[10])); - Assert.assertNull(network.getLinks().get(f.linkIds[11])); + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertNull(network.getLinks().get(f.linkIds[10])); + Assertions.assertNull(network.getLinks().get(f.linkIds[11])); } @Test @@ -413,20 +413,20 @@ void testRun_multipleModes() { MultimodalNetworkCleaner cleaner = new MultimodalNetworkCleaner(network); cleaner.run(createHashSet(TransportMode.car, TransportMode.walk)); - Assert.assertEquals("wrong number of links.", 12, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 9, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[9]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[10]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[11]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[12]).getAllowedModes()); + Assertions.assertEquals(12, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(9, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[9]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[10]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[11]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[12]).getAllowedModes()); } @Test @@ -441,26 +441,26 @@ void testRun_multipleModes_doubleSink() { network.addLink(network.getFactory().createLink(f.linkIds[18], node2, node10)); network.addLink(network.getFactory().createLink(f.linkIds[19], node3, node10)); - Assert.assertEquals("wrong number of links.", 14, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 10, network.getNodes().size()); + Assertions.assertEquals(14, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(10, network.getNodes().size(), "wrong number of nodes."); MultimodalNetworkCleaner cleaner = new MultimodalNetworkCleaner(network); cleaner.run(createHashSet(TransportMode.car, TransportMode.walk)); - Assert.assertEquals("wrong number of links.", 12, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 9, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[9]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[10]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[11]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[12]).getAllowedModes()); + Assertions.assertEquals(12, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(9, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[9]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[10]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[11]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[12]).getAllowedModes()); } @Test @@ -475,26 +475,26 @@ void testRun_multipleModes_doubleSource() { network.addLink(network.getFactory().createLink(f.linkIds[18], node10, node2)); network.addLink(network.getFactory().createLink(f.linkIds[19], node10, node3)); - Assert.assertEquals("wrong number of links.", 14, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 10, network.getNodes().size()); + Assertions.assertEquals(14, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(10, network.getNodes().size(), "wrong number of nodes."); MultimodalNetworkCleaner cleaner = new MultimodalNetworkCleaner(network); cleaner.run(createHashSet(TransportMode.car, TransportMode.walk)); - Assert.assertEquals("wrong number of links.", 12, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 9, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[9]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[10]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[11]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[12]).getAllowedModes()); + Assertions.assertEquals(12, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(9, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[9]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[10]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[11]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[12]).getAllowedModes()); } @Test @@ -506,16 +506,16 @@ void testRun_emptyModes() { cleaner.run(new HashSet()); // nothing should have changed from the initialization - Assert.assertEquals("wrong number of links.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 6, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); } @Test @@ -527,16 +527,16 @@ void testRun_unknownMode() { cleaner.run(Collections.singleton(TransportMode.pt)); // nothing should have changed from the initialization - Assert.assertEquals("wrong number of links.", 8, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 6, network.getNodes().size()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertEquals(8, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(6, network.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, network.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesW, network.getLinks().get(f.linkIds[8]).getAllowedModes()); } @Test @@ -560,19 +560,19 @@ void testRun_singleLinkNetwork() { /* a single link is no complete network, as the link's * from-node cannot be reached by the link's to-node * */ - Assert.assertEquals("wrong number of links.", 0, network.getLinks().size()); - Assert.assertEquals("wrong number of nodes.", 0, network.getNodes().size()); + Assertions.assertEquals(0, network.getLinks().size(), "wrong number of links."); + Assertions.assertEquals(0, network.getNodes().size(), "wrong number of nodes."); } @Test void testRun_singleModeWithConnectivity() { MultimodalFixture2 f = new MultimodalFixture2(); Network network = f.scenario.getNetwork(); - Assert.assertEquals(6, network.getNodes().size()); - Assert.assertEquals(8, network.getLinks().size()); + Assertions.assertEquals(6, network.getNodes().size()); + Assertions.assertEquals(8, network.getLinks().size()); new MultimodalNetworkCleaner(network).run(Collections.singleton(TransportMode.walk), Collections.singleton(TransportMode.pt)); - Assert.assertEquals(6, network.getNodes().size()); - Assert.assertEquals(8, network.getLinks().size()); + Assertions.assertEquals(6, network.getNodes().size()); + Assertions.assertEquals(8, network.getLinks().size()); } @Test @@ -588,11 +588,11 @@ void testRun_withConnectivity_connectedSource() { network.addLink(nf.createLink(f.linkIds[11], node7, node5)); network.getLinks().get(f.linkIds[10]).setAllowedModes(f.modesT); network.getLinks().get(f.linkIds[11]).setAllowedModes(f.modesW); - Assert.assertEquals(7, network.getNodes().size()); - Assert.assertEquals(10, network.getLinks().size()); + Assertions.assertEquals(7, network.getNodes().size()); + Assertions.assertEquals(10, network.getLinks().size()); new MultimodalNetworkCleaner(network).run(Collections.singleton(TransportMode.walk), Collections.singleton(TransportMode.pt)); - Assert.assertEquals(7, network.getNodes().size()); - Assert.assertEquals(10, network.getLinks().size()); + Assertions.assertEquals(7, network.getNodes().size()); + Assertions.assertEquals(10, network.getLinks().size()); } @Test @@ -608,11 +608,11 @@ void testRun_withConnectivity_connectedSink() { network.addLink(nf.createLink(f.linkIds[11], node7, node5)); network.getLinks().get(f.linkIds[10]).setAllowedModes(f.modesW); network.getLinks().get(f.linkIds[11]).setAllowedModes(f.modesT); - Assert.assertEquals(7, network.getNodes().size()); - Assert.assertEquals(10, network.getLinks().size()); + Assertions.assertEquals(7, network.getNodes().size()); + Assertions.assertEquals(10, network.getLinks().size()); new MultimodalNetworkCleaner(network).run(Collections.singleton(TransportMode.walk), Collections.singleton(TransportMode.pt)); - Assert.assertEquals(7, network.getNodes().size()); - Assert.assertEquals(10, network.getLinks().size()); + Assertions.assertEquals(7, network.getNodes().size()); + Assertions.assertEquals(10, network.getLinks().size()); } @Test @@ -628,12 +628,12 @@ void testRun_withConnectivity_unconnectedSource() { network.addLink(nf.createLink(f.linkIds[11], node7, node5)); network.getLinks().get(f.linkIds[10]).setAllowedModes(Collections.singleton("bike")); network.getLinks().get(f.linkIds[11]).setAllowedModes(f.modesW); - Assert.assertEquals(7, network.getNodes().size()); - Assert.assertEquals(10, network.getLinks().size()); + Assertions.assertEquals(7, network.getNodes().size()); + Assertions.assertEquals(10, network.getLinks().size()); new MultimodalNetworkCleaner(network).run(Collections.singleton(TransportMode.walk), Collections.singleton(TransportMode.pt)); - Assert.assertEquals(7, network.getNodes().size()); - Assert.assertEquals(9, network.getLinks().size()); - Assert.assertNull(network.getLinks().get(f.linkIds[11])); + Assertions.assertEquals(7, network.getNodes().size()); + Assertions.assertEquals(9, network.getLinks().size()); + Assertions.assertNull(network.getLinks().get(f.linkIds[11])); } @Test @@ -649,12 +649,12 @@ void testRun_withConnectivity_unconnectedSink() { network.addLink(nf.createLink(f.linkIds[11], node7, node5)); network.getLinks().get(f.linkIds[10]).setAllowedModes(f.modesW); network.getLinks().get(f.linkIds[11]).setAllowedModes(Collections.singleton("bike")); - Assert.assertEquals(7, network.getNodes().size()); - Assert.assertEquals(10, network.getLinks().size()); + Assertions.assertEquals(7, network.getNodes().size()); + Assertions.assertEquals(10, network.getLinks().size()); new MultimodalNetworkCleaner(network).run(Collections.singleton(TransportMode.walk), Collections.singleton(TransportMode.pt)); - Assert.assertEquals(7, network.getNodes().size()); - Assert.assertEquals(9, network.getLinks().size()); - Assert.assertNull(network.getLinks().get(f.linkIds[10])); + Assertions.assertEquals(7, network.getNodes().size()); + Assertions.assertEquals(9, network.getLinks().size()); + Assertions.assertNull(network.getLinks().get(f.linkIds[10])); } @Test @@ -678,15 +678,15 @@ void testRun_withConnectivity_unconnectedLink() { network.addLink(nf.createLink(f.linkIds[13], node10, node9)); network.getLinks().get(f.linkIds[12]).setAllowedModes(f.modesW); network.getLinks().get(f.linkIds[13]).setAllowedModes(f.modesT); - Assert.assertEquals(10, network.getNodes().size()); - Assert.assertEquals(12, network.getLinks().size()); + Assertions.assertEquals(10, network.getNodes().size()); + Assertions.assertEquals(12, network.getLinks().size()); new MultimodalNetworkCleaner(network).run(Collections.singleton(TransportMode.walk), Collections.singleton(TransportMode.pt)); - Assert.assertEquals(8, network.getNodes().size()); - Assert.assertEquals(9, network.getLinks().size()); - Assert.assertNull(network.getLinks().get(f.linkIds[10])); - Assert.assertNull(network.getLinks().get(f.linkIds[11])); - Assert.assertNull(network.getLinks().get(f.linkIds[12])); - Assert.assertNotNull(network.getLinks().get(f.linkIds[13])); + Assertions.assertEquals(8, network.getNodes().size()); + Assertions.assertEquals(9, network.getLinks().size()); + Assertions.assertNull(network.getLinks().get(f.linkIds[10])); + Assertions.assertNull(network.getLinks().get(f.linkIds[11])); + Assertions.assertNull(network.getLinks().get(f.linkIds[12])); + Assertions.assertNotNull(network.getLinks().get(f.linkIds[13])); } /** diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkCleanerTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkCleanerTest.java index 82612458c85..db870267bcc 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkCleanerTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkCleanerTest.java @@ -20,7 +20,7 @@ package org.matsim.core.network.algorithms; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -65,14 +65,14 @@ void testSink() { NetworkUtils.createAndAddLink(network,Id.create("5", Link.class), fromNode4, toNode4, (double) 100, (double) 100, (double) 100, (double) 1 ); // link 5 is a sink / dead end! - assertEquals("# nodes", 5, network.getNodes().size()); - assertEquals("# links", 5, network.getLinks().size()); + assertEquals(5, network.getNodes().size(), "# nodes"); + assertEquals(5, network.getLinks().size(), "# links"); NetworkCleaner cleaner = new NetworkCleaner(); cleaner.run(network); - assertEquals("# nodes", 4, network.getNodes().size()); - assertEquals("# links", 4, network.getLinks().size()); + assertEquals(4, network.getNodes().size(), "# nodes"); + assertEquals(4, network.getLinks().size(), "# links"); } @Test @@ -104,14 +104,14 @@ void testDoubleSink() { NetworkUtils.createAndAddLink(network,Id.create("6", Link.class), fromNode5, toNode5, (double) 100, (double) 100, (double) 100, (double) 1 ); // link 5 is a sink / dead end! - assertEquals("# nodes", 5, network.getNodes().size()); - assertEquals("# links", 6, network.getLinks().size()); + assertEquals(5, network.getNodes().size(), "# nodes"); + assertEquals(6, network.getLinks().size(), "# links"); NetworkCleaner cleaner = new NetworkCleaner(); cleaner.run(network); - assertEquals("# nodes", 4, network.getNodes().size()); - assertEquals("# links", 4, network.getLinks().size()); + assertEquals(4, network.getNodes().size(), "# nodes"); + assertEquals(4, network.getLinks().size(), "# links"); } @Test @@ -140,14 +140,14 @@ void testSource() { NetworkUtils.createAndAddLink(network,Id.create("5", Link.class), fromNode4, toNode4, (double) 100, (double) 100, (double) 100, (double) 1 ); // link 5 is a source / dead end! - assertEquals("# nodes", 5, network.getNodes().size()); - assertEquals("# links", 5, network.getLinks().size()); + assertEquals(5, network.getNodes().size(), "# nodes"); + assertEquals(5, network.getLinks().size(), "# links"); NetworkCleaner cleaner = new NetworkCleaner(); cleaner.run(network); - assertEquals("# nodes", 4, network.getNodes().size()); - assertEquals("# links", 4, network.getLinks().size()); + assertEquals(4, network.getNodes().size(), "# nodes"); + assertEquals(4, network.getLinks().size(), "# links"); } @Test @@ -179,14 +179,14 @@ void testDoubleSource() { NetworkUtils.createAndAddLink(network,Id.create("6", Link.class), fromNode5, toNode5, (double) 100, (double) 100, (double) 100, (double) 1 ); // link 5 is a source / dead end! - assertEquals("# nodes", 5, network.getNodes().size()); - assertEquals("# links", 6, network.getLinks().size()); + assertEquals(5, network.getNodes().size(), "# nodes"); + assertEquals(6, network.getLinks().size(), "# links"); NetworkCleaner cleaner = new NetworkCleaner(); cleaner.run(network); - assertEquals("# nodes", 4, network.getNodes().size()); - assertEquals("# links", 4, network.getLinks().size()); + assertEquals(4, network.getNodes().size(), "# nodes"); + assertEquals(4, network.getLinks().size(), "# links"); } } diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkExpandNodeTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkExpandNodeTest.java index 582e14d9a15..fde53bf90fc 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkExpandNodeTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkExpandNodeTest.java @@ -23,7 +23,7 @@ import java.util.HashSet; import java.util.Set; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -57,98 +57,98 @@ void testExpandNode() { exp.expandNode(Id.create("3", Node.class), turns); Network n = f.scenario.getNetwork(); - Assert.assertEquals(12, n.getLinks().size()); - Assert.assertEquals(10, n.getNodes().size()); - Assert.assertNotNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("6", Link.class))); - Assert.assertNotNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("6", Link.class))); - Assert.assertNotNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("2", Link.class))); - Assert.assertNotNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("4", Link.class))); - Assert.assertNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("2", Link.class))); - Assert.assertNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("4", Link.class))); - Assert.assertNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("2", Link.class))); - Assert.assertNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("4", Link.class))); - Assert.assertNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("6", Link.class))); + Assertions.assertEquals(12, n.getLinks().size()); + Assertions.assertEquals(10, n.getNodes().size()); + Assertions.assertNotNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("6", Link.class))); + Assertions.assertNotNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("6", Link.class))); + Assertions.assertNotNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("2", Link.class))); + Assertions.assertNotNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("4", Link.class))); + Assertions.assertNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("2", Link.class))); + Assertions.assertNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("4", Link.class))); + Assertions.assertNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("2", Link.class))); + Assertions.assertNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("4", Link.class))); + Assertions.assertNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("6", Link.class))); // test correct attributes on new links Link l = findLinkBetween(n, Id.create("1", Link.class), Id.create("6", Link.class)); - Assert.assertEquals("Capacity attribute is not correct", 1800.0, l.getCapacity(), 1e-8); - Assert.assertEquals("Number of lanes is not correct", 2.0, l.getNumberOfLanes(), 1e-8); - Assert.assertEquals("Freespeed is not correct", 10.0, l.getFreespeed(), 1e-8); + Assertions.assertEquals(1800.0, l.getCapacity(), 1e-8, "Capacity attribute is not correct"); + Assertions.assertEquals(2.0, l.getNumberOfLanes(), 1e-8, "Number of lanes is not correct"); + Assertions.assertEquals(10.0, l.getFreespeed(), 1e-8, "Freespeed is not correct"); Set modes = l.getAllowedModes(); - Assert.assertEquals("Allowed modes are not correct", 2, modes.size()); - Assert.assertTrue(modes.contains(TransportMode.walk)); - Assert.assertTrue(modes.contains(TransportMode.car)); + Assertions.assertEquals(2, modes.size(), "Allowed modes are not correct"); + Assertions.assertTrue(modes.contains(TransportMode.walk)); + Assertions.assertTrue(modes.contains(TransportMode.car)); // test correct attributes on modified in-links l = n.getLinks().get(Id.create("3", Link.class)); - Assert.assertEquals("Capacity attribute is not correct", 1800.0, l.getCapacity(), 1e-8); - Assert.assertEquals("Number of lanes is not correct", 2.0, l.getNumberOfLanes(), 1e-8); - Assert.assertEquals("Freespeed is not correct", 10.0, l.getFreespeed(), 1e-8); + Assertions.assertEquals(1800.0, l.getCapacity(), 1e-8, "Capacity attribute is not correct"); + Assertions.assertEquals(2.0, l.getNumberOfLanes(), 1e-8, "Number of lanes is not correct"); + Assertions.assertEquals(10.0, l.getFreespeed(), 1e-8, "Freespeed is not correct"); modes = l.getAllowedModes(); - Assert.assertEquals("Allowed modes are not correct", 2, modes.size()); - Assert.assertTrue(modes.contains(TransportMode.walk)); - Assert.assertTrue(modes.contains(TransportMode.car)); + Assertions.assertEquals(2, modes.size(), "Allowed modes are not correct"); + Assertions.assertTrue(modes.contains(TransportMode.walk)); + Assertions.assertTrue(modes.contains(TransportMode.car)); // test correct attributes on modified out-links l = n.getLinks().get(Id.create("6", Link.class)); - Assert.assertEquals("Capacity attribute is not correct", 1800.0, l.getCapacity(), 1e-8); - Assert.assertEquals("Number of lanes is not correct", 2.0, l.getNumberOfLanes(), 1e-8); - Assert.assertEquals("Freespeed is not correct", 10.0, l.getFreespeed(), 1e-8); + Assertions.assertEquals(1800.0, l.getCapacity(), 1e-8, "Capacity attribute is not correct"); + Assertions.assertEquals(2.0, l.getNumberOfLanes(), 1e-8, "Number of lanes is not correct"); + Assertions.assertEquals(10.0, l.getFreespeed(), 1e-8, "Freespeed is not correct"); modes = l.getAllowedModes(); - Assert.assertEquals("Allowed modes are not correct", 2, modes.size()); - Assert.assertTrue(modes.contains(TransportMode.walk)); - Assert.assertTrue(modes.contains(TransportMode.car)); + Assertions.assertEquals(2, modes.size(), "Allowed modes are not correct"); + Assertions.assertTrue(modes.contains(TransportMode.walk)); + Assertions.assertTrue(modes.contains(TransportMode.car)); // test coordinates of new nodes l = n.getLinks().get(Id.create("1", Link.class)); Coord c = l.getToNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); l = n.getLinks().get(Id.create("2", Link.class)); c = l.getFromNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); l = n.getLinks().get(Id.create("3", Link.class)); c = l.getToNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); l = n.getLinks().get(Id.create("4", Link.class)); c = l.getFromNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); l = n.getLinks().get(Id.create("5", Link.class)); c = l.getToNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); l = n.getLinks().get(Id.create("6", Link.class)); c = l.getFromNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); } @Test @@ -169,98 +169,98 @@ void testExpandNode_sameCoordinateLinks() { exp.expandNode(Id.create("3", Node.class), turns); Network n = f.scenario.getNetwork(); - Assert.assertEquals(12, n.getLinks().size()); - Assert.assertEquals(10, n.getNodes().size()); - Assert.assertNotNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("6", Link.class))); - Assert.assertNotNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("6", Link.class))); - Assert.assertNotNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("2", Link.class))); - Assert.assertNotNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("4", Link.class))); - Assert.assertNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("2", Link.class))); - Assert.assertNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("4", Link.class))); - Assert.assertNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("2", Link.class))); - Assert.assertNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("4", Link.class))); - Assert.assertNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("6", Link.class))); + Assertions.assertEquals(12, n.getLinks().size()); + Assertions.assertEquals(10, n.getNodes().size()); + Assertions.assertNotNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("6", Link.class))); + Assertions.assertNotNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("6", Link.class))); + Assertions.assertNotNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("2", Link.class))); + Assertions.assertNotNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("4", Link.class))); + Assertions.assertNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("2", Link.class))); + Assertions.assertNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("4", Link.class))); + Assertions.assertNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("2", Link.class))); + Assertions.assertNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("4", Link.class))); + Assertions.assertNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("6", Link.class))); // test correct attributes on new links Link l = findLinkBetween(n, Id.create("1", Link.class), Id.create("6", Link.class)); - Assert.assertEquals("Capacity attribute is not correct", 1800.0, l.getCapacity(), 1e-8); - Assert.assertEquals("Number of lanes is not correct", 2.0, l.getNumberOfLanes(), 1e-8); - Assert.assertEquals("Freespeed is not correct", 10.0, l.getFreespeed(), 1e-8); + Assertions.assertEquals(1800.0, l.getCapacity(), 1e-8, "Capacity attribute is not correct"); + Assertions.assertEquals(2.0, l.getNumberOfLanes(), 1e-8, "Number of lanes is not correct"); + Assertions.assertEquals(10.0, l.getFreespeed(), 1e-8, "Freespeed is not correct"); Set modes = l.getAllowedModes(); - Assert.assertEquals("Allowed modes are not correct", 2, modes.size()); - Assert.assertTrue(modes.contains(TransportMode.walk)); - Assert.assertTrue(modes.contains(TransportMode.car)); + Assertions.assertEquals(2, modes.size(), "Allowed modes are not correct"); + Assertions.assertTrue(modes.contains(TransportMode.walk)); + Assertions.assertTrue(modes.contains(TransportMode.car)); // test correct attributes on modified in-links l = n.getLinks().get(Id.create("3", Link.class)); - Assert.assertEquals("Capacity attribute is not correct", 1800.0, l.getCapacity(), 1e-8); - Assert.assertEquals("Number of lanes is not correct", 2.0, l.getNumberOfLanes(), 1e-8); - Assert.assertEquals("Freespeed is not correct", 10.0, l.getFreespeed(), 1e-8); + Assertions.assertEquals(1800.0, l.getCapacity(), 1e-8, "Capacity attribute is not correct"); + Assertions.assertEquals(2.0, l.getNumberOfLanes(), 1e-8, "Number of lanes is not correct"); + Assertions.assertEquals(10.0, l.getFreespeed(), 1e-8, "Freespeed is not correct"); modes = l.getAllowedModes(); - Assert.assertEquals("Allowed modes are not correct", 2, modes.size()); - Assert.assertTrue(modes.contains(TransportMode.walk)); - Assert.assertTrue(modes.contains(TransportMode.car)); + Assertions.assertEquals(2, modes.size(), "Allowed modes are not correct"); + Assertions.assertTrue(modes.contains(TransportMode.walk)); + Assertions.assertTrue(modes.contains(TransportMode.car)); // test correct attributes on modified out-links l = n.getLinks().get(Id.create("6", Link.class)); - Assert.assertEquals("Capacity attribute is not correct", 1800.0, l.getCapacity(), 1e-8); - Assert.assertEquals("Number of lanes is not correct", 2.0, l.getNumberOfLanes(), 1e-8); - Assert.assertEquals("Freespeed is not correct", 10.0, l.getFreespeed(), 1e-8); + Assertions.assertEquals(1800.0, l.getCapacity(), 1e-8, "Capacity attribute is not correct"); + Assertions.assertEquals(2.0, l.getNumberOfLanes(), 1e-8, "Number of lanes is not correct"); + Assertions.assertEquals(10.0, l.getFreespeed(), 1e-8, "Freespeed is not correct"); modes = l.getAllowedModes(); - Assert.assertEquals("Allowed modes are not correct", 2, modes.size()); - Assert.assertTrue(modes.contains(TransportMode.walk)); - Assert.assertTrue(modes.contains(TransportMode.car)); + Assertions.assertEquals(2, modes.size(), "Allowed modes are not correct"); + Assertions.assertTrue(modes.contains(TransportMode.walk)); + Assertions.assertTrue(modes.contains(TransportMode.car)); // test coordinates of new nodes l = n.getLinks().get(Id.create("1", Link.class)); c = l.getToNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); l = n.getLinks().get(Id.create("2", Link.class)); c = l.getFromNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); l = n.getLinks().get(Id.create("3", Link.class)); c = l.getToNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); l = n.getLinks().get(Id.create("4", Link.class)); c = l.getFromNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); l = n.getLinks().get(Id.create("5", Link.class)); c = l.getToNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); l = n.getLinks().get(Id.create("6", Link.class)); c = l.getFromNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); } @Test @@ -282,108 +282,108 @@ void testExpandNode_specificModes() { exp.expandNode(Id.create("3", Node.class), turns); Network n = f.scenario.getNetwork(); - Assert.assertEquals(12, n.getLinks().size()); - Assert.assertEquals(10, n.getNodes().size()); - Assert.assertNotNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("6", Link.class))); - Assert.assertNotNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("6", Link.class))); - Assert.assertNotNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("2", Link.class))); - Assert.assertNotNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("4", Link.class))); - Assert.assertNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("2", Link.class))); - Assert.assertNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("4", Link.class))); - Assert.assertNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("2", Link.class))); - Assert.assertNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("4", Link.class))); - Assert.assertNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("6", Link.class))); + Assertions.assertEquals(12, n.getLinks().size()); + Assertions.assertEquals(10, n.getNodes().size()); + Assertions.assertNotNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("6", Link.class))); + Assertions.assertNotNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("6", Link.class))); + Assertions.assertNotNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("2", Link.class))); + Assertions.assertNotNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("4", Link.class))); + Assertions.assertNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("2", Link.class))); + Assertions.assertNull(findLinkBetween(n, Id.create("1", Link.class), Id.create("4", Link.class))); + Assertions.assertNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("2", Link.class))); + Assertions.assertNull(findLinkBetween(n, Id.create("3", Link.class), Id.create("4", Link.class))); + Assertions.assertNull(findLinkBetween(n, Id.create("5", Link.class), Id.create("6", Link.class))); // test correct attributes on new links Link l = findLinkBetween(n, Id.create("1", Link.class), Id.create("6", Link.class)); - Assert.assertEquals("Capacity attribute is not correct", 1800.0, l.getCapacity(), 1e-8); - Assert.assertEquals("Number of lanes is not correct", 2.0, l.getNumberOfLanes(), 1e-8); - Assert.assertEquals("Freespeed is not correct", 10.0, l.getFreespeed(), 1e-8); + Assertions.assertEquals(1800.0, l.getCapacity(), 1e-8, "Capacity attribute is not correct"); + Assertions.assertEquals(2.0, l.getNumberOfLanes(), 1e-8, "Number of lanes is not correct"); + Assertions.assertEquals(10.0, l.getFreespeed(), 1e-8, "Freespeed is not correct"); Set modes = l.getAllowedModes(); - Assert.assertEquals("Allowed modes are not correct", 2, modes.size()); - Assert.assertTrue(modes.contains(TransportMode.walk)); - Assert.assertTrue(modes.contains(TransportMode.car)); + Assertions.assertEquals(2, modes.size(), "Allowed modes are not correct"); + Assertions.assertTrue(modes.contains(TransportMode.walk)); + Assertions.assertTrue(modes.contains(TransportMode.car)); l = findLinkBetween(n, Id.create("5", Link.class), Id.create("2", Link.class)); modes = l.getAllowedModes(); - Assert.assertEquals("Allowed modes are not correct", 1, modes.size()); - Assert.assertTrue(modes.contains(TransportMode.walk)); + Assertions.assertEquals(1, modes.size(), "Allowed modes are not correct"); + Assertions.assertTrue(modes.contains(TransportMode.walk)); l = findLinkBetween(n, Id.create("5", Link.class), Id.create("4", Link.class)); modes = l.getAllowedModes(); - Assert.assertEquals("Allowed modes are not correct", 1, modes.size()); - Assert.assertTrue(modes.contains(TransportMode.car)); + Assertions.assertEquals(1, modes.size(), "Allowed modes are not correct"); + Assertions.assertTrue(modes.contains(TransportMode.car)); // test correct attributes on modified in-links l = n.getLinks().get(Id.create("3", Link.class)); - Assert.assertEquals("Capacity attribute is not correct", 1800.0, l.getCapacity(), 1e-8); - Assert.assertEquals("Number of lanes is not correct", 2.0, l.getNumberOfLanes(), 1e-8); - Assert.assertEquals("Freespeed is not correct", 10.0, l.getFreespeed(), 1e-8); + Assertions.assertEquals(1800.0, l.getCapacity(), 1e-8, "Capacity attribute is not correct"); + Assertions.assertEquals(2.0, l.getNumberOfLanes(), 1e-8, "Number of lanes is not correct"); + Assertions.assertEquals(10.0, l.getFreespeed(), 1e-8, "Freespeed is not correct"); modes = l.getAllowedModes(); - Assert.assertEquals("Allowed modes are not correct", 2, modes.size()); - Assert.assertTrue(modes.contains(TransportMode.walk)); - Assert.assertTrue(modes.contains(TransportMode.car)); + Assertions.assertEquals(2, modes.size(), "Allowed modes are not correct"); + Assertions.assertTrue(modes.contains(TransportMode.walk)); + Assertions.assertTrue(modes.contains(TransportMode.car)); // test correct attributes on modified out-links l = n.getLinks().get(Id.create("6", Link.class)); - Assert.assertEquals("Capacity attribute is not correct", 1800.0, l.getCapacity(), 1e-8); - Assert.assertEquals("Number of lanes is not correct", 2.0, l.getNumberOfLanes(), 1e-8); - Assert.assertEquals("Freespeed is not correct", 10.0, l.getFreespeed(), 1e-8); + Assertions.assertEquals(1800.0, l.getCapacity(), 1e-8, "Capacity attribute is not correct"); + Assertions.assertEquals(2.0, l.getNumberOfLanes(), 1e-8, "Number of lanes is not correct"); + Assertions.assertEquals(10.0, l.getFreespeed(), 1e-8, "Freespeed is not correct"); modes = l.getAllowedModes(); - Assert.assertEquals("Allowed modes are not correct", 2, modes.size()); - Assert.assertTrue(modes.contains(TransportMode.walk)); - Assert.assertTrue(modes.contains(TransportMode.car)); + Assertions.assertEquals(2, modes.size(), "Allowed modes are not correct"); + Assertions.assertTrue(modes.contains(TransportMode.walk)); + Assertions.assertTrue(modes.contains(TransportMode.car)); // test coordinates of new nodes l = n.getLinks().get(Id.create("1", Link.class)); Coord c = l.getToNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); l = n.getLinks().get(Id.create("2", Link.class)); c = l.getFromNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); l = n.getLinks().get(Id.create("3", Link.class)); c = l.getToNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); l = n.getLinks().get(Id.create("4", Link.class)); c = l.getFromNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); l = n.getLinks().get(Id.create("5", Link.class)); c = l.getToNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); l = n.getLinks().get(Id.create("6", Link.class)); c = l.getFromNode().getCoord(); - Assert.assertFalse(Double.isNaN(c.getX())); - Assert.assertFalse(Double.isNaN(c.getY())); - Assert.assertFalse(Double.isInfinite(c.getX())); - Assert.assertFalse(Double.isInfinite(c.getY())); - Assert.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); + Assertions.assertFalse(Double.isNaN(c.getX())); + Assertions.assertFalse(Double.isNaN(c.getY())); + Assertions.assertFalse(Double.isInfinite(c.getX())); + Assertions.assertFalse(Double.isInfinite(c.getY())); + Assertions.assertTrue(CoordUtils.calcEuclideanDistance(c, new Coord((double) 1000, (double) 0)) < 30); } @Test @@ -408,7 +408,7 @@ void testTurnsAreSameAsSingleNode_IncludeUTurns() { turns.add(new TurnInfo(Id.create("5", Link.class), Id.create("4", Link.class), carOnly)); Id nodeId = Id.create("3", Node.class); - Assert.assertFalse(exp.turnsAreSameAsSingleNode(nodeId, turns, false)); + Assertions.assertFalse(exp.turnsAreSameAsSingleNode(nodeId, turns, false)); turns.clear(); turns.add(new TurnInfo(Id.create("1", Link.class), Id.create("2", Link.class))); @@ -421,7 +421,7 @@ void testTurnsAreSameAsSingleNode_IncludeUTurns() { turns.add(new TurnInfo(Id.create("5", Link.class), Id.create("4", Link.class))); turns.add(new TurnInfo(Id.create("5", Link.class), Id.create("6", Link.class))); - Assert.assertTrue(exp.turnsAreSameAsSingleNode(nodeId, turns, false)); + Assertions.assertTrue(exp.turnsAreSameAsSingleNode(nodeId, turns, false)); } @Test @@ -447,7 +447,7 @@ void testTurnsAreSameAsSingleNode_IgnoreUTurns() { turns.add(new TurnInfo(Id.create("5", Link.class), Id.create("4", Link.class), carOnly)); Id nodeId = Id.create("3", Node.class); - Assert.assertFalse(exp.turnsAreSameAsSingleNode(nodeId, turns, true)); + Assertions.assertFalse(exp.turnsAreSameAsSingleNode(nodeId, turns, true)); turns.clear(); turns.add(new TurnInfo(Id.create("1", Link.class), Id.create("2", Link.class))); // u-turn @@ -460,7 +460,7 @@ void testTurnsAreSameAsSingleNode_IgnoreUTurns() { turns.add(new TurnInfo(Id.create("5", Link.class), Id.create("4", Link.class))); turns.add(new TurnInfo(Id.create("5", Link.class), Id.create("6", Link.class), emptySet)); // u-turn - Assert.assertTrue(exp.turnsAreSameAsSingleNode(nodeId, turns, true)); + Assertions.assertTrue(exp.turnsAreSameAsSingleNode(nodeId, turns, true)); } @Test @@ -481,22 +481,22 @@ void testTurnInfo_equals() { TurnInfo ti22 = new TurnInfo(id1, id2, modes1); TurnInfo ti44 = new TurnInfo(id2, id1); - Assert.assertNotNull(ti1); - Assert.assertFalse(ti1.equals(ti2)); - Assert.assertFalse(ti1.equals(ti3)); - Assert.assertFalse(ti1.equals(ti4)); - Assert.assertFalse(ti1.equals(ti5)); - Assert.assertFalse(ti1.equals(ti6)); - - Assert.assertNotNull(ti2); - Assert.assertFalse(ti2.equals(ti1)); - Assert.assertFalse(ti2.equals(ti3)); - Assert.assertFalse(ti2.equals(ti4)); - Assert.assertFalse(ti2.equals(ti5)); - Assert.assertFalse(ti2.equals(ti6)); - - Assert.assertTrue(ti2.equals(ti22)); - Assert.assertTrue(ti4.equals(ti44)); + Assertions.assertNotNull(ti1); + Assertions.assertFalse(ti1.equals(ti2)); + Assertions.assertFalse(ti1.equals(ti3)); + Assertions.assertFalse(ti1.equals(ti4)); + Assertions.assertFalse(ti1.equals(ti5)); + Assertions.assertFalse(ti1.equals(ti6)); + + Assertions.assertNotNull(ti2); + Assertions.assertFalse(ti2.equals(ti1)); + Assertions.assertFalse(ti2.equals(ti3)); + Assertions.assertFalse(ti2.equals(ti4)); + Assertions.assertFalse(ti2.equals(ti5)); + Assertions.assertFalse(ti2.equals(ti6)); + + Assertions.assertTrue(ti2.equals(ti22)); + Assertions.assertTrue(ti4.equals(ti44)); } private static Link findLinkBetween(final Network network, final Id fromLinkId, final Id toLinkId) { diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkMergeDoubleLinksTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkMergeDoubleLinksTest.java index c5d32dbbc18..89e8564f44d 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkMergeDoubleLinksTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkMergeDoubleLinksTest.java @@ -19,7 +19,7 @@ package org.matsim.core.network.algorithms; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -43,29 +43,29 @@ void testRun_remove() { NetworkMergeDoubleLinks merger = new NetworkMergeDoubleLinks(NetworkMergeDoubleLinks.MergeType.REMOVE); merger.run(f.network); - Assert.assertEquals("wrong number of links.", 3, f.network.getLinks().size()); - Assert.assertNotNull(f.network.getLinks().get(f.linkIds[0])); - Assert.assertNull(f.network.getLinks().get(f.linkIds[10])); - Assert.assertNotNull(f.network.getLinks().get(f.linkIds[1])); - Assert.assertNull(f.network.getLinks().get(f.linkIds[11])); - Assert.assertNotNull(f.network.getLinks().get(f.linkIds[2])); - Assert.assertNull(f.network.getLinks().get(f.linkIds[12])); + Assertions.assertEquals(3, f.network.getLinks().size(), "wrong number of links."); + Assertions.assertNotNull(f.network.getLinks().get(f.linkIds[0])); + Assertions.assertNull(f.network.getLinks().get(f.linkIds[10])); + Assertions.assertNotNull(f.network.getLinks().get(f.linkIds[1])); + Assertions.assertNull(f.network.getLinks().get(f.linkIds[11])); + Assertions.assertNotNull(f.network.getLinks().get(f.linkIds[2])); + Assertions.assertNull(f.network.getLinks().get(f.linkIds[12])); // attributes should be unchanged - Assert.assertEquals(100.0, f.network.getLinks().get(f.linkIds[0]).getLength(), MatsimTestUtils.EPSILON); - Assert.assertEquals(200.0, f.network.getLinks().get(f.linkIds[0]).getCapacity(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1, f.network.getLinks().get(f.linkIds[0]).getNumberOfLanes(), MatsimTestUtils.EPSILON); - Assert.assertEquals(30.0/3.6, f.network.getLinks().get(f.linkIds[0]).getFreespeed(), MatsimTestUtils.EPSILON); - - Assert.assertEquals(500.0, f.network.getLinks().get(f.linkIds[1]).getLength(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2000.0, f.network.getLinks().get(f.linkIds[1]).getCapacity(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2, f.network.getLinks().get(f.linkIds[1]).getNumberOfLanes(), MatsimTestUtils.EPSILON); - Assert.assertEquals(70.0/3.6, f.network.getLinks().get(f.linkIds[1]).getFreespeed(), MatsimTestUtils.EPSILON); - - Assert.assertEquals(700.0, f.network.getLinks().get(f.linkIds[2]).getLength(), MatsimTestUtils.EPSILON); - Assert.assertEquals(500.0, f.network.getLinks().get(f.linkIds[2]).getCapacity(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2, f.network.getLinks().get(f.linkIds[2]).getNumberOfLanes(), MatsimTestUtils.EPSILON); - Assert.assertEquals(50.0/3.6, f.network.getLinks().get(f.linkIds[2]).getFreespeed(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(100.0, f.network.getLinks().get(f.linkIds[0]).getLength(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(200.0, f.network.getLinks().get(f.linkIds[0]).getCapacity(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, f.network.getLinks().get(f.linkIds[0]).getNumberOfLanes(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(30.0/3.6, f.network.getLinks().get(f.linkIds[0]).getFreespeed(), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(500.0, f.network.getLinks().get(f.linkIds[1]).getLength(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2000.0, f.network.getLinks().get(f.linkIds[1]).getCapacity(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, f.network.getLinks().get(f.linkIds[1]).getNumberOfLanes(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(70.0/3.6, f.network.getLinks().get(f.linkIds[1]).getFreespeed(), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(700.0, f.network.getLinks().get(f.linkIds[2]).getLength(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(500.0, f.network.getLinks().get(f.linkIds[2]).getCapacity(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, f.network.getLinks().get(f.linkIds[2]).getNumberOfLanes(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(50.0/3.6, f.network.getLinks().get(f.linkIds[2]).getFreespeed(), MatsimTestUtils.EPSILON); } @Test @@ -74,29 +74,29 @@ void testRun_additive() { NetworkMergeDoubleLinks merger = new NetworkMergeDoubleLinks(NetworkMergeDoubleLinks.MergeType.ADDITIVE); merger.run(f.network); - Assert.assertEquals("wrong number of links.", 3, f.network.getLinks().size()); - Assert.assertNotNull(f.network.getLinks().get(f.linkIds[0])); - Assert.assertNull(f.network.getLinks().get(f.linkIds[10])); - Assert.assertNotNull(f.network.getLinks().get(f.linkIds[1])); - Assert.assertNull(f.network.getLinks().get(f.linkIds[11])); - Assert.assertNotNull(f.network.getLinks().get(f.linkIds[2])); - Assert.assertNull(f.network.getLinks().get(f.linkIds[12])); + Assertions.assertEquals(3, f.network.getLinks().size(), "wrong number of links."); + Assertions.assertNotNull(f.network.getLinks().get(f.linkIds[0])); + Assertions.assertNull(f.network.getLinks().get(f.linkIds[10])); + Assertions.assertNotNull(f.network.getLinks().get(f.linkIds[1])); + Assertions.assertNull(f.network.getLinks().get(f.linkIds[11])); + Assertions.assertNotNull(f.network.getLinks().get(f.linkIds[2])); + Assertions.assertNull(f.network.getLinks().get(f.linkIds[12])); // additive merge (sum cap, max freespeed, sum lanes, max length) - Assert.assertEquals(500.0, f.network.getLinks().get(f.linkIds[0]).getLength(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2200.0, f.network.getLinks().get(f.linkIds[0]).getCapacity(), MatsimTestUtils.EPSILON); - Assert.assertEquals(3, f.network.getLinks().get(f.linkIds[0]).getNumberOfLanes(), MatsimTestUtils.EPSILON); - Assert.assertEquals(70.0/3.6, f.network.getLinks().get(f.linkIds[0]).getFreespeed(), MatsimTestUtils.EPSILON); - - Assert.assertEquals(500.0, f.network.getLinks().get(f.linkIds[1]).getLength(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2200.0, f.network.getLinks().get(f.linkIds[1]).getCapacity(), MatsimTestUtils.EPSILON); - Assert.assertEquals(3, f.network.getLinks().get(f.linkIds[1]).getNumberOfLanes(), MatsimTestUtils.EPSILON); - Assert.assertEquals(70.0/3.6, f.network.getLinks().get(f.linkIds[1]).getFreespeed(), MatsimTestUtils.EPSILON); - - Assert.assertEquals(700.0, f.network.getLinks().get(f.linkIds[2]).getLength(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1500.0, f.network.getLinks().get(f.linkIds[2]).getCapacity(), MatsimTestUtils.EPSILON); - Assert.assertEquals(3, f.network.getLinks().get(f.linkIds[2]).getNumberOfLanes(), MatsimTestUtils.EPSILON); - Assert.assertEquals(80.0/3.6, f.network.getLinks().get(f.linkIds[2]).getFreespeed(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(500.0, f.network.getLinks().get(f.linkIds[0]).getLength(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2200.0, f.network.getLinks().get(f.linkIds[0]).getCapacity(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, f.network.getLinks().get(f.linkIds[0]).getNumberOfLanes(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(70.0/3.6, f.network.getLinks().get(f.linkIds[0]).getFreespeed(), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(500.0, f.network.getLinks().get(f.linkIds[1]).getLength(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2200.0, f.network.getLinks().get(f.linkIds[1]).getCapacity(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, f.network.getLinks().get(f.linkIds[1]).getNumberOfLanes(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(70.0/3.6, f.network.getLinks().get(f.linkIds[1]).getFreespeed(), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(700.0, f.network.getLinks().get(f.linkIds[2]).getLength(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1500.0, f.network.getLinks().get(f.linkIds[2]).getCapacity(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(3, f.network.getLinks().get(f.linkIds[2]).getNumberOfLanes(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(80.0/3.6, f.network.getLinks().get(f.linkIds[2]).getFreespeed(), MatsimTestUtils.EPSILON); } @Test @@ -105,29 +105,29 @@ void testRun_maximum() { NetworkMergeDoubleLinks merger = new NetworkMergeDoubleLinks(NetworkMergeDoubleLinks.MergeType.MAXIMUM); merger.run(f.network); - Assert.assertEquals("wrong number of links.", 3, f.network.getLinks().size()); - Assert.assertNotNull(f.network.getLinks().get(f.linkIds[0])); - Assert.assertNull(f.network.getLinks().get(f.linkIds[10])); - Assert.assertNotNull(f.network.getLinks().get(f.linkIds[1])); - Assert.assertNull(f.network.getLinks().get(f.linkIds[11])); - Assert.assertNotNull(f.network.getLinks().get(f.linkIds[2])); - Assert.assertNull(f.network.getLinks().get(f.linkIds[12])); + Assertions.assertEquals(3, f.network.getLinks().size(), "wrong number of links."); + Assertions.assertNotNull(f.network.getLinks().get(f.linkIds[0])); + Assertions.assertNull(f.network.getLinks().get(f.linkIds[10])); + Assertions.assertNotNull(f.network.getLinks().get(f.linkIds[1])); + Assertions.assertNull(f.network.getLinks().get(f.linkIds[11])); + Assertions.assertNotNull(f.network.getLinks().get(f.linkIds[2])); + Assertions.assertNull(f.network.getLinks().get(f.linkIds[12])); // max merge (max cap, max freespeed, max langes, max length - Assert.assertEquals(500.0, f.network.getLinks().get(f.linkIds[0]).getLength(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2000.0, f.network.getLinks().get(f.linkIds[0]).getCapacity(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2, f.network.getLinks().get(f.linkIds[0]).getNumberOfLanes(), MatsimTestUtils.EPSILON); - Assert.assertEquals(70.0/3.6, f.network.getLinks().get(f.linkIds[0]).getFreespeed(), MatsimTestUtils.EPSILON); - - Assert.assertEquals(500.0, f.network.getLinks().get(f.linkIds[1]).getLength(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2000.0, f.network.getLinks().get(f.linkIds[1]).getCapacity(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2, f.network.getLinks().get(f.linkIds[1]).getNumberOfLanes(), MatsimTestUtils.EPSILON); - Assert.assertEquals(70.0/3.6, f.network.getLinks().get(f.linkIds[1]).getFreespeed(), MatsimTestUtils.EPSILON); - - Assert.assertEquals(700.0, f.network.getLinks().get(f.linkIds[2]).getLength(), MatsimTestUtils.EPSILON); - Assert.assertEquals(1000.0, f.network.getLinks().get(f.linkIds[2]).getCapacity(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2, f.network.getLinks().get(f.linkIds[2]).getNumberOfLanes(), MatsimTestUtils.EPSILON); - Assert.assertEquals(80.0/3.6, f.network.getLinks().get(f.linkIds[2]).getFreespeed(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(500.0, f.network.getLinks().get(f.linkIds[0]).getLength(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2000.0, f.network.getLinks().get(f.linkIds[0]).getCapacity(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, f.network.getLinks().get(f.linkIds[0]).getNumberOfLanes(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(70.0/3.6, f.network.getLinks().get(f.linkIds[0]).getFreespeed(), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(500.0, f.network.getLinks().get(f.linkIds[1]).getLength(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2000.0, f.network.getLinks().get(f.linkIds[1]).getCapacity(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, f.network.getLinks().get(f.linkIds[1]).getNumberOfLanes(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(70.0/3.6, f.network.getLinks().get(f.linkIds[1]).getFreespeed(), MatsimTestUtils.EPSILON); + + Assertions.assertEquals(700.0, f.network.getLinks().get(f.linkIds[2]).getLength(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1000.0, f.network.getLinks().get(f.linkIds[2]).getCapacity(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, f.network.getLinks().get(f.linkIds[2]).getNumberOfLanes(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(80.0/3.6, f.network.getLinks().get(f.linkIds[2]).getFreespeed(), MatsimTestUtils.EPSILON); } private static class Fixture { diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierPass2WayTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierPass2WayTest.java index 94feb8bcf41..af826adadc6 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierPass2WayTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierPass2WayTest.java @@ -19,8 +19,9 @@ package org.matsim.core.network.algorithms; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -48,7 +49,7 @@ void testSimplifying(){ int counter = 0; for (Network network : networks) { System.out.println("Running simplifier on network "+counter); - assertEquals("Wrong number of links", 10, network.getLinks().size()); + assertEquals(10, network.getLinks().size(), "Wrong number of links"); NetworkSimplifier networkSimplifier = new NetworkSimplifier(); networkSimplifier.setMergeLinkStats(false); @@ -56,13 +57,13 @@ void testSimplifying(){ network.getLinks().values().stream().forEach(l ->System.out.println(l.toString())); - assertEquals("Wrong number of links", 4, network.getLinks().size()); - assertNotNull("Expected link not found.", network.getLinks().get(Id.createLinkId("AB-BC-CD-DE-EF"))); + assertEquals(4, network.getLinks().size(), "Wrong number of links"); + assertNotNull(network.getLinks().get(Id.createLinkId("AB-BC-CD-DE-EF")), "Expected link not found."); - assertNotNull("Expected link not found.", network.getLinks().get(Id.createLinkId("CB"))); - assertNotNull("Expected link not found.", network.getLinks().get(Id.createLinkId("BA"))); + assertNotNull(network.getLinks().get(Id.createLinkId("CB")), "Expected link not found."); + assertNotNull(network.getLinks().get(Id.createLinkId("BA")), "Expected link not found."); - assertNotNull("Expected link not found.", network.getLinks().get(Id.createLinkId("FE-ED-DC"))); + assertNotNull(network.getLinks().get(Id.createLinkId("FE-ED-DC")), "Expected link not found."); } diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierTest.java index 542823a3ad4..ae5d22abaf3 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierTest.java @@ -20,13 +20,13 @@ package org.matsim.core.network.algorithms; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.Map; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -46,8 +46,8 @@ public void setUp() { @Test void testBuildNetwork() { Network network = buildNetwork(); - assertEquals("Wrong number of nodes.", 6, network.getNodes().size()); - assertEquals("Wrong number of links.", 5, network.getLinks().size()); + assertEquals(6, network.getNodes().size(), "Wrong number of nodes."); + assertEquals(5, network.getLinks().size(), "Wrong number of links."); } @Test @@ -56,10 +56,10 @@ void testRun() { NetworkSimplifier nst = new NetworkSimplifier(); nst.run(network, 20.0); - assertEquals("Wrong number of links", 3, network.getLinks().size()); - assertNotNull("Expected link not found.", network.getLinks().get(Id.createLinkId("AB-BC"))); - assertNotNull("Expected link not found.", network.getLinks().get(Id.createLinkId("CD"))); - assertNotNull("Expected link not found.", network.getLinks().get(Id.createLinkId("DE-EF"))); + assertEquals(3, network.getLinks().size(), "Wrong number of links"); + assertNotNull(network.getLinks().get(Id.createLinkId("AB-BC")), "Expected link not found."); + assertNotNull(network.getLinks().get(Id.createLinkId("CD")), "Expected link not found."); + assertNotNull(network.getLinks().get(Id.createLinkId("DE-EF")), "Expected link not found."); } @@ -70,18 +70,18 @@ void testRunMergeLinkStats() { NetworkSimplifier nst = new NetworkSimplifier(); nst.setMergeLinkStats(true); nst.run(network, 20.0); - assertEquals("Wrong number of links", 2, network.getLinks().size()); - assertNotNull("Expected link not found.", network.getLinks().get(Id.createLinkId("AB-BC"))); - assertNotNull("Expected link not found.", network.getLinks().get(Id.createLinkId("CD-DE-EF"))); + assertEquals(2, network.getLinks().size(), "Wrong number of links"); + assertNotNull(network.getLinks().get(Id.createLinkId("AB-BC")), "Expected link not found."); + assertNotNull(network.getLinks().get(Id.createLinkId("CD-DE-EF")), "Expected link not found."); network = buildNetwork(); nst.run(network, 40.0); - assertEquals("Wrong number of links", 1, network.getLinks().size()); - assertNotNull("Expected link not found.", network.getLinks().get(Id.createLinkId("AB-BC-CD-DE-EF"))); + assertEquals(1, network.getLinks().size(), "Wrong number of links"); + assertNotNull(network.getLinks().get(Id.createLinkId("AB-BC-CD-DE-EF")), "Expected link not found."); network = buildNetwork(); nst.run(network, 5.0); - assertEquals("Wrong number of links", 5, network.getLinks().size()); + assertEquals(5, network.getLinks().size(), "Wrong number of links"); } @Test @@ -166,37 +166,37 @@ void testDifferentAttributesPerDirection() { Id idHGGF = Id.create("HG-GF", Link.class); Id idFEED = Id.create("FE-ED", Link.class); - Assert.assertEquals("Wrong number of links.", 12, links.size()); - Assert.assertNotNull("Expected link not found.", links.get(idAC)); - Assert.assertNotNull("Expected link not found.", links.get(idCA)); - Assert.assertNotNull("Expected link not found.", links.get(idBC)); - Assert.assertNotNull("Expected link not found.", links.get(idCB)); - - Assert.assertNotNull("Expected link not found.", links.get(idHJ)); - Assert.assertNotNull("Expected link not found.", links.get(idJH)); - Assert.assertNotNull("Expected link not found.", links.get(idHK)); - Assert.assertNotNull("Expected link not found.", links.get(idKH)); - - Assert.assertNotNull("Expected link not found.", links.get(idCDDEEFFGGH)); - - Assert.assertNotNull("Expected link not found.", links.get(idHGGF)); - Assert.assertNotNull("Expected link not found.", links.get(idFEED)); - Assert.assertNotNull("Expected link not found.", links.get(idDC)); - - Assert.assertEquals(10.0, links.get(idAC).getLength(), 1e-8); - Assert.assertEquals(50.0, links.get(idCDDEEFFGGH).getLength(), 1e-8); - Assert.assertEquals(20.0, links.get(idHGGF).getLength(), 1e-8); - Assert.assertEquals(20.0, links.get(idFEED).getLength(), 1e-8); - - Assert.assertEquals(1000.0, links.get(idAC).getCapacity(), 1e-8); - Assert.assertEquals(2000.0, links.get(idCDDEEFFGGH).getCapacity(), 1e-8); - Assert.assertEquals(2000.0, links.get(idFEED).getCapacity(), 1e-8); - Assert.assertEquals(1000.0, links.get(idHGGF).getCapacity(), 1e-8); - - Assert.assertEquals(10.0, links.get(idAC).getFreespeed(), 1e-8); - Assert.assertEquals(10.0, links.get(idCDDEEFFGGH).getFreespeed(), 1e-8); - Assert.assertEquals(10.0, links.get(idHGGF).getFreespeed(), 1e-8); - Assert.assertEquals(10.0, links.get(idFEED).getFreespeed(), 1e-8); + Assertions.assertEquals(12, links.size(), "Wrong number of links."); + Assertions.assertNotNull(links.get(idAC), "Expected link not found."); + Assertions.assertNotNull(links.get(idCA), "Expected link not found."); + Assertions.assertNotNull(links.get(idBC), "Expected link not found."); + Assertions.assertNotNull(links.get(idCB), "Expected link not found."); + + Assertions.assertNotNull(links.get(idHJ), "Expected link not found."); + Assertions.assertNotNull(links.get(idJH), "Expected link not found."); + Assertions.assertNotNull(links.get(idHK), "Expected link not found."); + Assertions.assertNotNull(links.get(idKH), "Expected link not found."); + + Assertions.assertNotNull(links.get(idCDDEEFFGGH), "Expected link not found."); + + Assertions.assertNotNull(links.get(idHGGF), "Expected link not found."); + Assertions.assertNotNull(links.get(idFEED), "Expected link not found."); + Assertions.assertNotNull(links.get(idDC), "Expected link not found."); + + Assertions.assertEquals(10.0, links.get(idAC).getLength(), 1e-8); + Assertions.assertEquals(50.0, links.get(idCDDEEFFGGH).getLength(), 1e-8); + Assertions.assertEquals(20.0, links.get(idHGGF).getLength(), 1e-8); + Assertions.assertEquals(20.0, links.get(idFEED).getLength(), 1e-8); + + Assertions.assertEquals(1000.0, links.get(idAC).getCapacity(), 1e-8); + Assertions.assertEquals(2000.0, links.get(idCDDEEFFGGH).getCapacity(), 1e-8); + Assertions.assertEquals(2000.0, links.get(idFEED).getCapacity(), 1e-8); + Assertions.assertEquals(1000.0, links.get(idHGGF).getCapacity(), 1e-8); + + Assertions.assertEquals(10.0, links.get(idAC).getFreespeed(), 1e-8); + Assertions.assertEquals(10.0, links.get(idCDDEEFFGGH).getFreespeed(), 1e-8); + Assertions.assertEquals(10.0, links.get(idHGGF).getFreespeed(), 1e-8); + Assertions.assertEquals(10.0, links.get(idFEED).getFreespeed(), 1e-8); } diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/TransportModeNetworkFilterTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/TransportModeNetworkFilterTest.java index 1bfe470b9c8..a62e147d2f1 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/TransportModeNetworkFilterTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/TransportModeNetworkFilterTest.java @@ -23,7 +23,7 @@ import java.util.HashSet; import java.util.Set; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -55,89 +55,89 @@ void testFilter_SingleMode() { Network subNetwork = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getNetwork(); filter.filter(subNetwork, createHashSet(TransportMode.car)); - Assert.assertEquals("wrong number of nodes.", 13, subNetwork.getNodes().size()); - Assert.assertEquals("wrong number of links", 14, subNetwork.getLinks().size()); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[1])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[2])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[3])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[4])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[5])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[6])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[7])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[8])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[9])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[10])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[11])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[12])); - Assert.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[13])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[14])); - Assert.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[15])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[16])); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[8]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[9]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[10]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[11]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[12]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[14]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[16]).getAllowedModes()); - Assert.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().size()); - Assert.assertNotNull(subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().get(f.linkIds[3])); - Assert.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[7]).getOutLinks().size()); - Assert.assertNotNull(subNetwork.getNodes().get(f.nodeIds[7]).getOutLinks().get(f.linkIds[7])); + Assertions.assertEquals(13, subNetwork.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(14, subNetwork.getLinks().size(), "wrong number of links"); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[1])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[2])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[3])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[4])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[5])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[6])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[7])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[8])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[9])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[10])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[11])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[12])); + Assertions.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[13])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[14])); + Assertions.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[15])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[16])); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[9]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[10]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[11]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[12]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[14]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[16]).getAllowedModes()); + Assertions.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().size()); + Assertions.assertNotNull(subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().get(f.linkIds[3])); + Assertions.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[7]).getOutLinks().size()); + Assertions.assertNotNull(subNetwork.getNodes().get(f.nodeIds[7]).getOutLinks().get(f.linkIds[7])); subNetwork = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getNetwork(); filter.filter(subNetwork, createHashSet(TransportMode.bike)); - Assert.assertEquals("wrong number of nodes.", 9, subNetwork.getNodes().size()); - Assert.assertEquals("wrong number of links", 8, subNetwork.getLinks().size()); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[13])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[4])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[5])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[6])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[7])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[8])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[9])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[16])); - Assert.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[13]).getAllowedModes()); - Assert.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[8]).getAllowedModes()); - Assert.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[9]).getAllowedModes()); - Assert.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[16]).getAllowedModes()); - Assert.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().size()); - Assert.assertNotNull(subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().get(f.linkIds[13])); - Assert.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[4]).getOutLinks().size()); - Assert.assertNotNull(subNetwork.getNodes().get(f.nodeIds[4]).getOutLinks().get(f.linkIds[4])); + Assertions.assertEquals(9, subNetwork.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(8, subNetwork.getLinks().size(), "wrong number of links"); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[13])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[4])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[5])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[6])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[7])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[8])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[9])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[16])); + Assertions.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[13]).getAllowedModes()); + Assertions.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[9]).getAllowedModes()); + Assertions.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[16]).getAllowedModes()); + Assertions.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().size()); + Assertions.assertNotNull(subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().get(f.linkIds[13])); + Assertions.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[4]).getOutLinks().size()); + Assertions.assertNotNull(subNetwork.getNodes().get(f.nodeIds[4]).getOutLinks().get(f.linkIds[4])); subNetwork = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getNetwork(); filter.filter(subNetwork, createHashSet(TransportMode.walk)); - Assert.assertEquals("wrong number of nodes.", 5, subNetwork.getNodes().size()); - Assert.assertEquals("wrong number of links", 4, subNetwork.getLinks().size()); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[13])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[14])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[15])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[16])); - Assert.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[1])); - Assert.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[4])); - Assert.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[7])); - Assert.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[10])); - Assert.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[13])); - Assert.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[13]).getAllowedModes()); - Assert.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[14]).getAllowedModes()); - Assert.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[15]).getAllowedModes()); - Assert.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[16]).getAllowedModes()); - Assert.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().size()); - Assert.assertNotNull(subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().get(f.linkIds[13])); - Assert.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[4]).getOutLinks().size()); - Assert.assertNotNull(subNetwork.getNodes().get(f.nodeIds[4]).getOutLinks().get(f.linkIds[14])); + Assertions.assertEquals(5, subNetwork.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(4, subNetwork.getLinks().size(), "wrong number of links"); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[13])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[14])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[15])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[16])); + Assertions.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[1])); + Assertions.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[4])); + Assertions.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[7])); + Assertions.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[10])); + Assertions.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[13])); + Assertions.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[13]).getAllowedModes()); + Assertions.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[14]).getAllowedModes()); + Assertions.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[15]).getAllowedModes()); + Assertions.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[16]).getAllowedModes()); + Assertions.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().size()); + Assertions.assertNotNull(subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().get(f.linkIds[13])); + Assertions.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[4]).getOutLinks().size()); + Assertions.assertNotNull(subNetwork.getNodes().get(f.nodeIds[4]).getOutLinks().get(f.linkIds[14])); } @Test @@ -147,78 +147,78 @@ void testFilter_MultipleModes() { Network subNetwork = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getNetwork(); filter.filter(subNetwork, createHashSet(TransportMode.car, TransportMode.bike)); - Assert.assertEquals("wrong number of nodes.", 13, subNetwork.getNodes().size()); - Assert.assertEquals("wrong number of links", 15, subNetwork.getLinks().size()); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[1])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[2])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[3])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[4])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[5])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[6])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[7])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[8])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[9])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[10])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[11])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[12])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[13])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[14])); - Assert.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[15])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[16])); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[1]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[2]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[3]).getAllowedModes()); - Assert.assertEquals(f.modesCB, subNetwork.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesCB, subNetwork.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesCB, subNetwork.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesCB, subNetwork.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesCB, subNetwork.getLinks().get(f.linkIds[8]).getAllowedModes()); - Assert.assertEquals(f.modesCB, subNetwork.getLinks().get(f.linkIds[9]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[10]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[11]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[12]).getAllowedModes()); - Assert.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[13]).getAllowedModes()); - Assert.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[14]).getAllowedModes()); - Assert.assertEquals(f.modesCB, subNetwork.getLinks().get(f.linkIds[16]).getAllowedModes()); - Assert.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[7]).getOutLinks().size()); - Assert.assertNotNull(subNetwork.getNodes().get(f.nodeIds[7]).getOutLinks().get(f.linkIds[7])); - Assert.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[10]).getInLinks().size()); - Assert.assertNotNull(subNetwork.getNodes().get(f.nodeIds[10]).getInLinks().get(f.linkIds[9])); + Assertions.assertEquals(13, subNetwork.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(15, subNetwork.getLinks().size(), "wrong number of links"); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[1])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[2])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[3])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[4])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[5])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[6])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[7])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[8])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[9])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[10])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[11])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[12])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[13])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[14])); + Assertions.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[15])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[16])); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[1]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[2]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[3]).getAllowedModes()); + Assertions.assertEquals(f.modesCB, subNetwork.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesCB, subNetwork.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesCB, subNetwork.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesCB, subNetwork.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesCB, subNetwork.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertEquals(f.modesCB, subNetwork.getLinks().get(f.linkIds[9]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[10]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[11]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[12]).getAllowedModes()); + Assertions.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[13]).getAllowedModes()); + Assertions.assertEquals(f.modesC, subNetwork.getLinks().get(f.linkIds[14]).getAllowedModes()); + Assertions.assertEquals(f.modesCB, subNetwork.getLinks().get(f.linkIds[16]).getAllowedModes()); + Assertions.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[7]).getOutLinks().size()); + Assertions.assertNotNull(subNetwork.getNodes().get(f.nodeIds[7]).getOutLinks().get(f.linkIds[7])); + Assertions.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[10]).getInLinks().size()); + Assertions.assertNotNull(subNetwork.getNodes().get(f.nodeIds[10]).getInLinks().get(f.linkIds[9])); subNetwork = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getNetwork(); filter.filter(subNetwork, createHashSet(TransportMode.bike, TransportMode.walk)); - Assert.assertEquals("wrong number of nodes.", 9, subNetwork.getNodes().size()); - Assert.assertEquals("wrong number of links", 10, subNetwork.getLinks().size()); - Assert.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[1])); - Assert.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[2])); - Assert.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[3])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[4])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[5])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[6])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[7])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[8])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[9])); - Assert.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[10])); - Assert.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[11])); - Assert.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[12])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[13])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[14])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[15])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[16])); - Assert.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[4]).getAllowedModes()); - Assert.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[5]).getAllowedModes()); - Assert.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[6]).getAllowedModes()); - Assert.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[7]).getAllowedModes()); - Assert.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[8]).getAllowedModes()); - Assert.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[9]).getAllowedModes()); - Assert.assertEquals(f.modesWB, subNetwork.getLinks().get(f.linkIds[13]).getAllowedModes()); - Assert.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[14]).getAllowedModes()); - Assert.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[15]).getAllowedModes()); - Assert.assertEquals(f.modesWB, subNetwork.getLinks().get(f.linkIds[16]).getAllowedModes()); - Assert.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().size()); - Assert.assertNotNull(subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().get(f.linkIds[13])); - Assert.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[10]).getOutLinks().size()); - Assert.assertNotNull(subNetwork.getNodes().get(f.nodeIds[10]).getOutLinks().get(f.linkIds[16])); + Assertions.assertEquals(9, subNetwork.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(10, subNetwork.getLinks().size(), "wrong number of links"); + Assertions.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[1])); + Assertions.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[2])); + Assertions.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[3])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[4])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[5])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[6])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[7])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[8])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[9])); + Assertions.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[10])); + Assertions.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[11])); + Assertions.assertFalse(subNetwork.getLinks().containsKey(f.linkIds[12])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[13])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[14])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[15])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[16])); + Assertions.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[4]).getAllowedModes()); + Assertions.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[5]).getAllowedModes()); + Assertions.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[6]).getAllowedModes()); + Assertions.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[7]).getAllowedModes()); + Assertions.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[8]).getAllowedModes()); + Assertions.assertEquals(f.modesB, subNetwork.getLinks().get(f.linkIds[9]).getAllowedModes()); + Assertions.assertEquals(f.modesWB, subNetwork.getLinks().get(f.linkIds[13]).getAllowedModes()); + Assertions.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[14]).getAllowedModes()); + Assertions.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[15]).getAllowedModes()); + Assertions.assertEquals(f.modesWB, subNetwork.getLinks().get(f.linkIds[16]).getAllowedModes()); + Assertions.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().size()); + Assertions.assertNotNull(subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().get(f.linkIds[13])); + Assertions.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[10]).getOutLinks().size()); + Assertions.assertNotNull(subNetwork.getNodes().get(f.nodeIds[10]).getOutLinks().get(f.linkIds[16])); } @Test @@ -228,8 +228,8 @@ void testFilter_NoModes() { Network subNetwork = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getNetwork(); filter.filter(subNetwork, new HashSet()); - Assert.assertEquals("wrong number of nodes.", 0, subNetwork.getNodes().size()); - Assert.assertEquals("wrong number of links", 0, subNetwork.getLinks().size()); + Assertions.assertEquals(0, subNetwork.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(0, subNetwork.getLinks().size(), "wrong number of links"); } @Test @@ -239,25 +239,25 @@ void testFilter_AdditionalModes() { Network subNetwork = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getNetwork(); filter.filter(subNetwork, createHashSet(TransportMode.walk, TransportMode.pt, "motorbike")); - Assert.assertEquals("wrong number of nodes.", 5, subNetwork.getNodes().size()); - Assert.assertEquals("wrong number of links", 4, subNetwork.getLinks().size()); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[13])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[14])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[15])); - Assert.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[16])); - Assert.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[1])); - Assert.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[4])); - Assert.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[7])); - Assert.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[10])); - Assert.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[13])); - Assert.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[13]).getAllowedModes()); - Assert.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[14]).getAllowedModes()); - Assert.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[15]).getAllowedModes()); - Assert.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[16]).getAllowedModes()); - Assert.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().size()); - Assert.assertNotNull(subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().get(f.linkIds[13])); - Assert.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[4]).getOutLinks().size()); - Assert.assertNotNull(subNetwork.getNodes().get(f.nodeIds[4]).getOutLinks().get(f.linkIds[14])); + Assertions.assertEquals(5, subNetwork.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(4, subNetwork.getLinks().size(), "wrong number of links"); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[13])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[14])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[15])); + Assertions.assertTrue(subNetwork.getLinks().containsKey(f.linkIds[16])); + Assertions.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[1])); + Assertions.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[4])); + Assertions.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[7])); + Assertions.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[10])); + Assertions.assertTrue(subNetwork.getNodes().containsKey(f.nodeIds[13])); + Assertions.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[13]).getAllowedModes()); + Assertions.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[14]).getAllowedModes()); + Assertions.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[15]).getAllowedModes()); + Assertions.assertEquals(f.modesW, subNetwork.getLinks().get(f.linkIds[16]).getAllowedModes()); + Assertions.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().size()); + Assertions.assertNotNull(subNetwork.getNodes().get(f.nodeIds[4]).getInLinks().get(f.linkIds[13])); + Assertions.assertEquals(1, subNetwork.getNodes().get(f.nodeIds[4]).getOutLinks().size()); + Assertions.assertNotNull(subNetwork.getNodes().get(f.nodeIds[4]).getOutLinks().get(f.linkIds[14])); } @Test @@ -267,8 +267,8 @@ void testFilter_NoCommonModes() { Network subNetwork = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getNetwork(); filter.filter(subNetwork, createHashSet(TransportMode.pt, "motorbike")); - Assert.assertEquals("wrong number of nodes.", 0, subNetwork.getNodes().size()); - Assert.assertEquals("wrong number of links", 0, subNetwork.getLinks().size()); + Assertions.assertEquals(0, subNetwork.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(0, subNetwork.getLinks().size(), "wrong number of links"); } /** @@ -298,9 +298,9 @@ void testFilter_SingleMode_loop() { Network subNetwork = ScenarioUtils.createScenario(ConfigUtils.createConfig()).getNetwork(); filter.filter(subNetwork, createHashSet(TransportMode.car)); - Assert.assertEquals("wrong number of nodes.", 1, subNetwork.getNodes().size()); - Assert.assertEquals("wrong number of links", 1, subNetwork.getLinks().size()); - Assert.assertTrue(subNetwork.getLinks().containsKey(Id.create(1, Link.class))); + Assertions.assertEquals(1, subNetwork.getNodes().size(), "wrong number of nodes."); + Assertions.assertEquals(1, subNetwork.getLinks().size(), "wrong number of links"); + Assertions.assertTrue(subNetwork.getLinks().containsKey(Id.create(1, Link.class))); } /** @@ -327,18 +327,18 @@ void testFilter_timeVariant() { changeEvent.addLink(sourceLink); ((TimeDependentNetwork) sourceNetwork).addNetworkChangeEvent(changeEvent); - Assert.assertEquals(50.0, sourceLink.getFreespeed(), 1e-3); - Assert.assertEquals(50.0, sourceLink.getFreespeed(0.0), 1e-3); - Assert.assertEquals(100.0, sourceLink.getFreespeed(120.0), 1e-3); + Assertions.assertEquals(50.0, sourceLink.getFreespeed(), 1e-3); + Assertions.assertEquals(50.0, sourceLink.getFreespeed(0.0), 1e-3); + Assertions.assertEquals(100.0, sourceLink.getFreespeed(120.0), 1e-3); Network targetNetwork = NetworkUtils.createNetwork(config); new TransportModeNetworkFilter(sourceNetwork).filter(targetNetwork, Collections.singleton("car")); Link targetLink = targetNetwork.getLinks().get(sourceLink.getId()); - Assert.assertEquals(50.0, targetLink.getFreespeed(), 1e-3); - Assert.assertEquals(50.0, targetLink.getFreespeed(0.0), 1e-3); - Assert.assertEquals(100.0, targetLink.getFreespeed(120.0), 1e-3); + Assertions.assertEquals(50.0, targetLink.getFreespeed(), 1e-3); + Assertions.assertEquals(50.0, targetLink.getFreespeed(0.0), 1e-3); + Assertions.assertEquals(100.0, targetLink.getFreespeed(120.0), 1e-3); } /** diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/DensityClusterTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/DensityClusterTest.java index 6299e3dd572..b469de5af5b 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/DensityClusterTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/DensityClusterTest.java @@ -23,7 +23,7 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -51,13 +51,13 @@ void testDJCluster(){ DensityCluster djc = new DensityCluster(al, false); djc.clusterInput(2, 3); - Assert.assertEquals("There should only be two clusters", 2, djc.getClusterList().size()); + Assertions.assertEquals(2, djc.getClusterList().size(), "There should only be two clusters"); int small = Math.min(djc.getClusterList().get(0).getPoints().size(), djc.getClusterList().get(1).getPoints().size()); int large = Math.max(djc.getClusterList().get(0).getPoints().size(), djc.getClusterList().get(1).getPoints().size()); - Assert.assertEquals("The small cluster must have 4 points.", 4, small); - Assert.assertEquals("The large cluster must have 8 points.", 8, large); + Assertions.assertEquals(4, small, "The small cluster must have 4 points."); + Assertions.assertEquals(8, large, "The large cluster must have 8 points."); } diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/HullConverterTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/HullConverterTest.java index b5964c3c526..1cb622d8654 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/HullConverterTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/HullConverterTest.java @@ -19,7 +19,7 @@ package org.matsim.core.network.algorithms.intersectionSimplifier; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.GeometryFactory; @@ -49,7 +49,7 @@ void testConvertString(){ Object o = new Integer(0); HullConverter hc = new HullConverter(); String s = hc.convertToString(o); - Assert.assertTrue("Should receive empty string", s.isEmpty()); + Assertions.assertTrue(s.isEmpty(), "Should receive empty string"); /* Check String. */ GeometryFactory gf = new GeometryFactory(); @@ -64,7 +64,7 @@ void testConvertString(){ Point point = gf.createPoint(ca[0]); s = hc.convertToString(point); String pointString = "(0.0;0.0)"; - Assert.assertTrue("Wrong string for point.", pointString.equalsIgnoreCase(s)); + Assertions.assertTrue(pointString.equalsIgnoreCase(s), "Wrong string for point."); /* Line */ Coordinate[] ca2 = new Coordinate[2]; @@ -73,13 +73,13 @@ void testConvertString(){ LineString line = gf.createLineString(ca2); s = hc.convertToString(line); String lineString = "(0.0;0.0),(5.0;0.0)"; - Assert.assertTrue("Wrong string for line.", lineString.equalsIgnoreCase(s)); + Assertions.assertTrue(lineString.equalsIgnoreCase(s), "Wrong string for line."); /* Polygon */ Polygon polygon = gf.createPolygon(ca); s = hc.convertToString(polygon); String polygonString = "(0.0;0.0),(5.0;0.0),(5.0;5.0),(0.0;5.0),(0.0;0.0)"; - Assert.assertTrue("Wrong string for polygon.", polygonString.equalsIgnoreCase(s)); + Assertions.assertTrue(polygonString.equalsIgnoreCase(s), "Wrong string for polygon."); } @@ -104,18 +104,18 @@ void testConstructor(){ /* Point */ Point point = gf.createPoint(ca[0]); - Assert.assertEquals("Wrong point.", point, hc.convert(hc.convertToString(point))); + Assertions.assertEquals(point, hc.convert(hc.convertToString(point)), "Wrong point."); /* Line */ Coordinate[] ca2 = new Coordinate[2]; ca2[0] = ca[0]; ca2[1] = ca[1]; LineString line = gf.createLineString(ca2); - Assert.assertEquals("Wrong line.", line, hc.convert(hc.convertToString(line))); + Assertions.assertEquals(line, hc.convert(hc.convertToString(line)), "Wrong line."); /* Polygon */ Polygon polygon = gf.createPolygon(ca); - Assert.assertEquals("Wrong polygon.", polygon, hc.convert(hc.convertToString(polygon))); + Assertions.assertEquals(polygon, hc.convert(hc.convertToString(polygon)), "Wrong polygon."); } diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/IntersectionSimplifierTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/IntersectionSimplifierTest.java index 035a913d729..e1022df371a 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/IntersectionSimplifierTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/IntersectionSimplifierTest.java @@ -24,7 +24,7 @@ import java.util.Iterator; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -50,11 +50,11 @@ void testComplexIntersection() { network = buildComplexIntersection(); new NetworkWriter(network).write(utils.getOutputDirectory() + "network.xml.gz"); } catch (Exception e) { - Assert.fail("Should build and write without exception."); + Assertions.fail("Should build and write without exception."); } - Assert.assertEquals("Wrong number of nodes", 28, network.getNodes().size()); - Assert.assertEquals("Wrong number of links", 50, network.getLinks().size()); + Assertions.assertEquals(28, network.getNodes().size(), "Wrong number of nodes"); + Assertions.assertEquals(50, network.getLinks().size(), "Wrong number of links"); } @Test @@ -65,12 +65,12 @@ void testSimplifyCallOnlyOnce() { is.simplify(network); is.writeClustersToFile(utils.getOutputDirectory() + "clusters.csv"); } catch(Exception e) { - Assert.fail("Should not throw exceptions when simplifying network."); + Assertions.fail("Should not throw exceptions when simplifying network."); } try { is.simplify(network); - Assert.fail("Should not allow to simplify a network more than once"); + Assertions.fail("Should not allow to simplify a network more than once"); } catch(Exception e) { /* Pass. */ e.printStackTrace(); @@ -85,17 +85,17 @@ void testGetClusteredNode() { /* Test before simplifying. */ Node n = network.getNodes().get(Id.createNodeId(5)); - Assert.assertNull("Cannot be clustered before simplification was done.", is.getClusteredNode(n)); + Assertions.assertNull(is.getClusteredNode(n), "Cannot be clustered before simplification was done."); /* Test after simplifying. */ is.simplify(network); is.writeClustersToFile(utils.getOutputDirectory() + "clusters.csv"); Node centroid = is.getClusteredNode(n); - Assert.assertNotNull("Must be associated with a cluster.", centroid); + Assertions.assertNotNull(centroid, "Must be associated with a cluster."); Coord centroidCoord = CoordUtils.createCoord(85.0, 85.0); - Assert.assertTrue("Wrong centroid Coord.", centroidCoord.equals(centroid.getCoord())); - Assert.assertTrue("Wrong centroid Id (does not contain \"-\" separator between merged node ids).", centroid.getId().toString().contains("-")); + Assertions.assertTrue(centroidCoord.equals(centroid.getCoord()), "Wrong centroid Coord."); + Assertions.assertTrue(centroid.getId().toString().contains("-"), "Wrong centroid Id (does not contain \"-\" separator between merged node ids)."); } @@ -106,16 +106,16 @@ void testSimplifyOne() { Network simpleNetwork = is.simplify(network); is.writeClustersToFile(utils.getOutputDirectory() + "clusters.csv"); List clusters = is.getClusters(); - Assert.assertEquals("Wrong number of clusters", 6l, clusters.size()); + Assertions.assertEquals(6l, clusters.size(), "Wrong number of clusters"); /* Check some clusters. */ Cluster c1 = findCluster(clusters, CoordUtils.createCoord(85.0, 85.0)); - Assert.assertNotNull("Could not find a cluster with centroid (85.0,85.0)", c1); - Assert.assertEquals("Wrong number of points", 4, c1.getPoints().size()); + Assertions.assertNotNull(c1, "Could not find a cluster with centroid (85.0,85.0)"); + Assertions.assertEquals(4, c1.getPoints().size(), "Wrong number of points"); Cluster c2 = findCluster(clusters, CoordUtils.createCoord(225.0, 85.0)); - Assert.assertNotNull("Could not find cluster with centroid (225.0,85.0)", c2); - Assert.assertEquals("Wrong number of points", 4, c2.getPoints().size()); + Assertions.assertNotNull(c2, "Could not find cluster with centroid (225.0,85.0)"); + Assertions.assertEquals(4, c2.getPoints().size(), "Wrong number of points"); /* Write the cleaned network to file. */ new NetworkWriter(simpleNetwork).write(utils.getOutputDirectory() + "cleanNetwork.xml"); @@ -128,16 +128,16 @@ void testSimplifyTwo() { Network simpleNetwork = is.simplify(network); is.writeClustersToFile(utils.getOutputDirectory() + "clusters.csv"); List clusters = is.getClusters(); - Assert.assertEquals("Wrong number of clusters", 2l, clusters.size()); + Assertions.assertEquals(2l, clusters.size(), "Wrong number of clusters"); /* Check some clusters. */ Cluster c1 = findCluster(clusters, CoordUtils.createCoord(85.0, 85.0)); - Assert.assertNotNull("Could not find cluster with centroid (85.0,85.0)", c1); - Assert.assertEquals("Wrong number of points", 4, c1.getPoints().size()); + Assertions.assertNotNull(c1, "Could not find cluster with centroid (85.0,85.0)"); + Assertions.assertEquals(4, c1.getPoints().size(), "Wrong number of points"); Cluster c2 = findCluster(clusters, CoordUtils.createCoord(225.0, 85.0)); - Assert.assertNotNull("Could not find cluster with centroid (225.0,85.0)", c2); - Assert.assertEquals("Wrong number of points", 12, c2.getPoints().size()); + Assertions.assertNotNull(c2, "Could not find cluster with centroid (225.0,85.0)"); + Assertions.assertEquals(12, c2.getPoints().size(), "Wrong number of points"); /* Write the cleaned network to file. */ new NetworkWriter(simpleNetwork).write(utils.getOutputDirectory() + "cleanNetwork.xml"); @@ -157,28 +157,28 @@ void testNetworkCleaner() { new NetworkCleaner().run(simpleNetwork); new NetworkWriter(simpleNetwork).write(utils.getOutputDirectory() + "network2.xml"); - Assert.assertEquals("Wrong number of nodes.", 18l, simpleNetwork.getNodes().size()); - - Assert.assertNotNull("Should find node '1'", simpleNetwork.getNodes().get(Id.createNodeId("1"))); - Assert.assertNotNull("Should find node '3'", simpleNetwork.getNodes().get(Id.createNodeId("3"))); - Assert.assertNotNull("Should find node '10'", simpleNetwork.getNodes().get(Id.createNodeId("10"))); - Assert.assertNotNull("Should find node '11'", simpleNetwork.getNodes().get(Id.createNodeId("11"))); - Assert.assertNotNull("Should find node '26'", simpleNetwork.getNodes().get(Id.createNodeId("26"))); - Assert.assertNotNull("Should find node '28'", simpleNetwork.getNodes().get(Id.createNodeId("28"))); - - Assert.assertNotNull("Should find node '2'", simpleNetwork.getNodes().get(Id.createNodeId("2"))); - Assert.assertNotNull("Should find node '4'", simpleNetwork.getNodes().get(Id.createNodeId("4"))); - Assert.assertNotNull("Should find node '9'", simpleNetwork.getNodes().get(Id.createNodeId("9"))); - Assert.assertNotNull("Should find node '12'", simpleNetwork.getNodes().get(Id.createNodeId("12"))); - Assert.assertNotNull("Should find node '25'", simpleNetwork.getNodes().get(Id.createNodeId("25"))); - Assert.assertNotNull("Should find node '27'", simpleNetwork.getNodes().get(Id.createNodeId("27"))); - - Assert.assertNotNull("Should find simplified node '5-6-7-8'", simpleNetwork.getNodes().get(Id.createNodeId("5-6-7-8"))); - Assert.assertNotNull("Should find simplified node '13-14'", simpleNetwork.getNodes().get(Id.createNodeId("13-14"))); - Assert.assertNotNull("Should find simplified node '16-17-20-21'", simpleNetwork.getNodes().get(Id.createNodeId("16-17-20-21"))); - Assert.assertNotNull("Should find simplified node '18-22'", simpleNetwork.getNodes().get(Id.createNodeId("18-22"))); - Assert.assertNotNull("Should find simplified node '15-19'", simpleNetwork.getNodes().get(Id.createNodeId("15-19"))); - Assert.assertNotNull("Should find simplified node '23-24'", simpleNetwork.getNodes().get(Id.createNodeId("23-24"))); + Assertions.assertEquals(18l, simpleNetwork.getNodes().size(), "Wrong number of nodes."); + + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("1")), "Should find node '1'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("3")), "Should find node '3'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("10")), "Should find node '10'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("11")), "Should find node '11'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("26")), "Should find node '26'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("28")), "Should find node '28'"); + + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("2")), "Should find node '2'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("4")), "Should find node '4'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("9")), "Should find node '9'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("12")), "Should find node '12'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("25")), "Should find node '25'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("27")), "Should find node '27'"); + + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("5-6-7-8")), "Should find simplified node '5-6-7-8'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("13-14")), "Should find simplified node '13-14'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("16-17-20-21")), "Should find simplified node '16-17-20-21'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("18-22")), "Should find simplified node '18-22'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("15-19")), "Should find simplified node '15-19'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("23-24")), "Should find simplified node '23-24'"); } @Test @@ -195,28 +195,28 @@ void testNetworkSimplifier() { new NetworkCleaner().run(simpleNetwork); new NetworkWriter(simpleNetwork).write(utils.getOutputDirectory() + "network.xml"); - Assert.assertEquals("Wrong number of nodes.", 12l, simpleNetwork.getNodes().size()); - - Assert.assertNotNull("Should find node '1'", simpleNetwork.getNodes().get(Id.createNodeId("1"))); - Assert.assertNotNull("Should find node '3'", simpleNetwork.getNodes().get(Id.createNodeId("3"))); - Assert.assertNotNull("Should find node '10'", simpleNetwork.getNodes().get(Id.createNodeId("10"))); - Assert.assertNotNull("Should find node '11'", simpleNetwork.getNodes().get(Id.createNodeId("11"))); - Assert.assertNotNull("Should find node '26'", simpleNetwork.getNodes().get(Id.createNodeId("26"))); - Assert.assertNotNull("Should find node '28'", simpleNetwork.getNodes().get(Id.createNodeId("28"))); - - Assert.assertNull("Should NOT find node '2'", simpleNetwork.getNodes().get(Id.createNodeId("2"))); - Assert.assertNull("Should NOT find node '4'", simpleNetwork.getNodes().get(Id.createNodeId("4"))); - Assert.assertNull("Should NOT find node '9'", simpleNetwork.getNodes().get(Id.createNodeId("9"))); - Assert.assertNull("Should NOT find node '12'", simpleNetwork.getNodes().get(Id.createNodeId("12"))); - Assert.assertNull("Should NOT find node '25'", simpleNetwork.getNodes().get(Id.createNodeId("25"))); - Assert.assertNull("Should NOT find node '27'", simpleNetwork.getNodes().get(Id.createNodeId("27"))); - - Assert.assertNotNull("Should find simplified node '5-6-7-8'", simpleNetwork.getNodes().get(Id.createNodeId("5-6-7-8"))); - Assert.assertNotNull("Should find simplified node '13-14'", simpleNetwork.getNodes().get(Id.createNodeId("13-14"))); - Assert.assertNotNull("Should find simplified node '16-17-20-21'", simpleNetwork.getNodes().get(Id.createNodeId("16-17-20-21"))); - Assert.assertNotNull("Should find simplified node '18-22'", simpleNetwork.getNodes().get(Id.createNodeId("18-22"))); - Assert.assertNotNull("Should find simplified node '15-19'", simpleNetwork.getNodes().get(Id.createNodeId("15-19"))); - Assert.assertNotNull("Should find simplified node '23-24'", simpleNetwork.getNodes().get(Id.createNodeId("23-24"))); + Assertions.assertEquals(12l, simpleNetwork.getNodes().size(), "Wrong number of nodes."); + + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("1")), "Should find node '1'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("3")), "Should find node '3'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("10")), "Should find node '10'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("11")), "Should find node '11'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("26")), "Should find node '26'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("28")), "Should find node '28'"); + + Assertions.assertNull(simpleNetwork.getNodes().get(Id.createNodeId("2")), "Should NOT find node '2'"); + Assertions.assertNull(simpleNetwork.getNodes().get(Id.createNodeId("4")), "Should NOT find node '4'"); + Assertions.assertNull(simpleNetwork.getNodes().get(Id.createNodeId("9")), "Should NOT find node '9'"); + Assertions.assertNull(simpleNetwork.getNodes().get(Id.createNodeId("12")), "Should NOT find node '12'"); + Assertions.assertNull(simpleNetwork.getNodes().get(Id.createNodeId("25")), "Should NOT find node '25'"); + Assertions.assertNull(simpleNetwork.getNodes().get(Id.createNodeId("27")), "Should NOT find node '27'"); + + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("5-6-7-8")), "Should find simplified node '5-6-7-8'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("13-14")), "Should find simplified node '13-14'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("16-17-20-21")), "Should find simplified node '16-17-20-21'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("18-22")), "Should find simplified node '18-22'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("15-19")), "Should find simplified node '15-19'"); + Assertions.assertNotNull(simpleNetwork.getNodes().get(Id.createNodeId("23-24")), "Should find simplified node '23-24'"); } diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/containers/ConcaveHullTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/containers/ConcaveHullTest.java index 35c3cfd024d..a8dd27702a6 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/containers/ConcaveHullTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/intersectionSimplifier/containers/ConcaveHullTest.java @@ -19,7 +19,7 @@ package org.matsim.core.network.algorithms.intersectionSimplifier.containers; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.locationtech.jts.geom.Coordinate; @@ -38,11 +38,11 @@ public class ConcaveHullTest { void testConstructor(){ GeometryCollection gcIncorrect = setupWithDuplicates(); ConcaveHull ch1 = new ConcaveHull(gcIncorrect, 2); - Assert.assertEquals("Duplicates not removed.", 8, ch1.getInputPoints()); + Assertions.assertEquals(8, ch1.getInputPoints(), "Duplicates not removed."); GeometryCollection gcCorrect = setup(); ConcaveHull ch2 = new ConcaveHull(gcCorrect, 2); - Assert.assertEquals("Wrong number of input points.", 8, ch2.getInputPoints()); + Assertions.assertEquals(8, ch2.getInputPoints(), "Wrong number of input points."); } @@ -50,7 +50,7 @@ public void testGetConcaveHull(){ GeometryCollection gc = setup(); ConcaveHull ch = new ConcaveHull(gc, 1.0); Geometry g = ch.getConcaveHull(); - Assert.assertTrue("Wrong geometry created.", g instanceof Polygon); + Assertions.assertTrue(g instanceof Polygon, "Wrong geometry created."); } diff --git a/matsim/src/test/java/org/matsim/core/network/filter/NetworkFilterManagerTest.java b/matsim/src/test/java/org/matsim/core/network/filter/NetworkFilterManagerTest.java index 8796cc67bc4..16d9b4283cb 100644 --- a/matsim/src/test/java/org/matsim/core/network/filter/NetworkFilterManagerTest.java +++ b/matsim/src/test/java/org/matsim/core/network/filter/NetworkFilterManagerTest.java @@ -21,8 +21,8 @@ package org.matsim.core.network.filter; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -109,19 +109,19 @@ public boolean judgeLink(Link l) { Network filteredNetwork = networkFilterManager.applyFilters(); - Assert.assertEquals(2, filteredNetwork.getNodes().size()); - Assert.assertTrue("must be added by nodefilter", filteredNetwork.getNodes().containsKey(Id.createNodeId("a"))); - Assert.assertTrue("must be added for ab link", filteredNetwork.getNodes().containsKey(Id.createNodeId("b"))); + Assertions.assertEquals(2, filteredNetwork.getNodes().size()); + Assertions.assertTrue(filteredNetwork.getNodes().containsKey(Id.createNodeId("a")), "must be added by nodefilter"); + Assertions.assertTrue(filteredNetwork.getNodes().containsKey(Id.createNodeId("b")), "must be added for ab link"); - Assert.assertEquals(1, filteredNetwork.getLinks().size()); + Assertions.assertEquals(1, filteredNetwork.getLinks().size()); Link ab = filteredNetwork.getLinks().get(Id.createLinkId("ab")); - Assert.assertEquals(CAPACITY, ab.getCapacity(), DELTA); - Assert.assertEquals(FREESPEED, ab.getFreespeed(), DELTA); - Assert.assertEquals(LENGTH, ab.getLength(), DELTA); - Assert.assertEquals(NR_OF_LANES, ab.getNumberOfLanes(), DELTA); - Assert.assertEquals(ATTRIBUTE_VALUE, ab.getAttributes().getAttribute(ATTRIBUTE_KEY)); - Assert.assertEquals(ATTRIBUTE_VALUE2, ab.getAttributes().getAttribute(ATTRIBUTE_KEY2)); + Assertions.assertEquals(CAPACITY, ab.getCapacity(), DELTA); + Assertions.assertEquals(FREESPEED, ab.getFreespeed(), DELTA); + Assertions.assertEquals(LENGTH, ab.getLength(), DELTA); + Assertions.assertEquals(NR_OF_LANES, ab.getNumberOfLanes(), DELTA); + Assertions.assertEquals(ATTRIBUTE_VALUE, ab.getAttributes().getAttribute(ATTRIBUTE_KEY)); + Assertions.assertEquals(ATTRIBUTE_VALUE2, ab.getAttributes().getAttribute(ATTRIBUTE_KEY2)); } } diff --git a/matsim/src/test/java/org/matsim/core/network/io/NetworkAttributeConversionTest.java b/matsim/src/test/java/org/matsim/core/network/io/NetworkAttributeConversionTest.java index 313018fab00..9822c44b7e5 100644 --- a/matsim/src/test/java/org/matsim/core/network/io/NetworkAttributeConversionTest.java +++ b/matsim/src/test/java/org/matsim/core/network/io/NetworkAttributeConversionTest.java @@ -21,7 +21,7 @@ package org.matsim.core.network.io; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -34,7 +34,7 @@ import java.util.Objects; import java.util.function.Consumer; - public class NetworkAttributeConversionTest { + public class NetworkAttributeConversionTest { @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @@ -73,10 +73,10 @@ public void testWriteAndReread( final Network readNetwork = readScenario.getNetwork(); final Object readAttribute = readNetwork.getAttributes().getAttribute("attribute"); - Assert.assertEquals( - "unexpected read attribute", + Assertions.assertEquals( attribute, - readAttribute); + readAttribute, + "unexpected read attribute"); } private static class CustomClass { diff --git a/matsim/src/test/java/org/matsim/core/network/io/NetworkReaderMatsimV1Test.java b/matsim/src/test/java/org/matsim/core/network/io/NetworkReaderMatsimV1Test.java index 05795477641..04d357f7286 100644 --- a/matsim/src/test/java/org/matsim/core/network/io/NetworkReaderMatsimV1Test.java +++ b/matsim/src/test/java/org/matsim/core/network/io/NetworkReaderMatsimV1Test.java @@ -20,7 +20,7 @@ package org.matsim.core.network.io; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.Set; import java.util.Stack; @@ -53,14 +53,14 @@ public class NetworkReaderMatsimV1Test { void testAllowedModes_singleMode() { Link link = prepareTestAllowedModes("car"); Set modes = link.getAllowedModes(); - assertEquals("wrong number of allowed modes.", 1, modes.size()); - assertTrue("wrong mode.", modes.contains(TransportMode.car)); + assertEquals(1, modes.size(), "wrong number of allowed modes."); + assertTrue(modes.contains(TransportMode.car), "wrong mode."); // make sure we do not just get some default-value back... link = prepareTestAllowedModes("bike"); modes = link.getAllowedModes(); - assertEquals("wrong number of allowed modes.", 1, modes.size()); - assertTrue("wrong mode.", modes.contains(TransportMode.bike)); + assertEquals(1, modes.size(), "wrong number of allowed modes."); + assertTrue(modes.contains(TransportMode.bike), "wrong mode."); } /** @@ -70,7 +70,7 @@ void testAllowedModes_singleMode() { void testAllowedModes_emptyMode() { Link link = prepareTestAllowedModes(""); Set modes = link.getAllowedModes(); - assertEquals("wrong number of allowed modes.", 0, modes.size()); + assertEquals(0, modes.size(), "wrong number of allowed modes."); } /** @@ -80,22 +80,22 @@ void testAllowedModes_emptyMode() { void testAllowedModes_multipleModes() { Link link = prepareTestAllowedModes("car,bus"); Set modes = link.getAllowedModes(); - assertEquals("wrong number of allowed modes.", 2, modes.size()); - assertTrue("wrong mode.", modes.contains(TransportMode.car)); - assertTrue("wrong mode.", modes.contains("bus")); + assertEquals(2, modes.size(), "wrong number of allowed modes."); + assertTrue(modes.contains(TransportMode.car), "wrong mode."); + assertTrue(modes.contains("bus"), "wrong mode."); link = prepareTestAllowedModes("bike,bus,walk"); modes = link.getAllowedModes(); - assertEquals("wrong number of allowed modes.", 3, modes.size()); - assertTrue("wrong mode.", modes.contains(TransportMode.bike)); - assertTrue("wrong mode.", modes.contains("bus")); - assertTrue("wrong mode.", modes.contains(TransportMode.walk)); + assertEquals(3, modes.size(), "wrong number of allowed modes."); + assertTrue(modes.contains(TransportMode.bike), "wrong mode."); + assertTrue(modes.contains("bus"), "wrong mode."); + assertTrue(modes.contains(TransportMode.walk), "wrong mode."); link = prepareTestAllowedModes("pt, train"); // test with space after comma modes = link.getAllowedModes(); - assertEquals("wrong number of allowed modes.", 2, modes.size()); - assertTrue("wrong mode.", modes.contains(TransportMode.pt)); - assertTrue("wrong mode.", modes.contains("train")); + assertEquals(2, modes.size(), "wrong number of allowed modes."); + assertTrue(modes.contains(TransportMode.pt), "wrong mode."); + assertTrue(modes.contains("train"), "wrong mode."); } /** @@ -131,9 +131,9 @@ private Link prepareTestAllowedModes(final String modes) { reader.startTag("link", atts, context); // start test - assertEquals("expected one link.", 1, network.getLinks().size()); + assertEquals(1, network.getLinks().size(), "expected one link."); Link link = network.getLinks().get(Id.create("1", Link.class)); - assertNotNull("expected link with id=1.", link); + assertNotNull(link, "expected link with id=1."); return link; } diff --git a/matsim/src/test/java/org/matsim/core/network/io/NetworkReprojectionIOTest.java b/matsim/src/test/java/org/matsim/core/network/io/NetworkReprojectionIOTest.java index b57fd8ab3f5..8398f1a7db1 100644 --- a/matsim/src/test/java/org/matsim/core/network/io/NetworkReprojectionIOTest.java +++ b/matsim/src/test/java/org/matsim/core/network/io/NetworkReprojectionIOTest.java @@ -21,7 +21,7 @@ package org.matsim.core.network.io; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -40,7 +40,7 @@ import org.matsim.core.utils.geometry.transformations.TransformationFactory; import org.matsim.testcases.MatsimTestUtils; - /** + /** * @author thibautd */ public class NetworkReprojectionIOTest { @@ -67,17 +67,17 @@ void testInput() { INITIAL_CRS, TARGET_CRS, readNetwork ).readFile( networkFile ); - Assert.assertEquals( - "unexpected network size", + Assertions.assertEquals( 2, - readNetwork.getNodes().size() ); + readNetwork.getNodes().size(), + "unexpected network size" ); for ( Node n : readNetwork.getNodes().values() ) { Node initialNode = initialNetwork.getNodes().get(n.getId()); - Assert.assertEquals( "Unexpected coordinate", - transformation.transform(initialNode.getCoord()), - n.getCoord() ); + Assertions.assertEquals( transformation.transform(initialNode.getCoord()), + n.getCoord(), + "Unexpected coordinate" ); } } @@ -95,17 +95,17 @@ void testOutput() { new MatsimNetworkReader( readNetwork ).readFile( networkFile ); - Assert.assertEquals( - "unexpected network size", + Assertions.assertEquals( 2, - readNetwork.getNodes().size() ); + readNetwork.getNodes().size(), + "unexpected network size" ); for ( Node n : readNetwork.getNodes().values() ) { Node initialNode = initialNetwork.getNodes().get(n.getId()); - Assert.assertEquals( - "Unexpected coordinate", + Assertions.assertEquals( transformation.transform(initialNode.getCoord()), - n.getCoord() ); + n.getCoord(), + "Unexpected coordinate" ); } } @@ -132,16 +132,16 @@ void testWithControlerAndAttributes() { final Coord originalCoord = initialNetwork.getNodes().get( id ).getCoord(); final Coord internalCoord = scenario.getNetwork().getNodes().get( id ).getCoord(); - Assert.assertEquals( - "No coordinates transform performed!", + Assertions.assertEquals( transformation.transform(originalCoord), - internalCoord); + internalCoord, + "No coordinates transform performed!"); } - Assert.assertEquals( - "wrong CRS information after loading", + Assertions.assertEquals( TARGET_CRS, - ProjectionUtils.getCRS(scenario.getNetwork())); + ProjectionUtils.getCRS(scenario.getNetwork()), + "wrong CRS information after loading"); config.controller().setLastIteration( 0 ); final String outputDirectory = utils.getOutputDirectory()+"/output/"; @@ -156,10 +156,10 @@ void testWithControlerAndAttributes() { final Coord internalCoord = scenario.getNetwork().getNodes().get( id ).getCoord(); final Coord dumpedCoord = dumpedNetwork.getNodes().get( id ).getCoord(); - Assert.assertEquals( - "coordinates were reprojected for dump", + Assertions.assertEquals( internalCoord, - dumpedCoord); + dumpedCoord, + "coordinates were reprojected for dump"); } } @@ -185,16 +185,16 @@ void testWithControlerAndConfigParameters() { final Coord originalCoord = initialNetwork.getNodes().get( id ).getCoord(); final Coord internalCoord = scenario.getNetwork().getNodes().get( id ).getCoord(); - Assert.assertNotEquals( - "No coordinates transform performed!", + Assertions.assertNotEquals( originalCoord.getX(), internalCoord.getX(), - MatsimTestUtils.EPSILON ); - Assert.assertNotEquals( - "No coordinates transform performed!", + MatsimTestUtils.EPSILON, + "No coordinates transform performed!" ); + Assertions.assertNotEquals( originalCoord.getY(), internalCoord.getY(), - MatsimTestUtils.EPSILON ); + MatsimTestUtils.EPSILON, + "No coordinates transform performed!" ); } config.controller().setLastIteration( 0 ); @@ -210,16 +210,16 @@ void testWithControlerAndConfigParameters() { final Coord originalCoord = initialNetwork.getNodes().get( id ).getCoord(); final Coord dumpedCoord = dumpedNetwork.getNodes().get( id ).getCoord(); - Assert.assertNotEquals( - "coordinates were reprojected for dump", + Assertions.assertNotEquals( originalCoord.getX(), dumpedCoord.getX(), - MatsimTestUtils.EPSILON ); - Assert.assertNotEquals( - "coordinates were reprojected for dump", + MatsimTestUtils.EPSILON, + "coordinates were reprojected for dump" ); + Assertions.assertNotEquals( originalCoord.getY(), dumpedCoord.getY(), - MatsimTestUtils.EPSILON ); + MatsimTestUtils.EPSILON, + "coordinates were reprojected for dump" ); } } diff --git a/matsim/src/test/java/org/matsim/core/population/PersonImplTest.java b/matsim/src/test/java/org/matsim/core/population/PersonImplTest.java index 7b63c140391..66919058253 100644 --- a/matsim/src/test/java/org/matsim/core/population/PersonImplTest.java +++ b/matsim/src/test/java/org/matsim/core/population/PersonImplTest.java @@ -20,7 +20,7 @@ package org.matsim.core.population; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -106,12 +106,12 @@ void testRemoveUnselectedPlans() { Plan selPlan = PersonUtils.createAndAddPlan(person, true); PersonUtils.createAndAddPlan(person, false); - assertEquals("person should have 4 plans.", 4, person.getPlans().size()); + assertEquals(4, person.getPlans().size(), "person should have 4 plans."); PersonUtils.removeUnselectedPlans(person); - assertEquals("person should have 1 plan.", 1, person.getPlans().size()); - assertEquals("remaining plan should be selPlan.", selPlan, person.getPlans().get(0)); + assertEquals(1, person.getPlans().size(), "person should have 1 plan."); + assertEquals(selPlan, person.getPlans().get(0), "remaining plan should be selPlan."); } @Test @@ -123,21 +123,21 @@ void testRemovePlan() { Plan p4 = PersonUtils.createAndAddPlan(person, false); Plan p5 = PopulationUtils.createPlan(null); - assertEquals("wrong number of plans.", 4, person.getPlans().size()); - assertEquals("expected different selected plan.", p2, person.getSelectedPlan()); + assertEquals(4, person.getPlans().size(), "wrong number of plans."); + assertEquals(p2, person.getSelectedPlan(), "expected different selected plan."); assertTrue(person.removePlan(p3)); - assertEquals("wrong number of plans.", 3, person.getPlans().size()); - assertEquals("expected different selected plan.", p2, person.getSelectedPlan()); + assertEquals(3, person.getPlans().size(), "wrong number of plans."); + assertEquals(p2, person.getSelectedPlan(), "expected different selected plan."); assertFalse(person.removePlan(p5)); - assertEquals("wrong number of plans.", 3, person.getPlans().size()); + assertEquals(3, person.getPlans().size(), "wrong number of plans."); assertTrue(person.removePlan(p2)); - assertEquals("wrong number of plans.", 2, person.getPlans().size()); - assertNotSame("removed plan still set as selected.", p2, person.getSelectedPlan()); - assertFalse("plan cannot be removed twice.", person.removePlan(p2)); - assertEquals("wrong number of plans.", 2, person.getPlans().size()); + assertEquals(2, person.getPlans().size(), "wrong number of plans."); + assertNotSame(p2, person.getSelectedPlan(), "removed plan still set as selected."); + assertFalse(person.removePlan(p2), "plan cannot be removed twice."); + assertEquals(2, person.getPlans().size(), "wrong number of plans."); assertTrue(person.removePlan(p1)); assertTrue(person.removePlan(p4)); - assertEquals("wrong number of plans.", 0, person.getPlans().size()); + assertEquals(0, person.getPlans().size(), "wrong number of plans."); } @Test diff --git a/matsim/src/test/java/org/matsim/core/population/PlanImplTest.java b/matsim/src/test/java/org/matsim/core/population/PlanImplTest.java index b818a7ec02c..fb76825f3d7 100644 --- a/matsim/src/test/java/org/matsim/core/population/PlanImplTest.java +++ b/matsim/src/test/java/org/matsim/core/population/PlanImplTest.java @@ -20,11 +20,11 @@ package org.matsim.core.population; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -235,8 +235,8 @@ void testCopyPlan_NetworkRoute() { Plan plan2 = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(2, Person.class))); PopulationUtils.copyFromTo(plan, plan2); - assertEquals("person must not be copied.", Id.create(2, Person.class), plan2.getPerson().getId()); - assertEquals("wrong number of plan elements.", plan.getPlanElements().size(), plan2.getPlanElements().size()); + assertEquals(Id.create(2, Person.class), plan2.getPerson().getId(), "person must not be copied."); + assertEquals(plan.getPlanElements().size(), plan2.getPlanElements().size(), "wrong number of plan elements."); Route route2 = ((Leg) plan.getPlanElements().get(1)).getRoute(); assertTrue(route2 instanceof NetworkRoute); assertEquals(98.76, route2.getTravelTime().seconds(), 1e-8); @@ -266,8 +266,8 @@ void testCopyPlan_GenericRoute() { Plan plan2 = PopulationUtils.createPlan(PopulationUtils.getFactory().createPerson(Id.create(2, Person.class))); PopulationUtils.copyFromTo(plan, plan2); - assertEquals("person must not be copied.", Id.create(2, Person.class), plan2.getPerson().getId()); - assertEquals("wrong number of plan elements.", plan.getPlanElements().size(), plan2.getPlanElements().size()); + assertEquals(Id.create(2, Person.class), plan2.getPerson().getId(), "person must not be copied."); + assertEquals(plan.getPlanElements().size(), plan2.getPlanElements().size(), "wrong number of plan elements."); Route route2 = ((Leg) plan.getPlanElements().get(1)).getRoute(); // assertTrue(route2 instanceof GenericRouteImpl); assertEquals(98.76, route2.getTravelTime().seconds(), 1e-8); @@ -321,12 +321,12 @@ void addMultipleLegs() { p.addLeg(PopulationUtils.createLeg(TransportMode.walk)); p.addActivity(new ActivityImpl("w")); - Assert.assertEquals(5, p.getPlanElements().size()); - Assert.assertTrue(p.getPlanElements().get(0) instanceof Activity); - Assert.assertTrue(p.getPlanElements().get(1) instanceof Leg); - Assert.assertTrue(p.getPlanElements().get(2) instanceof Leg); - Assert.assertTrue(p.getPlanElements().get(3) instanceof Leg); - Assert.assertTrue(p.getPlanElements().get(4) instanceof Activity); + Assertions.assertEquals(5, p.getPlanElements().size()); + Assertions.assertTrue(p.getPlanElements().get(0) instanceof Activity); + Assertions.assertTrue(p.getPlanElements().get(1) instanceof Leg); + Assertions.assertTrue(p.getPlanElements().get(2) instanceof Leg); + Assertions.assertTrue(p.getPlanElements().get(3) instanceof Leg); + Assertions.assertTrue(p.getPlanElements().get(4) instanceof Activity); } @Test @@ -337,11 +337,11 @@ void addMultipleActs() { p.addActivity(new ActivityImpl("w")); p.addActivity(new ActivityImpl("l")); - Assert.assertEquals(4, p.getPlanElements().size()); - Assert.assertTrue(p.getPlanElements().get(0) instanceof Activity); - Assert.assertTrue(p.getPlanElements().get(1) instanceof Leg); - Assert.assertTrue(p.getPlanElements().get(2) instanceof Activity); - Assert.assertTrue(p.getPlanElements().get(3) instanceof Activity); + Assertions.assertEquals(4, p.getPlanElements().size()); + Assertions.assertTrue(p.getPlanElements().get(0) instanceof Activity); + Assertions.assertTrue(p.getPlanElements().get(1) instanceof Leg); + Assertions.assertTrue(p.getPlanElements().get(2) instanceof Activity); + Assertions.assertTrue(p.getPlanElements().get(3) instanceof Activity); } @Test @@ -353,12 +353,12 @@ void createAndAddMultipleLegs() { PopulationUtils.createAndAddLeg( p, TransportMode.walk ); PopulationUtils.createAndAddActivity(p, "w"); - Assert.assertEquals(5, p.getPlanElements().size()); - Assert.assertTrue(p.getPlanElements().get(0) instanceof Activity); - Assert.assertTrue(p.getPlanElements().get(1) instanceof Leg); - Assert.assertTrue(p.getPlanElements().get(2) instanceof Leg); - Assert.assertTrue(p.getPlanElements().get(3) instanceof Leg); - Assert.assertTrue(p.getPlanElements().get(4) instanceof Activity); + Assertions.assertEquals(5, p.getPlanElements().size()); + Assertions.assertTrue(p.getPlanElements().get(0) instanceof Activity); + Assertions.assertTrue(p.getPlanElements().get(1) instanceof Leg); + Assertions.assertTrue(p.getPlanElements().get(2) instanceof Leg); + Assertions.assertTrue(p.getPlanElements().get(3) instanceof Leg); + Assertions.assertTrue(p.getPlanElements().get(4) instanceof Activity); } @Test @@ -369,11 +369,11 @@ void createAndAddMultipleActs() { PopulationUtils.createAndAddActivity(p, "w"); PopulationUtils.createAndAddActivity(p, "l"); - Assert.assertEquals(4, p.getPlanElements().size()); - Assert.assertTrue(p.getPlanElements().get(0) instanceof Activity); - Assert.assertTrue(p.getPlanElements().get(1) instanceof Leg); - Assert.assertTrue(p.getPlanElements().get(2) instanceof Activity); - Assert.assertTrue(p.getPlanElements().get(3) instanceof Activity); + Assertions.assertEquals(4, p.getPlanElements().size()); + Assertions.assertTrue(p.getPlanElements().get(0) instanceof Activity); + Assertions.assertTrue(p.getPlanElements().get(1) instanceof Leg); + Assertions.assertTrue(p.getPlanElements().get(2) instanceof Activity); + Assertions.assertTrue(p.getPlanElements().get(3) instanceof Activity); } } diff --git a/matsim/src/test/java/org/matsim/core/population/PopulationUtilsTest.java b/matsim/src/test/java/org/matsim/core/population/PopulationUtilsTest.java index 4b083a3fb9d..44520f6f8d0 100644 --- a/matsim/src/test/java/org/matsim/core/population/PopulationUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/population/PopulationUtilsTest.java @@ -21,7 +21,7 @@ package org.matsim.core.population; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -31,7 +31,7 @@ import org.matsim.core.population.io.PopulationReader; import org.matsim.core.scenario.ScenarioUtils; - /** + /** * @author thibautd */ public class PopulationUtilsTest { @@ -61,25 +61,25 @@ void testPlanAttributesCopy() { final Plan planCopy = population.getFactory().createPlan(); PopulationUtils.copyFromTo( plan , planCopy ); - Assert.assertEquals( "unexpected plan length", - plan.getPlanElements().size(), - planCopy.getPlanElements().size() ); + Assertions.assertEquals( plan.getPlanElements().size(), + planCopy.getPlanElements().size(), + "unexpected plan length" ); final Activity activityCopy = (Activity) planCopy.getPlanElements().get( 0 ); - Assert.assertEquals( "unexpected attribute", - act.getAttributes().getAttribute( "makes sense" ), - activityCopy.getAttributes().getAttribute( "makes sense" ) ); + Assertions.assertEquals( act.getAttributes().getAttribute( "makes sense" ), + activityCopy.getAttributes().getAttribute( "makes sense" ), + "unexpected attribute" ); - Assert.assertEquals( "unexpected attribute", - act.getAttributes().getAttribute( "length" ), - activityCopy.getAttributes().getAttribute( "length" ) ); + Assertions.assertEquals( act.getAttributes().getAttribute( "length" ), + activityCopy.getAttributes().getAttribute( "length" ), + "unexpected attribute" ); final Leg legCopy = (Leg) planCopy.getPlanElements().get( 1 ); - Assert.assertEquals( "unexpected attribute", - leg.getAttributes().getAttribute( "mpg" ), - legCopy.getAttributes().getAttribute( "mpg" ) ); + Assertions.assertEquals( leg.getAttributes().getAttribute( "mpg" ), + legCopy.getAttributes().getAttribute( "mpg" ), + "unexpected attribute" ); } } diff --git a/matsim/src/test/java/org/matsim/core/population/io/CompressedRoutesIntegrationTest.java b/matsim/src/test/java/org/matsim/core/population/io/CompressedRoutesIntegrationTest.java index 58072ae7794..8283432f096 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/CompressedRoutesIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/population/io/CompressedRoutesIntegrationTest.java @@ -19,7 +19,7 @@ package org.matsim.core.population.io; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -42,7 +42,7 @@ void testReadingPlansV4parallel() { Scenario s = ScenarioUtils.createScenario(config); new MatsimNetworkReader(s.getNetwork()).readFile("test/scenarios/equil/network.xml"); new ParallelPopulationReaderMatsimV4(s).readFile("test/scenarios/equil/plans1.xml"); - Assert.assertEquals(1, s.getPopulation().getPersons().size()); + Assertions.assertEquals(1, s.getPopulation().getPersons().size()); Leg firstPersonsLeg = (Leg) s.getPopulation().getPersons().get(Id.create("1", Person.class)).getSelectedPlan().getPlanElements().get(1); // Assert.assertTrue(firstPersonsLeg.getRoute() instanceof CompressedNetworkRouteImpl); } diff --git a/matsim/src/test/java/org/matsim/core/population/io/MatsimPopulationReaderTest.java b/matsim/src/test/java/org/matsim/core/population/io/MatsimPopulationReaderTest.java index 7bf327f170d..54dd30d5cd2 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/MatsimPopulationReaderTest.java +++ b/matsim/src/test/java/org/matsim/core/population/io/MatsimPopulationReaderTest.java @@ -21,7 +21,7 @@ import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -44,92 +44,92 @@ public class MatsimPopulationReaderTest { @Test void testReadFile_v4() { Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - Assert.assertEquals(0, s.getPopulation().getPersons().size()); + Assertions.assertEquals(0, s.getPopulation().getPersons().size()); new MatsimNetworkReader(s.getNetwork()).readFile("test/scenarios/equil/network.xml"); new PopulationReader(s).readFile("test/scenarios/equil/plans1.xml"); - Assert.assertEquals(1, s.getPopulation().getPersons().size()); + Assertions.assertEquals(1, s.getPopulation().getPersons().size()); } @Test void testReadFile_v5() { Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - Assert.assertEquals(0, s.getPopulation().getPersons().size()); + Assertions.assertEquals(0, s.getPopulation().getPersons().size()); new PopulationReader(s).readFile("test/input/org/matsim/core/utils/io/MatsimFileTypeGuesserTest/population_v5_example.xml"); - Assert.assertEquals(1, s.getPopulation().getPersons().size()); + Assertions.assertEquals(1, s.getPopulation().getPersons().size()); Person person = s.getPopulation().getPersons().get(Id.create(1, Person.class)); - Assert.assertNotNull(person); + Assertions.assertNotNull(person); Plan plan = person.getSelectedPlan(); List planElements = plan.getPlanElements(); - Assert.assertEquals(3, planElements.size()); + Assertions.assertEquals(3, planElements.size()); - Assert.assertTrue(planElements.get(0) instanceof Activity); - Assert.assertTrue(planElements.get(1) instanceof Leg); - Assert.assertTrue(planElements.get(2) instanceof Activity); + Assertions.assertTrue(planElements.get(0) instanceof Activity); + Assertions.assertTrue(planElements.get(1) instanceof Leg); + Assertions.assertTrue(planElements.get(2) instanceof Activity); } @Test void testReadFile_v5_multipleSuccessiveLegs() { Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - Assert.assertEquals(0, s.getPopulation().getPersons().size()); + Assertions.assertEquals(0, s.getPopulation().getPersons().size()); new PopulationReader(s).readFile("test/input/org/matsim/core/utils/io/MatsimFileTypeGuesserTest/population_v5_multipleLegs.xml"); - Assert.assertEquals(1, s.getPopulation().getPersons().size()); + Assertions.assertEquals(1, s.getPopulation().getPersons().size()); Person person = s.getPopulation().getPersons().get(Id.create(1, Person.class)); - Assert.assertNotNull(person); + Assertions.assertNotNull(person); Plan plan = person.getSelectedPlan(); List planElements = plan.getPlanElements(); - Assert.assertEquals(5, planElements.size()); + Assertions.assertEquals(5, planElements.size()); - Assert.assertTrue(planElements.get(0) instanceof Activity); - Assert.assertTrue(planElements.get(1) instanceof Leg); - Assert.assertTrue(planElements.get(2) instanceof Leg); - Assert.assertTrue(planElements.get(3) instanceof Leg); - Assert.assertTrue(planElements.get(4) instanceof Activity); + Assertions.assertTrue(planElements.get(0) instanceof Activity); + Assertions.assertTrue(planElements.get(1) instanceof Leg); + Assertions.assertTrue(planElements.get(2) instanceof Leg); + Assertions.assertTrue(planElements.get(3) instanceof Leg); + Assertions.assertTrue(planElements.get(4) instanceof Activity); } @Test void testReadFile_v5_multipleSuccessiveLegsWithRoutes() { Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - Assert.assertEquals(0, s.getPopulation().getPersons().size()); + Assertions.assertEquals(0, s.getPopulation().getPersons().size()); new PopulationReader(s).readFile("test/input/org/matsim/core/utils/io/MatsimFileTypeGuesserTest/population_v5_multipleLegsWithRoutes.xml"); - Assert.assertEquals(1, s.getPopulation().getPersons().size()); + Assertions.assertEquals(1, s.getPopulation().getPersons().size()); Person person = s.getPopulation().getPersons().get(Id.create(1, Person.class)); - Assert.assertNotNull(person); + Assertions.assertNotNull(person); Plan plan = person.getSelectedPlan(); List planElements = plan.getPlanElements(); - Assert.assertEquals(5, planElements.size()); + Assertions.assertEquals(5, planElements.size()); - Assert.assertTrue(planElements.get(0) instanceof Activity); - Assert.assertTrue(planElements.get(1) instanceof Leg); - Assert.assertEquals(Id.create("1", Link.class), ((Leg) planElements.get(1)).getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("2", Link.class), ((Leg) planElements.get(1)).getRoute().getEndLinkId()); - Assert.assertTrue(planElements.get(2) instanceof Leg); - Assert.assertEquals(Id.create("2", Link.class), ((Leg) planElements.get(2)).getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("4", Link.class), ((Leg) planElements.get(2)).getRoute().getEndLinkId()); - Assert.assertTrue(planElements.get(3) instanceof Leg); - Assert.assertEquals(Id.create("4", Link.class), ((Leg) planElements.get(3)).getRoute().getStartLinkId()); - Assert.assertEquals(Id.create("6", Link.class), ((Leg) planElements.get(3)).getRoute().getEndLinkId()); - Assert.assertTrue(planElements.get(4) instanceof Activity); + Assertions.assertTrue(planElements.get(0) instanceof Activity); + Assertions.assertTrue(planElements.get(1) instanceof Leg); + Assertions.assertEquals(Id.create("1", Link.class), ((Leg) planElements.get(1)).getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("2", Link.class), ((Leg) planElements.get(1)).getRoute().getEndLinkId()); + Assertions.assertTrue(planElements.get(2) instanceof Leg); + Assertions.assertEquals(Id.create("2", Link.class), ((Leg) planElements.get(2)).getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("4", Link.class), ((Leg) planElements.get(2)).getRoute().getEndLinkId()); + Assertions.assertTrue(planElements.get(3) instanceof Leg); + Assertions.assertEquals(Id.create("4", Link.class), ((Leg) planElements.get(3)).getRoute().getStartLinkId()); + Assertions.assertEquals(Id.create("6", Link.class), ((Leg) planElements.get(3)).getRoute().getEndLinkId()); + Assertions.assertTrue(planElements.get(4) instanceof Activity); } @Test void testReadFile_v5_multipleSuccessiveLegsWithTeleportation() { Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - Assert.assertEquals(0, s.getPopulation().getPersons().size()); + Assertions.assertEquals(0, s.getPopulation().getPersons().size()); new PopulationReader(s).readFile("test/input/org/matsim/core/utils/io/MatsimFileTypeGuesserTest/population_v5_multipleTeleportedLegs.xml"); - Assert.assertEquals(1, s.getPopulation().getPersons().size()); + Assertions.assertEquals(1, s.getPopulation().getPersons().size()); Person person = s.getPopulation().getPersons().get(Id.create(1, Person.class)); - Assert.assertNotNull(person); + Assertions.assertNotNull(person); Plan plan = person.getSelectedPlan(); List planElements = plan.getPlanElements(); - Assert.assertEquals(5, planElements.size()); + Assertions.assertEquals(5, planElements.size()); - Assert.assertTrue(planElements.get(0) instanceof Activity); - Assert.assertTrue(planElements.get(1) instanceof Leg); + Assertions.assertTrue(planElements.get(0) instanceof Activity); + Assertions.assertTrue(planElements.get(1) instanceof Leg); // Assert.assertTrue(((Leg) planElements.get(1)).getRoute() instanceof GenericRouteImpl); - Assert.assertTrue(planElements.get(2) instanceof Leg); - Assert.assertTrue(((Leg) planElements.get(2)).getRoute() instanceof NetworkRoute); - Assert.assertTrue(planElements.get(3) instanceof Leg); + Assertions.assertTrue(planElements.get(2) instanceof Leg); + Assertions.assertTrue(((Leg) planElements.get(2)).getRoute() instanceof NetworkRoute); + Assertions.assertTrue(planElements.get(3) instanceof Leg); // Assert.assertTrue(((Leg) planElements.get(3)).getRoute() instanceof GenericRouteImpl); - Assert.assertTrue(planElements.get(4) instanceof Activity); + Assertions.assertTrue(planElements.get(4) instanceof Activity); } } diff --git a/matsim/src/test/java/org/matsim/core/population/io/ParallelPopulationReaderTest.java b/matsim/src/test/java/org/matsim/core/population/io/ParallelPopulationReaderTest.java index 54e4e2fbd33..930ca275208 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/ParallelPopulationReaderTest.java +++ b/matsim/src/test/java/org/matsim/core/population/io/ParallelPopulationReaderTest.java @@ -1,6 +1,6 @@ package org.matsim.core.population.io; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.ConfigUtils; @@ -35,7 +35,7 @@ void testParallelPopulationReaderV4_escalateException() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); try { new ParallelPopulationReaderMatsimV4(scenario).readStream(stream); - Assert.fail("Expected exception"); + Assertions.fail("Expected exception"); } catch (Exception expected) { expected.printStackTrace(); } @@ -65,7 +65,7 @@ void testParallelPopulationReaderV6_escalateException() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); try { new ParallelPopulationReaderMatsimV6(null, null, scenario).readStream(stream); - Assert.fail("Expected exception"); + Assertions.fail("Expected exception"); } catch (Exception expected) { expected.printStackTrace(); } diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationAttributeConversionTest.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationAttributeConversionTest.java index 86824f40ec2..7e28e75a7de 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationAttributeConversionTest.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationAttributeConversionTest.java @@ -21,7 +21,7 @@ package org.matsim.core.population.io; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -38,7 +38,7 @@ import java.util.Objects; import java.util.function.Consumer; - public class PopulationAttributeConversionTest { + public class PopulationAttributeConversionTest { @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @@ -95,10 +95,10 @@ public void testWriteAndReread( final Person readPerson = readScenario.getPopulation().getPersons().get(personId); final Object readAttribute = readPerson.getAttributes().getAttribute("job"); - Assert.assertEquals( - "unexpected read attribute", + Assertions.assertEquals( attribute, - readAttribute); + readAttribute, + "unexpected read attribute"); } private static class CustomClass { diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationReaderMatsimV4Test.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationReaderMatsimV4Test.java index c406b80ada0..0fce80b3bda 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationReaderMatsimV4Test.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationReaderMatsimV4Test.java @@ -26,7 +26,7 @@ import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -118,32 +118,32 @@ void testReadRoute() throws SAXException, ParserConfigurationException, IOExcept tester.endTag(); - Assert.assertEquals("population size.", 2, population.getPersons().size()); + Assertions.assertEquals(2, population.getPersons().size(), "population size."); Person person1 = population.getPersons().get(Id.create("1", Person.class)); Plan plan1 = person1.getPlans().get(0); Leg leg1a = (Leg) plan1.getPlanElements().get(1); Route route1a = leg1a.getRoute(); - Assert.assertEquals("different startLink for first leg.", network.getLinks().get(Id.create("1", Link.class)).getId(), route1a.getStartLinkId()); - Assert.assertEquals("different endLink for first leg.", network.getLinks().get(Id.create("20", Link.class)).getId(), route1a.getEndLinkId()); + Assertions.assertEquals(network.getLinks().get(Id.create("1", Link.class)).getId(), route1a.getStartLinkId(), "different startLink for first leg."); + Assertions.assertEquals(network.getLinks().get(Id.create("20", Link.class)).getId(), route1a.getEndLinkId(), "different endLink for first leg."); Leg leg1b = (Leg) plan1.getPlanElements().get(3); Route route1b = leg1b.getRoute(); - Assert.assertEquals("different startLink for second leg.", network.getLinks().get(Id.create("20", Link.class)).getId(), route1b.getStartLinkId()); - Assert.assertEquals("different endLink for second leg.", network.getLinks().get(Id.create("20", Link.class)).getId(), route1b.getEndLinkId()); + Assertions.assertEquals(network.getLinks().get(Id.create("20", Link.class)).getId(), route1b.getStartLinkId(), "different startLink for second leg."); + Assertions.assertEquals(network.getLinks().get(Id.create("20", Link.class)).getId(), route1b.getEndLinkId(), "different endLink for second leg."); Leg leg1c = (Leg) plan1.getPlanElements().get(5); Route route1c = leg1c.getRoute(); - Assert.assertEquals("different startLink for third leg.", network.getLinks().get(Id.create("20", Link.class)).getId(), route1c.getStartLinkId()); - Assert.assertEquals("different endLink for third leg.", network.getLinks().get(Id.create("1", Link.class)).getId(), route1c.getEndLinkId()); + Assertions.assertEquals(network.getLinks().get(Id.create("20", Link.class)).getId(), route1c.getStartLinkId(), "different startLink for third leg."); + Assertions.assertEquals(network.getLinks().get(Id.create("1", Link.class)).getId(), route1c.getEndLinkId(), "different endLink for third leg."); Person person2 = population.getPersons().get(Id.create("2", Person.class)); Plan plan2 = person2.getPlans().get(0); Leg leg2a = (Leg) plan2.getPlanElements().get(1); Route route2a = leg2a.getRoute(); - Assert.assertEquals("different startLink for first leg.", network.getLinks().get(Id.create("2", Link.class)).getId(), route2a.getStartLinkId()); - Assert.assertEquals("different endLink for first leg.", network.getLinks().get(Id.create("20", Link.class)).getId(), route2a.getEndLinkId()); + Assertions.assertEquals(network.getLinks().get(Id.create("2", Link.class)).getId(), route2a.getStartLinkId(), "different startLink for first leg."); + Assertions.assertEquals(network.getLinks().get(Id.create("20", Link.class)).getId(), route2a.getEndLinkId(), "different endLink for first leg."); Leg leg2b = (Leg) plan2.getPlanElements().get(3); Route route2b = leg2b.getRoute(); - Assert.assertEquals("different startLink for third leg.", network.getLinks().get(Id.create("20", Link.class)).getId(), route2b.getStartLinkId()); - Assert.assertEquals("different endLink for third leg.", network.getLinks().get(Id.create("1", Link.class)).getId(), route2b.getEndLinkId()); + Assertions.assertEquals(network.getLinks().get(Id.create("20", Link.class)).getId(), route2b.getStartLinkId(), "different startLink for third leg."); + Assertions.assertEquals(network.getLinks().get(Id.create("1", Link.class)).getId(), route2b.getEndLinkId(), "different endLink for third leg."); } /** @@ -176,12 +176,12 @@ void testReadRouteWithoutActivityLinks() { parser.endTag("person", null, context); parser.endTag("plans", null, context); - Assert.assertEquals("population size.", 1, population.getPersons().size()); + Assertions.assertEquals(1, population.getPersons().size(), "population size."); Person person1 = population.getPersons().get(Id.create("981", Person.class)); Plan plan1 = person1.getPlans().get(0); Leg leg1 = (Leg) plan1.getPlanElements().get(1); Route route1 = leg1.getRoute(); - Assert.assertNotNull(route1); + Assertions.assertNotNull(route1); } /** @@ -213,11 +213,11 @@ void testReadActivity() { reader.endTag("person", "", context); reader.endTag("plans", "", context); - Assert.assertEquals(1, population.getPersons().size()); + Assertions.assertEquals(1, population.getPersons().size()); Person person = population.getPersons().get(Id.create("2", Person.class)); Plan plan = person.getPlans().get(0); - Assert.assertEquals(link3.getId(), ((Activity) plan.getPlanElements().get(0)).getLinkId()); - Assert.assertEquals(Id.create("2", Link.class), ((Activity) plan.getPlanElements().get(2)).getLinkId()); + Assertions.assertEquals(link3.getId(), ((Activity) plan.getPlanElements().get(0)).getLinkId()); + Assertions.assertEquals(Id.create("2", Link.class), ((Activity) plan.getPlanElements().get(2)).getLinkId()); } @Test @@ -254,14 +254,14 @@ void testReadingRoutesWithoutType() { reader.parse(new ByteArrayInputStream(str.getBytes())); Plan plan = population.getPersons().get(Id.create(1, Person.class)).getSelectedPlan(); - Assert.assertEquals(7, plan.getPlanElements().size()); - Assert.assertTrue(plan.getPlanElements().get(0) instanceof Activity); - Assert.assertTrue(plan.getPlanElements().get(1) instanceof Leg); - Assert.assertTrue(plan.getPlanElements().get(2) instanceof Activity); - Assert.assertTrue(plan.getPlanElements().get(3) instanceof Leg); - Assert.assertTrue(plan.getPlanElements().get(4) instanceof Activity); - Assert.assertTrue(plan.getPlanElements().get(5) instanceof Leg); - Assert.assertTrue(plan.getPlanElements().get(6) instanceof Activity); + Assertions.assertEquals(7, plan.getPlanElements().size()); + Assertions.assertTrue(plan.getPlanElements().get(0) instanceof Activity); + Assertions.assertTrue(plan.getPlanElements().get(1) instanceof Leg); + Assertions.assertTrue(plan.getPlanElements().get(2) instanceof Activity); + Assertions.assertTrue(plan.getPlanElements().get(3) instanceof Leg); + Assertions.assertTrue(plan.getPlanElements().get(4) instanceof Activity); + Assertions.assertTrue(plan.getPlanElements().get(5) instanceof Leg); + Assertions.assertTrue(plan.getPlanElements().get(6) instanceof Activity); Leg leg1 = (Leg) plan.getPlanElements().get(1); Route route1 = leg1.getRoute(); @@ -270,9 +270,9 @@ void testReadingRoutesWithoutType() { Leg leg3 = (Leg) plan.getPlanElements().get(5); Route route3 = leg3.getRoute(); - Assert.assertTrue(route1 instanceof NetworkRoute); + Assertions.assertTrue(route1 instanceof NetworkRoute); // Assert.assertTrue(route2 instanceof GenericRouteImpl); - Assert.assertTrue(route3 instanceof TransitPassengerRoute); + Assertions.assertTrue(route3 instanceof TransitPassengerRoute); } @Test @@ -297,12 +297,12 @@ void testRepeatingLegs() { reader.parse(new ByteArrayInputStream(str.getBytes())); Plan plan = population.getPersons().get(Id.create(1, Person.class)).getSelectedPlan(); - Assert.assertEquals(5, plan.getPlanElements().size()); - Assert.assertTrue(plan.getPlanElements().get(0) instanceof Activity); - Assert.assertTrue(plan.getPlanElements().get(1) instanceof Leg); - Assert.assertTrue(plan.getPlanElements().get(2) instanceof Leg); - Assert.assertTrue(plan.getPlanElements().get(3) instanceof Leg); - Assert.assertTrue(plan.getPlanElements().get(4) instanceof Activity); + Assertions.assertEquals(5, plan.getPlanElements().size()); + Assertions.assertTrue(plan.getPlanElements().get(0) instanceof Activity); + Assertions.assertTrue(plan.getPlanElements().get(1) instanceof Leg); + Assertions.assertTrue(plan.getPlanElements().get(2) instanceof Leg); + Assertions.assertTrue(plan.getPlanElements().get(3) instanceof Leg); + Assertions.assertTrue(plan.getPlanElements().get(4) instanceof Activity); } @Test @@ -326,11 +326,11 @@ void testRepeatingActs() { reader.parse(new ByteArrayInputStream(str.getBytes())); Plan plan = population.getPersons().get(Id.create(1, Person.class)).getSelectedPlan(); - Assert.assertEquals(4, plan.getPlanElements().size()); - Assert.assertTrue(plan.getPlanElements().get(0) instanceof Activity); - Assert.assertTrue(plan.getPlanElements().get(1) instanceof Leg); - Assert.assertTrue(plan.getPlanElements().get(2) instanceof Activity); - Assert.assertTrue(plan.getPlanElements().get(3) instanceof Activity); + Assertions.assertEquals(4, plan.getPlanElements().size()); + Assertions.assertTrue(plan.getPlanElements().get(0) instanceof Activity); + Assertions.assertTrue(plan.getPlanElements().get(1) instanceof Leg); + Assertions.assertTrue(plan.getPlanElements().get(2) instanceof Activity); + Assertions.assertTrue(plan.getPlanElements().get(3) instanceof Activity); } private static class XmlParserTestHelper { diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationReaderMatsimV5Test.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationReaderMatsimV5Test.java index d6e6c4b31d9..af11666b729 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationReaderMatsimV5Test.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationReaderMatsimV5Test.java @@ -26,7 +26,7 @@ import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Activity; @@ -107,32 +107,32 @@ void testReadRoute() throws SAXException, ParserConfigurationException, IOExcept tester.endTag(); - Assert.assertEquals("population size.", 2, population.getPersons().size()); + Assertions.assertEquals(2, population.getPersons().size(), "population size."); Person person1 = population.getPersons().get(Id.create("1", Person.class)); Plan plan1 = person1.getPlans().get(0); Leg leg1a = (Leg) plan1.getPlanElements().get(1); Route route1a = leg1a.getRoute(); - Assert.assertEquals("different startLink for first leg.", "1", route1a.getStartLinkId().toString()); - Assert.assertEquals("different endLink for first leg.", "20", route1a.getEndLinkId().toString()); + Assertions.assertEquals("1", route1a.getStartLinkId().toString(), "different startLink for first leg."); + Assertions.assertEquals("20", route1a.getEndLinkId().toString(), "different endLink for first leg."); Leg leg1b = (Leg) plan1.getPlanElements().get(3); Route route1b = leg1b.getRoute(); - Assert.assertEquals("different startLink for second leg.", "20", route1b.getStartLinkId().toString()); - Assert.assertEquals("different endLink for second leg.", "20", route1b.getEndLinkId().toString()); + Assertions.assertEquals("20", route1b.getStartLinkId().toString(), "different startLink for second leg."); + Assertions.assertEquals("20", route1b.getEndLinkId().toString(), "different endLink for second leg."); Leg leg1c = (Leg) plan1.getPlanElements().get(5); Route route1c = leg1c.getRoute(); - Assert.assertEquals("different startLink for third leg.", "20", route1c.getStartLinkId().toString()); - Assert.assertEquals("different endLink for third leg.", "1", route1c.getEndLinkId().toString()); + Assertions.assertEquals("20", route1c.getStartLinkId().toString(), "different startLink for third leg."); + Assertions.assertEquals("1", route1c.getEndLinkId().toString(), "different endLink for third leg."); Person person2 = population.getPersons().get(Id.create("2", Person.class)); Plan plan2 = person2.getPlans().get(0); Leg leg2a = (Leg) plan2.getPlanElements().get(1); Route route2a = leg2a.getRoute(); - Assert.assertEquals("different startLink for first leg.", "2", route2a.getStartLinkId().toString()); - Assert.assertEquals("different endLink for first leg.", "20", route2a.getEndLinkId().toString()); + Assertions.assertEquals("2", route2a.getStartLinkId().toString(), "different startLink for first leg."); + Assertions.assertEquals("20", route2a.getEndLinkId().toString(), "different endLink for first leg."); Leg leg2b = (Leg) plan2.getPlanElements().get(3); Route route2b = leg2b.getRoute(); - Assert.assertEquals("different startLink for third leg.", "20", route2b.getStartLinkId().toString()); - Assert.assertEquals("different endLink for third leg.", "1", route2b.getEndLinkId().toString()); + Assertions.assertEquals("20", route2b.getStartLinkId().toString(), "different startLink for third leg."); + Assertions.assertEquals("1", route2b.getEndLinkId().toString(), "different endLink for third leg."); } @Test @@ -164,11 +164,11 @@ void testReadRoute_sameLinkRoute() throws SAXException, ParserConfigurationExcep Plan plan1 = person1.getPlans().get(0); Leg leg1a = (Leg) plan1.getPlanElements().get(1); Route route1a = leg1a.getRoute(); - Assert.assertEquals("different startLink for first leg.", "1", route1a.getStartLinkId().toString()); - Assert.assertEquals("different endLink for first leg.", "1", route1a.getEndLinkId().toString()); - Assert.assertTrue(route1a instanceof NetworkRoute); + Assertions.assertEquals("1", route1a.getStartLinkId().toString(), "different startLink for first leg."); + Assertions.assertEquals("1", route1a.getEndLinkId().toString(), "different endLink for first leg."); + Assertions.assertTrue(route1a instanceof NetworkRoute); NetworkRoute nr = (NetworkRoute) route1a; - Assert.assertEquals(0, nr.getLinkIds().size()); + Assertions.assertEquals(0, nr.getLinkIds().size()); } @Test @@ -200,11 +200,11 @@ void testReadRoute_consequentLinks() throws SAXException, ParserConfigurationExc Plan plan1 = person1.getPlans().get(0); Leg leg1a = (Leg) plan1.getPlanElements().get(1); Route route1a = leg1a.getRoute(); - Assert.assertEquals("different startLink for first leg.", "1", route1a.getStartLinkId().toString()); - Assert.assertEquals("different endLink for first leg.", "2", route1a.getEndLinkId().toString()); - Assert.assertTrue(route1a instanceof NetworkRoute); + Assertions.assertEquals("1", route1a.getStartLinkId().toString(), "different startLink for first leg."); + Assertions.assertEquals("2", route1a.getEndLinkId().toString(), "different endLink for first leg."); + Assertions.assertTrue(route1a instanceof NetworkRoute); NetworkRoute nr = (NetworkRoute) route1a; - Assert.assertEquals(0, nr.getLinkIds().size()); + Assertions.assertEquals(0, nr.getLinkIds().size()); } /** @@ -237,12 +237,12 @@ void testReadRouteWithoutActivityLinks() { parser.endTag("person", null, context); parser.endTag("population", null, context); - Assert.assertEquals("population size.", 1, population.getPersons().size()); + Assertions.assertEquals(1, population.getPersons().size(), "population size."); Person person1 = population.getPersons().get(Id.create("981", Person.class)); Plan plan1 = person1.getPlans().get(0); Leg leg1 = (Leg) plan1.getPlanElements().get(1); Route route1 = leg1.getRoute(); - Assert.assertNotNull(route1); + Assertions.assertNotNull(route1); } @Test @@ -280,14 +280,14 @@ void testReadingOldRoutesWithoutType() { reader.parse(new ByteArrayInputStream(str.getBytes())); Plan plan = population.getPersons().get(Id.create(1, Person.class)).getSelectedPlan(); - Assert.assertEquals(7, plan.getPlanElements().size()); - Assert.assertTrue(plan.getPlanElements().get(0) instanceof Activity); - Assert.assertTrue(plan.getPlanElements().get(1) instanceof Leg); - Assert.assertTrue(plan.getPlanElements().get(2) instanceof Activity); - Assert.assertTrue(plan.getPlanElements().get(3) instanceof Leg); - Assert.assertTrue(plan.getPlanElements().get(4) instanceof Activity); - Assert.assertTrue(plan.getPlanElements().get(5) instanceof Leg); - Assert.assertTrue(plan.getPlanElements().get(6) instanceof Activity); + Assertions.assertEquals(7, plan.getPlanElements().size()); + Assertions.assertTrue(plan.getPlanElements().get(0) instanceof Activity); + Assertions.assertTrue(plan.getPlanElements().get(1) instanceof Leg); + Assertions.assertTrue(plan.getPlanElements().get(2) instanceof Activity); + Assertions.assertTrue(plan.getPlanElements().get(3) instanceof Leg); + Assertions.assertTrue(plan.getPlanElements().get(4) instanceof Activity); + Assertions.assertTrue(plan.getPlanElements().get(5) instanceof Leg); + Assertions.assertTrue(plan.getPlanElements().get(6) instanceof Activity); Leg leg1 = (Leg) plan.getPlanElements().get(1); Route route1 = leg1.getRoute(); @@ -296,9 +296,9 @@ void testReadingOldRoutesWithoutType() { Leg leg3 = (Leg) plan.getPlanElements().get(5); Route route3 = leg3.getRoute(); - Assert.assertTrue(route1 instanceof NetworkRoute); + Assertions.assertTrue(route1 instanceof NetworkRoute); // Assert.assertTrue(route2 instanceof GenericRouteImpl); - Assert.assertTrue(route3 instanceof TransitPassengerRoute); + Assertions.assertTrue(route3 instanceof TransitPassengerRoute); } @@ -325,11 +325,11 @@ void testReadActivity() { reader.endTag("person", "", context); reader.endTag("population", "", context); - Assert.assertEquals(1, population.getPersons().size()); + Assertions.assertEquals(1, population.getPersons().size()); Person person = population.getPersons().get(Id.create("2", Person.class)); Plan plan = person.getPlans().get(0); - Assert.assertEquals("3", ((Activity) plan.getPlanElements().get(0)).getLinkId().toString()); - Assert.assertEquals("2", ((Activity) plan.getPlanElements().get(2)).getLinkId().toString()); + Assertions.assertEquals("3", ((Activity) plan.getPlanElements().get(0)).getLinkId().toString()); + Assertions.assertEquals("2", ((Activity) plan.getPlanElements().get(2)).getLinkId().toString()); } @Test @@ -354,12 +354,12 @@ void testRepeatingLegs() { reader.parse(new ByteArrayInputStream(str.getBytes())); Plan plan = population.getPersons().get(Id.create(1, Person.class)).getSelectedPlan(); - Assert.assertEquals(5, plan.getPlanElements().size()); - Assert.assertTrue(plan.getPlanElements().get(0) instanceof Activity); - Assert.assertTrue(plan.getPlanElements().get(1) instanceof Leg); - Assert.assertTrue(plan.getPlanElements().get(2) instanceof Leg); - Assert.assertTrue(plan.getPlanElements().get(3) instanceof Leg); - Assert.assertTrue(plan.getPlanElements().get(4) instanceof Activity); + Assertions.assertEquals(5, plan.getPlanElements().size()); + Assertions.assertTrue(plan.getPlanElements().get(0) instanceof Activity); + Assertions.assertTrue(plan.getPlanElements().get(1) instanceof Leg); + Assertions.assertTrue(plan.getPlanElements().get(2) instanceof Leg); + Assertions.assertTrue(plan.getPlanElements().get(3) instanceof Leg); + Assertions.assertTrue(plan.getPlanElements().get(4) instanceof Activity); } @Test @@ -383,11 +383,11 @@ void testRepeatingActs() { reader.parse(new ByteArrayInputStream(str.getBytes())); Plan plan = population.getPersons().get(Id.create(1, Person.class)).getSelectedPlan(); - Assert.assertEquals(4, plan.getPlanElements().size()); - Assert.assertTrue(plan.getPlanElements().get(0) instanceof Activity); - Assert.assertTrue(plan.getPlanElements().get(1) instanceof Leg); - Assert.assertTrue(plan.getPlanElements().get(2) instanceof Activity); - Assert.assertTrue(plan.getPlanElements().get(3) instanceof Activity); + Assertions.assertEquals(4, plan.getPlanElements().size()); + Assertions.assertTrue(plan.getPlanElements().get(0) instanceof Activity); + Assertions.assertTrue(plan.getPlanElements().get(1) instanceof Leg); + Assertions.assertTrue(plan.getPlanElements().get(2) instanceof Activity); + Assertions.assertTrue(plan.getPlanElements().get(3) instanceof Activity); } @Test @@ -412,13 +412,13 @@ void testVehicleIdInRoute() { reader.parse(new ByteArrayInputStream(str.getBytes())); Plan plan = population.getPersons().get(Id.create(1, Person.class)).getSelectedPlan(); - Assert.assertEquals(3, plan.getPlanElements().size()); - Assert.assertTrue(plan.getPlanElements().get(0) instanceof Activity); - Assert.assertTrue(plan.getPlanElements().get(1) instanceof Leg); + Assertions.assertEquals(3, plan.getPlanElements().size()); + Assertions.assertTrue(plan.getPlanElements().get(0) instanceof Activity); + Assertions.assertTrue(plan.getPlanElements().get(1) instanceof Leg); Leg leg = (Leg) plan.getPlanElements().get(1) ; NetworkRoute route = (NetworkRoute) leg.getRoute() ; - Assert.assertEquals(Id.create("123", Vehicle.class), route.getVehicleId() ) ; - Assert.assertTrue(plan.getPlanElements().get(2) instanceof Activity); + Assertions.assertEquals(Id.create("123", Vehicle.class), route.getVehicleId() ) ; + Assertions.assertTrue(plan.getPlanElements().get(2) instanceof Activity); } private static class XmlParserTestHelper { diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationReprojectionIOIT.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationReprojectionIOIT.java index adeec746849..6a2da5d5506 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationReprojectionIOIT.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationReprojectionIOIT.java @@ -27,7 +27,7 @@ import java.util.Iterator; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -52,7 +52,7 @@ import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; - /** + /** * @author thibautd */ public class PopulationReprojectionIOIT { @@ -190,10 +190,10 @@ void testWithControlerAndAttributes() { final List originalActivities = TripStructureUtils.getActivities( originalPerson.getSelectedPlan() , StageActivityHandling.StagesAsNormalActivities ); final List reprojectedActivities = TripStructureUtils.getActivities( internalPerson.getSelectedPlan() , StageActivityHandling.StagesAsNormalActivities ); - Assert.assertEquals( - "unexpected number of activities in reprojected plan", + Assertions.assertEquals( originalActivities.size(), - reprojectedActivities.size() ); + reprojectedActivities.size(), + "unexpected number of activities in reprojected plan" ); final Iterator originalIterator = originalActivities.iterator(); final Iterator reprojectedIterator = reprojectedActivities.iterator(); @@ -202,17 +202,17 @@ void testWithControlerAndAttributes() { final Activity o = originalIterator.next(); final Activity r = reprojectedIterator.next(); - Assert.assertNotEquals( - "No coordinates transform performed!", + Assertions.assertNotEquals( transformation.transform(o.getCoord()), - r); + r, + "No coordinates transform performed!"); } } - Assert.assertEquals( - "wrong CRS information after loading", + Assertions.assertEquals( TARGET_CRS, - ProjectionUtils.getCRS(scenario.getPopulation())); + ProjectionUtils.getCRS(scenario.getPopulation()), + "wrong CRS information after loading"); // do not perform ANY mobsim run config.controller().setLastIteration( -1 ); @@ -231,10 +231,10 @@ void testWithControlerAndAttributes() { final List internalActivities = TripStructureUtils.getActivities( internalPerson.getSelectedPlan() , StageActivityHandling.StagesAsNormalActivities ); final List reprojectedActivities = TripStructureUtils.getActivities( dumpedPerson.getSelectedPlan() , StageActivityHandling.StagesAsNormalActivities ); - Assert.assertEquals( - "unexpected number of activities in reprojected plan", + Assertions.assertEquals( internalActivities.size(), - reprojectedActivities.size() ); + reprojectedActivities.size(), + "unexpected number of activities in reprojected plan" ); final Iterator internalIterator = internalActivities.iterator(); final Iterator reprojectedIterator = reprojectedActivities.iterator(); @@ -243,16 +243,16 @@ void testWithControlerAndAttributes() { final Activity o = internalIterator.next(); final Activity r = reprojectedIterator.next(); - Assert.assertEquals( - "coordinates were reprojected for dump", + Assertions.assertEquals( o.getCoord().getX(), r.getCoord().getX(), - epsilon ); - Assert.assertEquals( - "coordinates were reprojected for dump", + epsilon, + "coordinates were reprojected for dump" ); + Assertions.assertEquals( o.getCoord().getY(), r.getCoord().getY(), - epsilon ); + epsilon, + "coordinates were reprojected for dump" ); } } } @@ -299,10 +299,10 @@ void testWithControlerAndConfigParameters() { final List originalActivities = TripStructureUtils.getActivities( originalPerson.getSelectedPlan() , StageActivityHandling.StagesAsNormalActivities ); final List reprojectedActivities = TripStructureUtils.getActivities( internalPerson.getSelectedPlan() , StageActivityHandling.StagesAsNormalActivities ); - Assert.assertEquals( - "unexpected number of activities in reprojected plan", + Assertions.assertEquals( originalActivities.size(), - reprojectedActivities.size() ); + reprojectedActivities.size(), + "unexpected number of activities in reprojected plan" ); final Iterator originalIterator = originalActivities.iterator(); final Iterator reprojectedIterator = reprojectedActivities.iterator(); @@ -311,10 +311,10 @@ void testWithControlerAndConfigParameters() { final Activity o = originalIterator.next(); final Activity r = reprojectedIterator.next(); - Assert.assertNotEquals( - "No coordinates transform performed!", + Assertions.assertNotEquals( transformation.transform(o.getCoord()), - r); + r, + "No coordinates transform performed!"); } } @@ -335,10 +335,10 @@ void testWithControlerAndConfigParameters() { final List internalActivities = TripStructureUtils.getActivities( internalPerson.getSelectedPlan() , StageActivityHandling.StagesAsNormalActivities ); final List reprojectedActivities = TripStructureUtils.getActivities( dumpedPerson.getSelectedPlan() , StageActivityHandling.StagesAsNormalActivities ); - Assert.assertEquals( - "unexpected number of activities in reprojected plan", + Assertions.assertEquals( internalActivities.size(), - reprojectedActivities.size() ); + reprojectedActivities.size(), + "unexpected number of activities in reprojected plan" ); final Iterator internalIterator = internalActivities.iterator(); final Iterator reprojectedIterator = reprojectedActivities.iterator(); @@ -347,16 +347,16 @@ void testWithControlerAndConfigParameters() { final Activity o = internalIterator.next(); final Activity r = reprojectedIterator.next(); - Assert.assertEquals( - "coordinates were reprojected for dump", + Assertions.assertEquals( o.getCoord().getX(), r.getCoord().getX(), - epsilon ); - Assert.assertEquals( - "coordinates were reprojected for dump", + epsilon, + "coordinates were reprojected for dump" ); + Assertions.assertEquals( o.getCoord().getY(), r.getCoord().getY(), - epsilon ); + epsilon, + "coordinates were reprojected for dump" ); } } } @@ -382,10 +382,10 @@ public void testConversionAtInput(final String inputFile) { private void assertPopulationCorrectlyTransformed( final Population originalPopulation, final Population reprojectedPopulation) { - Assert.assertEquals( - "unexpected size of reprojected population", + Assertions.assertEquals( originalPopulation.getPersons().size(), - reprojectedPopulation.getPersons().size()); + reprojectedPopulation.getPersons().size(), + "unexpected size of reprojected population"); for (Id personId : originalPopulation.getPersons().keySet()) { final Person originalPerson = originalPopulation.getPersons().get(personId); @@ -401,10 +401,10 @@ private void assertPlanCorrectlyTransformed( final List originalActivities = TripStructureUtils.getActivities( originalPlan , StageActivityHandling.StagesAsNormalActivities ); final List reprojectedActivities = TripStructureUtils.getActivities( reprojectedPlan , StageActivityHandling.StagesAsNormalActivities ); - Assert.assertEquals( - "unexpected number of activities in reprojected plan", + Assertions.assertEquals( originalActivities.size(), - reprojectedActivities.size() ); + reprojectedActivities.size(), + "unexpected number of activities in reprojected plan" ); final Iterator originalIterator = originalActivities.iterator(); final Iterator reprojectedIterator = reprojectedActivities.iterator(); @@ -420,10 +420,10 @@ private void assertPlanCorrectlyTransformed( private void assertIsCorrectlyTransformed( final Coord original , final Coord transformed ) { final Coord target = transformation.transform(original); - Assert.assertEquals( - "wrong reprojected value", + Assertions.assertEquals( target, - transformed); + transformed, + "wrong reprojected value"); } } diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationV6IOTest.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationV6IOTest.java index b30030727e9..4e7005dc1df 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationV6IOTest.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationV6IOTest.java @@ -21,7 +21,7 @@ package org.matsim.core.population.io; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -54,7 +54,7 @@ import java.util.Map; - /** + /** * @author thibautd */ public class PopulationV6IOTest { @@ -83,16 +83,16 @@ void testCoord3dIO() { final Activity readSpeach = (Activity) readPerson.getSelectedPlan().getPlanElements().get( 0 ); final Activity readTweet = (Activity) readPerson.getSelectedPlan().getPlanElements().get( 1 ); - Assert.assertFalse( "did not expect Z value in "+readSpeach.getCoord() , - readSpeach.getCoord().hasZ() ); + Assertions.assertFalse( readSpeach.getCoord().hasZ(), + "did not expect Z value in "+readSpeach.getCoord() ); - Assert.assertTrue( "did expect T value in "+readTweet.getCoord() , - readTweet.getCoord().hasZ() ); + Assertions.assertTrue( readTweet.getCoord().hasZ(), + "did expect T value in "+readTweet.getCoord() ); - Assert.assertEquals( "unexpected Z value in "+readTweet.getCoord(), - -100, + Assertions.assertEquals( -100, readTweet.getCoord().getZ(), - MatsimTestUtils.EPSILON ); + MatsimTestUtils.EPSILON, + "unexpected Z value in "+readTweet.getCoord() ); } @Test @@ -132,17 +132,17 @@ void testPersonAttributesIO() { final Person readPerson = readScenario.getPopulation().getPersons().get( Id.createPersonId( "Donald Trump" ) ); - Assert.assertEquals( "Unexpected boolean attribute in " + readPerson.getAttributes(), - person.getAttributes().getAttribute( "brain" ) , - readPerson.getAttributes().getAttribute( "brain" ) ); + Assertions.assertEquals( person.getAttributes().getAttribute( "brain" ) , + readPerson.getAttributes().getAttribute( "brain" ), + "Unexpected boolean attribute in " + readPerson.getAttributes() ); - Assert.assertEquals( "Unexpected String attribute in " + readPerson.getAttributes(), - person.getAttributes().getAttribute( "party" ) , - readPerson.getAttributes().getAttribute( "party" ) ); + Assertions.assertEquals( person.getAttributes().getAttribute( "party" ) , + readPerson.getAttributes().getAttribute( "party" ), + "Unexpected String attribute in " + readPerson.getAttributes() ); - Assert.assertEquals( "Unexpected PersonVehicle attribute in " + readPerson.getAttributes(), - VehicleUtils.getVehicleIds(person) , - VehicleUtils.getVehicleIds(readPerson) ); + Assertions.assertEquals( VehicleUtils.getVehicleIds(person) , + VehicleUtils.getVehicleIds(readPerson), + "Unexpected PersonVehicle attribute in " + readPerson.getAttributes() ); } @Test @@ -169,13 +169,13 @@ void testActivityAttributesIO() { final Person readPerson = readScenario.getPopulation().getPersons().get( Id.createPersonId( "Donald Trump" ) ); final Activity readAct = (Activity) readPerson.getSelectedPlan().getPlanElements().get( 0 ); - Assert.assertEquals( "Unexpected boolean attribute in " + readAct.getAttributes(), - act.getAttributes().getAttribute( "makes sense" ) , - readAct.getAttributes().getAttribute( "makes sense" ) ); + Assertions.assertEquals( act.getAttributes().getAttribute( "makes sense" ) , + readAct.getAttributes().getAttribute( "makes sense" ), + "Unexpected boolean attribute in " + readAct.getAttributes() ); - Assert.assertEquals( "Unexpected Long attribute in " + readAct.getAttributes(), - act.getAttributes().getAttribute( "length" ) , - readAct.getAttributes().getAttribute( "length" ) ); + Assertions.assertEquals( act.getAttributes().getAttribute( "length" ) , + readAct.getAttributes().getAttribute( "length" ), + "Unexpected Long attribute in " + readAct.getAttributes() ); } @Test @@ -204,12 +204,12 @@ void testLegAttributesIO() { final Person readPerson = readScenario.getPopulation().getPersons().get( Id.createPersonId( "Donald Trump" ) ); final Leg readLeg = (Leg) readPerson.getSelectedPlan().getPlanElements().get( 1 ); - Assert.assertEquals("Expected a single leg attribute.", 1, readLeg.getAttributes().size()); - Assert.assertEquals( "Unexpected Double attribute in " + readLeg.getAttributes(), - leg.getAttributes().getAttribute( "mpg" ) , - readLeg.getAttributes().getAttribute( "mpg" ) ); + Assertions.assertEquals(1, readLeg.getAttributes().size(), "Expected a single leg attribute."); + Assertions.assertEquals( leg.getAttributes().getAttribute( "mpg" ) , + readLeg.getAttributes().getAttribute( "mpg" ), + "Unexpected Double attribute in " + readLeg.getAttributes() ); - Assert.assertEquals("RoutingMode not set in Leg.", TransportMode.car, readLeg.getRoutingMode()); + Assertions.assertEquals(TransportMode.car, readLeg.getRoutingMode(), "RoutingMode not set in Leg."); } @Test @@ -238,12 +238,12 @@ void testLegAttributesLegacyIO() { final Person readPerson = readScenario.getPopulation().getPersons().get( Id.createPersonId( "Donald Trump" ) ); final Leg readLeg = (Leg) readPerson.getSelectedPlan().getPlanElements().get( 1 ); - Assert.assertEquals("Expected a single leg attribute.", 1, readLeg.getAttributes().size()); - Assert.assertEquals( "Unexpected Double attribute in " + readLeg.getAttributes(), - leg.getAttributes().getAttribute( "mpg" ) , - readLeg.getAttributes().getAttribute( "mpg" ) ); + Assertions.assertEquals(1, readLeg.getAttributes().size(), "Expected a single leg attribute."); + Assertions.assertEquals( leg.getAttributes().getAttribute( "mpg" ) , + readLeg.getAttributes().getAttribute( "mpg" ), + "Unexpected Double attribute in " + readLeg.getAttributes() ); - Assert.assertEquals("RoutingMode not set in Leg.", TransportMode.car, readLeg.getRoutingMode()); + Assertions.assertEquals(TransportMode.car, readLeg.getRoutingMode(), "RoutingMode not set in Leg."); } @Test @@ -271,7 +271,7 @@ void testPlanAttributesIO() { final Person readPerson = readScenario.getPopulation().getPersons().get( Id.createPersonId( "Donald Trump" ) ); final Plan readPlan = readPerson.getSelectedPlan() ; - Assert.assertEquals( plan.getAttributes().getAttribute( "beauty" ) , + Assertions.assertEquals( plan.getAttributes().getAttribute( "beauty" ) , readPlan.getAttributes().getAttribute( "beauty" ) ); } @@ -288,13 +288,13 @@ void testPopulationAttributesIO() { final Scenario readScenario = ScenarioUtils.createScenario( ConfigUtils.createConfig() ); new PopulationReader( readScenario ).readFile( file ); - Assert.assertEquals( "Unexpected numeric attribute in " + readScenario.getPopulation().getAttributes(), - population.getAttributes().getAttribute( "number" ) , - readScenario.getPopulation().getAttributes().getAttribute( "number" ) ); + Assertions.assertEquals( population.getAttributes().getAttribute( "number" ) , + readScenario.getPopulation().getAttributes().getAttribute( "number" ), + "Unexpected numeric attribute in " + readScenario.getPopulation().getAttributes() ); - Assert.assertEquals( "Unexpected String attribute in " + readScenario.getPopulation().getAttributes(), - population.getAttributes().getAttribute( "type" ) , - readScenario.getPopulation().getAttributes().getAttribute( "type" ) ); + Assertions.assertEquals( population.getAttributes().getAttribute( "type" ) , + readScenario.getPopulation().getAttributes().getAttribute( "type" ), + "Unexpected String attribute in " + readScenario.getPopulation().getAttributes() ); } // see MATSIM-927, https://matsim.atlassian.net/browse/MATSIM-927 @@ -329,7 +329,7 @@ void testRouteIO() { ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); new PopulationReader(scenario).parse(in); - Assert.assertEquals(route.getRouteDescription(), ((Leg) scenario.getPopulation().getPersons().get(person1.getId()).getSelectedPlan().getPlanElements().get(1)).getRoute().getRouteDescription()); + Assertions.assertEquals(route.getRouteDescription(), ((Leg) scenario.getPopulation().getPersons().get(person1.getId()).getSelectedPlan().getPlanElements().get(1)).getRoute().getRouteDescription()); } // inspired from MATSIM-927, https://matsim.atlassian.net/browse/MATSIM-927 @@ -373,10 +373,10 @@ void testSpecialCharactersIO() { Person p1 = scenario.getPopulation().getPersons().get(person1.getId()); // this already checks the id Plan pl1 = p1.getSelectedPlan(); - Assert.assertEquals(act1.getType(), ((Activity) pl1.getPlanElements().get(0)).getType()); - Assert.assertEquals(act1.getLinkId(), ((Activity) pl1.getPlanElements().get(0)).getLinkId()); + Assertions.assertEquals(act1.getType(), ((Activity) pl1.getPlanElements().get(0)).getType()); + Assertions.assertEquals(act1.getLinkId(), ((Activity) pl1.getPlanElements().get(0)).getLinkId()); - Assert.assertEquals(route.getRouteDescription(), ((Leg) scenario.getPopulation().getPersons().get(person1.getId()).getSelectedPlan().getPlanElements().get(1)).getRoute().getRouteDescription()); + Assertions.assertEquals(route.getRouteDescription(), ((Leg) scenario.getPopulation().getPersons().get(person1.getId()).getSelectedPlan().getPlanElements().get(1)).getRoute().getRouteDescription()); } @Test @@ -419,17 +419,17 @@ void testSingleActivityLocationInfoIO() { Person p1 = scenario.getPopulation().getPersons().get(person1.getId()); Plan pp1 = p1.getPlans().get(0); - Assert.assertEquals(((Activity) pp1.getPlanElements().get(0)).getFacilityId(), facilityId); - Assert.assertNull(((Activity) pp1.getPlanElements().get(0)).getCoord()); - Assert.assertNull(((Activity) pp1.getPlanElements().get(0)).getLinkId()); + Assertions.assertEquals(((Activity) pp1.getPlanElements().get(0)).getFacilityId(), facilityId); + Assertions.assertNull(((Activity) pp1.getPlanElements().get(0)).getCoord()); + Assertions.assertNull(((Activity) pp1.getPlanElements().get(0)).getLinkId()); - Assert.assertNull(((Activity) pp1.getPlanElements().get(2)).getFacilityId()); - Assert.assertEquals(((Activity) pp1.getPlanElements().get(2)).getCoord(), coord); - Assert.assertNull(((Activity) pp1.getPlanElements().get(2)).getLinkId()); + Assertions.assertNull(((Activity) pp1.getPlanElements().get(2)).getFacilityId()); + Assertions.assertEquals(((Activity) pp1.getPlanElements().get(2)).getCoord(), coord); + Assertions.assertNull(((Activity) pp1.getPlanElements().get(2)).getLinkId()); - Assert.assertNull(((Activity) pp1.getPlanElements().get(4)).getFacilityId()); - Assert.assertNull(((Activity) pp1.getPlanElements().get(4)).getCoord()); - Assert.assertEquals(((Activity) pp1.getPlanElements().get(4)).getLinkId(), linkId); + Assertions.assertNull(((Activity) pp1.getPlanElements().get(4)).getFacilityId()); + Assertions.assertNull(((Activity) pp1.getPlanElements().get(4)).getCoord()); + Assertions.assertEquals(((Activity) pp1.getPlanElements().get(4)).getLinkId(), linkId); } @Test @@ -457,8 +457,8 @@ void testPopulationCoordinateTransformationIO() { reader.readFile(outputDirectory + "output.xml"); Person inputPerson = scenario.getPopulation().getPersons().values().iterator().next(); Activity act = (Activity) inputPerson.getPlans().get(0).getPlanElements().get(0); - Assert.assertEquals(10.911495969392414, act.getCoord().getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals(2.3202288392002424, act.getCoord().getY(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(10.911495969392414, act.getCoord().getX(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2.3202288392002424, act.getCoord().getY(), MatsimTestUtils.EPSILON); } diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV4Test.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV4Test.java index 1de5e13e690..ba414a38881 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV4Test.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV4Test.java @@ -20,7 +20,7 @@ package org.matsim.core.population.io; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV5Test.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV5Test.java index a28f6de0734..fef85f401fb 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV5Test.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationWriterHandlerImplV5Test.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Stack; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -104,14 +104,14 @@ private NetworkRoute doTestWriteNetworkRoute(final String startLinkId, final Str Person person2 = pop2.getPersons().get(Id.create(1, Person.class)); Leg leg2 = (Leg) person2.getPlans().get(0).getPlanElements().get(1); Route route2 = leg2.getRoute(); - Assert.assertEquals(expectedRouteSerialization, popReader.interceptedRouteContent.trim()); - Assert.assertTrue("read route is of class " + route2.getClass().getCanonicalName(), route2 instanceof NetworkRoute); + Assertions.assertEquals(expectedRouteSerialization, popReader.interceptedRouteContent.trim()); + Assertions.assertTrue(route2 instanceof NetworkRoute, "read route is of class " + route2.getClass().getCanonicalName()); NetworkRoute nr = (NetworkRoute) route2; - Assert.assertEquals("wrong start link", startLinkId, nr.getStartLinkId().toString()); - Assert.assertEquals("wrong end link", endLinkId, nr.getEndLinkId().toString()); - Assert.assertEquals("wrong number of links in route", routeLinkIds.size(), nr.getLinkIds().size()); + Assertions.assertEquals(startLinkId, nr.getStartLinkId().toString(), "wrong start link"); + Assertions.assertEquals(endLinkId, nr.getEndLinkId().toString(), "wrong end link"); + Assertions.assertEquals(routeLinkIds.size(), nr.getLinkIds().size(), "wrong number of links in route"); for (int i = 0; i < routeLinkIds.size(); i++) { - Assert.assertEquals("wrong link in route at position " + i, routeLinkIds.get(i), nr.getLinkIds().get(i)); + Assertions.assertEquals(routeLinkIds.get(i), nr.getLinkIds().get(i), "wrong link in route at position " + i); } return nr; } @@ -152,10 +152,10 @@ void testWriteGenericRouteRoute() { Leg leg2 = (Leg) person2.getPlans().get(0).getPlanElements().get(1); Route route2 = leg2.getRoute(); // Assert.assertTrue("read route is of class " + route2.getClass().getCanonicalName(), route2 instanceof GenericRouteImpl); - Assert.assertEquals("wrong start link", startLinkId, route2.getStartLinkId().toString()); - Assert.assertEquals("wrong end link", endLinkId, route2.getEndLinkId().toString()); - Assert.assertEquals("wrong travel time", travTime, route2.getTravelTime().seconds(), 1e-9); - Assert.assertEquals("wrong distance", dist, route2.getDistance(), 1e-9); + Assertions.assertEquals(startLinkId, route2.getStartLinkId().toString(), "wrong start link"); + Assertions.assertEquals(endLinkId, route2.getEndLinkId().toString(), "wrong end link"); + Assertions.assertEquals(travTime, route2.getTravelTime().seconds(), 1e-9, "wrong travel time"); + Assertions.assertEquals(dist, route2.getDistance(), 1e-9, "wrong distance"); } private static final class RouteInterceptingPopulationReader extends MatsimXmlParser implements MatsimReader { diff --git a/matsim/src/test/java/org/matsim/core/population/io/StreamingPopulationAttributeConversionTest.java b/matsim/src/test/java/org/matsim/core/population/io/StreamingPopulationAttributeConversionTest.java index add49f76e92..0e1220ac877 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/StreamingPopulationAttributeConversionTest.java +++ b/matsim/src/test/java/org/matsim/core/population/io/StreamingPopulationAttributeConversionTest.java @@ -25,7 +25,7 @@ import java.util.function.BiConsumer; import java.util.function.Consumer; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -85,10 +85,10 @@ public void testWriteAndRereadStreaming( final Person readPerson = readScenario.getPopulation().getPersons().get(personId0); final Object readAttribute = readPerson.getAttributes().getAttribute("job"); - Assert.assertEquals( - "unexpected read attribute", + Assertions.assertEquals( attribute, - readAttribute); + readAttribute, + "unexpected read attribute"); } private static class CustomClass { diff --git a/matsim/src/test/java/org/matsim/core/population/routes/AbstractNetworkRouteTest.java b/matsim/src/test/java/org/matsim/core/population/routes/AbstractNetworkRouteTest.java index b3410153f72..d2c3542b04a 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/AbstractNetworkRouteTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/AbstractNetworkRouteTest.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -59,12 +59,12 @@ void testSetLinkIds() { route.setLinkIds(link11, links, link15); List> linkIds = route.getLinkIds(); - Assert.assertEquals("number of links in route.", 5, linkIds.size()); - Assert.assertEquals(Id.create("-22", Link.class), linkIds.get(0)); - Assert.assertEquals(Id.create("2", Link.class), linkIds.get(1)); - Assert.assertEquals(Id.create("3", Link.class), linkIds.get(2)); - Assert.assertEquals(Id.create("24", Link.class), linkIds.get(3)); - Assert.assertEquals(Id.create("14", Link.class), linkIds.get(4)); + Assertions.assertEquals(5, linkIds.size(), "number of links in route."); + Assertions.assertEquals(Id.create("-22", Link.class), linkIds.get(0)); + Assertions.assertEquals(Id.create("2", Link.class), linkIds.get(1)); + Assertions.assertEquals(Id.create("3", Link.class), linkIds.get(2)); + Assertions.assertEquals(Id.create("24", Link.class), linkIds.get(3)); + Assertions.assertEquals(Id.create("14", Link.class), linkIds.get(4)); } @Test @@ -83,7 +83,7 @@ void testSetLinks_linksNull() { Id link2 = Id.create("2", Link.class); route.setLinkIds(link1, null, link2); List> linkIds2 = route.getLinkIds(); - Assert.assertEquals("number of links in route.", 0, linkIds2.size()); + Assertions.assertEquals(0, linkIds2.size(), "number of links in route."); } } @@ -102,7 +102,7 @@ void testSetLinks_AllNull() { { route.setLinkIds(null, null, null); List> linkIds = route.getLinkIds(); - Assert.assertEquals("number of nodes in route.", 0, linkIds.size()); + Assertions.assertEquals(0, linkIds.size(), "number of nodes in route."); } } @@ -115,7 +115,7 @@ void testGetDistance() { route.setLinkIds(link1, NetworkUtils.getLinkIds("22 12 -23 3"), link4); route.setDistance(1234.5); - Assert.assertEquals("wrong difference.", 1234.5, route.getDistance(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1234.5, route.getDistance(), MatsimTestUtils.EPSILON, "wrong difference."); } @Test @@ -127,11 +127,11 @@ void testGetLinkIds() { route.setLinkIds(link1, NetworkUtils.getLinkIds("22 12 -23 3"), link4); List> ids = route.getLinkIds(); - Assert.assertEquals("number of links in route.", 4, ids.size()); - Assert.assertEquals(Id.create("22", Link.class), ids.get(0)); - Assert.assertEquals(Id.create("12", Link.class), ids.get(1)); - Assert.assertEquals(Id.create("-23", Link.class), ids.get(2)); - Assert.assertEquals(Id.create("3", Link.class), ids.get(3)); + Assertions.assertEquals(4, ids.size(), "number of links in route."); + Assertions.assertEquals(Id.create("22", Link.class), ids.get(0)); + Assertions.assertEquals(Id.create("12", Link.class), ids.get(1)); + Assertions.assertEquals(Id.create("-23", Link.class), ids.get(2)); + Assertions.assertEquals(Id.create("3", Link.class), ids.get(3)); } @Test @@ -148,11 +148,11 @@ void testGetSubRoute() { NetworkRoute subRoute = route.getSubRoute(id12, id24); List> linkIds = subRoute.getLinkIds(); - Assert.assertEquals("number of links in subRoute.", 2, linkIds.size()); - Assert.assertEquals(id23m, linkIds.get(0)); - Assert.assertEquals(id3, linkIds.get(1)); - Assert.assertEquals("wrong start link.", id12, subRoute.getStartLinkId()); - Assert.assertEquals("wrong end link.", id24, subRoute.getEndLinkId()); + Assertions.assertEquals(2, linkIds.size(), "number of links in subRoute."); + Assertions.assertEquals(id23m, linkIds.get(0)); + Assertions.assertEquals(id3, linkIds.get(1)); + Assertions.assertEquals(id12, subRoute.getStartLinkId(), "wrong start link."); + Assertions.assertEquals(id24, subRoute.getEndLinkId(), "wrong end link."); } @Test @@ -170,13 +170,13 @@ void testGetSubRoute_fromStart() { NetworkRoute subRoute = route.getSubRoute(id0, id3); List> linkIds = subRoute.getLinkIds(); - Assert.assertEquals("number of links in subRoute.", 4, linkIds.size()); - Assert.assertEquals(id1, linkIds.get(0)); - Assert.assertEquals(id22, linkIds.get(1)); - Assert.assertEquals(id12, linkIds.get(2)); - Assert.assertEquals(id23m, linkIds.get(3)); - Assert.assertEquals("wrong start link.", id0, subRoute.getStartLinkId()); - Assert.assertEquals("wrong end link.", id3, subRoute.getEndLinkId()); + Assertions.assertEquals(4, linkIds.size(), "number of links in subRoute."); + Assertions.assertEquals(id1, linkIds.get(0)); + Assertions.assertEquals(id22, linkIds.get(1)); + Assertions.assertEquals(id12, linkIds.get(2)); + Assertions.assertEquals(id23m, linkIds.get(3)); + Assertions.assertEquals(id0, subRoute.getStartLinkId(), "wrong start link."); + Assertions.assertEquals(id3, subRoute.getEndLinkId(), "wrong end link."); } @Test @@ -192,11 +192,11 @@ void testGetSubRoute_toEnd() { NetworkRoute subRoute = route.getSubRoute(id23m, id15); List> linkIds = subRoute.getLinkIds(); - Assert.assertEquals("number of links in subRoute.", 3, linkIds.size()); - Assert.assertEquals(id3, linkIds.get(0)); - Assert.assertEquals(id24, linkIds.get(1)); - Assert.assertEquals("wrong start link.", id23m, subRoute.getStartLinkId()); - Assert.assertEquals("wrong end link.", id15, subRoute.getEndLinkId()); + Assertions.assertEquals(3, linkIds.size(), "number of links in subRoute."); + Assertions.assertEquals(id3, linkIds.get(0)); + Assertions.assertEquals(id24, linkIds.get(1)); + Assertions.assertEquals(id23m, subRoute.getStartLinkId(), "wrong start link."); + Assertions.assertEquals(id15, subRoute.getEndLinkId(), "wrong end link."); } @Test @@ -209,9 +209,9 @@ void testGetSubRoute_startOnly() { NetworkRoute subRoute = route.getSubRoute(id0, id0); List> linkIds = subRoute.getLinkIds(); - Assert.assertEquals("number of links in subRoute.", 0, linkIds.size()); - Assert.assertEquals("wrong start link.", id0, subRoute.getStartLinkId()); - Assert.assertEquals("wrong end link.", id0, subRoute.getEndLinkId()); + Assertions.assertEquals(0, linkIds.size(), "number of links in subRoute."); + Assertions.assertEquals(id0, subRoute.getStartLinkId(), "wrong start link."); + Assertions.assertEquals(id0, subRoute.getEndLinkId(), "wrong end link."); } @Test @@ -224,9 +224,9 @@ void testGetSubRoute_endOnly() { NetworkRoute subRoute = route.getSubRoute(id15, id15); List> linkIds = subRoute.getLinkIds(); - Assert.assertEquals("number of links in subRoute.", 0, linkIds.size()); - Assert.assertEquals("wrong start link.", id15, subRoute.getStartLinkId()); - Assert.assertEquals("wrong end link.", id15, subRoute.getEndLinkId()); + Assertions.assertEquals(0, linkIds.size(), "number of links in subRoute."); + Assertions.assertEquals(id15, subRoute.getStartLinkId(), "wrong start link."); + Assertions.assertEquals(id15, subRoute.getEndLinkId(), "wrong end link."); } @Test @@ -240,7 +240,7 @@ void testGetSubRoute_wrongStart() { try { route.getSubRoute(id0, id15); - Assert.fail("expected IllegalArgumentException, but it did not happen."); + Assertions.fail("expected IllegalArgumentException, but it did not happen."); } catch (IllegalArgumentException expected) { log.info("catched expected exception: " + expected.getMessage()); } @@ -257,7 +257,7 @@ void testGetSubRoute_wrongEnd() { try { route.getSubRoute(id1, id15); - Assert.fail("expected IllegalArgumentException, but it did not happen."); + Assertions.fail("expected IllegalArgumentException, but it did not happen."); } catch (IllegalArgumentException expected) { log.info("catched expected exception: " + expected.getMessage()); } @@ -274,9 +274,9 @@ void testGetSubRoute_sameLinks() { NetworkRoute subRoute = route.getSubRoute(id12, id12); List> linkIds = subRoute.getLinkIds(); - Assert.assertEquals("number of links in subRoute.", 0, linkIds.size()); - Assert.assertEquals("wrong start link.", id12, subRoute.getStartLinkId()); - Assert.assertEquals("wrong end link.", id12, subRoute.getEndLinkId()); + Assertions.assertEquals(0, linkIds.size(), "number of links in subRoute."); + Assertions.assertEquals(id12, subRoute.getStartLinkId(), "wrong start link."); + Assertions.assertEquals(id12, subRoute.getEndLinkId(), "wrong end link."); } @Test @@ -288,9 +288,9 @@ void testGetSubRoute_sameLinks_emptyRoute1() { NetworkRoute subRoute = route.getSubRoute(id1, id1); List> linkIds = subRoute.getLinkIds(); - Assert.assertEquals("number of links in subRoute.", 0, linkIds.size()); - Assert.assertEquals("wrong start link.", id1, subRoute.getStartLinkId()); - Assert.assertEquals("wrong end link.", id1, subRoute.getEndLinkId()); + Assertions.assertEquals(0, linkIds.size(), "number of links in subRoute."); + Assertions.assertEquals(id1, subRoute.getStartLinkId(), "wrong start link."); + Assertions.assertEquals(id1, subRoute.getEndLinkId(), "wrong end link."); } @Test @@ -303,15 +303,15 @@ void testGetSubRoute_sameLinks_emptyRoute2() { NetworkRoute subRoute = route.getSubRoute(id1, id1); List> linkIds = subRoute.getLinkIds(); - Assert.assertEquals("number of links in subRoute.", 0, linkIds.size()); - Assert.assertEquals("wrong start link.", id1, subRoute.getStartLinkId()); - Assert.assertEquals("wrong end link.", id1, subRoute.getEndLinkId()); + Assertions.assertEquals(0, linkIds.size(), "number of links in subRoute."); + Assertions.assertEquals(id1, subRoute.getStartLinkId(), "wrong start link."); + Assertions.assertEquals(id1, subRoute.getEndLinkId(), "wrong end link."); NetworkRoute subRoute2 = route.getSubRoute(id2, id2); List> linkIds2 = subRoute2.getLinkIds(); - Assert.assertEquals("number of links in subRoute.", 0, linkIds2.size()); - Assert.assertEquals("wrong start link.", id2, subRoute2.getStartLinkId()); - Assert.assertEquals("wrong end link.", id2, subRoute2.getEndLinkId()); + Assertions.assertEquals(0, linkIds2.size(), "number of links in subRoute."); + Assertions.assertEquals(id2, subRoute2.getStartLinkId(), "wrong start link."); + Assertions.assertEquals(id2, subRoute2.getEndLinkId(), "wrong end link."); } @Test @@ -324,14 +324,14 @@ void testGetSubRoute_fullRoute() { NetworkRoute subRoute = route.getSubRoute(id0, id4); List> linkIds = subRoute.getLinkIds(); - Assert.assertEquals("number of links in subRoute.", 5, linkIds.size()); - Assert.assertEquals("wrong link.", Id.create("1", Link.class), subRoute.getLinkIds().get(0)); - Assert.assertEquals("wrong link.", Id.create("22", Link.class), subRoute.getLinkIds().get(1)); - Assert.assertEquals("wrong link.", Id.create("12", Link.class), subRoute.getLinkIds().get(2)); - Assert.assertEquals("wrong link.", Id.create("-23", Link.class), subRoute.getLinkIds().get(3)); - Assert.assertEquals("wrong link.", Id.create("3", Link.class), subRoute.getLinkIds().get(4)); - Assert.assertEquals("wrong start link.", id0, subRoute.getStartLinkId()); - Assert.assertEquals("wrong end link.", id4, subRoute.getEndLinkId()); + Assertions.assertEquals(5, linkIds.size(), "number of links in subRoute."); + Assertions.assertEquals(Id.create("1", Link.class), subRoute.getLinkIds().get(0), "wrong link."); + Assertions.assertEquals(Id.create("22", Link.class), subRoute.getLinkIds().get(1), "wrong link."); + Assertions.assertEquals(Id.create("12", Link.class), subRoute.getLinkIds().get(2), "wrong link."); + Assertions.assertEquals(Id.create("-23", Link.class), subRoute.getLinkIds().get(3), "wrong link."); + Assertions.assertEquals(Id.create("3", Link.class), subRoute.getLinkIds().get(4), "wrong link."); + Assertions.assertEquals(id0, subRoute.getStartLinkId(), "wrong start link."); + Assertions.assertEquals(id4, subRoute.getEndLinkId(), "wrong end link."); } @Test @@ -347,14 +347,14 @@ void testGetSubRoute_circleInRoute() { Id id14 = Id.create("14", Link.class); NetworkRoute subRoute = route.getSubRoute(id12, id14); List> linkIds = subRoute.getLinkIds(); - Assert.assertEquals("number of links in subRoute.", 5, linkIds.size()); - Assert.assertEquals("wrong link.", Id.create("13", Link.class), subRoute.getLinkIds().get(0)); - Assert.assertEquals("wrong link.", Id.create("-24", Link.class), subRoute.getLinkIds().get(1)); - Assert.assertEquals("wrong link.", Id.create("-3", Link.class), subRoute.getLinkIds().get(2)); - Assert.assertEquals("wrong link.", Id.create("23", Link.class), subRoute.getLinkIds().get(3)); - Assert.assertEquals("wrong link.", Id.create("13", Link.class), subRoute.getLinkIds().get(4)); - Assert.assertEquals("wrong start link.", id12, subRoute.getStartLinkId()); - Assert.assertEquals("wrong end link.", id14, subRoute.getEndLinkId()); + Assertions.assertEquals(5, linkIds.size(), "number of links in subRoute."); + Assertions.assertEquals(Id.create("13", Link.class), subRoute.getLinkIds().get(0), "wrong link."); + Assertions.assertEquals(Id.create("-24", Link.class), subRoute.getLinkIds().get(1), "wrong link."); + Assertions.assertEquals(Id.create("-3", Link.class), subRoute.getLinkIds().get(2), "wrong link."); + Assertions.assertEquals(Id.create("23", Link.class), subRoute.getLinkIds().get(3), "wrong link."); + Assertions.assertEquals(Id.create("13", Link.class), subRoute.getLinkIds().get(4), "wrong link."); + Assertions.assertEquals(id12, subRoute.getStartLinkId(), "wrong start link."); + Assertions.assertEquals(id14, subRoute.getEndLinkId(), "wrong end link."); } @Test @@ -370,11 +370,11 @@ void testGetSubRoute_startInCircle() { Id id23 = Id.create("23", Link.class); NetworkRoute subRoute = route.getSubRoute(id13, id23); List> linkIds = subRoute.getLinkIds(); - Assert.assertEquals("number of links in subRoute.", 2, linkIds.size()); - Assert.assertEquals("wrong link.", Id.create("-24", Link.class), subRoute.getLinkIds().get(0)); - Assert.assertEquals("wrong link.", Id.create("-3", Link.class), subRoute.getLinkIds().get(1)); - Assert.assertEquals("wrong start link.", id13, subRoute.getStartLinkId()); - Assert.assertEquals("wrong end link.", id23, subRoute.getEndLinkId()); + Assertions.assertEquals(2, linkIds.size(), "number of links in subRoute."); + Assertions.assertEquals(Id.create("-24", Link.class), subRoute.getLinkIds().get(0), "wrong link."); + Assertions.assertEquals(Id.create("-3", Link.class), subRoute.getLinkIds().get(1), "wrong link."); + Assertions.assertEquals(id13, subRoute.getStartLinkId(), "wrong start link."); + Assertions.assertEquals(id23, subRoute.getEndLinkId(), "wrong end link."); } @Test @@ -389,11 +389,11 @@ void testGetSubRoute_startInCircle_CircleInEnd() { Id id_24 = Id.create("-24", Link.class); NetworkRoute subRoute = route.getSubRoute(id_24, id13); List> linkIds = subRoute.getLinkIds(); - Assert.assertEquals("number of links in subRoute.", 2, linkIds.size()); - Assert.assertEquals("wrong link.", Id.create("-3", Link.class), subRoute.getLinkIds().get(0)); - Assert.assertEquals("wrong link.", Id.create("23", Link.class), subRoute.getLinkIds().get(1)); - Assert.assertEquals("wrong start link.", id_24, subRoute.getStartLinkId()); - Assert.assertEquals("wrong end link.", id13, subRoute.getEndLinkId()); + Assertions.assertEquals(2, linkIds.size(), "number of links in subRoute."); + Assertions.assertEquals(Id.create("-3", Link.class), subRoute.getLinkIds().get(0), "wrong link."); + Assertions.assertEquals(Id.create("23", Link.class), subRoute.getLinkIds().get(1), "wrong link."); + Assertions.assertEquals(id_24, subRoute.getStartLinkId(), "wrong start link."); + Assertions.assertEquals(id13, subRoute.getEndLinkId(), "wrong end link."); } @Test @@ -407,10 +407,10 @@ void testGetSubRoute_CircleAtStart() { NetworkRoute subRoute = route.getSubRoute(id13, id15); List> linkIds = subRoute.getLinkIds(); - Assert.assertEquals("number of links in subRoute.", 1, linkIds.size()); - Assert.assertEquals("wrong link.", Id.create("14", Link.class), subRoute.getLinkIds().get(0)); - Assert.assertEquals("wrong start link.", id13, subRoute.getStartLinkId()); - Assert.assertEquals("wrong end link.", id15, subRoute.getEndLinkId()); + Assertions.assertEquals(1, linkIds.size(), "number of links in subRoute."); + Assertions.assertEquals(Id.create("14", Link.class), subRoute.getLinkIds().get(0), "wrong link."); + Assertions.assertEquals(id13, subRoute.getStartLinkId(), "wrong start link."); + Assertions.assertEquals(id15, subRoute.getEndLinkId(), "wrong end link."); } @Test @@ -419,7 +419,7 @@ void testStartAndEndOnSameLinks_setLinks() { Id link = Id.create("3", Link.class); NetworkRoute route = getNetworkRouteInstance(link, link, network); route.setLinkIds(link, new ArrayList>(0), link); - Assert.assertEquals(0, route.getLinkIds().size()); + Assertions.assertEquals(0, route.getLinkIds().size()); } @Test @@ -429,7 +429,7 @@ void testStartAndEndOnSubsequentLinks_setLinks() { final Id link14 = Id.create("14", Link.class); NetworkRoute route = getNetworkRouteInstance(link13, link14, network); route.setLinkIds(link13, new ArrayList>(0), link14); - Assert.assertEquals(0, route.getLinkIds().size()); + Assertions.assertEquals(0, route.getLinkIds().size()); } @Test @@ -438,12 +438,12 @@ void testVehicleId() { Id link0 = Id.create("0", Link.class); Id link15 = Id.create("15", Link.class); NetworkRoute route = getNetworkRouteInstance(link0, link15, network); - Assert.assertNull(route.getVehicleId()); + Assertions.assertNull(route.getVehicleId()); Id id = Id.create("8134", Vehicle.class); route.setVehicleId(id); - Assert.assertEquals(id, route.getVehicleId()); + Assertions.assertEquals(id, route.getVehicleId()); route.setVehicleId(null); - Assert.assertNull(route.getVehicleId()); + Assertions.assertNull(route.getVehicleId()); } protected Network createTestNetwork() { diff --git a/matsim/src/test/java/org/matsim/core/population/routes/LinkNetworkRouteTest.java b/matsim/src/test/java/org/matsim/core/population/routes/LinkNetworkRouteTest.java index 82fcb5fb6d7..f06574e1ca5 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/LinkNetworkRouteTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/LinkNetworkRouteTest.java @@ -22,7 +22,7 @@ import java.util.ArrayList; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -56,15 +56,15 @@ void testClone() { srcRoute.add(link3.getId()); srcRoute.add(link4.getId()); route1.setLinkIds(startLink.getId(), srcRoute, endLink.getId()); - Assert.assertEquals(2, route1.getLinkIds().size()); + Assertions.assertEquals(2, route1.getLinkIds().size()); NetworkRoute route2 = (NetworkRoute) route1.clone(); srcRoute.add(link5.getId()); route1.setLinkIds(startLink.getId(), srcRoute, endLink.getId()); - Assert.assertEquals(3, route1.getLinkIds().size()); - Assert.assertEquals(2, route2.getLinkIds().size()); + Assertions.assertEquals(3, route1.getLinkIds().size()); + Assertions.assertEquals(2, route2.getLinkIds().size()); } } diff --git a/matsim/src/test/java/org/matsim/core/population/routes/NetworkFactoryTest.java b/matsim/src/test/java/org/matsim/core/population/routes/NetworkFactoryTest.java index 4288ce19e19..4477b446823 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/NetworkFactoryTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/NetworkFactoryTest.java @@ -20,7 +20,7 @@ package org.matsim.core.population.routes; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -114,10 +114,10 @@ void testSetRouteFactory() { // test default Route carRoute = factory.getRouteFactories().createRoute(NetworkRoute.class, null, null); - Assert.assertTrue(carRoute instanceof NetworkRoute); + Assertions.assertTrue(carRoute instanceof NetworkRoute); Route route = factory.getRouteFactories().createRoute(Route.class, null, null); - Assert.assertTrue(route instanceof GenericRouteImpl); + Assertions.assertTrue(route instanceof GenericRouteImpl); // overwrite car-mode factory.getRouteFactories().setRouteFactory(CarRouteMock.class, new CarRouteMockFactory()); @@ -126,18 +126,18 @@ void testSetRouteFactory() { // test car-mode carRoute = factory.getRouteFactories().createRoute(CarRouteMock.class, null, null); - Assert.assertTrue(carRoute instanceof CarRouteMock); + Assertions.assertTrue(carRoute instanceof CarRouteMock); // add pt-mode Route ptRoute = factory.getRouteFactories().createRoute(PtRouteMock.class, null, null); - Assert.assertTrue(ptRoute instanceof PtRouteMock); + Assertions.assertTrue(ptRoute instanceof PtRouteMock); // remove pt-mode factory.getRouteFactories().setRouteFactory(PtRouteMock.class, null); // test pt again route = factory.getRouteFactories().createRoute(PtRouteMock.class, null, null); - Assert.assertTrue(route instanceof GenericRouteImpl); + Assertions.assertTrue(route instanceof GenericRouteImpl); } diff --git a/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryImplTest.java b/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryImplTest.java index 943fb3c9adc..a058cde481a 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryImplTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryImplTest.java @@ -18,6 +18,7 @@ * *********************************************************************** */ package org.matsim.core.population.routes; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -31,8 +32,6 @@ import org.matsim.core.population.routes.mediumcompressed.MediumCompressedNetworkRoute; import org.matsim.core.scenario.ScenarioUtils; -import org.junit.Assert; - /** * @author mrieser / senozon */ @@ -47,7 +46,7 @@ void testConstructor_DefaultNetworkRouteType() { Id linkId = Id.create(1, Link.class); final Id startLinkId = linkId; final Id endLinkId = linkId; - Assert.assertEquals(GenericRouteImpl.class, pf.getRouteFactories().createRoute(Route.class, startLinkId, endLinkId).getClass()); + Assertions.assertEquals(GenericRouteImpl.class, pf.getRouteFactories().createRoute(Route.class, startLinkId, endLinkId).getClass()); } @Test @@ -60,7 +59,7 @@ void testConstructor_LinkNetworkRouteType() { Id linkId = Id.create(1, Link.class); final Id startLinkId = linkId; final Id endLinkId = linkId; - Assert.assertEquals(LinkNetworkRouteImpl.class, pf.getRouteFactories().createRoute(NetworkRoute.class, startLinkId, endLinkId).getClass()); + Assertions.assertEquals(LinkNetworkRouteImpl.class, pf.getRouteFactories().createRoute(NetworkRoute.class, startLinkId, endLinkId).getClass()); } @Test @@ -73,7 +72,7 @@ void testConstructor_HeavyCompressedNetworkRouteType() { Id linkId = Id.create(1, Link.class); final Id startLinkId = linkId; final Id endLinkId = linkId; - Assert.assertEquals(HeavyCompressedNetworkRoute.class, pf.getRouteFactories().createRoute(NetworkRoute.class, startLinkId, endLinkId).getClass()); + Assertions.assertEquals(HeavyCompressedNetworkRoute.class, pf.getRouteFactories().createRoute(NetworkRoute.class, startLinkId, endLinkId).getClass()); } @Test @@ -86,7 +85,7 @@ void testConstructor_MediumCompressedNetworkRouteType() { Id linkId = Id.create(1, Link.class); final Id startLinkId = linkId; final Id endLinkId = linkId; - Assert.assertEquals(MediumCompressedNetworkRoute.class, pf.getRouteFactories().createRoute(NetworkRoute.class, startLinkId, endLinkId).getClass()); + Assertions.assertEquals(MediumCompressedNetworkRoute.class, pf.getRouteFactories().createRoute(NetworkRoute.class, startLinkId, endLinkId).getClass()); } } diff --git a/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java b/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java index 25b4b0ba526..dfab4c52794 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java @@ -20,7 +20,7 @@ package org.matsim.core.population.routes; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.TransportMode; @@ -77,7 +77,7 @@ void testRouteFactoryIntegration() { if (pe instanceof Leg) { Leg leg = (Leg) pe; Route route = leg.getRoute(); - Assert.assertTrue(route instanceof NetworkRoute || route instanceof GenericRouteImpl ); // that must be different from the class used below + Assertions.assertTrue(route instanceof NetworkRoute || route instanceof GenericRouteImpl ); // that must be different from the class used below // yy I added the "|| route instanceof GenericRouteImpl" to compensate for the added walk legs; a more precise // test would be better. kai, feb'16 } @@ -105,8 +105,8 @@ void testRouteFactoryIntegration() { if (pe instanceof Leg) { Leg leg = (Leg) pe; Route route = leg.getRoute(); - Assert.assertTrue("person: " + person.getId() + "; plan: " + planCounter, - route instanceof HeavyCompressedNetworkRoute || route instanceof GenericRouteImpl ); + Assertions.assertTrue(route instanceof HeavyCompressedNetworkRoute || route instanceof GenericRouteImpl, + "person: " + person.getId() + "; plan: " + planCounter ); // yy I added the "|| route instanceof GenericRouteImpl" to compensate for the added walk legs; a more precise // test would be better. kai, feb'16 } diff --git a/matsim/src/test/java/org/matsim/core/population/routes/heavycompressed/HeavyCompressedNetworkRouteTest.java b/matsim/src/test/java/org/matsim/core/population/routes/heavycompressed/HeavyCompressedNetworkRouteTest.java index ed788d2cb1a..676caca941e 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/heavycompressed/HeavyCompressedNetworkRouteTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/heavycompressed/HeavyCompressedNetworkRouteTest.java @@ -20,7 +20,7 @@ package org.matsim.core.population.routes.heavycompressed; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -69,9 +69,9 @@ void testGetLinks_setLinks() { route.setLinkIds(link1.getId(), linkIds, link4.getId()); List> linksId2 = route.getLinkIds(); - Assert.assertEquals("wrong number of links.", linkIds.size(), linksId2.size()); + Assertions.assertEquals(linkIds.size(), linksId2.size(), "wrong number of links."); for (int i = 0, n = linkIds.size(); i < n; i++) { - Assert.assertEquals("different link at position " + i, linkIds.get(i), linksId2.get(i)); + Assertions.assertEquals(linkIds.get(i), linksId2.get(i), "different link at position " + i); } } @@ -96,9 +96,9 @@ void testGetLinks_onlySubsequentLinks() { route.setLinkIds(link0.getId(), linkIds, link4.getId()); List> linksId2 = route.getLinkIds(); - Assert.assertEquals("wrong number of links.", linkIds.size(), linksId2.size()); + Assertions.assertEquals(linkIds.size(), linksId2.size(), "wrong number of links."); for (int i = 0, n = linkIds.size(); i < n; i++) { - Assert.assertEquals("different link at position " + i, linkIds.get(i), linksId2.get(i)); + Assertions.assertEquals(linkIds.get(i), linksId2.get(i), "different link at position " + i); } } @@ -124,8 +124,8 @@ void testGetLinkIds_incompleteInitialization() { NetworkRoute route = new HeavyCompressedNetworkRoute(link0.getId(), link4.getId(), HeavyCompressedNetworkRouteFactory.createCompressionData(network, subsequentLinks)); // NO route.setLinks() here! - Assert.assertEquals("expected 0 links.", 0, route.getLinkIds().size()); - Assert.assertEquals("expected 0 link ids.", 0, route.getLinkIds().size()); + Assertions.assertEquals(0, route.getLinkIds().size(), "expected 0 links."); + Assertions.assertEquals(0, route.getLinkIds().size(), "expected 0 link ids."); } @Test @@ -169,15 +169,15 @@ void testClone() { ArrayList> srcRoute = new ArrayList<>(5); Collections.addAll(srcRoute, link3.getId(), link4.getId()); route1.setLinkIds(startLink.getId(), srcRoute, link5.getId()); - Assert.assertEquals(2, route1.getLinkIds().size()); + Assertions.assertEquals(2, route1.getLinkIds().size()); HeavyCompressedNetworkRoute route2 = route1.clone(); srcRoute.add(link5.getId()); route2.setLinkIds(startLink.getId(), srcRoute, endLink.getId()); - Assert.assertEquals(2, route1.getLinkIds().size()); - Assert.assertEquals(3, route2.getLinkIds().size()); + Assertions.assertEquals(2, route1.getLinkIds().size()); + Assertions.assertEquals(3, route2.getLinkIds().size()); } @Test @@ -195,9 +195,9 @@ void testGetLinks_setLinks_alternative() { route.setLinkIds(link1.getId(), linkIds, link4.getId()); List> linksId2 = route.getLinkIds(); - Assert.assertEquals("wrong number of links.", linkIds.size(), linksId2.size()); + Assertions.assertEquals(linkIds.size(), linksId2.size(), "wrong number of links."); for (int i = 0, n = linkIds.size(); i < n; i++) { - Assert.assertEquals("different link at position " + i, linkIds.get(i), linksId2.get(i)); + Assertions.assertEquals(linkIds.get(i), linksId2.get(i), "different link at position " + i); } } @@ -221,9 +221,9 @@ void testGetLinks_setLinks_endLoopLink() { route.setLinkIds(link1.getId(), linkIds, linkLoop5.getId()); List> linksId2 = route.getLinkIds(); - Assert.assertEquals("wrong number of links.", linkIds.size(), linksId2.size()); + Assertions.assertEquals(linkIds.size(), linksId2.size(), "wrong number of links."); for (int i = 0, n = linkIds.size(); i < n; i++) { - Assert.assertEquals("different link at position " + i, linkIds.get(i), linksId2.get(i)); + Assertions.assertEquals(linkIds.get(i), linksId2.get(i), "different link at position " + i); } } @@ -249,9 +249,9 @@ void testGetLinks_setLinks_containsLargeLoop() { route.setLinkIds(link1.getId(), linkIds, link4.getId()); List> linksId2 = route.getLinkIds(); - Assert.assertEquals("wrong number of links.", linkIds.size(), linksId2.size()); + Assertions.assertEquals(linkIds.size(), linksId2.size(), "wrong number of links."); for (int i = 0, n = linkIds.size(); i < n; i++) { - Assert.assertEquals("different link at position " + i, linkIds.get(i), linksId2.get(i)); + Assertions.assertEquals(linkIds.get(i), linksId2.get(i), "different link at position " + i); } } @@ -287,9 +287,9 @@ void testGetLinks_setLinks_containsLargeLoop_alternative() { route.setLinkIds(link1.getId(), linkIds, link23.getId()); List> linksId2 = route.getLinkIds(); - Assert.assertEquals("wrong number of links.", linkIds.size(), linksId2.size()); + Assertions.assertEquals(linkIds.size(), linksId2.size(), "wrong number of links."); for (int i = 0, n = linkIds.size(); i < n; i++) { - Assert.assertEquals("different link at position " + i, linkIds.get(i), linksId2.get(i)); + Assertions.assertEquals(linkIds.get(i), linksId2.get(i), "different link at position " + i); } } @@ -316,9 +316,9 @@ void testGetLinks_setLinks_isLargeLoop() { route.setLinkIds(link2.getId(), linkIds, link2.getId()); List> linksId2 = route.getLinkIds(); - Assert.assertEquals("wrong number of links.", linkIds.size(), linksId2.size()); + Assertions.assertEquals(linkIds.size(), linksId2.size(), "wrong number of links."); for (int i = 0, n = linkIds.size(); i < n; i++) { - Assert.assertEquals("different link at position " + i, linkIds.get(i), linksId2.get(i)); + Assertions.assertEquals(linkIds.get(i), linksId2.get(i), "different link at position " + i); } } diff --git a/matsim/src/test/java/org/matsim/core/population/routes/mediumcompressed/MediumCompressedNetworkRouteTest.java b/matsim/src/test/java/org/matsim/core/population/routes/mediumcompressed/MediumCompressedNetworkRouteTest.java index 483f7955606..afe9c68c62b 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/mediumcompressed/MediumCompressedNetworkRouteTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/mediumcompressed/MediumCompressedNetworkRouteTest.java @@ -20,7 +20,7 @@ package org.matsim.core.population.routes.mediumcompressed; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -68,9 +68,9 @@ void testGetLinks_setLinks() { route.setLinkIds(link1.getId(), linkIds, link4.getId()); List> linksId2 = route.getLinkIds(); - Assert.assertEquals("wrong number of links.", linkIds.size(), linksId2.size()); + Assertions.assertEquals(linkIds.size(), linksId2.size(), "wrong number of links."); for (int i = 0, n = linkIds.size(); i < n; i++) { - Assert.assertEquals("different link at position " + i, linkIds.get(i), linksId2.get(i)); + Assertions.assertEquals(linkIds.get(i), linksId2.get(i), "different link at position " + i); } } @@ -89,9 +89,9 @@ void testGetLinks_onlySubsequentLinks() { route.setLinkIds(link0.getId(), linkIds, link4.getId()); List> linksId2 = route.getLinkIds(); - Assert.assertEquals("wrong number of links.", linkIds.size(), linksId2.size()); + Assertions.assertEquals(linkIds.size(), linksId2.size(), "wrong number of links."); for (int i = 0, n = linkIds.size(); i < n; i++) { - Assert.assertEquals("different link at position " + i, linkIds.get(i), linksId2.get(i)); + Assertions.assertEquals(linkIds.get(i), linksId2.get(i), "different link at position " + i); } } @@ -108,8 +108,8 @@ void testGetLinkIds_incompleteInitialization() { NetworkRoute route = new MediumCompressedNetworkRoute(link0.getId(), link4.getId()); // NO route.setLinks() here! - Assert.assertEquals("expected 0 links.", 0, route.getLinkIds().size()); - Assert.assertEquals("expected 0 link ids.", 0, route.getLinkIds().size()); + Assertions.assertEquals(0, route.getLinkIds().size(), "expected 0 links."); + Assertions.assertEquals(0, route.getLinkIds().size(), "expected 0 link ids."); } @Test @@ -147,15 +147,15 @@ void testClone() { ArrayList> srcRoute = new ArrayList<>(5); Collections.addAll(srcRoute, link3.getId(), link4.getId()); route1.setLinkIds(startLink.getId(), srcRoute, link5.getId()); - Assert.assertEquals(2, route1.getLinkIds().size()); + Assertions.assertEquals(2, route1.getLinkIds().size()); MediumCompressedNetworkRoute route2 = route1.clone(); srcRoute.add(link5.getId()); route2.setLinkIds(startLink.getId(), srcRoute, endLink.getId()); - Assert.assertEquals(2, route1.getLinkIds().size()); - Assert.assertEquals(3, route2.getLinkIds().size()); + Assertions.assertEquals(2, route1.getLinkIds().size()); + Assertions.assertEquals(3, route2.getLinkIds().size()); } @Test @@ -173,9 +173,9 @@ void testGetLinks_setLinks_alternative() { route.setLinkIds(link1.getId(), linkIds, link4.getId()); List> linksId2 = route.getLinkIds(); - Assert.assertEquals("wrong number of links.", linkIds.size(), linksId2.size()); + Assertions.assertEquals(linkIds.size(), linksId2.size(), "wrong number of links."); for (int i = 0, n = linkIds.size(); i < n; i++) { - Assert.assertEquals("different link at position " + i, linkIds.get(i), linksId2.get(i)); + Assertions.assertEquals(linkIds.get(i), linksId2.get(i), "different link at position " + i); } } @@ -199,9 +199,9 @@ void testGetLinks_setLinks_endLoopLink() { route.setLinkIds(link1.getId(), linkIds, linkLoop5.getId()); List> linksId2 = route.getLinkIds(); - Assert.assertEquals("wrong number of links.", linkIds.size(), linksId2.size()); + Assertions.assertEquals(linkIds.size(), linksId2.size(), "wrong number of links."); for (int i = 0, n = linkIds.size(); i < n; i++) { - Assert.assertEquals("different link at position " + i, linkIds.get(i), linksId2.get(i)); + Assertions.assertEquals(linkIds.get(i), linksId2.get(i), "different link at position " + i); } } @@ -227,9 +227,9 @@ void testGetLinks_setLinks_containsLargeLoop() { route.setLinkIds(link1.getId(), linkIds, link4.getId()); List> linksId2 = route.getLinkIds(); - Assert.assertEquals("wrong number of links.", linkIds.size(), linksId2.size()); + Assertions.assertEquals(linkIds.size(), linksId2.size(), "wrong number of links."); for (int i = 0, n = linkIds.size(); i < n; i++) { - Assert.assertEquals("different link at position " + i, linkIds.get(i), linksId2.get(i)); + Assertions.assertEquals(linkIds.get(i), linksId2.get(i), "different link at position " + i); } } @@ -265,9 +265,9 @@ void testGetLinks_setLinks_containsLargeLoop_alternative() { route.setLinkIds(link1.getId(), linkIds, link23.getId()); List> linksId2 = route.getLinkIds(); - Assert.assertEquals("wrong number of links.", linkIds.size(), linksId2.size()); + Assertions.assertEquals(linkIds.size(), linksId2.size(), "wrong number of links."); for (int i = 0, n = linkIds.size(); i < n; i++) { - Assert.assertEquals("different link at position " + i, linkIds.get(i), linksId2.get(i)); + Assertions.assertEquals(linkIds.get(i), linksId2.get(i), "different link at position " + i); } } @@ -294,9 +294,9 @@ void testGetLinks_setLinks_isLargeLoop() { route.setLinkIds(link2.getId(), linkIds, link2.getId()); List> linksId2 = route.getLinkIds(); - Assert.assertEquals("wrong number of links.", linkIds.size(), linksId2.size()); + Assertions.assertEquals(linkIds.size(), linksId2.size(), "wrong number of links."); for (int i = 0, n = linkIds.size(); i < n; i++) { - Assert.assertEquals("different link at position " + i, linkIds.get(i), linksId2.get(i)); + Assertions.assertEquals(linkIds.get(i), linksId2.get(i), "different link at position " + i); } } diff --git a/matsim/src/test/java/org/matsim/core/replanning/PlanStrategyTest.java b/matsim/src/test/java/org/matsim/core/replanning/PlanStrategyTest.java index 00f3b6ba499..61f35fa4440 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/PlanStrategyTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/PlanStrategyTest.java @@ -20,7 +20,7 @@ package org.matsim.core.replanning; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/replanning/StrategyManagerSubpopulationsTest.java b/matsim/src/test/java/org/matsim/core/replanning/StrategyManagerSubpopulationsTest.java index df7709658c9..ce0f3336b16 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/StrategyManagerSubpopulationsTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/StrategyManagerSubpopulationsTest.java @@ -22,7 +22,7 @@ import java.util.Random; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.HasPlansAndId; @@ -80,10 +80,10 @@ public void run(HasPlansAndId person) { counter.incCounter(); Person person1 = population.getPersons().get( person.getId() ) ; Gbl.assertNotNull( person1 ); - Assert.assertNull( - "unexpected subpopulation", + Assertions.assertNull( + PopulationUtils.getSubpopulation( person1 ), // PopulationUtils.getPersonAttribute( person1, SUBPOP_ATT_NAME) ); - PopulationUtils.getSubpopulation( person1 ) ); + "unexpected subpopulation" ); } @@ -101,11 +101,12 @@ public void run(HasPlansAndId person) { counter.incCounter(); Person person1 = population.getPersons().get( person.getId() ) ; Gbl.assertNotNull( person1 ); - Assert.assertEquals( - "unexpected subpopulation", + Assertions.assertEquals( POP_NAME_1, // PopulationUtils.getPersonAttribute( person1, SUBPOP_ATT_NAME) ); - PopulationUtils.getSubpopulation( person1 ) ); + PopulationUtils.getSubpopulation( person1 ), +// PopulationUtils.getPersonAttribute( person1, SUBPOP_ATT_NAME) ); + "unexpected subpopulation" ); } @Override @@ -122,11 +123,12 @@ public void run(HasPlansAndId person) { counter.incCounter(); Person person1 = population.getPersons().get( person.getId() ) ; Gbl.assertNotNull( person1 ); - Assert.assertEquals( - "unexpected subpopulation", + Assertions.assertEquals( POP_NAME_2, // PopulationUtils.getPersonAttribute( person1, SUBPOP_ATT_NAME) ); - PopulationUtils.getSubpopulation( person1 ) ); + PopulationUtils.getSubpopulation( person1 ), +// PopulationUtils.getPersonAttribute( person1, SUBPOP_ATT_NAME) ); + "unexpected subpopulation" ); } @Override diff --git a/matsim/src/test/java/org/matsim/core/replanning/StrategyManagerTest.java b/matsim/src/test/java/org/matsim/core/replanning/StrategyManagerTest.java index 90748e9f33b..24c87c752de 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/StrategyManagerTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/StrategyManagerTest.java @@ -20,7 +20,7 @@ package org.matsim.core.replanning; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.HasPlansAndId; @@ -39,8 +39,7 @@ import java.util.List; -import static org.junit.Assert.*; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; public class StrategyManagerTest { @@ -236,7 +235,7 @@ void testOptimisticBehavior() { for (int i = 0; i < 4; i++) { manager.run(population, i, null); Plan plan = person.getSelectedPlan(); - assertNull("plan has not undefined score in iteration " + i, plan.getScore()); + assertNull(plan.getScore(), "plan has not undefined score in iteration " + i); plan.setScore(Double.valueOf(i)); } @@ -272,22 +271,22 @@ void testSetPlanSelectorForRemoval() { manager.setMaxPlansPerAgent(plans.length - 2); manager.run(pop, -1,null); - assertEquals("wrong number of plans.", 5, p.getPlans().size()); + assertEquals(5, p.getPlans().size(), "wrong number of plans."); // default of StrategyManager is to remove worst plans: - assertFalse("plan should have been removed.", p.getPlans().contains(plans[0])); - assertFalse("plan should have been removed.", p.getPlans().contains(plans[1])); - assertTrue("plan should not have been removed.", p.getPlans().contains(plans[2])); + assertFalse(p.getPlans().contains(plans[0]), "plan should have been removed."); + assertFalse(p.getPlans().contains(plans[1]), "plan should have been removed."); + assertTrue(p.getPlans().contains(plans[2]), "plan should not have been removed."); // change plan selector for removal and run again manager.setPlanSelectorForRemoval(new BestPlanSelector()); manager.setMaxPlansPerAgent(plans.length - 4); manager.run(pop, -1,null); - assertEquals("wrong number of plans.", 3, p.getPlans().size()); + assertEquals(3, p.getPlans().size(), "wrong number of plans."); // default of StrategyManager is to remove worst plans: - assertFalse("plan should have been removed.", p.getPlans().contains(plans[plans.length - 1])); - assertFalse("plan should have been removed.", p.getPlans().contains(plans[plans.length - 2])); - assertTrue("plan should not have been removed.", p.getPlans().contains(plans[plans.length - 3])); + assertFalse(p.getPlans().contains(plans[plans.length - 1]), "plan should have been removed."); + assertFalse(p.getPlans().contains(plans[plans.length - 2]), "plan should have been removed."); + assertTrue(p.getPlans().contains(plans[plans.length - 3]), "plan should not have been removed."); } @Test @@ -303,11 +302,11 @@ void testGetStrategies() { manager.addStrategy( str3, null, 0.5 ); List> strategies = manager.getStrategies( null ); - Assert.assertEquals(3, strategies.size()); + Assertions.assertEquals(3, strategies.size()); - Assert.assertEquals(str1, strategies.get(0)); - Assert.assertEquals(str2, strategies.get(1)); - Assert.assertEquals(str3, strategies.get(2)); + Assertions.assertEquals(str1, strategies.get(0)); + Assertions.assertEquals(str2, strategies.get(1)); + Assertions.assertEquals(str3, strategies.get(2)); } @Test @@ -323,11 +322,11 @@ void testGetWeights() { manager.addStrategy( str3, null, 0.5 ); List weights = manager.getWeights( null ); - Assert.assertEquals(3, weights.size()); + Assertions.assertEquals(3, weights.size()); - Assert.assertEquals(1.0, weights.get(0), 1e-8); - Assert.assertEquals(2.0, weights.get(1), 1e-8); - Assert.assertEquals(0.5, weights.get(2), 1e-8); + Assertions.assertEquals(1.0, weights.get(0), 1e-8); + Assertions.assertEquals(2.0, weights.get(1), 1e-8); + Assertions.assertEquals(0.5, weights.get(2), 1e-8); } @Test @@ -350,29 +349,29 @@ void testGetWeights_ChangeRequests() { manager.run(pop, 1, null); List weights = manager.getWeights( null ); - Assert.assertEquals(3, weights.size()); + Assertions.assertEquals(3, weights.size()); - Assert.assertEquals(1.0, weights.get(0), 1e-8); - Assert.assertEquals(2.0, weights.get(1), 1e-8); - Assert.assertEquals(0.5, weights.get(2), 1e-8); + Assertions.assertEquals(1.0, weights.get(0), 1e-8); + Assertions.assertEquals(2.0, weights.get(1), 1e-8); + Assertions.assertEquals(0.5, weights.get(2), 1e-8); manager.run(pop, 5, null); weights = manager.getWeights( null ); - Assert.assertEquals(3, weights.size()); + Assertions.assertEquals(3, weights.size()); - Assert.assertEquals(1.0, weights.get(0), 1e-8); - Assert.assertEquals(3.0, weights.get(1), 1e-8); - Assert.assertEquals(0.5, weights.get(2), 1e-8); + Assertions.assertEquals(1.0, weights.get(0), 1e-8); + Assertions.assertEquals(3.0, weights.get(1), 1e-8); + Assertions.assertEquals(0.5, weights.get(2), 1e-8); manager.run(pop, 10, null); weights = manager.getWeights( null ); - Assert.assertEquals(3, weights.size()); + Assertions.assertEquals(3, weights.size()); - Assert.assertEquals(1.0, weights.get(0), 1e-8); - Assert.assertEquals(3.0, weights.get(1), 1e-8); - Assert.assertEquals(1.0, weights.get(2), 1e-8); + Assertions.assertEquals(1.0, weights.get(0), 1e-8); + Assertions.assertEquals(3.0, weights.get(1), 1e-8); + Assertions.assertEquals(1.0, weights.get(2), 1e-8); } /** diff --git a/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java b/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java index 4d2a55cfbb1..fc56e540746 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java @@ -3,8 +3,8 @@ import java.io.BufferedReader; import java.io.IOException; import java.util.List; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -200,12 +200,12 @@ void testLinearAnneal() throws IOException { Controler controler = new Controler(this.scenario); controler.run(); - Assert.assertEquals(expectedLinearAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); + Assertions.assertEquals(expectedLinearAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); StrategyManager sm = controler.getInjector().getInstance(StrategyManager.class); List weights = sm.getWeights(null); - Assert.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); + Assertions.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); } @Test @@ -217,12 +217,12 @@ void testMsaAnneal() throws IOException { Controler controler = new Controler(this.scenario); controler.run(); - Assert.assertEquals(expectedMsaAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); + Assertions.assertEquals(expectedMsaAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); StrategyManager sm = controler.getInjector().getInstance(StrategyManager.class); List weights = sm.getWeights(null); - Assert.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); + Assertions.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); } @Test @@ -234,12 +234,12 @@ void testGeometricAnneal() throws IOException { Controler controler = new Controler(this.scenario); controler.run(); - Assert.assertEquals(expectedGeometricAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); + Assertions.assertEquals(expectedGeometricAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); StrategyManager sm = controler.getInjector().getInstance(StrategyManager.class); List weights = sm.getWeights(null); - Assert.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); + Assertions.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); } @Test @@ -251,12 +251,12 @@ void testExponentialAnneal() throws IOException { Controler controler = new Controler(this.scenario); controler.run(); - Assert.assertEquals(expectedExponentialAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); + Assertions.assertEquals(expectedExponentialAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); StrategyManager sm = controler.getInjector().getInstance(StrategyManager.class); List weights = sm.getWeights(null); - Assert.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); + Assertions.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); } @Test @@ -269,12 +269,12 @@ void testSigmoidAnneal() throws IOException { Controler controler = new Controler(this.scenario); controler.run(); - Assert.assertEquals(expectedSigmoidAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); + Assertions.assertEquals(expectedSigmoidAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); StrategyManager sm = controler.getInjector().getInstance(StrategyManager.class); List weights = sm.getWeights(null); - Assert.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); + Assertions.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); } @Test @@ -287,8 +287,8 @@ void testParameterAnneal() throws IOException { Controler controler = new Controler(this.scenario); controler.run(); - Assert.assertEquals(expectedParameterAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); - Assert.assertEquals(0.0, controler.getConfig().scoring().getBrainExpBeta(), 1e-4); + Assertions.assertEquals(expectedParameterAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); + Assertions.assertEquals(0.0, controler.getConfig().scoring().getBrainExpBeta(), 1e-4); } @Test @@ -307,13 +307,13 @@ void testTwoParameterAnneal() throws IOException { Controler controler = new Controler(this.scenario); controler.run(); - Assert.assertEquals(expectedTwoParameterAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); - Assert.assertEquals(0.0, controler.getConfig().scoring().getBrainExpBeta(), 1e-4); + Assertions.assertEquals(expectedTwoParameterAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); + Assertions.assertEquals(0.0, controler.getConfig().scoring().getBrainExpBeta(), 1e-4); StrategyManager sm = controler.getInjector().getInstance(StrategyManager.class); List weights = sm.getWeights(null); - Assert.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); + Assertions.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); } @Test @@ -326,12 +326,12 @@ void testInnovationSwitchoffAnneal() throws IOException { Controler controler = new Controler(this.scenario); controler.run(); - Assert.assertEquals(expectedInnovationSwitchoffAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); + Assertions.assertEquals(expectedInnovationSwitchoffAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); StrategyManager sm = controler.getInjector().getInstance(StrategyManager.class); List weights = sm.getWeights(null); - Assert.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); + Assertions.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); } @Test @@ -344,12 +344,12 @@ void testFreezeEarlyAnneal() throws IOException { Controler controler = new Controler(this.scenario); controler.run(); - Assert.assertEquals(expectedFreezeEarlyAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); + Assertions.assertEquals(expectedFreezeEarlyAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); StrategyManager sm = controler.getInjector().getInstance(StrategyManager.class); List weights = sm.getWeights(null); - Assert.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); + Assertions.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); } @Test @@ -369,12 +369,12 @@ void testSubpopulationAnneal() throws IOException { Controler controler = new Controler(this.scenario); controler.run(); - Assert.assertEquals(expectedLinearAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); + Assertions.assertEquals(expectedLinearAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); StrategyManager sm = controler.getInjector().getInstance(StrategyManager.class); List weights = sm.getWeights(targetSubpop); - Assert.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); + Assertions.assertEquals(1.0, weights.stream().mapToDouble(Double::doubleValue).sum(), 1e-4); } } diff --git a/matsim/src/test/java/org/matsim/core/replanning/choosers/ForceInnovationStrategyChooserTest.java b/matsim/src/test/java/org/matsim/core/replanning/choosers/ForceInnovationStrategyChooserTest.java index b6683edb58c..f1722a11e41 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/choosers/ForceInnovationStrategyChooserTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/choosers/ForceInnovationStrategyChooserTest.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; diff --git a/matsim/src/test/java/org/matsim/core/replanning/conflicts/ReplanningWithConflictsTest.java b/matsim/src/test/java/org/matsim/core/replanning/conflicts/ReplanningWithConflictsTest.java index 1015bd7582c..81b9522bb1b 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/conflicts/ReplanningWithConflictsTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/conflicts/ReplanningWithConflictsTest.java @@ -1,6 +1,6 @@ package org.matsim.core.replanning.conflicts; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/replanning/modules/AbstractMultithreadedModuleTest.java b/matsim/src/test/java/org/matsim/core/replanning/modules/AbstractMultithreadedModuleTest.java index 042b090e267..583a1ad2df3 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/modules/AbstractMultithreadedModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/modules/AbstractMultithreadedModuleTest.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.population.Plan; import org.matsim.core.config.Config; @@ -42,7 +42,7 @@ void testGetNumOfThreads() { config.addCoreModules(); config.global().setNumberOfThreads(3); DummyAbstractMultithreadedModule testee = new DummyAbstractMultithreadedModule(config.global()); - Assert.assertEquals(3, testee.getNumOfThreads()); + Assertions.assertEquals(3, testee.getNumOfThreads()); } @Test @@ -54,7 +54,7 @@ void testCrashingThread() { testee.handlePlan(null); testee.handlePlan(null); testee.finishReplanning(); - Assert.fail("expected exception, got none."); + Assertions.fail("expected exception, got none."); } catch (Exception e) { log.info("Catched expected exception.", e); } diff --git a/matsim/src/test/java/org/matsim/core/replanning/modules/ChangeLegModeTest.java b/matsim/src/test/java/org/matsim/core/replanning/modules/ChangeLegModeTest.java index b3fb4b3a27c..53621cacc8d 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/modules/ChangeLegModeTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/modules/ChangeLegModeTest.java @@ -20,7 +20,7 @@ package org.matsim.core.replanning.modules; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -122,7 +122,7 @@ void testWithConfig_withoutIgnoreCarAvailability() { Integer count = counter.get(leg.getMode()); counter.put(leg.getMode(), Integer.valueOf(count.intValue() + 1)); } - Assert.assertEquals(0, counter.get("car").intValue()); + Assertions.assertEquals(0, counter.get("car").intValue()); } private void runTest(final ChangeLegMode module, final String[] possibleModes) { @@ -141,13 +141,13 @@ private void runTest(final ChangeLegMode module, final String[] possibleModes) { for (int i = 0; i < 50; i++) { module.handlePlan(plan); Integer count = counter.get(leg.getMode()); - Assert.assertNotNull("unexpected mode: " + leg.getMode(), count); + Assertions.assertNotNull(count, "unexpected mode: " + leg.getMode()); counter.put(leg.getMode(), Integer.valueOf(count.intValue() + 1)); } for (Map.Entry entry : counter.entrySet()) { int count = entry.getValue().intValue(); - Assert.assertTrue("mode " + entry.getKey() + " was never chosen.", count > 0); + Assertions.assertTrue(count > 0, "mode " + entry.getKey() + " was never chosen."); } } } diff --git a/matsim/src/test/java/org/matsim/core/replanning/modules/ChangeSingleLegModeTest.java b/matsim/src/test/java/org/matsim/core/replanning/modules/ChangeSingleLegModeTest.java index fd66a829450..2e590fc9299 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/modules/ChangeSingleLegModeTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/modules/ChangeSingleLegModeTest.java @@ -23,7 +23,7 @@ import java.util.HashMap; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -98,7 +98,7 @@ void testWithConfig_withoutIgnoreCarAvailability() { Integer count = counter.get(leg.getMode()); counter.put(leg.getMode(), Integer.valueOf(count.intValue() + 1)); } - Assert.assertEquals(0, counter.get("car").intValue()); + Assertions.assertEquals(0, counter.get("car").intValue()); } private void runTest(final ChangeSingleLegMode module, final String[] possibleModes, final int nOfTries) { @@ -117,13 +117,13 @@ private void runTest(final ChangeSingleLegMode module, final String[] possibleMo for (int i = 0; i < nOfTries; i++) { module.handlePlan(plan); Integer count = counter.get(leg.getMode()); - Assert.assertNotNull("unexpected mode: " + leg.getMode(), count); + Assertions.assertNotNull(count, "unexpected mode: " + leg.getMode()); counter.put(leg.getMode(), Integer.valueOf(count.intValue() + 1)); } for (Map.Entry entry : counter.entrySet()) { int count = entry.getValue().intValue(); - Assert.assertTrue("mode " + entry.getKey() + " was never chosen.", count > 0); + Assertions.assertTrue(count > 0, "mode " + entry.getKey() + " was never chosen."); } } } diff --git a/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java b/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java index d739f20c19c..61f0dff7923 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java @@ -22,8 +22,8 @@ package org.matsim.core.replanning.modules; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -82,7 +82,7 @@ public boolean invoke() { } }, "test", outputDirectoryHierarchy, scenario); replanPopulation(scenario.getPopulation(), testee); - Assert.assertTrue(PopulationUtils.equalPopulation(scenario.getPopulation(), originalScenario.getPopulation())); + Assertions.assertTrue(PopulationUtils.equalPopulation(scenario.getPopulation(), originalScenario.getPopulation())); } @Test @@ -99,7 +99,7 @@ public boolean invoke() { } }, "test", outputDirectoryHierarchy, scenario); replanPopulation(scenario.getPopulation(), testee); - Assert.assertFalse(PopulationUtils.equalPopulation(scenario.getPopulation(), originalScenario.getPopulation())); + Assertions.assertFalse(PopulationUtils.equalPopulation(scenario.getPopulation(), originalScenario.getPopulation())); } private Population loadPopulation(String filename) { diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/AbstractPlanSelectorTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/AbstractPlanSelectorTest.java index 8b0774ada00..0412fa36c31 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/AbstractPlanSelectorTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/AbstractPlanSelectorTest.java @@ -20,8 +20,8 @@ package org.matsim.core.replanning.selectors; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/BestPlanSelectorTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/BestPlanSelectorTest.java index 53a61e636db..dd86806d2e1 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/BestPlanSelectorTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/BestPlanSelectorTest.java @@ -20,8 +20,8 @@ package org.matsim.core.replanning.selectors; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelectorTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelectorTest.java index fa08c8705d5..62ffb7eaaeb 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelectorTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelectorTest.java @@ -20,7 +20,7 @@ package org.matsim.core.replanning.selectors; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/KeepSelectedTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/KeepSelectedTest.java index 97f74593bc3..6c8dbb5fc91 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/KeepSelectedTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/KeepSelectedTest.java @@ -20,7 +20,7 @@ package org.matsim.core.replanning.selectors; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/PathSizeLogitSelectorTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/PathSizeLogitSelectorTest.java index 6a50781d5c5..905a8f32cdb 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/PathSizeLogitSelectorTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/PathSizeLogitSelectorTest.java @@ -20,8 +20,8 @@ package org.matsim.core.replanning.selectors; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.ArrayList; diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/RandomPlanSelectorTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/RandomPlanSelectorTest.java index 2d1bd9c14b5..9b56aafd4c1 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/RandomPlanSelectorTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/RandomPlanSelectorTest.java @@ -20,7 +20,7 @@ package org.matsim.core.replanning.selectors; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/WorstPlanForRemovalSelectorTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/WorstPlanForRemovalSelectorTest.java index 631173aa68d..c7e0a826528 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/WorstPlanForRemovalSelectorTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/WorstPlanForRemovalSelectorTest.java @@ -20,7 +20,7 @@ package org.matsim.core.replanning.selectors; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; @@ -60,20 +60,20 @@ void testRemoveWorstPlans_nullType() { person.addPlan(plan4); person.addPlan(plan5); - assertEquals("test we have all plans we want", 5, person.getPlans().size()); + assertEquals(5, person.getPlans().size(), "test we have all plans we want"); person.getPlans().remove(selector.selectPlan(person)); - assertEquals("test that a plan was removed", 4, person.getPlans().size()); - assertFalse("test that plan with undefined score was removed.", person.getPlans().contains(plan3)); + assertEquals(4, person.getPlans().size(), "test that a plan was removed"); + assertFalse(person.getPlans().contains(plan3), "test that plan with undefined score was removed."); person.getPlans().remove(selector.selectPlan(person)); - assertEquals("test that a plan was removed", 3, person.getPlans().size()); - assertFalse("test that the plan with minimal score was removed", person.getPlans().contains(plan4)); + assertEquals(3, person.getPlans().size(), "test that a plan was removed"); + assertFalse(person.getPlans().contains(plan4), "test that the plan with minimal score was removed"); person.getPlans().remove(selector.selectPlan(person)); person.getPlans().remove(selector.selectPlan(person)); - assertEquals("test that two plans were removed", 1, person.getPlans().size()); - assertTrue("test that the plan left has highest score", person.getPlans().contains(plan2)); + assertEquals(1, person.getPlans().size(), "test that two plans were removed"); + assertTrue(person.getPlans().contains(plan2), "test that the plan left has highest score"); } /** @@ -119,24 +119,24 @@ void testRemoveWorstPlans_withTypes() { person.addPlan(plan5); person.addPlan(plan6); - assertEquals("test we have all plans we want", 6, person.getPlans().size()); + assertEquals(6, person.getPlans().size(), "test we have all plans we want"); person.getPlans().remove(selector.selectPlan(person)); person.getPlans().remove(selector.selectPlan(person)); - assertEquals("test that two plans were removed", 4, person.getPlans().size()); - assertFalse("test that plan with undefined score was removed.", person.getPlans().contains(plan3)); - assertFalse("test that plan with worst score was removed.", person.getPlans().contains(plan4)); + assertEquals(4, person.getPlans().size(), "test that two plans were removed"); + assertFalse(person.getPlans().contains(plan3), "test that plan with undefined score was removed."); + assertFalse(person.getPlans().contains(plan4), "test that plan with worst score was removed."); person.getPlans().remove(selector.selectPlan(person)); person.getPlans().remove(selector.selectPlan(person)); - assertEquals("test that two plans were removed", 2, person.getPlans().size()); - assertFalse("test that the plan with worst score was removed", person.getPlans().contains(plan1)); - assertTrue("test that the now only plan of type a was not removed", person.getPlans().contains(plan5)); - assertFalse("test that the plan with the 2nd-worst score was removed", person.getPlans().contains(plan6)); + assertEquals(2, person.getPlans().size(), "test that two plans were removed"); + assertFalse(person.getPlans().contains(plan1), "test that the plan with worst score was removed"); + assertTrue(person.getPlans().contains(plan5), "test that the now only plan of type a was not removed"); + assertFalse(person.getPlans().contains(plan6), "test that the plan with the 2nd-worst score was removed"); person.getPlans().remove(selector.selectPlan(person)); - assertEquals("test that one plan was removed", 1, person.getPlans().size()); - assertTrue("test that the plan with highest score of type b was not removed", person.getPlans().contains(plan2)); + assertEquals(1, person.getPlans().size(), "test that one plan was removed"); + assertTrue(person.getPlans().contains(plan2), "test that the plan with highest score of type b was not removed"); } } diff --git a/matsim/src/test/java/org/matsim/core/replanning/strategies/DeterministicMultithreadedReplanningIT.java b/matsim/src/test/java/org/matsim/core/replanning/strategies/DeterministicMultithreadedReplanningIT.java index 1e32151930b..898ccfd8b2e 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/strategies/DeterministicMultithreadedReplanningIT.java +++ b/matsim/src/test/java/org/matsim/core/replanning/strategies/DeterministicMultithreadedReplanningIT.java @@ -21,8 +21,7 @@ package org.matsim.core.replanning.strategies; import com.google.inject.Singleton; - -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -98,13 +97,13 @@ void testTimeAllocationMutator() { long cksum1 = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "/run1/ITERS/it."+ i +"/"+ i +".events.xml.gz"); long cksum2 = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "/run2/ITERS/it."+ i +"/"+ i +".events.xml.gz"); - Assert.assertEquals("The checksums of events must be the same in iteration " + i + ", even when multiple threads are used.", cksum1, cksum2); + Assertions.assertEquals(cksum1, cksum2, "The checksums of events must be the same in iteration " + i + ", even when multiple threads are used."); } for (int i = 0; i < 2; i++) { long pcksum1 = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "/run1/ITERS/it."+ i +"/"+ i +".plans.xml.gz"); long pcksum2 = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "/run2/ITERS/it."+ i +"/"+ i +".plans.xml.gz"); - Assert.assertEquals("The checksums of plans must be the same in iteration " + i + ", even when multiple threads are used.", pcksum1, pcksum2); + Assertions.assertEquals(pcksum1, pcksum2, "The checksums of plans must be the same in iteration " + i + ", even when multiple threads are used."); } } @@ -151,13 +150,13 @@ void testReRouteTimeAllocationMutator() { long cksum1 = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "/run1/ITERS/it."+ i +"/"+ i +".events.xml.gz"); long cksum2 = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "/run2/ITERS/it."+ i +"/"+ i +".events.xml.gz"); - Assert.assertEquals("The checksums of events must be the same in iteration " + i + ", even when multiple threads are used.", cksum1, cksum2); + Assertions.assertEquals(cksum1, cksum2, "The checksums of events must be the same in iteration " + i + ", even when multiple threads are used."); } for (int i = 0; i < 2; i++) { long pcksum1 = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "/run1/ITERS/it."+ i +"/"+ i +".plans.xml.gz"); long pcksum2 = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "/run2/ITERS/it."+ i +"/"+ i +".plans.xml.gz"); - Assert.assertEquals("The checksums of plans must be the same in iteration " + i + ", even when multiple threads are used.", pcksum1, pcksum2); + Assertions.assertEquals(pcksum1, pcksum2, "The checksums of plans must be the same in iteration " + i + ", even when multiple threads are used."); } } @@ -205,13 +204,13 @@ void testReRouteOneAgent() { long cksum1 = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "/run1/ITERS/it."+ i +"/"+ i +".events.xml.gz"); long cksum2 = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "/run2/ITERS/it."+ i +"/"+ i +".events.xml.gz"); - Assert.assertEquals("The checksums of events must be the same in iteration " + i + ", even when multiple threads are used.", cksum1, cksum2); + Assertions.assertEquals(cksum1, cksum2, "The checksums of events must be the same in iteration " + i + ", even when multiple threads are used."); } for (int i = 0; i < 2; i++) { long pcksum1 = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "/run1/ITERS/it."+ i +"/"+ i +".plans.xml.gz"); long pcksum2 = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "/run2/ITERS/it."+ i +"/"+ i +".plans.xml.gz"); - Assert.assertEquals("The checksums of plans must be the same in iteration " + i + ", even when multiple threads are used.", pcksum1, pcksum2); + Assertions.assertEquals(pcksum1, pcksum2, "The checksums of plans must be the same in iteration " + i + ", even when multiple threads are used."); } } @@ -257,13 +256,13 @@ void testReRoute() { long cksum1 = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "/run1/ITERS/it."+ i +"/"+ i +".events.xml.gz"); long cksum2 = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "/run2/ITERS/it."+ i +"/"+ i +".events.xml.gz"); - Assert.assertEquals("The checksums of events must be the same in iteration " + i + ", even when multiple threads are used.", cksum1, cksum2); + Assertions.assertEquals(cksum1, cksum2, "The checksums of events must be the same in iteration " + i + ", even when multiple threads are used."); } for (int i = 0; i < 2; i++) { long pcksum1 = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "/run1/ITERS/it."+ i +"/"+ i +".plans.xml.gz"); long pcksum2 = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "/run2/ITERS/it."+ i +"/"+ i +".plans.xml.gz"); - Assert.assertEquals("The checksums of plans must be the same in iteration " + i + ", even when multiple threads are used.", pcksum1, pcksum2); + Assertions.assertEquals(pcksum1, pcksum2, "The checksums of plans must be the same in iteration " + i + ", even when multiple threads are used."); } } diff --git a/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java b/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java index 16d45333e37..f62b40c44e2 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java @@ -23,7 +23,7 @@ package org.matsim.core.replanning.strategies; import com.google.inject.*; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -139,18 +139,18 @@ public void notifyBeforeMobsim(BeforeMobsimEvent event) { for ( int ii = 0 ; ii < sm.getStrategies( null ).size(); ii++) { log.warn("strategy " + sm.getStrategies( null ).get(ii ) + " has weight " + sm.getWeights( null ).get(ii ) ); if (event.getIteration() == 11 && sm.getStrategies( null ).get(ii ).toString().contains(ReRoute.class.getSimpleName() )) { - Assert.assertEquals(0.1, sm.getWeights( null ).get(ii ), 0.000001 ); + Assertions.assertEquals(0.1, sm.getWeights( null ).get(ii ), 0.000001 ); } if (event.getIteration() == 12 && sm.getStrategies( null ).get(ii ).toString().contains(ReRoute.class.getSimpleName() )) { - Assert.assertEquals(0., sm.getWeights( null ).get(ii ), 0.000001 ); + Assertions.assertEquals(0., sm.getWeights( null ).get(ii ), 0.000001 ); } if (event.getIteration() == 13 && sm.getStrategies( null ).get(ii ).toString().contains( TimeAllocationMutatorModule.class.getSimpleName() )) { - Assert.assertEquals(0.1, sm.getWeights( null ).get(ii ), 0.000001 ); + Assertions.assertEquals(0.1, sm.getWeights( null ).get(ii ), 0.000001 ); } if (event.getIteration() == 14 && sm.getStrategies( null ).get(ii ).toString().contains( TimeAllocationMutatorModule.class.getSimpleName() )) { - Assert.assertEquals(0.0, sm.getWeights( null ).get(ii ), 0.000001 ); + Assertions.assertEquals(0.0, sm.getWeights( null ).get(ii ), 0.000001 ); } } System.err.flush(); diff --git a/matsim/src/test/java/org/matsim/core/replanning/strategies/TimeAllocationMutatorModuleTest.java b/matsim/src/test/java/org/matsim/core/replanning/strategies/TimeAllocationMutatorModuleTest.java index e82ed18aab7..2c8396b447e 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/strategies/TimeAllocationMutatorModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/strategies/TimeAllocationMutatorModuleTest.java @@ -20,9 +20,9 @@ package org.matsim.core.replanning.strategies; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -126,16 +126,16 @@ private void runSimplifiedMutationRangeTest(final PlanAlgorithm tripPlanMutateTi if (diff > maxDiff1) maxDiff1 = diff; if (diff < minDiff1) minDiff1 = diff; act1End = act1.getEndTime().seconds(); - assertTrue("activity end time cannot be smaller than 0, is " + act1End, act1End >= 0.0); + assertTrue(act1End >= 0.0, "activity end time cannot be smaller than 0, is " + act1End); // test end time of act2 diff = act2Dur - act2.getMaximumDuration().seconds(); if (diff > maxDiff2) maxDiff2 = diff; if (diff < minDiff2) minDiff2 = diff; act2Dur = act2.getMaximumDuration().seconds(); - assertTrue("activity duration cannot be smaller than 0, is " + act2Dur, act2Dur >= 0.0); + assertTrue(act2Dur >= 0.0, "activity duration cannot be smaller than 0, is " + act2Dur); } - assertTrue("mutation range differences wrong (act1).", minDiff1 <= maxDiff1); - assertTrue("mutation range differences wrong (act2).", minDiff2 <= maxDiff2); + assertTrue(minDiff1 <= maxDiff1, "mutation range differences wrong (act1)."); + assertTrue(minDiff2 <= maxDiff2, "mutation range differences wrong (act2)."); /* The following asserts are dependent on random numbers. * But I would still expect that we get up to at least 95% of the limit... */ @@ -146,7 +146,7 @@ private void runSimplifiedMutationRangeTest(final PlanAlgorithm tripPlanMutateTi } private static void assertValueInRange(final String message, final double actual, final double lowerLimit, final double upperLimit) { - assertTrue(message + " actual: " + actual + ", range: " + lowerLimit + "..." + upperLimit, (lowerLimit <= actual) && (actual <= upperLimit)); + assertTrue((lowerLimit <= actual) && (actual <= upperLimit), message + " actual: " + actual + ", range: " + lowerLimit + "..." + upperLimit); } @@ -182,10 +182,10 @@ void testRun() { affectingDuration, new Random(2011),24*3600,false,1); mutator.run(plan); - Assert.assertEquals(0.0, ptAct1.getMaximumDuration().seconds(), 1e-8); - Assert.assertEquals(0.0, ptAct2.getMaximumDuration().seconds(), 1e-8); - Assert.assertEquals(0.0, ptAct3.getMaximumDuration().seconds(), 1e-8); - Assert.assertEquals(0.0, ptAct4.getMaximumDuration().seconds(), 1e-8); + Assertions.assertEquals(0.0, ptAct1.getMaximumDuration().seconds(), 1e-8); + Assertions.assertEquals(0.0, ptAct2.getMaximumDuration().seconds(), 1e-8); + Assertions.assertEquals(0.0, ptAct3.getMaximumDuration().seconds(), 1e-8); + Assertions.assertEquals(0.0, ptAct4.getMaximumDuration().seconds(), 1e-8); } @Test @@ -227,19 +227,19 @@ void testRunLatestEndTime() { mutator.run(plan); - Assert.assertEquals(0.0, ptAct1.getMaximumDuration().seconds(), 1e-8); - Assert.assertEquals(0.0, ptAct2.getMaximumDuration().seconds(), 1e-8); - Assert.assertEquals(0.0, ptAct3.getMaximumDuration().seconds(), 1e-8); - Assert.assertEquals(0.0, ptAct4.getMaximumDuration().seconds(), 1e-8); + Assertions.assertEquals(0.0, ptAct1.getMaximumDuration().seconds(), 1e-8); + Assertions.assertEquals(0.0, ptAct2.getMaximumDuration().seconds(), 1e-8); + Assertions.assertEquals(0.0, ptAct3.getMaximumDuration().seconds(), 1e-8); + Assertions.assertEquals(0.0, ptAct4.getMaximumDuration().seconds(), 1e-8); // check whether activity times are equal or less than latestEndTime for (PlanElement pe : plan.getPlanElements()) { if (pe instanceof Activity activity) { if (activity.getStartTime().isDefined()) { - Assert.assertTrue(activity.getStartTime().seconds() <= latestEndTime); + Assertions.assertTrue(activity.getStartTime().seconds() <= latestEndTime); } if (activity.getEndTime().isDefined()) { - Assert.assertTrue(activity.getEndTime().seconds() <= latestEndTime); + Assertions.assertTrue(activity.getEndTime().seconds() <= latestEndTime); } } } @@ -271,8 +271,8 @@ void testLegTimesAreSetCorrectly() { double firstActEndTime = act.getEndTime().seconds(); double secondActDuration = act2.getMaximumDuration().seconds(); - Assert.assertEquals(firstActEndTime,leg1.getDepartureTime().seconds(), MatsimTestUtils.EPSILON); - Assert.assertEquals(firstActEndTime+secondActDuration+leg1.getTravelTime().seconds(),leg2.getDepartureTime().seconds(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(firstActEndTime,leg1.getDepartureTime().seconds(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(firstActEndTime+secondActDuration+leg1.getTravelTime().seconds(),leg2.getDepartureTime().seconds(), MatsimTestUtils.EPSILON); diff --git a/matsim/src/test/java/org/matsim/core/router/AbstractLeastCostPathCalculatorTest.java b/matsim/src/test/java/org/matsim/core/router/AbstractLeastCostPathCalculatorTest.java index 67ccf869eeb..1aa98e5bc16 100644 --- a/matsim/src/test/java/org/matsim/core/router/AbstractLeastCostPathCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/router/AbstractLeastCostPathCalculatorTest.java @@ -20,13 +20,13 @@ package org.matsim.core.router; -import static org.junit.Assert.assertEquals; - import java.io.IOException; import javax.xml.parsers.ParserConfigurationException; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -66,8 +66,8 @@ void testCalcLeastCostPath_Normal() throws SAXException, ParserConfigurationExce LeastCostPathCalculator routerAlgo = getLeastCostPathCalculator(network); Path path = routerAlgo.calcLeastCostPath(node12, node15, 8.0*3600, null, null); - assertEquals("number of nodes wrong.", 4, path.nodes.size()); - assertEquals("number of links wrong.", 3, path.links.size()); + assertEquals(4, path.nodes.size(), "number of nodes wrong."); + assertEquals(3, path.links.size(), "number of links wrong."); assertEquals(network.getNodes().get(Id.create("12", Node.class)), path.nodes.get(0)); assertEquals(network.getNodes().get(Id.create("13", Node.class)), path.nodes.get(1)); assertEquals(network.getNodes().get(Id.create("14", Node.class)), path.nodes.get(2)); @@ -87,8 +87,8 @@ void testCalcLeastCostPath_SameFromTo() throws SAXException, ParserConfiguration LeastCostPathCalculator routerAlgo = getLeastCostPathCalculator(network); Path path = routerAlgo.calcLeastCostPath(node12, node12, 8.0*3600, null, null); - assertEquals("number of nodes wrong.", 1, path.nodes.size()); - assertEquals("number of links wrong.", 0, path.links.size()); + assertEquals(1, path.nodes.size(), "number of nodes wrong."); + assertEquals(0, path.links.size(), "number of links wrong."); assertEquals(network.getNodes().get(Id.create("12", Node.class)), path.nodes.get(0)); } diff --git a/matsim/src/test/java/org/matsim/core/router/InvertertedNetworkRoutingTest.java b/matsim/src/test/java/org/matsim/core/router/InvertertedNetworkRoutingTest.java index 22f15d7f73e..1378f0b5195 100644 --- a/matsim/src/test/java/org/matsim/core/router/InvertertedNetworkRoutingTest.java +++ b/matsim/src/test/java/org/matsim/core/router/InvertertedNetworkRoutingTest.java @@ -18,6 +18,7 @@ * * * *********************************************************************** */ package org.matsim.core.router; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.*; import org.matsim.api.core.v01.network.*; @@ -32,7 +33,6 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.facilities.Facility; import org.matsim.vehicles.Vehicle; -import org.junit.Assert; /** @@ -64,36 +64,36 @@ void testInvertedNetworkLegRouter() { tt.setTurningMoveCosts(0.0, 100.0, 50.0); NetworkRoute route = calcRoute(router, fromFacility, toFacility, person); - Assert.assertNotNull(route); - Assert.assertEquals(Id.create("12", Link.class), route.getStartLinkId()); - Assert.assertEquals(Id.create("78", Link.class), route.getEndLinkId()); - Assert.assertEquals(3, route.getLinkIds().size()); - Assert.assertEquals(Id.create("23", Link.class), route.getLinkIds().get(0)); - Assert.assertEquals(Id.create("34", Link.class), route.getLinkIds().get(1)); - Assert.assertEquals(Id.create("47", Link.class), route.getLinkIds().get(2)); + Assertions.assertNotNull(route); + Assertions.assertEquals(Id.create("12", Link.class), route.getStartLinkId()); + Assertions.assertEquals(Id.create("78", Link.class), route.getEndLinkId()); + Assertions.assertEquals(3, route.getLinkIds().size()); + Assertions.assertEquals(Id.create("23", Link.class), route.getLinkIds().get(0)); + Assertions.assertEquals(Id.create("34", Link.class), route.getLinkIds().get(1)); + Assertions.assertEquals(Id.create("47", Link.class), route.getLinkIds().get(2)); //test 2 tt.setTurningMoveCosts(100.0, 0.0, 50.0); route = calcRoute(router, fromFacility, toFacility, person); - Assert.assertNotNull(route); - Assert.assertEquals(Id.create("12", Link.class), route.getStartLinkId()); - Assert.assertEquals(Id.create("78", Link.class), route.getEndLinkId()); - Assert.assertEquals(3, route.getLinkIds().size()); - Assert.assertEquals(Id.create("23", Link.class), route.getLinkIds().get(0)); - Assert.assertEquals(Id.create("35", Link.class), route.getLinkIds().get(1)); - Assert.assertEquals(Id.create("57", Link.class), route.getLinkIds().get(2)); + Assertions.assertNotNull(route); + Assertions.assertEquals(Id.create("12", Link.class), route.getStartLinkId()); + Assertions.assertEquals(Id.create("78", Link.class), route.getEndLinkId()); + Assertions.assertEquals(3, route.getLinkIds().size()); + Assertions.assertEquals(Id.create("23", Link.class), route.getLinkIds().get(0)); + Assertions.assertEquals(Id.create("35", Link.class), route.getLinkIds().get(1)); + Assertions.assertEquals(Id.create("57", Link.class), route.getLinkIds().get(2)); //test 3 tt.setTurningMoveCosts(50.0, 100.0, 0.0); route = calcRoute(router, fromFacility, toFacility, person); - Assert.assertNotNull(route); - Assert.assertEquals(Id.create("12", Link.class), route.getStartLinkId()); - Assert.assertEquals(Id.create("78", Link.class), route.getEndLinkId()); - Assert.assertEquals(3, route.getLinkIds().size()); - Assert.assertEquals(Id.create("23", Link.class), route.getLinkIds().get(0)); - Assert.assertEquals(Id.create("36", Link.class), route.getLinkIds().get(1)); - Assert.assertEquals(Id.create("67", Link.class), route.getLinkIds().get(2)); + Assertions.assertNotNull(route); + Assertions.assertEquals(Id.create("12", Link.class), route.getStartLinkId()); + Assertions.assertEquals(Id.create("78", Link.class), route.getEndLinkId()); + Assertions.assertEquals(3, route.getLinkIds().size()); + Assertions.assertEquals(Id.create("23", Link.class), route.getLinkIds().get(0)); + Assertions.assertEquals(Id.create("36", Link.class), route.getLinkIds().get(1)); + Assertions.assertEquals(Id.create("67", Link.class), route.getLinkIds().get(2)); diff --git a/matsim/src/test/java/org/matsim/core/router/MultimodalLinkChooserTest.java b/matsim/src/test/java/org/matsim/core/router/MultimodalLinkChooserTest.java index c7dfc9741e8..78a0dba6426 100644 --- a/matsim/src/test/java/org/matsim/core/router/MultimodalLinkChooserTest.java +++ b/matsim/src/test/java/org/matsim/core/router/MultimodalLinkChooserTest.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.core.router; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -77,16 +77,16 @@ void testDecideOnLink() { Link linkFromFacLinkId = linkChooser.decideOnLink(facilityLinkIdNotNull, network); - Assert.assertEquals(networkLink, linkFromFacLinkId); + Assertions.assertEquals(networkLink, linkFromFacLinkId); Link linkFromFacCoord = linkChooser.decideOnLink(facilityLinkIdNull, network); - Assert.assertEquals(networkLink, linkFromFacCoord); + Assertions.assertEquals(networkLink, linkFromFacCoord); //not sure whether the following makes sense as we basically are some functionality of NetworkUtils (which is used in the linkChooser) //testing this with the decideOnLink method would mean causing a RuntimeException -sm 0622 Link linkNotInNetwork = NetworkUtils.getNearestLink(netWithoutLinks, facilityLinkIdNull.getCoord()); - Assert.assertNull(linkNotInNetwork); + Assertions.assertNull(linkNotInNetwork); } } diff --git a/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java b/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java index 5329d4c68ee..be39a4c44ba 100644 --- a/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java @@ -33,8 +33,7 @@ import java.util.*; import java.util.stream.Collectors; -import static org.junit.Assert.*; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; public class NetworkRoutingInclAccessEgressModuleTest { diff --git a/matsim/src/test/java/org/matsim/core/router/NetworkRoutingModuleTest.java b/matsim/src/test/java/org/matsim/core/router/NetworkRoutingModuleTest.java index 57ee84872c5..f866a531b92 100644 --- a/matsim/src/test/java/org/matsim/core/router/NetworkRoutingModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/NetworkRoutingModuleTest.java @@ -21,7 +21,7 @@ import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -70,10 +70,10 @@ void testRouteLeg() { Facility fromFacility = FacilitiesUtils.toFacility( fromAct, f.s.getActivityFacilities() ); Facility toFacility = FacilitiesUtils.toFacility( toAct, f.s.getActivityFacilities() ); List result = routingModule.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFacility, toFacility, 7.0*3600, person)) ; - Assert.assertEquals(1, result.size() ); + Assertions.assertEquals(1, result.size() ); Leg leg = (Leg)result.get(0) ; - Assert.assertEquals(100.0, leg.getTravelTime().seconds(), 1e-8); - Assert.assertTrue(leg.getRoute() instanceof NetworkRoute); + Assertions.assertEquals(100.0, leg.getTravelTime().seconds(), 1e-8); + Assertions.assertTrue(leg.getRoute() instanceof NetworkRoute); } @Test @@ -103,14 +103,14 @@ void testRouteLegWithDistance() { List results = router.calcRoute( DefaultRoutingRequest.withoutAttributes( FacilitiesUtils.toFacility(fromAct, f.s.getActivityFacilities() ), FacilitiesUtils.toFacility(toAct, f.s.getActivityFacilities() ), 8.*3600, person ) ) ; - Assert.assertEquals( 1, results.size() ); + Assertions.assertEquals( 1, results.size() ); Leg leg = (Leg) results.get(0) ; - Assert.assertEquals(100.0, leg.getTravelTime().seconds(), 1e-8); - Assert.assertTrue(leg.getRoute() instanceof NetworkRoute); + Assertions.assertEquals(100.0, leg.getTravelTime().seconds(), 1e-8); + Assertions.assertTrue(leg.getRoute() instanceof NetworkRoute); NetworkRoute route = (NetworkRoute) leg.getRoute() ; - Assert.assertEquals(0.3333333333, route.getTravelCost(), 1e-8 ) ; + Assertions.assertEquals(0.3333333333, route.getTravelCost(), 1e-8 ) ; } // and now with a monetary distance rate different from zero: @@ -133,14 +133,14 @@ void testRouteLegWithDistance() { List result = router.calcRoute( DefaultRoutingRequest.withoutAttributes( FacilitiesUtils.toFacility(fromAct, f.s.getActivityFacilities() ), FacilitiesUtils.toFacility(toAct, f.s.getActivityFacilities() ), 7.*3600, person ) ) ; - Assert.assertEquals( 1, result.size() ) ; + Assertions.assertEquals( 1, result.size() ) ; Leg leg = (Leg) result.get(0) ; - Assert.assertEquals(100.0, leg.getTravelTime().seconds(), 1e-8); - Assert.assertTrue(leg.getRoute() instanceof NetworkRoute); + Assertions.assertEquals(100.0, leg.getTravelTime().seconds(), 1e-8); + Assertions.assertTrue(leg.getRoute() instanceof NetworkRoute); NetworkRoute route = (NetworkRoute) leg.getRoute() ; - Assert.assertEquals(1000.3333333333, route.getTravelCost(), 1e-8 ) ; + Assertions.assertEquals(1000.3333333333, route.getTravelCost(), 1e-8 ) ; } } diff --git a/matsim/src/test/java/org/matsim/core/router/PersonalizableDisutilityIntegrationTest.java b/matsim/src/test/java/org/matsim/core/router/PersonalizableDisutilityIntegrationTest.java index 703cf44b966..9a8a70a187a 100644 --- a/matsim/src/test/java/org/matsim/core/router/PersonalizableDisutilityIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/router/PersonalizableDisutilityIntegrationTest.java @@ -19,7 +19,7 @@ package org.matsim.core.router; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -57,7 +57,7 @@ void testPersonAvailableForDisutility_Dijkstra() { 07*3600, f.person, f.vehicle); // hopefully there was no Exception until here... - Assert.assertEquals(22, f.costFunction.cnt); // make sure the costFunction was actually used + Assertions.assertEquals(22, f.costFunction.cnt); // make sure the costFunction was actually used } @Test @@ -72,7 +72,7 @@ void testPersonAvailableForDisutility_AStarEuclidean() { 07*3600, f.person, f.vehicle); // hopefully there was no Exception until here... - Assert.assertEquals(22, f.costFunction.cnt); // make sure the costFunction was actually used + Assertions.assertEquals(22, f.costFunction.cnt); // make sure the costFunction was actually used } @Test @@ -86,7 +86,7 @@ void testPersonAvailableForDisutility_SpeedyALT() { 07*3600, f.person, f.vehicle); // hopefully there was no Exception until here... - Assert.assertEquals(22, f.costFunction.cnt); // make sure the costFunction was actually used + Assertions.assertEquals(22, f.costFunction.cnt); // make sure the costFunction was actually used } private static class Fixture { @@ -128,8 +128,8 @@ private static class PersonEnforcingTravelDisutility implements TravelDisutility @Override public double getLinkTravelDisutility(Link link, double time, Person person, Vehicle vehicle) { - Assert.assertEquals("different person than expected!", this.person, person); - Assert.assertEquals("different vehicle than expected!", this.veh, vehicle); + Assertions.assertEquals(this.person, person, "different person than expected!"); + Assertions.assertEquals(this.veh, vehicle, "different vehicle than expected!"); this.cnt++; return 1.0; } diff --git a/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java b/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java index be691aa8394..74f366f4864 100644 --- a/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java @@ -21,7 +21,7 @@ import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -80,10 +80,10 @@ void testRouteLeg() { double tt = new FreespeedFactorRoutingModule( "mode", f.s.getPopulation().getFactory(), f.s.getNetwork(), routeAlgo, params).routeLeg(person, leg, fromAct, toAct, 7.0*3600); - Assert.assertEquals(400.0, tt, 1e-8); - Assert.assertEquals(400.0, leg.getTravelTime().seconds(), 1e-8); + Assertions.assertEquals(400.0, tt, 1e-8); + Assertions.assertEquals(400.0, leg.getTravelTime().seconds(), 1e-8); // Assert.assertTrue(leg.getRoute() instanceof GenericRouteImpl); - Assert.assertEquals(3000.0, leg.getRoute().getDistance(), 1e-8); + Assertions.assertEquals(3000.0, leg.getRoute().getDistance(), 1e-8); }{ TeleportedModeParams params = new TeleportedModeParams("mode") ; params.setTeleportedModeFreespeedFactor(3.); @@ -91,9 +91,9 @@ void testRouteLeg() { double tt = new FreespeedFactorRoutingModule( "mode", f.s.getPopulation().getFactory(), f.s.getNetwork(), routeAlgo, params).routeLeg(person, leg, fromAct, toAct, 7.0*3600); - Assert.assertEquals(600.0, tt, 1e-8); - Assert.assertEquals(600.0, leg.getTravelTime().seconds(), 1e-8); - Assert.assertEquals(6000.0, leg.getRoute().getDistance(), 1e-8); + Assertions.assertEquals(600.0, tt, 1e-8); + Assertions.assertEquals(600.0, leg.getTravelTime().seconds(), 1e-8); + Assertions.assertEquals(6000.0, leg.getRoute().getDistance(), 1e-8); }{ // the following test is newer than the ones above. I wanted to test the freespeed limit. But could not do it in the same way // above since it is not in FreespeedTravelTimeAndDisutility. Could have modified that disutility. But preferred to test in context. @@ -124,9 +124,9 @@ void testRouteLeg() { Gbl.assertIf( result.size()==1); Leg newLeg = (Leg) result.get(0) ; - Assert.assertEquals(800.0, newLeg.getTravelTime().seconds(), 1e-8); + Assertions.assertEquals(800.0, newLeg.getTravelTime().seconds(), 1e-8); // Assert.assertTrue(leg.getRoute() instanceof GenericRouteImpl); - Assert.assertEquals(3000.0, newLeg.getRoute().getDistance(), 1e-8); + Assertions.assertEquals(3000.0, newLeg.getRoute().getDistance(), 1e-8); } } diff --git a/matsim/src/test/java/org/matsim/core/router/RoutingIT.java b/matsim/src/test/java/org/matsim/core/router/RoutingIT.java index 41da4c9aa46..35ac550ee68 100644 --- a/matsim/src/test/java/org/matsim/core/router/RoutingIT.java +++ b/matsim/src/test/java/org/matsim/core/router/RoutingIT.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -166,7 +166,7 @@ private void doTest(final RouterProvider provider) { new PopulationWriter(referenceScenario.getPopulation(), scenario.getNetwork()).write(this.utils.getOutputDirectory() + "/reference_population.xml.gz"); new PopulationWriter(scenario.getPopulation(), scenario.getNetwork()).write(this.utils.getOutputDirectory() + "/output_population.xml.gz"); } - Assert.assertTrue("different plans files.", isEqual); + Assertions.assertTrue(isEqual, "different plans files."); } private static void calcRoute( diff --git a/matsim/src/test/java/org/matsim/core/router/TeleportationRoutingModuleTest.java b/matsim/src/test/java/org/matsim/core/router/TeleportationRoutingModuleTest.java index 2245d7effe3..44fb6186ed6 100644 --- a/matsim/src/test/java/org/matsim/core/router/TeleportationRoutingModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TeleportationRoutingModuleTest.java @@ -19,7 +19,7 @@ package org.matsim.core.router; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -59,9 +59,9 @@ void testRouteLeg() { "mode", scenario, 10.0, 1.0); double tt = router.routeLeg(person, leg, fromAct, toAct, 7.0 * 3600); - Assert.assertEquals(100.0, tt, 10e-7); - Assert.assertEquals(100.0, leg.getTravelTime().seconds(), 10e-7); - Assert.assertEquals(100.0, leg.getRoute().getTravelTime().seconds(), 10e-7); + Assertions.assertEquals(100.0, tt, 10e-7); + Assertions.assertEquals(100.0, leg.getTravelTime().seconds(), 10e-7); + Assertions.assertEquals(100.0, leg.getRoute().getTravelTime().seconds(), 10e-7); router = new TeleportationRoutingModule( @@ -70,9 +70,9 @@ void testRouteLeg() { 20.0, 1.0); tt = router.routeLeg(person, leg, fromAct, toAct, 7.0 * 3600); - Assert.assertEquals(50.0, tt, 10e-7); - Assert.assertEquals(50.0, leg.getTravelTime().seconds(), 10e-7); - Assert.assertEquals(50.0, leg.getRoute().getTravelTime().seconds(), 10e-7); + Assertions.assertEquals(50.0, tt, 10e-7); + Assertions.assertEquals(50.0, leg.getTravelTime().seconds(), 10e-7); + Assertions.assertEquals(50.0, leg.getRoute().getTravelTime().seconds(), 10e-7); // Activity otherToAct = PopulationUtils.createActivityFromCoord("h", new Coord(1000, 1000)); Facility otherToAct = scenario.getActivityFacilities().getFactory().createActivityFacility( Id.create( "h", ActivityFacility.class ), @@ -85,8 +85,8 @@ void testRouteLeg() { 10.0, manhattanBeelineDistanceFactor); tt = router.routeLeg(person, leg, fromAct, otherToAct, 7.0 * 3600); - Assert.assertEquals(200.0, tt, 10e-7); - Assert.assertEquals(200.0, leg.getTravelTime().seconds(), 10e-7); - Assert.assertEquals(200.0, leg.getRoute().getTravelTime().seconds(), 10e-7); + Assertions.assertEquals(200.0, tt, 10e-7); + Assertions.assertEquals(200.0, leg.getTravelTime().seconds(), 10e-7); + Assertions.assertEquals(200.0, leg.getRoute().getTravelTime().seconds(), 10e-7); } } diff --git a/matsim/src/test/java/org/matsim/core/router/TestActivityWrapperFacility.java b/matsim/src/test/java/org/matsim/core/router/TestActivityWrapperFacility.java index fb433b944c3..0b924a0c516 100644 --- a/matsim/src/test/java/org/matsim/core/router/TestActivityWrapperFacility.java +++ b/matsim/src/test/java/org/matsim/core/router/TestActivityWrapperFacility.java @@ -22,8 +22,8 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -62,15 +62,15 @@ void testWrapper() { for (Activity activity : activities) { Facility wrapper = FacilitiesUtils.toFacility( activity, null ); - Assert.assertEquals( - "wrapped activity returns incorrect coordinate!", + Assertions.assertEquals( activity.getCoord(), - wrapper.getCoord()); + wrapper.getCoord(), + "wrapped activity returns incorrect coordinate!"); - Assert.assertEquals( - "wrapped activity returns incorrect link id!", + Assertions.assertEquals( activity.getLinkId(), - wrapper.getLinkId()); + wrapper.getLinkId(), + "wrapped activity returns incorrect link id!"); } } } diff --git a/matsim/src/test/java/org/matsim/core/router/TripRouterFactoryImplTest.java b/matsim/src/test/java/org/matsim/core/router/TripRouterFactoryImplTest.java index a49ac52dfd4..d2a23b546a1 100644 --- a/matsim/src/test/java/org/matsim/core/router/TripRouterFactoryImplTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TripRouterFactoryImplTest.java @@ -18,8 +18,7 @@ * * * *********************************************************************** */ package org.matsim.core.router; - -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -137,15 +136,15 @@ public void install() { // actual test NetworkRoute r = (NetworkRoute) l.getRoute(); - Assert.assertEquals( - "unexpected route length "+r.getLinkIds(), + Assertions.assertEquals( 1, - r.getLinkIds().size() ); + r.getLinkIds().size(), + "unexpected route length "+r.getLinkIds() ); - Assert.assertEquals( - "unexpected link", + Assertions.assertEquals( l2c.getId(), - r.getLinkIds().get( 0 )); + r.getLinkIds().get( 0 ), + "unexpected link"); } /** @@ -213,15 +212,15 @@ public void install() { // actual test NetworkRoute r = (NetworkRoute) l.getRoute(); - Assert.assertEquals( - "unexpected route length "+r.getLinkIds(), + Assertions.assertEquals( 1, - r.getLinkIds().size() ); + r.getLinkIds().size(), + "unexpected route length "+r.getLinkIds() ); - Assert.assertEquals( - "unexpected link", + Assertions.assertEquals( l2short.getId(), - r.getLinkIds().get( 0 )); + r.getLinkIds().get( 0 ), + "unexpected link"); } private static class LinkFacility implements Facility { diff --git a/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java b/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java index 7fd09524d24..dcc8626033a 100644 --- a/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java @@ -22,7 +22,7 @@ package org.matsim.core.router; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -52,7 +52,7 @@ void testRouterCreation() { scenario.getNetwork(), ControlerDefaults.createDefaultTravelDisutilityFactory(scenario).createTravelDisutility(new FreeSpeedTravelTime()), new FreeSpeedTravelTime()); - Assert.assertNotNull(pathCalculator); + Assertions.assertNotNull(pathCalculator); } } diff --git a/matsim/src/test/java/org/matsim/core/router/TripRouterTest.java b/matsim/src/test/java/org/matsim/core/router/TripRouterTest.java index d3150f2c945..b97cdf0b8a6 100644 --- a/matsim/src/test/java/org/matsim/core/router/TripRouterTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TripRouterTest.java @@ -19,8 +19,8 @@ * *********************************************************************** */ package org.matsim.core.router; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.List; @@ -64,9 +64,9 @@ void testTripInsertion() { TripRouter.insertTrip( plan , o , trip , d ); assertEquals( - "insertion did not produce the expected plan length!", 13, - plan.getPlanElements().size()); + plan.getPlanElements().size(), + "insertion did not produce the expected plan length!"); int oldIndex = Integer.MIN_VALUE; for (PlanElement pe : plan.getPlanElements()) { @@ -80,8 +80,8 @@ void testTripInsertion() { } assertTrue( - "wrong inserted sequence: "+plan.getPlanElements(), - newIndex > oldIndex); + newIndex > oldIndex, + "wrong inserted sequence: "+plan.getPlanElements()); oldIndex = newIndex; } } @@ -110,9 +110,9 @@ void testTripInsertionIfActivitiesImplementEquals() { TripRouter.insertTrip( plan , o , trip , d ); assertEquals( - "insertion did not produce the expected plan length!", 13, - plan.getPlanElements().size()); + plan.getPlanElements().size(), + "insertion did not produce the expected plan length!"); int oldIndex = Integer.MIN_VALUE; for (PlanElement pe : plan.getPlanElements()) { @@ -126,8 +126,8 @@ void testTripInsertionIfActivitiesImplementEquals() { } assertTrue( - "wrong inserted sequence: "+plan.getPlanElements(), - newIndex > oldIndex); + newIndex > oldIndex, + "wrong inserted sequence: "+plan.getPlanElements()); oldIndex = newIndex; } } @@ -159,9 +159,9 @@ void testReturnedOldTrip() throws Exception { trip.add( PopulationUtils.createLeg("4") ); assertEquals( - "wrong old trip", expected, - TripRouter.insertTrip( plan , o , trip , d ) ); + TripRouter.insertTrip( plan , o , trip , d ), + "wrong old trip" ); } private static class EqualsActivity implements Activity { diff --git a/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsSubtoursTest.java b/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsSubtoursTest.java index 9ca21632379..106ea1e7790 100644 --- a/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsSubtoursTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsSubtoursTest.java @@ -19,8 +19,8 @@ * *********************************************************************** */ package org.matsim.core.router; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.Arrays; @@ -794,18 +794,16 @@ private static void performTest(final Fixture fixture) { TripStructureUtils.getSubtours( fixture.plan ); assertEquals( - "[anchorAtFacilities="+fixture.useFacilitiesAsAnchorPoint+"] "+ - "unexpected number of subtours in "+subtours, fixture.expectedSubtours.size(), - subtours.size() ); + subtours.size(), + "[anchorAtFacilities="+fixture.useFacilitiesAsAnchorPoint+"] "+ + "unexpected number of subtours in "+subtours ); assertEquals( - "[anchorAtFacilities="+fixture.useFacilitiesAsAnchorPoint+"] "+ - "uncompatible subtours", - // do not bother about iteration order, - // but ensure you get some information on failure new HashSet( fixture.expectedSubtours ), - new HashSet( subtours ) ); + new HashSet( subtours ), + "[anchorAtFacilities="+fixture.useFacilitiesAsAnchorPoint+"] "+ + "uncompatible subtours" ); } @Test @@ -820,9 +818,9 @@ void testInconsistentPlan() throws Exception { } assertTrue( + hadException, "[anchorAtFacilities="+fixture.useFacilitiesAsAnchorPoint+"] "+ - "no exception was thrown!", - hadException); + "no exception was thrown!"); } @Test @@ -838,10 +836,10 @@ void testGetTripsWithoutSubSubtours() throws Exception { } assertEquals( - "[anchorAtFacilities="+f.useFacilitiesAsAnchorPoint+"] "+ - "unexpected total number of trips in subtours without subsubtours", countTrips, - nTrips); + nTrips, + "[anchorAtFacilities="+f.useFacilitiesAsAnchorPoint+"] "+ + "unexpected total number of trips in subtours without subsubtours"); } } @@ -853,17 +851,17 @@ void testFatherhood() throws Exception { for (Subtour s : subtours) { for ( Subtour child : s.getChildren() ) { assertEquals( - "[anchorAtFacilities="+f.useFacilitiesAsAnchorPoint+"] "+ - "wrong father!", child.getParent(), - s); + s, + "[anchorAtFacilities="+f.useFacilitiesAsAnchorPoint+"] "+ + "wrong father!"); } if ( s.getParent() != null ) { assertTrue( + s.getParent().getChildren().contains( s ), "[anchorAtFacilities="+f.useFacilitiesAsAnchorPoint+"] "+ - "father does not have subtour has a child", - s.getParent().getChildren().contains( s )); + "father does not have subtour has a child"); } } } diff --git a/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsTest.java b/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsTest.java index c27172a82ca..2f28185b50f 100644 --- a/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsTest.java @@ -26,8 +26,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.After; -import org.junit.Assert; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -42,8 +42,7 @@ import org.matsim.core.router.TripStructureUtils.Trip; import org.matsim.core.scenario.ScenarioUtils; -import static org.junit.Assert.*; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; /** * @author thibautd @@ -388,14 +387,14 @@ void testActivities() throws Exception { StageActivityHandling.ExcludeStageActivities); assertEquals( - "unexpected number of activities in "+acts+" for fixture "+fixture.name, fixture.expectedNActs, - acts.size() ); + acts.size(), + "unexpected number of activities in "+acts+" for fixture "+fixture.name ); for (Activity act : acts) { assertFalse( - "found a dummy act in "+acts+" for fixture "+fixture.name, - StageActivityTypeIdentifier.isStageActivity( act.getType() )); + StageActivityTypeIdentifier.isStageActivity( act.getType() ), + "found a dummy act in "+acts+" for fixture "+fixture.name); } } } @@ -407,16 +406,16 @@ void testTrips() throws Exception { TripStructureUtils.getTrips(fixture.plan); assertEquals( - "unexpected number of trips in "+trips+" for fixture "+fixture.name, fixture.expectedNTrips, - trips.size() ); + trips.size(), + "unexpected number of trips in "+trips+" for fixture "+fixture.name ); for (Trip trip : trips) { for (PlanElement pe : trip.getTripElements()) { if (pe instanceof Leg) continue; assertTrue( - "found a non-dummy act in "+trip.getTripElements()+" for fixture "+fixture.name, - StageActivityTypeIdentifier.isStageActivity( ((Activity) pe).getType() )); + StageActivityTypeIdentifier.isStageActivity( ((Activity) pe).getType() ), + "found a non-dummy act in "+trip.getTripElements()+" for fixture "+fixture.name); } final int indexOfStart = @@ -431,9 +430,9 @@ void testTrips() throws Exception { indexOfEnd ); assertEquals( - "trip in Trip is not the same as in plan for fixture "+fixture.name, inPlan, - trip.getTripElements()); + trip.getTripElements(), + "trip in Trip is not the same as in plan for fixture "+fixture.name); } } } @@ -450,9 +449,9 @@ void testLegs() throws Exception { } assertEquals( - "getLegsOnly() does not returns the right number of legs", fixture.expectedNLegs, - countLegs); + countLegs, + "getLegsOnly() does not returns the right number of legs"); } } @@ -535,8 +534,8 @@ void testFindTripAtPlanElement() { log.info( tripElement ); } log.info( "" ); - Assert.assertEquals( 9, trip.getTripElements().size() ); - Assert.assertEquals( 5, trip.getLegsOnly().size() ); + Assertions.assertEquals( 9, trip.getTripElements().size() ); + Assertions.assertEquals( 5, trip.getLegsOnly().size() ); } { Trip trip = TripStructureUtils.findTripAtPlanElement( leg, f0.plan, TripStructureUtils::isStageActivityType ) ; @@ -546,8 +545,8 @@ void testFindTripAtPlanElement() { log.info( tripElement ); } log.info( "" ); - Assert.assertEquals( 9, trip.getTripElements().size() ); - Assert.assertEquals( 5, trip.getLegsOnly().size() ); + Assertions.assertEquals( 9, trip.getTripElements().size() ); + Assertions.assertEquals( 5, trip.getLegsOnly().size() ); } { Trip trip = TripStructureUtils.findTripAtPlanElement( leg, f0.plan, TripStructureUtils.createStageActivityType(leg.getMode())::equals ) ; @@ -557,8 +556,8 @@ void testFindTripAtPlanElement() { log.info( tripElement ); } log.info( "" ); - Assert.assertEquals( 5, trip.getTripElements().size() ); - Assert.assertEquals( 3, trip.getLegsOnly().size() ); + Assertions.assertEquals( 5, trip.getTripElements().size() ); + Assertions.assertEquals( 3, trip.getLegsOnly().size() ); } } diff --git a/matsim/src/test/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityTest.java b/matsim/src/test/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityTest.java index b5526dd425a..b564dd46e49 100644 --- a/matsim/src/test/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityTest.java +++ b/matsim/src/test/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityTest.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Set; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -66,7 +66,7 @@ void testRoutesForDifferentSigmas() { routes.add(route.getLinkIds().toString()); } System.out.println("Route (sigma = 0.0): " + routes.toString()); - Assert.assertEquals("There should only be a single route in the sigma = 0 case.", 1, routes.size()); + Assertions.assertEquals(1, routes.size(), "There should only be a single route in the sigma = 0 case."); } { @@ -76,7 +76,7 @@ void testRoutesForDifferentSigmas() { routes.add(route.getLinkIds().toString()); } System.out.println("Route (sigma = 3.0): " + routes.toString()); - Assert.assertEquals("There should be two routes in the sigma = 3 case.", 2, routes.size()); + Assertions.assertEquals(2, routes.size(), "There should be two routes in the sigma = 3 case."); } } @@ -112,7 +112,7 @@ public NetworkRoute computeRoute(double sigma) { Facility fromFacility = FacilitiesUtils.toFacility( fromAct, f.s.getActivityFacilities() ); Facility toFacility = FacilitiesUtils.toFacility( toAct, f.s.getActivityFacilities() ); List result = routingModule.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFacility, toFacility, 7.0*3600, person)) ; - Assert.assertEquals(1, result.size() ); + Assertions.assertEquals(1, result.size() ); Leg leg = (Leg) result.get(0) ; return (NetworkRoute) leg.getRoute(); } diff --git a/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java b/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java index 128a511292e..abf9b242c7a 100644 --- a/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java +++ b/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java @@ -22,7 +22,7 @@ package org.matsim.core.router.old; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -81,9 +81,9 @@ public void install() { testee.run(plan); if ( config.routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { - Assert.assertEquals("Vehicle Id transferred to new Plan", vehicleId, ((NetworkRoute) TripStructureUtils.getLegs(plan).get(0).getRoute()).getVehicleId()); + Assertions.assertEquals(vehicleId, ((NetworkRoute) TripStructureUtils.getLegs(plan).get(0).getRoute()).getVehicleId(), "Vehicle Id transferred to new Plan"); } else { - Assert.assertEquals("Vehicle Id transferred to new Plan", vehicleId, ((NetworkRoute) TripStructureUtils.getLegs(plan).get(1).getRoute()).getVehicleId()); + Assertions.assertEquals(vehicleId, ((NetworkRoute) TripStructureUtils.getLegs(plan).get(1).getRoute()).getVehicleId(), "Vehicle Id transferred to new Plan"); // yy I changed get(0) to get(1) since in the input file there is no intervening walk leg, but in the output there is. kai, feb'16 } } @@ -139,9 +139,9 @@ public void install() { PlanRouter testee = new PlanRouter(tripRouter, TimeInterpretation.create(config)); testee.run(plan); if ( config.routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { - Assert.assertEquals("Vehicle Id from TripRouter used", newVehicleId, ((NetworkRoute) TripStructureUtils.getLegs(plan).get(0).getRoute()).getVehicleId()); + Assertions.assertEquals(newVehicleId, ((NetworkRoute) TripStructureUtils.getLegs(plan).get(0).getRoute()).getVehicleId(), "Vehicle Id from TripRouter used"); } else { - Assert.assertEquals("Vehicle Id from TripRouter used", newVehicleId, ((NetworkRoute) TripStructureUtils.getLegs(plan).get(1).getRoute()).getVehicleId()); + Assertions.assertEquals(newVehicleId, ((NetworkRoute) TripStructureUtils.getLegs(plan).get(1).getRoute()).getVehicleId(), "Vehicle Id from TripRouter used"); // yy I changed get(0) to get(1) since in the input file there is no intervening walk leg, but in the output there is. kai, feb'16 } diff --git a/matsim/src/test/java/org/matsim/core/router/priorityqueue/BinaryMinHeapTest.java b/matsim/src/test/java/org/matsim/core/router/priorityqueue/BinaryMinHeapTest.java index 3cc3590ef0c..b3c2ca23129 100644 --- a/matsim/src/test/java/org/matsim/core/router/priorityqueue/BinaryMinHeapTest.java +++ b/matsim/src/test/java/org/matsim/core/router/priorityqueue/BinaryMinHeapTest.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -52,16 +52,16 @@ private void testAdd(MinHeap pq) { DummyHeapEntry entry1 = new DummyHeapEntry(3); DummyHeapEntry entry2 = new DummyHeapEntry(6); - Assert.assertEquals(0, pq.size()); + Assertions.assertEquals(0, pq.size()); pq.add(entry0, 1.0); - Assert.assertEquals(1, pq.size()); + Assertions.assertEquals(1, pq.size()); pq.add(entry1, 2.0); - Assert.assertEquals(2, pq.size()); + Assertions.assertEquals(2, pq.size()); pq.add(entry2, 2.0); // different element with same priority - Assert.assertEquals(3, pq.size()); + Assertions.assertEquals(3, pq.size()); pq.add(entry2, 3.0); // same element with different priority - Assert.assertEquals(3, pq.size()); // should not be added! - Assert.assertEquals(3, iteratorElementCount(pq.iterator())); + Assertions.assertEquals(3, pq.size()); // should not be added! + Assertions.assertEquals(3, iteratorElementCount(pq.iterator())); } @Test @@ -75,13 +75,13 @@ void testAdd_Null() { private void testAdd_Null(MinHeap pq) { try { pq.add(null, 1.0); - Assert.fail("missing NullPointerException."); + Assertions.fail("missing NullPointerException."); } catch (NullPointerException e) { log.info("catched expected exception. ", e); } - Assert.assertEquals(0, pq.size()); - Assert.assertEquals(0, iteratorElementCount(pq.iterator())); + Assertions.assertEquals(0, pq.size()); + Assertions.assertEquals(0, iteratorElementCount(pq.iterator())); } @Test @@ -103,21 +103,21 @@ private void testPoll(MinHeap pq) { pq.add(entry0, 5.0); pq.add(entry1, 3.0); pq.add(entry2, 6.0); - Assert.assertEquals(3, pq.size()); + Assertions.assertEquals(3, pq.size()); assertEqualsHE(entry1, pq.poll()); - Assert.assertEquals(2, pq.size()); + Assertions.assertEquals(2, pq.size()); pq.add(entry3, 1.0); pq.add(entry4, 4.0); pq.add(entry5, 9.0); - Assert.assertEquals(5, pq.size()); + Assertions.assertEquals(5, pq.size()); assertEqualsHE(entry3, pq.poll()); assertEqualsHE(entry4, pq.poll()); assertEqualsHE(entry0, pq.poll()); assertEqualsHE(entry2, pq.poll()); assertEqualsHE(entry5, pq.poll()); - Assert.assertEquals(0, pq.size()); - Assert.assertNull(pq.poll()); + Assertions.assertEquals(0, pq.size()); + Assertions.assertNull(pq.poll()); } @Test @@ -140,21 +140,21 @@ private void testPoll2(MinHeap pq) { pq.add(entry0, 5.0); pq.add(entry1, 3.0); pq.add(entry2, 6.0); - Assert.assertEquals(3, pq.size()); + Assertions.assertEquals(3, pq.size()); assertEqualsHE(entry1, pq.poll()); - Assert.assertEquals(2, pq.size()); + Assertions.assertEquals(2, pq.size()); pq.add(entry3, 1.0); pq.add(entry4, 4.0); pq.add(entry5, 9.0); - Assert.assertEquals(5, pq.size()); + Assertions.assertEquals(5, pq.size()); assertEqualsHE(entry3, pq.poll()); assertEqualsHE(entry4, pq.poll()); assertEqualsHE(entry0, pq.poll()); assertEqualsHE(entry2, pq.poll()); assertEqualsHE(entry5, pq.poll()); - Assert.assertEquals(0, pq.size()); - Assert.assertNull(pq.poll()); + Assertions.assertEquals(0, pq.size()); + Assertions.assertNull(pq.poll()); } @Test @@ -174,11 +174,11 @@ private void testIterator(MinHeap pq) { pq.add(entry1, 3.0); pq.add(entry2, 6.0); Collection coll = getIteratorCollection(pq.iterator()); - Assert.assertEquals(3, coll.size()); - Assert.assertTrue(coll.contains(entry0)); - Assert.assertTrue(coll.contains(entry1)); - Assert.assertTrue(coll.contains(entry2)); - Assert.assertFalse(coll.contains(entry3)); + Assertions.assertEquals(3, coll.size()); + Assertions.assertTrue(coll.contains(entry0)); + Assertions.assertTrue(coll.contains(entry1)); + Assertions.assertTrue(coll.contains(entry2)); + Assertions.assertFalse(coll.contains(entry3)); } @Test @@ -198,21 +198,21 @@ private void testIterator_ConcurrentModification_add(MinHeap pq) { pq.add(entry1, 3.0); pq.add(entry2, 6.0); Iterator iter = pq.iterator(); - Assert.assertTrue(iter.hasNext()); - Assert.assertNotNull(iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertNotNull(iter.next()); pq.add(entry3, 4.0); - Assert.assertTrue(iter.hasNext()); + Assertions.assertTrue(iter.hasNext()); try { iter.next(); - Assert.fail("missing ConcurrentModificationException"); + Assertions.fail("missing ConcurrentModificationException"); } catch (ConcurrentModificationException e) { log.info("catched expected exception.", e); } iter = pq.iterator(); // but a new iterator must work again - Assert.assertTrue(iter.hasNext()); - Assert.assertNotNull(iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertNotNull(iter.next()); } @Test @@ -231,21 +231,21 @@ private void testIterator_ConcurrentModification_poll(MinHeap pq) { pq.add(entry1, 3.0); pq.add(entry2, 6.0); Iterator iter = pq.iterator(); - Assert.assertTrue(iter.hasNext()); - Assert.assertNotNull(iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertNotNull(iter.next()); pq.poll(); - Assert.assertTrue(iter.hasNext()); + Assertions.assertTrue(iter.hasNext()); try { iter.next(); - Assert.fail("missing ConcurrentModificationException"); + Assertions.fail("missing ConcurrentModificationException"); } catch (ConcurrentModificationException e) { log.info("catched expected exception.", e); } iter = pq.iterator(); // but a new iterator must work again - Assert.assertTrue(iter.hasNext()); - Assert.assertNotNull(iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertNotNull(iter.next()); } @Test @@ -264,24 +264,24 @@ private void testIterator_ConcurrentModification_remove(MinHeap pq) { pq.add(entry1, 3.0); pq.add(entry2, 6.0); Iterator iter = pq.iterator(); - Assert.assertTrue(iter.hasNext()); - Assert.assertNotNull(iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertNotNull(iter.next()); - Assert.assertTrue(pq.remove(entry0)); - Assert.assertTrue(iter.hasNext()); + Assertions.assertTrue(pq.remove(entry0)); + Assertions.assertTrue(iter.hasNext()); try { iter.next(); - Assert.fail("missing ConcurrentModificationException"); + Assertions.fail("missing ConcurrentModificationException"); } catch (ConcurrentModificationException e) { log.info("catched expected exception.", e); } iter = pq.iterator(); // but a new iterator must work again - Assert.assertTrue(iter.hasNext()); - Assert.assertNotNull(iter.next()); - Assert.assertFalse(pq.remove(entry0)); // cannot be removed, so it's no change - Assert.assertTrue(iter.hasNext()); - Assert.assertNotNull(iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertNotNull(iter.next()); + Assertions.assertFalse(pq.remove(entry0)); // cannot be removed, so it's no change + Assertions.assertTrue(iter.hasNext()); + Assertions.assertNotNull(iter.next()); } @Test @@ -300,11 +300,11 @@ private void testIterator_RemoveUnsupported(MinHeap pq) { pq.add(entry1, 3.0); pq.add(entry2, 6.0); Iterator iter = pq.iterator(); - Assert.assertTrue(iter.hasNext()); - Assert.assertNotNull(iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertNotNull(iter.next()); try { iter.remove(); - Assert.fail("missing UnsupportedOperationException"); + Assertions.fail("missing UnsupportedOperationException"); } catch (UnsupportedOperationException e) { log.info("catched expected exception.", e); @@ -329,39 +329,39 @@ private void testRemove(MinHeap pq) { pq.add(entry2, 6.0); Collection coll = getIteratorCollection(pq.iterator()); - Assert.assertEquals(3, coll.size()); - Assert.assertTrue(coll.contains(entry0)); - Assert.assertTrue(coll.contains(entry1)); - Assert.assertTrue(coll.contains(entry2)); - Assert.assertFalse(coll.contains(entry3)); + Assertions.assertEquals(3, coll.size()); + Assertions.assertTrue(coll.contains(entry0)); + Assertions.assertTrue(coll.contains(entry1)); + Assertions.assertTrue(coll.contains(entry2)); + Assertions.assertFalse(coll.contains(entry3)); // remove some element - Assert.assertTrue(pq.remove(entry0)); - Assert.assertEquals(2, pq.size()); + Assertions.assertTrue(pq.remove(entry0)); + Assertions.assertEquals(2, pq.size()); coll = getIteratorCollection(pq.iterator()); - Assert.assertEquals(2, coll.size()); - Assert.assertFalse(coll.contains(entry0)); - Assert.assertTrue(coll.contains(entry1)); - Assert.assertTrue(coll.contains(entry2)); + Assertions.assertEquals(2, coll.size()); + Assertions.assertFalse(coll.contains(entry0)); + Assertions.assertTrue(coll.contains(entry1)); + Assertions.assertTrue(coll.contains(entry2)); // remove the same element again - Assert.assertFalse(pq.remove(entry0)); - Assert.assertEquals(2, pq.size()); + Assertions.assertFalse(pq.remove(entry0)); + Assertions.assertEquals(2, pq.size()); coll = getIteratorCollection(pq.iterator()); - Assert.assertEquals(2, coll.size()); + Assertions.assertEquals(2, coll.size()); // remove null - Assert.assertFalse(pq.remove(null)); - Assert.assertEquals(2, pq.size()); + Assertions.assertFalse(pq.remove(null)); + Assertions.assertEquals(2, pq.size()); coll = getIteratorCollection(pq.iterator()); - Assert.assertEquals(2, coll.size()); - Assert.assertTrue(coll.contains(entry1)); - Assert.assertTrue(coll.contains(entry2)); + Assertions.assertEquals(2, coll.size()); + Assertions.assertTrue(coll.contains(entry1)); + Assertions.assertTrue(coll.contains(entry2)); // now poll the pq and ensure, no removed element is returned assertEqualsHE(entry1, pq.poll()); assertEqualsHE(entry2, pq.poll()); - Assert.assertNull(pq.poll()); + Assertions.assertNull(pq.poll()); } @Test @@ -380,17 +380,17 @@ private void testRemoveAndAdd_LowerPriority(MinHeap pq) { pq.add(entry1, 3.0); pq.add(entry2, 6.0); - Assert.assertEquals(3, pq.size()); + Assertions.assertEquals(3, pq.size()); // test removing an element and adding it with lower priority (=higher value) pq.remove(entry0); - Assert.assertEquals(2, pq.size()); + Assertions.assertEquals(2, pq.size()); pq.add(entry0, 7.0); - Assert.assertEquals(3, pq.size()); + Assertions.assertEquals(3, pq.size()); assertEqualsHE(entry1, pq.poll()); assertEqualsHE(entry2, pq.poll()); assertEqualsHE(entry0, pq.poll()); - Assert.assertNull(pq.poll()); + Assertions.assertNull(pq.poll()); } // increase priority -> decrease key since it is a min-heap @@ -422,15 +422,15 @@ private void testIncreasePriority(MinHeap pq) { pq.add(entry1, 3.0); pq.add(entry2, 6.0); - Assert.assertEquals(3, pq.size()); + Assertions.assertEquals(3, pq.size()); // test decreasing an element by increasing priority (=lower value) pq.decreaseKey(entry0, 2); - Assert.assertEquals(3, pq.size()); + Assertions.assertEquals(3, pq.size()); assertEqualsHE(entry0, pq.poll()); assertEqualsHE(entry1, pq.poll()); assertEqualsHE(entry2, pq.poll()); - Assert.assertNull(pq.poll()); + Assertions.assertNull(pq.poll()); /* * Add two elements with the same priority, then add one with a @@ -439,13 +439,13 @@ private void testIncreasePriority(MinHeap pq) { pq.add(entry0, 5.0); pq.add(entry1, 5.0); pq.add(entry2, 6.0); - Assert.assertEquals(3, pq.size()); + Assertions.assertEquals(3, pq.size()); pq.decreaseKey(entry2, 4.0); - Assert.assertEquals(3, pq.size()); + Assertions.assertEquals(3, pq.size()); assertEqualsHE(entry2, pq.poll()); assertEqualsHE(entry1, pq.poll()); assertEqualsHE(entry0, pq.poll()); - Assert.assertNull(pq.poll()); + Assertions.assertNull(pq.poll()); } @Test @@ -464,17 +464,17 @@ private void testRemoveAndAdd_HigherPriority(MinHeap pq) { pq.add(entry1, 3.0); pq.add(entry2, 6.0); - Assert.assertEquals(3, pq.size()); + Assertions.assertEquals(3, pq.size()); // test removing an element and adding it with higher priority (=lower value) pq.remove(entry0); - Assert.assertEquals(2, pq.size()); + Assertions.assertEquals(2, pq.size()); pq.add(entry0, 2.5); - Assert.assertEquals(3, pq.size()); + Assertions.assertEquals(3, pq.size()); assertEqualsHE(entry0, pq.poll()); assertEqualsHE(entry1, pq.poll()); assertEqualsHE(entry2, pq.poll()); - Assert.assertNull(pq.poll()); + Assertions.assertNull(pq.poll()); } @Test @@ -507,16 +507,16 @@ private void testEqualCosts(MinHeap pq) { pq.add(entry3, 5.0); pq.add(entry1, 5.0); pq.add(entry0, 5.0); - Assert.assertEquals(4, pq.size()); + Assertions.assertEquals(4, pq.size()); assertEqualsHE(entry0, pq.poll()); - Assert.assertEquals(3, pq.size()); + Assertions.assertEquals(3, pq.size()); assertEqualsHE(entry1, pq.poll()); - Assert.assertEquals(2, pq.size()); + Assertions.assertEquals(2, pq.size()); assertEqualsHE(entry2, pq.poll()); - Assert.assertEquals(1, pq.size()); + Assertions.assertEquals(1, pq.size()); assertEqualsHE(entry3, pq.poll()); - Assert.assertEquals(0, pq.size()); - Assert.assertNull(pq.poll()); + Assertions.assertEquals(0, pq.size()); + Assertions.assertNull(pq.poll()); } @Test @@ -577,7 +577,7 @@ private void testEqualCosts2(MinHeap pq) { assertEqualsHE(entry7, pq.poll()); assertEqualsHE(entry8, pq.poll()); assertEqualsHE(entry9, pq.poll()); - Assert.assertNull(pq.poll()); + Assertions.assertNull(pq.poll()); } @Test @@ -614,7 +614,7 @@ private void testExceedCapacity(MinHeap pq) { // this entry should exceed the heaps capacity try { pq.add(entry10, 5.0); - Assert.fail("missing NullPointerException."); + Assertions.fail("missing NullPointerException."); } catch (RuntimeException e) { log.info("catched expected exception. ", e); @@ -642,7 +642,7 @@ private void testOddOrder(MinHeap pq) { assertEqualsHE(entry1, pq.poll()); assertEqualsHE(entry2, pq.poll()); assertEqualsHE(entry3, pq.poll()); - Assert.assertNull(pq.poll()); + Assertions.assertNull(pq.poll()); } private MinHeap createMinHeap(boolean classicalRemove) { @@ -673,8 +673,8 @@ private Collection getIteratorCollection(final Iterator iterator) { } private void assertEqualsHE(HasIndex e1, HasIndex e2) { - Assert.assertEquals(e1.getArrayIndex(), e2.getArrayIndex()); - Assert.assertEquals(e1, e2); + Assertions.assertEquals(e1.getArrayIndex(), e2.getArrayIndex()); + Assertions.assertEquals(e1, e2); } private static class DummyHeapEntry implements HasIndex { diff --git a/matsim/src/test/java/org/matsim/core/router/speedy/DAryMinHeapTest.java b/matsim/src/test/java/org/matsim/core/router/speedy/DAryMinHeapTest.java index f2737b2ed76..01f30c231ac 100644 --- a/matsim/src/test/java/org/matsim/core/router/speedy/DAryMinHeapTest.java +++ b/matsim/src/test/java/org/matsim/core/router/speedy/DAryMinHeapTest.java @@ -1,6 +1,6 @@ package org.matsim.core.router.speedy; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.util.Random; @@ -28,27 +28,27 @@ void testPoll() { pq.insert(1, cost[1]); pq.insert(0, cost[0]); - Assert.assertEquals(3, pq.size()); + Assertions.assertEquals(3, pq.size()); - Assert.assertEquals(1, pq.poll()); - Assert.assertEquals(2, pq.poll()); - Assert.assertEquals(0, pq.poll()); + Assertions.assertEquals(1, pq.poll()); + Assertions.assertEquals(2, pq.poll()); + Assertions.assertEquals(0, pq.poll()); - Assert.assertTrue(pq.isEmpty()); + Assertions.assertTrue(pq.isEmpty()); for (int i = 0; i < 8; i++) { pq.insert(i, cost[i]); } - Assert.assertEquals(5, pq.poll()); - Assert.assertEquals(1, pq.poll()); - Assert.assertEquals(6, pq.poll()); - Assert.assertEquals(2, pq.poll()); - Assert.assertEquals(0, pq.poll()); - Assert.assertEquals(7, pq.poll()); - Assert.assertEquals(3, pq.poll()); - Assert.assertEquals(4, pq.poll()); - Assert.assertTrue(pq.isEmpty()); + Assertions.assertEquals(5, pq.poll()); + Assertions.assertEquals(1, pq.poll()); + Assertions.assertEquals(6, pq.poll()); + Assertions.assertEquals(2, pq.poll()); + Assertions.assertEquals(0, pq.poll()); + Assertions.assertEquals(7, pq.poll()); + Assertions.assertEquals(3, pq.poll()); + Assertions.assertEquals(4, pq.poll()); + Assertions.assertTrue(pq.isEmpty()); } @Test @@ -61,10 +61,10 @@ void testDecreaseKey() { pq.decreaseKey(2, 1.0); - Assert.assertEquals(2, pq.poll()); - Assert.assertEquals(1, pq.poll()); - Assert.assertEquals(0, pq.poll()); - Assert.assertTrue(pq.isEmpty()); + Assertions.assertEquals(2, pq.poll()); + Assertions.assertEquals(1, pq.poll()); + Assertions.assertEquals(0, pq.poll()); + Assertions.assertTrue(pq.isEmpty()); } @Test @@ -87,7 +87,7 @@ void stresstest() { step++; int node = pq.poll(); double nodeCost = cost[node]; - Assert.assertTrue(step + ": " + lastCost + " <= " + nodeCost, lastCost <= nodeCost); + Assertions.assertTrue(lastCost <= nodeCost, step + ": " + lastCost + " <= " + nodeCost); lastCost = nodeCost; } @@ -110,7 +110,7 @@ void stresstest() { step++; int node = pq.poll(); double nodeCost = cost[node]; - Assert.assertTrue(step + ": " + lastCost + " <= " + nodeCost, lastCost <= nodeCost); + Assertions.assertTrue(lastCost <= nodeCost, step + ": " + lastCost + " <= " + nodeCost); lastCost = nodeCost; } diff --git a/matsim/src/test/java/org/matsim/core/router/speedy/SpeedyGraphTest.java b/matsim/src/test/java/org/matsim/core/router/speedy/SpeedyGraphTest.java index 2127d559b03..4085ebd3b25 100644 --- a/matsim/src/test/java/org/matsim/core/router/speedy/SpeedyGraphTest.java +++ b/matsim/src/test/java/org/matsim/core/router/speedy/SpeedyGraphTest.java @@ -1,6 +1,6 @@ package org.matsim.core.router.speedy; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -32,58 +32,58 @@ void testConstruction() { // test out-links node 1 li.reset(f.node1.getId().index()); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link12); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link13); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link14); - Assert.assertFalse(li.next()); - Assert.assertFalse(li.next()); + Assertions.assertFalse(li.next()); + Assertions.assertFalse(li.next()); // test out-links node 2 li.reset(f.node2.getId().index()); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link21); - Assert.assertFalse(li.next()); - Assert.assertFalse(li.next()); + Assertions.assertFalse(li.next()); + Assertions.assertFalse(li.next()); // test out-links node 3 li.reset(f.node3.getId().index()); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link34); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link35); - Assert.assertFalse(li.next()); - Assert.assertFalse(li.next()); + Assertions.assertFalse(li.next()); + Assertions.assertFalse(li.next()); // test out-links node 4 li.reset(f.node4.getId().index()); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link46); - Assert.assertFalse(li.next()); - Assert.assertFalse(li.next()); + Assertions.assertFalse(li.next()); + Assertions.assertFalse(li.next()); // test out-links node 5 li.reset(f.node5.getId().index()); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link56); - Assert.assertFalse(li.next()); - Assert.assertFalse(li.next()); + Assertions.assertFalse(li.next()); + Assertions.assertFalse(li.next()); // test out-links node 6 li.reset(f.node6.getId().index()); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link65); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link62); - Assert.assertFalse(li.next()); - Assert.assertFalse(li.next()); + Assertions.assertFalse(li.next()); + Assertions.assertFalse(li.next()); // test in-links @@ -92,66 +92,66 @@ void testConstruction() { // test in-links node 1 li.reset(f.node1.getId().index()); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link21); - Assert.assertFalse(li.next()); - Assert.assertFalse(li.next()); + Assertions.assertFalse(li.next()); + Assertions.assertFalse(li.next()); // test in-links node 2 li.reset(f.node2.getId().index()); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link12); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link62); - Assert.assertFalse(li.next()); - Assert.assertFalse(li.next()); + Assertions.assertFalse(li.next()); + Assertions.assertFalse(li.next()); // test in-links node 3 li.reset(f.node3.getId().index()); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link13); - Assert.assertFalse(li.next()); - Assert.assertFalse(li.next()); + Assertions.assertFalse(li.next()); + Assertions.assertFalse(li.next()); // test in-links node 4 li.reset(f.node4.getId().index()); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link14); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link34); - Assert.assertFalse(li.next()); - Assert.assertFalse(li.next()); + Assertions.assertFalse(li.next()); + Assertions.assertFalse(li.next()); // test in-links node 5 li.reset(f.node5.getId().index()); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link35); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link65); - Assert.assertFalse(li.next()); - Assert.assertFalse(li.next()); + Assertions.assertFalse(li.next()); + Assertions.assertFalse(li.next()); // test in-links node 6 li.reset(f.node6.getId().index()); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link46); - Assert.assertTrue(li.next()); + Assertions.assertTrue(li.next()); assertLink(li, f.link56); - Assert.assertFalse(li.next()); - Assert.assertFalse(li.next()); + Assertions.assertFalse(li.next()); + Assertions.assertFalse(li.next()); } private void assertLink(LinkIterator li, Link link) { - Assert.assertEquals(link.getId().index(), li.getLinkIndex()); - Assert.assertEquals(link.getFromNode().getId().index(), li.getFromNodeIndex()); - Assert.assertEquals(link.getToNode().getId().index(), li.getToNodeIndex()); - Assert.assertEquals(link.getLength(), li.getLength(), 1e-2); - Assert.assertEquals(link.getLength() / link.getFreespeed(), li.getFreespeedTravelTime(), 1e-2); + Assertions.assertEquals(link.getId().index(), li.getLinkIndex()); + Assertions.assertEquals(link.getFromNode().getId().index(), li.getFromNodeIndex()); + Assertions.assertEquals(link.getToNode().getId().index(), li.getToNodeIndex()); + Assertions.assertEquals(link.getLength(), li.getLength(), 1e-2); + Assertions.assertEquals(link.getLength() / link.getFreespeed(), li.getFreespeedTravelTime(), 1e-2); } private static class Fixture { diff --git a/matsim/src/test/java/org/matsim/core/scenario/ScenarioByConfigInjectionTest.java b/matsim/src/test/java/org/matsim/core/scenario/ScenarioByConfigInjectionTest.java index a11338e58e2..0bc1000c65c 100644 --- a/matsim/src/test/java/org/matsim/core/scenario/ScenarioByConfigInjectionTest.java +++ b/matsim/src/test/java/org/matsim/core/scenario/ScenarioByConfigInjectionTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -42,7 +42,7 @@ import org.matsim.utils.objectattributes.ObjectAttributes; import org.matsim.utils.objectattributes.ObjectAttributesXmlWriter; - /** + /** * @author thibautd */ public class ScenarioByConfigInjectionTest { @@ -81,10 +81,10 @@ public void install() { Object stupid = person.getAttributes().getAttribute( "stupidAttribute" ); // TODO test for ALL attribute containers... - Assert.assertEquals( - "Unexpected type of read in attribute", + Assertions.assertEquals( StupidClass.class, - stupid.getClass() ); + stupid.getClass(), + "Unexpected type of read in attribute" ); log.info( "get person attribute" ); stupid = scenario.getPopulation() @@ -93,10 +93,10 @@ public void install() { .getAttributes() .getAttribute( "otherAttribute" ); - Assert.assertEquals( - "Unexpected type of read in attribute", + Assertions.assertEquals( StupidClass.class, - stupid.getClass() ); + stupid.getClass(), + "Unexpected type of read in attribute" ); log.info( "get activity attribute" ); stupid = scenario.getPopulation() @@ -108,10 +108,10 @@ public void install() { .getAttributes() .getAttribute( "actAttribute" ); - Assert.assertEquals( - "Unexpected type of read in attribute", + Assertions.assertEquals( StupidClass.class, - stupid.getClass() ); + stupid.getClass(), + "Unexpected type of read in attribute" ); log.info( "get leg attribute" ); stupid = scenario.getPopulation() @@ -123,20 +123,20 @@ public void install() { .getAttributes() .getAttribute( "legAttribute" ); - Assert.assertEquals( - "Unexpected type of read in attribute", + Assertions.assertEquals( StupidClass.class, - stupid.getClass() ); + stupid.getClass(), + "Unexpected type of read in attribute" ); log.info( "get network attribute" ); stupid = scenario.getNetwork() .getAttributes() .getAttribute( "networkAttribute" ); - Assert.assertEquals( - "Unexpected type of read in attribute", + Assertions.assertEquals( StupidClass.class, - stupid.getClass() ); + stupid.getClass(), + "Unexpected type of read in attribute" ); log.info( "get Link attribute" ); stupid = scenario.getNetwork() @@ -145,10 +145,10 @@ public void install() { .getAttributes() .getAttribute( "linkAttribute" ); - Assert.assertEquals( - "Unexpected type of read in attribute", + Assertions.assertEquals( StupidClass.class, - stupid.getClass() ); + stupid.getClass(), + "Unexpected type of read in attribute" ); log.info( "get Node attribute" ); stupid = scenario.getNetwork() @@ -157,10 +157,10 @@ public void install() { .getAttributes() .getAttribute( "nodeAttribute" ); - Assert.assertEquals( - "Unexpected type of read in attribute", + Assertions.assertEquals( StupidClass.class, - stupid.getClass() ); + stupid.getClass(), + "Unexpected type of read in attribute" ); } private Config createTestScenario() { diff --git a/matsim/src/test/java/org/matsim/core/scenario/ScenarioImplTest.java b/matsim/src/test/java/org/matsim/core/scenario/ScenarioImplTest.java index 20585a8dd28..741fbf70dca 100644 --- a/matsim/src/test/java/org/matsim/core/scenario/ScenarioImplTest.java +++ b/matsim/src/test/java/org/matsim/core/scenario/ScenarioImplTest.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.core.scenario; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.core.config.ConfigUtils; import org.matsim.households.Households; @@ -41,20 +41,20 @@ void testAddAndGetScenarioElement() { s.addScenarioElement( name1 , element1 ); s.addScenarioElement( name2 , element2 ); - Assert.assertSame( - "unexpected scenario element", + Assertions.assertSame( element1, - s.getScenarioElement( name1 ) ); + s.getScenarioElement( name1 ), + "unexpected scenario element" ); // just check that it is got, not removed - Assert.assertSame( - "unexpected scenario element", + Assertions.assertSame( element1, - s.getScenarioElement( name1 ) ); + s.getScenarioElement( name1 ), + "unexpected scenario element" ); - Assert.assertSame( - "unexpected scenario element", + Assertions.assertSame( element2, - s.getScenarioElement( name2 ) ); + s.getScenarioElement( name2 ), + "unexpected scenario element" ); } @@ -72,9 +72,9 @@ void testCannotAddAnElementToAnExistingName() { return; } catch (Exception e) { - Assert.fail( "wrong exception thrown when trying to add an element for an existing name "+e.getClass().getName() ); + Assertions.fail( "wrong exception thrown when trying to add an element for an existing name "+e.getClass().getName() ); } - Assert.fail( "no exception thrown when trying to add an element for an existing name" ); + Assertions.fail( "no exception thrown when trying to add an element for an existing name" ); } @Test @@ -85,13 +85,13 @@ void testRemoveElement() { final String name = "clark_kent"; s.addScenarioElement( name , element ); - Assert.assertSame( - "unexpected removed element", + Assertions.assertSame( element, - s.removeScenarioElement( name ) ); - Assert.assertNull( - "element was not removed", - s.getScenarioElement( name ) ); + s.removeScenarioElement( name ), + "unexpected removed element" ); + Assertions.assertNull( + s.getScenarioElement( name ), + "element was not removed" ); } diff --git a/matsim/src/test/java/org/matsim/core/scenario/ScenarioLoaderImplTest.java b/matsim/src/test/java/org/matsim/core/scenario/ScenarioLoaderImplTest.java index 1cdae1fd44a..a26eaacb88f 100644 --- a/matsim/src/test/java/org/matsim/core/scenario/ScenarioLoaderImplTest.java +++ b/matsim/src/test/java/org/matsim/core/scenario/ScenarioLoaderImplTest.java @@ -20,7 +20,7 @@ package org.matsim.core.scenario; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -55,18 +55,18 @@ void testLoadScenario_loadTransitData() { ScenarioBuilder builder = new ScenarioBuilder(ConfigUtils.loadConfig(IOUtils.extendUrl(this.util.classInputResourcePath(), "transitConfig.xml"))); // facilities is there by default???? Scenario scenario = builder.build() ; - Assert.assertEquals(0, scenario.getTransitSchedule().getTransitLines().size()); - Assert.assertEquals(0, scenario.getTransitSchedule().getFacilities().size()); + Assertions.assertEquals(0, scenario.getTransitSchedule().getTransitLines().size()); + Assertions.assertEquals(0, scenario.getTransitSchedule().getFacilities().size()); ScenarioUtils.loadScenario(scenario); - Assert.assertEquals(1, scenario.getTransitSchedule().getTransitLines().size()); - Assert.assertEquals(2, scenario.getTransitSchedule().getFacilities().size()); + Assertions.assertEquals(1, scenario.getTransitSchedule().getTransitLines().size()); + Assertions.assertEquals(2, scenario.getTransitSchedule().getFacilities().size()); } // load directly: { Scenario scenario = ScenarioUtils.loadScenario(ConfigUtils.loadConfig(IOUtils.extendUrl(this.util.classInputResourcePath(), "transitConfig.xml"))); - Assert.assertEquals(1, scenario.getTransitSchedule().getTransitLines().size()); - Assert.assertEquals(2, scenario.getTransitSchedule().getFacilities().size()); + Assertions.assertEquals(1, scenario.getTransitSchedule().getTransitLines().size()); + Assertions.assertEquals(2, scenario.getTransitSchedule().getFacilities().size()); } } @@ -79,7 +79,7 @@ void testLoadScenario_loadPersonAttributes_nowDeprecated() { Population population = scenario.getPopulation(); Person person = population.getPersons().get( Id.createPersonId( "1" ) ) ; Gbl.assertNotNull( person ); - Assert.assertEquals("world", person.getAttributes().getAttribute( "hello" ) ); + Assertions.assertEquals("world", person.getAttributes().getAttribute( "hello" ) ); } @Test @@ -94,7 +94,7 @@ void testLoadScenario_loadPersonAttributes() { // expected exception caughtException = true ; } - Assert.assertTrue( caughtException ); + Assertions.assertTrue( caughtException ); } @@ -104,12 +104,12 @@ void testLoadScenario_loadFacilitiesAttributes() { config.facilities().setInsistingOnUsingDeprecatedFacilitiesAttributeFile(true); config.facilities().addParam("inputFacilityAttributesFile", "facilityAttributes.xml"); Scenario scenario = ScenarioUtils.loadScenario(config); - Assert.assertEquals( - "unexpected attribute value", + Assertions.assertEquals( "world", FacilitiesUtils.getFacilityAttribute( scenario.getActivityFacilities().getFacilities().get(Id.create(1, ActivityFacility.class)), - "hello")); + "hello"), + "unexpected attribute value"); } @Test @@ -118,12 +118,12 @@ void testLoadScenario_loadHouseholdAttributes() { config.households().addParam("inputHouseholdAttributesFile", "householdAttributes.xml"); config.households().setInsistingOnUsingDeprecatedHouseholdsAttributeFile(true); Scenario scenario = ScenarioUtils.loadScenario(config); - Assert.assertEquals( - "unexpected attribute value", + Assertions.assertEquals( "world", HouseholdUtils.getHouseholdAttribute( scenario.getHouseholds().getHouseholds().get(Id.create(1, Household.class)), - "hello")); + "hello"), + "unexpected attribute value"); } } diff --git a/matsim/src/test/java/org/matsim/core/scenario/ScenarioUtilsTest.java b/matsim/src/test/java/org/matsim/core/scenario/ScenarioUtilsTest.java index 2e6b2aa7e22..ad3a64fa662 100644 --- a/matsim/src/test/java/org/matsim/core/scenario/ScenarioUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/scenario/ScenarioUtilsTest.java @@ -21,7 +21,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Scenario; @@ -36,11 +36,11 @@ public class ScenarioUtilsTest { void testCreateScenario_nullConfig() { try { Scenario s = ScenarioUtils.createScenario(null); - Assert.fail("expected NPE, but got none." + s.toString()); + Assertions.fail("expected NPE, but got none." + s.toString()); } catch (NullPointerException e) { log.info("Catched expected NPE.", e); - Assert.assertTrue("Message in NPE should not be empty.", e.getMessage().length() > 0); + Assertions.assertTrue(e.getMessage().length() > 0, "Message in NPE should not be empty."); } } } diff --git a/matsim/src/test/java/org/matsim/core/scoring/EventsToActivitiesTest.java b/matsim/src/test/java/org/matsim/core/scoring/EventsToActivitiesTest.java index 9af33789d81..463657b2410 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/EventsToActivitiesTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/EventsToActivitiesTest.java @@ -19,7 +19,7 @@ package org.matsim.core.scoring; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -42,11 +42,11 @@ void testCreatesActivty() { "work", new Coord( 123., 4.56 ) ) ); testee.handleEvent(new ActivityEndEvent(30.0, Id.create("1", Person.class), Id.create("l1", Link.class), Id.create("l1", ActivityFacility.class), "work", new Coord( 123., 4.56 ))); - Assert.assertNotNull(ah.handledActivity); - Assert.assertEquals(10.0, ah.handledActivity.getActivity().getStartTime().seconds(), 1e-8); - Assert.assertEquals(30.0, ah.handledActivity.getActivity().getEndTime().seconds(), 1e-8); - Assert.assertEquals( 123., ah.handledActivity.getActivity().getCoord().getX(), 0. ); - Assert.assertEquals( 4.56, ah.handledActivity.getActivity().getCoord().getY(), 0. ); + Assertions.assertNotNull(ah.handledActivity); + Assertions.assertEquals(10.0, ah.handledActivity.getActivity().getStartTime().seconds(), 1e-8); + Assertions.assertEquals(30.0, ah.handledActivity.getActivity().getEndTime().seconds(), 1e-8); + Assertions.assertEquals( 123., ah.handledActivity.getActivity().getCoord().getX(), 0. ); + Assertions.assertEquals( 4.56, ah.handledActivity.getActivity().getCoord().getY(), 0. ); } @Test @@ -57,18 +57,18 @@ void testCreateNightActivity() { testee.reset(0); testee.handleEvent(new ActivityEndEvent(10.0, Id.create("1", Person.class), Id.create("l1", Link.class), Id.create("l1", ActivityFacility.class), "home", new Coord( 123., 4.56 ))); - Assert.assertNotNull(ah.handledActivity); - Assert.assertTrue(ah.handledActivity.getActivity().getStartTime().isUndefined()); - Assert.assertEquals(10.0, ah.handledActivity.getActivity().getEndTime().seconds(), 1e-8); + Assertions.assertNotNull(ah.handledActivity); + Assertions.assertTrue(ah.handledActivity.getActivity().getStartTime().isUndefined()); + Assertions.assertEquals(10.0, ah.handledActivity.getActivity().getEndTime().seconds(), 1e-8); ah.reset(); testee.handleEvent(new ActivityStartEvent(90.0, Id.create("1", Person.class), Id.create("l1", Link.class), Id.create("l1", ActivityFacility.class), "home", new Coord( 123., 4.56 ) ) ); testee.finish(); - Assert.assertNotNull(ah.handledActivity); - Assert.assertTrue(ah.handledActivity.getActivity().getEndTime().isUndefined()); - Assert.assertEquals(90.0, ah.handledActivity.getActivity().getStartTime().seconds(), 1e-8); - Assert.assertEquals( 123., ah.handledActivity.getActivity().getCoord().getX(), 0. ); - Assert.assertEquals( 4.56, ah.handledActivity.getActivity().getCoord().getY(), 0. ); + Assertions.assertNotNull(ah.handledActivity); + Assertions.assertTrue(ah.handledActivity.getActivity().getEndTime().isUndefined()); + Assertions.assertEquals(90.0, ah.handledActivity.getActivity().getStartTime().seconds(), 1e-8); + Assertions.assertEquals( 123., ah.handledActivity.getActivity().getCoord().getX(), 0. ); + Assertions.assertEquals( 4.56, ah.handledActivity.getActivity().getCoord().getY(), 0. ); } @Test @@ -79,12 +79,12 @@ void testDontCreateNightActivityIfNoneIsBeingPerformedWhenSimulationEnds() { testee.reset(0); testee.handleEvent(new ActivityEndEvent(10.0, Id.create("1", Person.class), Id.create("l1", Link.class), Id.create("f1", ActivityFacility.class), "home", new Coord( 123., 4.56 ))); - Assert.assertNotNull(ah.handledActivity); - Assert.assertTrue(ah.handledActivity.getActivity().getStartTime().isUndefined()) ; - Assert.assertEquals(10.0, ah.handledActivity.getActivity().getEndTime().seconds(), 1e-8); + Assertions.assertNotNull(ah.handledActivity); + Assertions.assertTrue(ah.handledActivity.getActivity().getStartTime().isUndefined()) ; + Assertions.assertEquals(10.0, ah.handledActivity.getActivity().getEndTime().seconds(), 1e-8); ah.reset(); testee.finish(); - Assert.assertNull(ah.handledActivity); + Assertions.assertNull(ah.handledActivity); } private static class MockActivityHandler implements ActivityHandler { diff --git a/matsim/src/test/java/org/matsim/core/scoring/EventsToLegsTest.java b/matsim/src/test/java/org/matsim/core/scoring/EventsToLegsTest.java index e4867f43cad..aa5f159bca9 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/EventsToLegsTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/EventsToLegsTest.java @@ -21,7 +21,7 @@ import java.util.Collections; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -88,8 +88,7 @@ void testCreatesLegWithRoute() { eventsToLegs.handleEvent(new VehicleLeavesTrafficEvent(30.0, agentId, Id.createLinkId("l3"), vehId, "car", 1.0)); eventsToLegs.handleEvent(new PersonArrivalEvent(30.0, agentId, Id.createLinkId("l3"), "car")); assertLeg(lh, 10., 20., 550.0, "car"); - Assert.assertEquals(EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME + " missing or incorrect!", - 10.0, lh.handledLeg.getLeg().getAttributes().getAttribute(EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME)); + Assertions.assertEquals(10.0, lh.handledLeg.getLeg().getAttributes().getAttribute(EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME), EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME + " missing or incorrect!"); } @Test @@ -130,8 +129,7 @@ void testCreatesLegWithRoute_jointTrip() { eventsToLegs.handleEvent(new PersonArrivalEvent(30.0, agentId1, Id.createLinkId("l3"), "car")); assertLeg(lh, 10., 20., 550.0, "car"); - Assert.assertEquals(EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME + " missing or incorrect!", - 10.0, lh.handledLeg.getLeg().getAttributes().getAttribute(EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME)); + Assertions.assertEquals(10.0, lh.handledLeg.getLeg().getAttributes().getAttribute(EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME), EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME + " missing or incorrect!"); } @Test @@ -148,8 +146,7 @@ void testCreatesLegWithRoute_withoutEnteringTraffic() { //driver leaves out vehicle after 10 seconds, no driving at all eventsToLegs.handleEvent(new PersonArrivalEvent(20.0, agentId1, Id.createLinkId("l1"), "car")); assertLeg(lh, 10., 10., 0.0, "car"); - Assert.assertEquals(EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME + " missing or incorrect!", - 10.0, lh.handledLeg.getLeg().getAttributes().getAttribute(EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME)); + Assertions.assertEquals(10.0, lh.handledLeg.getLeg().getAttributes().getAttribute(EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME), EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME + " missing or incorrect!"); } @Test @@ -170,8 +167,7 @@ void testCreatesLegWithRoute_withLeavingTrafficOnTheSameLink() { new VehicleLeavesTrafficEvent(25.0, agentId1, Id.createLinkId("l1"), vehId, "car", 1.0)); eventsToLegs.handleEvent(new PersonArrivalEvent(20.0, agentId1, Id.createLinkId("l1"), "car")); assertLeg(lh, 10., 10., 500.0, "car"); - Assert.assertEquals(EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME + " missing or incorrect!", - 10.0, lh.handledLeg.getLeg().getAttributes().getAttribute(EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME)); + Assertions.assertEquals(10.0, lh.handledLeg.getLeg().getAttributes().getAttribute(EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME), EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME + " missing or incorrect!"); } @Test @@ -228,12 +224,12 @@ void testCreatesTransitPassengerRoute() { eventsToLegs.handleEvent(new PersonEntersVehicleEvent(100.0, passengerId, transitVehiceId)); eventsToLegs.handleEvent(new PersonArrivalEvent(1000.0, passengerId, accessLinkId, "pt")); - Assert.assertEquals(10.0, lh.handledLeg.getLeg().getDepartureTime().seconds(), 1e-3); - Assert.assertEquals(1000.0 - 10.0, lh.handledLeg.getLeg().getTravelTime().seconds(), 1e-3); - Assert.assertTrue(lh.handledLeg.getLeg().getRoute() instanceof TransitPassengerRoute); + Assertions.assertEquals(10.0, lh.handledLeg.getLeg().getDepartureTime().seconds(), 1e-3); + Assertions.assertEquals(1000.0 - 10.0, lh.handledLeg.getLeg().getTravelTime().seconds(), 1e-3); + Assertions.assertTrue(lh.handledLeg.getLeg().getRoute() instanceof TransitPassengerRoute); TransitPassengerRoute route = (TransitPassengerRoute) lh.handledLeg.getLeg().getRoute(); - Assert.assertEquals(100.0, route.getBoardingTime().seconds(), 1e-3); + Assertions.assertEquals(100.0, route.getBoardingTime().seconds(), 1e-3); } private static Scenario createTriangularNetwork() { @@ -266,12 +262,12 @@ private static Scenario createTriangularNetwork() { private void assertLeg(RememberingLegHandler lh, double departureTime, double travelTime, double distance, String mode) { - Assert.assertNotNull(lh.handledLeg); - Assert.assertEquals(departureTime, lh.handledLeg.getLeg().getDepartureTime().seconds(), 1e-9); - Assert.assertEquals(travelTime, lh.handledLeg.getLeg().getTravelTime().seconds(), 1e-9); - Assert.assertEquals(travelTime, lh.handledLeg.getLeg().getRoute().getTravelTime().seconds(), 1e-9); - Assert.assertEquals(distance, lh.handledLeg.getLeg().getRoute().getDistance(), 1e-9); - Assert.assertEquals(mode, lh.handledLeg.getLeg().getMode()); + Assertions.assertNotNull(lh.handledLeg); + Assertions.assertEquals(departureTime, lh.handledLeg.getLeg().getDepartureTime().seconds(), 1e-9); + Assertions.assertEquals(travelTime, lh.handledLeg.getLeg().getTravelTime().seconds(), 1e-9); + Assertions.assertEquals(travelTime, lh.handledLeg.getLeg().getRoute().getTravelTime().seconds(), 1e-9); + Assertions.assertEquals(distance, lh.handledLeg.getLeg().getRoute().getDistance(), 1e-9); + Assertions.assertEquals(mode, lh.handledLeg.getLeg().getMode()); } private static class RememberingLegHandler implements LegHandler { diff --git a/matsim/src/test/java/org/matsim/core/scoring/EventsToScoreTest.java b/matsim/src/test/java/org/matsim/core/scoring/EventsToScoreTest.java index ea8da87ea56..4d0bbb8f127 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/EventsToScoreTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/EventsToScoreTest.java @@ -20,7 +20,7 @@ package org.matsim.core.scoring; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -65,7 +65,7 @@ void testAddMoney() { events.processEvent(new PersonMoneyEvent(3600.0, person.getId(), 3.4, "tollRefund", "motorwayOperator")); events.finishProcessing(); e2s.finish(); - Assert.assertEquals(3.4, e2s.getAgentScore(person.getId()), 0); + Assertions.assertEquals(3.4, e2s.getAgentScore(person.getId()), 0); } @Test @@ -105,53 +105,53 @@ void testMsaAveraging() { switch(mockIteration){ case 99: - Assert.assertEquals(1.0, person.getSelectedPlan().getScore(), 0); + Assertions.assertEquals(1.0, person.getSelectedPlan().getScore(), 0); break ; case 100: // first MSA iteration; plain score should be ok: - Assert.assertEquals(2.0, person.getSelectedPlan().getScore(), 0); + Assertions.assertEquals(2.0, person.getSelectedPlan().getScore(), 0); break ; case 101: // second MSA iteration // (2+3)/2 = 2.5 - Assert.assertEquals(2.5, person.getSelectedPlan().getScore(), 0); + Assertions.assertEquals(2.5, person.getSelectedPlan().getScore(), 0); break ; case 102: // 3rd MSA iteration // (2+3+4)/3 = 3 - Assert.assertEquals(3.0, person.getSelectedPlan().getScore(), 0); + Assertions.assertEquals(3.0, person.getSelectedPlan().getScore(), 0); break ; case 103: // (2+3+4+5)/4 = 3.5 - Assert.assertEquals(3.5, person.getSelectedPlan().getScore(), 0); + Assertions.assertEquals(3.5, person.getSelectedPlan().getScore(), 0); break ; case 104: // 3rd MSA iteration - Assert.assertEquals(4.0, person.getSelectedPlan().getScore(), 0); + Assertions.assertEquals(4.0, person.getSelectedPlan().getScore(), 0); break ; case 105: // 3rd MSA iteration - Assert.assertEquals(4.5, person.getSelectedPlan().getScore(), 0); + Assertions.assertEquals(4.5, person.getSelectedPlan().getScore(), 0); break ; case 106: // 3rd MSA iteration - Assert.assertEquals(5.0, person.getSelectedPlan().getScore(), 0); + Assertions.assertEquals(5.0, person.getSelectedPlan().getScore(), 0); break ; case 107: // 3rd MSA iteration - Assert.assertEquals(5.5, person.getSelectedPlan().getScore(), 0); + Assertions.assertEquals(5.5, person.getSelectedPlan().getScore(), 0); break ; case 108: // 3rd MSA iteration - Assert.assertEquals(6.0, person.getSelectedPlan().getScore(), 0); + Assertions.assertEquals(6.0, person.getSelectedPlan().getScore(), 0); break ; case 109: // 3rd MSA iteration - Assert.assertEquals(6.5, person.getSelectedPlan().getScore(), 0); + Assertions.assertEquals(6.5, person.getSelectedPlan().getScore(), 0); break ; case 110: // 3rd MSA iteration - Assert.assertEquals(7.0, person.getSelectedPlan().getScore(), 0); + Assertions.assertEquals(7.0, person.getSelectedPlan().getScore(), 0); break ; } diff --git a/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java b/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java index 2f180299805..52cdbb2ca36 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java +++ b/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java @@ -44,7 +44,7 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.scoring.functions.CharyparNagelScoringFunctionFactory; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; public class ScoringFunctionsForPopulationStressIT { diff --git a/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationTest.java b/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationTest.java index 9eec6681fb6..cecacd2f17d 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationTest.java @@ -21,7 +21,7 @@ package org.matsim.core.scoring; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -44,7 +44,7 @@ import org.matsim.core.router.TripStructureUtils; import org.matsim.core.scenario.ScenarioUtils; - /** + /** * @author mrieser / Simunto GmbH */ public class ScoringFunctionsForPopulationTest { @@ -68,39 +68,39 @@ void testTripScoring() { ScoringFunctionsForPopulation sf = new ScoringFunctionsForPopulation(controlerListenerManager, eventsManager, eventsToActivities, eventsToLegs, population, scoringFunctionFactory, scenario.getConfig()); controlerListenerManager.fireControlerIterationStartsEvent(0, false); ScoringFunction s = sf.getScoringFunctionForAgent(personId); - Assert.assertEquals(RecordingScoringFunction.class, s.getClass()); + Assertions.assertEquals(RecordingScoringFunction.class, s.getClass()); RecordingScoringFunction rs = (RecordingScoringFunction) s; sf.handleActivity(new PersonExperiencedActivity(personId, pf.createActivityFromCoord("home", new Coord(100, 100)))); - Assert.assertEquals(0, rs.tripCounter); + Assertions.assertEquals(0, rs.tripCounter); sf.handleLeg(new PersonExperiencedLeg(personId, pf.createLeg("walk"))); - Assert.assertEquals(0, rs.tripCounter); + Assertions.assertEquals(0, rs.tripCounter); sf.handleEvent(new ActivityStartEvent(8*3600, personId, null, null, "work", new Coord(1000, 100))); - Assert.assertEquals(1, rs.tripCounter); + Assertions.assertEquals(1, rs.tripCounter); sf.handleActivity(new PersonExperiencedActivity(personId, pf.createActivityFromCoord("work", new Coord(1000, 100)))); - Assert.assertEquals(1, rs.tripCounter); - Assert.assertEquals(1, rs.lastTrip.getTripElements().size()); - Assert.assertEquals("walk", ((Leg) rs.lastTrip.getTripElements().get(0)).getMode()); + Assertions.assertEquals(1, rs.tripCounter); + Assertions.assertEquals(1, rs.lastTrip.getTripElements().size()); + Assertions.assertEquals("walk", ((Leg) rs.lastTrip.getTripElements().get(0)).getMode()); sf.handleLeg(new PersonExperiencedLeg(personId, pf.createLeg("transit_walk"))); sf.handleEvent(new ActivityStartEvent(17*3600 - 10, personId, null, null, "pt interaction", new Coord(1000, 200))); - Assert.assertEquals(1, rs.tripCounter); + Assertions.assertEquals(1, rs.tripCounter); sf.handleActivity(new PersonExperiencedActivity(personId, PopulationUtils.createStageActivityFromCoordLinkIdAndModePrefix(new Coord(1000, 200), null, TransportMode.pt))); - Assert.assertEquals(1, rs.tripCounter); + Assertions.assertEquals(1, rs.tripCounter); sf.handleLeg(new PersonExperiencedLeg(personId, pf.createLeg("pt"))); sf.handleEvent(new ActivityStartEvent(17*3600, personId, null, null, "pt interaction", new Coord(1000, 200))); - Assert.assertEquals(1, rs.tripCounter); + Assertions.assertEquals(1, rs.tripCounter); sf.handleActivity(new PersonExperiencedActivity(personId, PopulationUtils.createStageActivityFromCoordLinkIdAndModePrefix(new Coord(1000, 200), null, TransportMode.pt))); - Assert.assertEquals(1, rs.tripCounter); + Assertions.assertEquals(1, rs.tripCounter); sf.handleLeg(new PersonExperiencedLeg(personId, pf.createLeg("transit_walk"))); sf.handleEvent(new ActivityStartEvent(17*3600 + 10, personId, null, null, "leisure", new Coord(1000, 200))); - Assert.assertEquals(2, rs.tripCounter); + Assertions.assertEquals(2, rs.tripCounter); sf.handleActivity(new PersonExperiencedActivity(personId, pf.createActivityFromCoord("leisure", new Coord(1000, 200)))); - Assert.assertEquals(2, rs.tripCounter); - Assert.assertEquals(5, rs.lastTrip.getTripElements().size()); - Assert.assertEquals("transit_walk", ((Leg) rs.lastTrip.getTripElements().get(0)).getMode()); - Assert.assertEquals("pt", ((Leg) rs.lastTrip.getTripElements().get(2)).getMode()); - Assert.assertEquals("transit_walk", ((Leg) rs.lastTrip.getTripElements().get(4)).getMode()); + Assertions.assertEquals(2, rs.tripCounter); + Assertions.assertEquals(5, rs.lastTrip.getTripElements().size()); + Assertions.assertEquals("transit_walk", ((Leg) rs.lastTrip.getTripElements().get(0)).getMode()); + Assertions.assertEquals("pt", ((Leg) rs.lastTrip.getTripElements().get(2)).getMode()); + Assertions.assertEquals("transit_walk", ((Leg) rs.lastTrip.getTripElements().get(4)).getMode()); } @Test @@ -129,10 +129,10 @@ void testPersonScoreEventScoring() { eventsManager.processEvent(new PersonScoreEvent(9*3600, Id.create("xyz", Person.class), 2.345, "testing")); eventsManager.finishProcessing(); - Assert.assertTrue(s instanceof RecordingScoringFunction); + Assertions.assertTrue(s instanceof RecordingScoringFunction); RecordingScoringFunction rsf = (RecordingScoringFunction) s; - Assert.assertEquals(2, rsf.separateScoreCounter); - Assert.assertEquals(1.234+2.345, rsf.separateScoreSum, 1e-7); + Assertions.assertEquals(2, rsf.separateScoreCounter); + Assertions.assertEquals(1.234+2.345, rsf.separateScoreSum, 1e-7); } private static class RecordingScoringFunction implements ScoringFunction { diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringDailyConstantsTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringDailyConstantsTest.java index 20f3e790285..a80a186aa0e 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringDailyConstantsTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringDailyConstantsTest.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.core.scoring.functions; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -173,19 +173,19 @@ void test1() throws Exception { scoring2.finish(); } - Assert.assertEquals( - "wrong score; daily constants are not accounted for in the scoring.", + Assertions.assertEquals( -12345.678, scoring1.getScore(), - MatsimTestUtils.EPSILON ); + MatsimTestUtils.EPSILON, + "wrong score; daily constants are not accounted for in the scoring." ); double defaultScore = (legTravelTime1 + legTravelTime2) * new ScoringConfigGroup().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() / 3600. + legTravelTime3 * new ScoringConfigGroup().getModes().get(TransportMode.bike).getMarginalUtilityOfTraveling() / 3600.; - Assert.assertEquals( - "wrong score; daily constants are not accounted for in the scoring.", + Assertions.assertEquals( -12345.678 + defaultScore, scoring2.getScore(), - MatsimTestUtils.EPSILON ); + MatsimTestUtils.EPSILON, + "wrong score; daily constants are not accounted for in the scoring." ); } private CharyparNagelLegScoring createDefaultPlusConstants(Network network) { diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringPtChangeTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringPtChangeTest.java index 7993c58251f..cf0c0d3131b 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringPtChangeTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringPtChangeTest.java @@ -21,7 +21,7 @@ import java.util.Random; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -105,11 +105,11 @@ void testPtParamsDoNotInfluenceCarScore() throws Exception { scoring2.finish(); // here, we should get the same score. - Assert.assertEquals( - "score for car leg differs when changing pt parameters! Probably a problem in line change handling.", + Assertions.assertEquals( scoring1.getScore(), scoring2.getScore(), - MatsimTestUtils.EPSILON ); + MatsimTestUtils.EPSILON, + "score for car leg differs when changing pt parameters! Probably a problem in line change handling." ); } private static CharyparNagelLegScoring createScoring( diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelOpenTimesScoringFunctionTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelOpenTimesScoringFunctionTest.java index be33cc41056..18f059766b9 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelOpenTimesScoringFunctionTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelOpenTimesScoringFunctionTest.java @@ -20,7 +20,7 @@ package org.matsim.core.scoring.functions; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.After; import org.junit.Before; diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java index c6d2b91d154..b63e771c6f9 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java @@ -20,8 +20,8 @@ package org.matsim.core.scoring.functions; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelWithSubpopulationsTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelWithSubpopulationsTest.java index 0ea4ba8bcd4..153a2796e35 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelWithSubpopulationsTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelWithSubpopulationsTest.java @@ -18,7 +18,7 @@ * *********************************************************************** */ package org.matsim.core.scoring.functions; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -71,9 +71,9 @@ void testLegsScoredDifferently() { function2.handleLeg(leg); function2.finish(); - Assert.assertFalse( - "same score for legs of agents in different subpopulations", - Math.abs( function1.getScore() - function2.getScore() ) < 1E-9 ); + Assertions.assertFalse( + Math.abs( function1.getScore() - function2.getScore() ) < 1E-9, + "same score for legs of agents in different subpopulations" ); } @Test @@ -102,9 +102,9 @@ void testActivitiesScoredDifferently() { function2.handleActivity( act ); function2.finish(); - Assert.assertFalse( - "same score for legs of agents in different subpopulations", - Math.abs( function1.getScore() - function2.getScore() ) < 1E-9 ); + Assertions.assertFalse( + Math.abs( function1.getScore() - function2.getScore() ) < 1E-9, + "same score for legs of agents in different subpopulations" ); } private Scenario createTestScenario() { diff --git a/matsim/src/test/java/org/matsim/core/trafficmonitoring/LinkToLinkTravelTimeCalculatorTest.java b/matsim/src/test/java/org/matsim/core/trafficmonitoring/LinkToLinkTravelTimeCalculatorTest.java index 8fa5e790ab5..ad9ef3dcc1a 100644 --- a/matsim/src/test/java/org/matsim/core/trafficmonitoring/LinkToLinkTravelTimeCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/trafficmonitoring/LinkToLinkTravelTimeCalculatorTest.java @@ -20,7 +20,7 @@ package org.matsim.core.trafficmonitoring; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorTest.java b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorTest.java index 552d6399169..87495bae909 100644 --- a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorTest.java @@ -20,8 +20,8 @@ package org.matsim.core.trafficmonitoring; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -32,7 +32,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -359,8 +359,8 @@ void testReadFromFile_LargeScenarioCase() throws SAXException, ParserConfigurati Link link10 = network.getLinks().get(Id.create("10", Link.class)); - assertEquals("wrong link travel time at 06:00.", 110.0, ttCalc.getLinkTravelTimes().getLinkTravelTime(link10, 6.0 * 3600, null, null), MatsimTestUtils.EPSILON); - assertEquals("wrong link travel time at 06:15.", 359.9712023038157, ttCalc.getLinkTravelTimes().getLinkTravelTime(link10, 6.25 * 3600, null, null), 1e-3); // traveltimecalculator has a resolution of 0.001 seconds + assertEquals(110.0, ttCalc.getLinkTravelTimes().getLinkTravelTime(link10, 6.0 * 3600, null, null), MatsimTestUtils.EPSILON, "wrong link travel time at 06:00."); + assertEquals(359.9712023038157, ttCalc.getLinkTravelTimes().getLinkTravelTime(link10, 6.25 * 3600, null, null), 1e-3, "wrong link travel time at 06:15."); // traveltimecalculator has a resolution of 0.001 seconds } /** @@ -389,7 +389,7 @@ void testGetLinkTravelTime_ignorePtVehiclesAtStop() { ttc.handleEvent(new VehicleArrivesAtFacilityEvent(240, ptVehId, Id.create("stop", TransitStopFacility.class), 0)); ttc.handleEvent(new LinkLeaveEvent(350, ptVehId, link1.getId())); - Assert.assertEquals("The time of transit vehicles at stop should not be counted", 100.0, ttc.getLinkTravelTimes().getLinkTravelTime(link1, 200, null, null), 1e-8); + Assertions.assertEquals(100.0, ttc.getLinkTravelTimes().getLinkTravelTime(link1, 200, null, null), 1e-8, "The time of transit vehicles at stop should not be counted"); } /** @@ -417,7 +417,7 @@ void testGetLinkTravelTime_usePtVehiclesWithoutStop() { ttc.handleEvent(new LinkLeaveEvent(200, ivVehId, link1.getId())); ttc.handleEvent(new LinkLeaveEvent(300, ptVehId, link1.getId())); - Assert.assertEquals("The time of transit vehicles at stop should not be counted", 125.0, ttc.getLinkTravelTimes().getLinkTravelTime(link1, 200, null, null), 1e-8); + Assertions.assertEquals(125.0, ttc.getLinkTravelTimes().getLinkTravelTime(link1, 200, null, null), 1e-8, "The time of transit vehicles at stop should not be counted"); } @@ -454,7 +454,7 @@ void testGetLinkTravelTime_NoAnalyzedModes() { ttc.handleEvent(new LinkEnterEvent(200, vehId, link2.getId())); ttc.handleEvent(new LinkLeaveEvent(300, vehId, link2.getId())); - Assert.assertEquals("No transport mode has been registered to be analyzed, therefore no vehicle/agent should be counted", 1000.0, ttc.getLinkTravelTimes().getLinkTravelTime(link2, 300, null, null), 1e-8); + Assertions.assertEquals(1000.0, ttc.getLinkTravelTimes().getLinkTravelTime(link2, 300, null, null), 1e-8, "No transport mode has been registered to be analyzed, therefore no vehicle/agent should be counted"); // 1000.0s is the freespeed travel time (euclidean link length: 1000m, default freespeed: 1m/s) } @@ -497,7 +497,7 @@ void testGetLinkTravelTime_CarAnalyzedModes() { ttc.handleEvent(new LinkLeaveEvent(200, vehId1, link2.getId())); ttc.handleEvent(new LinkLeaveEvent(410, vehId2, link2.getId())); - Assert.assertEquals("Only transport mode has been registered to be analyzed, therefore no walk agent should be counted", 100.0, ttc.getLinkTravelTimes().getLinkTravelTime(link2, 200, null, null), 1e-8); + Assertions.assertEquals(100.0, ttc.getLinkTravelTimes().getLinkTravelTime(link2, 200, null, null), 1e-8, "Only transport mode has been registered to be analyzed, therefore no walk agent should be counted"); } /** @@ -539,7 +539,7 @@ void testGetLinkTravelTime_NoFilterModes() { ttc.handleEvent(new LinkLeaveEvent(200, vehId1, link2.getId())); ttc.handleEvent(new LinkLeaveEvent(410, vehId2, link2.getId())); - Assert.assertEquals("Filtering analyzed transport modes is disabled, therefore count all modes", 200.0, ttc.getLinkTravelTimes().getLinkTravelTime(link2, 200, null, null), 1e-8); + Assertions.assertEquals(200.0, ttc.getLinkTravelTimes().getLinkTravelTime(link2, 200, null, null), 1e-8, "Filtering analyzed transport modes is disabled, therefore count all modes"); } /** @@ -580,7 +580,7 @@ void testGetLinkTravelTime_FilterDefaultModes() { ttc.handleEvent(new LinkLeaveEvent(200, vehId1, link2.getId())); ttc.handleEvent(new LinkLeaveEvent(410, vehId2, link2.getId())); - Assert.assertEquals("Filtering analyzed transport modes is enabled, but no modes set. Therefore, use default (=car)", 100.0, - ttc.getLinkTravelTimes().getLinkTravelTime(link2, 200, null, null), 1e-8); + Assertions.assertEquals(100.0, + ttc.getLinkTravelTimes().getLinkTravelTime(link2, 200, null, null), 1e-8, "Filtering analyzed transport modes is enabled, but no modes set. Therefore, use default (=car)"); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/charts/BarChartTest.java b/matsim/src/test/java/org/matsim/core/utils/charts/BarChartTest.java index 4d9f848e412..1b5156efb97 100644 --- a/matsim/src/test/java/org/matsim/core/utils/charts/BarChartTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/charts/BarChartTest.java @@ -20,8 +20,8 @@ package org.matsim.core.utils.charts; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.awt.image.BufferedImage; import java.io.File; diff --git a/matsim/src/test/java/org/matsim/core/utils/charts/LineChartTest.java b/matsim/src/test/java/org/matsim/core/utils/charts/LineChartTest.java index d51e8a862ad..b69ed06a93c 100644 --- a/matsim/src/test/java/org/matsim/core/utils/charts/LineChartTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/charts/LineChartTest.java @@ -20,8 +20,8 @@ package org.matsim.core.utils.charts; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.awt.image.BufferedImage; import java.io.File; diff --git a/matsim/src/test/java/org/matsim/core/utils/charts/XYLineChartTest.java b/matsim/src/test/java/org/matsim/core/utils/charts/XYLineChartTest.java index 2820560dec5..4b8274257fa 100644 --- a/matsim/src/test/java/org/matsim/core/utils/charts/XYLineChartTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/charts/XYLineChartTest.java @@ -20,8 +20,8 @@ package org.matsim.core.utils.charts; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.awt.image.BufferedImage; import java.io.File; diff --git a/matsim/src/test/java/org/matsim/core/utils/charts/XYScatterChartTest.java b/matsim/src/test/java/org/matsim/core/utils/charts/XYScatterChartTest.java index 146203c96d9..2f3dd4db905 100644 --- a/matsim/src/test/java/org/matsim/core/utils/charts/XYScatterChartTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/charts/XYScatterChartTest.java @@ -20,8 +20,8 @@ package org.matsim.core.utils.charts; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.awt.image.BufferedImage; import java.io.File; diff --git a/matsim/src/test/java/org/matsim/core/utils/collections/ArrayMapTest.java b/matsim/src/test/java/org/matsim/core/utils/collections/ArrayMapTest.java index c50c2131c3e..becaf977020 100644 --- a/matsim/src/test/java/org/matsim/core/utils/collections/ArrayMapTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/collections/ArrayMapTest.java @@ -1,6 +1,6 @@ package org.matsim.core.utils.collections; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.util.ArrayList; @@ -22,36 +22,36 @@ public class ArrayMapTest { void testPutGetRemoveSize() { ArrayMap map = new ArrayMap<>(); - Assert.assertEquals(0, map.size()); - Assert.assertTrue(map.isEmpty()); + Assertions.assertEquals(0, map.size()); + Assertions.assertTrue(map.isEmpty()); - Assert.assertNull(map.put("1", "one")); + Assertions.assertNull(map.put("1", "one")); - Assert.assertEquals(1, map.size()); - Assert.assertFalse(map.isEmpty()); + Assertions.assertEquals(1, map.size()); + Assertions.assertFalse(map.isEmpty()); - Assert.assertNull(map.put("2", "two")); + Assertions.assertNull(map.put("2", "two")); - Assert.assertEquals(2, map.size()); - Assert.assertFalse(map.isEmpty()); + Assertions.assertEquals(2, map.size()); + Assertions.assertFalse(map.isEmpty()); - Assert.assertEquals("one", map.put("1", "also-one")); - Assert.assertEquals(2, map.size()); + Assertions.assertEquals("one", map.put("1", "also-one")); + Assertions.assertEquals(2, map.size()); - Assert.assertNull(map.put("3", "three")); - Assert.assertEquals(3, map.size()); + Assertions.assertNull(map.put("3", "three")); + Assertions.assertEquals(3, map.size()); - Assert.assertNull(map.put("4", null)); - Assert.assertEquals(4, map.size()); + Assertions.assertNull(map.put("4", null)); + Assertions.assertEquals(4, map.size()); - Assert.assertEquals("also-one", map.get("1")); - Assert.assertEquals("two", map.get("2")); - Assert.assertEquals("three", map.get("3")); - Assert.assertNull(map.get("4")); + Assertions.assertEquals("also-one", map.get("1")); + Assertions.assertEquals("two", map.get("2")); + Assertions.assertEquals("three", map.get("3")); + Assertions.assertNull(map.get("4")); - Assert.assertEquals("two", map.remove("2")); - Assert.assertEquals(3, map.size()); - Assert.assertNull(map.get("2")); + Assertions.assertEquals("two", map.remove("2")); + Assertions.assertEquals(3, map.size()); + Assertions.assertNull(map.get("2")); } @Test @@ -66,19 +66,19 @@ void testValuesIterable() { int i = 0; for (String data : map.values()) { if (i == 0) { - Assert.assertEquals("one", data); + Assertions.assertEquals("one", data); } else if (i == 1) { - Assert.assertEquals("two", data); + Assertions.assertEquals("two", data); } else if (i == 2) { - Assert.assertEquals("four", data); + Assertions.assertEquals("four", data); } else if (i == 3) { - Assert.assertEquals("five", data); + Assertions.assertEquals("five", data); } else { throw new RuntimeException("unexpected element: " + data); } i++; } - Assert.assertEquals(4, i); + Assertions.assertEquals(4, i); } @Test @@ -94,17 +94,17 @@ void testForEach() { map.forEach((k, v) -> data.add(new Tuple<>(k, v))); - Assert.assertEquals("1", data.get(0).getFirst()); - Assert.assertEquals("one", data.get(0).getSecond()); + Assertions.assertEquals("1", data.get(0).getFirst()); + Assertions.assertEquals("one", data.get(0).getSecond()); - Assert.assertEquals("2", data.get(1).getFirst()); - Assert.assertEquals("two", data.get(1).getSecond()); + Assertions.assertEquals("2", data.get(1).getFirst()); + Assertions.assertEquals("two", data.get(1).getSecond()); - Assert.assertEquals("4", data.get(2).getFirst()); - Assert.assertEquals("four", data.get(2).getSecond()); + Assertions.assertEquals("4", data.get(2).getFirst()); + Assertions.assertEquals("four", data.get(2).getSecond()); - Assert.assertEquals("5", data.get(3).getFirst()); - Assert.assertEquals("five", data.get(3).getSecond()); + Assertions.assertEquals("5", data.get(3).getFirst()); + Assertions.assertEquals("five", data.get(3).getSecond()); } @Test @@ -116,19 +116,19 @@ void testContainsKey() { map.put("4", "four"); map.put("5", "five"); - Assert.assertTrue(map.containsKey("1")); - Assert.assertTrue(map.containsKey("2")); - Assert.assertFalse(map.containsKey("3")); - Assert.assertTrue(map.containsKey("4")); - Assert.assertTrue(map.containsKey("5")); - Assert.assertFalse(map.containsKey("6")); - - Assert.assertTrue(map.containsKey("1")); - Assert.assertTrue(map.containsKey("2")); - Assert.assertFalse(map.containsKey("3")); - Assert.assertTrue(map.containsKey("4")); - Assert.assertTrue(map.containsKey("5")); - Assert.assertFalse(map.containsKey("6")); + Assertions.assertTrue(map.containsKey("1")); + Assertions.assertTrue(map.containsKey("2")); + Assertions.assertFalse(map.containsKey("3")); + Assertions.assertTrue(map.containsKey("4")); + Assertions.assertTrue(map.containsKey("5")); + Assertions.assertFalse(map.containsKey("6")); + + Assertions.assertTrue(map.containsKey("1")); + Assertions.assertTrue(map.containsKey("2")); + Assertions.assertFalse(map.containsKey("3")); + Assertions.assertTrue(map.containsKey("4")); + Assertions.assertTrue(map.containsKey("5")); + Assertions.assertFalse(map.containsKey("6")); } @Test @@ -140,12 +140,12 @@ void testContainsValue() { map.put("4", "four"); map.put("5", "five"); - Assert.assertTrue(map.containsValue("one")); - Assert.assertTrue(map.containsValue("two")); - Assert.assertFalse(map.containsValue("three")); - Assert.assertTrue(map.containsValue("four")); - Assert.assertTrue(map.containsValue("five")); - Assert.assertFalse(map.containsValue("six")); + Assertions.assertTrue(map.containsValue("one")); + Assertions.assertTrue(map.containsValue("two")); + Assertions.assertFalse(map.containsValue("three")); + Assertions.assertTrue(map.containsValue("four")); + Assertions.assertTrue(map.containsValue("five")); + Assertions.assertFalse(map.containsValue("six")); } @Test @@ -160,13 +160,13 @@ void testPutAll_ArrayMap() { map.putAll(map2); - Assert.assertEquals(4, map.size()); + Assertions.assertEquals(4, map.size()); - Assert.assertEquals("one", map.get("1")); - Assert.assertEquals("two", map.get("2")); - Assert.assertNull(map.get("3")); - Assert.assertEquals("four", map.get("4")); - Assert.assertEquals("five", map.get("5")); + Assertions.assertEquals("one", map.get("1")); + Assertions.assertEquals("two", map.get("2")); + Assertions.assertNull(map.get("3")); + Assertions.assertEquals("four", map.get("4")); + Assertions.assertEquals("five", map.get("5")); } @Test @@ -181,13 +181,13 @@ void testPutAll_GenericMap() { map.putAll(map2); - Assert.assertEquals(4, map.size()); + Assertions.assertEquals(4, map.size()); - Assert.assertEquals("one", map.get("1")); - Assert.assertEquals("two", map.get("2")); - Assert.assertNull(map.get("3")); - Assert.assertEquals("four", map.get("4")); - Assert.assertEquals("five", map.get("5")); + Assertions.assertEquals("one", map.get("1")); + Assertions.assertEquals("two", map.get("2")); + Assertions.assertNull(map.get("3")); + Assertions.assertEquals("four", map.get("4")); + Assertions.assertEquals("five", map.get("5")); } @Test @@ -199,17 +199,17 @@ void testClear() { map.put("4", "four"); map.put("5", "five"); - Assert.assertEquals(4, map.size()); + Assertions.assertEquals(4, map.size()); map.clear(); - Assert.assertEquals(0, map.size()); + Assertions.assertEquals(0, map.size()); - Assert.assertNull(map.get("1")); - Assert.assertNull(map.get("2")); - Assert.assertNull(map.get("3")); + Assertions.assertNull(map.get("1")); + Assertions.assertNull(map.get("2")); + Assertions.assertNull(map.get("3")); - Assert.assertFalse(map.containsKey("1")); + Assertions.assertFalse(map.containsKey("1")); } @Test @@ -222,28 +222,28 @@ void testValues() { map.put("5", "five"); Collection coll = map.values(); - Assert.assertEquals(4, coll.size()); + Assertions.assertEquals(4, coll.size()); map.put("6", "six"); - Assert.assertEquals(5, coll.size()); + Assertions.assertEquals(5, coll.size()); - Assert.assertTrue(coll.remove("one")); - Assert.assertFalse(coll.remove("null")); + Assertions.assertTrue(coll.remove("one")); + Assertions.assertFalse(coll.remove("null")); - Assert.assertFalse(map.containsValue("one")); - Assert.assertTrue(map.containsValue("two")); + Assertions.assertFalse(map.containsValue("one")); + Assertions.assertTrue(map.containsValue("two")); - Assert.assertTrue(coll.contains("two")); - Assert.assertFalse(coll.contains("one")); + Assertions.assertTrue(coll.contains("two")); + Assertions.assertFalse(coll.contains("one")); Set values = new HashSet<>(); coll.forEach(v -> values.add(v)); - Assert.assertEquals(4, values.size()); - Assert.assertTrue(values.contains("two")); - Assert.assertTrue(values.contains("four")); - Assert.assertTrue(values.contains("five")); - Assert.assertTrue(values.contains("six")); + Assertions.assertEquals(4, values.size()); + Assertions.assertTrue(values.contains("two")); + Assertions.assertTrue(values.contains("four")); + Assertions.assertTrue(values.contains("five")); + Assertions.assertTrue(values.contains("six")); } @Test @@ -263,28 +263,28 @@ void testKeySet() { map.put(key5, "five"); Set set = map.keySet(); - Assert.assertEquals(4, set.size()); + Assertions.assertEquals(4, set.size()); map.put(key6, "six"); - Assert.assertEquals(5, set.size()); + Assertions.assertEquals(5, set.size()); - Assert.assertTrue(set.remove(key1)); - Assert.assertFalse(set.remove(key3)); + Assertions.assertTrue(set.remove(key1)); + Assertions.assertFalse(set.remove(key3)); - Assert.assertFalse(map.containsKey(key1)); - Assert.assertTrue(map.containsKey(key2)); + Assertions.assertFalse(map.containsKey(key1)); + Assertions.assertTrue(map.containsKey(key2)); - Assert.assertTrue(set.contains(key2)); - Assert.assertFalse(set.contains(key1)); + Assertions.assertTrue(set.contains(key2)); + Assertions.assertFalse(set.contains(key1)); Set keys = new HashSet<>(); set.forEach(k -> keys.add(k)); - Assert.assertEquals(4, keys.size()); - Assert.assertTrue(keys.contains(key2)); - Assert.assertTrue(keys.contains(key4)); - Assert.assertTrue(keys.contains(key5)); - Assert.assertTrue(keys.contains(key6)); + Assertions.assertEquals(4, keys.size()); + Assertions.assertTrue(keys.contains(key2)); + Assertions.assertTrue(keys.contains(key4)); + Assertions.assertTrue(keys.contains(key5)); + Assertions.assertTrue(keys.contains(key6)); } @Test @@ -303,10 +303,10 @@ void testEntrySet() { map.put(key5, "five"); Set> set = map.entrySet(); - Assert.assertEquals(4, set.size()); + Assertions.assertEquals(4, set.size()); map.put(key6, "six"); - Assert.assertEquals(5, set.size()); + Assertions.assertEquals(5, set.size()); Map> entries = new HashMap<>(); @@ -314,31 +314,31 @@ void testEntrySet() { entries.put(e.getKey(), e); } - Assert.assertEquals(key1, entries.get(key1).getKey()); - Assert.assertEquals("one", entries.get(key1).getValue()); - Assert.assertEquals("two", entries.get(key2).getValue()); - Assert.assertEquals("four", entries.get(key4).getValue()); - Assert.assertEquals("five", entries.get(key5).getValue()); + Assertions.assertEquals(key1, entries.get(key1).getKey()); + Assertions.assertEquals("one", entries.get(key1).getValue()); + Assertions.assertEquals("two", entries.get(key2).getValue()); + Assertions.assertEquals("four", entries.get(key4).getValue()); + Assertions.assertEquals("five", entries.get(key5).getValue()); - Assert.assertTrue(set.remove(entries.get(key1))); + Assertions.assertTrue(set.remove(entries.get(key1))); //noinspection SuspiciousMethodCalls - Assert.assertFalse(set.remove(new Object())); + Assertions.assertFalse(set.remove(new Object())); - Assert.assertFalse(map.containsKey(key1)); - Assert.assertTrue(map.containsKey(key2)); + Assertions.assertFalse(map.containsKey(key1)); + Assertions.assertTrue(map.containsKey(key2)); - Assert.assertTrue(set.contains(entries.get(key2))); - Assert.assertFalse(set.contains(entries.get(key1))); + Assertions.assertTrue(set.contains(entries.get(key2))); + Assertions.assertFalse(set.contains(entries.get(key1))); // test forEach Set> es = new HashSet<>(); set.forEach(k -> es.add(k)); - Assert.assertEquals(4, es.size()); - Assert.assertTrue(es.contains(entries.get(key2))); - Assert.assertTrue(es.contains(entries.get(key4))); - Assert.assertTrue(es.contains(entries.get(key5))); - Assert.assertTrue(es.contains(entries.get(key6))); + Assertions.assertEquals(4, es.size()); + Assertions.assertTrue(es.contains(entries.get(key2))); + Assertions.assertTrue(es.contains(entries.get(key4))); + Assertions.assertTrue(es.contains(entries.get(key5))); + Assertions.assertTrue(es.contains(entries.get(key6))); } @Test @@ -356,28 +356,28 @@ void testValuesIterator_iterate() { map.put(key5, "five"); Iterator iter = map.values().iterator(); - Assert.assertNotNull(iter); + Assertions.assertNotNull(iter); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("one", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("one", iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("two", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("two", iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("four", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("four", iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("five", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("five", iter.next()); - Assert.assertFalse(iter.hasNext()); + Assertions.assertFalse(iter.hasNext()); try { iter.next(); - Assert.fail("Expected exception, got none."); + Assertions.fail("Expected exception, got none."); } catch (NoSuchElementException ignore) { } - Assert.assertFalse(iter.hasNext()); + Assertions.assertFalse(iter.hasNext()); } @Test @@ -395,24 +395,24 @@ void testValuesIterator_remove() { map.put(key5, "five"); Iterator iter = map.values().iterator(); - Assert.assertNotNull(iter); + Assertions.assertNotNull(iter); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("one", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("one", iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("two", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("two", iter.next()); iter.remove(); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("four", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("four", iter.next()); - Assert.assertEquals(3, map.size()); - Assert.assertTrue(map.containsValue("one")); - Assert.assertFalse(map.containsValue("two")); - Assert.assertTrue(map.containsValue("four")); - Assert.assertTrue(map.containsValue("five")); + Assertions.assertEquals(3, map.size()); + Assertions.assertTrue(map.containsValue("one")); + Assertions.assertFalse(map.containsValue("two")); + Assertions.assertTrue(map.containsValue("four")); + Assertions.assertTrue(map.containsValue("five")); } @Test @@ -430,28 +430,28 @@ void testKeySetIterator_iterate() { map.put(key5, "five"); Iterator iter = map.keySet().iterator(); - Assert.assertNotNull(iter); + Assertions.assertNotNull(iter); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("1", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("1", iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("2", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("2", iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("4", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("4", iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("5", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("5", iter.next()); - Assert.assertFalse(iter.hasNext()); + Assertions.assertFalse(iter.hasNext()); try { iter.next(); - Assert.fail("Expected exception, got none."); + Assertions.fail("Expected exception, got none."); } catch (NoSuchElementException ignore) { } - Assert.assertFalse(iter.hasNext()); + Assertions.assertFalse(iter.hasNext()); } @Test @@ -469,24 +469,24 @@ void testKeySetIterator_remove() { map.put(key5, "five"); Iterator iter = map.keySet().iterator(); - Assert.assertNotNull(iter); + Assertions.assertNotNull(iter); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("1", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("1", iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("2", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("2", iter.next()); iter.remove(); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("4", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("4", iter.next()); - Assert.assertEquals(3, map.size()); - Assert.assertTrue(map.containsKey("1")); - Assert.assertFalse(map.containsKey("2")); - Assert.assertTrue(map.containsKey("4")); - Assert.assertTrue(map.containsKey("5")); + Assertions.assertEquals(3, map.size()); + Assertions.assertTrue(map.containsKey("1")); + Assertions.assertFalse(map.containsKey("2")); + Assertions.assertTrue(map.containsKey("4")); + Assertions.assertTrue(map.containsKey("5")); } @Test @@ -504,10 +504,10 @@ void testKeySetToArray() { map.put(key5, "five"); Object[] array = map.keySet().toArray(); - Assert.assertEquals(key1, array[0]); - Assert.assertEquals(key2, array[1]); - Assert.assertEquals(key4, array[2]); - Assert.assertEquals(key5, array[3]); + Assertions.assertEquals(key1, array[0]); + Assertions.assertEquals(key2, array[1]); + Assertions.assertEquals(key4, array[2]); + Assertions.assertEquals(key5, array[3]); } @@ -521,26 +521,26 @@ void testCopyConstructor() { ArrayMap map = new ArrayMap<>(map0); - Assert.assertEquals(4, map.size()); - Assert.assertFalse(map.isEmpty()); - - Assert.assertTrue(map.containsKey("2")); - Assert.assertTrue(map.containsKey("1")); - Assert.assertTrue(map.containsKey("3")); - Assert.assertTrue(map.containsKey("4")); - Assert.assertFalse(map.containsKey("5")); - - Assert.assertTrue(map.containsValue("one")); - Assert.assertTrue(map.containsValue("two")); - Assert.assertTrue(map.containsValue("three")); - Assert.assertTrue(map.containsValue("four")); - Assert.assertFalse(map.containsValue("five")); - - Assert.assertEquals("one", map.get("1")); - Assert.assertEquals("two", map.get("2")); - Assert.assertEquals("three", map.get("3")); - Assert.assertEquals("four", map.get("4")); - Assert.assertNull(map.get("5")); + Assertions.assertEquals(4, map.size()); + Assertions.assertFalse(map.isEmpty()); + + Assertions.assertTrue(map.containsKey("2")); + Assertions.assertTrue(map.containsKey("1")); + Assertions.assertTrue(map.containsKey("3")); + Assertions.assertTrue(map.containsKey("4")); + Assertions.assertFalse(map.containsKey("5")); + + Assertions.assertTrue(map.containsValue("one")); + Assertions.assertTrue(map.containsValue("two")); + Assertions.assertTrue(map.containsValue("three")); + Assertions.assertTrue(map.containsValue("four")); + Assertions.assertFalse(map.containsValue("five")); + + Assertions.assertEquals("one", map.get("1")); + Assertions.assertEquals("two", map.get("2")); + Assertions.assertEquals("three", map.get("3")); + Assertions.assertEquals("four", map.get("4")); + Assertions.assertNull(map.get("5")); } } \ No newline at end of file diff --git a/matsim/src/test/java/org/matsim/core/utils/collections/CollectionUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/collections/CollectionUtilsTest.java index 40ad88c902d..67f3a4924bd 100644 --- a/matsim/src/test/java/org/matsim/core/utils/collections/CollectionUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/collections/CollectionUtilsTest.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -44,13 +44,13 @@ void testSetToString() { set.add("Bbb"); set.add("Ddd"); set.add("Ccc"); - Assert.assertEquals("Aaa,Bbb,Ddd,Ccc", CollectionUtils.setToString(set)); + Assertions.assertEquals("Aaa,Bbb,Ddd,Ccc", CollectionUtils.setToString(set)); } @Test void testArrayToString() { String[] array = new String[] {"Aaa", "Bbb", "Ddd", "Ccc"}; - Assert.assertEquals("Aaa,Bbb,Ddd,Ccc", CollectionUtils.arrayToString(array)); + Assertions.assertEquals("Aaa,Bbb,Ddd,Ccc", CollectionUtils.arrayToString(array)); } @Test @@ -68,20 +68,20 @@ void testStringToSet() { for (String str : testStrings) { log.info("testing String: " + str); Set set = CollectionUtils.stringToSet(str); - Assert.assertEquals(4, set.size()); + Assertions.assertEquals(4, set.size()); Iterator iter = set.iterator(); - Assert.assertEquals("Aaa", iter.next()); - Assert.assertEquals("Bbb", iter.next()); - Assert.assertEquals("Ddd", iter.next()); - Assert.assertEquals("Ccc", iter.next()); - Assert.assertFalse(iter.hasNext()); + Assertions.assertEquals("Aaa", iter.next()); + Assertions.assertEquals("Bbb", iter.next()); + Assertions.assertEquals("Ddd", iter.next()); + Assertions.assertEquals("Ccc", iter.next()); + Assertions.assertFalse(iter.hasNext()); } } @Test void testNullStringToSet() { Set set = CollectionUtils.stringToSet(null); - Assert.assertEquals(0, set.size()); + Assertions.assertEquals(0, set.size()); } @Test @@ -99,18 +99,18 @@ void testStringToArray() { for (String str : testStrings) { log.info("testing String: " + str); String[] array = CollectionUtils.stringToArray(str); - Assert.assertEquals(4, array.length); - Assert.assertEquals("Aaa", array[0]); - Assert.assertEquals("Bbb", array[1]); - Assert.assertEquals("Ddd", array[2]); - Assert.assertEquals("Ccc", array[3]); + Assertions.assertEquals(4, array.length); + Assertions.assertEquals("Aaa", array[0]); + Assertions.assertEquals("Bbb", array[1]); + Assertions.assertEquals("Ddd", array[2]); + Assertions.assertEquals("Ccc", array[3]); } } @Test void testNullStringToArray() { String[] array = CollectionUtils.stringToArray(null); - Assert.assertEquals(0, array.length); + Assertions.assertEquals(0, array.length); } @Test @@ -120,7 +120,7 @@ void testIdSetToString() { set.add(Id.create("Bbb", Link.class)); set.add(Id.create("Ddd", Link.class)); set.add(Id.create("Ccc", Link.class)); - Assert.assertEquals("Aaa,Bbb,Ddd,Ccc", CollectionUtils.idSetToString(set)); + Assertions.assertEquals("Aaa,Bbb,Ddd,Ccc", CollectionUtils.idSetToString(set)); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/collections/IdentifiableArrayMapTest.java b/matsim/src/test/java/org/matsim/core/utils/collections/IdentifiableArrayMapTest.java index d7ab9d6f2a6..f15c84aa5e3 100644 --- a/matsim/src/test/java/org/matsim/core/utils/collections/IdentifiableArrayMapTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/collections/IdentifiableArrayMapTest.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Identifiable; @@ -42,8 +42,8 @@ public class IdentifiableArrayMapTest { @Test void testConstructor() { Map, TO> map = new IdentifiableArrayMap<>(); - Assert.assertEquals(0, map.size()); - Assert.assertTrue(map.isEmpty()); + Assertions.assertEquals(0, map.size()); + Assertions.assertTrue(map.isEmpty()); } @Test @@ -57,20 +57,20 @@ void testPutGet() { TO to2 = new TO(id2); TO to3 = new TO(id3); - Assert.assertNull(map.put(id1, to1)); - Assert.assertEquals(1, map.size()); - Assert.assertFalse(map.isEmpty()); - Assert.assertEquals(to1, map.get(id1)); + Assertions.assertNull(map.put(id1, to1)); + Assertions.assertEquals(1, map.size()); + Assertions.assertFalse(map.isEmpty()); + Assertions.assertEquals(to1, map.get(id1)); - Assert.assertNull(map.put(id2, to2)); - Assert.assertEquals(2, map.size()); - Assert.assertEquals(to2, map.get(id2)); + Assertions.assertNull(map.put(id2, to2)); + Assertions.assertEquals(2, map.size()); + Assertions.assertEquals(to2, map.get(id2)); - Assert.assertNull(map.put(id3, to3)); - Assert.assertEquals(3, map.size()); - Assert.assertEquals(to3, map.get(id3)); - Assert.assertEquals(to2, map.get(id2)); - Assert.assertEquals(to1, map.get(id1)); + Assertions.assertNull(map.put(id3, to3)); + Assertions.assertEquals(3, map.size()); + Assertions.assertEquals(to3, map.get(id3)); + Assertions.assertEquals(to2, map.get(id2)); + Assertions.assertEquals(to1, map.get(id1)); } @Test @@ -84,19 +84,19 @@ void testPutGet_identifiablePut() { TO to2 = new TO(id2); TO to3 = new TO(id3); - Assert.assertNull(map.put(to1)); - Assert.assertEquals(1, map.size()); - Assert.assertEquals(to1, map.get(id1)); + Assertions.assertNull(map.put(to1)); + Assertions.assertEquals(1, map.size()); + Assertions.assertEquals(to1, map.get(id1)); - Assert.assertNull(map.put(to2)); - Assert.assertEquals(2, map.size()); - Assert.assertEquals(to2, map.get(id2)); + Assertions.assertNull(map.put(to2)); + Assertions.assertEquals(2, map.size()); + Assertions.assertEquals(to2, map.get(id2)); - Assert.assertNull(map.put(to3)); - Assert.assertEquals(3, map.size()); - Assert.assertEquals(to3, map.get(id3)); - Assert.assertEquals(to2, map.get(id2)); - Assert.assertEquals(to1, map.get(id1)); + Assertions.assertNull(map.put(to3)); + Assertions.assertEquals(3, map.size()); + Assertions.assertEquals(to3, map.get(id3)); + Assertions.assertEquals(to2, map.get(id2)); + Assertions.assertEquals(to1, map.get(id1)); } @Test @@ -111,25 +111,25 @@ void testPut_multiple() { TO to3 = new TO(id3); map.put(id1, to1); - Assert.assertEquals(1, map.size()); + Assertions.assertEquals(1, map.size()); map.put(id1, to1); - Assert.assertEquals(1, map.size()); + Assertions.assertEquals(1, map.size()); map.put(id2, to2); - Assert.assertEquals(2, map.size()); + Assertions.assertEquals(2, map.size()); map.put(id2, to2); - Assert.assertEquals(2, map.size()); + Assertions.assertEquals(2, map.size()); map.put(id3, to3); - Assert.assertEquals(3, map.size()); + Assertions.assertEquals(3, map.size()); map.put(id2, to2); - Assert.assertEquals(3, map.size()); + Assertions.assertEquals(3, map.size()); map.put(id1, to1); - Assert.assertEquals(3, map.size()); + Assertions.assertEquals(3, map.size()); } @Test @@ -141,9 +141,9 @@ void testGet_equalKeys() { TO to2 = new TO(id2a); map.put(id2a, to2); - Assert.assertEquals(1, map.size()); - Assert.assertEquals(to2, map.get(id2a)); - Assert.assertEquals(to2, map.get(id2b)); + Assertions.assertEquals(1, map.size()); + Assertions.assertEquals(to2, map.get(id2a)); + Assertions.assertEquals(to2, map.get(id2b)); } @Test @@ -160,18 +160,18 @@ void testPut_Overwrite() { TO to3 = new TO(id3); map.put(id1, to1); - Assert.assertEquals(1, map.size()); + Assertions.assertEquals(1, map.size()); - Assert.assertNull(map.put(id2a, to2a)); - Assert.assertEquals(2, map.size()); + Assertions.assertNull(map.put(id2a, to2a)); + Assertions.assertEquals(2, map.size()); map.put(id3, to3); - Assert.assertEquals(3, map.size()); + Assertions.assertEquals(3, map.size()); - Assert.assertEquals(to2a, map.get(id2a)); - Assert.assertEquals(to2a, map.put(id2b, to2b)); - Assert.assertEquals(to2b, map.get(id2b)); - Assert.assertEquals(to2b, map.get(id2a)); + Assertions.assertEquals(to2a, map.get(id2a)); + Assertions.assertEquals(to2a, map.put(id2b, to2b)); + Assertions.assertEquals(to2b, map.get(id2b)); + Assertions.assertEquals(to2b, map.get(id2a)); } @Test @@ -186,28 +186,28 @@ void testContainsKey() { TO to2 = new TO(id2); TO to3 = new TO(id3); - Assert.assertFalse(map.containsKey(id1)); - Assert.assertFalse(map.containsKey(id2)); - Assert.assertFalse(map.containsKey(id2b)); - Assert.assertFalse(map.containsKey(id3)); + Assertions.assertFalse(map.containsKey(id1)); + Assertions.assertFalse(map.containsKey(id2)); + Assertions.assertFalse(map.containsKey(id2b)); + Assertions.assertFalse(map.containsKey(id3)); map.put(id1, to1); - Assert.assertTrue(map.containsKey(id1)); - Assert.assertFalse(map.containsKey(id2)); - Assert.assertFalse(map.containsKey(id2b)); - Assert.assertFalse(map.containsKey(id3)); + Assertions.assertTrue(map.containsKey(id1)); + Assertions.assertFalse(map.containsKey(id2)); + Assertions.assertFalse(map.containsKey(id2b)); + Assertions.assertFalse(map.containsKey(id3)); map.put(id2, to2); - Assert.assertTrue(map.containsKey(id1)); - Assert.assertTrue(map.containsKey(id2)); - Assert.assertTrue(map.containsKey(id2b)); - Assert.assertFalse(map.containsKey(id3)); + Assertions.assertTrue(map.containsKey(id1)); + Assertions.assertTrue(map.containsKey(id2)); + Assertions.assertTrue(map.containsKey(id2b)); + Assertions.assertFalse(map.containsKey(id3)); map.put(id3, to3); - Assert.assertTrue(map.containsKey(id1)); - Assert.assertTrue(map.containsKey(id2)); - Assert.assertTrue(map.containsKey(id2b)); - Assert.assertTrue(map.containsKey(id3)); + Assertions.assertTrue(map.containsKey(id1)); + Assertions.assertTrue(map.containsKey(id2)); + Assertions.assertTrue(map.containsKey(id2b)); + Assertions.assertTrue(map.containsKey(id3)); } @Test @@ -221,24 +221,24 @@ void testContainsValue() { TO to2 = new TO(id2); TO to3 = new TO(id3); - Assert.assertFalse(map.containsValue(to1)); - Assert.assertFalse(map.containsValue(to2)); - Assert.assertFalse(map.containsValue(to3)); + Assertions.assertFalse(map.containsValue(to1)); + Assertions.assertFalse(map.containsValue(to2)); + Assertions.assertFalse(map.containsValue(to3)); map.put(id1, to1); - Assert.assertTrue(map.containsValue(to1)); - Assert.assertFalse(map.containsValue(to2)); - Assert.assertFalse(map.containsValue(to3)); + Assertions.assertTrue(map.containsValue(to1)); + Assertions.assertFalse(map.containsValue(to2)); + Assertions.assertFalse(map.containsValue(to3)); map.put(id2, to2); - Assert.assertTrue(map.containsValue(to1)); - Assert.assertTrue(map.containsValue(to2)); - Assert.assertFalse(map.containsValue(to3)); + Assertions.assertTrue(map.containsValue(to1)); + Assertions.assertTrue(map.containsValue(to2)); + Assertions.assertFalse(map.containsValue(to3)); map.put(id3, to3); - Assert.assertTrue(map.containsValue(to1)); - Assert.assertTrue(map.containsValue(to2)); - Assert.assertTrue(map.containsValue(to3)); + Assertions.assertTrue(map.containsValue(to1)); + Assertions.assertTrue(map.containsValue(to2)); + Assertions.assertTrue(map.containsValue(to3)); } @Test @@ -256,12 +256,12 @@ void testRemove_middle() { map.put(id2, to2); map.put(id3, to3); - Assert.assertTrue(map.containsValue(to2)); - Assert.assertEquals(to2, map.remove(id2)); + Assertions.assertTrue(map.containsValue(to2)); + Assertions.assertEquals(to2, map.remove(id2)); - Assert.assertTrue(map.containsValue(to1)); - Assert.assertFalse(map.containsValue(to2)); - Assert.assertTrue(map.containsValue(to3)); + Assertions.assertTrue(map.containsValue(to1)); + Assertions.assertFalse(map.containsValue(to2)); + Assertions.assertTrue(map.containsValue(to3)); } @Test @@ -279,12 +279,12 @@ void testRemove_start() { map.put(id2, to2); map.put(id3, to3); - Assert.assertTrue(map.containsValue(to2)); - Assert.assertEquals(to1, map.remove(id1)); + Assertions.assertTrue(map.containsValue(to2)); + Assertions.assertEquals(to1, map.remove(id1)); - Assert.assertFalse(map.containsValue(to1)); - Assert.assertTrue(map.containsValue(to2)); - Assert.assertTrue(map.containsValue(to3)); + Assertions.assertFalse(map.containsValue(to1)); + Assertions.assertTrue(map.containsValue(to2)); + Assertions.assertTrue(map.containsValue(to3)); } @Test @@ -302,12 +302,12 @@ void testRemove_end() { map.put(id2, to2); map.put(id3, to3); - Assert.assertTrue(map.containsValue(to2)); - Assert.assertEquals(to3, map.remove(id3)); + Assertions.assertTrue(map.containsValue(to2)); + Assertions.assertEquals(to3, map.remove(id3)); - Assert.assertTrue(map.containsValue(to1)); - Assert.assertTrue(map.containsValue(to2)); - Assert.assertFalse(map.containsValue(to3)); + Assertions.assertTrue(map.containsValue(to1)); + Assertions.assertTrue(map.containsValue(to2)); + Assertions.assertFalse(map.containsValue(to3)); } @Test @@ -325,14 +325,14 @@ void testClear() { map.put(id2, to2); map.put(id3, to3); - Assert.assertEquals(3, map.size()); + Assertions.assertEquals(3, map.size()); map.clear(); - Assert.assertEquals(0, map.size()); - Assert.assertTrue(map.isEmpty()); - Assert.assertFalse(map.containsValue(to2)); - Assert.assertNull(map.get(id2)); + Assertions.assertEquals(0, map.size()); + Assertions.assertTrue(map.isEmpty()); + Assertions.assertFalse(map.containsValue(to2)); + Assertions.assertNull(map.get(id2)); } @Test @@ -352,10 +352,10 @@ void testValues() { Collection values = map.values(); - Assert.assertEquals(3, values.size()); - Assert.assertTrue(values.contains(to1)); - Assert.assertTrue(values.contains(to2)); - Assert.assertTrue(values.contains(to3)); + Assertions.assertEquals(3, values.size()); + Assertions.assertTrue(values.contains(to1)); + Assertions.assertTrue(values.contains(to2)); + Assertions.assertTrue(values.contains(to3)); } @Test @@ -375,10 +375,10 @@ void testKeySet() { Set> keys = map.keySet(); - Assert.assertEquals(3, keys.size()); - Assert.assertTrue(keys.contains(id1)); - Assert.assertTrue(keys.contains(id2)); - Assert.assertTrue(keys.contains(id3)); + Assertions.assertEquals(3, keys.size()); + Assertions.assertTrue(keys.contains(id1)); + Assertions.assertTrue(keys.contains(id2)); + Assertions.assertTrue(keys.contains(id3)); } @Test @@ -398,7 +398,7 @@ void testEntrySet() { Set, TO>> entries = map.entrySet(); - Assert.assertEquals(3, entries.size()); + Assertions.assertEquals(3, entries.size()); } @Test @@ -417,18 +417,18 @@ void testValuesIterator() { map.put(id3, to3); Iterator iter = map.values().iterator(); - Assert.assertNotNull(iter); - - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals(to1, iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals(to2, iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals(to3, iter.next()); - Assert.assertFalse(iter.hasNext()); + Assertions.assertNotNull(iter); + + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals(to1, iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals(to2, iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals(to3, iter.next()); + Assertions.assertFalse(iter.hasNext()); try { iter.next(); - Assert.fail("expected NoSuchElementException."); + Assertions.fail("expected NoSuchElementException."); } catch (NoSuchElementException e) { log.info("catched expected exception."); } @@ -450,22 +450,22 @@ void testValuesToArray() { map.put(id3, to3); Object[] array1 = map.values().toArray(); - Assert.assertEquals(3, array1.length); - Assert.assertEquals(to1, array1[0]); - Assert.assertEquals(to2, array1[1]); - Assert.assertEquals(to3, array1[2]); + Assertions.assertEquals(3, array1.length); + Assertions.assertEquals(to1, array1[0]); + Assertions.assertEquals(to2, array1[1]); + Assertions.assertEquals(to3, array1[2]); TO[] array2 = map.values().toArray(new TO[0]); - Assert.assertEquals(3, array2.length); - Assert.assertEquals(to1, array2[0]); - Assert.assertEquals(to2, array2[1]); - Assert.assertEquals(to3, array2[2]); + Assertions.assertEquals(3, array2.length); + Assertions.assertEquals(to1, array2[0]); + Assertions.assertEquals(to2, array2[1]); + Assertions.assertEquals(to3, array2[2]); TO[] array3 = map.values().toArray(new TO[3]); - Assert.assertEquals(3, array3.length); - Assert.assertEquals(to1, array3[0]); - Assert.assertEquals(to2, array3[1]); - Assert.assertEquals(to3, array3[2]); + Assertions.assertEquals(3, array3.length); + Assertions.assertEquals(to1, array3[0]); + Assertions.assertEquals(to2, array3[1]); + Assertions.assertEquals(to3, array3[2]); } @Test @@ -479,7 +479,7 @@ void testValuesIterator_SingleDiretor() { TO toX = map.values().iterator().next(); - Assert.assertEquals(to1, toX); + Assertions.assertEquals(to1, toX); } private static class TO implements Identifiable { diff --git a/matsim/src/test/java/org/matsim/core/utils/collections/IntArrayMapTest.java b/matsim/src/test/java/org/matsim/core/utils/collections/IntArrayMapTest.java index a23afe67ad0..ea8a040a699 100644 --- a/matsim/src/test/java/org/matsim/core/utils/collections/IntArrayMapTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/collections/IntArrayMapTest.java @@ -1,6 +1,6 @@ package org.matsim.core.utils.collections; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.util.ArrayList; @@ -22,36 +22,36 @@ public class IntArrayMapTest { void testPutGetRemoveSize() { IntArrayMap map = new IntArrayMap<>(); - Assert.assertEquals(0, map.size()); - Assert.assertTrue(map.isEmpty()); + Assertions.assertEquals(0, map.size()); + Assertions.assertTrue(map.isEmpty()); - Assert.assertNull(map.put(1, "one")); + Assertions.assertNull(map.put(1, "one")); - Assert.assertEquals(1, map.size()); - Assert.assertFalse(map.isEmpty()); + Assertions.assertEquals(1, map.size()); + Assertions.assertFalse(map.isEmpty()); - Assert.assertNull(map.put(2, "two")); + Assertions.assertNull(map.put(2, "two")); - Assert.assertEquals(2, map.size()); - Assert.assertFalse(map.isEmpty()); + Assertions.assertEquals(2, map.size()); + Assertions.assertFalse(map.isEmpty()); - Assert.assertEquals("one", map.put(1, "also-one")); - Assert.assertEquals(2, map.size()); + Assertions.assertEquals("one", map.put(1, "also-one")); + Assertions.assertEquals(2, map.size()); - Assert.assertNull(map.put(3, "three")); - Assert.assertEquals(3, map.size()); + Assertions.assertNull(map.put(3, "three")); + Assertions.assertEquals(3, map.size()); - Assert.assertNull(map.put(4, null)); - Assert.assertEquals(4, map.size()); + Assertions.assertNull(map.put(4, null)); + Assertions.assertEquals(4, map.size()); - Assert.assertEquals("also-one", map.get(1)); - Assert.assertEquals("two", map.get(2)); - Assert.assertEquals("three", map.get(3)); - Assert.assertNull(map.get(4)); + Assertions.assertEquals("also-one", map.get(1)); + Assertions.assertEquals("two", map.get(2)); + Assertions.assertEquals("three", map.get(3)); + Assertions.assertNull(map.get(4)); - Assert.assertEquals("two", map.remove(2)); - Assert.assertEquals(3, map.size()); - Assert.assertNull(map.get(2)); + Assertions.assertEquals("two", map.remove(2)); + Assertions.assertEquals(3, map.size()); + Assertions.assertNull(map.get(2)); } @Test @@ -66,19 +66,19 @@ void testValuesIterable() { int i = 0; for (String data : map.values()) { if (i == 0) { - Assert.assertEquals("one", data); + Assertions.assertEquals("one", data); } else if (i == 1) { - Assert.assertEquals("two", data); + Assertions.assertEquals("two", data); } else if (i == 2) { - Assert.assertEquals("four", data); + Assertions.assertEquals("four", data); } else if (i == 3) { - Assert.assertEquals("five", data); + Assertions.assertEquals("five", data); } else { throw new RuntimeException("unexpected element: " + data); } i++; } - Assert.assertEquals(4, i); + Assertions.assertEquals(4, i); } @Test @@ -94,17 +94,17 @@ void testForEach() { map.forEach((k, v) -> data.add(new Tuple<>(k, v))); - Assert.assertEquals(1, data.get(0).getFirst().intValue()); - Assert.assertEquals("one", data.get(0).getSecond()); + Assertions.assertEquals(1, data.get(0).getFirst().intValue()); + Assertions.assertEquals("one", data.get(0).getSecond()); - Assert.assertEquals(2, data.get(1).getFirst().intValue()); - Assert.assertEquals("two", data.get(1).getSecond()); + Assertions.assertEquals(2, data.get(1).getFirst().intValue()); + Assertions.assertEquals("two", data.get(1).getSecond()); - Assert.assertEquals(4, data.get(2).getFirst().intValue()); - Assert.assertEquals("four", data.get(2).getSecond()); + Assertions.assertEquals(4, data.get(2).getFirst().intValue()); + Assertions.assertEquals("four", data.get(2).getSecond()); - Assert.assertEquals(5, data.get(3).getFirst().intValue()); - Assert.assertEquals("five", data.get(3).getSecond()); + Assertions.assertEquals(5, data.get(3).getFirst().intValue()); + Assertions.assertEquals("five", data.get(3).getSecond()); } @Test @@ -116,19 +116,19 @@ void testContainsKey() { map.put(4, "four"); map.put(5, "five"); - Assert.assertTrue(map.containsKey(1)); - Assert.assertTrue(map.containsKey(2)); - Assert.assertFalse(map.containsKey(3)); - Assert.assertTrue(map.containsKey(4)); - Assert.assertTrue(map.containsKey(5)); - Assert.assertFalse(map.containsKey(6)); - - Assert.assertTrue(map.containsKey(1)); - Assert.assertTrue(map.containsKey(2)); - Assert.assertFalse(map.containsKey(3)); - Assert.assertTrue(map.containsKey(4)); - Assert.assertTrue(map.containsKey(5)); - Assert.assertFalse(map.containsKey(6)); + Assertions.assertTrue(map.containsKey(1)); + Assertions.assertTrue(map.containsKey(2)); + Assertions.assertFalse(map.containsKey(3)); + Assertions.assertTrue(map.containsKey(4)); + Assertions.assertTrue(map.containsKey(5)); + Assertions.assertFalse(map.containsKey(6)); + + Assertions.assertTrue(map.containsKey(1)); + Assertions.assertTrue(map.containsKey(2)); + Assertions.assertFalse(map.containsKey(3)); + Assertions.assertTrue(map.containsKey(4)); + Assertions.assertTrue(map.containsKey(5)); + Assertions.assertFalse(map.containsKey(6)); } @Test @@ -140,12 +140,12 @@ void testContainsValue() { map.put(4, "four"); map.put(5, "five"); - Assert.assertTrue(map.containsValue("one")); - Assert.assertTrue(map.containsValue("two")); - Assert.assertFalse(map.containsValue("three")); - Assert.assertTrue(map.containsValue("four")); - Assert.assertTrue(map.containsValue("five")); - Assert.assertFalse(map.containsValue("six")); + Assertions.assertTrue(map.containsValue("one")); + Assertions.assertTrue(map.containsValue("two")); + Assertions.assertFalse(map.containsValue("three")); + Assertions.assertTrue(map.containsValue("four")); + Assertions.assertTrue(map.containsValue("five")); + Assertions.assertFalse(map.containsValue("six")); } @Test @@ -160,13 +160,13 @@ void testPutAll_ArrayMap() { map.putAll(map2); - Assert.assertEquals(4, map.size()); + Assertions.assertEquals(4, map.size()); - Assert.assertEquals("one", map.get(1)); - Assert.assertEquals("two", map.get(2)); - Assert.assertNull(map.get(3)); - Assert.assertEquals("four", map.get(4)); - Assert.assertEquals("five", map.get(5)); + Assertions.assertEquals("one", map.get(1)); + Assertions.assertEquals("two", map.get(2)); + Assertions.assertNull(map.get(3)); + Assertions.assertEquals("four", map.get(4)); + Assertions.assertEquals("five", map.get(5)); } @Test @@ -181,13 +181,13 @@ void testPutAll_GenericMap() { map.putAll(map2); - Assert.assertEquals(4, map.size()); + Assertions.assertEquals(4, map.size()); - Assert.assertEquals("one", map.get(1)); - Assert.assertEquals("two", map.get(2)); - Assert.assertNull(map.get(3)); - Assert.assertEquals("four", map.get(4)); - Assert.assertEquals("five", map.get(5)); + Assertions.assertEquals("one", map.get(1)); + Assertions.assertEquals("two", map.get(2)); + Assertions.assertNull(map.get(3)); + Assertions.assertEquals("four", map.get(4)); + Assertions.assertEquals("five", map.get(5)); } @Test @@ -199,17 +199,17 @@ void testClear() { map.put(4, "four"); map.put(5, "five"); - Assert.assertEquals(4, map.size()); + Assertions.assertEquals(4, map.size()); map.clear(); - Assert.assertEquals(0, map.size()); + Assertions.assertEquals(0, map.size()); - Assert.assertNull(map.get(1)); - Assert.assertNull(map.get(2)); - Assert.assertNull(map.get(3)); + Assertions.assertNull(map.get(1)); + Assertions.assertNull(map.get(2)); + Assertions.assertNull(map.get(3)); - Assert.assertFalse(map.containsKey(1)); + Assertions.assertFalse(map.containsKey(1)); } @Test @@ -222,28 +222,28 @@ void testValues() { map.put(5, "five"); Collection coll = map.values(); - Assert.assertEquals(4, coll.size()); + Assertions.assertEquals(4, coll.size()); map.put(6, "six"); - Assert.assertEquals(5, coll.size()); + Assertions.assertEquals(5, coll.size()); - Assert.assertTrue(coll.remove("one")); - Assert.assertFalse(coll.remove("null")); + Assertions.assertTrue(coll.remove("one")); + Assertions.assertFalse(coll.remove("null")); - Assert.assertFalse(map.containsValue("one")); - Assert.assertTrue(map.containsValue("two")); + Assertions.assertFalse(map.containsValue("one")); + Assertions.assertTrue(map.containsValue("two")); - Assert.assertTrue(coll.contains("two")); - Assert.assertFalse(coll.contains("one")); + Assertions.assertTrue(coll.contains("two")); + Assertions.assertFalse(coll.contains("one")); Set values = new HashSet<>(); coll.forEach(v -> values.add(v)); - Assert.assertEquals(4, values.size()); - Assert.assertTrue(values.contains("two")); - Assert.assertTrue(values.contains("four")); - Assert.assertTrue(values.contains("five")); - Assert.assertTrue(values.contains("six")); + Assertions.assertEquals(4, values.size()); + Assertions.assertTrue(values.contains("two")); + Assertions.assertTrue(values.contains("four")); + Assertions.assertTrue(values.contains("five")); + Assertions.assertTrue(values.contains("six")); } @Test @@ -263,28 +263,28 @@ void testKeySet() { map.put(key5, "five"); Set set = map.keySet(); - Assert.assertEquals(4, set.size()); + Assertions.assertEquals(4, set.size()); map.put(key6, "six"); - Assert.assertEquals(5, set.size()); + Assertions.assertEquals(5, set.size()); - Assert.assertTrue(set.remove(key1)); - Assert.assertFalse(set.remove(key3)); + Assertions.assertTrue(set.remove(key1)); + Assertions.assertFalse(set.remove(key3)); - Assert.assertFalse(map.containsKey(key1)); - Assert.assertTrue(map.containsKey(key2)); + Assertions.assertFalse(map.containsKey(key1)); + Assertions.assertTrue(map.containsKey(key2)); - Assert.assertTrue(set.contains(key2)); - Assert.assertFalse(set.contains(key1)); + Assertions.assertTrue(set.contains(key2)); + Assertions.assertFalse(set.contains(key1)); Set keys = new HashSet<>(); set.forEach(k -> keys.add(k)); - Assert.assertEquals(4, keys.size()); - Assert.assertTrue(keys.contains(key2)); - Assert.assertTrue(keys.contains(key4)); - Assert.assertTrue(keys.contains(key5)); - Assert.assertTrue(keys.contains(key6)); + Assertions.assertEquals(4, keys.size()); + Assertions.assertTrue(keys.contains(key2)); + Assertions.assertTrue(keys.contains(key4)); + Assertions.assertTrue(keys.contains(key5)); + Assertions.assertTrue(keys.contains(key6)); } @Test @@ -303,10 +303,10 @@ void testEntrySet() { map.put(key5, "five"); Set> set = map.entrySet(); - Assert.assertEquals(4, set.size()); + Assertions.assertEquals(4, set.size()); map.put(key6, "six"); - Assert.assertEquals(5, set.size()); + Assertions.assertEquals(5, set.size()); Map> entries = new HashMap<>(); @@ -314,31 +314,31 @@ void testEntrySet() { entries.put(e.getKey(), e); } - Assert.assertEquals(key1, entries.get(key1).getKey().intValue()); - Assert.assertEquals("one", entries.get(key1).getValue()); - Assert.assertEquals("two", entries.get(key2).getValue()); - Assert.assertEquals("four", entries.get(key4).getValue()); - Assert.assertEquals("five", entries.get(key5).getValue()); + Assertions.assertEquals(key1, entries.get(key1).getKey().intValue()); + Assertions.assertEquals("one", entries.get(key1).getValue()); + Assertions.assertEquals("two", entries.get(key2).getValue()); + Assertions.assertEquals("four", entries.get(key4).getValue()); + Assertions.assertEquals("five", entries.get(key5).getValue()); - Assert.assertTrue(set.remove(entries.get(key1))); + Assertions.assertTrue(set.remove(entries.get(key1))); //noinspection SuspiciousMethodCalls - Assert.assertFalse(set.remove(new Object())); + Assertions.assertFalse(set.remove(new Object())); - Assert.assertFalse(map.containsKey(key1)); - Assert.assertTrue(map.containsKey(key2)); + Assertions.assertFalse(map.containsKey(key1)); + Assertions.assertTrue(map.containsKey(key2)); - Assert.assertTrue(set.contains(entries.get(key2))); - Assert.assertFalse(set.contains(entries.get(key1))); + Assertions.assertTrue(set.contains(entries.get(key2))); + Assertions.assertFalse(set.contains(entries.get(key1))); // test forEach Set> es = new HashSet<>(); set.forEach(k -> es.add(k)); - Assert.assertEquals(4, es.size()); - Assert.assertTrue(es.contains(entries.get(key2))); - Assert.assertTrue(es.contains(entries.get(key4))); - Assert.assertTrue(es.contains(entries.get(key5))); - Assert.assertTrue(es.contains(entries.get(key6))); + Assertions.assertEquals(4, es.size()); + Assertions.assertTrue(es.contains(entries.get(key2))); + Assertions.assertTrue(es.contains(entries.get(key4))); + Assertions.assertTrue(es.contains(entries.get(key5))); + Assertions.assertTrue(es.contains(entries.get(key6))); } @Test @@ -356,28 +356,28 @@ void testValuesIterator_iterate() { map.put(key5, "five"); Iterator iter = map.values().iterator(); - Assert.assertNotNull(iter); + Assertions.assertNotNull(iter); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("one", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("one", iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("two", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("two", iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("four", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("four", iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("five", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("five", iter.next()); - Assert.assertFalse(iter.hasNext()); + Assertions.assertFalse(iter.hasNext()); try { iter.next(); - Assert.fail("Expected exception, got none."); + Assertions.fail("Expected exception, got none."); } catch (NoSuchElementException ignore) { } - Assert.assertFalse(iter.hasNext()); + Assertions.assertFalse(iter.hasNext()); } @Test @@ -395,25 +395,25 @@ void testValuesIterator_remove() { map.put(key5, "five"); Iterator iter = map.values().iterator(); - Assert.assertNotNull(iter); + Assertions.assertNotNull(iter); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("one", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("one", iter.next()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("two", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("two", iter.next()); iter.remove(); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals("five", iter.next()); - Assert.assertEquals("four", iter.next()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals("five", iter.next()); + Assertions.assertEquals("four", iter.next()); - Assert.assertEquals(3, map.size()); - Assert.assertTrue(map.containsValue("one")); - Assert.assertFalse(map.containsValue("two")); - Assert.assertTrue(map.containsValue("four")); - Assert.assertTrue(map.containsValue("five")); + Assertions.assertEquals(3, map.size()); + Assertions.assertTrue(map.containsValue("one")); + Assertions.assertFalse(map.containsValue("two")); + Assertions.assertTrue(map.containsValue("four")); + Assertions.assertTrue(map.containsValue("five")); } @Test @@ -431,28 +431,28 @@ void testKeySetIterator_iterate() { map.put(key5, "five"); Iterator iter = map.keySet().iterator(); - Assert.assertNotNull(iter); + Assertions.assertNotNull(iter); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals(1, iter.next().intValue()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals(1, iter.next().intValue()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals(2, iter.next().intValue()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals(2, iter.next().intValue()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals(4, iter.next().intValue()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals(4, iter.next().intValue()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals(5, iter.next().intValue()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals(5, iter.next().intValue()); - Assert.assertFalse(iter.hasNext()); + Assertions.assertFalse(iter.hasNext()); try { iter.next(); - Assert.fail("Expected exception, got none."); + Assertions.fail("Expected exception, got none."); } catch (NoSuchElementException ignore) { } - Assert.assertFalse(iter.hasNext()); + Assertions.assertFalse(iter.hasNext()); } @Test @@ -470,25 +470,25 @@ void testKeySetIterator_remove() { map.put(key5, "five"); Iterator iter = map.keySet().iterator(); - Assert.assertNotNull(iter); + Assertions.assertNotNull(iter); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals(1, iter.next().intValue()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals(1, iter.next().intValue()); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals(2, iter.next().intValue()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals(2, iter.next().intValue()); iter.remove(); - Assert.assertTrue(iter.hasNext()); - Assert.assertEquals(5, iter.next().intValue()); - Assert.assertEquals(4, iter.next().intValue()); + Assertions.assertTrue(iter.hasNext()); + Assertions.assertEquals(5, iter.next().intValue()); + Assertions.assertEquals(4, iter.next().intValue()); - Assert.assertEquals(3, map.size()); - Assert.assertTrue(map.containsKey(1)); - Assert.assertFalse(map.containsKey(2)); - Assert.assertTrue(map.containsKey(4)); - Assert.assertTrue(map.containsKey(5)); + Assertions.assertEquals(3, map.size()); + Assertions.assertTrue(map.containsKey(1)); + Assertions.assertFalse(map.containsKey(2)); + Assertions.assertTrue(map.containsKey(4)); + Assertions.assertTrue(map.containsKey(5)); } @Test @@ -506,10 +506,10 @@ void testKeySetToArray() { map.put(key5, "five"); Object[] array = map.keySet().toArray(); - Assert.assertEquals(key1, array[0]); - Assert.assertEquals(key2, array[1]); - Assert.assertEquals(key4, array[2]); - Assert.assertEquals(key5, array[3]); + Assertions.assertEquals(key1, array[0]); + Assertions.assertEquals(key2, array[1]); + Assertions.assertEquals(key4, array[2]); + Assertions.assertEquals(key5, array[3]); } } \ No newline at end of file diff --git a/matsim/src/test/java/org/matsim/core/utils/collections/PseudoRemovePriorityQueueTest.java b/matsim/src/test/java/org/matsim/core/utils/collections/PseudoRemovePriorityQueueTest.java index d1f726ab458..cf10dd84105 100644 --- a/matsim/src/test/java/org/matsim/core/utils/collections/PseudoRemovePriorityQueueTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/collections/PseudoRemovePriorityQueueTest.java @@ -20,7 +20,7 @@ package org.matsim.core.utils.collections; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.Collection; import java.util.ConcurrentModificationException; diff --git a/matsim/src/test/java/org/matsim/core/utils/collections/QuadTreeTest.java b/matsim/src/test/java/org/matsim/core/utils/collections/QuadTreeTest.java index 56a7867b1f9..61f66e6a0ce 100644 --- a/matsim/src/test/java/org/matsim/core/utils/collections/QuadTreeTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/collections/QuadTreeTest.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.collections.QuadTree.Rect; @@ -40,11 +40,7 @@ import java.util.List; import java.util.Random; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; /** * Test for {@link QuadTree}. @@ -111,7 +107,7 @@ void testPutOutsideBounds() { QuadTree qt = new QuadTree<>(-50.0, -50.0, 50.0, 50.0); try { qt.put( -100 , 0 , "-100 0" ); - Assert.fail( "no exception when adding an element on the left" ); + Assertions.fail( "no exception when adding an element on the left" ); } catch (IllegalArgumentException e) { log.info( "catched expected exception" , e ); @@ -119,7 +115,7 @@ void testPutOutsideBounds() { try { qt.put( 100 , 0 , "100 0" ); - Assert.fail( "no exception when adding an element on the right" ); + Assertions.fail( "no exception when adding an element on the right" ); } catch (IllegalArgumentException e) { log.info( "catched expected exception" , e ); @@ -127,7 +123,7 @@ void testPutOutsideBounds() { try { qt.put( 0 , 100 , "0 100" ); - Assert.fail( "no exception when adding an element above" ); + Assertions.fail( "no exception when adding an element above" ); } catch (IllegalArgumentException e) { log.info( "catched expected exception" , e ); @@ -135,7 +131,7 @@ void testPutOutsideBounds() { try { qt.put( 0 , -100 , "0 -100" ); - Assert.fail( "no exception when adding an element below" ); + Assertions.fail( "no exception when adding an element below" ); } catch (IllegalArgumentException e) { log.info( "catched expected exception" , e ); @@ -189,19 +185,19 @@ void testGet() { // test "distance" get with critical distances values = qt.getDisk(90.0, 0.0, 9.0); - assertEquals("test with distance 9.0", 0, values.size()); + assertEquals(0, values.size(), "test with distance 9.0"); values = qt.getDisk(90.0, 0.0, 9.999); - assertEquals("test with distance 9.999", 0, values.size()); + assertEquals(0, values.size(), "test with distance 9.999"); values = qt.getDisk(90.0, 0.0, 10.0); - assertEquals("test with distance 10.0", 1, values.size()); + assertEquals(1, values.size(), "test with distance 10.0"); values = qt.getDisk(90.0, 0.0, 10.001); - assertEquals("test with distance 10.001", 1, values.size()); + assertEquals(1, values.size(), "test with distance 10.001"); values = qt.getDisk(90.0, 0.0, 11.0); - assertEquals("test with distance 11.0", 1, values.size()); + assertEquals(1, values.size(), "test with distance 11.0"); // test "area" values.clear(); @@ -363,14 +359,14 @@ void testGetElliptical() { distance ); //log.info( "testing foci "+f1+" and "+f2+", distance="+distance+", expected="+expected ); - Assert.assertEquals( - "unexpected number of elements returned for foci "+f1+" and "+f2+", distance="+distance, + Assertions.assertEquals( expected.size(), - actual.size() ); + actual.size(), + "unexpected number of elements returned for foci "+f1+" and "+f2+", distance="+distance ); - Assert.assertTrue( - "unexpected elements returned for foci "+f1+" and "+f2+", distance="+distance, - expected.containsAll( actual ) ); + Assertions.assertTrue( + expected.containsAll( actual ), + "unexpected elements returned for foci "+f1+" and "+f2+", distance="+distance ); } } } @@ -388,9 +384,9 @@ void testGetRect() { Collection values = new ArrayList<>(); qt.getRectangle(new Rect(400, 300, 700, 900), values); - Assert.assertEquals(2, values.size()); - Assert.assertTrue(values.contains("node2")); - Assert.assertTrue(values.contains("node3")); + Assertions.assertEquals(2, values.size()); + Assertions.assertTrue(values.contains("node2")); + Assertions.assertTrue(values.contains("node3")); } @Test @@ -403,15 +399,15 @@ void testGetRect_flatNetwork() { Collection values = new ArrayList<>(); qt.getRectangle(new Rect(90, -10, 600, +10), values); - Assert.assertEquals(2, values.size()); - Assert.assertTrue(values.contains("node2")); - Assert.assertTrue(values.contains("node3")); + Assertions.assertEquals(2, values.size()); + Assertions.assertTrue(values.contains("node2")); + Assertions.assertTrue(values.contains("node3")); Collection values2 = new ArrayList<>(); qt.getRectangle(new Rect(90, 0, 600, 0), values2); - Assert.assertEquals(2, values2.size()); - Assert.assertTrue(values2.contains("node2")); - Assert.assertTrue(values2.contains("node3")); + Assertions.assertEquals(2, values2.size()); + Assertions.assertTrue(values2.contains("node2")); + Assertions.assertTrue(values2.contains("node3")); } /** @@ -704,11 +700,11 @@ void testGetValues() { } List items = new ArrayList<>(qt.values()); - Assert.assertEquals(1000, items.size()); + Assertions.assertEquals(1000, items.size()); items.sort(String::compareTo); expected.sort(String::compareTo); for (int i = 0; i < 1000; i++) { - Assert.assertEquals(expected.get(i), items.get(i)); + Assertions.assertEquals(expected.get(i), items.get(i)); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/collections/TupleTest.java b/matsim/src/test/java/org/matsim/core/utils/collections/TupleTest.java index bb7a2d62046..059938c9b50 100644 --- a/matsim/src/test/java/org/matsim/core/utils/collections/TupleTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/collections/TupleTest.java @@ -20,7 +20,7 @@ package org.matsim.core.utils.collections; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/CoordImplTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/CoordImplTest.java index ee6b99929f1..7beaf878b34 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/CoordImplTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/CoordImplTest.java @@ -21,7 +21,7 @@ import java.util.Arrays; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -62,6 +62,6 @@ void testHashCode() { lastValue = hc; } - Assert.assertEquals("There has been a hashCode collision, which is undesired!", hashCodes.length, cnt); + Assertions.assertEquals(hashCodes.length, cnt, "There has been a hashCode collision, which is undesired!"); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/CoordUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/CoordUtilsTest.java index 01bb58b1090..958f38182ec 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/CoordUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/CoordUtilsTest.java @@ -20,10 +20,10 @@ package org.matsim.core.utils.geometry; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; -import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.testcases.MatsimTestUtils; @@ -153,20 +153,20 @@ void testRotateToRight() { Coord coord1 = new Coord(3., 2.); Coord result = CoordUtils.rotateToRight( coord1 ) ; - Assert.assertEquals( 2., result.getX(), MatsimTestUtils.EPSILON ) ; - Assert.assertEquals( -3., result.getY(), MatsimTestUtils.EPSILON ) ; + Assertions.assertEquals( 2., result.getX(), MatsimTestUtils.EPSILON ) ; + Assertions.assertEquals( -3., result.getY(), MatsimTestUtils.EPSILON ) ; result = CoordUtils.rotateToRight( result ) ; - Assert.assertEquals( -3., result.getX(), MatsimTestUtils.EPSILON ) ; - Assert.assertEquals( -2., result.getY(), MatsimTestUtils.EPSILON ) ; + Assertions.assertEquals( -3., result.getX(), MatsimTestUtils.EPSILON ) ; + Assertions.assertEquals( -2., result.getY(), MatsimTestUtils.EPSILON ) ; result = CoordUtils.rotateToRight( result ) ; - Assert.assertEquals( -2., result.getX(), MatsimTestUtils.EPSILON ) ; - Assert.assertEquals( 3., result.getY(), MatsimTestUtils.EPSILON ) ; + Assertions.assertEquals( -2., result.getX(), MatsimTestUtils.EPSILON ) ; + Assertions.assertEquals( 3., result.getY(), MatsimTestUtils.EPSILON ) ; result = CoordUtils.rotateToRight( result ) ; - Assert.assertEquals( coord1.getX(), result.getX(), MatsimTestUtils.EPSILON ) ; - Assert.assertEquals( coord1.getY(), result.getY(), MatsimTestUtils.EPSILON ) ; + Assertions.assertEquals( coord1.getX(), result.getX(), MatsimTestUtils.EPSILON ) ; + Assertions.assertEquals( coord1.getY(), result.getY(), MatsimTestUtils.EPSILON ) ; } @Test diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/GeometryUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/GeometryUtilsTest.java index 10527d9d759..ace12f31bf6 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/GeometryUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/GeometryUtilsTest.java @@ -20,7 +20,7 @@ package org.matsim.core.utils.geometry; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.locationtech.jts.geom.Coordinate; @@ -63,9 +63,9 @@ final void testIntersectingLinks() { List> expectedLinkIds = List.of(Id.createLinkId(1)); - Assert.assertEquals(expectedLinkIds.size(), results.size()) ; + Assertions.assertEquals(expectedLinkIds.size(), results.size()) ; for ( int ii=0 ; ii> expectedIds = List.of(Id.createLinkId(2), Id.createLinkId(3), Id.createLinkId(4), Id.createLinkId(5), Id.createLinkId(6)); - Assert.assertEquals(expectedIds.size(), results.size()); + Assertions.assertEquals(expectedIds.size(), results.size()); for (Id id : expectedIds) { - Assert.assertTrue("expected link " + id, intersectingLinkIds.contains(id)); + Assertions.assertTrue(intersectingLinkIds.contains(id), "expected link " + id); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/geotools/MGCTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/geotools/MGCTest.java index bef47a55d81..67cdccc70a1 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/geotools/MGCTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/geotools/MGCTest.java @@ -21,6 +21,7 @@ package org.matsim.core.utils.geometry.geotools; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.locationtech.jts.geom.Coordinate; @@ -28,7 +29,7 @@ import org.matsim.api.core.v01.Coord; import org.matsim.testcases.MatsimTestUtils; - /** + /** * * @author laemmel * @@ -49,8 +50,8 @@ void testCoord2CoordinateAndViceVersa(){ Coord coord3 = MGC.coordinate2Coord(coord2); double x1 = coord3.getX(); double y1 = coord3.getY(); - org.junit.Assert.assertEquals(x,x1,delta); - org.junit.Assert.assertEquals(y,y1,delta); + Assertions.assertEquals(x,x1,delta); + Assertions.assertEquals(y,y1,delta); } @Test @@ -63,8 +64,8 @@ void testCoord2PointAndViceVersa(){ Coord coord2 = MGC.point2Coord(p); double x1 = coord2.getX(); double y1 = coord2.getY(); - org.junit.Assert.assertEquals(x,x1,delta); - org.junit.Assert.assertEquals(y,y1,delta); + Assertions.assertEquals(x,x1,delta); + Assertions.assertEquals(y,y1,delta); } @@ -75,59 +76,59 @@ void testGetUTMEPSGCodeForWGS84Coordinate() { double lat = 53.562021; double lon = 9.961533; String epsg = MGC.getUTMEPSGCodeForWGS84Coordinate(lon, lat); - org.junit.Assert.assertEquals("EPSG:32632", epsg); + Assertions.assertEquals("EPSG:32632", epsg); } { //Cupertino - should be UTM 10 North --> EPSG:32610 double lat = 37.333488; double lon = -122.029710; String epsg = MGC.getUTMEPSGCodeForWGS84Coordinate(lon, lat); - org.junit.Assert.assertEquals("EPSG:32610", epsg); + Assertions.assertEquals("EPSG:32610", epsg); } { //Anchorage - should be UTM 6 North --> EPSG:32606 double lat = 61.2176; double lon = -149.8997; String epsg = MGC.getUTMEPSGCodeForWGS84Coordinate(lon, lat); - org.junit.Assert.assertEquals("EPSG:32606", epsg); + Assertions.assertEquals("EPSG:32606", epsg); } { //Lourdes (France) - should be UTM 30 North --> EPSG:32630 double lat = 43.1; double lon = -0.05; String epsg = MGC.getUTMEPSGCodeForWGS84Coordinate(lon, lat); - org.junit.Assert.assertEquals("EPSG:32630", epsg); + Assertions.assertEquals("EPSG:32630", epsg); } { //east of Lourdes (France) - should be UTM 31 North --> EPSG:32631 double lat = 43.1; double lon = 0.05; String epsg = MGC.getUTMEPSGCodeForWGS84Coordinate(lon, lat); - org.junit.Assert.assertEquals("EPSG:32631", epsg); + Assertions.assertEquals("EPSG:32631", epsg); } { //Padang - should be UTM 47 South --> EPSG:32747 double lat = -0.959484; double lon = 100.354052; String epsg = MGC.getUTMEPSGCodeForWGS84Coordinate(lon, lat); - org.junit.Assert.assertEquals("EPSG:32747", epsg); + Assertions.assertEquals("EPSG:32747", epsg); } } @Test void testGetCRS(){ // CH1903_LV03 Id - org.junit.Assert.assertNotNull(MGC.getCRS("EPSG:21781")); + Assertions.assertNotNull(MGC.getCRS("EPSG:21781")); try { MGC.getCRS(""); - org.junit.Assert.fail("IllegalArgumentException expected"); + Assertions.fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { } // unknown EPSG Id try { MGC.getCRS("EPSG:MATSim"); - org.junit.Assert.fail("IllegalArgumentException expected"); + Assertions.fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { } } diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03PlustoWGS84Test.java b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03PlustoWGS84Test.java index 3c88bf71af1..6b0dbf8e097 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03PlustoWGS84Test.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03PlustoWGS84Test.java @@ -21,7 +21,7 @@ package org.matsim.core.utils.geometry.transformations; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -42,7 +42,7 @@ void testTransform() { CH1903LV03PlustoWGS84 converter = new CH1903LV03PlustoWGS84(); Coord n = converter.transform(new Coord((double) 2700000, (double) 1100000)); - Assert.assertEquals(xx, n.getX(), epsilon); - Assert.assertEquals(yy, n.getY(), epsilon); + Assertions.assertEquals(xx, n.getX(), epsilon); + Assertions.assertEquals(yy, n.getY(), epsilon); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03PlustofromCH1903LV03Test.java b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03PlustofromCH1903LV03Test.java index 3f7420d1340..6fcc291e693 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03PlustofromCH1903LV03Test.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03PlustofromCH1903LV03Test.java @@ -21,7 +21,7 @@ package org.matsim.core.utils.geometry.transformations; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -34,15 +34,15 @@ public class CH1903LV03PlustofromCH1903LV03Test { void testCH1903LV03PlustoCH1903LV03() { CH1903LV03PlustoCH1903LV03 converter = new CH1903LV03PlustoCH1903LV03(); Coord n = converter.transform(new Coord((double) 2700000, (double) 1100000)); - Assert.assertEquals(700000, n.getX(), 0.0); - Assert.assertEquals(100000, n.getY(), 0.0); + Assertions.assertEquals(700000, n.getX(), 0.0); + Assertions.assertEquals(100000, n.getY(), 0.0); } @Test void testCH1903LV03toCH1903LV03Plus() { CH1903LV03toCH1903LV03Plus converter = new CH1903LV03toCH1903LV03Plus(); Coord n = converter.transform(new Coord((double) 700000, (double) 100000)); - Assert.assertEquals(2700000, n.getX(), 0.0); - Assert.assertEquals(1100000, n.getY(), 0.0); + Assertions.assertEquals(2700000, n.getX(), 0.0); + Assertions.assertEquals(1100000, n.getY(), 0.0); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03toWGS84Test.java b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03toWGS84Test.java index a8e43c4d8ed..3a767dd39c7 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03toWGS84Test.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/CH1903LV03toWGS84Test.java @@ -19,7 +19,7 @@ package org.matsim.core.utils.geometry.transformations; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -40,7 +40,7 @@ void testTransform() { CH1903LV03toWGS84 converter = new CH1903LV03toWGS84(); Coord n = converter.transform(new Coord((double) 700000, (double) 100000)); - Assert.assertEquals(xx, n.getX(), epsilon); - Assert.assertEquals(yy, n.getY(), epsilon); + Assertions.assertEquals(xx, n.getX(), epsilon); + Assertions.assertEquals(yy, n.getY(), epsilon); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/GeotoolsTransformationTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/GeotoolsTransformationTest.java index aac31a1b9be..b10f60aeca0 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/GeotoolsTransformationTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/GeotoolsTransformationTest.java @@ -20,6 +20,7 @@ package org.matsim.core.utils.geometry.transformations; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -56,8 +57,8 @@ void testTransform(){ double yWGS84 = coordWGS84.getY(); - org.junit.Assert.assertEquals(targetX, xWGS84, delta); - org.junit.Assert.assertEquals(targetY, yWGS84, delta); + Assertions.assertEquals(targetX, xWGS84, delta); + Assertions.assertEquals(targetY, yWGS84, delta); } diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/TransformationFactoryTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/TransformationFactoryTest.java index f55454c7314..4be45f50e96 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/TransformationFactoryTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/TransformationFactoryTest.java @@ -20,7 +20,7 @@ package org.matsim.core.utils.geometry.transformations; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/WGS84toCH1903LV03PlusTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/WGS84toCH1903LV03PlusTest.java index 93fecc49e19..9b36045dd2d 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/WGS84toCH1903LV03PlusTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/WGS84toCH1903LV03PlusTest.java @@ -21,7 +21,7 @@ package org.matsim.core.utils.geometry.transformations; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -42,8 +42,8 @@ void testTransform() { WGS84toCH1903LV03Plus converter = new WGS84toCH1903LV03Plus(); Coord n = converter.transform(new Coord(xx, yy)); - Assert.assertEquals(2700000.0, n.getX(), epsilon); - Assert.assertEquals(1100000.0, n.getY(), epsilon); + Assertions.assertEquals(2700000.0, n.getX(), epsilon); + Assertions.assertEquals(1100000.0, n.getY(), epsilon); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/WGS84toCH1903LV03Test.java b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/WGS84toCH1903LV03Test.java index 717fa4da70c..a16578d4f83 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/WGS84toCH1903LV03Test.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/transformations/WGS84toCH1903LV03Test.java @@ -19,7 +19,7 @@ package org.matsim.core.utils.geometry.transformations; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -36,8 +36,8 @@ void testTransform() { WGS84toCH1903LV03 converter = new WGS84toCH1903LV03(); Coord n = converter.transform(new Coord(xx, yy)); - Assert.assertEquals(699999.76, n.getX(), epsilon); - Assert.assertEquals(99999.97, n.getY(), epsilon); + Assertions.assertEquals(699999.76, n.getX(), epsilon); + Assertions.assertEquals(99999.97, n.getY(), epsilon); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileReaderTest.java b/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileReaderTest.java index 650293090b4..1a07451aa7b 100644 --- a/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileReaderTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileReaderTest.java @@ -24,7 +24,7 @@ import java.io.IOException; import org.geotools.data.FeatureSource; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -44,6 +44,6 @@ public class ShapeFileReaderTest { void testPlusInFilename() throws IOException { String filename = "src/test/resources/" + utils.getInputDirectory() + "test+test.shp"; FeatureSource fs = ShapeFileReader.readDataFile(filename); - Assert.assertEquals(3, fs.getFeatures().size()); + Assertions.assertEquals(3, fs.getFeatures().size()); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileWriterTest.java b/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileWriterTest.java index a953c2bfd62..70c19d22d88 100644 --- a/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileWriterTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/gis/ShapeFileWriterTest.java @@ -32,7 +32,7 @@ import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.geotools.referencing.crs.DefaultGeographicCRS; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.locationtech.jts.geom.Coordinate; @@ -70,7 +70,7 @@ void testShapeFileWriter() throws IOException{ SimpleFeature ft1 = it1.next(); Geometry g1 = (Geometry) ft1.getDefaultGeometry(); - Assert.assertEquals(g.getCoordinates().length, g1.getCoordinates().length); + Assertions.assertEquals(g.getCoordinates().length, g1.getCoordinates().length); } @@ -102,7 +102,7 @@ void testShapeFileWriterWithSelfCreatedContent() throws IOException { SimpleFeature ft1 = it1.next(); Geometry g1 = (Geometry) ft1.getDefaultGeometry(); - Assert.assertEquals(g0.getCoordinates().length, g1.getCoordinates().length); + Assertions.assertEquals(g0.getCoordinates().length, g1.getCoordinates().length); } @@ -133,7 +133,7 @@ void testShapeFileWriterWithSelfCreatedContent_withMatsimFactory_Polygon() throw SimpleFeature ft1 = it1.next(); Geometry g1 = (Geometry) ft1.getDefaultGeometry(); - Assert.assertEquals(g0.getCoordinates().length, g1.getCoordinates().length); + Assertions.assertEquals(g0.getCoordinates().length, g1.getCoordinates().length); } @Test @@ -162,7 +162,7 @@ void testShapeFileWriterWithSelfCreatedContent_withMatsimFactory_Polyline() thro SimpleFeature ft1 = it1.next(); Geometry g1 = (Geometry) ft1.getDefaultGeometry(); - Assert.assertEquals(g0.getCoordinates().length, g1.getCoordinates().length); + Assertions.assertEquals(g0.getCoordinates().length, g1.getCoordinates().length); } @Test @@ -190,6 +190,6 @@ void testShapeFileWriterWithSelfCreatedContent_withMatsimFactory_Point() throws SimpleFeature ft1 = it1.next(); Geometry g1 = (Geometry) ft1.getDefaultGeometry(); - Assert.assertEquals(g0.getCoordinates().length, g1.getCoordinates().length); + Assertions.assertEquals(g0.getCoordinates().length, g1.getCoordinates().length); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/io/IOUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/io/IOUtilsTest.java index 150f1982025..5f7394b5b5a 100644 --- a/matsim/src/test/java/org/matsim/core/utils/io/IOUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/io/IOUtilsTest.java @@ -21,7 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.controler.OutputDirectoryLogging; @@ -51,8 +51,8 @@ void testInitOutputDirLogging() throws IOException { File l = new File(outDir + OutputDirectoryLogging.LOGFILE); File errorLog = new File(outDir + OutputDirectoryLogging.WARNLOGFILE); - Assert.assertTrue(l.exists()); - Assert.assertTrue(errorLog.exists()); + Assertions.assertTrue(l.exists()); + Assertions.assertTrue(errorLog.exists()); } /** @@ -64,14 +64,14 @@ void testDeleteDir() throws IOException { String testDir = outputDir + "a"; String someFilename = testDir + "/a.txt"; File dir = new File(testDir); - Assert.assertTrue(dir.mkdir()); + Assertions.assertTrue(dir.mkdir()); File someFile = new File(someFilename); - Assert.assertTrue(someFile.createNewFile()); + Assertions.assertTrue(someFile.createNewFile()); IOUtils.deleteDirectoryRecursively(dir.toPath()); - Assert.assertFalse(someFile.exists()); - Assert.assertFalse(dir.exists()); + Assertions.assertFalse(someFile.exists()); + Assertions.assertFalse(dir.exists()); } /** @@ -84,7 +84,7 @@ void testDeleteDir_InexistentDir() { String testDir = outputDir + "a"; File dir = new File(testDir); IOUtils.deleteDirectoryRecursively(dir.toPath()); - Assert.assertFalse(dir.exists()); + Assertions.assertFalse(dir.exists()); }); } @@ -93,8 +93,8 @@ void testGetBufferedReader_encodingMacRoman() throws IOException { URL url = IOUtils.resolveFileOrResource(this.utils.getClassInputDirectory() + "textsample_MacRoman.txt"); BufferedReader reader = IOUtils.getBufferedReader(url, Charset.forName("MacRoman")); String line = reader.readLine(); - Assert.assertNotNull(line); - Assert.assertEquals("äöüÉç", line); + Assertions.assertNotNull(line); + Assertions.assertEquals("äöüÉç", line); } @Test @@ -102,8 +102,8 @@ void testGetBufferedReader_encodingIsoLatin1() throws IOException { URL url = IOUtils.resolveFileOrResource(this.utils.getClassInputDirectory() + "textsample_IsoLatin1.txt"); BufferedReader reader = IOUtils.getBufferedReader(url, Charset.forName("ISO-8859-1")); String line = reader.readLine(); - Assert.assertNotNull(line); - Assert.assertEquals("äöüÉç", line); + Assertions.assertNotNull(line); + Assertions.assertEquals("äöüÉç", line); } @Test @@ -111,8 +111,8 @@ void testGetBufferedReader_encodingUTF8() throws IOException { URL url = IOUtils.resolveFileOrResource(this.utils.getClassInputDirectory() + "textsample_UTF8.txt"); BufferedReader reader = IOUtils.getBufferedReader(url); String line = reader.readLine(); - Assert.assertNotNull(line); - Assert.assertEquals("äöüÉç", line); + Assertions.assertNotNull(line); + Assertions.assertEquals("äöüÉç", line); } @Test @@ -124,7 +124,7 @@ void testGetBufferedWriter_encodingMacRoman() throws IOException { writer.close(); long crc1 = CRCChecksum.getCRCFromFile(this.utils.getClassInputDirectory() + "textsample_MacRoman.txt"); long crc2 = CRCChecksum.getCRCFromFile(filename); - Assert.assertEquals("File was not written with encoding MacRoman.", crc1, crc2); + Assertions.assertEquals(crc1, crc2, "File was not written with encoding MacRoman."); } @Test @@ -136,7 +136,7 @@ void testGetBufferedWriter_encodingIsoLatin1() throws IOException { writer.close(); long crc1 = CRCChecksum.getCRCFromFile(this.utils.getClassInputDirectory() + "textsample_IsoLatin1.txt"); long crc2 = CRCChecksum.getCRCFromFile(filename); - Assert.assertEquals("File was not written with encoding IsoLatin1.", crc1, crc2); + Assertions.assertEquals(crc1, crc2, "File was not written with encoding IsoLatin1."); } @Test @@ -148,7 +148,7 @@ void testGetBufferedWriter_encodingUTF8() throws IOException { writer.close(); long crc1 = CRCChecksum.getCRCFromFile(this.utils.getClassInputDirectory() + "textsample_UTF8.txt"); long crc2 = CRCChecksum.getCRCFromFile(filename); - Assert.assertEquals("File was not written with encoding UTF8.", crc1, crc2); + Assertions.assertEquals(crc1, crc2, "File was not written with encoding UTF8."); } @Test @@ -163,7 +163,7 @@ void testGetBufferedWriter_overwrite() throws IOException { writer2.close(); BufferedReader reader = IOUtils.getBufferedReader(url); String line = reader.readLine(); - Assert.assertEquals("bbb", line); + Assertions.assertEquals("bbb", line); } @Test @@ -178,7 +178,7 @@ void testGetBufferedWriter_append() throws IOException { writer2.close(); BufferedReader reader = IOUtils.getBufferedReader(url); String line = reader.readLine(); - Assert.assertEquals("aaabbb", line); + Assertions.assertEquals("aaabbb", line); } @Test @@ -193,7 +193,7 @@ void testGetBufferedWriter_overwrite_gzipped() throws IOException { writer2.close(); BufferedReader reader = IOUtils.getBufferedReader(url); String line = reader.readLine(); - Assert.assertEquals("bbb", line); + Assertions.assertEquals("bbb", line); } @Test @@ -216,7 +216,7 @@ void testGetBufferedWriter_gzipped() throws IOException { writer.write("12345678901234567890123456789012345678901234567890"); writer.close(); File file = new File(filename); - Assert.assertTrue("compressed file should be less than 50 bytes, but is " + file.length(), file.length() < 50); + Assertions.assertTrue(file.length() < 50, "compressed file should be less than 50 bytes, but is " + file.length()); } @Test @@ -239,10 +239,10 @@ void testGetBufferedWriter_lz4() throws IOException { writer.write("12345678901234567890123456789012345678901234567890"); writer.close(); File file = new File(filename); - Assert.assertEquals("compressed file should be equal 35 bytes, but is " + file.length(), 35, file.length()); + Assertions.assertEquals(35, file.length(), "compressed file should be equal 35 bytes, but is " + file.length()); String content = IOUtils.getBufferedReader(filename).readLine(); - Assert.assertEquals("12345678901234567890123456789012345678901234567890", content); + Assertions.assertEquals("12345678901234567890123456789012345678901234567890", content); } @Test @@ -265,7 +265,7 @@ void testGetBufferedWriter_bz2() throws IOException { writer.write("12345678901234567890123456789012345678901234567890"); writer.close(); File file = new File(filename); - Assert.assertTrue("compressed file should be equal 51 bytes, but is " + file.length(), file.length() == 51); + Assertions.assertTrue(file.length() == 51, "compressed file should be equal 51 bytes, but is " + file.length()); } @Test @@ -280,7 +280,7 @@ void testGetBufferedWriter_append_zst() throws IOException { writer.close(); BufferedReader reader = IOUtils.getBufferedReader(url); String content = reader.readLine(); - Assert.assertEquals("aaabbb", content); + Assertions.assertEquals("aaabbb", content); } @Test @@ -291,7 +291,7 @@ void testGetBufferedWriter_zst() throws IOException { writer.write("12345678901234567890123456789012345678901234567890"); writer.close(); File file = new File(filename); - Assert.assertEquals("compressed file should be equal 28 bytes, but is " + file.length(), 28, file.length()); + Assertions.assertEquals(28, file.length(), "compressed file should be equal 28 bytes, but is " + file.length()); } @Test @@ -302,7 +302,7 @@ void testGetInputStream_UTFwithoutBOM() throws IOException { out.close(); InputStream in = IOUtils.getInputStream(IOUtils.resolveFileOrResource(filename)); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } @@ -315,7 +315,7 @@ void testGetInputStream_UTFwithBOM() throws IOException { out.close(); InputStream in = IOUtils.getInputStream(IOUtils.resolveFileOrResource(filename)); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } @@ -328,7 +328,7 @@ void testGetInputStream_UTFwithBOM_Compressed() throws IOException { out.close(); InputStream in = IOUtils.getInputStream(IOUtils.resolveFileOrResource(filename)); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } @@ -341,7 +341,7 @@ void testGetInputStream_UTFwithBOM_Lz4() throws IOException { out.close(); InputStream in = IOUtils.getInputStream(IOUtils.resolveFileOrResource(filename)); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } @@ -354,7 +354,7 @@ void testGetInputStream_UTFwithBOM_bz2() throws IOException { out.close(); InputStream in = IOUtils.getInputStream(IOUtils.resolveFileOrResource(filename)); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } @@ -367,7 +367,7 @@ void testGetInputStream_UTFwithBOM_zst() throws IOException { out.close(); InputStream in = IOUtils.getInputStream(IOUtils.resolveFileOrResource(filename)); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } @@ -380,17 +380,17 @@ void testGetBufferedReader_UTFwithoutBOM() throws IOException { { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename)); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename), IOUtils.CHARSET_UTF8); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename), IOUtils.CHARSET_WINDOWS_ISO88591); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } } @@ -405,17 +405,17 @@ void testGetBufferedReader_UTFwithBOM() throws IOException { { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename)); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename), IOUtils.CHARSET_UTF8); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename), IOUtils.CHARSET_WINDOWS_ISO88591); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } } @@ -430,22 +430,22 @@ void testGetBufferedReader_UTFwithBOM_Compressed() throws IOException { { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename)); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename.substring(0, filename.length() - 3))); // without the .gz extension - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename), IOUtils.CHARSET_UTF8); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename), IOUtils.CHARSET_WINDOWS_ISO88591); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } } @@ -460,17 +460,17 @@ void testGetBufferedReader_UTFwithBOM_lz4() throws IOException { { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename)); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename), IOUtils.CHARSET_UTF8); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename), IOUtils.CHARSET_WINDOWS_ISO88591); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } } @@ -485,17 +485,17 @@ void testGetBufferedReader_UTFwithBOM_bz2() throws IOException { { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename)); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename), IOUtils.CHARSET_UTF8); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename), IOUtils.CHARSET_WINDOWS_ISO88591); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } } @@ -510,17 +510,17 @@ void testGetBufferedReader_UTFwithBOM_zst() throws IOException { { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename)); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename), IOUtils.CHARSET_UTF8); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } { BufferedReader in = IOUtils.getBufferedReader(IOUtils.resolveFileOrResource(filename), IOUtils.CHARSET_WINDOWS_ISO88591); - Assert.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); + Assertions.assertEquals("ABCdef", new String(new byte[] { (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read(), (byte) in.read() })); in.close(); } } @@ -539,8 +539,8 @@ void testGetBufferedWriter_withPlusInFilename() throws IOException { writer.close(); File file = new File(filename); - Assert.assertTrue(file.exists()); - Assert.assertEquals("test+test.txt", file.getCanonicalFile().getName()); + Assertions.assertTrue(file.exists()); + Assertions.assertEquals("test+test.txt", file.getCanonicalFile().getName()); } @Test @@ -562,8 +562,8 @@ void testResolveFileOrResource() throws URISyntaxException, IOException { try (InputStream is = url.openStream()) { byte[] data = new byte[4096]; int size = is.read(data); - Assert.assertEquals(9, size); - Assert.assertEquals("Success!\n", new String(data, 0, size)); + Assertions.assertEquals(9, size); + Assertions.assertEquals("Success!\n", new String(data, 0, size)); } } @@ -572,14 +572,14 @@ void testResolveFileOrResource_withWhitespace() throws URISyntaxException, IOExc File jarFile = new File("test/input/org/matsim/core/utils/io/IOUtils/test directory/testfile.jar"); String fileUrlString = "jar:" + jarFile.toURI().toString() + "!/the_file.txt"; - Assert.assertTrue(fileUrlString.contains("test%20directory")); // just make sure the space is correctly URL-encoded + Assertions.assertTrue(fileUrlString.contains("test%20directory")); // just make sure the space is correctly URL-encoded URL url = IOUtils.resolveFileOrResource(fileUrlString); try (InputStream is = url.openStream()) { byte[] data = new byte[4096]; int size = is.read(data); - Assert.assertEquals(9, size); - Assert.assertEquals("Success!\n", new String(data, 0, size)); + Assertions.assertEquals(9, size); + Assertions.assertEquals("Success!\n", new String(data, 0, size)); } } @@ -592,10 +592,10 @@ void testEncryptedFile() throws IOException { // openssl enc -aes256 -md sha512 -pbkdf2 -iter 10000 -in some.secret -out some.secret.enc BufferedReader decrypted = IOUtils.getBufferedReader(new File("test/input/org/matsim/core/utils/io/IOUtils/some.secret.enc").toURL()); - Assert.assertEquals(input, decrypted.readLine()); + Assertions.assertEquals(input, decrypted.readLine()); BufferedReader gziped = IOUtils.getBufferedReader(new File("test/input/org/matsim/core/utils/io/IOUtils/some.secret.gz.enc").toURL()); - Assert.assertEquals(input, gziped.readLine()); + Assertions.assertEquals(input, gziped.readLine()); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/io/MatsimFileTypeGuesserTest.java b/matsim/src/test/java/org/matsim/core/utils/io/MatsimFileTypeGuesserTest.java index 3ec8ab16e69..96008a0ac09 100644 --- a/matsim/src/test/java/org/matsim/core/utils/io/MatsimFileTypeGuesserTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/io/MatsimFileTypeGuesserTest.java @@ -20,10 +20,7 @@ package org.matsim.core.utils.io; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlParserTest.java b/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlParserTest.java index 7f692064d1d..d4d3f715283 100644 --- a/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlParserTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlParserTest.java @@ -19,7 +19,7 @@ package org.matsim.core.utils.io; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.io.TempDir; @@ -56,13 +56,13 @@ void testParsingReservedEntities_AttributeValue() { parser.setValidating(false); parser.parse(new ByteArrayInputStream(str.getBytes())); - Assert.assertEquals("dummy", parser.lastStartTag); - Assert.assertEquals("dummy", parser.lastEndTag); - Assert.assertEquals("content", parser.lastContent); - Assert.assertEquals(1, parser.lastAttributes.getLength()); - Assert.assertEquals("someAttribute", parser.lastAttributes.getLocalName(0)); - Assert.assertEquals("value\"&<>value", parser.lastAttributes.getValue(0)); - Assert.assertEquals("value\"&<>value", parser.lastAttributes.getValue("someAttribute")); + Assertions.assertEquals("dummy", parser.lastStartTag); + Assertions.assertEquals("dummy", parser.lastEndTag); + Assertions.assertEquals("content", parser.lastContent); + Assertions.assertEquals(1, parser.lastAttributes.getLength()); + Assertions.assertEquals("someAttribute", parser.lastAttributes.getLocalName(0)); + Assertions.assertEquals("value\"&<>value", parser.lastAttributes.getValue(0)); + Assertions.assertEquals("value\"&<>value", parser.lastAttributes.getValue("someAttribute")); } @Test @@ -74,13 +74,13 @@ void testParsingReservedEntities_Content() { parser.setValidating(false); parser.parse(new ByteArrayInputStream(str.getBytes())); - Assert.assertEquals("dummy", parser.lastStartTag); - Assert.assertEquals("dummy", parser.lastEndTag); - Assert.assertEquals("content\"&<>content", parser.lastContent); - Assert.assertEquals(1, parser.lastAttributes.getLength()); - Assert.assertEquals("someAttribute", parser.lastAttributes.getLocalName(0)); - Assert.assertEquals("value", parser.lastAttributes.getValue(0)); - Assert.assertEquals("value", parser.lastAttributes.getValue("someAttribute")); + Assertions.assertEquals("dummy", parser.lastStartTag); + Assertions.assertEquals("dummy", parser.lastEndTag); + Assertions.assertEquals("content\"&<>content", parser.lastContent); + Assertions.assertEquals(1, parser.lastAttributes.getLength()); + Assertions.assertEquals("someAttribute", parser.lastAttributes.getLocalName(0)); + Assertions.assertEquals("value", parser.lastAttributes.getValue(0)); + Assertions.assertEquals("value", parser.lastAttributes.getValue("someAttribute")); } /** @@ -100,12 +100,12 @@ void testParsing_WindowsLinebreaks() { parser.setValidating(false); parser.parse(new ByteArrayInputStream(str.getBytes())); - Assert.assertEquals("dummy2", parser.lastStartTag); - Assert.assertEquals("root", parser.lastEndTag); - Assert.assertEquals(1, parser.lastAttributes.getLength()); - Assert.assertEquals("someAttribute2", parser.lastAttributes.getLocalName(0)); - Assert.assertEquals("value2", parser.lastAttributes.getValue(0)); - Assert.assertEquals("value2", parser.lastAttributes.getValue("someAttribute2")); + Assertions.assertEquals("dummy2", parser.lastStartTag); + Assertions.assertEquals("root", parser.lastEndTag); + Assertions.assertEquals(1, parser.lastAttributes.getLength()); + Assertions.assertEquals("someAttribute2", parser.lastAttributes.getLocalName(0)); + Assertions.assertEquals("value2", parser.lastAttributes.getValue(0)); + Assertions.assertEquals("value2", parser.lastAttributes.getValue("someAttribute2")); } private static class TestParser extends MatsimXmlParser { @@ -142,13 +142,13 @@ void testParsingPlusSign() { parser.setValidating(false); parser.parse(new ByteArrayInputStream(str.getBytes())); - Assert.assertEquals("dummy", parser.lastStartTag); - Assert.assertEquals("dummy", parser.lastEndTag); - Assert.assertEquals("content+content", parser.lastContent); - Assert.assertEquals(1, parser.lastAttributes.getLength()); - Assert.assertEquals("someAttribute", parser.lastAttributes.getLocalName(0)); - Assert.assertEquals("value+value", parser.lastAttributes.getValue(0)); - Assert.assertEquals("value+value", parser.lastAttributes.getValue("someAttribute")); + Assertions.assertEquals("dummy", parser.lastStartTag); + Assertions.assertEquals("dummy", parser.lastEndTag); + Assertions.assertEquals("content+content", parser.lastContent); + Assertions.assertEquals(1, parser.lastAttributes.getLength()); + Assertions.assertEquals("someAttribute", parser.lastAttributes.getLocalName(0)); + Assertions.assertEquals("value+value", parser.lastAttributes.getValue(0)); + Assertions.assertEquals("value+value", parser.lastAttributes.getValue("someAttribute")); } @Test @@ -178,8 +178,8 @@ public void endTag(String name, String content, Stack context) { } }.parse(stream); - Assert.assertEquals("b1", log.get(0)); - Assert.assertEquals("b2", log.get(1)); + Assertions.assertEquals("b1", log.get(0)); + Assertions.assertEquals("b2", log.get(1)); } @Test @@ -207,16 +207,16 @@ public void startTag(String name, Attributes atts, Stack context) { public void endTag(String name, String content, Stack context) { } }.parse(stream); - Assert.fail("expected exception."); + Assertions.fail("expected exception."); } catch (UncheckedIOException e) { - Assert.assertTrue(e.getCause() instanceof IOException); // expected - Assert.assertTrue(e.getCause().getCause() instanceof SAXParseException); // expected + Assertions.assertTrue(e.getCause() instanceof IOException); // expected + Assertions.assertTrue(e.getCause().getCause() instanceof SAXParseException); // expected } - Assert.assertEquals(3, log.size()); - Assert.assertEquals("network", log.get(0)); - Assert.assertEquals("nodes", log.get(1)); - Assert.assertEquals("node", log.get(2)); + Assertions.assertEquals(3, log.size()); + Assertions.assertEquals("network", log.get(0)); + Assertions.assertEquals("nodes", log.get(1)); + Assertions.assertEquals("node", log.get(2)); } @Test @@ -246,12 +246,12 @@ public void endTag(String name, String content, Stack context) { } }.parse(stream); - Assert.assertEquals(5, log.size()); - Assert.assertEquals("vehicleDefinitions", log.get(0)); - Assert.assertEquals("vehicleType", log.get(1)); - Assert.assertEquals("capacity", log.get(2)); - Assert.assertEquals("length", log.get(3)); - Assert.assertEquals("width", log.get(4)); + Assertions.assertEquals(5, log.size()); + Assertions.assertEquals("vehicleDefinitions", log.get(0)); + Assertions.assertEquals("vehicleType", log.get(1)); + Assertions.assertEquals("capacity", log.get(2)); + Assertions.assertEquals("length", log.get(3)); + Assertions.assertEquals("width", log.get(4)); } @Test @@ -283,18 +283,18 @@ public void startTag(String name, Attributes atts, Stack context) { public void endTag(String name, String content, Stack context) { } }.parse(stream); - Assert.fail("expected exception."); + Assertions.fail("expected exception."); } catch (UncheckedIOException e) { - Assert.assertTrue(e.getCause() instanceof IOException); // expected - Assert.assertTrue(e.getCause().getCause() instanceof SAXParseException); // expected + Assertions.assertTrue(e.getCause() instanceof IOException); // expected + Assertions.assertTrue(e.getCause().getCause() instanceof SAXParseException); // expected } - Assert.assertEquals(5, log.size()); - Assert.assertEquals("vehicleDefinitions", log.get(0)); - Assert.assertEquals("vehicleType", log.get(1)); - Assert.assertEquals("capacity", log.get(2)); - Assert.assertEquals("length", log.get(3)); - Assert.assertEquals("width", log.get(4)); + Assertions.assertEquals(5, log.size()); + Assertions.assertEquals("vehicleDefinitions", log.get(0)); + Assertions.assertEquals("vehicleType", log.get(1)); + Assertions.assertEquals("capacity", log.get(2)); + Assertions.assertEquals("length", log.get(3)); + Assertions.assertEquals("width", log.get(4)); } @Test @@ -336,12 +336,12 @@ public void endTag(String name, String content, Stack context) { log.add(content); } }.parse(stream); - Assert.fail("Expected exception, got none."); + Assertions.fail("Expected exception, got none."); } catch (UncheckedIOException expected) {} - Assert.assertEquals(2, log.size()); - Assert.assertEquals("b1", log.get(0)); - Assert.assertEquals(" - b2 - ", log.get(1)); + Assertions.assertEquals(2, log.size()); + Assertions.assertEquals("b1", log.get(0)); + Assertions.assertEquals(" - b2 - ", log.get(1)); } @Test @@ -385,11 +385,11 @@ public void endTag(String name, String content, Stack context) { } }.parse(stream); - Assert.assertEquals(4, log.size()); - Assert.assertEquals("attribute-a2", log.get(0)); - Assert.assertEquals("attribute-", log.get(1)); - Assert.assertEquals("object-", log.get(2)); - Assert.assertEquals("objectattributes-", log.get(3)); + Assertions.assertEquals(4, log.size()); + Assertions.assertEquals("attribute-a2", log.get(0)); + Assertions.assertEquals("attribute-", log.get(1)); + Assertions.assertEquals("object-", log.get(2)); + Assertions.assertEquals("objectattributes-", log.get(3)); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlWriterTest.java b/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlWriterTest.java index 031e405293e..7a8e90c3d85 100644 --- a/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlWriterTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlWriterTest.java @@ -3,7 +3,7 @@ import java.io.ByteArrayOutputStream; import java.util.List; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; diff --git a/matsim/src/test/java/org/matsim/core/utils/io/OsmNetworkReaderTest.java b/matsim/src/test/java/org/matsim/core/utils/io/OsmNetworkReaderTest.java index b307e54c47d..1fc057aa857 100644 --- a/matsim/src/test/java/org/matsim/core/utils/io/OsmNetworkReaderTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/io/OsmNetworkReaderTest.java @@ -19,7 +19,7 @@ package org.matsim.core.utils.io; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -54,12 +54,12 @@ void testConversion() { new OsmNetworkReader(net,ct).parse(filename); - Assert.assertEquals("number of nodes is wrong.", 399, net.getNodes().size()); - Assert.assertEquals("number of links is wrong.", 872, net.getLinks().size()); + Assertions.assertEquals(399, net.getNodes().size(), "number of nodes is wrong."); + Assertions.assertEquals(872, net.getLinks().size(), "number of links is wrong."); new NetworkCleaner().run(net); - Assert.assertEquals("number of nodes is wrong.", 344, net.getNodes().size()); - Assert.assertEquals("number of links is wrong.", 794, net.getLinks().size()); + Assertions.assertEquals(344, net.getNodes().size(), "number of nodes is wrong."); + Assertions.assertEquals(794, net.getLinks().size(), "number of links is wrong."); } @Test @@ -75,12 +75,12 @@ void testConversionWithDetails() { reader.setKeepPaths(true); reader.parse(filename); - Assert.assertEquals("number of nodes is wrong.", 1844, net.getNodes().size()); - Assert.assertEquals("number of links is wrong.", 3535, net.getLinks().size()); + Assertions.assertEquals(1844, net.getNodes().size(), "number of nodes is wrong."); + Assertions.assertEquals(3535, net.getLinks().size(), "number of links is wrong."); new NetworkCleaner().run(net); - Assert.assertEquals("number of nodes is wrong.", 1561, net.getNodes().size()); - Assert.assertEquals("number of links is wrong.", 3168, net.getLinks().size()); + Assertions.assertEquals(1561, net.getNodes().size(), "number of nodes is wrong."); + Assertions.assertEquals(3168, net.getLinks().size(), "number of links is wrong."); } @Test @@ -97,12 +97,12 @@ void testConversionWithDetails_witMemoryOptimized() { reader.setMemoryOptimization(true); reader.parse(filename); - Assert.assertEquals("number of nodes is wrong.", 1844, net.getNodes().size()); - Assert.assertEquals("number of links is wrong.", 3535, net.getLinks().size()); + Assertions.assertEquals(1844, net.getNodes().size(), "number of nodes is wrong."); + Assertions.assertEquals(3535, net.getLinks().size(), "number of links is wrong."); new NetworkCleaner().run(net); - Assert.assertEquals("number of nodes is wrong.", 1561, net.getNodes().size()); - Assert.assertEquals("number of links is wrong.", 3168, net.getLinks().size()); + Assertions.assertEquals(1561, net.getNodes().size(), "number of nodes is wrong."); + Assertions.assertEquals(3168, net.getLinks().size(), "number of links is wrong."); } @Test @@ -119,11 +119,11 @@ void testConversionWithSettings() { reader.setMemoryOptimization(false); reader.parse(filename); - Assert.assertEquals("number of nodes is wrong.", 67, net.getNodes().size()); - Assert.assertEquals("number of links is wrong.", 122, net.getLinks().size()); + Assertions.assertEquals(67, net.getNodes().size(), "number of nodes is wrong."); + Assertions.assertEquals(122, net.getLinks().size(), "number of links is wrong."); new NetworkCleaner().run(net); - Assert.assertEquals("number of nodes is wrong.", 57, net.getNodes().size()); - Assert.assertEquals("number of links is wrong.", 114, net.getLinks().size()); + Assertions.assertEquals(57, net.getNodes().size(), "number of nodes is wrong."); + Assertions.assertEquals(114, net.getLinks().size(), "number of links is wrong."); } @Test @@ -140,11 +140,11 @@ void testConversionWithSettings_withMemoryOptimization() { reader.setMemoryOptimization(true); reader.parse(filename); - Assert.assertEquals("number of nodes is wrong.", 67, net.getNodes().size()); - Assert.assertEquals("number of links is wrong.", 122, net.getLinks().size()); + Assertions.assertEquals(67, net.getNodes().size(), "number of nodes is wrong."); + Assertions.assertEquals(122, net.getLinks().size(), "number of links is wrong."); new NetworkCleaner().run(net); - Assert.assertEquals("number of nodes is wrong.", 57, net.getNodes().size()); - Assert.assertEquals("number of links is wrong.", 114, net.getLinks().size()); + Assertions.assertEquals(57, net.getNodes().size(), "number of nodes is wrong."); + Assertions.assertEquals(114, net.getLinks().size(), "number of links is wrong."); } @Test @@ -161,11 +161,11 @@ void testConversionWithSettingsAndDetails() { reader.setHierarchyLayer(47.4, 8.5, 47.2, 8.6, 5); reader.parse(filename); - Assert.assertEquals("number of nodes is wrong.", 769, net.getNodes().size()); - Assert.assertEquals("number of links is wrong.", 1016, net.getLinks().size()); + Assertions.assertEquals(769, net.getNodes().size(), "number of nodes is wrong."); + Assertions.assertEquals(1016, net.getLinks().size(), "number of links is wrong."); new NetworkCleaner().run(net); - Assert.assertEquals("number of nodes is wrong.", 441, net.getNodes().size()); - Assert.assertEquals("number of links is wrong.", 841, net.getLinks().size()); + Assertions.assertEquals(441, net.getNodes().size(), "number of nodes is wrong."); + Assertions.assertEquals(841, net.getLinks().size(), "number of links is wrong."); } @Test @@ -195,8 +195,8 @@ void testConversion_MissingNodeRef() { " \n" + ""; reader.parse(() -> new ByteArrayInputStream(str.getBytes())); - Assert.assertEquals("incomplete ways should not be converted.", 0, net.getNodes().size()); - Assert.assertEquals("incomplete ways should not be converted.", 0, net.getLinks().size()); + Assertions.assertEquals(0, net.getNodes().size(), "incomplete ways should not be converted."); + Assertions.assertEquals(0, net.getLinks().size(), "incomplete ways should not be converted."); } @Test @@ -246,12 +246,12 @@ void testConversion_maxspeeds() { Link link1 = net.getLinks().get(Id.create("1", Link.class)); Link link3 = net.getLinks().get(Id.create("3", Link.class)); Link link5 = net.getLinks().get(Id.create("5", Link.class)); - Assert.assertNotNull("Could not find converted link 1.", link1); - Assert.assertNotNull("Could not find converted link 3", link3); - Assert.assertNotNull("Could not find converted link 5", link5); - Assert.assertEquals(50.0/3.6, link1.getFreespeed(), 1e-8); - Assert.assertEquals(40.0/3.6, link3.getFreespeed(), 1e-8); - Assert.assertEquals(60.0/3.6, link5.getFreespeed(), 1e-8); + Assertions.assertNotNull(link1, "Could not find converted link 1."); + Assertions.assertNotNull(link3, "Could not find converted link 3"); + Assertions.assertNotNull(link5, "Could not find converted link 5"); + Assertions.assertEquals(50.0/3.6, link1.getFreespeed(), 1e-8); + Assertions.assertEquals(40.0/3.6, link3.getFreespeed(), 1e-8); + Assertions.assertEquals(60.0/3.6, link5.getFreespeed(), 1e-8); } /** @@ -301,8 +301,8 @@ void testConversion_emptyWay() { Link link1 = net.getLinks().get(Id.create("1", Link.class)); Link link3 = net.getLinks().get(Id.create("3", Link.class)); - Assert.assertNotNull("Could not find converted link 1.", link1); - Assert.assertNotNull("Could not find converted link 3", link3); - Assert.assertNull(net.getLinks().get(Id.create("5", Link.class))); + Assertions.assertNotNull(link1, "Could not find converted link 1."); + Assertions.assertNotNull(link3, "Could not find converted link 3"); + Assertions.assertNull(net.getLinks().get(Id.create("5", Link.class))); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/io/XmlUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/io/XmlUtilsTest.java index 1923fddcfae..5bf09eafec3 100644 --- a/matsim/src/test/java/org/matsim/core/utils/io/XmlUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/io/XmlUtilsTest.java @@ -19,7 +19,7 @@ package org.matsim.core.utils.io; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -29,24 +29,24 @@ public class XmlUtilsTest { @Test void testEncodeAttributeValue() { - Assert.assertEquals("hello world!", XmlUtils.encodeAttributeValue("hello world!")); - Assert.assertEquals("you & me", XmlUtils.encodeAttributeValue("you & me")); - Assert.assertEquals("you & me & her", XmlUtils.encodeAttributeValue("you & me & her")); - Assert.assertEquals("tick " tack", XmlUtils.encodeAttributeValue("tick \" tack")); - Assert.assertEquals("tick " tack " tock", XmlUtils.encodeAttributeValue("tick \" tack \" tock")); - Assert.assertEquals("this & that " these & those", XmlUtils.encodeAttributeValue("this & that \" these & those")); - Assert.assertEquals("tick < tack > tock", XmlUtils.encodeAttributeValue("tick < tack > tock")); + Assertions.assertEquals("hello world!", XmlUtils.encodeAttributeValue("hello world!")); + Assertions.assertEquals("you & me", XmlUtils.encodeAttributeValue("you & me")); + Assertions.assertEquals("you & me & her", XmlUtils.encodeAttributeValue("you & me & her")); + Assertions.assertEquals("tick " tack", XmlUtils.encodeAttributeValue("tick \" tack")); + Assertions.assertEquals("tick " tack " tock", XmlUtils.encodeAttributeValue("tick \" tack \" tock")); + Assertions.assertEquals("this & that " these & those", XmlUtils.encodeAttributeValue("this & that \" these & those")); + Assertions.assertEquals("tick < tack > tock", XmlUtils.encodeAttributeValue("tick < tack > tock")); } @Test void testEncodedContent() { - Assert.assertEquals("hello world!", XmlUtils.encodeContent("hello world!")); - Assert.assertEquals("you & me", XmlUtils.encodeContent("you & me")); - Assert.assertEquals("you & me & her", XmlUtils.encodeContent("you & me & her")); - Assert.assertEquals("tick \" tack", XmlUtils.encodeContent("tick \" tack")); - Assert.assertEquals("tick \" tack \" tock", XmlUtils.encodeContent("tick \" tack \" tock")); - Assert.assertEquals("this & that \" these & those", XmlUtils.encodeContent("this & that \" these & those")); - Assert.assertEquals("tick < tack > tock", XmlUtils.encodeContent("tick < tack > tock")); + Assertions.assertEquals("hello world!", XmlUtils.encodeContent("hello world!")); + Assertions.assertEquals("you & me", XmlUtils.encodeContent("you & me")); + Assertions.assertEquals("you & me & her", XmlUtils.encodeContent("you & me & her")); + Assertions.assertEquals("tick \" tack", XmlUtils.encodeContent("tick \" tack")); + Assertions.assertEquals("tick \" tack \" tock", XmlUtils.encodeContent("tick \" tack \" tock")); + Assertions.assertEquals("this & that \" these & those", XmlUtils.encodeContent("this & that \" these & those")); + Assertions.assertEquals("tick < tack > tock", XmlUtils.encodeContent("tick < tack > tock")); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/ArgumentParserTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/ArgumentParserTest.java index 3e4e9948379..550ae2c07d4 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/ArgumentParserTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/ArgumentParserTest.java @@ -20,8 +20,8 @@ package org.matsim.core.utils.misc; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.util.Iterator; import java.util.NoSuchElementException; diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/ByteBufferUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/ByteBufferUtilsTest.java index 2325de69101..8438ed9b621 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/ByteBufferUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/ByteBufferUtilsTest.java @@ -20,8 +20,8 @@ package org.matsim.core.utils.misc; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import java.io.Serializable; import java.nio.ByteBuffer; diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/ClassUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/ClassUtilsTest.java index de4b6b6bb0c..d53b1e6d49e 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/ClassUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/ClassUtilsTest.java @@ -21,7 +21,7 @@ import java.util.Set; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -32,110 +32,110 @@ public class ClassUtilsTest { @Test void testInterfaceNoInheritance() { Set> set = ClassUtils.getAllTypes(A.class); - Assert.assertEquals(1, set.size()); - Assert.assertTrue(set.contains(A.class)); + Assertions.assertEquals(1, set.size()); + Assertions.assertTrue(set.contains(A.class)); } @Test void testClassNoInheritance() { Set> set = ClassUtils.getAllTypes(Z.class); - Assert.assertEquals(2, set.size()); - Assert.assertTrue(set.contains(Z.class)); - Assert.assertTrue(set.contains(Object.class)); + Assertions.assertEquals(2, set.size()); + Assertions.assertTrue(set.contains(Z.class)); + Assertions.assertTrue(set.contains(Object.class)); } @Test void testInterfaceSingleInheritance() { Set> set = ClassUtils.getAllTypes(B.class); - Assert.assertEquals(2, set.size()); - Assert.assertTrue(set.contains(A.class)); - Assert.assertTrue(set.contains(B.class)); + Assertions.assertEquals(2, set.size()); + Assertions.assertTrue(set.contains(A.class)); + Assertions.assertTrue(set.contains(B.class)); } @Test void testClassSingleInheritance() { Set> set = ClassUtils.getAllTypes(Y.class); - Assert.assertEquals(3, set.size()); - Assert.assertTrue(set.contains(Z.class)); - Assert.assertTrue(set.contains(Y.class)); - Assert.assertTrue(set.contains(Object.class)); + Assertions.assertEquals(3, set.size()); + Assertions.assertTrue(set.contains(Z.class)); + Assertions.assertTrue(set.contains(Y.class)); + Assertions.assertTrue(set.contains(Object.class)); } @Test void testInterfaceMultipleInheritance_SingleLevel() { Set> set = ClassUtils.getAllTypes(AB.class); - Assert.assertEquals(3, set.size()); - Assert.assertTrue(set.contains(A.class)); - Assert.assertTrue(set.contains(B.class)); - Assert.assertTrue(set.contains(AB.class)); + Assertions.assertEquals(3, set.size()); + Assertions.assertTrue(set.contains(A.class)); + Assertions.assertTrue(set.contains(B.class)); + Assertions.assertTrue(set.contains(AB.class)); } @Test void testInterfaceMultipleInheritance_MultipleLevel() { Set> set = ClassUtils.getAllTypes(C.class); - Assert.assertEquals(3, set.size()); - Assert.assertTrue(set.contains(A.class)); - Assert.assertTrue(set.contains(B.class)); - Assert.assertTrue(set.contains(C.class)); + Assertions.assertEquals(3, set.size()); + Assertions.assertTrue(set.contains(A.class)); + Assertions.assertTrue(set.contains(B.class)); + Assertions.assertTrue(set.contains(C.class)); } @Test void testClassMultipleInheritance_MultipleLevel() { Set> set = ClassUtils.getAllTypes(X.class); - Assert.assertEquals(4, set.size()); - Assert.assertTrue(set.contains(Z.class)); - Assert.assertTrue(set.contains(Y.class)); - Assert.assertTrue(set.contains(X.class)); - Assert.assertTrue(set.contains(Object.class)); + Assertions.assertEquals(4, set.size()); + Assertions.assertTrue(set.contains(Z.class)); + Assertions.assertTrue(set.contains(Y.class)); + Assertions.assertTrue(set.contains(X.class)); + Assertions.assertTrue(set.contains(Object.class)); } @Test void testSingleInterfaceImplementation() { Set> set = ClassUtils.getAllTypes(Aimpl.class); - Assert.assertEquals(3, set.size()); - Assert.assertTrue(set.contains(Aimpl.class)); - Assert.assertTrue(set.contains(A.class)); - Assert.assertTrue(set.contains(Object.class)); + Assertions.assertEquals(3, set.size()); + Assertions.assertTrue(set.contains(Aimpl.class)); + Assertions.assertTrue(set.contains(A.class)); + Assertions.assertTrue(set.contains(Object.class)); } @Test void testSingleInterfaceImplementation_MultipleLevel() { Set> set = ClassUtils.getAllTypes(Bimpl.class); - Assert.assertEquals(4, set.size()); - Assert.assertTrue(set.contains(Bimpl.class)); - Assert.assertTrue(set.contains(B.class)); - Assert.assertTrue(set.contains(A.class)); - Assert.assertTrue(set.contains(Object.class)); + Assertions.assertEquals(4, set.size()); + Assertions.assertTrue(set.contains(Bimpl.class)); + Assertions.assertTrue(set.contains(B.class)); + Assertions.assertTrue(set.contains(A.class)); + Assertions.assertTrue(set.contains(Object.class)); } @Test void testMultipleInterfaceImplementation() { Set> set = ClassUtils.getAllTypes(ABimpl.class); - Assert.assertEquals(4, set.size()); - Assert.assertTrue(set.contains(ABimpl.class)); - Assert.assertTrue(set.contains(B.class)); - Assert.assertTrue(set.contains(A.class)); - Assert.assertTrue(set.contains(Object.class)); + Assertions.assertEquals(4, set.size()); + Assertions.assertTrue(set.contains(ABimpl.class)); + Assertions.assertTrue(set.contains(B.class)); + Assertions.assertTrue(set.contains(A.class)); + Assertions.assertTrue(set.contains(Object.class)); } @Test void testComplexClass() { Set> set = ClassUtils.getAllTypes(Dimpl.class); - Assert.assertEquals(5, set.size()); - Assert.assertTrue(set.contains(Dimpl.class)); - Assert.assertTrue(set.contains(Bimpl.class)); - Assert.assertTrue(set.contains(B.class)); - Assert.assertTrue(set.contains(A.class)); - Assert.assertTrue(set.contains(Object.class)); + Assertions.assertEquals(5, set.size()); + Assertions.assertTrue(set.contains(Dimpl.class)); + Assertions.assertTrue(set.contains(Bimpl.class)); + Assertions.assertTrue(set.contains(B.class)); + Assertions.assertTrue(set.contains(A.class)); + Assertions.assertTrue(set.contains(Object.class)); set = ClassUtils.getAllTypes(BCDimpl.class); - Assert.assertEquals(6, set.size()); - Assert.assertTrue(set.contains(BCDimpl.class)); - Assert.assertTrue(set.contains(Bimpl.class)); - Assert.assertTrue(set.contains(C.class)); - Assert.assertTrue(set.contains(B.class)); - Assert.assertTrue(set.contains(A.class)); - Assert.assertTrue(set.contains(Object.class)); + Assertions.assertEquals(6, set.size()); + Assertions.assertTrue(set.contains(BCDimpl.class)); + Assertions.assertTrue(set.contains(Bimpl.class)); + Assertions.assertTrue(set.contains(C.class)); + Assertions.assertTrue(set.contains(B.class)); + Assertions.assertTrue(set.contains(A.class)); + Assertions.assertTrue(set.contains(Object.class)); } /*package*/ interface A { } diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java index 383eba26f43..73c7bde965d 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java @@ -25,6 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.config.Config; @@ -46,33 +47,33 @@ public class ConfigUtilsTest { @Test void testLoadConfig_filenameOnly() throws IOException { Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); - Assert.assertNotNull(config); - Assert.assertEquals("network.xml", config.network().getInputFile()); + Assertions.assertNotNull(config); + Assertions.assertEquals("network.xml", config.network().getInputFile()); } @Test void testLoadConfig_emptyConfig() throws IOException { Config config = new Config(); - Assert.assertNull(config.network()); + Assertions.assertNull(config.network()); ConfigUtils.loadConfig(config, IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); - Assert.assertNotNull(config.network()); - Assert.assertEquals("network.xml", config.network().getInputFile()); + Assertions.assertNotNull(config.network()); + Assertions.assertEquals("network.xml", config.network().getInputFile()); } @Test void testLoadConfig_preparedConfig() throws IOException { Config config = new Config(); config.addCoreModules(); - Assert.assertNotNull(config.network()); - Assert.assertNull(config.network().getInputFile()); + Assertions.assertNotNull(config.network()); + Assertions.assertNull(config.network().getInputFile()); ConfigUtils.loadConfig(config, IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); - Assert.assertEquals("network.xml", config.network().getInputFile()); + Assertions.assertEquals("network.xml", config.network().getInputFile()); } @Test void testModifyPaths_missingSeparator() throws IOException { Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); - Assert.assertEquals("network.xml", config.network().getInputFile()); + Assertions.assertEquals("network.xml", config.network().getInputFile()); ConfigUtils.modifyFilePaths(config, "/home/username/matsim"); Assert.assertThat(config.network().getInputFile(), anyOf(is("/home/username/matsim/network.xml"),is("/home/username/matsim\\network.xml"))); @@ -81,7 +82,7 @@ void testModifyPaths_missingSeparator() throws IOException { @Test void testModifyPaths_withSeparator() throws IOException { Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); - Assert.assertEquals("network.xml", config.network().getInputFile()); + Assertions.assertEquals("network.xml", config.network().getInputFile()); ConfigUtils.modifyFilePaths(config, "/home/username/matsim/"); Assert.assertThat(config.network().getInputFile(), anyOf(is("/home/username/matsim/network.xml"),is("/home/username/matsim\\network.xml"))); } @@ -91,7 +92,7 @@ void loadConfigWithTypedArgs(){ final URL url = IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ); final String [] typedArgs = {"--config:controler.outputDirectory=abc"} ; Config config = ConfigUtils.loadConfig( url, typedArgs ); - Assert.assertEquals("abc", config.controller().getOutputDirectory()); + Assertions.assertEquals("abc", config.controller().getOutputDirectory()); } @Test @@ -106,6 +107,6 @@ void loadConfigWithTypedArgsWithTypo(){ hasFailed = true ; log.warn("the above exception was expected") ; } - Assert.assertTrue( hasFailed ); + Assertions.assertTrue( hasFailed ); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/NetworkUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/NetworkUtilsTest.java index 8f9caadb543..146468c9db8 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/NetworkUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/NetworkUtilsTest.java @@ -20,14 +20,14 @@ package org.matsim.core.utils.misc; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -225,7 +225,7 @@ void testIsMultimodal_carOnly() { for (Link l : f.links) { l.setAllowedModes(CollectionUtils.stringToSet("car")); } - Assert.assertFalse(NetworkUtils.isMultimodal(f.network)); + Assertions.assertFalse(NetworkUtils.isMultimodal(f.network)); } @Test @@ -235,7 +235,7 @@ void testIsMultimodal_walkOnly() { for (Link l : f.links) { l.setAllowedModes(CollectionUtils.stringToSet("walk")); } - Assert.assertFalse(NetworkUtils.isMultimodal(f.network)); + Assertions.assertFalse(NetworkUtils.isMultimodal(f.network)); } @Test @@ -245,7 +245,7 @@ void testIsMultimodal_2modesOnSingleLink() { l.setAllowedModes(CollectionUtils.stringToSet("car")); } f.links[3].setAllowedModes(CollectionUtils.stringToSet("car,bike")); - Assert.assertTrue(NetworkUtils.isMultimodal(f.network)); + Assertions.assertTrue(NetworkUtils.isMultimodal(f.network)); } @Test @@ -255,7 +255,7 @@ void testIsMultimodal_2modesOnDifferentLinks() { l.setAllowedModes(CollectionUtils.stringToSet("car")); } f.links[2].setAllowedModes(CollectionUtils.stringToSet("bike")); - Assert.assertTrue(NetworkUtils.isMultimodal(f.network)); + Assertions.assertTrue(NetworkUtils.isMultimodal(f.network)); } @Test @@ -265,7 +265,7 @@ void testIsMultimodal_3modes() { l.setAllowedModes(CollectionUtils.stringToSet("car")); } f.links[2].setAllowedModes(CollectionUtils.stringToSet("bike,walk")); - Assert.assertTrue(NetworkUtils.isMultimodal(f.network)); + Assertions.assertTrue(NetworkUtils.isMultimodal(f.network)); } @Test @@ -274,7 +274,7 @@ void testIsMultimodal_onlyNoModes() { for (Link l : f.links) { l.setAllowedModes(CollectionUtils.stringToSet("")); } - Assert.assertFalse(NetworkUtils.isMultimodal(f.network)); + Assertions.assertFalse(NetworkUtils.isMultimodal(f.network)); } @Test @@ -284,7 +284,7 @@ void testIsMultimodal_sometimesNoModes() { l.setAllowedModes(CollectionUtils.stringToSet("car")); } f.links[2].setAllowedModes(CollectionUtils.stringToSet("")); - Assert.assertTrue(NetworkUtils.isMultimodal(f.network)); + Assertions.assertTrue(NetworkUtils.isMultimodal(f.network)); } @Test @@ -296,11 +296,11 @@ void testGetConnectingLink() { Link link1 = net.getLinks().get(Id.create(1, Link.class)); Link link2 = net.getLinks().get(Id.create(2, Link.class)); - Assert.assertEquals(link1, NetworkUtils.getConnectingLink(node1, node2)); - Assert.assertEquals(link2, NetworkUtils.getConnectingLink(node2, node3)); - Assert.assertNull(NetworkUtils.getConnectingLink(node1, node3)); // skip one node - Assert.assertNull(NetworkUtils.getConnectingLink(node3, node2)); // backwards - Assert.assertNull(NetworkUtils.getConnectingLink(node2, node1)); // backwards + Assertions.assertEquals(link1, NetworkUtils.getConnectingLink(node1, node2)); + Assertions.assertEquals(link2, NetworkUtils.getConnectingLink(node2, node3)); + Assertions.assertNull(NetworkUtils.getConnectingLink(node1, node3)); // skip one node + Assertions.assertNull(NetworkUtils.getConnectingLink(node3, node2)); // backwards + Assertions.assertNull(NetworkUtils.getConnectingLink(node2, node1)); // backwards } private static class PseudoLink extends FakeLink { diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/PopulationUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/PopulationUtilsTest.java index 5f30320cbd3..f00cd245d00 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/PopulationUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/PopulationUtilsTest.java @@ -20,7 +20,7 @@ import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -58,11 +58,11 @@ void testLegOverlap() { List legs3 = PopulationUtils.getLegs(f.plan3); // Assert.assertEquals( 2., PopulationUtils.calculateSimilarity( legs1, legs2, null, 1., 1. ) , 0.001 ) ; - Assert.assertEquals( 4., PopulationUtils.calculateSimilarity( legs1, legs2, null, 1., 1. ) , 0.001 ) ; + Assertions.assertEquals( 4., PopulationUtils.calculateSimilarity( legs1, legs2, null, 1., 1. ) , 0.001 ) ; // (no route is now counted as "same route" and thus reaps the reward. kai, jul'18) // Assert.assertEquals( 1., PopulationUtils.calculateSimilarity( legs1, legs3, null, 1., 1. ) , 0.001 ) ; - Assert.assertEquals( 2., PopulationUtils.calculateSimilarity( legs1, legs3, null, 1., 1. ) , 0.001 ) ; + Assertions.assertEquals( 2., PopulationUtils.calculateSimilarity( legs1, legs3, null, 1., 1. ) , 0.001 ) ; // (no route is now counted as "same route" and thus reaps the reward. kai, jul'18) } @@ -74,8 +74,8 @@ void testActivityOverlap() { List acts2 = PopulationUtils.getActivities(f.plan2, StageActivityHandling.StagesAsNormalActivities ) ; List acts3 = PopulationUtils.getActivities(f.plan3, StageActivityHandling.StagesAsNormalActivities ) ; - Assert.assertEquals( 6., PopulationUtils.calculateSimilarity( acts1, acts2 , 1., 1., 0. ) , 0.001 ) ; - Assert.assertEquals( 5., PopulationUtils.calculateSimilarity( acts1, acts3 , 1., 1., 0. ) , 0.001 ) ; + Assertions.assertEquals( 6., PopulationUtils.calculateSimilarity( acts1, acts2 , 1., 1., 0. ) , 0.001 ) ; + Assertions.assertEquals( 5., PopulationUtils.calculateSimilarity( acts1, acts3 , 1., 1., 0. ) , 0.001 ) ; } private static class Fixture { @@ -153,7 +153,7 @@ private static class Fixture { void testEmptyPopulation() { Scenario s1 = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Scenario s2 = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - Assert.assertTrue(PopulationUtils.equalPopulation(s1.getPopulation(), s2.getPopulation())); + Assertions.assertTrue(PopulationUtils.equalPopulation(s1.getPopulation(), s2.getPopulation())); } @Test @@ -162,8 +162,8 @@ void testEmptyPopulationVsOnePerson() { Scenario s2 = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Person person = s2.getPopulation().getFactory().createPerson(Id.create("1", Person.class)); s2.getPopulation().addPerson(person); - Assert.assertFalse(PopulationUtils.equalPopulation(s1.getPopulation(), s2.getPopulation())); - Assert.assertFalse(PopulationUtils.equalPopulation(s2.getPopulation(), s1.getPopulation())); + Assertions.assertFalse(PopulationUtils.equalPopulation(s1.getPopulation(), s2.getPopulation())); + Assertions.assertFalse(PopulationUtils.equalPopulation(s2.getPopulation(), s1.getPopulation())); } @Test @@ -173,7 +173,7 @@ void testCompareBigPopulationWithItself() { String popFileName = "test/scenarios/berlin/plans_hwh_1pct.xml.gz"; new MatsimNetworkReader(s1.getNetwork()).readFile(netFileName); new PopulationReader(s1).readFile(popFileName); - Assert.assertTrue(PopulationUtils.equalPopulation(s1.getPopulation(), s1.getPopulation())); + Assertions.assertTrue(PopulationUtils.equalPopulation(s1.getPopulation(), s1.getPopulation())); } } diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/RouteUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/RouteUtilsTest.java index 01c37c7d52f..8aa058cdf5d 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/RouteUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/RouteUtilsTest.java @@ -23,7 +23,7 @@ import java.util.Collections; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -78,9 +78,9 @@ void testCalculateCoverage() { route3.setLinkIds(startLink.getId(), linkIds, endLink.getId()); } - Assert.assertEquals( 1. , RouteUtils.calculateCoverage( route, route2, f.network ), 0.0001 ); - Assert.assertEquals( (200.+400.+500.)/(200.+300.+400.+500.) , RouteUtils.calculateCoverage( route, route3, f.network ), 0.0001 ); - Assert.assertEquals( 1. , RouteUtils.calculateCoverage( route3, route, f.network ), 0.0001 ); + Assertions.assertEquals( 1. , RouteUtils.calculateCoverage( route, route2, f.network ), 0.0001 ); + Assertions.assertEquals( (200.+400.+500.)/(200.+300.+400.+500.) , RouteUtils.calculateCoverage( route, route3, f.network ), 0.0001 ); + Assertions.assertEquals( 1. , RouteUtils.calculateCoverage( route3, route, f.network ), 0.0001 ); } @@ -95,12 +95,12 @@ void testGetNodes() { route.setLinkIds(startLink.getId(), linkIds, endLink.getId()); List nodes = RouteUtils.getNodes(route, f.network); - Assert.assertEquals(5, nodes.size()); - Assert.assertEquals(f.nodeIds[1], nodes.get(0).getId()); - Assert.assertEquals(f.nodeIds[2], nodes.get(1).getId()); - Assert.assertEquals(f.nodeIds[3], nodes.get(2).getId()); - Assert.assertEquals(f.nodeIds[4], nodes.get(3).getId()); - Assert.assertEquals(f.nodeIds[5], nodes.get(4).getId()); + Assertions.assertEquals(5, nodes.size()); + Assertions.assertEquals(f.nodeIds[1], nodes.get(0).getId()); + Assertions.assertEquals(f.nodeIds[2], nodes.get(1).getId()); + Assertions.assertEquals(f.nodeIds[3], nodes.get(2).getId()); + Assertions.assertEquals(f.nodeIds[4], nodes.get(3).getId()); + Assertions.assertEquals(f.nodeIds[5], nodes.get(4).getId()); } @Test @@ -113,7 +113,7 @@ void testGetNodes_SameStartEndLink() { route.setLinkIds(startLink.getId(), links, endLink.getId()); List nodes = RouteUtils.getNodes(route, f.network); - Assert.assertEquals(0, nodes.size()); + Assertions.assertEquals(0, nodes.size()); } @Test @@ -126,8 +126,8 @@ void testGetNodes_NoLinksBetween() { route.setLinkIds(startLinkId, linkIds, endLinkId); List nodes = RouteUtils.getNodes(route, f.network); - Assert.assertEquals(1, nodes.size()); - Assert.assertEquals(f.nodeIds[4], nodes.get(0).getId()); + Assertions.assertEquals(1, nodes.size()); + Assertions.assertEquals(f.nodeIds[4], nodes.get(0).getId()); } @Test @@ -144,14 +144,14 @@ void testGetNodes_CircularRoute() { route.setLinkIds(startLink.getId(), linkIds, endLink.getId()); List nodes = RouteUtils.getNodes(route, f.network); - Assert.assertEquals(7, nodes.size()); - Assert.assertEquals(f.nodeIds[4], nodes.get(0).getId()); - Assert.assertEquals(f.nodeIds[5], nodes.get(1).getId()); - Assert.assertEquals(f.nodeIds[6], nodes.get(2).getId()); - Assert.assertEquals(f.nodeIds[0], nodes.get(3).getId()); - Assert.assertEquals(f.nodeIds[1], nodes.get(4).getId()); - Assert.assertEquals(f.nodeIds[2], nodes.get(5).getId()); - Assert.assertEquals(f.nodeIds[3], nodes.get(6).getId()); + Assertions.assertEquals(7, nodes.size()); + Assertions.assertEquals(f.nodeIds[4], nodes.get(0).getId()); + Assertions.assertEquals(f.nodeIds[5], nodes.get(1).getId()); + Assertions.assertEquals(f.nodeIds[6], nodes.get(2).getId()); + Assertions.assertEquals(f.nodeIds[0], nodes.get(3).getId()); + Assertions.assertEquals(f.nodeIds[1], nodes.get(4).getId()); + Assertions.assertEquals(f.nodeIds[2], nodes.get(5).getId()); + Assertions.assertEquals(f.nodeIds[3], nodes.get(6).getId()); } @Test @@ -160,29 +160,29 @@ void testGetLinksFromNodes() { ArrayList nodes = new ArrayList(); List links = RouteUtils.getLinksFromNodes(nodes); - Assert.assertEquals(0, links.size()); + Assertions.assertEquals(0, links.size()); nodes.add(f.network.getNodes().get(f.nodeIds[3])); links = RouteUtils.getLinksFromNodes(nodes); - Assert.assertEquals(0, links.size()); + Assertions.assertEquals(0, links.size()); nodes.add(f.network.getNodes().get(f.nodeIds[4])); links = RouteUtils.getLinksFromNodes(nodes); - Assert.assertEquals(1, links.size()); - Assert.assertEquals(f.linkIds[3], links.get(0).getId()); + Assertions.assertEquals(1, links.size()); + Assertions.assertEquals(f.linkIds[3], links.get(0).getId()); nodes.add(f.network.getNodes().get(f.nodeIds[5])); links = RouteUtils.getLinksFromNodes(nodes); - Assert.assertEquals(2, links.size()); - Assert.assertEquals(f.linkIds[3], links.get(0).getId()); - Assert.assertEquals(f.linkIds[4], links.get(1).getId()); + Assertions.assertEquals(2, links.size()); + Assertions.assertEquals(f.linkIds[3], links.get(0).getId()); + Assertions.assertEquals(f.linkIds[4], links.get(1).getId()); nodes.add(0, f.network.getNodes().get(f.nodeIds[2])); links = RouteUtils.getLinksFromNodes(nodes); - Assert.assertEquals(3, links.size()); - Assert.assertEquals(f.linkIds[2], links.get(0).getId()); - Assert.assertEquals(f.linkIds[3], links.get(1).getId()); - Assert.assertEquals(f.linkIds[4], links.get(2).getId()); + Assertions.assertEquals(3, links.size()); + Assertions.assertEquals(f.linkIds[2], links.get(0).getId()); + Assertions.assertEquals(f.linkIds[3], links.get(1).getId()); + Assertions.assertEquals(f.linkIds[4], links.get(2).getId()); } @Test @@ -194,11 +194,11 @@ void testGetSubRoute() { route.setLinkIds(f.linkIds[0], linkIds, f.linkIds[5]); NetworkRoute subRoute = RouteUtils.getSubRoute(route, f.network.getNodes().get(f.nodeIds[3]), f.network.getNodes().get(f.nodeIds[5]), f.network); - Assert.assertEquals(2, subRoute.getLinkIds().size()); - Assert.assertEquals(f.linkIds[2], subRoute.getStartLinkId()); - Assert.assertEquals(f.linkIds[3], subRoute.getLinkIds().get(0)); - Assert.assertEquals(f.linkIds[4], subRoute.getLinkIds().get(1)); - Assert.assertEquals(f.linkIds[5], subRoute.getEndLinkId()); + Assertions.assertEquals(2, subRoute.getLinkIds().size()); + Assertions.assertEquals(f.linkIds[2], subRoute.getStartLinkId()); + Assertions.assertEquals(f.linkIds[3], subRoute.getLinkIds().get(0)); + Assertions.assertEquals(f.linkIds[4], subRoute.getLinkIds().get(1)); + Assertions.assertEquals(f.linkIds[5], subRoute.getEndLinkId()); } @Test @@ -210,13 +210,13 @@ void testGetSubRoute_fullRoute() { route.setLinkIds(f.linkIds[0], linkIds, f.linkIds[5]); NetworkRoute subRoute = RouteUtils.getSubRoute(route, f.network.getNodes().get(f.nodeIds[1]), f.network.getNodes().get(f.nodeIds[5]), f.network); - Assert.assertEquals(4, subRoute.getLinkIds().size()); - Assert.assertEquals(f.linkIds[0], subRoute.getStartLinkId()); - Assert.assertEquals(f.linkIds[1], subRoute.getLinkIds().get(0)); - Assert.assertEquals(f.linkIds[2], subRoute.getLinkIds().get(1)); - Assert.assertEquals(f.linkIds[3], subRoute.getLinkIds().get(2)); - Assert.assertEquals(f.linkIds[4], subRoute.getLinkIds().get(3)); - Assert.assertEquals(f.linkIds[5], subRoute.getEndLinkId()); + Assertions.assertEquals(4, subRoute.getLinkIds().size()); + Assertions.assertEquals(f.linkIds[0], subRoute.getStartLinkId()); + Assertions.assertEquals(f.linkIds[1], subRoute.getLinkIds().get(0)); + Assertions.assertEquals(f.linkIds[2], subRoute.getLinkIds().get(1)); + Assertions.assertEquals(f.linkIds[3], subRoute.getLinkIds().get(2)); + Assertions.assertEquals(f.linkIds[4], subRoute.getLinkIds().get(3)); + Assertions.assertEquals(f.linkIds[5], subRoute.getEndLinkId()); } @Test @@ -228,9 +228,9 @@ void testGetSubRoute_emptySubRoute() { route.setLinkIds(f.linkIds[0], linkIds, f.linkIds[5]); NetworkRoute subRoute = RouteUtils.getSubRoute(route, f.network.getNodes().get(f.nodeIds[4]), f.network.getNodes().get(f.nodeIds[4]), f.network); - Assert.assertEquals(0, subRoute.getLinkIds().size()); - Assert.assertEquals(f.linkIds[3], subRoute.getStartLinkId()); - Assert.assertEquals(f.linkIds[4], subRoute.getEndLinkId()); + Assertions.assertEquals(0, subRoute.getLinkIds().size()); + Assertions.assertEquals(f.linkIds[3], subRoute.getStartLinkId()); + Assertions.assertEquals(f.linkIds[4], subRoute.getEndLinkId()); } @Test @@ -242,9 +242,9 @@ void testGetSubRoute_sameStartEnd() { route.setLinkIds(f.linkIds[0], linkIds, f.linkIds[5]); NetworkRoute subRoute = RouteUtils.getSubRoute(route, f.network.getNodes().get(f.nodeIds[5]), f.network.getNodes().get(f.nodeIds[4]), f.network); - Assert.assertEquals(0, subRoute.getLinkIds().size()); - Assert.assertEquals(f.linkIds[4], subRoute.getStartLinkId()); - Assert.assertEquals(f.linkIds[4], subRoute.getEndLinkId()); + Assertions.assertEquals(0, subRoute.getLinkIds().size()); + Assertions.assertEquals(f.linkIds[4], subRoute.getStartLinkId()); + Assertions.assertEquals(f.linkIds[4], subRoute.getEndLinkId()); } @Test @@ -260,13 +260,13 @@ void testCalcDistance() { List> linkIds = new ArrayList>(); Collections.addAll(linkIds, f.linkIds[1], f.linkIds[2], f.linkIds[3]); route.setLinkIds(f.linkIds[0], linkIds, f.linkIds[4]); - Assert.assertEquals(900.0, RouteUtils.calcDistanceExcludingStartEndLink(route, f.network), MatsimTestUtils.EPSILON); - Assert.assertEquals(1400.0, RouteUtils.calcDistance(route, 1.0, 1.0, f.network), MatsimTestUtils.EPSILON); + Assertions.assertEquals(900.0, RouteUtils.calcDistanceExcludingStartEndLink(route, f.network), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1400.0, RouteUtils.calcDistance(route, 1.0, 1.0, f.network), MatsimTestUtils.EPSILON); // modify the route linkIds.add(f.linkIds[4]); route.setLinkIds(f.linkIds[0], linkIds, f.linkIds[5]); - Assert.assertEquals(1400.0, RouteUtils.calcDistanceExcludingStartEndLink(route, f.network), MatsimTestUtils.EPSILON); - Assert.assertEquals(2000.0, RouteUtils.calcDistance(route, 1.0, 1.0, f.network), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1400.0, RouteUtils.calcDistanceExcludingStartEndLink(route, f.network), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2000.0, RouteUtils.calcDistance(route, 1.0, 1.0, f.network), MatsimTestUtils.EPSILON); } @Test @@ -281,9 +281,9 @@ void testCalcDistance_sameStartEndRoute() { NetworkRoute route = RouteUtils.createLinkNetworkRouteImpl(f.linkIds[3], f.linkIds[3]); List> linkIds = new ArrayList>(); route.setLinkIds(f.linkIds[3], linkIds, f.linkIds[3]); - Assert.assertEquals(0.0, RouteUtils.calcDistanceExcludingStartEndLink(route, f.network), MatsimTestUtils.EPSILON); - Assert.assertEquals(0.0, RouteUtils.calcDistance(route, 1.0, 1.0, f.network), MatsimTestUtils.EPSILON); - Assert.assertEquals(400.0, RouteUtils.calcDistance(route, 0.0, 1.0, f.network), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, RouteUtils.calcDistanceExcludingStartEndLink(route, f.network), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, RouteUtils.calcDistance(route, 1.0, 1.0, f.network), MatsimTestUtils.EPSILON); + Assertions.assertEquals(400.0, RouteUtils.calcDistance(route, 0.0, 1.0, f.network), MatsimTestUtils.EPSILON); } @Test @@ -298,8 +298,8 @@ void testCalcDistance_subsequentStartEndRoute() { NetworkRoute route = RouteUtils.createLinkNetworkRouteImpl(f.linkIds[2], f.linkIds[3]); List> linkIds = new ArrayList>(); route.setLinkIds(f.linkIds[2], linkIds, f.linkIds[3]); - Assert.assertEquals(0.0, RouteUtils.calcDistanceExcludingStartEndLink(route, f.network), MatsimTestUtils.EPSILON); - Assert.assertEquals(400.0, RouteUtils.calcDistance(route, 1.0, 1.0, f.network), MatsimTestUtils.EPSILON); + Assertions.assertEquals(0.0, RouteUtils.calcDistanceExcludingStartEndLink(route, f.network), MatsimTestUtils.EPSILON); + Assertions.assertEquals(400.0, RouteUtils.calcDistance(route, 1.0, 1.0, f.network), MatsimTestUtils.EPSILON); } @Test @@ -315,8 +315,8 @@ void testCalcDistance_oneLinkRoute() { List> linkIds = new ArrayList>(); linkIds.add(f.linkIds[3]); route.setLinkIds(f.linkIds[2], linkIds, f.linkIds[4]); - Assert.assertEquals(400.0, RouteUtils.calcDistanceExcludingStartEndLink(route, f.network), MatsimTestUtils.EPSILON); - Assert.assertEquals(900.0, RouteUtils.calcDistance(route, 1.0, 1.0, f.network), MatsimTestUtils.EPSILON); + Assertions.assertEquals(400.0, RouteUtils.calcDistanceExcludingStartEndLink(route, f.network), MatsimTestUtils.EPSILON); + Assertions.assertEquals(900.0, RouteUtils.calcDistance(route, 1.0, 1.0, f.network), MatsimTestUtils.EPSILON); } private static class Fixture { diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/StringUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/StringUtilsTest.java index b4048bb20f6..f7b918995f6 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/StringUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/StringUtilsTest.java @@ -20,7 +20,7 @@ package org.matsim.core.utils.misc; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -47,9 +47,9 @@ void testExplode() { for (String test : testStrings) { String[] resultExplode = StringUtils.explode(test, ':'); String[] resultSplit = test.split(":"); - assertEquals("Different result lengths with test string \"" + test + "\"", resultSplit.length, resultExplode.length); + assertEquals(resultSplit.length, resultExplode.length, "Different result lengths with test string \"" + test + "\""); for (int i = 0; i < resultExplode.length; i++) { - assertEquals("Different result part " + i + " when testing string: \"" + test + "\"", resultSplit[i], resultExplode[i]); + assertEquals(resultSplit[i], resultExplode[i], "Different result part " + i + " when testing string: \"" + test + "\""); } } } @@ -64,9 +64,9 @@ void testExplodeLimit() { for (String test : testStrings) { String[] resultExplode = StringUtils.explode(test, ':', 3); String[] resultSplit = test.split(":", 3); - assertEquals("Different result lengths with test string \"" + test + "\"", resultSplit.length, resultExplode.length); + assertEquals(resultSplit.length, resultExplode.length, "Different result lengths with test string \"" + test + "\""); for (int i = 0; i < resultExplode.length; i++) { - assertEquals("Different result part " + i + " when testing string: \"" + test + "\"", resultSplit[i], resultExplode[i]); + assertEquals(resultSplit[i], resultExplode[i], "Different result part " + i + " when testing string: \"" + test + "\""); } } } diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/TimeTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/TimeTest.java index 1654c1330ba..9f8d3049d58 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/TimeTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/TimeTest.java @@ -20,8 +20,8 @@ package org.matsim.core.utils.misc; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import org.junit.jupiter.api.Test; diff --git a/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java b/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java index 51722441ce6..d771d585de9 100644 --- a/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java @@ -20,11 +20,11 @@ package org.matsim.core.utils.timing; -import static org.junit.Assert.assertEquals; - import java.util.List; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; diff --git a/matsim/src/test/java/org/matsim/counts/CountTest.java b/matsim/src/test/java/org/matsim/counts/CountTest.java index 7b5194b49c9..641e9dd4c73 100644 --- a/matsim/src/test/java/org/matsim/counts/CountTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountTest.java @@ -20,11 +20,11 @@ package org.matsim.counts; -import static org.junit.Assert.assertTrue; - import java.util.Iterator; import org.junit.Before; + +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -47,15 +47,15 @@ public void setUp() throws Exception { void testCreateVolume() { Count count = counts.createAndAddCount(Id.create(0, Link.class), "1"); Volume volume = count.createVolume(1, 100.0); - assertTrue("Creation and initialization of volume failed", volume.getHourOfDayStartingWithOne()==1); - assertTrue("Creation and initialization of volume failed", volume.getValue()==100.0); + assertTrue(volume.getHourOfDayStartingWithOne()==1, "Creation and initialization of volume failed"); + assertTrue(volume.getValue()==100.0, "Creation and initialization of volume failed"); } @Test void testGetVolume() { Count count = counts.createAndAddCount(Id.create(0, Link.class), "1"); count.createVolume(1, 100.0); - assertTrue("Getting volume failed", count.getVolume(1).getValue() == 100.0); + assertTrue(count.getVolume(1).getValue() == 100.0, "Getting volume failed"); } @Test @@ -66,7 +66,7 @@ void testGetVolumes() { Iterator vol_it = count.getVolumes().values().iterator(); while (vol_it.hasNext()) { Volume v = vol_it.next(); - assertTrue("Getting volumes failed", v.getValue() == 100.0); + assertTrue(v.getValue() == 100.0, "Getting volumes failed"); } } diff --git a/matsim/src/test/java/org/matsim/counts/CountsComparisonAlgorithmTest.java b/matsim/src/test/java/org/matsim/counts/CountsComparisonAlgorithmTest.java index 7e652c0e25a..8c65712e935 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsComparisonAlgorithmTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsComparisonAlgorithmTest.java @@ -20,11 +20,11 @@ package org.matsim.counts; -import static org.junit.Assert.assertEquals; - import java.util.List; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.counts.algorithms.CountsComparisonAlgorithm; import org.matsim.testcases.MatsimTestUtils; @@ -47,7 +47,7 @@ void testCompare() { int cnt=0; for (CountSimComparison csc : csc_list) { - assertEquals("Wrong sim value set", 2*cnt, csc.getSimulationValue(), 0.0); + assertEquals(2*cnt, csc.getSimulationValue(), 0.0, "Wrong sim value set"); cnt++; cnt=cnt%24; }//while @@ -63,7 +63,7 @@ void testDistanceFilter() { cca.run(); List csc_list = cca.getComparison(); - assertEquals("Distance filter not working", 0, csc_list.size()); + assertEquals(0, csc_list.size(), "Distance filter not working"); } } diff --git a/matsim/src/test/java/org/matsim/counts/CountsControlerListenerTest.java b/matsim/src/test/java/org/matsim/counts/CountsControlerListenerTest.java index 9327948fec4..db2a0498c3e 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsControlerListenerTest.java @@ -26,7 +26,7 @@ import jakarta.inject.Inject; import jakarta.inject.Singleton; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -68,184 +68,184 @@ void testUseVolumesOfIteration() { CountsControlerListener ccl = new CountsControlerListener(config.global(), scenario.getNetwork(), config.controller(), config.counts(), null, null, null); // test defaults - Assert.assertEquals(10, config.counts().getWriteCountsInterval()); - Assert.assertEquals(5, config.counts().getAverageCountsOverIterations()); + Assertions.assertEquals(10, config.counts().getWriteCountsInterval()); + Assertions.assertEquals(5, config.counts().getAverageCountsOverIterations()); // now the real tests - Assert.assertFalse(ccl.useVolumesOfIteration(0, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(1, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(2, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(3, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(4, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(5, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(6, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(7, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(8, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(9, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(10, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(11, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(12, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(13, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(14, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(15, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(16, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(17, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(18, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(19, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(20, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(21, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(0, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(1, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(2, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(3, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(4, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(5, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(6, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(7, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(8, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(9, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(10, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(11, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(12, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(13, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(14, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(15, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(16, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(17, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(18, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(19, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(20, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(21, 0)); // change some values config.counts().setWriteCountsInterval(8); config.counts().setAverageCountsOverIterations(2); - Assert.assertFalse(ccl.useVolumesOfIteration(0, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(1, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(2, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(3, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(4, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(5, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(6, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(7, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(8, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(9, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(10, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(11, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(12, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(13, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(14, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(15, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(16, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(17, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(18, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(19, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(20, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(21, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(0, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(1, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(2, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(3, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(4, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(5, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(6, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(7, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(8, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(9, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(10, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(11, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(12, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(13, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(14, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(15, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(16, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(17, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(18, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(19, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(20, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(21, 0)); // change some values: averaging = 1 config.counts().setWriteCountsInterval(5); config.counts().setAverageCountsOverIterations(1); - Assert.assertTrue(ccl.useVolumesOfIteration(0, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(1, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(2, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(3, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(4, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(5, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(6, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(7, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(8, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(9, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(10, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(11, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(12, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(13, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(14, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(15, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(16, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(17, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(18, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(19, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(20, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(21, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(0, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(1, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(2, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(3, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(4, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(5, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(6, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(7, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(8, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(9, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(10, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(11, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(12, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(13, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(14, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(15, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(16, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(17, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(18, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(19, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(20, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(21, 0)); // change some values: averaging = 0 config.counts().setWriteCountsInterval(5); config.counts().setAverageCountsOverIterations(0); - Assert.assertTrue(ccl.useVolumesOfIteration(0, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(1, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(2, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(3, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(4, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(5, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(6, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(7, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(8, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(9, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(10, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(11, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(12, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(13, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(14, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(15, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(16, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(17, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(18, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(19, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(20, 0)); - Assert.assertFalse(ccl.useVolumesOfIteration(21, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(0, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(1, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(2, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(3, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(4, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(5, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(6, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(7, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(8, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(9, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(10, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(11, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(12, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(13, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(14, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(15, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(16, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(17, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(18, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(19, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(20, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(21, 0)); // change some values: interval equal averaging config.counts().setWriteCountsInterval(5); config.counts().setAverageCountsOverIterations(5); - Assert.assertFalse(ccl.useVolumesOfIteration(0, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(1, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(2, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(3, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(4, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(5, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(6, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(7, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(8, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(9, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(10, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(11, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(12, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(13, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(14, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(15, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(16, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(17, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(18, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(19, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(20, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(21, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(0, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(1, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(2, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(3, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(4, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(5, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(6, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(7, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(8, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(9, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(10, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(11, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(12, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(13, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(14, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(15, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(16, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(17, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(18, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(19, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(20, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(21, 0)); // change some values: averaging > interval config.counts().setWriteCountsInterval(5); config.counts().setAverageCountsOverIterations(6); - Assert.assertFalse(ccl.useVolumesOfIteration(0, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(1, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(2, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(3, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(4, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(5, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(6, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(7, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(8, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(9, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(10, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(11, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(12, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(13, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(14, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(15, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(16, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(17, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(18, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(19, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(20, 0)); - Assert.assertTrue(ccl.useVolumesOfIteration(21, 0)); + Assertions.assertFalse(ccl.useVolumesOfIteration(0, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(1, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(2, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(3, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(4, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(5, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(6, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(7, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(8, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(9, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(10, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(11, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(12, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(13, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(14, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(15, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(16, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(17, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(18, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(19, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(20, 0)); + Assertions.assertTrue(ccl.useVolumesOfIteration(21, 0)); // change some values: different firstIteration config.counts().setWriteCountsInterval(5); config.counts().setAverageCountsOverIterations(3); - Assert.assertFalse(ccl.useVolumesOfIteration(4, 4)); - Assert.assertFalse(ccl.useVolumesOfIteration(5, 4)); - Assert.assertFalse(ccl.useVolumesOfIteration(6, 4)); - Assert.assertFalse(ccl.useVolumesOfIteration(7, 4)); - Assert.assertTrue(ccl.useVolumesOfIteration(8, 4)); - Assert.assertTrue(ccl.useVolumesOfIteration(9, 4)); - Assert.assertTrue(ccl.useVolumesOfIteration(10, 4)); - Assert.assertFalse(ccl.useVolumesOfIteration(11, 4)); - Assert.assertFalse(ccl.useVolumesOfIteration(12, 4)); - Assert.assertTrue(ccl.useVolumesOfIteration(13, 4)); - Assert.assertTrue(ccl.useVolumesOfIteration(14, 4)); - Assert.assertTrue(ccl.useVolumesOfIteration(15, 4)); - Assert.assertFalse(ccl.useVolumesOfIteration(16, 4)); - Assert.assertFalse(ccl.useVolumesOfIteration(17, 4)); - Assert.assertTrue(ccl.useVolumesOfIteration(18, 4)); - Assert.assertTrue(ccl.useVolumesOfIteration(19, 4)); - Assert.assertTrue(ccl.useVolumesOfIteration(20, 4)); - Assert.assertFalse(ccl.useVolumesOfIteration(21, 4)); + Assertions.assertFalse(ccl.useVolumesOfIteration(4, 4)); + Assertions.assertFalse(ccl.useVolumesOfIteration(5, 4)); + Assertions.assertFalse(ccl.useVolumesOfIteration(6, 4)); + Assertions.assertFalse(ccl.useVolumesOfIteration(7, 4)); + Assertions.assertTrue(ccl.useVolumesOfIteration(8, 4)); + Assertions.assertTrue(ccl.useVolumesOfIteration(9, 4)); + Assertions.assertTrue(ccl.useVolumesOfIteration(10, 4)); + Assertions.assertFalse(ccl.useVolumesOfIteration(11, 4)); + Assertions.assertFalse(ccl.useVolumesOfIteration(12, 4)); + Assertions.assertTrue(ccl.useVolumesOfIteration(13, 4)); + Assertions.assertTrue(ccl.useVolumesOfIteration(14, 4)); + Assertions.assertTrue(ccl.useVolumesOfIteration(15, 4)); + Assertions.assertFalse(ccl.useVolumesOfIteration(16, 4)); + Assertions.assertFalse(ccl.useVolumesOfIteration(17, 4)); + Assertions.assertTrue(ccl.useVolumesOfIteration(18, 4)); + Assertions.assertTrue(ccl.useVolumesOfIteration(19, 4)); + Assertions.assertTrue(ccl.useVolumesOfIteration(20, 4)); + Assertions.assertFalse(ccl.useVolumesOfIteration(21, 4)); } @Test @@ -274,14 +274,14 @@ public void install() { config.controller().setWritePlansInterval(0); controler.run(); - Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.0/0.countscompare.txt").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.1/1.countscompare.txt").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.2/2.countscompare.txt").exists()); - Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompare.txt").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.4/4.countscompare.txt").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.5/5.countscompare.txt").exists()); - Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.6/6.countscompare.txt").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.7/7.countscompare.txt").exists()); + Assertions.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.0/0.countscompare.txt").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.1/1.countscompare.txt").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.2/2.countscompare.txt").exists()); + Assertions.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompare.txt").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.4/4.countscompare.txt").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.5/5.countscompare.txt").exists()); + Assertions.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.6/6.countscompare.txt").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.7/7.countscompare.txt").exists()); } @Test @@ -312,17 +312,17 @@ public void install() { config.controller().setWritePlansInterval(0); controler.run(); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.0/0.countscompareAWTV.txt").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.1/1.countscompareAWTV.txt").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.2/2.countscompareAWTV.txt").exists()); - Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.4/4.countscompareAWTV.txt").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.5/5.countscompareAWTV.txt").exists()); - Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.6/6.countscompareAWTV.txt").exists()); - Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.7/7.countscompareAWTV.txt").exists()); - - Assert.assertEquals(3.5, getVolume(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); - Assert.assertEquals(6.5, getVolume(config.controller().getOutputDirectory() + "ITERS/it.6/6.countscompareAWTV.txt"), 1e-8); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.0/0.countscompareAWTV.txt").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.1/1.countscompareAWTV.txt").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.2/2.countscompareAWTV.txt").exists()); + Assertions.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.4/4.countscompareAWTV.txt").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.5/5.countscompareAWTV.txt").exists()); + Assertions.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.6/6.countscompareAWTV.txt").exists()); + Assertions.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.7/7.countscompareAWTV.txt").exists()); + + Assertions.assertEquals(3.5, getVolume(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); + Assertions.assertEquals(6.5, getVolume(config.controller().getOutputDirectory() + "ITERS/it.6/6.countscompareAWTV.txt"), 1e-8); } @Test @@ -342,25 +342,25 @@ void testFilterAnalyzedModes() throws IOException { config.controller().setLastIteration(3); createAndRunControler(config); - Assert.assertEquals(150, getVolume(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); + Assertions.assertEquals(150, getVolume(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); // enable modes filtering and count only car cConfig.setAnalyzedModes(TransportMode.car); cConfig.setFilterModes(true); createAndRunControler(config); - Assert.assertEquals(100, getVolume(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); + Assertions.assertEquals(100, getVolume(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); // enable modes filtering and count only walk cConfig.setAnalyzedModes(TransportMode.walk); cConfig.setFilterModes(true); createAndRunControler(config); - Assert.assertEquals(50, getVolume(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); + Assertions.assertEquals(50, getVolume(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); // enable modes filtering and count only bike cConfig.setAnalyzedModes(TransportMode.bike); cConfig.setFilterModes(true); createAndRunControler(config); - Assert.assertEquals(0, getVolume(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); + Assertions.assertEquals(0, getVolume(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); } diff --git a/matsim/src/test/java/org/matsim/counts/CountsErrorGraphTest.java b/matsim/src/test/java/org/matsim/counts/CountsErrorGraphTest.java index 9b517b8e4e1..bdbb1f2f297 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsErrorGraphTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsErrorGraphTest.java @@ -20,7 +20,7 @@ package org.matsim.counts; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -39,6 +39,6 @@ void testCreateChart() { fixture.setUp(); BoxPlotErrorGraph eg = new BoxPlotErrorGraph(fixture.ceateCountSimCompList(), 1, "testCreateChart", "testCreateChart"); - assertNotNull("No graph is created", eg.createChart(0)); + assertNotNull(eg.createChart(0), "No graph is created"); } } diff --git a/matsim/src/test/java/org/matsim/counts/CountsHtmlAndGraphsWriterTest.java b/matsim/src/test/java/org/matsim/counts/CountsHtmlAndGraphsWriterTest.java index 853f4d548e7..27a8bc1a51c 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsHtmlAndGraphsWriterTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsHtmlAndGraphsWriterTest.java @@ -20,7 +20,7 @@ package org.matsim.counts; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/counts/CountsLoadCurveGraphTest.java b/matsim/src/test/java/org/matsim/counts/CountsLoadCurveGraphTest.java index b8dc6aecacb..9c8e27e0039 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsLoadCurveGraphTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsLoadCurveGraphTest.java @@ -20,7 +20,7 @@ package org.matsim.counts; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -39,6 +39,6 @@ void testCreateChart() { fixture.setUp(); CountsLoadCurveGraph eg = new CountsLoadCurveGraph(fixture.ceateCountSimCompList(), 1, "testCreateChart"); - assertNotNull("No graph is created", eg.createChart(0)); + assertNotNull(eg.createChart(0), "No graph is created"); } } diff --git a/matsim/src/test/java/org/matsim/counts/CountsParserTest.java b/matsim/src/test/java/org/matsim/counts/CountsParserTest.java index 5dabdc4ac08..f1d180a0fab 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsParserTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsParserTest.java @@ -20,7 +20,7 @@ package org.matsim.counts; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -44,9 +44,9 @@ void testSEElementCounts() throws SAXException { reader.startElement("", "counts", "counts", attributeFactory.createCountsAttributes()); - assertEquals("Counts attribute setting failed", "testName", counts.getName()); - assertEquals("Counts attribute setting failed", "testDesc", counts.getDescription()); - assertEquals("Counts attribute setting failed", 2000, counts.getYear()); + assertEquals("testName", counts.getName(), "Counts attribute setting failed"); + assertEquals("testDesc", counts.getDescription(), "Counts attribute setting failed"); + assertEquals(2000, counts.getYear(), "Counts attribute setting failed"); try { reader.endElement("", "counts", "counts"); } catch (SAXException e) { @@ -65,8 +65,8 @@ void testSEElementCountWithoutCoords() throws SAXException { reader.startElement("", "count", "count", attributeFactory.createCountAttributes()); Count count = counts.getCount(Id.create(1, Link.class)); - assertEquals("Count attribute setting failed", "testNr", count.getCsLabel()); - assertNull("Count attributes x,y should not be set", count.getCoord()); + assertEquals("testNr", count.getCsLabel(), "Count attribute setting failed"); + assertNull(count.getCoord(), "Count attributes x,y should not be set"); reader.endElement("", "count", "count"); reader.endElement("", "counts", "counts"); @@ -83,9 +83,9 @@ void testSEElementCountWithCoords() throws SAXException { reader.startElement("", "count", "count", attributeFactory.createCountAttributesWithCoords()); Count count = counts.getCount(Id.create(1, Link.class)); - assertNotNull("Count attribute x,y setting failed", count.getCoord()); - assertEquals("Count attribute x setting failed", 123.456, count.getCoord().getX(), MatsimTestUtils.EPSILON); - assertEquals("Count attribute y setting failed", 987.654, count.getCoord().getY(), MatsimTestUtils.EPSILON); + assertNotNull(count.getCoord(), "Count attribute x,y setting failed"); + assertEquals(123.456, count.getCoord().getX(), MatsimTestUtils.EPSILON, "Count attribute x setting failed"); + assertEquals(987.654, count.getCoord().getY(), MatsimTestUtils.EPSILON, "Count attribute y setting failed"); reader.endElement("", "count", "count"); reader.endElement("", "counts", "counts"); @@ -102,7 +102,7 @@ void testSEElementVolume() throws SAXException { reader.startElement("", "count", "count", attributeFactory.createCountAttributes()); reader.startElement("", "volume", "volume", attributeFactory.createVolumeAttributes()); - assertEquals("Volume attribute setting failed", 100.0, counts.getCount(Id.create(1, Link.class)).getVolume(1).getValue(), MatsimTestUtils.EPSILON); + assertEquals(100.0, counts.getCount(Id.create(1, Link.class)).getVolume(1).getValue(), MatsimTestUtils.EPSILON, "Volume attribute setting failed"); reader.endElement("", "volume", "volume"); reader.endElement("", "count", "count"); diff --git a/matsim/src/test/java/org/matsim/counts/CountsParserWriterTest.java b/matsim/src/test/java/org/matsim/counts/CountsParserWriterTest.java index 6c7e2a9e76b..06fba65ea32 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsParserWriterTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsParserWriterTest.java @@ -26,7 +26,7 @@ import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -54,21 +54,21 @@ void testParserWriter() { // test if required fields of schema are filled out: // Counts: - Assert.assertNotNull(fixture.counts.getCounts()); - Assert.assertTrue(fixture.counts.getYear()>2000); - Assert.assertNotNull(fixture.counts.getName()); + Assertions.assertNotNull(fixture.counts.getCounts()); + Assertions.assertTrue(fixture.counts.getYear()>2000); + Assertions.assertNotNull(fixture.counts.getName()); // Count & Volume Iterator c_it = fixture.counts.getCounts().values().iterator(); while (c_it.hasNext()) { Count c = c_it.next(); - Assert.assertNotNull(c.getId()); + Assertions.assertNotNull(c.getId()); Iterator vol_it = c.getVolumes().values().iterator(); while (vol_it.hasNext()) { Volume v = vol_it.next(); - Assert.assertTrue(v.getHourOfDayStartingWithOne()>0); - Assert.assertTrue(v.getValue()>=0.0); + Assertions.assertTrue(v.getHourOfDayStartingWithOne()>0); + Assertions.assertTrue(v.getValue()>=0.0); }//while }//while @@ -80,7 +80,7 @@ void testParserWriter() { CountsWriter counts_writer = new CountsWriter(fixture.counts); counts_writer.write(filename); File f = new File(filename); - Assert.assertTrue(f.length() > 0.0); + Assertions.assertTrue(f.length() > 0.0); } /** @@ -95,12 +95,12 @@ void testWriteParse_nameIsNull() throws SAXException, ParserConfigurationExcepti CountsFixture f = new CountsFixture(); f.setUp(); f.counts.setName(null); - Assert.assertNull(f.counts.getName()); + Assertions.assertNull(f.counts.getName()); String filename = this.utils.getOutputDirectory() + "counts.xml"; new CountsWriterV1(f.counts).write(filename); Counts counts2 = new Counts(); new CountsReaderMatsimV1(counts2).readFile(filename); - Assert.assertEquals("", counts2.getName()); + Assertions.assertEquals("", counts2.getName()); } } diff --git a/matsim/src/test/java/org/matsim/counts/CountsReaderHandlerImplV1Test.java b/matsim/src/test/java/org/matsim/counts/CountsReaderHandlerImplV1Test.java index d4214f2485f..c54ed8961c0 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsReaderHandlerImplV1Test.java +++ b/matsim/src/test/java/org/matsim/counts/CountsReaderHandlerImplV1Test.java @@ -20,7 +20,7 @@ package org.matsim.counts; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -41,9 +41,9 @@ void testSECounts() { CountsReaderMatsimV1 reader = new CountsReaderMatsimV1(counts); reader.startTag("counts", attributeFactory.createCountsAttributes(), null); - assertEquals("Counts attribute setting failed", "testName", counts.getName()); - assertEquals("Counts attribute setting failed", "testDesc", counts.getDescription()); - assertEquals("Counts attribute setting failed", 2000, counts.getYear()); + assertEquals("testName", counts.getName(), "Counts attribute setting failed"); + assertEquals("testDesc", counts.getDescription(), "Counts attribute setting failed"); + assertEquals(2000, counts.getYear(), "Counts attribute setting failed"); } @Test @@ -55,7 +55,7 @@ void testSECount() { reader.startTag("counts", attributeFactory.createCountsAttributes(), null); reader.startTag("count", attributeFactory.createCountAttributes(), null); - assertEquals("Count attribute setting failed", "testNr", counts.getCount(Id.create(1, Link.class)).getCsLabel()); + assertEquals("testNr", counts.getCount(Id.create(1, Link.class)).getCsLabel(), "Count attribute setting failed"); } @Test @@ -67,6 +67,6 @@ void testSEVolume() { reader.startTag("count", attributeFactory.createCountAttributes(), null); reader.startTag("volume", attributeFactory.createVolumeAttributes(), null); - assertEquals("Volume attribute setting failed", 100.0, counts.getCount(Id.create(1, Link.class)).getVolume(1).getValue(), MatsimTestUtils.EPSILON); + assertEquals(100.0, counts.getCount(Id.create(1, Link.class)).getVolume(1).getValue(), MatsimTestUtils.EPSILON, "Volume attribute setting failed"); } } diff --git a/matsim/src/test/java/org/matsim/counts/CountsReprojectionIOTest.java b/matsim/src/test/java/org/matsim/counts/CountsReprojectionIOTest.java index 860767a6553..6badf9a2391 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsReprojectionIOTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsReprojectionIOTest.java @@ -23,7 +23,7 @@ import com.google.inject.Key; import com.google.inject.TypeLiteral; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -38,7 +38,7 @@ import org.matsim.core.utils.geometry.transformations.TransformationFactory; import org.matsim.testcases.MatsimTestUtils; - /** + /** * @author thibautd */ public class CountsReprojectionIOTest { @@ -108,16 +108,16 @@ void testWithControlerAndConfigParameters() { final Coord originalCoord = originalCounts.getCount( id ).getCoord(); final Coord internalCoord = internalCounts.getCount( id ).getCoord(); - Assert.assertNotEquals( - "No coordinates transform performed!", + Assertions.assertNotEquals( originalCoord.getX(), internalCoord.getX(), - epsilon ); - Assert.assertNotEquals( - "No coordinates transform performed!", + epsilon, + "No coordinates transform performed!" ); + Assertions.assertNotEquals( originalCoord.getY(), internalCoord.getY(), - epsilon ); + epsilon, + "No coordinates transform performed!" ); } @@ -128,41 +128,41 @@ void testWithControlerAndConfigParameters() { final Coord originalCoord = originalCounts.getCount( id ).getCoord(); final Coord dumpedCoord = dumpedCounts.getCount( id ).getCoord(); - Assert.assertEquals( - "coordinates were not reprojected for dump", + Assertions.assertEquals( originalCoord.getX(), dumpedCoord.getX(), - epsilon ); - Assert.assertEquals( - "coordinates were not reprojected for dump", + epsilon, + "coordinates were not reprojected for dump" ); + Assertions.assertEquals( originalCoord.getY(), dumpedCoord.getY(), - epsilon ); + epsilon, + "coordinates were not reprojected for dump" ); } } private void assertCountsAreReprojectedCorrectly( Counts originalCounts, Counts reprojectedCounts) { - Assert.assertEquals( - "unexpected number of counts", + Assertions.assertEquals( originalCounts.getCounts().size(), - reprojectedCounts.getCounts().size() ); + reprojectedCounts.getCounts().size(), + "unexpected number of counts" ); for ( Id id : originalCounts.getCounts().keySet() ) { final Coord original = originalCounts.getCount( id ).getCoord(); final Coord transformed = reprojectedCounts.getCount( id ).getCoord(); - Assert.assertEquals( - "wrong reprojected X value", + Assertions.assertEquals( original.getX() + 1000 , transformed.getX(), - MatsimTestUtils.EPSILON ); - Assert.assertEquals( - "wrong reprojected Y value", + MatsimTestUtils.EPSILON, + "wrong reprojected X value" ); + Assertions.assertEquals( original.getY() + 1000 , transformed.getY(), - MatsimTestUtils.EPSILON ); + MatsimTestUtils.EPSILON, + "wrong reprojected Y value" ); } } diff --git a/matsim/src/test/java/org/matsim/counts/CountsSimRealPerHourGraphTest.java b/matsim/src/test/java/org/matsim/counts/CountsSimRealPerHourGraphTest.java index 2df385e8ab3..c9d89bb8a8c 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsSimRealPerHourGraphTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsSimRealPerHourGraphTest.java @@ -20,7 +20,7 @@ package org.matsim.counts; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -39,6 +39,6 @@ void testCreateChart() { fixture.setUp(); CountsSimRealPerHourGraph eg = new CountsSimRealPerHourGraph(fixture.ceateCountSimCompList(), 1, "testCreateChart"); - assertNotNull("No graph is created", eg.createChart(0)); + assertNotNull(eg.createChart(0), "No graph is created"); } } diff --git a/matsim/src/test/java/org/matsim/counts/CountsTableWriterTest.java b/matsim/src/test/java/org/matsim/counts/CountsTableWriterTest.java index f373db66b6f..4fb0287175d 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsTableWriterTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsTableWriterTest.java @@ -20,12 +20,12 @@ package org.matsim.counts; -import static org.junit.Assert.assertTrue; - import java.io.File; import java.util.Locale; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.counts.algorithms.CountSimComparisonTableWriter; import org.matsim.counts.algorithms.CountsComparisonAlgorithm; diff --git a/matsim/src/test/java/org/matsim/counts/CountsTest.java b/matsim/src/test/java/org/matsim/counts/CountsTest.java index f8ee0015e52..3ce4092c295 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsTest.java @@ -20,7 +20,7 @@ package org.matsim.counts; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -38,6 +38,6 @@ public class CountsTest { void testGetCounts() { final Counts counts = new Counts(); counts.createAndAddCount(Id.create(0, Link.class), "1"); - assertEquals("Getting counts failed", 1, counts.getCounts().size()); + assertEquals(1, counts.getCounts().size(), "Getting counts failed"); } } diff --git a/matsim/src/test/java/org/matsim/counts/CountsV2Test.java b/matsim/src/test/java/org/matsim/counts/CountsV2Test.java index 3ee67c26678..85c211033ee 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsV2Test.java +++ b/matsim/src/test/java/org/matsim/counts/CountsV2Test.java @@ -1,7 +1,7 @@ package org.matsim.counts; import org.assertj.core.api.Assertions; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -66,10 +66,10 @@ void test_reader_writer() throws IOException { Assertions.assertThatNoException().isThrownBy(() -> reader.readFile(filename)); Map, MeasurementLocation> countMap = counts.getMeasureLocations(); - Assert.assertEquals(21, countMap.size()); + Assertions.assertEquals(21, countMap.size()); boolean onlyDailyValues = countMap.get(Id.create("12", Link.class)).getMeasurableForMode(Measurable.VOLUMES, TransportMode.car).getInterval() == 24 * 60; - Assert.assertFalse(onlyDailyValues); + Assertions.assertFalse(onlyDailyValues); assertThat(dummyCounts.getMeasurableTypes()) .isEqualTo(counts.getMeasurableTypes()); diff --git a/matsim/src/test/java/org/matsim/counts/MatsimCountsIOTest.java b/matsim/src/test/java/org/matsim/counts/MatsimCountsIOTest.java index 6f2da37f269..e1b45a3328a 100644 --- a/matsim/src/test/java/org/matsim/counts/MatsimCountsIOTest.java +++ b/matsim/src/test/java/org/matsim/counts/MatsimCountsIOTest.java @@ -21,14 +21,14 @@ package org.matsim.counts; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; - /** + /** * @author mrieser / Simunto GmbH */ public class MatsimCountsIOTest { @@ -77,7 +77,7 @@ void testReading_year0() { MatsimCountsReader reader = new MatsimCountsReader(counts); ByteArrayInputStream stream = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); reader.parse(stream); - Assert.assertEquals(1, counts.getCounts().size()); + Assertions.assertEquals(1, counts.getCounts().size()); } /** @@ -124,7 +124,7 @@ void testReading_year1padded() { MatsimCountsReader reader = new MatsimCountsReader(counts); ByteArrayInputStream stream = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); reader.parse(stream); - Assert.assertEquals(1, counts.getCounts().size()); + Assertions.assertEquals(1, counts.getCounts().size()); } @Test diff --git a/matsim/src/test/java/org/matsim/counts/OutputDelegateTest.java b/matsim/src/test/java/org/matsim/counts/OutputDelegateTest.java index c1c5e39c014..cbc377b6c15 100644 --- a/matsim/src/test/java/org/matsim/counts/OutputDelegateTest.java +++ b/matsim/src/test/java/org/matsim/counts/OutputDelegateTest.java @@ -20,8 +20,8 @@ package org.matsim.counts; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.util.List; @@ -57,13 +57,13 @@ void testOutputHtml() { new File(utils.getOutputDirectory() + "graphs").mkdir(); OutputDelegate outputDelegate=new OutputDelegate(utils.getOutputDirectory() + "graphs/"); outputDelegate.addSection(new Section("testOutPutAll")); - assertNotNull("No graph was created", sg.createChart(0)); + assertNotNull(sg.createChart(0), "No graph was created"); outputDelegate.addCountsGraph(sg); outputDelegate.outputHtml(); String filename = utils.getOutputDirectory() + "graphs/png/" + sg.getFilename() +".png"; File fPng = new File(filename); - assertTrue("The png output file " + filename + " doesn't exist", fPng.exists()); - assertTrue("The png output file " + filename + " is empty", fPng.length()>0.0); + assertTrue(fPng.exists(), "The png output file " + filename + " doesn't exist"); + assertTrue(fPng.length()>0.0, "The png output file " + filename + " is empty"); } } diff --git a/matsim/src/test/java/org/matsim/examples/EquilTest.java b/matsim/src/test/java/org/matsim/examples/EquilTest.java index caeaba1786c..ded2c6a9777 100644 --- a/matsim/src/test/java/org/matsim/examples/EquilTest.java +++ b/matsim/src/test/java/org/matsim/examples/EquilTest.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.runner.RunWith; @@ -102,6 +102,6 @@ void testEquil() { writer.closeFile(); final EventsFileComparator.Result result = new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( referenceFileName , eventsFileName ); - Assert.assertEquals("different event files.", EventsFileComparator.Result.FILES_ARE_EQUAL, result ); + Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, result, "different event files." ); } } diff --git a/matsim/src/test/java/org/matsim/examples/OnePercentBerlin10sIT.java b/matsim/src/test/java/org/matsim/examples/OnePercentBerlin10sIT.java index 5c3a02d326b..89237ec5b1a 100644 --- a/matsim/src/test/java/org/matsim/examples/OnePercentBerlin10sIT.java +++ b/matsim/src/test/java/org/matsim/examples/OnePercentBerlin10sIT.java @@ -20,7 +20,7 @@ package org.matsim.examples; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -92,8 +92,9 @@ void testOnePercent10sQSim() { writer.closeFile(); System.out.println("reffile: " + referenceEventsFileName); - assertEquals( "different event files", EventsFileComparator.Result.FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( referenceEventsFileName, eventsFileName ) ); + assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( referenceEventsFileName, eventsFileName ), + "different event files" ); } @@ -136,8 +137,9 @@ void testOnePercent10sQSimTryEndTimeThenDuration() { writer.closeFile(); - assertEquals( "different event files", EventsFileComparator.Result.FILES_ARE_EQUAL, - new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( referenceEventsFileName, eventsFileName ) ); + assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, + new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( referenceEventsFileName, eventsFileName ), + "different event files" ); } diff --git a/matsim/src/test/java/org/matsim/examples/PtTutorialIT.java b/matsim/src/test/java/org/matsim/examples/PtTutorialIT.java index 3b7f7fd87ca..f9eb2d4f608 100644 --- a/matsim/src/test/java/org/matsim/examples/PtTutorialIT.java +++ b/matsim/src/test/java/org/matsim/examples/PtTutorialIT.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -71,14 +71,14 @@ void ensure_tutorial_runs() throws MalformedURLException { } }); controler.run(); - Assert.assertEquals( 1867, enterVehicleEventCounter.getCnt() ); + Assertions.assertEquals( 1867, enterVehicleEventCounter.getCnt() ); } catch (Exception e) { log.error(e.getMessage(), e); - Assert.fail("There shouldn't be any exception, but there was ... :-("); + Assertions.fail("There shouldn't be any exception, but there was ... :-("); } final String it1Plans = "ITERS/it.1/1.plans.xml.gz"; - Assert.assertTrue(new File(config.controller().getOutputDirectory(), it1Plans).exists()); - Assert.assertTrue(new File(config.controller().getOutputDirectory(), "output_config.xml").exists()); + Assertions.assertTrue(new File(config.controller().getOutputDirectory(), it1Plans).exists()); + Assertions.assertTrue(new File(config.controller().getOutputDirectory(), "output_config.xml").exists()); log.info( Controler.DIVIDER ) ; log.info( Controler.DIVIDER ) ; @@ -106,10 +106,10 @@ void ensure_tutorial_runs() throws MalformedURLException { }); controler.run(); System.err.println( " cnt=" + enterVehicleEventCounter.getCnt() ) ; - Assert.assertEquals( 1867, enterVehicleEventCounter.getCnt() ); + Assertions.assertEquals( 1867, enterVehicleEventCounter.getCnt() ); } catch (Exception e) { log.error(e.getMessage(), e); - Assert.fail("There shouldn't be any exception, but there was ... :-("); + Assertions.fail("There shouldn't be any exception, but there was ... :-("); } } @@ -144,13 +144,11 @@ private static final class StageActivityDurationChecker implements ActivityStart @Override public void handleEvent( ActivityEndEvent endEvent ) { if (StageActivityTypeIdentifier.isStageActivity(endEvent.getActType()) ) { ActivityStartEvent startEvent = personId2ActivityStartEvent.get(endEvent.getPersonId()); - Assert.assertEquals("Stage activity should have same type in current ActivityEndEvent and in last ActivityStartEvent, but did not. PersonId " + + Assertions.assertEquals(startEvent.getActType(), endEvent.getActType(), "Stage activity should have same type in current ActivityEndEvent and in last ActivityStartEvent, but did not. PersonId " + endEvent.getPersonId() + ", ActivityStartEvent type: " + startEvent.getActType() + ", ActivityEndEvent type: " + endEvent.getActType() + - ", start time: " + startEvent.getTime() + ", end time: " + endEvent.getTime(), - startEvent.getActType(), endEvent.getActType()); - Assert.assertEquals("Stage activity should have a duration of 0 seconds, but did not. PersonId " + - endEvent.getPersonId() + ", start time: " + startEvent.getTime() + ", end time: " + endEvent.getTime(), - 0.0, startEvent.getTime() - endEvent.getTime(), MatsimTestUtils.EPSILON); + ", start time: " + startEvent.getTime() + ", end time: " + endEvent.getTime()); + Assertions.assertEquals(0.0, startEvent.getTime() - endEvent.getTime(), MatsimTestUtils.EPSILON, "Stage activity should have a duration of 0 seconds, but did not. PersonId " + + endEvent.getPersonId() + ", start time: " + startEvent.getTime() + ", end time: " + endEvent.getTime()); personId2ActivityStartEvent.remove(endEvent.getPersonId()); } } diff --git a/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java b/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java index a2ef3a5a8ec..c8b41781421 100644 --- a/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java +++ b/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java @@ -21,7 +21,7 @@ import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.runner.RunWith; @@ -206,10 +206,10 @@ void test_PtScoringLineswitch() { System.out.println(" score: " + pp.getSelectedPlan().getScore() ) ; if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ - Assert.assertEquals(-21.280962467387187, pp.getSelectedPlan().getScore(), MatsimTestUtils.EPSILON ) ; + Assertions.assertEquals(-21.280962467387187, pp.getSelectedPlan().getScore(), MatsimTestUtils.EPSILON ) ; } else{ - Assert.assertEquals(27.468448990195423, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; + Assertions.assertEquals(27.468448990195423, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; } } @@ -362,10 +362,10 @@ void test_PtScoringLineswitchAndPtConstant() { if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ // Assert.assertEquals(89.14608279715044, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; - Assert.assertEquals(-19.280962467387187, pp.getSelectedPlan().getScore(), MatsimTestUtils.EPSILON ) ; + Assertions.assertEquals(-19.280962467387187, pp.getSelectedPlan().getScore(), MatsimTestUtils.EPSILON ) ; } else{ - Assert.assertEquals(29.468448990195423, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; + Assertions.assertEquals(29.468448990195423, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; } } @@ -449,10 +449,10 @@ void test_PtScoring_Wait() { System.out.println("agent score: " + pp.getSelectedPlan().getScore() ) ; if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ - Assert.assertEquals(89.13108279715044, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; + Assertions.assertEquals(89.13108279715044, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; } else{ - Assert.assertEquals(137.1310827971504, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; + Assertions.assertEquals(137.1310827971504, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; } } @@ -531,10 +531,10 @@ void test_PtScoring() { System.out.println(" score: " + pp.getSelectedPlan().getScore() ) ; if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ - Assert.assertEquals(89.87441613048377, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; + Assertions.assertEquals(89.87441613048377, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; } else{ - Assert.assertEquals(137.87441613048375, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; + Assertions.assertEquals(137.87441613048375, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; } diff --git a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesFactoryImplTest.java b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesFactoryImplTest.java index e5f8838a405..c016764df06 100644 --- a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesFactoryImplTest.java +++ b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesFactoryImplTest.java @@ -19,7 +19,7 @@ package org.matsim.facilities; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -34,9 +34,9 @@ void testCreateActivityFacility() { ActivityFacilitiesFactoryImpl factory = new ActivityFacilitiesFactoryImpl(); ActivityFacility facility = factory.createActivityFacility(Id.create(1980, ActivityFacility.class), new Coord((double) 5, (double) 11)); - Assert.assertEquals("1980", facility.getId().toString()); - Assert.assertEquals(5.0, facility.getCoord().getX(), 1e-9); - Assert.assertEquals(11.0, facility.getCoord().getY(), 1e-9); + Assertions.assertEquals("1980", facility.getId().toString()); + Assertions.assertEquals(5.0, facility.getCoord().getX(), 1e-9); + Assertions.assertEquals(11.0, facility.getCoord().getY(), 1e-9); } @Test @@ -44,8 +44,8 @@ void testCreateActivityOption() { ActivityFacilitiesFactoryImpl factory = new ActivityFacilitiesFactoryImpl(); ActivityOption option = factory.createActivityOption("leisure"); - Assert.assertEquals("leisure", option.getType()); - Assert.assertEquals(Integer.MAX_VALUE, option.getCapacity(), 1e-9); + Assertions.assertEquals("leisure", option.getType()); + Assertions.assertEquals(Integer.MAX_VALUE, option.getCapacity(), 1e-9); } } diff --git a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesImplTest.java b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesImplTest.java index 223c6e20898..284e73cfe79 100644 --- a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesImplTest.java +++ b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesImplTest.java @@ -19,7 +19,7 @@ package org.matsim.facilities; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -35,16 +35,16 @@ void testAddActivityFacility() { ActivityFacilitiesFactory factory = facilities.getFactory(); ActivityFacility facility1 = factory.createActivityFacility(Id.create(1, ActivityFacility.class), new Coord((double) 200, (double) 5000)); - Assert.assertEquals(0, facilities.getFacilities().size()); + Assertions.assertEquals(0, facilities.getFacilities().size()); facilities.addActivityFacility(facility1); - Assert.assertEquals(1, facilities.getFacilities().size()); + Assertions.assertEquals(1, facilities.getFacilities().size()); ActivityFacility facility2 = factory.createActivityFacility(Id.create(2, ActivityFacility.class), new Coord((double) 300, (double) 4000)); facilities.addActivityFacility(facility2); - Assert.assertEquals(2, facilities.getFacilities().size()); + Assertions.assertEquals(2, facilities.getFacilities().size()); } @Test @@ -54,18 +54,18 @@ void testAddActivityFacility_addingTwice() { ActivityFacility facility1 = factory.createActivityFacility(Id.create(1, ActivityFacility.class), new Coord((double) 200, (double) 5000)); ActivityFacility facility2 = factory.createActivityFacility(Id.create(2, ActivityFacility.class), new Coord((double) 300, (double) 4000)); - Assert.assertEquals(0, facilities.getFacilities().size()); + Assertions.assertEquals(0, facilities.getFacilities().size()); facilities.addActivityFacility(facility1); facilities.addActivityFacility(facility2); - Assert.assertEquals(2, facilities.getFacilities().size()); + Assertions.assertEquals(2, facilities.getFacilities().size()); try { facilities.addActivityFacility(facility1); - Assert.fail("Expected exception, got none."); + Assertions.fail("Expected exception, got none."); } catch (IllegalArgumentException expected) {} - Assert.assertEquals(2, facilities.getFacilities().size()); + Assertions.assertEquals(2, facilities.getFacilities().size()); } @Test @@ -75,16 +75,16 @@ void testAddActivityFacility_sameId() { ActivityFacility facility1 = factory.createActivityFacility(Id.create(1, ActivityFacility.class), new Coord((double) 200, (double) 5000)); ActivityFacility facility2 = factory.createActivityFacility(Id.create(1, ActivityFacility.class), new Coord((double) 300, (double) 4000)); - Assert.assertEquals(0, facilities.getFacilities().size()); + Assertions.assertEquals(0, facilities.getFacilities().size()); facilities.addActivityFacility(facility1); try { facilities.addActivityFacility(facility2); - Assert.fail("Expected exception, got none."); + Assertions.fail("Expected exception, got none."); } catch (IllegalArgumentException expected) {} - Assert.assertEquals(1, facilities.getFacilities().size()); - Assert.assertEquals(facility1, facilities.getFacilities().get(Id.create(1, ActivityFacility.class))); + Assertions.assertEquals(1, facilities.getFacilities().size()); + Assertions.assertEquals(facility1, facilities.getFacilities().get(Id.create(1, ActivityFacility.class))); } /** @@ -99,10 +99,10 @@ void testRemove() { ActivityFacility facility2 = factory.createActivityFacility(Id.create(2, ActivityFacility.class), new Coord((double) 300, (double) 4000)); facilities.addActivityFacility(facility1); facilities.addActivityFacility(facility2); - Assert.assertEquals(2, facilities.getFacilities().size()); + Assertions.assertEquals(2, facilities.getFacilities().size()); - Assert.assertEquals(facility1, facilities.getFacilities().remove(Id.create(1, ActivityFacility.class))); - Assert.assertEquals(1, facilities.getFacilities().size()); + Assertions.assertEquals(facility1, facilities.getFacilities().remove(Id.create(1, ActivityFacility.class))); + Assertions.assertEquals(1, facilities.getFacilities().size()); } } diff --git a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java index 08eb702178b..7fa5c7b47f8 100644 --- a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java +++ b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java @@ -19,7 +19,7 @@ package org.matsim.facilities; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.runner.RunWith; @@ -99,32 +99,32 @@ void test(){ break; case fromFile: for (ActivityFacility af : activityFacilities.getFacilities().values()){ - Assert.assertNotNull(af.getLinkId()); + Assertions.assertNotNull(af.getLinkId()); } break; case setInScenario: - Assert.assertEquals("wrong number of facilities", 2, activityFacilities.getFacilities().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, activityFacilities.getFacilities().size(), MatsimTestUtils.EPSILON, "wrong number of facilities"); if (facilitiesWithCoordOnly) { for (ActivityFacility af : activityFacilities.getFacilities().values()){ - Assert.assertNotNull(af.getLinkId()); + Assertions.assertNotNull(af.getLinkId()); } } else { for (ActivityFacility af : activityFacilities.getFacilities().values()){ - Assert.assertNull(af.getCoord()); + Assertions.assertNull(af.getCoord()); } } break; case onePerActivityLinkInPlansFile: - Assert.assertEquals("wrong number of facilities", 4, getFacilities(scenario.getConfig().controller().getOutputDirectory()).getFacilities().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(4, getFacilities(scenario.getConfig().controller().getOutputDirectory()).getFacilities().size(), MatsimTestUtils.EPSILON, "wrong number of facilities"); for (ActivityFacility af : activityFacilities.getFacilities().values()){ - Assert.assertNotNull(af.getLinkId()); + Assertions.assertNotNull(af.getLinkId()); } break; case onePerActivityLocationInPlansFile: - Assert.assertEquals("wrong number of facilities", 2, getFacilities(scenario.getConfig().controller().getOutputDirectory()).getFacilities().size(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, getFacilities(scenario.getConfig().controller().getOutputDirectory()).getFacilities().size(), MatsimTestUtils.EPSILON, "wrong number of facilities"); for (ActivityFacility af : activityFacilities.getFacilities().values()){ - Assert.assertNotNull(af.getCoord()); - Assert.assertNotNull(af.getLinkId()); + Assertions.assertNotNull(af.getCoord()); + Assertions.assertNotNull(af.getLinkId()); } break; } diff --git a/matsim/src/test/java/org/matsim/facilities/ActivityWithOnlyFacilityIdTest.java b/matsim/src/test/java/org/matsim/facilities/ActivityWithOnlyFacilityIdTest.java index 8c768e8be87..ef42e06d8b5 100644 --- a/matsim/src/test/java/org/matsim/facilities/ActivityWithOnlyFacilityIdTest.java +++ b/matsim/src/test/java/org/matsim/facilities/ActivityWithOnlyFacilityIdTest.java @@ -1,12 +1,12 @@ package org.matsim.facilities; -import static org.junit.Assert.assertTrue; - import java.net.URL; import java.util.Set; import java.util.stream.Collectors; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Activity; import org.matsim.core.config.Config; @@ -34,7 +34,7 @@ void testSiouxFallsWithOnlyFacilityIds() { .flatMap(person -> person.getPlans().stream()).flatMap(plan -> plan.getPlanElements().stream()) .filter(Activity.class::isInstance).map(Activity.class::cast).filter(act -> act.getFacilityId() != null) .collect(Collectors.toSet()); - assertTrue("Need at least some activities with facilityIds.", activitiesWithFacilityIds.size() > 0); + assertTrue(activitiesWithFacilityIds.size() > 0, "Need at least some activities with facilityIds."); // Remove all (redundant) coords and linkIds from activities with facilityIds. activitiesWithFacilityIds.forEach(act -> { diff --git a/matsim/src/test/java/org/matsim/facilities/FacilitiesAttributeConvertionTest.java b/matsim/src/test/java/org/matsim/facilities/FacilitiesAttributeConvertionTest.java index 15ecc2fe919..bf397bf1abb 100644 --- a/matsim/src/test/java/org/matsim/facilities/FacilitiesAttributeConvertionTest.java +++ b/matsim/src/test/java/org/matsim/facilities/FacilitiesAttributeConvertionTest.java @@ -21,7 +21,7 @@ package org.matsim.facilities; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -34,7 +34,7 @@ import java.util.Objects; import java.util.function.Consumer; - public class FacilitiesAttributeConvertionTest { + public class FacilitiesAttributeConvertionTest { @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @@ -80,10 +80,10 @@ public void testWriteAndReread( final ActivityFacilities readFacilities = readScenario.getActivityFacilities(); final Object readAttribute = readFacilities.getAttributes().getAttribute("attribute"); - Assert.assertEquals( - "unexpected read attribute", + Assertions.assertEquals( attribute, - readAttribute); + readAttribute, + "unexpected read attribute"); } private static class CustomClass { diff --git a/matsim/src/test/java/org/matsim/facilities/FacilitiesFromPopulationTest.java b/matsim/src/test/java/org/matsim/facilities/FacilitiesFromPopulationTest.java index 9de3293c4ed..5c49682c9db 100644 --- a/matsim/src/test/java/org/matsim/facilities/FacilitiesFromPopulationTest.java +++ b/matsim/src/test/java/org/matsim/facilities/FacilitiesFromPopulationTest.java @@ -22,7 +22,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -55,11 +55,11 @@ void testRun_onePerLink_assignLinks() { generator.setAssignLinksToFacilitiesIfMissing( f.scenario.getNetwork() ); generator.run(f.scenario.getPopulation()); - Assert.assertEquals(3, f.scenario.getActivityFacilities().getFacilities().size()); + Assertions.assertEquals(3, f.scenario.getActivityFacilities().getFacilities().size()); - Assert.assertEquals("bc", f.scenario.getActivityFacilities().getFacilities().get(Id.create("bc", ActivityFacility.class)).getLinkId().toString()); - Assert.assertEquals("ca", f.scenario.getActivityFacilities().getFacilities().get(Id.create("ca", ActivityFacility.class)).getLinkId().toString()); - Assert.assertEquals("ab", f.scenario.getActivityFacilities().getFacilities().get(Id.create("ab", ActivityFacility.class)).getLinkId().toString()); + Assertions.assertEquals("bc", f.scenario.getActivityFacilities().getFacilities().get(Id.create("bc", ActivityFacility.class)).getLinkId().toString()); + Assertions.assertEquals("ca", f.scenario.getActivityFacilities().getFacilities().get(Id.create("ca", ActivityFacility.class)).getLinkId().toString()); + Assertions.assertEquals("ab", f.scenario.getActivityFacilities().getFacilities().get(Id.create("ab", ActivityFacility.class)).getLinkId().toString()); assertPlan(f.scenario.getPopulation().getPersons().get(Id.create("1", Person.class)).getSelectedPlan(), "ab", "bc", true); assertPlan(f.scenario.getPopulation().getPersons().get(Id.create("2", Person.class)).getSelectedPlan(), "ab", "bc", true); @@ -91,11 +91,11 @@ void testRun_onePerLink_assignLinks_openingTimes() { generator.assignOpeningTimes( config ); generator.run(f.scenario.getPopulation()); - Assert.assertEquals(3, f.scenario.getActivityFacilities().getFacilities().size()); + Assertions.assertEquals(3, f.scenario.getActivityFacilities().getFacilities().size()); Map, ? extends ActivityFacility> ffs = f.scenario.getActivityFacilities().getFacilities(); - Assert.assertEquals(7*3600, ffs.get(Id.create("ab", ActivityFacility.class)).getActivityOptions().get("work").getOpeningTimes().first().getStartTime(), 1e-7); - Assert.assertEquals(19*3600, ffs.get(Id.create("ab", ActivityFacility.class)).getActivityOptions().get("work").getOpeningTimes().first().getEndTime(), 1e-7); + Assertions.assertEquals(7*3600, ffs.get(Id.create("ab", ActivityFacility.class)).getActivityOptions().get("work").getOpeningTimes().first().getStartTime(), 1e-7); + Assertions.assertEquals(19*3600, ffs.get(Id.create("ab", ActivityFacility.class)).getActivityOptions().get("work").getOpeningTimes().first().getEndTime(), 1e-7); assertPlan(f.scenario.getPopulation().getPersons().get(Id.create("1", Person.class)).getSelectedPlan(), "ab", "bc", true); assertPlan(f.scenario.getPopulation().getPersons().get(Id.create("2", Person.class)).getSelectedPlan(), "ab", "bc", true); @@ -122,22 +122,22 @@ void testRun_multiple_assignLinks() { // System.out.println(af.getId() + "\t" + af.getLinkId() + "\t" + af.getCoord().getX() + "\t" + af.getCoord().getY()); // } - Assert.assertEquals(13, f.scenario.getActivityFacilities().getFacilities().size()); + Assertions.assertEquals(13, f.scenario.getActivityFacilities().getFacilities().size()); Map, ? extends ActivityFacility> ffs = f.scenario.getActivityFacilities().getFacilities(); - Assert.assertEquals("ab", ffs.get(Id.create("0", ActivityFacility.class)).getLinkId().toString()); // home of agent 1 - Assert.assertEquals("bc", ffs.get(Id.create("1", ActivityFacility.class)).getLinkId().toString()); // work of agent 1-3 - Assert.assertEquals("ab", ffs.get(Id.create("2", ActivityFacility.class)).getLinkId().toString()); // home of agent 2 - Assert.assertEquals("ab", ffs.get(Id.create("3", ActivityFacility.class)).getLinkId().toString()); // home of agent 3 - Assert.assertEquals("bc", ffs.get(Id.create("4", ActivityFacility.class)).getLinkId().toString()); // home of agent 4 - Assert.assertEquals("ca", ffs.get(Id.create("5", ActivityFacility.class)).getLinkId().toString()); // work of agent 4-7 - Assert.assertEquals("bc", ffs.get(Id.create("6", ActivityFacility.class)).getLinkId().toString()); // home of agent 5 - Assert.assertEquals("bc", ffs.get(Id.create("7", ActivityFacility.class)).getLinkId().toString()); // home of agent 6 - Assert.assertEquals("bc", ffs.get(Id.create("8", ActivityFacility.class)).getLinkId().toString()); // home of agent 7 - Assert.assertEquals("ca", ffs.get(Id.create("9", ActivityFacility.class)).getLinkId().toString()); // home of agent 8 - Assert.assertEquals("ab", ffs.get(Id.create("10", ActivityFacility.class)).getLinkId().toString()); // work of agent 8-10 - Assert.assertEquals("ca", ffs.get(Id.create("11", ActivityFacility.class)).getLinkId().toString()); // home of agent 9 - Assert.assertEquals("ca", ffs.get(Id.create("12", ActivityFacility.class)).getLinkId().toString()); // home of agent 10 + Assertions.assertEquals("ab", ffs.get(Id.create("0", ActivityFacility.class)).getLinkId().toString()); // home of agent 1 + Assertions.assertEquals("bc", ffs.get(Id.create("1", ActivityFacility.class)).getLinkId().toString()); // work of agent 1-3 + Assertions.assertEquals("ab", ffs.get(Id.create("2", ActivityFacility.class)).getLinkId().toString()); // home of agent 2 + Assertions.assertEquals("ab", ffs.get(Id.create("3", ActivityFacility.class)).getLinkId().toString()); // home of agent 3 + Assertions.assertEquals("bc", ffs.get(Id.create("4", ActivityFacility.class)).getLinkId().toString()); // home of agent 4 + Assertions.assertEquals("ca", ffs.get(Id.create("5", ActivityFacility.class)).getLinkId().toString()); // work of agent 4-7 + Assertions.assertEquals("bc", ffs.get(Id.create("6", ActivityFacility.class)).getLinkId().toString()); // home of agent 5 + Assertions.assertEquals("bc", ffs.get(Id.create("7", ActivityFacility.class)).getLinkId().toString()); // home of agent 6 + Assertions.assertEquals("bc", ffs.get(Id.create("8", ActivityFacility.class)).getLinkId().toString()); // home of agent 7 + Assertions.assertEquals("ca", ffs.get(Id.create("9", ActivityFacility.class)).getLinkId().toString()); // home of agent 8 + Assertions.assertEquals("ab", ffs.get(Id.create("10", ActivityFacility.class)).getLinkId().toString()); // work of agent 8-10 + Assertions.assertEquals("ca", ffs.get(Id.create("11", ActivityFacility.class)).getLinkId().toString()); // home of agent 9 + Assertions.assertEquals("ca", ffs.get(Id.create("12", ActivityFacility.class)).getLinkId().toString()); // home of agent 10 assertPlan(f.scenario.getPopulation().getPersons().get(Id.create("1", Person.class)).getSelectedPlan(), "0", "1", true); assertPlan(f.scenario.getPopulation().getPersons().get(Id.create("2", Person.class)).getSelectedPlan(), "2", "1", true); @@ -156,17 +156,17 @@ private void assertPlan(Plan plan, String homeFacilityId, String workFacilityId, Activity work = (Activity) plan.getPlanElements().get(2); Activity home2 = (Activity) plan.getPlanElements().get(4); - Assert.assertEquals(homeFacilityId, home1.getFacilityId().toString()); - Assert.assertEquals(workFacilityId, work.getFacilityId().toString()); - Assert.assertEquals(homeFacilityId, home2.getFacilityId().toString()); + Assertions.assertEquals(homeFacilityId, home1.getFacilityId().toString()); + Assertions.assertEquals(workFacilityId, work.getFacilityId().toString()); + Assertions.assertEquals(homeFacilityId, home2.getFacilityId().toString()); if (linkCoordMustBeNull) { - Assert.assertNull(home1.getLinkId()); - Assert.assertNull(home1.getCoord()); - Assert.assertNull(work.getLinkId()); - Assert.assertNull(work.getCoord()); - Assert.assertNull(home2.getLinkId()); - Assert.assertNull(home2.getCoord()); + Assertions.assertNull(home1.getLinkId()); + Assertions.assertNull(home1.getCoord()); + Assertions.assertNull(work.getLinkId()); + Assertions.assertNull(work.getCoord()); + Assertions.assertNull(home2.getLinkId()); + Assertions.assertNull(home2.getCoord()); } } diff --git a/matsim/src/test/java/org/matsim/facilities/FacilitiesParserWriterTest.java b/matsim/src/test/java/org/matsim/facilities/FacilitiesParserWriterTest.java index a56aa037fdd..8fe325a4306 100644 --- a/matsim/src/test/java/org/matsim/facilities/FacilitiesParserWriterTest.java +++ b/matsim/src/test/java/org/matsim/facilities/FacilitiesParserWriterTest.java @@ -20,7 +20,7 @@ package org.matsim.facilities; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -58,7 +58,7 @@ void testParserWriter1() { long checksum_ref = CRCChecksum.getCRCFromFile(config.facilities().getInputFile()); long checksum_run = CRCChecksum.getCRCFromFile(outputFilename); - Assert.assertEquals(checksum_ref, checksum_run); + Assertions.assertEquals(checksum_ref, checksum_run); } @Test @@ -87,19 +87,19 @@ void testWriteReadV2_withActivities() { ActivityFacilities facilities2 = FacilitiesUtils.createActivityFacilities(); new MatsimFacilitiesReader(null, null, facilities2).parse(inStream); - Assert.assertEquals(2, facilities2.getFacilities().size()); + Assertions.assertEquals(2, facilities2.getFacilities().size()); ActivityFacility fac1b = facilities2.getFacilities().get(Id.create("1", ActivityFacility.class)); - Assert.assertEquals(1, fac1b.getActivityOptions().size()); - Assert.assertTrue(fac1b.getActivityOptions().get("home").getOpeningTimes().isEmpty()); - Assert.assertEquals(0, fac1b.getAttributes().size()); + Assertions.assertEquals(1, fac1b.getActivityOptions().size()); + Assertions.assertTrue(fac1b.getActivityOptions().get("home").getOpeningTimes().isEmpty()); + Assertions.assertEquals(0, fac1b.getAttributes().size()); ActivityFacility fac2b = facilities2.getFacilities().get(Id.create("2", ActivityFacility.class)); - Assert.assertEquals(1, fac2b.getActivityOptions().size()); - Assert.assertNotNull(fac2b.getActivityOptions().get("shop").getOpeningTimes()); - Assert.assertEquals(8*3600, fac2b.getActivityOptions().get("shop").getOpeningTimes().first().getStartTime(), 0.0); - Assert.assertEquals(20*3600, fac2b.getActivityOptions().get("shop").getOpeningTimes().first().getEndTime(), 0.0); - Assert.assertEquals(0, fac2b.getAttributes().size()); + Assertions.assertEquals(1, fac2b.getActivityOptions().size()); + Assertions.assertNotNull(fac2b.getActivityOptions().get("shop").getOpeningTimes()); + Assertions.assertEquals(8*3600, fac2b.getActivityOptions().get("shop").getOpeningTimes().first().getStartTime(), 0.0); + Assertions.assertEquals(20*3600, fac2b.getActivityOptions().get("shop").getOpeningTimes().first().getEndTime(), 0.0); + Assertions.assertEquals(0, fac2b.getAttributes().size()); } @Test @@ -126,17 +126,17 @@ void testWriteReadV2_withAttributes() { ActivityFacilities facilities2 = FacilitiesUtils.createActivityFacilities(); new MatsimFacilitiesReader(null, null, facilities2).parse(inStream); - Assert.assertEquals(2, facilities2.getFacilities().size()); + Assertions.assertEquals(2, facilities2.getFacilities().size()); ActivityFacility fac1b = facilities2.getFacilities().get(Id.create("1", ActivityFacility.class)); - Assert.assertEquals(0, fac1b.getActivityOptions().size()); - Assert.assertEquals(1, fac1b.getAttributes().size()); - Assert.assertEquals(100, fac1b.getAttributes().getAttribute("size_m2")); + Assertions.assertEquals(0, fac1b.getActivityOptions().size()); + Assertions.assertEquals(1, fac1b.getAttributes().size()); + Assertions.assertEquals(100, fac1b.getAttributes().getAttribute("size_m2")); ActivityFacility fac2b = facilities2.getFacilities().get(Id.create("2", ActivityFacility.class)); - Assert.assertEquals(0, fac2b.getActivityOptions().size()); - Assert.assertEquals(1, fac2b.getAttributes().size()); - Assert.assertEquals(500, fac2b.getAttributes().getAttribute("size_m2")); + Assertions.assertEquals(0, fac2b.getActivityOptions().size()); + Assertions.assertEquals(1, fac2b.getAttributes().size()); + Assertions.assertEquals(500, fac2b.getAttributes().getAttribute("size_m2")); } @Test @@ -168,21 +168,21 @@ void testWriteReadV2_withActivitiesAndAttributes() { // MATSIM-859 ActivityFacilities facilities2 = FacilitiesUtils.createActivityFacilities(); new MatsimFacilitiesReader(null, null, facilities2).parse(inStream); - Assert.assertEquals(2, facilities2.getFacilities().size()); + Assertions.assertEquals(2, facilities2.getFacilities().size()); ActivityFacility fac1b = facilities2.getFacilities().get(Id.create("1", ActivityFacility.class)); - Assert.assertEquals(1, fac1b.getActivityOptions().size()); - Assert.assertTrue(fac1b.getActivityOptions().get("home").getOpeningTimes().isEmpty()); - Assert.assertEquals(1, fac1b.getAttributes().size()); - Assert.assertEquals(100, fac1b.getAttributes().getAttribute("size_m2")); + Assertions.assertEquals(1, fac1b.getActivityOptions().size()); + Assertions.assertTrue(fac1b.getActivityOptions().get("home").getOpeningTimes().isEmpty()); + Assertions.assertEquals(1, fac1b.getAttributes().size()); + Assertions.assertEquals(100, fac1b.getAttributes().getAttribute("size_m2")); ActivityFacility fac2b = facilities2.getFacilities().get(Id.create("2", ActivityFacility.class)); - Assert.assertEquals(1, fac2b.getActivityOptions().size()); - Assert.assertNotNull(fac2b.getActivityOptions().get("shop").getOpeningTimes()); - Assert.assertEquals(8*3600, fac2b.getActivityOptions().get("shop").getOpeningTimes().first().getStartTime(), 0.0); - Assert.assertEquals(20*3600, fac2b.getActivityOptions().get("shop").getOpeningTimes().first().getEndTime(), 0.0); - Assert.assertEquals(1, fac2b.getAttributes().size()); - Assert.assertEquals(500, fac2b.getAttributes().getAttribute("size_m2")); + Assertions.assertEquals(1, fac2b.getActivityOptions().size()); + Assertions.assertNotNull(fac2b.getActivityOptions().get("shop").getOpeningTimes()); + Assertions.assertEquals(8*3600, fac2b.getActivityOptions().get("shop").getOpeningTimes().first().getStartTime(), 0.0); + Assertions.assertEquals(20*3600, fac2b.getActivityOptions().get("shop").getOpeningTimes().first().getEndTime(), 0.0); + Assertions.assertEquals(1, fac2b.getAttributes().size()); + Assertions.assertEquals(500, fac2b.getAttributes().getAttribute("size_m2")); } } diff --git a/matsim/src/test/java/org/matsim/facilities/FacilitiesReprojectionIOTest.java b/matsim/src/test/java/org/matsim/facilities/FacilitiesReprojectionIOTest.java index 23682c3794b..efee8929cda 100644 --- a/matsim/src/test/java/org/matsim/facilities/FacilitiesReprojectionIOTest.java +++ b/matsim/src/test/java/org/matsim/facilities/FacilitiesReprojectionIOTest.java @@ -21,7 +21,7 @@ package org.matsim.facilities; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -39,7 +39,7 @@ import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; - /** + /** * @author thibautd */ public class FacilitiesReprojectionIOTest { @@ -103,16 +103,16 @@ void testWithControlerAndObjectAttributes() { final Coord originalCoord = originalScenario.getActivityFacilities().getFacilities().get( id ).getCoord(); final Coord internalCoord = scenario.getActivityFacilities().getFacilities().get( id ).getCoord(); - Assert.assertEquals( - "Wrong coordinate transform performed!", + Assertions.assertEquals( transformation.transform(originalCoord), - internalCoord); + internalCoord, + "Wrong coordinate transform performed!"); } - Assert.assertEquals( - "wrong CRS information after loading", + Assertions.assertEquals( TARGET_CRS, - ProjectionUtils.getCRS(scenario.getActivityFacilities())); + ProjectionUtils.getCRS(scenario.getActivityFacilities()), + "wrong CRS information after loading"); config.controller().setLastIteration( -1 ); final String outputDirectory = utils.getOutputDirectory()+"/output/"; @@ -127,16 +127,16 @@ void testWithControlerAndObjectAttributes() { final Coord internalCoord = scenario.getActivityFacilities().getFacilities().get( id ).getCoord(); final Coord dumpedCoord = dumpedScenario.getActivityFacilities().getFacilities().get( id ).getCoord(); - Assert.assertEquals( - "coordinates were reprojected for dump", + Assertions.assertEquals( internalCoord.getX(), dumpedCoord.getX(), - epsilon ); - Assert.assertEquals( - "coordinates were reprojected for dump", + epsilon, + "coordinates were reprojected for dump" ); + Assertions.assertEquals( internalCoord.getY(), dumpedCoord.getY(), - epsilon ); + epsilon, + "coordinates were reprojected for dump" ); } } @@ -167,16 +167,16 @@ void testWithControlerAndConfigParameters() { final Coord originalCoord = originalScenario.getActivityFacilities().getFacilities().get( id ).getCoord(); final Coord internalCoord = scenario.getActivityFacilities().getFacilities().get( id ).getCoord(); - Assert.assertNotEquals( - "No coordinates transform performed!", + Assertions.assertNotEquals( originalCoord.getX(), internalCoord.getX(), - epsilon ); - Assert.assertNotEquals( - "No coordinates transform performed!", + epsilon, + "No coordinates transform performed!" ); + Assertions.assertNotEquals( originalCoord.getY(), internalCoord.getY(), - epsilon ); + epsilon, + "No coordinates transform performed!" ); } config.controller().setLastIteration( -1 ); @@ -192,16 +192,16 @@ void testWithControlerAndConfigParameters() { final Coord originalCoord = originalScenario.getActivityFacilities().getFacilities().get( id ).getCoord(); final Coord dumpedCoord = dumpedScenario.getActivityFacilities().getFacilities().get( id ).getCoord(); - Assert.assertNotEquals( - "coordinates not reprojected for dump", + Assertions.assertNotEquals( originalCoord.getX(), dumpedCoord.getX(), - epsilon ); - Assert.assertNotEquals( - "coordinates not reprojected for dump", + epsilon, + "coordinates not reprojected for dump" ); + Assertions.assertNotEquals( originalCoord.getY(), dumpedCoord.getY(), - epsilon ); + epsilon, + "coordinates not reprojected for dump" ); } } @@ -209,10 +209,10 @@ private void assertScenarioReprojectedCorrectly(Scenario originalScenario, Scena final ActivityFacilities originalFacilities = originalScenario.getActivityFacilities(); final ActivityFacilities reprojectedFacilities = reprojectedScenario.getActivityFacilities(); - Assert.assertEquals( - "unexpected size of reprojected facilities", + Assertions.assertEquals( originalFacilities.getFacilities().size(), - reprojectedFacilities.getFacilities().size() ); + reprojectedFacilities.getFacilities().size(), + "unexpected size of reprojected facilities" ); for (Id id : originalFacilities.getFacilities().keySet() ) { final ActivityFacility originalFacility = originalFacilities.getFacilities().get( id ); @@ -226,9 +226,9 @@ private void assertReprojectedCorrectly(ActivityFacility originalFacility, Activ final Coord original = originalFacility.getCoord(); final Coord transformed = reprojectedFacility.getCoord(); - Assert.assertEquals( - "wrong reprojected coordinate", + Assertions.assertEquals( transformation.transform(original), - transformed); + transformed, + "wrong reprojected coordinate"); } } diff --git a/matsim/src/test/java/org/matsim/facilities/FacilitiesWriterTest.java b/matsim/src/test/java/org/matsim/facilities/FacilitiesWriterTest.java index 2cef9ffb5d5..7a33183eaaf 100644 --- a/matsim/src/test/java/org/matsim/facilities/FacilitiesWriterTest.java +++ b/matsim/src/test/java/org/matsim/facilities/FacilitiesWriterTest.java @@ -21,7 +21,7 @@ package org.matsim.facilities; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -33,7 +33,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; - /** + /** * @author mrieser */ public class FacilitiesWriterTest { @@ -68,19 +68,19 @@ void testWriteLinkId() { MatsimFacilitiesReader reader = new MatsimFacilitiesReader(scenario); reader.parse(inputStream); - Assert.assertEquals(3, facilities.getFacilities().size()); + Assertions.assertEquals(3, facilities.getFacilities().size()); ActivityFacility fac1b = facilities.getFacilities().get(Id.create(1, ActivityFacility.class)); - Assert.assertEquals(Id.create("Abc", Link.class), fac1b.getLinkId()); - Assert.assertEquals(1000, fac1b.getAttributes().getAttribute("population")); + Assertions.assertEquals(Id.create("Abc", Link.class), fac1b.getLinkId()); + Assertions.assertEquals(1000, fac1b.getAttributes().getAttribute("population")); ActivityFacility fac2b = facilities.getFacilities().get(Id.create(2, ActivityFacility.class)); - Assert.assertEquals(Id.create("Def", Link.class), fac2b.getLinkId()); - Assert.assertEquals(1200, fac2b.getAttributes().getAttribute("population")); + Assertions.assertEquals(Id.create("Def", Link.class), fac2b.getLinkId()); + Assertions.assertEquals(1200, fac2b.getAttributes().getAttribute("population")); ActivityFacility fac3b = facilities.getFacilities().get(Id.create(3, ActivityFacility.class)); - Assert.assertNull(fac3b.getLinkId()); - Assert.assertEquals("pepsiCo", fac3b.getAttributes().getAttribute("owner")); + Assertions.assertNull(fac3b.getLinkId()); + Assertions.assertEquals("pepsiCo", fac3b.getAttributes().getAttribute("owner")); } @Test @@ -107,18 +107,18 @@ void testWrite3DCoord() { MatsimFacilitiesReader reader = new MatsimFacilitiesReader(scenario); reader.parse(inputStream); - Assert.assertEquals(3, facilities.getFacilities().size()); + Assertions.assertEquals(3, facilities.getFacilities().size()); ActivityFacility fac1b = facilities.getFacilities().get(Id.create(1, ActivityFacility.class)); - Assert.assertTrue(fac1b.getCoord().hasZ()); - Assert.assertEquals(12.3, fac1b.getCoord().getZ(), Double.MIN_NORMAL); + Assertions.assertTrue(fac1b.getCoord().hasZ()); + Assertions.assertEquals(12.3, fac1b.getCoord().getZ(), Double.MIN_NORMAL); ActivityFacility fac2b = facilities.getFacilities().get(Id.create(2, ActivityFacility.class)); - Assert.assertTrue(fac2b.getCoord().hasZ()); - Assert.assertEquals(-4.2, fac2b.getCoord().getZ(), Double.MIN_NORMAL); + Assertions.assertTrue(fac2b.getCoord().hasZ()); + Assertions.assertEquals(-4.2, fac2b.getCoord().getZ(), Double.MIN_NORMAL); ActivityFacility fac3b = facilities.getFacilities().get(Id.create(3, ActivityFacility.class)); - Assert.assertFalse(fac3b.getCoord().hasZ()); + Assertions.assertFalse(fac3b.getCoord().hasZ()); } // the better fix for https://github.com/matsim-org/matsim/pull/505 @@ -150,10 +150,10 @@ void testFacilityDescription() { // check - Assert.assertEquals(1, facilities.getFacilities().size()); + Assertions.assertEquals(1, facilities.getFacilities().size()); ActivityFacility fac1b = facilities.getFacilities().get(Id.create(1, ActivityFacility.class)); String desc2 = ((ActivityFacilityImpl) fac1b).getDesc(); - Assert.assertEquals(desc, desc2); + Assertions.assertEquals(desc, desc2); } // inspired by https://github.com/matsim-org/matsim/pull/505 @@ -183,7 +183,7 @@ void testFacilitiesName() { // check String desc2 = facilities.getName(); - Assert.assertEquals(desc, desc2); + Assertions.assertEquals(desc, desc2); } } diff --git a/matsim/src/test/java/org/matsim/facilities/MatsimFacilitiesReaderTest.java b/matsim/src/test/java/org/matsim/facilities/MatsimFacilitiesReaderTest.java index e1b5329bb19..049a8e8a398 100644 --- a/matsim/src/test/java/org/matsim/facilities/MatsimFacilitiesReaderTest.java +++ b/matsim/src/test/java/org/matsim/facilities/MatsimFacilitiesReaderTest.java @@ -23,7 +23,7 @@ import java.io.ByteArrayInputStream; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -31,7 +31,7 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.scenario.ScenarioUtils; - /** + /** * @author mrieser / Senozon AG */ public class MatsimFacilitiesReaderTest { @@ -72,16 +72,16 @@ void testReadLinkId() { reader.parse(new ByteArrayInputStream(str.getBytes())); ActivityFacilities facilities = scenario.getActivityFacilities(); - Assert.assertEquals(3, facilities.getFacilities().size()); + Assertions.assertEquals(3, facilities.getFacilities().size()); ActivityFacility fac1 = facilities.getFacilities().get(Id.create(1, ActivityFacility.class)); - Assert.assertEquals(Id.create("Aa", Link.class), fac1.getLinkId()); + Assertions.assertEquals(Id.create("Aa", Link.class), fac1.getLinkId()); ActivityFacility fac10 = facilities.getFacilities().get(Id.create(10, ActivityFacility.class)); - Assert.assertEquals(Id.create("Bb", Link.class), fac10.getLinkId()); + Assertions.assertEquals(Id.create("Bb", Link.class), fac10.getLinkId()); ActivityFacility fac20 = facilities.getFacilities().get(Id.create(20, ActivityFacility.class)); - Assert.assertNull(fac20.getLinkId()); + Assertions.assertNull(fac20.getLinkId()); } @Test @@ -120,17 +120,17 @@ void testRead3DCoord() { reader.parse(new ByteArrayInputStream(str.getBytes())); ActivityFacilities facilities = scenario.getActivityFacilities(); - Assert.assertEquals(3, facilities.getFacilities().size()); + Assertions.assertEquals(3, facilities.getFacilities().size()); ActivityFacility fac1 = facilities.getFacilities().get(Id.create(1, ActivityFacility.class)); - Assert.assertTrue(fac1.getCoord().hasZ()); - Assert.assertEquals(12.3, fac1.getCoord().getZ(), Double.MIN_NORMAL); + Assertions.assertTrue(fac1.getCoord().hasZ()); + Assertions.assertEquals(12.3, fac1.getCoord().getZ(), Double.MIN_NORMAL); ActivityFacility fac10 = facilities.getFacilities().get(Id.create(10, ActivityFacility.class)); - Assert.assertTrue(fac10.getCoord().hasZ()); - Assert.assertEquals(-4.2, fac10.getCoord().getZ(), Double.MIN_NORMAL); + Assertions.assertTrue(fac10.getCoord().hasZ()); + Assertions.assertEquals(-4.2, fac10.getCoord().getZ(), Double.MIN_NORMAL); ActivityFacility fac20 = facilities.getFacilities().get(Id.create(20, ActivityFacility.class)); - Assert.assertFalse(fac20.getCoord().hasZ()); + Assertions.assertFalse(fac20.getCoord().hasZ()); } } diff --git a/matsim/src/test/java/org/matsim/facilities/StreamingActivityFacilitiesTest.java b/matsim/src/test/java/org/matsim/facilities/StreamingActivityFacilitiesTest.java index 58a92229f5d..d8cfe1bb722 100644 --- a/matsim/src/test/java/org/matsim/facilities/StreamingActivityFacilitiesTest.java +++ b/matsim/src/test/java/org/matsim/facilities/StreamingActivityFacilitiesTest.java @@ -1,6 +1,6 @@ package org.matsim.facilities; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; @@ -45,30 +45,30 @@ void testFacilityIsComplete() { boolean[] foundFacilities = new boolean[3]; StreamingActivityFacilities streamingFacilities = new StreamingActivityFacilities(f -> { if (f.getId().toString().equals("1")) { - Assert.assertEquals(60.0, f.getCoord().getX(), 1e-7); - Assert.assertTrue(f.getActivityOptions().containsKey("home")); - Assert.assertEquals(1000, ((Integer) f.getAttributes().getAttribute("population")).intValue()); + Assertions.assertEquals(60.0, f.getCoord().getX(), 1e-7); + Assertions.assertTrue(f.getActivityOptions().containsKey("home")); + Assertions.assertEquals(1000, ((Integer) f.getAttributes().getAttribute("population")).intValue()); foundFacilities[0] = true; } if (f.getId().toString().equals("10")) { - Assert.assertEquals(110.0, f.getCoord().getX(), 1e-7); - Assert.assertTrue(f.getActivityOptions().containsKey("education")); - Assert.assertTrue(f.getAttributes().isEmpty()); + Assertions.assertEquals(110.0, f.getCoord().getX(), 1e-7); + Assertions.assertTrue(f.getActivityOptions().containsKey("education")); + Assertions.assertTrue(f.getAttributes().isEmpty()); foundFacilities[1] = true; } if (f.getId().toString().equals("20")) { - Assert.assertEquals(120.0, f.getCoord().getX(), 1e-7); - Assert.assertTrue(f.getActivityOptions().containsKey("shop")); - Assert.assertTrue(f.getAttributes().isEmpty()); + Assertions.assertEquals(120.0, f.getCoord().getX(), 1e-7); + Assertions.assertTrue(f.getActivityOptions().containsKey("shop")); + Assertions.assertTrue(f.getAttributes().isEmpty()); foundFacilities[2] = true; } }); MatsimFacilitiesReader reader = new MatsimFacilitiesReader(null, null, streamingFacilities); reader.parse(new ByteArrayInputStream(str.getBytes())); - Assert.assertTrue(foundFacilities[0]); - Assert.assertTrue(foundFacilities[1]); - Assert.assertTrue(foundFacilities[2]); + Assertions.assertTrue(foundFacilities[0]); + Assertions.assertTrue(foundFacilities[1]); + Assertions.assertTrue(foundFacilities[2]); } } diff --git a/matsim/src/test/java/org/matsim/facilities/algorithms/AbstractFacilityAlgorithmTest.java b/matsim/src/test/java/org/matsim/facilities/algorithms/AbstractFacilityAlgorithmTest.java index f115010be8a..ecfd778ca93 100644 --- a/matsim/src/test/java/org/matsim/facilities/algorithms/AbstractFacilityAlgorithmTest.java +++ b/matsim/src/test/java/org/matsim/facilities/algorithms/AbstractFacilityAlgorithmTest.java @@ -20,7 +20,7 @@ package org.matsim.facilities.algorithms; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -45,7 +45,7 @@ void testRunAlgorithms() { // create an algo and let it run over the facilities MockAlgo1 algo1 = new MockAlgo1(); algo1.run(facilities); - assertEquals("TestAlgo should have handled 2 facilities.", 2, algo1.getCounter()); + assertEquals(2, algo1.getCounter(), "TestAlgo should have handled 2 facilities."); } /*package*/ static class MockAlgo1 extends AbstractFacilityAlgorithm { diff --git a/matsim/src/test/java/org/matsim/households/HouseholdAttributeConversionTest.java b/matsim/src/test/java/org/matsim/households/HouseholdAttributeConversionTest.java index 3c3b207f51f..6f8dbc7bbf3 100644 --- a/matsim/src/test/java/org/matsim/households/HouseholdAttributeConversionTest.java +++ b/matsim/src/test/java/org/matsim/households/HouseholdAttributeConversionTest.java @@ -23,7 +23,7 @@ -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -39,7 +39,7 @@ import java.util.Objects; import java.util.function.Consumer; - public class HouseholdAttributeConversionTest { + public class HouseholdAttributeConversionTest { @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @@ -77,10 +77,10 @@ public void testWriteAndReread( final Household readHousehold = readHouseholds.getHouseholds().get(id); final Object readAttribute = readHousehold.getAttributes().getAttribute("attribute"); - Assert.assertEquals( - "unexpected read attribute", + Assertions.assertEquals( attribute, - readAttribute); + readAttribute, + "unexpected read attribute"); } private static class CustomClass { diff --git a/matsim/src/test/java/org/matsim/households/HouseholdImplTest.java b/matsim/src/test/java/org/matsim/households/HouseholdImplTest.java index 8aa02ede926..920477bcf7c 100644 --- a/matsim/src/test/java/org/matsim/households/HouseholdImplTest.java +++ b/matsim/src/test/java/org/matsim/households/HouseholdImplTest.java @@ -20,7 +20,7 @@ package org.matsim.households; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -42,10 +42,10 @@ void testAddHousehold_DuplicateId(){ Household hh1 = new HouseholdImpl(Id.create("1", Household.class)); Household hh2 = new HouseholdImpl(Id.create("1", Household.class)); - assertEquals("Shouldn't have a household.", 0, hhs.getHouseholds().size()); + assertEquals(0, hhs.getHouseholds().size(), "Shouldn't have a household."); hhs.addHousehold(hh1); - assertEquals("Didn't add the household.", 1, hhs.getHouseholds().size()); - assertEquals("Should have added the household.", hh1, hhs.getHouseholds().get(hh1.getId())); + assertEquals(1, hhs.getHouseholds().size(), "Didn't add the household."); + assertEquals(hh1, hhs.getHouseholds().get(hh1.getId()), "Should have added the household."); try{ hhs.addHousehold(hh2); fail("Should not have accepted household with similar Id."); @@ -64,12 +64,12 @@ void testAddHousehold_NoStreaming(){ Household hh2 = new HouseholdImpl(Id.create("2", Household.class)); hhs.addHousehold(hh1); - assertEquals("Should have the first household added.", 1, hhs.getHouseholds().size()); - assertTrue("First household not present.", hhs.getHouseholds().containsValue(hh1)); + assertEquals(1, hhs.getHouseholds().size(), "Should have the first household added."); + assertTrue(hhs.getHouseholds().containsValue(hh1), "First household not present."); hhs.addHousehold(hh2); - assertEquals("Should have the first AND second household added.", 2, hhs.getHouseholds().size()); - assertTrue("First household not present.", hhs.getHouseholds().containsValue(hh1)); - assertTrue("Second household not present.", hhs.getHouseholds().containsValue(hh2)); + assertEquals(2, hhs.getHouseholds().size(), "Should have the first AND second household added."); + assertTrue(hhs.getHouseholds().containsValue(hh1), "First household not present."); + assertTrue(hhs.getHouseholds().containsValue(hh2), "Second household not present."); } } diff --git a/matsim/src/test/java/org/matsim/households/HouseholdsIoTest.java b/matsim/src/test/java/org/matsim/households/HouseholdsIoTest.java index bba8e6a3916..f2bd9411b73 100644 --- a/matsim/src/test/java/org/matsim/households/HouseholdsIoTest.java +++ b/matsim/src/test/java/org/matsim/households/HouseholdsIoTest.java @@ -19,7 +19,7 @@ package org.matsim.households; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.io.File; import java.io.IOException; @@ -108,7 +108,7 @@ private void checkContent(Households households) { assertEquals(50000.0d, hh.getIncome().getIncome(), MatsimTestUtils.EPSILON); Attributes currentAttributes = hh.getAttributes(); - assertNotNull("Custom attributes from household with id 23 should not be empty.", currentAttributes); + assertNotNull(currentAttributes, "Custom attributes from household with id 23 should not be empty."); String customAttributeName = "customAttribute1"; String customContent = (String)currentAttributes.getAttribute(customAttributeName); assertEquals("customValue1", customContent); diff --git a/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java b/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java index 3db4c83d19f..3e3af8a0501 100644 --- a/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java +++ b/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java @@ -51,7 +51,7 @@ import jakarta.inject.Inject; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.matsim.testcases.MatsimTestUtils.EPSILON; /** diff --git a/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java b/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java index 0ed09266633..9bd875631c0 100644 --- a/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java +++ b/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java @@ -20,11 +20,11 @@ package org.matsim.integration; -import static org.junit.Assert.assertEquals; - import java.util.Arrays; import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -300,7 +300,7 @@ void testTeleportationScore() { scorer.finish(); Double score = plan.getScore(); - assertEquals("Expecting -1.0 from travel time, -1.0 from travel distance.", -2.0, score, MatsimTestUtils.EPSILON); + assertEquals(-2.0, score, MatsimTestUtils.EPSILON, "Expecting -1.0 from travel time, -1.0 from travel distance."); } diff --git a/matsim/src/test/java/org/matsim/integration/events/PersonMoneyEventIntegrationTest.java b/matsim/src/test/java/org/matsim/integration/events/PersonMoneyEventIntegrationTest.java index c99bcf65622..4d2bf07173c 100644 --- a/matsim/src/test/java/org/matsim/integration/events/PersonMoneyEventIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/integration/events/PersonMoneyEventIntegrationTest.java @@ -20,8 +20,8 @@ package org.matsim.integration.events; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.BufferedWriter; import java.io.IOException; diff --git a/matsim/src/test/java/org/matsim/integration/events/PersonScoreEventTest.java b/matsim/src/test/java/org/matsim/integration/events/PersonScoreEventTest.java index 8e690949e5e..f1a1eb70d9e 100644 --- a/matsim/src/test/java/org/matsim/integration/events/PersonScoreEventTest.java +++ b/matsim/src/test/java/org/matsim/integration/events/PersonScoreEventTest.java @@ -18,8 +18,8 @@ package org.matsim.integration.events; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; diff --git a/matsim/src/test/java/org/matsim/integration/events/TransitDriverStartsEventHandlerIntegrationTest.java b/matsim/src/test/java/org/matsim/integration/events/TransitDriverStartsEventHandlerIntegrationTest.java index 4ed3071fb8e..1055467d26d 100644 --- a/matsim/src/test/java/org/matsim/integration/events/TransitDriverStartsEventHandlerIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/integration/events/TransitDriverStartsEventHandlerIntegrationTest.java @@ -22,7 +22,7 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.TransitDriverStartsEvent; @@ -48,14 +48,14 @@ void testProcessEventIntegration() { TransitDriverStartsTestEventHandler eh = new TransitDriverStartsTestEventHandler(); em.addHandler(eh); - Assert.assertEquals(0, eh.events.size()); + Assertions.assertEquals(0, eh.events.size()); em.initProcessing(); em.processEvent(e1); em.finishProcessing(); - Assert.assertEquals(1, eh.events.size()); - Assert.assertEquals(e1, eh.events.get(0)); + Assertions.assertEquals(1, eh.events.size()); + Assertions.assertEquals(e1, eh.events.get(0)); } /*package*/ static class TransitDriverStartsTestEventHandler implements TransitDriverStartsEventHandler { diff --git a/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingIT.java b/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingIT.java index 438b9fa07c4..3780604dcbf 100644 --- a/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingIT.java +++ b/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingIT.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.integration.invertednetworks; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.controler.Controler; @@ -48,7 +48,7 @@ public void notifyStartup(StartupEvent event) { } }); c.run(); - Assert.assertTrue("No traffic on link", testHandler.hadTrafficOnLink25); + Assertions.assertTrue(testHandler.hadTrafficOnLink25, "No traffic on link"); } @@ -68,7 +68,7 @@ public void notifyStartup(StartupEvent event) { } }); c.run(); - Assert.assertTrue("No traffic on link", testHandler.hadTrafficOnLink25); + Assertions.assertTrue(testHandler.hadTrafficOnLink25, "No traffic on link"); } @Test @@ -89,6 +89,6 @@ public void notifyStartup(StartupEvent event) { } }); c.run(); - Assert.assertTrue("No traffic on link", testHandler.hadTrafficOnLink25); + Assertions.assertTrue(testHandler.hadTrafficOnLink25, "No traffic on link"); } } diff --git a/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java b/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java index f5c0a37ec99..c068845de9e 100644 --- a/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java +++ b/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -82,12 +82,12 @@ public void install() { addMobsimListenerBinding().toInstance(new MobsimInitializedListener() { @Override public void notifyMobsimInitialized(MobsimInitializedEvent e) { - Assert.assertTrue(e.getQueueSimulation() instanceof QSim); + Assertions.assertTrue(e.getQueueSimulation() instanceof QSim); QSim qsim = (QSim) e.getQueueSimulation(); NetsimLink link = qsim.getNetsimNetwork().getNetsimLink(Id.create("23", Link.class)); - Assert.assertTrue(link instanceof QLinkLanesImpl); + Assertions.assertTrue(link instanceof QLinkLanesImpl); QLinkLanesImpl link23 = (QLinkLanesImpl) link; - Assert.assertNotNull(link23.getQueueLanes()); + Assertions.assertNotNull(link23.getQueueLanes()); // for (QLane lane : link23.getQueueLanes()){ // Assert.assertNotNull(lane); // log.error("lane " + lane.getId() + " flow " + lane.getSimulatedFlowCapacity()); @@ -139,9 +139,9 @@ public void notifyShutdown(ShutdownEvent event) { log.info( "link36:" + percent36 ); // The lanes attached to link 23 should distribute the 3600 veh/h capacity as follows: - Assert.assertEquals("lane to link 34 should have approx. 600 veh/h, i.e. 16.6% of the total flow", 16.6, percent34, 1); - Assert.assertEquals("lane to link 35 should have approx. 1200 veh/h, i.e. 33.3% of the total flow", 33.3, percent35, 1); - Assert.assertEquals("lane to link 36 should have approx. 1800 veh/h, i.e. 50.0% of the total flow", 50.0, percent36, 1); + Assertions.assertEquals(16.6, percent34, 1, "lane to link 34 should have approx. 600 veh/h, i.e. 16.6% of the total flow"); + Assertions.assertEquals(33.3, percent35, 1, "lane to link 35 should have approx. 1200 veh/h, i.e. 33.3% of the total flow"); + Assertions.assertEquals(50.0, percent36, 1, "lane to link 36 should have approx. 1800 veh/h, i.e. 50.0% of the total flow"); } } diff --git a/matsim/src/test/java/org/matsim/integration/population/NonAlternatingPlanElementsIT.java b/matsim/src/test/java/org/matsim/integration/population/NonAlternatingPlanElementsIT.java index 8d745a9e89f..033857c8a4c 100644 --- a/matsim/src/test/java/org/matsim/integration/population/NonAlternatingPlanElementsIT.java +++ b/matsim/src/test/java/org/matsim/integration/population/NonAlternatingPlanElementsIT.java @@ -22,7 +22,7 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -91,7 +91,7 @@ void test_Controler_QSim_Routechoice_acts() { controler.getConfig().controller().setCreateGraphs(false); controler.run(); - Assert.assertTrue(person.getPlans().size() > 1); // ensure there was some replanning + Assertions.assertTrue(person.getPlans().size() > 1); // ensure there was some replanning } @Test @@ -123,7 +123,7 @@ void test_Controler_QSim_Routechoice_legs() { controler.getConfig().controller().setCreateGraphs(false); controler.run(); - Assert.assertTrue(person.getPlans().size() > 1); // ensure there was some replanning + Assertions.assertTrue(person.getPlans().size() > 1); // ensure there was some replanning } // TODO: make more complicated plans when testing subtour mode choice diff --git a/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java b/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java index 933fb43fbf6..e3d4651b7e0 100644 --- a/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java @@ -20,8 +20,8 @@ package org.matsim.integration.replanning; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -130,11 +130,11 @@ public void install() { manager.run(population, 0, injector.getInstance(ReplanningContext.class)); // test that everything worked as expected - assertEquals("number of plans in person.", 2, person.getPlans().size()); + assertEquals(2, person.getPlans().size(), "number of plans in person."); Plan newPlan = person.getSelectedPlan(); Leg newLeg = (Leg) newPlan.getPlanElements().get(1); assertEquals(TransportMode.walk, newLeg.getMode()); - assertNotNull("the leg should now have a route.", newLeg.getRoute()); + assertNotNull(newLeg.getRoute(), "the leg should now have a route."); } } diff --git a/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java b/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java index 2375b591263..c432538434a 100644 --- a/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java +++ b/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -130,7 +130,7 @@ private void evaluate(String plansFilename) throws MalformedURLException { new PopulationWriter(referenceScenario.getPopulation(), scenario.getNetwork()).write(utils.getOutputDirectory() + "/reference_population.xml.gz"); new PopulationWriter(scenario.getPopulation(), scenario.getNetwork()).write(utils.getOutputDirectory() + "/output_population.xml.gz"); } - Assert.assertTrue("different plans files.", isEqual); + Assertions.assertTrue(isEqual, "different plans files."); } } diff --git a/matsim/src/test/java/org/matsim/integration/replanning/ResumableRunsIT.java b/matsim/src/test/java/org/matsim/integration/replanning/ResumableRunsIT.java index 23691588cff..2b602dfd73c 100644 --- a/matsim/src/test/java/org/matsim/integration/replanning/ResumableRunsIT.java +++ b/matsim/src/test/java/org/matsim/integration/replanning/ResumableRunsIT.java @@ -20,7 +20,7 @@ package org.matsim.integration.replanning; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -89,15 +89,15 @@ void testResumableRuns() throws MalformedURLException { // comparison long cksum1 = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + "/run1/ITERS/it.10/10.plans.xml.gz"); long cksum2 = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + "/run2/ITERS/it.10/10.plans.xml.gz"); - Assert.assertEquals("Plans must not be altered just be reading in and writing out again.", cksum1, cksum2); + Assertions.assertEquals(cksum1, cksum2, "Plans must not be altered just be reading in and writing out again."); cksum1 = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + "/run1/ITERS/it.10/10.events.xml.gz"); cksum2 = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + "/run2/ITERS/it.10/10.events.xml.gz"); - Assert.assertEquals("The checksums of events must be the same when resuming runs.", cksum1, cksum2); + Assertions.assertEquals(cksum1, cksum2, "The checksums of events must be the same when resuming runs."); cksum1 = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + "/run1/ITERS/it.11/11.events.xml.gz"); cksum2 = CRCChecksum.getCRCFromFile(utils.getOutputDirectory() + "/run2/ITERS/it.11/11.events.xml.gz"); - Assert.assertEquals("The checksums of events must be the same when resuming runs.", cksum1, cksum2); + Assertions.assertEquals(cksum1, cksum2, "The checksums of events must be the same when resuming runs."); } } diff --git a/matsim/src/test/java/org/matsim/integration/timevariantnetworks/QSimIntegrationTest.java b/matsim/src/test/java/org/matsim/integration/timevariantnetworks/QSimIntegrationTest.java index 214a92bc0a0..609737eb135 100644 --- a/matsim/src/test/java/org/matsim/integration/timevariantnetworks/QSimIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/integration/timevariantnetworks/QSimIntegrationTest.java @@ -20,12 +20,12 @@ package org.matsim.integration.timevariantnetworks; -import static org.junit.Assert.assertEquals; - import java.util.ArrayList; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -116,8 +116,8 @@ void testFreespeed() { .run(); // check that we get the expected result - assertEquals("Person 1 should travel for 11 seconds.", 10.0 + 1.0, ttcalc.person1leaveTime - ttcalc.person1enterTime, MatsimTestUtils.EPSILON); - assertEquals("Person 2 should travel for 6 seconds.", 5.0 + 1.0, ttcalc.person2leaveTime - ttcalc.person2enterTime, MatsimTestUtils.EPSILON); + assertEquals(10.0 + 1.0, ttcalc.person1leaveTime - ttcalc.person1enterTime, MatsimTestUtils.EPSILON, "Person 1 should travel for 11 seconds."); + assertEquals(5.0 + 1.0, ttcalc.person2leaveTime - ttcalc.person2enterTime, MatsimTestUtils.EPSILON, "Person 2 should travel for 6 seconds."); } /** @@ -187,8 +187,8 @@ void testCapacity() { * link 3 (because of the spill-back). The last person of the second * wave should have free-flow travel time. */ - assertEquals("Person 1 should travel for 20 seconds.", 20.0, ttcalc.person1leaveTime - ttcalc.person1enterTime, MatsimTestUtils.EPSILON); - assertEquals("Person 2 should travel for 11 seconds.", 10.0 + 1.0, ttcalc.person2leaveTime - ttcalc.person2enterTime, MatsimTestUtils.EPSILON); + assertEquals(20.0, ttcalc.person1leaveTime - ttcalc.person1enterTime, MatsimTestUtils.EPSILON, "Person 1 should travel for 20 seconds."); + assertEquals(10.0 + 1.0, ttcalc.person2leaveTime - ttcalc.person2enterTime, MatsimTestUtils.EPSILON, "Person 2 should travel for 11 seconds."); } @@ -249,9 +249,9 @@ public void reset(int iteration) {} @Override public void handleEvent(LinkEnterEvent event) { if (id2.equals(event.getLinkId())) - Assert.assertEquals(1.0, event.getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1.0, event.getTime(), MatsimTestUtils.EPSILON); if (id3.equals(event.getLinkId())) - Assert.fail("Link 3 should never be reached as capacity of link 2 is set to 0"); + Assertions.fail("Link 3 should never be reached as capacity of link 2 is set to 0"); } }); @@ -261,9 +261,9 @@ public void reset(int iteration) {} @Override public void handleEvent(PersonStuckEvent event) { - Assert.assertEquals(id2, event.getLinkId()); - Assert.assertEquals(simEndTime, event.getTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals(personId, event.getPersonId()); + Assertions.assertEquals(id2, event.getLinkId()); + Assertions.assertEquals(simEndTime, event.getTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(personId, event.getPersonId()); } }); diff --git a/matsim/src/test/java/org/matsim/lanes/data/LanesReaderWriterTest.java b/matsim/src/test/java/org/matsim/lanes/data/LanesReaderWriterTest.java index 55ca134f315..3311be000ac 100644 --- a/matsim/src/test/java/org/matsim/lanes/data/LanesReaderWriterTest.java +++ b/matsim/src/test/java/org/matsim/lanes/data/LanesReaderWriterTest.java @@ -19,8 +19,8 @@ * *********************************************************************** */ package org.matsim.lanes.data; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.ArrayList; import java.util.List; diff --git a/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java b/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java index a76a672ff7a..b0ee67d400c 100644 --- a/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java +++ b/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java @@ -27,8 +27,7 @@ import java.util.Map; import jakarta.inject.Inject; - -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.runner.RunWith; @@ -110,40 +109,40 @@ public void notifyShutdown(ShutdownEvent event) { if ( config.routing().getAccessEgressType().equals(AccessEgressType.none) ) { { Double[] array = result.get(ScoreItem.worst).values().toArray(new Double[0]) ; - Assert.assertEquals(64.75686659291274, array[0], DELTA); - Assert.assertEquals(64.78366379257605, array[1], DELTA); + Assertions.assertEquals(64.75686659291274, array[0], DELTA); + Assertions.assertEquals(64.78366379257605, array[1], DELTA); } { Double[] array = result.get(ScoreItem.best).values().toArray(new Double[0]) ; - Assert.assertEquals(64.75686659291274, array[0], DELTA); - Assert.assertEquals(64.84180132563583, array[1], DELTA); + Assertions.assertEquals(64.75686659291274, array[0], DELTA); + Assertions.assertEquals(64.84180132563583, array[1], DELTA); }{ Double[] array = result.get(ScoreItem.average).values().toArray(new Double[0]) ; - Assert.assertEquals(64.75686659291274, array[0], DELTA); - Assert.assertEquals(64.81273255910591, array[1], DELTA); + Assertions.assertEquals(64.75686659291274, array[0], DELTA); + Assertions.assertEquals(64.81273255910591, array[1], DELTA); }{ Double[] array = result.get(ScoreItem.executed).values().toArray(new Double[0]) ; - Assert.assertEquals(64.75686659291274, array[0], DELTA); - Assert.assertEquals(64.84180132563583, array[1], DELTA); + Assertions.assertEquals(64.75686659291274, array[0], DELTA); + Assertions.assertEquals(64.84180132563583, array[1], DELTA); } } else { // yyyy these change with the access/egress car router, but I cannot say if the magnitude of change is plausible. kai, feb'16 // if(config.qsim().isUsingFastCapacityUpdate()) { { Double[] array = result.get(ScoreItem.worst).values().toArray(new Double[0]) ; - Assert.assertEquals(new double[]{53.18953957492432, 38.73201822323088}[0], array[0], DELTA); - Assert.assertEquals(new double[]{53.18953957492432, 38.73201822323088}[1], array[1], DELTA); + Assertions.assertEquals(new double[]{53.18953957492432, 38.73201822323088}[0], array[0], DELTA); + Assertions.assertEquals(new double[]{53.18953957492432, 38.73201822323088}[1], array[1], DELTA); }{ Double[] array = result.get(ScoreItem.best).values().toArray(new Double[0]) ; - Assert.assertEquals(new double[]{53.18953957492432, 53.2163372155953}[0], array[0], DELTA); - Assert.assertEquals(new double[]{53.18953957492432, 53.2163372155953}[1], array[1], DELTA); + Assertions.assertEquals(new double[]{53.18953957492432, 53.2163372155953}[0], array[0], DELTA); + Assertions.assertEquals(new double[]{53.18953957492432, 53.2163372155953}[1], array[1], DELTA); }{ Double[] array = result.get(ScoreItem.average).values().toArray(new Double[0]) ; - Assert.assertEquals(new double[]{53.18953957492432, 45.9741777194131}[0], array[0], DELTA); - Assert.assertEquals(new double[]{53.18953957492432, 45.9741777194131}[1], array[1], DELTA); + Assertions.assertEquals(new double[]{53.18953957492432, 45.9741777194131}[0], array[0], DELTA); + Assertions.assertEquals(new double[]{53.18953957492432, 45.9741777194131}[1], array[1], DELTA); }{ Double[] array = result.get(ScoreItem.executed).values().toArray(new Double[0]) ; - Assert.assertEquals(new double[]{53.18953957492432, 38.73201822323088}[0], array[0], DELTA); - Assert.assertEquals(new double[]{53.18953957492432, 38.73201822323088}[1], array[1], DELTA); + Assertions.assertEquals(new double[]{53.18953957492432, 38.73201822323088}[0], array[0], DELTA); + Assertions.assertEquals(new double[]{53.18953957492432, 38.73201822323088}[1], array[1], DELTA); } // } else { // { diff --git a/matsim/src/test/java/org/matsim/other/DownloadAndReadXmlTest.java b/matsim/src/test/java/org/matsim/other/DownloadAndReadXmlTest.java index a2aa6eaf190..a7dfc337995 100644 --- a/matsim/src/test/java/org/matsim/other/DownloadAndReadXmlTest.java +++ b/matsim/src/test/java/org/matsim/other/DownloadAndReadXmlTest.java @@ -19,8 +19,8 @@ package org.matsim.other; -import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -58,10 +58,10 @@ final void testHttpFromSvn() { Network network = scenario.getNetwork(); // 3 pt nodes and 4 x 4 car nodes - Assert.assertEquals(3 + 4 * 4, network.getNodes().size()); + Assertions.assertEquals(3 + 4 * 4, network.getNodes().size()); // 6 pt links and 3 links * 2 directions * 4 times in parallel * 2 (horizontally and vertically) - Assert.assertEquals(6 + 3 * 2 * 4 * 2, network.getLinks().size()); + Assertions.assertEquals(6 + 3 * 2 * 4 * 2, network.getLinks().size()); } @Test @@ -78,10 +78,10 @@ final void testHttpsFromSvn() { Network network = scenario.getNetwork(); // 3 pt nodes and 4 x 4 car nodes - Assert.assertEquals(3 + 4 * 4, network.getNodes().size()); + Assertions.assertEquals(3 + 4 * 4, network.getNodes().size()); // 6 pt links and 3 links * 2 directions * 4 times in parallel * 2 (horizontally and vertically) - Assert.assertEquals(6 + 3 * 2 * 4 * 2, network.getLinks().size()); + Assertions.assertEquals(6 + 3 * 2 * 4 * 2, network.getLinks().size()); } } diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourComplexTripsTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourComplexTripsTest.java index bcf1d9d33ee..4f65ed8e50d 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourComplexTripsTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourComplexTripsTest.java @@ -24,7 +24,7 @@ import java.util.Collection; import java.util.List; import java.util.Random; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -482,17 +482,17 @@ void testMutatedTrips() { final List newTrips = TripStructureUtils.getTrips( plan ); - Assert.assertEquals( - "number of trips changed with mode mutation!?", + Assertions.assertEquals( initNTrips, - newTrips.size()); + newTrips.size(), + "number of trips changed with mode mutation!?"); final Collection newSubtours = TripStructureUtils.getSubtours( plan ); - Assert.assertEquals( - "number of subtours changed with mode mutation!?", + Assertions.assertEquals( initSubtours.size(), - newSubtours.size()); + newSubtours.size(), + "number of subtours changed with mode mutation!?"); final List mutated = new ArrayList(); for ( Subtour newSubtour : newSubtours ) { @@ -501,9 +501,9 @@ void testMutatedTrips() { } } - Assert.assertFalse( - "no mutated subtours", - mutated.isEmpty() ); + Assertions.assertFalse( + mutated.isEmpty(), + "no mutated subtours" ); int nMutatedWithoutMutatedFather = 0; for ( Subtour s : mutated ) { @@ -512,17 +512,17 @@ void testMutatedTrips() { } for ( Trip t : s.getTrips() ) { - Assert.assertEquals( - "unexpected mutated trip length", + Assertions.assertEquals( 1, - t.getTripElements().size()); + t.getTripElements().size(), + "unexpected mutated trip length"); } } - Assert.assertEquals( - "unexpected number of roots in mutated subtours", + Assertions.assertEquals( 1, - nMutatedWithoutMutatedFather); + nMutatedWithoutMutatedFather, + "unexpected number of roots in mutated subtours"); } } } diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourDiffModesTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourDiffModesTest.java index 95030f763d7..cac43bb101c 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourDiffModesTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourDiffModesTest.java @@ -24,7 +24,7 @@ import java.util.Collection; import java.util.List; import java.util.Random; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -133,17 +133,17 @@ void testMutatedTrips() { final List newTrips = TripStructureUtils.getTrips( plan ); - Assert.assertEquals( - "number of trips changed with mode mutation!?", + Assertions.assertEquals( initNTrips, - newTrips.size()); + newTrips.size(), + "number of trips changed with mode mutation!?"); final Collection newSubtours = TripStructureUtils.getSubtours( plan ); - Assert.assertEquals( - "number of subtours changed with mode mutation!?", + Assertions.assertEquals( initSubtours.size(), - newSubtours.size()); + newSubtours.size(), + "number of subtours changed with mode mutation!?"); final List mutated = new ArrayList(); for ( Subtour newSubtour : newSubtours ) { @@ -152,9 +152,9 @@ void testMutatedTrips() { } } - Assert.assertFalse( - "no mutated subtours", - mutated.isEmpty() ); + Assertions.assertFalse( + mutated.isEmpty(), + "no mutated subtours" ); int nMutatedWithoutMutatedFather = 0; for ( Subtour s : mutated ) { @@ -163,17 +163,17 @@ void testMutatedTrips() { } for ( Trip t : s.getTrips() ) { - Assert.assertEquals( - "unexpected mutated trip length", + Assertions.assertEquals( 1, - t.getTripElements().size()); + t.getTripElements().size(), + "unexpected mutated trip length"); } } - Assert.assertEquals( - "unexpected number of roots in mutated subtours", + Assertions.assertEquals( 1, - nMutatedWithoutMutatedFather); + nMutatedWithoutMutatedFather, + "unexpected number of roots in mutated subtours"); for ( Subtour subtour : newSubtours ) { @@ -223,16 +223,16 @@ private void checkSubtour(Subtour subtour) { } if (atLeastOneSubtourWithDifferentChainBasedModes) { - Assert.fail("Two different modes during one subtour where one of the two different modes is a chain-based mode."); + Assertions.fail("Two different modes during one subtour where one of the two different modes is a chain-based mode."); } if (this.probaForRandomSingleTripMode > 0.) { if (atLeastOneSubtourWithDifferentNonChainBasedModes == false) { - Assert.fail("There is not a single subtour with different non-chain-based modes even though the probability for random single trip mode is " + this.probaForRandomSingleTripMode); + Assertions.fail("There is not a single subtour with different non-chain-based modes even though the probability for random single trip mode is " + this.probaForRandomSingleTripMode); } } else { if (atLeastOneSubtourWithDifferentNonChainBasedModes == true) { - Assert.fail("There is at least one subtour with different non-chain-based modes even though the probability for random single trip mode is " + this.probaForRandomSingleTripMode); + Assertions.fail("There is at least one subtour with different non-chain-based modes even though the probability for random single trip mode is " + this.probaForRandomSingleTripMode); } } } diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourTest.java index 091cb019655..e6dc7997e19 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourTest.java @@ -21,7 +21,7 @@ package org.matsim.population.algorithms; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.ArrayList; import java.util.Arrays; @@ -197,9 +197,9 @@ void testSingleTripSubtourHandling() { testee.run(plan); assertEquals( - "unexpected plan size", 3, - plan.getPlanElements().size()); + plan.getPlanElements().size(), + "unexpected plan size"); final Leg newLeg = (Leg) plan.getPlanElements().get( 1 ); @@ -214,11 +214,11 @@ void testSingleTripSubtourHandling() { } } assertTrue( + hasCar && hasPt && hasWalk, "expected subtours with car, pt and walk, got"+ (hasCar ? " car" : " NO car")+","+ (hasPt ? " pt" : " NO pt")+","+ - (hasWalk ? " walk" : " NO walk"), - hasCar && hasPt && hasWalk); + (hasWalk ? " walk" : " NO walk")); } { // test with special single trip subtour settings testee.setSingleTripSubtourModes(new String[] {"pt", "walk"}); @@ -230,9 +230,9 @@ void testSingleTripSubtourHandling() { testee.run(plan); assertEquals( - "unexpected plan size", 3, - plan.getPlanElements().size()); + plan.getPlanElements().size(), + "unexpected plan size"); final Leg newLeg = (Leg) plan.getPlanElements().get( 1 ); @@ -247,11 +247,11 @@ void testSingleTripSubtourHandling() { } } assertTrue( + !hasCar && hasPt && hasWalk, "expected subtours with NO car, pt and walk, got"+ (hasCar ? " car" : " NO car")+","+ (hasPt ? " pt" : " NO pt")+","+ - (hasWalk ? " walk" : " NO walk"), - !hasCar && hasPt && hasWalk); + (hasWalk ? " walk" : " NO walk")); } } @@ -401,17 +401,17 @@ private void testCarDoesntTeleport(Network network, String originalMode, String Id nextLocation = nextActivity.getLinkId(); if (nextLeg.getMode().equals(TransportMode.car)) { assertEquals( - "wrong car location at leg "+legCount+" in "+plan.getPlanElements(), currentLocation, - carLocation); + carLocation, + "wrong car location at leg "+legCount+" in "+plan.getPlanElements()); carLocation = nextLocation; } currentLocation = nextLocation; } assertEquals( - "wrong car location at the end of "+plan.getPlanElements(), firstLocation, - carLocation); + carLocation, + "wrong car location at the end of "+plan.getPlanElements()); } } @@ -435,17 +435,17 @@ private void testCarDoesntTeleport(ActivityFacilities facilities, String origina Id nextLocation = nextActivity.getLinkId(); if (nextLeg.getMode().equals(TransportMode.car)) { assertEquals( - "wrong car location at leg "+legCount+" in "+plan.getPlanElements(), currentLocation, - carLocation); + carLocation, + "wrong car location at leg "+legCount+" in "+plan.getPlanElements()); carLocation = nextLocation; } currentLocation = nextLocation; } assertEquals( - "wrong car location at the end of "+plan.getPlanElements(), firstLocation, - carLocation); + carLocation, + "wrong car location at the end of "+plan.getPlanElements()); } } @@ -460,9 +460,9 @@ private static void assertSubTourMutated( TripStructureUtils.getSubtours( plan ); assertEquals( - "number of subtour changed", originalSubtours.size(), - mutatedSubtours.size()); + mutatedSubtours.size(), + "number of subtour changed"); final List mutateds = new ArrayList(); for (Subtour mutated : mutatedSubtours) { @@ -472,14 +472,14 @@ private static void assertSubTourMutated( for (Trip trip : mutated.getTripsWithoutSubSubtours()) { if ( expectedMode.equals( trip.getLegsOnly().get( 0 ).getMode() ) ) { assertTrue( - "inconsistent mode chain", - isFirst || containsMutatedMode ); + isFirst || containsMutatedMode, + "inconsistent mode chain" ); containsMutatedMode = true; } else { assertFalse( - "inconsistent mode chain", - containsMutatedMode ); + containsMutatedMode, + "inconsistent mode chain" ); } isFirst = false; } @@ -488,8 +488,8 @@ private static void assertSubTourMutated( } assertFalse( - "no mutated subtour", - mutateds.isEmpty() ); + mutateds.isEmpty(), + "no mutated subtour" ); int nMutatedWithoutMutatedFather = 0; for ( Subtour s : mutateds ) { @@ -499,9 +499,9 @@ private static void assertSubTourMutated( } assertEquals( - "unexpected number of roots in mutated subtours", 1, - nMutatedWithoutMutatedFather); + nMutatedWithoutMutatedFather, + "unexpected number of roots in mutated subtours"); } private static Plan createPlan(ActivityFacilities facilities, String facString, String mode) { diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeTest.java index 3e9b98977f7..5813718f3fb 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeTest.java @@ -20,7 +20,7 @@ package org.matsim.population.algorithms; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.Random; @@ -60,7 +60,7 @@ void testRandomChoice() { String previousMode = leg.getMode(); for (int i = 0; i < 10; i++) { algo.run(plan); - assertNotSame("leg mode must have changed.", previousMode, leg.getMode()); + assertNotSame(previousMode, leg.getMode(), "leg mode must have changed."); previousMode = leg.getMode(); if (TransportMode.car.equals(previousMode)) { foundCarMode = true; @@ -72,9 +72,9 @@ void testRandomChoice() { fail("unexpected mode: " + previousMode); } } - assertTrue("expected to find car-mode", foundCarMode); - assertTrue("expected to find pt-mode", foundPtMode); - assertTrue("expected to find walk-mode", foundWalkMode); + assertTrue(foundCarMode, "expected to find car-mode"); + assertTrue(foundPtMode, "expected to find pt-mode"); + assertTrue(foundWalkMode, "expected to find walk-mode"); } @Test @@ -90,7 +90,7 @@ void testRandomChoiceWithinListedModesOnly() { String previousMode = leg.getMode(); for (int i = 0; i < 10; i++) { algo.run(plan); - assertNotSame("leg mode must have changed.", previousMode, leg.getMode()); + assertNotSame(previousMode, leg.getMode(), "leg mode must have changed."); previousMode = leg.getMode(); if (TransportMode.car.equals(previousMode)) { foundCarMode = true; @@ -102,9 +102,9 @@ void testRandomChoiceWithinListedModesOnly() { fail("unexpected mode: " + previousMode); } } - assertTrue("expected to find car-mode", foundCarMode); - assertTrue("expected to find pt-mode", foundPtMode); - assertTrue("expected to find walk-mode", foundWalkMode); + assertTrue(foundCarMode, "expected to find car-mode"); + assertTrue(foundPtMode, "expected to find pt-mode"); + assertTrue(foundWalkMode, "expected to find walk-mode"); } @Test @@ -116,7 +116,7 @@ void testRandomChoiceWithinListedModesOnlyWorks() { PopulationUtils.createAndAddActivityFromCoord(plan, "work", new Coord((double) 0, (double) 0)); String previousMode = leg.getMode(); algo.run(plan); - assertSame("leg mode must have changed.", previousMode, leg.getMode()); + assertSame(previousMode, leg.getMode(), "leg mode must have changed."); } @@ -152,9 +152,9 @@ void testMultipleLegs() { PopulationUtils.createAndAddLeg( plan, TransportMode.car ); PopulationUtils.createAndAddActivityFromCoord(plan, "home", new Coord((double) 0, (double) 0)); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode()); - assertEquals("unexpected leg mode in leg 2.", TransportMode.pt, ((Leg) plan.getPlanElements().get(3)).getMode()); - assertEquals("unexpected leg mode in leg 3.", TransportMode.pt, ((Leg) plan.getPlanElements().get(5)).getMode()); + assertEquals(TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); + assertEquals(TransportMode.pt, ((Leg) plan.getPlanElements().get(3)).getMode(), "unexpected leg mode in leg 2."); + assertEquals(TransportMode.pt, ((Leg) plan.getPlanElements().get(5)).getMode(), "unexpected leg mode in leg 3."); } @Test @@ -168,11 +168,11 @@ void testIgnoreCarAvailability_Never() { PopulationUtils.createAndAddLeg( plan, TransportMode.pt ); PopulationUtils.createAndAddActivityFromCoord(plan, "work", new Coord((double) 0, (double) 0)); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.bike, ((Leg) plan.getPlanElements().get(1)).getMode()); + assertEquals(TransportMode.bike, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode()); + assertEquals(TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.bike, ((Leg) plan.getPlanElements().get(1)).getMode()); + assertEquals(TransportMode.bike, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); } @Test @@ -186,7 +186,7 @@ void testIgnoreCarAvailability_Never_noChoice() { PopulationUtils.createAndAddLeg( plan, TransportMode.pt ); PopulationUtils.createAndAddActivityFromCoord(plan, "work", new Coord((double) 0, (double) 0)); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode()); + assertEquals(TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); } @Test @@ -200,13 +200,13 @@ void testIgnoreCarAvailability_Always() { PopulationUtils.createAndAddLeg( plan, TransportMode.pt ); PopulationUtils.createAndAddActivityFromCoord(plan, "work", new Coord((double) 0, (double) 0)); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.bike, ((Leg) plan.getPlanElements().get(1)).getMode()); + assertEquals(TransportMode.bike, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.car, ((Leg) plan.getPlanElements().get(1)).getMode()); + assertEquals(TransportMode.car, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode()); + assertEquals(TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.car, ((Leg) plan.getPlanElements().get(1)).getMode()); + assertEquals(TransportMode.car, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); } } diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomSingleLegModeTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomSingleLegModeTest.java index c8e4b31cefa..4acfb093c05 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomSingleLegModeTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomSingleLegModeTest.java @@ -20,13 +20,10 @@ package org.matsim.population.algorithms; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.util.Random; -import org.junit.Assert; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -68,9 +65,9 @@ void testRandomChoice() { fail("unexpected mode: " + mode); } } - assertTrue("expected to find car-mode", foundCarMode); - assertTrue("expected to find pt-mode", foundPtMode); - assertTrue("expected to find walk-mode", foundWalkMode); + assertTrue(foundCarMode, "expected to find car-mode"); + assertTrue(foundPtMode, "expected to find pt-mode"); + assertTrue(foundWalkMode, "expected to find walk-mode"); } @@ -97,9 +94,9 @@ void testRandomChoiceWithListedModesOnly() { fail("unexpected mode: " + mode); } } - assertTrue("expected to find car-mode", foundCarMode); - assertTrue("expected to find pt-mode", foundPtMode); - assertTrue("expected to find walk-mode", foundWalkMode); + assertTrue(foundCarMode, "expected to find car-mode"); + assertTrue(foundPtMode, "expected to find pt-mode"); + assertTrue(foundWalkMode, "expected to find walk-mode"); } @Test @@ -111,7 +108,7 @@ void testRandomChoiceWithListedModesOnlyAndDifferentFromMode() { PopulationUtils.createAndAddActivityFromCoord(plan, "work", new Coord((double) 0, (double) 0)); algo.run(plan); String mode = leg.getMode(); - Assert.assertSame(TransportMode.car, mode); + Assertions.assertSame(TransportMode.car, mode); } @Test @@ -186,13 +183,13 @@ void testIgnoreCarAvailability_Never() { PopulationUtils.createAndAddLeg( plan, TransportMode.pt ); PopulationUtils.createAndAddActivityFromCoord(plan, "work", new Coord((double) 0, (double) 0)); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.bike, ((Leg) plan.getPlanElements().get(1)).getMode()); + assertEquals(TransportMode.bike, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode()); + assertEquals(TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.bike, ((Leg) plan.getPlanElements().get(1)).getMode()); + assertEquals(TransportMode.bike, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode()); + assertEquals(TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); } @Test @@ -206,7 +203,7 @@ void testIgnoreCarAvailability_Never_noChoice() { PopulationUtils.createAndAddLeg( plan, TransportMode.pt ); PopulationUtils.createAndAddActivityFromCoord(plan, "work", new Coord((double) 0, (double) 0)); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode()); + assertEquals(TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); } @Test @@ -220,13 +217,13 @@ void testIgnoreCarAvailability_Always() { PopulationUtils.createAndAddLeg( plan, TransportMode.pt ); PopulationUtils.createAndAddActivityFromCoord(plan, "work", new Coord((double) 0, (double) 0)); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.car, ((Leg) plan.getPlanElements().get(1)).getMode()); + assertEquals(TransportMode.car, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode()); + assertEquals(TransportMode.pt, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.car, ((Leg) plan.getPlanElements().get(1)).getMode()); + assertEquals(TransportMode.car, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); algo.run(plan); - assertEquals("unexpected leg mode in leg 1.", TransportMode.bike, ((Leg) plan.getPlanElements().get(1)).getMode()); + assertEquals(TransportMode.bike, ((Leg) plan.getPlanElements().get(1)).getMode(), "unexpected leg mode in leg 1."); } } diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ParallelPersonAlgorithmRunnerTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ParallelPersonAlgorithmRunnerTest.java index 319411270e0..5090918a377 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ParallelPersonAlgorithmRunnerTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ParallelPersonAlgorithmRunnerTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -54,11 +54,11 @@ void testNumberOfThreads() { PersonAlgorithmTester algo = new PersonAlgorithmTester(); PersonAlgoProviderTester tester = new PersonAlgoProviderTester(algo); ParallelPersonAlgorithmUtils.run(population, 2, tester); - Assert.assertEquals(2, tester.counter); + Assertions.assertEquals(2, tester.counter); PersonAlgoProviderTester tester2 = new PersonAlgoProviderTester(algo); ParallelPersonAlgorithmUtils.run(population, 4, tester2); - Assert.assertEquals(4, tester2.counter); + Assertions.assertEquals(4, tester2.counter); } /** @@ -77,7 +77,7 @@ void testNofPersons() { final PersonAlgorithmTester tester = new PersonAlgorithmTester(); ParallelPersonAlgorithmUtils.run(population, 2, tester); - Assert.assertEquals(100, tester.personIds.size()); + Assertions.assertEquals(100, tester.personIds.size()); // test that all 100 different persons got handled, and not 1 person 100 times int sum = 0; @@ -87,7 +87,7 @@ void testNofPersons() { sumRef += i; sum += Integer.parseInt(population.getPersons().get(tester.personIds.get(i)).getId().toString()); } - Assert.assertEquals(sumRef, sum); + Assertions.assertEquals(sumRef, sum); } @Test @@ -105,7 +105,7 @@ public void run(Person person) { person.getPlans().get(0).setScore(null); // this will result in an IndexOutOfBoundsException } }); - Assert.fail("Expected Exception, got none."); + Assertions.fail("Expected Exception, got none."); } catch (RuntimeException e) { LogManager.getLogger(ParallelPersonAlgorithmRunnerTest.class).info("Catched expected exception.", e); } diff --git a/matsim/src/test/java/org/matsim/population/algorithms/PermissibleModesCalculatorImplTest.java b/matsim/src/test/java/org/matsim/population/algorithms/PermissibleModesCalculatorImplTest.java index e4889cb2097..02181c75683 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/PermissibleModesCalculatorImplTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/PermissibleModesCalculatorImplTest.java @@ -19,8 +19,8 @@ * *********************************************************************** */ package org.matsim.population.algorithms; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.Arrays; @@ -141,13 +141,13 @@ private static void assertListsAreCompatible( final List expected, final Collection actual) { assertEquals( - expected+" and "+actual+" have incompatible sizes for fixture "+fixtureName, expected.size(), - actual.size()); + actual.size(), + expected+" and "+actual+" have incompatible sizes for fixture "+fixtureName); assertTrue( - expected+" and "+actual+" are not compatible for fixture "+fixtureName, - expected.containsAll( actual )); + expected.containsAll( actual ), + expected+" and "+actual+" are not compatible for fixture "+fixtureName); } } diff --git a/matsim/src/test/java/org/matsim/population/algorithms/PersonPrepareForSimTest.java b/matsim/src/test/java/org/matsim/population/algorithms/PersonPrepareForSimTest.java index f7766a370df..883bef1aa26 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/PersonPrepareForSimTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/PersonPrepareForSimTest.java @@ -22,8 +22,8 @@ import java.util.HashSet; import java.util.Set; -import org.junit.Assert; import org.junit.Ignore; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -85,8 +85,8 @@ void testRun_MultimodalNetwork() { new PersonPrepareForSim(new DummyRouter(), sc).run(person); - Assert.assertEquals(link1id, activity1.getLinkId()); - Assert.assertEquals(link1id, activity2.getLinkId()); // must also be linked to l1, as l2 has no car mode + Assertions.assertEquals(link1id, activity1.getLinkId()); + Assertions.assertEquals(link1id, activity2.getLinkId()); // must also be linked to l1, as l2 has no car mode } @Test @@ -117,8 +117,8 @@ void testRun_MultimodalScenario() { new PersonPrepareForSim(new DummyRouter(), sc).run(person); - Assert.assertEquals(link1id, a1.getLinkId()); - Assert.assertEquals(link1id, a2.getLinkId()); // must also be linked to l1, as l2 has no car mode + Assertions.assertEquals(link1id, a1.getLinkId()); + Assertions.assertEquals(link1id, a2.getLinkId()); // must also be linked to l1, as l2 has no car mode } @Test @@ -145,8 +145,9 @@ void testSingleLegTripRoutingMode() { new PersonPrepareForSim(new DummyRouter(), sc).run(person); - Assert.assertEquals("wrong routing mode!", TransportMode.pt, - TripStructureUtils.getRoutingMode(leg)); + Assertions.assertEquals(TransportMode.pt, + TripStructureUtils.getRoutingMode(leg), + "wrong routing mode!"); } // test routing mode set @@ -167,8 +168,9 @@ void testSingleLegTripRoutingMode() { new PersonPrepareForSim(new DummyRouter(), sc).run(person); - Assert.assertEquals("wrong routing mode!", TransportMode.pt, - TripStructureUtils.getRoutingMode(leg)); + Assertions.assertEquals(TransportMode.pt, + TripStructureUtils.getRoutingMode(leg), + "wrong routing mode!"); } } @@ -204,7 +206,7 @@ void testSingleFallbackModeLegTrip() { try { new PersonPrepareForSim(new DummyRouter(), sc).run(person); - Assert.fail("expected Exception, got none."); + Assertions.fail("expected Exception, got none."); } catch (RuntimeException expected) {} } @@ -226,9 +228,10 @@ void testSingleFallbackModeLegTrip() { new PersonPrepareForSim(new DummyRouter(), sc).run(person); - Assert.assertEquals("wrong leg mode replacement", "drt67_fallback", leg.getMode()); - Assert.assertEquals("wrong routing mode set", "drt67_fallback", - TripStructureUtils.getRoutingMode(leg)); + Assertions.assertEquals("drt67_fallback", leg.getMode(), "wrong leg mode replacement"); + Assertions.assertEquals("drt67_fallback", + TripStructureUtils.getRoutingMode(leg), + "wrong routing mode set"); } } @@ -268,14 +271,14 @@ void testCorrectTripsRemainUnchanged() { new PersonPrepareForSim(new DummyRouter(), sc).run(person); // Check leg modes remain unchanged - Assert.assertEquals("wrong routing mode!", TransportMode.walk, leg1.getMode()); - Assert.assertEquals("wrong routing mode!", TransportMode.car, leg2.getMode()); - Assert.assertEquals("wrong routing mode!", TransportMode.walk, leg3.getMode()); + Assertions.assertEquals(TransportMode.walk, leg1.getMode(), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.car, leg2.getMode(), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.walk, leg3.getMode(), "wrong routing mode!"); // Check routing mode: - Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg1)); - Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg2)); - Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg3)); + Assertions.assertEquals(TransportMode.car, TripStructureUtils.getRoutingMode(leg1), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.car, TripStructureUtils.getRoutingMode(leg2), "wrong routing mode!"); + Assertions.assertEquals(TransportMode.car, TripStructureUtils.getRoutingMode(leg3), "wrong routing mode!"); } // test complicated intermodal trip with consistent routing modes passes unchanged @@ -345,17 +348,17 @@ void testCorrectTripsRemainUnchanged() { new PersonPrepareForSim(new DummyRouter(), sc).run(person); - Assert.assertEquals("wrong routing mode set", TransportMode.pt, TripStructureUtils.getRoutingMode(leg1)); - Assert.assertEquals("wrong routing mode set", TransportMode.pt, TripStructureUtils.getRoutingMode(leg2)); - Assert.assertEquals("wrong routing mode set", TransportMode.pt, TripStructureUtils.getRoutingMode(leg3)); - Assert.assertEquals("wrong routing mode set", TransportMode.pt, TripStructureUtils.getRoutingMode(leg4)); - Assert.assertEquals("wrong routing mode set", TransportMode.pt, TripStructureUtils.getRoutingMode(leg5)); - Assert.assertEquals("wrong routing mode set", TransportMode.pt, TripStructureUtils.getRoutingMode(leg6)); - Assert.assertEquals("wrong routing mode set", TransportMode.pt, TripStructureUtils.getRoutingMode(leg7)); - Assert.assertEquals("wrong routing mode set", TransportMode.pt, TripStructureUtils.getRoutingMode(leg8)); - Assert.assertEquals("wrong routing mode set", TransportMode.pt, TripStructureUtils.getRoutingMode(leg9)); - Assert.assertEquals("wrong routing mode set", TransportMode.pt, TripStructureUtils.getRoutingMode(leg10)); - Assert.assertEquals("wrong routing mode set", TransportMode.pt, TripStructureUtils.getRoutingMode(leg11)); + Assertions.assertEquals(TransportMode.pt, TripStructureUtils.getRoutingMode(leg1), "wrong routing mode set"); + Assertions.assertEquals(TransportMode.pt, TripStructureUtils.getRoutingMode(leg2), "wrong routing mode set"); + Assertions.assertEquals(TransportMode.pt, TripStructureUtils.getRoutingMode(leg3), "wrong routing mode set"); + Assertions.assertEquals(TransportMode.pt, TripStructureUtils.getRoutingMode(leg4), "wrong routing mode set"); + Assertions.assertEquals(TransportMode.pt, TripStructureUtils.getRoutingMode(leg5), "wrong routing mode set"); + Assertions.assertEquals(TransportMode.pt, TripStructureUtils.getRoutingMode(leg6), "wrong routing mode set"); + Assertions.assertEquals(TransportMode.pt, TripStructureUtils.getRoutingMode(leg7), "wrong routing mode set"); + Assertions.assertEquals(TransportMode.pt, TripStructureUtils.getRoutingMode(leg8), "wrong routing mode set"); + Assertions.assertEquals(TransportMode.pt, TripStructureUtils.getRoutingMode(leg9), "wrong routing mode set"); + Assertions.assertEquals(TransportMode.pt, TripStructureUtils.getRoutingMode(leg10), "wrong routing mode set"); + Assertions.assertEquals(TransportMode.pt, TripStructureUtils.getRoutingMode(leg11), "wrong routing mode set"); } } @@ -392,7 +395,7 @@ void testRoutingModeConsistency() { try { new PersonPrepareForSim(new DummyRouter(), sc).run(person); - Assert.fail("expected Exception, got none."); + Assertions.fail("expected Exception, got none."); } catch (RuntimeException expected) {} } @@ -423,7 +426,7 @@ void testRoutingModeConsistency() { try { new PersonPrepareForSim(new DummyRouter(), sc).run(person); - Assert.fail("expected Exception, got none."); + Assertions.fail("expected Exception, got none."); } catch (RuntimeException expected) {} } } @@ -467,13 +470,13 @@ void testReplaceExperimentalTransitRoute() { new PersonPrepareForSim(new DummyRouter(), sc).run(person); - Assert.assertEquals(DefaultTransitPassengerRoute.ROUTE_TYPE, leg.getRoute().getRouteType()); - Assert.assertEquals(startLink, leg.getRoute().getStartLinkId()); - Assert.assertEquals(endLink, leg.getRoute().getEndLinkId()); - Assert.assertEquals(stopFacility1.getId(), ((DefaultTransitPassengerRoute) leg.getRoute()).getAccessStopId()); - Assert.assertEquals(stopFacility2.getId(), ((DefaultTransitPassengerRoute) leg.getRoute()).getEgressStopId()); - Assert.assertEquals(line, ((DefaultTransitPassengerRoute) leg.getRoute()).getLineId()); - Assert.assertEquals(route, ((DefaultTransitPassengerRoute) leg.getRoute()).getRouteId()); + Assertions.assertEquals(DefaultTransitPassengerRoute.ROUTE_TYPE, leg.getRoute().getRouteType()); + Assertions.assertEquals(startLink, leg.getRoute().getStartLinkId()); + Assertions.assertEquals(endLink, leg.getRoute().getEndLinkId()); + Assertions.assertEquals(stopFacility1.getId(), ((DefaultTransitPassengerRoute) leg.getRoute()).getAccessStopId()); + Assertions.assertEquals(stopFacility2.getId(), ((DefaultTransitPassengerRoute) leg.getRoute()).getEgressStopId()); + Assertions.assertEquals(line, ((DefaultTransitPassengerRoute) leg.getRoute()).getLineId()); + Assertions.assertEquals(route, ((DefaultTransitPassengerRoute) leg.getRoute()).getRouteId()); } private static class DummyRouter implements PlanAlgorithm { diff --git a/matsim/src/test/java/org/matsim/population/algorithms/TripsToLegsAlgorithmTest.java b/matsim/src/test/java/org/matsim/population/algorithms/TripsToLegsAlgorithmTest.java index 2cb4da8a744..4f3f75738b7 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/TripsToLegsAlgorithmTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/TripsToLegsAlgorithmTest.java @@ -19,8 +19,8 @@ * *********************************************************************** */ package org.matsim.population.algorithms; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.Iterator; @@ -239,9 +239,9 @@ private static void performTest(final Fixture fixture) { algorithm.run( fixture.plan ); assertEquals( - "wrong structure size for fixture <<"+fixture.name+">>", fixture.expectedPlanStructure.size(), - fixture.plan.getPlanElements().size()); + fixture.plan.getPlanElements().size(), + "wrong structure size for fixture <<"+fixture.name+">>"); final Iterator expIter = fixture.expectedPlanStructure.iterator(); final Iterator actualIter = fixture.plan.getPlanElements().iterator(); @@ -252,23 +252,23 @@ private static void performTest(final Fixture fixture) { if ( actual instanceof Activity ) { assertTrue( - "incompatible Activity/Leg sequence in fixture <<"+fixture.name+">>", - expected instanceof Activity ); + expected instanceof Activity, + "incompatible Activity/Leg sequence in fixture <<"+fixture.name+">>" ); assertEquals( - "incompatible activity types in fixture <<"+fixture.name+">>", ((Activity) expected).getType(), - ((Activity) actual).getType()); + ((Activity) actual).getType(), + "incompatible activity types in fixture <<"+fixture.name+">>"); } else if ( actual instanceof Leg ) { assertTrue( - "incompatible types sequence in fixture <<"+fixture.name+">>", - expected instanceof Leg ); + expected instanceof Leg, + "incompatible types sequence in fixture <<"+fixture.name+">>" ); assertEquals( - "incompatible leg modes in fixture <<"+fixture.name+">>", ((Leg) expected).getMode(), - ((Leg) actual).getMode()); + ((Leg) actual).getMode(), + "incompatible leg modes in fixture <<"+fixture.name+">>"); } else { throw new RuntimeException( actual.getClass().getName() ); diff --git a/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadIntegrationTest.java b/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadIntegrationTest.java index d6b291abc83..6d640a9378c 100644 --- a/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadIntegrationTest.java @@ -19,7 +19,7 @@ package org.matsim.pt.analysis; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -71,6 +71,6 @@ public void notifyStartup(StartupEvent event) { Departure departure = route.getDepartures().get(Id.create("07", Departure.class)); int load = transitload.getLoadAtDeparture(line, route, stopFacility, departure); - Assert.assertEquals("wrong number of passengers.", 4, load); + Assertions.assertEquals(4, load, "wrong number of passengers."); } } diff --git a/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadTest.java b/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadTest.java index 8e8aa411ba8..b6ecf76b5e0 100644 --- a/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadTest.java +++ b/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadTest.java @@ -23,7 +23,7 @@ import java.util.Collections; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -114,48 +114,48 @@ void testTransitLoad_singleLine() { tl.handleEvent(new PersonLeavesVehicleEvent(7.45*3600-20, Id.create("ptDriver1", Person.class), vehicleIdDep1)); - Assert.assertEquals(1, tl.getLoadAtDeparture(line1, route1, stop1, dep1)); - Assert.assertEquals(2, tl.getLoadAtDeparture(line1, route1, stop2, dep1)); - Assert.assertEquals(2, tl.getLoadAtDeparture(line1, route1, stop3, dep1)); - Assert.assertEquals(2, tl.getLoadAtDeparture(line1, route1, stop4, dep1)); + Assertions.assertEquals(1, tl.getLoadAtDeparture(line1, route1, stop1, dep1)); + Assertions.assertEquals(2, tl.getLoadAtDeparture(line1, route1, stop2, dep1)); + Assertions.assertEquals(2, tl.getLoadAtDeparture(line1, route1, stop3, dep1)); + Assertions.assertEquals(2, tl.getLoadAtDeparture(line1, route1, stop4, dep1)); - Assert.assertEquals(1, tl.getLoadAtDeparture(line1, route1, 0, dep1)); - Assert.assertEquals(2, tl.getLoadAtDeparture(line1, route1, 1, dep1)); - Assert.assertEquals(2, tl.getLoadAtDeparture(line1, route1, 2, dep1)); - Assert.assertEquals(2, tl.getLoadAtDeparture(line1, route1, 3, dep1)); - Assert.assertEquals(0, tl.getLoadAtDeparture(line1, route1, 4, dep1)); + Assertions.assertEquals(1, tl.getLoadAtDeparture(line1, route1, 0, dep1)); + Assertions.assertEquals(2, tl.getLoadAtDeparture(line1, route1, 1, dep1)); + Assertions.assertEquals(2, tl.getLoadAtDeparture(line1, route1, 2, dep1)); + Assertions.assertEquals(2, tl.getLoadAtDeparture(line1, route1, 3, dep1)); + Assertions.assertEquals(0, tl.getLoadAtDeparture(line1, route1, 4, dep1)); TransitLoad.StopInformation si = tl.getDepartureStopInformation(line1, route1, stop1, dep1).get(0); - Assert.assertEquals(7.0*3600-10, si.arrivalTime, MatsimTestUtils.EPSILON); - Assert.assertEquals(7.0*3600+10, si.departureTime, MatsimTestUtils.EPSILON); - Assert.assertEquals(1, si.nOfEntering); - Assert.assertEquals(0, si.nOfLeaving); + Assertions.assertEquals(7.0*3600-10, si.arrivalTime, MatsimTestUtils.EPSILON); + Assertions.assertEquals(7.0*3600+10, si.departureTime, MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, si.nOfEntering); + Assertions.assertEquals(0, si.nOfLeaving); si = tl.getDepartureStopInformation(line1, route1, stop2, dep1).get(0); - Assert.assertEquals(7.1*3600-25, si.arrivalTime, MatsimTestUtils.EPSILON); - Assert.assertEquals(7.1*3600+25, si.departureTime, MatsimTestUtils.EPSILON); - Assert.assertEquals(2, si.nOfEntering); - Assert.assertEquals(1, si.nOfLeaving); + Assertions.assertEquals(7.1*3600-25, si.arrivalTime, MatsimTestUtils.EPSILON); + Assertions.assertEquals(7.1*3600+25, si.departureTime, MatsimTestUtils.EPSILON); + Assertions.assertEquals(2, si.nOfEntering); + Assertions.assertEquals(1, si.nOfLeaving); si = tl.getDepartureStopInformation(line1, route1, stop3, dep1).get(0); - Assert.assertEquals(7.2*3600-15, si.arrivalTime, MatsimTestUtils.EPSILON); - Assert.assertEquals(7.2*3600+20, si.departureTime, MatsimTestUtils.EPSILON); - Assert.assertEquals(1, si.nOfEntering); - Assert.assertEquals(1, si.nOfLeaving); + Assertions.assertEquals(7.2*3600-15, si.arrivalTime, MatsimTestUtils.EPSILON); + Assertions.assertEquals(7.2*3600+20, si.departureTime, MatsimTestUtils.EPSILON); + Assertions.assertEquals(1, si.nOfEntering); + Assertions.assertEquals(1, si.nOfLeaving); si = tl.getDepartureStopInformation(line1, route1, stop4, dep1).get(0); - Assert.assertEquals(7.3*3600-20, si.arrivalTime, MatsimTestUtils.EPSILON); - Assert.assertEquals(7.3*3600+5, si.departureTime, MatsimTestUtils.EPSILON); - Assert.assertEquals(0, si.nOfEntering); - Assert.assertEquals(0, si.nOfLeaving); + Assertions.assertEquals(7.3*3600-20, si.arrivalTime, MatsimTestUtils.EPSILON); + Assertions.assertEquals(7.3*3600+5, si.departureTime, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0, si.nOfEntering); + Assertions.assertEquals(0, si.nOfLeaving); si = tl.getDepartureStopInformation(line1, route1, stop1, dep1).get(1); - Assert.assertEquals(7.4*3600-20, si.arrivalTime, MatsimTestUtils.EPSILON); - Assert.assertEquals(7.4*3600+5, si.departureTime, MatsimTestUtils.EPSILON); - Assert.assertEquals(0, si.nOfEntering); - Assert.assertEquals(2, si.nOfLeaving); + Assertions.assertEquals(7.4*3600-20, si.arrivalTime, MatsimTestUtils.EPSILON); + Assertions.assertEquals(7.4*3600+5, si.departureTime, MatsimTestUtils.EPSILON); + Assertions.assertEquals(0, si.nOfEntering); + Assertions.assertEquals(2, si.nOfLeaving); List siList = tl.getDepartureStopInformation(line1, route1, stop1, dep2); - Assert.assertNull(siList); + Assertions.assertNull(siList); } } diff --git a/matsim/src/test/java/org/matsim/pt/config/TransitConfigGroupTest.java b/matsim/src/test/java/org/matsim/pt/config/TransitConfigGroupTest.java index c00969cd10e..3e57e959245 100644 --- a/matsim/src/test/java/org/matsim/pt/config/TransitConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/pt/config/TransitConfigGroupTest.java @@ -20,7 +20,7 @@ package org.matsim.pt.config; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.HashSet; import java.util.Set; diff --git a/matsim/src/test/java/org/matsim/pt/router/TransitActsRemoverTest.java b/matsim/src/test/java/org/matsim/pt/router/TransitActsRemoverTest.java index e4f2d81ba07..8448d251c7d 100644 --- a/matsim/src/test/java/org/matsim/pt/router/TransitActsRemoverTest.java +++ b/matsim/src/test/java/org/matsim/pt/router/TransitActsRemoverTest.java @@ -20,8 +20,8 @@ package org.matsim.pt.router; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; diff --git a/matsim/src/test/java/org/matsim/pt/router/TransitRouterConfigTest.java b/matsim/src/test/java/org/matsim/pt/router/TransitRouterConfigTest.java index 3b2f4b585c0..ad473916ea7 100644 --- a/matsim/src/test/java/org/matsim/pt/router/TransitRouterConfigTest.java +++ b/matsim/src/test/java/org/matsim/pt/router/TransitRouterConfigTest.java @@ -19,7 +19,7 @@ package org.matsim.pt.router; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.core.config.groups.ScoringConfigGroup; @@ -71,33 +71,33 @@ void testConstructor() { // a number of changes related to the fact that the opportunity cost of time is now // included in the pt routing. Either the test here or some scoring // test needs to be adapted; this seems the better place. kai/benjamin, oct'12 - Assert.assertEquals(-15.0/3600, config.getMarginalUtilityOfTravelTimePt_utl_s(), 1e-8); - Assert.assertEquals(-17.0/3600, config.getMarginalUtilityOfTravelTimeWalk_utl_s(), 1e-8); - Assert.assertEquals(-19.0/3600, config.getMarginalUtilityOfWaitingPt_utl_s(), 1e-8); + Assertions.assertEquals(-15.0/3600, config.getMarginalUtilityOfTravelTimePt_utl_s(), 1e-8); + Assertions.assertEquals(-17.0/3600, config.getMarginalUtilityOfTravelTimeWalk_utl_s(), 1e-8); + Assertions.assertEquals(-19.0/3600, config.getMarginalUtilityOfWaitingPt_utl_s(), 1e-8); - Assert.assertEquals(-2.34, config.getUtilityOfLineSwitch_utl(), 1e-8); - Assert.assertEquals(1.37 / 1.2, config.getBeelineWalkSpeed(), 1e-8); + Assertions.assertEquals(-2.34, config.getUtilityOfLineSwitch_utl(), 1e-8); + Assertions.assertEquals(1.37 / 1.2, config.getBeelineWalkSpeed(), 1e-8); - Assert.assertEquals(128.0, config.getAdditionalTransferTime(), 1e-8); - Assert.assertEquals(987.6, config.getSearchRadius(), 1e-8); - Assert.assertEquals(123.4, config.getExtensionRadius(), 1e-8); - Assert.assertEquals(23.4, config.getBeelineWalkConnectionDistance(), 1e-8); + Assertions.assertEquals(128.0, config.getAdditionalTransferTime(), 1e-8); + Assertions.assertEquals(987.6, config.getSearchRadius(), 1e-8); + Assertions.assertEquals(123.4, config.getExtensionRadius(), 1e-8); + Assertions.assertEquals(23.4, config.getBeelineWalkConnectionDistance(), 1e-8); } // test with marginal utl of time: { TransitRouterConfig config = new TransitRouterConfig(planScoring, planRouting, transitRouting, vspConfig ); - Assert.assertEquals(-15.0/3600, config.getMarginalUtilityOfTravelTimePt_utl_s(), 1e-8); - Assert.assertEquals(-17.0/3600, config.getMarginalUtilityOfTravelTimeWalk_utl_s(), 1e-8); - Assert.assertEquals(-19.0/3600, config.getMarginalUtilityOfWaitingPt_utl_s(), 1e-8); - Assert.assertEquals(-2.34, config.getUtilityOfLineSwitch_utl(), 1e-8); - Assert.assertEquals(1.37 / 1.2, config.getBeelineWalkSpeed(), 1e-8); + Assertions.assertEquals(-15.0/3600, config.getMarginalUtilityOfTravelTimePt_utl_s(), 1e-8); + Assertions.assertEquals(-17.0/3600, config.getMarginalUtilityOfTravelTimeWalk_utl_s(), 1e-8); + Assertions.assertEquals(-19.0/3600, config.getMarginalUtilityOfWaitingPt_utl_s(), 1e-8); + Assertions.assertEquals(-2.34, config.getUtilityOfLineSwitch_utl(), 1e-8); + Assertions.assertEquals(1.37 / 1.2, config.getBeelineWalkSpeed(), 1e-8); - Assert.assertEquals(128.0, config.getAdditionalTransferTime(), 1e-8); - Assert.assertEquals(987.6, config.getSearchRadius(), 1e-8); - Assert.assertEquals(123.4, config.getExtensionRadius(), 1e-8); - Assert.assertEquals(23.4, config.getBeelineWalkConnectionDistance(), 1e-8); + Assertions.assertEquals(128.0, config.getAdditionalTransferTime(), 1e-8); + Assertions.assertEquals(987.6, config.getSearchRadius(), 1e-8); + Assertions.assertEquals(123.4, config.getExtensionRadius(), 1e-8); + Assertions.assertEquals(23.4, config.getBeelineWalkConnectionDistance(), 1e-8); } } } diff --git a/matsim/src/test/java/org/matsim/pt/router/TransitRouterModuleTest.java b/matsim/src/test/java/org/matsim/pt/router/TransitRouterModuleTest.java index 86df76d670e..a4c44e2631d 100644 --- a/matsim/src/test/java/org/matsim/pt/router/TransitRouterModuleTest.java +++ b/matsim/src/test/java/org/matsim/pt/router/TransitRouterModuleTest.java @@ -2,7 +2,7 @@ import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptor; import com.google.inject.Injector; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.controler.AbstractModule; @@ -37,7 +37,7 @@ public void install() { Injector injector = controler.getInjector(); TransitRouter router = injector.getInstance(TransitRouter.class); - Assert.assertEquals(SwissRailRaptor.class, router.getClass()); + Assertions.assertEquals(SwissRailRaptor.class, router.getClass()); } private static class DummyMobsim implements Mobsim { diff --git a/matsim/src/test/java/org/matsim/pt/routes/DefaultTransitPassengerRouteTest.java b/matsim/src/test/java/org/matsim/pt/routes/DefaultTransitPassengerRouteTest.java index b0dcdd68f44..3875db6a088 100644 --- a/matsim/src/test/java/org/matsim/pt/routes/DefaultTransitPassengerRouteTest.java +++ b/matsim/src/test/java/org/matsim/pt/routes/DefaultTransitPassengerRouteTest.java @@ -20,7 +20,7 @@ package org.matsim.pt.routes; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.Collections; diff --git a/matsim/src/test/java/org/matsim/pt/routes/ExperimentalTransitRouteTest.java b/matsim/src/test/java/org/matsim/pt/routes/ExperimentalTransitRouteTest.java index 68439b3b087..2f09a6e3491 100644 --- a/matsim/src/test/java/org/matsim/pt/routes/ExperimentalTransitRouteTest.java +++ b/matsim/src/test/java/org/matsim/pt/routes/ExperimentalTransitRouteTest.java @@ -20,7 +20,7 @@ package org.matsim.pt.routes; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.Collections; diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/DepartureTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/DepartureTest.java index 57b725f2d9b..a05de0bfb4e 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/DepartureTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/DepartureTest.java @@ -20,8 +20,8 @@ package org.matsim.pt.transitSchedule; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/MinimalTransferTimesImplTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/MinimalTransferTimesImplTest.java index f58e13bf1fd..4c6c8c0a8fc 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/MinimalTransferTimesImplTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/MinimalTransferTimesImplTest.java @@ -19,7 +19,7 @@ package org.matsim.pt.transitSchedule; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.pt.transitSchedule.api.MinimalTransferTimes; @@ -41,51 +41,51 @@ public class MinimalTransferTimesImplTest { @Test void testSetGet() { MinimalTransferTimes mtt = new MinimalTransferTimesImpl(); - Assert.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId2), 0.0); + Assertions.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId2), 0.0); mtt.set(this.stopId1, this.stopId2, 180.0); mtt.set(this.stopId1, this.stopId3, 240.0); - Assert.assertEquals(180.0, mtt.get(this.stopId1, this.stopId2), 0.0); - Assert.assertEquals(240.0, mtt.get(this.stopId1, this.stopId3), 0.0); + Assertions.assertEquals(180.0, mtt.get(this.stopId1, this.stopId2), 0.0); + Assertions.assertEquals(240.0, mtt.get(this.stopId1, this.stopId3), 0.0); // overwrite a value mtt.set(this.stopId1, this.stopId2, 300.0); - Assert.assertEquals(300.0, mtt.get(this.stopId1, this.stopId2), 0.0); + Assertions.assertEquals(300.0, mtt.get(this.stopId1, this.stopId2), 0.0); - Assert.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId4), 0.0); + Assertions.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId4), 0.0); } @Test void testGetWithDefault() { MinimalTransferTimes mtt = new MinimalTransferTimesImpl(); double defaultSeconds = 60.0; - Assert.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId2), 0.0); - Assert.assertEquals(60.0, mtt.get(this.stopId1, this.stopId2, defaultSeconds), 0.0); + Assertions.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId2), 0.0); + Assertions.assertEquals(60.0, mtt.get(this.stopId1, this.stopId2, defaultSeconds), 0.0); mtt.set(this.stopId1, this.stopId2, 180.0); mtt.set(this.stopId1, this.stopId3, 240.0); - Assert.assertEquals(180.0, mtt.get(this.stopId1, this.stopId2, defaultSeconds), 0.0); - Assert.assertEquals(240.0, mtt.get(this.stopId1, this.stopId3, defaultSeconds), 0.0); + Assertions.assertEquals(180.0, mtt.get(this.stopId1, this.stopId2, defaultSeconds), 0.0); + Assertions.assertEquals(240.0, mtt.get(this.stopId1, this.stopId3, defaultSeconds), 0.0); - Assert.assertEquals(defaultSeconds, mtt.get(this.stopId1, this.stopId4, defaultSeconds), 0.0); + Assertions.assertEquals(defaultSeconds, mtt.get(this.stopId1, this.stopId4, defaultSeconds), 0.0); } @Test void testRemove() { MinimalTransferTimes mtt = new MinimalTransferTimesImpl(); - Assert.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId2), 0.0); + Assertions.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId2), 0.0); mtt.set(this.stopId1, this.stopId2, 180.0); mtt.set(this.stopId1, this.stopId3, 240.0); - Assert.assertEquals(180.0, mtt.get(this.stopId1, this.stopId2), 0.0); - Assert.assertEquals(240.0, mtt.get(this.stopId1, this.stopId3), 0.0); + Assertions.assertEquals(180.0, mtt.get(this.stopId1, this.stopId2), 0.0); + Assertions.assertEquals(240.0, mtt.get(this.stopId1, this.stopId3), 0.0); - Assert.assertEquals(180.0, mtt.remove(this.stopId1, this.stopId2), 0.0); - Assert.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId2), 0.0); - Assert.assertEquals(240.0, mtt.get(this.stopId1, this.stopId3), 0.0); + Assertions.assertEquals(180.0, mtt.remove(this.stopId1, this.stopId2), 0.0); + Assertions.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId2), 0.0); + Assertions.assertEquals(240.0, mtt.get(this.stopId1, this.stopId3), 0.0); - Assert.assertEquals(Double.NaN, mtt.remove(this.stopId1, this.stopId4), 0.0); // we never set it, let's not throw an exception - Assert.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId4), 0.0); + Assertions.assertEquals(Double.NaN, mtt.remove(this.stopId1, this.stopId4), 0.0); // we never set it, let's not throw an exception + Assertions.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId4), 0.0); } @Test @@ -94,14 +94,14 @@ void testNotBidirection() { mtt.set(this.stopId1, this.stopId2, 180.0); mtt.set(this.stopId1, this.stopId3, 240.0); - Assert.assertEquals(180.0, mtt.get(this.stopId1, this.stopId2), 0.0); - Assert.assertEquals(Double.NaN, mtt.get(this.stopId2, this.stopId1), 0.0); - Assert.assertEquals(240.0, mtt.get(this.stopId1, this.stopId3), 0.0); - Assert.assertEquals(Double.NaN, mtt.get(this.stopId3, this.stopId1), 0.0); + Assertions.assertEquals(180.0, mtt.get(this.stopId1, this.stopId2), 0.0); + Assertions.assertEquals(Double.NaN, mtt.get(this.stopId2, this.stopId1), 0.0); + Assertions.assertEquals(240.0, mtt.get(this.stopId1, this.stopId3), 0.0); + Assertions.assertEquals(Double.NaN, mtt.get(this.stopId3, this.stopId1), 0.0); mtt.set(this.stopId3, this.stopId1, 120.0); - Assert.assertEquals(120.0, mtt.get(this.stopId3, this.stopId1), 0.0); - Assert.assertEquals(240.0, mtt.get(this.stopId1, this.stopId3), 0.0); + Assertions.assertEquals(120.0, mtt.get(this.stopId3, this.stopId1), 0.0); + Assertions.assertEquals(240.0, mtt.get(this.stopId1, this.stopId3), 0.0); } @Test @@ -110,13 +110,13 @@ void testNotTransitive() { mtt.set(this.stopId1, this.stopId2, 180.0); mtt.set(this.stopId2, this.stopId3, 240.0); - Assert.assertEquals(180.0, mtt.get(this.stopId1, this.stopId2), 0.0); - Assert.assertEquals(240.0, mtt.get(this.stopId2, this.stopId3), 0.0); - Assert.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId3), 0.0); - Assert.assertEquals(Double.NaN, mtt.get(this.stopId3, this.stopId1), 0.0); + Assertions.assertEquals(180.0, mtt.get(this.stopId1, this.stopId2), 0.0); + Assertions.assertEquals(240.0, mtt.get(this.stopId2, this.stopId3), 0.0); + Assertions.assertEquals(Double.NaN, mtt.get(this.stopId1, this.stopId3), 0.0); + Assertions.assertEquals(Double.NaN, mtt.get(this.stopId3, this.stopId1), 0.0); mtt.set(this.stopId1, this.stopId3, 480.0); - Assert.assertEquals(480.0, mtt.get(this.stopId1, this.stopId3), 0.0); + Assertions.assertEquals(480.0, mtt.get(this.stopId1, this.stopId3), 0.0); } @Test @@ -125,30 +125,30 @@ void testIterator_empty() { MinimalTransferTimes.MinimalTransferTimesIterator iter = mtt.iterator(); - Assert.assertFalse(iter.hasNext()); + Assertions.assertFalse(iter.hasNext()); try { iter.getFromStopId(); - Assert.fail("expected Exception, got none."); + Assertions.fail("expected Exception, got none."); } catch (NoSuchElementException expected) {} try { iter.getToStopId(); - Assert.fail("expected Exception, got none."); + Assertions.fail("expected Exception, got none."); } catch (NoSuchElementException expected) {} try { iter.getSeconds(); - Assert.fail("expected Exception, got none."); + Assertions.fail("expected Exception, got none."); } catch (NoSuchElementException expected) {} try { iter.next(); - Assert.fail("expected Exception"); + Assertions.fail("expected Exception"); } catch (NoSuchElementException expected) {} try { iter.getFromStopId(); // there should still be an exception after calling next() - Assert.fail("expected Exception, got none."); + Assertions.fail("expected Exception, got none."); } catch (NoSuchElementException expected) {} } @@ -158,32 +158,32 @@ void testIterator() { MinimalTransferTimes mtt = new MinimalTransferTimesImpl(); MinimalTransferTimes.MinimalTransferTimesIterator iter = mtt.iterator(); - Assert.assertFalse(iter.hasNext()); + Assertions.assertFalse(iter.hasNext()); mtt.set(this.stopId1, this.stopId2, 120.0); iter = mtt.iterator(); - Assert.assertTrue(iter.hasNext()); + Assertions.assertTrue(iter.hasNext()); try { iter.getFromStopId(); - Assert.fail("expected Exception, got none."); + Assertions.fail("expected Exception, got none."); } catch (NoSuchElementException expected) {} iter.next(); - Assert.assertEquals(this.stopId1, iter.getFromStopId()); - Assert.assertEquals(this.stopId2, iter.getToStopId()); - Assert.assertEquals(120, iter.getSeconds(), 0.0); + Assertions.assertEquals(this.stopId1, iter.getFromStopId()); + Assertions.assertEquals(this.stopId2, iter.getToStopId()); + Assertions.assertEquals(120, iter.getSeconds(), 0.0); - Assert.assertFalse(iter.hasNext()); + Assertions.assertFalse(iter.hasNext()); try { iter.next(); - Assert.fail("expected Exception, got none."); + Assertions.fail("expected Exception, got none."); } catch (NoSuchElementException expected) {} try { iter.getFromStopId(); - Assert.fail("expected Exception, got none."); + Assertions.fail("expected Exception, got none."); } catch (NoSuchElementException expected) {} mtt.set(this.stopId1, this.stopId3, 180); @@ -209,15 +209,15 @@ void testIterator() { } else if (fromStopId == this.stopId2 && toStopId == this.stopId3 && seconds == 240) { found2to3 = true; } else { - Assert.fail("found unexcpected minimal transfer time: " + fromStopId + " / " + toStopId + " / " + seconds); + Assertions.fail("found unexcpected minimal transfer time: " + fromStopId + " / " + toStopId + " / " + seconds); } if (count > 3) { - Assert.fail("too many elements in iterator."); + Assertions.fail("too many elements in iterator."); } } - Assert.assertTrue(found1to2); - Assert.assertTrue(found1to3); - Assert.assertTrue(found2to3); + Assertions.assertTrue(found1to2); + Assertions.assertTrue(found1to3); + Assertions.assertTrue(found2to3); } @@ -235,7 +235,7 @@ void testIterator_withRemove() { count++; iter.next(); } - Assert.assertEquals(3, count); + Assertions.assertEquals(3, count); mtt.remove(this.stopId2, this.stopId3); count = 0; @@ -244,7 +244,7 @@ void testIterator_withRemove() { count++; iter.next(); } - Assert.assertEquals(2, count); + Assertions.assertEquals(2, count); mtt.remove(this.stopId1, this.stopId2); count = 0; @@ -253,10 +253,10 @@ void testIterator_withRemove() { count++; iter.next(); } - Assert.assertEquals(1, count); + Assertions.assertEquals(1, count); mtt.remove(this.stopId3, this.stopId1); iter = mtt.iterator(); - Assert.assertFalse(iter.hasNext()); + Assertions.assertFalse(iter.hasNext()); } } \ No newline at end of file diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitLineTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitLineTest.java index fa5bd256eb4..67720561b2e 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitLineTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitLineTest.java @@ -20,7 +20,7 @@ package org.matsim.pt.transitSchedule; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.ArrayList; @@ -62,7 +62,7 @@ void testInitialization() { Id id = Id.create(511, TransitLine.class); TransitLine tLine = createTransitLine(id); assertNotNull(tLine); - assertEquals("different ids.", id.toString(), tLine.getId().toString()); + assertEquals(id.toString(), tLine.getId().toString(), "different ids."); } @Test diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteStopTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteStopTest.java index 812205dc8e8..2e005b801fe 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteStopTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteStopTest.java @@ -20,7 +20,7 @@ package org.matsim.pt.transitSchedule; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteTest.java index 58da3c5f807..9a92aabe151 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitRouteTest.java @@ -20,7 +20,7 @@ package org.matsim.pt.transitSchedule; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.ArrayList; import java.util.List; @@ -78,8 +78,8 @@ void testInitialization() { stops.add(stop); TransitRoute tRoute = createTransitRoute(id, route, stops, "train"); - assertEquals("wrong id.", id.toString(), tRoute.getId().toString()); - assertEquals("wrong route.", route, tRoute.getRoute()); + assertEquals(id.toString(), tRoute.getId().toString(), "wrong id."); + assertEquals(route, tRoute.getRoute(), "wrong route."); assertEquals(stops.size(), tRoute.getStops().size()); assertEquals(stop, tRoute.getStops().get(0)); assertEquals("train", tRoute.getTransportMode()); diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFactoryTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFactoryTest.java index 1940a5c8976..2b3747ed202 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFactoryTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFactoryTest.java @@ -23,7 +23,7 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -53,7 +53,7 @@ protected TransitScheduleFactory createTransitScheduleBuilder() { void testCreateTransitSchedule() { TransitScheduleFactory builder = createTransitScheduleBuilder(); TransitSchedule schedule = builder.createTransitSchedule(); - Assert.assertEquals(builder, schedule.getFactory()); + Assertions.assertEquals(builder, schedule.getFactory()); } @Test @@ -61,7 +61,7 @@ void testCreateTransitLine() { TransitScheduleFactory builder = createTransitScheduleBuilder(); Id id = Id.create(1, TransitLine.class); TransitLine line = builder.createTransitLine(id); - Assert.assertEquals(id, line.getId()); + Assertions.assertEquals(id, line.getId()); } @Test @@ -74,11 +74,11 @@ void testCreateTransitRoute() { stops.add(stop1); String mode = TransportMode.pt; TransitRoute tRoute = builder.createTransitRoute(id, route, stops, mode); - Assert.assertEquals(id, tRoute.getId()); - Assert.assertEquals(route, tRoute.getRoute()); - Assert.assertEquals(1, tRoute.getStops().size()); - Assert.assertEquals(stop1, tRoute.getStops().get(0)); - Assert.assertEquals(mode, tRoute.getTransportMode()); + Assertions.assertEquals(id, tRoute.getId()); + Assertions.assertEquals(route, tRoute.getRoute()); + Assertions.assertEquals(1, tRoute.getStops().size()); + Assertions.assertEquals(stop1, tRoute.getStops().get(0)); + Assertions.assertEquals(mode, tRoute.getTransportMode()); } @Test @@ -88,9 +88,9 @@ void testCreateTransitRouteStop() { double arrivalOffset = 23; double departureOffset = 42; TransitRouteStop stop = builder.createTransitRouteStop(stopFacility, 23, 42); - Assert.assertEquals(stopFacility, stop.getStopFacility()); - Assert.assertEquals(arrivalOffset, stop.getArrivalOffset().seconds(), MatsimTestUtils.EPSILON); - Assert.assertEquals(departureOffset, stop.getDepartureOffset().seconds(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(stopFacility, stop.getStopFacility()); + Assertions.assertEquals(arrivalOffset, stop.getArrivalOffset().seconds(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(departureOffset, stop.getDepartureOffset().seconds(), MatsimTestUtils.EPSILON); } @Test @@ -101,15 +101,15 @@ void testCreateTransitStopFacility() { Id id2 = Id.create(7, TransitStopFacility.class); Coord coord2 = new Coord((double) 105, (double) 1979); TransitStopFacility stopFacility1 = builder.createTransitStopFacility(id1, coord1, false); - Assert.assertEquals(id1, stopFacility1.getId()); - Assert.assertEquals(coord1.getX(), stopFacility1.getCoord().getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals(coord1.getY(), stopFacility1.getCoord().getY(), MatsimTestUtils.EPSILON); - Assert.assertFalse(stopFacility1.getIsBlockingLane()); + Assertions.assertEquals(id1, stopFacility1.getId()); + Assertions.assertEquals(coord1.getX(), stopFacility1.getCoord().getX(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(coord1.getY(), stopFacility1.getCoord().getY(), MatsimTestUtils.EPSILON); + Assertions.assertFalse(stopFacility1.getIsBlockingLane()); TransitStopFacility stopFacility2 = builder.createTransitStopFacility(id2, coord2, true); - Assert.assertEquals(id2, stopFacility2.getId()); - Assert.assertEquals(coord2.getX(), stopFacility2.getCoord().getX(), MatsimTestUtils.EPSILON); - Assert.assertEquals(coord2.getY(), stopFacility2.getCoord().getY(), MatsimTestUtils.EPSILON); - Assert.assertTrue(stopFacility2.getIsBlockingLane()); + Assertions.assertEquals(id2, stopFacility2.getId()); + Assertions.assertEquals(coord2.getX(), stopFacility2.getCoord().getX(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(coord2.getY(), stopFacility2.getCoord().getY(), MatsimTestUtils.EPSILON); + Assertions.assertTrue(stopFacility2.getIsBlockingLane()); } @Test @@ -118,8 +118,8 @@ void testCreateDeparture() { Id id = Id.create(8, Departure.class); double time = 9.0*3600; Departure dep = builder.createDeparture(id, time); - Assert.assertEquals(id, dep.getId()); - Assert.assertEquals(time, dep.getDepartureTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(id, dep.getId()); + Assertions.assertEquals(time, dep.getDepartureTime(), MatsimTestUtils.EPSILON); } } diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFormatV1Test.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFormatV1Test.java index d43aee23f33..f3593cf5120 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFormatV1Test.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleFormatV1Test.java @@ -20,7 +20,7 @@ package org.matsim.pt.transitSchedule; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.io.IOException; import java.util.ArrayList; @@ -158,60 +158,60 @@ void testWriteRead() throws IOException, SAXException, ParserConfigurationExcept private static void assertEqualSchedules(final TransitSchedule expected, final TransitSchedule actual) { - assertEquals("different number of stopFacilities.", expected.getFacilities().size(), actual.getFacilities().size()); + assertEquals(expected.getFacilities().size(), actual.getFacilities().size(), "different number of stopFacilities."); for (TransitStopFacility stopE : expected.getFacilities().values()) { TransitStopFacility stopA = actual.getFacilities().get(stopE.getId()); - assertNotNull("stopFacility not found: " + stopE.getId().toString(), stopA); - assertEquals("different x coordinates.", stopE.getCoord().getX(), stopA.getCoord().getX(), MatsimTestUtils.EPSILON); - assertEquals("different y coordinates.", stopE.getCoord().getY(), stopA.getCoord().getY(), MatsimTestUtils.EPSILON); - assertEquals("different link information.", stopE.getLinkId(), stopA.getLinkId()); - assertEquals("different isBlocking.", stopE.getIsBlockingLane(), stopA.getIsBlockingLane()); - assertEquals("different names.", stopE.getName(), stopA.getName()); + assertNotNull(stopA, "stopFacility not found: " + stopE.getId().toString()); + assertEquals(stopE.getCoord().getX(), stopA.getCoord().getX(), MatsimTestUtils.EPSILON, "different x coordinates."); + assertEquals(stopE.getCoord().getY(), stopA.getCoord().getY(), MatsimTestUtils.EPSILON, "different y coordinates."); + assertEquals(stopE.getLinkId(), stopA.getLinkId(), "different link information."); + assertEquals(stopE.getIsBlockingLane(), stopA.getIsBlockingLane(), "different isBlocking."); + assertEquals(stopE.getName(), stopA.getName(), "different names."); } - assertEquals("different number of transitLines.", expected.getTransitLines().size(), actual.getTransitLines().size()); + assertEquals(expected.getTransitLines().size(), actual.getTransitLines().size(), "different number of transitLines."); for (TransitLine lineE : expected.getTransitLines().values()) { // *E = expected, *A = actual TransitLine lineA = actual.getTransitLines().get(lineE.getId()); - assertNotNull("transit line not found: " + lineE.getId().toString(), lineA); - assertEquals("different number of routes in line.", lineE.getRoutes().size(), lineA.getRoutes().size()); + assertNotNull(lineA, "transit line not found: " + lineE.getId().toString()); + assertEquals(lineE.getRoutes().size(), lineA.getRoutes().size(), "different number of routes in line."); for (TransitRoute routeE : lineE.getRoutes().values()) { TransitRoute routeA = lineA.getRoutes().get(routeE.getId()); - assertNotNull("transit route not found: " + routeE.getId().toString(), routeA); - assertEquals("different route descriptions.", routeE.getDescription(), routeA.getDescription()); + assertNotNull(routeA, "transit route not found: " + routeE.getId().toString()); + assertEquals(routeE.getDescription(), routeA.getDescription(), "different route descriptions."); - assertEquals("different number of stops.", routeE.getStops().size(), routeA.getStops().size()); + assertEquals(routeE.getStops().size(), routeA.getStops().size(), "different number of stops."); for (int i = 0, n = routeE.getStops().size(); i < n; i++) { TransitRouteStop stopE = routeE.getStops().get(i); TransitRouteStop stopA = routeA.getStops().get(i); - assertNotNull("stop not found", stopA); - assertEquals("different stop facilities.", stopE.getStopFacility().getId(), stopA.getStopFacility().getId()); - assertEquals("different arrival delay.", stopE.getArrivalOffset(), stopA.getArrivalOffset()); - assertEquals("different departure delay.", stopE.getDepartureOffset(), stopA.getDepartureOffset()); - assertEquals("different awaitDepartureTime.", stopE.isAwaitDepartureTime(), stopA.isAwaitDepartureTime()); + assertNotNull(stopA, "stop not found"); + assertEquals(stopE.getStopFacility().getId(), stopA.getStopFacility().getId(), "different stop facilities."); + assertEquals(stopE.getArrivalOffset(), stopA.getArrivalOffset(), "different arrival delay."); + assertEquals(stopE.getDepartureOffset(), stopA.getDepartureOffset(), "different departure delay."); + assertEquals(stopE.isAwaitDepartureTime(), stopA.isAwaitDepartureTime(), "different awaitDepartureTime."); } NetworkRoute netRouteE = routeE.getRoute(); if (netRouteE == null) { - assertNull("bad network route, must be null.", routeA.getRoute()); + assertNull(routeA.getRoute(), "bad network route, must be null."); } else { NetworkRoute netRouteA = routeA.getRoute(); - assertNotNull("bad network route, must not be null.", netRouteA); - assertEquals("wrong start link.", netRouteE.getStartLinkId(), netRouteA.getStartLinkId()); - assertEquals("wrong end link.", netRouteE.getEndLinkId(), netRouteA.getEndLinkId()); + assertNotNull(netRouteA, "bad network route, must not be null."); + assertEquals(netRouteE.getStartLinkId(), netRouteA.getStartLinkId(), "wrong start link."); + assertEquals(netRouteE.getEndLinkId(), netRouteA.getEndLinkId(), "wrong end link."); List> linkIdsE = netRouteE.getLinkIds(); List> linkIdsA = netRouteA.getLinkIds(); for (int i = 0, n = linkIdsE.size(); i < n; i++) { - assertEquals("wrong link in network route", linkIdsE.get(i), linkIdsA.get(i)); + assertEquals(linkIdsE.get(i), linkIdsA.get(i), "wrong link in network route"); } } - assertEquals("different number of departures in route.", routeE.getDepartures().size(), routeA.getDepartures().size()); + assertEquals(routeE.getDepartures().size(), routeA.getDepartures().size(), "different number of departures in route."); for (Departure departureE : routeE.getDepartures().values()) { Departure departureA = routeA.getDepartures().get(departureE.getId()); - assertNotNull("departure not found: " + departureE.getId().toString(), departureA); - assertEquals("different departure times.", departureE.getDepartureTime(), departureA.getDepartureTime(), MatsimTestUtils.EPSILON); - assertEquals("different vehicle ids.", departureE.getVehicleId(), departureA.getVehicleId()); + assertNotNull(departureA, "departure not found: " + departureE.getId().toString()); + assertEquals(departureE.getDepartureTime(), departureA.getDepartureTime(), MatsimTestUtils.EPSILON, "different departure times."); + assertEquals(departureE.getVehicleId(), departureA.getVehicleId(), "different vehicle ids."); } } } diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleIOTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleIOTest.java index 8157150e23a..8b4f9688a6d 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleIOTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleIOTest.java @@ -24,7 +24,7 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -112,45 +112,45 @@ void testWriteRead_V2() { TransitSchedule schedule2 = scenario.getTransitSchedule(); // assert schedule - Assert.assertEquals("myImagination", schedule2.getAttributes().getAttribute("source")); + Assertions.assertEquals("myImagination", schedule2.getAttributes().getAttribute("source")); // assert stop facilities TransitStopFacility stop1 = schedule2.getFacilities().get(Id.create(1, TransitStopFacility.class)); - Assert.assertTrue(AttributesUtils.isEmpty(stop1.getAttributes())); + Assertions.assertTrue(AttributesUtils.isEmpty(stop1.getAttributes())); TransitStopFacility stop2 = schedule2.getFacilities().get(Id.create(2, TransitStopFacility.class)); - Assert.assertFalse(AttributesUtils.isEmpty(stop2.getAttributes())); - Assert.assertEquals("thin", stop2.getAttributes().getAttribute("air")); - Assert.assertTrue(stop2.getCoord().hasZ()); - Assert.assertEquals(98765.0, stop2.getCoord().getZ(), 0.0); - Assert.assertEquals("GZ", stop2.getStopAreaId().toString()); + Assertions.assertFalse(AttributesUtils.isEmpty(stop2.getAttributes())); + Assertions.assertEquals("thin", stop2.getAttributes().getAttribute("air")); + Assertions.assertTrue(stop2.getCoord().hasZ()); + Assertions.assertEquals(98765.0, stop2.getCoord().getZ(), 0.0); + Assertions.assertEquals("GZ", stop2.getStopAreaId().toString()); // assert minmal transfer times - Assert.assertEquals(300, schedule2.getMinimalTransferTimes().get(stop1.getId(), stop2.getId()), 0.0); - Assert.assertEquals(360, schedule2.getMinimalTransferTimes().get(stop2.getId(), stop1.getId()), 0.0); - Assert.assertEquals(Double.NaN, schedule2.getMinimalTransferTimes().get(stop1.getId(), stop1.getId()), 0.0); + Assertions.assertEquals(300, schedule2.getMinimalTransferTimes().get(stop1.getId(), stop2.getId()), 0.0); + Assertions.assertEquals(360, schedule2.getMinimalTransferTimes().get(stop2.getId(), stop1.getId()), 0.0); + Assertions.assertEquals(Double.NaN, schedule2.getMinimalTransferTimes().get(stop1.getId(), stop1.getId()), 0.0); // assert transit lines TransitLine line1 = schedule2.getTransitLines().get(Id.create("blue", TransitLine.class)); - Assert.assertNotNull(line1); - Assert.assertFalse(AttributesUtils.isEmpty(line1.getAttributes())); - Assert.assertEquals("like the sky", line1.getAttributes().getAttribute("color")); - Assert.assertEquals("higher being", line1.getAttributes().getAttribute("operator")); + Assertions.assertNotNull(line1); + Assertions.assertFalse(AttributesUtils.isEmpty(line1.getAttributes())); + Assertions.assertEquals("like the sky", line1.getAttributes().getAttribute("color")); + Assertions.assertEquals("higher being", line1.getAttributes().getAttribute("operator")); // assert transit routes TransitRoute route1 = line1.getRoutes().get(Id.create("upwards", TransitRoute.class)); - Assert.assertNotNull(route1); - Assert.assertFalse(AttributesUtils.isEmpty(route1.getAttributes())); - Assert.assertTrue(route1.getAttributes().getAttribute("bidirectional") instanceof Boolean); - Assert.assertFalse((Boolean) route1.getAttributes().getAttribute("bidirectional")); + Assertions.assertNotNull(route1); + Assertions.assertFalse(AttributesUtils.isEmpty(route1.getAttributes())); + Assertions.assertTrue(route1.getAttributes().getAttribute("bidirectional") instanceof Boolean); + Assertions.assertFalse((Boolean) route1.getAttributes().getAttribute("bidirectional")); // assert departures Departure dep1 = route1.getDepartures().get(Id.create("first", Departure.class)); - Assert.assertNotNull(dep1); - Assert.assertFalse(AttributesUtils.isEmpty(dep1.getAttributes())); - Assert.assertEquals("yes", dep1.getAttributes().getAttribute("early")); + Assertions.assertNotNull(dep1); + Assertions.assertFalse(AttributesUtils.isEmpty(dep1.getAttributes())); + Assertions.assertEquals("yes", dep1.getAttributes().getAttribute("early")); Departure dep2 = route1.getDepartures().get(Id.create("last", Departure.class)); - Assert.assertNotNull(dep2); - Assert.assertTrue(AttributesUtils.isEmpty(dep2.getAttributes())); + Assertions.assertNotNull(dep2); + Assertions.assertTrue(AttributesUtils.isEmpty(dep2.getAttributes())); } } diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderTest.java index d65d912f554..666a764319c 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderTest.java @@ -20,8 +20,8 @@ package org.matsim.pt.transitSchedule; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.IOException; import java.util.List; @@ -75,28 +75,28 @@ void testReadFileV1() throws SAXException, ParserConfigurationException, IOExcep TransitSchedule schedule = builder.createTransitSchedule(); new TransitScheduleReaderV1(schedule, scenario.getPopulation().getFactory().getRouteFactories()).readFile(inputDir + INPUT_TEST_FILE_TRANSITSCHEDULE); - assertEquals("wrong number of transit lines.", 1, schedule.getTransitLines().size()); - assertEquals("wrong line id.", Id.create("T1", TransitLine.class), schedule.getTransitLines().keySet().iterator().next()); + assertEquals(1, schedule.getTransitLines().size(), "wrong number of transit lines."); + assertEquals(Id.create("T1", TransitLine.class), schedule.getTransitLines().keySet().iterator().next(), "wrong line id."); TransitLine lineT1 = schedule.getTransitLines().get(Id.create("T1", TransitLine.class)); - assertNotNull("could not find line with id T1.", lineT1); + assertNotNull(lineT1, "could not find line with id T1."); TransitRoute route1 = lineT1.getRoutes().get(Id.create("1", TransitRoute.class)); - assertNotNull("could not find route 1 in line T1.", route1); + assertNotNull(route1, "could not find route 1 in line T1."); Map, Departure> departures = route1.getDepartures(); - assertNotNull("could not get departures of route 1 in line T1.", departures); - assertEquals("wrong number of departures.", 3, departures.size()); + assertNotNull(departures, "could not get departures of route 1 in line T1."); + assertEquals(3, departures.size(), "wrong number of departures."); List stops = route1.getStops(); - assertNotNull("could not get transit route stops.", stops); - assertEquals("wrong number of stops.", 6, stops.size()); + assertNotNull(stops, "could not get transit route stops."); + assertEquals(6, stops.size(), "wrong number of stops."); NetworkRoute route = route1.getRoute(); - assertNotNull("could not get route.", route); - assertEquals("wrong start link.", network.getLinks().get(Id.create("1", Link.class)).getId(), route.getStartLinkId()); - assertEquals("wrong end link.", network.getLinks().get(Id.create("8", Link.class)).getId(), route.getEndLinkId()); - assertEquals("wrong number of links in route.", 4, route.getLinkIds().size()); + assertNotNull(route, "could not get route."); + assertEquals(network.getLinks().get(Id.create("1", Link.class)).getId(), route.getStartLinkId(), "wrong start link."); + assertEquals(network.getLinks().get(Id.create("8", Link.class)).getId(), route.getEndLinkId(), "wrong end link."); + assertEquals(4, route.getLinkIds().size(), "wrong number of links in route."); } @Test @@ -111,7 +111,7 @@ void testReadFile() throws IOException, SAXException, ParserConfigurationExcepti new TransitScheduleReader(scenario).readFile(inputDir + INPUT_TEST_FILE_TRANSITSCHEDULE); // only a minimal test, the actual reader used should be tested somewhere separately - assertEquals("wrong number of transit lines.", 1, scenario.getTransitSchedule().getTransitLines().size()); + assertEquals(1, scenario.getTransitSchedule().getTransitLines().size(), "wrong number of transit lines."); // in the end, we mostly test that there is no Exception when reading the file. } diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderV1Test.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderV1Test.java index c7e8c372a5e..f6375a034b2 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderV1Test.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReaderV1Test.java @@ -20,7 +20,7 @@ package org.matsim.pt.transitSchedule; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.Stack; diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReprojectionIOTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReprojectionIOTest.java index d53fb2163cd..4be9bbe91fb 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReprojectionIOTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReprojectionIOTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -49,7 +49,7 @@ import java.io.File; import java.net.URL; - /** + /** * @author thibautd */ public class TransitScheduleReprojectionIOTest { @@ -124,10 +124,10 @@ void testWithControlerAndConfigParameters() { final Coord originalCoord = originalScenario.getTransitSchedule().getFacilities().get( id ).getCoord(); final Coord internalCoord = scenario.getTransitSchedule().getFacilities().get( id ).getCoord(); - Assert.assertEquals( - "No coordinates transform performed!", + Assertions.assertEquals( transformation.transform(originalCoord), - internalCoord); + internalCoord, + "No coordinates transform performed!"); } final Controler controler = new Controler( scenario ); @@ -144,10 +144,10 @@ void testWithControlerAndConfigParameters() { final Coord internalCoord = scenario.getTransitSchedule().getFacilities().get( id ).getCoord(); final Coord dumpedCoord = dumpedScenario.getTransitSchedule().getFacilities().get( id ).getCoord(); - Assert.assertEquals( - "coordinates were reprojected for dump", + Assertions.assertEquals( internalCoord, - dumpedCoord); + dumpedCoord, + "coordinates were reprojected for dump"); } } @@ -196,16 +196,16 @@ void testWithControlerAndAttributes() { final Coord originalCoord = originalScenario.getTransitSchedule().getFacilities().get( id ).getCoord(); final Coord internalCoord = scenario.getTransitSchedule().getFacilities().get( id ).getCoord(); - Assert.assertEquals( - "No coordinates transform performed!", + Assertions.assertEquals( transformation.transform(originalCoord), - internalCoord); + internalCoord, + "No coordinates transform performed!"); } - Assert.assertEquals( - "wrong CRS information after loading", + Assertions.assertEquals( TARGET_CRS, - ProjectionUtils.getCRS(scenario.getTransitSchedule())); + ProjectionUtils.getCRS(scenario.getTransitSchedule()), + "wrong CRS information after loading"); final Controler controler = new Controler( scenario ); controler.run(); @@ -221,29 +221,29 @@ void testWithControlerAndAttributes() { final Coord internalCoord = scenario.getTransitSchedule().getFacilities().get( id ).getCoord(); final Coord dumpedCoord = dumpedScenario.getTransitSchedule().getFacilities().get( id ).getCoord(); - Assert.assertEquals( - "coordinates were reprojected for dump", + Assertions.assertEquals( internalCoord, - dumpedCoord); + dumpedCoord, + "coordinates were reprojected for dump"); } } private void assertCorrectlyReprojected( final TransitSchedule originalSchedule, final TransitSchedule transformedSchedule) { - Assert.assertEquals( - "unexpected number of stops", + Assertions.assertEquals( originalSchedule.getFacilities().size(), - transformedSchedule.getFacilities().size() ); + transformedSchedule.getFacilities().size(), + "unexpected number of stops" ); for ( Id stopId : originalSchedule.getFacilities().keySet() ) { final Coord original = originalSchedule.getFacilities().get( stopId ).getCoord(); final Coord transformed = transformedSchedule.getFacilities().get( stopId ).getCoord(); - Assert.assertEquals( - "wrong reprojected X value", + Assertions.assertEquals( transformation.transform(original), - transformed); + transformed, + "wrong reprojected X value"); } } diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleTest.java index dc67a806b9d..6c4c787eec9 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleTest.java @@ -20,12 +20,12 @@ package org.matsim.pt.transitSchedule; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -168,9 +168,9 @@ void testRemoveStopFacility() { TransitStopFacility stop1 = new TransitStopFacilityImpl(Id.create(1, TransitStopFacility.class), new Coord((double) 0, (double) 0), false); TransitStopFacility stop1b = new TransitStopFacilityImpl(Id.create(1, TransitStopFacility.class), new Coord((double) 10, (double) 10), false); schedule.addStopFacility(stop1); - Assert.assertFalse(schedule.removeStopFacility(stop1b)); - Assert.assertTrue(schedule.removeStopFacility(stop1)); - Assert.assertFalse(schedule.removeStopFacility(stop1)); + Assertions.assertFalse(schedule.removeStopFacility(stop1b)); + Assertions.assertTrue(schedule.removeStopFacility(stop1)); + Assertions.assertFalse(schedule.removeStopFacility(stop1)); } @Test @@ -179,9 +179,9 @@ void testRemoveTransitLine() { TransitLine line1 = new TransitLineImpl(Id.create(1, TransitLine.class)); TransitLine line1b = new TransitLineImpl(Id.create(1, TransitLine.class)); schedule.addTransitLine(line1); - Assert.assertFalse(schedule.removeTransitLine(line1b)); - Assert.assertTrue(schedule.removeTransitLine(line1)); - Assert.assertFalse(schedule.removeTransitLine(line1)); + Assertions.assertFalse(schedule.removeTransitLine(line1b)); + Assertions.assertTrue(schedule.removeTransitLine(line1)); + Assertions.assertFalse(schedule.removeTransitLine(line1)); } } diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleWriterTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleWriterTest.java index ad6a354bbff..bf8b2ae254c 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleWriterTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleWriterTest.java @@ -24,7 +24,7 @@ import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -65,7 +65,7 @@ void testDefaultV2() throws IOException, SAXException, ParserConfigurationExcept TransitScheduleFactory builder2 = new TransitScheduleFactoryImpl(); TransitSchedule schedule2 = builder2.createTransitSchedule(); new TransitScheduleReaderV2(schedule2, new RouteFactories()).readFile(filename); - Assert.assertEquals(1, schedule2.getTransitLines().size()); + Assertions.assertEquals(1, schedule2.getTransitLines().size()); } @Test @@ -84,7 +84,7 @@ void testTransitLineName() { TransitScheduleFactory builder2 = new TransitScheduleFactoryImpl(); TransitSchedule schedule2 = builder2.createTransitSchedule(); new TransitScheduleReaderV1(schedule2, new RouteFactories()).readFile(filename); - Assert.assertEquals(1, schedule2.getTransitLines().size()); - Assert.assertEquals("Blue line", schedule2.getTransitLines().get(Id.create(1, TransitLine.class)).getName()); + Assertions.assertEquals(1, schedule2.getTransitLines().size()); + Assertions.assertEquals("Blue line", schedule2.getTransitLines().get(Id.create(1, TransitLine.class)).getName()); } } diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitStopFacilityTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitStopFacilityTest.java index 1f0a7edb5ec..e44a9b616af 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitStopFacilityTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitStopFacilityTest.java @@ -20,7 +20,7 @@ package org.matsim.pt.transitSchedule; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/pt/utils/TransitScheduleValidatorTest.java b/matsim/src/test/java/org/matsim/pt/utils/TransitScheduleValidatorTest.java index 721bdffe4ec..e191c160ff8 100644 --- a/matsim/src/test/java/org/matsim/pt/utils/TransitScheduleValidatorTest.java +++ b/matsim/src/test/java/org/matsim/pt/utils/TransitScheduleValidatorTest.java @@ -22,7 +22,7 @@ package org.matsim.pt.utils; import org.assertj.core.api.Assertions; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -89,11 +89,11 @@ void testValidator_Transfers_implausibleTime() { schedule.getMinimalTransferTimes().set(id1, id2, 120); TransitScheduleValidator.ValidationResult result = TransitScheduleValidator.validateTransfers(schedule); - Assert.assertTrue(result.getIssues().isEmpty()); + Assertions.assertTrue(result.getIssues().isEmpty()); schedule.getMinimalTransferTimes().set(id1, id2, 0); result = TransitScheduleValidator.validateTransfers(schedule); - Assert.assertEquals("Should warn against implausible transfer time.", 1, result.getIssues().size()); + Assertions.assertEquals(1, result.getIssues().size(), "Should warn against implausible transfer time."); } @Test @@ -112,14 +112,14 @@ void testValidator_Transfers_missingStop() { schedule.getMinimalTransferTimes().set(id1, id3, 120); TransitScheduleValidator.ValidationResult result = TransitScheduleValidator.validateTransfers(schedule); - Assert.assertEquals("Should warn against missing stop3.", 1, result.getIssues().size()); - Assert.assertTrue("Message should contain hint about stop3 being missing. " + result.getIssues().get(0).getMessage(), result.getIssues().get(0).getMessage().contains("stop3")); + Assertions.assertEquals(1, result.getIssues().size(), "Should warn against missing stop3."); + Assertions.assertTrue(result.getIssues().get(0).getMessage().contains("stop3"), "Message should contain hint about stop3 being missing. " + result.getIssues().get(0).getMessage()); schedule.getMinimalTransferTimes().remove(id1, id3); schedule.getMinimalTransferTimes().set(id4, id2, 120); result = TransitScheduleValidator.validateTransfers(schedule); - Assert.assertEquals("Should warn against missing stop4.", 1, result.getIssues().size()); - Assert.assertTrue("Message should contain hint about stop4 being missing. " + result.getIssues().get(0).getMessage(), result.getIssues().get(0).getMessage().contains("stop4")); + Assertions.assertEquals(1, result.getIssues().size(), "Should warn against missing stop4."); + Assertions.assertTrue(result.getIssues().get(0).getMessage().contains("stop4"), "Message should contain hint about stop4 being missing. " + result.getIssues().get(0).getMessage()); } } diff --git a/matsim/src/test/java/org/matsim/run/CreateFullConfigTest.java b/matsim/src/test/java/org/matsim/run/CreateFullConfigTest.java index fafc8d3307a..f0c40562681 100644 --- a/matsim/src/test/java/org/matsim/run/CreateFullConfigTest.java +++ b/matsim/src/test/java/org/matsim/run/CreateFullConfigTest.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -43,10 +43,10 @@ void testMain() { args[0] = helper.getOutputDirectory() + "newConfig.xml"; File configFile = new File(args[0]); - Assert.assertFalse(configFile.exists()); + Assertions.assertFalse(configFile.exists()); CreateFullConfig.main(args); - Assert.assertTrue(configFile.exists()); + Assertions.assertTrue(configFile.exists()); } } diff --git a/matsim/src/test/java/org/matsim/run/InitRoutesTest.java b/matsim/src/test/java/org/matsim/run/InitRoutesTest.java index ae311cd6fc6..afeac78d8cb 100644 --- a/matsim/src/test/java/org/matsim/run/InitRoutesTest.java +++ b/matsim/src/test/java/org/matsim/run/InitRoutesTest.java @@ -20,7 +20,7 @@ package org.matsim.run; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.io.File; @@ -93,24 +93,24 @@ void testMain() throws Exception { new ConfigWriter(config).write(CONFIG_FILE); // some pre-tests - assertFalse("Output-File should not yet exist.", new File(PLANS_FILE_TESTOUTPUT).exists()); + assertFalse(new File(PLANS_FILE_TESTOUTPUT).exists(), "Output-File should not yet exist."); // now run the tested class InitRoutes.main(new String[] {CONFIG_FILE, PLANS_FILE_TESTOUTPUT}); // now perform some tests - assertTrue("no output generated.", new File(PLANS_FILE_TESTOUTPUT).exists()); + assertTrue(new File(PLANS_FILE_TESTOUTPUT).exists(), "no output generated."); Population population2 = scenario.getPopulation(); new PopulationReader(scenario).readFile(PLANS_FILE_TESTOUTPUT); - assertEquals("wrong number of persons.", 1, population2.getPersons().size()); + assertEquals(1, population2.getPersons().size(), "wrong number of persons."); Person person2 = population2.getPersons().get(Id.create("1", Person.class)); - assertNotNull("person 1 missing", person2); - assertEquals("wrong number of plans in person 1", 1, person2.getPlans().size()); + assertNotNull(person2, "person 1 missing"); + assertEquals(1, person2.getPlans().size(), "wrong number of plans in person 1"); Plan plan2 = person2.getPlans().get(0); Leg leg2 = (Leg) plan2.getPlanElements().get(1); NetworkRoute route2 = (NetworkRoute) leg2.getRoute(); - assertNotNull("no route assigned.", route2); - assertEquals("wrong route", 2, route2.getLinkIds().size()); + assertNotNull(route2, "no route assigned."); + assertEquals(2, route2.getLinkIds().size(), "wrong route"); } } diff --git a/matsim/src/test/java/org/matsim/run/XY2LinksTest.java b/matsim/src/test/java/org/matsim/run/XY2LinksTest.java index 5d0e67a2f27..2c878e990b7 100644 --- a/matsim/src/test/java/org/matsim/run/XY2LinksTest.java +++ b/matsim/src/test/java/org/matsim/run/XY2LinksTest.java @@ -20,7 +20,7 @@ package org.matsim.run; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.io.File; @@ -88,22 +88,22 @@ void testMain() throws Exception { new ConfigWriter(config).write(CONFIG_FILE); // some pre-tests - assertFalse("Output-File should not yet exist.", new File(PLANS_FILE_TESTOUTPUT).exists()); + assertFalse(new File(PLANS_FILE_TESTOUTPUT).exists(), "Output-File should not yet exist."); // now run the tested class XY2Links.main(new String[] {CONFIG_FILE, PLANS_FILE_TESTOUTPUT}); // now perform some tests - assertTrue("no output generated.", new File(PLANS_FILE_TESTOUTPUT).exists()); + assertTrue(new File(PLANS_FILE_TESTOUTPUT).exists(), "no output generated."); Population population2 = scenario.getPopulation(); new PopulationReader(scenario).readFile(PLANS_FILE_TESTOUTPUT); - assertEquals("wrong number of persons.", 1, population2.getPersons().size()); + assertEquals(1, population2.getPersons().size(), "wrong number of persons."); Person person2 = population2.getPersons().get(Id.create("1", Person.class)); - assertNotNull("person 1 missing", person2); - assertEquals("wrong number of plans in person 1", 1, person2.getPlans().size()); + assertNotNull(person2, "person 1 missing"); + assertEquals(1, person2.getPlans().size(), "wrong number of plans in person 1"); Plan plan2 = person2.getPlans().get(0); Activity act2 = (Activity) plan2.getPlanElements().get(0); - assertNotNull("no link assigned.", act2.getLinkId()); + assertNotNull(act2.getLinkId(), "no link assigned."); } } diff --git a/matsim/src/test/java/org/matsim/testcases/utils/LogCounterTest.java b/matsim/src/test/java/org/matsim/testcases/utils/LogCounterTest.java index 0c32d32d939..daf219efed9 100644 --- a/matsim/src/test/java/org/matsim/testcases/utils/LogCounterTest.java +++ b/matsim/src/test/java/org/matsim/testcases/utils/LogCounterTest.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -41,12 +41,12 @@ void testLogCounter_INFO() throws IOException { LOG.info("hello world - this is just a test"); LOG.warn("hello world - this is just a test"); counter.deactivate(); - Assert.assertEquals(1, counter.getInfoCount()); - Assert.assertEquals(1, counter.getWarnCount()); + Assertions.assertEquals(1, counter.getInfoCount()); + Assertions.assertEquals(1, counter.getWarnCount()); LOG.info("hello world - this is just a test"); // this should not be counted LOG.warn("hello world - this is just a test"); // this should not be counted - Assert.assertEquals(1, counter.getInfoCount()); - Assert.assertEquals(1, counter.getWarnCount()); + Assertions.assertEquals(1, counter.getInfoCount()); + Assertions.assertEquals(1, counter.getWarnCount()); } @Test @@ -56,11 +56,11 @@ void testLogCounter_WARN() throws IOException { LOG.info("hello world - this is just a test"); LOG.warn("hello world - this is just a test"); counter.deactivate(); - Assert.assertEquals(0, counter.getInfoCount()); - Assert.assertEquals(1, counter.getWarnCount()); + Assertions.assertEquals(0, counter.getInfoCount()); + Assertions.assertEquals(1, counter.getWarnCount()); LOG.info("hello world - this is just a test"); // this should not be counted LOG.warn("hello world - this is just a test"); // this should not be counted - Assert.assertEquals(0, counter.getInfoCount()); - Assert.assertEquals(1, counter.getWarnCount()); + Assertions.assertEquals(0, counter.getInfoCount()); + Assertions.assertEquals(1, counter.getWarnCount()); } } diff --git a/matsim/src/test/java/org/matsim/utils/eventsfilecomparison/EventsFileComparatorTest.java b/matsim/src/test/java/org/matsim/utils/eventsfilecomparison/EventsFileComparatorTest.java index b0870fa8b7b..6618b85dc17 100644 --- a/matsim/src/test/java/org/matsim/utils/eventsfilecomparison/EventsFileComparatorTest.java +++ b/matsim/src/test/java/org/matsim/utils/eventsfilecomparison/EventsFileComparatorTest.java @@ -19,7 +19,7 @@ package org.matsim.utils.eventsfilecomparison; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.matsim.utils.eventsfilecomparison.EventsFileComparator.Result.*; import org.junit.jupiter.api.Test; @@ -40,44 +40,44 @@ public class EventsFileComparatorTest { void testRetCode0() { String f1 = utils.getClassInputDirectory() + "/events0.xml.gz"; String f2 = utils.getClassInputDirectory() + "/events5.xml.gz"; - assertEquals("return val = " + FILES_ARE_EQUAL, FILES_ARE_EQUAL, EventsFileComparator.compare(f1, f2)); + assertEquals(FILES_ARE_EQUAL, EventsFileComparator.compare(f1, f2), "return val = " + FILES_ARE_EQUAL); - assertEquals("return val = " + FILES_ARE_EQUAL, FILES_ARE_EQUAL, EventsFileComparator.compare(f2, f1)); + assertEquals(FILES_ARE_EQUAL, EventsFileComparator.compare(f2, f1), "return val = " + FILES_ARE_EQUAL); } @Test void testRetCodeM1() { String f1 = utils.getClassInputDirectory() + "/events0.xml.gz"; String f2 = utils.getClassInputDirectory() + "/events1.xml.gz"; - assertEquals("return val " +DIFFERENT_NUMBER_OF_TIMESTEPS, DIFFERENT_NUMBER_OF_TIMESTEPS, EventsFileComparator.compare(f1, f2)); + assertEquals(DIFFERENT_NUMBER_OF_TIMESTEPS, EventsFileComparator.compare(f1, f2), "return val " +DIFFERENT_NUMBER_OF_TIMESTEPS); - assertEquals("return val " +DIFFERENT_NUMBER_OF_TIMESTEPS, DIFFERENT_NUMBER_OF_TIMESTEPS, EventsFileComparator.compare(f2, f1)); + assertEquals(DIFFERENT_NUMBER_OF_TIMESTEPS, EventsFileComparator.compare(f2, f1), "return val " +DIFFERENT_NUMBER_OF_TIMESTEPS); } @Test void testRetCodeM2() { String f1 = utils.getClassInputDirectory() + "/events0.xml.gz"; String f2 = utils.getClassInputDirectory() + "/events2.xml.gz"; - assertEquals("return val = " + DIFFERENT_TIMESTEPS, DIFFERENT_TIMESTEPS, EventsFileComparator.compare(f1, f2)); + assertEquals(DIFFERENT_TIMESTEPS, EventsFileComparator.compare(f1, f2), "return val = " + DIFFERENT_TIMESTEPS); - assertEquals("return val = " + DIFFERENT_TIMESTEPS, DIFFERENT_TIMESTEPS, EventsFileComparator.compare(f2, f1)); + assertEquals(DIFFERENT_TIMESTEPS, EventsFileComparator.compare(f2, f1), "return val = " + DIFFERENT_TIMESTEPS); } @Test void testRetCodeM3() { String f1 = utils.getClassInputDirectory() + "/events0.xml.gz"; String f2 = utils.getClassInputDirectory() + "/events3.xml.gz"; - assertEquals("return val = " + MISSING_EVENT, MISSING_EVENT, EventsFileComparator.compare(f1, f2)); + assertEquals(MISSING_EVENT, EventsFileComparator.compare(f1, f2), "return val = " + MISSING_EVENT); - assertEquals("return val = " + MISSING_EVENT, MISSING_EVENT, EventsFileComparator.compare(f2, f1)); + assertEquals(MISSING_EVENT, EventsFileComparator.compare(f2, f1), "return val = " + MISSING_EVENT); } @Test void testRetCodeM4() { String f1 = utils.getClassInputDirectory() + "/events0.xml.gz"; String f2 = utils.getClassInputDirectory() + "/events4.xml.gz"; - assertEquals("return val = " + WRONG_EVENT_COUNT, WRONG_EVENT_COUNT, EventsFileComparator.compare(f1, f2)); + assertEquals(WRONG_EVENT_COUNT, EventsFileComparator.compare(f1, f2), "return val = " + WRONG_EVENT_COUNT); - assertEquals("return val = " + WRONG_EVENT_COUNT, WRONG_EVENT_COUNT, EventsFileComparator.compare(f2, f1)); + assertEquals(WRONG_EVENT_COUNT, EventsFileComparator.compare(f2, f1), "return val = " + WRONG_EVENT_COUNT); } } diff --git a/matsim/src/test/java/org/matsim/utils/geometry/CoordUtilsTest.java b/matsim/src/test/java/org/matsim/utils/geometry/CoordUtilsTest.java index d2c2fc47982..da953b9fa65 100644 --- a/matsim/src/test/java/org/matsim/utils/geometry/CoordUtilsTest.java +++ b/matsim/src/test/java/org/matsim/utils/geometry/CoordUtilsTest.java @@ -20,7 +20,7 @@ package org.matsim.utils.geometry; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.core.utils.geometry.CoordUtils; @@ -39,8 +39,8 @@ void testPlus() { Coord coord1 = new Coord(1., 2.); Coord coord2 = new Coord(3., 4.); Coord result = CoordUtils.plus( coord1, coord2 ) ; - Assert.assertEquals( 4., result.getX(), delta) ; - Assert.assertEquals( 6., result.getY(), delta) ; + Assertions.assertEquals( 4., result.getX(), delta) ; + Assertions.assertEquals( 6., result.getY(), delta) ; } /** @@ -51,8 +51,8 @@ void testMinus() { Coord coord1 = new Coord(1., 2.); Coord coord2 = new Coord(3., 5.); Coord result = CoordUtils.minus( coord1, coord2 ) ; - Assert.assertEquals( -2., result.getX(), delta) ; - Assert.assertEquals( -3., result.getY(), delta) ; + Assertions.assertEquals( -2., result.getX(), delta) ; + Assertions.assertEquals( -3., result.getY(), delta) ; } /** @@ -62,8 +62,8 @@ void testMinus() { void testScalarMult() { Coord coord1 = new Coord(1., 2.); Coord result = CoordUtils.scalarMult( -0.33 , coord1 ) ; - Assert.assertEquals( -0.33, result.getX(), delta) ; - Assert.assertEquals( -0.66, result.getY(), delta) ; + Assertions.assertEquals( -0.33, result.getX(), delta) ; + Assertions.assertEquals( -0.66, result.getY(), delta) ; } /** @@ -74,8 +74,8 @@ void testGetCenter() { Coord coord1 = new Coord(1., 2.); Coord coord2 = new Coord(3., 5.); Coord result = CoordUtils.getCenter( coord1, coord2 ) ; - Assert.assertEquals( 2., result.getX(), delta) ; - Assert.assertEquals( 3.5, result.getY(), delta) ; + Assertions.assertEquals( 2., result.getX(), delta) ; + Assertions.assertEquals( 3.5, result.getY(), delta) ; } /** @@ -85,6 +85,6 @@ void testGetCenter() { void testLength() { Coord coord1 = new Coord(3., 2.); double result = CoordUtils.length( coord1 ) ; - Assert.assertEquals( Math.sqrt( 9. + 4. ), result, delta) ; + Assertions.assertEquals( Math.sqrt( 9. + 4. ), result, delta) ; } } diff --git a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/LanesBasedWidthCalculatorTest.java b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/LanesBasedWidthCalculatorTest.java index dfb2d043f62..1515e9e5009 100644 --- a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/LanesBasedWidthCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/LanesBasedWidthCalculatorTest.java @@ -19,7 +19,7 @@ package org.matsim.utils.gis.matsim2esri.network; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -44,11 +44,11 @@ void testGetWidth_laneWidthNaN() { l1.setNumberOfLanes(2.0); - Assert.assertEquals("The default in the Network is set to a value that is possibly not conform to the default in network_v1.dtd", 3.75, net.getEffectiveLaneWidth(), 1e-10); + Assertions.assertEquals(3.75, net.getEffectiveLaneWidth(), 1e-10, "The default in the Network is set to a value that is possibly not conform to the default in network_v1.dtd"); ((Network)net).setEffectiveLaneWidth(1.0); double w = new LanesBasedWidthCalculator((Network) net, 1.0).getWidth(l1); - Assert.assertFalse(Double.isNaN(w)); - Assert.assertEquals(2.0, w, 1e-10); + Assertions.assertFalse(Double.isNaN(w)); + Assertions.assertEquals(2.0, w, 1e-10); } } diff --git a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/Network2ESRIShapeTest.java b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/Network2ESRIShapeTest.java index 4a5d5f918eb..6700340ee8f 100755 --- a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/Network2ESRIShapeTest.java +++ b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/network/Network2ESRIShapeTest.java @@ -22,7 +22,7 @@ import java.util.Collection; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -61,7 +61,7 @@ void testPolygonCapacityShape() { new Links2ESRIShape(network,outputFileP, builder).write(); Collection writtenFeatures = ShapeFileReader.getAllFeatures(outputFileP); - Assert.assertEquals(network.getLinks().size(), writtenFeatures.size()); + Assertions.assertEquals(network.getLinks().size(), writtenFeatures.size()); } @Test @@ -84,7 +84,7 @@ void testPolygonLanesShape() { new Links2ESRIShape(network,outputFileP, builder).write(); Collection writtenFeatures = ShapeFileReader.getAllFeatures(outputFileP); - Assert.assertEquals(network.getLinks().size(), writtenFeatures.size()); + Assertions.assertEquals(network.getLinks().size(), writtenFeatures.size()); } @Test @@ -107,7 +107,7 @@ void testPolygonFreespeedShape() { new Links2ESRIShape(network,outputFileP, builder).write(); Collection writtenFeatures = ShapeFileReader.getAllFeatures(outputFileP); - Assert.assertEquals(network.getLinks().size(), writtenFeatures.size()); + Assertions.assertEquals(network.getLinks().size(), writtenFeatures.size()); } @Test @@ -130,7 +130,7 @@ void testLineStringShape() { new Links2ESRIShape(network,outputFileShp, builder).write(); Collection writtenFeatures = ShapeFileReader.getAllFeatures(outputFileShp); - Assert.assertEquals(network.getLinks().size(), writtenFeatures.size()); + Assertions.assertEquals(network.getLinks().size(), writtenFeatures.size()); } @Test @@ -146,6 +146,6 @@ void testNodesShape() { new Nodes2ESRIShape(network,outputFileShp, "DHDN_GK4").write(); Collection writtenFeatures = ShapeFileReader.getAllFeatures(outputFileShp); - Assert.assertEquals(network.getNodes().size(), writtenFeatures.size()); + Assertions.assertEquals(network.getNodes().size(), writtenFeatures.size()); } } diff --git a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShapeTest.java b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShapeTest.java index 13f5e0eb3c4..f5ec5a13be3 100755 --- a/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShapeTest.java +++ b/matsim/src/test/java/org/matsim/utils/gis/matsim2esri/plans/SelectedPlans2ESRIShapeTest.java @@ -24,7 +24,7 @@ import java.util.Collection; import java.util.zip.GZIPInputStream; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -67,7 +67,7 @@ void testSelectedPlansActsShape() throws IOException { sp.write(); Collection writtenFeatures = ShapeFileReader.getAllFeatures(outShp); - Assert.assertEquals(2235, writtenFeatures.size()); + Assertions.assertEquals(2235, writtenFeatures.size()); } @Test @@ -92,7 +92,7 @@ void testSelectedPlansLegsShape() throws IOException { sp.write(); Collection writtenFeatures = ShapeFileReader.getAllFeatures(outShp); - Assert.assertEquals(1431, writtenFeatures.size()); + Assertions.assertEquals(1431, writtenFeatures.size()); } } diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesConverterTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesConverterTest.java index 3ae0e9ed2ab..d7d60c4cde6 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesConverterTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesConverterTest.java @@ -21,7 +21,7 @@ package org.matsim.utils.objectattributes; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.time.Month; @@ -30,10 +30,10 @@ import java.util.HashMap; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; - /** + /** * @author thibautd */ public class ObjectAttributesConverterTest { @@ -45,14 +45,14 @@ void testEnumToString() { // And is thus unavailable to the ObjectAttributesConverter // So use something from the standard library, as there is no way this goes away String converted = converter.convertToString(Month.JANUARY); - Assert.assertEquals("unexpected string converted from enum value", "JANUARY", converted); + Assertions.assertEquals("JANUARY", converted, "unexpected string converted from enum value"); } @Test void testStringToEnum() { final ObjectAttributesConverter converter = new ObjectAttributesConverter(); Object converted = converter.convert(Month.class.getCanonicalName(), "JANUARY"); - Assert.assertEquals("unexpected enum converted from String value", Month.JANUARY, converted); + Assertions.assertEquals(Month.JANUARY, converted, "unexpected enum converted from String value"); } @Test diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesTest.java index 68d563e731a..11a28b9d41e 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesTest.java @@ -19,7 +19,7 @@ package org.matsim.utils.objectattributes; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -30,10 +30,10 @@ public class ObjectAttributesTest { @Test void testPutGet() { ObjectAttributes linkAttributes = new ObjectAttributes(); - Assert.assertNull(linkAttributes.getAttribute("1", "osm:roadtype")); - Assert.assertNull(linkAttributes.putAttribute("1", "osm:roadtype", "trunk")); - Assert.assertEquals("trunk", linkAttributes.getAttribute("1", "osm:roadtype")); - Assert.assertEquals("trunk", linkAttributes.putAttribute("1", "osm:roadtype", "motorway")); - Assert.assertEquals("motorway", linkAttributes.getAttribute("1", "osm:roadtype")); + Assertions.assertNull(linkAttributes.getAttribute("1", "osm:roadtype")); + Assertions.assertNull(linkAttributes.putAttribute("1", "osm:roadtype", "trunk")); + Assertions.assertEquals("trunk", linkAttributes.getAttribute("1", "osm:roadtype")); + Assertions.assertEquals("trunk", linkAttributes.putAttribute("1", "osm:roadtype", "motorway")); + Assertions.assertEquals("motorway", linkAttributes.getAttribute("1", "osm:roadtype")); } } diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesUtilsTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesUtilsTest.java index 44b32343163..df0f6588c36 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesUtilsTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesUtilsTest.java @@ -22,7 +22,7 @@ import java.util.Collection; import java.util.Iterator; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** @@ -38,11 +38,11 @@ void testGetAllAttributes() { oa.putAttribute("1", "c", "C"); Collection names = ObjectAttributesUtils.getAllAttributeNames(oa, "1"); - Assert.assertEquals(3, names.size()); - Assert.assertTrue(names.contains("a")); - Assert.assertTrue(names.contains("b")); - Assert.assertTrue(names.contains("c")); - Assert.assertFalse(names.contains("d")); + Assertions.assertEquals(3, names.size()); + Assertions.assertTrue(names.contains("a")); + Assertions.assertTrue(names.contains("b")); + Assertions.assertTrue(names.contains("c")); + Assertions.assertFalse(names.contains("d")); } @Test @@ -55,13 +55,13 @@ void testGetAllAttributes_isImmutable() { Collection names = ObjectAttributesUtils.getAllAttributeNames(oa, "1"); try { names.add("d"); - Assert.fail("Expected immutability-exception"); + Assertions.fail("Expected immutability-exception"); } catch (Exception everythingOkay) { } try { names.remove("b"); - Assert.fail("Expected immutability-exception"); + Assertions.fail("Expected immutability-exception"); } catch (Exception everythingOkay) { } @@ -69,7 +69,7 @@ void testGetAllAttributes_isImmutable() { Iterator iter = names.iterator(); iter.next(); iter.remove(); - Assert.fail("Expected immutability-exception"); + Assertions.fail("Expected immutability-exception"); } catch (Exception everythingOkay) { } diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlIOTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlIOTest.java index dd98dd5db7b..f28041ceb6a 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlIOTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlIOTest.java @@ -23,7 +23,7 @@ import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -48,10 +48,10 @@ void testReadWrite() throws IOException, SAXException, ParserConfigurationExcept ObjectAttributes oa2 = new ObjectAttributes(); new ObjectAttributesXmlReader(oa2).readFile(this.utils.getOutputDirectory() + "oa.xml"); - Assert.assertEquals("A", oa2.getAttribute("one", "a")); - Assert.assertEquals(Integer.valueOf(1), oa2.getAttribute("one", "b")); - Assert.assertEquals(Double.valueOf(1.5), oa2.getAttribute("two", "c")); - Assert.assertEquals(Boolean.TRUE, oa2.getAttribute("two", "d")); + Assertions.assertEquals("A", oa2.getAttribute("one", "a")); + Assertions.assertEquals(Integer.valueOf(1), oa2.getAttribute("one", "b")); + Assertions.assertEquals(Double.valueOf(1.5), oa2.getAttribute("two", "c")); + Assertions.assertEquals(Boolean.TRUE, oa2.getAttribute("two", "d")); } @Test @@ -64,7 +64,7 @@ void testReadWrite_CustomAttribute() { writer.putAttributeConverter(MyTuple.class, converter); writer.writeFile(this.utils.getOutputDirectory() + "oa.xml"); - Assert.assertFalse("toString() should return something different from converter to test functionality.", t.toString().equals(converter.convertToString(t))); + Assertions.assertFalse(t.toString().equals(converter.convertToString(t)), "toString() should return something different from converter to test functionality."); ObjectAttributes oa2 = new ObjectAttributes(); ObjectAttributesXmlReader reader = new ObjectAttributesXmlReader(oa2); @@ -72,11 +72,11 @@ void testReadWrite_CustomAttribute() { reader.readFile(this.utils.getOutputDirectory() + "oa.xml"); Object o = oa2.getAttribute("1", "A"); - Assert.assertNotNull(o); - Assert.assertEquals(MyTuple.class, o.getClass()); + Assertions.assertNotNull(o); + Assertions.assertEquals(MyTuple.class, o.getClass()); MyTuple t2 = (MyTuple) o; - Assert.assertEquals(3, t2.a); - Assert.assertEquals(4, t2.b); + Assertions.assertEquals(3, t2.a); + Assertions.assertEquals(4, t2.b); } } diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlReaderTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlReaderTest.java index b9b0f592bb0..dcb6644cbf0 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlReaderTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/ObjectAttributesXmlReaderTest.java @@ -24,7 +24,7 @@ import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -55,14 +55,14 @@ void testParse_customConverter() throws SAXException, ParserConfigurationExcepti reader.parse(new ByteArrayInputStream(str.getBytes())); Object o = attributes.getAttribute("one", "a"); - Assert.assertTrue(o instanceof MyTuple); - Assert.assertEquals(1, ((MyTuple) o).a); - Assert.assertEquals(2, ((MyTuple) o).b); + Assertions.assertTrue(o instanceof MyTuple); + Assertions.assertEquals(1, ((MyTuple) o).a); + Assertions.assertEquals(2, ((MyTuple) o).b); o = attributes.getAttribute("two", "b"); - Assert.assertTrue(o instanceof MyTuple); - Assert.assertEquals(3, ((MyTuple) o).a); - Assert.assertEquals(4, ((MyTuple) o).b); + Assertions.assertTrue(o instanceof MyTuple); + Assertions.assertEquals(3, ((MyTuple) o).a); + Assertions.assertEquals(4, ((MyTuple) o).b); } @Test @@ -84,16 +84,16 @@ void testParse_missingConverter() throws SAXException, ParserConfigurationExcept reader.parse(new ByteArrayInputStream(str.getBytes())); Object o = attributes.getAttribute("one", "a1"); - Assert.assertNull(o); + Assertions.assertNull(o); o = attributes.getAttribute("one", "a2"); - Assert.assertTrue(o instanceof String); - Assert.assertEquals("foo", o); + Assertions.assertTrue(o instanceof String); + Assertions.assertEquals("foo", o); o = attributes.getAttribute("two", "b1"); - Assert.assertNull(o); + Assertions.assertNull(o); o = attributes.getAttribute("two", "b2"); - Assert.assertTrue(o instanceof Integer); - Assert.assertEquals(1980, ((Integer) o).intValue()); + Assertions.assertTrue(o instanceof Integer); + Assertions.assertEquals(1980, ((Integer) o).intValue()); } @Test @@ -103,16 +103,16 @@ void testParse_withDtd() throws SAXException, ParserConfigurationException, IOEx new ObjectAttributesXmlReader(oa).readFile(filename); Object o = oa.getAttribute("one", "a"); - Assert.assertTrue(o instanceof String); - Assert.assertEquals("foobar", o); + Assertions.assertTrue(o instanceof String); + Assertions.assertEquals("foobar", o); o = oa.getAttribute("two", "b"); - Assert.assertTrue(o instanceof Boolean); - Assert.assertTrue(((Boolean) o).booleanValue()); + Assertions.assertTrue(o instanceof Boolean); + Assertions.assertTrue(((Boolean) o).booleanValue()); o = oa.getAttribute("two", "ccc"); - Assert.assertTrue(o instanceof Integer); - Assert.assertEquals(42, ((Integer) o).intValue()); + Assertions.assertTrue(o instanceof Integer); + Assertions.assertEquals(42, ((Integer) o).intValue()); } @Test @@ -122,16 +122,16 @@ void testParse_withoutDtd() throws SAXException, ParserConfigurationException, I new ObjectAttributesXmlReader(oa).readFile(filename); Object o = oa.getAttribute("one", "a"); - Assert.assertTrue(o instanceof String); - Assert.assertEquals("foobar", o); + Assertions.assertTrue(o instanceof String); + Assertions.assertEquals("foobar", o); o = oa.getAttribute("two", "b"); - Assert.assertTrue(o instanceof Boolean); - Assert.assertTrue(((Boolean) o).booleanValue()); + Assertions.assertTrue(o instanceof Boolean); + Assertions.assertTrue(((Boolean) o).booleanValue()); o = oa.getAttribute("two", "ccc"); - Assert.assertTrue(o instanceof Integer); - Assert.assertEquals(42, ((Integer) o).intValue()); + Assertions.assertTrue(o instanceof Integer); + Assertions.assertEquals(42, ((Integer) o).intValue()); } } diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/attributable/AttributesTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/attributable/AttributesTest.java index 6b43346e33c..353c7b5476b 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/attributable/AttributesTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/attributable/AttributesTest.java @@ -21,14 +21,14 @@ package org.matsim.utils.objectattributes.attributable; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; - /** + /** * @author thibautd */ public class AttributesTest { @@ -41,24 +41,23 @@ void testInsertion() { attributes.putAttribute( "the answer" , 42 ); attributes.putAttribute( "1 the begin" , 1L ); - Assert.assertEquals( "unexpected number of elements in "+attributes , - 4 , attributes.size() ); + Assertions.assertEquals( 4 , attributes.size(), "unexpected number of elements in "+attributes ); - Assert.assertEquals( "unexpected value " , - "nice" , - attributes.getAttribute( "sun" ) ); + Assertions.assertEquals( "nice" , + attributes.getAttribute( "sun" ), + "unexpected value " ); - Assert.assertEquals( "unexpected value " , - false , - attributes.getAttribute( "rain is nice" ) ); + Assertions.assertEquals( false , + attributes.getAttribute( "rain is nice" ), + "unexpected value " ); - Assert.assertEquals( "unexpected value " , - 42 , - attributes.getAttribute( "the answer" ) ); + Assertions.assertEquals( 42 , + attributes.getAttribute( "the answer" ), + "unexpected value " ); - Assert.assertEquals( "unexpected value " , - 1L , - attributes.getAttribute( "1 the begin" ) ); + Assertions.assertEquals( 1L , + attributes.getAttribute( "1 the begin" ), + "unexpected value " ); } @Test @@ -73,15 +72,13 @@ void testReplacement() { // that was wrong! final Object wrong = attributes.putAttribute( "the answer" , 42 ); - Assert.assertEquals( "unexpected number of elements in "+attributes , - 4 , attributes.size() ); + Assertions.assertEquals( 4 , attributes.size(), "unexpected number of elements in "+attributes ); - Assert.assertEquals( "unexpected replaced value " , - 7 , wrong ); + Assertions.assertEquals( 7 , wrong, "unexpected replaced value " ); - Assert.assertEquals( "unexpected value " , - 42 , - attributes.getAttribute( "the answer" ) ); + Assertions.assertEquals( 42 , + attributes.getAttribute( "the answer" ), + "unexpected value " ); } @Test @@ -96,14 +93,12 @@ void testRemoval() { // no need to store such a stupid statement final Object wrong = attributes.removeAttribute( "rain is nice" ); - Assert.assertEquals( "unexpected number of elements in "+attributes , - 3 , attributes.size() ); + Assertions.assertEquals( 3 , attributes.size(), "unexpected number of elements in "+attributes ); - Assert.assertEquals( "unexpected removed value " , - false , wrong ); + Assertions.assertEquals( false , wrong, "unexpected removed value " ); - Assert.assertNull( "unexpected mapping " , - attributes.getAttribute( "rain is nice" ) ); + Assertions.assertNull( attributes.getAttribute( "rain is nice" ), + "unexpected mapping " ); } @Test @@ -114,15 +109,15 @@ void testGetAsMap() { attributes.putAttribute( "rain is nice" , false ); Map map = attributes.getAsMap(); - Assert.assertEquals(2, map.size()); + Assertions.assertEquals(2, map.size()); - Assert.assertEquals("nice", map.get("sun")); - Assert.assertEquals(false, map.get("rain is nice")); + Assertions.assertEquals("nice", map.get("sun")); + Assertions.assertEquals(false, map.get("rain is nice")); Iterator> iter = map.entrySet().iterator(); boolean foundSun = false; boolean foundRain = false; - Assert.assertTrue(iter.hasNext()); + Assertions.assertTrue(iter.hasNext()); Map.Entry e = iter.next(); if (e.getKey().equals("sun") && e.getValue().equals("nice")) { foundSun = true; @@ -130,7 +125,7 @@ void testGetAsMap() { if (e.getKey().equals("rain is nice") && e.getValue().equals(false)) { foundRain = true; } - Assert.assertTrue(iter.hasNext()); + Assertions.assertTrue(iter.hasNext()); e = iter.next(); if (e.getKey().equals("sun") && e.getValue().equals("nice")) { foundSun = true; @@ -138,19 +133,19 @@ void testGetAsMap() { if (e.getKey().equals("rain is nice") && e.getValue().equals(false)) { foundRain = true; } - Assert.assertFalse(iter.hasNext()); + Assertions.assertFalse(iter.hasNext()); - Assert.assertTrue(foundSun); - Assert.assertTrue(foundRain); + Assertions.assertTrue(foundSun); + Assertions.assertTrue(foundRain); try { iter.next(); - Assert.fail("Expected NoSuchElementException, but got none."); + Assertions.fail("Expected NoSuchElementException, but got none."); } catch (NoSuchElementException ignore) { // expected } catch (Exception ex) { ex.printStackTrace(); - Assert.fail("Expected NoSuchElementException, but caught a different one."); + Assertions.fail("Expected NoSuchElementException, but caught a different one."); } } } diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/attributable/AttributesUtilsTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/attributable/AttributesUtilsTest.java index 7507806be8e..8f5527253e7 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/attributable/AttributesUtilsTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/attributable/AttributesUtilsTest.java @@ -1,6 +1,6 @@ package org.matsim.utils.objectattributes.attributable; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/CoordArrayConverterTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/CoordArrayConverterTest.java index c57aa1a4b75..72165d592a6 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/CoordArrayConverterTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/CoordArrayConverterTest.java @@ -20,7 +20,7 @@ package org.matsim.utils.objectattributes.attributeconverters; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -31,25 +31,25 @@ void testFromToString() { final CoordArrayConverter converter = new CoordArrayConverter(); String a = "[(223380.4988791829;6758072.4280857295),(223404.67545027257;6758049.17275259),(223417.0127605943;6758038.021038004),(223450.67625251273;6757924.791645723),(223456.13332351885;6757906.359813054)]"; Coord[] coords = converter.convert(a); - Assert.assertEquals(coords.length, 5); - Assert.assertEquals(coords[0].hasZ(), false); - Assert.assertEquals(coords[0].getX(), 223380.4988791829, 0.00005); - Assert.assertEquals(coords[0].getY(), 6758072.4280857295, 0.00005); - Assert.assertEquals(coords[1].hasZ(), false); - Assert.assertEquals(coords[1].getX(), 223404.67545027257, 0.00005); - Assert.assertEquals(coords[1].getY(), 6758049.17275259, 0.00005); - Assert.assertEquals(coords[2].hasZ(), false); - Assert.assertEquals(coords[2].getX(), 223417.0127605943, 0.00005); - Assert.assertEquals(coords[2].getY(), 6758038.021038004, 0.00005); - Assert.assertEquals(coords[3].hasZ(), false); - Assert.assertEquals(coords[3].getX(), 223450.67625251273, 0.00005); - Assert.assertEquals(coords[3].getY(), 6757924.791645723, 0.00005); - Assert.assertEquals(coords[4].hasZ(), false); - Assert.assertEquals(coords[4].getX(), 223456.13332351885, 0.00005); - Assert.assertEquals(coords[4].getY(), 6757906.359813054, 0.00005); + Assertions.assertEquals(coords.length, 5); + Assertions.assertEquals(coords[0].hasZ(), false); + Assertions.assertEquals(coords[0].getX(), 223380.4988791829, 0.00005); + Assertions.assertEquals(coords[0].getY(), 6758072.4280857295, 0.00005); + Assertions.assertEquals(coords[1].hasZ(), false); + Assertions.assertEquals(coords[1].getX(), 223404.67545027257, 0.00005); + Assertions.assertEquals(coords[1].getY(), 6758049.17275259, 0.00005); + Assertions.assertEquals(coords[2].hasZ(), false); + Assertions.assertEquals(coords[2].getX(), 223417.0127605943, 0.00005); + Assertions.assertEquals(coords[2].getY(), 6758038.021038004, 0.00005); + Assertions.assertEquals(coords[3].hasZ(), false); + Assertions.assertEquals(coords[3].getX(), 223450.67625251273, 0.00005); + Assertions.assertEquals(coords[3].getY(), 6757924.791645723, 0.00005); + Assertions.assertEquals(coords[4].hasZ(), false); + Assertions.assertEquals(coords[4].getX(), 223456.13332351885, 0.00005); + Assertions.assertEquals(coords[4].getY(), 6757906.359813054, 0.00005); String b = converter.convertToString(coords); - Assert.assertEquals(a, b); + Assertions.assertEquals(a, b); } } diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/CoordConverterTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/CoordConverterTest.java index ee8b2db2c58..7395273817d 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/CoordConverterTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/CoordConverterTest.java @@ -20,7 +20,7 @@ package org.matsim.utils.objectattributes.attributeconverters; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -32,12 +32,12 @@ void testFromToString() { final CoordConverter converter = new CoordConverter(); String a = "(224489.3667496938;6757449.720111595)"; Coord coord = converter.convert(a); - Assert.assertEquals(coord.hasZ(), false); - Assert.assertEquals(coord.getX(), 224489.3667496938, 0.00005); - Assert.assertEquals(coord.getY(), 6757449.720111595, 0.00005); + Assertions.assertEquals(coord.hasZ(), false); + Assertions.assertEquals(coord.getX(), 224489.3667496938, 0.00005); + Assertions.assertEquals(coord.getY(), 6757449.720111595, 0.00005); String b = converter.convertToString(coord); - Assert.assertEquals(a, b); + Assertions.assertEquals(a, b); } } diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/DoubleArrayConverterTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/DoubleArrayConverterTest.java index e97d61653a8..35a30b580e7 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/DoubleArrayConverterTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/DoubleArrayConverterTest.java @@ -21,10 +21,10 @@ package org.matsim.utils.objectattributes.attributeconverters; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; - /** + /** * @author jbischoff */ public class DoubleArrayConverterTest { @@ -35,15 +35,15 @@ void testFromToString() { final DoubleArrayConverter converter = new DoubleArrayConverter(); String a = "-0.1,0,0.0005,17.3,5.2E22"; double[] array = converter.convert(a); - Assert.assertEquals(array.length, 5); - Assert.assertEquals(array[0], -0.1, 0.00005); - Assert.assertEquals(array[1], 0.0, 0.00005); - Assert.assertEquals(array[2], 0.0005, 0.00005); - Assert.assertEquals(array[3], 17.3, 0.00005); - Assert.assertEquals(array[4], 5.2E22, 0.00005); + Assertions.assertEquals(array.length, 5); + Assertions.assertEquals(array[0], -0.1, 0.00005); + Assertions.assertEquals(array[1], 0.0, 0.00005); + Assertions.assertEquals(array[2], 0.0005, 0.00005); + Assertions.assertEquals(array[3], 17.3, 0.00005); + Assertions.assertEquals(array[4], 5.2E22, 0.00005); String b = converter.convertToString(array); - Assert.assertEquals("-0.1,0.0,5.0E-4,17.3,5.2E22", b); + Assertions.assertEquals("-0.1,0.0,5.0E-4,17.3,5.2E22", b); } diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/EnumConverterTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/EnumConverterTest.java index 63318c6c71a..d69151a9db7 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/EnumConverterTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/EnumConverterTest.java @@ -21,10 +21,10 @@ package org.matsim.utils.objectattributes.attributeconverters; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; - /** + /** * @author thibautd */ public class EnumConverterTest { @@ -45,15 +45,15 @@ void testFromString() { MyEnum some = converter.convert( "SOME_CONSTANT" ); MyEnum other = converter.convert( "SOME_OTHER_CONSTANT" ); - Assert.assertEquals("unexpected enum", MyEnum.SOME_CONSTANT, some); - Assert.assertEquals("unexpected enum", MyEnum.SOME_OTHER_CONSTANT, other); + Assertions.assertEquals(MyEnum.SOME_CONSTANT, some, "unexpected enum"); + Assertions.assertEquals(MyEnum.SOME_OTHER_CONSTANT, other, "unexpected enum"); } @Test void testToString() { final EnumConverter converter = new EnumConverter<>( MyEnum.class ); - Assert.assertEquals( "unexpected String value", "SOME_CONSTANT", converter.convertToString( MyEnum.SOME_CONSTANT ) ); - Assert.assertEquals( "unexpected String value", "SOME_OTHER_CONSTANT", converter.convertToString( MyEnum.SOME_OTHER_CONSTANT ) ); + Assertions.assertEquals( "SOME_CONSTANT", converter.convertToString( MyEnum.SOME_CONSTANT ), "unexpected String value" ); + Assertions.assertEquals( "SOME_OTHER_CONSTANT", converter.convertToString( MyEnum.SOME_OTHER_CONSTANT ), "unexpected String value" ); } } diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/StringCollectionConverterTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/StringCollectionConverterTest.java index 7470881f42d..bdaa3ee6977 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/StringCollectionConverterTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/StringCollectionConverterTest.java @@ -3,10 +3,10 @@ import java.util.Collection; import java.util.Map; -import static org.junit.Assert.assertEquals; - import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class StringCollectionConverterTest { @Test diff --git a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/StringStringMapConverterTest.java b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/StringStringMapConverterTest.java index 686cc3efe37..a6884a90965 100644 --- a/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/StringStringMapConverterTest.java +++ b/matsim/src/test/java/org/matsim/utils/objectattributes/attributeconverters/StringStringMapConverterTest.java @@ -1,6 +1,6 @@ package org.matsim.utils.objectattributes.attributeconverters; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; diff --git a/matsim/src/test/java/org/matsim/vehicles/MatsimVehicleWriterTest.java b/matsim/src/test/java/org/matsim/vehicles/MatsimVehicleWriterTest.java index 152586c364d..d50dbb5234e 100644 --- a/matsim/src/test/java/org/matsim/vehicles/MatsimVehicleWriterTest.java +++ b/matsim/src/test/java/org/matsim/vehicles/MatsimVehicleWriterTest.java @@ -19,7 +19,7 @@ package org.matsim.vehicles; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.io.File; import java.io.FileNotFoundException; diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV1Test.java b/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV1Test.java index 7f6716c5acd..79e3ca7e10d 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV1Test.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV1Test.java @@ -19,7 +19,7 @@ package org.matsim.vehicles; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.Map; diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV2Test.java b/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV2Test.java index 599b853217d..83e51b5bdf3 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV2Test.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV2Test.java @@ -19,7 +19,7 @@ package org.matsim.vehicles; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.Map; diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV1Test.java b/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV1Test.java index d103a29f287..1e970b893f4 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV1Test.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV1Test.java @@ -19,7 +19,7 @@ package org.matsim.vehicles; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.io.File; import java.util.Map; diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV2Test.java b/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV2Test.java index 9b65d2f6608..e3ebbe417bf 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV2Test.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV2Test.java @@ -19,7 +19,7 @@ package org.matsim.vehicles; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.io.File; import java.io.IOException; diff --git a/matsim/src/test/java/org/matsim/vehicles/VehiclesImplTest.java b/matsim/src/test/java/org/matsim/vehicles/VehiclesImplTest.java index 2cace0fd2e6..4835940bbef 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehiclesImplTest.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehiclesImplTest.java @@ -19,7 +19,7 @@ package org.matsim.vehicles; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; @@ -40,7 +40,7 @@ void testAddVehicle() { /* Must add vehicle type before adding vehicle. */ try{ vehicles.addVehicle(v1); - Assert.fail("Should not allow adding a vehicle if vehicle type has not been added to container first."); + Assertions.fail("Should not allow adding a vehicle if vehicle type has not been added to container first."); } catch(IllegalArgumentException e){ /* Pass. */ } @@ -51,7 +51,7 @@ void testAddVehicle() { Vehicle v2 = vehicles.getFactory().createVehicle(Id.create("v1", Vehicle.class), testType); try{ vehicles.addVehicle(v2); - Assert.fail("Cannot add another vehicle with the same Id."); + Assertions.fail("Cannot add another vehicle with the same Id."); } catch (IllegalArgumentException e){ /* Pass. */ } @@ -70,7 +70,7 @@ void testGetVehicles(){ try{ vehicles.getVehicles().put(Id.create("v1", Vehicle.class), v1 ); vehicles.getVehicles(); - Assert.fail("Should not be able to add to an unmodiafiable Map"); + Assertions.fail("Should not be able to add to an unmodiafiable Map"); } catch (UnsupportedOperationException e){ /* Pass. */ } @@ -85,7 +85,7 @@ void testGetVehicleTypes(){ /* Should get an unmodifiable Map of the Vehicles container. */ try{ vehicles.getVehicleTypes().put(Id.create("type1", VehicleType.class), t1 ); - Assert.fail("Should not be able to add to an unmodiafiable Map"); + Assertions.fail("Should not be able to add to an unmodiafiable Map"); } catch (UnsupportedOperationException e){ /* Pass. */ } @@ -101,7 +101,7 @@ void testAddVehicleType(){ vehicles.addVehicleType(t1); try{ vehicles.addVehicleType(t2); - Assert.fail("Cannot add another vehicle type with the same Id"); + Assertions.fail("Cannot add another vehicle type with the same Id"); } catch (IllegalArgumentException e){ /* Pass. */ } @@ -115,11 +115,11 @@ void testRemoveVehicle() { Vehicle v1 = vehicles.getFactory().createVehicle(Id.create("v1", Vehicle.class), t1); - Assert.assertEquals(0, vehicles.getVehicles().size()); + Assertions.assertEquals(0, vehicles.getVehicles().size()); vehicles.addVehicle(v1); - Assert.assertEquals(1, vehicles.getVehicles().size()); + Assertions.assertEquals(1, vehicles.getVehicles().size()); vehicles.removeVehicle(Id.create("v1", Vehicle.class)); - Assert.assertEquals(0, vehicles.getVehicles().size()); + Assertions.assertEquals(0, vehicles.getVehicles().size()); } @Test @@ -132,7 +132,7 @@ void testRemoveVehicleType() { try { vehicles.removeVehicleType(t1.getId()); - Assert.fail("expected exception, as vehicle type is still in use."); + Assertions.fail("expected exception, as vehicle type is still in use."); } catch (IllegalArgumentException e) { // pass } diff --git a/matsim/src/test/java/org/matsim/vis/snapshotwriters/PositionInfoTest.java b/matsim/src/test/java/org/matsim/vis/snapshotwriters/PositionInfoTest.java index 178b07d1236..cd8c7e9a449 100644 --- a/matsim/src/test/java/org/matsim/vis/snapshotwriters/PositionInfoTest.java +++ b/matsim/src/test/java/org/matsim/vis/snapshotwriters/PositionInfoTest.java @@ -20,7 +20,7 @@ package org.matsim.vis.snapshotwriters; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java b/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java index 88ee4b705a2..bad57d42cc7 100644 --- a/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java +++ b/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -124,7 +124,7 @@ public void install() { */ File file = new File(this.utils.getOutputDirectory() + "/ITERS/it.0/0." + ExecutedPlansServiceImpl.EXECUTEDPLANSFILE); - Assert.assertTrue(file.exists()); + Assertions.assertTrue(file.exists()); Config experiencedConfig = ConfigUtils.createConfig(); experiencedConfig.plans().setInputFile(this.utils.getOutputDirectory() + "/ITERS/it.0/0." + @@ -139,10 +139,10 @@ public void install() { Leg leg02 = (Leg) p02.getSelectedPlan().getPlanElements().get(1); // expect leg from p01 to be unchanged - Assert.assertEquals(1, ((NetworkRoute) leg01.getRoute()).getLinkIds().size()); + Assertions.assertEquals(1, ((NetworkRoute) leg01.getRoute()).getLinkIds().size()); // expect leg from p02 to be adapted - Assert.assertEquals(3, ((NetworkRoute) leg02.getRoute()).getLinkIds().size()); + Assertions.assertEquals(3, ((NetworkRoute) leg02.getRoute()).getLinkIds().size()); } private static class WriterInitializer implements StartupListener { diff --git a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java index f0870a25f99..cde10531df3 100644 --- a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java +++ b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java @@ -20,12 +20,12 @@ package org.matsim.withinday.replanning.identifiers.tools; -import static org.junit.Assert.assertEquals; - import java.util.LinkedHashMap; import java.util.Map; import jakarta.inject.Inject; + +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; diff --git a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java index ed3ffd5c1a7..6b37b4707d3 100644 --- a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java +++ b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java @@ -20,7 +20,7 @@ package org.matsim.withinday.replanning.identifiers.tools; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import jakarta.inject.Inject; import org.junit.jupiter.api.Test; diff --git a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/TtmobsimListener.java b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/TtmobsimListener.java index 7d8dab36738..e1330840f24 100644 --- a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/TtmobsimListener.java +++ b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/TtmobsimListener.java @@ -18,8 +18,7 @@ * *********************************************************************** */ package org.matsim.withinday.trafficmonitoring; - -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.network.Link; import org.matsim.core.mobsim.framework.events.MobsimAfterSimStepEvent; @@ -59,7 +58,7 @@ public TtmobsimListener(NetworkChangeEvent nce) { this.networkChangeEventTime = nce.getStartTime(); this.reducedFreespeed = nce.getFreespeedChange().getValue(); - Assert.assertEquals(true, this.reducedFreespeed < this.link.getFreespeed()); + Assertions.assertEquals(true, this.reducedFreespeed < this.link.getFreespeed()); } } } @@ -69,18 +68,18 @@ public void notifyMobsimAfterSimStep(MobsimAfterSimStepEvent e) { if (e.getSimulationTime() <= networkChangeEventTime) { - Assert.assertEquals("Wrong travel time at time step " + e.getSimulationTime() + ". Should be the freespeed travel time.", - Math.ceil(link.getLength()/link.getFreespeed()), + Assertions.assertEquals(Math.ceil(link.getLength()/link.getFreespeed()), Math.ceil(travelTime.getLinkTravelTime(link, e.getSimulationTime(), null, null)), - testUtils.EPSILON); + testUtils.EPSILON, + "Wrong travel time at time step " + e.getSimulationTime() + ". Should be the freespeed travel time."); case1 = true; } else { - Assert.assertEquals("Wrong travel time at time step " + e.getSimulationTime() + ". Should be the travel time resulting from the network change event (reduced freespeed).", - Math.ceil(link.getLength() / reducedFreespeed), + Assertions.assertEquals(Math.ceil(link.getLength() / reducedFreespeed), Math.ceil(travelTime.getLinkTravelTime(link, e.getSimulationTime(), null, null)), - testUtils.EPSILON); + testUtils.EPSILON, + "Wrong travel time at time step " + e.getSimulationTime() + ". Should be the travel time resulting from the network change event (reduced freespeed)."); case2 = true; } diff --git a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java index 8bb4b9ca4f6..22473f07d16 100644 --- a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java +++ b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java @@ -20,7 +20,7 @@ package org.matsim.withinday.trafficmonitoring; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; diff --git a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java index 85961c100a2..2b63bbb9f0d 100644 --- a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java +++ b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Set; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -130,8 +130,8 @@ final void testTTviaMobSimAfterSimStepListener() { controler.run(); - Assert.assertEquals(true, ttmobsimListener.isCase1()); - Assert.assertEquals(true, ttmobsimListener.isCase2()); + Assertions.assertEquals(true, ttmobsimListener.isCase1()); + Assertions.assertEquals(true, ttmobsimListener.isCase2()); } diff --git a/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java b/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java index 6931b60b91f..5b0d8f2883b 100644 --- a/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java +++ b/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java @@ -20,7 +20,7 @@ package org.matsim.withinday.utils; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.ArrayList; import java.util.Arrays; diff --git a/matsim/src/test/java/org/matsim/withinday/utils/ReplacePlanElementsTest.java b/matsim/src/test/java/org/matsim/withinday/utils/ReplacePlanElementsTest.java index 3d2f16c8350..ffd14815885 100644 --- a/matsim/src/test/java/org/matsim/withinday/utils/ReplacePlanElementsTest.java +++ b/matsim/src/test/java/org/matsim/withinday/utils/ReplacePlanElementsTest.java @@ -20,7 +20,7 @@ package org.matsim.withinday.utils; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; From b64024fbe32599135a4bcc57bdec34961c246998 Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Mon, 11 Dec 2023 19:51:50 +0100 Subject: [PATCH 12/21] fixed imports --- .../freight/carriers/jsprit/MatsimTransformerTest.java | 1 + .../freight/carriers/utils/CarrierControlerUtilsTest.java | 1 + .../modules/InsertionRemovalIterativeActionTest.java | 1 + .../socnetsim/usage/replanning/GroupPlanStrategyTest.java | 6 +++--- .../matsim/analysis/ScoreStatsControlerListenerTest.java | 7 ++++--- matsim/src/test/java/org/matsim/counts/CountsV2Test.java | 4 ++-- .../algorithms/ChooseRandomSingleLegModeTest.java | 3 ++- .../org/matsim/pt/utils/TransitScheduleValidatorTest.java | 7 ++++--- 8 files changed, 18 insertions(+), 12 deletions(-) diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java index a3e187a4fe2..310c1942ad4 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java @@ -50,6 +50,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.*; public class MatsimTransformerTest { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java index 143a2a45a6b..55d1c268c7a 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java @@ -31,6 +31,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIterativeActionTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIterativeActionTest.java index fe45fa49200..bae28cc67cf 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIterativeActionTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIterativeActionTest.java @@ -29,6 +29,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Before; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/GroupPlanStrategyTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/GroupPlanStrategyTest.java index 08ff8da07ce..5202da7e0ed 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/GroupPlanStrategyTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/usage/replanning/GroupPlanStrategyTest.java @@ -19,8 +19,6 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.usage.replanning; -import static org.junit.jupiter.api.Assertions.assertFalse; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -46,6 +44,8 @@ import org.matsim.contrib.socnetsim.framework.replanning.selectors.EmptyIncompatiblePlansIdentifierFactory; import org.matsim.contrib.socnetsim.framework.replanning.selectors.HighestScoreSumSelector; +import static org.junit.jupiter.api.Assertions.*; + /** * @author thibautd */ @@ -212,7 +212,7 @@ private static Person createPerson( return person; } - + private static ReplanningContext createContext() { return null; } diff --git a/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java index 1a25c737c17..1cf98effe1f 100644 --- a/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java @@ -5,7 +5,6 @@ import java.util.Collections; import java.util.ListIterator; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -34,6 +33,8 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.testcases.MatsimTestUtils; +import static org.assertj.core.api.Assertions.assertThat; + /** * @author Aravind * @@ -559,10 +560,10 @@ private void readAndValidateValues(String outDir, int itr, Population populatio iteration++; } - Assertions.assertThat(new File(outDir, "scorestats_group1.csv")) + assertThat(new File(outDir, "scorestats_group1.csv")) .isFile(); - Assertions.assertThat(new File(outDir, "scorestats_group2.csv")) + assertThat(new File(outDir, "scorestats_group2.csv")) .isFile(); } diff --git a/matsim/src/test/java/org/matsim/counts/CountsV2Test.java b/matsim/src/test/java/org/matsim/counts/CountsV2Test.java index 85c211033ee..d8aacb1146a 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsV2Test.java +++ b/matsim/src/test/java/org/matsim/counts/CountsV2Test.java @@ -1,6 +1,5 @@ package org.matsim.counts; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -22,6 +21,7 @@ import java.util.SplittableRandom; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatNoException; import static org.junit.jupiter.api.Assertions.assertThrows; public class CountsV2Test { @@ -63,7 +63,7 @@ void test_reader_writer() throws IOException { Counts counts = new Counts<>(); CountsReaderMatsimV2 reader = new CountsReaderMatsimV2(counts, Link.class); - Assertions.assertThatNoException().isThrownBy(() -> reader.readFile(filename)); + Assertions.assertDoesNotThrow(() -> reader.readFile(filename)); Map, MeasurementLocation> countMap = counts.getMeasureLocations(); Assertions.assertEquals(21, countMap.size()); diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomSingleLegModeTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomSingleLegModeTest.java index 4acfb093c05..331a2fc5de3 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomSingleLegModeTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomSingleLegModeTest.java @@ -20,10 +20,11 @@ package org.matsim.population.algorithms; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.*; import java.util.Random; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; diff --git a/matsim/src/test/java/org/matsim/pt/utils/TransitScheduleValidatorTest.java b/matsim/src/test/java/org/matsim/pt/utils/TransitScheduleValidatorTest.java index e191c160ff8..fb97f3b1ecd 100644 --- a/matsim/src/test/java/org/matsim/pt/utils/TransitScheduleValidatorTest.java +++ b/matsim/src/test/java/org/matsim/pt/utils/TransitScheduleValidatorTest.java @@ -21,7 +21,6 @@ package org.matsim.pt.utils; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -39,6 +38,8 @@ import java.util.Collections; import java.util.List; +import static org.assertj.core.api.Assertions.assertThat; + public class TransitScheduleValidatorTest { @Test @@ -47,7 +48,7 @@ void testPtTutorial() { ConfigUtils.loadConfig("test/scenarios/pt-tutorial/0.config.xml")); TransitScheduleValidator.ValidationResult validationResult = TransitScheduleValidator.validateAll( scenario.getTransitSchedule(), scenario.getNetwork()); - Assertions.assertThat(validationResult.getIssues()).isEmpty(); + assertThat(validationResult.getIssues()).isEmpty(); } @Test @@ -65,7 +66,7 @@ void testPtTutorialWithError() { scenario.getTransitSchedule(), scenario.getNetwork()); System.out.println(validationResult); - Assertions.assertThat(validationResult.getIssues()).usingRecursiveFieldByFieldElementComparator() + assertThat(validationResult.getIssues()).usingRecursiveFieldByFieldElementComparator() .containsExactly(new TransitScheduleValidator.ValidationResult.ValidationIssue<>( TransitScheduleValidator.ValidationResult.Severity.ERROR, "Transit line Blue Line, route 3to1: Stop 2b cannot be reached along network route.", From 58b12657b4de803399c1aab99869bac7257ffccc Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Mon, 11 Dec 2023 20:15:10 +0100 Subject: [PATCH 13/21] fixed compile --- .../analysis/ModeStatsControlerListenerTest.java | 2 +- .../analysis/ScoreStatsControlerListenerTest.java | 6 +++--- .../org/matsim/analysis/TravelDistanceStatsTest.java | 2 +- .../core/config/groups/ControllerConfigGroupTest.java | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java index 8182e8d3032..9b744c8d1b8 100644 --- a/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java @@ -454,7 +454,7 @@ private void readAndcompareValues(HashMap modes, int itr) { } iteration++; } - Assert.assertEquals(itr, iteration); + Assertions.assertEquals(itr, iteration); } catch (IOException e) { e.printStackTrace(); } diff --git a/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java index 7837bcb9e2f..2bc0864ed85 100644 --- a/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java @@ -563,10 +563,10 @@ private void readAndValidateValues(String outDir, int itr, Population populatio Assertions.assertEquals(itr, iteration); - assertThat(new File(outDir, "scorestats_group1.csv")) - Assert.assertEquals(itr, iteration); + assertThat(new File(outDir, "scorestats_group1.csv")).isFile(); + Assertions.assertEquals(itr, iteration); - Assertions.assertThat(new File(outDir, "scorestats_group1.csv")) + assertThat(new File(outDir, "scorestats_group1.csv")) .isFile(); assertThat(new File(outDir, "scorestats_group2.csv")) diff --git a/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java b/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java index cfb2ffa8b61..1bd013dbb2b 100644 --- a/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java +++ b/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java @@ -397,7 +397,7 @@ private void readAndValidateValues(int itr, Double legSum, int totalTrip, long t } iteration++; } - Assert.assertEquals("There are too less entries.", itr, iteration); + Assertions.assertEquals(itr, iteration, "There are too less entries."); } catch (IOException e) { e.printStackTrace(); } diff --git a/matsim/src/test/java/org/matsim/core/config/groups/ControllerConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/ControllerConfigGroupTest.java index d524334f96a..431dd6a5d3c 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/ControllerConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/ControllerConfigGroupTest.java @@ -165,17 +165,17 @@ void testWriteSnapshotInterval(){ public void testCreateGraphsInterval() { ControllerConfigGroup cg = new ControllerConfigGroup(); //initial value - Assert.assertEquals(1, cg.getCreateGraphsInterval()); + Assertions.assertEquals(1, cg.getCreateGraphsInterval()); //modify by string cg.addParam("createGraphsInterval", "10"); - Assert.assertEquals(10, cg.getCreateGraphsInterval()); + Assertions.assertEquals(10, cg.getCreateGraphsInterval()); //modify by setter cg.setCreateGraphsInterval(42); - Assert.assertEquals("42", cg.getValue("createGraphsInterval")); - Assert.assertEquals(42, cg.getCreateGraphsInterval()); + Assertions.assertEquals("42", cg.getValue("createGraphsInterval")); + Assertions.assertEquals(42, cg.getCreateGraphsInterval()); //modify by deprecated setter cg.setCreateGraphs(true); - Assert.assertEquals(1, cg.getCreateGraphsInterval()); + Assertions.assertEquals(1, cg.getCreateGraphsInterval()); } From e10a3920a11b08cf8374ab4468c150eb1e809d8d Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Mon, 11 Dec 2023 20:30:55 +0100 Subject: [PATCH 14/21] fix before and after --- benchmark/pom.xml | 4 -- .../kai/KNAnalysisEventsHandlerTest.java | 8 +-- .../BicycleLinkSpeedCalculatorTest.java | 4 +- .../IsTheRightCustomerScoredTest.java | 4 +- .../util/WeightedRandomSelectionTest.java | 4 +- .../MultiModaFixedDrtLegEstimatorTest.java | 4 +- .../MultiModalDrtLegEstimatorTest.java | 4 +- ...ultiInsertionDetourPathCalculatorTest.java | 4 +- ...ngleInsertionDetourPathCalculatorTest.java | 4 +- .../path/OneToManyPathCalculatorTest.java | 4 +- ...issionAnalysisModuleTrafficSituations.java | 14 ++-- .../freight/carriers/CarrierModuleTest.java | 4 +- .../carriers/CarrierPlanXmlReaderV2Test.java | 4 +- .../CarrierPlanXmlReaderV2WithDtdTest.java | 4 +- .../carriers/CarrierPlanXmlWriterV2Test.java | 4 +- .../CarrierPlanXmlWriterV2_1Test.java | 4 +- .../CarrierVehicleTypeLoaderTest.java | 4 +- .../CarrierVehicleTypeReaderTest.java | 4 +- .../carriers/CarrierVehicleTypeTest.java | 4 +- .../EquilWithCarrierWithPersonsIT.java | 4 +- .../carriers/jsprit/FixedCostsTest.java | 4 +- .../utils/CarrierControlerUtilsIT.java | 4 +- .../utils/CarrierControlerUtilsTest.java | 4 +- .../hybridsim/utils/IdIntMapperTest.java | 8 +-- .../matsim/modechoice/EstimateRouterTest.java | 4 +- .../org/matsim/modechoice/ScenarioTest.java | 4 +- ...RelaxedMassConservationConstraintTest.java | 6 +- .../RelaxedSubtourConstraintTest.java | 6 +- .../MultinomialLogitSelectorTest.java | 4 +- .../modechoice/search/TopKMinMaxTest.java | 4 +- .../frozenepsilons/SamplerTest.java | 4 +- .../matrixbasedptrouter/PtMatrixTest.java | 4 +- .../genericUtils/TerminusStopFinderTest.java | 52 +++++++------- ...eaBtwLinksVsTerminiBeelinePenaltyTest.java | 32 ++++----- .../RouteDesignScoringManagerTest.java | 72 +++++++++---------- .../StopServedMultipleTimesPenaltyTest.java | 28 ++++---- .../networkReader/OsmNetworkParserTest.java | 4 +- .../networkReader/OsmSignalsParserTest.java | 4 +- contribs/pom.xml | 4 -- .../railsim/qsimengine/RailsimEngineTest.java | 4 +- .../matsim/mobsim/qsim/SBBQSimModuleTest.java | 4 +- .../simwrapper/viz/PlotlyExamplesTest.java | 4 +- .../org/matsim/simwrapper/viz/PlotlyTest.java | 4 +- .../replanning/grouping/GroupPlansTest.java | 10 +-- .../replanning/modules/MergingTest.java | 10 +-- .../selectors/HighestWeightSelectorTest.java | 10 +-- .../selectors/RandomSelectorsTest.java | 16 ++--- .../WhoIsTheBossSelectorTest.java | 2 +- .../GroupCompositionPenalizerTest.java | 2 +- .../jointtrips/JointTravelUtilsTest.java | 22 +++--- ...InsertionRemovalIgnoranceBehaviorTest.java | 8 +-- .../InsertionRemovalIterativeActionTest.java | 4 +- .../JointTripRemoverAlgorithmTest.java | 8 +-- ...nchronizeCoTravelerPlansAlgorithmTest.java | 10 +-- .../router/JointTripRouterFactoryTest.java | 4 +- ...ehicleToPlansInGroupPlanAlgorithmTest.java | 8 +-- ...omPersonAttributesNoSubpopulationTest.java | 4 +- ...ingParametersFromPersonAttributesTest.java | 4 +- .../analysis/RunFreightAnalysisIT.java | 4 +- .../java/playground/vsp/ev/UrbanEVTests.java | 2 +- ...rarchicalFLowEfficiencyCalculatorTest.java | 4 +- .../PlanFileModifierTest.java | 4 +- .../vsp/pt/fare/PtTripFareEstimatorTest.java | 4 +- ...nScoringParametersNoSubpopulationTest.java | 4 +- ...ityOfMoneyPersonScoringParametersTest.java | 4 +- matsim/pom.xml | 4 -- .../SwissRailRaptorConfigGroupTest.java | 4 +- .../routing/pt/raptor/RaptorUtilsTest.java | 4 +- .../pt/raptor/SwissRailRaptorModuleTest.java | 4 +- .../org/matsim/analysis/CalcLegTimesTest.java | 8 +-- .../api/core/v01/DemandGenerationTest.java | 8 +-- .../core/v01/IdDeSerializationModuleTest.java | 4 +- .../core/controler/ControlerEventsTest.java | 8 +-- .../events/ParallelEventsManagerTest.java | 6 +- .../core/mobsim/hermes/FlowCapacityTest.java | 4 +- .../matsim/core/mobsim/hermes/HermesTest.java | 4 +- .../core/mobsim/hermes/HermesTransitTest.java | 4 +- .../mobsim/jdeqsim/AbstractJDEQSimTest.java | 8 +-- .../core/mobsim/qsim/pt/UmlaufDriverTest.java | 4 +- .../algorithms/NetworkSimplifierTest.java | 26 +++---- .../filter/NetworkFilterManagerTest.java | 4 +- .../annealing/ReplanningAnnealerTest.java | 4 +- .../modules/ExternalModuleTest.java | 4 +- .../selectors/ExpBetaPlanSelectorTest.java | 8 +-- .../selectors/PathSizeLogitSelectorTest.java | 8 +-- .../router/TestActivityWrapperFacility.java | 4 +- .../core/router/TripStructureUtilsTest.java | 16 ++--- ...yparNagelOpenTimesScoringFunctionTest.java | 8 +-- .../java/org/matsim/counts/CountTest.java | 4 +- .../PermissibleModesCalculatorImplTest.java | 16 ++--- .../vehicles/MatsimVehicleWriterTest.java | 4 +- .../matsim/vehicles/VehicleReaderV1Test.java | 4 +- .../matsim/vehicles/VehicleReaderV2Test.java | 4 +- .../matsim/vehicles/VehicleWriteReadTest.java | 4 +- .../matsim/vehicles/VehicleWriterV1Test.java | 4 +- .../matsim/vehicles/VehicleWriterV2Test.java | 4 +- pom.xml | 6 -- 97 files changed, 349 insertions(+), 367 deletions(-) diff --git a/benchmark/pom.xml b/benchmark/pom.xml index dd8bbafda2c..f8104490737 100644 --- a/benchmark/pom.xml +++ b/benchmark/pom.xml @@ -40,10 +40,6 @@ matsim-examples 16.0-SNAPSHOT - - org.junit.vintage - junit-vintage-engine - org.junit.jupiter junit-jupiter-engine diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java index a42e5780cc4..ec4fa06dd61 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java @@ -22,8 +22,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.Ignore; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -68,7 +68,7 @@ public class KNAnalysisEventsHandlerTest { private Population population = null ; private Network network = null ; - @Before + @BeforeEach public void setUp() throws Exception { scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); @@ -101,7 +101,7 @@ public void setUp() throws Exception { this.network.addLink(link); } - @After + @AfterEach public void tearDown() throws Exception { this.population = null; this.network = null; diff --git a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleLinkSpeedCalculatorTest.java b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleLinkSpeedCalculatorTest.java index bb131f1005a..8d58af0313f 100644 --- a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleLinkSpeedCalculatorTest.java +++ b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/BicycleLinkSpeedCalculatorTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.bicycle; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -42,7 +42,7 @@ public class BicycleLinkSpeedCalculatorTest { private BicycleConfigGroup configGroup; private final Network unusedNetwork = NetworkUtils.createNetwork(); - @Before + @BeforeEach public void before() { configGroup = ConfigUtils.addOrGetModule( config, BicycleConfigGroup.class ); configGroup.setMaxBicycleSpeedForRouting(MAX_BICYCLE_SPEED); diff --git a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/IsTheRightCustomerScoredTest.java b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/IsTheRightCustomerScoredTest.java index 8e083962c5d..813601153ce 100644 --- a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/IsTheRightCustomerScoredTest.java +++ b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/IsTheRightCustomerScoredTest.java @@ -18,7 +18,7 @@ package org.matsim.contrib.commercialTrafficApplications.jointDemand; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; @@ -41,7 +41,7 @@ public class IsTheRightCustomerScoredTest { Scenario scenario; - @Before + @BeforeEach public void setUp() { Config config = ConfigUtils.loadConfig("./scenarios/grid/jointDemand_config.xml"); diff --git a/contribs/common/src/test/java/org/matsim/contrib/common/util/WeightedRandomSelectionTest.java b/contribs/common/src/test/java/org/matsim/contrib/common/util/WeightedRandomSelectionTest.java index fb30100ab83..2c33545ebe5 100644 --- a/contribs/common/src/test/java/org/matsim/contrib/common/util/WeightedRandomSelectionTest.java +++ b/contribs/common/src/test/java/org/matsim/contrib/common/util/WeightedRandomSelectionTest.java @@ -26,7 +26,7 @@ import java.util.Random; import org.apache.commons.lang3.mutable.MutableDouble; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; /** @@ -37,7 +37,7 @@ public class WeightedRandomSelectionTest { private final MutableDouble randomDouble = new MutableDouble(); private WeightedRandomSelection weightedRandomSelection; - @Before + @BeforeEach public void init() { weightedRandomSelection = new WeightedRandomSelection<>(new Random() { @Override diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModaFixedDrtLegEstimatorTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModaFixedDrtLegEstimatorTest.java index cb93757590c..5d4a8a1d5b6 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModaFixedDrtLegEstimatorTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModaFixedDrtLegEstimatorTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.drt.extension.estimator; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.application.MATSimApplication; @@ -67,7 +67,7 @@ private static void prepare(Config config) { } - @Before + @BeforeEach public void setUp() throws Exception { Config config = DrtTestScenario.loadConfig(utils); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModalDrtLegEstimatorTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModalDrtLegEstimatorTest.java index 4f57b22744e..90601b72b29 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModalDrtLegEstimatorTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/estimator/MultiModalDrtLegEstimatorTest.java @@ -1,6 +1,6 @@ package org.matsim.contrib.drt.extension.estimator; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.application.MATSimApplication; @@ -31,7 +31,7 @@ public class MultiModalDrtLegEstimatorTest { private Controler controler; - @Before + @BeforeEach public void setUp() throws Exception { Config config = DrtTestScenario.loadConfig(utils); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/MultiInsertionDetourPathCalculatorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/MultiInsertionDetourPathCalculatorTest.java index 9c604cb7acd..b11903b01df 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/MultiInsertionDetourPathCalculatorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/extensive/MultiInsertionDetourPathCalculatorTest.java @@ -31,7 +31,7 @@ import java.util.List; import java.util.Map; -import org.junit.After; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -70,7 +70,7 @@ public class MultiInsertionDetourPathCalculatorTest { private final MultiInsertionDetourPathCalculator detourPathCalculator = new MultiInsertionDetourPathCalculator( pathSearch, pathSearch, pathSearch, pathSearch, 1); - @After + @AfterEach public void after() { detourPathCalculator.notifyMobsimBeforeCleanup(null); } diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/selective/SingleInsertionDetourPathCalculatorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/selective/SingleInsertionDetourPathCalculatorTest.java index 62a8f56f9e6..19897df2149 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/selective/SingleInsertionDetourPathCalculatorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/selective/SingleInsertionDetourPathCalculatorTest.java @@ -30,7 +30,7 @@ import java.util.List; -import org.junit.After; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -74,7 +74,7 @@ public class SingleInsertionDetourPathCalculatorTest { private final SingleInsertionDetourPathCalculator detourPathCalculator = new SingleInsertionDetourPathCalculator( null, new FreeSpeedTravelTime(), null, 1, (network, travelCosts, travelTimes) -> pathCalculator); - @After + @AfterEach public void after() { detourPathCalculator.notifyMobsimBeforeCleanup(null); } diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/path/OneToManyPathCalculatorTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/path/OneToManyPathCalculatorTest.java index 8730f17dcb9..2db1640cdf5 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/path/OneToManyPathCalculatorTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/path/OneToManyPathCalculatorTest.java @@ -26,7 +26,7 @@ import java.util.List; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -68,7 +68,7 @@ public class OneToManyPathCalculatorTest { private final LeastCostPathTree dijkstraTree = new LeastCostPathTree(new SpeedyGraph(network), travelTime, new TimeAsTravelDisutility(travelTime)); - @Before + @BeforeEach public void init() { for (Node node : List.of(nodeA, nodeB, nodeC, nodeD, nodeE)) { nodeMap.put(node.getId(), node); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleTrafficSituations.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleTrafficSituations.java index c275756af07..6f555874356 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleTrafficSituations.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleTrafficSituations.java @@ -19,7 +19,7 @@ * *********************************************************************** */ import org.junit.Assert; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -44,7 +44,7 @@ /** * @author joe - + /* * test for playground.vsp.emissions.WarmEmissionAnalysisModule @@ -96,7 +96,7 @@ public static Collection createCombinations() { return list; } - @Before + @BeforeEach public void setUp() { Map avgHbefaWarmTable = new HashMap<>(); Map detailedHbefaWarmTable = new HashMap<>(); @@ -257,7 +257,7 @@ private void fillDetailedTable( Map avgHbefaWarmTable) { @@ -282,7 +282,7 @@ private void fillAverageTable( Map vehicleTypeId = Id.create( "medium", VehicleType.class ); VehicleType mediumType = VehicleUtils.getFactory().createVehicleType( vehicleTypeId ); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java index 507326c6e2b..acfb8eab226 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java @@ -21,7 +21,7 @@ package org.matsim.freight.carriers.controler; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -60,7 +60,7 @@ static Config commonConfig( MatsimTestUtils testUtils ) { return config; } - @Before + @BeforeEach public void setUp(){ Config config = commonConfig( testUtils ); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java index d9aeaf17ef7..07ea6e5ac60 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java @@ -29,7 +29,7 @@ import com.graphhopper.jsprit.core.util.Solutions; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -64,7 +64,7 @@ public class FixedCostsTest { private final Carriers carriers = new Carriers(); private final Carriers carriersPlannedAndRouted = new Carriers(); - @Before + @BeforeEach public void setUp() throws Exception { // Create carrier with services; service1 nearby the depot, service2 at the opposite side of the network CarrierService service1 = createMatsimService("Service1", "i(3,0)", 1); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsIT.java index 3cdf13513c1..a50b4c5430d 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsIT.java @@ -26,7 +26,7 @@ import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution; import com.graphhopper.jsprit.core.util.Solutions; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -67,7 +67,7 @@ public class CarrierControlerUtilsIT { @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); - @Before + @BeforeEach public void setUp() { //Create carrier with services and shipments diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java index 55d1c268c7a..678b2727ff1 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControlerUtilsTest.java @@ -30,7 +30,7 @@ import com.graphhopper.jsprit.core.util.Solutions; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -79,7 +79,7 @@ public class CarrierControlerUtilsTest { @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); - @Before + @BeforeEach public void setUp() { //Create carrier with services and shipments diff --git a/contribs/hybridsim/src/test/java/org/matsim/contrib/hybridsim/utils/IdIntMapperTest.java b/contribs/hybridsim/src/test/java/org/matsim/contrib/hybridsim/utils/IdIntMapperTest.java index fad773395d3..7f2c5802c1a 100644 --- a/contribs/hybridsim/src/test/java/org/matsim/contrib/hybridsim/utils/IdIntMapperTest.java +++ b/contribs/hybridsim/src/test/java/org/matsim/contrib/hybridsim/utils/IdIntMapperTest.java @@ -13,8 +13,8 @@ // /****************************************************************************/ -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -33,12 +33,12 @@ public class IdIntMapperTest { private IdIntMapper mapper; - @Before + @BeforeEach public void setup() { this.mapper = new IdIntMapper(); } - @After + @AfterEach public void tearDown() { this.mapper = null; } diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/EstimateRouterTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/EstimateRouterTest.java index fae4abb3ab1..b91a3b8ea45 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/EstimateRouterTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/EstimateRouterTest.java @@ -1,7 +1,7 @@ package org.matsim.modechoice; import com.google.inject.Injector; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -27,7 +27,7 @@ public class EstimateRouterTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Before + @BeforeEach public void setUp() throws Exception { Config config = TestScenario.loadConfig(utils); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ScenarioTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ScenarioTest.java index 2042b6c03a0..4d5ea25153e 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ScenarioTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ScenarioTest.java @@ -1,7 +1,7 @@ package org.matsim.modechoice; import com.google.inject.Injector; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.application.MATSimApplication; import org.matsim.core.config.Config; @@ -18,7 +18,7 @@ public class ScenarioTest { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); - @Before + @BeforeEach public void setUp() throws Exception { Config config = TestScenario.loadConfig(utils); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedMassConservationConstraintTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedMassConservationConstraintTest.java index abd2614acbb..5e060d2be5d 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedMassConservationConstraintTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedMassConservationConstraintTest.java @@ -1,6 +1,6 @@ package org.matsim.modechoice.constraints; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -18,7 +18,7 @@ public class RelaxedMassConservationConstraintTest { private RelaxedMassConservationConstraint constraint; - @Before + @BeforeEach public void setUp() throws Exception { SubtourModeChoiceConfigGroup config = new SubtourModeChoiceConfigGroup(); @@ -135,4 +135,4 @@ void openEnd() { // TODO: test 5th agent from list -} \ No newline at end of file +} diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedSubtourConstraintTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedSubtourConstraintTest.java index 3be3bbb887a..7f58c6e14c1 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedSubtourConstraintTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/constraints/RelaxedSubtourConstraintTest.java @@ -1,6 +1,6 @@ package org.matsim.modechoice.constraints; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -22,7 +22,7 @@ public class RelaxedSubtourConstraintTest { private RelaxedSubtourConstraint constraint; - @Before + @BeforeEach public void setUp() throws Exception { SubtourModeChoiceConfigGroup config = new SubtourModeChoiceConfigGroup(); @@ -133,4 +133,4 @@ void openEnd() { } -} \ No newline at end of file +} diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/MultinomialLogitSelectorTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/MultinomialLogitSelectorTest.java index 44658a957bb..851404656f9 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/MultinomialLogitSelectorTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/MultinomialLogitSelectorTest.java @@ -1,7 +1,7 @@ package org.matsim.modechoice.replanning; import org.assertj.core.data.Offset; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.matsim.modechoice.PlanCandidate; @@ -16,7 +16,7 @@ public class MultinomialLogitSelectorTest { private static final int N = 500_000; - @Before + @BeforeEach public void setUp() throws Exception { selector = new MultinomialLogitSelector(1, new Random(0)); } diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java index a32fc12df0c..f307a5b77c3 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java @@ -5,7 +5,7 @@ import com.google.inject.multibindings.Multibinder; import org.assertj.core.api.InstanceOfAssertFactories; import org.assertj.core.data.Offset; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.runner.RunWith; @@ -62,7 +62,7 @@ public class TopKMinMaxTest { @Mock private EventsManager em; - @Before + @BeforeEach public void setUp() throws Exception { TestModule testModule = new TestModule(); diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/SamplerTest.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/SamplerTest.java index df26aac50ab..c54db135674 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/SamplerTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/SamplerTest.java @@ -24,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -44,7 +44,7 @@ public class SamplerTest { private DestinationChoiceContext context; private Scenario scenario; - @Before + @BeforeEach public void setUp() throws Exception { Config config = ConfigUtils.loadConfig("test/scenarios/chessboard/config.xml", new FrozenTastesConfigGroup() ); ConfigUtils.loadConfig(config, utils.getPackageInputDirectory() + "/config.xml"); diff --git a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java index f1cfe36973c..35bb1f4dbd3 100644 --- a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java +++ b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -76,7 +76,7 @@ public class PtMatrixTest { @TempDir public File folder; - @Before + @BeforeEach public void setUp() throws Exception { OutputDirectoryLogging.catchLogEntries(); // (collect log messages internally before they can be written to file. Can be called multiple times without harm.) diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/genericUtils/TerminusStopFinderTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/genericUtils/TerminusStopFinderTest.java index 0809f0e6bf3..455a61840a9 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/genericUtils/TerminusStopFinderTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/genericUtils/TerminusStopFinderTest.java @@ -30,23 +30,23 @@ import org.matsim.pt.transitSchedule.api.TransitScheduleFactory; import org.matsim.pt.transitSchedule.api.TransitStopFacility; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; /** - * + * * @author gleich * */ public class TerminusStopFinderTest { - + TransitSchedule schedule; TransitScheduleFactory stopFactory; @Test void testFindSecondTerminusStop() { - /* + /* * straight line - * + * * /----------------------\ * X------->--------------{>} */ @@ -54,13 +54,13 @@ void testFindSecondTerminusStop() { stops.add(getOrCreateStopAtCoord(0, 0)); stops.add(getOrCreateStopAtCoord(10, 0)); stops.add(getOrCreateStopAtCoord(40, 0)); - + int indexSecondTerminusStop = TerminusStopFinder.findSecondTerminusStop(stops); Assertions.assertEquals(2, indexSecondTerminusStop); - - /* + + /* * rectangular line - * + * * <------{^} * | | * | | @@ -72,13 +72,13 @@ void testFindSecondTerminusStop() { stops.add(getOrCreateStopAtCoord(10, 0)); stops.add(getOrCreateStopAtCoord(10, 10)); stops.add(getOrCreateStopAtCoord(0, 10)); - + indexSecondTerminusStop = TerminusStopFinder.findSecondTerminusStop(stops); Assertions.assertEquals(2, indexSecondTerminusStop); - - /* + + /* * triangular line both candidate stops at same distance from first terminus - * + * * <---\ * | \ * | \ @@ -92,10 +92,10 @@ void testFindSecondTerminusStop() { indexSecondTerminusStop = TerminusStopFinder.findSecondTerminusStop(stops); Assertions.assertEquals(1, indexSecondTerminusStop); - - /* + + /* * triangular line many stops - * + * * <-\ * | \ * | \--{<}----\ @@ -110,16 +110,16 @@ void testFindSecondTerminusStop() { stops.add(getOrCreateStopAtCoord(40, 0)); stops.add(getOrCreateStopAtCoord(20, 10)); stops.add(getOrCreateStopAtCoord(0, 20)); - + indexSecondTerminusStop = TerminusStopFinder.findSecondTerminusStop(stops); Assertions.assertEquals(5, indexSecondTerminusStop); - - /* + + /* * TODO: Currently failing, would require a more elaborate algorithm to determine the terminus stop * More complex example: - * + * * Back- and forth directions have different lengths. For the human eye the second terminus is obvious - * + * * {<}------<---<---<---^ * \------>---> | * | ^ @@ -151,17 +151,17 @@ void testFindSecondTerminusStop() { stops.add(getOrCreateStopAtCoord(30, 10)); stops.add(getOrCreateStopAtCoord(20, 10)); stops.add(getOrCreateStopAtCoord(10, 10)); - + indexSecondTerminusStop = TerminusStopFinder.findSecondTerminusStop(stops); // Assert.assertEquals(11, indexSecondTerminusStop); } - - @Before + + @BeforeEach public void setUp() { schedule = ScenarioUtils.loadScenario(ConfigUtils.createConfig()).getTransitSchedule(); stopFactory = schedule.getFactory(); } - + private TransitStopFacility getOrCreateStopAtCoord(int x, int y) { Id stopId = getStopId(x, y); if (schedule.getFacilities().containsKey(stopId)) { @@ -171,7 +171,7 @@ private TransitStopFacility getOrCreateStopAtCoord(int x, int y) { stopId, CoordUtils.createCoord(x, y), false); } } - + private Id getStopId(int x, int y) { return Id.create(x + "," + y, TransitStopFacility.class); } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/AreaBtwLinksVsTerminiBeelinePenaltyTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/AreaBtwLinksVsTerminiBeelinePenaltyTest.java index c4a80910840..e09e1424dfd 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/AreaBtwLinksVsTerminiBeelinePenaltyTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/AreaBtwLinksVsTerminiBeelinePenaltyTest.java @@ -22,7 +22,7 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; @@ -47,18 +47,18 @@ import org.matsim.pt.transitSchedule.api.TransitStopFacility; /** - * + * * Tests {@link AreaBtwLinksVsTerminiBeelinePenalty}. - * + * * @author gleich - * + * */ public class AreaBtwLinksVsTerminiBeelinePenaltyTest { - + Scenario scenario; TransitScheduleFactory factory; - - @Before + + @BeforeEach public void setUp() { scenario = ScenarioUtils.loadScenario(ConfigUtils.createConfig()); factory = scenario.getTransitSchedule().getFactory(); @@ -68,14 +68,14 @@ public void setUp() { void testRectangularLine() { ArrayList stopsToBeServed = new ArrayList<>(); ArrayList stops = new ArrayList<>(); - + stopsToBeServed.add(getOrCreateStopAtCoord(0, 0)); stopsToBeServed.add(getOrCreateStopAtCoord(10, 0)); - + stops.add(factory.createTransitRouteStop(getOrCreateStopAtCoord(0, 0), 0, 0)); stops.add(factory.createTransitRouteStop(getOrCreateStopAtCoord(10, 0), 0, 0)); stops.add(factory.createTransitRouteStop(getOrCreateStopAtCoord(10, 10), 0, 0)); - + // Nodes a-d are passed by TransitRoute, Node e not Id idNodeA = Id.createNodeId("a"); Id idNodeB = Id.createNodeId("b"); @@ -87,7 +87,7 @@ void testRectangularLine() { NetworkUtils.createAndAddNode(scenario.getNetwork(), idNodeC, CoordUtils.createCoord(10, 10)); NetworkUtils.createAndAddNode(scenario.getNetwork(), idNodeD, CoordUtils.createCoord(0, 10)); NetworkUtils.createAndAddNode(scenario.getNetwork(), idNodeE, CoordUtils.createCoord(5, 5)); - + Id idLinkAB = Id.createLinkId("a>b"); Id idLinkBC = Id.createLinkId("b>c"); Id idLinkCD = Id.createLinkId("c>d"); @@ -112,14 +112,14 @@ void testRectangularLine() { linkIds.add(idLinkBC); linkIds.add(idLinkCD); route.setLinkIds(idLinkAB, linkIds, idLinkDA); - + PPlan pPlan1 = new PPlan(Id.create("PPlan1", PPlan.class), "creator1", Id.create("PPlanParent1", PPlan.class)); pPlan1.setStopsToBeServed(stopsToBeServed); TransitLine line1 = factory.createTransitLine(Id.create("line1", TransitLine.class)); TransitRoute route1 = factory.createTransitRoute(Id.create("TransitRoute1", TransitRoute.class), route, stops, "bus"); line1.addRoute(route1); pPlan1.setLine(line1); - + /* option StopListToEvaluate.transitRouteAllStops */ PConfigGroup pConfig = new PConfigGroup(); RouteDesignScoreParams params = new RouteDesignScoreParams(); @@ -128,14 +128,14 @@ void testRectangularLine() { params.setStopListToEvaluate(StopListToEvaluate.transitRouteAllStops); params.setValueToStartScoring(1); pConfig.addRouteDesignScoreParams(params); - + AreaBtwLinksVsTerminiBeelinePenalty penalty = new AreaBtwLinksVsTerminiBeelinePenalty(params, scenario.getNetwork()); double actual = penalty.getScore(pPlan1, route1); // area 10 x 10 = 100; beeline termini ({0,0}, {10,0}) = 10 double expected = -1 * ((10.0 * 10.0 / 10.0) - 1); Assertions.assertEquals(expected, actual, 0.001); } - + private TransitStopFacility getOrCreateStopAtCoord(int x, int y) { Id stopId = getStopId(x, y); if (scenario.getTransitSchedule().getFacilities().containsKey(stopId)) { @@ -145,7 +145,7 @@ private TransitStopFacility getOrCreateStopAtCoord(int x, int y) { stopId, CoordUtils.createCoord(x, y), false); } } - + private Id getStopId(int x, int y) { return Id.create(x + "," + y, TransitStopFacility.class); } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/RouteDesignScoringManagerTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/RouteDesignScoringManagerTest.java index bd2ee9230a3..375d9d814d0 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/RouteDesignScoringManagerTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/RouteDesignScoringManagerTest.java @@ -22,7 +22,7 @@ import java.util.ArrayList; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; @@ -44,23 +44,23 @@ import org.matsim.pt.transitSchedule.api.TransitStopFacility; /** - * + * * Tests {@link RouteDesignScoringManager}, * {@link AreaBtwStopsVsTerminiBeelinePenalty}, * {@link Stop2StopVsTerminiBeelinePenalty}. - * + * * The latter two are tested here, because they are also used as two example * RouteDesignScoringFunctions managed by RouteDesignScoringManager. - * + * * @author gleich - * + * */ public class RouteDesignScoringManagerTest { - + Scenario scenario; TransitScheduleFactory factory; - - @Before + + @BeforeEach public void setUp() { scenario = ScenarioUtils.loadScenario(ConfigUtils.createConfig()); factory = scenario.getTransitSchedule().getFactory(); @@ -70,28 +70,28 @@ public void setUp() { void testRectangularLine() { ArrayList stopsToBeServed = new ArrayList<>(); ArrayList stops = new ArrayList<>(); - + stopsToBeServed.add(getOrCreateStopAtCoord(0, 0)); stopsToBeServed.add(getOrCreateStopAtCoord(10, 0)); stopsToBeServed.add(getOrCreateStopAtCoord(10, 10)); stopsToBeServed.add(getOrCreateStopAtCoord(0, 10)); - + stops.add(factory.createTransitRouteStop(getOrCreateStopAtCoord(0, 0), 0, 0)); stops.add(factory.createTransitRouteStop(getOrCreateStopAtCoord(10, 0), 0, 0)); stops.add(factory.createTransitRouteStop(getOrCreateStopAtCoord(10, 10), 0, 0)); stops.add(factory.createTransitRouteStop(getOrCreateStopAtCoord(0, 10), 0, 0)); stops.add(factory.createTransitRouteStop(getOrCreateStopAtCoord(-10, 10), 0, 0)); stops.add(factory.createTransitRouteStop(getOrCreateStopAtCoord(-10, 0), 0, 0)); - + NetworkRoute route = RouteUtils.createLinkNetworkRouteImpl(Id.createLinkId("dummy1.1"), Id.createLinkId("dummy1.2")); - + PPlan pPlan1 = new PPlan(Id.create("PPlan1", PPlan.class), "creator1", Id.create("PPlanParent1", PPlan.class)); pPlan1.setStopsToBeServed(stopsToBeServed); TransitLine line1 = factory.createTransitLine(Id.create("line1", TransitLine.class)); TransitRoute route1 = factory.createTransitRoute(Id.create("TransitRoute1", TransitRoute.class), route, stops, "bus"); line1.addRoute(route1); pPlan1.setLine(line1); - + /* stop2StopVsBeelinePenalty */ /* option StopListToEvaluate.transitRouteAllStops */ PConfigGroup pConfig = new PConfigGroup(); @@ -101,26 +101,26 @@ void testRectangularLine() { stop2stopVsBeeline.setStopListToEvaluate(StopListToEvaluate.transitRouteAllStops); stop2stopVsBeeline.setValueToStartScoring(1); pConfig.addRouteDesignScoreParams(stop2stopVsBeeline); - + RouteDesignScoringManager manager1 = new RouteDesignScoringManager(); manager1.init(pConfig, scenario.getNetwork()); double actual = manager1.scoreRouteDesign(pPlan1); // 6 stop->stop distances of 10 units each in the stops (not stopsToBeServed) double expected = -1 * ((6 * 10 / (10 * Math.sqrt(2))) - 1); Assertions.assertEquals(expected, actual, 0.001); - + /* option StopListToEvaluate.pPlanStopsToBeServed */ stop2stopVsBeeline.setStopListToEvaluate(StopListToEvaluate.pPlanStopsToBeServed); - + manager1 = new RouteDesignScoringManager(); manager1.init(pConfig, scenario.getNetwork()); actual = manager1.scoreRouteDesign(pPlan1); // 4 stop->stop distances of 10 units each in the stops expected = -1 * ((4 * 10 / (10 * Math.sqrt(2))) - 1); Assertions.assertEquals(expected, actual, 0.001); - + pConfig.removeRouteDesignScoreParams(RouteDesignScoreFunctionName.stop2StopVsBeelinePenalty); - + /* areaVsBeelinePenalty */ /* option StopListToEvaluate.transitRouteAllStops */ RouteDesignScoreParams areaVsBeeline = new RouteDesignScoreParams(); @@ -129,77 +129,77 @@ void testRectangularLine() { areaVsBeeline.setStopListToEvaluate(StopListToEvaluate.transitRouteAllStops); areaVsBeeline.setValueToStartScoring(1); pConfig.addRouteDesignScoreParams(areaVsBeeline); - + manager1 = new RouteDesignScoringManager(); manager1.init(pConfig, scenario.getNetwork()); actual = manager1.scoreRouteDesign(pPlan1); // x=[-10,10], y=[0,10] -> 20 X 10 expected = -1 * ((20 * 10 / (10 * Math.sqrt(2))) - 1); Assertions.assertEquals(expected, actual, 0.001); - + /* option StopListToEvaluate.pPlanStopsToBeServed */ areaVsBeeline.setStopListToEvaluate(StopListToEvaluate.pPlanStopsToBeServed); - + manager1 = new RouteDesignScoringManager(); manager1.init(pConfig, scenario.getNetwork()); actual = manager1.scoreRouteDesign(pPlan1); // x=[0,10], y=[0,10] -> 10 X 10 expected = -1 * ((10 * 10 / (10 * Math.sqrt(2))) - 1); Assertions.assertEquals(expected, actual, 0.001); - + /* check summing up of both */ pConfig.addRouteDesignScoreParams(stop2stopVsBeeline); - + manager1 = new RouteDesignScoringManager(); manager1.init(pConfig, scenario.getNetwork()); actual = manager1.scoreRouteDesign(pPlan1); // x=[0,10], y=[0,10] -> 10 X 10 ; 4 stop->stop distances of 10 units each in the stops expected = -1 * ((10 * 10 / (10 * Math.sqrt(2))) - 1) + (-1) * ((4 * 10 / (10 * Math.sqrt(2))) - 1); Assertions.assertEquals(expected, actual, 0.001); - + /* Check route with only two stops */ stopsToBeServed = new ArrayList<>(); stops = new ArrayList<>(); - + stopsToBeServed.add(getOrCreateStopAtCoord(0, 0)); stopsToBeServed.add(getOrCreateStopAtCoord(10, 0)); - + stops.add(factory.createTransitRouteStop(getOrCreateStopAtCoord(0, 0), 0, 0)); stops.add(factory.createTransitRouteStop(getOrCreateStopAtCoord(10, 0), 0, 0)); - + route = RouteUtils.createLinkNetworkRouteImpl(Id.createLinkId("dummy2.1"), Id.createLinkId("dummy2.2")); - + PPlan pPlan2 = new PPlan(Id.create("PPlan2", PPlan.class), "creator2", Id.create("PPlanParent2", PPlan.class)); pPlan2.setStopsToBeServed(stopsToBeServed); TransitLine line2 = factory.createTransitLine(Id.create("line2", TransitLine.class)); TransitRoute route2 = factory.createTransitRoute(Id.create("TransitRoute2", TransitRoute.class), route, stops, "bus"); line2.addRoute(route2); pPlan2.setLine(line2); - + manager1 = new RouteDesignScoringManager(); manager1.init(pConfig, scenario.getNetwork()); actual = manager1.scoreRouteDesign(pPlan2); // would be positive expected = -1; Assertions.assertEquals(expected, actual, 0.001); - + /* check that no subsidy emerges (no positive route design score) */ // high valueToStartScoring -> all scores below would be positive, check that they are capped at 0 stop2stopVsBeeline.setValueToStartScoring(10); areaVsBeeline.setValueToStartScoring(10); - + // add a third stop stops.add(factory.createTransitRouteStop(getOrCreateStopAtCoord(5, 0), 0, 0)); - + route = RouteUtils.createLinkNetworkRouteImpl(Id.createLinkId("dummy2.1"), Id.createLinkId("dummy2.2")); - + PPlan pPlan3 = new PPlan(Id.create("PPlan3", PPlan.class), "creator3", Id.create("PPlanParent3", PPlan.class)); pPlan3.setStopsToBeServed(stopsToBeServed); TransitLine line3 = factory.createTransitLine(Id.create("line3", TransitLine.class)); TransitRoute route3 = factory.createTransitRoute(Id.create("TransitRoute3", TransitRoute.class), route, stops, "bus"); line3.addRoute(route3); pPlan3.setLine(line3); - + manager1 = new RouteDesignScoringManager(); manager1.init(pConfig, scenario.getNetwork()); actual = manager1.scoreRouteDesign(pPlan3); @@ -207,7 +207,7 @@ void testRectangularLine() { expected = 0; Assertions.assertEquals(expected, actual, 0.001); } - + private TransitStopFacility getOrCreateStopAtCoord(int x, int y) { Id stopId = getStopId(x, y); if (scenario.getTransitSchedule().getFacilities().containsKey(stopId)) { @@ -217,7 +217,7 @@ private TransitStopFacility getOrCreateStopAtCoord(int x, int y) { stopId, CoordUtils.createCoord(x, y), false); } } - + private Id getStopId(int x, int y) { return Id.create(x + "," + y, TransitStopFacility.class); } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/StopServedMultipleTimesPenaltyTest.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/StopServedMultipleTimesPenaltyTest.java index 1a5d848bfe1..9bcb9a50fe3 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/StopServedMultipleTimesPenaltyTest.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/scoring/routeDesignScoring/StopServedMultipleTimesPenaltyTest.java @@ -21,7 +21,7 @@ import java.util.ArrayList; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; @@ -43,18 +43,18 @@ import org.matsim.pt.transitSchedule.api.TransitStopFacility; /** - * + * * Tests {@link StopServedMultipleTimesPenalty} - * + * * @author gleich * */ public class StopServedMultipleTimesPenaltyTest { - + Scenario scenario; TransitScheduleFactory factory; - - @Before + + @BeforeEach public void setUp() { scenario = ScenarioUtils.loadScenario(ConfigUtils.createConfig()); factory = scenario.getTransitSchedule().getFactory(); @@ -64,24 +64,24 @@ public void setUp() { void testRouteServingSameStopTwice() { ArrayList stopsToBeServed = new ArrayList<>(); ArrayList stops = new ArrayList<>(); - + stopsToBeServed.add(getOrCreateStopAtCoord(0, 0)); stopsToBeServed.add(getOrCreateStopAtCoord(10, 0)); - + stops.add(factory.createTransitRouteStop(getOrCreateStopAtCoord(0, 0), 0, 0)); stops.add(factory.createTransitRouteStop(getOrCreateStopAtCoord(10, 0), 0, 0)); stops.add(factory.createTransitRouteStop(getOrCreateStopAtCoord(10, 10), 0, 0)); stops.add(factory.createTransitRouteStop(getOrCreateStopAtCoord(0, 0), 0, 0)); - + NetworkRoute route = RouteUtils.createLinkNetworkRouteImpl(Id.createLinkId("dummy1.1"), Id.createLinkId("dummy1.2")); - + PPlan pPlan1 = new PPlan(Id.create("PPlan1", PPlan.class), "creator1", Id.create("PPlanParent1", PPlan.class)); pPlan1.setStopsToBeServed(stopsToBeServed); TransitLine line1 = factory.createTransitLine(Id.create("line1", TransitLine.class)); TransitRoute route1 = factory.createTransitRoute(Id.create("TransitRoute1", TransitRoute.class), route, stops, "bus"); line1.addRoute(route1); pPlan1.setLine(line1); - + /* option StopListToEvaluate.transitRouteAllStops */ PConfigGroup pConfig = new PConfigGroup(); RouteDesignScoreParams params = new RouteDesignScoreParams(); @@ -90,14 +90,14 @@ void testRouteServingSameStopTwice() { params.setStopListToEvaluate(StopListToEvaluate.transitRouteAllStops); params.setValueToStartScoring(1); pConfig.addRouteDesignScoreParams(params); - + StopServedMultipleTimesPenalty penalty = new StopServedMultipleTimesPenalty(params); double actual = penalty.getScore(pPlan1, route1); // 4 stops served, but only 3 different stop ids double expected = -1 * ((4.0 / 3) - 1); Assertions.assertEquals(expected, actual, 0.001); } - + private TransitStopFacility getOrCreateStopAtCoord(int x, int y) { Id stopId = getStopId(x, y); if (scenario.getTransitSchedule().getFacilities().containsKey(stopId)) { @@ -107,7 +107,7 @@ private TransitStopFacility getOrCreateStopAtCoord(int x, int y) { stopId, CoordUtils.createCoord(x, y), false); } } - + private Id getStopId(int x, int y) { return Id.create(x + "," + y, TransitStopFacility.class); } diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmNetworkParserTest.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmNetworkParserTest.java index be16614ebf8..1f9324b51f6 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmNetworkParserTest.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmNetworkParserTest.java @@ -3,7 +3,7 @@ import de.topobyte.osm4j.core.model.iface.OsmNode; import de.topobyte.osm4j.core.model.iface.OsmWay; -import org.junit.After; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -28,7 +28,7 @@ public class OsmNetworkParserTest { @RegisterExtension private MatsimTestUtils matsimUtils = new MatsimTestUtils(); - @After + @AfterEach public void shutDownExecutor() { executor.shutdown(); } diff --git a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmSignalsParserTest.java b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmSignalsParserTest.java index 96a13bec584..2e150c78b6e 100644 --- a/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmSignalsParserTest.java +++ b/contribs/osm/src/test/java/org/matsim/contrib/osm/networkReader/OsmSignalsParserTest.java @@ -6,7 +6,7 @@ import de.topobyte.osm4j.core.model.impl.RelationMember; import de.topobyte.osm4j.core.model.impl.Tag; -import org.junit.After; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.utils.geometry.CoordinateTransformation; @@ -34,7 +34,7 @@ public class OsmSignalsParserTest { private MatsimTestUtils utils = new MatsimTestUtils(); - @After + @AfterEach public void shutDownExecutor() { executor.shutdown(); } diff --git a/contribs/pom.xml b/contribs/pom.xml index 49124a6bd25..e901a081789 100644 --- a/contribs/pom.xml +++ b/contribs/pom.xml @@ -103,10 +103,6 @@ - - org.junit.vintage - junit-vintage-engine - org.junit.jupiter junit-jupiter-engine diff --git a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimEngineTest.java b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimEngineTest.java index c2bb085c360..8b5aee8695e 100644 --- a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimEngineTest.java +++ b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimEngineTest.java @@ -23,7 +23,7 @@ import ch.sbb.matsim.contrib.railsim.config.RailsimConfigGroup; import ch.sbb.matsim.contrib.railsim.qsimengine.disposition.SimpleDisposition; import ch.sbb.matsim.contrib.railsim.qsimengine.router.TrainRouter; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.network.Link; @@ -45,7 +45,7 @@ public class RailsimEngineTest { private EventsManager eventsManager; private RailsimTestUtils.EventCollector collector; - @Before + @BeforeEach public void setUp() { eventsManager = EventsUtils.createEventsManager(); collector = new RailsimTestUtils.EventCollector(); diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java index 3484f72f2f3..cc89d2c14a6 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java @@ -24,7 +24,7 @@ import com.google.inject.Provides; import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -46,7 +46,7 @@ public class SBBQSimModuleTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Before + @BeforeEach public void setUp() { System.setProperty("matsim.preferLocalDtds", "true"); } diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyExamplesTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyExamplesTest.java index 7d03f3966ae..11ed885109b 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyExamplesTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyExamplesTest.java @@ -1,7 +1,7 @@ package org.matsim.simwrapper.viz; import com.fasterxml.jackson.databind.ObjectWriter; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -32,7 +32,7 @@ public class PlotlyExamplesTest { private ObjectWriter writer; - @Before + @BeforeEach public void setUp() throws Exception { writer = createWriter(); } diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyTest.java index 3956c9d505c..7642c997e8d 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/viz/PlotlyTest.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.assertj.core.api.Assertions; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.simwrapper.ComponentMixin; @@ -48,7 +48,7 @@ public static ObjectWriter createWriter() { return mapper.writerFor(Plotly.class); } - @Before + @BeforeEach public void setUp() throws Exception { writer = createWriter(); } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/GroupPlansTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/GroupPlansTest.java index bb64b0ae091..e524cbc56a1 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/GroupPlansTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/grouping/GroupPlansTest.java @@ -27,8 +27,8 @@ import java.util.List; import java.util.Map; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -48,7 +48,7 @@ public class GroupPlansTest { private final List testPlans = new ArrayList(); private final JointPlanFactory factory = new JointPlanFactory(); - @Before + @BeforeEach public void initPlanWithoutJointPlan() { final List plans = new ArrayList(); @@ -59,7 +59,7 @@ public void initPlanWithoutJointPlan() { testPlans.add( new GroupPlans( Collections.EMPTY_LIST , plans ) ); } - @Before + @BeforeEach public void initPlanWithoutIndividualPlans() { final List plans = new ArrayList(); @@ -78,7 +78,7 @@ public void initPlanWithoutIndividualPlans() { testPlans.add( new GroupPlans( plans , Collections.EMPTY_LIST ) ); } - @After + @AfterEach public void clear() { testPlans.clear(); } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/MergingTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/MergingTest.java index 51f2365c46f..390347380fc 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/MergingTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/modules/MergingTest.java @@ -26,10 +26,10 @@ import java.util.Map; import java.util.Random; -import org.junit.After; +import org.junit.jupiter.api.AfterEach; import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -49,13 +49,13 @@ public class MergingTest { // ///////////////////////////////////////////////////////////////////////// // fixtures management // ///////////////////////////////////////////////////////////////////////// - @After + @AfterEach public void clean() { testPlans.clear(); jointPlans = new JointPlans(); } - @Before + @BeforeEach public void allIndividuals() { List plans = new ArrayList(); @@ -66,7 +66,7 @@ public void allIndividuals() { testPlans.add( new GroupPlans( Collections.EMPTY_LIST , plans ) ); } - @Before + @BeforeEach public void allJoints() { List plans = new ArrayList(); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/HighestWeightSelectorTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/HighestWeightSelectorTest.java index 41316c90707..9962f22480c 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/HighestWeightSelectorTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/HighestWeightSelectorTest.java @@ -31,7 +31,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; @@ -1200,11 +1200,11 @@ public static Fixture createDifferentForbidGroupsPerJointPlan() { GroupPlans expected = new GroupPlans( Arrays.asList( jointPlan2 , jointPlan4 ), - Collections.emptyList()); + Collections.emptyList()); GroupPlans expectedForbidding = new GroupPlans( Arrays.asList( jointPlan2 , jointPlan3 ), - Collections.emptyList()); + Collections.emptyList()); return new Fixture( "different forbids in jointPlans", @@ -1224,7 +1224,7 @@ public IncompatiblePlansIdentifier createIdentifier( jointPlans); } - @Before + @BeforeEach public void setupLogging() { //Logger.getRootLogger().setLevel( Level.TRACE ); } @@ -1301,7 +1301,7 @@ private void testSelectedPlans( throw new RuntimeException( "exception thrown for instance <<"+fixture.name+">>", e ); } - final GroupPlans expected = + final GroupPlans expected = blocking ? fixture.expectedSelectedPlansWhenBlocking : (forbidding ? diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/RandomSelectorsTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/RandomSelectorsTest.java index deeb0b00ed6..4d55d689c81 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/RandomSelectorsTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/RandomSelectorsTest.java @@ -24,8 +24,8 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; @@ -55,13 +55,13 @@ public class RandomSelectorsTest { private final List testGroups = new ArrayList(); private JointPlans jointPlans = new JointPlans(); - @After + @AfterEach public void clear() { testGroups.clear(); jointPlans = new JointPlans(); } - @Before + @BeforeEach public void createIndividualPlans() { ReplanningGroup group = new ReplanningGroup(); testGroups.add( group ); @@ -99,7 +99,7 @@ public void createIndividualPlans() { plan.setScore( -5000d ); } - @Before + @BeforeEach public void createFullyJointPlans() { ReplanningGroup group = new ReplanningGroup(); testGroups.add( group ); @@ -172,7 +172,7 @@ public void createFullyJointPlans() { jointPlans.getFactory().createJointPlan( jp3 ) ); } - @Before + @BeforeEach public void createPartiallyJointPlansMessOfJointPlans() { ReplanningGroup group = new ReplanningGroup(); testGroups.add( group ); @@ -284,7 +284,7 @@ public void createPartiallyJointPlansMessOfJointPlans() { jointPlans.getFactory().createJointPlan( jp8 ) ); } - @Before + @BeforeEach public void createPartiallyJointPlans() { ReplanningGroup group = new ReplanningGroup(); testGroups.add( group ); @@ -338,7 +338,7 @@ public void createPartiallyJointPlans() { jointPlans.getFactory().createJointPlan( jp2 ) ); } - @Before + @BeforeEach public void createRandomFixtures() { final Random random = new Random( 42 ); for ( int i=0; i < 100; i++ ) { diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/whoisthebossselector/WhoIsTheBossSelectorTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/whoisthebossselector/WhoIsTheBossSelectorTest.java index 50823516b3e..518ba077207 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/whoisthebossselector/WhoIsTheBossSelectorTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/whoisthebossselector/WhoIsTheBossSelectorTest.java @@ -31,7 +31,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.Ignore; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/scoring/GroupCompositionPenalizerTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/scoring/GroupCompositionPenalizerTest.java index e341cb726ae..fc04d7684f0 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/scoring/GroupCompositionPenalizerTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/scoring/GroupCompositionPenalizerTest.java @@ -21,7 +21,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/JointTravelUtilsTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/JointTravelUtilsTest.java index 5d5f3ecea96..44377a842a6 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/JointTravelUtilsTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/JointTravelUtilsTest.java @@ -19,8 +19,8 @@ * *********************************************************************** */ package org.matsim.contrib.socnetsim.jointtrips; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; @@ -50,12 +50,12 @@ public class JointTravelUtilsTest { private final List fixtures = new ArrayList(); - @After + @AfterEach public void clearFixtures() { fixtures.clear(); } - @Before + @BeforeEach public void initOnePassengerFixture() { final Person driver = PopulationUtils.getFactory().createPerson(Id.createPersonId("Alain Prost")); final Person passenger1 = PopulationUtils.getFactory().createPerson(Id.createPersonId("Tintin")); @@ -115,7 +115,7 @@ public void initOnePassengerFixture() { new JointPlanFactory().createJointPlan( plans ))); } - @Before + @BeforeEach public void initTwoPassengerTwoOdFixture() { final Person driver = PopulationUtils.getFactory().createPerson(Id.create("Alain Prost", Person.class)); final Person passenger1 = PopulationUtils.getFactory().createPerson(Id.create("Tintin", Person.class)); @@ -206,7 +206,7 @@ public void initTwoPassengerTwoOdFixture() { new JointPlanFactory().createJointPlan( plans ))); } - @Before + @BeforeEach public void initTwoPassengersTwoOdsTwoJtFixture() { final Person driver = PopulationUtils.getFactory().createPerson(Id.createPersonId("Alain Prost")); final Person passenger1 = PopulationUtils.getFactory().createPerson(Id.createPersonId("Tintin")); @@ -327,7 +327,7 @@ public void initTwoPassengersTwoOdsTwoJtFixture() { new JointPlanFactory().createJointPlan( plans ))); } - @Before + @BeforeEach public void initTwoPassengersMiddleTripFixture() { final Person driver = PopulationUtils.getFactory().createPerson(Id.createPersonId("Alain Prost")); final Person passenger1 = PopulationUtils.getFactory().createPerson(Id.createPersonId("Tintin")); @@ -426,7 +426,7 @@ public void initTwoPassengersMiddleTripFixture() { new JointPlanFactory().createJointPlan( plans ))); } - @Before + @BeforeEach public void initOnePassengerTwoTripsFixture() { final Person driver = PopulationUtils.getFactory().createPerson(Id.createPersonId("Alain Prost")); final Person passenger1 = PopulationUtils.getFactory().createPerson(Id.createPersonId("Tintin")); @@ -515,7 +515,7 @@ public void initOnePassengerTwoTripsFixture() { new JointPlanFactory().createJointPlan( plans ))); } - @Before + @BeforeEach public void initOnePassengerTwoTripsWithDifferentDriversFixture() { final Person driver1 = PopulationUtils.getFactory().createPerson(Id.createPersonId("Alain Prost")); final Person driver2 = PopulationUtils.getFactory().createPerson(Id.createPersonId("Michel Vaillant")); @@ -611,7 +611,7 @@ public void initOnePassengerTwoTripsWithDifferentDriversFixture() { } // bugs may depend on iteration order... - @Before + @BeforeEach public void initOnePassengerTwoTripsWithDifferentDriversSecondDriverFirstFixture() { final Person driver1 = PopulationUtils.getFactory().createPerson(Id.createPersonId("Alain Prost")); final Person driver2 = PopulationUtils.getFactory().createPerson(Id.createPersonId("Michel Vaillant")); @@ -712,7 +712,7 @@ public void initOnePassengerTwoTripsWithDifferentDriversSecondDriverFirstFixture * the same way going to the bus station when no bus is running is a valid, though stupid, * plan. */ - @Before + @BeforeEach public void initOnePassengerTwoTripsInconsistentSequenceFixture() { final Person driver = PopulationUtils.getFactory().createPerson(Id.createPersonId("Alain Prost")); final Person passenger1 = PopulationUtils.getFactory().createPerson(Id.createPersonId("Tintin")); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIgnoranceBehaviorTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIgnoranceBehaviorTest.java index 83420c9ea39..7a0e431fbe3 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIgnoranceBehaviorTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIgnoranceBehaviorTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -57,7 +57,7 @@ public class InsertionRemovalIgnoranceBehaviorTest { private TripRouter tripRouter; private Random random; - @Before + @BeforeEach public void init() { config = JointScenarioUtils.createConfig(); // tripRouter = new TripRouter(); @@ -68,7 +68,7 @@ public void init() { @Test void testRemoverIgnorance() throws Exception { final JointTripRemoverAlgorithm algo = new JointTripRemoverAlgorithm( random , new MainModeIdentifierImpl() ); - + JointPlan jointPlan = createPlanWithJointTrips(); assertNull( @@ -85,7 +85,7 @@ void testInsertorIgnorance() throws Exception { null, (JointTripInsertorConfigGroup) config.getModule( JointTripInsertorConfigGroup.GROUP_NAME ), TripStructureUtils.getRoutingModeIdentifier() ); // yyyyyy ?????? - + JointPlan jointPlan = createPlanWithoutJointTrips(); assertNull( diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIterativeActionTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIterativeActionTest.java index bae28cc67cf..f8ad25b6757 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIterativeActionTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/InsertionRemovalIterativeActionTest.java @@ -28,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -62,7 +62,7 @@ public class InsertionRemovalIterativeActionTest { private TripRouter tripRouter; private Random random; - @Before + @BeforeEach public void init() { config = JointScenarioUtils.createConfig(); // tripRouter = new TripRouter(); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripRemoverAlgorithmTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripRemoverAlgorithmTest.java index 34cd73df76f..98d2dc63d83 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripRemoverAlgorithmTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/JointTripRemoverAlgorithmTest.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -65,7 +65,7 @@ public class JointTripRemoverAlgorithmTest { // ///////////////////////////////////////////////////////////////////////// // init routines // ///////////////////////////////////////////////////////////////////////// - @Before + @BeforeEach public void initFixtures() { fixtures = new ArrayList(); @@ -537,7 +537,7 @@ private Fixture createMultiDriverStageFixture() { expectedAfterRemoval.put( passenger.getId(), Arrays.asList( pAct1 , PopulationUtils.createLeg(TransportMode.pt) , pAct2 )); - + return new Fixture( "complex access trip driver", new JointPlanFactory().createJointPlan( plans ), @@ -608,7 +608,7 @@ private Fixture createMultiPassengerStageFixture() { expectedAfterRemoval.put( passenger.getId(), Arrays.asList( pAct1 , PopulationUtils.createLeg(TransportMode.pt) , pAct2 )); - + Set stageActivityTypes = new HashSet<>(); stageActivityTypes.add(stageType); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/SynchronizeCoTravelerPlansAlgorithmTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/SynchronizeCoTravelerPlansAlgorithmTest.java index d5f974964b5..6ef60d64652 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/SynchronizeCoTravelerPlansAlgorithmTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/replanning/modules/SynchronizeCoTravelerPlansAlgorithmTest.java @@ -24,8 +24,8 @@ import java.util.List; import java.util.Map; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; @@ -72,12 +72,12 @@ public Fixture( } } - @After + @AfterEach public void clear() { fixtures.clear(); } - @Before + @BeforeEach public void createSimpleFixture() { final FixtureBuilder builder = new FixtureBuilder(); @@ -170,7 +170,7 @@ public void createSimpleFixture() { fixtures.add( builder.build() ); } - @Before + @BeforeEach public void createFixtureWithPotentiallyNegativeEndTimes() { final FixtureBuilder builder = new FixtureBuilder(); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointTripRouterFactoryTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointTripRouterFactoryTest.java index d3e427f262c..993cfdb52bb 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointTripRouterFactoryTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/jointtrips/router/JointTripRouterFactoryTest.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -77,7 +77,7 @@ public class JointTripRouterFactoryTest { private Provider factory; private Scenario scenario; - @Before + @BeforeEach public void initFixtures() { this.scenario = createScenario(); this.factory = createFactory( scenario ); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/AllocateVehicleToPlansInGroupPlanAlgorithmTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/AllocateVehicleToPlansInGroupPlanAlgorithmTest.java index 5ba2aa6069a..f8be251b899 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/AllocateVehicleToPlansInGroupPlanAlgorithmTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/AllocateVehicleToPlansInGroupPlanAlgorithmTest.java @@ -62,7 +62,7 @@ public class AllocateVehicleToPlansInGroupPlanAlgorithmTest { private static final String MODE = "the_vehicular_mode"; // uncomment to get more information in case of failure - //@Before + //@BeforeEach //public void setupLog() { // LogManager.getLogger( AllocateVehicleToPlansInGroupPlanAlgorithm.class ).setLevel( Level.TRACE ); //} @@ -205,7 +205,7 @@ void testRandomness() { if ( v == null ) continue; final Id person = p.getPerson().getId(); final Id oldV = allocations.get( person ); - + if ( oldV == null ) { allocations.put( person , v ); } @@ -244,7 +244,7 @@ void testDeterminism() { if ( v == null ) continue; final Id person = p.getPerson().getId(); final Id oldV = allocations.get( person ); - + if ( oldV == null ) { allocations.put( person , v ); } @@ -269,7 +269,7 @@ private static Id assertSingleVehicleAndGetVehicleId(final Plan p) { if ( !MODE.equals( leg.getMode() ) ) continue; final NetworkRoute r = (NetworkRoute) leg.getRoute(); - + Assertions.assertNotNull( r.getVehicleId(), "null vehicle id in route" ); diff --git a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java index 57fcaa18660..3e089eaf6c9 100644 --- a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java +++ b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java @@ -19,7 +19,7 @@ package org.matsim.core.scoring.functions; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -55,7 +55,7 @@ public class PersonScoringParametersFromPersonAttributesNoSubpopulationTest { private PersonScoringParametersFromPersonAttributes personScoringParams; private Population population; - @Before + @BeforeEach public void setUp() { TransitConfigGroup transitConfigGroup = new TransitConfigGroup(); ScenarioConfigGroup scenarioConfigGroup = new ScenarioConfigGroup(); diff --git a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java index 69d5bb6835f..6202e3c83b5 100644 --- a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java +++ b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java @@ -19,7 +19,7 @@ package org.matsim.core.scoring.functions; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -55,7 +55,7 @@ public class PersonScoringParametersFromPersonAttributesTest { private PersonScoringParametersFromPersonAttributes personScoringParams; private Population population; - @Before + @BeforeEach public void setUp() { TransitConfigGroup transitConfigGroup = new TransitConfigGroup(); ScenarioConfigGroup scenarioConfigGroup = new ScenarioConfigGroup(); diff --git a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java index b64c9eca7a8..4b8c08a4d04 100644 --- a/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java +++ b/contribs/vsp/src/test/java/org/matsim/freight/carriers/analysis/RunFreightAnalysisIT.java @@ -21,7 +21,7 @@ package org.matsim.freight.carriers.analysis; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -44,7 +44,7 @@ public class RunFreightAnalysisIT { @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); - @Before + @BeforeEach public void runAnalysis(){ final String packageInputDirectory = testUtils.getClassInputDirectory(); final String outputDirectory = testUtils.getOutputDirectory(); diff --git a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java index 15bd18ad185..ce74cd04415 100644 --- a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java +++ b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java @@ -60,7 +60,7 @@ public class UrbanEVTests { private static UrbanEVTestHandler handler; private static Map, List> plannedActivitiesPerPerson; - @BeforeClass + @BeforeEachClass public static void run() { Scenario scenario = CreateUrbanEVTestScenario.createTestScenario(); scenario.getConfig().controller().setOutputDirectory("test/output/playground/vsp/ev/UrbanEVTests/"); diff --git a/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java b/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java index 2eeae6af2fe..4e11d41f780 100644 --- a/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java @@ -1,7 +1,7 @@ package playground.vsp.flowEfficiency; import com.google.inject.Provides; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -82,7 +82,7 @@ void testThatDrtAVMoveFaster(){ } - @Before + @BeforeEach public void simulate(){ URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("dvrp-grid"), "eight_shared_taxi_config.xml"); diff --git a/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java b/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java index d6d72219e1d..35500e7f900 100644 --- a/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/openberlinscenario/planmodification/PlanFileModifierTest.java @@ -2,7 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -32,7 +32,7 @@ public class PlanFileModifierTest { private Population modifiedPopulationCase1; private Population modifiedPopulationCase2; - @Before + @BeforeEach public void initializeTestPopulations() { String formatedInputPlansFile = utils.getClassInputDirectory() + "testPlansFormated.xml"; diff --git a/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java b/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java index 875a03eb3ae..7c3527d08b4 100644 --- a/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java @@ -4,7 +4,7 @@ import com.google.inject.Injector; import org.assertj.core.api.InstanceOfAssertFactories; import org.assertj.core.data.Offset; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -47,7 +47,7 @@ public class PtTripFareEstimatorTest { private Map> tripEstimator; private PtTripWithDistanceBasedFareEstimator estimator; - @Before + @BeforeEach public void setUp() throws Exception { Config config = TestScenario.loadConfig(utils); diff --git a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java index dc39db4c237..e5c151a010e 100644 --- a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java @@ -1,6 +1,6 @@ package playground.vsp.scoring; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -33,7 +33,7 @@ public class IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulation private IncomeDependentUtilityOfMoneyPersonScoringParameters personScoringParams; private Population population; - @Before + @BeforeEach public void setUp() { TransitConfigGroup transitConfigGroup = new TransitConfigGroup(); ScenarioConfigGroup scenarioConfigGroup = new ScenarioConfigGroup(); diff --git a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java index 35fa3d927ba..215d1c5816e 100644 --- a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java @@ -1,6 +1,6 @@ package playground.vsp.scoring; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -33,7 +33,7 @@ public class IncomeDependentUtilityOfMoneyPersonScoringParametersTest { private IncomeDependentUtilityOfMoneyPersonScoringParameters personScoringParams; private Population population; - @Before + @BeforeEach public void setUp() { TransitConfigGroup transitConfigGroup = new TransitConfigGroup(); ScenarioConfigGroup scenarioConfigGroup = new ScenarioConfigGroup(); diff --git a/matsim/pom.xml b/matsim/pom.xml index 5f88ffc874b..dcd4afd69c3 100644 --- a/matsim/pom.xml +++ b/matsim/pom.xml @@ -159,10 +159,6 @@ jfreechart 1.5.4 - - org.junit.vintage - junit-vintage-engine - org.junit.jupiter junit-jupiter-engine diff --git a/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java b/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java index b9b49e15c95..d206be9f32b 100644 --- a/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java @@ -25,7 +25,7 @@ import ch.sbb.matsim.config.SwissRailRaptorConfigGroup.RouteSelectorParameterSet; import ch.sbb.matsim.routing.pt.raptor.RaptorStopFinder.Direction; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; @@ -44,7 +44,7 @@ */ public class SwissRailRaptorConfigGroupTest { - @Before + @BeforeEach public void setup() { System.setProperty("matsim.preferLocalDtds", "true"); } diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtilsTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtilsTest.java index 6033cbdfdbd..5b6460c3b95 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtilsTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtilsTest.java @@ -20,7 +20,7 @@ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.core.config.Config; @@ -38,7 +38,7 @@ */ public class RaptorUtilsTest { - @Before + @BeforeEach public void setup() { System.setProperty("matsim.preferLocalDtds", "true"); } diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java index 5085ec806b2..102b9c0e9a6 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java @@ -23,7 +23,7 @@ import java.util.Arrays; import java.util.List; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -85,7 +85,7 @@ public class SwissRailRaptorModuleTest { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); - @Before + @BeforeEach public void setUp() { System.setProperty("matsim.preferLocalDtds", "true"); } diff --git a/matsim/src/test/java/org/matsim/analysis/CalcLegTimesTest.java b/matsim/src/test/java/org/matsim/analysis/CalcLegTimesTest.java index d2b5219d8b5..c6ac0a9324a 100644 --- a/matsim/src/test/java/org/matsim/analysis/CalcLegTimesTest.java +++ b/matsim/src/test/java/org/matsim/analysis/CalcLegTimesTest.java @@ -23,8 +23,8 @@ import java.io.BufferedReader; import java.io.IOException; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -67,7 +67,7 @@ public class CalcLegTimesTest { private Population population = null; private Network network = null; - @Before public void setUp() { + @BeforeEach public void setUp() { utils.loadConfig((String)null); MutableScenario s = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); @@ -97,7 +97,7 @@ public class CalcLegTimesTest { this.network.addLink(link); } - @After public void tearDown() { + @AfterEach public void tearDown() { this.population = null; this.network = null; } diff --git a/matsim/src/test/java/org/matsim/api/core/v01/DemandGenerationTest.java b/matsim/src/test/java/org/matsim/api/core/v01/DemandGenerationTest.java index 7c026b15ca4..885d7b721b6 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/DemandGenerationTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/DemandGenerationTest.java @@ -23,8 +23,8 @@ import java.io.File; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.network.Link; @@ -60,11 +60,11 @@ public class DemandGenerationTest { private int personCount = 6; private int linkCount = 6; - @Before public void setUp() { + @BeforeEach public void setUp() { this.sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); } - @After public void tearDown() { + @AfterEach public void tearDown() { this.sc = null; } diff --git a/matsim/src/test/java/org/matsim/api/core/v01/IdDeSerializationModuleTest.java b/matsim/src/test/java/org/matsim/api/core/v01/IdDeSerializationModuleTest.java index 04c48fcafe8..1dbf78b8f61 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/IdDeSerializationModuleTest.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/IdDeSerializationModuleTest.java @@ -3,7 +3,7 @@ import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.network.Link; @@ -20,7 +20,7 @@ public class IdDeSerializationModuleTest { private static final TypeFactory TYPE_FACTORY = TypeFactory.defaultInstance(); private final ObjectMapper objectMapper = new ObjectMapper(); - @Before + @BeforeEach public void init() { this.objectMapper.registerModule(IdDeSerializationModule.getInstance()); } diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java b/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java index e889fb576ea..33c4efd272e 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java @@ -26,8 +26,8 @@ import java.util.ArrayList; import java.util.List; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.config.Config; @@ -52,11 +52,11 @@ void addCalledStartupListenerNumber(int i) { this.calledStartupListener.add(i); } - @Before public void setUp() { + @BeforeEach public void setUp() { this.calledStartupListener = new ArrayList<>(3); } - @After public void tearDown() { + @AfterEach public void tearDown() { this.calledStartupListener = null; } diff --git a/matsim/src/test/java/org/matsim/core/events/ParallelEventsManagerTest.java b/matsim/src/test/java/org/matsim/core/events/ParallelEventsManagerTest.java index 24ce9763e4c..c77b7a72521 100644 --- a/matsim/src/test/java/org/matsim/core/events/ParallelEventsManagerTest.java +++ b/matsim/src/test/java/org/matsim/core/events/ParallelEventsManagerTest.java @@ -1,6 +1,6 @@ package org.matsim.core.events; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.events.Event; import org.matsim.core.api.experimental.events.EventsManager; @@ -14,7 +14,7 @@ public class ParallelEventsManagerTest { private EventsManagerImplTest.CountingMyEventHandler handler; - @Before + @BeforeEach public void setUp() throws Exception { handler = new EventsManagerImplTest.CountingMyEventHandler(); } @@ -49,4 +49,4 @@ void lateHandler() { assertEquals(0, handler.counter); } -} \ No newline at end of file +} diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/FlowCapacityTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/FlowCapacityTest.java index 60ca78d0d54..2a8a10cb7a4 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/FlowCapacityTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/FlowCapacityTest.java @@ -20,7 +20,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.analysis.VolumesAnalyzer; @@ -51,7 +51,7 @@ public class FlowCapacityTest { private final static Logger log = LogManager.getLogger(FlowCapacityTest.class); - @Before + @BeforeEach public void setup() { Id.resetCaches(); } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTest.java index 8d6dce636f6..09cb1763746 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTest.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -101,7 +101,7 @@ protected static Hermes createHermes(Scenario scenario, EventsManager events, bo return new HermesBuilder().build(scenario, events); } - @Before + @BeforeEach public void prepareTest() { // TODO - fix these two! Id.resetCaches(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTransitTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTransitTest.java index 4dfd0d0c319..69c49091a42 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTransitTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTransitTest.java @@ -1,6 +1,6 @@ package org.matsim.core.mobsim.hermes; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; @@ -103,7 +103,7 @@ protected static Hermes createHermes(Scenario scenario, EventsManager events, bo return new HermesBuilder().build(scenario, events); } - @Before + @BeforeEach public void prepareTest() { Id.resetCaches(); ScenarioImporter.flush(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/AbstractJDEQSimTest.java b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/AbstractJDEQSimTest.java index a9220f145a8..166dd6bca81 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/AbstractJDEQSimTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/jdeqsim/AbstractJDEQSimTest.java @@ -30,8 +30,8 @@ import java.util.Map; import java.util.Map.Entry; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -76,14 +76,14 @@ public abstract class AbstractJDEQSimTest { protected Map, List> eventsByPerson = null; public LinkedList allEvents = null; - @Before + @BeforeEach public final void setUp() throws Exception { this.eventsByPerson = new HashMap, List>(); this.vehicleToDriver = new HashMap<>(); this.allEvents = new LinkedList(); } - @After + @AfterEach public final void tearDown() throws Exception { this.eventsByPerson = null; this.vehicleToDriver = null; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/UmlaufDriverTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/UmlaufDriverTest.java index e73ea8ae49f..7b7def63c73 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/UmlaufDriverTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/pt/UmlaufDriverTest.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -80,7 +80,7 @@ public class UmlaufDriverTest { private static final Logger log = LogManager.getLogger(UmlaufDriverTest.class); - @Before public void setUp() { + @BeforeEach public void setUp() { utils.loadConfig((String)null); } diff --git a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierTest.java b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierTest.java index ae5d22abaf3..fc63a2e9b7d 100644 --- a/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierTest.java +++ b/matsim/src/test/java/org/matsim/core/network/algorithms/NetworkSimplifierTest.java @@ -25,7 +25,7 @@ import java.util.Map; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -38,7 +38,7 @@ public class NetworkSimplifierTest { - @Before + @BeforeEach public void setUp() { Id.resetCaches(); } @@ -66,19 +66,19 @@ void testRun() { @Test void testRunMergeLinkStats() { Network network = buildNetwork(); - + NetworkSimplifier nst = new NetworkSimplifier(); nst.setMergeLinkStats(true); nst.run(network, 20.0); assertEquals(2, network.getLinks().size(), "Wrong number of links"); assertNotNull(network.getLinks().get(Id.createLinkId("AB-BC")), "Expected link not found."); assertNotNull(network.getLinks().get(Id.createLinkId("CD-DE-EF")), "Expected link not found."); - + network = buildNetwork(); nst.run(network, 40.0); assertEquals(1, network.getLinks().size(), "Wrong number of links"); assertNotNull(network.getLinks().get(Id.createLinkId("AB-BC-CD-DE-EF")), "Expected link not found."); - + network = buildNetwork(); nst.run(network, 5.0); assertEquals(5, network.getLinks().size(), "Wrong number of links"); @@ -198,16 +198,16 @@ void testDifferentAttributesPerDirection() { Assertions.assertEquals(10.0, links.get(idHGGF).getFreespeed(), 1e-8); Assertions.assertEquals(10.0, links.get(idFEED).getFreespeed(), 1e-8); } - - + + /** * Builds a test network like the following diagram. - * + * * A--->B--->C===>D--->E--->F - * - * with each link having length 10m. Links AB, BC, DE, and EF have one + * + * with each link having length 10m. Links AB, BC, DE, and EF have one * lanes each, while CD has two lanes. All free-flow speeds are 60km/h. - * + * * @return */ private Network buildNetwork(){ @@ -218,13 +218,13 @@ private Network buildNetwork(){ Node d = NetworkUtils.createAndAddNode(network, Id.createNodeId("D"), CoordUtils.createCoord(30.0, 0.0)); Node e = NetworkUtils.createAndAddNode(network, Id.createNodeId("E"), CoordUtils.createCoord(40.0, 0.0)); Node f = NetworkUtils.createAndAddNode(network, Id.createNodeId("F"), CoordUtils.createCoord(50.0, 0.0)); - + NetworkUtils.createAndAddLink(network, Id.createLinkId("AB"), a, b, 10.0, 60.0/3.6, 1000.0, 1); NetworkUtils.createAndAddLink(network, Id.createLinkId("BC"), b, c, 10.0, 60.0/3.6, 1000.0, 1); NetworkUtils.createAndAddLink(network, Id.createLinkId("CD"), c, d, 10.0, 60.0/3.6, 1000.0, 2); NetworkUtils.createAndAddLink(network, Id.createLinkId("DE"), d, e, 10.0, 60.0/3.6, 1000.0, 1); NetworkUtils.createAndAddLink(network, Id.createLinkId("EF"), e, f, 10.0, 60.0/3.6, 1000.0, 1); - + return network; } diff --git a/matsim/src/test/java/org/matsim/core/network/filter/NetworkFilterManagerTest.java b/matsim/src/test/java/org/matsim/core/network/filter/NetworkFilterManagerTest.java index 16d9b4283cb..0a294ca7a01 100644 --- a/matsim/src/test/java/org/matsim/core/network/filter/NetworkFilterManagerTest.java +++ b/matsim/src/test/java/org/matsim/core/network/filter/NetworkFilterManagerTest.java @@ -21,7 +21,7 @@ package org.matsim.core.network.filter; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -54,7 +54,7 @@ public class NetworkFilterManagerTest { private Network filterNetwork; - @Before + @BeforeEach public void prepareTestAllowedModes() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network = scenario.getNetwork(); diff --git a/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java b/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java index fc56e540746..d16b44098a6 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java @@ -3,7 +3,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.util.List; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -158,7 +158,7 @@ private static String readResult(String filePath) throws IOException { return sb.toString(); } - @Before + @BeforeEach public void setup() { this.config = ConfigUtils.createConfig(); config.global().setDefaultDelimiter(";"); diff --git a/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java b/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java index 61f0dff7923..e9c44723123 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java @@ -22,7 +22,7 @@ package org.matsim.core.replanning.modules; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -48,7 +48,7 @@ public class ExternalModuleTest { private OutputDirectoryHierarchy outputDirectoryHierarchy; private Scenario originalScenario; - @Before + @BeforeEach public void setUp() { scenario = ScenarioUtils.loadScenario(utils.loadConfig("test/scenarios/equil/config.xml")); originalScenario = ScenarioUtils.loadScenario(utils.loadConfig("test/scenarios/equil/config.xml")); diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelectorTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelectorTest.java index 62ffb7eaaeb..37016e60ad4 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelectorTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelectorTest.java @@ -24,8 +24,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; @@ -44,11 +44,11 @@ public class ExpBetaPlanSelectorTest extends AbstractPlanSelectorTest { private final static Logger log = LogManager.getLogger(ExpBetaPlanSelectorTest.class); private Config config = null; - @Before public void setUp() { + @BeforeEach public void setUp() { this.config = utils.loadConfig((String)null); // required for planCalcScore.beta to be defined } - @After public void tearDown() { + @AfterEach public void tearDown() { this.config = null; } diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/PathSizeLogitSelectorTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/PathSizeLogitSelectorTest.java index 905a8f32cdb..0607540583f 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/PathSizeLogitSelectorTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/PathSizeLogitSelectorTest.java @@ -27,8 +27,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -58,14 +58,14 @@ public class PathSizeLogitSelectorTest extends AbstractPlanSelectorTest { private Network network = null; private Config config = null; - @Before public void setUp() { + @BeforeEach public void setUp() { this.config = utils.loadConfig((String)null); // required for planCalcScore.beta to be defined config.scoring().setBrainExpBeta(2.0); config.scoring().setPathSizeLogitBeta(2.0); this.network = null; } - @After public void tearDown() { + @AfterEach public void tearDown() { this.network = null; this.config = null; } diff --git a/matsim/src/test/java/org/matsim/core/router/TestActivityWrapperFacility.java b/matsim/src/test/java/org/matsim/core/router/TestActivityWrapperFacility.java index 0b924a0c516..d0c234ad0dd 100644 --- a/matsim/src/test/java/org/matsim/core/router/TestActivityWrapperFacility.java +++ b/matsim/src/test/java/org/matsim/core/router/TestActivityWrapperFacility.java @@ -22,7 +22,7 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -39,7 +39,7 @@ public class TestActivityWrapperFacility { private List activities; - @Before + @BeforeEach public void init() { activities = new ArrayList(); diff --git a/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsTest.java b/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsTest.java index 2f28185b50f..6cf9f409b72 100644 --- a/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsTest.java @@ -25,8 +25,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -77,12 +77,12 @@ public Fixture( } } - @After + @AfterEach public void clean() { fixtures.clear(); } - @Before + @BeforeEach public void createSimpleFixture() { final Plan plan = populationFactory.createPlan(); @@ -146,7 +146,7 @@ public void createSimpleFixture() { nTrips)); } - @Before + @BeforeEach public void createFixtureWithComplexTrips() { final Plan plan = populationFactory.createPlan(); @@ -241,7 +241,7 @@ public void createFixtureWithComplexTrips() { } - @Before + @BeforeEach public void createFixtureWithSuccessiveActivities() { final Plan plan = populationFactory.createPlan(); @@ -330,7 +330,7 @@ public void createFixtureWithSuccessiveActivities() { nTrips)); } - @Before + @BeforeEach public void createFixtureWithAccessEgress() { final Plan plan = populationFactory.createPlan() ; @@ -383,7 +383,7 @@ void testActivities() throws Exception { for (Fixture fixture : fixtures) { final List acts = TripStructureUtils.getActivities( - fixture.plan, + fixture.plan, StageActivityHandling.ExcludeStageActivities); assertEquals( diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelOpenTimesScoringFunctionTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelOpenTimesScoringFunctionTest.java index 18f059766b9..4f92d9ffb8e 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelOpenTimesScoringFunctionTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelOpenTimesScoringFunctionTest.java @@ -22,8 +22,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; @@ -53,7 +53,7 @@ public class CharyparNagelOpenTimesScoringFunctionTest { private Person person = null; private ActivityFacilities facilities = null; - @Before public void setUp() { + @BeforeEach public void setUp() { final Config config = ConfigUtils.createConfig(); final Scenario scenario = ScenarioUtils.createScenario( config ); @@ -86,7 +86,7 @@ public class CharyparNagelOpenTimesScoringFunctionTest { act.setEndTime(16.0 * 3600); } - @After public void tearDown() { + @AfterEach public void tearDown() { this.person = null; this.facilities = null; } diff --git a/matsim/src/test/java/org/matsim/counts/CountTest.java b/matsim/src/test/java/org/matsim/counts/CountTest.java index 641e9dd4c73..3864f3a3c1d 100644 --- a/matsim/src/test/java/org/matsim/counts/CountTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountTest.java @@ -22,7 +22,7 @@ import java.util.Iterator; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -38,7 +38,7 @@ public class CountTest { private Counts counts; - @Before + @BeforeEach public void setUp() throws Exception { this.counts = new Counts<>(); } diff --git a/matsim/src/test/java/org/matsim/population/algorithms/PermissibleModesCalculatorImplTest.java b/matsim/src/test/java/org/matsim/population/algorithms/PermissibleModesCalculatorImplTest.java index 02181c75683..f75e0c37861 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/PermissibleModesCalculatorImplTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/PermissibleModesCalculatorImplTest.java @@ -26,8 +26,8 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -49,7 +49,7 @@ private static class Fixture { public final Plan plan; public final boolean carAvail; - public Fixture( + public Fixture( final String name, final Plan plan, final boolean carAvail ) { @@ -60,12 +60,12 @@ public Fixture( } private final List fixtures = new ArrayList(); - @After + @AfterEach public void clean() { fixtures.clear(); } - @Before + @BeforeEach public void fixtureWithNothing() { String name = "no information"; Person person = PopulationUtils.getFactory().createPerson(Id.create(name, Person.class)); @@ -73,7 +73,7 @@ public void fixtureWithNothing() { fixtures.add( new Fixture( name , plan , true ) ); } - @Before + @BeforeEach public void fixtureWithNoLicense() { String name = "no License"; Person person = PopulationUtils.getFactory().createPerson(Id.create(name, Person.class)); @@ -82,7 +82,7 @@ public void fixtureWithNoLicense() { fixtures.add( new Fixture( name , plan , false ) ); } - @Before + @BeforeEach public void fixtureWithNoCar() { String name = "no car" ; Person person = PopulationUtils.getFactory().createPerson(Id.create(name, Person.class)); @@ -91,7 +91,7 @@ public void fixtureWithNoCar() { fixtures.add( new Fixture( name , plan , false ) ); } - @Before + @BeforeEach public void fixtureWithCarSometimes() { String name = "car sometimes"; Person person = PopulationUtils.getFactory().createPerson(Id.create(name, Person.class)); diff --git a/matsim/src/test/java/org/matsim/vehicles/MatsimVehicleWriterTest.java b/matsim/src/test/java/org/matsim/vehicles/MatsimVehicleWriterTest.java index d50dbb5234e..ca6facbf262 100644 --- a/matsim/src/test/java/org/matsim/vehicles/MatsimVehicleWriterTest.java +++ b/matsim/src/test/java/org/matsim/vehicles/MatsimVehicleWriterTest.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -50,7 +50,7 @@ public class MatsimVehicleWriterTest { private Id id42; private Id id42_23; - @Before public void setUp() { + @BeforeEach public void setUp() { id23 = Id.create("23", Vehicle.class); id42 = Id.create("42", Vehicle.class); diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV1Test.java b/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV1Test.java index 79e3ca7e10d..d883adc3ed2 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV1Test.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV1Test.java @@ -23,7 +23,7 @@ import java.util.Map; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -47,7 +47,7 @@ public class VehicleReaderV1Test { private Map, VehicleType> vehicleTypes; private Map, Vehicle> vehicles; - @Before public void setUp() { + @BeforeEach public void setUp() { Vehicles veh = VehicleUtils.createVehiclesContainer(); MatsimVehicleReader reader = new MatsimVehicleReader(veh); reader.readFile(utils.getPackageInputDirectory() + TESTXML); diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV2Test.java b/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV2Test.java index 83e51b5bdf3..30547c26436 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV2Test.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleReaderV2Test.java @@ -23,7 +23,7 @@ import java.util.Map; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -47,7 +47,7 @@ public class VehicleReaderV2Test { private Map, VehicleType> vehicleTypes; private Map, Vehicle> vehicles; - @Before public void setUp() { + @BeforeEach public void setUp() { Vehicles veh = VehicleUtils.createVehiclesContainer(); MatsimVehicleReader reader = new MatsimVehicleReader(veh); diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleWriteReadTest.java b/matsim/src/test/java/org/matsim/vehicles/VehicleWriteReadTest.java index 3caafd4c6af..dd2d695f04e 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleWriteReadTest.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleWriteReadTest.java @@ -5,7 +5,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -23,7 +23,7 @@ public class VehicleWriteReadTest{ private static final String OUTXML_v2 = "testOutputVehicles_v2.xml"; - @Before + @BeforeEach public void setUp() throws IOException { } diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV1Test.java b/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV1Test.java index 1e970b893f4..2aa9ad71223 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV1Test.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV1Test.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -49,7 +49,7 @@ public class VehicleWriterV1Test { private Id id42; private Id id42_23; - @Before public void setUp() { + @BeforeEach public void setUp() { id23 = Id.create("23", Vehicle.class); id42 = Id.create("42", Vehicle.class); diff --git a/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV2Test.java b/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV2Test.java index e3ebbe417bf..1bd89738340 100644 --- a/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV2Test.java +++ b/matsim/src/test/java/org/matsim/vehicles/VehicleWriterV2Test.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -52,7 +52,7 @@ public class VehicleWriterV2Test { private Map, VehicleType> vehicleTypes; private Map, Vehicle> vehicles; - @Before public void setUp() throws IOException { + @BeforeEach public void setUp() throws IOException { String outfileName = utils.getOutputDirectory() + "../testOutputVehicles.xml"; // read it diff --git a/pom.xml b/pom.xml index c9e328d64fb..2b03c25e29d 100644 --- a/pom.xml +++ b/pom.xml @@ -216,12 +216,6 @@ 4.2.2 - - org.junit.vintage - junit-vintage-engine - ${junit.version} - test - org.junit.jupiter junit-jupiter-engine From 684bf9887bda8c04845ec495b793d377b7095513 Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Tue, 12 Dec 2023 10:51:59 +0100 Subject: [PATCH 15/21] changed parameterized runners from junit 4 to junit 5 --- .../TestWarmEmissionAnalysisModule.java | 91 ++++---- .../TestWarmEmissionAnalysisModuleCase1.java | 78 +++---- .../TestWarmEmissionAnalysisModuleCase2.java | 50 ++--- .../TestWarmEmissionAnalysisModuleCase3.java | 50 ++--- .../TestWarmEmissionAnalysisModuleCase4.java | 47 ++-- .../TestWarmEmissionAnalysisModuleCase5.java | 101 ++++----- ...issionAnalysisModuleTrafficSituations.java | 66 +++--- .../CreateAutomatedFDTest.java | 70 +++--- .../run/RunWithParkingProxyIT.java | 4 +- .../SignalsAndLanesOsmNetworkReaderTest.java | 61 +++-- .../selectors/HighestWeightSelectorTest.java | 76 +++---- .../CoalitionSelectorTest.java | 31 +-- .../drtAndPt/PtAlongALine2Test.java | 1 - .../ModalDistanceAndCountsCadytsIT.java | 36 +-- .../matsim/core/controler/ControlerIT.java | 47 ++-- .../core/mobsim/hermes/HermesTransitTest.java | 143 ++++++------ .../mobsim/qsim/FlowStorageSpillbackTest.java | 25 +-- .../core/mobsim/qsim/NodeTransitionTest.java | 55 ++--- .../org/matsim/core/mobsim/qsim/QSimTest.java | 209 ++++++++++-------- .../core/mobsim/qsim/VehicleSourceTest.java | 64 ++---- .../mobsim/qsim/qnetsimengine/QLinkTest.java | 59 +++-- .../qsim/qnetsimengine/SeepageTest.java | 39 ++-- .../qnetsimengine/VehVsLinkSpeedTest.java | 41 ++-- .../TripStructureUtilsSubtoursTest.java | 83 ++++--- .../CharyparNagelScoringFunctionTest.java | 68 +++--- .../java/org/matsim/examples/EquilTest.java | 25 +-- .../matsim/examples/simple/PtScoringTest.java | 50 ++--- .../ActivityFacilitiesSourceTest.java | 49 ++-- .../matsim/modules/ScoreStatsModuleTest.java | 37 +--- ...ndomLegModeForSubtourComplexTripsTest.java | 35 +-- ...eRandomLegModeForSubtourDiffModesTest.java | 64 +++--- .../ChooseRandomLegModeForSubtourTest.java | 83 ++++--- 32 files changed, 836 insertions(+), 1102 deletions(-) diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModule.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModule.java index 92440ecfd30..cd88c087a65 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModule.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModule.java @@ -20,10 +20,12 @@ package org.matsim.contrib.emissions; -import org.junit.jupiter.api.Assertions; +import org.geotools.metadata.iso.quality.TemporalAccuracyImpl; import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Node; @@ -38,6 +40,7 @@ import org.matsim.vehicles.VehiclesFactory; import java.util.*; +import java.util.stream.Stream; import static org.matsim.contrib.emissions.Pollutant.*; @@ -48,8 +51,8 @@ /* * test for playground.vsp.emissions.WarmEmissionAnalysisModule * - * WarmEmissionAnalysisModule (weam) - * public methods and corresponding tests: + * WarmEmissionAnalysisModule (weam) + * public methods and corresponding tests: * weamParameter - testWarmEmissionAnalysisParameter * throw warm EmissionEvent - testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent*, testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions * check vehicle info and calculate warm emissions -testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent*, testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions @@ -61,7 +64,7 @@ * get top go km couter - testCounters*() * get warm emission event counter - testCounters*() * - * private methods and corresponding tests: + * private methods and corresponding tests: * rescale warm emissions - rescaleWarmEmissionsTest() * calculate warm emissions - implicitly tested * convert string 2 tuple - implicitly tested @@ -70,7 +73,6 @@ * see test methods for details on the particular test cases **/ -@RunWith(Parameterized.class) public class TestWarmEmissionAnalysisModule { // This used to be one large test class, which had separate table entries for each test, but put them all into the same table. The result was // difficult if not impossible to debug, and the resulting detailed table was inconsistent in the sense that it did not contain all combinations of @@ -78,12 +80,8 @@ public class TestWarmEmissionAnalysisModule { // single class before was so large that I could not fully comprehend it, there may now be errors in the ripped-apart classes. Hopefully, over time, // this will help to sort things out. kai, feb'20 - - - private static final Set pollutants = new HashSet<>( Arrays.asList( Pollutant.values() )); static final String HBEFA_ROAD_CATEGORY = "URB"; - private final EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod; private boolean excep = false; private static final String PASSENGER_CAR = "PASSENGER_CAR"; @@ -113,24 +111,18 @@ public class TestWarmEmissionAnalysisModule { private final String sgffConcept = "sg ff concept"; private final String sgffSizeClass = "sg ff size class"; - - @Parameterized.Parameters( name = "{index}: ComputationMethod={0}") - public static Collection createCombinations() { - List list = new ArrayList<>(); - list.add( new Object [] {EmissionsConfigGroup.EmissionsComputationMethod.StopAndGoFraction} ) ; - list.add( new Object [] {EmissionsConfigGroup.EmissionsComputationMethod.AverageSpeed} ) ; - return list; + public static Stream arguments() { + return Stream.of( + EmissionsConfigGroup.EmissionsComputationMethod.StopAndGoFraction, + EmissionsConfigGroup.EmissionsComputationMethod.AverageSpeed + ); } - public TestWarmEmissionAnalysisModule( EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod ) { - this.emissionsComputationMethod = emissionsComputationMethod; - } - - - @Test - void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent6(){ + @ParameterizedTest + @MethodSource("arguments") + void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent6(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod){ //-- set up tables, event handler, parameters, module - setUp(); + setUp(emissionsComputationMethod); Id sgffVehicleId = Id.create("vehicle sg equals ff", Vehicle.class); double sgffLinklength = 4000.; @@ -164,10 +156,11 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent6() } } - @Test - void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions1(){ + @ParameterizedTest + @MethodSource("arguments") + void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions1(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod){ //-- set up tables, event handler, parameters, module - setUp(); + setUp(emissionsComputationMethod); // case 5 - no entry in any table - must be different to other test case's strings //With the bug fix to handle missing values - this test should no longer throw an error - jm oct'18 @@ -196,10 +189,11 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Ex excep=false; } - @Test - void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions2(){ + @ParameterizedTest + @MethodSource("arguments") + void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions2(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod){ //-- set up tables, event handler, parameters, module - setUp(); + setUp(emissionsComputationMethod); // no vehicle information given Id noeVehicleId = Id.create("veh 6", Vehicle.class); @@ -221,12 +215,13 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Ex Assertions.assertTrue(excep); excep=false; } - @Test - void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions3(){ + @ParameterizedTest + @MethodSource("arguments") + void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions3(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod){ //-- set up tables, event handler, parameters, module - setUp(); + setUp(emissionsComputationMethod); - // empty vehicle information + // empty vehicle information Id noeVehicleId = Id.create("veh 7", Vehicle.class); Id noeVehicleTypeId = Id.create(";;;", VehicleType.class); VehiclesFactory vehFac = VehicleUtils.getFactory(); @@ -245,10 +240,11 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Ex Assertions.assertTrue(excep); excep=false; } - @Test - void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions4(){ + @ParameterizedTest + @MethodSource("arguments") + void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions4(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod){ //-- set up tables, event handler, parameters, module - setUp(); + setUp(emissionsComputationMethod); // vehicle information string is 'null' Id noeVehicleId = Id.create("veh 8", Vehicle.class); VehiclesFactory vehFac = VehicleUtils.getFactory(); @@ -268,9 +264,10 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Ex } - @Test - void testCounters7(){ - setUp(); + @ParameterizedTest + @MethodSource("arguments") + void testCounters7(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod){ + setUp(emissionsComputationMethod); emissionsModule.reset(); // case 10 - data in detailed table, stop go speed > free flow speed @@ -295,7 +292,7 @@ void testCounters7(){ emissionsModule.reset(); // ff < sg < avg - handled like free flow as well - no additional test needed - // avg < ff < sg - handled like stop go + // avg < ff < sg - handled like stop go emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(tableVehicle, tableLink, 2* tableLinkLength/(AVG_PASSENGER_CAR_SPEED_FF_KMH)*3.6 ); Assertions.assertEquals(0, emissionsModule.getFractionOccurences() ); Assertions.assertEquals(0., emissionsModule.getFreeFlowKmCounter(), MatsimTestUtils.EPSILON ); @@ -308,7 +305,7 @@ void testCounters7(){ } - private void setUp() { + private void setUp(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod) { Map avgHbefaWarmTable = new HashMap<>(); Map detailedHbefaWarmTable = new HashMap<>(); @@ -322,7 +319,7 @@ private void setUp() { EventsManager emissionEventManager = new HandlerToTestEmissionAnalysisModules(); EmissionsConfigGroup ecg = new EmissionsConfigGroup(); ecg.setHbefaVehicleDescriptionSource( EmissionsConfigGroup.HbefaVehicleDescriptionSource.usingVehicleTypeId ); - ecg.setEmissionsComputationMethod( this.emissionsComputationMethod ); + ecg.setEmissionsComputationMethod( emissionsComputationMethod ); ecg.setDetailedVsAverageLookupBehavior( DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable ); emissionsModule = new WarmEmissionAnalysisModule( avgHbefaWarmTable, detailedHbefaWarmTable, hbefaRoadTrafficSpeeds, pollutants, emissionEventManager, ecg ); @@ -451,7 +448,7 @@ static void addDetailedRecordsToTestSpeedsTable( } - - + + diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase1.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase1.java index 48734493dce..2bc080b1bc3 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase1.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestWarmEmissionAnalysisModuleCase1.java @@ -22,8 +22,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.EnumSource; +import org.junit.jupiter.params.provider.MethodSource; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; @@ -36,6 +38,7 @@ import org.matsim.vehicles.VehiclesFactory; import java.util.*; +import java.util.stream.Stream; import static org.matsim.contrib.emissions.Pollutant.CO2_TOTAL; import static org.matsim.contrib.emissions.TestWarmEmissionAnalysisModule.HBEFA_ROAD_CATEGORY; @@ -55,8 +58,8 @@ /* * test for playground.vsp.emissions.WarmEmissionAnalysisModule * - * WarmEmissionAnalysisModule (weam) - * public methods and corresponding tests: + * WarmEmissionAnalysisModule (weam) + * public methods and corresponding tests: * weamParameter - testWarmEmissionAnalysisParameter * throw warm EmissionEvent - testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent*, testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions * check vehicle info and calculate warm emissions -testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent*, testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent_Exceptions @@ -68,7 +71,7 @@ * get top go km couter - testCounters*() * get warm emission event counter - testCounters*() * - * private methods and corresponding tests: + * private methods and corresponding tests: * rescale warm emissions - rescaleWarmEmissionsTest() * calculate warm emissions - implicitly tested * convert string 2 tuple - implicitly tested @@ -77,7 +80,6 @@ * see test methods for details on the particular test cases **/ -@RunWith(Parameterized.class) public class TestWarmEmissionAnalysisModuleCase1{ // This used to be one large test class, which had separate table entries for each test, but put them all into the same table. The result was // difficult if not impossible to debug, and the resulting detailed table was inconsistent in the sense that it did not contain all combinations of @@ -89,7 +91,6 @@ public class TestWarmEmissionAnalysisModuleCase1{ private static final Set pollutants = new HashSet<>( Arrays.asList( Pollutant.values() )); private static final int leaveTime = 0; - private final EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod; private static final String PASSENGER_CAR = "PASSENGER_CAR"; @@ -104,20 +105,7 @@ public class TestWarmEmissionAnalysisModuleCase1{ private static final Double PETROL_SPEED_FF = 20.; //km/h private static final Double PETROL_SPEED_SG = 10.; //km/h - - @Parameterized.Parameters( name = "{index}: ComputationMethod={0}") - public static Collection createCombinations() { - List list = new ArrayList<>(); - list.add( new Object [] {EmissionsConfigGroup.EmissionsComputationMethod.StopAndGoFraction} ) ; - list.add( new Object [] {EmissionsConfigGroup.EmissionsComputationMethod.AverageSpeed} ) ; - return list; - } - - public TestWarmEmissionAnalysisModuleCase1( EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod ) { - this.emissionsComputationMethod = emissionsComputationMethod; - } - - private WarmEmissionAnalysisModule setUp() { + private WarmEmissionAnalysisModule setUp(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod) { Map avgHbefaWarmTable = new HashMap<>(); Map detailedHbefaWarmTable = new HashMap<>(); TestWarmEmissionAnalysisModule.fillAverageTable( avgHbefaWarmTable ); @@ -128,7 +116,7 @@ private WarmEmissionAnalysisModule setUp() { EventsManager emissionEventManager = TestWarmEmissionAnalysisModuleCase1.emissionEventManager; EmissionsConfigGroup ecg = new EmissionsConfigGroup(); ecg.setHbefaVehicleDescriptionSource( EmissionsConfigGroup.HbefaVehicleDescriptionSource.usingVehicleTypeId ); - ecg.setEmissionsComputationMethod( this.emissionsComputationMethod ); + ecg.setEmissionsComputationMethod( emissionsComputationMethod ); ecg.setDetailedVsAverageLookupBehavior( DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable ); return new WarmEmissionAnalysisModule( avgHbefaWarmTable, detailedHbefaWarmTable, hbefaRoadTrafficSpeeds, pollutants, emissionEventManager, ecg ); } @@ -137,10 +125,11 @@ private WarmEmissionAnalysisModule setUp() { //this test method creates a mock link and mock vehicle with a complete vehicleTypId --> detailed values are used //the CO2_TOTAL warm Emissions are compared to a given value --> computed by using detailed Petrol and traffic state freeflow //the "Sum" of all emissions is tested - @Test - void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent1(){ + @ParameterizedTest + @EnumSource(EmissionsConfigGroup.EmissionsComputationMethod.class) + void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent1(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod){ //-- set up tables, event handler, parameters, module - WarmEmissionAnalysisModule warmEmissionAnalysisModule = setUp(); + WarmEmissionAnalysisModule warmEmissionAnalysisModule = setUp(emissionsComputationMethod); // case 1 - data in both tables -> use detailed Id vehicleId = Id.create("veh 1", Vehicle.class); double linkLength = 200.; @@ -167,9 +156,10 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent1() * the counters for all possible combinations of avg, stop go and free flow speed are tested * for the cases: > s&g speed, use detailed // free flow velocity inconsistent -> different value in table @@ -308,10 +299,11 @@ void testCounters5(){ } - @Test - void testCounters1fractional(){ + @ParameterizedTest + @EnumSource(EmissionsConfigGroup.EmissionsComputationMethod.class) + void testCounters1fractional(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod){ - WarmEmissionAnalysisModule emissionsModule = setUp(); + WarmEmissionAnalysisModule emissionsModule = setUp(emissionsComputationMethod); emissionsModule.getEcg().setEmissionsComputationMethod(StopAndGoFraction ); // yyyyyy !!!!!! @@ -394,10 +386,11 @@ void testCounters1fractional(){ } - @Test - void testCounters6(){ + @ParameterizedTest + @EnumSource(EmissionsConfigGroup.EmissionsComputationMethod.class) + void testCounters6(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod){ - WarmEmissionAnalysisModule emissionsModule = setUp(); + WarmEmissionAnalysisModule emissionsModule = setUp(emissionsComputationMethod); emissionsModule.getEcg().setEmissionsComputationMethod(StopAndGoFraction ); // case 1 - data in both tables -> use detailed @@ -431,10 +424,11 @@ void testCounters6(){ emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(inconffVehicle, inconLink, 2 * inconff / (PETROL_SPEED_FF + PETROL_SPEED_SG) * 3.6); } - @Test - void testCounters8(){ + @ParameterizedTest + @EnumSource(EmissionsConfigGroup.EmissionsComputationMethod.class) + void testCounters8(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod){ - WarmEmissionAnalysisModule emissionsModule = setUp(); + WarmEmissionAnalysisModule emissionsModule = setUp(emissionsComputationMethod); // test summing up of counters @@ -516,7 +510,7 @@ private static void fillDetailedTable( Map pollutants = new HashSet<>( Arrays.asList( Pollutant.values() )); static final String HBEFA_ROAD_CATEGORY = "URB"; private static final int leaveTime = 0; - private final EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod; private static final String PASSENGER_CAR = "PASSENGER_CAR"; @@ -106,30 +106,17 @@ public class TestWarmEmissionAnalysisModuleCase2{ private static final Double PCSG_VELOCITY_KMH = 10.; //km/h private static final double DETAILED_PC_FACTOR_FF = .0001; - - @Parameterized.Parameters( name = "{index}: ComputationMethod={0}") - public static Collection createCombinations() { - List list = new ArrayList<>(); - list.add( new Object [] {EmissionsConfigGroup.EmissionsComputationMethod.StopAndGoFraction} ) ; - list.add( new Object [] {EmissionsConfigGroup.EmissionsComputationMethod.AverageSpeed} ) ; - return list; - } - - public TestWarmEmissionAnalysisModuleCase2( EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod ) { - this.emissionsComputationMethod = emissionsComputationMethod; - } - - /* * this test method creates a mock link and mock vehicle with a complete vehicleTypId --> lookUpBehaviour: tryDetailedThenTechnologyAverageThenAverageTable * for two speed cases: avg speed = free flow speed & avg speed = stop go speed the NMHC warm emissions and emissions sum are computed using the two emissionsComputationMethods StopAndGoFraction & AverageSpeed */ - @Test - void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent2(){ + @ParameterizedTest + @EnumSource(EmissionsConfigGroup.EmissionsComputationMethod.class) + void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent2(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod){ //-- set up tables, event handler, parameters, module - WarmEmissionAnalysisModule emissionsModule = setUp(); + WarmEmissionAnalysisModule emissionsModule = setUp(emissionsComputationMethod); // case 2 - free flow entry in both tables, stop go entry in average table -> use average // see (*) below. kai, jan'20 @@ -185,10 +172,11 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent2() * for three cases: "current speed equals free flow speed" & "current speed equals stop go speed" & "current speed equals stop go speed" the counters are tested * average values are used */ - @Test - void testCounters3(){ + @ParameterizedTest + @EnumSource(EmissionsConfigGroup.EmissionsComputationMethod.class) + void testCounters3(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod){ - WarmEmissionAnalysisModule emissionsModule = setUp(); + WarmEmissionAnalysisModule emissionsModule = setUp(emissionsComputationMethod); // case 2 - free flow entry in both tables, stop go entry in average table -> use average Id pcVehicleId = Id.create("vehicle 2", Vehicle.class); @@ -221,7 +209,7 @@ void testCounters3(){ } - private WarmEmissionAnalysisModule setUp() { + private WarmEmissionAnalysisModule setUp(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod) { Map avgHbefaWarmTable = new HashMap<>(); Map detailedHbefaWarmTable = new HashMap<>(); @@ -234,7 +222,7 @@ private WarmEmissionAnalysisModule setUp() { EventsManager emissionEventManager = this.emissionEventManager; EmissionsConfigGroup ecg = new EmissionsConfigGroup(); ecg.setHbefaVehicleDescriptionSource( EmissionsConfigGroup.HbefaVehicleDescriptionSource.usingVehicleTypeId ); - ecg.setEmissionsComputationMethod( this.emissionsComputationMethod ); + ecg.setEmissionsComputationMethod( emissionsComputationMethod ); ecg.setDetailedVsAverageLookupBehavior( DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable ); return new WarmEmissionAnalysisModule( avgHbefaWarmTable, detailedHbefaWarmTable, hbefaRoadTrafficSpeeds, pollutants, emissionEventManager, ecg ); @@ -331,7 +319,7 @@ private void fillDetailedTable( Map pollutants = new HashSet<>( Arrays.asList( Pollutant.values() )); static final String HBEFA_ROAD_CATEGORY = "URB"; private static final int leaveTime = 0; - private final EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod; private static final String PASSENGER_CAR = "PASSENGER_CAR"; private Map warmEmissions; @@ -99,27 +99,16 @@ public class TestWarmEmissionAnalysisModuleCase3{ private final String dieselSizeClass = "diesel"; private final String dieselConcept = ">=2L"; - @Parameterized.Parameters( name = "{index}: ComputationMethod={0}") - public static Collection createCombinations() { - List list = new ArrayList<>(); - list.add( new Object [] {EmissionsConfigGroup.EmissionsComputationMethod.StopAndGoFraction} ) ; - list.add( new Object [] {EmissionsConfigGroup.EmissionsComputationMethod.AverageSpeed} ) ; - return list; - } - - public TestWarmEmissionAnalysisModuleCase3( EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod ) { - this.emissionsComputationMethod = emissionsComputationMethod; - } - /* * this test method creates a diesel vehicle and mock link * for two cases: "avg speed = free flow speed" & "avg speed = stop go speed" the average values are used to calculate the PM warm emissions */ - @Test - void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent3(){ + @ParameterizedTest + @EnumSource(EmissionsConfigGroup.EmissionsComputationMethod.class) + void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent3(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod){ //-- set up tables, event handler, parameters, module - WarmEmissionAnalysisModule emissionsModule = setUp(); + WarmEmissionAnalysisModule emissionsModule = setUp(emissionsComputationMethod); // case 3 - stop go entry in both tables, free flow entry in average table -> use average Id dieselVehicleId = Id.create("veh 3", Vehicle.class); @@ -154,10 +143,11 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent3() * this test method creates a diesel vehicle and mock link * for two cases: "current speed equals free flow speed" & "current speed equals stop go speed" the counters are tested */ - @Test - void testCounters4(){ + @ParameterizedTest + @EnumSource(EmissionsConfigGroup.EmissionsComputationMethod.class) + void testCounters4(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod){ - WarmEmissionAnalysisModule emissionsModule = setUp(); + WarmEmissionAnalysisModule emissionsModule = setUp(emissionsComputationMethod); // case 3 - stop go entry in both tables, free flow entry in average table -> use average Id dieselVehicleId = Id.create("vehicle 3", Vehicle.class); @@ -191,7 +181,7 @@ void testCounters4(){ emissionsModule.reset(); } - private WarmEmissionAnalysisModule setUp() { + private WarmEmissionAnalysisModule setUp(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod) { Map avgHbefaWarmTable = new HashMap<>(); Map detailedHbefaWarmTable = new HashMap<>(); @@ -204,7 +194,7 @@ private WarmEmissionAnalysisModule setUp() { EventsManager emissionEventManager = this.emissionEventManager; EmissionsConfigGroup ecg = new EmissionsConfigGroup(); ecg.setHbefaVehicleDescriptionSource( EmissionsConfigGroup.HbefaVehicleDescriptionSource.usingVehicleTypeId ); - ecg.setEmissionsComputationMethod( this.emissionsComputationMethod ); + ecg.setEmissionsComputationMethod( emissionsComputationMethod ); ecg.setDetailedVsAverageLookupBehavior( DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable ); return new WarmEmissionAnalysisModule( avgHbefaWarmTable, detailedHbefaWarmTable, hbefaRoadTrafficSpeeds, pollutants, emissionEventManager, ecg ); @@ -286,7 +276,7 @@ private void fillDetailedTable( Map pollutants = new HashSet<>( Arrays.asList( Pollutant.values() )); private static final String HBEFA_ROAD_CATEGORY = "URB"; private static final int leaveTime = 0; - private final EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod; private static final String PASSENGER_CAR = "PASSENGER_CAR"; private Map warmEmissions; @@ -105,29 +103,17 @@ public class TestWarmEmissionAnalysisModuleCase4{ private static final Double SPEED_FF = 20.; //km/h private static final Double SPEED_SG = 10.; //km/h - @Parameterized.Parameters( name = "{index}: ComputationMethod={0}") - public static Collection createCombinations() { - List list = new ArrayList<>(); - list.add(new Object[]{EmissionsConfigGroup.EmissionsComputationMethod.StopAndGoFraction}); - list.add(new Object[]{EmissionsConfigGroup.EmissionsComputationMethod.AverageSpeed}); - return list; - } - - public TestWarmEmissionAnalysisModuleCase4(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod) { - this.emissionsComputationMethod = emissionsComputationMethod; - } - - /* * this test method creates a vehicle (lpg properties) and a mock link * for two cases: "avg speed = stop go speed" & "avg speed = free flow speed" the PM warm Emissions and the Emissions "sum" are tested * average values are used */ - @Test - void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent4() { + @ParameterizedTest + @EnumSource(EmissionsConfigGroup.EmissionsComputationMethod.class) + void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent4(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod) { //-- set up tables, event handler, parameters, module - WarmEmissionAnalysisModule emissionsModule = setUp(); + WarmEmissionAnalysisModule emissionsModule = setUp(emissionsComputationMethod); // case 4 - data in average table Id lpgVehicleId = Id.create("veh 4", Vehicle.class); @@ -161,9 +147,10 @@ void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent4() * for two cases: "avg speed = stop go speed" & "avg speed = free flow speed" the PM warm Emissions are tested * average values are used */ - @Test - void testCounters2(){ - WarmEmissionAnalysisModule emissionsModule = setUp(); + @ParameterizedTest + @EnumSource(EmissionsConfigGroup.EmissionsComputationMethod.class) + void testCounters2(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod){ + WarmEmissionAnalysisModule emissionsModule = setUp(emissionsComputationMethod); // ff und sg not part of the detailed table -> use average table Id vehicleId = Id.create("vehicle 4", Vehicle.class); @@ -197,7 +184,7 @@ void testCounters2(){ } - private WarmEmissionAnalysisModule setUp() { + private WarmEmissionAnalysisModule setUp(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod) { Map avgHbefaWarmTable = new HashMap<>(); Map detailedHbefaWarmTable = new HashMap<>(); @@ -209,7 +196,7 @@ private WarmEmissionAnalysisModule setUp() { EventsManager emissionEventManager = this.emissionEventManager; EmissionsConfigGroup ecg = new EmissionsConfigGroup(); ecg.setHbefaVehicleDescriptionSource(EmissionsConfigGroup.HbefaVehicleDescriptionSource.usingVehicleTypeId); - ecg.setEmissionsComputationMethod(this.emissionsComputationMethod); + ecg.setEmissionsComputationMethod(emissionsComputationMethod); ecg.setDetailedVsAverageLookupBehavior(DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable); return new WarmEmissionAnalysisModule( avgHbefaWarmTable, detailedHbefaWarmTable, hbefaRoadTrafficSpeeds, pollutants, emissionEventManager, ecg ); @@ -289,7 +276,7 @@ private void fillDetailedTable(Map pollutants = new HashSet<>( Arrays.asList( Pollutant.values() )); - private final EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod; + private static final Set pollutants = new HashSet<>(Arrays.asList(Pollutant.values())); private static final String PASSENGER_CAR = "PASSENGER_CAR"; - - private static final Double DETAILED_ZERO_FACTOR_FF = .0011; + private static final Double DETAILED_ZERO_FACTOR_FF = .0011; + private final HandlerToTestEmissionAnalysisModules emissionEventManager = new HandlerToTestEmissionAnalysisModules(); // vehicle information for regular test cases - // case 5 - data in detailed table, stop go speed zero private final String zeroRoadCategory = "URB_case6"; private final String zeroTechnology = "zero technology"; @@ -99,76 +101,65 @@ public class TestWarmEmissionAnalysisModuleCase5{ private final Double zeroFreeVelocity = 20.; //km/h private final Double zeroSgVelocity = 0.; //km/h - - - @Parameterized.Parameters( name = "{index}: ComputationMethod={0}") - public static Collection createCombinations() { - List list = new ArrayList<>(); - list.add( new Object [] {EmissionsConfigGroup.EmissionsComputationMethod.StopAndGoFraction} ) ; - list.add( new Object [] {EmissionsConfigGroup.EmissionsComputationMethod.AverageSpeed} ) ; - return list; - } - - public TestWarmEmissionAnalysisModuleCase5( EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod ) { - this.emissionsComputationMethod = emissionsComputationMethod; - } - /* * this test method creates a vehicle and a mock link (both zero properties) * the free flow factor is used to calculate and test the PM warm Emissions and HandlerToTestEmissionAnalysisModules Sum * detailed values are used */ - @Test - void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent5(){ + @ParameterizedTest + @EnumSource(EmissionsConfigGroup.EmissionsComputationMethod.class) + public void testCheckVehicleInfoAndCalculateWarmEmissions_and_throwWarmEmissionEvent5(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod) { //-- set up tables, event handler, parameters, module - WarmEmissionAnalysisModule emissionsModule = setUp(); + WarmEmissionAnalysisModule emissionsModule = setUp(emissionsComputationMethod); // case 6 - data in detailed table, stop go speed zero // use free flow factor to calculate emissions Id zeroVehicleId = Id.create("vehicle zero", Vehicle.class); double zeroLinklength = 3000.; - Link zerolink = TestWarmEmissionAnalysisModule.createMockLink("link zero", zeroLinklength, zeroFreeVelocity / 3.6 ); + Link zerolink = TestWarmEmissionAnalysisModule.createMockLink("link zero", zeroLinklength, zeroFreeVelocity / 3.6); Id lpgLinkId = zerolink.getId(); EmissionUtils.setHbefaRoadType(zerolink, zeroRoadCategory); Id zeroVehicleTypeId = Id.create( - PASSENGER_CAR + ";"+ zeroTechnology + ";" + zeroSizeClass + ";" + zeroConcept, VehicleType.class ); + PASSENGER_CAR + ";" + zeroTechnology + ";" + zeroSizeClass + ";" + zeroConcept, VehicleType.class); VehiclesFactory vehFac = VehicleUtils.getFactory(); Vehicle zeroVehicle = vehFac.createVehicle(zeroVehicleId, vehFac.createVehicleType(zeroVehicleTypeId)); - Map warmEmissions = emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(zeroVehicle, zerolink, 2 * zeroLinklength / (zeroFreeVelocity + zeroSgVelocity) * 3.6); - Assertions.assertEquals( DETAILED_ZERO_FACTOR_FF *zeroLinklength/1000., warmEmissions.get(PM ), MatsimTestUtils.EPSILON ); + Map warmEmissions = emissionsModule.checkVehicleInfoAndCalculateWarmEmissions(zeroVehicle, zerolink, + 2 * zeroLinklength / (zeroFreeVelocity + zeroSgVelocity) * 3.6); + Assertions.assertEquals(DETAILED_ZERO_FACTOR_FF * zeroLinklength / 1000., warmEmissions.get(PM), MatsimTestUtils.EPSILON); emissionsModule.throwWarmEmissionEvent(22., lpgLinkId, zeroVehicleId, warmEmissions); - Assertions.assertEquals( pollutants.size() * DETAILED_ZERO_FACTOR_FF *zeroLinklength/1000., emissionEventManager.getSum(), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(pollutants.size() * DETAILED_ZERO_FACTOR_FF * zeroLinklength / 1000., emissionEventManager.getSum(), + MatsimTestUtils.EPSILON); warmEmissions.clear(); } - - private WarmEmissionAnalysisModule setUp() { + private WarmEmissionAnalysisModule setUp(EmissionsConfigGroup.EmissionsComputationMethod emissionsComputationMethod) { Map avgHbefaWarmTable = new HashMap<>(); Map detailedHbefaWarmTable = new HashMap<>(); - TestWarmEmissionAnalysisModule.fillAverageTable( avgHbefaWarmTable ); - fillDetailedTable( detailedHbefaWarmTable ); + TestWarmEmissionAnalysisModule.fillAverageTable(avgHbefaWarmTable); + fillDetailedTable(detailedHbefaWarmTable); Map> hbefaRoadTrafficSpeeds = EmissionUtils.createHBEFASpeedsTable( - avgHbefaWarmTable ); - TestWarmEmissionAnalysisModule.addDetailedRecordsToTestSpeedsTable( hbefaRoadTrafficSpeeds, detailedHbefaWarmTable ); + avgHbefaWarmTable); + TestWarmEmissionAnalysisModule.addDetailedRecordsToTestSpeedsTable(hbefaRoadTrafficSpeeds, detailedHbefaWarmTable); EventsManager emissionEventManager = this.emissionEventManager; EmissionsConfigGroup ecg = new EmissionsConfigGroup(); - ecg.setHbefaVehicleDescriptionSource( EmissionsConfigGroup.HbefaVehicleDescriptionSource.usingVehicleTypeId ); - ecg.setEmissionsComputationMethod( this.emissionsComputationMethod ); - ecg.setDetailedVsAverageLookupBehavior( DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable ); + ecg.setHbefaVehicleDescriptionSource(EmissionsConfigGroup.HbefaVehicleDescriptionSource.usingVehicleTypeId); + ecg.setEmissionsComputationMethod(emissionsComputationMethod); + ecg.setDetailedVsAverageLookupBehavior(DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable); - return new WarmEmissionAnalysisModule( avgHbefaWarmTable, detailedHbefaWarmTable, hbefaRoadTrafficSpeeds, pollutants, emissionEventManager, ecg ); + return new WarmEmissionAnalysisModule(avgHbefaWarmTable, detailedHbefaWarmTable, hbefaRoadTrafficSpeeds, pollutants, emissionEventManager, + ecg); } - private void fillDetailedTable( Map detailedHbefaWarmTable) { + private void fillDetailedTable(Map detailedHbefaWarmTable) { //entries for zero case { @@ -204,7 +195,3 @@ private void fillDetailedTable( Map pollutants = new HashSet<>( Arrays.asList( Pollutant.values() ) ); private static final String hbefaRoadCategory = "URB"; - private final EmissionsComputationMethod emissionsComputationMethod; private final String passengercar= "PASSENGER_CAR"; private WarmEmissionAnalysisModule weam; @@ -84,20 +85,7 @@ public class TestWarmEmissionAnalysisModuleTrafficSituations { private static final String pcConcept = "<1,4L"; private static final double[] avgPetrolFactor = {20, 200, 2000, 20000, 200000}; - public TestWarmEmissionAnalysisModuleTrafficSituations( EmissionsComputationMethod emissionsComputationMethod ) { - this.emissionsComputationMethod = emissionsComputationMethod; - } - - @Parameterized.Parameters( name = "{index}: ComputationMethod={0}") - public static Collection createCombinations() { - List list = new ArrayList<>(); - list.add( new Object [] {EmissionsComputationMethod.StopAndGoFraction} ) ; - list.add( new Object [] {EmissionsComputationMethod.AverageSpeed} ) ; - return list; - } - - @BeforeEach - public void setUp() { + public void setUp(EmissionsComputationMethod emissionsComputationMethod) { Map avgHbefaWarmTable = new HashMap<>(); Map detailedHbefaWarmTable = new HashMap<>(); @@ -110,7 +98,7 @@ public void setUp() { EventsManager emissionEventManager = new HandlerToTestEmissionAnalysisModules(); EmissionsConfigGroup ecg = new EmissionsConfigGroup(); ecg.setHbefaVehicleDescriptionSource( EmissionsConfigGroup.HbefaVehicleDescriptionSource.usingVehicleTypeId ); - ecg.setEmissionsComputationMethod( this.emissionsComputationMethod ); + ecg.setEmissionsComputationMethod( emissionsComputationMethod ); ecg.setDetailedVsAverageLookupBehavior(EmissionsConfigGroup.DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort); //declare using detailed values weam = new WarmEmissionAnalysisModule( avgHbefaWarmTable, detailedHbefaWarmTable, hbefaRoadTrafficSpeeds, pollutants, emissionEventManager, ecg ); @@ -120,8 +108,10 @@ public void setUp() { //Test to check that vehicles not found in the detailed table revert back to average table - ie detailed (petrol, 1,2,3), average (petrol), search pet 4 - @Test - public void testFallBackToAverageTable() { + @ParameterizedTest + @EnumSource(EmissionsConfigGroup.EmissionsComputationMethod.class) + public void testFallBackToAverageTable(EmissionsComputationMethod emissionsComputationMethod) { + setUp(emissionsComputationMethod); Id vehicleId = Id.create("vehicle 1", Vehicle.class); double linkLength = 2*1000.; //in meter Id vehicleTypeId = Id.create(passengercar+ ";"+petrolTechnology+";"+petrolSizeClass+";"+petrolConcept, VehicleType.class); @@ -134,18 +124,20 @@ public void testFallBackToAverageTable() { //allow fallback to average table weam.getEcg().setDetailedVsAverageLookupBehavior( EmissionsConfigGroup.DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable ); warmEmissions = weam.checkVehicleInfoAndCalculateWarmEmissions(vehicle, pcLink, travelTime*3.6); - Assert.assertEquals(detailedPetrolFactor[FF_INDEX]*(linkLength/1000.), warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(detailedPetrolFactor[FF_INDEX]*(linkLength/1000.), warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); vehicleTypeId = Id.create(passengercar+ ";"+pcTechnology+";"+pcSizeClass+";"+pcConcept, VehicleType.class); vehicle = vehFac.createVehicle(vehicleId, vehFac.createVehicleType(vehicleTypeId)); warmEmissions = weam.checkVehicleInfoAndCalculateWarmEmissions(vehicle, pcLink, travelTime*3.6); - Assert.assertEquals(avgPetrolFactor[FF_INDEX]*(linkLength/1000.), warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(avgPetrolFactor[FF_INDEX]*(linkLength/1000.), warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); } //using the different computation methods, the NOx warm Emissions are calculated for the diffrent trafic Situations (FF;HEAVY;SAT;SG) - @Test - public void testTrafficSituations() { + @ParameterizedTest + @EnumSource(EmissionsConfigGroup.EmissionsComputationMethod.class) + public void testTrafficSituations(EmissionsComputationMethod emissionsComputationMethod) { + setUp(emissionsComputationMethod); Id vehicleId = Id.create("vehicle 1", Vehicle.class); double linkLength = 2*1000.; //in meter Id vehicleTypeId = Id.create(passengercar+ ";"+petrolTechnology+";"+petrolSizeClass+";"+petrolConcept, VehicleType.class); @@ -159,17 +151,17 @@ public void testTrafficSituations() { double actualSpeed = avgPassengerCarSpeed[FF_INDEX]; double travelTime = linkLength/actualSpeed; warmEmissions = weam.checkVehicleInfoAndCalculateWarmEmissions(vehicle, pcLink, travelTime*3.6); - Assert.assertEquals(detailedPetrolFactor[FF_INDEX]*(linkLength/1000.), warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(detailedPetrolFactor[FF_INDEX]*(linkLength/1000.), warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); actualSpeed = avgPassengerCarSpeed[HEAVY_INDEX]; travelTime = linkLength/actualSpeed; warmEmissions = weam.checkVehicleInfoAndCalculateWarmEmissions(vehicle, pcLink, travelTime*3.6); switch( emissionsComputationMethod ) { case StopAndGoFraction: - Assert.assertEquals( 1360.1219512195123, warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( 1360.1219512195123, warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); break; case AverageSpeed: - Assert.assertEquals(detailedPetrolFactor[HEAVY_INDEX]*(linkLength/1000.), warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(detailedPetrolFactor[HEAVY_INDEX]*(linkLength/1000.), warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); break; default: throw new IllegalStateException( "Unexpected value: " + emissionsComputationMethod ); @@ -180,10 +172,10 @@ public void testTrafficSituations() { warmEmissions = weam.checkVehicleInfoAndCalculateWarmEmissions(vehicle, pcLink, travelTime*3.6); switch( emissionsComputationMethod ) { case StopAndGoFraction: - Assert.assertEquals( 3431.219512195123, warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals( 3431.219512195123, warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); break; case AverageSpeed: - Assert.assertEquals(detailedPetrolFactor[SAT_INDEX]*(linkLength/1000.), warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(detailedPetrolFactor[SAT_INDEX]*(linkLength/1000.), warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); break; default: throw new IllegalStateException( "Unexpected value: " + emissionsComputationMethod ); @@ -192,18 +184,18 @@ public void testTrafficSituations() { actualSpeed = avgPassengerCarSpeed[SG_INDEX]; travelTime = linkLength/actualSpeed; warmEmissions = weam.checkVehicleInfoAndCalculateWarmEmissions(vehicle, pcLink, travelTime*3.6); - Assert.assertEquals(detailedPetrolFactor[SG_INDEX]*(linkLength/1000.), warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(detailedPetrolFactor[SG_INDEX]*(linkLength/1000.), warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); actualSpeed = avgPassengerCarSpeed[SG_INDEX] + 5; travelTime = linkLength/actualSpeed; warmEmissions = weam.checkVehicleInfoAndCalculateWarmEmissions(vehicle, pcLink, travelTime*3.6); switch( emissionsComputationMethod ) { case StopAndGoFraction: - Assert.assertEquals(11715.609756097561, warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(11715.609756097561, warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); break; case AverageSpeed: - Assert.assertEquals(detailedPetrolFactor[SAT_INDEX]*(linkLength/1000.), warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); + Assertions.assertEquals(detailedPetrolFactor[SAT_INDEX]*(linkLength/1000.), warmEmissions.get( NOx ), MatsimTestUtils.EPSILON ); break; default: throw new IllegalStateException( "Unexpected value: " + emissionsComputationMethod ); @@ -214,10 +206,10 @@ public void testTrafficSituations() { actualSpeed = avgPassengerCarSpeed[SG_INDEX] - 5; travelTime = linkLength / actualSpeed; warmEmissions = weam.checkVehicleInfoAndCalculateWarmEmissions(vehicle, pcLink, travelTime * 3.6); - Assert.assertEquals(detailedPetrolFactor[SG_INDEX] * (linkLength / 1000.), warmEmissions.get(NOx), MatsimTestUtils.EPSILON); + Assertions.assertEquals(detailedPetrolFactor[SG_INDEX] * (linkLength / 1000.), warmEmissions.get(NOx), MatsimTestUtils.EPSILON); //results should be equal here, because in both cases only the s&g value is relevant (0% freeflow, 100% stop&go). - Assert.assertEquals(20000, warmEmissions.get(NOx), MatsimTestUtils.EPSILON); + Assertions.assertEquals(20000, warmEmissions.get(NOx), MatsimTestUtils.EPSILON); } } diff --git a/contribs/integration/src/test/java/org/matsim/integration/weekly/fundamentaldiagram/CreateAutomatedFDTest.java b/contribs/integration/src/test/java/org/matsim/integration/weekly/fundamentaldiagram/CreateAutomatedFDTest.java index a2bcc7ed20b..2d6b1fffa60 100644 --- a/contribs/integration/src/test/java/org/matsim/integration/weekly/fundamentaldiagram/CreateAutomatedFDTest.java +++ b/contribs/integration/src/test/java/org/matsim/integration/weekly/fundamentaldiagram/CreateAutomatedFDTest.java @@ -30,6 +30,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; +import java.util.stream.Stream; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -45,9 +46,9 @@ import org.jfree.data.xy.XYSeriesCollection; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -91,64 +92,49 @@ * @author amit */ -@RunWith(Parameterized.class) public class CreateAutomatedFDTest { - - /** - * Constructor. Even if it does not look like one. - */ - public CreateAutomatedFDTest(LinkDynamics linkDynamics, TrafficDynamics trafficDynamics) { - this.linkDynamics = linkDynamics; - this.trafficDynamics = trafficDynamics; - this.travelModes = new String [] {"car","bike"}; - } - - private LinkDynamics linkDynamics; - private TrafficDynamics trafficDynamics; private final Map,String> person2Mode = new HashMap<>(); - @Parameters(name = "{index}: LinkDynamics == {0}; Traffic dynamics == {1};") - // the convention is that the output of the method marked by "@Parameters" is taken as input to the constructor - // before running each test. kai, jul'16 - public static Collection createFds() { - int combos = LinkDynamics.values().length * TrafficDynamics.values().length ; - Object [][] combos2run = new Object [combos][2]; // #ld x #td x #params - int index = 0; + public static Stream arguments() { + List result = new LinkedList<>(); for (LinkDynamics ld : LinkDynamics.values()) { for (TrafficDynamics td : TrafficDynamics.values()) { - combos2run[index] = new Object [] {ld, td}; - index++; + result.add(Arguments.of(ld, td)); } } - return Arrays.asList(combos2run); + return result.stream(); } - @Test - void fdsCarTruck(){ + @ParameterizedTest + @MethodSource("arguments") + void fdsCarTruck(LinkDynamics linkDynamics, TrafficDynamics trafficDynamics){ this.travelModes = new String [] {"car","truck"}; - run(false); + run(false, linkDynamics, trafficDynamics); } - @Test - void fdsCarBike(){ - run(false); + @ParameterizedTest + @MethodSource("arguments") + void fdsCarBike(LinkDynamics linkDynamics, TrafficDynamics trafficDynamics){ + run(false,linkDynamics, trafficDynamics); } - @Test - void fdsCarBikeFastCapacityUpdate(){ - run(true); + @ParameterizedTest + @MethodSource("arguments") + void fdsCarBikeFastCapacityUpdate(LinkDynamics linkDynamics, TrafficDynamics trafficDynamics){ + run(true, linkDynamics, trafficDynamics); } - @Test - void fdsCarOnly(){ + @ParameterizedTest + @MethodSource("arguments") + void fdsCarOnly(LinkDynamics linkDynamics, TrafficDynamics trafficDynamics){ this.travelModes = new String [] {"car"}; - run(false); + run(false, linkDynamics, trafficDynamics); } @RegisterExtension private MatsimTestUtils helper = new MatsimTestUtils(); - private String [] travelModes; + private String [] travelModes = new String [] {"car","bike"}; public final Id flowDynamicsMeasurementLinkId = Id.createLinkId(0); private Map modeVehicleTypes; private Map, TravelModesFlowDynamicsUpdator> mode2FlowData; @@ -156,7 +142,7 @@ void fdsCarOnly(){ private final static Logger LOG = LogManager.getLogger(CreateAutomatedFDTest.class); - private void run(final boolean isUsingFastCapacityUpdate) { + private void run(final boolean isUsingFastCapacityUpdate, LinkDynamics linkDynamics, TrafficDynamics trafficDynamics) { MatsimRandom.reset(); @@ -675,13 +661,13 @@ private void updateFlow900(double nowTime, double pcuVeh){ } else { flowTableReset(); } - this.flowTime = new Double(nowTime); + this.flowTime = nowTime; } updateLastXFlows900(); } private void updateLastXFlows900(){ - Double nowFlow = new Double(this.getCurrentHourlyFlow()); + Double nowFlow = this.getCurrentHourlyFlow(); for (int i=NUMBER_OF_MEMORIZED_FLOWS-2; i>=0; i--){ this.lastXFlows900.set(i+1, this.lastXFlows900.get(i).doubleValue()); } diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxyIT.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxyIT.java index abd3e9a34d0..6d17839c44c 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxyIT.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxyIT.java @@ -20,7 +20,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.population.Population; @@ -37,7 +37,7 @@ public class RunWithParkingProxyIT { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); @Test - @Ignore + @Disabled void testMain(){ RunWithParkingProxy.main( new String []{ IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "chessboard" ), "config.xml" ).toString() , "--config:controler.outputDirectory=" + utils.getOutputDirectory() diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java index 6860c74bd76..4e81fc7628a 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java @@ -10,14 +10,15 @@ import java.util.Collections; import java.util.LinkedList; import java.util.List; +import java.util.stream.Stream; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -58,7 +59,6 @@ @author */ -@RunWith(Parameterized.class) public class SignalsAndLanesOsmNetworkReaderTest { private static final Logger log = LogManager.getLogger(SignalsAndLanesOsmNetworkReaderTest.class); @@ -66,30 +66,19 @@ public class SignalsAndLanesOsmNetworkReaderTest { @RegisterExtension public MatsimTestUtils matsimTestUtils = new MatsimTestUtils(); - @Parameterized.Parameters - public static Collection data() { - Object[][] data = new Object[][]{{true, true, true}, - {true, true, false}, - {true, false, true}, - {false, true, true}, - {true, false, false}, - {false, true, false}, - {false, false, true}, - {false, false, false},}; - return Arrays.asList(data); + public static Stream arguments() { + return Stream.of( + Arguments.of(true, true, true), + Arguments.of(true, true, false), + Arguments.of(true, false, true), + Arguments.of(false, true, true), + Arguments.of(true, false, false), + Arguments.of(false, true, false), + Arguments.of(false, false, true), + Arguments.of(false, false, false) + ); } - @Parameterized.Parameter - public boolean setMergeOnewaySignalSystems; - @Parameterized.Parameter(1) - public boolean setAllowUTurnAtLeftLaneOnly; - @Parameterized.Parameter(2) - public boolean setMakePedestrianSignals; - - - - - private static void writeOsmData(Collection nodes, Collection ways, Path file) { try (OutputStream outputStream = Files.newOutputStream(file)) { @@ -177,8 +166,9 @@ public OsmData constructSignalisedJunction(){ // @SuppressWarnings("ConstantConditions") - @Test - void singleJunction(){ + @ParameterizedTest + @MethodSource("arguments") + void singleJunction(boolean setMergeOnewaySignalSystems, boolean setAllowUTurnAtLeftLaneOnly, boolean setMakePedestrianSignals){ OsmData osmData = constructSignalisedJunction(); Path file = Paths.get(matsimTestUtils.getOutputDirectory(), "singleJunction.xml"); writeOsmData(osmData.getNodes(),osmData.getWays(),file); @@ -239,8 +229,9 @@ void singleJunction(){ Assertions.assertEquals(8, signals, "Assert number of Signals"); } - @Test - void singleJunctionWithBoundingBox(){ + @ParameterizedTest + @MethodSource("arguments") + void singleJunctionWithBoundingBox(boolean setMergeOnewaySignalSystems, boolean setAllowUTurnAtLeftLaneOnly, boolean setMakePedestrianSignals){ OsmData osmData = constructSignalisedJunction(); Path file = Paths.get(matsimTestUtils.getOutputDirectory(), "singleJunction.xml"); writeOsmData(osmData.getNodes(),osmData.getWays(),file); @@ -303,8 +294,9 @@ void singleJunctionWithBoundingBox(){ Assertions.assertEquals(8, signals, "Assert number of Signals"); } - @Test - void singleJunctionBadBoundingBox(){ + @ParameterizedTest + @MethodSource("arguments") + void singleJunctionBadBoundingBox(boolean setMergeOnewaySignalSystems, boolean setAllowUTurnAtLeftLaneOnly, boolean setMakePedestrianSignals){ OsmData osmData = constructSignalisedJunction(); Path file = Paths.get(matsimTestUtils.getOutputDirectory(), "singleJunction.xml"); writeOsmData(osmData.getNodes(),osmData.getWays(),file); @@ -360,8 +352,9 @@ void singleJunctionBadBoundingBox(){ } } - @Test - void berlinSnippet(){ + @ParameterizedTest + @MethodSource("arguments") + void berlinSnippet(boolean setMergeOnewaySignalSystems, boolean setAllowUTurnAtLeftLaneOnly, boolean setMakePedestrianSignals){ Path inputfile = Paths.get(matsimTestUtils.getClassInputDirectory()); inputfile = Paths.get(inputfile.toString(),"berlinSnippet.osm.gz"); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/HighestWeightSelectorTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/HighestWeightSelectorTest.java index 9962f22480c..e59150830b7 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/HighestWeightSelectorTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/HighestWeightSelectorTest.java @@ -21,25 +21,23 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Stream; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; -import org.matsim.api.core.v01.population.Plan; import org.matsim.core.population.PersonUtils; import org.matsim.core.population.PopulationUtils; import org.matsim.contrib.socnetsim.framework.cliques.Clique; @@ -51,13 +49,10 @@ /** * @author thibautd */ -@RunWith(Parameterized.class) public class HighestWeightSelectorTest { private static final Logger log = LogManager.getLogger(HighestWeightSelectorTest.class); - private final Fixture fixture; - public static class Fixture { final String name; final ReplanningGroup group; @@ -85,29 +80,21 @@ public Fixture( } } - // XXX the SAME instance is used for all tests! - // should ot be a problem, but this is contrary to the idea of "fixture" - public HighestWeightSelectorTest(final Fixture fixture) { - this.fixture = fixture; - log.info( "fixture "+fixture.name ); - } - - @Parameterized.Parameters - public static Collection fixtures() { - return Arrays.asList( - new Fixture[]{createIndividualPlans()}, - new Fixture[]{createFullyJointPlans()}, - new Fixture[]{createPartiallyJointPlansOneSelectedJp()}, - new Fixture[]{createPartiallyJointPlansTwoSelectedJps()}, - new Fixture[]{createPartiallyJointPlansMessOfJointPlans()}, - new Fixture[]{createPartiallyJointPlansNoSelectedJp()}, - new Fixture[]{createOneBigJointPlanDifferentNPlansPerAgent()}, - new Fixture[]{createOneBigJointPlanDifferentNPlansPerAgent2()}, - new Fixture[]{createOneBigJointPlanDifferentNPlansPerAgentWithNullScores()}, - new Fixture[]{createPlanWithDifferentSolutionIfBlocked()}, - new Fixture[]{createPlanWithNoSolutionIfBlocked()}, - new Fixture[]{createIndividualPlansWithSpecialForbidder()}, - new Fixture[]{createDifferentForbidGroupsPerJointPlan()}); + public static Stream arguments() { + return Stream.of( + createIndividualPlans(), + createFullyJointPlans(), + createPartiallyJointPlansOneSelectedJp(), + createPartiallyJointPlansTwoSelectedJps(), + createPartiallyJointPlansMessOfJointPlans(), + createPartiallyJointPlansNoSelectedJp(), + createOneBigJointPlanDifferentNPlansPerAgent(), + createOneBigJointPlanDifferentNPlansPerAgent2(), + createOneBigJointPlanDifferentNPlansPerAgentWithNullScores(), + createPlanWithDifferentSolutionIfBlocked(), + createPlanWithNoSolutionIfBlocked(), + createIndividualPlansWithSpecialForbidder(), + createDifferentForbidGroupsPerJointPlan()); } // ///////////////////////////////////////////////////////////////////////// @@ -1232,27 +1219,31 @@ public void setupLogging() { // ///////////////////////////////////////////////////////////////////////// // Tests // ///////////////////////////////////////////////////////////////////////// - @Test - void testSelectedPlansNonBlocking() throws Exception { - testSelectedPlans( false , false ); + @ParameterizedTest + @MethodSource("arguments") + void testSelectedPlansNonBlocking(Fixture fixture) throws Exception { + testSelectedPlans( fixture, false , false ); } - @Test - void testSelectedPlansForbidding() throws Exception { - testSelectedPlans( false , true ); + @ParameterizedTest + @MethodSource("arguments") + void testSelectedPlansForbidding(Fixture fixture) throws Exception { + testSelectedPlans( fixture, false , true ); } - @Test - void testSelectedPlansBlocking() throws Exception { - testSelectedPlans( true , false ); + @ParameterizedTest + @MethodSource("arguments") + void testSelectedPlansBlocking(Fixture fixture) throws Exception { + testSelectedPlans( fixture, true , false ); } /** * Check that plans are not removed from the plans DB in the selection process, * particularly when pruning unplausible plans. */ - @Test - void testNoSideEffects() throws Exception { + @ParameterizedTest + @MethodSource("arguments") + void testNoSideEffects(Fixture fixture) throws Exception { HighestScoreSumSelector selector = new HighestScoreSumSelector( new EmptyIncompatiblePlansIdentifierFactory(), @@ -1282,6 +1273,7 @@ void testNoSideEffects() throws Exception { } private void testSelectedPlans( + Fixture fixture, final boolean blocking, final boolean forbidding) { if ( blocking && forbidding ) throw new UnsupportedOperationException(); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/CoalitionSelectorTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/CoalitionSelectorTest.java index 2209f10164b..fc161bc7cef 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/CoalitionSelectorTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/coalitionselector/CoalitionSelectorTest.java @@ -26,15 +26,16 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; -import org.matsim.api.core.v01.population.Plan; import org.matsim.core.population.PersonUtils; import org.matsim.core.population.PopulationUtils; import org.matsim.contrib.socnetsim.framework.population.JointPlan; @@ -45,10 +46,7 @@ /** * @author thibautd */ -@RunWith(Parameterized.class) public class CoalitionSelectorTest { - private final FixtureFactory fixtureFactory; - public interface FixtureFactory { public Fixture create(); } @@ -71,13 +69,8 @@ public Fixture( } } - public CoalitionSelectorTest(final FixtureFactory fixture) { - this.fixtureFactory = fixture; - } - - @Parameterized.Parameters - public static Collection fixtures() { - return toArgList( + public static Stream arguments() { + return Stream.of( new FixtureFactory() { @Override public Fixture create() { @@ -200,13 +193,6 @@ public Fixture create() { } - private static Collection toArgList(final FixtureFactory... args) { - final List list = new ArrayList(); - - for ( FixtureFactory arg : args ) list.add( new FixtureFactory[]{ arg } ); - return list; - } - // ///////////////////////////////////////////////////////////////////////// // fixtures management // ///////////////////////////////////////////////////////////////////////// @@ -214,8 +200,9 @@ private static Collection toArgList(final FixtureFactory... ar // ///////////////////////////////////////////////////////////////////////// // Tests // ///////////////////////////////////////////////////////////////////////// - @Test - void testSelectedPlans() { + @ParameterizedTest + @MethodSource("arguments") + void testSelectedPlans(FixtureFactory fixtureFactory) { final Fixture fixture = fixtureFactory.create(); final CoalitionSelector selector = new CoalitionSelector(); diff --git a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java index 89d9446b529..1cb5418e60e 100644 --- a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java +++ b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java @@ -64,7 +64,6 @@ import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup.IntermodalAccessEgressParameterSet; -//@RunWith(Parameterized.class) public class PtAlongALine2Test { private static final Logger log = LogManager.getLogger(PtAlongALine2Test.class); diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java index 64755202e05..0173d5e8552 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java @@ -1,8 +1,9 @@ package playground.vsp.cadyts.marginals; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -37,33 +38,19 @@ import jakarta.inject.Inject; import java.util.*; +import java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -@RunWith(Parameterized.class) public class ModalDistanceAndCountsCadytsIT { - - @Parameterized.Parameters(name = "{index}: countsWeight == {0}; modalDistanceWeight == {1};") - public static Collection parameterObjects() { - return Arrays.asList(new Object[][]{ - {150.0, 0.0}, - {0.0, 150.0}, - {150.0, 150.0} - }); + public static Stream arguments() { + return Stream.of(Arguments.of(0.0, 150.0), Arguments.of(150.0, 0.0), Arguments.of(150.0, 150.0)); } @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - private double countsWeight; - private double modalDistanceWeight; - - public ModalDistanceAndCountsCadytsIT(double countsWeight, double modalDistanceWeight) { - this.modalDistanceWeight = modalDistanceWeight; - this.countsWeight = countsWeight; - } - private static DistanceDistribution createDistanceDistribution() { DistanceDistribution result = new DistanceDistribution(); @@ -252,8 +239,9 @@ private static Plan createPlan(String mode, String endLink, Network network, Pop * One with mode car and one with mode bike. The selected plan is the car plan. Now, the desired distance distribution * is set to have an equal share of car and bike users. The accepted error in the test is 5%, due to stochastic fuzziness */ - @Test - void test() { + @ParameterizedTest + @MethodSource("arguments") + void test(double countsWeight, double modalDistanceWeight) { Config config = createConfig(); CadytsConfigGroup cadytsConfigGroup = new CadytsConfigGroup(); @@ -342,16 +330,16 @@ public ScoringFunction createNewScoringFunction(Person person) { modalDistanceCount.merge(mode + "_" + distance, 1, Integer::sum); } - if (this.modalDistanceWeight > 0 && this.countsWeight == 0) { + if (modalDistanceWeight > 0 && countsWeight == 0) { // don't know how to get a better accuracy than 8% assertEquals(100, modalDistanceCount.get("car_2050.0"), 80); assertEquals(100, modalDistanceCount.get("car_2150.0"), 80); assertEquals(400, modalDistanceCount.get("bike_2050.0"), 80); assertEquals(400, modalDistanceCount.get("bike_2150.0"), 80); - } else if (this.modalDistanceWeight == 0 && this.countsWeight > 0) { + } else if (modalDistanceWeight == 0 && countsWeight > 0) { assertTrue(modalDistanceCount.get("car_2250.0") > 500, "expected more than 500 car trips on the long route but the number of trips was " + modalDistanceCount.get("car_2250.0")); // don't know. one would assume a stronger impact when only running the cadyts count correction but there isn't - } else if (this.modalDistanceWeight > 0 && this.countsWeight > 0) { + } else if (modalDistanceWeight > 0 && countsWeight > 0) { /* This assumes that counts have a higher impact than distance distributions * (because counts request 1000 on car_2250 and the distance distribution requests 100 on car_2050 and car_2150 but 0 on car_2250). * Probably this should rather depend on the weight that is set for counts and distance distributions... diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java b/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java index 88478e19bb8..ff8e7c8ca99 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java @@ -36,9 +36,8 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -75,25 +74,11 @@ import com.google.inject.Provider; -@RunWith(Parameterized.class) public class ControlerIT { private final static Logger log = LogManager.getLogger(ControlerIT.class); @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - private final boolean isUsingFastCapacityUpdate; - - public ControlerIT(boolean isUsingFastCapacityUpdate) { - this.isUsingFastCapacityUpdate = isUsingFastCapacityUpdate; - } - - @Parameters(name = "{index}: isUsingfastCapacityUpdate == {0}") - public static Collection parameterObjects () { - Object [] capacityUpdates = new Object [] { false, true }; - return Arrays.asList(capacityUpdates); - // yyyy I am not sure why it is doing this ... it is necessary to do this around the qsim, but why here? kai, aug'16 - } - @Test void testScenarioLoading() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); @@ -155,8 +140,9 @@ void testConstructor_EventsManagerTypeImmutable() { * * @author mrieser */ - @Test - void testTravelTimeCalculation() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testTravelTimeCalculation(boolean isUsingFastCapacityUpdate) { Fixture f = new Fixture(ConfigUtils.createConfig()); Config config = f.scenario.getConfig(); @@ -213,7 +199,7 @@ void testTravelTimeCalculation() { // - make sure we don't use threads, as they are not deterministic config.global().setNumberOfThreads(0); - config.qsim().setUsingFastCapacityUpdate(this.isUsingFastCapacityUpdate); + config.qsim().setUsingFastCapacityUpdate(isUsingFastCapacityUpdate); // Now run the simulation Controler controler = new Controler(f.scenario); @@ -248,12 +234,13 @@ void testTravelTimeCalculation() { * * @author mrieser */ - @Test - void testSetScoringFunctionFactory() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testSetScoringFunctionFactory(boolean isUsingFastCapacityUpdate) { final Config config = this.utils.loadConfig((String) null); config.controller().setLastIteration(0); - config.qsim().setUsingFastCapacityUpdate( this.isUsingFastCapacityUpdate ); + config.qsim().setUsingFastCapacityUpdate( isUsingFastCapacityUpdate ); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); // create a very simple network with one link only and an empty population @@ -296,8 +283,9 @@ public Mobsim get() { * * @author mrieser */ - @Test - void testCalcMissingRoutes() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testCalcMissingRoutes(boolean isUsingFastCapacityUpdate) { Config config = this.utils.loadConfig((String) null); Fixture f = new Fixture(config); @@ -343,7 +331,7 @@ void testCalcMissingRoutes() { // - make sure we don't use threads, as they are not deterministic config.global().setNumberOfThreads(1); - config.qsim().setUsingFastCapacityUpdate( this.isUsingFastCapacityUpdate ); + config.qsim().setUsingFastCapacityUpdate( isUsingFastCapacityUpdate ); // Now run the simulation Controler controler = new Controler(f.scenario); @@ -385,8 +373,9 @@ public Mobsim get() { * * @author mrieser */ - @Test - void testCalcMissingActLinks() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testCalcMissingActLinks(boolean isUsingFastCapacityUpdate) { Config config = this.utils.loadConfig((String) null); Fixture f = new Fixture(config); @@ -441,7 +430,7 @@ void testCalcMissingActLinks() { // - make sure we don't use threads, as they are not deterministic config.global().setNumberOfThreads(1); - config.qsim().setUsingFastCapacityUpdate( this.isUsingFastCapacityUpdate ); + config.qsim().setUsingFastCapacityUpdate( isUsingFastCapacityUpdate ); // Now run the simulation Controler controler = new Controler(f.scenario); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTransitTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTransitTest.java index 69c49091a42..5fba7f1c420 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTransitTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesTransitTest.java @@ -3,9 +3,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.ValueSource; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -67,22 +67,8 @@ * * @author mrieser / Simunto */ -@RunWith(Parameterized.class) public class HermesTransitTest { - private final boolean isDeterministic; - - public HermesTransitTest(boolean isDeterministic) { - this.isDeterministic = isDeterministic; - } - - @Parameters(name = "{index}: isDeterministic == {0}") - public static Collection parameterObjects () { - Object[] states = new Object[] { false, true }; - return Arrays.asList(states); - } - - protected static Hermes createHermes(MutableScenario scenario, EventsManager events) { PrepareForSimUtils.createDefaultPrepareForSim(scenario).run(); return new HermesBuilder().build(scenario, events); @@ -113,11 +99,12 @@ public void prepareTest() { /** * Makes sure Hermes works also when not all stop facilities are used by transit lines. */ - @Test - void testSuperflousStopFacilities() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testSuperflousStopFacilities(boolean isDeterministic) { Fixture f = new Fixture(); f.config.transit().setUseTransit(true); - f.config.hermes().setDeterministicPt(this.isDeterministic); + f.config.hermes().setDeterministicPt(isDeterministic); Vehicles ptVehicles = f.scenario.getTransitVehicles(); @@ -198,11 +185,12 @@ void testSuperflousStopFacilities() { /** * Makes sure Hermes works also when transit routes in different lines have the same Id */ - @Test - void testRepeatedRouteIds() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testRepeatedRouteIds(boolean isDeterministic) { Fixture f = new Fixture(); f.config.transit().setUseTransit(true); - f.config.hermes().setDeterministicPt(this.isDeterministic); + f.config.hermes().setDeterministicPt(isDeterministic); Vehicles ptVehicles = f.scenario.getTransitVehicles(); @@ -300,11 +288,12 @@ void testRepeatedRouteIds() { * Makes sure Hermes works with TransitRoutes where two successive stops are on the same link. * Originally, this resulted in wrong events because there was an exception that there is at most one stop per link. */ - @Test - void testConsecutiveStopsWithSameLink_1() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testConsecutiveStopsWithSameLink_1(boolean isDeterministic) { Fixture f = new Fixture(); f.config.transit().setUseTransit(true); - f.config.hermes().setDeterministicPt(this.isDeterministic); + f.config.hermes().setDeterministicPt(isDeterministic); Vehicles ptVehicles = f.scenario.getTransitVehicles(); @@ -393,11 +382,12 @@ void testConsecutiveStopsWithSameLink_1() { * Originally, this resulted in problems as the distance between the stops was 0 meters, given they are on the same link, * and this 0 meters than resulted in infinite values somewhere later on. */ - @Test - void testConsecutiveStopsWithSameLink_2() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testConsecutiveStopsWithSameLink_2(boolean isDeterministic) { Fixture f = new Fixture(); f.config.transit().setUseTransit(true); - f.config.hermes().setDeterministicPt(this.isDeterministic); + f.config.hermes().setDeterministicPt(isDeterministic); Vehicles ptVehicles = f.scenario.getTransitVehicles(); @@ -486,12 +476,13 @@ void testConsecutiveStopsWithSameLink_2() { /** * Makes sure Hermes does not produce exceptions when the configured end time is before the latest transit event */ - @Test - void testEarlyEnd() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testEarlyEnd(boolean isDeterministic) { double baseTime = 30 * 3600 - 10; // HERMES has a default of 30:00:00 as end time, so let's start later Fixture f = new Fixture(); f.config.transit().setUseTransit(true); - f.config.hermes().setDeterministicPt(this.isDeterministic); + f.config.hermes().setDeterministicPt(isDeterministic); Vehicles ptVehicles = f.scenario.getTransitVehicles(); @@ -557,11 +548,12 @@ void testEarlyEnd() { /** * Makes sure Hermes correctly handles strange transit routes with some links before the first stop is served. */ - @Test - void testLinksAtRouteStart() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testLinksAtRouteStart(boolean isDeterministic) { Fixture f = new Fixture(); f.config.transit().setUseTransit(true); - f.config.hermes().setDeterministicPt(this.isDeterministic); + f.config.hermes().setDeterministicPt(isDeterministic); Vehicles ptVehicles = f.scenario.getTransitVehicles(); @@ -627,11 +619,12 @@ void testLinksAtRouteStart() { /** * In some cases, the time information of linkEnter/linkLeave events was wrong. */ - @Test - void testDeterministicCorrectTiming() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testDeterministicCorrectTiming(boolean isDeterministic) { Fixture f = new Fixture(); f.config.transit().setUseTransit(true); - f.config.hermes().setDeterministicPt(this.isDeterministic); + f.config.hermes().setDeterministicPt(isDeterministic); Vehicles ptVehicles = f.scenario.getTransitVehicles(); @@ -716,47 +709,48 @@ void testDeterministicCorrectTiming() { Assertions.assertEquals(3, arrivesAtFacilityEvents.size(), "wrong number of VehicleArrivesAtFacilityEvents."); Assertions.assertEquals(3, departsAtFacilityEvents.size(), "wrong number of VehicleDepartsAtFacilityEvents."); - if (this.isDeterministic) Assertions.assertEquals(997.0, transitDriverStartsEvents.get(0).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(997.0, transitDriverStartsEvents.get(0).getTime(), 1e-8); - if (this.isDeterministic) Assertions.assertEquals(998.0, arrivesAtFacilityEvents.get(0).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(998.0, arrivesAtFacilityEvents.get(0).getTime(), 1e-8); Assertions.assertEquals(stop1.getId(), arrivesAtFacilityEvents.get(0).getFacilityId()); - if (this.isDeterministic) Assertions.assertEquals(1000.0, departsAtFacilityEvents.get(0).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1000.0, departsAtFacilityEvents.get(0).getTime(), 1e-8); Assertions.assertEquals(stop1.getId(), departsAtFacilityEvents.get(0).getFacilityId()); - if (this.isDeterministic) Assertions.assertEquals(1001.0, linkLeaveEvents.get(0).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1001.0, linkLeaveEvents.get(0).getTime(), 1e-8); Assertions.assertEquals(f.link1.getId(), linkLeaveEvents.get(0).getLinkId()); - if (this.isDeterministic) Assertions.assertEquals(1001.0, linkEnterEvents.get(0).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1001.0, linkEnterEvents.get(0).getTime(), 1e-8); Assertions.assertEquals(f.link2.getId(), linkEnterEvents.get(0).getLinkId()); - if (this.isDeterministic) Assertions.assertEquals(1251.0, linkLeaveEvents.get(1).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1251.0, linkLeaveEvents.get(1).getTime(), 1e-8); Assertions.assertEquals(f.link2.getId(), linkLeaveEvents.get(1).getLinkId()); - if (this.isDeterministic) Assertions.assertEquals(1251.0, linkEnterEvents.get(1).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1251.0, linkEnterEvents.get(1).getTime(), 1e-8); Assertions.assertEquals(f.link3.getId(), linkEnterEvents.get(1).getLinkId()); - if (this.isDeterministic) Assertions.assertEquals(1298.0, arrivesAtFacilityEvents.get(1).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1298.0, arrivesAtFacilityEvents.get(1).getTime(), 1e-8); Assertions.assertEquals(stop2.getId(), arrivesAtFacilityEvents.get(1).getFacilityId()); - if (this.isDeterministic) Assertions.assertEquals(1300.0, departsAtFacilityEvents.get(1).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1300.0, departsAtFacilityEvents.get(1).getTime(), 1e-8); Assertions.assertEquals(stop2.getId(), departsAtFacilityEvents.get(1).getFacilityId()); - if (this.isDeterministic) Assertions.assertEquals(1598.0, arrivesAtFacilityEvents.get(2).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1598.0, arrivesAtFacilityEvents.get(2).getTime(), 1e-8); Assertions.assertEquals(stop3.getId(), arrivesAtFacilityEvents.get(2).getFacilityId()); - if (this.isDeterministic) Assertions.assertEquals(1600.0, departsAtFacilityEvents.get(2).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1600.0, departsAtFacilityEvents.get(2).getTime(), 1e-8); Assertions.assertEquals(stop3.getId(), departsAtFacilityEvents.get(2).getFacilityId()); } /** * Tests that event times are correct when a transit route starts with some links before arriving at the first stop. */ - @Test - void testDeterministicCorrectTiming_initialLinks() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testDeterministicCorrectTiming_initialLinks(boolean isDeterministic) { Fixture f = new Fixture(); f.config.transit().setUseTransit(true); - f.config.hermes().setDeterministicPt(this.isDeterministic); + f.config.hermes().setDeterministicPt(isDeterministic); Vehicles ptVehicles = f.scenario.getTransitVehicles(); @@ -843,39 +837,40 @@ void testDeterministicCorrectTiming_initialLinks() { Assertions.assertEquals(1000.0, transitDriverStartsEvents.get(0).getTime(), 1e-8); - if (this.isDeterministic) Assertions.assertEquals(1001.0, linkLeaveEvents.get(0).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1001.0, linkLeaveEvents.get(0).getTime(), 1e-8); Assertions.assertEquals(f.link1.getId(), linkLeaveEvents.get(0).getLinkId()); - if (this.isDeterministic) Assertions.assertEquals(1001.0, linkEnterEvents.get(0).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1001.0, linkEnterEvents.get(0).getTime(), 1e-8); Assertions.assertEquals(f.link2.getId(), linkEnterEvents.get(0).getLinkId()); - if (this.isDeterministic) Assertions.assertEquals(1058.0, arrivesAtFacilityEvents.get(0).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1058.0, arrivesAtFacilityEvents.get(0).getTime(), 1e-8); Assertions.assertEquals(stop2.getId(), arrivesAtFacilityEvents.get(0).getFacilityId()); - if (this.isDeterministic) Assertions.assertEquals(1060.0, departsAtFacilityEvents.get(0).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1060.0, departsAtFacilityEvents.get(0).getTime(), 1e-8); Assertions.assertEquals(stop2.getId(), departsAtFacilityEvents.get(0).getFacilityId()); - if (this.isDeterministic) Assertions.assertEquals(1061.0, linkLeaveEvents.get(1).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1061.0, linkLeaveEvents.get(1).getTime(), 1e-8); Assertions.assertEquals(f.link2.getId(), linkLeaveEvents.get(1).getLinkId()); - if (this.isDeterministic) Assertions.assertEquals(1061.0, linkEnterEvents.get(1).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1061.0, linkEnterEvents.get(1).getTime(), 1e-8); Assertions.assertEquals(f.link3.getId(), linkEnterEvents.get(1).getLinkId()); - if (this.isDeterministic) Assertions.assertEquals(1598.0, arrivesAtFacilityEvents.get(1).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1598.0, arrivesAtFacilityEvents.get(1).getTime(), 1e-8); Assertions.assertEquals(stop3.getId(), arrivesAtFacilityEvents.get(1).getFacilityId()); - if (this.isDeterministic) Assertions.assertEquals(1600.0, departsAtFacilityEvents.get(1).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1600.0, departsAtFacilityEvents.get(1).getTime(), 1e-8); Assertions.assertEquals(stop3.getId(), departsAtFacilityEvents.get(1).getFacilityId()); } /** * Tests that everything is correct when a transit route ends with some links after arriving at the last stop. */ - @Test - void testTrailingLinksInRoute() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testTrailingLinksInRoute(boolean isDeterministic) { Fixture f = new Fixture(); f.config.transit().setUseTransit(true); - f.config.hermes().setDeterministicPt(this.isDeterministic); + f.config.hermes().setDeterministicPt(isDeterministic); Vehicles ptVehicles = f.scenario.getTransitVehicles(); @@ -962,37 +957,37 @@ void testTrailingLinksInRoute() { Assertions.assertEquals(2, departsAtFacilityEvents.size(), "wrong number of VehicleDepartsAtFacilityEvents."); Assertions.assertEquals(2, personLeavesVehicleEvents.size(), "wrong number of PersonLeavesVehicleEvents."); - if (this.isDeterministic) Assertions.assertEquals(997.0, transitDriverStartsEvents.get(0).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(997.0, transitDriverStartsEvents.get(0).getTime(), 1e-8); Id transitDriverId = transitDriverStartsEvents.get(0).getDriverId(); - if (this.isDeterministic) Assertions.assertEquals(998.0, arrivesAtFacilityEvents.get(0).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(998.0, arrivesAtFacilityEvents.get(0).getTime(), 1e-8); Assertions.assertEquals(stop1.getId(), arrivesAtFacilityEvents.get(0).getFacilityId()); - if (this.isDeterministic) Assertions.assertEquals(1000.0, departsAtFacilityEvents.get(0).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1000.0, departsAtFacilityEvents.get(0).getTime(), 1e-8); Assertions.assertEquals(stop1.getId(), departsAtFacilityEvents.get(0).getFacilityId()); - if (this.isDeterministic) Assertions.assertEquals(1001.0, linkLeaveEvents.get(0).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1001.0, linkLeaveEvents.get(0).getTime(), 1e-8); Assertions.assertEquals(f.link1.getId(), linkLeaveEvents.get(0).getLinkId()); - if (this.isDeterministic) Assertions.assertEquals(1001.0, linkEnterEvents.get(0).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1001.0, linkEnterEvents.get(0).getTime(), 1e-8); Assertions.assertEquals(f.link2.getId(), linkEnterEvents.get(0).getLinkId()); - if (this.isDeterministic) Assertions.assertEquals(1298.0, arrivesAtFacilityEvents.get(1).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1298.0, arrivesAtFacilityEvents.get(1).getTime(), 1e-8); Assertions.assertEquals(stop2.getId(), arrivesAtFacilityEvents.get(1).getFacilityId()); - if (this.isDeterministic) Assertions.assertEquals(1299.0, personLeavesVehicleEvents.get(0).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1299.0, personLeavesVehicleEvents.get(0).getTime(), 1e-8); Assertions.assertEquals(person.getId(), personLeavesVehicleEvents.get(0).getPersonId()); - if (this.isDeterministic) Assertions.assertEquals(1300.0, departsAtFacilityEvents.get(1).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1300.0, departsAtFacilityEvents.get(1).getTime(), 1e-8); Assertions.assertEquals(stop2.getId(), departsAtFacilityEvents.get(1).getFacilityId()); - if (this.isDeterministic) Assertions.assertEquals(1301.0, linkLeaveEvents.get(1).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1301.0, linkLeaveEvents.get(1).getTime(), 1e-8); Assertions.assertEquals(f.link2.getId(), linkLeaveEvents.get(1).getLinkId()); - if (this.isDeterministic) Assertions.assertEquals(1301.0, linkEnterEvents.get(1).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1301.0, linkEnterEvents.get(1).getTime(), 1e-8); Assertions.assertEquals(f.link3.getId(), linkEnterEvents.get(1).getLinkId()); - if (this.isDeterministic) Assertions.assertEquals(1312.0, personLeavesVehicleEvents.get(1).getTime(), 1e-8); + if (isDeterministic) Assertions.assertEquals(1312.0, personLeavesVehicleEvents.get(1).getTime(), 1e-8); Assertions.assertEquals(transitDriverId, personLeavesVehicleEvents.get(1).getPersonId()); } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/FlowStorageSpillbackTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/FlowStorageSpillbackTest.java index 7577f729919..a46bea6bb90 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/FlowStorageSpillbackTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/FlowStorageSpillbackTest.java @@ -27,9 +27,8 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -59,24 +58,11 @@ * @author ikaddoura * */ -@RunWith(Parameterized.class) public class FlowStorageSpillbackTest { @RegisterExtension private MatsimTestUtils testUtils = new MatsimTestUtils(); - private final boolean isUsingFastCapacityUpdate; - - public FlowStorageSpillbackTest(boolean isUsingFastCapacityUpdate) { - this.isUsingFastCapacityUpdate = isUsingFastCapacityUpdate; - } - - @Parameters(name = "{index}: isUsingfastCapacityUpdate == {0}") - public static Collection parameterObjects () { - Object [] capacityUpdates = new Object [] { false, true }; - return Arrays.asList(capacityUpdates); - } - private EventsManager events; private Id testAgent1 = Id.create("testAgent1", Person.class); @@ -89,13 +75,14 @@ public static Collection parameterObjects () { private Id linkId3 = Id.create("link3", Link.class); private Id linkId4 = Id.create("link4", Link.class); - @Test - final void testFlowCongestion(){ + @ParameterizedTest + @ValueSource(booleans = {false, true}) + final void testFlowCongestion(boolean isUsingFastCapacityUpdate){ Scenario sc = loadScenario(); setPopulation(sc); - sc.getConfig().qsim().setUsingFastCapacityUpdate(this.isUsingFastCapacityUpdate); + sc.getConfig().qsim().setUsingFastCapacityUpdate(isUsingFastCapacityUpdate); final List linkLeaveEvents = new ArrayList(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java index ac40a182b9d..b57ed217c3e 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java @@ -28,8 +28,9 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.ValueSource; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -72,25 +73,11 @@ * @author tthunig * */ -@RunWith(Parameterized.class) public class NodeTransitionTest { - @Parameterized.Parameters(name = "{index}: useFastCapUpdate == {0};") - public static Collection parameterObjects() { - return Arrays.asList(new Object[][]{ - {true}, - {false} - }); - } - - private boolean useFastCapUpdate; - - public NodeTransitionTest(boolean useFastCapUpdate) { - this.useFastCapUpdate = useFastCapUpdate; - } - - @Test - void testMergeSituationWithEmptyBufferAfterBufferRandomDistribution() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testMergeSituationWithEmptyBufferAfterBufferRandomDistribution(boolean useFastCapUpdate) { Scenario scenario = Fixture.createMergeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.emptyBufferAfterBufferRandomDistribution_dontBlockNode); scenario.getConfig().qsim().setUsingFastCapacityUpdate(useFastCapUpdate); @@ -157,8 +144,9 @@ void testMergeSituationWithEmptyBufferAfterBufferRandomDistribution() { Assertions.assertEquals(9./10, avgThroughputCongestedThreeLinks.get(Id.createLinkId("6_7")), delta, "Troughput on link 6_7 is wrong"); // 0.9285714285714286 } - @Test - void testMergeSituationWithMoveVehByVehRandomDistribution() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testMergeSituationWithMoveVehByVehRandomDistribution(boolean useFastCapUpdate) { Scenario scenario = Fixture.createMergeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.moveVehByVehRandomDistribution_dontBlockNode); scenario.getConfig().qsim().setUsingFastCapacityUpdate(useFastCapUpdate); @@ -232,8 +220,9 @@ void testMergeSituationWithMoveVehByVehRandomDistribution() { Assertions.assertEquals(41./50, avgThroughputCongestedThreeLinks.get(Id.createLinkId("6_7")), delta, "Troughput on link 6_7 is wrong"); // 0.8571428571428571 } - @Test - void testMergeSituationWithMoveVehByVehDeterministicPriorities() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testMergeSituationWithMoveVehByVehDeterministicPriorities(boolean useFastCapUpdate) { Scenario scenario = Fixture.createMergeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.moveVehByVehDeterministicPriorities_nodeBlockedWhenSingleOutlinkFull); // note: the deterministic node transition is only implemented for the case when the node is blocked as soon as one outgoing link is full @@ -301,8 +290,9 @@ void testMergeSituationWithMoveVehByVehDeterministicPriorities() { Assertions.assertEquals(2./5 * 2, avgThroughputCongestedThreeLinks.get(Id.createLinkId("6_7")), delta, "Troughput on link 6_7 is wrong"); // 0.8 } - @Test - void testBlockedNodeSituationWithEmptyBufferAfterBufferRandomDistribution() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testBlockedNodeSituationWithEmptyBufferAfterBufferRandomDistribution(boolean useFastCapUpdate) { Scenario scenario = Fixture.createBlockedNodeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.emptyBufferAfterBufferRandomDistribution_nodeBlockedWhenSingleOutlinkFull); scenario.getConfig().qsim().setUsingFastCapacityUpdate(useFastCapUpdate); @@ -382,8 +372,9 @@ void testBlockedNodeSituationWithEmptyBufferAfterBufferRandomDistribution() { Assertions.assertEquals(1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON, "Troughput on link 5_8 is wrong"); } - @Test - void testBlockedNodeSituationWithMoveVehByVehRandomDistribution() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testBlockedNodeSituationWithMoveVehByVehRandomDistribution(boolean useFastCapUpdate) { Scenario scenario = Fixture.createBlockedNodeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.moveVehByVehRandomDistribution_nodeBlockedWhenSingleOutlinkFull); scenario.getConfig().qsim().setUsingFastCapacityUpdate(useFastCapUpdate); @@ -464,8 +455,9 @@ void testBlockedNodeSituationWithMoveVehByVehRandomDistribution() { Assertions.assertEquals(1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON, "Troughput on link 5_8 is wrong"); } - @Test - void testBlockedNodeSituationWithMoveVehByVehDeterministicPriorities() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testBlockedNodeSituationWithMoveVehByVehDeterministicPriorities(boolean useFastCapUpdate) { Scenario scenario = Fixture.createBlockedNodeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.moveVehByVehDeterministicPriorities_nodeBlockedWhenSingleOutlinkFull); scenario.getConfig().qsim().setUsingFastCapacityUpdate(useFastCapUpdate); @@ -553,8 +545,9 @@ void testBlockedNodeSituationWithMoveVehByVehDeterministicPriorities() { * 2. correct storage capacity bounds for a time bin size smaller than 1 (see e.g. former bug in QueueWithBuffer calculateStorageCapacity); * 3. both streams are independently (because blockNode=false). */ - @Test - void testNodeTransitionWithTimeStepSizeSmallerOne() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testNodeTransitionWithTimeStepSizeSmallerOne(boolean useFastCapUpdate) { Scenario scenario = Fixture.createBlockedNodeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.emptyBufferAfterBufferRandomDistribution_dontBlockNode); scenario.getConfig().qsim().setTimeStepSize(0.5); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimTest.java index fcded837c33..e33947ee22f 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimTest.java @@ -21,19 +21,18 @@ package org.matsim.core.mobsim.qsim; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.stream.Stream; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.matsim.analysis.VolumesAnalyzer; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -95,28 +94,16 @@ import org.matsim.vehicles.VehicleType; import org.matsim.vehicles.VehicleUtils; -@RunWith(Parameterized.class) public class QSimTest { private final static Logger log = LogManager.getLogger(QSimTest.class); - private final boolean isUsingFastCapacityUpdate; - private final int numberOfThreads; - - public QSimTest(boolean isUsingFastCapacityUpdate, int numberOfThreads) { - this.isUsingFastCapacityUpdate = isUsingFastCapacityUpdate; - this.numberOfThreads = numberOfThreads; - } -// - @Parameters(name = "{index}: isUsingfastCapacityUpdate == {0}; numberOfThreads == {1};") - public static Collection parameterObjects () { - Object[][] capacityUpdates = new Object [][] { - new Object[] {true, 1}, - new Object[] {false, 1}, - new Object[] {true, 2}, - new Object[] {false, 2} - }; - return Arrays.asList(capacityUpdates); + public static Stream arguments () { + return Stream.of( + Arguments.of(true, 1), + Arguments.of(false, 1), + Arguments.of(true, 2), + Arguments.of(false, 2)); } private static QSim createQSim(MutableScenario scenario, EventsManager events) { @@ -143,8 +130,9 @@ private static QSim createQSim(Fixture f, EventsManager events) { * * @author mrieser */ - @Test - void testSingleAgent() { + @ParameterizedTest + @MethodSource("arguments") + void testSingleAgent(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add a single person with leg from link1 to link3 @@ -183,8 +171,9 @@ void testSingleAgent() { * @author mrieser * @author Kai Nagel */ - @Test - void testSingleAgentWithEndOnLeg() { + @ParameterizedTest + @MethodSource("arguments") + void testSingleAgentWithEndOnLeg(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add a single person with leg from link1 to link3 @@ -249,8 +238,9 @@ void testSingleAgentWithEndOnLeg() { * * @author mrieser */ - @Test - void testTwoAgent() { + @ParameterizedTest + @MethodSource("arguments") + void testTwoAgent(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add two persons with leg from link1 to link3, the first starting at 6am, the second at 7am @@ -290,8 +280,9 @@ void testTwoAgent() { * * @author mrieser */ - @Test - void testTeleportationSingleAgent() { + @ParameterizedTest + @MethodSource("arguments") + void testTeleportationSingleAgent(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add a single person with leg from link1 to link3 @@ -337,8 +328,9 @@ void testTeleportationSingleAgent() { * * @author cdobler */ - @Test - void testSingleAgentImmediateDeparture() { + @ParameterizedTest + @MethodSource("arguments") + void testSingleAgentImmediateDeparture(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add a single person with leg from link1 to link3 @@ -382,8 +374,9 @@ void testSingleAgentImmediateDeparture() { * * @author mrieser */ - @Test - void testSingleAgent_EmptyRoute() { + @ParameterizedTest + @MethodSource("arguments") + void testSingleAgent_EmptyRoute(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add a single person with leg from link1 to link1 @@ -459,8 +452,9 @@ void testSingleAgent_EmptyRoute() { * * @author mrieser */ - @Test - void testSingleAgent_LastLinkIsLoop() { + @ParameterizedTest + @MethodSource("arguments") + void testSingleAgent_LastLinkIsLoop(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); Link loopLink = NetworkUtils.createAndAddLink(f.network,Id.create("loop", Link.class), f.node4, f.node4, 100.0, 10.0, 500, 1 ); @@ -529,8 +523,9 @@ public void reset(final int iteration) { * * @author mrieser */ - @Test - void testAgentWithoutLeg() { + @ParameterizedTest + @MethodSource("arguments") + void testAgentWithoutLeg(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -556,8 +551,9 @@ void testAgentWithoutLeg() { * * @author mrieser */ - @Test - void testAgentWithoutLegWithEndtime() { + @ParameterizedTest + @MethodSource("arguments") + void testAgentWithoutLegWithEndtime(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -584,8 +580,9 @@ void testAgentWithoutLegWithEndtime() { * * @author mrieser */ - @Test - void testAgentWithLastActWithEndtime() { + @ParameterizedTest + @MethodSource("arguments") + void testAgentWithLastActWithEndtime(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -619,8 +616,9 @@ void testAgentWithLastActWithEndtime() { * * @author mrieser */ - @Test - void testFlowCapacityDriving() { + @ParameterizedTest + @MethodSource("arguments") + void testFlowCapacityDriving(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add a lot of persons with legs from link1 to link3, starting at 6:30 @@ -684,8 +682,9 @@ void testFlowCapacityDriving() { * * @author michaz */ - @Test - void testFlowCapacityDrivingFraction() { + @ParameterizedTest + @MethodSource("arguments") + void testFlowCapacityDrivingFraction(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); f.link2.setCapacity(900.0); // One vehicle every 4 seconds @@ -739,8 +738,9 @@ void testFlowCapacityDrivingFraction() { * * @author mrieser */ - @Test - void testFlowCapacityStarting() { + @ParameterizedTest + @MethodSource("arguments") + void testFlowCapacityStarting(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add a lot of persons with legs from link2 to link3 @@ -794,8 +794,9 @@ void testFlowCapacityStarting() { * * @author mrieser */ - @Test - void testFlowCapacityMixed() { + @ParameterizedTest + @MethodSource("arguments") + void testFlowCapacityMixed(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); // add a lot of persons with legs from link2 to link3 @@ -862,8 +863,9 @@ void testFlowCapacityMixed() { * * @author mrieser */ - @Test - void testVehicleTeleportationTrue() { + @ParameterizedTest + @MethodSource("arguments") + void testVehicleTeleportationTrue(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan plan = PersonUtils.createAndAddPlan(person, true); @@ -917,8 +919,9 @@ void testVehicleTeleportationTrue() { * * @author michaz */ - @Test - void testWaitingForCar() { + @ParameterizedTest + @MethodSource("arguments") + void testWaitingForCar(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); f.scenario.getConfig().qsim().setVehicleBehavior(QSimConfigGroup.VehicleBehavior.wait); f.scenario.getConfig().qsim().setEndTime(24.0 * 60.0 * 60.0); @@ -1012,8 +1015,9 @@ void testWaitingForCar() { * * @author mrieser */ - @Test - void testVehicleTeleportationFalse() { + @ParameterizedTest + @MethodSource("arguments") + void testVehicleTeleportationFalse(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); f.scenario.getConfig().qsim().setVehicleBehavior(QSimConfigGroup.VehicleBehavior.exception); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); @@ -1065,8 +1069,9 @@ void testVehicleTeleportationFalse() { * * @author mrieser */ - @Test - void testAssignedVehicles() { + @ParameterizedTest + @MethodSource("arguments") + void testAssignedVehicles(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); // do not add person to population, we'll do it ourselves for the test Plan plan = PersonUtils.createAndAddPlan(person, true); @@ -1121,8 +1126,9 @@ void testAssignedVehicles() { * * @author mrieser */ - @Test - void testCircleAsRoute() { + @ParameterizedTest + @MethodSource("arguments") + void testCircleAsRoute(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); Link link4 = NetworkUtils.createAndAddLink(f.network,Id.create(4, Link.class), f.node4, f.node1, 1000.0, 100.0, 6000, 1.0 ); // close the network @@ -1179,8 +1185,9 @@ void testCircleAsRoute() { * * @author mrieser */ - @Test - void testRouteWithEndLinkTwice() { + @ParameterizedTest + @MethodSource("arguments") + void testRouteWithEndLinkTwice(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); Link link4 = NetworkUtils.createAndAddLink(f.network,Id.create(4, Link.class), f.node4, f.node1, 1000.0, 100.0, 6000, 1.0 ); // close the network @@ -1240,12 +1247,13 @@ void testRouteWithEndLinkTwice() { * * @author mrieser */ - @Test - void testConsistentRoutes_WrongRoute() { + @ParameterizedTest + @MethodSource("arguments") + void testConsistentRoutes_WrongRoute(boolean isUsingFastCapacityUpdate, int numberOfThreads) { EventsManager events = EventsUtils.createEventsManager(); EnterLinkEventCounter counter = new EnterLinkEventCounter("6"); events.addHandler(counter); - LogCounter logger = runConsistentRoutesTestSim("1", "2 3", "5", events); // route should continue on link 4 + LogCounter logger = runConsistentRoutesTestSim("1", "2 3", "5", events, isUsingFastCapacityUpdate, numberOfThreads); // route should continue on link 4 Assertions.assertEquals(0, counter.getCounter()); // the agent should have been removed from the sim, so nobody travels there Assertions.assertTrue((logger.getWarnCount() + logger.getErrorCount()) > 0); // there should have been at least a warning } @@ -1256,12 +1264,13 @@ void testConsistentRoutes_WrongRoute() { * * @author mrieser */ - @Test - void testConsistentRoutes_WrongStartLink() { + @ParameterizedTest + @MethodSource("arguments") + void testConsistentRoutes_WrongStartLink(boolean isUsingFastCapacityUpdate, int numberOfThreads) { EventsManager events = EventsUtils.createEventsManager(); EnterLinkEventCounter counter = new EnterLinkEventCounter("6"); events.addHandler(counter); - LogCounter logger = runConsistentRoutesTestSim("2", "3 4", "5", events); // first act is on link 1, not 2 + LogCounter logger = runConsistentRoutesTestSim("2", "3 4", "5", events, isUsingFastCapacityUpdate, numberOfThreads); // first act is on link 1, not 2 Assertions.assertEquals(0, counter.getCounter()); // the agent should have been removed from the sim, so nobody travels there Assertions.assertTrue((logger.getWarnCount() + logger.getErrorCount()) > 0); // there should have been at least a warning } @@ -1272,12 +1281,13 @@ void testConsistentRoutes_WrongStartLink() { * * @author mrieser */ - @Test - void testConsistentRoutes_WrongEndLink() { + @ParameterizedTest + @MethodSource("arguments") + void testConsistentRoutes_WrongEndLink(boolean isUsingFastCapacityUpdate, int numberOfThreads) { EventsManager events = EventsUtils.createEventsManager(); EnterLinkEventCounter counter = new EnterLinkEventCounter("6"); events.addHandler(counter); - LogCounter logger = runConsistentRoutesTestSim("1", "2 3", "4", events); // second act is on link 5, not 4 + LogCounter logger = runConsistentRoutesTestSim("1", "2 3", "4", events, isUsingFastCapacityUpdate, numberOfThreads); // second act is on link 5, not 4 Assertions.assertEquals(0, counter.getCounter()); // the agent should have been removed from the sim, so nobody travels there Assertions.assertTrue((logger.getWarnCount() + logger.getErrorCount()) > 0); // there should have been at least a warning } @@ -1289,12 +1299,13 @@ void testConsistentRoutes_WrongEndLink() { * * @author mrieser */ - @Test - void testConsistentRoutes_ImpossibleRoute() { + @ParameterizedTest + @MethodSource("arguments") + void testConsistentRoutes_ImpossibleRoute(boolean isUsingFastCapacityUpdate, int numberOfThreads) { EventsManager events = EventsUtils.createEventsManager(); EnterLinkEventCounter counter = new EnterLinkEventCounter("6"); events.addHandler(counter); - LogCounter logger = runConsistentRoutesTestSim("1", "2 4", "5", events); // link 3 is missing + LogCounter logger = runConsistentRoutesTestSim("1", "2 4", "5", events,isUsingFastCapacityUpdate, numberOfThreads); // link 3 is missing Assertions.assertEquals(0, counter.getCounter()); // the agent should have been removed from the sim, so nobody travels there Assertions.assertTrue((logger.getWarnCount() + logger.getErrorCount()) > 0); // there should have been at least a warning } @@ -1305,29 +1316,32 @@ void testConsistentRoutes_ImpossibleRoute() { * * @author mrieser */ - @Test - void testConsistentRoutes_MissingRoute() { + @ParameterizedTest + @MethodSource("arguments") + void testConsistentRoutes_MissingRoute(boolean isUsingFastCapacityUpdate, int numberOfThreads) { EventsManager events = EventsUtils.createEventsManager(); EnterLinkEventCounter counter = new EnterLinkEventCounter("6"); events.addHandler(counter); - LogCounter logger = runConsistentRoutesTestSim("1", "", "5", events); // no links at all + LogCounter logger = runConsistentRoutesTestSim("1", "", "5", events, isUsingFastCapacityUpdate, numberOfThreads); // no links at all Assertions.assertEquals(0, counter.getCounter()); // the agent should have been removed from the sim, so nobody travels there Assertions.assertTrue((logger.getWarnCount() + logger.getErrorCount()) > 0); // there should have been at least a warning } - /** Prepares miscellaneous data for the testConsistentRoutes() tests: + /** + * Prepares miscellaneous data for the testConsistentRoutes() tests: * Creates a network of 6 links, and a population of one person driving from * link 1 to link 5, and then from link 5 to link 6. * - * @param startLinkId the start link of the route for the first leg - * @param linkIds the links the agent should travel along on the first leg - * @param endLinkId the end link of the route for the first leg - * @param events the Events object to be used by the simulation. + * @param startLinkId the start link of the route for the first leg + * @param linkIds the links the agent should travel along on the first leg + * @param endLinkId the end link of the route for the first leg + * @param events the Events object to be used by the simulation. + * @param isUsingFastCapacityUpdate + * @param numberOfThreads * @return A QueueSimulation which can be started immediately. - * * @author mrieser **/ - private LogCounter runConsistentRoutesTestSim(final String startLinkId, final String linkIds, final String endLinkId, final EventsManager events) { + private LogCounter runConsistentRoutesTestSim(final String startLinkId, final String linkIds, final String endLinkId, final EventsManager events, boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); /* enhance network */ @@ -1374,8 +1388,9 @@ private LogCounter runConsistentRoutesTestSim(final String startLinkId, final St return logger; } - @Test - void testStartAndEndTime() { + @ParameterizedTest + @MethodSource("arguments") + void testStartAndEndTime(boolean isUsingFastCapacityUpdate, int numberOfThreads) { final Config config = ConfigUtils.createConfig(); config.qsim().setUsingFastCapacityUpdate(isUsingFastCapacityUpdate); @@ -1440,8 +1455,9 @@ void testStartAndEndTime() { * * @author mrieser */ - @Test - void testCleanupSim_EarlyEnd() { + @ParameterizedTest + @MethodSource("arguments") + void testCleanupSim_EarlyEnd(boolean isUsingFastCapacityUpdate, int numberOfThreads) { MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); Config config = scenario.getConfig(); @@ -1538,8 +1554,9 @@ void testCleanupSim_EarlyEnd() { * * @author ikaddoura based on mrieser */ - @Test - void testFlowCapacityDrivingKinematicWavesWithFlowReductionCorrectionBehavior() { + @ParameterizedTest + @MethodSource("arguments") + void testFlowCapacityDrivingKinematicWavesWithFlowReductionCorrectionBehavior(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); f.config.qsim().setTrafficDynamics(TrafficDynamics.kinematicWaves); f.config.qsim().setInflowCapacitySetting(QSimConfigGroup.InflowCapacitySetting.INFLOW_FROM_FDIAG); @@ -1598,8 +1615,9 @@ void testFlowCapacityDrivingKinematicWavesWithFlowReductionCorrectionBehavior() * * @author ikaddoura based on mrieser */ - @Test - void testFlowCapacityDrivingKinematicWavesWithLaneIncreaseCorrectionBehavior() { + @ParameterizedTest + @MethodSource("arguments") + void testFlowCapacityDrivingKinematicWavesWithLaneIncreaseCorrectionBehavior(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); f.config.qsim().setTrafficDynamics(TrafficDynamics.kinematicWaves); f.config.qsim().setInflowCapacitySetting(QSimConfigGroup.InflowCapacitySetting.NR_OF_LANES_FROM_FDIAG); @@ -1658,8 +1676,9 @@ void testFlowCapacityDrivingKinematicWavesWithLaneIncreaseCorrectionBehavior() { * * @author tschlenther based on ikaddoura based on mrieser */ - @Test - void testFlowCapacityDrivingKinematicWavesWithInflowEqualToMaxCapForOneLane() { + @ParameterizedTest + @MethodSource("arguments") + void testFlowCapacityDrivingKinematicWavesWithInflowEqualToMaxCapForOneLane(boolean isUsingFastCapacityUpdate, int numberOfThreads) { Fixture f = new Fixture(isUsingFastCapacityUpdate, numberOfThreads); f.config.qsim().setTrafficDynamics(TrafficDynamics.kinematicWaves); f.config.qsim().setInflowCapacitySetting(QSimConfigGroup.InflowCapacitySetting.MAX_CAP_FOR_ONE_LANE); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java index f91acc6e562..ac787bb7de9 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java @@ -21,9 +21,9 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -54,6 +54,7 @@ import org.matsim.vehicles.VehiclesFactory; import java.util.*; +import java.util.stream.Stream; /** * A test to check the functionality of the VehicleSource. @@ -61,42 +62,20 @@ * @author amit */ -@RunWith(Parameterized.class) public class VehicleSourceTest { - - private final VehiclesSource vehiclesSource; - private final boolean usingPersonIdForMissingVehicleId; - - /** - * testing if there is a meaningful error message if vehicles are _not_ added to person - */ - private final boolean providingVehiclesInPerson ; - - public VehicleSourceTest( VehiclesSource vehiclesSource, boolean usingPersonIdForMissingVehicleId, boolean providingVehiclesInPerson ) { - this.vehiclesSource = vehiclesSource; - this.usingPersonIdForMissingVehicleId = usingPersonIdForMissingVehicleId; - this.providingVehiclesInPerson = providingVehiclesInPerson; - } - - @Parameters(name = "{index}: vehicleSource == {0}; isUsingPersonIdForMissingVehicleId == {1}") - public static Collection parameterObjects () { + public static Stream arguments () { // create the combinations manually, since 'fromVehiclesData' in combination with 'isUsingPersonIdForMissingVehicleId' doesn't make sense - return Arrays.asList( - new Object[]{VehiclesSource.defaultVehicle, true, true}, + return Stream.of(Arguments.of(VehiclesSource.defaultVehicle, true, true), // new Object[]{VehiclesSource.defaultVehicle, true, false}, // not meaningful for defaultVehicle - - new Object[]{VehiclesSource.defaultVehicle, false, true}, + Arguments.of(VehiclesSource.defaultVehicle, false, true), // new Object[]{VehiclesSource.defaultVehicle, false, false}, // not meaningful for defaultVehicle - - new Object[]{VehiclesSource.modeVehicleTypesFromVehiclesData, true, true}, - new Object[]{VehiclesSource.modeVehicleTypesFromVehiclesData, true, false}, - - new Object[]{VehiclesSource.modeVehicleTypesFromVehiclesData, false, true }, - new Object[]{VehiclesSource.modeVehicleTypesFromVehiclesData, false, false }, - - new Object[]{VehiclesSource.fromVehiclesData, false, true }, - new Object[]{VehiclesSource.fromVehiclesData, false, false } + Arguments.of(VehiclesSource.modeVehicleTypesFromVehiclesData, true, true), + Arguments.of(VehiclesSource.modeVehicleTypesFromVehiclesData, true, false), + Arguments.of(VehiclesSource.modeVehicleTypesFromVehiclesData, false, true), + Arguments.of(VehiclesSource.modeVehicleTypesFromVehiclesData, false, false), + Arguments.of(VehiclesSource.fromVehiclesData, false, true), + Arguments.of(VehiclesSource.fromVehiclesData, false, false) ); } @@ -107,12 +86,13 @@ public static Collection parameterObjects () { private Link link2; private Link link3; - @Test - void main() { + @ParameterizedTest + @MethodSource("arguments") + void main(VehiclesSource vehiclesSource, boolean usingPersonIdForMissingVehicleId, boolean providingVehiclesInPerson) { scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); createNetwork(); - createPlans(); + createPlans(vehiclesSource, providingVehiclesInPerson); Config config = scenario.getConfig(); config.qsim().setFlowCapFactor(1.0); @@ -121,8 +101,8 @@ void main() { //config.plansCalcRoute().setNetworkModes(Arrays.asList(transportModes)); config.qsim().setLinkDynamics(QSimConfigGroup.LinkDynamics.PassingQ); - config.qsim().setVehiclesSource(this.vehiclesSource ); - config.qsim().setUsePersonIdForMissingVehicleId(this.usingPersonIdForMissingVehicleId ); + config.qsim().setVehiclesSource(vehiclesSource ); + config.qsim().setUsePersonIdForMissingVehicleId(usingPersonIdForMissingVehicleId ); config.controller().setOutputDirectory(helper.getOutputDirectory()); config.controller().setLastIteration(0); @@ -187,7 +167,7 @@ public void install() { int bikeTravelTime = travelTime1.get(Id.create("2", Link.class)).intValue(); int carTravelTime = travelTime2.get(Id.create("2", Link.class)).intValue(); - switch (this.vehiclesSource ) { + switch (vehiclesSource ) { case defaultVehicle: // both bike and car are default vehicles (i.e. identical) Assertions.assertEquals(0, bikeTravelTime - carTravelTime, MatsimTestUtils.EPSILON, "Both car, bike are default vehicles (i.e. identical), thus should have same travel time."); break; @@ -214,7 +194,7 @@ private void createNetwork(){ link3 = NetworkUtils.createAndAddLink(network, Id.create("3", Link.class), node3, node4, 100, 25, 600, 1, null, "22"); } - private void createPlans(){ + private void createPlans(VehiclesSource vehiclesSource, boolean providingVehiclesInPerson){ Population population = scenario.getPopulation(); VehiclesFactory vehiclesFactory = scenario.getVehicles().getFactory(); @@ -259,7 +239,7 @@ private void createPlans(){ } //adding vehicle type and vehicle to scenario as needed: - switch (this.vehiclesSource ) { + switch (vehiclesSource ) { case defaultVehicle: //don't add anything break; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkTest.java index 6bcba7b34bc..ff153e4a86f 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QLinkTest.java @@ -30,9 +30,8 @@ import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -85,7 +84,6 @@ * @author mrieser */ -@RunWith(Parameterized.class) public final class QLinkTest { @RegisterExtension @@ -93,21 +91,9 @@ public final class QLinkTest { private static final Logger logger = LogManager.getLogger( QLinkTest.class ); - private final boolean isUsingFastCapacityUpdate; - - public QLinkTest(boolean isUsingFastCapacityUpdate) { - this.isUsingFastCapacityUpdate = isUsingFastCapacityUpdate; - } - - @Parameters(name = "{index}: isUsingfastCapacityUpdate == {0}") - public static Collection parameterObjects () { - Object [] capacityUpdates = new Object [] { false, true }; - return Arrays.asList(capacityUpdates); - } - - - @Test - void testInit() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testInit(boolean isUsingFastCapacityUpdate) { Fixture f = new Fixture(isUsingFastCapacityUpdate); assertNotNull(f.qlink1); assertEquals(1.0, f.qlink1.getSimulatedFlowCapacityPerTimeStep(), MatsimTestUtils.EPSILON); @@ -121,8 +107,9 @@ void testInit() { } - @Test - void testAdd() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testAdd(boolean isUsingFastCapacityUpdate) { Fixture f = new Fixture(isUsingFastCapacityUpdate); assertEquals(0, ((QueueWithBuffer) f.qlink1.getAcceptingQLane()).getAllVehicles().size()); QVehicle v = new QVehicleImpl(f.basicVehicle); @@ -153,8 +140,9 @@ private static PersonDriverAgentImpl createAndInsertPersonDriverAgentImpl(Person * @author mrieser */ - @Test - void testGetVehicle_Driving() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testGetVehicle_Driving(boolean isUsingFastCapacityUpdate) { Fixture f = new Fixture(isUsingFastCapacityUpdate); Id id1 = Id.create("1", Vehicle.class); @@ -219,8 +207,9 @@ void testGetVehicle_Driving() { * @author mrieser */ - @Test - void testGetVehicle_Parking() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testGetVehicle_Parking(boolean isUsingFastCapacityUpdate) { Fixture f = new Fixture(isUsingFastCapacityUpdate); Id id1 = Id.create("1", Vehicle.class); @@ -257,8 +246,9 @@ void testGetVehicle_Parking() { * @author mrieser */ - @Test - void testGetVehicle_Departing() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testGetVehicle_Departing(boolean isUsingFastCapacityUpdate) { Fixture f = new Fixture(isUsingFastCapacityUpdate); Id id1 = Id.create("1", Vehicle.class); @@ -322,8 +312,9 @@ void testGetVehicle_Departing() { * @author mrieser */ - @Test - void testBuffer() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testBuffer(boolean isUsingFastCapacityUpdate) { Config conf = utils.loadConfig((String)null); conf.qsim().setUsingFastCapacityUpdate(isUsingFastCapacityUpdate); @@ -446,8 +437,9 @@ private static Person createPerson(Id personId, MutableScenario scenario } - @Test - void testStorageSpaceDifferentVehicleSizes() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testStorageSpaceDifferentVehicleSizes(boolean isUsingFastCapacityUpdate) { Fixture f = new Fixture(isUsingFastCapacityUpdate); @@ -548,8 +540,9 @@ private Person createPerson2(Id personId, Fixture f) { } - @Test - void testStuckEvents() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testStuckEvents(boolean isUsingFastCapacityUpdate) { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); scenario.getConfig().qsim().setStuckTime(100); scenario.getConfig().qsim().setRemoveStuckVehicles(true); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SeepageTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SeepageTest.java index 8cfe3e14e1e..89e0f598b0a 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SeepageTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SeepageTest.java @@ -22,9 +22,8 @@ import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -58,24 +57,11 @@ /** * Tests that in congested part, walk (seep mode) can overtake (seep) car mode. - * + * */ -@RunWith(Parameterized.class) public class SeepageTest { static private final Logger log = LogManager.getLogger( SeepageTest.class); - private final boolean isUsingFastCapacityUpdate; - - public SeepageTest(boolean isUsingFastCapacityUpdate) { - this.isUsingFastCapacityUpdate = isUsingFastCapacityUpdate; - } - - @Parameters(name = "{index}: isUsingfastCapacityUpdate == {0}") - public static Collection parameterObjects () { - Object [] capacityUpdates = new Object [] { false, true }; - return Arrays.asList(capacityUpdates); - } - /** * Two carAgents end act at time 948 and 949 sec and walkAgent ends act at 49 sec. * Link length is 1 km and flow capacity 1 PCU/min. Speed of car and walk is 20 mps and 1 mps. @@ -83,16 +69,17 @@ public static Collection parameterObjects () { * WalkAgent joins queue at 1050 sec but leave link before second car at 1060 sec and thus blocking link for another 6 sec(flowCap*PCU) * Thus, second car leaves link after walkAgent. */ - @Test - void seepageOfWalkInCongestedRegime(){ + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void seepageOfWalkInCongestedRegime(boolean isUsingFastCapacityUpdate){ SimpleNetwork net = new SimpleNetwork(); - + Scenario sc = net.scenario; sc.getConfig().qsim().setVehiclesSource(VehiclesSource.fromVehiclesData); - sc.getConfig().qsim().setUsingFastCapacityUpdate(this.isUsingFastCapacityUpdate); - + sc.getConfig().qsim().setUsingFastCapacityUpdate(isUsingFastCapacityUpdate); + Map modesType = new HashMap(); VehicleType car = VehicleUtils.getFactory().createVehicleType(Id.create(TransportMode.car,VehicleType.class)); car.setMaximumVelocity(20); @@ -136,7 +123,7 @@ void seepageOfWalkInCongestedRegime(){ Vehicle vehicle = VehicleUtils.getFactory().createVehicle(vehicleId, modesType.get(leg.getMode())); sc.getVehicles().addVehicle(vehicle); } - + Map, Map, Double>> vehicleLinkTravelTimes = new HashMap<>(); EventsManager manager = EventsUtils.createEventsManager(); @@ -152,7 +139,7 @@ void seepageOfWalkInCongestedRegime(){ Map, Double> travelTime1 = vehicleLinkTravelTimes.get(Id.createVehicleId("2")); Map, Double> travelTime2 = vehicleLinkTravelTimes.get(Id.createVehicleId("1")); - int walkTravelTime = travelTime1.get(Id.createLinkId("2")).intValue(); + int walkTravelTime = travelTime1.get(Id.createLinkId("2")).intValue(); int carTravelTime = travelTime2.get(Id.createLinkId("2")).intValue(); // if(this.isUsingFastCapacityUpdate) { @@ -184,7 +171,7 @@ public SimpleNetwork(){ config.qsim().setStorageCapFactor(1.0); config.qsim().setMainModes(Arrays.asList(TransportMode.car,TransportMode.walk)); config.qsim().setLinkDynamics(LinkDynamics.SeepageQ); - + config.qsim().setSeepModes(Arrays.asList(TransportMode.walk) ); config.qsim().setSeepModeStorageFree(false); config.qsim().setRestrictingSeepage(true); @@ -256,4 +243,4 @@ public void handleEvent(LinkLeaveEvent event) { public void reset(int iteration) { } } -} \ No newline at end of file +} diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehVsLinkSpeedTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehVsLinkSpeedTest.java index 19f03965a02..10ec18198e2 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehVsLinkSpeedTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehVsLinkSpeedTest.java @@ -22,9 +22,8 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -61,28 +60,14 @@ * @author amit */ -@RunWith(Parameterized.class) public class VehVsLinkSpeedTest { - - public VehVsLinkSpeedTest(final double vehSpeed) { - this.vehSpeed = vehSpeed; - } - - private double vehSpeed ; private final static double MAX_SPEED_ON_LINK = 25; //in m/s - @Parameters(name = "{index}: vehicleSpeed == {0};") - public static Collection createFds() { - Object [] vehSpeeds = new Object [] { - 30, 20 - }; - return Arrays.asList(vehSpeeds); - } - - @Test - void testVehicleSpeed(){ + @ParameterizedTest + @ValueSource(doubles = {20, 30}) + void testVehicleSpeed(double vehSpeed){ SimpleNetwork net = new SimpleNetwork(); - + Id id = Id.createPersonId(0); Person p = net.population.getFactory().createPerson(id); Plan plan = net.population.getFactory().createPlan(); @@ -92,7 +77,7 @@ void testVehicleSpeed(){ Leg leg = net.population.getFactory().createLeg(TransportMode.car); plan.addActivity(a1); plan.addLeg(leg); - + LinkNetworkRouteFactory factory = new LinkNetworkRouteFactory(); NetworkRoute route = (NetworkRoute) factory.createRoute(net.link1.getId(), net.link3.getId()); route.setLinkIds(net.link1.getId(), Arrays.asList(net.link2.getId()), net.link3.getId()); @@ -107,7 +92,7 @@ void testVehicleSpeed(){ manager.addHandler(new VehicleLinkTravelTimeHandler(vehicleLinkTravelTime)); VehicleType car = VehicleUtils.getFactory().createVehicleType(Id.create("car", VehicleType.class)); - car.setMaximumVelocity(this.vehSpeed); + car.setMaximumVelocity(vehSpeed); car.setPcuEquivalents(1.0); net.scenario.getVehicles().addVehicleType(car); @@ -118,9 +103,9 @@ void testVehicleSpeed(){ .run(); Map, Double> travelTime1 = vehicleLinkTravelTime.get(Id.create("0", Vehicle.class)); - + Link desiredLink = net.scenario.getNetwork().getLinks().get(Id.createLinkId(2)); - + double carTravelTime = travelTime1.get(desiredLink.getId()); // 1000 / min(25, vehSpeed) double speedUsedInSimulation = Math.round( desiredLink.getLength() / (carTravelTime - 1) ); @@ -160,10 +145,10 @@ public SimpleNetwork(){ link1 = NetworkUtils.createAndAddLink(network,Id.create("1", Link.class), fromNode, toNode, (double) 100, MAX_SPEED_ON_LINK, (double) 60, (double) 1, null, "22"); final Node fromNode1 = node2; - final Node toNode1 = node3; + final Node toNode1 = node3; link2 = NetworkUtils.createAndAddLink(network,Id.create("2", Link.class), fromNode1, toNode1, (double) 1000, MAX_SPEED_ON_LINK, (double) 60, (double) 1, null, "22"); final Node fromNode2 = node3; - final Node toNode2 = node4; + final Node toNode2 = node4; link3 = NetworkUtils.createAndAddLink(network,Id.create("3", Link.class), fromNode2, toNode2, (double) 100, MAX_SPEED_ON_LINK, (double) 60, (double) 1, null, "22"); population = scenario.getPopulation(); @@ -203,4 +188,4 @@ public void handleEvent(LinkLeaveEvent event) { public void reset(int iteration) { } } -} \ No newline at end of file +} diff --git a/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsSubtoursTest.java b/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsSubtoursTest.java index 106ea1e7790..7dae5a07ce9 100644 --- a/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsSubtoursTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TripStructureUtilsSubtoursTest.java @@ -30,9 +30,8 @@ import java.util.List; import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Activity; @@ -49,20 +48,8 @@ /** * @author thibautd */ -@RunWith( Parameterized.class ) public class TripStructureUtilsSubtoursTest { private static final String STAGE = "stage_activity interaction"; - private final boolean useFacilitiesAsAnchorPoint; - - @Parameters - public static Collection contructorParameters() { - return Arrays.asList( new Boolean[]{true} , new Boolean[]{false} ); - } - - public TripStructureUtilsSubtoursTest(final boolean useFacilitiesAsAnchorPoint) { - this.useFacilitiesAsAnchorPoint = useFacilitiesAsAnchorPoint; - } - // ///////////////////////////////////////////////////////////////////////// // fixtures // ///////////////////////////////////////////////////////////////////////// @@ -97,7 +84,7 @@ private static Activity createActivityFromLocationId( return act; } - + private static Id createId(long no, boolean anchorAtFacilities){ Id id; if (anchorAtFacilities){ @@ -107,7 +94,7 @@ private static Id createId(long no, boolean anchorAtFacilities){ id = Id.create(no, Link.class); } - + return id; } @@ -267,7 +254,7 @@ private static Fixture createComplexSubtours(final boolean anchorAtFacilities) { final Activity act5 = createActivityFromLocationId( anchorAtFacilities , fact , "aa" , createId(3,anchorAtFacilities) ); plan.addActivity( act5 ); - + final List trip5 = new ArrayList(); final Leg leg7 = fact.createLeg( "skateboard" ); plan.addLeg( leg7 ); @@ -748,46 +735,55 @@ private static Collection allFixtures(final boolean anchorAtFacilities) // ///////////////////////////////////////////////////////////////////////// // tests // ///////////////////////////////////////////////////////////////////////// - @Test - void testOneSubtour() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testOneSubtour(boolean useFacilitiesAsAnchorPoint) { performTest( createMonoSubtourFixture( useFacilitiesAsAnchorPoint ) ); } - @Test - void testTwoNestedSubtours() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testTwoNestedSubtours(boolean useFacilitiesAsAnchorPoint) { performTest( createTwoNestedSubtours(useFacilitiesAsAnchorPoint) ); } - @Test - void testTwoChildren() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testTwoChildren(boolean useFacilitiesAsAnchorPoint) { performTest( createTwoChildren(useFacilitiesAsAnchorPoint) ); } - @Test - void testComplexSubtours() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testComplexSubtours(boolean useFacilitiesAsAnchorPoint) { performTest( createComplexSubtours(useFacilitiesAsAnchorPoint) ); } - @Test - void testOpenPlan() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testOpenPlan(boolean useFacilitiesAsAnchorPoint) { performTest( createOpenPlan(useFacilitiesAsAnchorPoint) ); } - @Test - void testLoops() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testLoops(boolean useFacilitiesAsAnchorPoint) { performTest( createPlanWithLoops(useFacilitiesAsAnchorPoint) ); } - @Test - void testTwoIndependentTours() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testTwoIndependentTours(boolean useFacilitiesAsAnchorPoint) { performTest( createTwoIndependentTours(useFacilitiesAsAnchorPoint) ); } - @Test - void testTripFromSomewhereElse() { performTest( createSingleTourComingFromSomewhereElse(useFacilitiesAsAnchorPoint));} + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testTripFromSomewhereElse(boolean useFacilitiesAsAnchorPoint) { performTest( createSingleTourComingFromSomewhereElse(useFacilitiesAsAnchorPoint));} - @Test - void testTripToSomewhereElse() { performTest( createSingleTourGoingToSomewhereElse(useFacilitiesAsAnchorPoint));} + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testTripToSomewhereElse(boolean useFacilitiesAsAnchorPoint) { performTest( createSingleTourGoingToSomewhereElse(useFacilitiesAsAnchorPoint));} private static void performTest(final Fixture fixture) { final Collection subtours = @@ -806,8 +802,9 @@ private static void performTest(final Fixture fixture) { "uncompatible subtours" ); } - @Test - void testInconsistentPlan() throws Exception { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testInconsistentPlan(boolean useFacilitiesAsAnchorPoint) throws Exception { final Fixture fixture = createInconsistentTrips( useFacilitiesAsAnchorPoint ); boolean hadException = false; try { @@ -823,8 +820,9 @@ void testInconsistentPlan() throws Exception { "no exception was thrown!"); } - @Test - void testGetTripsWithoutSubSubtours() throws Exception { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testGetTripsWithoutSubSubtours(boolean useFacilitiesAsAnchorPoint) throws Exception { for (Fixture f : allFixtures( useFacilitiesAsAnchorPoint )) { final int nTrips = TripStructureUtils.getTrips( f.plan ).size(); final Collection subtours = @@ -843,8 +841,9 @@ void testGetTripsWithoutSubSubtours() throws Exception { } } - @Test - void testFatherhood() throws Exception { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testFatherhood(boolean useFacilitiesAsAnchorPoint) throws Exception { for (Fixture f : allFixtures( useFacilitiesAsAnchorPoint )) { final Collection subtours = TripStructureUtils.getSubtours( f.plan ); diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java index b63e771c6f9..9b83941165a 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java @@ -26,9 +26,8 @@ import java.util.Arrays; import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -73,20 +72,10 @@ * @author mrieser */ -@RunWith(Parameterized.class) public class CharyparNagelScoringFunctionTest { private static final double EPSILON =1e-9; - @Parameter - public TypicalDurationScoreComputation typicalDurationComputation; - - @Parameterized.Parameters - public static Object[] testParameters() { - return new Object[] {TypicalDurationScoreComputation.relative,TypicalDurationScoreComputation.uniform}; - } - - private ScoringFunction getScoringFunctionInstance(final Fixture f, final Person person) { CharyparNagelScoringFunctionFactory charyparNagelScoringFunctionFactory = new CharyparNagelScoringFunctionFactory( f.scenario ); @@ -117,7 +106,7 @@ private double calcScore(final Fixture f) { * @param priority * @return the duration (in hours) at which the activity has a utility of 0. */ - private double getZeroUtilDuration_hrs(final double typicalDuration_hrs, final double priority) { + private double getZeroUtilDuration_hrs(final double typicalDuration_hrs, final double priority, TypicalDurationScoreComputation typicalDurationComputation) { // yy could/should use static function from CharyparNagelScoringUtils. kai, nov'13 if(typicalDurationComputation.equals(TypicalDurationScoreComputation.uniform)){ @@ -130,14 +119,15 @@ private double getZeroUtilDuration_hrs(final double typicalDuration_hrs, final d /** * Test the calculation of the zero-utility-duration. */ - @Test - void testZeroUtilityDuration() { - double zeroUtilDurW = getZeroUtilDuration_hrs(8.0, 1.0); - double zeroUtilDurH = getZeroUtilDuration_hrs(16.0, 1.0); - double zeroUtilDurW2 = getZeroUtilDuration_hrs(8.0, 2.0); + @ParameterizedTest + @EnumSource(TypicalDurationScoreComputation.class) + void testZeroUtilityDuration(TypicalDurationScoreComputation typicalDurationComputation) { + double zeroUtilDurW = getZeroUtilDuration_hrs(8.0, 1.0, typicalDurationComputation); + double zeroUtilDurH = getZeroUtilDuration_hrs(16.0, 1.0, typicalDurationComputation); + double zeroUtilDurW2 = getZeroUtilDuration_hrs(8.0, 2.0, typicalDurationComputation); ZeroUtilityComputation computation; - if(this.typicalDurationComputation.equals(TypicalDurationScoreComputation.uniform)){ + if(typicalDurationComputation.equals(TypicalDurationScoreComputation.uniform)){ computation = new ActivityUtilityParameters.SameAbsoluteScore(); } else { computation = new ActivityUtilityParameters.SameRelativeScore(); @@ -233,13 +223,14 @@ void testTravelingBikeAndConstantBike(){ /** * Test the performing part of the scoring function. */ - @Test - void testPerforming() { + @ParameterizedTest + @EnumSource(TypicalDurationScoreComputation.class) + void testPerforming(TypicalDurationScoreComputation typicalDurationComputation) { Fixture f = new Fixture(); double perf = +6.0; - double zeroUtilDurW = getZeroUtilDuration_hrs(3.0, 1.0); - double zeroUtilDurH = getZeroUtilDuration_hrs(15.0, 1.0); + double zeroUtilDurW = getZeroUtilDuration_hrs(3.0, 1.0, typicalDurationComputation); + double zeroUtilDurH = getZeroUtilDuration_hrs(15.0, 1.0, typicalDurationComputation); f.config.scoring().setPerforming_utils_hr(perf); @@ -301,8 +292,9 @@ void testClosingTime() { /** * Test the performing part of the scoring function when an activity has OpeningTime and ClosingTime set. */ - @Test - void testOpeningClosingTime() { + @ParameterizedTest + @EnumSource(TypicalDurationScoreComputation.class) + void testOpeningClosingTime(TypicalDurationScoreComputation typicalDurationComputation) { Fixture f = new Fixture(); double perf_hrs = +6.0; f.config.scoring().setPerforming_utils_hr(perf_hrs); @@ -336,10 +328,10 @@ void testOpeningClosingTime() { // // only the home-activity should add to the score // assertEquals(perf * 15.0 * Math.log(14.75 / zeroUtilDurH), calcScore(f), EPSILON); // not longer true, since not doing a scheduled activity now carries a penalty. kai, nov'13 - double score_home = perf_hrs * 15.0 * Math.log(14.75 / getZeroUtilDuration_hrs(15.0, 1.0)) ; + double score_home = perf_hrs * 15.0 * Math.log(14.75 / getZeroUtilDuration_hrs(15.0, 1.0, typicalDurationComputation)) ; final double typicalDuration_work_sec = wParams.getTypicalDuration().seconds(); - final double zeroUtilityDuration_work_sec = 3600. * getZeroUtilDuration_hrs(typicalDuration_work_sec/3600., 1. ); + final double zeroUtilityDuration_work_sec = 3600. * getZeroUtilDuration_hrs(typicalDuration_work_sec/3600., 1., typicalDurationComputation ); double slope_work_at_zero_utility_h = perf_hrs * typicalDuration_work_sec / zeroUtilityDuration_work_sec ; double score_work = - zeroUtilityDuration_work_sec * slope_work_at_zero_utility_h / 3600. ; assertEquals( score_home+3.*score_work , calcScore(f), EPSILON ) ; @@ -509,8 +501,9 @@ void testDistanceCostScoringPt() { /** * Test how the scoring function reacts when the first and the last activity do not have the same act-type. */ - @Test - void testDifferentFirstLastAct() { + @ParameterizedTest + @EnumSource(TypicalDurationScoreComputation.class) + void testDifferentFirstLastAct(TypicalDurationScoreComputation typicalDurationComputation) { Fixture f = new Fixture(); // change the last act to something different than the first act ((Activity) f.plan.getPlanElements().get(8)).setType("h2"); @@ -529,9 +522,9 @@ void testDifferentFirstLastAct() { double perf = +6.0; f.config.scoring().setPerforming_utils_hr(perf); - double zeroUtilDurW = getZeroUtilDuration_hrs(3.0, 1.0); - double zeroUtilDurH = getZeroUtilDuration_hrs(6.0, 1.0); - double zeroUtilDurH2 = getZeroUtilDuration_hrs(8.0, 1.0); + double zeroUtilDurW = getZeroUtilDuration_hrs(3.0, 1.0, typicalDurationComputation); + double zeroUtilDurH = getZeroUtilDuration_hrs(6.0, 1.0, typicalDurationComputation); + double zeroUtilDurH2 = getZeroUtilDuration_hrs(8.0, 1.0, typicalDurationComputation); assertEquals(perf * 3.0 * Math.log(2.5 / zeroUtilDurW) + perf * 3.0 * Math.log(2.75/zeroUtilDurW) @@ -545,11 +538,12 @@ void testDifferentFirstLastAct() { * don't end the day with an ongoing activity at all. This is half of the case * when the first and last activity aren't the same. */ - @Test - void testNoNightActivity() { + @ParameterizedTest + @EnumSource(TypicalDurationScoreComputation.class) + void testNoNightActivity(TypicalDurationScoreComputation typicalDurationComputation) { - double zeroUtilDurW = getZeroUtilDuration_hrs(3.0, 1.0); - double zeroUtilDurH = getZeroUtilDuration_hrs(7.0, 1.0); + double zeroUtilDurW = getZeroUtilDuration_hrs(3.0, 1.0, typicalDurationComputation); + double zeroUtilDurH = getZeroUtilDuration_hrs(7.0, 1.0, typicalDurationComputation); double perf = +3.0; Fixture f = new Fixture(); diff --git a/matsim/src/test/java/org/matsim/examples/EquilTest.java b/matsim/src/test/java/org/matsim/examples/EquilTest.java index ded2c6a9777..30b722f1065 100644 --- a/matsim/src/test/java/org/matsim/examples/EquilTest.java +++ b/matsim/src/test/java/org/matsim/examples/EquilTest.java @@ -28,9 +28,8 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.api.internal.MatsimReader; import org.matsim.core.config.Config; @@ -47,29 +46,17 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.utils.eventsfilecomparison.EventsFileComparator; -@RunWith(Parameterized.class) public class EquilTest { private static final Logger log = LogManager.getLogger( EquilTest.class ) ; @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - private final boolean isUsingFastCapacityUpdate; - - public EquilTest(boolean isUsingFastCapacityUpdate) { - this.isUsingFastCapacityUpdate = isUsingFastCapacityUpdate; - } - - @Parameters(name = "{index}: isUsingfastCapacityUpdate == {0}") - public static Collection parameterObjects () { - Object [] capacityUpdates = new Object [] { false, true }; - return Arrays.asList(capacityUpdates); - } - - @Test - void testEquil() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testEquil(boolean isUsingFastCapacityUpdate) { Config config = ConfigUtils.createConfig() ; config.controller().setOutputDirectory( utils.getOutputDirectory() ); - config.qsim().setUsingFastCapacityUpdate(this.isUsingFastCapacityUpdate); + config.qsim().setUsingFastCapacityUpdate(isUsingFastCapacityUpdate); config.facilities().setFacilitiesSource( FacilitiesConfigGroup.FacilitiesSource.onePerActivityLinkInPlansFile ); String netFileName = "test/scenarios/equil/network.xml"; diff --git a/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java b/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java index c8b41781421..bf0fda1ee5c 100644 --- a/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java +++ b/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java @@ -24,9 +24,8 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.events.Event; @@ -50,25 +49,17 @@ * */ -@RunWith(Parameterized.class) public class PtScoringTest { - @Parameter - public TypicalDurationScoreComputation typicalDurationScoreComputation; - - @Parameterized.Parameters - public static Object[] testParameters() { - return new Object[] {TypicalDurationScoreComputation.relative, TypicalDurationScoreComputation.uniform}; - } - @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Test - void test_PtScoringLineswitch() { + @ParameterizedTest + @EnumSource(TypicalDurationScoreComputation.class) + void test_PtScoringLineswitch(TypicalDurationScoreComputation typicalDurationScoreComputation) { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-simple-lineswitch"), "config.xml")); ScoringConfigGroup pcs = config.scoring() ; - if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ + if(typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ for(ActivityParams params : pcs.getActivityParams()){ params.setTypicalDurationScoreComputation(typicalDurationScoreComputation); } @@ -205,7 +196,7 @@ void test_PtScoringLineswitch() { System.out.println(" score: " + pp.getSelectedPlan().getScore() ) ; - if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ + if(typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ Assertions.assertEquals(-21.280962467387187, pp.getSelectedPlan().getScore(), MatsimTestUtils.EPSILON ) ; } else{ @@ -216,12 +207,13 @@ void test_PtScoringLineswitch() { } - @Test - void test_PtScoringLineswitchAndPtConstant() { + @ParameterizedTest + @EnumSource(TypicalDurationScoreComputation.class) + void test_PtScoringLineswitchAndPtConstant(TypicalDurationScoreComputation typicalDurationScoreComputation) { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-simple-lineswitch"), "config.xml")); ScoringConfigGroup pcs = config.scoring() ; - if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)) + if(typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)) for(ActivityParams params : pcs.getActivityParams()){ params.setTypicalDurationScoreComputation(typicalDurationScoreComputation); } @@ -360,7 +352,7 @@ void test_PtScoringLineswitchAndPtConstant() { System.out.println(" score: " + pp.getSelectedPlan().getScore() ) ; - if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ + if(typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ // Assert.assertEquals(89.14608279715044, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; Assertions.assertEquals(-19.280962467387187, pp.getSelectedPlan().getScore(), MatsimTestUtils.EPSILON ) ; } @@ -372,12 +364,13 @@ void test_PtScoringLineswitchAndPtConstant() { } - @Test - void test_PtScoring_Wait() { + @ParameterizedTest + @EnumSource(TypicalDurationScoreComputation.class) + void test_PtScoring_Wait(TypicalDurationScoreComputation typicalDurationScoreComputation) { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-simple"), "config.xml")); ScoringConfigGroup pcs = config.scoring(); - if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ + if(typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ for(ActivityParams params : pcs.getActivityParams()){ params.setTypicalDurationScoreComputation(typicalDurationScoreComputation); } @@ -448,7 +441,7 @@ void test_PtScoring_Wait() { System.out.println("agent score: " + pp.getSelectedPlan().getScore() ) ; - if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ + if(typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ Assertions.assertEquals(89.13108279715044, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; } else{ @@ -458,12 +451,13 @@ void test_PtScoring_Wait() { } - @Test - void test_PtScoring() { + @ParameterizedTest + @EnumSource(TypicalDurationScoreComputation.class) + void test_PtScoring(TypicalDurationScoreComputation typicalDurationScoreComputation) { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-simple"), "config.xml")); ScoringConfigGroup pcs = config.scoring() ; - if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)) + if(typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)) for(ActivityParams params : pcs.getActivityParams()){ params.setTypicalDurationScoreComputation(typicalDurationScoreComputation); } @@ -530,7 +524,7 @@ void test_PtScoring() { System.out.println(" score: " + pp.getSelectedPlan().getScore() ) ; - if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ + if(typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ Assertions.assertEquals(89.87441613048377, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; } else{ diff --git a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java index 7fa5c7b47f8..de9dddfc5d5 100644 --- a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java +++ b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java @@ -22,8 +22,9 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -45,47 +46,37 @@ import java.io.File; import java.util.Arrays; import java.util.Collection; +import java.util.stream.Stream; /** * Created by amit on 05.02.18. */ -@RunWith(Parameterized.class) public class ActivityFacilitiesSourceTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; - // private static final String outDir = "test/output/"+ActivityFacilitiesSourceTest.class.getCanonicalName().replace('.','/')+"/"; - - private final FacilitiesConfigGroup.FacilitiesSource facilitiesSource; - private final boolean facilitiesWithCoordOnly ; - - public ActivityFacilitiesSourceTest(FacilitiesConfigGroup.FacilitiesSource facilitiesSource, boolean facilitiesWithCoordOnly) { - this.facilitiesSource = facilitiesSource; - this.facilitiesWithCoordOnly = facilitiesWithCoordOnly; - } - - @Parameterized.Parameters(name = "{index}: FacilitiesSource - {0}; facilitiesWithCoordOnly - {1}") - public static Collection parametersForFacilitiesSourceTest() { + public static Stream arguments() { // it is not clear to me why/how this works. The documentation of JUnitParamsRunner says that such // implicit behavior ("dirty tricks") should no longer be necessary when using it. kai, jul'18 - return Arrays.asList( - new Object[]{FacilitiesConfigGroup.FacilitiesSource.none, true} // true/false doen't matter here - ,new Object[]{FacilitiesConfigGroup.FacilitiesSource.fromFile, true}// true/false doen't matter here - ,new Object[]{FacilitiesConfigGroup.FacilitiesSource.setInScenario, true} - ,new Object[]{FacilitiesConfigGroup.FacilitiesSource.setInScenario, false} - ,new Object[]{FacilitiesConfigGroup.FacilitiesSource.onePerActivityLinkInPlansFile, true} // true/false doen't matter here - ,new Object[]{FacilitiesConfigGroup.FacilitiesSource.onePerActivityLocationInPlansFile, true} // true/false doen't matter here + return Stream.of( + Arguments.of(FacilitiesConfigGroup.FacilitiesSource.none, true), // true/false doen't matter here + Arguments.of(FacilitiesConfigGroup.FacilitiesSource.fromFile, true),// true/false doen't matter here + Arguments.of(FacilitiesConfigGroup.FacilitiesSource.setInScenario, true), + Arguments.of(FacilitiesConfigGroup.FacilitiesSource.setInScenario, false), + Arguments.of(FacilitiesConfigGroup.FacilitiesSource.onePerActivityLinkInPlansFile, true), // true/false doen't matter here + Arguments.of(FacilitiesConfigGroup.FacilitiesSource.onePerActivityLocationInPlansFile, true) // true/false doen't matter here ); } - @Test - void test(){ + @ParameterizedTest + @MethodSource("arguments") + void test(FacilitiesConfigGroup.FacilitiesSource facilitiesSource, boolean facilitiesWithCoordOnly){ String outDir = utils.getOutputDirectory() ; String testOutDir = outDir + "/" + facilitiesSource.toString() + "_facilitiesWithCoordOnly_" + String.valueOf(facilitiesWithCoordOnly) + "/"; new File(testOutDir).mkdirs(); - Scenario scenario = prepareScenario(); + Scenario scenario = prepareScenario(facilitiesSource, facilitiesWithCoordOnly); scenario.getConfig().controller().setOutputDirectory(testOutDir); scenario.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); // (overwriteExistingFiles is needed here for the parameterized test since otherwise all output directories except for @@ -94,7 +85,7 @@ void test(){ // checks ActivityFacilities activityFacilities = getFacilities(scenario.getConfig().controller().getOutputDirectory()); - switch (this.facilitiesSource) { + switch (facilitiesSource) { case none: break; case fromFile: @@ -138,7 +129,7 @@ private ActivityFacilities getFacilities(String outputDir){ // create basic scenario - private Scenario prepareScenario() { + private Scenario prepareScenario(FacilitiesConfigGroup.FacilitiesSource facilitiesSource, boolean facilitiesWithCoordOnly) { Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); config.plans().setInputFile(null); config.controller().setLastIteration(0); @@ -213,7 +204,7 @@ private Scenario prepareScenario() { } // activity from link only - if (! this.facilitiesSource.equals(FacilitiesConfigGroup.FacilitiesSource.onePerActivityLocationInPlansFile)){ + if (! facilitiesSource.equals(FacilitiesConfigGroup.FacilitiesSource.onePerActivityLocationInPlansFile)){ Person person = populationFactory.createPerson(Id.createPersonId("1")); Plan plan = populationFactory.createPlan(); Activity home = populationFactory.createActivityFromLinkId("h", Id.createLinkId("1")); @@ -250,7 +241,7 @@ private Scenario prepareScenario() { plan.addLeg(populationFactory.createLeg( mode ) ); Activity work = populationFactory.createActivityFromLinkId("w", Id.createLinkId("20")); - if ( this.facilitiesSource.equals(FacilitiesConfigGroup.FacilitiesSource.onePerActivityLocationInPlansFile)){ + if (facilitiesSource.equals(FacilitiesConfigGroup.FacilitiesSource.onePerActivityLocationInPlansFile)){ work.setCoord(new Coord(10000.0, 0.0)); } diff --git a/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java b/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java index b0ee67d400c..a128a9ff6ea 100644 --- a/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java +++ b/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java @@ -25,14 +25,15 @@ import java.util.Arrays; import java.util.Collection; import java.util.Map; +import java.util.stream.Stream; import jakarta.inject.Inject; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.matsim.analysis.ScoreStats; import org.matsim.analysis.ScoreStatsControlerListener.ScoreItem; import org.matsim.core.config.Config; @@ -43,38 +44,24 @@ import org.matsim.core.controler.listener.ShutdownListener; import org.matsim.testcases.MatsimTestUtils; -@RunWith(Parameterized.class) public class ScoreStatsModuleTest { public static final double DELTA = 0.0000000001; + @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - private final boolean isUsingFastCapacityUpdate; - private final boolean isInsertingAccessEgressWalk; - - public ScoreStatsModuleTest(boolean isUsingFastCapacityUpdate, boolean isInsertingAccessEgressWalk) { - this.isUsingFastCapacityUpdate = isUsingFastCapacityUpdate; - this.isInsertingAccessEgressWalk = isInsertingAccessEgressWalk; - } - - @Parameters(name = "{index}: isUsingfastCapacityUpdate == {0}; isInsertingAccessEgressWalk = {1}") - public static Collection parameterObjects () { - Object [] [] os = new Object [][] { - // { false, true }, - // { true, true }, - { false, false }, - { true, false } - }; - return Arrays.asList(os); + public static Stream arguments () { + return Stream.of(Arguments.of(false, false), Arguments.of(true, false)); } - @Test - void testScoreStats() { + @ParameterizedTest + @MethodSource("arguments") + void testScoreStats(boolean isUsingFastCapacityUpdate, boolean isInsertingAccessEgressWalk) { Config config = utils.loadConfig("test/scenarios/equil/config.xml"); - config.qsim().setUsingFastCapacityUpdate(this.isUsingFastCapacityUpdate); - config.routing().setAccessEgressType(this.isInsertingAccessEgressWalk? AccessEgressType.accessEgressModeToLink : AccessEgressType.none); + config.qsim().setUsingFastCapacityUpdate(isUsingFastCapacityUpdate); + config.routing().setAccessEgressType(isInsertingAccessEgressWalk? AccessEgressType.accessEgressModeToLink : AccessEgressType.none); config.controller().setLastIteration(1); Controler controler = new Controler(config); diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourComplexTripsTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourComplexTripsTest.java index 4f65ed8e50d..364e2ead7f1 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourComplexTripsTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourComplexTripsTest.java @@ -25,9 +25,8 @@ import java.util.List; import java.util.Random; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -51,7 +50,6 @@ * as possible. * @author thibautd */ -@RunWith(Parameterized.class) public class ChooseRandomLegModeForSubtourComplexTripsTest { // transit_walk is not here but is in the fixtures: thus, pt trips are // identified as "known mode" only if trip-level mode detection is done @@ -60,8 +58,7 @@ public class ChooseRandomLegModeForSubtourComplexTripsTest { private static final String[] CHAIN_BASED_MODES = new String[]{TransportMode.car}; private static final String STAGE = PtConstants.TRANSIT_ACTIVITY_TYPE; - private final double probaForRandomSingleTripMode; - + // ///////////////////////////////////////////////////////////////////////// // Fixtures // ///////////////////////////////////////////////////////////////////////// @@ -80,7 +77,7 @@ public Plan createNewPlanInstance() { final Id id3 = Id.create( 3, Link.class ); final Plan plan = fact.createPlan(); - + plan.addActivity( fact.createActivityFromLinkId( "h" , id1 ) ); plan.addLeg( fact.createLeg( TransportMode.transit_walk ) ); @@ -123,7 +120,7 @@ public Plan createNewPlanInstance() { final Id id3 = Id.create( 3, Link.class ); final Plan plan = fact.createPlan(); - + plan.addActivity( fact.createActivityFromLinkId( "h" , id1 ) ); for (int i =0; i < 2; i++) { @@ -169,7 +166,7 @@ public Plan createNewPlanInstance() { final Id id4 = Id.create( 4, Link.class ); final Plan plan = fact.createPlan(); - + plan.addActivity( fact.createActivityFromLinkId( "h" , id1 ) ); plan.addLeg( fact.createLeg( TransportMode.transit_walk ) ); @@ -265,7 +262,7 @@ public Plan createNewPlanInstance() { final Id id4 = Id.create( 4, Link.class ); final Plan plan = fact.createPlan(); - + plan.addActivity( fact.createActivityFromLinkId( "h" , id1 ) ); plan.addLeg( fact.createLeg( TransportMode.car ) ); @@ -340,7 +337,7 @@ public Plan createNewPlanInstance() { final Id id4 = Id.create( 4, Link.class ); final Plan plan = fact.createPlan(); - + plan.addActivity( fact.createActivityFromLinkId( "sleep" , id1 ) ); plan.addActivity( fact.createActivityFromLinkId( "shower" , id1 ) ); plan.addActivity( fact.createActivityFromLinkId( "breakfast" , id1 ) ); @@ -450,17 +447,9 @@ private static PopulationFactory createPopulationFactory() { // ///////////////////////////////////////////////////////////////////////// // tests // ///////////////////////////////////////////////////////////////////////// - @Parameterized.Parameters(name = "{index}: probaForChooseRandomSingleTripMode == {0}") - public static Collection createTests() { - return Arrays.asList(0., 0.5); - } - public ChooseRandomLegModeForSubtourComplexTripsTest( double proba ) { - this.probaForRandomSingleTripMode = proba ; - } - - - @Test - void testMutatedTrips() { + @ParameterizedTest + @ValueSource(doubles = {0.0, 0.5}) + void testMutatedTrips(double probaForRandomSingleTripMode) { Config config = ConfigUtils.createConfig(); config.subtourModeChoice().setModes(MODES); config.subtourModeChoice().setConsiderCarAvailability(false); @@ -481,7 +470,7 @@ void testMutatedTrips() { testee.run( plan ); final List newTrips = TripStructureUtils.getTrips( plan ); - + Assertions.assertEquals( initNTrips, newTrips.size(), diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourDiffModesTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourDiffModesTest.java index cac43bb101c..6246fb409a6 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourDiffModesTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourDiffModesTest.java @@ -26,8 +26,8 @@ import java.util.Random; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -47,17 +47,14 @@ /** * Tests specific to the 'probability-for-random-single-trip-mode' parameter. - * + * * @author ikaddoura based on thibautd */ -@RunWith(Parameterized.class) public class ChooseRandomLegModeForSubtourDiffModesTest { - + private static final String[] MODES = new String[]{TransportMode.pt, TransportMode.car, TransportMode.walk}; private static final String[] CHAIN_BASED_MODES = new String[]{TransportMode.car}; - - private final double probaForRandomSingleTripMode; - + // ///////////////////////////////////////////////////////////////////////// // Fixtures // ///////////////////////////////////////////////////////////////////////// @@ -75,7 +72,7 @@ public Plan createNewPlanInstance() { final Id id3 = Id.create( 3, Link.class ); final Plan plan = fact.createPlan(); - + plan.addActivity( fact.createActivityFromLinkId( "h" , id1 ) ); plan.addLeg( fact.createLeg( TransportMode.walk ) ); @@ -90,7 +87,7 @@ public Plan createNewPlanInstance() { } }; } - + private static Collection createFixtures() { return Arrays.asList( createOneTourFixture()); @@ -102,16 +99,9 @@ private static PopulationFactory createPopulationFactory() { // ///////////////////////////////////////////////////////////////////////// // tests // ///////////////////////////////////////////////////////////////////////// - @Parameterized.Parameters(name = "{index}: probaForChooseRandomSingleTripMode == {0}") - public static Collection createTests() { - return Arrays.asList(0., 1.0); - } - public ChooseRandomLegModeForSubtourDiffModesTest( double proba ) { - this.probaForRandomSingleTripMode = proba ; - } - - @Test - void testMutatedTrips() { + @ParameterizedTest + @ValueSource(doubles = {0., 1.}) + void testMutatedTrips(double probaForRandomSingleTripMode) { Config config = ConfigUtils.createConfig(); config.subtourModeChoice().setModes(MODES); config.subtourModeChoice().setConsiderCarAvailability(false); @@ -132,7 +122,7 @@ void testMutatedTrips() { testee.run( plan ); final List newTrips = TripStructureUtils.getTrips( plan ); - + Assertions.assertEquals( initNTrips, newTrips.size(), @@ -174,11 +164,11 @@ void testMutatedTrips() { 1, nMutatedWithoutMutatedFather, "unexpected number of roots in mutated subtours"); - - + + for ( Subtour subtour : newSubtours ) { if (subtour.getChildren().isEmpty()) { - checkSubtour(subtour); + checkSubtour(subtour, probaForRandomSingleTripMode); } else { throw new RuntimeException("This test is not (yet) made for subtours with children."); } @@ -186,8 +176,8 @@ void testMutatedTrips() { } } } - - private void checkSubtour(Subtour subtour) { + + private void checkSubtour(Subtour subtour, double probaForRandomSingleTripMode) { boolean atLeastOneSubtourWithDifferentNonChainBasedModes = false; boolean atLeastOneSubtourWithDifferentChainBasedModes = false; @@ -195,22 +185,22 @@ private void checkSubtour(Subtour subtour) { String modePreviousTripSameSubtour = null; for (Trip trip: subtour.getTrips()) { - + for (Leg leg : trip.getLegsOnly()) { - + if (modePreviousTripSameSubtour == null) { // first trip during this subtour } else { if (leg.getMode().equals(modePreviousTripSameSubtour)) { - // same mode - + // same mode + } else { // different modes, should only occur for non-chain-based modes - + if (isChainBasedMode(leg.getMode()) || isChainBasedMode(modePreviousTripSameSubtour)) { // one of the two different modes is a chain-based mode which shouldn't just fall from the sky atLeastOneSubtourWithDifferentChainBasedModes = true; - + } else { // not a chain-based mode atLeastOneSubtourWithDifferentNonChainBasedModes = true; @@ -221,18 +211,18 @@ private void checkSubtour(Subtour subtour) { } } } - + if (atLeastOneSubtourWithDifferentChainBasedModes) { Assertions.fail("Two different modes during one subtour where one of the two different modes is a chain-based mode."); } - - if (this.probaForRandomSingleTripMode > 0.) { + + if (probaForRandomSingleTripMode > 0.) { if (atLeastOneSubtourWithDifferentNonChainBasedModes == false) { - Assertions.fail("There is not a single subtour with different non-chain-based modes even though the probability for random single trip mode is " + this.probaForRandomSingleTripMode); + Assertions.fail("There is not a single subtour with different non-chain-based modes even though the probability for random single trip mode is " + probaForRandomSingleTripMode); } } else { if (atLeastOneSubtourWithDifferentNonChainBasedModes == true) { - Assertions.fail("There is at least one subtour with different non-chain-based modes even though the probability for random single trip mode is " + this.probaForRandomSingleTripMode); + Assertions.fail("There is at least one subtour with different non-chain-based modes even though the probability for random single trip mode is " + probaForRandomSingleTripMode); } } } diff --git a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourTest.java b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourTest.java index e6dc7997e19..394fe8398fe 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/ChooseRandomLegModeForSubtourTest.java @@ -32,8 +32,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -63,11 +63,8 @@ /** * @author mrieser, michaz */ -@RunWith(Parameterized.class) public class ChooseRandomLegModeForSubtourTest { - private double probaForRandomSingleTripMode; - private static class AllowTheseModesForEveryone implements PermissibleModesCalculator { @@ -109,17 +106,9 @@ public static enum TripStructureAnalysisLayerOption {facility,link} "1 2 2 3 2 2 2 1 4 1", "1 2 3 4 3 1"); - @Parameterized.Parameters(name = "{index}: probaForRandomSingleTripMode == {0}") - public static Collection createTests() { - return Arrays.asList(0., 0.5); - } - public ChooseRandomLegModeForSubtourTest( double proba ) { - this.probaForRandomSingleTripMode = proba ; - } - - - @Test - void testHandleEmptyPlan() { + @ParameterizedTest + @ValueSource(doubles = {0.0, 0.5}) + void testHandleEmptyPlan(double probaForRandomSingleTripMode) { String[] modes = new String[] {TransportMode.car, TransportMode.pt, TransportMode.walk}; ChooseRandomLegModeForSubtour algo = new ChooseRandomLegModeForSubtour( new MainModeIdentifierImpl() , new AllowTheseModesForEveryone(modes), modes, CHAIN_BASED_MODES, MatsimRandom.getRandom(), SubtourModeChoice.Behavior.fromSpecifiedModesToSpecifiedModes, probaForRandomSingleTripMode); @@ -128,8 +117,9 @@ void testHandleEmptyPlan() { // no specific assert, but there should also be no NullPointerException or similar stuff that could theoretically happen } - @Test - void testHandlePlanWithoutLeg() { + @ParameterizedTest + @ValueSource(doubles = {0.0, 0.5}) + void testHandlePlanWithoutLeg(double probaForRandomSingleTripMode) { String[] modes = new String[] {TransportMode.car, TransportMode.pt, TransportMode.walk}; ChooseRandomLegModeForSubtour algo = new ChooseRandomLegModeForSubtour( new MainModeIdentifierImpl() ,new AllowTheseModesForEveryone(modes), modes, CHAIN_BASED_MODES, MatsimRandom.getRandom(), SubtourModeChoice.Behavior.fromSpecifiedModesToSpecifiedModes, probaForRandomSingleTripMode); @@ -140,40 +130,44 @@ void testHandlePlanWithoutLeg() { } - @Test - void testSubTourMutationNetworkBased() { + @ParameterizedTest + @ValueSource(doubles = {0.0, 0.5}) + void testSubTourMutationNetworkBased(double probaForRandomSingleTripMode) { Config config = utils.loadConfig(CONFIGFILE); Scenario scenario = ScenarioUtils.createScenario(config); Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).parse(config.network().getInputFileURL(config.getContext())); - this.testSubTourMutationToCar(network); - this.testSubTourMutationToPt(network); - this.testUnknownModeDoesntMutate(network); + this.testSubTourMutationToCar(network, probaForRandomSingleTripMode); + this.testSubTourMutationToPt(network, probaForRandomSingleTripMode); + this.testUnknownModeDoesntMutate(network, probaForRandomSingleTripMode); } - @Test - void testSubTourMutationFacilitiesBased() { + @ParameterizedTest + @ValueSource(doubles = {0.0, 0.5}) + void testSubTourMutationFacilitiesBased(double probaForRandomSingleTripMode) { Config config = utils.loadConfig(CONFIGFILE); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); ActivityFacilitiesImpl facilities = (ActivityFacilitiesImpl) scenario.getActivityFacilities(); new MatsimFacilitiesReader(scenario).parse(config.facilities().getInputFileURL(config.getContext())); - this.testSubTourMutationToCar(facilities); - this.testSubTourMutationToPt(facilities); - this.testUnknownModeDoesntMutate(facilities); + this.testSubTourMutationToCar(facilities, probaForRandomSingleTripMode); + this.testSubTourMutationToPt(facilities, probaForRandomSingleTripMode); + this.testUnknownModeDoesntMutate(facilities, probaForRandomSingleTripMode); } - @Test - void testCarDoesntTeleportFromHome() { + @ParameterizedTest + @ValueSource(doubles = {0.0, 0.5}) + void testCarDoesntTeleportFromHome(double probaForRandomSingleTripMode) { Config config = utils.loadConfig(CONFIGFILE); Scenario scenario = ScenarioUtils.createScenario(config); Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).parse(config.network().getInputFileURL(config.getContext())); - testCarDoesntTeleport(network, TransportMode.car, TransportMode.pt); - testCarDoesntTeleport(network, TransportMode.pt, TransportMode.car); + testCarDoesntTeleport(network, TransportMode.car, TransportMode.pt, probaForRandomSingleTripMode); + testCarDoesntTeleport(network, TransportMode.pt, TransportMode.car, probaForRandomSingleTripMode); } - @Test - void testSingleTripSubtourHandling() { + @ParameterizedTest + @ValueSource(doubles = {0.0, 0.5}) + void testSingleTripSubtourHandling(double probaForRandomSingleTripMode) { String[] modes = new String[] {"car", "pt", "walk"}; ChooseRandomLegModeForSubtour testee = new ChooseRandomLegModeForSubtour( new MainModeIdentifierImpl() ,new AllowTheseModesForEveryone(modes), modes, CHAIN_BASED_MODES, new Random(15102011), SubtourModeChoice.Behavior.fromSpecifiedModesToSpecifiedModes, probaForRandomSingleTripMode); @@ -257,8 +251,9 @@ void testSingleTripSubtourHandling() { } - @Test - void testUnclosedSubtour() { + @ParameterizedTest + @ValueSource(doubles = {0.0, 0.5}) + void testUnclosedSubtour(double probaForRandomSingleTripMode) { String[] modes = new String[] {"car", "pt", "walk"}; @@ -287,7 +282,7 @@ void testUnclosedSubtour() { } - private void testSubTourMutationToCar(Network network) { + private void testSubTourMutationToCar(Network network, double probaForRandomSingleTripMode) { String expectedMode = TransportMode.car; String originalMode = TransportMode.pt; String[] modes = new String[] {expectedMode, originalMode}; @@ -303,7 +298,7 @@ private void testSubTourMutationToCar(Network network) { } } - private void testSubTourMutationToCar(ActivityFacilities facilities) { + private void testSubTourMutationToCar(ActivityFacilities facilities, double probaForRandomSingleTripMode) { String expectedMode = TransportMode.car; String originalMode = TransportMode.pt; String[] modes = new String[] {expectedMode, originalMode}; @@ -319,7 +314,7 @@ private void testSubTourMutationToCar(ActivityFacilities facilities) { } } - private void testUnknownModeDoesntMutate(Network network) { + private void testUnknownModeDoesntMutate(Network network, double probaForRandomSingleTripMode) { String originalMode = TransportMode.walk; String[] modes = new String[] {TransportMode.car, TransportMode.pt}; ChooseRandomLegModeForSubtour testee = new ChooseRandomLegModeForSubtour( new MainModeIdentifierImpl() ,new AllowTheseModesForEveryone(modes), modes, CHAIN_BASED_MODES, MatsimRandom.getRandom(), SubtourModeChoice.Behavior.fromSpecifiedModesToSpecifiedModes, probaForRandomSingleTripMode); @@ -334,7 +329,7 @@ private void testUnknownModeDoesntMutate(Network network) { } } - private void testUnknownModeDoesntMutate(ActivityFacilities facilities) { + private void testUnknownModeDoesntMutate(ActivityFacilities facilities, double probaForRandomSingleTripMode) { String originalMode = TransportMode.walk; String[] modes = new String[] {TransportMode.car, TransportMode.pt}; ChooseRandomLegModeForSubtour testee = new ChooseRandomLegModeForSubtour( new MainModeIdentifierImpl() ,new AllowTheseModesForEveryone(modes), modes, CHAIN_BASED_MODES, MatsimRandom.getRandom(), SubtourModeChoice.Behavior.fromSpecifiedModesToSpecifiedModes, probaForRandomSingleTripMode); @@ -349,7 +344,7 @@ private void testUnknownModeDoesntMutate(ActivityFacilities facilities) { } } - private void testSubTourMutationToPt(ActivityFacilities facilities) { + private void testSubTourMutationToPt(ActivityFacilities facilities, double probaForRandomSingleTripMode) { String expectedMode = TransportMode.pt; String originalMode = TransportMode.car; String[] modes = new String[] {expectedMode, originalMode}; @@ -365,7 +360,7 @@ private void testSubTourMutationToPt(ActivityFacilities facilities) { } } - private void testSubTourMutationToPt(Network network) { + private void testSubTourMutationToPt(Network network, double probaForRandomSingleTripMode) { String expectedMode = TransportMode.pt; String originalMode = TransportMode.car; String[] modes = new String[] {expectedMode, originalMode}; @@ -381,7 +376,7 @@ private void testSubTourMutationToPt(Network network) { } } - private void testCarDoesntTeleport(Network network, String originalMode, String otherMode) { + private void testCarDoesntTeleport(Network network, String originalMode, String otherMode, double probaForRandomSingleTripMode) { String[] modes = new String[] {originalMode, otherMode}; ChooseRandomLegModeForSubtour testee = new ChooseRandomLegModeForSubtour( new MainModeIdentifierImpl() ,new AllowTheseModesForEveryone(modes), modes, CHAIN_BASED_MODES, MatsimRandom.getRandom(), SubtourModeChoice.Behavior.fromSpecifiedModesToSpecifiedModes, probaForRandomSingleTripMode); @@ -415,7 +410,7 @@ private void testCarDoesntTeleport(Network network, String originalMode, String } } - private void testCarDoesntTeleport(ActivityFacilities facilities, String originalMode, String otherMode) { + private void testCarDoesntTeleport(ActivityFacilities facilities, String originalMode, String otherMode, double probaForRandomSingleTripMode) { String[] modes = new String[] {originalMode, otherMode}; ChooseRandomLegModeForSubtour testee = new ChooseRandomLegModeForSubtour( new MainModeIdentifierImpl() ,new AllowTheseModesForEveryone(modes), modes, CHAIN_BASED_MODES, MatsimRandom.getRandom(), SubtourModeChoice.Behavior.fromSpecifiedModesToSpecifiedModes, probaForRandomSingleTripMode); From ae945824c233b85da7facccd70e6431a12e22fad Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Tue, 12 Dec 2023 16:45:55 +0100 Subject: [PATCH 16/21] removed last junit 4 imports --- .../run/AccessibilityIntegrationTest.java | 6 +- .../run/TinyMultimodalAccessibilityTest.java | 4 +- .../kai/KNAnalysisEventsHandlerTest.java | 6 +- .../application/MATSimApplicationTest.java | 8 +- .../application/options/CsvOptionsTest.java | 1 - .../application/options/ShpOptionsTest.java | 9 +- .../prepare/CreateLandUseShpTest.java | 4 +- .../prepare/ShapeFileTextLookupTest.java | 4 +- .../cadyts/car/CadytsCarWithPtScenarioIT.java | 4 +- .../DiversityGeneratingPlansRemoverTest.java | 21 ++-- .../DrtWithExtensionsConfigGroupTest.java | 1 - .../drt/sharingmetrics/SharingFactorTest.java | 108 +++++++++--------- .../RunOneTaxiWithPrebookingExampleIT.java | 4 +- .../TestColdEmissionAnalysisModule.java | 36 +++--- .../emissions/TestPositionEmissionModule.java | 4 +- ...EmissionToolOnlineExampleIT_vehTypeV1.java | 4 +- ...EmissionToolOnlineExampleIT_vehTypeV2.java | 4 +- .../CarrierPlanXmlReaderV2WithDtdTest.java | 20 ++-- .../jsprit/MatsimTransformerTest.java | 2 +- ...istanceScoringFunctionFactoryForTests.java | 4 +- .../ScoringFunctionFactoryForTests.java | 4 +- .../StrategyManagerFactoryForTests.java | 4 +- .../TimeScoringFunctionFactoryForTests.java | 4 +- contribs/informed-mode-choice/pom.xml | 5 + .../modechoice/search/TopKMinMaxTest.java | 6 +- contribs/integration/README.txt | 2 +- .../MatrixBasedPtRouterIT.java | 1 - .../matrixbasedptrouter/PtMatrixTest.java | 1 - .../integration/SubsidyContextTestIT.java | 6 +- .../MultiModalControlerListenerTest.java | 8 +- .../contrib/protobuf/EventWriterPBTest.java | 1 - .../contrib/pseudosimulation/RunPSimTest.java | 6 +- .../SimulatedAnnealingConfigGroupTest.java | 1 - .../dashboard/EmissionsDashboardTest.java | 4 +- .../FullExplorationVsCuttoffTest.java | 4 +- .../WhoIsTheBossSelectorTest.java | 4 +- ...imizeVehicleAllocationAtTourLevelTest.java | 6 +- .../drtAndPt/PtAlongALine2Test.java | 4 +- .../drtAndPt/PtAlongALineTest.java | 10 +- .../bvgAna/level1/StopId2LineId2PulkTest.java | 4 +- ...tionHandlerFlowSpillbackQueueQsimTest.java | 16 +-- .../java/playground/vsp/ev/UrbanEVTests.java | 5 +- .../TransitRouteTrimmerTest.java | 46 ++++---- matsim/pom.xml | 4 + .../api/core/v01/AutoResetIdCaches.java | 18 ++- .../controler/MatsimServicesImplTest.java | 4 +- .../mobsim/qsim/AgentNotificationTest.java | 7 +- .../core/network/DisallowedNextLinksTest.java | 1 - .../NetworkChangeEventsParserWriterTest.java | 2 +- ...ScoringFunctionsForPopulationStressIT.java | 4 +- .../TravelTimeCalculatorModuleTest.java | 22 ++-- .../core/utils/geometry/CoordUtilsTest.java | 50 ++++---- .../core/utils/io/MatsimXmlParserTest.java | 1 - .../core/utils/misc/ConfigUtilsTest.java | 6 +- .../matsim/other/DownloadAndReadXmlTest.java | 5 +- .../algorithms/PersonPrepareForSimTest.java | 40 +++---- .../population/algorithms/TestsUtil.java | 4 +- pom.xml | 26 +++-- 58 files changed, 309 insertions(+), 291 deletions(-) diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java index e859cf969bb..25b3a4598eb 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -76,7 +76,7 @@ public class AccessibilityIntegrationTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Ignore + @Disabled @Test void testRunAccessibilityExample() { Config config = ConfigUtils.loadConfig("./examples/RunAccessibilityExample/config.xml"); @@ -350,7 +350,7 @@ public void install() { } - @Ignore + @Disabled @Test void testWithFile(){ /*TODO Complete - JWJ, Dec'16 */ diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java index d7ab5eaaf3c..43574962078 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java @@ -21,7 +21,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -69,7 +69,7 @@ public class TinyMultimodalAccessibilityTest { // non-deterministic presumably because of multi-threading. kai, sep'19 @Test - @Ignore + @Disabled void testWithBoundingBox() { final Config config = createTestConfig(); diff --git a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java index ec4fa06dd61..67352fcabbf 100644 --- a/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java +++ b/contribs/analysis/src/test/java/org/matsim/contrib/analysis/kai/KNAnalysisEventsHandlerTest.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -108,7 +108,7 @@ public void tearDown() throws Exception { } @Test - @Ignore + @Disabled void testNoEvents() { KNAnalysisEventsHandler testee = new KNAnalysisEventsHandler(this.scenario); @@ -122,7 +122,7 @@ void testNoEvents() { } @Test - @Ignore + @Disabled void testAveraging() { // yy this test is probably not doing anything with respect to some of the newer statistics, such as money. kai, mar'14 diff --git a/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java b/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java index 0db41fd13eb..9d9d2052338 100644 --- a/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java +++ b/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java @@ -1,7 +1,7 @@ package org.matsim.application; -import org.junit.Assume; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.application.options.SampleOptions; @@ -127,13 +127,13 @@ void population() throws MalformedURLException { } @Test - @Ignore("Class is deprecated") + @Disabled("Class is deprecated") void freight() { Path input = Path.of("..", "..", "..", "..", "shared-svn", "komodnext", "data", "freight", "original_data").toAbsolutePath().normalize(); - Assume.assumeTrue(Files.exists(input)); + Assumptions.assumeTrue(Files.exists(input)); Path output = Path.of(utils.getOutputDirectory()); diff --git a/contribs/application/src/test/java/org/matsim/application/options/CsvOptionsTest.java b/contribs/application/src/test/java/org/matsim/application/options/CsvOptionsTest.java index da166a7ea88..65299cb0e81 100644 --- a/contribs/application/src/test/java/org/matsim/application/options/CsvOptionsTest.java +++ b/contribs/application/src/test/java/org/matsim/application/options/CsvOptionsTest.java @@ -5,7 +5,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.io.TempDir; -import org.junit.rules.TemporaryFolder; import java.io.IOException; import java.nio.file.Path; diff --git a/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java b/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java index 16c043ef0c8..2c9282c4add 100644 --- a/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java +++ b/contribs/application/src/test/java/org/matsim/application/options/ShpOptionsTest.java @@ -1,8 +1,7 @@ package org.matsim.application.options; import org.assertj.core.data.Offset; -import org.junit.Assume; -import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.locationtech.jts.geom.Geometry; @@ -32,7 +31,7 @@ void readZip() { .replace("options", "prepare")) .resolve("andorra-latest-free.shp.zip"); - Assume.assumeTrue(Files.exists(input)); + Assumptions.assumeTrue(Files.exists(input)); ShpOptions shp = new ShpOptions(input, null, null); @@ -52,7 +51,7 @@ void all() { .replace("options", "prepare")) .resolve("andorra-latest-free.shp.zip"); - Assume.assumeTrue(Files.exists(input)); + Assumptions.assumeTrue(Files.exists(input)); ShpOptions shp = new ShpOptions(input, null, null); @@ -74,7 +73,7 @@ void testGetGeometry() { .replace("options", "prepare")) .resolve("andorra-latest-free.shp.zip"); - Assume.assumeTrue(Files.exists(input)); + Assumptions.assumeTrue(Files.exists(input)); ShpOptions shp = new ShpOptions(input, null, null); Geometry geometry = shp.getGeometry() ; diff --git a/contribs/application/src/test/java/org/matsim/application/prepare/CreateLandUseShpTest.java b/contribs/application/src/test/java/org/matsim/application/prepare/CreateLandUseShpTest.java index 38747c0fbc7..ca40a8f3057 100644 --- a/contribs/application/src/test/java/org/matsim/application/prepare/CreateLandUseShpTest.java +++ b/contribs/application/src/test/java/org/matsim/application/prepare/CreateLandUseShpTest.java @@ -1,6 +1,6 @@ package org.matsim.application.prepare; -import org.junit.Assume; +import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -20,7 +20,7 @@ void convert() { Path input = Path.of(utils.getClassInputDirectory(), "andorra-latest-free.shp.zip"); - Assume.assumeTrue(Files.exists(input)); + Assumptions.assumeTrue(Files.exists(input)); Path output = Path.of(utils.getOutputDirectory(), "output.shp"); diff --git a/contribs/application/src/test/java/org/matsim/application/prepare/ShapeFileTextLookupTest.java b/contribs/application/src/test/java/org/matsim/application/prepare/ShapeFileTextLookupTest.java index 0ff988f14cf..74153b6ab75 100644 --- a/contribs/application/src/test/java/org/matsim/application/prepare/ShapeFileTextLookupTest.java +++ b/contribs/application/src/test/java/org/matsim/application/prepare/ShapeFileTextLookupTest.java @@ -1,6 +1,6 @@ package org.matsim.application.prepare; -import org.junit.Assume; +import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; @@ -22,7 +22,7 @@ void main() { Path input = Path.of(utils.getClassInputDirectory(), "verkehrszellen.csv"); Path output = Path.of(utils.getOutputDirectory(), "output.csv"); - Assume.assumeTrue(Files.exists(input)); + Assumptions.assumeTrue(Files.exists(input)); CommandLine cli = new CommandLine(new ShapeFileTextLookup()); int ret = cli.execute( diff --git a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarWithPtScenarioIT.java b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarWithPtScenarioIT.java index 9ab184be6b4..943cebbe4f0 100644 --- a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarWithPtScenarioIT.java +++ b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarWithPtScenarioIT.java @@ -2,7 +2,7 @@ import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -23,7 +23,7 @@ public class CadytsCarWithPtScenarioIT { @Test - @Ignore + @Disabled void testCadytsWithPtVehicles() { final Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("siouxfalls-2014"), "config_default.xml")); config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); diff --git a/contribs/common/src/test/java/org/matsim/contrib/common/diversitygeneration/planselectors/DiversityGeneratingPlansRemoverTest.java b/contribs/common/src/test/java/org/matsim/contrib/common/diversitygeneration/planselectors/DiversityGeneratingPlansRemoverTest.java index a2b73e1657d..04a8efe7547 100644 --- a/contribs/common/src/test/java/org/matsim/contrib/common/diversitygeneration/planselectors/DiversityGeneratingPlansRemoverTest.java +++ b/contribs/common/src/test/java/org/matsim/contrib/common/diversitygeneration/planselectors/DiversityGeneratingPlansRemoverTest.java @@ -4,7 +4,6 @@ import gnu.trove.map.TMap; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -37,7 +36,7 @@ public class DiversityGeneratingPlansRemoverTest { private static final Logger log = LogManager.getLogger( DiversityGeneratingPlansRemoverTest.class ) ; - + private final Id node0 = Id.createNodeId( "node0" ) ; private final Id node1 = Id.createNodeId( "node1" ) ; private final Id node2 = Id.createNodeId( "node2" ) ; @@ -50,7 +49,7 @@ public class DiversityGeneratingPlansRemoverTest { void calcWeights() { // yy This is not really a strong test. Rather something I wrote for debugging. Would be a good // starting point for a fuller test. kai, jul'18 - + Scenario scenario = ScenarioUtils.createScenario( ConfigUtils.createConfig() ) ; { Network net = scenario.getNetwork(); @@ -130,11 +129,11 @@ void calcWeights() { plans.put("hwh_car_otherMode",plan) ; } pop.addPerson( person ); - + DiversityGeneratingPlansRemover.Builder builder = new DiversityGeneratingPlansRemover.Builder() ; builder.setNetwork( scenario.getNetwork() ) ; final DiversityGeneratingPlansRemover remover = builder.get(); - + for ( Map.Entry entry : plans.entrySet() ) { log.info( "similarity " + entry.getKey() + " to self is " + remover.similarity( entry.getValue(), entry.getValue() ) ); log.info("") ; @@ -145,7 +144,7 @@ void calcWeights() { } log.info("") ; } - + // { // final double similarity = remover.similarity( person.getPlans().get( 0 ), person.getPlans().get( 1 ) ); // log.info( "similarity 0 to 1: " + similarity ); @@ -161,7 +160,7 @@ void calcWeights() { // log.info( "similarity 0 to 2: " + similarity ); // Assert.assertEquals( 12.0, similarity, 10.*Double.MIN_VALUE ); // } - + final Map retVal = remover.calcWeights( person.getPlans() ); log.info("") ; for ( Map.Entry entry : retVal.entrySet() ) { @@ -173,13 +172,13 @@ void calcWeights() { } double[] expecteds = new double[]{1.0,0.0} ; - + // Assert.assertArrayEquals( expecteds, Doubles.toArray( retVal.values() ) , 10.*Double.MIN_VALUE ); } - - + + } - + private Plan createHwhPlan( final PopulationFactory pf ) { Plan plan = pf.createPlan() ; { diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtWithExtensionsConfigGroupTest.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtWithExtensionsConfigGroupTest.java index 10b53461d07..a169febcd9e 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtWithExtensionsConfigGroupTest.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtWithExtensionsConfigGroupTest.java @@ -28,7 +28,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.io.TempDir; -import org.junit.rules.TemporaryFolder; import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup; import org.matsim.contrib.drt.extension.companions.DrtCompanionParams; import org.matsim.contrib.drt.extension.operations.DrtOperationsParams; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/sharingmetrics/SharingFactorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/sharingmetrics/SharingFactorTest.java index e98a066d0ce..b731cedf080 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/sharingmetrics/SharingFactorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/sharingmetrics/SharingFactorTest.java @@ -1,7 +1,7 @@ package org.matsim.contrib.drt.sharingmetrics; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Person; import org.matsim.contrib.dvrp.fleet.DvrpVehicle; @@ -53,15 +53,15 @@ public boolean isGroupRepresentative(Id personId) { { //single trip, no pooling var requestId = Id.create(0, Request.class); - Assert.assertNull(sharingFactorTracker.getPoolingRates().get(requestId)); + Assertions.assertNull(sharingFactorTracker.getPoolingRates().get(requestId)); events.processEvent(new PassengerPickedUpEvent(100.0, mode, requestId, personId1, vehicleId)); events.processEvent(new PassengerDroppedOffEvent(300.0, mode, requestId, personId1, vehicleId)); events.flush(); - Assert.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId)); - Assert.assertFalse(sharingFactorTracker.getPoolingRates().get(requestId)); - Assert.assertEquals(1., sharingFactorTracker.getSharingFactors().get(requestId), MatsimTestUtils.EPSILON); + Assertions.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId)); + Assertions.assertFalse(sharingFactorTracker.getPoolingRates().get(requestId)); + Assertions.assertEquals(1., sharingFactorTracker.getSharingFactors().get(requestId), MatsimTestUtils.EPSILON); } //clean up @@ -71,8 +71,8 @@ public boolean isGroupRepresentative(Id personId) { //two trips exactly after each other, no pooling var requestId1 = Id.create(0, Request.class); var requestId2 = Id.create(1, Request.class); - Assert.assertNull(sharingFactorTracker.getPoolingRates().get(requestId1)); - Assert.assertNull(sharingFactorTracker.getPoolingRates().get(requestId2)); + Assertions.assertNull(sharingFactorTracker.getPoolingRates().get(requestId1)); + Assertions.assertNull(sharingFactorTracker.getPoolingRates().get(requestId2)); events.processEvent(new PassengerPickedUpEvent(100.0, mode, requestId1, personId1, vehicleId)); events.processEvent(new PassengerDroppedOffEvent(300.0, mode, requestId1, personId1, vehicleId)); @@ -80,15 +80,15 @@ public boolean isGroupRepresentative(Id personId) { events.processEvent(new PassengerDroppedOffEvent(500.0, mode, requestId2, personId2, vehicleId)); events.flush(); - Assert.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId1)); - Assert.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId1)); - Assert.assertFalse(sharingFactorTracker.getPoolingRates().get(requestId1)); - Assert.assertEquals(1., sharingFactorTracker.getSharingFactors().get(requestId1), MatsimTestUtils.EPSILON); + Assertions.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId1)); + Assertions.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId1)); + Assertions.assertFalse(sharingFactorTracker.getPoolingRates().get(requestId1)); + Assertions.assertEquals(1., sharingFactorTracker.getSharingFactors().get(requestId1), MatsimTestUtils.EPSILON); - Assert.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId2)); - Assert.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId2)); - Assert.assertFalse(sharingFactorTracker.getPoolingRates().get(requestId2)); - Assert.assertEquals(1., sharingFactorTracker.getSharingFactors().get(requestId2), MatsimTestUtils.EPSILON); + Assertions.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId2)); + Assertions.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId2)); + Assertions.assertFalse(sharingFactorTracker.getPoolingRates().get(requestId2)); + Assertions.assertEquals(1., sharingFactorTracker.getSharingFactors().get(requestId2), MatsimTestUtils.EPSILON); } //clean up @@ -98,8 +98,8 @@ public boolean isGroupRepresentative(Id personId) { //two trips overlap half of the time var requestId1 = Id.create(0, Request.class); var requestId2 = Id.create(1, Request.class); - Assert.assertNull(sharingFactorTracker.getPoolingRates().get(requestId1)); - Assert.assertNull(sharingFactorTracker.getPoolingRates().get(requestId2)); + Assertions.assertNull(sharingFactorTracker.getPoolingRates().get(requestId1)); + Assertions.assertNull(sharingFactorTracker.getPoolingRates().get(requestId2)); events.processEvent(new PassengerPickedUpEvent(100.0, mode, requestId1, personId1, vehicleId)); events.processEvent(new PassengerPickedUpEvent(200.0, mode, requestId2, personId2, vehicleId)); @@ -107,15 +107,15 @@ public boolean isGroupRepresentative(Id personId) { events.processEvent(new PassengerDroppedOffEvent(400.0, mode, requestId2, personId2, vehicleId)); events.flush(); - Assert.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId1)); - Assert.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId1)); - Assert.assertTrue(sharingFactorTracker.getPoolingRates().get(requestId1)); - Assert.assertEquals((100. + 100.) / (100 + 50), sharingFactorTracker.getSharingFactors().get(requestId1), MatsimTestUtils.EPSILON); + Assertions.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId1)); + Assertions.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId1)); + Assertions.assertTrue(sharingFactorTracker.getPoolingRates().get(requestId1)); + Assertions.assertEquals((100. + 100.) / (100 + 50), sharingFactorTracker.getSharingFactors().get(requestId1), MatsimTestUtils.EPSILON); - Assert.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId2)); - Assert.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId2)); - Assert.assertTrue(sharingFactorTracker.getPoolingRates().get(requestId2)); - Assert.assertEquals((100. + 100.) / (50 + 100), sharingFactorTracker.getSharingFactors().get(requestId2), MatsimTestUtils.EPSILON); + Assertions.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId2)); + Assertions.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId2)); + Assertions.assertTrue(sharingFactorTracker.getPoolingRates().get(requestId2)); + Assertions.assertEquals((100. + 100.) / (50 + 100), sharingFactorTracker.getSharingFactors().get(requestId2), MatsimTestUtils.EPSILON); } @@ -126,8 +126,8 @@ public boolean isGroupRepresentative(Id personId) { // second trip (sharing factor = 2) happens completely within first trip (sharing factor = 1.2) var requestId1 = Id.create(0, Request.class); var requestId2 = Id.create(1, Request.class); - Assert.assertNull(sharingFactorTracker.getPoolingRates().get(requestId1)); - Assert.assertNull(sharingFactorTracker.getPoolingRates().get(requestId2)); + Assertions.assertNull(sharingFactorTracker.getPoolingRates().get(requestId1)); + Assertions.assertNull(sharingFactorTracker.getPoolingRates().get(requestId2)); events.processEvent(new PassengerPickedUpEvent(100.0, mode, requestId1, personId1, vehicleId)); events.processEvent(new PassengerPickedUpEvent(200.0, mode, requestId2, personId2, vehicleId)); @@ -135,15 +135,15 @@ public boolean isGroupRepresentative(Id personId) { events.processEvent(new PassengerDroppedOffEvent(400.0, mode, requestId1, personId1, vehicleId)); events.flush(); - Assert.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId1)); - Assert.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId1)); - Assert.assertTrue(sharingFactorTracker.getPoolingRates().get(requestId1)); - Assert.assertEquals((100. + 100. + 100.) / (100 + 50 + 100), sharingFactorTracker.getSharingFactors().get(requestId1), MatsimTestUtils.EPSILON); + Assertions.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId1)); + Assertions.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId1)); + Assertions.assertTrue(sharingFactorTracker.getPoolingRates().get(requestId1)); + Assertions.assertEquals((100. + 100. + 100.) / (100 + 50 + 100), sharingFactorTracker.getSharingFactors().get(requestId1), MatsimTestUtils.EPSILON); - Assert.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId2)); - Assert.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId2)); - Assert.assertTrue(sharingFactorTracker.getPoolingRates().get(requestId2)); - Assert.assertEquals((100. ) / (50.), sharingFactorTracker.getSharingFactors().get(requestId2), MatsimTestUtils.EPSILON); + Assertions.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId2)); + Assertions.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId2)); + Assertions.assertTrue(sharingFactorTracker.getPoolingRates().get(requestId2)); + Assertions.assertEquals((100. ) / (50.), sharingFactorTracker.getSharingFactors().get(requestId2), MatsimTestUtils.EPSILON); } //clean up @@ -154,8 +154,8 @@ public boolean isGroupRepresentative(Id personId) { var requestId1 = Id.create(0, Request.class); var requestId2 = Id.create(1, Request.class); - Assert.assertNull(sharingFactorTracker.getPoolingRates().get(requestId1)); - Assert.assertNull(sharingFactorTracker.getPoolingRates().get(requestId2)); + Assertions.assertNull(sharingFactorTracker.getPoolingRates().get(requestId1)); + Assertions.assertNull(sharingFactorTracker.getPoolingRates().get(requestId2)); events.processEvent(new PassengerPickedUpEvent(100.0, mode, requestId1, personId1, vehicleId)); events.processEvent(new PassengerPickedUpEvent(100.0, mode, requestId2, personId2, vehicleId)); @@ -163,15 +163,15 @@ public boolean isGroupRepresentative(Id personId) { events.processEvent(new PassengerDroppedOffEvent(200.0, mode, requestId2, personId2, vehicleId)); events.flush(); - Assert.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId1)); - Assert.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId1)); - Assert.assertTrue(sharingFactorTracker.getPoolingRates().get(requestId1)); - Assert.assertEquals(2., sharingFactorTracker.getSharingFactors().get(requestId1), MatsimTestUtils.EPSILON); + Assertions.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId1)); + Assertions.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId1)); + Assertions.assertTrue(sharingFactorTracker.getPoolingRates().get(requestId1)); + Assertions.assertEquals(2., sharingFactorTracker.getSharingFactors().get(requestId1), MatsimTestUtils.EPSILON); - Assert.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId2)); - Assert.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId2)); - Assert.assertTrue(sharingFactorTracker.getPoolingRates().get(requestId2)); - Assert.assertEquals(2., sharingFactorTracker.getSharingFactors().get(requestId2), MatsimTestUtils.EPSILON); + Assertions.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId2)); + Assertions.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId2)); + Assertions.assertTrue(sharingFactorTracker.getPoolingRates().get(requestId2)); + Assertions.assertEquals(2., sharingFactorTracker.getSharingFactors().get(requestId2), MatsimTestUtils.EPSILON); } @@ -184,8 +184,8 @@ public boolean isGroupRepresentative(Id personId) { var requestId1 = Id.create(0, Request.class); var requestId2 = Id.create(1, Request.class); - Assert.assertNull(sharingFactorTracker.getPoolingRates().get(requestId1)); - Assert.assertNull(sharingFactorTracker.getPoolingRates().get(requestId2)); + Assertions.assertNull(sharingFactorTracker.getPoolingRates().get(requestId1)); + Assertions.assertNull(sharingFactorTracker.getPoolingRates().get(requestId2)); events.processEvent(new PassengerPickedUpEvent(100.0, mode, requestId1, personId1, vehicleId)); events.processEvent(new PassengerPickedUpEvent(100.0, mode, requestId2, personId2, vehicleId)); @@ -193,13 +193,13 @@ public boolean isGroupRepresentative(Id personId) { events.processEvent(new PassengerDroppedOffEvent(200.0, mode, requestId2, personId2, vehicleId)); events.flush(); - Assert.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId1)); - Assert.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId1)); - Assert.assertFalse(sharingFactorTracker.getPoolingRates().get(requestId1)); - Assert.assertEquals(1., sharingFactorTracker.getSharingFactors().get(requestId1), MatsimTestUtils.EPSILON); + Assertions.assertNotNull(sharingFactorTracker.getPoolingRates().get(requestId1)); + Assertions.assertNotNull(sharingFactorTracker.getSharingFactors().get(requestId1)); + Assertions.assertFalse(sharingFactorTracker.getPoolingRates().get(requestId1)); + Assertions.assertEquals(1., sharingFactorTracker.getSharingFactors().get(requestId1), MatsimTestUtils.EPSILON); - Assert.assertNull(sharingFactorTracker.getPoolingRates().get(requestId2)); - Assert.assertNull(sharingFactorTracker.getSharingFactors().get(requestId2)); + Assertions.assertNull(sharingFactorTracker.getPoolingRates().get(requestId2)); + Assertions.assertNull(sharingFactorTracker.getSharingFactors().get(requestId2)); } } } diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiWithPrebookingExampleIT.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiWithPrebookingExampleIT.java index fc8deb6874c..b6661027c45 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiWithPrebookingExampleIT.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiWithPrebookingExampleIT.java @@ -32,7 +32,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.assertj.core.data.Offset; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -71,7 +71,7 @@ public class RunOneTaxiWithPrebookingExampleIT { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Ignore + @Disabled @Test void testRun() { // load config diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModule.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModule.java index 18bf6881844..d5d32b96239 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModule.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestColdEmissionAnalysisModule.java @@ -20,7 +20,7 @@ package org.matsim.contrib.emissions; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; @@ -70,11 +70,11 @@ public class TestColdEmissionAnalysisModule { private static final Set pollutants = new HashSet<>(Arrays.asList(CO, CO2_TOTAL, FC, HC, NMHC, NOx, NO2,PM, SO2)); private final int numberOfColdEmissions = pollutants.size(); // strings for test cases - + // The material below was confused in the way that strings like "petrol" or "diesel" were given for the // size classes, and "<1,4L" or ">=2L" for the emissions concept. Tried to make it consistent, // but I don't know if it is still testing the original functionality. kai, jul'18 - + // first case: complete data - corresponding entry in average table private static final String petrol_technology = "petrol"; private static final String none_sizeClass = "average"; @@ -95,7 +95,7 @@ public class TestColdEmissionAnalysisModule { private static final Double averagePetrolFactor = .01; private static final double fakeFactor = -1.; - + private boolean excep = false; @@ -116,7 +116,7 @@ void calculateColdEmissionsAndThrowEventTest_Exceptions() { testCasesExceptions.add( Id.create( "", VehicleType.class ) ); //case: null id testCasesExceptions.add( null ); - + for ( Id vehicleTypeId : testCasesExceptions ) { String message = "'" + vehicleTypeId + "'" + " was used to calculate cold emissions and generate an emissions event." + "It should instead throw an exception because it is not a valid vehicle information string."; @@ -139,7 +139,7 @@ void calculateColdEmissionsAndThrowEventTest_minimalVehicleInformation() { ColdEmissionAnalysisModule coldEmissionAnalysisModule = setUp(); excep = false; - + // case: no specifications for technology, size, class, em concept // string has no semicolons as separators - use average values Id vehInfo11 = Id.create("PASSENGER_CAR", VehicleType.class ); @@ -155,16 +155,16 @@ void calculateColdEmissionsAndThrowEventTest_minimalVehicleInformation() { String message = "The expected emissions for an emissions event with vehicle information string '" + vehInfo11 + "' are " + numberOfColdEmissions * averageAverageFactor + " but were " + sumOfEmissions; Assertions.assertEquals( numberOfColdEmissions * averageAverageFactor, sumOfEmissions, MatsimTestUtils.EPSILON, message ); - + } - + private static ColdEmissionAnalysisModule setUp() { Map avgHbefaColdTable = new HashMap<>(); Map detailedHbefaColdTable = new HashMap<>(); - + fillAveragesTable( avgHbefaColdTable ); fillDetailedTable( detailedHbefaColdTable ); - + EventsManager emissionEventManager = new HandlerToTestEmissionAnalysisModules(); EmissionsConfigGroup ecg = new EmissionsConfigGroup(); ecg.setHbefaVehicleDescriptionSource( EmissionsConfigGroup.HbefaVehicleDescriptionSource.usingVehicleTypeId ); @@ -172,7 +172,7 @@ private static ColdEmissionAnalysisModule setUp() { //This represents the previous behavior, which fallbacks to the average table, if values are not found in the detailed table, kmt apr'20 ecg.setDetailedVsAverageLookupBehavior(EmissionsConfigGroup.DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable); return new ColdEmissionAnalysisModule( avgHbefaColdTable, detailedHbefaColdTable, ecg, pollutants, emissionEventManager ); - + } @@ -196,36 +196,36 @@ private static void fillDetailedTable( Map avgHbefaColdTable ) { // create all needed and one unneeded entry for the average table { // add passenger car entry "average;average;average": HbefaVehicleAttributes vehAtt = ColdEmissionAnalysisModule.createHbefaVehicleAttributes( "average", "average", "average" ) ; - + putIntoHbefaColdTable( avgHbefaColdTable, vehAtt, new HbefaColdEmissionFactor(averageAverageFactor), PASSENGER_CAR ); } { HbefaVehicleAttributes vehAtt = ColdEmissionAnalysisModule.createHbefaVehicleAttributes( petrol_technology, none_sizeClass, none_emConcept ); - + putIntoHbefaColdTable( avgHbefaColdTable, vehAtt, new HbefaColdEmissionFactor( averagePetrolFactor ), PASSENGER_CAR ); } { // duplicate from detailed table, but with different emission factor. // this should not be used but is needed to assure that the detailed table is tried before the average table HbefaVehicleAttributes vehAtt = ColdEmissionAnalysisModule.createHbefaVehicleAttributes( diesel_technology, geq2l_sizeClass, PC_D_Euro_3_emConcept ); - + putIntoHbefaColdTable( avgHbefaColdTable, vehAtt, new HbefaColdEmissionFactor( fakeFactor ), PASSENGER_CAR ); } { // add HGV entry "petrol;none;none". // (pre-existing comment: HEAVY_GOODS_VEHICLE;PC petrol;petrol;none should not be used --???) final HbefaVehicleAttributes vehAtt = ColdEmissionAnalysisModule.createHbefaVehicleAttributes( petrol_technology, none_sizeClass, none_emConcept ); - + putIntoHbefaColdTable( avgHbefaColdTable, vehAtt, new HbefaColdEmissionFactor( fakeFactor ), HEAVY_GOODS_VEHICLE ); } } - + private static void putIntoHbefaColdTable( final Map detailedHbefaColdTable, final HbefaVehicleAttributes vehAtt, final HbefaColdEmissionFactor detColdFactor, final HbefaVehicleCategory hbefaVehicleCategory ) { for ( Pollutant cp : pollutants ) { HbefaColdEmissionFactorKey detColdKey = new HbefaColdEmissionFactorKey(); @@ -237,5 +237,5 @@ private static void putIntoHbefaColdTable( final Map> Maybe a problem in @link{ParallelEventsManagerImpl.class}? + @Disabled //Ignore this test, because the thrown exception during events handling does not always leads to an abort of the Simulation ->> Maybe a problem in @link{ParallelEventsManagerImpl.class}? @Test final void testDetailed_vehTypeV1() { boolean gotAnException = false ; diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java index 62e8af5a78e..95cbc87199b 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java @@ -18,7 +18,7 @@ * *********************************************************************** */ package org.matsim.contrib.emissions.example; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -40,7 +40,7 @@ public class RunDetailedEmissionToolOnlineExampleIT_vehTypeV2 { */ // @Test(expected=RuntimeException.class) // Expecting RuntimeException, because requested values are only in average file. Without fallback it has to fail! - @Ignore //Ignore this test, because the thrown exception during events handling does not always leads to an abort of the Simulation ->> Maybe a problem in @link{ParallelEventsManagerImpl.class}? + @Disabled //Ignore this test, because the thrown exception during events handling does not always leads to an abort of the Simulation ->> Maybe a problem in @link{ParallelEventsManagerImpl.class}? @Test final void testDetailed_vehTypeV2() { boolean gotAnException = false ; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java index 760d4942e04..22d23f8eefe 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java @@ -22,7 +22,7 @@ package org.matsim.freight.carriers; import org.junit.jupiter.api.BeforeEach; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -55,7 +55,7 @@ public void setUp() throws Exception{ } @Test - @Ignore + @Disabled void test_whenReadingServices_nuOfServicesIsCorrect(){ Assertions.assertEquals(3,testCarrier.getServices().size()); } @@ -77,7 +77,7 @@ void test_whenReadingCarrier_itReadsTypeIdsCorrectly(){ } @Test - @Ignore + @Disabled void test_whenReadingCarrier_itReadsVehiclesCorrectly(){ Map, CarrierVehicle> carrierVehicles = testCarrier.getCarrierCapabilities().getCarrierVehicles(); Assertions.assertEquals(3,carrierVehicles.size()); @@ -86,25 +86,25 @@ void test_whenReadingCarrier_itReadsVehiclesCorrectly(){ } @Test - @Ignore + @Disabled void test_whenReadingCarrier_itReadsFleetSizeCorrectly(){ Assertions.assertEquals(FleetSize.INFINITE, testCarrier.getCarrierCapabilities().getFleetSize()); } @Test - @Ignore + @Disabled void test_whenReadingCarrier_itReadsShipmentsCorrectly(){ Assertions.assertEquals(2, testCarrier.getShipments().size()); } @Test - @Ignore + @Disabled void test_whenReadingCarrier_itReadsPlansCorrectly(){ Assertions.assertEquals(3, testCarrier.getPlans().size()); } @Test - @Ignore + @Disabled void test_whenReadingCarrier_itSelectsPlansCorrectly(){ Assertions.assertNotNull(testCarrier.getSelectedPlan()); } @@ -122,7 +122,7 @@ void test_whenReadingCarrierWithFiniteFleet_itSetsFleetSizeCorrectly(){ } @Test - @Ignore + @Disabled void test_whenReadingPlans_nuOfToursIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); Assertions.assertEquals(1, plans.get(0).getScheduledTours().size()); @@ -131,7 +131,7 @@ void test_whenReadingPlans_nuOfToursIsCorrect(){ } @Test - @Ignore + @Disabled void test_whenReadingToursOfPlan1_nuOfActivitiesIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); CarrierPlan plan1 = plans.get(0); @@ -148,7 +148,7 @@ void test_whenReadingToursOfPlan2_nuOfActivitiesIsCorrect(){ } @Test - @Ignore + @Disabled void test_whenReadingToursOfPlan3_nuOfActivitiesIsCorrect(){ List plans = new ArrayList<>(testCarrier.getPlans()); CarrierPlan plan3 = plans.get(2); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java index 310c1942ad4..9514854743f 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java @@ -461,7 +461,7 @@ void createVehicleRoutingProblemWithShipments_isMadeCorrectly() { // TODO create } - // @Ignore //Set to ignore due to not implemented functionality of Shipments in MatsimJspritFactory + // @Disabled //Set to ignore due to not implemented functionality of Shipments in MatsimJspritFactory @Test void createVehicleRoutingProblemBuilderWithShipments_isMadeCorrectly() { Carrier carrier = createCarrierWithShipments(); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/DistanceScoringFunctionFactoryForTests.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/DistanceScoringFunctionFactoryForTests.java index 7dba7a46fdb..121eb0c5616 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/DistanceScoringFunctionFactoryForTests.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/DistanceScoringFunctionFactoryForTests.java @@ -22,7 +22,7 @@ package org.matsim.freight.carriers.mobsim; import jakarta.inject.Inject; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -46,7 +46,7 @@ import java.util.HashSet; import java.util.Set; -@Ignore +@Disabled public class DistanceScoringFunctionFactoryForTests implements CarrierScoringFunctionFactory{ static class DriverLegScoring implements BasicScoring, LegScoring{ diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/ScoringFunctionFactoryForTests.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/ScoringFunctionFactoryForTests.java index be93f2ad668..3bf4716a680 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/ScoringFunctionFactoryForTests.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/ScoringFunctionFactoryForTests.java @@ -21,7 +21,7 @@ package org.matsim.freight.carriers.mobsim; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -45,7 +45,7 @@ import java.util.HashSet; import java.util.Set; -@Ignore +@Disabled public class ScoringFunctionFactoryForTests implements CarrierScoringFunctionFactory{ static class DriverLegScoring implements BasicScoring, LegScoring{ diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/StrategyManagerFactoryForTests.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/StrategyManagerFactoryForTests.java index fc693360e04..680ef4e1953 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/StrategyManagerFactoryForTests.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/StrategyManagerFactoryForTests.java @@ -23,7 +23,7 @@ import com.google.inject.Provider; import jakarta.inject.Inject; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -43,7 +43,7 @@ import java.util.Map; -@Ignore +@Disabled public class StrategyManagerFactoryForTests implements Provider{ @Inject Network network; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/TimeScoringFunctionFactoryForTests.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/TimeScoringFunctionFactoryForTests.java index b55a80f9ba1..ee8e1921ed7 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/TimeScoringFunctionFactoryForTests.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/TimeScoringFunctionFactoryForTests.java @@ -22,7 +22,7 @@ package org.matsim.freight.carriers.mobsim; import jakarta.inject.Inject; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -46,7 +46,7 @@ import java.util.HashSet; import java.util.Set; -@Ignore +@Disabled public class TimeScoringFunctionFactoryForTests implements CarrierScoringFunctionFactory{ static class DriverLegScoring implements BasicScoring, LegScoring{ diff --git a/contribs/informed-mode-choice/pom.xml b/contribs/informed-mode-choice/pom.xml index 15bc5fa15b9..ee62e49fbc5 100644 --- a/contribs/informed-mode-choice/pom.xml +++ b/contribs/informed-mode-choice/pom.xml @@ -40,6 +40,11 @@ mockito-core test + + org.mockito + mockito-junit-jupiter + test + diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java index f307a5b77c3..01efd0381a4 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java @@ -7,8 +7,8 @@ import org.assertj.core.data.Offset; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.runner.RunWith; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; @@ -31,7 +31,7 @@ import org.matsim.testcases.MatsimTestUtils; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.stubbing.Answer; import java.util.Collection; @@ -44,7 +44,7 @@ import static org.mockito.ArgumentMatchers.anyDouble; import static org.mockito.Mockito.when; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class TopKMinMaxTest { @RegisterExtension diff --git a/contribs/integration/README.txt b/contribs/integration/README.txt index 5f488fea2e3..1820036b350 100644 --- a/contribs/integration/README.txt +++ b/contribs/integration/README.txt @@ -15,7 +15,7 @@ To add an integration test: Sub-packages (e.g. org.matsim.integration.daily.mycode.MyTest.java) are supported. - make sure the class name ends in "Test". - annotate your test methods with "@Test" (import org.junit.Test). -- write your test functionality, including assert statements from JUnit (import org.junit.Assert). +- write your test functionality, including assert statements from JUnit (import org.junit.jupiter.api.assertions). To run the daily/weekly tests locally: diff --git a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java index 029bc07e9ed..6553e8c813a 100644 --- a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java +++ b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java @@ -29,7 +29,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.io.TempDir; -import org.junit.rules.TemporaryFolder; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; diff --git a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java index 35bb1f4dbd3..2bbde2d9450 100644 --- a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java +++ b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java @@ -33,7 +33,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.io.TempDir; -import org.junit.rules.TemporaryFolder; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Network; diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java index 2050a1ad87c..85d490e30f1 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java @@ -24,7 +24,7 @@ import java.util.LinkedList; import java.util.List; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -56,7 +56,7 @@ public class SubsidyContextTestIT implements TabularFileHandler { private final ArrayList pStatsResults = new ArrayList<>(); private String gridScenarioDirectory ="../../example-scenario/input/"; - @Ignore + @Disabled @Test final void testDefaultPControler() { @@ -115,7 +115,7 @@ final void testDefaultPControler() { Assertions.assertEquals("16", this.pStatsResults.get(31)[8], "Number of +veh (final iteration)"); } - @Ignore + @Disabled @Test final void testSubsidyPControler() { diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java index 995516bba38..cb24c3d8849 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java @@ -25,7 +25,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -187,21 +187,21 @@ static void runSimpleScenario(int numberOfThreads) { Assertions.assertEquals(8, linkModeChecker.linkLeftCount); } - @Ignore("Due to bugfixes in slow flowCap accumulation in QueueWithBuffer")//by michalm + @Disabled("Due to bugfixes in slow flowCap accumulation in QueueWithBuffer")//by michalm @Test void testBerlinScenario_singleThreaded() { log.info("Run test single threaded..."); runBerlinScenario(1); } - @Ignore("Due to bugfixes in slow flowCap accumulation in QueueWithBuffer")//by michalm + @Disabled("Due to bugfixes in slow flowCap accumulation in QueueWithBuffer")//by michalm @Test void testBerlinScenario_multiThreaded_2() { log.info("Run test multi threaded with 2 threads..."); runBerlinScenario(2); } - @Ignore("Due to bugfixes in slow flowCap accumulation in QueueWithBuffer")//by michalm + @Disabled("Due to bugfixes in slow flowCap accumulation in QueueWithBuffer")//by michalm @Test void testBerlinScenario_multiThreaded_4() { log.info("Run test multi threaded with 4 threads..."); diff --git a/contribs/protobuf/src/test/java/org/matsim/contrib/protobuf/EventWriterPBTest.java b/contribs/protobuf/src/test/java/org/matsim/contrib/protobuf/EventWriterPBTest.java index 6c90bffb6cd..fe89a11d0f4 100644 --- a/contribs/protobuf/src/test/java/org/matsim/contrib/protobuf/EventWriterPBTest.java +++ b/contribs/protobuf/src/test/java/org/matsim/contrib/protobuf/EventWriterPBTest.java @@ -5,7 +5,6 @@ import org.assertj.core.api.Condition; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.rules.TemporaryFolder; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.Event; import org.matsim.api.core.v01.events.GenericEvent; diff --git a/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java b/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java index 12c258a2d6e..bd9e68ada04 100644 --- a/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java +++ b/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java @@ -3,11 +3,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.FixMethodOrder; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.runners.MethodSorters; import org.matsim.analysis.ScoreStatsControlerListener; import org.matsim.api.core.v01.population.Population; import org.matsim.contrib.pseudosimulation.mobsim.transitperformance.NoTransitEmulator; @@ -31,7 +31,7 @@ import java.util.ArrayList; import java.util.List; -@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@TestMethodOrder(MethodOrderer.MethodName.class) public class RunPSimTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); diff --git a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingConfigGroupTest.java b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingConfigGroupTest.java index 7b5ac7bfb78..26ad9aa3867 100644 --- a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingConfigGroupTest.java +++ b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingConfigGroupTest.java @@ -12,7 +12,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.io.TempDir; -import org.junit.rules.TemporaryFolder; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.testcases.MatsimTestUtils; diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/EmissionsDashboardTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/EmissionsDashboardTest.java index 4cbd29d9e7d..a809edfc795 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/EmissionsDashboardTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/EmissionsDashboardTest.java @@ -2,7 +2,7 @@ import com.google.common.collect.Iterables; import org.assertj.core.api.Assertions; -import org.junit.Assume; +import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -40,7 +40,7 @@ public class EmissionsDashboardTest { void generate() { // This test can only run if the password is set - Assume.assumeTrue(System.getenv("MATSIM_DECRYPTION_PASSWORD") != null); + Assumptions.assumeTrue(System.getenv("MATSIM_DECRYPTION_PASSWORD") != null); Path out = Path.of(utils.getOutputDirectory(), "analysis", "emissions"); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/FullExplorationVsCuttoffTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/FullExplorationVsCuttoffTest.java index 2bf1b4d1c99..a2612ee9214 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/FullExplorationVsCuttoffTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/FullExplorationVsCuttoffTest.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -39,7 +39,7 @@ /** * @author thibautd */ -@Ignore( "expensive") +@Disabled( "expensive") public class FullExplorationVsCuttoffTest { private static final Logger log = LogManager.getLogger(FullExplorationVsCuttoffTest.class); diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/whoisthebossselector/WhoIsTheBossSelectorTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/whoisthebossselector/WhoIsTheBossSelectorTest.java index 518ba077207..1b898a30398 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/whoisthebossselector/WhoIsTheBossSelectorTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/framework/replanning/selectors/whoisthebossselector/WhoIsTheBossSelectorTest.java @@ -32,7 +32,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.BeforeEach; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; @@ -120,7 +120,7 @@ private Set getGroupIds(final ReplanningGroup group) { } @Test - @Ignore("TODO") + @Disabled("TODO") void testBestPlanIsSelectedIfPossible() throws Exception { throw new UnsupportedOperationException( "TODO" ); } diff --git a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/OptimizeVehicleAllocationAtTourLevelTest.java b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/OptimizeVehicleAllocationAtTourLevelTest.java index 20514741157..2fe372d3158 100644 --- a/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/OptimizeVehicleAllocationAtTourLevelTest.java +++ b/contribs/socnetsim/src/test/java/org/matsim/contrib/socnetsim/sharedvehicles/replanning/OptimizeVehicleAllocationAtTourLevelTest.java @@ -26,7 +26,7 @@ import java.util.Random; import java.util.Set; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; @@ -102,7 +102,7 @@ private void fillPlan( } @Test - @Ignore("TODO") + @Disabled("TODO") void testVehiclesAreAllocatedAtTheTourLevel() throws Exception { throw new UnsupportedOperationException( "TODO" ); } @@ -133,7 +133,7 @@ void testCannotFindBetterAllocationRandomly() throws Exception { new AllocateVehicleToPlansInGroupPlanAlgorithm( new Random( j ), vehs, - Collections.singleton( MODE ), + Collections.singleton( MODE ), false, false).run( randomized ); final double randomizedOverlap = algo.calcOverlap( randomized ); diff --git a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java index 1cb5418e60e..7d884443580 100644 --- a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java +++ b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java @@ -9,7 +9,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -746,7 +746,7 @@ public void install() { // this test is failing because raptor treats "walk" in a special way. kai, jul'19 @Test - @Ignore + @Disabled void networkWalkDoesNotWorkWithRaptor() { // test fails with null pointer exception diff --git a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java index 6c315ddf84b..00c908721c0 100644 --- a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java +++ b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java @@ -3,7 +3,7 @@ import java.util.HashSet; import java.util.Set; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -51,7 +51,7 @@ public class PtAlongALineTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Ignore + @Disabled @Test void testPtAlongALine() { @@ -68,7 +68,7 @@ void testPtAlongALine() { * Test of Intermodal Access & Egress to pt using bike.There are three transit stops, and * only the middle stop is accessible by bike. */ - @Ignore + @Disabled @Test void testPtAlongALineWithRaptorAndBike() { @@ -91,7 +91,7 @@ void testPtAlongALineWithRaptorAndBike() { * Test of Drt. 200 drt Vehicles are generated on Link 499-500, and all Agents rely on these * drts to get to their destination */ - @Ignore + @Disabled @Test void testDrtAlongALine() { @@ -202,7 +202,7 @@ void testDrtAlongALine() { * drt, which is set by a StopFilterAttribute */ - @Ignore + @Disabled @Test void testPtAlongALineWithRaptorAndDrtStopFilterAttribute() { Config config = PtAlongALineTest.createConfig(utils.getOutputDirectory()); diff --git a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2LineId2PulkTest.java b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2LineId2PulkTest.java index 1b4a71190da..bfa02894495 100644 --- a/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2LineId2PulkTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/andreas/bvgAna/level1/StopId2LineId2PulkTest.java @@ -1,6 +1,6 @@ package playground.vsp.andreas.bvgAna.level1; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; @@ -16,7 +16,7 @@ public class StopId2LineId2PulkTest { @Test - @Ignore + @Disabled void testStopId2LineId2Pulk() { // assign Ids to routes, vehicles and agents to be used in Test diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java index c2f58a3cc25..1d0f93eb272 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java @@ -32,7 +32,7 @@ import jakarta.inject.Inject; import jakarta.inject.Provider; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -131,7 +131,7 @@ public class MarginalCongestionHandlerFlowSpillbackQueueQsimTest { * V3 * */ - @Ignore("Temporarily ignoring")//TODO for Amit + @Disabled("Temporarily ignoring")//TODO for Amit @Test final void testFlowAndStorageCongestion_3agents(){ @@ -259,7 +259,7 @@ public void handleEvent(CongestionEvent event) { * V10 * */ - @Ignore("Temporarily ignoring")//TODO for Amit + @Disabled("Temporarily ignoring")//TODO for Amit @Test final void testFlowAndStorageCongestion_3agents_V10() { @@ -309,7 +309,7 @@ public void handleEvent(CongestionEvent event) { // in both iterations the "toll" and the "tollOldValue" should be the same // // 3 iterations are necessary to check the equality of the "toll" and the "tollOldValue" - @Ignore("Temporarily ignoring")//TODO for Amit + @Disabled("Temporarily ignoring")//TODO for Amit @Test final void testRouting(){ @@ -449,7 +449,7 @@ else if(((event.getServices().getConfig().controller().getLastIteration())-(even } // setInsertingWaitingVehiclesBeforeDrivingVehicles = false - @Ignore("Temporarily ignoring")//TODO for Amit + @Disabled("Temporarily ignoring")//TODO for Amit @Test final void testInsertingWaitingVehicles_01(){ @@ -508,7 +508,7 @@ public void handleEvent(LinkLeaveEvent event) { // setInsertingWaitingVehiclesBeforeDrivingVehicles = true // to compare - @Ignore("Temporarily ignoring")//TODO for Amit + @Disabled("Temporarily ignoring")//TODO for Amit @Test final void testInsertingWaitingVehicles_02(){ @@ -569,7 +569,7 @@ public void handleEvent(LinkLeaveEvent event) { // setInsertingWaitingVehiclesBeforeDrivingVehicles = false // agent 2 is already on link 2 when agent 3 ends his activity, // therefore agent 3 has to wait until agent 2 has left the link - @Ignore("Temporarily ignoring")//TODO for Amit + @Disabled("Temporarily ignoring")//TODO for Amit @Test final void testInsertingWaitingVehicles_03(){ @@ -627,7 +627,7 @@ public void handleEvent(LinkLeaveEvent event) { } - @Ignore("Temporarily ignoring")//TODO for Amit + @Disabled("Temporarily ignoring")//TODO for Amit @Test final void testStuckTimePeriod(){ diff --git a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java index ce74cd04415..9d9cf8230ec 100644 --- a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java +++ b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java @@ -6,9 +6,10 @@ import java.util.Map; import java.util.stream.Collectors; -import org.junit.BeforeClass; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -60,7 +61,7 @@ public class UrbanEVTests { private static UrbanEVTestHandler handler; private static Map, List> plannedActivitiesPerPerson; - @BeforeEachClass + @BeforeAll public static void run() { Scenario scenario = CreateUrbanEVTestScenario.createTestScenario(); scenario.getConfig().controller().setOutputDirectory("test/output/playground/vsp/ev/UrbanEVTests/"); diff --git a/contribs/vsp/src/test/java/playground/vsp/pt/transitRouteTrimmer/TransitRouteTrimmerTest.java b/contribs/vsp/src/test/java/playground/vsp/pt/transitRouteTrimmer/TransitRouteTrimmerTest.java index 81bd2b2b013..4f1eeb06787 100644 --- a/contribs/vsp/src/test/java/playground/vsp/pt/transitRouteTrimmer/TransitRouteTrimmerTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/pt/transitRouteTrimmer/TransitRouteTrimmerTest.java @@ -21,7 +21,7 @@ package playground.vsp.pt.transitRouteTrimmer; import javafx.util.Pair; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.locationtech.jts.geom.prep.PreparedGeometry; @@ -53,7 +53,7 @@ * * @author jakobrehmann */ -@Ignore // is ignored :-( +@Disabled // is ignored :-( public class TransitRouteTrimmerTest { final String inZoneShpFile = "https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/berlin/projects/avoev/shp-files/shp-berlin-hundekopf-areas/berlin_hundekopf.shp"; @@ -96,7 +96,7 @@ public enum routeType { /** * In the allIn scenario, the transitRoute in question should have all stops within zone. */ - @Ignore + @Disabled @Test void test_AllIn() { @@ -126,7 +126,7 @@ void test_AllIn() { * In the halfIn scenario, the transitRoute in question begins outside of the zone and * ends within the zone. */ - @Ignore + @Disabled @Test void test_HalfIn() { @@ -154,7 +154,7 @@ void test_HalfIn() { * In the MiddleIn scenario, the transitRoute in question begins outside of the zone then dips * into the zone, and finally leaves the zone once again */ - @Ignore + @Disabled @Test void test_MiddleIn() { @@ -188,7 +188,7 @@ void test_MiddleIn() { * route scenario: AllIn * The testRoute should be deleted since all stops are within the zone. */ - @Ignore + @Disabled @Test void testDeleteRoutesEntirelyInsideZone_AllIn() { @@ -223,7 +223,7 @@ void testDeleteRoutesEntirelyInsideZone_AllIn() { * The testRoute should be retained and left unmodified, * since some stops are outside the zone. */ - @Ignore + @Disabled @Test void testDeleteRoutesEntirelyInsideZone_HalfIn() { @@ -270,7 +270,7 @@ void testDeleteRoutesEntirelyInsideZone_HalfIn() { * The testRoute should be retained and left unmodified, * since some stops are outside the zone. */ - @Ignore + @Disabled @Test void testDeleteRoutesEntirelyInsideZone_MiddleIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); @@ -316,7 +316,7 @@ void testDeleteRoutesEntirelyInsideZone_MiddleIn() { * route scenario: AllIn * The testRoute should be deleted since all stops are within the zone. */ - @Ignore + @Disabled @Test void testTrimEnds_AllIn() { @@ -350,7 +350,7 @@ void testTrimEnds_AllIn() { * route scenario: HalfIn * The second half of the route is outside the zone and should be trimmed */ - @Ignore + @Disabled @Test void testTrimEnds_HalfIn() { @@ -403,7 +403,7 @@ void testTrimEnds_HalfIn() { * route scenario: MiddleIn * Since the ends are both outside of zone, route should not be modified */ - @Ignore + @Disabled @Test void testTrimEnds_MiddleIn() { @@ -449,7 +449,7 @@ void testTrimEnds_MiddleIn() { * route scenario: AllIn * New route should be empty */ - @Ignore + @Disabled @Test void testSkipStops_AllIn() { @@ -481,7 +481,7 @@ void testSkipStops_AllIn() { * route scenario: HalfIn * Stops outside zone should be skipped */ - @Ignore + @Disabled @Test void testSkipStops_HalfIn() { @@ -531,7 +531,7 @@ void testSkipStops_HalfIn() { * route scenario: MiddleIn * New route should have less stops than old route, but same amount of links */ - @Ignore + @Disabled @Test void testSkipStops_MiddleIn() { @@ -578,7 +578,7 @@ void testSkipStops_MiddleIn() { * route scenario: AllIn * route will be deleted */ - @Ignore + @Disabled @Test void testSplitRoutes_AllIn() { @@ -612,7 +612,7 @@ void testSplitRoutes_AllIn() { * route scenario: HalfIn * New route should have less stops than old route */ - @Ignore + @Disabled @Test void testSplitRoutes_HalfIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); @@ -661,7 +661,7 @@ void testSplitRoutes_HalfIn() { * route scenario: MiddleIn * Two routes should be created, each with only one stop within zone */ - @Ignore + @Disabled @Test void testSplitRoutes_MiddleIn() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); @@ -727,7 +727,7 @@ Hubs allow route to extend into zone to reach a import transit stop (like a majo * tests reach of hubs. Left hub should be included in route 1, while right hub should not be * included in route 2, due to lacking reach */ - @Ignore + @Disabled @Test void testSplitRoutes_MiddleIn_Hub_ValidateReach() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); @@ -797,7 +797,7 @@ void testSplitRoutes_MiddleIn_Hub_ValidateReach() { * tests parameter to include first nearest hub, even if reach is insufficient. * Right hub should be included, even though reach is too low. */ - @Ignore + @Disabled @Test void testSplitRoutes_MiddleIn_Hub_IncludeFirstHubInZone() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); @@ -870,7 +870,7 @@ void testSplitRoutes_MiddleIn_Hub_IncludeFirstHubInZone() { * route scenario: MiddleIn * if multiple hubs are within reach of route, the route should go to further one */ - @Ignore + @Disabled @Test void testSplitRoutes_MiddleIn_Hub_MultipleHubs() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); @@ -939,7 +939,7 @@ void testSplitRoutes_MiddleIn_Hub_MultipleHubs() { * if two new routes overlap (because they both reach to same hub) * then they should be combined into one route */ - @Ignore + @Disabled @Test void testSplitRoutes_MiddleIn_Hub_OverlapRoutes() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); @@ -995,7 +995,7 @@ void testSplitRoutes_MiddleIn_Hub_OverlapRoutes() { * route should not be split, since the parameter allowableStopsWithinZone is equal to the number * of stops within zone */ - @Ignore + @Disabled @Test void testSplitRoutes_MiddleIn_AllowableStopsWithin() { Scenario scenario = provideCopyOfScenario(this.inScheduleFile, this.inNetworkFile, this.inVehiclesFile); @@ -1037,7 +1037,7 @@ void testSplitRoutes_MiddleIn_AllowableStopsWithin() { } - @Ignore + @Disabled @Test void testDeparturesAndOffsetsAndDescription() { diff --git a/matsim/pom.xml b/matsim/pom.xml index dcd4afd69c3..f0c0802c04e 100644 --- a/matsim/pom.xml +++ b/matsim/pom.xml @@ -167,6 +167,10 @@ org.junit.jupiter junit-jupiter + + org.hamcrest + hamcrest + org.matsim matsim-examples diff --git a/matsim/src/test/java/org/matsim/api/core/v01/AutoResetIdCaches.java b/matsim/src/test/java/org/matsim/api/core/v01/AutoResetIdCaches.java index d1145a2e37b..6cc313cbf9f 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/AutoResetIdCaches.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/AutoResetIdCaches.java @@ -20,8 +20,8 @@ package org.matsim.api.core.v01; -import org.junit.runner.Description; -import org.junit.runner.notification.RunListener; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.TestWatcher; /** * Auto-resets Id caches before each test is started. This helps to keep every single unit test independent of others @@ -48,9 +48,19 @@ * * @author Michal Maciejewski (michalm) */ -public class AutoResetIdCaches extends RunListener { +public class AutoResetIdCaches implements TestWatcher { @Override - public void testStarted(Description description) { + public void testSuccessful(ExtensionContext context) { + Id.resetCaches(); + } + + @Override + public void testAborted(ExtensionContext context, Throwable cause) { + Id.resetCaches(); + } + + @Override + public void testFailed(ExtensionContext context, Throwable cause) { Id.resetCaches(); } } diff --git a/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java b/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java index 79e6db37f10..e0b53ca6cd6 100644 --- a/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java @@ -21,7 +21,7 @@ package org.matsim.core.controler; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -36,7 +36,7 @@ public class MatsimServicesImplTest { @RegisterExtension public MatsimTestUtils utils = new MatsimTestUtils(); - @Ignore + @Disabled @Test void testIterationInServicesEqualsIterationInEvent() { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/AgentNotificationTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/AgentNotificationTest.java index 49a35771959..beb29df2294 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/AgentNotificationTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/AgentNotificationTest.java @@ -22,8 +22,7 @@ package org.matsim.core.mobsim.qsim; import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.assertThat; -import static org.junit.Assume.assumeThat; +import static org.hamcrest.MatcherAssert.assertThat; import java.util.Map; @@ -31,6 +30,7 @@ import org.hamcrest.FeatureMatcher; import org.hamcrest.Matcher; +import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -288,8 +288,7 @@ protected void configureQSim() { .build(scenario, eventsManager) // .run(); - assumeThat(handler.getEvents(), hasItem( - is(both(eventWithTime(25200.0)).and(instanceOf(PersonDepartureEvent.class))))); + Assumptions.assumeTrue(handler.getEvents().stream().anyMatch(e -> e.getTime() == 25200.0 && e instanceof PersonDepartureEvent)); assertThat(handler.getEvents(), hasItem( is(both(eventWithTime(25800.0)).and(instanceOf(MyAgentFactory.MyAgent.HomesicknessEvent.class))))); } diff --git a/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksTest.java b/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksTest.java index c1c37f3f96e..d3b5c37d7fe 100644 --- a/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksTest.java +++ b/matsim/src/test/java/org/matsim/core/network/DisallowedNextLinksTest.java @@ -11,7 +11,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.io.TempDir; -import org.junit.rules.TemporaryFolder; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; diff --git a/matsim/src/test/java/org/matsim/core/network/NetworkChangeEventsParserWriterTest.java b/matsim/src/test/java/org/matsim/core/network/NetworkChangeEventsParserWriterTest.java index 407d57d09c8..1824d8ee25e 100644 --- a/matsim/src/test/java/org/matsim/core/network/NetworkChangeEventsParserWriterTest.java +++ b/matsim/src/test/java/org/matsim/core/network/NetworkChangeEventsParserWriterTest.java @@ -37,8 +37,8 @@ import java.util.ArrayList; import java.util.List; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsCollectionContaining.hasItem; -import static org.junit.Assert.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java b/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java index 52cdbb2ca36..5d1b6ebe200 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java +++ b/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java @@ -20,7 +20,7 @@ package org.matsim.core.scoring; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -252,7 +252,7 @@ so this tests actually tests some additional (and potentially optional) behavior as it tests some non-required functionality. */ @Test - @Ignore + @Disabled void unlikelyTimingOfScoringFunctionStillWorks() { Config config = ConfigUtils.createConfig(); config.eventsManager().setNumberOfThreads(8); diff --git a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModuleTest.java b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModuleTest.java index 5c20985f8cb..ae05592d528 100644 --- a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModuleTest.java @@ -23,8 +23,8 @@ import com.google.inject.Key; import com.google.inject.Singleton; -import com.google.inject.name.Names; -import org.junit.jupiter.api.Test; +import com.google.inject.name.Names; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; @@ -50,14 +50,14 @@ import java.util.LinkedHashSet; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - +import static org.hamcrest.MatcherAssert.assertThat; + public class TravelTimeCalculatorModuleTest { @RegisterExtension - private MatsimTestUtils utils = new MatsimTestUtils(); - - @Test + private MatsimTestUtils utils = new MatsimTestUtils(); + + @Test void testOneTravelTimeCalculatorForAll() { Config config = ConfigUtils.createConfig(); config.travelTimeCalculator().setSeparateModes(false); @@ -90,10 +90,10 @@ public void install() { events.processEvent(new VehicleLeavesTrafficEvent(8.0, Id.createPersonId(1), linkId, Id.createVehicleId(1), "bike", 0.0)); assertThat(testee.getLinkTravelTimes().getLinkTravelTime(link, 0.0,null,null), is(5.0)); - } - - - @Test + } + + + @Test void testOneTravelTimeCalculatorPerMode() { Config config = ConfigUtils.createConfig(); diff --git a/matsim/src/test/java/org/matsim/core/utils/geometry/CoordUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/geometry/CoordUtilsTest.java index 958f38182ec..0f0a2865a2c 100644 --- a/matsim/src/test/java/org/matsim/core/utils/geometry/CoordUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/geometry/CoordUtilsTest.java @@ -22,7 +22,7 @@ import static org.junit.jupiter.api.Assertions.*; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -53,11 +53,11 @@ void testPlus() { Coord c2a = CoordUtils.createCoord(1.0, 1.0); Coord c2b = CoordUtils.createCoord(2.0, 2.0); Coord c2c = CoordUtils.createCoord(3.0, 3.0); - + Coord c3a = CoordUtils.createCoord(1.0, 1.0, 1.0); Coord c3b = CoordUtils.createCoord(2.0, 2.0, 2.0); Coord c3c = CoordUtils.createCoord(3.0, 3.0, 3.0); - + // 2D assertEquals(c2c, CoordUtils.plus(c2a, c2b)); // 3D @@ -84,11 +84,11 @@ void testMinus() { Coord c2a = CoordUtils.createCoord(1.0, 1.0); Coord c2b = CoordUtils.createCoord(2.0, 2.0); Coord c2c = CoordUtils.createCoord(3.0, 3.0); - + Coord c3a = CoordUtils.createCoord(1.0, 1.0, 1.0); Coord c3b = CoordUtils.createCoord(2.0, 2.0, 2.0); Coord c3c = CoordUtils.createCoord(3.0, 3.0, 3.0); - + // 2D assertEquals(c2a, CoordUtils.minus(c2c, c2b)); // 3D @@ -116,7 +116,7 @@ void testScalarMult() { Coord c2a = CoordUtils.createCoord(1.0, 1.0); Coord c2b = CoordUtils.createCoord(2.0, 2.0); assertEquals(c2b, CoordUtils.scalarMult(2.0, c2a)); - + // 3D Coord c3a = CoordUtils.createCoord(1.0, 1.0, 1.0); Coord c3b = CoordUtils.createCoord(2.0, 2.0, 2.0); @@ -130,7 +130,7 @@ void testGetCenter() { Coord c2b = CoordUtils.createCoord(2.0, 2.0); Coord c2c = CoordUtils.createCoord(1.0, 1.0); assertEquals(c2c, CoordUtils.getCenter(c2a, c2b)); - + // 3D Coord c3a = CoordUtils.createCoord(0.0, 0.0, 0.0); Coord c3b = CoordUtils.createCoord(2.0, 2.0, 2.0); @@ -170,7 +170,7 @@ void testRotateToRight() { } @Test - @Ignore + @Disabled void testGetCenterWOffset() { fail("Not yet implemented"); } @@ -185,7 +185,7 @@ void testCalcEuclideanDistance() { assertEquals(1.0, CoordUtils.calcEuclideanDistance(c2a, c2b), MatsimTestUtils.EPSILON); assertEquals(1.0, CoordUtils.calcEuclideanDistance(c2a, c2c), MatsimTestUtils.EPSILON); assertEquals(Math.sqrt(2.0), CoordUtils.calcEuclideanDistance(c2a, c2d), MatsimTestUtils.EPSILON); - + // 3D Coord c3a = CoordUtils.createCoord(0.0, 0.0, 0.0); Coord c3b = CoordUtils.createCoord(1.0, 0.0, 0.0); @@ -208,12 +208,12 @@ void testCalcProjectedDistance() { Coord c2a = CoordUtils.createCoord(0.0, 0.0); Coord c2b = CoordUtils.createCoord(1.0, 1.0); assertEquals(Math.sqrt(2.0), CoordUtils.calcProjectedEuclideanDistance(c2a, c2b), MatsimTestUtils.EPSILON); - + // 3D Coord c3a = CoordUtils.createCoord(0.0, 0.0, 0.0); Coord c3b = CoordUtils.createCoord(1.0, 1.0, 1.0); assertEquals(Math.sqrt(2.0), CoordUtils.calcProjectedEuclideanDistance(c3a, c3b), MatsimTestUtils.EPSILON); - + // Mixed 2D and 3D assertEquals(Math.sqrt(2.0), CoordUtils.calcProjectedEuclideanDistance(c2a, c3b), MatsimTestUtils.EPSILON); } @@ -222,9 +222,9 @@ void testCalcProjectedDistance() { @Test void testDistancePointLinesegment() { /* First: 2D */ - + /* * (0,1) c1 - * + * * c2 (1,0) *-------* (2,0) c3 */ Coord c1 = CoordUtils.createCoord(0.0, 1.0); @@ -234,23 +234,23 @@ void testDistancePointLinesegment() { assertEquals(Math.sqrt(2.0), dist, MatsimTestUtils.EPSILON); /* * (3,1) c1 - * + * * c2 (1,0) *-------* (2,0) c3 */ c1 = CoordUtils.createCoord(3.0, 1.0); dist = CoordUtils.distancePointLinesegment(c2, c3, c1); assertEquals(Math.sqrt(2.0), dist, MatsimTestUtils.EPSILON); - + /* * (1.5,1) c1 - * + * * c2 (1,0) *-------* (2,0) c3 */ c1 = CoordUtils.createCoord(1.5, 1.0); dist = CoordUtils.distancePointLinesegment(c2, c3, c1); assertEquals(Math.sqrt(1.0), dist, MatsimTestUtils.EPSILON); - + /* Second: 3D */ - + /* Here the line segment has first/from coordinate (1.0, 1.0, 1.0) and * a second/to coordinate (2.0, 2.0, 2.0) */ c1 = CoordUtils.createCoord(0.0, 0.0, 0.0); @@ -258,11 +258,11 @@ void testDistancePointLinesegment() { c3 = CoordUtils.createCoord(2.0, 2.0, 2.0); dist = CoordUtils.distancePointLinesegment(c2, c3, c1); assertEquals(Math.sqrt(3.0), dist, MatsimTestUtils.EPSILON); - + c1 = CoordUtils.createCoord(1.5, 1.5, 1.5); dist = CoordUtils.distancePointLinesegment(c2, c3, c1); assertEquals(0.0, dist, MatsimTestUtils.EPSILON); - + c1 = CoordUtils.createCoord(3.0, 2.0, 3.0); dist = CoordUtils.distancePointLinesegment(c2, c3, c1); assertEquals(CoordUtils.calcEuclideanDistance(c3, c1), dist, MatsimTestUtils.EPSILON); @@ -274,21 +274,21 @@ void testOrthogonalProjectionOnLineSegment(){ Coord point = CoordUtils.createCoord(2.0, 0.0); Coord lineFrom = CoordUtils.createCoord(0.0, 0.0); Coord lineTo = CoordUtils.createCoord(2.0, 2.0); - + Coord projection = CoordUtils.createCoord(1.0, 1.0); assertEquals(projection, CoordUtils.orthogonalProjectionOnLineSegment(lineFrom, lineTo, point)); - + /* Second: 3D */ lineFrom = CoordUtils.createCoord(0.0, 0.0, 0.0); lineTo = CoordUtils.createCoord(2.0, 2.0, 2.0); point = CoordUtils.createCoord(2.0, 0.0, 1.0); - + projection = CoordUtils.createCoord(1.0, 1.0, 1.0); assertEquals(projection, CoordUtils.orthogonalProjectionOnLineSegment(lineFrom, lineTo, point)); - + point = CoordUtils.createCoord(3.0, 3.0, 3.0); assertEquals(point, CoordUtils.orthogonalProjectionOnLineSegment(lineFrom, lineTo, point)); } - + } diff --git a/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlParserTest.java b/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlParserTest.java index d4d3f715283..4c300c39c09 100644 --- a/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlParserTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/io/MatsimXmlParserTest.java @@ -23,7 +23,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.io.TempDir; -import org.junit.rules.TemporaryFolder; import org.xml.sax.Attributes; import org.xml.sax.SAXParseException; diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java index 73c7bde965d..c2bf6888369 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java @@ -24,7 +24,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Assert; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -75,8 +74,7 @@ void testModifyPaths_missingSeparator() throws IOException { Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); Assertions.assertEquals("network.xml", config.network().getInputFile()); ConfigUtils.modifyFilePaths(config, "/home/username/matsim"); - Assert.assertThat(config.network().getInputFile(), anyOf(is("/home/username/matsim/network.xml"),is("/home/username/matsim\\network.xml"))); - + Assertions.assertTrue(config.network().getInputFile().equals("/home/username/matsim/network.xml") || config.network().getInputFile().equals("/home/username/matsim\\network.xml")); } @Test @@ -84,7 +82,7 @@ void testModifyPaths_withSeparator() throws IOException { Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); Assertions.assertEquals("network.xml", config.network().getInputFile()); ConfigUtils.modifyFilePaths(config, "/home/username/matsim/"); - Assert.assertThat(config.network().getInputFile(), anyOf(is("/home/username/matsim/network.xml"),is("/home/username/matsim\\network.xml"))); + Assertions.assertTrue(config.network().getInputFile().equals("/home/username/matsim/network.xml") || config.network().getInputFile().equals("/home/username/matsim\\network.xml")); } @Test diff --git a/matsim/src/test/java/org/matsim/other/DownloadAndReadXmlTest.java b/matsim/src/test/java/org/matsim/other/DownloadAndReadXmlTest.java index a7dfc337995..8b523e2ba36 100644 --- a/matsim/src/test/java/org/matsim/other/DownloadAndReadXmlTest.java +++ b/matsim/src/test/java/org/matsim/other/DownloadAndReadXmlTest.java @@ -19,8 +19,9 @@ package org.matsim.other; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; @@ -41,7 +42,7 @@ public class DownloadAndReadXmlTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils(); - @Ignore + @Disabled @Test /** * Http downloads from the SVN server will be forbidden soon, according to jwilk. */ diff --git a/matsim/src/test/java/org/matsim/population/algorithms/PersonPrepareForSimTest.java b/matsim/src/test/java/org/matsim/population/algorithms/PersonPrepareForSimTest.java index 883bef1aa26..c5bfec0e2b7 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/PersonPrepareForSimTest.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/PersonPrepareForSimTest.java @@ -22,7 +22,7 @@ import java.util.HashSet; import java.util.Set; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Coord; @@ -94,7 +94,7 @@ void testRun_MultimodalScenario() { Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); createAndAddNetwork(sc); Id link1id = Id.createLinkId("1"); - + Population pop = sc.getPopulation(); Person person; Activity a1; @@ -114,9 +114,9 @@ void testRun_MultimodalScenario() { person.addPlan(p); pop.addPerson(person); } - + new PersonPrepareForSim(new DummyRouter(), sc).run(person); - + Assertions.assertEquals(link1id, a1.getLinkId()); Assertions.assertEquals(link1id, a2.getLinkId()); // must also be linked to l1, as l2 has no car mode } @@ -149,7 +149,7 @@ void testSingleLegTripRoutingMode() { TripStructureUtils.getRoutingMode(leg), "wrong routing mode!"); } - + // test routing mode set { PopulationFactory pf = pop.getFactory(); @@ -177,8 +177,8 @@ void testSingleLegTripRoutingMode() { /** * Fallback modes are outdated with the introduction of routingMode. So, we want the simulation to crash if we encounter * them after {@link PrepareForSimImpl} was run (and adapted outdated plans). However, for the time being we do not - * explicitly check for outdated modes and hope that an exception will be thrown during routing of that single leg trip, - * because no router should be registered for those modes (and wasn't registered before introducing routingMode, besides + * explicitly check for outdated modes and hope that an exception will be thrown during routing of that single leg trip, + * because no router should be registered for those modes (and wasn't registered before introducing routingMode, besides * "transit_walk" which was also used for access/egress to pt and transfer between pt and therefore is * checked explicitly). */ @@ -209,7 +209,7 @@ void testSingleFallbackModeLegTrip() { Assertions.fail("expected Exception, got none."); } catch (RuntimeException expected) {} } - + // test outdated fallback mode single leg trip (arbitrary drt mode) { PopulationFactory pf = pop.getFactory(); @@ -240,7 +240,7 @@ void testCorrectTripsRemainUnchanged() { Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); createAndAddNetwork(sc); Population pop = sc.getPopulation(); - + // test car trip with access/egress walk legs { PopulationFactory pf = pop.getFactory(); @@ -267,20 +267,20 @@ void testCorrectTripsRemainUnchanged() { plan.addActivity(activity4); person.addPlan(plan); pop.addPerson(person); - + new PersonPrepareForSim(new DummyRouter(), sc).run(person); - + // Check leg modes remain unchanged Assertions.assertEquals(TransportMode.walk, leg1.getMode(), "wrong routing mode!"); Assertions.assertEquals(TransportMode.car, leg2.getMode(), "wrong routing mode!"); Assertions.assertEquals(TransportMode.walk, leg3.getMode(), "wrong routing mode!"); - + // Check routing mode: Assertions.assertEquals(TransportMode.car, TripStructureUtils.getRoutingMode(leg1), "wrong routing mode!"); Assertions.assertEquals(TransportMode.car, TripStructureUtils.getRoutingMode(leg2), "wrong routing mode!"); Assertions.assertEquals(TransportMode.car, TripStructureUtils.getRoutingMode(leg3), "wrong routing mode!"); } - + // test complicated intermodal trip with consistent routing modes passes unchanged { PopulationFactory pf = pop.getFactory(); @@ -345,9 +345,9 @@ void testCorrectTripsRemainUnchanged() { plan.addActivity(activity12); person.addPlan(plan); pop.addPerson(person); - + new PersonPrepareForSim(new DummyRouter(), sc).run(person); - + Assertions.assertEquals(TransportMode.pt, TripStructureUtils.getRoutingMode(leg1), "wrong routing mode set"); Assertions.assertEquals(TransportMode.pt, TripStructureUtils.getRoutingMode(leg2), "wrong routing mode set"); Assertions.assertEquals(TransportMode.pt, TripStructureUtils.getRoutingMode(leg3), "wrong routing mode set"); @@ -367,7 +367,7 @@ void testRoutingModeConsistency() { Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); createAndAddNetwork(sc); Population pop = sc.getPopulation(); - + // test trip with inconsistent routing modes causes exception { PopulationFactory pf = pop.getFactory(); @@ -392,13 +392,13 @@ void testRoutingModeConsistency() { plan.addActivity(activity4); person.addPlan(plan); pop.addPerson(person); - + try { new PersonPrepareForSim(new DummyRouter(), sc).run(person); Assertions.fail("expected Exception, got none."); } catch (RuntimeException expected) {} } - + // test trip with legs with and others without routing modes causes exception { PopulationFactory pf = pop.getFactory(); @@ -423,7 +423,7 @@ void testRoutingModeConsistency() { plan.addActivity(activity4); person.addPlan(plan); pop.addPerson(person); - + try { new PersonPrepareForSim(new DummyRouter(), sc).run(person); Assertions.fail("expected Exception, got none."); @@ -484,7 +484,7 @@ private static class DummyRouter implements PlanAlgorithm { public void run(final Plan plan) { } } - + private Link createAndAddNetwork(Scenario sc) { Network net = sc.getNetwork(); Link link1; diff --git a/matsim/src/test/java/org/matsim/population/algorithms/TestsUtil.java b/matsim/src/test/java/org/matsim/population/algorithms/TestsUtil.java index d113d5a99cc..2c18cc6e194 100644 --- a/matsim/src/test/java/org/matsim/population/algorithms/TestsUtil.java +++ b/matsim/src/test/java/org/matsim/population/algorithms/TestsUtil.java @@ -21,7 +21,7 @@ import java.util.List; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; @@ -34,7 +34,7 @@ import org.matsim.facilities.ActivityFacilitiesImpl; import org.matsim.facilities.ActivityFacility; -@Ignore +@Disabled public class TestsUtil { static Plan createPlanFromFacilities(ActivityFacilitiesImpl layer, Person person, String mode, String facString) { diff --git a/pom.xml b/pom.xml index 2b03c25e29d..a820708afc1 100644 --- a/pom.xml +++ b/pom.xml @@ -314,6 +314,18 @@ 5.8.0 test + + org.mockito + mockito-junit-jupiter + 5.8.0 + test + + + org.hamcrest + hamcrest + 2.2 + test + tech.tablesaw @@ -378,10 +390,9 @@ maven-surefire-plugin - - listener - org.matsim.api.core.v01.AutoResetIdCaches - + + true + @@ -390,10 +401,9 @@ maven-failsafe-plugin - - listener - org.matsim.api.core.v01.AutoResetIdCaches - + + true + From ae32b5956e402497a2640b90c2bb37be0d47245d Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Tue, 12 Dec 2023 16:59:41 +0100 Subject: [PATCH 17/21] fixed matsim test utils usage --- ...coringParametersFromPersonAttributesNoSubpopulationTest.java | 2 +- .../PersonScoringParametersFromPersonAttributesTest.java | 2 +- contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java | 1 - ...tilityOfMoneyPersonScoringParametersNoSubpopulationTest.java | 2 +- ...ncomeDependentUtilityOfMoneyPersonScoringParametersTest.java | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java index 3e089eaf6c9..395990c6a8c 100644 --- a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java +++ b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java @@ -51,7 +51,7 @@ public class PersonScoringParametersFromPersonAttributesNoSubpopulationTest { @RegisterExtension - private MatsimTestUtils utils; + private MatsimTestUtils utils = new MatsimTestUtils(); private PersonScoringParametersFromPersonAttributes personScoringParams; private Population population; diff --git a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java index 6202e3c83b5..72f00ce92ef 100644 --- a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java +++ b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java @@ -51,7 +51,7 @@ public class PersonScoringParametersFromPersonAttributesTest { @RegisterExtension - private MatsimTestUtils utils; + private MatsimTestUtils utils = new MatsimTestUtils(); private PersonScoringParametersFromPersonAttributes personScoringParams; private Population population; diff --git a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java index 9d9cf8230ec..a71bfc6ce8a 100644 --- a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java +++ b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java @@ -9,7 +9,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; diff --git a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java index e5c151a010e..0a0d109b4cb 100644 --- a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java @@ -29,7 +29,7 @@ public class IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest { @RegisterExtension - private MatsimTestUtils utils; + private MatsimTestUtils utils = new MatsimTestUtils(); private IncomeDependentUtilityOfMoneyPersonScoringParameters personScoringParams; private Population population; diff --git a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java index 215d1c5816e..9332cbf6bdb 100644 --- a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java @@ -29,7 +29,7 @@ public class IncomeDependentUtilityOfMoneyPersonScoringParametersTest { @RegisterExtension - private MatsimTestUtils utils; + private MatsimTestUtils utils = new MatsimTestUtils(); private IncomeDependentUtilityOfMoneyPersonScoringParameters personScoringParams; private Population population; From 76f5cc15d6fa5aff71a0bafd3c01ab937bfadf24 Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Wed, 13 Dec 2023 16:13:12 +0100 Subject: [PATCH 18/21] delete auto id reset --- .../api/core/v01/AutoResetIdCaches.java | 66 ------------------- pom.xml | 14 ---- 2 files changed, 80 deletions(-) delete mode 100644 matsim/src/test/java/org/matsim/api/core/v01/AutoResetIdCaches.java diff --git a/matsim/src/test/java/org/matsim/api/core/v01/AutoResetIdCaches.java b/matsim/src/test/java/org/matsim/api/core/v01/AutoResetIdCaches.java deleted file mode 100644 index 6cc313cbf9f..00000000000 --- a/matsim/src/test/java/org/matsim/api/core/v01/AutoResetIdCaches.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * *********************************************************************** * - * project: org.matsim.* - * *********************************************************************** * - * * - * copyright : (C) 2021 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** * - */ - -package org.matsim.api.core.v01; - -import org.junit.jupiter.api.extension.ExtensionContext; -import org.junit.jupiter.api.extension.TestWatcher; - -/** - * Auto-resets Id caches before each test is started. This helps to keep every single unit test independent of others - * (so things like execution order etc. will not impact them). - *

- * It is enabled in tests (run by maven) by registering them as listeners in the surefire and failsafe plugin configs: - *

- * {@code
- * 
- * listener
- * org.matsim.api.core.v01.IdCacheCleaner
- * 
- * }
- * 
- *

- * IntelliJ does not support junit listeners out of the box. To enable them in IntelliJ, you can install a plugin - * https://plugins.jetbrains.com/plugin/15718-junit-4-surefire-listener - *

- * Not sure about Eclipse, but it seems that an additional plugin would be required (see: - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=538885) - *

- * Since IDEs have a limited support for registering jUnit RunListeners via pom.xml, there may be cases where we need - * to explicitly reset the Id caches while setting up a test (to make them green in IDEs). - * - * @author Michal Maciejewski (michalm) - */ -public class AutoResetIdCaches implements TestWatcher { - @Override - public void testSuccessful(ExtensionContext context) { - Id.resetCaches(); - } - - @Override - public void testAborted(ExtensionContext context, Throwable cause) { - Id.resetCaches(); - } - - @Override - public void testFailed(ExtensionContext context, Throwable cause) { - Id.resetCaches(); - } -} diff --git a/pom.xml b/pom.xml index a820708afc1..1d47117e4ed 100644 --- a/pom.xml +++ b/pom.xml @@ -388,24 +388,10 @@ org.apache.maven.plugins maven-surefire-plugin - - - - true - - - org.apache.maven.plugins maven-failsafe-plugin - - - - true - - - From 2d046b0f84a1c9e3d97a1ab71df86d6ac4cedc3c Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Thu, 14 Dec 2023 10:51:16 +0100 Subject: [PATCH 19/21] add auto reset id caches --- .../api/core/v01/AutoResetIdCaches.java | 50 +++++++++++++++++++ .../org.junit.jupiter.api.extension.Extension | 1 + .../test/resources/junit-platform.properties | 1 + pom.xml | 10 ++++ .../org.junit.jupiter.api.extension.Extension | 1 + src/test/resources/junit-platform.properties | 1 + 6 files changed, 64 insertions(+) create mode 100644 matsim/src/test/java/org/matsim/api/core/v01/AutoResetIdCaches.java create mode 100644 matsim/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension create mode 100644 matsim/src/test/resources/junit-platform.properties create mode 100644 src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension create mode 100644 src/test/resources/junit-platform.properties diff --git a/matsim/src/test/java/org/matsim/api/core/v01/AutoResetIdCaches.java b/matsim/src/test/java/org/matsim/api/core/v01/AutoResetIdCaches.java new file mode 100644 index 00000000000..ec4ef401864 --- /dev/null +++ b/matsim/src/test/java/org/matsim/api/core/v01/AutoResetIdCaches.java @@ -0,0 +1,50 @@ +/* + * *********************************************************************** * + * project: org.matsim.* + * *********************************************************************** * + * * + * copyright : (C) 2021 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** * + */ + +package org.matsim.api.core.v01; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.TestInstancePostProcessor; + +/** + * Auto-resets Id caches before each test is started. This helps to keep every single unit test independent of others + * (so things like execution order etc. will not impact them). + *

+ * It is configured in the junit-platform.properties file and in META-INF/services/org.junit.jupiter.api.extension.Extension file. + * (Also see https://www.baeldung.com/junit-5-extensions) + * Both files are located in the root of the matsim project in order to inherit the auto extension in all submodules. + *

+ * IntelliJ does also recognize this configuration and will automatically enable the extension. + *

+ * For some reason, the configuration files need to be placed in the matsim module (where this class is placed). Otherwise, it won't work. + * + * @author Michal Maciejewski (michalm) + */ +public class AutoResetIdCaches implements TestInstancePostProcessor { + private static final Logger log = LogManager.getLogger(AutoResetIdCaches.class); + + @Override + public void postProcessTestInstance(Object o, ExtensionContext extensionContext) throws Exception { + log.info("Resetting Id caches."); + Id.resetCaches(); + } +} diff --git a/matsim/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension b/matsim/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension new file mode 100644 index 00000000000..b4e0250699e --- /dev/null +++ b/matsim/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension @@ -0,0 +1 @@ +org.matsim.api.core.v01.AutoResetIdCaches \ No newline at end of file diff --git a/matsim/src/test/resources/junit-platform.properties b/matsim/src/test/resources/junit-platform.properties new file mode 100644 index 00000000000..b059a65dc46 --- /dev/null +++ b/matsim/src/test/resources/junit-platform.properties @@ -0,0 +1 @@ +junit.jupiter.extensions.autodetection.enabled=true \ No newline at end of file diff --git a/pom.xml b/pom.xml index 1d47117e4ed..b25040479a6 100644 --- a/pom.xml +++ b/pom.xml @@ -453,6 +453,16 @@ + + + src/test/resources + true + + **/*.pdf + **/*.gz + + + diff --git a/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension b/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension new file mode 100644 index 00000000000..b4e0250699e --- /dev/null +++ b/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension @@ -0,0 +1 @@ +org.matsim.api.core.v01.AutoResetIdCaches \ No newline at end of file diff --git a/src/test/resources/junit-platform.properties b/src/test/resources/junit-platform.properties new file mode 100644 index 00000000000..b059a65dc46 --- /dev/null +++ b/src/test/resources/junit-platform.properties @@ -0,0 +1 @@ +junit.jupiter.extensions.autodetection.enabled=true \ No newline at end of file From 62ca2fcc7e9a33d22edf38965742deb2aa874803 Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Thu, 14 Dec 2023 12:45:16 +0100 Subject: [PATCH 20/21] implemented test watcher instead of post instance processor --- .../api/core/v01/AutoResetIdCaches.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/matsim/src/test/java/org/matsim/api/core/v01/AutoResetIdCaches.java b/matsim/src/test/java/org/matsim/api/core/v01/AutoResetIdCaches.java index ec4ef401864..8d992aaa110 100644 --- a/matsim/src/test/java/org/matsim/api/core/v01/AutoResetIdCaches.java +++ b/matsim/src/test/java/org/matsim/api/core/v01/AutoResetIdCaches.java @@ -24,6 +24,9 @@ import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.api.extension.TestInstancePostProcessor; +import org.junit.jupiter.api.extension.TestWatcher; + +import java.util.Optional; /** * Auto-resets Id caches before each test is started. This helps to keep every single unit test independent of others @@ -39,11 +42,30 @@ * * @author Michal Maciejewski (michalm) */ -public class AutoResetIdCaches implements TestInstancePostProcessor { +public class AutoResetIdCaches implements TestWatcher { private static final Logger log = LogManager.getLogger(AutoResetIdCaches.class); @Override - public void postProcessTestInstance(Object o, ExtensionContext extensionContext) throws Exception { + public void testDisabled(ExtensionContext context, Optional reason) { + resetIdCaches(); + } + + @Override + public void testSuccessful(ExtensionContext context) { + resetIdCaches(); + } + + @Override + public void testAborted(ExtensionContext context, Throwable cause) { + resetIdCaches(); + } + + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + resetIdCaches(); + } + + private void resetIdCaches() { log.info("Resetting Id caches."); Id.resetCaches(); } From ad3990cc029ad2c19309da1af28308090a3cac3a Mon Sep 17 00:00:00 2001 From: Paul Heinrich Date: Thu, 14 Dec 2023 13:49:38 +0100 Subject: [PATCH 21/21] removed unnecessary resources in pom --- pom.xml | 10 ---------- .../services/org.junit.jupiter.api.extension.Extension | 1 - src/test/resources/junit-platform.properties | 1 - 3 files changed, 12 deletions(-) delete mode 100644 src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension delete mode 100644 src/test/resources/junit-platform.properties diff --git a/pom.xml b/pom.xml index b25040479a6..1d47117e4ed 100644 --- a/pom.xml +++ b/pom.xml @@ -453,16 +453,6 @@ - - - src/test/resources - true - - **/*.pdf - **/*.gz - - - diff --git a/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension b/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension deleted file mode 100644 index b4e0250699e..00000000000 --- a/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension +++ /dev/null @@ -1 +0,0 @@ -org.matsim.api.core.v01.AutoResetIdCaches \ No newline at end of file diff --git a/src/test/resources/junit-platform.properties b/src/test/resources/junit-platform.properties deleted file mode 100644 index b059a65dc46..00000000000 --- a/src/test/resources/junit-platform.properties +++ /dev/null @@ -1 +0,0 @@ -junit.jupiter.extensions.autodetection.enabled=true \ No newline at end of file