Skip to content

Commit

Permalink
add tests for the method findUserByEmail
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeep-yerramsetty committed Nov 1, 2021
1 parent 9705580 commit 84e9881
Showing 1 changed file with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ public void connect()
channels.put("channelid4",new SlackChannel("channelid4", "testchannel4", "topicchannel4", "topicchannel4", false, false, false));
channels.put("channelid5",new SlackChannel("channelid5", "testchannel5", "topicchannel5", "topicchannel5", false, false, false));

users.put("userid1",SlackPersonaImpl.builder().id("userid1").userName("username1").profile(SlackProfileImpl.builder().presence(SlackPresence.ACTIVE).skype("testSkype").phone("testPhone").title("testTitle").build()).timeZone("tz").timeZoneLabel("txLabel").build());
users.put("userid2",SlackPersonaImpl.builder().id("userid2").userName("username2").profile(SlackProfileImpl.builder().presence(SlackPresence.ACTIVE).skype("testSkype").phone("testPhone").title("testTitle").build()).timeZone("tz").timeZoneLabel("txLabel").build());
users.put("userid3",SlackPersonaImpl.builder().id("userid3").userName("username3").profile(SlackProfileImpl.builder().presence(SlackPresence.ACTIVE).skype("testSkype").phone("testPhone").title("testTitle").build()).timeZone("tz").timeZoneLabel("txLabel").build());
users.put("userid4",SlackPersonaImpl.builder().id("userid4").userName("username4").profile(SlackProfileImpl.builder().presence(SlackPresence.ACTIVE).skype("testSkype").phone("testPhone").title("testTitle").build()).timeZone("tz").timeZoneLabel("txLabel").build());
users.put("userid5",SlackPersonaImpl.builder().id("userid5").userName("username5").profile(SlackProfileImpl.builder().presence(SlackPresence.ACTIVE).skype("testSkype").phone("testPhone").title("testTitle").build()).timeZone("tz").timeZoneLabel("txLabel").build());
users.put("userid1",SlackPersonaImpl.builder().id("userid1").userName("username1").profile(SlackProfileImpl.builder().presence(SlackPresence.ACTIVE).skype("testSkype").phone("testPhone").title("testTitle").email("[email protected]").build()).timeZone("tz").timeZoneLabel("txLabel").build());
users.put("userid2",SlackPersonaImpl.builder().id("userid2").userName("username2").profile(SlackProfileImpl.builder().presence(SlackPresence.ACTIVE).skype("testSkype").phone("testPhone").title("testTitle").email("[email protected]").build()).timeZone("tz").timeZoneLabel("txLabel").build());
users.put("userid3",SlackPersonaImpl.builder().id("userid3").userName("username3").profile(SlackProfileImpl.builder().presence(SlackPresence.ACTIVE).skype("testSkype").phone("testPhone").title("testTitle").email("[email protected]").build()).timeZone("tz").timeZoneLabel("txLabel").build());
users.put("userid4",SlackPersonaImpl.builder().id("userid4").userName("username4").profile(SlackProfileImpl.builder().presence(SlackPresence.ACTIVE).skype("testSkype").phone("testPhone").title("testTitle").email("[email protected]").build()).timeZone("tz").timeZoneLabel("txLabel").build());
users.put("userid5",SlackPersonaImpl.builder().id("userid5").userName("username5").profile(SlackProfileImpl.builder().presence(SlackPresence.ACTIVE).skype("testSkype").phone("testPhone").title("testTitle").email("[email protected]").build()).timeZone("tz").timeZoneLabel("txLabel").build());
users.put("botid1",SlackPersonaImpl.builder().bot(true).id("botid1").userName("botname1").profile(SlackProfileImpl.builder().realName("real bot name 1").presence(SlackPresence.ACTIVE).skype("testSkype").phone("testPhone").title("testTitle").build()).timeZone("tz").timeZoneLabel("txLabel").build());
users.put("botid2",SlackPersonaImpl.builder().bot(true).id("botid2").userName("botname2").profile(SlackProfileImpl.builder().realName("real bot name 2").presence(SlackPresence.ACTIVE).skype("testSkype").phone("testPhone").title("testTitle").build()).timeZone("tz").timeZoneLabel("txLabel").build());
users.put("botid3",SlackPersonaImpl.builder().bot(true).id("botid3").userName("botname3").profile(SlackProfileImpl.builder().realName("real bot name 3").presence(SlackPresence.ACTIVE).skype("testSkype").phone("testPhone").title("testTitle").build()).timeZone("tz").timeZoneLabel("txLabel").build());

}

@Override
Expand Down Expand Up @@ -278,7 +277,7 @@ public SlackMessageHandle<EmojiSlackReply> listEmoji() {
public void refetchUsers() {}

@Override
public SlackMessageHandle inviteUser(String email, String firstName, boolean setActive)
public SlackMessageHandle inviteUser(String email, String firstName, boolean setActive)
{
return null;
}
Expand Down Expand Up @@ -497,6 +496,34 @@ public void testFindUserByUserName_MissingBot()
assertThat(slackSession.findUserByUserName("unknownuser")).isNull();
}

@Test
public void testFindUserByEmail_ExistingBot()
{
TestSlackSessionImpl slackSession = new TestSlackSessionImpl();

slackSession.connect();

// case-sensitive
SlackUser slackUser = slackSession.findUserByEmail("[email protected]");
assertThat(slackUser).isNotNull();
assertThat(slackUser.getId()).isEqualTo("userid1");

// case-insensitive
slackUser = slackSession.findUserByEmail("[email protected]");
assertThat(slackUser).isNotNull();
assertThat(slackUser.getId()).isEqualTo("userid1");
}

@Test
public void testFindUserByEmail_MissingBot()
{
TestSlackSessionImpl slackSession = new TestSlackSessionImpl();

slackSession.connect();

assertThat(slackSession.findUserByEmail("[email protected]")).isNull();
}

@Test
public void testAddConnectedListener() {
SlackConnectedListener listener = new SlackConnectedListener() {
Expand Down

0 comments on commit 84e9881

Please sign in to comment.