Search in sources :

Example 6 with GlobalHipChatConfigEntity

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);
}
Also used : ChannelRestConnectionFactory(com.blackducksoftware.integration.hub.alert.channel.rest.ChannelRestConnectionFactory) GlobalHipChatConfigEntity(com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.global.GlobalHipChatConfigEntity) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) ExternalConnectionTest(com.blackducksoftware.integration.test.annotation.ExternalConnectionTest) Test(org.junit.Test) ChannelTest(com.blackducksoftware.integration.hub.alert.channel.ChannelTest)

Example 7 with GlobalHipChatConfigEntity

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: "));
    }
}
Also used : IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) ChannelRestConnectionFactory(com.blackducksoftware.integration.hub.alert.channel.rest.ChannelRestConnectionFactory) GlobalHipChatConfigEntity(com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.global.GlobalHipChatConfigEntity) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) ExternalConnectionTest(com.blackducksoftware.integration.test.annotation.ExternalConnectionTest) Test(org.junit.Test) ChannelTest(com.blackducksoftware.integration.hub.alert.channel.ChannelTest)

Example 8 with GlobalHipChatConfigEntity

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);
}
Also used : GlobalHipChatConfigRestModel(com.blackducksoftware.integration.hub.alert.channel.hipchat.controller.global.GlobalHipChatConfigRestModel) GlobalHipChatConfigEntity(com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.global.GlobalHipChatConfigEntity) MockHipChatGlobalRestModel(com.blackducksoftware.integration.hub.alert.channel.hipchat.mock.MockHipChatGlobalRestModel) MockHipChatGlobalEntity(com.blackducksoftware.integration.hub.alert.channel.hipchat.mock.MockHipChatGlobalEntity) Test(org.junit.Test)

Aggregations

GlobalHipChatConfigEntity (com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.global.GlobalHipChatConfigEntity)8 Test (org.junit.Test)7 ChannelTest (com.blackducksoftware.integration.hub.alert.channel.ChannelTest)6 ChannelRestConnectionFactory (com.blackducksoftware.integration.hub.alert.channel.rest.ChannelRestConnectionFactory)6 ExternalConnectionTest (com.blackducksoftware.integration.test.annotation.ExternalConnectionTest)6 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)3 TestGlobalProperties (com.blackducksoftware.integration.hub.alert.TestGlobalProperties)3 AuditEntryRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper)1 GlobalHipChatConfigRestModel (com.blackducksoftware.integration.hub.alert.channel.hipchat.controller.global.GlobalHipChatConfigRestModel)1 MockHipChatGlobalEntity (com.blackducksoftware.integration.hub.alert.channel.hipchat.mock.MockHipChatGlobalEntity)1 MockHipChatGlobalRestModel (com.blackducksoftware.integration.hub.alert.channel.hipchat.mock.MockHipChatGlobalRestModel)1 HipChatDistributionConfigEntity (com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.distribution.HipChatDistributionConfigEntity)1 GlobalHubRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.global.GlobalHubRepositoryWrapper)1 ProjectData (com.blackducksoftware.integration.hub.alert.digest.model.ProjectData)1 RestConnection (com.blackducksoftware.integration.hub.rest.RestConnection)1 UnauthenticatedRestConnection (com.blackducksoftware.integration.hub.rest.UnauthenticatedRestConnection)1 UriCombiner (com.blackducksoftware.integration.hub.rest.UriCombiner)1 PrintStreamIntLogger (com.blackducksoftware.integration.log.PrintStreamIntLogger)1 URL (java.net.URL)1 Category (org.junit.experimental.categories.Category)1