use of com.fanap.podchat.requestobject.RequestMessage in project pod-chat-android-sdk by FanapSoft.
the class IntegrationTest method searchHistoryWithMetadata_OR_Test.
@Test
@LargeTest
public void searchHistoryWithMetadata_OR_Test() {
populateThreadsListFromServerOnly();
ChatListener mTestListener = Mockito.mock(ChatListener.class);
chat.setListener(mTestListener);
assert threads.size() > 0;
Thread thread = threads.get(0);
DummyMetadataVO dummyMetadataVO = new DummyMetadataVO();
int random1 = Math.abs(new Random().nextInt());
dummyMetadataVO.count = random1;
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);
int random2 = Math.abs(new Random().nextInt());
dummyMetadataVO.count = random2;
meta = App.getGson().toJson(dummyMetadataVO);
sendMessageWithMetadataRequest.setJsonMetaData(meta);
chat.sendTextMessage(sendMessageWithMetadataRequest, null);
sleep(6000);
// NosqlSearchMetadataCriteria
// metadataCriteriaLB =
// new NosqlSearchMetadataCriteria.Builder("count")
// .is(String.valueOf(random1))
// .build();
NosqlSearchMetadataCriteria metadataCriteriaUB = new NosqlSearchMetadataCriteria.Builder("count").is(String.valueOf(random2)).build();
List<NosqlSearchMetadataCriteria> criteriaList = new ArrayList<>();
// criteriaList.add(metadataCriteriaLB);
criteriaList.add(metadataCriteriaUB);
NosqlSearchMetadataCriteria metadataCriteria = new NosqlSearchMetadataCriteria.Builder("count").is(String.valueOf(random1)).or(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.requestobject.RequestMessage in project pod-chat-android-sdk by FanapSoft.
the class ChatActivity method sendMessage.
public void sendMessage(View view) {
// Inviter inviter = new Inviter();
// inviter.setName("farhad");
// String meta = gson.toJson(inviter);
String meta = getMetaData();
RequestMessage request = new RequestMessage.Builder("Salam", 1000).messageType(TextMessageType.Constants.TEXT).build();
//
//
presenter.sendTextMessage(et_text.getText().toString(), TEST_THREAD_ID, TextMessageType.Constants.TEXT, meta, null);
//
//
// editText.setText("");
// presenter.sendTextMessage("test at" + " " + new Date().getTime() + name
// , 1576, 2, meta, null);
//
// new ChatHandler() {
// @Override
// public void onSent(String uniqueId, long threadId) {
// super.onSent(uniqueId, threadId);
// Toast.makeText(ChatActivity.this, "its worked", Toast.LENGTH_SHORT).show();
// }
//
// @Override
// public void onSentResult(String content) {
// super.onSentResult(content);
// if (content != null) {
// Toast.makeText(ChatActivity.this, "no null", Toast.LENGTH_SHORT).show();
//
// }
// }
// });
// presenter.sendTextMessage("test at" + " " + new Date().getTime() + name
// , 312, meta, new Chat.SendTextMessageHandler() {
// @Override
// public void onSent(String uniqueId, long threadId) {
//
// }
// });
// String text = editText.getText().toString();
// // long textThread = Long.valueOf(editTextThread.getText().toString());
// // if (!text.equals("")) {
// // presenter.sendTextMessage(text, 381, null);
// // } else {
// // Toast.makeText(this, "Message is Empty", Toast.LENGTH_SHORT).show();
// // }
}
Aggregations