use of com.fanap.podchat.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.
the class AssistantCacheTest method populateThreadsListFromServerOrCache.
// ///////////////////////////////////////////////////////////////////////////////
// requests for list of threads
public void populateThreadsListFromServerOrCache() {
chatListeners = new ChatListener() {
@Override
public void onGetThread(String content, ChatResponse<ResultThreads> thread) {
print("Received List: " + content);
threads.addAll(thread.getResult().getThreads());
chat.removeListener(chatListeners);
}
};
chat.addListener(chatListeners);
RequestThread requestThread = new RequestThread.Builder().count(25).build();
presenter.getThreads(requestThread, null);
long t1 = System.currentTimeMillis();
Mockito.verify(view, Mockito.after(10000).atLeastOnce()).onGetThreadList(Mockito.any(), Mockito.any());
long t2 = System.currentTimeMillis();
System.out.println("Received List: " + threads.size() + " after: " + (t2 - t1) + " ms");
}
use of com.fanap.podchat.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.
the class AssistantCacheTest method getAssistantList.
@Test
public void getAssistantList() {
ChatListener mTestListener = Mockito.mock(ChatListener.class);
chat.addListener(mTestListener);
GetAssistantRequest request = new GetAssistantRequest.Builder().setCount(25).setOffset(0).build();
chat.getAssistants(request);
Mockito.verify(mTestListener, Mockito.after(2000).atLeastOnce()).onGetAssistants(Mockito.any());
}
use of com.fanap.podchat.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.
the class AssistantCacheTest method getAndValidateAssistantHistoriesCache.
@Test
public void getAndValidateAssistantHistoriesCache() {
ArrayList<AssistantVo> assistantVoArrayList = new ArrayList<>();
chat.addListener(new ChatListener() {
@Override
public void onGetAssistants(ChatResponse<List<AssistantVo>> response) {
assistantVoArrayList.addAll(response.getResult());
chat.removeListener(this);
resumeProcess();
}
});
GetAssistantRequest request = new GetAssistantRequest.Builder().setCount(25).setOffset(0).build();
chat.getAssistants(request);
pauseProcess();
Collections.shuffle(assistantVoArrayList);
ArrayList<AssistantHistoryVo> assistantHistoryVos = new ArrayList<>();
ArrayList<AssistantHistoryVo> assistantHistoryVosCache = new ArrayList<>();
chat.addListener(new ChatListener() {
@Override
public void onGetAssistantHistory(ChatResponse<List<AssistantHistoryVo>> response) {
print("Received Assistant Histories cache: " + response.isCache());
prettyLog(App.getGson().toJson(response.getResult()));
if (response.isCache()) {
assistantHistoryVosCache.addAll(response.getResult());
} else {
assistantHistoryVos.addAll(response.getResult());
}
if (assistantHistoryVos.size() == assistantHistoryVosCache.size()) {
chat.removeListener(this);
resumeProcess();
}
}
});
GetAssistantHistoryRequest getAssistantHistoryRequest = new GetAssistantHistoryRequest.Builder().setCount(50).build();
chat.getAssistantHistory(getAssistantHistoryRequest);
pauseProcess();
Assert.assertTrue(true);
}
use of com.fanap.podchat.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.
the class ChatTestIntegration method createChat.
@Before
public void createChat() {
Looper.prepare();
MockitoAnnotations.initMocks(this);
RequestConnect rc = new RequestConnect.Builder(socketAddress, APP_ID, serverName, TOKEN, ssoHost, platformHost, fileServer, "podSpaceServer").build();
chatListeners = new ChatListener() {
@Override
public void onChatState(String state) {
if (state.equals(CHAT_READY)) {
resumeProcess();
}
}
};
chat.addListener(chatListeners);
chat.connect(rc);
pauseProcess();
}
use of com.fanap.podchat.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.
the class ChatTestIntegration method chatListeners.
// @After
// public void closeChat() {
// if (chat != null) {
// chat.closeChat();
// } else if (presenter != null) {
// presenter.closeChat();
// }
// }
@Test
public void chatListeners() {
ChatListener listener1 = new ChatListener() {
@Override
public void onSent(String content, ChatResponse<ResultMessage> response) {
}
};
chat.addListener(listener1);
ChatListener listener2 = new ChatListener() {
@Override
public void onSent(String content, ChatResponse<ResultMessage> response) {
}
};
chat.addListener(listener2);
ChatListener listener3 = new ChatListener() {
@Override
public void onSent(String content, ChatResponse<ResultMessage> response) {
}
};
chat.addListener(listener3);
chat.removeListener(listener2);
Assert.assertFalse(chat.getListeners().contains(listener2));
}
Aggregations