Search in sources :

Example 16 with MessageVO

use of com.fanap.podchat.mainmodel.MessageVO in project pod-chat-android-sdk by FanapSoft.

the class MentionCacheTest method checkMentionsAreSameInCacheAndServer.

public void checkMentionsAreSameInCacheAndServer() {
    Assert.assertEquals(threadMentionMessagesListInCache.size(), threadMentionMessagesListInServer.size());
    Assert.assertEquals(threadMentionMessagesListInCache.size() > 0, threadMentionMessagesListInServer.size() > 0);
    for (MessageVO msg : threadMentionMessagesListInServer) {
        if (msg.getMessage() == null)
            continue;
        MessageVO msgInCache = threadMentionMessagesListInCache.stream().filter(messageVO -> messageVO.getId() == msg.getId()).findFirst().get();
        System.out.println(">>>>>>>>>>> Server Mention Message " + msg.getMessage());
        System.out.println(">>>>>>>>>>> Cache Mention Message " + msgInCache.getMessage());
        Assert.assertEquals(msg.getMessage(), msgInCache.getMessage());
        Assert.assertEquals(msg.getId(), msgInCache.getId());
    }
}
Also used : MessageVO(com.fanap.podchat.mainmodel.MessageVO)

Example 17 with MessageVO

use of com.fanap.podchat.mainmodel.MessageVO in project pod-chat-android-sdk by FanapSoft.

the class DbTest method updateCacheFirstMsgIdAndLastMsgIdConditional2.

// first messsage and last message
// Conditional 2
// cache siz more than one but server size is 1
@Test
public void updateCacheFirstMsgIdAndLastMsgIdConditional2() {
    long threadId = 2;
    Callback callback = new Callback();
    List<MessageVO> messageVOS = new ArrayList<>();
    // MessageVO messageVO = new MessageVO(
    // 5653,
    // false,
    // false,
    // false,
    // false,
    // false,
    // "91efe7da-547f-4c5f-c34b-0442951ffbbc",
    // 0,
    // 5652,
    // "",
    // null,
    // 13354321,
    // 321000000,
    // "",
    // null,
    // null,
    // null,
    // null
    // 
    // );
    List<CacheMessageVO> cacheMessageVOS = new ArrayList<>();
    CacheMessageVO cacheMessageVO = new CacheMessageVO();
    cacheMessageVO.setId(5878);
    cacheMessageVO.setThreadVoId(2L);
    cacheMessageVOS.add(cacheMessageVO);
    // messageVOS.add(messageVO);
    callback.setOffset(0);
    callback.setOffset(0);
    callback.setCount(50);
    callback.setOrder("asc");
    callback.setFirstMessageId(5652);
    callback.setLastMessageId(5878);
    messageDatabaseHelper.updateGetHistoryResponse(callback, messageVOS, threadId, cacheMessageVOS);
}
Also used : Callback(com.fanap.podchat.util.Callback) ArrayList(java.util.ArrayList) MessageVO(com.fanap.podchat.mainmodel.MessageVO) CacheMessageVO(com.fanap.podchat.cachemodel.CacheMessageVO) CacheMessageVO(com.fanap.podchat.cachemodel.CacheMessageVO) Test(org.junit.Test)

Example 18 with MessageVO

use of com.fanap.podchat.mainmodel.MessageVO in project pod-chat-android-sdk by FanapSoft.

the class HashTagCacheTest method populateHashTagListFromServer.

public void populateHashTagListFromServer(long threadId) {
    threadHashTagMessagesListInServer.clear();
    chatListeners = new ChatListener() {

        @Override
        public void onGetHashTagList(ChatResponse<ResultHistory> response) {
            if (!response.isCache()) {
                System.out.println("Received HashTag Message List Server: " + response.getJson());
                threadHashTagMessagesListInServer.addAll(response.getResult().getHistory().stream().filter(messageVO -> messageVO.getMessage() != null).collect(Collectors.toList()));
                chat.removeListener(chatListeners);
                resumeProcess();
            }
        }
    };
    chat.setListener(chatListeners);
    RequestGetHashTagList request = new RequestGetHashTagList.Builder(threadId).offset(0).count(25).setHashtag("test").build();
    presenter.getHashTagList(request, null);
    pauseProcess();
    System.out.println("Received HashTag Message List Server: " + threadHashTagMessagesListInServer.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) 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) 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) RequestGetMentionList(com.fanap.podchat.chat.mention.model.RequestGetMentionList) MessageVO(com.fanap.podchat.mainmodel.MessageVO) Collectors(java.util.stream.Collectors) RequestGetHashTagList(com.fanap.podchat.chat.hashtag.model.RequestGetHashTagList) 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) RequestGetHashTagList(com.fanap.podchat.chat.hashtag.model.RequestGetHashTagList) ChatListener(com.fanap.podchat.chat.ChatListener) ResultHistory(com.fanap.podchat.model.ResultHistory)

