use of com.fanap.podchat.requestobject.RequestMessage in project pod-chat-android-sdk by FanapSoft.
the class ThreadCacheTest method sendMessageAndEdit.
public void sendMessageAndEdit() {
populateThreadsFromServer();
Collections.shuffle(threadsInServer);
Thread thread = threadsInServer.get(0);
Assert.assertNotNull(thread);
final long[] messageId = { 0 };
// send new message
chatListeners = new ChatListener() {
@Override
public void onNewMessage(String content, ChatResponse<ResultNewMessage> response) {
messageId[0] = response.getResult().getMessageVO().getId();
resumeProcess();
System.out.println("new message sent -> msg : " + content);
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("Message for test edit :" + thread.getId(), thread.getId()).messageType(TextMessageType.Constants.TEXT).build();
chat.sendTextMessage(request, null);
pauseProcess();
// delete last message
chatListeners = new ChatListener() {
@Override
public void onEditedMessage(String content, ChatResponse<ResultNewMessage> response) {
resumeProcess();
System.out.println("Edited: " + content);
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);
RequestEditMessage requestEditMessage = new RequestEditMessage.Builder("last message edited " + messageId[0], messageId[0]).build();
chat.editMessage(requestEditMessage, null);
pauseProcess();
}
use of com.fanap.podchat.requestobject.RequestMessage in project pod-chat-android-sdk by FanapSoft.
the class IntegrationTest 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.requestobject.RequestMessage in project pod-chat-android-sdk by FanapSoft.
the class IntegrationTest method searchHistoryWithMetadata_GT_Test.
@Test
@LargeTest
public void searchHistoryWithMetadata_GT_Test() {
populateThreadsListFromServerOnly();
assert threads.size() > 0;
Thread thread = threads.get(0);
ChatListener mTestListener = Mockito.mock(ChatListener.class);
chat.setListener(mTestListener);
DummyMetadataVO dummyMetadataVO = new DummyMetadataVO();
dummyMetadataVO.desc = "GT test";
dummyMetadataVO.count = 12;
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("count").gte("12").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().size() > 0));
}
use of com.fanap.podchat.requestobject.RequestMessage in project pod-chat-android-sdk by FanapSoft.
the class IntegrationTest 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 HashTagCacheTest method sendHashTagMessage.
public void sendHashTagMessage(long threadId) {
chatListeners = new ChatListener() {
@Override
public void onNewMessage(String content, ChatResponse<ResultNewMessage> response) {
resumeProcess();
}
};
RequestMessage request = new RequestMessage.Builder("#test", threadId).messageType(TextMessageType.Constants.TEXT).build();
chat.setListener(chatListeners);
chat.sendTextMessage(request, null);
pauseProcess();
sleep(6000);
}
Aggregations