use of com.fanap.podchat.mainmodel.Invitee in project pod-chat-android-sdk by FanapSoft.
the class AssistantCacheTest method blockAssistantAndCheckCache.
@Test
public void blockAssistantAndCheckCache() {
populateContactsFromServer();
List<AssistantVo> assistantVos = new ArrayList<>();
chat.addListener(new ChatListener() {
@Override
public void onGetAssistants(ChatResponse<List<AssistantVo>> response) {
if (!response.isCache()) {
prettyLog(response.getJson());
assistantVos.addAll(response.getResult());
chat.removeListener(this);
resumeProcess();
}
}
});
GetAssistantRequest request = new GetAssistantRequest.Builder().setCount(25).withNoCache().setOffset(0).build();
chat.getAssistants(request);
pauseProcess();
// the block assistant method accepts only Invitee
Collections.shuffle(assistantVos);
List<AssistantVo> notBlockedAssistants = assistantVos.stream().filter(assistantVo -> !assistantVo.getBlock()).collect(Collectors.toList());
Contact assistantContactToBlock = contacts.stream().filter(contact -> contact.getLinkedUser() != null && Objects.equals(contact.getLinkedUser().getUsername(), notBlockedAssistants.get(0).getParticipantVO().getUsername())).findFirst().get();
print("Going to block " + assistantContactToBlock.getFirstName());
prettyLog(App.getGson().toJson(assistantContactToBlock));
Invitee invitee = new Invitee(assistantContactToBlock.getId(), InviteType.Constants.TO_BE_USER_CONTACT_ID);
AssistantVo assistantToBlock = new AssistantVo();
assistantToBlock.setInvitees(invitee);
List<AssistantVo> toBlockAssistantList = new ArrayList<>();
toBlockAssistantList.add(assistantToBlock);
chat.addListener(new ChatListener() {
@Override
public void onAssistantBlocked(ChatResponse<List<AssistantVo>> response) {
prettyLog(response.getJson());
toBlockAssistantList.clear();
toBlockAssistantList.addAll(response.getResult());
chat.removeListener(this);
resumeProcess();
}
});
BlockUnblockAssistantRequest requestBlock = new BlockUnblockAssistantRequest.Builder(toBlockAssistantList, true).build();
chat.blockAssistant(requestBlock);
pauseProcess();
ArrayList<AssistantVo> inCache = new ArrayList<>();
chat.addListener(new ChatListener() {
@Override
public void onGetAssistants(ChatResponse<List<AssistantVo>> response) {
if (response.isCache()) {
prettyLog(response.getJson());
inCache.addAll(response.getResult());
chat.removeListener(this);
resumeProcess();
}
}
});
GetAssistantRequest requestGetAssistantFromCache = new GetAssistantRequest.Builder().setCount(25).setOffset(0).build();
chat.getAssistants(requestGetAssistantFromCache);
pauseProcess();
assert inCache.size() > 0;
Assert.assertTrue(inCache.stream().filter(anAssistantInCache -> toBlockAssistantList.stream().anyMatch(blockListAssistant -> anAssistantInCache.getParticipantVO().getId() == blockListAssistant.getParticipantVO().getId())).findFirst().get().getBlock());
}
use of com.fanap.podchat.mainmodel.Invitee in project pod-chat-android-sdk by FanapSoft.
the class ChatTestIntegration method deActiveAssistant.
private void deActiveAssistant() {
// 52987 khodam
// 103187 nemati
// invite
Invitee invite = new Invitee("63253", InviteType.Constants.TO_BE_USER_CONTACT_ID);
List<AssistantVo> assistantVos = new ArrayList<>();
AssistantVo assistantVo = new AssistantVo();
assistantVo.setInvitees(invite);
assistantVos.add(assistantVo);
DeActiveAssistantRequest request = new DeActiveAssistantRequest.Builder(assistantVos).build();
presenter.deActiveAssistant(request);
pauseProcess();
}
use of com.fanap.podchat.mainmodel.Invitee in project pod-chat-android-sdk by FanapSoft.
the class ChatTestSandbox 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.Invitee in project pod-chat-android-sdk by FanapSoft.
the class ChatTestSandbox method registerAssistant.
private void registerAssistant() {
// 63253 kheirkhah
// 63254 sajadi
// //63255 anvari
// 63256 amjadi
// 63257 zhiani
// invite list
// 52987 khodam
// 103187 nemati
Invitee invite = new Invitee("52987", InviteType.Constants.TO_BE_USER_CONTACT_ID);
// roles
ArrayList<String> typeRoles = new ArrayList<>();
typeRoles.add(RoleType.Constants.READ_THREAD);
typeRoles.add(RoleType.Constants.EDIT_THREAD);
typeRoles.add(RoleType.Constants.ADD_ROLE_TO_USER);
List<AssistantVo> assistantVos = new ArrayList<>();
AssistantVo assistantVo = new AssistantVo();
assistantVo.setInvitees(invite);
assistantVo.setContactType("default");
assistantVo.setRoles(typeRoles);
assistantVos.add(assistantVo);
RegisterAssistantRequest request = new RegisterAssistantRequest.Builder(assistantVos).build();
presenter.registerAssistant(request);
pauseProcess();
}
use of com.fanap.podchat.mainmodel.Invitee in project pod-chat-android-sdk by FanapSoft.
the class ChatTest 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);
}
Aggregations