package com.cloudmine.api.rest;

import com.android.volley.AuthFailureError;
import com.cloudmine.api.CMApiCredentials;
import com.cloudmine.api.DeviceIdentifier;
import com.cloudmine.test.CloudMineTestRunner;
import com.xtremelabs.robolectric.Robolectric;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.Arrays;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
 * <br>Copyright CloudMine LLC. All rights reserved
 * <br> See LICENSE file included with SDK for details.
 */
@RunWith(CloudMineTestRunner.class)
public class CloudMineRequestTest {

    @Test
    public void testCMApiCredentials() throws Exception{
        DeviceIdentifier.initialize(Robolectric.application);
        CMApiCredentials.initialize("appid", "apikey", "https://vz.api.cloudmine.me");
        CloudMineRequest request = new BaseObjectLoadRequest(Arrays.asList("objId"), null, null, null, null);
        assertContainsCredentials(request, "vz.api.cloudmine.me", "appid", "apikey");

        CMApiCredentials apiCredentials = new CMApiCredentials("difApp", "difApi", "https://rs.api.cloudmine.me/");
        request = new BaseObjectLoadRequest(Arrays.asList("objId"), null, apiCredentials, null, null, null);
        assertContainsCredentials(request, apiCredentials);

        request = new BaseObjectLoadRequest(Arrays.asList("objId"), null, null, null, null);
        assertContainsCredentials(request, "vz.api.cloudmine.me", "appid", "apikey");
    }

    protected void assertContainsCredentials(CloudMineRequest request,  CMApiCredentials credentials) throws AuthFailureError {
        assertContainsCredentials(request, credentials.getBaseUrl(), credentials.getIdentifier(), credentials.getApiKey());
    }

    protected void assertContainsCredentials(CloudMineRequest request,
                                             String baseUrl, String appid, String apikey) throws com.android.volley.AuthFailureError {
        assertTrue(request.getUrl().contains(baseUrl));
        assertTrue(request.getUrl().contains(appid));
        assertEquals(apikey, request.getHeaders().get(HeaderFactory.API_HEADER_KEY));
    }
}

@@ -804,18 +804,23 @@
 https://
-vz
+testing
 .api.clo
@@ -978,34 +978,39 @@
 tials(request, %22
-vz
+testing
 .api.cloudmine.m
@@ -1461,10 +1461,15 @@
 t, %22
-vz
+testing
 .api

Change url paths