@Test public void snapshots() throws IOException, ParseException { Reader reader = new InputStreamReader(getClass().getResourceAsStream("/snapshots.tcx")); TCX2Workout to = new TCX2Workout(reader).workout(); Workout workout = to.getWorkout(); assertEquals(Mon_Jun_15_2015 + (60 * 1000), (long)workout.start.get()); assertEquals(3, (int)workout.duration.get()); assertEquals(6, (int)workout.distance.get()); assertEquals(2, (int)workout.strokes.get()); assertEquals(3, (int)workout.energy.get()); List<Snapshot> snapshots = to.getSnapshots(); assertEquals(3, snapshots.size()); Snapshot snapshot = snapshots.get(0); assertEquals(4_50, (int)snapshot.speed.get()); assertEquals(80, (int)snapshot.pulse.get()); assertEquals(25, (int)snapshot.strokeRate.get()); assertEquals(2, (int)snapshot.distance.get()); assertEquals(0, (int)snapshot.strokes.get()); assertEquals(0, (int)snapshot.power.get()); snapshot = snapshots.get(1); assertEquals(4_51, (int)snapshot.speed.get()); assertEquals(81, (int)snapshot.pulse.get()); assertEquals(26, (int)snapshot.strokeRate.get()); assertEquals(4, (int)snapshot.distance.get()); assertEquals(0, (int)snapshot.strokes.get()); assertEquals(1, (int)snapshot.power.get()); snapshot = snapshots.get(2); assertEquals(4_52, (int)snapshot.speed.get()); assertEquals(82, (int)snapshot.pulse.get()); assertEquals(27, (int)snapshot.strokeRate.get()); assertEquals(6, (int)snapshot.distance.get()); assertEquals(0, (int)snapshot.strokes.get()); assertEquals(2, (int)snapshot.power.get()); assertEquals("Test Program", to.getProgramName()); }
private List<Snapshot> snapshots(Workout workout) throws IOException { List<Snapshot> snapshots = new ArrayList<>(); if (navigator.descent("Track")) { while (navigator.descent("Trackpoint")) { if (snapshots.size() == 0) { workout.location.set(location()); } snapshots.add(snapshot()); navigator.ascent(); } navigator.ascent(); } return snapshots; }
TCX2Workout { private List<Snapshot> snapshots(Workout workout) throws IOException { List<Snapshot> snapshots = new ArrayList<>(); if (navigator.descent("Track")) { while (navigator.descent("Trackpoint")) { if (snapshots.size() == 0) { workout.location.set(location()); } snapshots.add(snapshot()); navigator.ascent(); } navigator.ascent(); } return snapshots; } }
TCX2Workout { private List<Snapshot> snapshots(Workout workout) throws IOException { List<Snapshot> snapshots = new ArrayList<>(); if (navigator.descent("Track")) { while (navigator.descent("Trackpoint")) { if (snapshots.size() == 0) { workout.location.set(location()); } snapshots.add(snapshot()); navigator.ascent(); } navigator.ascent(); } return snapshots; } TCX2Workout(Reader reader); }
TCX2Workout { private List<Snapshot> snapshots(Workout workout) throws IOException { List<Snapshot> snapshots = new ArrayList<>(); if (navigator.descent("Track")) { while (navigator.descent("Trackpoint")) { if (snapshots.size() == 0) { workout.location.set(location()); } snapshots.add(snapshot()); navigator.ascent(); } navigator.ascent(); } return snapshots; } TCX2Workout(Reader reader); Workout getWorkout(); List<Snapshot> getSnapshots(); String getProgramName(); TCX2Workout workout(); }
TCX2Workout { private List<Snapshot> snapshots(Workout workout) throws IOException { List<Snapshot> snapshots = new ArrayList<>(); if (navigator.descent("Track")) { while (navigator.descent("Trackpoint")) { if (snapshots.size() == 0) { workout.location.set(location()); } snapshots.add(snapshot()); navigator.ascent(); } navigator.ascent(); } return snapshots; } TCX2Workout(Reader reader); Workout getWorkout(); List<Snapshot> getSnapshots(); String getProgramName(); TCX2Workout workout();  }