Package org.jongo.model

Examples of org.jongo.model.Friend


    }

    @Test
    public void distinctWithQuery() throws Exception {
        /* given */
        collection.save(new Friend("John", new Coordinate(1, 2)));
        collection.save(new Friend("Peter", new Coordinate(1, 2)));
        String emptyName = null;
        collection.save(new Friend(emptyName, new Coordinate(125, 72)));

        /* when */
        Iterator<Coordinate> coordinates = collection.distinct("coordinate").query("{name:{$exists:true}}").as(Coordinate.class).iterator();

        /* then */
 
View Full Code Here


    }

    @Test
    public void distinctWithParameterizedQuery() throws Exception {
        /* given */
        collection.save(new Friend("John", new Coordinate(1, 2)));
        collection.save(new Friend("Peter", new Coordinate(3, 4)));

        /* when */
        Iterator<Coordinate> coordinates = collection.distinct("coordinate").query("{name:#}", "Peter").as(Coordinate.class).iterator();

        /* then */
 
View Full Code Here

    }

    @Test
    public void canFind() throws Exception {
        /* given */
        Friend friend = new Friend(new ObjectId(), "John");
        collection.save(friend);

        /* when */
        Iterator<Friend> friends = collection.find("{name:'John'}").as(Friend.class);

View Full Code Here

    }

    @Test
    public void canFindAndCount() throws Exception {

        Friend friend = new Friend(new ObjectId(), "John");
        collection.save(friend);
        MongoCursor<Friend> friends = collection.find("{name:'John'}").as(Friend.class);

        int nbResults = friends.count();
View Full Code Here

    }

    @Test
    public void canFindUsingSubProperty() throws Exception {
        /* given */
        collection.save(new Friend("John", new Coordinate(2, 31)));

        /* when */
        Iterator<Friend> results = collection.find("{'coordinate.lat':2}").as(Friend.class).iterator();

        /* then */
 
View Full Code Here

    @Test
    public void canFindWithOid() throws Exception {
        /* given */
        ObjectId id = new ObjectId();
        Friend john = new Friend(id, "John");
        collection.save(john);

        Iterator<Friend> friends = collection.find("{_id:{$oid:#}}", id.toString()).as(Friend.class);

        /* then */
 
View Full Code Here

    }

    @Test
    public void canFindWithReadPreference() throws Exception {
        /* given */
        Friend friend = new Friend(new ObjectId(), "John");
        collection.save(friend);

        /* when */
        MongoCursor<Friend> friends = collection.withReadPreference(ReadPreference.primaryPreferred()).find("{name:'John'}").as(Friend.class);

View Full Code Here

        for (int i = 0; i < reps; i++) {

            DBObject dbo = decode(DefaultDBDecoder.FACTORY);
            DBObject coord = (DBObject) dbo.get("coordinate");
            Coordinate coordinate = new Coordinate((Integer) coord.get("lat"), (Integer) coord.get("lng"));
            Friend f = new Friend((String) dbo.get("name"), (String) dbo.get("address"), coordinate);
        }
    }
View Full Code Here

    public void timeDecodeWithBsonJongo(int reps) {

        for (int docIndex = 0; docIndex < reps; docIndex++) {
            DBObject dbo = decode(BsonDBDecoder.FACTORY);
            BsonDocument document = Bson.createDocument(dbo);
            Friend f = engine.unmarshall(document, Friend.class);
        }
    }
View Full Code Here

    }

    @Test
    public void canRemoveASpecificDocument() throws Exception {
        /* given */
        collection.save(new Friend("John"));
        collection.save(new Friend("Peter"));

        /* when */
        WriteResult writeResult = collection.remove("{name:'John'}");

        /* then */
 
View Full Code Here

TOP

Related Classes of org.jongo.model.Friend

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.