use of com.synopsys.integration.alert.component.certificates.AlertTrustStoreManager in project hub-alert by blackducksoftware.
the class CertificateActionsTestIT method createExceptionTest.
@Test
public void createExceptionTest() throws Exception {
String certificateContent = certTestUtil.readCertificateContents();
CertificateModel certificate = new CertificateModel(TEST_ALIAS, certificateContent, DateUtils.createCurrentDateString(DateUtils.UTC_DATE_FORMAT_TO_MINUTE));
AlertTrustStoreManager trustStoreService = Mockito.mock(AlertTrustStoreManager.class);
AuthorizationManager authorizationManager = Mockito.mock(AuthorizationManager.class);
Mockito.when(authorizationManager.hasCreatePermission(Mockito.anyString(), Mockito.anyString())).thenReturn(Boolean.TRUE);
Mockito.doThrow(new AlertException("Test exception")).when(trustStoreService).importCertificate(Mockito.any(CustomCertificateModel.class));
CertificateActions certificateActions = new CertificateActions(new CertificatesDescriptorKey(), authorizationManager, certificateAccessor, trustStoreService);
ActionResponse<CertificateModel> response = certificateActions.create(certificate);
assertTrue(response.isError());
assertTrue(certificateAccessor.getCertificates().isEmpty());
}
Aggregations