Package net.vz.mongodb.jackson.mock

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


        assertThat(remaining, not(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


        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"));
     
      coll.removeById("id1");
      coll.removeById("id2");
View Full Code Here

        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

        assertThat(coll.insert(new MockObject("blah", "ten", 10)).getSavedId(), equalTo("blah"));
    }

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

        assertThat(coll.insert(o).getSavedObject(), equalTo(o));
    }
   
    @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

      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

        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));
        assertThat(cursor.curr(), equalTo(o1));
View Full Code Here

        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

        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 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.