Skip to content
Snippets Groups Projects
Commit 0da5c4f5 authored by Martin Staehr's avatar Martin Staehr
Browse files

#63 feat: implement exists function

parent 8efc1978
No related branches found
No related tags found
No related merge requests found
......@@ -77,6 +77,8 @@ public interface ICommunication {
*/
String getChatRoomName(String roomId);
boolean exists(String roomId);
/**
* api: https://rocket.chat/docs/developer-guides/rest-api/authentication/login/
*
......
......@@ -45,6 +45,8 @@ public class CommunicationDummyService implements ICommunication {
private UnirestService unirestService;
private UserDAO userDAO;
// TODO: refactor error handling and add maybe some descriptions
@Inject
public CommunicationDummyService(UnirestService unirestService, UserDAO userDAO) {
this.unirestService = unirestService;
......@@ -314,6 +316,10 @@ public class CommunicationDummyService implements ICommunication {
}
user.setRocketChatPersonalAccessToken(responseBody.get("token").toString());
return true;
}
@Override
public boolean exists(String roomId) {
return !getChatRoomName(roomId).isEmpty();
}
}
......@@ -67,5 +67,20 @@ public class CommunicationDummyServiceTest {
String actualChatRoomName = iCommunication.getChatRoomName(chatRoomId);
assertEquals(expectedChatRoomName, actualChatRoomName);
String nonExistingChatRoomName = iCommunication.getChatRoomName("1");
assertTrue(nonExistingChatRoomName.isEmpty());
}
@Test
public void exists() {
String expectedChatRoomName = "ChatRoomName";
String chatRoomId = iCommunication.createEmptyChatRoom(expectedChatRoomName, false);
assertNotNull(chatRoomId);
assertFalse(chatRoomId.isEmpty());
assertTrue(iCommunication.exists(chatRoomId));
assertFalse(iCommunication.exists("1"));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment