@Test public void createsDbRecordForNewClient_whenConfigured() {

  ApiDate now = ApiDate.now();
  Client newClient =
      new Client(2345L, "new-client", "desc", null, now, "automatic", now, "automatic",
          null, null, true, false
      );
  // lookup doesn't find client
  when(clientDAO.getClientByName("new-client")).thenReturn(Optional.empty());
  // a new DB record is created
  when(clientDAO.createClient(eq("new-client"), eq("automatic"), any(), any())).thenReturn(2345L);
  when(clientDAO.getClientById(2345L)).thenReturn(Optional.of(newClient));
  assertThat(authenticator.authenticate(SimplePrincipal.of("CN=new-client"), true)).isEqualTo(
      Optional.of(newClient));
}