// Path: nakadi-producer/src/main/java/org/zalando/nakadiproducer/snapshots/SimpleSnapshotEventGenerator.java
// public final class SimpleSnapshotEventGenerator implements SnapshotEventGenerator {
//     private final String supportedEventType;
//     private final BiFunction<Object, String, List<Snapshot>> getSnapshotFunction;
// 
//     /**
//      * Creates a SnapshotEventGenerator for an event type, which doesn't support
//      * filtering.
//      *
//      * @param supportedEventType
//      *            the eventType that this SnapShotEventProvider will support.
//      * @param snapshotEventFactory
//      *            a snapshot event factory function conforming to the
//      *            specification of
//      *            {@link SnapshotEventGenerator#generateSnapshots(Object, String)}
//      *            (but without the filter parameter). Any filter provided by the
//      *            caller will be thrown away.
//      */
//     public SimpleSnapshotEventGenerator(String supportedEventType,
//             Function<Object, List<Snapshot>> snapshotEventFactory) {
//         this.supportedEventType = supportedEventType;
//         this.getSnapshotFunction = (id, filter) -> snapshotEventFactory.apply(id);
//     }
// 
//     /**
//      * Creates a SnapshotEventGenerator for an event type, with filtering
//      * support.
//      *
//      * @param supportedEventType
//      *            the eventType that this SnapShotEventProvider will support.
//      * @param snapshotEventFactory
//      *            a snapshot event factory function conforming to the
//      *            specification of
//      *            {@link SnapshotEventGenerator#generateSnapshots(Object, String)}.
//      */
//     public SimpleSnapshotEventGenerator(String supportedEventType,
//             BiFunction<Object, String, List<Snapshot>> snapshotEventFactory) {
//         this.supportedEventType = supportedEventType;
//         this.getSnapshotFunction = snapshotEventFactory;
//     }
// 
//     @Override
//     public List<Snapshot> generateSnapshots(Object withIdGreaterThan, String filter) {
//         return getSnapshotFunction.apply(withIdGreaterThan, filter);
//     }
// 
//     @Override
//     public String getSupportedEventType() {
//         return supportedEventType;
//     }
// }
// 
// Path: nakadi-producer/src/main/java/org/zalando/nakadiproducer/snapshots/Snapshot.java
// @AllArgsConstructor
// @Getter
// public class Snapshot {
//     private Object id;
//     private String dataType;
//     private Object data;
// }
// 
// Path: nakadi-producer/src/main/java/org/zalando/nakadiproducer/snapshots/SnapshotEventGenerator.java
// public interface SnapshotEventGenerator {
// 
//     /**
//      * <p>
//      * Returns a batch of snapshots of given type (event type is an event
//      * channel topic name). The implementation may return an arbitrary amount of
//      * results, but it must return at least one element if there are entities
//      * matching the parameters.
//      * </p>
//      * <p>
//      * Calling this method must have no side effects.
//      * </p>
//      * The library will call your implementation like this:
//      * <ul>
//      * <li>Request: generateSnapshots(null, filter), Response: 1,2,3</li>
//      * <li>Request: generateSnapshots(3, filter), Response: 4,5</li>
//      * <li>Request: generateSnapshots(5, filter), Response: emptyList</li>
//      * </ul>
//      * <p>
//      * It is your responsibility to make sure that the returned events are
//      * ordered by their ID ascending and that, given you return a list of events
//      * for entities with IDs {id<sub>1</sub>, ..., id<sub>N</sub>}, there exists
//      * no entity with an ID between id<sub>1</sub> and id<sub>N</sub>, that is
//      * not part of the result.
//      * </p>
//      *
//      * @param withIdGreaterThan
//      *            if not null, only events for entities with an ID greater than
//      *            the given one must be returned
//      *
//      * @param filter
//      *            a filter for the snapshot generation mechanism. This value is
//      *            simply passed through from the request body of the REST
//      *            endpoint (or from any other triggering mechanism). If there
//      *            was no request body, this will be {@code null}.
//      *
//      *            Implementors can interpret it in whatever way they want (even
//      *            ignore it). All calls for one snapshot generation will receive
//      *            the same string.
//      *
//      * @return list of elements (wrapped in Snapshot objects) ordered by their
//      *         ID.
//      */
//     List<Snapshot> generateSnapshots(Object withIdGreaterThan, String filter);
// 
//     /**
//      * The name of the event type supported by this snapshot generator.
//      */
//     String getSupportedEventType();
// }


import com.opentable.db.postgres.embedded.EmbeddedPostgres;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.zalando.nakadiproducer.EnableNakadiProducer;
import org.zalando.nakadiproducer.snapshots.SimpleSnapshotEventGenerator;
import org.zalando.nakadiproducer.snapshots.Snapshot;
import org.zalando.nakadiproducer.snapshots.SnapshotEventGenerator;
import javax.sql.DataSource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
package org.zalando.nakadiproducer.tests;




