<commit_before>package util;


import okhttp3.*;

import java.io.IOException;
import java.util.Date;
import java.util.List;

/**
 * Intercepts HTTP requests and returns mock responses for unit testing.
 */
public class MockInterceptor implements Interceptor {
    public static String TEST_FILENAME = "filestack_test.txt";
    public static String TEST_FILE_CONTENT = "Test content for handle: %s\n%s\n";
    public static String TEST_FILE_TYPE = "text/plain; charset=utf-8";

    public static String HEADER_FILENAME = "x-file-name";

    public static String MESSAGE_OK = "OK";

    @Override
    public Response intercept(Chain chain) throws IOException {
        HttpUrl url = chain.request().url();
        Response.Builder builder = null;

        String host = url.host();
        List<String> path = url.pathSegments();
        String query = url.query();

        if (CdnService.URL.contains(host)) {
            if (path.size() == 1) {
                String handle = path.get(0);
                builder = genGetResponse(handle);
            }
        }

        if (builder == null)
            throw new IOException("The request was not matched by the interceptor");

        return builder
                .protocol(Protocol.HTTP_1_1)
                .request(chain.request())
                .build();
    }

    /**
     * Generates a test response for get requests.
     * Response contains data for a simple text file.
     *
     * @param handle File handle / id
     */
    private Response.Builder genGetResponse(String handle) {
        String bodyText = String.format(TEST_FILE_CONTENT, handle, new Date());
        ResponseBody body = ResponseBody.create(MediaType.parse(TEST_FILE_TYPE), bodyText);
        return new Response.Builder()
                .addHeader(HEADER_FILENAME, TEST_FILENAME)
                .body(body)
                .code(200)
                .message(MESSAGE_OK);
    }
}<commit_msg>Add default case to MockInterceptor for request matching<commit_after>package util;


import okhttp3.*;

import java.io.IOException;
import java.util.Date;
import java.util.List;

/**
 * Intercepts HTTP requests and returns mock responses for unit testing.
 */
public class MockInterceptor implements Interceptor {
    public static String TEST_FILENAME = "filestack_test.txt";
    public static String TEST_FILE_CONTENT = "Test content for handle: %s\n%s\n";
    public static String TEST_FILE_TYPE = "text/plain; charset=utf-8";

    public static String HEADER_FILENAME = "x-file-name";

    public static String MESSAGE_OK = "OK";

    @Override
    public Response intercept(Chain chain) throws IOException {
        HttpUrl url = chain.request().url();
        Response.Builder builder = null;

        String host = url.host();
        List<String> path = url.pathSegments();
        String query = url.query();

        if (CdnService.URL.contains(host)) {
            if (path.size() == 1) {
                String handle = path.get(0);
                builder = genGetResponse(handle);
            }
        } else {
            builder = genDefaultResponse();
        }

        if (builder == null)
            throw new IOException("The request was not matched by the interceptor");

        return builder
                .protocol(Protocol.HTTP_1_1)
                .request(chain.request())
                .build();
    }

    /**
     * Generates a test response for get requests.
     * Response contains data for a simple text file.
     *
     * @param handle File handle / id
     */
    private Response.Builder genGetResponse(String handle) {
        String bodyText = String.format(TEST_FILE_CONTENT, handle, new Date());
        ResponseBody body = ResponseBody.create(MediaType.parse(TEST_FILE_TYPE), bodyText);
        return new Response.Builder()
                .addHeader(HEADER_FILENAME, TEST_FILENAME)
                .body(body)
                .code(200)
                .message(MESSAGE_OK);
    }

    /**
     * Generates a test response for requests that don't match a host.
     */
    private Response.Builder genDefaultResponse() {
        return new Response.Builder()
                .code(200)
                .message(MESSAGE_OK);
    }
}
{'fraction_non_alphanumeric': 0.09793692198245198, 'fraction_numerical': 0.004979843490633152, 'mean_word_length': 2.23963133640553, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6121666', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1102, 'n_words': 323}