// Path: core/src/main/java/org/jeeventstore/ChangeSet.java
// public interface ChangeSet extends Serializable {
// 
//     /**
//      * Identifies the bucket to which the event stream belongs.
//      * 
//      * @return  the identifier
//      */
//     String bucketId();
// 
//     /**
//      * Identifies the event stream to which this belongs.
//      * 
//      * @return  the identifier
//      */
//     String streamId();
// 
//     /**
//      * Gets the version of the event stream to which this applies.
//      * 
//      * @return  the version
//      */
//     long streamVersion();
// 
//     /**
//      * Gets the unique identifier for this ChangeSet within the stream.
//      * 
//      * @return the unique identifer
//      */
//     String changeSetId();
//     
//     /**
//      * Gets an iterator to the events contained within this ChangeSet.
//      * 
//      * @return  the iterator
//      */
//     Iterator<Serializable> events();
//     
// }
// 
// Path: core/src/main/java/org/jeeventstore/util/IteratorUtils.java
// public class IteratorUtils {
//     
//     /** 
//      * Gets a list based on an iterator. 
//      * As the wrapped Iterator is traversed, an {@link ArrayList} of its values
//      * is created. At the end, the list is returned.
// 
//      * @param <T> the event type
//      * @param it  the iterator to be traversed
//      * @return   the list of values found in the traversal of the iterator
//      */
//     public static <T> List<T> toList(Iterator<T> it) {
//         List<T> list = new ArrayList<>();
//         while (it.hasNext())
//             list.add(it.next());
//         return list;
//     }
//     
// }


import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import org.jeeventstore.ChangeSet;
import org.jeeventstore.util.IteratorUtils;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
    @Test
    public void test_that_values_are_valid() {
        ChangeSet cs = get();
        assertEquals(cs.bucketId(), BUCKET_ID);
        assertEquals(cs.streamId(), STREAM_ID);
        assertEquals(cs.streamVersion(), STREAM_VERSION);
        assertEquals(cs.changeSetId(), CHANGE_SET_ID);
        assertEquals(IteratorUtils.toList(cs.events()), IteratorUtils.toList(EVENTS.iterator()));
        assertTrue(cs.events().hasNext());
    }

    @Test
    public void test_that_events_are_readonly() {
        ChangeSet cs = get();
        Iterator<Serializable> it = cs.events();
        assertTrue(it.hasNext());
        it.next();
        try {
            it.remove();
            fail("Should have failed by now");
        } catch (UnsupportedOperationException e) {
            // expected
        }
    }

    @Test
    public void test_invalid_args() {
        try {
            new DefaultChangeSet(null, STREAM_ID, STREAM_VERSION, CHANGE_SET_ID, EVENTS);
            fail("Should have failed by now");
// Path: core/src/main/java/org/jeeventstore/ChangeSet.java
// public interface ChangeSet extends Serializable {
// 
//     /**
//      * Identifies the bucket to which the event stream belongs.
//      * 
//      * @return  the identifier
//      */
//     String bucketId();
// 
//     /**
//      * Identifies the event stream to which this belongs.
//      * 
//      * @return  the identifier
//      */
//     String streamId();
// 
//     /**
//      * Gets the version of the event stream to which this applies.
//      * 
//      * @return  the version
//      */
//     long streamVersion();
// 
//     /**
//      * Gets the unique identifier for this ChangeSet within the stream.
//      * 
//      * @return the unique identifer
//      */
//     String changeSetId();
//     
//     /**
//      * Gets an iterator to the events contained within this ChangeSet.
//      * 
//      * @return  the iterator
//      */
//     Iterator<Serializable> events();
//     
// }
// 
// Path: core/src/main/java/org/jeeventstore/util/IteratorUtils.java
// public class IteratorUtils {
//     
//     /** 
//      * Gets a list based on an iterator. 
//      * As the wrapped Iterator is traversed, an {@link ArrayList} of its values
//      * is created. At the end, the list is returned.
// 
//      * @param <T> the event type
//      * @param it  the iterator to be traversed
//      * @return   the list of values found in the traversal of the iterator
//      */
//     public static <T> List<T> toList(Iterator<T> it) {
//         List<T> list = new ArrayList<>();
//         while (it.hasNext())
//             list.add(it.next());
//         return list;
//     }
//     
// }


// Path: core/src/test/java/org/jeeventstore/store/DefaultChangeSetTest.java
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import org.jeeventstore.ChangeSet;
import org.jeeventstore.util.IteratorUtils;
import static org.testng.Assert.*;
import org.testng.annotations.Test;

    @Test
    public void test_that_values_are_valid() {
        ChangeSet cs = get();
        assertEquals(cs.bucketId(), BUCKET_ID);
        assertEquals(cs.streamId(), STREAM_ID);
        assertEquals(cs.streamVersion(), STREAM_VERSION);
        assertEquals(cs.changeSetId(), CHANGE_SET_ID);
        assertEquals(IteratorUtils.toList(cs.events()), IteratorUtils.toList(EVENTS.iterator()));
        assertTrue(cs.events().hasNext());
    }

    @Test
    public void test_that_events_are_readonly() {
        ChangeSet cs = get();
        Iterator<Serializable> it = cs.events();
        assertTrue(it.hasNext());
        it.next();
        try {
            it.remove();
            fail("Should have failed by now");
        } catch (UnsupportedOperationException e) {
            // expected
        }
    }

    @Test
    public void test_invalid_args() {
        try {
            new DefaultChangeSet(null, STREAM_ID, STREAM_VERSION, CHANGE_SET_ID, EVENTS);
            fail("Should have failed by now");
        } catch (NullPointerException e) {