Package org.springframework.data.mongodb.core.query

Examples of org.springframework.data.mongodb.core.query.Query


    }

    @Test
    public void countAll(){

        expect(tagTemplate.count(new Query())).andReturn(2L);
        replay(tagTemplate);

        int result = repo.getCountAll();
        assertThat(result, is(equalTo(2)));
View Full Code Here


    }

    @Test
    public void getAll_null(){

        expect(tagTemplate.find(new Query())).andReturn(Lists.<Tag>newArrayList());
        replay(tagTemplate);

        List<Tag> result = repo.getAll();
        assertThat(result.size(), is(equalTo(0)));
View Full Code Here

        widgetRepository.delete(item);
    }

    private Query getQuery(String id) {
        return new Query(new Criteria().orOperator(where("subPages").elemMatch(where("regions").elemMatch(where("regionWidgets").elemMatch(where("_id").is(id)))),where("regions").elemMatch(where("regionWidgets").elemMatch(where("_id").is(id)))));
    }
View Full Code Here

    }

    @Test
    public void getCountAll_Valid(){
        long doubleOseven = 007;
        expect(template.count(new Query())).andReturn(doubleOseven);
        replay(template);
        assertThat((int)doubleOseven, is(sameInstance(userRepository.getCountAll())));
    }
View Full Code Here

    @Override
    public List<Person> findFriends(String username, String appId) {
        MongoDbUser user = (MongoDbUser) template.findOne(getUsernameQuery(username));
        Widget w = widgetOperations.findOne(query(where("url").is(appId)));
        Query q = query(where("ownerId").in(getFriendIds(user.getFriends())).and("regions").elemMatch(where("regionWidgets").elemMatch(where("widgetId").is(w.getId()))));
        List<Page> pages = pageTemplate.find(q);
        return getPersonListFromPages(pages);
    }
View Full Code Here

    @Test
    public void getByPageLayoutCode_Valid() {
        String codename = "codename";
        MongoDbPageLayout found = new MongoDbPageLayout();
        expect(template.findOne(new Query(where("code").is(codename)), MongoDbPageLayoutRepository.CLASS, CollectionNames.PAGE_LAYOUT_COLLECTION)).andReturn(found);
        replay(template);

        assertThat((MongoDbPageLayout) pageLayoutRepository.getByPageLayoutCode(codename), is(sameInstance(found)));
    }
View Full Code Here

    }

    @Test
    public void getAllUserSelectable_Valid() {
        List<MongoDbPageLayout> userSelectable = new ArrayList<MongoDbPageLayout>();
        expect(template.find(new Query(where("userSelectable").is(true)), pageLayoutRepository.CLASS, CollectionNames.PAGE_LAYOUT_COLLECTION)).andReturn(userSelectable);
        replay(template);

        List<PageLayout> returned = pageLayoutRepository.getAllUserSelectable();

        assertThat(returned, is(sameInstance(CollectionUtils.<PageLayout>toBaseTypedList(userSelectable))));
View Full Code Here

    @Test
    public void save_Valid() {
        PageLayout item1 = new MongoDbPageLayout();
        item1.setCode("blah1");
        expect(template.findOne(new Query(where("code").is(item1.getCode())), pageLayoutRepository.CLASS, CollectionNames.PAGE_LAYOUT_COLLECTION)).andReturn(null);
        template.save(isA(MongoDbPageLayout.class), eq(CollectionNames.PAGE_LAYOUT_COLLECTION));
        expectLastCall();
        replay(template);

        PageLayout saved = pageLayoutRepository.save(item1);
View Full Code Here

        item1.setCode("blah1");
        item1.setNumberOfRegions((long)123);
        item1.setRenderSequence((long)432);
        item1.setUserSelectable(true);
        MongoDbPageLayout toSave = new MongoDbPageLayout();
        expect(template.findOne(new Query(where("code").is(item1.getCode())), pageLayoutRepository.CLASS, CollectionNames.PAGE_LAYOUT_COLLECTION)).andReturn(toSave);
        template.save(isA(MongoDbPageLayout.class), eq(CollectionNames.PAGE_LAYOUT_COLLECTION));
        expectLastCall();
        replay(template);

        PageLayout saved = pageLayoutRepository.save(item1);
View Full Code Here

    @Test
    public void delete_Valid(){
        PageLayout item = new MongoDbPageLayout();
        item.setCode("123");
        expect(template.findOne(new Query(where("code").is(item.getCode())), pageLayoutRepository.CLASS, CollectionNames.PAGE_LAYOUT_COLLECTION)).andReturn((MongoDbPageLayout)item);

          template.remove(item);
        expectLastCall();
        replay(template);
View Full Code Here

TOP

Related Classes of org.springframework.data.mongodb.core.query.Query

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.