Package org.mongolink.test.entity

Examples of org.mongolink.test.entity.FakeAggregate


            element.put("value", i);
            collection.save(element);
        }
        final AggregateMapper aggregateMapper = mock(AggregateMapper.class);
        when(aggregateMapper.collectionName()).thenReturn("collection");
        when(aggregateMapper.toInstance(Matchers.<DBObject>any())).thenReturn(new FakeAggregate("gfg"));
        return new QueryExecutor<FakeAggregate>(db, aggregateMapper, new UnitOfWork(mock(MongoSessionImpl.class)));
    }
View Full Code Here


        BasicDBObject dbo = new BasicDBObject();
        dbo.put("_id", "1");
        dbo.put("__discriminator", "FakeChildAggregate");
        entities().insert(dbo);

        FakeAggregate entity = session.get("1", FakeAggregate.class);

        assertThat(entity).isNotNull();
        assertThat(entity).isInstanceOf(FakeChildAggregate.class);
    }
View Full Code Here

        BasicDBObject dbo = new BasicDBObject();
        dbo.put("_id", "1");
        dbo.put("__discriminator", "FakeChildAggregate");
        entities().insert(dbo);

        FakeAggregate entity = session.get("1", FakeChildAggregate.class);

        assertThat(entity).isNotNull();

    }
View Full Code Here

    }

    @Test
    public void canSerializeToDBOject() throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
        final BasicDBObject into = new BasicDBObject();
        FakeAggregate entity = new FakeAggregate("te");
        final Comment comment = new Comment("tes");
        entity.setComment(comment);

        propertyMapperForComponent().save(entity, into);

        final BasicDBObject commentDB = (BasicDBObject) into.get("comment");
        assertThat(commentDB, notNullValue());
View Full Code Here

    public void canPopulate() throws NoSuchMethodException {
        final BasicDBObject from = new BasicDBObject();
        final BasicDBObject val = new BasicDBObject();
        val.put("value", "valeur");
        from.put("comment", val);
        FakeAggregate instance = new FakeAggregate("kjklj");

        propertyMapperForComponent().populate(instance, from);

        assertThat(instance.getComment().getValue(), Matchers.is("valeur"));
    }
View Full Code Here

    }


    @Test
    public void canCreateFromField() throws NoSuchFieldException {
        FakeAggregate entity = new FakeAggregate("value");
        BasicDBObject dbObject = new BasicDBObject();

        propertyMapperFromField().save(entity, dbObject);

        assertThat(dbObject.getString("value"), Matchers.is("value"));
View Full Code Here

        dbo.put("_id", "good id");
        dbo.put("value", "this is a value");
        dbo.put("childName", "this is a name");
        dbo.put("__discriminator", "FakeChildAggregate");

        FakeAggregate entity = context.mapperFor(FakeAggregate.class).toInstance(dbo);

        assertThat(entity, instanceOf(FakeChildAggregate.class));
    }
View Full Code Here

TOP

Related Classes of org.mongolink.test.entity.FakeAggregate

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.