@Test public void testGetNodes_Empty() { Network network = getTestNetwork(); List<Node> nodes = NetworkUtils.getNodes(network, ""); assertEquals(0, nodes.size()); List<Node> nodes2 = NetworkUtils.getNodes(network, " "); assertEquals(0, nodes2.size()); List<Node> nodes3 = NetworkUtils.getNodes(network, " \t\r\n \t \t "); assertEquals(0, nodes3.size()); }
private void startAct(final Attributes atts) { if (atts.getValue("zone") != null) { log.info("The attribute 'zone' of <act> will be ignored"); } Activity act; if (atts.getValue("link") != null) { Id<Link> linkId = Id.create(atts.getValue("link"), Link.class); final Id<Link> linkId1 = linkId; act = PopulationUtils.createAndAddActivityFromLinkId(this.currplan, atts.getValue("type"), linkId1); if (atts.getValue(ATTR_X100) != null && atts.getValue(ATTR_Y100) != null) { final Coord coord = parseCoord( atts ); act.setCoord(coord); } } else if (atts.getValue(ATTR_X100) != null && atts.getValue(ATTR_Y100) != null) { final Coord coord = parseCoord( atts ); act = PopulationUtils.createAndAddActivityFromCoord(this.currplan, atts.getValue("type"), coord); } else { throw new IllegalArgumentException("Either the coords or the link must be specified for an Act."); } act.setStartTime(Time.parseTime(atts.getValue("start_time"))); act.setMaximumDuration(Time.parseTime(atts.getValue("dur"))); act.setEndTime(Time.parseTime(atts.getValue("end_time"))); if (this.routeNodes != null) { this.currroute.setLinkIds(this.prevAct.getLinkId(), NetworkUtils.getLinkIds(RouteUtils.getLinksFromNodes(NetworkUtils.getNodes(this.network, this.routeNodes))), act.getLinkId()); this.routeNodes = null; this.currroute = null; } this.prevAct = act; }
private void startAct(final Attributes atts) { Activity act = null; if (atts.getValue("link") != null) { final Id<Link> linkId = Id.create(atts.getValue("link"), Link.class); act = PopulationUtils.createAndAddActivityFromLinkId(this.currplan, atts.getValue("type"), linkId); if (atts.getValue(ATTR_X100) != null && atts.getValue(ATTR_Y100) != null) { final Coord coord = parseCoord( atts ); act.setCoord(coord); } } else if (atts.getValue(ATTR_X100) != null && atts.getValue(ATTR_Y100) != null) { final Coord coord = parseCoord( atts ); act = PopulationUtils.createAndAddActivityFromCoord(this.currplan, atts.getValue("type"), coord); } else { throw new IllegalArgumentException("Either the coords or the link must be specified for an Act."); } act.setStartTime(Time.parseTime(atts.getValue("start_time"))); act.setMaximumDuration(Time.parseTime(atts.getValue("dur"))); act.setEndTime(Time.parseTime(atts.getValue("end_time"))); if (this.routeNodes != null) { this.currroute.setLinkIds(this.prevAct.getLinkId(), NetworkUtils.getLinkIds(RouteUtils.getLinksFromNodes(NetworkUtils.getNodes(this.network, this.routeNodes))), act.getLinkId()); this.routeNodes = null; this.currroute = null; } this.prevAct = act; }
@Test public void testGetNodes_NonExistant() { Network network = getTestNetwork(); try { NetworkUtils.getNodes(network, "1 3 ab 5"); fail("expected Exception, but didn't happen."); } catch (IllegalArgumentException e) { log.info("catched expected exception: " + e.getMessage()); } }
@Test public void testGetNodes_Null() { Network network = getTestNetwork(); List<Node> nodes = NetworkUtils.getNodes(network, null); assertEquals(0, nodes.size()); }
((NetworkRoute) this.currRoute).setLinkIds(startLinkId, NetworkUtils.getLinkIds(RouteUtils .getLinksFromNodes(NetworkUtils.getNodes( this.network, this.routeDescription))), endLinkId);
@Test public void testGetNodes_mixedDelimiters() { Network network = getTestNetwork(); List<Node> nodes = NetworkUtils.getNodes(network, " 1\t\t2 \n4\t \t5 3 "); assertEquals(5, nodes.size()); assertEquals(network.getNodes().get(Id.create(1, Node.class)), nodes.get(0)); assertEquals(network.getNodes().get(Id.create(2, Node.class)), nodes.get(1)); assertEquals(network.getNodes().get(Id.create(4, Node.class)), nodes.get(2)); assertEquals(network.getNodes().get(Id.create(5, Node.class)), nodes.get(3)); assertEquals(network.getNodes().get(Id.create(3, Node.class)), nodes.get(4)); }