/** * @author mrieser */ @Test public void testReadActivity() { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); final Population population = scenario.getPopulation(); PopulationReaderMatsimV5 reader = new PopulationReaderMatsimV5(scenario); Stack<String> context = new Stack<String>(); // not sure the context is ever used in the reader... reader.startTag("population", AttributesBuilder.getEmpty(), context); reader.startTag("person", new AttributesBuilder().add("id", "2").get(), context); reader.startTag("plan", new AttributesBuilder().add("selected", "no").get(), context); reader.startTag("act", new AttributesBuilder().add("type", "h").add("link", "3").get(), context); reader.endTag("act", "", context); reader.startTag("leg", new AttributesBuilder().add("mode", "car").get(), context); reader.endTag("leg", "", context); reader.startTag("act", new AttributesBuilder().add("type", "h").add("link", "2").get(), context); reader.endTag("plan", "", context); reader.endTag("person", "", context); reader.endTag("population", "", context); Assert.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()); }
parser.startTag("plan", new AttributesBuilder().add("selected", "yes").get(), context); parser.startTag("act", new AttributesBuilder().add("type", "h").add("x", "125").add("y", "500").add("end_time", "08:00:00").get(), context); parser.endTag("act", null, context); parser.startTag("leg", new AttributesBuilder().add("mode", "pt").get(), context); parser.startTag("route", new AttributesBuilder().add("type", "links").get(), context); parser.endTag("route", " ", context); parser.endTag("leg", null, context); parser.startTag("act", new AttributesBuilder().add("type", "w").add("x", "500").add("y", "1100").add("start_time", "10:05:00").get(), context); parser.endTag("act", null, context); parser.endTag("plan", null, context); parser.endTag("person", null, context); parser.endTag("population", null, context);