Package org.mongojack.mock

Examples of org.mongojack.mock.MockObject


                equalTo("blah"));
    }

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


    }

    @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));
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 testGroupSumSort() {
        coll.insert(new MockObject("foo", 5));
        coll.insert(new MockObject("foo", 6));
        coll.insert(new MockObject("bar", 101));
        coll.insert(new MockObject("bar", 102));

        AggregationBuilder<MockObjectAggregationResult> builder = new AggregationBuilder<MockObjectAggregationResult>();
        builder.group(new GroupAggregation("string").withSum("integer", "integer")).sort(new SortAggregation().descending("string"));

        AggregationResult<MockObjectAggregationResult> aggregationResult = coll.aggregate(builder.build(MockObjectAggregationResult.class));
View Full Code Here

    }

    @Test
    public void testMatchGroupMin() {

        coll.insert(new MockObject("foo", 5));
        coll.insert(new MockObject("foo", 6));
        coll.insert(new MockObject("bar", 101));
        coll.insert(new MockObject("bar", 102));

        AggregationBuilder<MockObjectAggregationResult> builder = new AggregationBuilder<MockObjectAggregationResult>();
        builder.match(new MatchAggregation("string", "foo"))
                .group(new GroupAggregation("string").withMin("integer", "integer"));
View Full Code Here

    }

    @Test
    public void testGroupProject() {

        coll.insert(new MockObject("foo", 5));
        coll.insert(new MockObject("foo", 6));
        coll.insert(new MockObject("bar", 101));
        coll.insert(new MockObject("bar", 102));

        AggregationBuilder<MockObjectAggregationResult> builder = new AggregationBuilder<MockObjectAggregationResult>();
        builder.group(new GroupAggregation("string").withSum("integer", "integer"))
                .project(new ProjectAggregation().set("integer", "string"));
View Full Code Here

    }

    @Test
    public void testUnwindGroup() {

        MockObject mock = new MockObject("foo", 5);
        mock.simpleList = new ArrayList<String>();
        mock.simpleList.add("bar");
        mock.simpleList.add("baz");
        mock.simpleList.add("qux");
View Full Code Here

    }

    @Test
    public void testLimit() {

        coll.insert(new MockObject("foo", 1));
        coll.insert(new MockObject("bar", 1));
        coll.insert(new MockObject("baz", 1));
        coll.insert(new MockObject("qux", 1));

        AggregationBuilder<MockObjectAggregationResult> builder = new AggregationBuilder<MockObjectAggregationResult>();
        builder.group(new GroupAggregation("string"))
                .limit(new LimitAggregation(2));
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.