String inputFilePath =
this.getClass().getResource("/com/pc/dailymile/cli/runkeeper/runkeeper.csv")
.getFile();
RunKeeperConverter rkc = new RunKeeperConverter(inputFilePath);
CSVReader reader = null;
try {
reader = new CSVReader(new FileReader(inputFilePath));
List<String[]> lines = reader.readAll();
//first row is headers, so start at 1
String[] nextLine = lines.get(1);
Workout wo = rkc.createWorkout(nextLine);
assertEquals(Type.Running, wo.getType());
assertEquals(1740L, wo.getDuration().longValue());
assertEquals(Units.kilometers, wo.getDistanceUnits());
assertEquals("1.17", wo.getDistanceValue());
nextLine = lines.get(2);
wo = rkc.createWorkout(nextLine);
assertEquals(Type.Walking, wo.getType());
assertEquals(1241L, wo.getDuration().longValue());
assertEquals(Units.kilometers, wo.getDistanceUnits());
assertEquals("0.96", wo.getDistanceValue());
} catch (Exception e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (Exception e) {
// ignore
}
}
}