Package net.vz.mongodb.jackson.mock

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


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

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


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

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

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

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

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

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

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

    @Test
    public void testPullWithQuery() throws Exception {
        MockObject toSave = new MockObject("blah", "string", 10);
        toSave.simpleList = Arrays.asList("hello", "world");
        coll.insert(toSave);
        coll.updateById("blah", DBUpdate.pull("simpleList", new BasicDBObject("$regex", Pattern.compile("w??ld"))));
        MockObject updated = coll.findOneById("blah");
        assertThat(updated.simpleList, hasSize(1));
        assertThat(updated.simpleList, hasItem("hello"));
    }
View Full Code Here

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

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

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

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

        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

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.