@Test
public void testUpdate() throws Exception {

  // Configure the mock because our class under test expects values to be returned from the db
  when(db.query(anyString(), anyString())).thenReturn(new RowStub()
      .withColumnNames("sample_name", "update_sequence", "update_time")
      .addRow("Foo", 3, now));
  Date before = new Date(now.getTime() - 5000);
  Sample sample = new Sample();
  sample.setSampleId(100L);
  sample.setName("Foo");
  sample.setUpdateSequence(13);
  sample.setUpdateTime(before);
  sampleDao.updateSample(sample, 23L);
  // Verify object in memory is updated properly
  assertEquals(new Long(100L), sample.getSampleId());
  assertEquals("Foo", sample.getName());
  assertEquals(new Integer(14), sample.getUpdateSequence());
  assertEquals(now, sample.getUpdateTime());
  // Verify database queries against golden copies
  verify(db).update(eq("update sample set sample_name=?, update_sequence=?, update_time=? where sample_id=?"), anyString());
  verify(db).insert(eq("insert into sample_history (sample_id, sample_name, update_sequence, update_time, update_user_id, is_deleted) values (?,?,?,?,?,'N')"), anyString());
  verifyNoMoreInteractions(db);
}