Examples of MockObject


Examples of org.mongojack.mock.MockObject

        assertThat(remaining, contains(object));
    }

    @Test
    public void testRemoveById() {
        coll.insert(new MockObject("id1", "ten", 10));
        coll.insert(new MockObject("id2", "ten", 100));
        MockObject object = new MockObject("id3", "twenty", 20);
        coll.insert(object);

        coll.removeById("id3");

        List<MockObject> remaining = coll.find().toArray();
View Full Code Here

Examples of org.mongojack.mock.MockObject

        assertThat(remaining, not(contains(object)));
    }

    @Test
    public void testFindAndModifyWithBuilder() {
        coll.insert(new MockObject("id1", "ten", 10));
        coll.insert(new MockObject("id2", "ten", 10));

        MockObject result1 = coll.findAndModify(DBQuery.is("_id", "id1"), null,
                null, false, DBUpdate.set("integer", 20)
                        .set("string", "twenty"), true, false);
        assertThat(result1.integer, equalTo(20));
        assertThat(result1.string, equalTo("twenty"));

        MockObject result2 = coll.findAndModify(DBQuery.is("_id", "id2"), null,
                null, false, DBUpdate.set("integer", 30)
                        .set("string", "thirty"), true, false);
        assertThat(result2.integer, equalTo(30));
        assertThat(result2.string, equalTo("thirty"));
View Full Code Here

Examples of org.mongojack.mock.MockObject

    }

    @Test
    public void testFindAndModifyWithParameterizedType() {
        coll.insert(new MockObject("ten", 10));

        MockObject init = coll.findOne(DBQuery.is("string", "ten").is(
                "integer", 10));

        MockObject result1 = coll.findAndModify(DBQuery.is("_id", init._id),
                null, null, false, new MockObject("twenty", 20), true, true);
        assertThat(result1.integer, equalTo(20));
        assertThat(result1.string, equalTo("twenty"));

        MockObject result2 = coll.findAndModify(DBQuery.is("_id", "id2"), null,
                null, false, new MockObject("id2", "thirty", 30), true, true);
        assertThat(result2._id, equalTo("id2"));
        assertThat(result2.integer, equalTo(30));
        assertThat(result2.string, equalTo("thirty"));

        coll.removeById("id1");
View Full Code Here

Examples of org.mongojack.mock.MockObject

    private JacksonDBCollection<MockObject, String> coll;

    @Before
    public void setUp() {
        coll = getCollection(MockObject.class, String.class);
        coll.save(new MockObject("1", "b", 10));
        coll.save(new MockObject("2", "a", 30));
        coll.save(new MockObject("3", "a", 20));
    }
View Full Code Here

Examples of org.mongojack.mock.MockObject

        coll = getCollection(MockObject.class, String.class);
    }

    @Test
    public void testGetSavedId() {
        assertThat(coll.insert(new MockObject("blah", "ten", 10)).getSavedId(),
                equalTo("blah"));
    }
View Full Code Here

Examples of org.mongojack.mock.MockObject

                equalTo("blah"));
    }

    @Test
    public void testGetSavedObject() {
        MockObject o = new MockObject("blah", "ten", 10);
        assertThat(coll.insert(o).getSavedObject(), equalTo(o));
    }
View Full Code Here

Examples of org.mongojack.mock.MockObject

    }

    @Test
    public void testGetSavedIds() {
        final WriteResult<MockObject, String> result = coll.insert(
                new MockObject("A", "a", 1), new MockObject("B", "b", 2));
        assertThat(result.getSavedIds().get(0), equalTo("A"));
        assertThat(result.getSavedIds().get(1), equalTo("B"));
    }
View Full Code Here

Examples of org.mongojack.mock.MockObject

        assertThat(result.getSavedIds().get(1), equalTo("B"));
    }

    @Test
    public void testGetSavedObjects() {
        final MockObject a = new MockObject("A", "a", 1);
        final MockObject b = new MockObject("B", "b", 2);
        final WriteResult<MockObject, String> result = coll.insert(a, b);
        assertThat(result.getSavedObjects().get(0), equalTo(a));
        assertThat(result.getSavedObjects().get(1), equalTo(b));
    }
View Full Code Here

Examples of org.mongojack.mock.MockObject

        coll = getCollection(MockObject.class, String.class);
    }

    @Test
    public void testIterator() {
        MockObject o1 = new MockObject("id1", "blah1", 10);
        MockObject o2 = new MockObject("id2", "blah2", 20);
        MockObject o3 = new MockObject("id3", "blah3", 30);
        coll.insert(o1, o2, o3);
        DBCursor<MockObject> cursor = coll.find().sort(
                new BasicDBObject("integer", 1));
        assertThat(cursor.hasNext(), equalTo(true));
        assertThat(cursor.next(), equalTo(o1));
View Full Code Here

Examples of org.mongojack.mock.MockObject

        assertThat(cursor.hasNext(), equalTo(false));
    }

    @Test
    public void testArray() {
        MockObject o1 = new MockObject("id1", "blah1", 10);
        MockObject o2 = new MockObject("id2", "blah2", 20);
        MockObject o3 = new MockObject("id3", "blah3", 30);
        coll.insert(o1, o2, o3);
        List<MockObject> results = coll.find()
                .sort(new BasicDBObject("integer", 1)).toArray();
        assertThat(results, contains(o1, o2, o3));
        assertThat(results, hasSize(3));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.