use of com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.global.GlobalHipChatConfigEntity 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.channel.hipchat.repository.global.GlobalHipChatConfigEntity 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: "));
}
}
use of com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.global.GlobalHipChatConfigEntity in project hub-alert by blackducksoftware.
the class ObjectTransformerTest method testTransformHipchatModels.
@Test
public void testTransformHipchatModels() throws Exception {
final MockHipChatGlobalEntity mockHipChatGlobalEntity = new MockHipChatGlobalEntity();
final MockHipChatGlobalRestModel hipChatMockUtils = new MockHipChatGlobalRestModel();
final ObjectTransformer objectTransformer = new ObjectTransformer();
final GlobalHipChatConfigRestModel restModel = hipChatMockUtils.createGlobalRestModel();
final GlobalHipChatConfigEntity configEntity = mockHipChatGlobalEntity.createGlobalEntity();
final GlobalHipChatConfigEntity transformedConfigEntity = objectTransformer.configRestModelToDatabaseEntity(restModel, GlobalHipChatConfigEntity.class);
final GlobalHipChatConfigRestModel transformedConfigRestModel = objectTransformer.databaseEntityToConfigRestModel(configEntity, GlobalHipChatConfigRestModel.class);
assertEquals(restModel, transformedConfigRestModel);
assertEquals(configEntity, transformedConfigEntity);
}
Aggregations