Package org.jongo.model

Examples of org.jongo.model.Friend


    public void canDropIndexes() {

        //given
        collection.ensureIndex("{name: 1}", "{unique: true}");
        collection.ensureIndex("{way: 1}", "{unique: true}");
        collection.save(new Friend("John", "way"));

        //when
        collection.dropIndexes();

        //then
        collection.save(new Friend("John", "way"));
    }
View Full Code Here


    public void canHandleObjectSerializedAsAPrimitive() throws Exception {

        Mapping mapping = new Mapping.Builder().addSerializer(Friend.class, new PrimitiveJsonSerializer()).build();
        factory = new BsonQueryFactory(new JacksonEngine(mapping));

        DBObject query = factory.createQuery("{bytes:#}", new Friend("Robert")).toDBObject();

        assertThat(query.get("bytes")).isEqualTo("Robert");
    }
View Full Code Here

    }

    @Test
    public void shouldBindASingleTokenAsParameter() throws Exception {

        Query query = factory.createQuery("#", new Friend("John"));

        assertThat(query.toDBObject()).isEqualTo(QueryBuilder.start("name").is("John").get());
    }
View Full Code Here

    private Friend friend;

    @Before
    public void setUp() throws Exception {
        collection = createEmptyCollection("friends");
        friend = new Friend("John", "22 Wall Street Avenue");
    }
View Full Code Here

    public void shouldIgnoreNullProjection() throws Exception {
        /* given */
        collection.save(friend);

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

        assertThat(friend.getName()).isEqualTo("John");
        assertThat(friend.getAddress()).isEqualTo("22 Wall Street Avenue");
    }
View Full Code Here

    private MongoCollection collection;

    @Before
    public void setUp() throws Exception {
        collection = createEmptyCollection("marshalling");
        collection.save(new Friend("robert", "Wall Street", new Coordinate(2, 3)));
    }
View Full Code Here

    }

    @Test
    public void canBindAPojo() throws Exception {

        long nb = collection.count("#", new Friend("robert", "Wall Street", new Coordinate(2, 3)));

        assertThat(nb).isEqualTo(1);
    }
View Full Code Here

    }

    @Test
    public void canBindEnum() throws Exception {

        Friend friend = new Friend("John", new Coordinate(2, 31));
        friend.setGender(Gender.FEMALE);
        collection.save(friend);

        Iterator<Friend> results = collection.find("{'gender':#}", Gender.FEMALE).as(Friend.class);

        assertThat(results.next().getGender()).isEqualTo(Gender.FEMALE);
View Full Code Here

    @Test
    // https://github.com/bguerout/jongo/issues/60
    public void canBindPattern() throws Exception {

        collection.save(new Friend("ab"));

        assertThat(collection.findOne("{name:#}", Pattern.compile("ab")).as(Friend.class)).isNotNull();
        assertThat(collection.findOne("{name:{$regex: 'ab'}}").as(Friend.class)).isNotNull();
    }
View Full Code Here

    @Test
    public void canBindTwoOidInSameQuery() throws Exception {
        /* given */
        ObjectId id1 = new ObjectId();
        Friend john = new Friend(id1, "John");
        ObjectId id2 = new ObjectId();
        Friend peter = new Friend(id2, "Peter");

        collection.save(john);
        collection.save(peter);

        MongoCursor<Friend> friends = collection.find("{$or :[{_id:{$oid:#}},{_id:{$oid:#}}]}", id1.toString(), id2.toString()).as(Friend.class);
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.