Search in sources :

Example 1 with MockAuditEntryEntity

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());
}
Also used : MockNotificationContent(com.synopsys.integration.alert.mock.entity.MockNotificationContent) DefaultNotificationAccessor(com.synopsys.integration.alert.database.api.DefaultNotificationAccessor) NotificationContentRepository(com.synopsys.integration.alert.database.notification.NotificationContentRepository) DescriptorKey(com.synopsys.integration.alert.descriptor.api.model.DescriptorKey) AuditDescriptorKey(com.synopsys.integration.alert.component.audit.AuditDescriptorKey) AuditDescriptorKey(com.synopsys.integration.alert.component.audit.AuditDescriptorKey) AuditEntryPageModel(com.synopsys.integration.alert.common.persistence.model.AuditEntryPageModel) AuditEntryRepository(com.synopsys.integration.alert.database.audit.AuditEntryRepository) JobAccessor(com.synopsys.integration.alert.common.persistence.accessor.JobAccessor) AuditNotificationRepository(com.synopsys.integration.alert.database.audit.AuditNotificationRepository) DefaultRestApiAuditAccessor(com.synopsys.integration.alert.database.api.DefaultRestApiAuditAccessor) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) ConfigContextEnum(com.synopsys.integration.alert.common.enumeration.ConfigContextEnum) MockAuditEntryEntity(com.synopsys.integration.alert.component.audit.mock.MockAuditEntryEntity) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigContextEnum (com.synopsys.integration.alert.common.enumeration.ConfigContextEnum)1 JobAccessor (com.synopsys.integration.alert.common.persistence.accessor.JobAccessor)1 AuditEntryPageModel (com.synopsys.integration.alert.common.persistence.model.AuditEntryPageModel)1 AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)1 AuditDescriptorKey (com.synopsys.integration.alert.component.audit.AuditDescriptorKey)1 MockAuditEntryEntity (com.synopsys.integration.alert.component.audit.mock.MockAuditEntryEntity)1 DefaultNotificationAccessor (com.synopsys.integration.alert.database.api.DefaultNotificationAccessor)1 DefaultRestApiAuditAccessor (com.synopsys.integration.alert.database.api.DefaultRestApiAuditAccessor)1 AuditEntryRepository (com.synopsys.integration.alert.database.audit.AuditEntryRepository)1 AuditNotificationRepository (com.synopsys.integration.alert.database.audit.AuditNotificationRepository)1 NotificationContentRepository (com.synopsys.integration.alert.database.notification.NotificationContentRepository)1 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)1 MockNotificationContent (com.synopsys.integration.alert.mock.entity.MockNotificationContent)1 Test (org.junit.jupiter.api.Test)1