Package org.jongo.model

Examples of org.jongo.model.Friend


    @Test
    public void canBindAHashIntoParameter() throws Exception {

        collection.insert("{name:#}", "test val#1");

        Friend friend = collection.findOne("{name:#}", "test val#1").as(Friend.class);

        assertThat(friend).isNotNull();
        assertThat(friend.getName()).isEqualTo("test val#1");
    }
View Full Code Here


    @Test
    // https://groups.google.com/forum/?hl=fr&fromgroups#!topic/jongo-user/ga3n5_ybYm4
    public void canUseParameterWith$push() throws Exception {

        Buddies buddies = new Buddies();
        buddies.add(new Friend("john"));
        collection.save(buddies);

        collection.update("{}").with("{$push:{friends:#}}", new Friend("peter"));

        assertThat(collection.count("{ friends.name : 'peter'}")).isEqualTo(1);
    }
View Full Code Here

    @Test
    public void canUseListOfPojosParameterWith$or() throws Exception {
        collection.insert("{name:'John'}");
        collection.insert("{name:'Robert'}");
        List<Friend> friends = Lists.newArrayList(new Friend("John"), new Friend("Robert"));

        Iterator<Friend> results = collection.find("{$or : #}", friends).as(Friend.class);

        assertThat(results.hasNext()).isTrue();
    }
View Full Code Here

    }

    @Test
    public void canUseListOfPojosParameterWith$and() throws Exception {
        collection.insert("{ name: ['John', 'Robert' ] }");
        List<Friend> friends = Lists.newArrayList(new Friend("John"), new Friend("Robert"));

        Iterator<Friend> results = collection.find("{ $and: # }", friends).as(Friend.class);

        assertThat(results.hasNext()).isTrue();
    }
View Full Code Here

    @Test
    public void canHandleMapWithComplexType() throws Exception {

        Map<String, Friend> friends = new HashMap<String, Friend>();
        Friend robert = new Friend("robert");
        friends.put("key", robert);
        BSONPrimitiveType type = new BSONPrimitiveType();
        type.friends = friends;

        collection.save(type);
View Full Code Here

    ObjectIdUpdater objectIdUpdater = mock(ObjectIdUpdater.class);

    @Test
    public void shouldPreventLazyDBObjectToBeDeserialized() throws Exception {

        Friend friend = new Friend(ObjectId.get(), "John");
        ObjectId deserializedOid = ObjectId.get();
        when(objectIdUpdater.getId(friend)).thenReturn(deserializedOid);
        Insert insert = new Insert(mockedDBCollection, WriteConcern.NONE, getMapper().getMarshaller(), objectIdUpdater, getMapper().getQueryFactory());

        insert.save(friend);
View Full Code Here

    @Test
    public void shouldNotPreventLazyDBObjectToBeDeserializedWhenOidIsNull() throws Exception {

        ObjectId id = ObjectId.get();
        Friend friend = new Friend(id, "John");
        when(objectIdUpdater.getId(friend)).thenReturn(null);
        Insert insert = new Insert(mockedDBCollection, WriteConcern.NONE, getMapper().getMarshaller(), objectIdUpdater, getMapper().getQueryFactory());

        insert.save(friend);
View Full Code Here

    }

    @Test
    public void distinctOnStringEntities() throws Exception {
        /* given */
        collection.save(new Friend("John", wallStreetAvenue));
        collection.save(new Friend("Smith", wallStreetAvenue));
        collection.save(new Friend("Peter", "24 Wall Street Avenue"));

        /* when */
        Iterator<String> addresses = collection.distinct("address").as(String.class).iterator();

        /* then */
 
View Full Code Here

    }

    @Test
    public void distinctOnIntegerEntities() throws Exception {
        /* given */
        collection.save(new Friend("John", new Coordinate(1, 2)));
        collection.save(new Friend("Peter", new Coordinate(1, 2)));
        collection.save(new Friend("Paul", new Coordinate(125, 72)));

        /* when */
        Iterator<Integer> addresses = collection.distinct("coordinate.lat").as(Integer.class).iterator();

        /* then */
 
View Full Code Here

    }

    @Test
    public void distinctOnTypedProperty() throws Exception {
        /* given */
        collection.save(new Friend("John", new Coordinate(1, 2)));
        collection.save(new Friend("Peter", new Coordinate(1, 2)));
        collection.save(new Friend("Paul", new Coordinate(125, 72)));

        /* when */
        Iterator<Coordinate> coordinates = collection.distinct("coordinate").as(Coordinate.class).iterator();

        /* 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.