@Test
public void findActiveVersion_whenCertificateIsNotACa_throwsException() {

  final CertificateCredentialVersion notACertificateAuthority = mock(CertificateCredentialVersion.class);
  when(notACertificateAuthority.getParsedCertificate()).thenReturn(mock(CertificateReader.class));
  when(notACertificateAuthority.getCertificate()).thenReturn(SIMPLE_SELF_SIGNED_TEST_CERT);
  when(certificateVersionDataService.findActive(CREDENTIAL_NAME))
    .thenReturn(notACertificateAuthority);
  try {
    certificateAuthorityService.findActiveVersion(CREDENTIAL_NAME);
  } catch (final ParameterizedValidationException pe) {
    assertThat(pe.getMessage(), equalTo(ErrorMessages.CERT_NOT_CA));
  }
}