Search in sources :

Example 41 with ApiResponse

use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.

the class RegisterUserClientService method syncAccountStatus.

// deprecated code >>>
// Cleanup: can be removed
/**
 * @deprecated This method is no longer used and will be removed soon.
 */
@Deprecated
public void syncAccountStatus() {
    try {
        String response = httpRequestUtils.getResponse(getPricingPackageUrl(), "application/json", "application/json");
        Utils.printLog(context, TAG, "Pricing package response: " + response);
        ApiResponse apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
        if (apiResponse.getResponse() != null) {
            int pricingPackage = Integer.parseInt(apiResponse.getResponse().toString());
            MobiComUserPreference.getInstance(context).setPricingPackage(pricingPackage);
        }
    } catch (Exception e) {
        Utils.printLog(context, TAG, "Account status sync call failed");
    }
}
Also used : ApiResponse(com.applozic.mobicomkit.feed.ApiResponse) ApplozicException(com.applozic.mobicomkit.exception.ApplozicException) ConnectException(java.net.ConnectException)

Example 42 with ApiResponse

use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.

the class UserServiceTest method processUserBlockFailure.

@Test
public void processUserBlockFailure() {
    ApiResponse expectedFailureApiResponse = new ApiResponse();
    expectedFailureApiResponse.setStatus("anything but success");
    Mockito.when(userClientService.userBlock(testUserId, true)).thenReturn(expectedFailureApiResponse);
    ApiResponse actualFailureApiResponse = userService.processUserBlock(testUserId, true);
    Truth.assertThat(actualFailureApiResponse).isNull();
    Mockito.verify(appContactService, Mockito.never()).updateUserBlocked(ArgumentMatchers.anyString(), ArgumentMatchers.anyBoolean());
}
Also used : MockedConstants.userDetailsApiResponse(com.applozic.mobicomkit.MockedConstants.userDetailsApiResponse) RegisteredUsersApiResponse(com.applozic.mobicomkit.feed.RegisteredUsersApiResponse) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse) SyncBlockUserApiResponse(com.applozic.mobicomkit.feed.SyncBlockUserApiResponse) Test(org.junit.Test)

Example 43 with ApiResponse

use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.

the class UserServiceTest method getUserListBySearch.

@Test
public void getUserListBySearch() throws Exception {
    List<UserDetail> expectedUserDetails = Arrays.asList((UserDetail[]) GsonUtils.getObjectFromJson(userDetailsApiResponse, UserDetail[].class));
    ApiResponse expectedApiResponse = new ApiResponse();
    expectedApiResponse.setStatus("success");
    expectedApiResponse.setResponse(expectedUserDetails);
    Mockito.when(userClientService.getUsersBySearchString(ArgumentMatchers.anyString())).thenReturn(expectedApiResponse);
    List<Contact> expectedContactList = new ArrayList<>();
    for (UserDetail userDetail : expectedUserDetails) {
        // *A
        // has been tested, NOTE: this will also call baseContactService.upsert()
        expectedContactList.add(userService.getContactFromUserDetail(userDetail));
    }
    // *B
    List<Contact> actualContactList = userService.getUserListBySearch("Test Search");
    Truth.assertThat(actualContactList.size()).isEqualTo(expectedContactList.size());
    Truth.assertThat(actualContactList.get(0).toString()).isEqualTo(expectedContactList.get(0).toString());
    Truth.assertThat(actualContactList.get(1).toString()).isEqualTo(expectedContactList.get(1).toString());
    // 2 for *A, 2 for *B
    Mockito.verify(appContactService, Mockito.times(4)).upsert(ArgumentMatchers.any());
}
Also used : UserDetail(com.applozic.mobicomkit.api.account.user.UserDetail) ArrayList(java.util.ArrayList) MockedConstants.userDetailsApiResponse(com.applozic.mobicomkit.MockedConstants.userDetailsApiResponse) RegisteredUsersApiResponse(com.applozic.mobicomkit.feed.RegisteredUsersApiResponse) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse) SyncBlockUserApiResponse(com.applozic.mobicomkit.feed.SyncBlockUserApiResponse) Contact(com.applozic.mobicommons.people.contact.Contact) Test(org.junit.Test)

