Search in sources :

Example 1 with RegisterAssistantRequest

use of com.fanap.podchat.chat.assistant.request_model.RegisterAssistantRequest 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();
}
Also used : Invitee(com.fanap.podchat.mainmodel.Invitee) AssistantVo(com.fanap.podchat.chat.assistant.model.AssistantVo) ArrayList(java.util.ArrayList) RegisterAssistantRequest(com.fanap.podchat.chat.assistant.request_model.RegisterAssistantRequest)

Example 2 with RegisterAssistantRequest

use of com.fanap.podchat.chat.assistant.request_model.RegisterAssistantRequest in project pod-chat-android-sdk by FanapSoft.

the class AssistantCacheTest method checkRegisteredAssistantInCache.

// Register new assistant and check if it is in cache
@LargeTest
@Test
public void checkRegisteredAssistantInCache() {
    populateContactsFromServer();
    assert contacts.size() > 0;
    Collections.shuffle(contacts);
    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);
    final AssistantVo[] registeredAssistant = new AssistantVo[1];
    ChatListener mListener = new ChatListener() {

        @Override
        public void onRegisterAssistant(ChatResponse<List<AssistantVo>> response) {
            registeredAssistant[0] = response.getResult().get(0);
            chat.removeListener(this);
            resumeProcess();
        }
    };
    chat.setListener(mListener);
    RegisterAssistantRequest request = new RegisterAssistantRequest.Builder(assistantVos).build();
    chat.registerAssistant(request);
    pauseProcess();
    ChatListener mTestListener = Mockito.mock(ChatListener.class);
    chat.addListener(mTestListener);
    GetAssistantRequest requestGet = new GetAssistantRequest.Builder().setCount(25).setOffset(0).build();
    chat.getAssistants(requestGet);
    Mockito.verify(mTestListener, Mockito.after(2000).atLeastOnce()).onGetAssistants(Mockito.argThat((ChatResponse<List<AssistantVo>> response) -> (response.isCache() && validateAssistantsAreSame(registeredAssistant[0], response.getResult()))));
}
Also used : AssistantVo(com.fanap.podchat.chat.assistant.model.AssistantVo) ArrayList(java.util.ArrayList) ResultContact(com.fanap.podchat.model.ResultContact) RequestGetContact(com.fanap.podchat.requestobject.RequestGetContact) Contact(com.fanap.podchat.mainmodel.Contact) Invitee(com.fanap.podchat.mainmodel.Invitee) ChatResponse(com.fanap.podchat.model.ChatResponse) ChatListener(com.fanap.podchat.chat.ChatListener) List(java.util.List) ArrayList(java.util.ArrayList) RegisterAssistantRequest(com.fanap.podchat.chat.assistant.request_model.RegisterAssistantRequest) GetAssistantRequest(com.fanap.podchat.chat.assistant.request_model.GetAssistantRequest) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest) LargeTest(android.support.test.filters.LargeTest)

Example 3 with RegisterAssistantRequest

use of com.fanap.podchat.chat.assistant.request_model.RegisterAssistantRequest 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())));
}
Also used : Invitee(com.fanap.podchat.mainmodel.Invitee) AssistantVo(com.fanap.podchat.chat.assistant.model.AssistantVo) ChatListener(com.fanap.podchat.chat.ChatListener) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) RegisterAssistantRequest(com.fanap.podchat.chat.assistant.request_model.RegisterAssistantRequest) ResultContact(com.fanap.podchat.model.ResultContact) RequestGetContact(com.fanap.podchat.requestobject.RequestGetContact) Contact(com.fanap.podchat.mainmodel.Contact) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest)

Example 4 with RegisterAssistantRequest

use of com.fanap.podchat.chat.assistant.request_model.RegisterAssistantRequest in project pod-chat-android-sdk by FanapSoft.

the class ChatTestIntegration 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("63253", 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();
}
Also used : Invitee(com.fanap.podchat.mainmodel.Invitee) AssistantVo(com.fanap.podchat.chat.assistant.model.AssistantVo) ArrayList(java.util.ArrayList) RegisterAssistantRequest(com.fanap.podchat.chat.assistant.request_model.RegisterAssistantRequest)

Example 5 with RegisterAssistantRequest

use of com.fanap.podchat.chat.assistant.request_model.RegisterAssistantRequest in project pod-chat-android-sdk by FanapSoft.

the class ChatActivity method registerAssistant.

private void registerAssistant() {
    // 63263 kheirkhah
    // //63264 anvari
    // 63254 sajadi
    // 63256 amjadi
    // 63257 zhiani
    // invite list
    // 103187 nemati sandbox
    // 52987 sajadi 9063 sandbox
    Invitee invite = new Invitee("63256", InviteType.Constants.TO_BE_USER_CONTACT_ID);
    // roles
    ArrayList<String> typeRoles = new ArrayList<>();
    typeRoles.add(RoleType.Constants.REMOVE_ROLE_FROM_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);
}
Also used : Invitee(com.fanap.podchat.mainmodel.Invitee) AssistantVo(com.fanap.podchat.chat.assistant.model.AssistantVo) ArrayList(java.util.ArrayList) RegisterAssistantRequest(com.fanap.podchat.chat.assistant.request_model.RegisterAssistantRequest)

Aggregations

AssistantVo (com.fanap.podchat.chat.assistant.model.AssistantVo)5 RegisterAssistantRequest (com.fanap.podchat.chat.assistant.request_model.RegisterAssistantRequest)5 Invitee (com.fanap.podchat.mainmodel.Invitee)5 ArrayList (java.util.ArrayList)5 LargeTest (android.support.test.filters.LargeTest)2 ChatListener (com.fanap.podchat.chat.ChatListener)2 Contact (com.fanap.podchat.mainmodel.Contact)2 ResultContact (com.fanap.podchat.model.ResultContact)2 RequestGetContact (com.fanap.podchat.requestobject.RequestGetContact)2 List (java.util.List)2 Test (org.junit.Test)2 GetAssistantRequest (com.fanap.podchat.chat.assistant.request_model.GetAssistantRequest)1 ChatResponse (com.fanap.podchat.model.ChatResponse)1