Package org.mongojack.mock

Examples of org.mongojack.mock.MockObject


    }
   
    @Test
    public void testMatchUnaryComparison() {

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

        AggregationBuilder<MockObjectAggregationResult> builder = new AggregationBuilder<MockObjectAggregationResult>();
        builder.match(new MatchAggregation().greaterThan("integer", 2));

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


    }
   
    @Test
    public void testMatchIn() {

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

        AggregationBuilder<MockObjectAggregationResult> builder = new AggregationBuilder<MockObjectAggregationResult>();
        builder.match(new MatchAggregation().in("string", "foo", "baz"));

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

        Assert.assertEquals(0, result.results().size());
    }

    @Test
    public void testAggregateSingleOpItemsInCollection() {
        coll.insert(new MockObject("string1", 1));
        coll.insert(new MockObject("string2", 2));
        AggregationResult<MockObject> result =
                coll.aggregate(new Aggregation<MockObject>(MockObject.class,
                        new BasicDBObject("$match", new BasicDBObject("string", Pattern.compile(".*")))));
        Assert.assertEquals(2, result.results().size());
    }
View Full Code Here

        Assert.assertEquals(2, result.results().size());
    }

    @Test
    public void testAggregateMultipleOpsItemsInCollection() {
        coll.insert(new MockObject("string1", 1));
        coll.insert(new MockObject("string2", 2));
        AggregationResult<MockObject> result =
                coll.aggregate(new Aggregation<MockObject>(MockObject.class,
                        new BasicDBObject("$match", new BasicDBObject("string", Pattern.compile("string1")))));
        Assert.assertEquals(1, result.results().size());
        Assert.assertEquals(1, result.results().get(0).integer.intValue());
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    @Test
    public void testAggregateAugmentedFieldSetReturnedInDifferentObject() {
        coll.insert(new MockObject("string4", 4));
        coll.insert(new MockObject("string3", 3));
        coll.insert(new MockObject("string2", 2));
        coll.insert(new MockObject("string1", 1));
        coll.insert(new MockObject("string0", 0));
        coll.insert(new MockObject("string-1", -1));
        coll.insert(new MockObject("string-2", -2));
        coll.insert(new MockObject("string-3", -3));
        coll.insert(new MockObject("string-4", -4));

        // build the steps in our aggregation pipeline

        // get the difference between 0 and the document's integer value
        // {$project : { string :1, integer : 1, distance : {$subtract : [0, "$integer"]}}}
View Full Code Here

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

    @Test
    public void testInsertNoId() {
        MockObject object = new MockObject();
        coll.insert(object);
        assertNotNull(coll.findOne()._id);
    }
View Full Code Here

        assertNotNull(coll.findOne()._id);
    }

    @Test
    public void testInsertRetrieveAllEmpty() {
        MockObject object = new MockObject();
        object._id = "1";
        coll.insert(object);
        MockObject result = coll.findOne();
        assertEquals(object, result);
    }
View Full Code Here

        assertEquals(object, result);
    }

    @Test
    public void testInsertRetrieveString() {
        MockObject object = new MockObject();
        object.string = "a string";
        coll.insert(object);
        MockObject result = coll.findOne();
        assertEquals(object.string, result.string);
    }
View Full Code Here

        assertEquals(object.string, result.string);
    }

    @Test
    public void testInsertRetrieveInteger() {
        MockObject object = new MockObject();
        object.integer = 10;
        coll.insert(object);
        MockObject result = coll.findOne();
        assertEquals(object.integer, result.integer);
    }
View Full Code Here

        assertEquals(object.integer, result.integer);
    }

    @Test
    public void testInsertRetrieveLong() {
        MockObject object = new MockObject();
        object.longs = 10L;
        coll.insert(object);
        MockObject result = coll.findOne();
        assertEquals(object.longs, result.longs);
    }
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.