// 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;
/*
 * Copyright (c) 2013-2014 Red Rainbow IT Solutions GmbH, Germany
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package org.jeeventstore.store;


public class DefaultChangeSetTest {

    private final static String BUCKET_ID = "TEST_BUCKET";
    private final static String STREAM_ID = "TEST_STREAM";
    private final static long STREAM_VERSION = 28;
    private final static String CHANGE_SET_ID = UUID.randomUUID().toString();
    private final static List<Serializable> EVENTS = new ArrayList<Serializable>();
    
    private ChangeSet get() {
        if (EVENTS.isEmpty())
            EVENTS.add("Hello!");
        return new DefaultChangeSet(BUCKET_ID, STREAM_ID, STREAM_VERSION, CHANGE_SET_ID, EVENTS);
    }

    @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);
// 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;

/*
 * Copyright (c) 2013-2014 Red Rainbow IT Solutions GmbH, Germany
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package org.jeeventstore.store;


public class DefaultChangeSetTest {

    private final static String BUCKET_ID = "TEST_BUCKET";
    private final static String STREAM_ID = "TEST_STREAM";
    private final static long STREAM_VERSION = 28;
    private final static String CHANGE_SET_ID = UUID.randomUUID().toString();
    private final static List<Serializable> EVENTS = new ArrayList<Serializable>();
    
    private ChangeSet get() {
        if (EVENTS.isEmpty())
            EVENTS.add("Hello!");
        return new DefaultChangeSet(BUCKET_ID, STREAM_ID, STREAM_VERSION, CHANGE_SET_ID, EVENTS);
    }

    @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()));