Program: 168424
Project: 168424
Buggy source:
/** 
 * This method tests the parser with an Polar S510 raw exercise file recorded in metric units. This test is taken from the C# test class so the code could be better :-)
 */
@Test public void testParseS510ExerciseCyclingWithMetricUnits() throws EVException {
  EVExercise exercise=parser.parseExercise("String_Node_Str");
  assertEquals(exercise.getFileType(),EVExercise.ExerciseFileType.S510RAW);
  assertEquals(exercise.getUserID(),(byte)1);
  Calendar date=Calendar.getInstance();
  date.setTime(exercise.getDate());
  assertEquals(3,date.get(Calendar.DAY_OF_MONTH));
  assertEquals(10,date.get(Calendar.MONTH));
  assertEquals(2007,date.get(Calendar.YEAR));
  assertEquals(11,date.get(Calendar.HOUR_OF_DAY));
  assertEquals(03,date.get(Calendar.MINUTE));
  assertEquals(exercise.getType(),(byte)0);
  assertEquals(exercise.getTypeLabel(),"String_Node_Str");
  assertEquals(exercise.getRecordingMode().isAltitude(),false);
  assertEquals(exercise.getRecordingMode().isSpeed(),true);
  assertEquals(exercise.getRecordingMode().isCadence(),false);
  assertEquals(exercise.getRecordingMode().isPower(),false);
  assertEquals(exercise.getRecordingMode().getBikeNumber(),(byte)2);
  assertEquals(exercise.getDuration(),10 * ((2 * 60 * 60) + (14 * 60) + 51) + 5);
  assertEquals(exercise.getRecordingInterval(),(short)120);
  assertEquals(exercise.getHeartRateAVG(),(short)171);
  assertEquals(exercise.getHeartRateMax(),(short)194);
  assertEquals(exercise.getSpeed().getDistance(),45800);
  assertEquals(Math.round(exercise.getSpeed().getSpeedAVG() * 10),206);
  assertEquals(Math.round(exercise.getSpeed().getSpeedMax() * 10),494);
  assertEquals(exercise.getCadence(),null);
  assertEquals(exercise.getAltitude(),null);
  assertEquals(exercise.getTemperature(),null);
  assertEquals(exercise.getEnergy(),1616);
  assertEquals(exercise.getEnergyTotal(),160947);
  assertEquals(exercise.getSumExerciseTime(),(644 * 60) + 41);
  assertEquals(exercise.getSumRideTime(),8173);
  assertEquals(exercise.getOdometer(),3007);
  assertEquals(exercise.getHeartRateLimits().length,3);
  assertTrue(exercise.getHeartRateLimits()[0].isAbsoluteRange());
  assertEquals(exercise.getHeartRateLimits()[0].getLowerHeartRate(),(short)150);
  assertEquals(exercise.getHeartRateLimits()[0].getUpperHeartRate(),(short)160);
  assertEquals(exercise.getHeartRateLimits()[0].getTimeBelow(),(0 * 60 * 60) + (0 * 60) + 0);
  assertEquals(exercise.getHeartRateLimits()[0].getTimeWithin(),(0 * 60 * 60) + (0 * 60) + 0);
  assertEquals(exercise.getHeartRateLimits()[0].getTimeAbove(),(0 * 60 * 60) + (0 * 60) + 0);
  assertTrue(exercise.getHeartRateLimits()[1].isAbsoluteRange());
  assertEquals(exercise.getHeartRateLimits()[1].getLowerHeartRate(),(short)183);
  assertEquals(exercise.getHeartRateLimits()[1].getUpperHeartRate(),(short)187);
  assertEquals(exercise.getHeartRateLimits()[1].getTimeBelow(),(0 * 60 * 60) + (0 * 60) + 0);
  assertEquals(exercise.getHeartRateLimits()[1].getTimeWithin(),(0 * 60 * 60) + (0 * 60) + 0);
  assertEquals(exercise.getHeartRateLimits()[1].getTimeAbove(),(0 * 60 * 60) + (0 * 60) + 0);
  assertTrue(exercise.getHeartRateLimits()[2].isAbsoluteRange());
  assertEquals(exercise.getHeartRateLimits()[2].getLowerHeartRate(),(short)90);
  assertEquals(exercise.getHeartRateLimits()[2].getUpperHeartRate(),(short)130);
  assertEquals(exercise.getHeartRateLimits()[2].getTimeBelow(),(0 * 60 * 60) + (0 * 60) + 0);
  assertEquals(exercise.getHeartRateLimits()[2].getTimeWithin(),(0 * 60 * 60) + (0 * 60) + 0);
  assertEquals(exercise.getHeartRateLimits()[2].getTimeAbove(),(0 * 60 * 60) + (0 * 60) + 0);
  assertEquals(exercise.getLapList().length,2);
  assertEquals(exercise.getLapList()[0].getTimeSplit(),(1 * 60 * 60* 10) + (31 * 60 * 10) + (11 * 10)+ 7);
  assertEquals(exercise.getLapList()[0].getHeartRateSplit(),(short)156);
  assertEquals(exercise.getLapList()[0].getHeartRateAVG(),(short)173);
  assertEquals(exercise.getLapList()[0].getHeartRateMax(),(short)194);
  assertEquals(Math.round(exercise.getLapList()[0].getSpeed().getSpeedEnd() * 10),164);
  assertEquals(Math.round(exercise.getLapList()[0].getSpeed().getDistance() / 100),310);
  assertEquals(exercise.getLapList()[0].getAltitude(),null);
  assertEquals(exercise.getLapList()[0].getTemperature(),null);
  assertEquals(exercise.getLapList()[1].getTimeSplit(),(2 * 60 * 60* 10) + (14 * 60 * 10) + (51 * 10)+ 5);
  assertEquals(exercise.getLapList()[1].getHeartRateSplit(),(short)155);
  assertEquals(exercise.getLapList()[1].getHeartRateAVG(),(short)169);
  assertEquals(exercise.getLapList()[1].getHeartRateMax(),(short)189);
  assertEquals(Math.round(exercise.getLapList()[1].getSpeed().getSpeedEnd() * 10),3);
  assertEquals(Math.round(exercise.getLapList()[1].getSpeed().getDistance() / 100),458);
  assertEquals(exercise.getLapList()[1].getAltitude(),null);
  assertEquals(exercise.getLapList()[1].getTemperature(),null);
  assertEquals(exercise.getSampleList().length,67);
  assertEquals(0,exercise.getSampleList()[0].getTimestamp());
  assertEquals(exercise.getSampleList()[0].getHeartRate(),(short)152);
  assertEquals(exercise.getSampleList()[0].getAltitude(),(short)0);
  assertEquals(Math.round(exercise.getSampleList()[0].getSpeed() * 10),230);
  assertEquals(exercise.getSampleList()[0].getCadence(),(short)0);
  assertEquals(exercise.getSampleList()[0].getDistance(),0);
  assertEquals(24 * 120 * 1000,exercise.getSampleList()[24].getTimestamp());
  assertEquals(exercise.getSampleList()[24].getHeartRate(),(short)165);
  assertEquals(exercise.getSampleList()[24].getAltitude(),(short)0);
  assertEquals(Math.round(exercise.getSampleList()[24].getSpeed() * 10),270);
  assertEquals(exercise.getSampleList()[24].getCadence(),(short)0);
  assertEquals(exercise.getSampleList()[24].getDistance(),16500);
  assertEquals(48 * 120 * 1000,exercise.getSampleList()[48].getTimestamp());
  assertEquals(exercise.getSampleList()[48].getHeartRate(),(short)164);
  assertEquals(exercise.getSampleList()[48].getAltitude(),(short)0);
  assertEquals(Math.round(exercise.getSampleList()[48].getSpeed() * 10),190);
  assertEquals(exercise.getSampleList()[48].getCadence(),(short)0);
  assertEquals(exercise.getSampleList()[48].getDistance(),32933);
  assertEquals(66 * 120 * 1000,exercise.getSampleList()[66].getTimestamp());
  assertEquals(exercise.getSampleList()[66].getHeartRate(),(short)161);
  assertEquals(exercise.getSampleList()[66].getAltitude(),(short)0);
  assertEquals(Math.round(exercise.getSampleList()[66].getSpeed() * 10),210);
  assertEquals(exercise.getSampleList()[66].getCadence(),(short)0);
  assertEquals(exercise.getSampleList()[66].getDistance(),45800);
}

