package org.jeeventstore.core.store;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import org.jeeventstore.core.ChangeSet;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;

/**
 *
 * @author Alexander Langer
 */
public class TestUtils {

    public static List<Integer> randomdata(int count) {
        Random rand = new Random();
        List<Integer> list = new ArrayList<>();
        while (count-- > 0)
            list.add(rand.nextInt());
        return list;
    }

    public static void compare(EventsIterator has, List<ChangeSet> wants) {
        for (ChangeSet cs: wants) {
            Iterator<Serializable> eit = cs.events();
            while (eit.hasNext()) {
                Serializable ev = eit.next();
                assertTrue(has.hasNext());
                assertEquals(ev, has.next());
            }
        }
        assertTrue(!has.hasNext());
    } 
}

@@ -163,16 +163,39 @@
 Random;%0A
+import java.util.UUID;%0A
 import o
@@ -226,16 +226,16 @@
 ngeSet;%0A
-
 import s
@@ -315,16 +315,53 @@
 ertTrue;
+%0Aimport org.testng.collections.Lists;
 %0A%0A/**%0A *
@@ -1054,13 +1054,715 @@
 ));%0A
-
     %7D %0A
+%0A    public static List%3CChangeSet%3E createChangeSets(String bId, String sId, int minversion, int maxversion) %7B%0A        List%3CChangeSet%3E list = new ArrayList%3C%3E();%0A        for (int i = minversion; i %3C= maxversion; i++) %7B%0A            List%3CInteger%3E data = TestUtils.randomdata(i %25 (maxversion - minversion + 5));%0A            ChangeSet cs = new DefaultChangeSet(bId, sId, i, UUID.randomUUID(), data);%0A            list.add(cs);%0A        %7D%0A        return list;%0A    %7D%0A%0A    // we do not use IteratorUtils to avoid a dependency%0A    public static %3CT%3E List%3CT%3E toList(Iterator%3CT%3E it) %7B%0A        List%3CT%3E list = new ArrayList%3C%3E();%0A        while (it.hasNext())%0A            list.add(it.next());%0A        return list;%0A    %7D%0A%0A
 %7D%0A

Add createChangeSets() to TestUtils