Skip to content

Commit

Permalink
update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Jan 24, 2024
1 parent 8149ee8 commit f92ed80
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/test/java/org/matsim/run/RunLeipzigIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.matsim.analysis.ParkingLocation;
import org.matsim.api.core.v01.Id;
Expand All @@ -10,9 +11,13 @@
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.controler.OutputDirectoryHierarchy;
import org.matsim.core.events.EventsUtils;
import org.matsim.core.network.NetworkUtils;
import org.matsim.simwrapper.SimWrapperConfigGroup;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.utils.eventsfilecomparison.EventsFileComparator;

import java.io.File;
import java.nio.file.Path;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -23,30 +28,34 @@ public class RunLeipzigIntegrationTest {
private static final String URL = "https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/leipzig/leipzig-v1.2/input/";
private static final String exampleShp = "input/v1.3/drtServiceArea/Leipzig_stadt.shp";

@Rule
public MatsimTestUtils utils = new MatsimTestUtils();

@Test
public final void runPoint1pctIntegrationTest() {
Path output = Path.of("output/it-1pct");

Config config = ConfigUtils.loadConfig("input/v1.3/leipzig-v1.3-10pct.config.xml");

config.global().setNumberOfThreads(1);
config.qsim().setNumberOfThreads(1);
config.controler().setLastIteration(1);
config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists);
config.controler().setOutputDirectory(output.toString());
config.controler().setOutputDirectory(utils.getOutputDirectory());
config.plans().setInputFile(URL + "leipzig-v1.2-0.1pct.plans-initial.xml.gz");

ConfigUtils.addOrGetModule(config, SimWrapperConfigGroup.class).defaultDashboards = SimWrapperConfigGroup.Mode.disabled;

MATSimApplication.execute(RunLeipzigScenario.class, config, "run", "--1pct", "--slow-speed-area", exampleShp,
"--slow-speed-relative-change", "0.5","--drt-area", exampleShp, "--post-processing", "disabled"
"--slow-speed-relative-change", "0.5", "--drt-area", exampleShp, "--post-processing", "disabled"
);

assertThat(output)
.exists()
.isNotEmptyDirectory();
assertThat(EventsUtils.compareEventsFiles(
new File(utils.getOutputDirectory(), "leipzig-1pct.output_events.xml.gz").toString(),
new File(utils.getClassInputDirectory(), "runPoint1pctIntegrationTest_events.xml.zst").toString()
)).isEqualTo(EventsFileComparator.Result.FILES_ARE_EQUAL);


Network network = NetworkUtils.readNetwork(output + "/" + config.controler().getRunId() + ".output_network.xml.gz");
Network network = NetworkUtils.readNetwork(utils.getOutputDirectory() + "/" + config.controler().getRunId() + ".output_network.xml.gz");
assertTrue(network.getLinks().get(Id.createLinkId("24232899")).getFreespeed() < 12.501000000000001);
assertTrue(network.getLinks().get(Id.createLinkId("24675139")).getFreespeed() < 7.497);
}
Expand Down Expand Up @@ -91,7 +100,7 @@ public final void runOptDrtExamplePopulationTest() {
ConfigUtils.addOrGetModule(config, SimWrapperConfigGroup.class).defaultDashboards = SimWrapperConfigGroup.Mode.disabled;

MATSimApplication.execute(RunLeipzigScenario.class, config, "run", "--1pct", "--drt-area", exampleShp,
"--drt-modes", "drtNorth,drtSoutheast", "--waiting-time-threshold-optDrt", "600", "--post-processing", "disabled");
"--drt-modes", "drtNorth,drtSoutheast", "--waiting-time-threshold-optDrt", "600", "--post-processing", "disabled");

Assert.assertNotNull(config.getModules().get("multiModeOptDrt"));
Assert.assertNotNull(config.getModules().get("multiModeOptDrt").getParameterSets());
Expand Down
Binary file not shown.

0 comments on commit f92ed80

Please sign in to comment.