<commit_before>package qub;

public class HttpClientTests
{
    public static void test(TestRunner runner, Function1<Test,HttpClient> creator)
    {
        runner.testGroup(HttpClient.class, () ->
        {
            runner.testGroup("send(HttpRequest)", () ->
            {
                runner.test("with null", (Test test) ->
                {
                    final HttpClient httpClient = creator.run(test);
                    final Result<HttpResponse> response = httpClient.send(null);
                    test.assertError(new IllegalArgumentException("request cannot be null."), response);
                });

                runner.test("with unknown host", (Test test) ->
                {
                    final HttpClient httpClient = creator.run(test);
                    final HttpRequest httpRequest = HttpRequest.create(HttpMethod.GET, "http://www.idontexistbecauseimnotagoodurl.com").getValue();
                    final Result<HttpResponse> httpResponse = httpClient.send(httpRequest);
                    test.assertError(new java.net.UnknownHostException("www.idontexistbecauseimnotagoodurl.com"), httpResponse);
                });

                runner.test("with GET request to www.example.com", (Test test) ->
                {
                    final HttpClient httpClient = creator.run(test);
                    final HttpRequest httpRequest = HttpRequest.create(HttpMethod.GET, "http://www.example.com").getValue();

                    final Result<HttpResponse> httpResponseResult = httpClient.send(httpRequest);
                    test.assertSuccess(httpResponseResult);

                    final HttpResponse httpResponse = httpResponseResult.getValue();
                    test.assertEqual("HTTP/1.1", httpResponse.getHttpVersion());
                    test.assertEqual(200, httpResponse.getStatusCode());
                    test.assertEqual("OK", httpResponse.getReasonPhrase());
                    test.assertNotNull(httpResponse.getHeaders());
                    test.assertSuccess("1270", httpResponse.getHeaders().getValue("content-length"));
                    test.assertNotNull(httpResponse.getBody());
                    final String bodyString = httpResponse.getBody().asCharacterReadStream().readString(3000).getValue();
                    test.assertNotNull(bodyString);
                    test.assertTrue(bodyString.contains("<html>"));<commit_msg>Add more assertions to HttpClient tests<commit_after>package qub;

public class HttpClientTests
{
    public static void test(TestRunner runner, Function1<Test,HttpClient> creator)
    {
        runner.testGroup(HttpClient.class, () ->
        {
            runner.testGroup("send(HttpRequest)", () ->
            {
                runner.test("with null", (Test test) ->
                {
                    final HttpClient httpClient = creator.run(test);
                    final Result<HttpResponse> response = httpClient.send(null);
                    test.assertError(new IllegalArgumentException("request cannot be null."), response);
                });

                runner.test("with unknown host", (Test test) ->
                {
                    final HttpClient httpClient = creator.run(test);
                    final HttpRequest httpRequest = HttpRequest.create(HttpMethod.GET, "http://www.idontexistbecauseimnotagoodurl.com").getValue();
                    final Result<HttpResponse> httpResponse = httpClient.send(httpRequest);
                    test.assertError(new java.net.UnknownHostException("www.idontexistbecauseimnotagoodurl.com"), httpResponse);
                });

                runner.test("with GET request to www.example.com", (Test test) ->
                {
                    final HttpClient httpClient = creator.run(test);
                    final HttpRequest httpRequest = HttpRequest.create(HttpMethod.GET, "http://www.example.com").getValue();

                    final Result<HttpResponse> httpResponseResult = httpClient.send(httpRequest);
                    test.assertSuccess(httpResponseResult);

                    final HttpResponse httpResponse = httpResponseResult.getValue();
                    test.assertEqual("HTTP/1.1", httpResponse.getHttpVersion());
                    test.assertEqual(200, httpResponse.getStatusCode());
                    test.assertEqual("OK", httpResponse.getReasonPhrase());
                    test.assertNotNull(httpResponse.getHeaders());
                    test.assertSuccess("1270", httpResponse.getHeaders().getValue("content-length"));
                    test.assertNotNull(httpResponse.getBody());
                    final String bodyString = httpResponse.getBody().asCharacterReadStream().readString(3000).getValue();
                    test.assertNotNull(bodyString);
                    test.assertTrue(bodyString.startsWith("<!doctype html>"));
                    test.assertTrue(bodyString.contains("<html>"));
{'fraction_non_alphanumeric': 0.1082172420755098, 'fraction_numerical': 0.005653139511407228, 'mean_word_length': 2.09625, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, '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': '7635407', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1092, 'n_words': 196}