@Test
public void whenCAExists_andItIsARootCA_aValidChildCertificateIsGenerated() throws Exception {

  final KeyPair childCertificateKeyPair = setupKeyPair();
  setupMocksForRootCA(childCertificateKeyPair);
  final CertificateCredentialValue certificateSignedByRoot = subject.generateCredential(inputParameters);
  assertThat(certificateSignedByRoot.getCa(),
    equalTo(rootCa.getCertificate()));
  assertThat(certificateSignedByRoot.getPrivateKey(),
    equalTo(CertificateFormatter.pemOf(childCertificateKeyPair.getPrivate())));
  assertThat(certificateSignedByRoot.getCertificate(),
    equalTo(CertificateFormatter.pemOf(childX509Certificate)));
  assertThat(certificateSignedByRoot.getCaName(), equalTo("/my-ca-name"));
  verify(keyGenerator, times(1)).generateKeyPair(2048);
}