package com.proxerme.library;

import com.proxerme.library.api.ProxerApi;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.mockwebserver.MockWebServer;
import okio.Okio;
import org.jetbrains.annotations.NotNull;
import org.junit.After;
import org.junit.Before;

import java.io.IOException;

/**
 * TODO: Describe class
 *
 * @author Ruben Gees
 */
public abstract class ApiTest {

    protected MockWebServer server;
    protected ProxerApi api;

    @Before
    public void setUp() throws IOException {
        server = new MockWebServer();
        api = new ProxerApi.Builder("mockKey")
                .okHttp(new OkHttpClient.Builder()
                        .addInterceptor(chain -> {
                            final HttpUrl oldUrl = chain.request().url();
                            final HttpUrl serverUrl = server.url(oldUrl.encodedPath());
                            final HttpUrl newUrl = oldUrl.newBuilder()
                                    .scheme(serverUrl.scheme())
                                    .host(serverUrl.host())
                                    .port(serverUrl.port())
                                    .build();

                            return chain.proceed(chain.request().newBuilder().url(newUrl).build());
                        }).build())
                .build();

        server.start();
    }

    @After
    public void tearDown() throws IOException {
        server.shutdown();
    }

    @NotNull
    protected String fromResource(@NotNull final String file) throws IOException {
        return Okio.buffer(Okio.source(getClass().getClassLoader().getResourceAsStream(file))).readUtf8();
    }
}

@@ -106,28 +106,81 @@
 okhttp3.
-OkHttpClient
+Interceptor;%0Aimport okhttp3.OkHttpClient;%0Aimport okhttp3.Response
 ;%0Aimport
@@ -749,19 +749,158 @@
 tor(
-chain -%3E %7B%0A
+new Interceptor() %7B%0A                            @Override%0A                            public Response intercept(Chain chain) throws IOException %7B%0A    
     
@@ -989,32 +989,36 @@
                 
+    
 final HttpUrl se
@@ -1057,24 +1057,28 @@
 dedPath());%0A
+    
             
@@ -1172,16 +1172,20 @@
         
+    
 .scheme(
@@ -1200,24 +1200,28 @@
 l.scheme())%0A
+    
             
@@ -1304,16 +1304,20 @@
         
+    
 .port(se
@@ -1360,32 +1360,36 @@
                 
+ 
+   
 .build();%0A%0A     
@@ -1375,32 +1375,36 @@
      .build();%0A%0A
+    
                 
@@ -1483,24 +1483,54 @@
 ).build());%0A
+                            %7D%0A
             

Make the project actually compile under Java 7