Search in sources :

Example 1 with ProcessingAuditAccessor

use of com.synopsys.integration.alert.common.persistence.accessor.ProcessingAuditAccessor in project hub-alert by blackducksoftware.

the class DistributionEventHandlerTest method handleEventSuccessTest.

@Test
public void handleEventSuccessTest() {
    ProcessingAuditAccessor auditAccessor = Mockito.mock(ProcessingAuditAccessor.class);
    Mockito.doNothing().when(auditAccessor).setAuditEntrySuccess(Mockito.any(), Mockito.anySet());
    DistributionJobDetailsModel details = new DistributionJobDetailsModel(null, null) {
    };
    JobDetailsAccessor<DistributionJobDetailsModel> jobDetailsAccessor = x -> Optional.of(details);
    DistributionChannel<DistributionJobDetailsModel> channel = (x, y, z) -> null;
    DistributionEventHandler<DistributionJobDetailsModel> eventHandler = new DistributionEventHandler<>(channel, jobDetailsAccessor, auditAccessor);
    UUID testJobId = UUID.randomUUID();
    Set<Long> testNotificationIds = Set.of(1L, 3L, 5L);
    DistributionEvent testEvent = new DistributionEvent(channelKey, testJobId, "jobName", testNotificationIds, null);
    eventHandler.handle(testEvent);
    Mockito.verify(auditAccessor, Mockito.times(1)).setAuditEntrySuccess(Mockito.eq(testJobId), Mockito.eq(testNotificationIds));
}
Also used : DistributionJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) ProcessingAuditAccessor(com.synopsys.integration.alert.common.persistence.accessor.ProcessingAuditAccessor) Optional(java.util.Optional) Set(java.util.Set) ChannelKey(com.synopsys.integration.alert.descriptor.api.model.ChannelKey) UUID(java.util.UUID) DistributionJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel) JobDetailsAccessor(com.synopsys.integration.alert.common.persistence.accessor.JobDetailsAccessor) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) DistributionEvent(com.synopsys.integration.alert.processor.api.distribute.DistributionEvent) DistributionEvent(com.synopsys.integration.alert.processor.api.distribute.DistributionEvent) ProcessingAuditAccessor(com.synopsys.integration.alert.common.persistence.accessor.ProcessingAuditAccessor) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Example 2 with ProcessingAuditAccessor

use of com.synopsys.integration.alert.common.persistence.accessor.ProcessingAuditAccessor in project hub-alert by blackducksoftware.

the class DistributionEventHandlerTest method handleEventExceptionTest.

@Test
public void handleEventExceptionTest() {
    ProcessingAuditAccessor auditAccessor = Mockito.mock(ProcessingAuditAccessor.class);
    Mockito.doNothing().when(auditAccessor).setAuditEntryFailure(Mockito.any(), Mockito.anySet(), Mockito.anyString(), Mockito.any());
    DistributionJobDetailsModel details = new DistributionJobDetailsModel(null, null) {
    };
    JobDetailsAccessor<DistributionJobDetailsModel> jobDetailsAccessor = x -> Optional.of(details);
    AlertException testException = new AlertException("Test exception");
    DistributionChannel<DistributionJobDetailsModel> channel = (x, y, z) -> {
        throw testException;
    };
    DistributionEventHandler<DistributionJobDetailsModel> eventHandler = new DistributionEventHandler<>(channel, jobDetailsAccessor, auditAccessor);
    UUID testJobId = UUID.randomUUID();
    Set<Long> testNotificationIds = Set.of(1L, 3L, 5L);
    DistributionEvent testEvent = new DistributionEvent(channelKey, testJobId, "jobName", testNotificationIds, null);
    eventHandler.handle(testEvent);
    Mockito.verify(auditAccessor, Mockito.times(1)).setAuditEntryFailure(Mockito.eq(testJobId), Mockito.eq(testNotificationIds), Mockito.anyString(), Mockito.any());
}
Also used : DistributionJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) ProcessingAuditAccessor(com.synopsys.integration.alert.common.persistence.accessor.ProcessingAuditAccessor) Optional(java.util.Optional) Set(java.util.Set) ChannelKey(com.synopsys.integration.alert.descriptor.api.model.ChannelKey) UUID(java.util.UUID) DistributionJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel) JobDetailsAccessor(com.synopsys.integration.alert.common.persistence.accessor.JobDetailsAccessor) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) DistributionEvent(com.synopsys.integration.alert.processor.api.distribute.DistributionEvent) DistributionEvent(com.synopsys.integration.alert.processor.api.distribute.DistributionEvent) ProcessingAuditAccessor(com.synopsys.integration.alert.common.persistence.accessor.ProcessingAuditAccessor) UUID(java.util.UUID) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) Test(org.junit.jupiter.api.Test)

Example 3 with ProcessingAuditAccessor

use of com.synopsys.integration.alert.common.persistence.accessor.ProcessingAuditAccessor in project hub-alert by blackducksoftware.

the class DistributionEventHandlerTest method handleEventJobDetailsMissingTest.

@Test
public void handleEventJobDetailsMissingTest() {
    ProcessingAuditAccessor auditAccessor = Mockito.mock(ProcessingAuditAccessor.class);
    Mockito.doNothing().when(auditAccessor).setAuditEntryFailure(Mockito.any(), Mockito.anySet(), Mockito.anyString(), Mockito.any());
    JobDetailsAccessor<DistributionJobDetailsModel> jobDetailsAccessor = x -> Optional.empty();
    DistributionEventHandler<DistributionJobDetailsModel> eventHandler = new DistributionEventHandler<>(null, jobDetailsAccessor, auditAccessor);
    UUID testJobId = UUID.randomUUID();
    Set<Long> testNotificationIds = Set.of(1L, 3L, 5L);
    DistributionEvent testEvent = new DistributionEvent(channelKey, testJobId, "jobName", testNotificationIds, null);
    eventHandler.handle(testEvent);
    Mockito.verify(auditAccessor, Mockito.times(1)).setAuditEntryFailure(Mockito.eq(testJobId), Mockito.eq(testNotificationIds), Mockito.anyString(), Mockito.any());
}
Also used : DistributionJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) ProcessingAuditAccessor(com.synopsys.integration.alert.common.persistence.accessor.ProcessingAuditAccessor) Optional(java.util.Optional) Set(java.util.Set) ChannelKey(com.synopsys.integration.alert.descriptor.api.model.ChannelKey) UUID(java.util.UUID) DistributionJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel) JobDetailsAccessor(com.synopsys.integration.alert.common.persistence.accessor.JobDetailsAccessor) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) DistributionEvent(com.synopsys.integration.alert.processor.api.distribute.DistributionEvent) DistributionEvent(com.synopsys.integration.alert.processor.api.distribute.DistributionEvent) ProcessingAuditAccessor(com.synopsys.integration.alert.common.persistence.accessor.ProcessingAuditAccessor) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Aggregations

AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)3 JobDetailsAccessor (com.synopsys.integration.alert.common.persistence.accessor.JobDetailsAccessor)3 ProcessingAuditAccessor (com.synopsys.integration.alert.common.persistence.accessor.ProcessingAuditAccessor)3 DistributionJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel)3 ChannelKey (com.synopsys.integration.alert.descriptor.api.model.ChannelKey)3 DistributionEvent (com.synopsys.integration.alert.processor.api.distribute.DistributionEvent)3 Optional (java.util.Optional)3 Set (java.util.Set)3 UUID (java.util.UUID)3 Test (org.junit.jupiter.api.Test)3 Mockito (org.mockito.Mockito)3