use of org.infobip.mobile.messaging.api.support.ApiIOException in project mobile-messaging-sdk-android by infobip.
the class MobileApiResourceProviderTest method shouldUseNewUrlForSecondRequest.
@Test
public void shouldUseNewUrlForSecondRequest() {
// given
debugServer.respondWith(NanoHTTPD.Response.Status.OK, null, new HashMap<String, String>() {
{
put(CustomApiHeaders.NEW_BASE_URL.getValue(), "http://customurl");
}
});
MobileApiVersion givenMobileApiVersion = mobileApiResourceProvider.getMobileApiVersion(context);
// when
givenMobileApiVersion.getLatestRelease();
try {
givenMobileApiVersion.getLatestRelease();
assertTrue(false);
} catch (ApiIOException e) {
assertTrue(e.getCause() instanceof UnknownHostException);
assertTrue(e.getCause().getMessage().contains("customurl"));
}
}
use of org.infobip.mobile.messaging.api.support.ApiIOException in project mobile-messaging-sdk-android by infobip.
the class MAsyncTaskTest method shouldMapInvalidCustomValueToAppropriateException.
@Test
public void shouldMapInvalidCustomValueToAppropriateException() {
// Given
ApiIOException givenError = new ApiIOException(ApiErrorCode.INVALID_VALUE, "");
Mockito.when(tester.run(any(Object[].class))).thenThrow(givenError);
// When
asyncTask.execute(executor);
// Then
Mockito.verify(tester, Mockito.after(100).times(1)).error(any(Object[].class), eqInvalidParamErrorWith(givenError));
Mockito.verify(tester, Mockito.never()).after(Mockito.any());
}
use of org.infobip.mobile.messaging.api.support.ApiIOException in project mobile-messaging-sdk-android by infobip.
the class MAsyncTaskTest method shouldMapInvalidEmailToAppropriateException.
@Test
public void shouldMapInvalidEmailToAppropriateException() {
// Given
ApiIOException givenError = new ApiIOException(ApiErrorCode.INVALID_EMAIL_FORMAT, "");
Mockito.when(tester.run(any(Object[].class))).thenThrow(givenError);
// When
asyncTask.execute(executor);
// Then
Mockito.verify(tester, Mockito.after(100).times(1)).error(any(Object[].class), eqInvalidParamErrorWith(givenError));
Mockito.verify(tester, Mockito.never()).after(Mockito.any());
}
use of org.infobip.mobile.messaging.api.support.ApiIOException in project mobile-messaging-sdk-android by infobip.
the class MAsyncTaskTest method shouldMapErrorWithContentAndInvalidParameterToAppropriateException.
@Test
public void shouldMapErrorWithContentAndInvalidParameterToAppropriateException() {
// Given
String givenContent = "content";
ApiIOException givenError = new ApiBackendExceptionWithContent(ApiErrorCode.INVALID_MSISDN_FORMAT, "", givenContent);
Mockito.when(tester.run(any(Object[].class))).thenThrow(givenError);
// When
asyncTask.execute(executor);
// Then
Mockito.verify(tester, Mockito.after(100).times(1)).error(any(Object[].class), eqInvalidParamErrorWithContent(givenError, givenContent));
Mockito.verify(tester, Mockito.never()).after(Mockito.any());
}
use of org.infobip.mobile.messaging.api.support.ApiIOException in project mobile-messaging-sdk-android by infobip.
the class MAsyncTaskTest method shouldMapInvalidMsisdnToAppropriateException.
@Test
public void shouldMapInvalidMsisdnToAppropriateException() {
// Given
ApiIOException givenError = new ApiIOException(ApiErrorCode.INVALID_MSISDN_FORMAT, "");
Mockito.when(tester.run(any(Object[].class))).thenThrow(givenError);
// When
asyncTask.execute(executor);
// Then
Mockito.verify(tester, Mockito.after(100).times(1)).error(any(Object[].class), eqInvalidParamErrorWith(givenError));
Mockito.verify(tester, Mockito.never()).after(Mockito.any());
}
Aggregations