use of com.synopsys.integration.alert.component.audit.mock.MockAuditEntryEntity in project hub-alert by blackducksoftware.
the class AuditEntryActionsTest method testResendNotificationException.
@Test
public void testResendNotificationException() {
AuthorizationManager authorizationManager = Mockito.mock(AuthorizationManager.class);
Mockito.when(authorizationManager.hasExecutePermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class))).thenReturn(Boolean.TRUE);
AuditDescriptorKey auditDescriptorKey = new AuditDescriptorKey();
AuditEntryRepository auditEntryRepository = Mockito.mock(AuditEntryRepository.class);
NotificationContentRepository notificationRepository = Mockito.mock(NotificationContentRepository.class);
AuditNotificationRepository auditNotificationRepository = Mockito.mock(AuditNotificationRepository.class);
JobAccessor jobAccessor = Mockito.mock(JobAccessor.class);
Mockito.when(jobAccessor.getJobById(Mockito.any())).thenReturn(null);
MockAuditEntryEntity mockAuditEntryEntity = new MockAuditEntryEntity();
MockNotificationContent mockNotificationEntity = new MockNotificationContent();
Mockito.when(auditEntryRepository.findById(Mockito.anyLong())).thenReturn(Optional.of(mockAuditEntryEntity.createEmptyEntity()));
Mockito.when(notificationRepository.findAllById(Mockito.anyList())).thenReturn(Collections.singletonList(mockNotificationEntity.createEntity()));
DefaultNotificationAccessor notificationManager = new DefaultNotificationAccessor(notificationRepository, auditEntryRepository, null);
DefaultRestApiAuditAccessor auditEntryUtility = new DefaultRestApiAuditAccessor(auditEntryRepository, auditNotificationRepository, jobAccessor, null, notificationManager, null);
AuditEntryActions auditEntryActions = new AuditEntryActions(authorizationManager, auditDescriptorKey, auditEntryUtility, notificationManager, jobAccessor, null, null);
ActionResponse<AuditEntryPageModel> response = auditEntryActions.resendNotification(1L, null);
assertTrue(response.isError());
assertFalse(response.hasContent());
}
Aggregations