@Test
public void findActiveVersion_givenExistingCa_returnsTheCa() {

  final CertificateReader certificateReader = mock(CertificateReader.class);
  when(certificateVersionDataService.findActive(CREDENTIAL_NAME)).thenReturn(certificateCredential);
  when(certificateCredential.getPrivateKey()).thenReturn("my-key");
  when(certificateCredential.getParsedCertificate()).thenReturn(certificateReader);
  when(certificateReader.isCa()).thenReturn(true);
  when(certificateCredential.isCertificateAuthority()).thenReturn(true);
  when(certificateCredential.isSelfSigned()).thenReturn(true);
  when(certificateCredential.getCertificate()).thenReturn(SELF_SIGNED_CA_CERT);
  when(certificateCredential.getGenerated()).thenReturn(false);
  when(certificateCredential.isVersionTransitional()).thenReturn(false);
  assertThat(certificateAuthorityService.findActiveVersion(CREDENTIAL_NAME),
    samePropertyValuesAs(certificate));
}