// Path: src/main/java/moulder/Moulder.java
// public interface Moulder {
//     /**
//      * This is where a moulder can process the input element to generate its
//      * result.
//      *
//      * @param element the element and its associated data to process
//      * @return the list of nodes and their associated data that were generated
//      *         after processing the input element.
//      */
//     List<Node> process(Element element);
// }


import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import java.io.StringReader;
import java.util.List;
import moulder.Moulder;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.junit.Test;
package moulder.moulds;





public class AddCssClassMoulderTest extends BaseMoulderTest {

    @Test
    public void noClass() throws Exception {

        final String bodyHtml = "<tag>text</tag>";
        final String cssClass = "ss";
        final String expected = "<tag class=\"ss\">text\n</tag>";

        test(bodyHtml, cssClass, expected);
    }

    @Test
    public void withSameClass() throws Exception {

        final String bodyHtml = "<tag class=\"ss\">text</tag>";
        final String cssClass = "ss";
        final String expected = "<tag class=\"ss\">text\n</tag>";

        test(bodyHtml, cssClass, expected);
    }

    @Test
    public void withSimilarClass() throws Exception {

        final String bodyHtml = "<tag class=\"sss ss1\">text</tag>";
        final String cssClass = "ss";
        final String expected = "<tag class=\"sss ss1 ss\">text\n</tag>";

        test(bodyHtml, cssClass, expected);
    }

    private void test(String bodyHtml, String cssClass, String expected) throws Exception {
        Document document = Jsoup.parseBodyFragment(bodyHtml);
        Element element = document.getElementsByTag("tag").first();

// Path: src/main/java/moulder/Moulder.java
// public interface Moulder {
//     /**
//      * This is where a moulder can process the input element to generate its
//      * result.
//      *
//      * @param element the element and its associated data to process
//      * @return the list of nodes and their associated data that were generated
//      *         after processing the input element.
//      */
//     List<Node> process(Element element);
// }


// Path: src/test/java/moulder/moulds/AddCssClassMoulderTest.java
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import java.io.StringReader;
import java.util.List;
import moulder.Moulder;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.junit.Test;

package moulder.moulds;





public class AddCssClassMoulderTest extends BaseMoulderTest {

    @Test
    public void noClass() throws Exception {

        final String bodyHtml = "<tag>text</tag>";
        final String cssClass = "ss";
        final String expected = "<tag class=\"ss\">text\n</tag>";

        test(bodyHtml, cssClass, expected);
    }

    @Test
    public void withSameClass() throws Exception {

        final String bodyHtml = "<tag class=\"ss\">text</tag>";
        final String cssClass = "ss";
        final String expected = "<tag class=\"ss\">text\n</tag>";

        test(bodyHtml, cssClass, expected);
    }

    @Test
    public void withSimilarClass() throws Exception {

        final String bodyHtml = "<tag class=\"sss ss1\">text</tag>";
        final String cssClass = "ss";
        final String expected = "<tag class=\"sss ss1 ss\">text\n</tag>";

        test(bodyHtml, cssClass, expected);
    }

    private void test(String bodyHtml, String cssClass, String expected) throws Exception {
        Document document = Jsoup.parseBodyFragment(bodyHtml);
        Element element = document.getElementsByTag("tag").first();

        Moulder moulder = new AddCssClassMoulder(cssClass);