Search in sources :

Example 21 with RequestThread

use of com.fanap.podchat.requestobject.RequestThread 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());
}
Also used : ResultThreads(com.fanap.podchat.model.ResultThreads) ChatListener(com.fanap.podchat.chat.ChatListener) RequestThread(com.fanap.podchat.requestobject.RequestThread) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest)

Example 22 with RequestThread

use of com.fanap.podchat.requestobject.RequestThread in project pod-chat-android-sdk by FanapSoft.

the class TextMessagesQueueTest 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()) {
                System.out.println("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();
    System.out.println("Received List: " + threads.size());
}
Also used : ResultThreads(com.fanap.podchat.model.ResultThreads) Context(android.content.Context) ResultNewMessage(com.fanap.podchat.model.ResultNewMessage) RequestConnect(com.fanap.podchat.requestobject.RequestConnect) BeforeClass(org.junit.BeforeClass) SendingQueueCache(com.fanap.podchat.cachemodel.queue.SendingQueueCache) Mock(org.mockito.Mock) Date(java.util.Date) Thread(com.fanap.podchat.mainmodel.Thread) RunWith(org.junit.runner.RunWith) ChatPresenter(com.example.chat.application.chatexample.ChatPresenter) ChatContract(com.example.chat.application.chatexample.ChatContract) ChatResponse(com.fanap.podchat.model.ChatResponse) ArrayList(java.util.ArrayList) WaitQueueCache(com.fanap.podchat.cachemodel.queue.WaitQueueCache) R(com.fanap.podchat.example.R) ResultHistory(com.fanap.podchat.model.ResultHistory) Looper(android.os.Looper) BaseApplication(com.example.chat.application.chatexample.BaseApplication) ChatActivity(com.example.chat.application.chatexample.ChatActivity) RequestThread(com.fanap.podchat.requestobject.RequestThread) RequestMessage(com.fanap.podchat.requestobject.RequestMessage) Before(org.junit.Before) RequestGetHistory(com.fanap.podchat.requestobject.RequestGetHistory) CHAT_READY(com.fanap.podchat.util.ChatStateType.ChatSateConstant.CHAT_READY) ActivityTestRule(android.support.test.rule.ActivityTestRule) Test(org.junit.Test) InstrumentationRegistry(android.support.test.InstrumentationRegistry) AndroidJUnit4(android.support.test.runner.AndroidJUnit4) ChatListener(com.fanap.podchat.chat.ChatListener) MessageVO(com.fanap.podchat.mainmodel.MessageVO) Collectors(java.util.stream.Collectors) Mockito(org.mockito.Mockito) APP_ID(com.example.chat.application.chatexample.ChatActivity.APP_ID) List(java.util.List) ErrorOutPut(com.fanap.podchat.model.ErrorOutPut) ResultMessage(com.fanap.podchat.model.ResultMessage) Rule(org.junit.Rule) TextMessageType(com.fanap.podchat.util.TextMessageType) Assert(org.junit.Assert) Activity(android.app.Activity) Chat(com.fanap.podchat.chat.Chat) ResultThreads(com.fanap.podchat.model.ResultThreads) ChatListener(com.fanap.podchat.chat.ChatListener) RequestThread(com.fanap.podchat.requestobject.RequestThread)

Example 23 with RequestThread

use of com.fanap.podchat.requestobject.RequestThread in project pod-chat-android-sdk by FanapSoft.

the class ChatTestIntegration method populateThreadsListFromServerOrCache.

@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());
            resumeProcess();
        }
    };
    chat.addListener(chatListeners);
    RequestThread requestThread = new RequestThread.Builder().count(25).build();
    presenter.getThreads(requestThread, null);
    pauseProcess();
    System.out.println("Received List: " + threads.size());
}
Also used : ResultThreads(com.fanap.podchat.model.ResultThreads) ChatListener(com.fanap.podchat.chat.ChatListener) RequestThread(com.fanap.podchat.requestobject.RequestThread) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest)

Example 24 with RequestThread

use of com.fanap.podchat.requestobject.RequestThread in project pod-chat-android-sdk by FanapSoft.

the class ThreadCacheTest method populateThreadsFromServer.

public void populateThreadsFromServer() {
    chatListeners = new ChatListener() {

        @Override
        public void onGetThread(String content, ChatResponse<ResultThreads> thread) {
            assert thread.getResult().getThreads().size() > 0;
            if (!thread.isCache()) {
                threadsInServer.addAll(new ArrayList<>(thread.getResult().getThreads()));
                chat.removeListener(chatListeners);
            }
        }
    };
    chat.addListener(chatListeners);
    RequestThread requestThread = new RequestThread.Builder().count(25).build();
    presenter.getThreads(requestThread, null);
    long t1 = System.currentTimeMillis();
    sleep(2500);
    long t2 = System.currentTimeMillis();
    System.out.println("Received List: " + threadsInServer.size() + " after: " + (t2 - t1) + " ms");
}
Also used : ResultThreads(com.fanap.podchat.model.ResultThreads) ChatListener(com.fanap.podchat.chat.ChatListener) ArrayList(java.util.ArrayList) RequestThread(com.fanap.podchat.requestobject.RequestThread)

Example 25 with RequestThread

use of com.fanap.podchat.requestobject.RequestThread in project pod-chat-android-sdk by FanapSoft.

the class IntegrationTest 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");
}
Also used : ResultThreads(com.fanap.podchat.model.ResultThreads) ChatListener(com.fanap.podchat.chat.ChatListener) RequestThread(com.fanap.podchat.requestobject.RequestThread) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest)

Aggregations

RequestThread (com.fanap.podchat.requestobject.RequestThread)28 ChatListener (com.fanap.podchat.chat.ChatListener)24 ResultThreads (com.fanap.podchat.model.ResultThreads)24 Test (org.junit.Test)14 LargeTest (android.support.test.filters.LargeTest)12 FlakyTest (android.support.test.filters.FlakyTest)5 MediumTest (android.support.test.filters.MediumTest)5 Thread (com.fanap.podchat.mainmodel.Thread)5 ArrayList (java.util.ArrayList)5 ResultHistory (com.fanap.podchat.model.ResultHistory)4 Activity (android.app.Activity)3 Context (android.content.Context)3 Looper (android.os.Looper)3 InstrumentationRegistry (android.support.test.InstrumentationRegistry)3 ActivityTestRule (android.support.test.rule.ActivityTestRule)3 AndroidJUnit4 (android.support.test.runner.AndroidJUnit4)3 BaseApplication (com.example.chat.application.chatexample.BaseApplication)3 ChatActivity (com.example.chat.application.chatexample.ChatActivity)3 APP_ID (com.example.chat.application.chatexample.ChatActivity.APP_ID)3 ChatContract (com.example.chat.application.chatexample.ChatContract)3