use of com.fanap.podchat.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.
the class SearchMetadataTest method searchHistoryWithMetadata_Has_Test.
@Test
@LargeTest
public void searchHistoryWithMetadata_Has_Test() {
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 = "Find me before " + System.currentTimeMillis() + (1_000_000 * 6);
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").has(" me ").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().contains(dummyMetadataVO.desc))));
}
use of com.fanap.podchat.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.
the class TagCacheTest method createChat.
@Before
public void createChat() {
view = Mockito.mock(ChatContract.view.class);
chatActivity = chatActivityRule.getActivity();
presenter = new ChatPresenter(appContext, view, chatActivity);
RequestConnect rc = new RequestConnect.Builder(socketAddress, APP_ID, serverName, TOKEN, ssoHost, platformHost, fileServer, "podSpaceServer").build();
chatListeners = new ChatListener() {
@Override
public void onChatState(String state) {
if (state.equals(CHAT_READY)) {
resumeProcess();
}
}
};
chat.addListener(chatListeners);
chat.connect(rc);
chat.isCacheables(CACHE);
pauseProcess();
}
use of com.fanap.podchat.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.
the class TagCacheTest method editTag.
public void editTag(long tagId) {
chatListeners = new ChatListener() {
@Override
public void onTagEdited(String content, ChatResponse<TagResult> response) {
chat.removeListener(chatListeners);
resumeProcess();
}
};
chat.setListener(chatListeners);
EditTagRequest request = new EditTagRequest.Builder(tagId, "EditedTag_" + System.currentTimeMillis()).build();
chat.editTag(request);
pauseProcess();
System.out.println("Tag Edited: ");
}
use of com.fanap.podchat.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.
the class TextMessagesQueueTest 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.chat.ChatListener in project pod-chat-android-sdk by FanapSoft.
the class TextMessagesQueueTest method createChat.
@Before
public void createChat() {
view = Mockito.mock(ChatContract.view.class);
chatActivity = chatActivityRule.getActivity();
presenter = new ChatPresenter(appContext, view, chatActivity);
RequestConnect rc = new RequestConnect.Builder(socketAddress, APP_ID, serverName, TOKEN, ssoHost, platformHost, fileServer, "podSpaceServer").build();
chatListeners = new ChatListener() {
@Override
public void onChatState(String state) {
if (state.equals(CHAT_READY)) {
resumeProcess();
}
}
};
chat.addListener(chatListeners);
chat.connect(rc);
chat.isCacheables(CACHE);
pauseProcess();
}
Aggregations