Package net.vz.mongodb.jackson.mock

Examples of net.vz.mongodb.jackson.mock.MockObject


        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

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

    @Test
    public void testAddToSetSingle() throws Exception {
        MockObject toSave = new MockObject("blah", "string", 10);
        toSave.simpleList = Arrays.asList("hello");
        coll.insert(toSave);
        coll.updateById("blah", DBUpdate.addToSet("simpleList", "world"));
        MockObject updated = coll.findOneById("blah");
        assertThat(updated.simpleList, hasSize(2));
        assertThat(updated.simpleList, hasItem("world"));
        // Try again, this time should not be updated
        coll.updateById("blah", DBUpdate.addToSet("simpleList", "world"));
        updated = coll.findOneById("blah");
View Full Code Here

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

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

    }

    @Test
    public void testAddToSetListWithUpsert() throws Exception {
        coll.update(new BasicDBObject("_id", "blah"), DBUpdate.addToSet("simpleList", Arrays.asList("hello", "world")), true, false);
        MockObject inserted = coll.findOneById("blah");
        assertThat(inserted.simpleList, hasSize(2));
        assertThat(inserted.simpleList, hasItem("hello"));
        assertThat(inserted.simpleList, hasItem("world"));
    }
View Full Code Here

TOP

Related Classes of net.vz.mongodb.jackson.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.