use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class AssistantCacheTest method populateMessagesFromServer.
public void populateMessagesFromServer() {
populateThreadsListFromServerOnly();
assert threads.size() > 0;
Thread thread = threads.get(0);
chatListeners = new ChatListener() {
@Override
public void onGetHistory(String content, ChatResponse<ResultHistory> history) {
if (!history.isCache()) {
print("Received Message List Server: " + content);
threadMessagesList.addAll(history.getResult().getHistory().stream().filter(messageVO -> messageVO.getMessage() != null).collect(Collectors.toList()));
chat.removeListener(chatListeners);
resumeProcess();
}
}
};
chat.addListener(chatListeners);
RequestGetHistory requestGetHistory = new RequestGetHistory.Builder(thread.getId()).withNoCache().build();
chat.getHistory(requestGetHistory, null);
pauseProcess();
}
use of com.fanap.podchat.model.ChatResponse 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));
}
use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class ChatTestIntegration method getThreadFullHistory.
private void getThreadFullHistory(Thread thread) {
long startTime = System.currentTimeMillis();
AtomicBoolean hasNext = new AtomicBoolean(true);
int count = 25;
int offset = 0;
AtomicLong threadMessagesCount = new AtomicLong(-1);
AtomicLong threadReceivedHistory = new AtomicLong(0);
ChatListener historyListeners = new ChatListener() {
@Override
public void onGetHistory(String content, ChatResponse<ResultHistory> history) {
threadMessagesCount.set(history.getResult().getContentCount());
long received = threadReceivedHistory.get();
threadReceivedHistory.set(received + history.getResult().getHistory().size());
hasNext.set(history.getResult().isHasNext());
resumeProcess();
}
};
chat.addListener(historyListeners);
while (hasNext.get()) {
RequestGetHistory requestGetHistory = new RequestGetHistory.Builder(thread.getId()).offset(offset).count(count).order("desc").build();
String uniqueId = presenter.getHistory(requestGetHistory, null);
offset = offset + count;
pauseProcess();
}
long endTime = System.currentTimeMillis();
System.out.println(">>> >>> >>>");
System.out.println(">>> >>> >>>");
System.out.println(">>> >>> >>>");
System.out.println("RUNNING TEST ON THREAD:");
System.out.println(thread.getTitle());
System.out.println(thread.getId());
System.out.println("RECEIVED TOTAL " + threadReceivedHistory + " MESSAGES OF HISTORY IN");
System.out.println(endTime - startTime + " MILLISECONDS");
System.out.println(">>> >>> >>>");
System.out.println(">>> >>> >>>");
System.out.println(">>> >>> >>>");
// Assert.assertEquals(threadMessagesCount.get(), threadReceivedHistory.get());
}
use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class ChatTestIntegration method getHistoryHashtagTest.
@Test
@LargeTest
public void getHistoryHashtagTest() {
long startTime = System.currentTimeMillis();
ChatListener historyListeners = new ChatListener() {
@Override
public void onGetHistory(String content, ChatResponse<ResultHistory> history) {
System.out.println("onGetHistory: ");
Logger.json(history.getJson());
Assert.assertTrue(true);
resumeProcess();
}
};
chat.setListener(historyListeners);
RequestGetHistory request = new RequestGetHistory.Builder(8085).offset(0).count(25).order("desc").build();
presenter.getHistory(request, null);
pauseProcess();
}
use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class ChatTestIntegration method registerAssistantsTest.
@Test
@LargeTest
public void registerAssistantsTest() {
ChatListener historyListeners = new ChatListener() {
@Override
public void onRegisterAssistant(ChatResponse<List<AssistantVo>> response) {
System.out.println("onRegisterAssistant: " + response.getJson());
Assert.assertTrue(true);
resumeProcess();
}
};
chat.addListener(historyListeners);
registerAssistant();
}
Aggregations