ShapePoint p3 = point(47.654265901710744, -122.30511511259459);
List<ShapePoint> points = Arrays.asList(p1, p2, p3);
Mockito.when(gtfsDao.getShapePointsForShapeId(shapeId)).thenReturn(points);
ShapePoints shapePoints = helper.getShapePointsForShapeId(shapeId);
assertEquals(3, shapePoints.getSize());
for (int i = 0; i < 3; i++) {
assertEquals(points.get(i).getLat(), shapePoints.getLatForIndex(i), 1e-7);
assertEquals(points.get(i).getLon(), shapePoints.getLonForIndex(i), 1e-7);
}
assertEquals(0.0, shapePoints.getDistTraveledForIndex(0), 0.01);
assertEquals(122.79, shapePoints.getDistTraveledForIndex(1), 0.01);
assertEquals(243.66, shapePoints.getDistTraveledForIndex(2), 0.01);
helper.getShapePointsForShapeId(shapeId);
// The second call should be cached
Mockito.verify(gtfsDao, Mockito.times(1)).getShapePointsForShapeId(shapeId);