@Test public void sawClientTest() {

  assertThat(client1.getLastSeen()).isNull();
  assertThat(client2.getLastSeen()).isNull();
  Instant expiration = Instant.now();
  // Remove nanos because database drops it on storage, and we want
  // to compare later to make sure the proper expiration was set in DB.
  expiration = expiration.minusNanos(expiration.get(NANO_OF_SECOND));
  CertificatePrincipal principal = mock(CertificatePrincipal.class);
  when(principal.getCertificateExpiration()).thenReturn(expiration);
  ApiDate now = ApiDate.now();
  clientDAO.sawClient(client1, principal);
  // reload clients from db, as sawClient doesn't update in-memory object
  Client client1v2 = clientDAO.getClientByName(client1.getName()).get();
  Client client2v2 = clientDAO.getClientByName(client2.getName()).get();
  // verify client1 from db has updated lastSeen, and client2 hasn't changed
  assertThat(client1v2.getLastSeen()).isNotNull();
  assertTrue(client1v2.getLastSeen().toEpochSecond() >= now.toEpochSecond());
  assertThat(client2v2.getLastSeen()).isNull();
  assertThat(client1v2.getExpiration()).isNotNull();
  assertThat(client1v2.getExpiration().toInstant()).isEqualTo(expiration);
  assertThat(client2v2.getExpiration()).isNull();
}