use of com.fanap.podchat.mainmodel.Thread in project pod-chat-android-sdk by FanapSoft.
the class AssistantCacheTest method populateMessagesFromServerOrCache.
public void populateMessagesFromServerOrCache() {
populateThreadsListFromServerOnly();
assert threads.size() > 0;
Thread thread = threads.get(0);
chatListeners = new ChatListener() {
@Override
public void onGetHistory(String content, ChatResponse<ResultHistory> history) {
System.out.println("Received Message List, Cache: " + history.isCache() + " Content: " + 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.mainmodel.Thread in project pod-chat-android-sdk by FanapSoft.
the class AssistantCacheTest method getValidGroupThread.
private Thread getValidGroupThread() {
Thread selected = threads.stream().filter(thread1 -> (thread1.isGroup() && !thread1.isClosed() && thread1.getAdmin())).collect(Collectors.toList()).get(0);
print("Selected thread: " + App.getGson().toJson(selected));
return selected;
}
use of com.fanap.podchat.mainmodel.Thread in project pod-chat-android-sdk by FanapSoft.
the class AssistantCacheTest method populateThreadsListFromServerOnly.
// requests for list of threads from server
public void populateThreadsListFromServerOnly() {
chatListeners = new ChatListener() {
@Override
public void onGetThread(String content, ChatResponse<ResultThreads> response) {
if (!response.isCache()) {
print("Received List: " + content);
threads.addAll(response.getResult().getThreads().stream().filter(thread -> thread.getTitle() != null && thread.getId() > 0 && !thread.isClosed() && thread.getLastMessageVO() != null).collect(Collectors.toList()));
chat.removeListener(chatListeners);
resumeProcess();
}
}
};
chat.setListener(chatListeners);
RequestThread requestThread = new RequestThread.Builder().count(25).withNoCache().build();
presenter.getThreads(requestThread, null);
pauseProcess();
print("Received List: " + threads.size());
}
use of com.fanap.podchat.mainmodel.Thread in project pod-chat-android-sdk by FanapSoft.
the class ChatTest method getUserRolesInThread.
@Test
@LargeTest
public void getUserRolesInThread() {
populateThreadsListFromServerOrCache();
for (Thread t : threads) {
if (t.getAdmin()) {
System.out.println("Get roles in " + t.getId());
getCurrentUserRoles(t.getId());
break;
}
}
System.out.println("** Get roles in " + threads.get(0).getId());
getCurrentUserRoles(threads.get(0).getId());
}
use of com.fanap.podchat.mainmodel.Thread in project pod-chat-android-sdk by FanapSoft.
the class ChatTest method sendALotOfMessageToThread.
@Test
@LargeTest
public void sendALotOfMessageToThread() {
populateThreadsListFromServerOnly();
long threadID = threads.get(0).getId();
for (Thread thread : new ArrayList<>(threads)) {
if (!thread.isClosed() && thread.getParticipantCount() > 1) {
threadID = thread.getId();
}
}
if (threadID > 0) {
int counter = 0;
int count = 5;
while (counter < count) {
RequestMessage requestMessage = new RequestMessage.Builder("This is test " + new Date().getTime(), threadID).messageType(TextMessageType.Constants.TEXT).jsonMetaData("From android instrumental test at " + new Date().getTime()).build();
presenter.sendTextMessage(requestMessage, null);
counter++;
}
sleep(7000);
Mockito.verify(view, Mockito.atLeastOnce()).onSentMessage();
} else {
Assert.fail("no suitable thread found");
}
}
Aggregations