Package org.mongolink.domain.criteria

Examples of org.mongolink.domain.criteria.Criteria


    }

    @Test
    public void returnSameInstanceOnGetByCriteria() {
        final String id = createFakeAggregate("plop");
        final Criteria criteria = session.createCriteria(FakeAggregate.class);

        final FakeAggregate instanceById = session.get(id, FakeAggregate.class);
        final FakeAggregate instanceByCriteria = (FakeAggregate) criteria.list().get(0);

        assertThat(instanceById, sameInstance(instanceByCriteria));
    }
View Full Code Here


    @Override
    public <U> Criteria createCriteria(Class<U> type) {
        checkNotNull(type, "Type was null");
        AggregateMapper<?> mapper = entityMapper(type);
        Criteria criteria = criteriaFactory.create(createExecutor(mapper));
        mapper.applyRestrictionsFor(type, criteria);
        return criteria;
    }
View Full Code Here

    }

    @Test
    public void canPopulateRestrictionForAllSubtypes() {
        AggregateMapper<FakeAggregate> mapper = (AggregateMapper<FakeAggregate>) context.mapperFor(FakeAggregate.class);
        Criteria criteria = new Criteria(mock(QueryExecutor.class));

        mapper.applyRestrictionsFor(FakeAggregate.class, criteria);

        DBObject query = criteria.createQuery();
        assertThat(query.get("$or"), notNullValue());
        BasicDBList or = (BasicDBList) query.get("$or");
        assertThat(or.size(), is(2));
    }
View Full Code Here

    }

    @Test
    public void canPopulateRestrictionForAGivenSubtype() {
        AggregateMapper<FakeAggregate> mapper = (AggregateMapper<FakeAggregate>) context.mapperFor(FakeAggregate.class);
        Criteria criteria = new Criteria(mock(QueryExecutor.class));

        mapper.applyRestrictionsFor(FakeChildAggregate.class, criteria);

        DBObject query = criteria.createQuery();
        assertThat(query.get("$or"), notNullValue());
        BasicDBList or = (BasicDBList) query.get("$or");
        assertThat(or.size(), is(1));
    }
View Full Code Here

TOP

Related Classes of org.mongolink.domain.criteria.Criteria

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.