Example 19 with MessageVO

use of com.fanap.podchat.mainmodel.MessageVO in project pod-chat-android-sdk by FanapSoft.

the class HashTagCacheTest method checkHashTagsAreSameInCacheAndServer.

public void checkHashTagsAreSameInCacheAndServer() {
    Assert.assertEquals(threadHashTagMessagesListInCache.size(), threadHashTagMessagesListInServer.size());
    Assert.assertEquals(threadHashTagMessagesListInCache.size() > 0, threadHashTagMessagesListInServer.size() > 0);
    for (MessageVO msg : threadHashTagMessagesListInServer) {
        if (msg.getMessage() == null)
            continue;
        MessageVO msgInCache = threadHashTagMessagesListInCache.stream().filter(messageVO -> messageVO.getId() == msg.getId()).findFirst().get();
        System.out.println(">>>>>>>>>>> Server HashTag Message " + msg.getMessage());
        System.out.println(">>>>>>>>>>> Cache HashTag Message " + msgInCache.getMessage());
        Assert.assertEquals(msg.getMessage(), msgInCache.getMessage());
        Assert.assertEquals(msg.getId(), msgInCache.getId());
    }
}
Also used : MessageVO(com.fanap.podchat.mainmodel.MessageVO)

Example 20 with MessageVO

use of com.fanap.podchat.mainmodel.MessageVO in project pod-chat-android-sdk by FanapSoft.

the class HashTagCacheTest method populateHashTagListFromCache.

public void populateHashTagListFromCache(long threadId) {
    threadHashTagMessagesListInCache.clear();
    chatListeners = new ChatListener() {

        @Override
        public void onGetHashTagList(ChatResponse<ResultHistory> response) {
            if (response.isCache()) {
                System.out.println("Received HashTag Message List Server: " + response.getJson());
                threadHashTagMessagesListInCache.addAll(response.getResult().getHistory().stream().filter(messageVO -> messageVO.getMessage() != null).collect(Collectors.toList()));
                chat.removeListener(chatListeners);
                resumeProcess();
            } else {
                Assert.assertEquals(5, 10);
                resumeProcess();
            }
        }
    };
    chat.setListener(chatListeners);
    RequestGetHashTagList request = new RequestGetHashTagList.Builder(threadId).offset(0).count(25).setHashtag("test").build();
    presenter.getHashTagList(request, null);
    pauseProcess();
    System.out.println("Received HashTag Message List Server: " + threadHashTagMessagesListInCache.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) 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) 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) RequestGetMentionList(com.fanap.podchat.chat.mention.model.RequestGetMentionList) MessageVO(com.fanap.podchat.mainmodel.MessageVO) Collectors(java.util.stream.Collectors) RequestGetHashTagList(com.fanap.podchat.chat.hashtag.model.RequestGetHashTagList) 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) RequestGetHashTagList(com.fanap.podchat.chat.hashtag.model.RequestGetHashTagList) ChatListener(com.fanap.podchat.chat.ChatListener) ResultHistory(com.fanap.podchat.model.ResultHistory)

Aggregations

MessageVO (com.fanap.podchat.mainmodel.MessageVO)48 ArrayList (java.util.ArrayList)34 CacheMessageVO (com.fanap.podchat.cachemodel.CacheMessageVO)25 GapMessageVO (com.fanap.podchat.cachemodel.GapMessageVO)20 Thread (com.fanap.podchat.mainmodel.Thread)20 Test (org.junit.Test)20 ChatResponse (com.fanap.podchat.model.ChatResponse)18 ResultHistory (com.fanap.podchat.model.ResultHistory)18 ChatListener (com.fanap.podchat.chat.ChatListener)15 ResultNewMessage (com.fanap.podchat.model.ResultNewMessage)15 RequestThread (com.fanap.podchat.requestobject.RequestThread)15 PinMessageVO (com.fanap.podchat.mainmodel.PinMessageVO)13 Activity (android.app.Activity)10 Context (android.content.Context)10 Looper (android.os.Looper)10 InstrumentationRegistry (android.support.test.InstrumentationRegistry)10 ActivityTestRule (android.support.test.rule.ActivityTestRule)10 AndroidJUnit4 (android.support.test.runner.AndroidJUnit4)10 BaseApplication (com.example.chat.application.chatexample.BaseApplication)10 ChatActivity (com.example.chat.application.chatexample.ChatActivity)10