Search in sources :

Example 1 with HipChatDistributionConfigEntity

use of com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.distribution.HipChatDistributionConfigEntity in project hub-alert by blackducksoftware.

the class HipChatChannelTest method sendMessageTestIT.

@Test
@Category(ExternalConnectionTest.class)
public void sendMessageTestIT() throws IOException, IntegrationException {
    final AuditEntryRepositoryWrapper auditEntryRepository = Mockito.mock(AuditEntryRepositoryWrapper.class);
    final GlobalHubRepositoryWrapper mockedGlobalRepository = Mockito.mock(GlobalHubRepositoryWrapper.class);
    final TestGlobalProperties globalProperties = new TestGlobalProperties(mockedGlobalRepository, null);
    final ChannelRestConnectionFactory channelRestConnectionFactory = new ChannelRestConnectionFactory(globalProperties);
    HipChatChannel hipChatChannel = new HipChatChannel(gson, auditEntryRepository, null, null, null, channelRestConnectionFactory);
    final ProjectData data = createProjectData("Integration test project");
    final HipChatEvent event = new HipChatEvent(data, null);
    final int roomId = Integer.parseInt(properties.getProperty(TestPropertyKey.TEST_HIPCHAT_ROOM_ID));
    final boolean notify = false;
    final String color = "random";
    final HipChatDistributionConfigEntity config = new HipChatDistributionConfigEntity(roomId, notify, color);
    hipChatChannel = Mockito.spy(hipChatChannel);
    Mockito.doReturn(new GlobalHipChatConfigEntity(properties.getProperty(TestPropertyKey.TEST_HIPCHAT_API_KEY))).when(hipChatChannel).getGlobalConfigEntity();
    hipChatChannel.sendAuditedMessage(event, config);
    final boolean responseLine = outputLogger.isLineContainingText("Successfully sent a hipchat_channel message!");
    assertTrue(responseLine);
}
Also used : ChannelRestConnectionFactory(com.blackducksoftware.integration.hub.alert.channel.rest.ChannelRestConnectionFactory) AuditEntryRepositoryWrapper(com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper) GlobalHipChatConfigEntity(com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.global.GlobalHipChatConfigEntity) HipChatDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.distribution.HipChatDistributionConfigEntity) GlobalHubRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.global.GlobalHubRepositoryWrapper) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) ProjectData(com.blackducksoftware.integration.hub.alert.digest.model.ProjectData) Category(org.junit.experimental.categories.Category) ExternalConnectionTest(com.blackducksoftware.integration.test.annotation.ExternalConnectionTest) Test(org.junit.Test) ChannelTest(com.blackducksoftware.integration.hub.alert.channel.ChannelTest)

Example 2 with HipChatDistributionConfigEntity

use of com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.distribution.HipChatDistributionConfigEntity in project hub-alert by blackducksoftware.

the class HipChatChannelTest method createRequestThrowsExceptionTest.

@Test
public void createRequestThrowsExceptionTest() throws Exception {
    final AuditEntryRepositoryWrapper auditEntryRepository = Mockito.mock(AuditEntryRepositoryWrapper.class);
    final HipChatChannel hipChatChannel = new HipChatChannel(gson, auditEntryRepository, null, null, null, null);
    final ChannelRequestHelper channelRequestHelper = new ChannelRequestHelper(null);
    final HipChatDistributionConfigEntity config = new HipChatDistributionConfigEntity(12345, Boolean.FALSE, null);
    final ProjectData projectData = createProjectData("HipChat IT test");
    final String userDir = System.getProperties().getProperty("user.dir");
    try {
        System.getProperties().setProperty("user.dir", "garbage");
        RuntimeException thrownException = null;
        try {
            hipChatChannel.createRequest(channelRequestHelper, config, projectData);
        } catch (final RuntimeException e) {
            thrownException = e;
        }
        assertNotNull(thrownException);
    } finally {
        System.getProperties().setProperty("user.dir", userDir);
    }
}
Also used : AuditEntryRepositoryWrapper(com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper) HipChatDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.distribution.HipChatDistributionConfigEntity) ChannelRequestHelper(com.blackducksoftware.integration.hub.alert.channel.rest.ChannelRequestHelper) ProjectData(com.blackducksoftware.integration.hub.alert.digest.model.ProjectData) ExternalConnectionTest(com.blackducksoftware.integration.test.annotation.ExternalConnectionTest) Test(org.junit.Test) ChannelTest(com.blackducksoftware.integration.hub.alert.channel.ChannelTest)

Example 3 with HipChatDistributionConfigEntity

use of com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.distribution.HipChatDistributionConfigEntity in project hub-alert by blackducksoftware.

the class HipChatChannelTest method createRequestThrowsExceptionWhenRoomIdIsNullTest.

public void createRequestThrowsExceptionWhenRoomIdIsNullTest() {
    final HipChatChannel hipChatChannel = new HipChatChannel(null, null, null, null, null, null);
    IntegrationException intException = null;
    try {
        hipChatChannel.createRequest(null, new HipChatDistributionConfigEntity(null, null, null), null);
    } catch (final IntegrationException e) {
        intException = e;
    }
    assertNotNull(intException);
}
Also used : IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) HipChatDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.distribution.HipChatDistributionConfigEntity)

Example 4 with HipChatDistributionConfigEntity

use of com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.distribution.HipChatDistributionConfigEntity in project hub-alert by blackducksoftware.

the class MockHipChatEntity method createEntity.

@Override
public HipChatDistributionConfigEntity createEntity() {
    final HipChatDistributionConfigEntity hipChatDistributionConfigEntity = new HipChatDistributionConfigEntity(roomId, notify, color);
    hipChatDistributionConfigEntity.setId(id);
    return hipChatDistributionConfigEntity;
}
Also used : HipChatDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.distribution.HipChatDistributionConfigEntity)

Aggregations

HipChatDistributionConfigEntity (com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.distribution.HipChatDistributionConfigEntity)4 AuditEntryRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper)2 ChannelTest (com.blackducksoftware.integration.hub.alert.channel.ChannelTest)2 ProjectData (com.blackducksoftware.integration.hub.alert.digest.model.ProjectData)2 ExternalConnectionTest (com.blackducksoftware.integration.test.annotation.ExternalConnectionTest)2 Test (org.junit.Test)2 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)1 TestGlobalProperties (com.blackducksoftware.integration.hub.alert.TestGlobalProperties)1 GlobalHipChatConfigEntity (com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.global.GlobalHipChatConfigEntity)1 ChannelRequestHelper (com.blackducksoftware.integration.hub.alert.channel.rest.ChannelRequestHelper)1 ChannelRestConnectionFactory (com.blackducksoftware.integration.hub.alert.channel.rest.ChannelRestConnectionFactory)1 GlobalHubRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.global.GlobalHubRepositoryWrapper)1 Category (org.junit.experimental.categories.Category)1