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");
}
}
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());
}
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());
}
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();
}
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));
}
Aggregations