Example 44 with ApiResponse

use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.

the class UserServiceTest method updateUserDisplayNameFailure.

@Test
public void updateUserDisplayNameFailure() {
    // Note: return value from userService.updateUserDisplayName() is not used
    Mockito.when(userClientService.updateUserDisplayName(ArgumentMatchers.anyString(), ArgumentMatchers.anyString())).thenReturn(null);
    ApiResponse actualApiResponse = userService.updateUserDisplayName(testUserId, "Display Name");
    Mockito.verify(appContactService, Mockito.never()).updateMetadataKeyValueForUserId(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.anyString());
    Truth.assertThat(actualApiResponse).isNull();
}
Also used : MockedConstants.userDetailsApiResponse(com.applozic.mobicomkit.MockedConstants.userDetailsApiResponse) RegisteredUsersApiResponse(com.applozic.mobicomkit.feed.RegisteredUsersApiResponse) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse) SyncBlockUserApiResponse(com.applozic.mobicomkit.feed.SyncBlockUserApiResponse) Test(org.junit.Test)

Example 45 with ApiResponse

use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.

the class UserServiceTest method updateDisplayNameORImageLink.

@Test
public void updateDisplayNameORImageLink() {
    ApiResponse expectedApiResponse = new ApiResponse();
    expectedApiResponse.setStatus("success");
    Mockito.when(userClientService.updateDisplayNameORImageLink("displayName", "profileImageLink", "status", "contactNumber", "emailId", null, "userId")).thenReturn(expectedApiResponse);
    Mockito.when(appContactService.getContactById(ArgumentMatchers.anyString())).thenReturn(new Contact());
    String status = userService.updateDisplayNameORImageLink("displayName", "profileImageLink", "localURL", "status", "contactNumber", "emailId", null, "userId");
    Truth.assertThat(status).isEqualTo(expectedApiResponse.getStatus());
    Mockito.verify(appContactService, Mockito.times(1)).upsert(ArgumentMatchers.any(Contact.class));
}
Also used : MockedConstants.userDetailsApiResponse(com.applozic.mobicomkit.MockedConstants.userDetailsApiResponse) RegisteredUsersApiResponse(com.applozic.mobicomkit.feed.RegisteredUsersApiResponse) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse) SyncBlockUserApiResponse(com.applozic.mobicomkit.feed.SyncBlockUserApiResponse) Contact(com.applozic.mobicommons.people.contact.Contact) Test(org.junit.Test)

Aggregations

ApiResponse (com.applozic.mobicomkit.feed.ApiResponse)54 SyncBlockUserApiResponse (com.applozic.mobicomkit.feed.SyncBlockUserApiResponse)23 ChannelFeedApiResponse (com.applozic.mobicomkit.feed.ChannelFeedApiResponse)22 JSONException (org.json.JSONException)19 ApplozicException (com.applozic.mobicomkit.exception.ApplozicException)16 RegisteredUsersApiResponse (com.applozic.mobicomkit.feed.RegisteredUsersApiResponse)16 Test (org.junit.Test)14 MultipleChannelFeedApiResponse (com.applozic.mobicomkit.MultipleChannelFeedApiResponse)12 MockedConstants.userDetailsApiResponse (com.applozic.mobicomkit.MockedConstants.userDetailsApiResponse)10 UnsupportedEncodingException (java.io.UnsupportedEncodingException)9 Nullable (androidx.annotation.Nullable)8 Contact (com.applozic.mobicommons.people.contact.Contact)8 ChannelUserMapper (com.applozic.mobicommons.people.channel.ChannelUserMapper)3 ArrayList (java.util.ArrayList)3 PatternSyntaxException (java.util.regex.PatternSyntaxException)3 ProgressDialog (android.app.ProgressDialog)2 Toast (android.widget.Toast)2 UserBlockTask (com.applozic.mobicomkit.api.account.user.UserBlockTask)2 MuteNotificationAsync (com.applozic.mobicomkit.api.notification.MuteNotificationAsync)2 MuteNotificationRequest (com.applozic.mobicomkit.api.notification.MuteNotificationRequest)2