Package org.mongojack.mock

Examples of org.mongojack.mock.MockObject


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

    @Test
    public void testRename() throws Exception {
        coll.insert(new MockObject("blah", "some string", 10));
        coll.updateById("blah", DBUpdate.rename("string", "something"));
        DBObject object = coll.getDbCollection().findOne("blah");
        assertThat(object.get("string"), nullValue());
        assertThat((String) object.get("something"), equalTo("some string"));
    }
View Full Code Here


        assertThat((String) object.get("something"), equalTo("some string"));
    }

    @Test
    public void testBit() throws Exception {
        coll.insert(new MockObject("blah", "some string", 1 + 4 + 8));
        coll.updateById("blah", DBUpdate.bit("integer", "and", 4 + 8 + 16));
        assertThat(coll.findOneById("blah").integer, equalTo(4 + 8));
    }
View Full Code Here

        assertThat(coll.findOneById("blah").integer, equalTo(4 + 8));
    }

    @Test
    public void testBitTwoOperations() throws Exception {
        coll.insert(new MockObject("blah", "some string", 1 + 4 + 8));
        coll.updateById("blah",
                DBUpdate.bit("integer", "and", 4 + 8 + 16, "or", 32));
        assertThat(coll.findOneById("blah").integer, equalTo(4 + 8 + 32));
    }
View Full Code Here

        assertThat(coll.findOneById("blah").integer, equalTo(4 + 8 + 32));
    }

    @Test
    public void testBitwiseAnd() throws Exception {
        coll.insert(new MockObject("blah", "some string", 1 + 4 + 8));
        coll.updateById("blah", DBUpdate.bitwiseAnd("integer", 4 + 8 + 16));
        assertThat(coll.findOneById("blah").integer, equalTo(4 + 8));
    }
View Full Code Here

        assertThat(coll.findOneById("blah").integer, equalTo(4 + 8));
    }

    @Test
    public void testBitwiseOr() throws Exception {
        coll.insert(new MockObject("blah", "some string", 1 + 4 + 8));
        coll.updateById("blah", DBUpdate.bitwiseOr("integer", 4 + 8 + 16));
        assertThat(coll.findOneById("blah").integer, equalTo(1 + 4 + 8 + 16));
    }
View Full Code Here

        assertThat(coll.findOneById("blah").integer, equalTo(1 + 4 + 8 + 16));
    }

    @Test
    public void testObjectSerialisation() throws Exception {
        coll.insert(new MockObject("blah", "some string", 10));
        coll.updateById("blah",
                DBUpdate.set("object", new MockEmbeddedObject("hello")));
        assertThat(coll.findOneById("blah").object,
                equalTo(new MockEmbeddedObject("hello")));
    }
View Full Code Here

                equalTo(new MockEmbeddedObject("hello")));
    }

    @Test
    public void testObjectInListSerialisation() throws Exception {
        coll.insert(new MockObject("blah", "some string", 10));
        coll.updateById(
                "blah",
                DBUpdate.pushAll("complexList",
                        Arrays.asList(new MockEmbeddedObject("hello"))));
        assertThat(coll.findOneById("blah").complexList,
View Full Code Here

                hasItem(new MockEmbeddedObject("hello")));
    }

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

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

    @Test
    public void testIsPositive() throws Exception {
        MockObject mockObject = insertMockObject();
        DBCursor<MockObject> cursor = coll.find().is("integer", 10);
        assertThat(cursor.hasNext(), equalTo(true));
        assertThat(cursor.next(), equalTo(mockObject));
    }
View Full Code Here

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

    @Test
    public void testGreaterThanPositive() throws Exception {
        MockObject mockObject = insertMockObject();
        DBCursor<MockObject> cursor = coll.find().greaterThan("integer", 9);
        assertThat(cursor.hasNext(), equalTo(true));
        assertThat(cursor.next(), equalTo(mockObject));
    }
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.