use of com.fanap.podchat.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.
the class SearchMetadataTest method populateThreadsListFromServerOrCache.
// requests for list of threads
@Test
public void populateThreadsListFromServerOrCache() {
chatListeners = new ChatListener() {
@Override
public void onGetThread(String content, ChatResponse<ResultThreads> thread) {
System.out.println("Received List: " + content);
threads.addAll(thread.getResult().getThreads());
}
};
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 SearchMetadataTest method searchHistoryWithMetadata_Is_NumberTest.
@Test
@LargeTest
public void searchHistoryWithMetadata_Is_NumberTest() {
populateThreadsListFromServerOnly();
ChatListener mTestListener = Mockito.mock(ChatListener.class);
chat.setListener(mTestListener);
assert threads.size() > 0;
Thread thread = threads.get(0);
DummyMetadataVO dummyMetadataVO = new DummyMetadataVO();
dummyMetadataVO.desc = "876";
String meta = App.getGson().toJson(dummyMetadataVO);
RequestMessage sendMessageWithMetadataRequest = new RequestMessage.Builder("Android Test " + new Date(), thread.getId()).messageType(TextMessageType.Constants.TEXT).jsonMetaData(meta).build();
chat.sendTextMessage(sendMessageWithMetadataRequest, null);
sleep(6000);
NosqlSearchMetadataCriteria metadataCriteria = new NosqlSearchMetadataCriteria.Builder("desc").is(dummyMetadataVO.desc).build();
SearchSystemMetadataRequest request = new SearchSystemMetadataRequest.Builder(thread.getId()).metadataCriteria(metadataCriteria).count(50).build();
chat.searchHistory(request, null);
Mockito.verify(mTestListener, Mockito.after(5000).atLeastOnce()).onGetHistory(Mockito.any(String.class), Mockito.argThat((ChatResponse<ResultHistory> resp) -> resp.getResult().getHistory().stream().anyMatch(messageVO -> messageVO.getSystemMetadata().equals(meta))));
}
use of com.fanap.podchat.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.
the class SearchMetadataTest method chatListeners.
@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.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.
the class SearchMetadataTest method populateThreadsListFromServerOnly.
// requests for list of threads from server
@Test
public void populateThreadsListFromServerOnly() {
chatListeners = new ChatListener() {
@Override
public void onGetThread(String content, ChatResponse<ResultThreads> thread) {
if (!thread.isCache()) {
System.out.println("Received List: " + content);
threads.addAll(thread.getResult().getThreads());
resumeProcess();
}
}
};
chat.setListener(chatListeners);
RequestThread requestThread = new RequestThread.Builder().count(25).withNoCache().build();
presenter.getThreads(requestThread, null);
pauseProcess();
System.out.println("Received List: " + threads.size());
}
use of com.fanap.podchat.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.
the class SearchMetadataTest method searchHistoryWithMetadata_LT_Test.
@Test
@LargeTest
public void searchHistoryWithMetadata_LT_Test() {
populateThreadsListFromServerOnly();
assert threads.size() > 0;
Thread thread = threads.get(0);
ChatListener mTestListener = Mockito.mock(ChatListener.class);
chat.setListener(mTestListener);
NosqlSearchMetadataCriteria metadataCriteria = new NosqlSearchMetadataCriteria.Builder("count").lte("4").build();
SearchSystemMetadataRequest request = new SearchSystemMetadataRequest.Builder(thread.getId()).metadataCriteria(metadataCriteria).count(50).build();
chat.searchHistory(request, null);
Mockito.verify(mTestListener, Mockito.after(5000).atLeastOnce()).onGetHistory(Mockito.any(String.class), Mockito.argThat((ChatResponse<ResultHistory> resp) -> resp.getResult().getHistory().size() > 0));
}
Aggregations