Package org.mongojack.mock

Examples of org.mongojack.mock.MockObject


        assertEquals(object.complexList, result.complexList);
    }

    @Test
    public void testInsertRetrieveEmbeddedObject() {
        MockObject object = new MockObject();
        object.object = new MockEmbeddedObject();
        object.object.value = "blah";
        coll.insert(object);
        MockObject result = coll.findOne();
        assertEquals(object.object, result.object);
    }
View Full Code Here


        assertEquals(object.object, result.object);
    }

    @Test
    public void testInsertRetrieveEmebeddedObjectList() {
        MockObject object = new MockObject();
        object.object = new MockEmbeddedObject();
        object.object.list = Arrays.asList("1", "2");
        coll.insert(object);
        MockObject result = coll.findOne();
        assertEquals(object.object, result.object);
    }
View Full Code Here

        assertEquals(object.object, result.object);
    }

    @Test
    public void testEverything() {
        MockObject object = new MockObject();
        object._id = "theid";
        object.integer = 123;
        object.longs = 1234L;
        object.floats = 12.34f;
        object.doubles = 123.456;
View Full Code Here

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

    @Test
    public void testIncByOne() throws Exception {
        coll.insert(new MockObject("blah", "string", 10));
        coll.updateById("blah", DBUpdate.inc("integer"));
        assertThat(coll.findOneById("blah").integer, equalTo(11));
    }
View Full Code Here

        assertThat(coll.findOneById("blah").integer, equalTo(11));
    }

    @Test
    public void testInc() throws Exception {
        coll.insert(new MockObject("blah", "string", 10));
        coll.updateById("blah", DBUpdate.inc("integer", 2));
        assertThat(coll.findOneById("blah").integer, equalTo(12));
    }
View Full Code Here

        assertThat(coll.findOneById("blah").integer, equalTo(12));
    }

    @Test
    public void testSet() throws Exception {
        coll.insert(new MockObject("blah", "string", 10));
        coll.updateById("blah", DBUpdate.set("integer", 2));
        assertThat(coll.findOneById("blah").integer, equalTo(2));
    }
View Full Code Here

        assertThat(coll.findOneById("blah").integer, equalTo(2));
    }

    @Test
    public void testUnset() throws Exception {
        coll.insert(new MockObject("blah", "string", 10));
        coll.updateById("blah", DBUpdate.unset("integer"));
        assertThat(coll.findOneById("blah").integer, nullValue());
    }
View Full Code Here

        assertThat(coll.findOneById("blah").integer, nullValue());
    }

    @Test
    public void testPush() throws Exception {
        MockObject toSave = new MockObject("blah", "string", 10);
        toSave.simpleList = Arrays.asList("hello");
        coll.insert(toSave);
        coll.updateById("blah", DBUpdate.push("simpleList", "world"));
        MockObject updated = coll.findOneById("blah");
        assertThat(updated.simpleList, hasSize(2));
        assertThat(updated.simpleList, hasItem("world"));
    }
View Full Code Here

        assertThat(updated.simpleList, hasItem("world"));
    }

    @Test
    public void testPushAllList() throws Exception {
        MockObject toSave = new MockObject("blah", "string", 10);
        toSave.simpleList = Arrays.asList("hello");
        coll.insert(toSave);
        coll.updateById("blah",
                DBUpdate.pushAll("simpleList", Arrays.asList("world", "!")));
        MockObject updated = coll.findOneById("blah");
        assertThat(updated.simpleList, hasSize(3));
        assertThat(updated.simpleList, hasItem("world"));
        assertThat(updated.simpleList, hasItem("!"));
    }
View Full Code Here

        assertThat(updated.simpleList, hasItem("!"));
    }

    @Test
    public void testPushAllVarArgs() throws Exception {
        MockObject toSave = new MockObject("blah", "string", 10);
        toSave.simpleList = Arrays.asList("hello");
        coll.insert(toSave);
        coll.updateById("blah", DBUpdate.pushAll("simpleList", "world", "!"));
        MockObject updated = coll.findOneById("blah");
        assertThat(updated.simpleList, hasSize(3));
        assertThat(updated.simpleList, hasItem("world"));
        assertThat(updated.simpleList, hasItem("!"));
    }
View Full Code Here

TOP

Related Classes of org.mongojack.mock.MockObject

Copyright © 2018 www.massapicom. 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.