@Test public void testCreateGroupChat() { ArrayList<String> users = new ArrayList<>(); users.add("user1"); users.add("user2"); assertNotNull(users); String name = "name"; String icon = "icon"; Map<String, Object> data = new HashMap<>(); data.put("users", users); data.put("name", name); data.put("icon", icon); HttpsCallableReference mHttpsCallableReference = mock(HttpsCallableReference.class); when(mFirebaseFunction.getHttpsCallable("createGroupChat")).thenReturn(mHttpsCallableReference); when(mHttpsCallableReference.call(data)).thenReturn(null); conversationManager.createGroupChat(users, name, icon); verify(mFirebaseFunction, times(1)).getHttpsCallable("createGroupChat"); verify(mHttpsCallableReference, atLeastOnce()).call(data); }
public Task<HttpsCallableResult> createGroupChat(ArrayList<String> users, String name, String icon) { FirebaseFunctions mFunctions = FirebaseFunctions.getInstance(); Map<String, Object> data = new HashMap<>(); data.put("users", users); data.put("name", name); data.put("icon", icon); return mFunctions.getHttpsCallable("createGroupChat").call(data); }
ConversationManager { public Task<HttpsCallableResult> createGroupChat(ArrayList<String> users, String name, String icon) { FirebaseFunctions mFunctions = FirebaseFunctions.getInstance(); Map<String, Object> data = new HashMap<>(); data.put("users", users); data.put("name", name); data.put("icon", icon); return mFunctions.getHttpsCallable("createGroupChat").call(data); } }
ConversationManager { public Task<HttpsCallableResult> createGroupChat(ArrayList<String> users, String name, String icon) { FirebaseFunctions mFunctions = FirebaseFunctions.getInstance(); Map<String, Object> data = new HashMap<>(); data.put("users", users); data.put("name", name); data.put("icon", icon); return mFunctions.getHttpsCallable("createGroupChat").call(data); } ConversationManager(); }
ConversationManager { public Task<HttpsCallableResult> createGroupChat(ArrayList<String> users, String name, String icon) { FirebaseFunctions mFunctions = FirebaseFunctions.getInstance(); Map<String, Object> data = new HashMap<>(); data.put("users", users); data.put("name", name); data.put("icon", icon); return mFunctions.getHttpsCallable("createGroupChat").call(data); } ConversationManager(); static ConversationManager getInstance(); static void init(); void stopListening(); Conversation getConversation(String convId); String getPrivateConvId(String userId); PrivateConversation getPrivateConversation(String userId); ArrayList<Conversation> getConversations(); ArrayList<String> getFriendList(); Task<HttpsCallableResult> addFriend(String targetUid); Task<Void> deleteFriend(String targetUid); Task<HttpsCallableResult> createGroupChat(ArrayList<String> users, String name, String icon); void waitForOpenChatAvtivity(String convId); void deleteGroup(String convId); String getUid(); }
ConversationManager { public Task<HttpsCallableResult> createGroupChat(ArrayList<String> users, String name, String icon) { FirebaseFunctions mFunctions = FirebaseFunctions.getInstance(); Map<String, Object> data = new HashMap<>(); data.put("users", users); data.put("name", name); data.put("icon", icon); return mFunctions.getHttpsCallable("createGroupChat").call(data); } ConversationManager(); static ConversationManager getInstance(); static void init(); void stopListening(); Conversation getConversation(String convId); String getPrivateConvId(String userId); PrivateConversation getPrivateConversation(String userId); ArrayList<Conversation> getConversations(); ArrayList<String> getFriendList(); Task<HttpsCallableResult> addFriend(String targetUid); Task<Void> deleteFriend(String targetUid); Task<HttpsCallableResult> createGroupChat(ArrayList<String> users, String name, String icon); void waitForOpenChatAvtivity(String convId); void deleteGroup(String convId); String getUid(); final static String BROADCAST_CONVERSATION_UPDATED; final static String BROADCAST_MESSAGE_READ_CHANGE; }