package model;

import com.google.gson.JsonObject;
import okhttp3.OkHttpClient;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import util.MockInterceptor;
import util.Networking;

import java.io.IOException;

import static org.junit.Assert.assertTrue;
import static util.MockConstants.*;

public class TestImageTransform {
    private static final String SOURCE = "https://example.com/image.jpg";

    /**
     * Set a custom httpClient for our testing.
     * This custom client has an added interceptor to create mock responses.
     */
    @BeforeClass
    public static void setup() {
        OkHttpClient client = new OkHttpClient.Builder()
                .addInterceptor(new MockInterceptor())
                .build();
        Networking.setCustomClient(client);
    }

    @Test
    public void testDebug() throws IOException {
        ImageTransform transform = new ImageTransform(FILE_LINK);
        transform = transform.resize(100, 100, null, null);
        JsonObject debugResponse = transform.debug();
        String message = "Debug response was null";
        assertTrue(message, debugResponse != null);
    }

    @Test
    public void testDebugExternal() throws IOException {
        ImageTransform transform = new ImageTransform(CLIENT, SOURCE);
        transform = transform.resize(100, 100, null, null);
        JsonObject debugResponse = transform.debug();
        String message = "External debug response was null";
        assertTrue(message, debugResponse != null);
    }

    /**
     * Clear changes to {@link Networking Networking} class since it's a shared resource.
     */
    @AfterClass
    public static void teardown() {
        Networking.removeCustomClient();
    }
}

@@ -155,16 +155,46 @@
 t.Test;%0A
+import util.FilestackService;%0A
 import u
@@ -382,16 +382,100 @@
 sform %7B%0A
+    private static final String RESIZE_TASK_STRING = %22resize=width:100,height:100%22;%0A
     priv
@@ -1279,366 +1279,1421 @@
     
-@Test%0A    public void testDebugExternal() throws IOException %7B%0A        ImageTransform transform = new ImageTransform(CLIENT, SOURCE);%0A        transform = transform.resize(100, 100, null, null);%0A        JsonObject debugResponse = transform.debug();%0A        String message = %22External debug response was null%22;%0A        assertTrue(message, debugResponse != null
+public void testDebugUrl() throws IOException %7B%0A        FilestackService.Process processService = Networking.getProcessService();%0A%0A        String correct = FilestackService.Process.URL + %22debug/%22 + RESIZE_TASK_STRING + %22/%22 + HANDLE;%0A        String output = processService.debug(RESIZE_TASK_STRING, HANDLE).request().url().toString();%0A%0A        String message = String.format(%22Debug URL malformed%5CnCorrect: %25s%5CnOutput:  %25s%22, correct, output);%0A        assertTrue(message, output.equals(correct));%0A    %7D%0A%0A    @Test%0A    public void testDebugExternal() throws IOException %7B%0A        ImageTransform transform = new ImageTransform(CLIENT, SOURCE);%0A        transform = transform.resize(100, 100, null, null);%0A        JsonObject debugResponse = transform.debug();%0A        String message = %22External debug response was null%22;%0A        assertTrue(message, debugResponse != null);%0A    %7D%0A%0A    public void testDebugExternalUrl() throws IOException %7B%0A        FilestackService.Process processService = Networking.getProcessService();%0A%0A        String correct = FilestackService.Process.URL + API_KEY + %22/debug/%22 + RESIZE_TASK_STRING + %22/%22 + SOURCE;%0A        String output = processService.debugExternal(API_KEY, RESIZE_TASK_STRING, SOURCE).request().url().toString();%0A%0A        String message = String.format(%22External debug URL malformed%5CnCorrect: %25s%5CnOutput:  %25s%22, correct, output);%0A        assertTrue(message, output.equals(correct)
 );%0A 

Add tests for debug method URL forming