// Path: stardao-core/src/main/java/io/stardog/stardao/core/Results.java
// @AutoValue
// public abstract class Results<M,N> {
//     @ApiModelProperty(value = "list of results returned", required = true)
//     public abstract List<M> getData();
// 
//     @ApiModelProperty(value = "identifier to return the next item in the sequence")
//     public abstract Optional<N> getNext();
// 
//     public static <M,N> Results<M,N> of(Iterable<M> data) {
//         return new AutoValue_Results<M, N>(ImmutableList.copyOf(data), Optional.empty());
//     }
// 
//     public static <M,N> Results<M,N> of(Iterable<M> data, N next) {
//         return new AutoValue_Results<M, N>(ImmutableList.copyOf(data), Optional.ofNullable(next));
//     }
// }
// 
// Path: stardao-core/src/main/java/io/stardog/stardao/core/Update.java
// @AutoValue
// @JsonDeserialize(using = UpdateDeserializer.class)
// @JsonSerialize(using = UpdateSerializer.class)
// public abstract class Update<P> {
//     public abstract P getPartial();
//     public abstract Set<String> getSetFields();
//     public abstract Set<String> getRemoveFields();
// 
//     public static <T> Update<T> of(T setObject, Set<String> setFields) {
//         return new AutoValue_Update<>(setObject, setFields, ImmutableSet.of());
//     }
// 
//     public static <T> Update<T> of(T setObject, Set<String> setFields, Set<String> removeFields) {
//         return new AutoValue_Update<>(setObject, setFields, removeFields);
//     }
// 
//     public boolean isEmpty() {
//         return getSetFields().isEmpty() && getRemoveFields().isEmpty();
//     }
// 
//     public Set<String> getUpdateFields() {
//         return Sets.union(getSetFields(), getRemoveFields());
//     }
// 
//     public boolean isUpdateField(String field) {
//         return getSetFields().contains(field) || getRemoveFields().contains(field);
//     }
// }
// 
// Path: stardao-core/src/main/java/io/stardog/stardao/exceptions/DataNotFoundException.java
// public class DataNotFoundException extends DataException {
//     public DataNotFoundException(String message) {
//         super(message);
//     }
// }


