Search in sources :

Example 1 with CHAT_READY

use of com.fanap.podchat.util.ChatStateType.ChatSateConstant.CHAT_READY in project pod-chat-android-sdk by FanapSoft.

the class TextMessagesQueueTest method checkSendingQueue.

@Test
public void checkSendingQueue() {
    populateThreadsListFromServerOnly();
    assert threads.size() > 0;
    Thread thread = threads.get(0);
    ChatListener mTestListener = Mockito.mock(ChatListener.class);
    chat.setListener(mTestListener);
    chat.closeChat();
    sleep(2000);
    Assert.assertNotEquals(chat.getChatState(), CHAT_READY);
    RequestMessage request = new RequestMessage.Builder("Android Test " + new Date(), thread.getId()).messageType(TextMessageType.Constants.TEXT).build();
    String uniqueId = chat.sendTextMessage(request, null);
    List<SendingQueueCache> sendQ = chat.getSendingQ();
    Assert.assertTrue(sendQ.stream().anyMatch(sendingQueueCache -> sendingQueueCache.getUniqueId().equals(uniqueId)));
}
Also used : SendingQueueCache(com.fanap.podchat.cachemodel.queue.SendingQueueCache) 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) RequestMessage(com.fanap.podchat.requestobject.RequestMessage) ChatListener(com.fanap.podchat.chat.ChatListener) Date(java.util.Date) Thread(com.fanap.podchat.mainmodel.Thread) RequestThread(com.fanap.podchat.requestobject.RequestThread) Test(org.junit.Test)

Aggregations

Activity (android.app.Activity)1 Context (android.content.Context)1 Looper (android.os.Looper)1 InstrumentationRegistry (android.support.test.InstrumentationRegistry)1 ActivityTestRule (android.support.test.rule.ActivityTestRule)1 AndroidJUnit4 (android.support.test.runner.AndroidJUnit4)1 BaseApplication (com.example.chat.application.chatexample.BaseApplication)1 ChatActivity (com.example.chat.application.chatexample.ChatActivity)1 APP_ID (com.example.chat.application.chatexample.ChatActivity.APP_ID)1 ChatContract (com.example.chat.application.chatexample.ChatContract)1 ChatPresenter (com.example.chat.application.chatexample.ChatPresenter)1 SendingQueueCache (com.fanap.podchat.cachemodel.queue.SendingQueueCache)1 WaitQueueCache (com.fanap.podchat.cachemodel.queue.WaitQueueCache)1 Chat (com.fanap.podchat.chat.Chat)1 ChatListener (com.fanap.podchat.chat.ChatListener)1 R (com.fanap.podchat.example.R)1 MessageVO (com.fanap.podchat.mainmodel.MessageVO)1 Thread (com.fanap.podchat.mainmodel.Thread)1 ChatResponse (com.fanap.podchat.model.ChatResponse)1 ErrorOutPut (com.fanap.podchat.model.ErrorOutPut)1