use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class ChatTestSandbox 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 ChatTestSandbox 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 ChatTestSandbox method getAssistantTest.
@Test
@LargeTest
public void getAssistantTest() {
long startTime = System.currentTimeMillis();
ChatListener historyListeners = new ChatListener() {
@Override
public void onGetAssistants(ChatResponse<List<AssistantVo>> response) {
System.out.println("onGetAssistants: " + response);
Assert.assertTrue(true);
}
};
chat.addListener(historyListeners);
getAssistants();
}
use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class ChatTestSandbox method deActiveAssistantTest.
@Test
@LargeTest
public void deActiveAssistantTest() {
long startTime = System.currentTimeMillis();
ChatListener historyListeners = new ChatListener() {
@Override
public void onDeActiveAssistant(ChatResponse<List<AssistantVo>> response) {
System.out.println("onDeActiveAssistant: " + response);
Assert.assertTrue(true);
}
};
chat.addListener(historyListeners);
deActiveAssistant();
}
use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class ChatTest method getThreadFullHistory.
private void getThreadFullHistory(Thread thread) {
long startTime = System.currentTimeMillis();
AtomicBoolean hasNext = new AtomicBoolean(true);
int count = 25;
AtomicLong offset = new AtomicLong(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());
if (hasNext.get()) {
offset.set(offset.get() + history.getResult().getHistory().size());
}
resumeProcess();
}
@Override
public void onError(String content, ErrorOutPut error) {
Assert.fail(content);
}
};
chat.addListener(historyListeners);
while (hasNext.get()) {
RequestGetHistory requestGetHistory = new RequestGetHistory.Builder(thread.getId()).offset(offset.get()).withNoCache().count(count).order("desc").build();
String uniqueId = presenter.getHistory(requestGetHistory, null);
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());
}
Aggregations