generated from matsim-scenarios/matsim-scenario-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
106 additions
and
16 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/test/java/org/matsim/run/prepare/PrepareDrtScenarioAgentsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package org.matsim.run.prepare; | ||
|
||
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; | ||
import org.matsim.api.core.v01.TransportMode; | ||
import org.matsim.api.core.v01.population.*; | ||
import org.matsim.application.MATSimApplication; | ||
import org.matsim.core.population.PopulationUtils; | ||
import org.matsim.run.scenarios.LausitzScenario; | ||
import org.matsim.testcases.MatsimTestUtils; | ||
|
||
import java.util.List; | ||
|
||
class PrepareDrtScenarioAgentsTest { | ||
@RegisterExtension | ||
private final MatsimTestUtils utils = new MatsimTestUtils(); | ||
private static final String URL = String.format("https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/lausitz/input/v%s/", | ||
LausitzScenario.VERSION); | ||
private static final Id<Person> PERSON_ID = Id.createPersonId("642052"); | ||
|
||
@Test | ||
void testPrepareDrtScenarioAgents() { | ||
String inputPopulationPath = "./input/v1.1/lausitz-pt-case-test_experienced_plans_1person.xml.gz"; | ||
Population in = PopulationUtils.readPopulation(inputPopulationPath); | ||
String networkPath = URL + String.format("lausitz-v%s-network-with-pt.xml.gz", LausitzScenario.VERSION); | ||
String outPath = utils.getOutputDirectory() + "/drt-test-population.xml.gz"; | ||
|
||
assert MATSimApplication.execute(LausitzScenario.class, "prepare", "prepare-drt-agents", | ||
inputPopulationPath, | ||
"--network", networkPath, | ||
"--output", outPath, | ||
"--shp", "./input/shp/lausitz.shp") | ||
== 0 : "Must return non error code"; | ||
|
||
Population out = PopulationUtils.readPopulation(outPath); | ||
List<PlanElement> outSelectedPlanElements = out.getPersons().get(PERSON_ID).getSelectedPlan().getPlanElements(); | ||
|
||
// there is only 1 person in the population | ||
for (int index : PrepareDrtScenarioAgents.getNewPtLineIndexes(in.getPersons().get(PERSON_ID).getSelectedPlan())) { | ||
// access leg | ||
Assertions.assertInstanceOf(Leg.class, outSelectedPlanElements.get(index - 2)); | ||
Leg access = (Leg) outSelectedPlanElements.get(index - 2); | ||
Assertions.assertNull(access.getRoute()); | ||
Assertions.assertEquals(TransportMode.drt, access.getRoutingMode()); | ||
|
||
// interaction act before leg | ||
Assertions.assertInstanceOf(Activity.class, outSelectedPlanElements.get(index - 1)); | ||
Activity before = (Activity) outSelectedPlanElements.get(index - 1); | ||
Assertions.assertNull(before.getCoord()); | ||
Assertions.assertNull(before.getFacilityId()); | ||
Assertions.assertEquals("drt interaction", before.getType()); | ||
|
||
// pt leg which was converted to drt leg | ||
Assertions.assertInstanceOf(Leg.class, outSelectedPlanElements.get(index)); | ||
Leg leg = (Leg) outSelectedPlanElements.get(index); | ||
Assertions.assertNull(leg.getRoute()); | ||
Assertions.assertEquals(TransportMode.drt, leg.getMode()); | ||
|
||
// interaction act after leg | ||
Assertions.assertInstanceOf(Activity.class, outSelectedPlanElements.get(index + 1)); | ||
Activity after = (Activity) outSelectedPlanElements.get(index + 1); | ||
Assertions.assertNull(after.getCoord()); | ||
Assertions.assertNull(after.getFacilityId()); | ||
Assertions.assertEquals("drt interaction", after.getType()); | ||
|
||
// egress leg | ||
Assertions.assertInstanceOf(Leg.class, outSelectedPlanElements.get(index + 2)); | ||
Leg egress = (Leg) outSelectedPlanElements.get(index + 2); | ||
Assertions.assertNull(egress.getRoute()); | ||
Assertions.assertEquals(TransportMode.drt, egress.getRoutingMode()); | ||
} | ||
} | ||
} |