use of com.fanap.podchat.requestobject.RequestGetHistory 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.requestobject.RequestGetHistory in project pod-chat-android-sdk by FanapSoft.
the class AssistantCacheTest method populateMessagesFromCache.
public void populateMessagesFromCache() {
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 Cache: " + content);
threadMessagesList.addAll(history.getResult().getHistory());
chat.removeListener(chatListeners);
resumeProcess();
}
}
};
chat.addListener(chatListeners);
RequestGetHistory requestGetHistory = new RequestGetHistory.Builder(thread.getId()).build();
chat.getHistory(requestGetHistory, null);
pauseProcess();
}
use of com.fanap.podchat.requestobject.RequestGetHistory 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.requestobject.RequestGetHistory 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.requestobject.RequestGetHistory in project pod-chat-android-sdk by FanapSoft.
the class ChatTestSandbox method getThreadHistory.
public void getThreadHistory(long threadId) {
RequestGetHistory request = new RequestGetHistory.Builder(threadId).offset(0).count(25).order(// .order("asc")
"desc").build();
presenter.getHistory(request, null);
sleep(2000);
Mockito.verify(view, Mockito.atLeastOnce()).onGetThreadHistory(Mockito.any());
}
Aggregations