Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException while message sending #216

Merged
merged 2 commits into from
Oct 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,9 @@ private void stopConnectionMonitoring() {

@Override
public SlackMessageHandle<SlackMessageReply> sendMessage(SlackChannel channel, SlackPreparedMessage preparedMessage, SlackChatConfiguration chatConfiguration) {
if (channel == null) {
throw new IllegalArgumentException("Channel can't be null");
}
SlackMessageHandle<SlackMessageReply> handle = new SlackMessageHandle<>(getNextMessageId());
Map<String, String> arguments = new HashMap<>();
arguments.put("token", authToken);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.ullink.slack.simpleslackapi.impl;

import com.ullink.slack.simpleslackapi.WebSocketContainerProvider;
import mockit.Mocked;
import org.junit.Test;

import java.util.concurrent.TimeUnit;

import static org.junit.Assert.fail;

public class TestSlackWebSocketSessionImpl {

@Test(expected = IllegalArgumentException.class)
public void testSendMessageWithNullChanel(@Mocked WebSocketContainerProvider provider) throws Exception{
SlackWebSocketSessionImpl webSocketSession = new SlackWebSocketSessionImpl(provider,
"", false, 42L, TimeUnit.MILLISECONDS);
try {
webSocketSession.sendMessage(null, "");
} catch (NullPointerException e) {
fail("NullPointerException unexpected here");
}
}
}