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());
}
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);
}
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);
}
Aggregations