<commit_before>/*
* Copyright 2015 herd contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.finra.herd.swaggergen;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.maven.plugin.MojoExecutionException;
import org.junit.Test;

import org.finra.herd.swaggergen.test.exampleXmlGenerator.BasicCase;
import org.finra.herd.swaggergen.test.exampleXmlGenerator.DatetimeCase;
import org.finra.herd.swaggergen.test.exampleXmlGenerator.EdgeCase;
import org.finra.herd.swaggergen.test.exampleXmlGenerator.MultiTypedListCase;
import org.finra.herd.swaggergen.test.exampleXmlGenerator.NonParametrizedListCase;
import org.finra.herd.swaggergen.test.exampleXmlGenerator.WildcardParameterizedListCase;
import org.finra.herd.swaggergen.test.exampleXmlGenerator.XmlTypeInterfaceCase;

public class ExampleXmlGeneratorTest extends AbstractTest
{
    @Test
    public void test_1() throws Exception
    {
        ExampleXmlGenerator exampleXmlGenerator = new ExampleXmlGenerator(LOG, BasicCase.class);
        String exampleXml = exampleXmlGenerator.getExampleXml();
        assertEquals(getResourceAsString("/exampleXml1"), exampleXml);
    }

    @Test
    public void test_2() throws Exception
    {
        ExampleXmlGenerator exampleXmlGenerator = new ExampleXmlGenerator(LOG, DatetimeCase.class);
        String exampleXml = exampleXmlGenerator.getExampleXml();
        Pattern pattern = Pattern.compile(
            "<xmlGregorianCalendar>[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}-[0-9]{2}:[0-9]{2}</xmlGregorianCalendar>");
        Matcher matcher = pattern.matcher(exampleXml);
        assertTrue(matcher.find());
    }

    @Test
    public void test_3() throws Exception
    {
        ExampleXmlGenerator exampleXmlGenerator = new ExampleXmlGenerator(LOG, EdgeCase.class);
        String exampleXml = exampleXmlGenerator.getExampleXml();
        assertEquals(getResourceAsString("/exampleXml2"), exampleXml);
    }

    @Test
    public void test_4() throws Exception
    {
        try
        {
            new ExampleXmlGenerator(LOG, NonParametrizedListCase.class);
            fail();
        }
        catch (Exception e)
        {
            assertEquals(MojoExecutionException.class, e.getClass());<commit_msg>Added logging to failed test<commit_after>/*
* Copyright 2015 herd contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.finra.herd.swaggergen;

import static java.lang.String.format;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.maven.plugin.MojoExecutionException;
import org.junit.Test;

import org.finra.herd.swaggergen.test.exampleXmlGenerator.BasicCase;
import org.finra.herd.swaggergen.test.exampleXmlGenerator.DatetimeCase;
import org.finra.herd.swaggergen.test.exampleXmlGenerator.EdgeCase;
import org.finra.herd.swaggergen.test.exampleXmlGenerator.MultiTypedListCase;
import org.finra.herd.swaggergen.test.exampleXmlGenerator.NonParametrizedListCase;
import org.finra.herd.swaggergen.test.exampleXmlGenerator.WildcardParameterizedListCase;
import org.finra.herd.swaggergen.test.exampleXmlGenerator.XmlTypeInterfaceCase;

public class ExampleXmlGeneratorTest extends AbstractTest
{
    @Test
    public void test_1() throws Exception
    {
        ExampleXmlGenerator exampleXmlGenerator = new ExampleXmlGenerator(LOG, BasicCase.class);
        String exampleXml = exampleXmlGenerator.getExampleXml();
        assertEquals(getResourceAsString("/exampleXml1"), exampleXml);
    }

    @Test
    public void test_2() throws Exception
    {
        ExampleXmlGenerator exampleXmlGenerator = new ExampleXmlGenerator(LOG, DatetimeCase.class);
        String exampleXml = exampleXmlGenerator.getExampleXml();
        Pattern pattern = Pattern.compile(
            "<xmlGregorianCalendar>[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}-[0-9]{2}:[0-9]{2}</xmlGregorianCalendar>");
        Matcher matcher = pattern.matcher(exampleXml);
        assertTrue(format("exampleXml does not match pattern. exampleXml: %s, pattern: %s", exampleXml, pattern), matcher.find());
    }

    @Test
    public void test_3() throws Exception
    {
        ExampleXmlGenerator exampleXmlGenerator = new ExampleXmlGenerator(LOG, EdgeCase.class);
        String exampleXml = exampleXmlGenerator.getExampleXml();
        assertEquals(getResourceAsString("/exampleXml2"), exampleXml);
    }

    @Test
    public void test_4() throws Exception
    {
        try
        {
            new ExampleXmlGenerator(LOG, NonParametrizedListCase.class);
            fail();
        }
        catch (Exception e)
        {
            assertEquals(MojoExecutionException.class, e.getClass());
{'fraction_non_alphanumeric': 0.10065315692513817, 'fraction_numerical': 0.013733043041366605, 'mean_word_length': 4.056731583403895, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, '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': '7156416', 'n_tokens_mistral': 1697, 'n_tokens_neox': 1668, 'n_words': 399}