use of com.fanap.podchat.mainmodel.Contact in project pod-chat-android-sdk by FanapSoft.
the class AssistantCacheTest method registerNewAssistant.
@Test
public void registerNewAssistant() {
populateContactsFromServer();
ChatListener mTestListener = Mockito.mock(ChatListener.class);
chat.addListener(mTestListener);
assert contacts.size() > 0;
Contact contact = getValidContact();
print("Selected contact for register as assistant " + App.getGson().toJson(contact));
ArrayList<String> typeRoles = new ArrayList<>();
typeRoles.add(RoleType.Constants.ADD_ROLE_TO_USER);
typeRoles.add(RoleType.Constants.READ_THREAD);
typeRoles.add(RoleType.Constants.EDIT_THREAD);
List<AssistantVo> assistantVos = new ArrayList<>();
AssistantVo assistantVo = new AssistantVo();
Invitee invite = new Invitee(contact.getId(), InviteType.Constants.TO_BE_USER_CONTACT_ID);
assistantVo.setInvitees(invite);
assistantVo.setContactType("default");
assistantVo.setRoles(typeRoles);
assistantVos.add(assistantVo);
RegisterAssistantRequest request = new RegisterAssistantRequest.Builder(assistantVos).build();
chat.registerAssistant(request);
Mockito.verify(mTestListener, Mockito.after(5000).atLeastOnce()).onRegisterAssistant(Mockito.argThat((ChatResponse<List<AssistantVo>> response) -> response.getResult().stream().anyMatch(assistantVo1 -> assistantVo1.getParticipantVO().getCoreUserId() == contact.getLinkedUser().getCoreUserId())));
}
use of com.fanap.podchat.mainmodel.Contact in project pod-chat-android-sdk by FanapSoft.
the class AssistantCacheTest method unBlockAssistantAndCheckBlockListInCache.
@Test
public void unBlockAssistantAndCheckBlockListInCache() {
populateContactsFromServer();
ArrayList<AssistantVo> blockedListFromServer = new ArrayList<>();
chat.addListener(new ChatListener() {
@Override
public void onAssistantBlocks(ChatResponse<List<AssistantVo>> response) {
print("Blocked assistants list cache: " + response.isCache());
prettyLog(response.getJson());
blockedListFromServer.addAll(response.getResult());
chat.removeListener(this);
resumeProcess();
}
});
GetBlockedAssistantsRequest getBlockedAssistantsRequest = new GetBlockedAssistantsRequest.Builder().withNoCache().build();
chat.getBlocksAssistant(getBlockedAssistantsRequest);
pauseProcess();
Contact assistantContactToUnBlock = contacts.stream().filter(contact -> contact.getLinkedUser() != null && Objects.equals(contact.getLinkedUser().getUsername(), blockedListFromServer.get(0).getParticipantVO().getUsername())).findFirst().get();
print("Going to unblock " + assistantContactToUnBlock.getFirstName());
prettyLog(App.getGson().toJson(assistantContactToUnBlock));
Invitee invitee = new Invitee(assistantContactToUnBlock.getId(), InviteType.Constants.TO_BE_USER_CONTACT_ID);
AssistantVo assistantToUnBlock = new AssistantVo();
assistantToUnBlock.setInvitees(invitee);
List<AssistantVo> toUnBlockAssistantList = new ArrayList<>();
toUnBlockAssistantList.add(assistantToUnBlock);
chat.addListener(new ChatListener() {
@Override
public void onAssistantUnBlocked(ChatResponse<List<AssistantVo>> response) {
print("Assistant unblocked");
prettyLog(response.getJson());
toUnBlockAssistantList.clear();
toUnBlockAssistantList.addAll(response.getResult());
chat.removeListener(this);
resumeProcess();
}
});
ChatListener mMockedListener = Mockito.mock(ChatListener.class);
chat.addListener(mMockedListener);
BlockUnblockAssistantRequest requestBlock = new BlockUnblockAssistantRequest.Builder(toUnBlockAssistantList, false).build();
chat.unBlockAssistant(requestBlock);
pauseProcess();
ArrayList<AssistantVo> blockedListInCache = new ArrayList<>();
chat.addListener(new ChatListener() {
@Override
public void onAssistantBlocks(ChatResponse<List<AssistantVo>> response) {
print("Blocked assistants list cache: " + response.isCache());
prettyLog(response.getJson());
if (response.isCache()) {
blockedListInCache.addAll(response.getResult());
chat.removeListener(this);
resumeProcess();
}
}
});
GetBlockedAssistantsRequest getBlockedAssistantsRequest2 = new GetBlockedAssistantsRequest.Builder().build();
chat.getBlocksAssistant(getBlockedAssistantsRequest2);
pauseProcess();
Assert.assertTrue(blockedListInCache.stream().noneMatch(assistantVo -> assistantVo.getParticipantVO().getId() == toUnBlockAssistantList.get(0).getParticipantVO().getId()));
}
use of com.fanap.podchat.mainmodel.Contact in project pod-chat-android-sdk by FanapSoft.
the class Util method getReformatOutPutAddContact.
@NonNull
public static ChatResponse<ResultAddContact> getReformatOutPutAddContact(Contacts contacts, String uniqueId) {
ChatResponse<ResultAddContact> chatResponse = new ChatResponse<>();
chatResponse.setUniqueId(uniqueId);
ResultAddContact resultAddContact = new ResultAddContact();
resultAddContact.setContentCount(1);
Contact contact = new Contact();
contact.setCellphoneNumber(contacts.getResult().get(0).getCellphoneNumber());
contact.setEmail(contacts.getResult().get(0).getEmail());
contact.setFirstName(contacts.getResult().get(0).getFirstName());
contact.setId(contacts.getResult().get(0).getId());
contact.setLastName(contacts.getResult().get(0).getLastName());
contact.setUniqueId(contacts.getResult().get(0).getUniqueId());
// add linked user
LinkedUser linkedUser = contacts.getResult().get(0).getLinkedUser();
if (linkedUser != null)
contact.setLinkedUser(linkedUser);
resultAddContact.setContact(contact);
chatResponse.setResult(resultAddContact);
return chatResponse;
}
use of com.fanap.podchat.mainmodel.Contact in project pod-chat-android-sdk by FanapSoft.
the class ChatTestIntegration method createThreadWithMetaData.
@Test
@MediumTest
public void createThreadWithMetaData() {
sleep(7000);
Invitee[] invite = new Invitee[] { new Invitee("589", 2), new Invitee("1162", 2), new Invitee("2404", 2) // , new Invitee(824, 2)
};
Contact contac = new Contact();
contac.setLastName("mamadi");
// String metaData =
// JsonUtil.getJson(contac);
// presenter.createThread(0,invite,null,null,null,metaData,null);
}
use of com.fanap.podchat.mainmodel.Contact in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method cacheContactToContactMapper.
private Contact cacheContactToContactMapper(CacheContact cacheContact) {
Contact contact = new Contact(cacheContact.getId(), cacheContact.getFirstName(), cacheContact.getUserId(), cacheContact.getLastName(), cacheContact.getBlocked(), cacheContact.getCreationDate(), cacheContact.getLinkedUser(), cacheContact.getCellphoneNumber(), cacheContact.getEmail(), cacheContact.getUniqueId(), cacheContact.getNotSeenDuration(), cacheContact.isHasUser());
contact.setCache(true);
return contact;
}
Aggregations