Fill out BugReport.txt with information about the four bugs you've identified in JdbcTimesheetDao using the DAO tests.
An example of reporting and fixing a bug
Consider the following deleteTimesheet() method:
public void deleteTimesheet(int timesheetId) {
String sql = "DELETE FROM timesheet WHERE timesheet_id = ?";
jdbcTemplate.update(sql, 1);
}
A method written this way would contain a bug. It always deletes the record with a timesheet_id of 1 rather than using the value of timesheetId.
There are several ways this could cause the deleted_timesheet_cant_be_retrieved test to fail—for example, if the test called deleteTimesheet(2) and then found that getTimesheet(2) still retrieved the timesheet.
After that test fails, you'd fix the deleteTimesheet() method like this:
public void deleteTimesheet(int timesheetId) {
String sql = "DELETE FROM timesheet WHERE timesheet_id = ?";
jdbcTemplate.update(sql, timesheetId);
}
Then you'd complete the bug report as follows:
Test that demonstrates problem:
deleted_timesheet_cant_be_retrieved
Expected output:
getTimesheet(2) returns null after calling deleteTimesheet(2)
Actual output:
getTimesheet(2) was still returning a Timesheet object
How did you fix this bug?
Replaced hardcoded value of 1 in deleteTimesheet with timesheetId so it doesn't always delete the same timesheet.