Search in sources :

Example 1 with RequestForwardMessage

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

the class MessagesCacheTest method forwardMessageAndCheckCache.

@Test
public void forwardMessageAndCheckCache() {
    populateThreadsListFromServerOnly();
    populateMessagesFromServer();
    assert threads.size() > 1;
    assert threadMessagesList.size() > 0;
    Collections.shuffle(threads);
    Thread thread2 = threads.get(1);
    MessageVO message = threadMessagesList.get(0);
    ChatListener mTestListener = Mockito.mock(ChatListener.class);
    chat.setListener(mTestListener);
    RequestForwardMessage forRequest = new RequestForwardMessage.Builder(thread2.getId(), new ArrayList<>(Collections.singletonList(message.getId()))).build();
    chat.forwardMessage(forRequest);
    sleep(2000);
    RequestGetHistory requestGetHistory = new RequestGetHistory.Builder(thread2.getId()).build();
    chat.getHistory(requestGetHistory, null);
    Mockito.verify(mTestListener, Mockito.after(2000).atLeastOnce()).onGetHistory(Mockito.any(), Mockito.argThat((ChatResponse<ResultHistory> response) -> response.isCache() && response.getResult().getHistory().stream().anyMatch(messageVO -> messageVO.getForwardInfo() != null)));
}
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) RequestForwardMessage(com.fanap.podchat.requestobject.RequestForwardMessage) 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) 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) Rule(org.junit.Rule) TextMessageType(com.fanap.podchat.util.TextMessageType) Assert(org.junit.Assert) Activity(android.app.Activity) Chat(com.fanap.podchat.chat.Chat) Collections(java.util.Collections) RequestReplyMessage(com.fanap.podchat.requestobject.RequestReplyMessage) RequestForwardMessage(com.fanap.podchat.requestobject.RequestForwardMessage) RequestGetHistory(com.fanap.podchat.requestobject.RequestGetHistory) ChatListener(com.fanap.podchat.chat.ChatListener) ArrayList(java.util.ArrayList) MessageVO(com.fanap.podchat.mainmodel.MessageVO) ResultHistory(com.fanap.podchat.model.ResultHistory) Thread(com.fanap.podchat.mainmodel.Thread) RequestThread(com.fanap.podchat.requestobject.RequestThread) Test(org.junit.Test)

Example 2 with RequestForwardMessage

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

the class MessagesCacheTest method forwardMessage.

@Test
public void forwardMessage() {
    populateThreadsListFromServerOnly();
    populateMessagesFromServer();
    assert threads.size() > 1;
    assert threadMessagesList.size() > 0;
    Thread thread = threads.get(0);
    Thread thread2 = threads.get(1);
    MessageVO message = threadMessagesList.get(0);
    ChatListener mTestListener = Mockito.mock(ChatListener.class);
    chat.setListener(mTestListener);
    RequestForwardMessage forRequest = new RequestForwardMessage.Builder(thread2.getId(), new ArrayList<>(Collections.singletonList(message.getId()))).build();
    chat.forwardMessage(forRequest);
    Mockito.verify(mTestListener, Mockito.after(2000).atLeastOnce()).onNewMessage(Mockito.any(), Mockito.any());
    sleep(2000);
}
Also used : RequestForwardMessage(com.fanap.podchat.requestobject.RequestForwardMessage) ChatListener(com.fanap.podchat.chat.ChatListener) ArrayList(java.util.ArrayList) MessageVO(com.fanap.podchat.mainmodel.MessageVO) Thread(com.fanap.podchat.mainmodel.Thread) RequestThread(com.fanap.podchat.requestobject.RequestThread) Test(org.junit.Test)

Example 3 with RequestForwardMessage

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

the class ChatActivity method forwardMessage.

public void forwardMessage() {
    ArrayList<Long> messageIds = new ArrayList<>();
    messageIds.add(73328L);
    messageIds.add(73327L);
    messageIds.add(73326L);
    long threadId = TEST_THREAD_ID;
    // presenter.forwardMessage(threadId, messageIds);
    RequestForwardMessage forwardMessage = new RequestForwardMessage.Builder(threadId, messageIds).build();
    presenter.forwardMessage(forwardMessage);
}
Also used : RequestForwardMessage(com.fanap.podchat.requestobject.RequestForwardMessage) ArrayList(java.util.ArrayList)

Aggregations

RequestForwardMessage (com.fanap.podchat.requestobject.RequestForwardMessage)3 ArrayList (java.util.ArrayList)3 ChatListener (com.fanap.podchat.chat.ChatListener)2 MessageVO (com.fanap.podchat.mainmodel.MessageVO)2 Thread (com.fanap.podchat.mainmodel.Thread)2 RequestThread (com.fanap.podchat.requestobject.RequestThread)2 Test (org.junit.Test)2 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 Chat (com.fanap.podchat.chat.Chat)1 R (com.fanap.podchat.example.R)1