use of com.blackducksoftware.integration.hub.alert.TestGlobalProperties in project hub-alert by blackducksoftware.
the class GlobalHubConfigActionsTest method createMockedConfigActionsUsingObjectTransformer.
@Override
public GlobalHubConfigActions createMockedConfigActionsUsingObjectTransformer(final ObjectTransformer objectTransformer) {
final GlobalHubRepositoryWrapper mockedGlobalRepository = Mockito.mock(GlobalHubRepositoryWrapper.class);
final GlobalProperties globalProperties = new TestGlobalProperties(mockedGlobalRepository);
final GlobalHubConfigActions configActions = new GlobalHubConfigActions(mockedGlobalRepository, globalProperties, objectTransformer);
return configActions;
}
use of com.blackducksoftware.integration.hub.alert.TestGlobalProperties in project hub-alert by blackducksoftware.
the class LoginActionsTestIT method testValidateHubConfigurationException.
@Test
public void testValidateHubConfigurationException() {
mockLoginRestModel.setHubUsername(null);
final LoginActions loginActions = new LoginActions(new TestGlobalProperties());
try {
final boolean authenticated = loginActions.authenticateUser(mockLoginRestModel.createRestModel(), new Slf4jIntLogger(logger));
assertFalse(authenticated);
} catch (final IntegrationException e) {
fail();
}
}
use of com.blackducksoftware.integration.hub.alert.TestGlobalProperties in project hub-alert by blackducksoftware.
the class DistributionChannelTest method handleEventWrongTypeTest.
@Test
public void handleEventWrongTypeTest() {
final GlobalProperties globalProperties = new TestGlobalProperties();
final Gson gson = new Gson();
final CommonDistributionRepositoryWrapper commonRepositoryWrapper = Mockito.mock(CommonDistributionRepositoryWrapper.class);
final EmailGroupChannel channel = new EmailGroupChannel(globalProperties, gson, null, null, null, commonRepositoryWrapper);
final Long commonId = 1L;
final EmailGroupEvent event = new EmailGroupEvent(createProjectData("Distribution Channel Test"), commonId);
final CommonDistributionConfigEntity commonEntity = new CommonDistributionConfigEntity(commonId, SupportedChannels.SLACK, "Other Config", DigestTypeEnum.REAL_TIME, false);
Mockito.when(commonRepositoryWrapper.findOne(Mockito.anyLong())).thenReturn(commonEntity);
channel.handleEvent(event);
}
use of com.blackducksoftware.integration.hub.alert.TestGlobalProperties in project hub-alert by blackducksoftware.
the class HipChatChannelTest method testGlobalConfigValidApiKeyTest.
@Test
public void testGlobalConfigValidApiKeyTest() throws Exception {
final TestGlobalProperties globalProperties = new TestGlobalProperties();
globalProperties.setHubTrustCertificate(Boolean.TRUE);
final ChannelRestConnectionFactory restFactory = new ChannelRestConnectionFactory(globalProperties);
final HipChatChannel hipChatChannel = new HipChatChannel(null, null, null, null, null, restFactory);
hipChatMockUtil.setApiKey(properties.getProperty(TestPropertyKey.TEST_HIPCHAT_API_KEY));
final GlobalHipChatConfigEntity entity = hipChatMockUtil.createGlobalEntity();
final String validMessage = hipChatChannel.testGlobalConfig(entity);
assertEquals("API key is valid.", validMessage);
}
use of com.blackducksoftware.integration.hub.alert.TestGlobalProperties in project hub-alert by blackducksoftware.
the class HipChatChannelTest method testGlobalConfigInvalidApiKeyTest.
@Test
public void testGlobalConfigInvalidApiKeyTest() {
final TestGlobalProperties globalProperties = new TestGlobalProperties();
globalProperties.setHubTrustCertificate(Boolean.TRUE);
final ChannelRestConnectionFactory restFactory = new ChannelRestConnectionFactory(globalProperties);
final HipChatChannel hipChatChannel = new HipChatChannel(null, null, null, null, null, restFactory);
hipChatMockUtil.setApiKey("garbage");
try {
final GlobalHipChatConfigEntity entity = hipChatMockUtil.createGlobalEntity();
hipChatChannel.testGlobalConfig(entity);
} catch (final IntegrationException ex) {
assertTrue(ex.getMessage().contains("Invalid API key: "));
}
}
Aggregations