Search in sources :

Example 11 with WaitQueueCache

use of com.fanap.podchat.cachemodel.queue.WaitQueueCache in project pod-chat-android-sdk by FanapSoft.

the class TextMessagesQueueTest method cancelMessage.

@Test
public void cancelMessage() {
    List<WaitQueueCache> waiting = chat.getWaitingQ();
    System.out.println(">>> Message waiting: " + waiting.size());
    WaitQueueCache msgWaiting = waiting.get(0);
    chat.cancelMessage(msgWaiting.getUniqueId());
    sleep(1000);
    Assert.assertTrue(chat.getWaitingQ().stream().noneMatch(message -> message.getUniqueId().equals(msgWaiting.getUniqueId())));
    System.out.println(">>> Message waiting: " + chat.getWaitingQ().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) WaitQueueCache(com.fanap.podchat.cachemodel.queue.WaitQueueCache) Test(org.junit.Test)

Example 12 with WaitQueueCache

use of com.fanap.podchat.cachemodel.queue.WaitQueueCache in project pod-chat-android-sdk by FanapSoft.

the class TextMessagesQueueTest method resendMessageFromWaitingQ.

@Test
public void resendMessageFromWaitingQ() {
    ChatListener mTestListener = Mockito.mock(ChatListener.class);
    chat.setListener(mTestListener);
    List<WaitQueueCache> waitList = chat.getWaitingQ();
    WaitQueueCache wToSend = waitList.remove(0);
    chat.resendMessage(wToSend.getUniqueId());
    Mockito.verify(mTestListener, Mockito.after(2000).atLeastOnce()).onNewMessage(Mockito.any(), Mockito.argThat((ChatResponse<ResultNewMessage> result) -> result.getResult().getMessageVO().getUniqueId().equals(wToSend.getUniqueId())));
}
Also used : ResultNewMessage(com.fanap.podchat.model.ResultNewMessage) ChatListener(com.fanap.podchat.chat.ChatListener) WaitQueueCache(com.fanap.podchat.cachemodel.queue.WaitQueueCache) Test(org.junit.Test)

Aggregations

WaitQueueCache (com.fanap.podchat.cachemodel.queue.WaitQueueCache)12 SendingQueueCache (com.fanap.podchat.cachemodel.queue.SendingQueueCache)5 ChatListener (com.fanap.podchat.chat.ChatListener)3 MessageVO (com.fanap.podchat.mainmodel.MessageVO)3 ResultNewMessage (com.fanap.podchat.model.ResultNewMessage)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 Activity (android.app.Activity)2 Context (android.content.Context)2 Looper (android.os.Looper)2 InstrumentationRegistry (android.support.test.InstrumentationRegistry)2 ActivityTestRule (android.support.test.rule.ActivityTestRule)2 AndroidJUnit4 (android.support.test.runner.AndroidJUnit4)2 BaseApplication (com.example.chat.application.chatexample.BaseApplication)2 ChatActivity (com.example.chat.application.chatexample.ChatActivity)2 APP_ID (com.example.chat.application.chatexample.ChatActivity.APP_ID)2 ChatContract (com.example.chat.application.chatexample.ChatContract)2 ChatPresenter (com.example.chat.application.chatexample.ChatPresenter)2 Chat (com.fanap.podchat.chat.Chat)2 R (com.fanap.podchat.example.R)2