Package org.jongo.model

Examples of org.jongo.model.Friend


        assertThat(writeResult.getLastConcern()).isEqualTo(WriteConcern.SAFE);
    }

    @Test
    public void canPartiallyUdpateWithAPreexistingDocument() throws Exception {
        Friend friend = new Friend("John", "123 Wall Street");
        collection.save(friend);
        Friend preexistingDocument = new Friend(friend.getId(), "Johnny");

        collection.update("{name:'John'}").with(preexistingDocument);

        Friend johnny = collection.findOne("{name:'Johnny'}}").as(Friend.class);
        assertThat(johnny).isNotNull();
        assertThat(johnny.getName()).isEqualTo("Johnny");
        assertThat(johnny.getAddress()).isEqualTo("123 Wall Street");
    }
View Full Code Here


        assertThat(johnny.getAddress()).isEqualTo("123 Wall Street");
    }

    @Test
    public void canPartiallyUdpateWithaNewDocument() throws Exception {
        Friend friend = new Friend("John", "123 Wall Street");
        collection.save(friend);
        Friend newDocument = new Friend("Johnny");

        collection.update("{name:'John'}").with(newDocument);

        Friend johnny = collection.findOne("{name:'Johnny'}}").as(Friend.class);
        assertThat(johnny).isNotNull();
        assertThat(johnny.getName()).isEqualTo("Johnny");
        assertThat(johnny.getAddress()).isEqualTo("123 Wall Street");
    }
View Full Code Here

    }

    @Test
    public void canReplaceAllFields() throws Exception {

        Friend friend = new Friend("Peter", "31 rue des Lilas");
        collection.save(friend);

        collection.update(friend.getId()).with("#", new Friend("John"));

        Map map = collection.findOne().as(Map.class);
        assertThat(map.get("name")).isEqualTo("John");
        assertThat(map).doesNotContainKey("address");
    }
View Full Code Here

    public void tearDown() throws Exception {
        dropCollection("friends");
    }

    public Friend newFriend() {
        return new Friend("John", "22 Wall Street Avenue");
    }
View Full Code Here

    @Test
    public void canCountWithParameters() throws Exception {
        /* given */
        collection.save(newFriend());
        collection.save(new Friend("Peter", "22 Wall Street Avenue"));

        /* then */
        assertThat(collection.count("{name:#}", "Peter")).isEqualTo(1);
    }
View Full Code Here

    }

    @Test
    public void canFindWithHint() throws Exception {
        /* given */
        Friend noName = new Friend(new ObjectId(), null);
        collection.save(noName);

        collection.ensureIndex("{name: 1}", "{sparse: true}");

        /* when */
 
View Full Code Here

    }

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

        /* when */
        Iterator<Friend> friends = collection.find()
                .with(new QueryModifier() {
                    public void modify(DBCursor cursor) {
View Full Code Here

    @Test
    public void canHandleIterableWithComplexType() throws Exception {

        BSONPrimitiveType type = new BSONPrimitiveType();
        List<Friend> friends = new ArrayList<Friend>();
        Friend robert = new Friend("robert");
        friends.add(robert);
        type.complexList = friends;

        collection.save(type);
View Full Code Here

    @Test
    public void canUnmarshallBson() throws IOException {

        BsonDocument document = bsonify("{'address': '22 rue des murlins'}");

        Friend friend = engine.unmarshall(document, Friend.class);

        assertThat(friend.getAddress()).isEqualTo("22 rue des murlins");
    }
View Full Code Here

        BsonDocument document = Bson.createDocument(new BasicDBObject("name", "robert"));
        Mapper mapper = new JacksonMapper.Builder()
                .addDeserializer(String.class, new DoeJsonDeserializer())
                .build();

        Friend friend = mapper.getUnmarshaller().unmarshall(document, Friend.class);

        assertThat(friend.getName()).isEqualTo("Doe");
    }
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.