package com.bkromhout.minerva.test;

import com.bkromhout.minerva.data.SuperBook;
import nl.siegmann.epublib.domain.*;

import java.util.Collections;

/**
 * Utility class which creates SuperBooks for testing.
 */
public class TestBookFactory {
    /**
     * Number currently being used to help generate a {@link TestSuperBook}.
     */
    private long genNum;

    public TestBookFactory() {
        this.genNum = 0L;
    }

    /**
     * Create a new {@link SuperBook} wrapped in a {@link TestSuperBook}.
     * @return A {@link TestSuperBook} guaranteed to be different than the one returned by the last call to this method
     * for the current instance of {@link TestBookFactory}.
     */
    public final TestSuperBook generate() {
        genNum += 1L;
        String title = "Test Book " + genNum;
        Book book = new Book();
        Metadata metadata = book.getMetadata();
        metadata.addTitle(new DcmesElement(title));
        metadata.addAuthor(new Author("Author " + genNum));
        metadata.addDescription(new DcmesElement("Description " + genNum));
        metadata.setSubjects(Collections.singletonList(new DcmesElement("Subject " + genNum)));
        metadata.addType(new DcmesElement("Type " + genNum));
        metadata.setFormat("application/epub+zip");
        metadata.addPublisher(new DcmesElement("Publisher " + genNum));
        metadata.addDate(new Date("Create Date " + genNum, Date.Event.CREATION));
        metadata.addDate(new Date("Publish Date " + genNum, Date.Event.PUBLICATION));
        metadata.addDate(new Date("Modified Date " + genNum, Date.Event.MODIFICATION));
        return new TestSuperBook(book, "path/to/book_" + genNum, title.getBytes(), genNum);
    }
}

@@ -130,27 +130,78 @@
 va.util.
-Collections
+ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.List
 ;%0A%0A/**%0A 
@@ -624,120 +624,50 @@
 ent 
-than the one returned by the last call to this method%0A     * for the current instance of %7B@link TestBookFactory%7D
+from any others generated by this instance
 .%0A  
@@ -1582,32 +1582,32 @@
 MODIFICATION));%0A
-
         return n
@@ -1687,11 +1687,540 @@
 );%0A    %7D
+%0A%0A    /**%0A     * Create %7B@code num%7D new %7B@link SuperBook%7Ds wrapped in %7B@link TestSuperBook%7Ds.%0A     * @param num Number of %7B@link TestSuperBook%7Ds to generate.%0A     * @return A list of %7B@link TestSuperBook%7Ds guaranteed to be different from each other and any others generated by%0A     * this instance.%0A     */%0A    public final List%3CTestSuperBook%3E generateMultiple(int num) %7B%0A        ArrayList%3CTestSuperBook%3E tsbList = new ArrayList%3C%3E(num);%0A        for (int i = 0; i %3C num; i++) tsbList.add(generate());%0A        return tsbList;%0A    %7D
 %0A%7D%0A

Add convenience method to generate multiple TestSuperBooks