import com.github.fakemongo.Fongo;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import io.stardog.stardao.core.Results;
import io.stardog.stardao.core.Update;
import io.stardog.stardao.exceptions.DataNotFoundException;
import org.bson.Document;
import org.bson.types.ObjectId;
import org.geojson.Point;
import org.junit.Before;
import org.junit.Test;
import java.sql.Date;
import java.time.Instant;
import java.time.LocalDate;
import java.util.Iterator;
import java.util.Optional;
import static org.junit.Assert.*;
            fail("Expected DataNotFoundException");
        } catch (DataNotFoundException e) {
            assertEquals("TestUser not found", e.getMessage());
        }
    }

    @Test
    public void testLoadByQuerySort() throws Exception {
        TestUser created1 = dao.create(TestUser.builder().name("Ian").email("ian1@example.com").build());
        TestUser created2 = dao.create(TestUser.builder().name("Ian").email("ian2@example.com").build());

        TestUser load = dao.loadByQuery(new Document("name", "Ian"), new Document("email", 1));
        assertEquals(created1, load);
    }

    @Test
    public void testLoadByQueryOpt() throws Exception {
        TestUser created = dao.create(TestUser.builder().name("Ian").email("ian@example.com").build());

        TestUser load = dao.loadByQueryOpt(new Document("email", "ian@example.com")).get();
        assertEquals(load, created);

        assertFalse(dao.loadByQueryOpt(new Document("email", "bob@example.com")).isPresent());
    }

    @Test
    public void testFindByQuery() throws Exception {
        TestUser created1 = dao.create(TestUser.builder().name("Ian").email("ian1@example.com").build());
        TestUser created2 = dao.create(TestUser.builder().name("Ian").email("ian2@example.com").build());

// Path: stardao-core/src/main/java/io/stardog/stardao/core/Results.java
// @AutoValue
// public abstract class Results<M,N> {
//     @ApiModelProperty(value = "list of results returned", required = true)
//     public abstract List<M> getData();
// 
//     @ApiModelProperty(value = "identifier to return the next item in the sequence")
//     public abstract Optional<N> getNext();
// 
//     public static <M,N> Results<M,N> of(Iterable<M> data) {
//         return new AutoValue_Results<M, N>(ImmutableList.copyOf(data), Optional.empty());
//     }
// 
//     public static <M,N> Results<M,N> of(Iterable<M> data, N next) {
//         return new AutoValue_Results<M, N>(ImmutableList.copyOf(data), Optional.ofNullable(next));
//     }
// }
// 
// Path: stardao-core/src/main/java/io/stardog/stardao/core/Update.java
// @AutoValue
// @JsonDeserialize(using = UpdateDeserializer.class)
// @JsonSerialize(using = UpdateSerializer.class)
// public abstract class Update<P> {
//     public abstract P getPartial();
//     public abstract Set<String> getSetFields();
//     public abstract Set<String> getRemoveFields();
// 
//     public static <T> Update<T> of(T setObject, Set<String> setFields) {
//         return new AutoValue_Update<>(setObject, setFields, ImmutableSet.of());
//     }
// 
//     public static <T> Update<T> of(T setObject, Set<String> setFields, Set<String> removeFields) {
//         return new AutoValue_Update<>(setObject, setFields, removeFields);
//     }
// 
//     public boolean isEmpty() {
//         return getSetFields().isEmpty() && getRemoveFields().isEmpty();
//     }
// 
//     public Set<String> getUpdateFields() {
//         return Sets.union(getSetFields(), getRemoveFields());
//     }
// 
//     public boolean isUpdateField(String field) {
//         return getSetFields().contains(field) || getRemoveFields().contains(field);
//     }
// }
// 
// Path: stardao-core/src/main/java/io/stardog/stardao/exceptions/DataNotFoundException.java
// public class DataNotFoundException extends DataException {
//     public DataNotFoundException(String message) {
//         super(message);
//     }
// }


// Path: stardao-mongodb/src/test/java/io/stardog/stardao/mongodb/AbstractMongoDaoTest.java
import com.github.fakemongo.Fongo;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import io.stardog.stardao.core.Results;
import io.stardog.stardao.core.Update;
import io.stardog.stardao.exceptions.DataNotFoundException;
import org.bson.Document;
import org.bson.types.ObjectId;
import org.geojson.Point;
import org.junit.Before;
import org.junit.Test;
import java.sql.Date;
import java.time.Instant;
import java.time.LocalDate;
import java.util.Iterator;
import java.util.Optional;
import static org.junit.Assert.*;

            fail("Expected DataNotFoundException");
        } catch (DataNotFoundException e) {
            assertEquals("TestUser not found", e.getMessage());
        }
    }

    @Test
    public void testLoadByQuerySort() throws Exception {
        TestUser created1 = dao.create(TestUser.builder().name("Ian").email("ian1@example.com").build());
        TestUser created2 = dao.create(TestUser.builder().name("Ian").email("ian2@example.com").build());

        TestUser load = dao.loadByQuery(new Document("name", "Ian"), new Document("email", 1));
        assertEquals(created1, load);
    }

    @Test
    public void testLoadByQueryOpt() throws Exception {
        TestUser created = dao.create(TestUser.builder().name("Ian").email("ian@example.com").build());

        TestUser load = dao.loadByQueryOpt(new Document("email", "ian@example.com")).get();
        assertEquals(load, created);

        assertFalse(dao.loadByQueryOpt(new Document("email", "bob@example.com")).isPresent());
    }

    @Test
    public void testFindByQuery() throws Exception {
        TestUser created1 = dao.create(TestUser.builder().name("Ian").email("ian1@example.com").build());
        TestUser created2 = dao.create(TestUser.builder().name("Ian").email("ian2@example.com").build());

        Results<TestUser,ObjectId> results = dao.findByQuery(new Document("name", "Ian"), new Document("email", -1));