use of com.fanap.podchat.requestobject.RequestMessage 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.requestobject.RequestMessage in project pod-chat-android-sdk by FanapSoft.
the class IntegrationTest method sendMessageWithMetadataTest.
@Test
@LargeTest
public void sendMessageWithMetadataTest() {
populateThreadsListFromServerOnly();
assert threads.size() > 0;
Thread thread = threads.get(0);
ChatListener mTestListener = Mockito.mock(ChatListener.class);
chat.setListener(mTestListener);
DummyMetadataVO dummyMetadataVO = new DummyMetadataVO();
dummyMetadataVO.count = new Random().nextInt();
dummyMetadataVO.desc = dummyMetadataVO.desc + "" + dummyMetadataVO.count;
String meta = App.getGson().toJson(dummyMetadataVO);
RequestMessage request = new RequestMessage.Builder("Android Test " + new Date(), thread.getId()).messageType(TextMessageType.Constants.TEXT).jsonMetaData(meta).build();
chat.sendTextMessage(request, null);
sleep(2000);
for (int i = 0; i < 16; i++) {
dummyMetadataVO.count++;
dummyMetadataVO.desc = String.format("%s%d", dummyMetadataVO.desc, dummyMetadataVO.count);
String meta2 = App.getGson().toJson(dummyMetadataVO);
request = new RequestMessage.Builder("Android Test " + new Date(), thread.getId()).messageType(TextMessageType.Constants.TEXT).jsonMetaData(meta2).build();
chat.sendTextMessage(request, null);
sleep(6000);
}
Mockito.verify(mTestListener, Mockito.after(2000).atLeastOnce()).onNewMessage(Mockito.any(), Mockito.argThat((ChatResponse<ResultNewMessage> resp) -> resp.getResult().getMessageVO().getSystemMetadata().equals(meta)));
Mockito.verify(mTestListener, Mockito.after(2000).atLeastOnce()).onNewMessage(Mockito.any(), Mockito.argThat((ChatResponse<ResultNewMessage> resp) -> !resp.getResult().getMessageVO().getSystemMetadata().equals("I'm something else!")));
}
use of com.fanap.podchat.requestobject.RequestMessage in project pod-chat-android-sdk by FanapSoft.
the class SearchMetadataTest method searchHistoryWithMetadata_Has_Test.
@Test
@LargeTest
public void searchHistoryWithMetadata_Has_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.desc = "Find me before " + System.currentTimeMillis() + (1_000_000 * 6);
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").has(" me ").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(dummyMetadataVO.desc))));
}
use of com.fanap.podchat.requestobject.RequestMessage in project pod-chat-android-sdk by FanapSoft.
the class TextMessagesQueueTest method sendMessageFromSendingQueue.
@Test
public void sendMessageFromSendingQueue() {
populateThreadsListFromServerOnly();
assert threads.size() > 0;
Thread thread = threads.get(0);
ChatListener mTestListener = Mockito.mock(ChatListener.class);
chat.setListener(mTestListener);
chat.closeChat();
sleep(2000);
Assert.assertNotEquals(chat.getChatState(), CHAT_READY);
RequestMessage request = new RequestMessage.Builder("Android Test " + new Date(), thread.getId()).messageType(TextMessageType.Constants.TEXT).build();
String uniqueId = chat.sendTextMessage(request, null);
chat.resumeChat();
Mockito.verify(mTestListener, Mockito.after(5000).atLeastOnce()).onNewMessage(Mockito.any(), Mockito.any());
}
use of com.fanap.podchat.requestobject.RequestMessage in project pod-chat-android-sdk by FanapSoft.
the class ThreadCacheTest method sendMessage.
public void sendMessage() {
populateThreadsFromServer();
Collections.shuffle(threadsInServer);
Thread thread = threadsInServer.get(0);
System.out.println("Thread : " + thread.getTitle());
Assert.assertNotNull(thread);
chatListeners = new ChatListener() {
@Override
public void onNewMessage(String content, ChatResponse<ResultNewMessage> response) {
resumeProcess();
chat.removeListener(chatListeners);
}
@Override
public void onError(String content, ErrorOutPut error) {
resumeProcess();
System.out.println("Error: " + content);
Assert.assertEquals(0, 1);
chat.removeListener(chatListeners);
}
};
chat.addListener(chatListeners);
RequestMessage request = new RequestMessage.Builder("Android Test " + new Date(), thread.getId()).messageType(TextMessageType.Constants.TEXT).build();
chat.sendTextMessage(request, null);
}
Aggregations