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);
}
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);
}
}
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);
}
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;
}
Aggregations