// Path: src/main/java/immanix/matchers/StartElementMatcher.java
// public class StartElementMatcher extends BaseEventMatcher<StartElement> {
// 
//     @Override
//     protected boolean accept(XMLEvent e) {
//         if (!e.isStartElement()) {
//             //System.out.println("failed to match <");
//         }
//         return e.isStartElement();
//     }
// 
//     @Override
//     protected StartElement process(XMLEvent e) {
//         return e.asStartElement();
//     }
// 
//     @Override
//     protected String expects() {
//         return "Start of any element";
//     }
// 
//     @Override
//     public String toString() {
//         return "Start of any element";
//     }
// }
// 
// Path: src/main/java/immanix/readers/ReplayEventReader.java
// @SuppressWarnings("restriction")
// public class ReplayEventReader implements EventReader {
// 
//     private Iterator<? extends XMLEvent> events;
// 
//     public ReplayEventReader(List<? extends XMLEvent> events) {
//         super();
//         this.events = new ArrayList(events).iterator();
//     }
// 
//     public boolean hasNext() {
//         return events.hasNext();
//     }
// 
//     public XMLEvent next() throws XMLStreamException {
//         return events.next();
//     }
// 
//     public EventReader unwrap() {
//         return this;
//     }
// 
//     @Override
//     public String toString() {
//         return "Replayer";
//     }
// }
// 
// Path: src/test/java/immanix/utils/XMLEventsUtils.java
// public static XMLEvent c(String val) {
//     return eventFactory.createCharacters(val);
// }
// 
// Path: src/test/java/immanix/utils/XMLEventsUtils.java
// public static XMLEvent se(String name) {
//     return eventFactory.createStartElement(new QName(name), null, null);
// }


import org.junit.Test;
import immanix.matchers.StartElementMatcher;
import immanix.readers.ReplayEventReader;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.*;
import static immanix.utils.XMLEventsUtils.c;
import static immanix.utils.XMLEventsUtils.se;
package immanix;




public class StartElementMatcherTest {
    @Test
    public void testSuccessMatch() throws Exception {
        StartElementMatcher m = new StartElementMatcher();
        List<XMLEvent> events = Arrays.asList(se("42"), c("hi"));
        ReplayEventReader reader = new ReplayEventReader(events);
        MatcherResult<StartElement> res = m.match(reader);
        //must match
        assertFalse(res.isFailure());
        //must call the data method with "hi"
        assertEquals(se("42"), res.data);
        //reader must return next element
        assertTrue(res.reader.hasNext());
        assertEquals(c("hi"), res.reader.next());
    }

    @Test
// Path: src/main/java/immanix/matchers/StartElementMatcher.java
// public class StartElementMatcher extends BaseEventMatcher<StartElement> {
// 
//     @Override
//     protected boolean accept(XMLEvent e) {
//         if (!e.isStartElement()) {
//             //System.out.println("failed to match <");
//         }
//         return e.isStartElement();
//     }
// 
//     @Override
//     protected StartElement process(XMLEvent e) {
//         return e.asStartElement();
//     }
// 
//     @Override
//     protected String expects() {
//         return "Start of any element";
//     }
// 
//     @Override
//     public String toString() {
//         return "Start of any element";
//     }
// }
// 
// Path: src/main/java/immanix/readers/ReplayEventReader.java
// @SuppressWarnings("restriction")
// public class ReplayEventReader implements EventReader {
// 
//     private Iterator<? extends XMLEvent> events;
// 
//     public ReplayEventReader(List<? extends XMLEvent> events) {
//         super();
//         this.events = new ArrayList(events).iterator();
//     }
// 
//     public boolean hasNext() {
//         return events.hasNext();
//     }
// 
//     public XMLEvent next() throws XMLStreamException {
//         return events.next();
//     }
// 
//     public EventReader unwrap() {
//         return this;
//     }
// 
//     @Override
//     public String toString() {
//         return "Replayer";
//     }
// }
// 
// Path: src/test/java/immanix/utils/XMLEventsUtils.java
// public static XMLEvent c(String val) {
//     return eventFactory.createCharacters(val);
// }
// 
// Path: src/test/java/immanix/utils/XMLEventsUtils.java
// public static XMLEvent se(String name) {
//     return eventFactory.createStartElement(new QName(name), null, null);
// }


// Path: src/test/java/immanix/StartElementMatcherTest.java
import org.junit.Test;
import immanix.matchers.StartElementMatcher;
import immanix.readers.ReplayEventReader;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.*;
import static immanix.utils.XMLEventsUtils.c;
import static immanix.utils.XMLEventsUtils.se;

package immanix;




public class StartElementMatcherTest {
    @Test
    public void testSuccessMatch() throws Exception {
        StartElementMatcher m = new StartElementMatcher();
        List<XMLEvent> events = Arrays.asList(se("42"), c("hi"));
        ReplayEventReader reader = new ReplayEventReader(events);
        MatcherResult<StartElement> res = m.match(reader);
        //must match
        assertFalse(res.isFailure());
        //must call the data method with "hi"
        assertEquals(se("42"), res.data);
        //reader must return next element
        assertTrue(res.reader.hasNext());
        assertEquals(c("hi"), res.reader.next());
    }

    @Test
    public void testFailureMatch() throws Exception {