// SEC-2879
  @Test
  public void updateUsesLastUsed() {
    JdbcTemplate template = mock(JdbcTemplate.class);
    Date lastUsed = new Date(1424841314059L);
    JdbcTokenRepositoryImpl repository = new JdbcTokenRepositoryImpl();
    repository.setJdbcTemplate(template);

    repository.updateToken("series", "token", lastUsed);

    verify(template).update(anyString(), anyString(), eq(lastUsed), anyString());
  }
  @Test
  public void updatingTokenModifiesTokenValueAndLastUsed() {
    Timestamp ts = new Timestamp(System.currentTimeMillis() - 1);
    template.execute(
        "insert into persistent_logins (series, username, token, last_used) values "
            + "('joesseries', 'joeuser', 'atoken', '"
            + ts.toString()
            + "')");
    repo.updateToken("joesseries", "newtoken", new Date());

    Map<String, Object> results =
        template.queryForMap("select * from persistent_logins where series = 'joesseries'");

    assertEquals("joeuser", results.get("username"));
    assertEquals("joesseries", results.get("series"));
    assertEquals("newtoken", results.get("token"));
    Date lastUsed = (Date) results.get("last_used");
    assertTrue(lastUsed.getTime() > ts.getTime());
  }