// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
//    private String eventId;
//    private String eventType;
//    private Long eventNumber;
//    private String streamId;
//    private Boolean isLinkMetaData;
//    private Long positionEventNumber;
//    private String positionStreamId;
//    private String title;
//    private String id;
//    private String updated;
//    private Author author;
//    private String summary;
// 
//    private String eventStreamId;
//    private String data;
//    private String metadata;
// }
// 
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
//    private String title;
//    private String id;
//    private String updated;
//    private Author author;
//    private String summary;
// 
//    private Event content;
// }
// 
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReader.java
// public interface EventStreamReader {
// 
//    /**
//     * Start at the beginning of the stream.
//     */
//    void start();
// 
//    /**
//     * Start after the given title (exclusive)
//     */
//    void start(String title);
// 
//    /**
//     * Start after the given timestamp (exclusive)
//     */
//    void start(Date timestamp);
// 
//    /**
//     * Manually trigger a catch up. If the reader is in the middle of a catchup this will do nothing
//     */
//    void catchUp();
// 
//    boolean isPaused();
// 
//    void setPaused(boolean paused);
// 
//    /**
//     * If you restart this reader at any point this is the maximum amount of time the reader waits for running catchUp operations to finish.
//     *
//     * @param catchUpTerminationPeriodMillis
//     */
//    void setCatchUpTerminationPeriodMillis(long catchUpTerminationPeriodMillis);
// 
// }
// 
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReaderImpl.java
// @FunctionalInterface
// public interface EventStreamReaderCallback {
//    void readEvent(final EventResponse event);
// }


import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EventStreamReader;
import de.qyotta.eventstore.utils.EventStreamReaderImpl.EventStreamReaderCallback;
import static com.jayway.awaitility.Awaitility.await;
import static com.jayway.awaitility.Duration.FIVE_SECONDS;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import com.google.gson.Gson;
package de.qyotta.eventstore;






@SuppressWarnings("nls")
public class EventStreamReaderTest extends AbstractEsTest {

   @After
   public void tearDown() {
      // try hard deleting created streams. This might not do anything depending on the test
      deleteStream(streamUrl);
   }

   @Test
   public void shouldTraverseAllEventsInOrder() throws InterruptedException {
      createEvents(10);
      final EventStreamReader eventStreamReader = client.newEventStreamReader(streamName, -1, new EventStreamReaderCallback() {
         private long previousEventNumber = -1;

         @Override
         public void readEvent(final EventResponse event) {
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/Event.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class Event {
//    private String eventId;
//    private String eventType;
//    private Long eventNumber;
//    private String streamId;
//    private Boolean isLinkMetaData;
//    private Long positionEventNumber;
//    private String positionStreamId;
//    private String title;
//    private String id;
//    private String updated;
//    private Author author;
//    private String summary;
// 
//    private String eventStreamId;
//    private String data;
//    private String metadata;
// }
// 
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/model/EventResponse.java
// @Getter
// @Setter
// @Builder(toBuilder = true)
// @ToString
// @EqualsAndHashCode
// @NoArgsConstructor(access = AccessLevel.PUBLIC)
// @AllArgsConstructor(access = AccessLevel.PUBLIC)
// public class EventResponse {
//    private String title;
//    private String id;
//    private String updated;
//    private Author author;
//    private String summary;
// 
//    private Event content;
// }
// 
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReader.java
// public interface EventStreamReader {
// 
//    /**
//     * Start at the beginning of the stream.
//     */
//    void start();
// 
//    /**
//     * Start after the given title (exclusive)
//     */
//    void start(String title);
// 
//    /**
//     * Start after the given timestamp (exclusive)
//     */
//    void start(Date timestamp);
// 
//    /**
//     * Manually trigger a catch up. If the reader is in the middle of a catchup this will do nothing
//     */
//    void catchUp();
// 
//    boolean isPaused();
// 
//    void setPaused(boolean paused);
// 
//    /**
//     * If you restart this reader at any point this is the maximum amount of time the reader waits for running catchUp operations to finish.
//     *
//     * @param catchUpTerminationPeriodMillis
//     */
//    void setCatchUpTerminationPeriodMillis(long catchUpTerminationPeriodMillis);
// 
// }
// 
// Path: eventstore-client/src/main/java/de/qyotta/eventstore/utils/EventStreamReaderImpl.java
// @FunctionalInterface
// public interface EventStreamReaderCallback {
//    void readEvent(final EventResponse event);
// }


// Path: eventstore-client/src/test/java/de/qyotta/eventstore/EventStreamReaderTest.java
import de.qyotta.eventstore.model.Event;
import de.qyotta.eventstore.model.EventResponse;
import de.qyotta.eventstore.utils.EventStreamReader;
import de.qyotta.eventstore.utils.EventStreamReaderImpl.EventStreamReaderCallback;
import static com.jayway.awaitility.Awaitility.await;
import static com.jayway.awaitility.Duration.FIVE_SECONDS;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import com.google.gson.Gson;

package de.qyotta.eventstore;






@SuppressWarnings("nls")
public class EventStreamReaderTest extends AbstractEsTest {

   @After
   public void tearDown() {
      // try hard deleting created streams. This might not do anything depending on the test
      deleteStream(streamUrl);
   }

   @Test
   public void shouldTraverseAllEventsInOrder() throws InterruptedException {
      createEvents(10);
      final EventStreamReader eventStreamReader = client.newEventStreamReader(streamName, -1, new EventStreamReaderCallback() {
         private long previousEventNumber = -1;

         @Override
         public void readEvent(final EventResponse event) {
            final Event expected = expectedEvents.remove(event.getContent()