Fixed version (ground truth):
/** 
 * This method tests the parser with an Polar S510 raw exercise file recorded in metric units. This test is taken from the C# test class so the code could be better :-)
 */
@Test public void testParseS510ExerciseCyclingWithMetricUnits() throws EVException {
  EVExercise exercise=parser.parseExercise("String_Node_Str");
  assertEquals(exercise.getFileType(),EVExercise.ExerciseFileType.S510RAW);
  assertEquals(exercise.getUserID(),(byte)1);
  Calendar date=Calendar.getInstance();
  date.setTime(exercise.getDate());
  assertEquals(3,date.get(Calendar.DAY_OF_MONTH));
  assertEquals(10,date.get(Calendar.MONTH));
  assertEquals(2007,date.get(Calendar.YEAR));
  assertEquals(11,date.get(Calendar.HOUR_OF_DAY));
  assertEquals(03,date.get(Calendar.MINUTE));
  assertEquals(exercise.getType(),(byte)0);
  assertEquals(exercise.getTypeLabel(),"String_Node_Str");
  assertEquals(exercise.getRecordingMode().isAltitude(),false);
  assertEquals(exercise.getRecordingMode().isSpeed(),true);
  assertEquals(exercise.getRecordingMode().isCadence(),false);
  assertEquals(exercise.getRecordingMode().isPower(),false);
  assertEquals(exercise.getRecordingMode().getBikeNumber(),(byte)2);
  assertEquals(exercise.getDuration(),10 * ((2 * 60 * 60) + (14 * 60) + 51) + 5);
  assertEquals(exercise.getRecordingInterval(),(short)120);
  assertEquals(exercise.getHeartRateAVG(),(short)171);
  assertEquals(exercise.getHeartRateMax(),(short)194);
  assertEquals(exercise.getSpeed().getDistance(),45800);
  assertEquals(Math.round(exercise.getSpeed().getSpeedAVG() * 10),206);
  assertEquals(Math.round(exercise.getSpeed().getSpeedMax() * 10),494);
  assertEquals(exercise.getCadence(),null);
  assertEquals(exercise.getAltitude(),null);
  assertEquals(exercise.getTemperature(),null);
  assertEquals(exercise.getEnergy(),1616);
  assertEquals(exercise.getEnergyTotal(),160947);
  assertEquals(exercise.getSumExerciseTime(),(644 * 60) + 41);
  assertEquals(exercise.getSumRideTime(),8173);
  assertEquals(exercise.getOdometer(),3007);
  assertEquals(exercise.getHeartRateLimits().length,3);
  assertTrue(exercise.getHeartRateLimits()[0].isAbsoluteRange());
  assertEquals(exercise.getHeartRateLimits()[0].getLowerHeartRate(),(short)150);
  assertEquals(exercise.getHeartRateLimits()[0].getUpperHeartRate(),(short)160);
  assertEquals(exercise.getHeartRateLimits()[0].getTimeBelow(),(0 * 60 * 60) + (0 * 60) + 0);
  assertEquals(exercise.getHeartRateLimits()[0].getTimeWithin(),(0 * 60 * 60) + (0 * 60) + 0);
  assertEquals(exercise.getHeartRateLimits()[0].getTimeAbove(),(0 * 60 * 60) + (0 * 60) + 0);
  assertTrue(exercise.getHeartRateLimits()[1].isAbsoluteRange());
  assertEquals(exercise.getHeartRateLimits()[1].getLowerHeartRate(),(short)183);
  assertEquals(exercise.getHeartRateLimits()[1].getUpperHeartRate(),(short)187);
  assertEquals(exercise.getHeartRateLimits()[1].getTimeBelow(),(0 * 60 * 60) + (0 * 60) + 0);
  assertEquals(exercise.getHeartRateLimits()[1].getTimeWithin(),(0 * 60 * 60) + (0 * 60) + 0);
  assertEquals(exercise.getHeartRateLimits()[1].getTimeAbove(),(0 * 60 * 60) + (0 * 60) + 0);
  assertTrue(exercise.getHeartRateLimits()[2].isAbsoluteRange());
  assertEquals(exercise.getHeartRateLimits()[2].getLowerHeartRate(),(short)90);
  assertEquals(exercise.getHeartRateLimits()[2].getUpperHeartRate(),(short)130);
  assertEquals(exercise.getHeartRateLimits()[2].getTimeBelow(),(0 * 60 * 60) + (0 * 60) + 0);
  assertEquals(exercise.getHeartRateLimits()[2].getTimeWithin(),(0 * 60 * 60) + (0 * 60) + 0);
  assertEquals(exercise.getHeartRateLimits()[2].getTimeAbove(),(0 * 60 * 60) + (0 * 60) + 0);
  assertEquals(exercise.getLapList().length,2);
  assertEquals(exercise.getLapList()[0].getTimeSplit(),(1 * 60 * 60* 10) + (31 * 60 * 10) + (11 * 10)+ 7);
  assertEquals(exercise.getLapList()[0].getHeartRateSplit(),(short)156);
  assertEquals(exercise.getLapList()[0].getHeartRateAVG(),(short)173);
  assertEquals(exercise.getLapList()[0].getHeartRateMax(),(short)194);
  assertEquals(Math.round(exercise.getLapList()[0].getSpeed().getSpeedEnd() * 10),164);
  assertEquals(Math.round(exercise.getLapList()[0].getSpeed().getDistance() / 100f),310);
  assertEquals(exercise.getLapList()[0].getAltitude(),null);
  assertEquals(exercise.getLapList()[0].getTemperature(),null);
  assertEquals(exercise.getLapList()[1].getTimeSplit(),(2 * 60 * 60* 10) + (14 * 60 * 10) + (51 * 10)+ 5);
  assertEquals(exercise.getLapList()[1].getHeartRateSplit(),(short)155);
  assertEquals(exercise.getLapList()[1].getHeartRateAVG(),(short)169);
  assertEquals(exercise.getLapList()[1].getHeartRateMax(),(short)189);
  assertEquals(Math.round(exercise.getLapList()[1].getSpeed().getSpeedEnd() * 10),3);
  assertEquals(Math.round(exercise.getLapList()[1].getSpeed().getDistance() / 100),458);
  assertEquals(exercise.getLapList()[1].getAltitude(),null);
  assertEquals(exercise.getLapList()[1].getTemperature(),null);
  assertEquals(exercise.getSampleList().length,67);
  assertEquals(0,exercise.getSampleList()[0].getTimestamp());
  assertEquals(exercise.getSampleList()[0].getHeartRate(),(short)152);
  assertEquals(exercise.getSampleList()[0].getAltitude(),(short)0);
  assertEquals(Math.round(exercise.getSampleList()[0].getSpeed() * 10),230);
  assertEquals(exercise.getSampleList()[0].getCadence(),(short)0);
  assertEquals(exercise.getSampleList()[0].getDistance(),0);
  assertEquals(24 * 120 * 1000,exercise.getSampleList()[24].getTimestamp());
  assertEquals(exercise.getSampleList()[24].getHeartRate(),(short)165);
  assertEquals(exercise.getSampleList()[24].getAltitude(),(short)0);
  assertEquals(Math.round(exercise.getSampleList()[24].getSpeed() * 10),270);
  assertEquals(exercise.getSampleList()[24].getCadence(),(short)0);
  assertEquals(exercise.getSampleList()[24].getDistance(),16500);
  assertEquals(48 * 120 * 1000,exercise.getSampleList()[48].getTimestamp());
  assertEquals(exercise.getSampleList()[48].getHeartRate(),(short)164);
  assertEquals(exercise.getSampleList()[48].getAltitude(),(short)0);
  assertEquals(Math.round(exercise.getSampleList()[48].getSpeed() * 10),190);
  assertEquals(exercise.getSampleList()[48].getCadence(),(short)0);
  assertEquals(exercise.getSampleList()[48].getDistance(),32933);
  assertEquals(66 * 120 * 1000,exercise.getSampleList()[66].getTimestamp());
  assertEquals(exercise.getSampleList()[66].getHeartRate(),(short)161);
  assertEquals(exercise.getSampleList()[66].getAltitude(),(short)0);
  assertEquals(Math.round(exercise.getSampleList()[66].getSpeed() * 10),210);
  assertEquals(exercise.getSampleList()[66].getCadence(),(short)0);
  assertEquals(exercise.getSampleList()[66].getDistance(),45800);
}