@EnableAutoConfiguration
@EnableNakadiProducer
public class Application {

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }

    @Bean
    @Primary
    public DataSource dataSource(EmbeddedPostgres postgres) throws IOException {
        return postgres.getPostgresDatabase();
    }

    @Bean
    public EmbeddedPostgres embeddedPostgres() throws IOException {
        return EmbeddedPostgres.start();
    }

    @Bean
    public SnapshotEventGenerator snapshotEventGenerator() {
        return new SimpleSnapshotEventGenerator("eventtype", (withIdGreaterThan, filter) -> {
            if (withIdGreaterThan == null) {
// Path: nakadi-producer/src/main/java/org/zalando/nakadiproducer/snapshots/SimpleSnapshotEventGenerator.java
// public final class SimpleSnapshotEventGenerator implements SnapshotEventGenerator {
//     private final String supportedEventType;
//     private final BiFunction<Object, String, List<Snapshot>> getSnapshotFunction;
// 
//     /**
//      * Creates a SnapshotEventGenerator for an event type, which doesn't support
//      * filtering.
//      *
//      * @param supportedEventType
//      *            the eventType that this SnapShotEventProvider will support.
//      * @param snapshotEventFactory
//      *            a snapshot event factory function conforming to the
//      *            specification of
//      *            {@link SnapshotEventGenerator#generateSnapshots(Object, String)}
//      *            (but without the filter parameter). Any filter provided by the
//      *            caller will be thrown away.
//      */
//     public SimpleSnapshotEventGenerator(String supportedEventType,
//             Function<Object, List<Snapshot>> snapshotEventFactory) {
//         this.supportedEventType = supportedEventType;
//         this.getSnapshotFunction = (id, filter) -> snapshotEventFactory.apply(id);
//     }
// 
//     /**
//      * Creates a SnapshotEventGenerator for an event type, with filtering
//      * support.
//      *
//      * @param supportedEventType
//      *            the eventType that this SnapShotEventProvider will support.
//      * @param snapshotEventFactory
//      *            a snapshot event factory function conforming to the
//      *            specification of
//      *            {@link SnapshotEventGenerator#generateSnapshots(Object, String)}.
//      */
//     public SimpleSnapshotEventGenerator(String supportedEventType,
//             BiFunction<Object, String, List<Snapshot>> snapshotEventFactory) {
//         this.supportedEventType = supportedEventType;
//         this.getSnapshotFunction = snapshotEventFactory;
//     }
// 
//     @Override
//     public List<Snapshot> generateSnapshots(Object withIdGreaterThan, String filter) {
//         return getSnapshotFunction.apply(withIdGreaterThan, filter);
//     }
// 
//     @Override
//     public String getSupportedEventType() {
//         return supportedEventType;
//     }
// }
// 
// Path: nakadi-producer/src/main/java/org/zalando/nakadiproducer/snapshots/Snapshot.java
// @AllArgsConstructor
// @Getter
// public class Snapshot {
//     private Object id;
//     private String dataType;
//     private Object data;
// }
// 
// Path: nakadi-producer/src/main/java/org/zalando/nakadiproducer/snapshots/SnapshotEventGenerator.java
// public interface SnapshotEventGenerator {
// 
//     /**
//      * <p>
//      * Returns a batch of snapshots of given type (event type is an event
//      * channel topic name). The implementation may return an arbitrary amount of
//      * results, but it must return at least one element if there are entities
//      * matching the parameters.
//      * </p>
//      * <p>
//      * Calling this method must have no side effects.
//      * </p>
//      * The library will call your implementation like this:
//      * <ul>
//      * <li>Request: generateSnapshots(null, filter), Response: 1,2,3</li>
//      * <li>Request: generateSnapshots(3, filter), Response: 4,5</li>
//      * <li>Request: generateSnapshots(5, filter), Response: emptyList</li>
//      * </ul>
//      * <p>
//      * It is your responsibility to make sure that the returned events are
//      * ordered by their ID ascending and that, given you return a list of events
//      * for entities with IDs {id<sub>1</sub>, ..., id<sub>N</sub>}, there exists
//      * no entity with an ID between id<sub>1</sub> and id<sub>N</sub>, that is
//      * not part of the result.
//      * </p>
//      *
//      * @param withIdGreaterThan
//      *            if not null, only events for entities with an ID greater than
//      *            the given one must be returned
//      *
//      * @param filter
//      *            a filter for the snapshot generation mechanism. This value is
//      *            simply passed through from the request body of the REST
//      *            endpoint (or from any other triggering mechanism). If there
//      *            was no request body, this will be {@code null}.
//      *
//      *            Implementors can interpret it in whatever way they want (even
//      *            ignore it). All calls for one snapshot generation will receive
//      *            the same string.
//      *
//      * @return list of elements (wrapped in Snapshot objects) ordered by their
//      *         ID.
//      */
//     List<Snapshot> generateSnapshots(Object withIdGreaterThan, String filter);
// 
//     /**
//      * The name of the event type supported by this snapshot generator.
//      */
//     String getSupportedEventType();
// }


// Path: nakadi-producer-starter-spring-boot-2-test/src/main/java/org/zalando/nakadiproducer/tests/Application.java
import com.opentable.db.postgres.embedded.EmbeddedPostgres;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.zalando.nakadiproducer.EnableNakadiProducer;
import org.zalando.nakadiproducer.snapshots.SimpleSnapshotEventGenerator;
import org.zalando.nakadiproducer.snapshots.Snapshot;
import org.zalando.nakadiproducer.snapshots.SnapshotEventGenerator;
import javax.sql.DataSource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;

package org.zalando.nakadiproducer.tests;




@EnableAutoConfiguration
@EnableNakadiProducer
public class Application {

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }

    @Bean
    @Primary
    public DataSource dataSource(EmbeddedPostgres postgres) throws IOException {
        return postgres.getPostgresDatabase();
    }

    @Bean
    public EmbeddedPostgres embeddedPostgres() throws IOException {
        return EmbeddedPostgres.start();
    }

    @Bean
    public SnapshotEventGenerator snapshotEventGenerator() {
        return new SimpleSnapshotEventGenerator("eventtype", (withIdGreaterThan, filter) -> {
            if (withIdGreaterThan == null) {
                return Collections.singletonList(new Snapshot("1", "foo", filter));