Search in sources :

Example 1 with MobileApiVersion

use of org.infobip.mobile.messaging.api.version.MobileApiVersion 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"));
    }
}
Also used : MobileApiVersion(org.infobip.mobile.messaging.api.version.MobileApiVersion) UnknownHostException(java.net.UnknownHostException) ApiIOException(org.infobip.mobile.messaging.api.support.ApiIOException) Test(org.junit.Test)

Example 2 with MobileApiVersion

use of org.infobip.mobile.messaging.api.version.MobileApiVersion in project mobile-messaging-sdk-android by infobip.

the class MobileApiVersionTest method setUp.

@Before
public void setUp() throws Exception {
    debugServer = new DebugServer();
    debugServer.start();
    Properties properties = new Properties();
    properties.put("api.key", "my_API_key");
    Generator generator = new Generator.Builder().withBaseUrl("http://127.0.0.1:" + debugServer.getListeningPort() + "/").withProperties(properties).build();
    mobileApiVersion = generator.create(MobileApiVersion.class);
}
Also used : MobileApiVersion(org.infobip.mobile.messaging.api.version.MobileApiVersion) DebugServer(org.infobip.mobile.messaging.api.tools.DebugServer) Properties(java.util.Properties) Generator(org.infobip.mobile.messaging.api.support.Generator) Before(org.junit.Before)

Aggregations

MobileApiVersion (org.infobip.mobile.messaging.api.version.MobileApiVersion)2 UnknownHostException (java.net.UnknownHostException)1 Properties (java.util.Properties)1 ApiIOException (org.infobip.mobile.messaging.api.support.ApiIOException)1 Generator (org.infobip.mobile.messaging.api.support.Generator)1 DebugServer (org.infobip.mobile.messaging.api.tools.DebugServer)1 Before (org.junit.Before)1 Test (org.junit.Test)1