Search in sources :

Example 46 with ChatResponse

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));
}
Also used : ChatResponse(com.fanap.podchat.model.ChatResponse) ChatListener(com.fanap.podchat.chat.ChatListener) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest)

Example 47 with ChatResponse

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();
}
Also used : RequestGetHistory(com.fanap.podchat.requestobject.RequestGetHistory) ChatResponse(com.fanap.podchat.model.ChatResponse) ChatListener(com.fanap.podchat.chat.ChatListener) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest) LargeTest(android.support.test.filters.LargeTest)

Example 48 with ChatResponse

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();
}
Also used : AssistantVo(com.fanap.podchat.chat.assistant.model.AssistantVo) ChatResponse(com.fanap.podchat.model.ChatResponse) ChatListener(com.fanap.podchat.chat.ChatListener) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest) LargeTest(android.support.test.filters.LargeTest)

Example 49 with ChatResponse

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();
}
Also used : AssistantVo(com.fanap.podchat.chat.assistant.model.AssistantVo) ChatResponse(com.fanap.podchat.model.ChatResponse) ChatListener(com.fanap.podchat.chat.ChatListener) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest) LargeTest(android.support.test.filters.LargeTest)

Example 50 with ChatResponse

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());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicLong(java.util.concurrent.atomic.AtomicLong) RequestGetHistory(com.fanap.podchat.requestobject.RequestGetHistory) ChatResponse(com.fanap.podchat.model.ChatResponse) ChatListener(com.fanap.podchat.chat.ChatListener) ErrorOutPut(com.fanap.podchat.model.ErrorOutPut)

Aggregations

ChatResponse (com.fanap.podchat.model.ChatResponse)162 ChatListener (com.fanap.podchat.chat.ChatListener)38 Test (org.junit.Test)38 ArrayList (java.util.ArrayList)35 Thread (com.fanap.podchat.mainmodel.Thread)29 JsonSyntaxException (com.google.gson.JsonSyntaxException)29 ResultHistory (com.fanap.podchat.model.ResultHistory)28 LargeTest (android.support.test.filters.LargeTest)27 RequestThread (com.fanap.podchat.requestobject.RequestThread)27 PodChatException (com.fanap.podchat.util.PodChatException)26 MessageVO (com.fanap.podchat.mainmodel.MessageVO)25 RoomIntegrityException (com.fanap.podchat.persistance.RoomIntegrityException)23 IOException (java.io.IOException)23 JSONException (org.json.JSONException)22 ResultThreads (com.fanap.podchat.model.ResultThreads)21 RequestGetHistory (com.fanap.podchat.requestobject.RequestGetHistory)21 SentryException (io.sentry.core.protocol.SentryException)21 FlakyTest (android.support.test.filters.FlakyTest)19 MediumTest (android.support.test.filters.MediumTest)19 Activity (android.app.Activity)17