// 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/main/java/moulder/Value.java
// public interface Value<T> {
// 	/**
// 	 * 
// 	 * @return the generated value
// 	 */
// 	T get();
// }


import moulder.Moulder;
import moulder.Value;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import java.io.StringReader;
import java.util.Arrays;
import java.util.List;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.mockito.Mockito.*;
package moulder.moulds;




public class IfMoulderTest extends BaseMoulderTest {

    @Test
    public void testThen() throws Exception {
        test(true, "<body><b>text</b>text</body>");
    }

    @Test
    public void testElse() throws Exception {
        test(false, "<body><c>content</c>text</body>");
    }

    private void test(boolean res, String expected) throws Exception {
        Value<Boolean> condition = mock(Value.class);
        when(condition.get()).thenReturn(res);

        Document document = Jsoup
                .parseBodyFragment("<html><body><outer a='v'><a>test</a></outer></body></html>");
        Element element = document.getElementsByTag("outer").first();

        Moulder thenMoulder = mock(Moulder.class);
        ArgumentCaptor<Element> ifMoulderCaptor = ArgumentCaptor
                .forClass(Element.class);
        when(
                thenMoulder.process(ifMoulderCaptor.capture())).thenReturn(
                Arrays.asList(parseNode("<b>text</b>"),
                        parseNode("text")));

// 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/main/java/moulder/Value.java
// public interface Value<T> {
// 	/**
// 	 * 
// 	 * @return the generated value
// 	 */
// 	T get();
// }


// Path: src/test/java/moulder/moulds/IfMoulderTest.java
import moulder.Moulder;
import moulder.Value;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import java.io.StringReader;
import java.util.Arrays;
import java.util.List;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.mockito.Mockito.*;

package moulder.moulds;




public class IfMoulderTest extends BaseMoulderTest {

    @Test
    public void testThen() throws Exception {
        test(true, "<body><b>text</b>text</body>");
    }

    @Test
    public void testElse() throws Exception {
        test(false, "<body><c>content</c>text</body>");
    }

    private void test(boolean res, String expected) throws Exception {
        Value<Boolean> condition = mock(Value.class);
        when(condition.get()).thenReturn(res);

        Document document = Jsoup
                .parseBodyFragment("<html><body><outer a='v'><a>test</a></outer></body></html>");
        Element element = document.getElementsByTag("outer").first();

        Moulder thenMoulder = mock(Moulder.class);
        ArgumentCaptor<Element> ifMoulderCaptor = ArgumentCaptor
                .forClass(Element.class);
        when(
                thenMoulder.process(ifMoulderCaptor.capture())).thenReturn(
                Arrays.asList(parseNode("<b>text</b>"),
                        parseNode("text")));

        Moulder elseMoulder = mock(Moulder.class);