Search in sources :

Example 1 with GetAssistantHistoryRequest

use of com.fanap.podchat.chat.assistant.request_model.GetAssistantHistoryRequest in project pod-chat-android-sdk by FanapSoft.

the class AssistantCacheTest method getAssistantHistories.

@Test
public void getAssistantHistories() {
    ArrayList<AssistantVo> assistantVoArrayList = new ArrayList<>();
    chat.addListener(new ChatListener() {

        @Override
        public void onGetAssistants(ChatResponse<List<AssistantVo>> response) {
            assistantVoArrayList.addAll(response.getResult());
            chat.removeListener(this);
            resumeProcess();
        }
    });
    GetAssistantRequest request = new GetAssistantRequest.Builder().setCount(25).setOffset(0).build();
    chat.getAssistants(request);
    pauseProcess();
    Collections.shuffle(assistantVoArrayList);
    ChatListener mMockedListener = Mockito.mock(ChatListener.class);
    chat.addListener(mMockedListener);
    GetAssistantHistoryRequest getAssistantHistoryRequest = new GetAssistantHistoryRequest.Builder().setCount(50).build();
    chat.getAssistantHistory(getAssistantHistoryRequest);
    Mockito.verify(mMockedListener, Mockito.after(3000).atLeastOnce()).onGetAssistantHistory(Mockito.any());
}
Also used : AssistantVo(com.fanap.podchat.chat.assistant.model.AssistantVo) ArrayList(java.util.ArrayList) ChatListener(com.fanap.podchat.chat.ChatListener) List(java.util.List) ArrayList(java.util.ArrayList) GetAssistantHistoryRequest(com.fanap.podchat.chat.assistant.request_model.GetAssistantHistoryRequest) GetAssistantRequest(com.fanap.podchat.chat.assistant.request_model.GetAssistantRequest) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest)

Example 2 with GetAssistantHistoryRequest

use of com.fanap.podchat.chat.assistant.request_model.GetAssistantHistoryRequest in project pod-chat-android-sdk by FanapSoft.

the class AssistantCacheTest method getAndValidateAssistantHistoriesCache.

@Test
public void getAndValidateAssistantHistoriesCache() {
    ArrayList<AssistantVo> assistantVoArrayList = new ArrayList<>();
    chat.addListener(new ChatListener() {

        @Override
        public void onGetAssistants(ChatResponse<List<AssistantVo>> response) {
            assistantVoArrayList.addAll(response.getResult());
            chat.removeListener(this);
            resumeProcess();
        }
    });
    GetAssistantRequest request = new GetAssistantRequest.Builder().setCount(25).setOffset(0).build();
    chat.getAssistants(request);
    pauseProcess();
    Collections.shuffle(assistantVoArrayList);
    ArrayList<AssistantHistoryVo> assistantHistoryVos = new ArrayList<>();
    ArrayList<AssistantHistoryVo> assistantHistoryVosCache = new ArrayList<>();
    chat.addListener(new ChatListener() {

        @Override
        public void onGetAssistantHistory(ChatResponse<List<AssistantHistoryVo>> response) {
            print("Received Assistant Histories cache: " + response.isCache());
            prettyLog(App.getGson().toJson(response.getResult()));
            if (response.isCache()) {
                assistantHistoryVosCache.addAll(response.getResult());
            } else {
                assistantHistoryVos.addAll(response.getResult());
            }
            if (assistantHistoryVos.size() == assistantHistoryVosCache.size()) {
                chat.removeListener(this);
                resumeProcess();
            }
        }
    });
    GetAssistantHistoryRequest getAssistantHistoryRequest = new GetAssistantHistoryRequest.Builder().setCount(50).build();
    chat.getAssistantHistory(getAssistantHistoryRequest);
    pauseProcess();
    Assert.assertTrue(true);
}
Also used : AssistantVo(com.fanap.podchat.chat.assistant.model.AssistantVo) ArrayList(java.util.ArrayList) AssistantHistoryVo(com.fanap.podchat.chat.assistant.model.AssistantHistoryVo) ChatListener(com.fanap.podchat.chat.ChatListener) List(java.util.List) ArrayList(java.util.ArrayList) GetAssistantHistoryRequest(com.fanap.podchat.chat.assistant.request_model.GetAssistantHistoryRequest) GetAssistantRequest(com.fanap.podchat.chat.assistant.request_model.GetAssistantRequest) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest)

Example 3 with GetAssistantHistoryRequest

use of com.fanap.podchat.chat.assistant.request_model.GetAssistantHistoryRequest in project pod-chat-android-sdk by FanapSoft.

the class ChatActivity method getAssistantHistory.

private void getAssistantHistory() {
    GetAssistantHistoryRequest request = new GetAssistantHistoryRequest.Builder().build();
    presenter.getAssistantHistory(request);
}
Also used : GetAssistantHistoryRequest(com.fanap.podchat.chat.assistant.request_model.GetAssistantHistoryRequest)

Aggregations

GetAssistantHistoryRequest (com.fanap.podchat.chat.assistant.request_model.GetAssistantHistoryRequest)3 LargeTest (android.support.test.filters.LargeTest)2 ChatListener (com.fanap.podchat.chat.ChatListener)2 AssistantVo (com.fanap.podchat.chat.assistant.model.AssistantVo)2 GetAssistantRequest (com.fanap.podchat.chat.assistant.request_model.GetAssistantRequest)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Test (org.junit.Test)2 AssistantHistoryVo (com.fanap.podchat.chat.assistant.model.AssistantHistoryVo)1