use of com.fanap.podchat.model.ResultHistory in project pod-chat-android-sdk by FanapSoft.
the class SearchMetadataTest method searchHistoryWithMetadata_AND_Test.
@Test
@LargeTest
public void searchHistoryWithMetadata_AND_Test() {
populateThreadsListFromServerOnly();
ChatListener mTestListener = Mockito.mock(ChatListener.class);
chat.setListener(mTestListener);
assert threads.size() > 0;
Thread thread = threads.get(0);
DummyMetadataVO dummyMetadataVO = new DummyMetadataVO();
dummyMetadataVO.count = 1001;
// String meta = App.getGson().toJson(dummyMetadataVO);
//
// RequestMessage sendMessageWithMetadataRequest =
// new RequestMessage.Builder("Android Test " + new Date(), thread.getId())
// .messageType(TextMessageType.Constants.TEXT)
// .jsonMetaData(meta)
// .build();
//
// chat.sendTextMessage(sendMessageWithMetadataRequest, null);
//
// sleep(6000);
//
// dummyMetadataVO.count = 1002;
// meta = App.getGson().toJson(dummyMetadataVO);
//
// sendMessageWithMetadataRequest.setJsonMetaData(meta);
// chat.sendTextMessage(sendMessageWithMetadataRequest, null);
//
// sleep(6000);
// NosqlSearchMetadataCriteria
// metadataCriteriaLB =
// new NosqlSearchMetadataCriteria.Builder("count")
// .gt("1000")
// .build();
NosqlSearchMetadataCriteria metadataCriteriaUB = new NosqlSearchMetadataCriteria.Builder("count").lte("1002").build();
List<NosqlSearchMetadataCriteria> criteriaList = new ArrayList<>();
// criteriaList.add(metadataCriteriaLB);
criteriaList.add(metadataCriteriaUB);
NosqlSearchMetadataCriteria metadataCriteria = new NosqlSearchMetadataCriteria.Builder("count").gt("1000").and(criteriaList).build();
SearchSystemMetadataRequest request = new SearchSystemMetadataRequest.Builder(thread.getId()).metadataCriteria(metadataCriteria).count(50).build();
chat.searchHistory(request, null);
Mockito.verify(mTestListener, Mockito.after(5000).atLeastOnce()).onGetHistory(Mockito.any(String.class), Mockito.argThat((ChatResponse<ResultHistory> resp) -> resp.getResult().getHistory().stream().anyMatch(messageVO -> messageVO.getSystemMetadata().contains(String.valueOf(dummyMetadataVO.count)))));
}
use of com.fanap.podchat.model.ResultHistory in project pod-chat-android-sdk by FanapSoft.
the class SearchMetadataTest method searchHistoryWithMetadata_Is_StringTest.
@Test
@LargeTest
public void searchHistoryWithMetadata_Is_StringTest() {
populateThreadsListFromServerOnly();
ChatListener mTestListener = Mockito.mock(ChatListener.class);
chat.setListener(mTestListener);
assert threads.size() > 0;
Thread thread = threads.get(0);
DummyMetadataVO dummyMetadataVO = new DummyMetadataVO();
dummyMetadataVO.desc = "This is me!";
// dummyMetadataVO.desc = UUID.randomUUID().toString();
String meta = App.getGson().toJson(dummyMetadataVO);
RequestMessage sendMessageWithMetadataRequest = new RequestMessage.Builder("Android Test " + new Date(), thread.getId()).messageType(TextMessageType.Constants.TEXT).jsonMetaData(meta).build();
chat.sendTextMessage(sendMessageWithMetadataRequest, null);
sleep(6000);
NosqlSearchMetadataCriteria metadataCriteria = new NosqlSearchMetadataCriteria.Builder("desc").is(dummyMetadataVO.desc).build();
SearchSystemMetadataRequest request = new SearchSystemMetadataRequest.Builder(thread.getId()).metadataCriteria(metadataCriteria).count(50).build();
chat.searchHistory(request, null);
Mockito.verify(mTestListener, Mockito.after(5000).atLeastOnce()).onGetHistory(Mockito.any(String.class), Mockito.argThat((ChatResponse<ResultHistory> resp) -> resp.getResult().getHistory().stream().anyMatch(messageVO -> messageVO.getSystemMetadata().equals(meta))));
}
use of com.fanap.podchat.model.ResultHistory in project pod-chat-android-sdk by FanapSoft.
the class IntegrationTest method searchHistoryWithMetadata_Is_NumberTest.
@Test
@LargeTest
public void searchHistoryWithMetadata_Is_NumberTest() {
populateThreadsListFromServerOnly();
ChatListener mTestListener = Mockito.mock(ChatListener.class);
chat.setListener(mTestListener);
assert threads.size() > 0;
Thread thread = threads.get(0);
DummyMetadataVO dummyMetadataVO = new DummyMetadataVO();
dummyMetadataVO.desc = "876";
String meta = App.getGson().toJson(dummyMetadataVO);
RequestMessage sendMessageWithMetadataRequest = new RequestMessage.Builder("Android Test " + new Date(), thread.getId()).messageType(TextMessageType.Constants.TEXT).jsonMetaData(meta).build();
chat.sendTextMessage(sendMessageWithMetadataRequest, null);
sleep(6000);
NosqlSearchMetadataCriteria metadataCriteria = new NosqlSearchMetadataCriteria.Builder("desc").is(dummyMetadataVO.desc).build();
SearchSystemMetadataRequest request = new SearchSystemMetadataRequest.Builder(thread.getId()).metadataCriteria(metadataCriteria).count(50).build();
chat.searchHistory(request, null);
Mockito.verify(mTestListener, Mockito.after(5000).atLeastOnce()).onGetHistory(Mockito.any(String.class), Mockito.argThat((ChatResponse<ResultHistory> resp) -> resp.getResult().getHistory().stream().anyMatch(messageVO -> messageVO.getSystemMetadata().equals(meta))));
}
use of com.fanap.podchat.model.ResultHistory in project pod-chat-android-sdk by FanapSoft.
the class IntegrationTest method searchHistoryWithMetadata_NOT_Test.
@Test
@LargeTest
public void searchHistoryWithMetadata_NOT_Test() {
populateThreadsListFromServerOnly();
ChatListener mTestListener = Mockito.mock(ChatListener.class);
chat.setListener(mTestListener);
assert threads.size() > 0;
Thread thread = threads.get(0);
DummyMetadataVO dummyMetadataVO = new DummyMetadataVO();
RequestMessage.Builder sendMessageWithMetadataRequest;
sendMessageWithMetadataRequest = new RequestMessage.Builder("Android Test " + new Date(), thread.getId()).messageType(TextMessageType.Constants.TEXT);
// Meta1
int random1 = Math.abs(new Random().nextInt());
dummyMetadataVO.count = random1;
String meta1 = App.getGson().toJson(dummyMetadataVO);
sendMessageWithMetadataRequest.jsonMetaData(meta1);
chat.sendTextMessage(sendMessageWithMetadataRequest.build(), null);
sleep(6000);
// Meta2
int random2 = Math.abs(new Random().nextInt());
dummyMetadataVO.count = random2;
String meta2 = App.getGson().toJson(dummyMetadataVO);
sendMessageWithMetadataRequest.jsonMetaData(meta2);
chat.sendTextMessage(sendMessageWithMetadataRequest.build(), null);
sleep(6000);
NosqlSearchMetadataCriteria metadataCriteriaUB = new NosqlSearchMetadataCriteria.Builder("count").is(String.valueOf(random2)).build();
List<NosqlSearchMetadataCriteria> criteriaList = new ArrayList<>();
criteriaList.add(metadataCriteriaUB);
NosqlSearchMetadataCriteria metadataCriteria = new NosqlSearchMetadataCriteria.Builder("count").gte(String.valueOf(random1)).not(criteriaList).build();
SearchSystemMetadataRequest request = new SearchSystemMetadataRequest.Builder(thread.getId()).metadataCriteria(metadataCriteria).count(50).build();
chat.searchHistory(request, null);
Mockito.verify(mTestListener, Mockito.after(5000).atLeastOnce()).onGetHistory(Mockito.any(String.class), Mockito.argThat((ChatResponse<ResultHistory> resp) -> resp.getResult().getHistory().stream().noneMatch(messageVO -> messageVO.getSystemMetadata().contains(meta2))));
}
use of com.fanap.podchat.model.ResultHistory in project pod-chat-android-sdk by FanapSoft.
the class MentionCacheTest method populateMentionListFromServer.
public void populateMentionListFromServer(long threadId) {
chatListeners = new ChatListener() {
@Override
public void onGetMentionList(ChatResponse<ResultHistory> response) {
if (!response.isCache()) {
System.out.println("Received Mention Message List Server: " + response.getJson());
threadMentionMessagesListInServer.addAll(response.getResult().getHistory().stream().filter(messageVO -> messageVO.getMessage() != null).collect(Collectors.toList()));
chat.removeListener(chatListeners);
resumeProcess();
}
}
};
chat.setListener(chatListeners);
RequestGetMentionList req = new RequestGetMentionList.Builder(threadId).offset(0).count(25).build();
presenter.getMentionList(req);
pauseProcess();
System.out.println("Received Mention Message List Server: " + threadMentionMessagesListInServer.size());
}
Aggregations