@Test
public void testGenerateIdentity() {

    
    final String cert = "cert";
    final String caCert = "caCert";
    CertSigner certSigner = Mockito.mock(com.yahoo.athenz.common.server.cert.CertSigner.class);
    when(certSigner.generateX509Certificate(any(), any(), Mockito.anyInt())).thenReturn(cert);
    when(certSigner.getCACertificate()).thenReturn(caCert);
    
    InstanceCertManager instanceManager = new InstanceCertManager(null, null, null, false);
    instanceManager.setCertSigner(certSigner);
    InstanceIdentity identity = instanceManager.generateIdentity("csr", "cn", null, 0);
    
    assertNotNull(identity);
    assertEquals(identity.getName(), "cn");
    assertEquals(identity.getX509Certificate(), cert);
    assertTrue(identity.getX509CertificateSigner().contains("-----BEGIN CERTIFICATE-----"));
    instanceManager.shutdown();
}