Package org.jongo.model

Examples of org.jongo.model.Friend


    }

    @Test
    public void canAddSerializer() throws Exception {

        Friend robert = new Friend("Robert");
        Mapper mapper = new JacksonMapper.Builder()
                .addSerializer(String.class, new DoeJsonSerializer())
                .build();

        BsonDocument document = mapper.getMarshaller().marshall(robert);
View Full Code Here


    @Test
    public void canAddModule() throws Exception {

        ObjectId oid = new ObjectId("504482e5e4b0d1b2c47fff66");
        Friend friend = new Friend(oid, "Robert");
        Mapper mapper = new JacksonMapper.Builder()
                .registerModule(new Module() {
                    @Override
                    public String getModuleName() {
                        return "test-module";
View Full Code Here

    }

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

        /* when */
        Friend friend = collection.findOne("{name:'John'}").as(Friend.class);

        /* then */
        assertThat(friend.getName()).isEqualTo("John");
    }
View Full Code Here

    }

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

        /* when */
        Friend friend = collection.findOne().as(Friend.class);

        /* then */
        assertThat(friend.getName()).isEqualTo("John");
    }
View Full Code Here

    }

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

        Friend foundFriend = collection.findOne(john.getId()).as(Friend.class);

        /* then */
        assertThat(foundFriend).isNotNull();
        assertThat(foundFriend.getId()).isEqualTo(john.getId());
    }
View Full Code Here

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

        Friend foundFriend = collection.findOne("{_id:#}", id).as(Friend.class);

        /* then */
        assertThat(foundFriend).isNotNull();
        assertThat(foundFriend.getId()).isEqualTo(id);
    }
View Full Code Here

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

        Friend foundFriend = collection.findOne("{_id:{$oid:#}}", id.toString()).as(Friend.class);

        /* then */
        assertThat(foundFriend).isNotNull();
        assertThat(foundFriend.getId()).isEqualTo(id);
    }
View Full Code Here

    }

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

        /* when */
        Friend friend = collection.withReadPreference(ReadPreference.primaryPreferred()).findOne("{name:'John'}").as(Friend.class);

        /* then */
        assertThat(friend.getName()).isEqualTo("John");

        // warning: we cannot check that ReadPreference is really used by driver, this unit test only checks the API
    }
View Full Code Here

    }

    @Test
    public void canOrderBy() throws Exception {

        collection.save(new Friend("John", "23 Wall Street Av."));
        collection.save(new Friend("John", "21 Wall Street Av."));
        collection.save(new Friend("John", "22 Wall Street Av."));

        Friend friend = collection.findOne().orderBy("{address:1}").as(Friend.class);

        assertThat(friend.getAddress()).isEqualTo("21 Wall Street Av.");
    }
View Full Code Here

    }

    @Test
    public void canInsertPojo() throws Exception {

        Friend friend = new Friend("John");

        collection.insert(friend);

        Friend result = collection.findOne("{name:'John'}").as(Friend.class);
        assertThat(result.getName()).isEqualTo("John");
    }
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.