<commit_before>package org.tosca.docs.generators.html;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.fluent.Content;
import org.apache.http.client.fluent.Request;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.tosca.docs.model.*;
import org.tosca.docs.model.impl.*;

import java.io.*;
import java.nio.charset.Charset;
import java.util.Locale;

public class HtmlGeneratorTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    /**
     * Sends the generated HTML to an external HTML validator tool and verifies there are no errors or warnings
     *
     * @throws IOException if exception occurred reading the expected HTML file or sending the HTTP request to the validator
     */
    @Test
    public void validateHtml() throws IOException {

        String expectedHtml;
        try (InputStream expectedInputStream = HtmlGeneratorTest.class.getResourceAsStream("/expected_tosca_spec.html")) {
            expectedHtml = IOUtils.toString(expectedInputStream, Charset.defaultCharset());
        }

        HttpEntity entity = MultipartEntityBuilder
                .create()
                .addTextBody("content", expectedHtml)
                .build();

        Content content = Request.Post("https://validator.w3.org/nu")
                .body(entity)
                .execute()
                .returnContent();

        String responseBody = content.asString();
        if (!responseBody.contains("The document validates according to the specified schema(s).")) {
            String reportFile = "/tmp/html_validator_report.html";<commit_msg>Added "/" at the end of validator.w3.org/nu to correct it to orginal URL.<commit_after>package org.tosca.docs.generators.html;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.fluent.Content;
import org.apache.http.client.fluent.Request;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.tosca.docs.model.*;
import org.tosca.docs.model.impl.*;

import java.io.*;
import java.nio.charset.Charset;
import java.util.Locale;

public class HtmlGeneratorTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    /**
     * Sends the generated HTML to an external HTML validator tool and verifies there are no errors or warnings
     *
     * @throws IOException if exception occurred reading the expected HTML file or sending the HTTP request to the validator
     */
    @Test
    public void validateHtml() throws IOException {

        String expectedHtml;
        try (InputStream expectedInputStream = HtmlGeneratorTest.class.getResourceAsStream("/expected_tosca_spec.html")) {
            expectedHtml = IOUtils.toString(expectedInputStream, Charset.defaultCharset());
        }

        HttpEntity entity = MultipartEntityBuilder
                .create()
                .addTextBody("content", expectedHtml)
                .build();

        Content content = Request.Post("https://validator.w3.org/nu/")
                .body(entity)
                .execute()
                .returnContent();

        String responseBody = content.asString();
        if (!responseBody.contains("The document validates according to the specified schema(s).")) {
            String reportFile = "/tmp/html_validator_report.html";
{'fraction_non_alphanumeric': 0.09961489088575096, 'fraction_numerical': 0.0007702182284980744, 'mean_word_length': 3.202804746494067, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '4442022', 'n_tokens_mistral': 1046, 'n_tokens_neox': 1039, 'n_words': 256}