@Test
public void whenCAExists_andItIsARootCA_aValidChildCertificateIsGeneratedWithTheProvidedKeyLength()
  throws Exception {

  final KeyPair childCertificateKeyPair = setupKeyPair();
  setupMocksForRootCA(childCertificateKeyPair);
  generationParameters.setKeyLength(4096);
  final CertificateGenerationParameters params = new CertificateGenerationParameters(generationParameters);
  when(
    signedCertificateGenerator
      .getSignedByIssuer(childCertificateKeyPair, params, rootCaX509Certificate, rootCaKeyPair.getPrivate())
  ).thenReturn(childX509Certificate);
  final CertificateCredentialValue certificate = subject.generateCredential(params);
  assertThat(certificate, notNullValue());
  verify(keyGenerator, times(1)).generateKeyPair(4096);
}