use of com.blackducksoftware.integration.hub.alert.channel.slack.mock.MockSlackEntity in project hub-alert by blackducksoftware.
the class SlackChannelTestIT method testCreateRequestExceptions.
@Test
public void testCreateRequestExceptions() {
final SlackChannel slackChannel = new SlackChannel(gson, null, null, null, null);
final MockSlackEntity mockSlackEntity = new MockSlackEntity();
Request request = null;
try {
request = slackChannel.createRequest(null, mockSlackEntity.createEmptyEntity(), null);
fail();
} catch (final IntegrationException e) {
assertNull(request);
}
mockSlackEntity.setChannelName("");
try {
request = slackChannel.createRequest(null, mockSlackEntity.createEntity(), null);
fail();
} catch (final IntegrationException e) {
assertNull(request);
}
}
use of com.blackducksoftware.integration.hub.alert.channel.slack.mock.MockSlackEntity in project hub-alert by blackducksoftware.
the class SlackChannelTestIT method testCreateHtmlMessage.
@SuppressWarnings("unchecked")
@Test
public void testCreateHtmlMessage() throws IntegrationException {
final SlackChannel slackChannel = new SlackChannel(gson, null, null, null, null);
final MockSlackEntity mockSlackEntity = new MockSlackEntity();
final ProjectData projectData = createSlackProjectData();
final ChannelRequestHelper channelRequestHelper = new ChannelRequestHelper(null) {
@Override
public Request createPostMessageRequest(final String url, final Map<String, String> headers, final String body) {
assertTrue(body.contains("Vulnerability Count Added: "));
assertTrue(body.contains("Vulnerability Count Updated: "));
assertTrue(body.contains("Vulnerability Count Deleted: "));
return null;
}
};
final ChannelRequestHelper spyChannelRequestHelper = Mockito.spy(channelRequestHelper);
final Request request = slackChannel.createRequest(spyChannelRequestHelper, mockSlackEntity.createEntity(), projectData);
assertNull(request);
Mockito.verify(spyChannelRequestHelper).createPostMessageRequest(Mockito.anyString(), Mockito.anyMap(), Mockito.anyString());
}
use of com.blackducksoftware.integration.hub.alert.channel.slack.mock.MockSlackEntity in project hub-alert by blackducksoftware.
the class SlackChannelTestIT method testCreateHtmlMessageEmpty.
@Test
@SuppressWarnings("unchecked")
public void testCreateHtmlMessageEmpty() throws IntegrationException {
final SlackChannel slackChannel = new SlackChannel(gson, null, null, null, null);
final MockSlackEntity mockSlackEntity = new MockSlackEntity();
final ProjectData projectData = new ProjectData(DigestTypeEnum.DAILY, "Slack", "1", null, null);
final ChannelRequestHelper channelRequestHelper = new ChannelRequestHelper(null) {
@Override
public Request createPostMessageRequest(final String url, final Map<String, String> headers, final String body) {
assertTrue(body.contains("A notification was received, but it was empty."));
return null;
}
};
final ChannelRequestHelper spyChannelRequestHelper = Mockito.spy(channelRequestHelper);
final Request request = slackChannel.createRequest(spyChannelRequestHelper, mockSlackEntity.createEntity(), projectData);
assertNull(request);
Mockito.verify(spyChannelRequestHelper).createPostMessageRequest(Mockito.anyString(), Mockito.anyMap(), Mockito.anyString());
}
Aggregations