// Path: src/test/java/com/medium/api/test/TestUtils.java
// public final class TestUtils {
// 
//     /**
//      * The envelope name (key in JSON).
//      */
//     private static final String ENVELOPE_KEY = "data";
// 
//     /**
//      * Gets the contents of the test resource as a string.
//      *
//      * Note: this is probably pretty "Maven"-y.
//      *
//      * @param resourceId the id of the resource (e.g. a file name)
//      *
//      * @return the contents of the resource
//      */
//     public static String getResourceContents(final String resourceId) {
//         final ClassLoader classloader =
//             Thread.currentThread().getContextClassLoader();
// 
//         final InputStream inputStream =
//             classloader.getResourceAsStream(resourceId);
// 
//         final Scanner scanner =
//             new Scanner(inputStream).useDelimiter("\\A");
// 
//         final String contents =
//             scanner.hasNext() ? scanner.next() : "";
// 
//         return contents;
//     }
// 
//     /**
//      * Wraps the JSON string in a data envelope.
//      *
//      * @param json the JSON to wrap in an envelope.
//      *
//      * @return the JSON string, but wrapped in an envelope
//      */
//     public static String wrapInEnvelope(final String json) {
//         return "{\"" + ENVELOPE_KEY + "\": " + json + "}";
//     }
// }


import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import com.medium.api.test.TestUtils;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.junit.After;
import org.junit.Before;
/*
 * Copyright 2017 nosemaj.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you
 * may not use this file except in compliance with the License. You may
 * obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

package com.medium.api.dependencies.http;






/**
 * Test the OkayHttpClient implementation.
 *
 * Since the okhttp3 library is pretty much entirely comprised of final
 * classes, Mockito is of practically almost no use at all. So, instead
 * we have to use the vendor tool, this MockWebServer which will server
 * mock HTTP responses.
 */
public class OkayHttpClientTest {

    private static final String BEARER = "Bearer";
    private static final String TEST_TOKEN = "VERY_SECRET_STUFF";
    private static final String NEW_TOKEN ="NuToken(22)";
    private static final String AUTHORIZATION = "Authorization";

    // Just some random JSON
    private static final String TEST_JSON =
// Path: src/test/java/com/medium/api/test/TestUtils.java
// public final class TestUtils {
// 
//     /**
//      * The envelope name (key in JSON).
//      */
//     private static final String ENVELOPE_KEY = "data";
// 
//     /**
//      * Gets the contents of the test resource as a string.
//      *
//      * Note: this is probably pretty "Maven"-y.
//      *
//      * @param resourceId the id of the resource (e.g. a file name)
//      *
//      * @return the contents of the resource
//      */
//     public static String getResourceContents(final String resourceId) {
//         final ClassLoader classloader =
//             Thread.currentThread().getContextClassLoader();
// 
//         final InputStream inputStream =
//             classloader.getResourceAsStream(resourceId);
// 
//         final Scanner scanner =
//             new Scanner(inputStream).useDelimiter("\\A");
// 
//         final String contents =
//             scanner.hasNext() ? scanner.next() : "";
// 
//         return contents;
//     }
// 
//     /**
//      * Wraps the JSON string in a data envelope.
//      *
//      * @param json the JSON to wrap in an envelope.
//      *
//      * @return the JSON string, but wrapped in an envelope
//      */
//     public static String wrapInEnvelope(final String json) {
//         return "{\"" + ENVELOPE_KEY + "\": " + json + "}";
//     }
// }


// Path: src/test/java/com/medium/api/dependencies/http/OkayHttpClientTest.java
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import com.medium.api.test.TestUtils;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.junit.After;
import org.junit.Before;

/*
 * Copyright 2017 nosemaj.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you
 * may not use this file except in compliance with the License. You may
 * obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

package com.medium.api.dependencies.http;






/**
 * Test the OkayHttpClient implementation.
 *
 * Since the okhttp3 library is pretty much entirely comprised of final
 * classes, Mockito is of practically almost no use at all. So, instead
 * we have to use the vendor tool, this MockWebServer which will server
 * mock HTTP responses.
 */
public class OkayHttpClientTest {

    private static final String BEARER = "Bearer";
    private static final String TEST_TOKEN = "VERY_SECRET_STUFF";
    private static final String NEW_TOKEN ="NuToken(22)";
    private static final String AUTHORIZATION = "Authorization";

    // Just some random JSON
    private static final String TEST_JSON =
            TestUtils.getResourceContents("contributor-list.json");