Assert.assertFalse(edge1.hasValues());
Assert.assertEquals(0, edge1.numLanes());
try {
StatLane lane1 = new StatLane("dummy1_0", 6.0, 100.0, 9.0, 14.4,
22.7, 4, 6, 3, 9);
lane1.setMaxSpeed(30.0);
lane1.setMinSpeed(5.0);
StatLane lane2 = new StatLane("dummy1_1", 10.0, 200.0, 2.0, 7.2,
20.1, 0, 8, 0, 8);
lane2.setMaxSpeed(60.0);
lane2.setMinSpeed(0.0);
edge1.addStatLane(lane1);
edge1.addStatLane(lane2);
Assert.assertEquals(2, edge1.numLanes());
} catch (Exception e) {
e.printStackTrace();
Assert.fail();
}
// edge should have mean data of his child lanes, as soon as first
// value is accessed
Assert.assertEquals(8.0, edge1.getValue(Value.TRAVELTIME));
Assert.assertTrue(edge1.hasValues());
Assert.assertEquals(150.0, edge1.getValue(Value.SAMPLEDSECONDS));
Assert.assertEquals(5.5, edge1.getValue(Value.DENSITY));
Assert.assertEquals(10.8, edge1.getValue(Value.OCCUPANCY));
Assert.assertEquals(21.4, edge1.getValue(Value.SPEED));
Assert.assertEquals(2, edge1.getValue(Value.NRSTOPS),0);
Assert.assertEquals(7, edge1.getValue(Value.VEHICLESENTERED),0);
Assert.assertEquals(1, edge1.getValue(Value.VEHICLESEMITTED),0);
Assert.assertEquals(8, edge1.getValue(Value.VEHICLESLEFT),0);
Assert.assertEquals(45.0, edge1.getValue(Value.MAXSPEED),0);
Assert.assertEquals(2.5, edge1.getValue(Value.MINSPEED),0);
// test edge without child lanes
StatEdge edge2 = new StatEdge("dummy1");
Assert.assertEquals(0.0, edge2.getValue(Value.TRAVELTIME));
Assert.assertEquals(0.0, edge2.getValue(Value.SAMPLEDSECONDS));
Assert.assertEquals(0.0, edge2.getValue(Value.DENSITY));
Assert.assertEquals(0.0, edge2.getValue(Value.OCCUPANCY));
Assert.assertEquals(0.0, edge2.getValue(Value.SPEED));
Assert.assertEquals(0, edge2.getValue(Value.NRSTOPS),0);
Assert.assertEquals(0, edge2.getValue(Value.VEHICLESENTERED),0);
Assert.assertEquals(0, edge2.getValue(Value.VEHICLESEMITTED),0);
Assert.assertEquals(0, edge2.getValue(Value.VEHICLESLEFT),0);
Assert.assertFalse(edge2.hasValues());
Assert.assertEquals(0, edge2.numLanes());
// test edge with values AND childs
// should return values of edge only, no mean values
StatEdge edge3 = new StatEdge("dummy3", 10.0, 200.0, 8.9, 14.4, 22.7,
4, 6, 3, 9);
Assert.assertEquals("dummy3", edge3.getId());
Assert.assertEquals(10.0, edge3.getValue(Value.TRAVELTIME));
Assert.assertEquals(200.0, edge3.getValue(Value.SAMPLEDSECONDS));
Assert.assertEquals(8.9, edge3.getValue(Value.DENSITY));
Assert.assertEquals(14.4, edge3.getValue(Value.OCCUPANCY));
Assert.assertEquals(22.7, edge3.getValue(Value.SPEED));
Assert.assertEquals(4, edge3.getValue(Value.NRSTOPS),0);
Assert.assertEquals(6, edge3.getValue(Value.VEHICLESENTERED),0);
Assert.assertEquals(3, edge3.getValue(Value.VEHICLESEMITTED),0);
Assert.assertEquals(9, edge3.getValue(Value.VEHICLESLEFT),0);
Assert.assertTrue(edge3.hasValues());
Assert.assertEquals(0, edge3.numLanes());
// add two lanes
try {
StatLane lane3 = new StatLane("dummy1_0", 6.0, 100.0, 9.0, 14.4,
22.7, 4, 6, 3, 9);
lane3.setMaxSpeed(30.0);
lane3.setMinSpeed(5.0);
StatLane lane4 = new StatLane("dummy1_1", 10.0, 200.0, 2.0, 7.2,
20.1, 0, 8, 0, 8);
lane4.setMaxSpeed(60.0);
lane4.setMinSpeed(0.0);
edge3.addStatLane(lane3);
edge3.addStatLane(lane4);
Assert.assertEquals(2, edge1.numLanes());
} catch (Exception e) {
e.printStackTrace();