use of com.blackducksoftware.integration.hub.alert.config.GlobalProperties in project hub-alert by blackducksoftware.
the class DistributionChannelTest method receiveMessageTest.
@Test
public void receiveMessageTest() {
final GlobalProperties globalProperties = new TestGlobalProperties();
final Gson gson = new Gson();
final AuditEntryRepositoryWrapper auditEntryRepository = Mockito.mock(AuditEntryRepositoryWrapper.class);
final GlobalEmailRepositoryWrapper globalEmailRepositoryWrapper = Mockito.mock(GlobalEmailRepositoryWrapper.class);
final EmailGroupDistributionRepositoryWrapper emailGroupRepositoryWrapper = Mockito.mock(EmailGroupDistributionRepositoryWrapper.class);
final CommonDistributionRepositoryWrapper commonRepositoryWrapper = Mockito.mock(CommonDistributionRepositoryWrapper.class);
final EmailGroupChannel channel = new EmailGroupChannel(globalProperties, gson, auditEntryRepository, globalEmailRepositoryWrapper, emailGroupRepositoryWrapper, commonRepositoryWrapper);
final Long commonId = 1L;
final EmailGroupEvent event = new EmailGroupEvent(createProjectData("Distribution Channel Test"), commonId);
final String jsonRepresentation = gson.toJson(event);
final CommonDistributionConfigEntity commonEntity = new CommonDistributionConfigEntity(commonId, SupportedChannels.EMAIL_GROUP, "Email Config", DigestTypeEnum.REAL_TIME, false);
Mockito.when(commonRepositoryWrapper.findOne(Mockito.anyLong())).thenReturn(commonEntity);
final EmailGroupDistributionConfigEntity specificEntity = new EmailGroupDistributionConfigEntity("admins", "", "TEST SUBJECT LINE");
Mockito.when(emailGroupRepositoryWrapper.findOne(Mockito.anyLong())).thenReturn(specificEntity);
channel.receiveMessage(jsonRepresentation);
}
use of com.blackducksoftware.integration.hub.alert.config.GlobalProperties in project hub-alert by blackducksoftware.
the class RestDistributionChannelTest method sendMessageFailureTest.
@Test
public void sendMessageFailureTest() {
final GlobalProperties globalProperties = new TestGlobalProperties();
final ChannelRestConnectionFactory channelRestConnectionFactory = new ChannelRestConnectionFactory(globalProperties);
final RestDistributionChannel<AbstractChannelEvent, GlobalChannelConfigEntity, DistributionChannelConfigEntity> restChannel = new RestDistributionChannel<AbstractChannelEvent, GlobalChannelConfigEntity, DistributionChannelConfigEntity>(null, null, null, null, null, null, channelRestConnectionFactory) {
@Override
public String getApiUrl() {
return null;
}
@Override
public Request createRequest(final ChannelRequestHelper channelRequestHelper, final DistributionChannelConfigEntity config, final ProjectData projectData) throws AlertException {
return new Request.Builder().uri("http://google.com").build();
}
};
final SlackEvent event = new SlackEvent(createProjectData("Rest channel test"), 1L);
final SlackDistributionConfigEntity config = new SlackDistributionConfigEntity("more garbage", "garbage", "garbage");
Exception thrownException = null;
try {
restChannel.sendAuditedMessage(event, config);
} catch (final IntegrationException ex) {
thrownException = ex;
}
assertNotNull(thrownException);
}
use of com.blackducksoftware.integration.hub.alert.config.GlobalProperties in project hub-alert by blackducksoftware.
the class HubDataActionsTest method testGetHubGroupsNullHubServicesFactory.
@Test
public void testGetHubGroupsNullHubServicesFactory() throws Exception {
final GlobalProperties globalProperties = Mockito.mock(GlobalProperties.class);
Mockito.when(globalProperties.createHubServicesFactory(Mockito.any(Logger.class))).thenReturn(null);
final HubDataActions hubDataActions = new HubDataActions(globalProperties);
try {
hubDataActions.getHubGroups();
fail();
} catch (final AlertException e) {
assertEquals("Missing global configuration.", e.getMessage());
}
}
use of com.blackducksoftware.integration.hub.alert.config.GlobalProperties in project hub-alert by blackducksoftware.
the class HubDataActionsTest method testGetHubGroupsNoGroups.
@Test
public void testGetHubGroupsNoGroups() throws Exception {
final GlobalProperties globalProperties = Mockito.mock(GlobalProperties.class);
final HubServicesFactory hubServicesFactory = Mockito.mock(HubServicesFactory.class);
final HubService hubService = Mockito.mock(HubService.class);
Mockito.when(hubService.getAllResponses(ApiDiscovery.USERGROUPS_LINK_RESPONSE)).thenReturn(Collections.emptyList());
Mockito.when(hubServicesFactory.createHubService()).thenReturn(hubService);
Mockito.when(globalProperties.createHubServicesFactory(Mockito.any(Logger.class))).thenReturn(hubServicesFactory);
final HubDataActions hubDataActions = new HubDataActions(globalProperties);
final List<HubGroup> hubGroups = hubDataActions.getHubGroups();
assertEquals(0, hubGroups.size());
}
use of com.blackducksoftware.integration.hub.alert.config.GlobalProperties in project hub-alert by blackducksoftware.
the class NotificationItemProcessorTest method testInit.
@Test
public void testInit() {
final GlobalProperties globalProperties = new TestGlobalProperties();
final NotificationItemProcessor notificationItemProcessor = new NotificationItemProcessor(globalProperties, new TestLogger());
assertTrue(notificationItemProcessor.getCacheList().size() == 2);
assertTrue(notificationItemProcessor.getProcessorMap().size() == 4);
}
Aggregations