Search in sources :

Example 1 with ApiError

use of org.infobip.mobile.messaging.api.support.http.client.model.ApiError in project mobile-messaging-sdk-android by infobip.

the class DefaultApiClientTest method execute_withQueryParams_withHeaders_noBody_receivesError.

@Test(expected = ApiException.class)
public void execute_withQueryParams_withHeaders_noBody_receivesError() throws Exception {
    debugServer.respondWith(NanoHTTPD.Response.Status.UNAUTHORIZED, DefaultApiClient.JSON_SERIALIZER.serialize(new ApiResponse(new ApiError(new ApiServiceException("1", "Invalid Application ID")))));
    apiClient.execute(HttpMethod.GET, "http://127.0.0.1:" + debugServer.getListeningPort(), null, null, MapUtils.map("applicationId", "xyz", "currentRegistrationId", "1234"), MapUtils.map("X-Test-1", "test1", "X-Test-2", "test2"), null, ApiResponse.class);
}
Also used : ApiError(org.infobip.mobile.messaging.api.support.http.client.model.ApiError) ApiServiceException(org.infobip.mobile.messaging.api.support.http.client.model.ApiServiceException) ApiResponse(org.infobip.mobile.messaging.api.support.http.client.model.ApiResponse) Test(org.junit.Test)

Example 2 with ApiError

use of org.infobip.mobile.messaging.api.support.http.client.model.ApiError in project mobile-messaging-sdk-android by infobip.

the class DefaultApiClientTest method execute_withQueryParams_noHeaders_withBody_receivesError.

@Test(expected = ApiException.class)
public void execute_withQueryParams_noHeaders_withBody_receivesError() throws Exception {
    debugServer.respondWith(NanoHTTPD.Response.Status.UNAUTHORIZED, DefaultApiClient.JSON_SERIALIZER.serialize(new ApiResponse(new ApiError(new ApiServiceException("1", "Invalid Application ID")))));
    apiClient.execute(HttpMethod.POST, "http://127.0.0.1:" + debugServer.getListeningPort(), null, null, MapUtils.map("applicationId", "xyz", "currentRegistrationId", "1234"), null, new SomeApiRequest("Test"), ApiResponse.class);
}
Also used : ApiError(org.infobip.mobile.messaging.api.support.http.client.model.ApiError) ApiServiceException(org.infobip.mobile.messaging.api.support.http.client.model.ApiServiceException) ApiResponse(org.infobip.mobile.messaging.api.support.http.client.model.ApiResponse) Test(org.junit.Test)

Example 3 with ApiError

use of org.infobip.mobile.messaging.api.support.http.client.model.ApiError in project mobile-messaging-sdk-android by infobip.

the class DefaultApiClientTest method execute_withQueryParams_noHeaders_noBody_receivesError.

@Test(expected = ApiException.class)
public void execute_withQueryParams_noHeaders_noBody_receivesError() throws Exception {
    debugServer.respondWith(NanoHTTPD.Response.Status.UNAUTHORIZED, DefaultApiClient.JSON_SERIALIZER.serialize(new ApiResponse(new ApiError(new ApiServiceException("1", "Invalid Application ID")))));
    apiClient.execute(HttpMethod.GET, "http://127.0.0.1:" + debugServer.getListeningPort(), null, null, MapUtils.map("applicationId", "xyz", "currentRegistrationId", "1234"), null, null, ApiResponse.class);
}
Also used : ApiError(org.infobip.mobile.messaging.api.support.http.client.model.ApiError) ApiServiceException(org.infobip.mobile.messaging.api.support.http.client.model.ApiServiceException) ApiResponse(org.infobip.mobile.messaging.api.support.http.client.model.ApiResponse) Test(org.junit.Test)

Example 4 with ApiError

use of org.infobip.mobile.messaging.api.support.http.client.model.ApiError in project mobile-messaging-sdk-android by infobip.

the class DefaultApiClientTest method execute_withQueryParams_withHeaders_withBody_receivesError.

@Test(expected = ApiException.class)
public void execute_withQueryParams_withHeaders_withBody_receivesError() throws Exception {
    debugServer.respondWith(NanoHTTPD.Response.Status.UNAUTHORIZED, DefaultApiClient.JSON_SERIALIZER.serialize(new ApiResponse(new ApiError(new ApiServiceException("1", "Invalid Application ID")))));
    apiClient.execute(HttpMethod.POST, "http://127.0.0.1:" + debugServer.getListeningPort(), null, null, MapUtils.map("applicationId", "xyz", "currentRegistrationId", "1234"), MapUtils.map("X-Test-1", "test1", "X-Test-2", "test2"), new SomeApiRequest("Test"), ApiResponse.class);
}
Also used : ApiError(org.infobip.mobile.messaging.api.support.http.client.model.ApiError) ApiServiceException(org.infobip.mobile.messaging.api.support.http.client.model.ApiServiceException) ApiResponse(org.infobip.mobile.messaging.api.support.http.client.model.ApiResponse) Test(org.junit.Test)

Aggregations

ApiError (org.infobip.mobile.messaging.api.support.http.client.model.ApiError)4 ApiResponse (org.infobip.mobile.messaging.api.support.http.client.model.ApiResponse)4 ApiServiceException (org.infobip.mobile.messaging.api.support.http.client.model.ApiServiceException)4 Test (org.junit.Test)4