Search in sources :

Example 1 with SyncUserDetailsResponse

use of com.applozic.mobicomkit.sync.SyncUserDetailsResponse in project Applozic-Android-SDK by AppLozic.

the class MessageServiceTest method processUserDetails.

@Test
public void processUserDetails() {
    try {
        List<UserDetail> userDetails = new ArrayList<UserDetail>();
        userDetails.add(new UserDetail());
        SyncUserDetailsResponse response = new SyncUserDetailsResponse();
        response.setGeneratedAt("GEneratedAtString");
        response.setStatus("success");
        response.setResponse(userDetails);
        when(messageClientService.getUserDetailsList(anyString())).thenReturn(response);
        when(appContactService.getContactById("")).thenReturn(new Contact());
        // Mockito.doNothing().when(appContactService).upsert(any(Contact.class));
        mobiComConversationService.processLastSeenAtStatus();
        assertEquals(response.getGeneratedAt(), MobiComUserPreference.getInstance(context).getLastSeenAtSyncTime());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : UserDetail(com.applozic.mobicomkit.api.account.user.UserDetail) SyncUserDetailsResponse(com.applozic.mobicomkit.sync.SyncUserDetailsResponse) ArrayList(java.util.ArrayList) MockitoException(org.mockito.exceptions.base.MockitoException) Contact(com.applozic.mobicommons.people.contact.Contact) Test(org.junit.Test)

Example 2 with SyncUserDetailsResponse

use of com.applozic.mobicomkit.sync.SyncUserDetailsResponse in project Applozic-Android-SDK by AppLozic.

the class MessageClientService method getUserDetailsList.

// Cleanup: default
public SyncUserDetailsResponse getUserDetailsList(String lastSeenAt) {
    try {
        String url = getUserDetailsListUrl() + "?lastSeenAt=" + lastSeenAt;
        String response = httpRequestUtils.getResponse(url, "application/json", "application/json");
        if (response == null || TextUtils.isEmpty(response) || response.equals("UnAuthorized Access")) {
            return null;
        }
        Utils.printLog(context, TAG, "Sync UserDetails response is:" + response);
        SyncUserDetailsResponse userDetails = (SyncUserDetailsResponse) GsonUtils.getObjectFromJson(response, SyncUserDetailsResponse.class);
        return userDetails;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : SyncUserDetailsResponse(com.applozic.mobicomkit.sync.SyncUserDetailsResponse) ApplozicException(com.applozic.mobicomkit.exception.ApplozicException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 3 with SyncUserDetailsResponse

use of com.applozic.mobicomkit.sync.SyncUserDetailsResponse in project Applozic-Android-SDK by AppLozic.

the class ConversationServiceTest method processUserDetails.

@Test
public void processUserDetails() {
    try {
        List<UserDetail> userDetails = new ArrayList<UserDetail>();
        userDetails.add(new UserDetail());
        SyncUserDetailsResponse response = new SyncUserDetailsResponse();
        response.setGeneratedAt("GeneratedAtString");
        response.setStatus("success");
        response.setResponse(userDetails);
        Mockito.when(messageClientService.getUserDetailsList(ArgumentMatchers.anyString())).thenReturn(response);
        Mockito.when(appContactService.getContactById("")).thenReturn(new Contact());
        Mockito.doNothing().when(appContactService).upsert(ArgumentMatchers.any(Contact.class));
        mobiComConversationService.processLastSeenAtStatus();
        Assert.assertEquals(response.getGeneratedAt(), MobiComUserPreference.getInstance(context).getLastSeenAtSyncTime());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : UserDetail(com.applozic.mobicomkit.api.account.user.UserDetail) SyncUserDetailsResponse(com.applozic.mobicomkit.sync.SyncUserDetailsResponse) ArrayList(java.util.ArrayList) MockitoException(org.mockito.exceptions.base.MockitoException) Contact(com.applozic.mobicommons.people.contact.Contact) Test(org.junit.Test)

Aggregations

SyncUserDetailsResponse (com.applozic.mobicomkit.sync.SyncUserDetailsResponse)3 UserDetail (com.applozic.mobicomkit.api.account.user.UserDetail)2 Contact (com.applozic.mobicommons.people.contact.Contact)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 MockitoException (org.mockito.exceptions.base.MockitoException)2 ApplozicException (com.applozic.mobicomkit.exception.ApplozicException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1