Package org.apache.rave.portal.model

Examples of org.apache.rave.portal.model.MongoDbCategory


        assertThat(converted, is(sameInstance(categoryRepository.save(item))));
    }

    @Test
    public void delete_Valid(){
        Category item = new MongoDbCategory();
        String id = "123";
        item.setId(id);
        MongoDbCategory hydrate = new MongoDbCategory();

        expect(template.findById(id, categoryRepository.CLASS, CollectionNames.CATEGORY_COLLECTION)).andReturn(hydrate);
        template.remove(hydrate, CollectionNames.CATEGORY_COLLECTION);
        expectLastCall();
        converter.hydrate(hydrate, Category.class);
View Full Code Here


        return Category.class;
    }

    @Override
    public MongoDbCategory convert(Category source) {
        MongoDbCategory category = new MongoDbCategory();
        category.setId(source.getId() == null ? generateId() : source.getId());
        category.setCreatedDate(source.getCreatedDate());
        category.setCreatedUserId(source.getCreatedUserId());
        category.setLastModifiedUserId(source.getLastModifiedUserId());
        category.setWidgetRepository(null);
        category.setText(source.getText());
        category.setWidgets(null);
        return category;
    }
View Full Code Here

    }

    @Test
    public void getAll_Valid(){
        List<MongoDbCategory> categoryList = new ArrayList<MongoDbCategory>();
        MongoDbCategory category = new MongoDbCategory();
        categoryList.add(category);
        expect(template.findAll(categoryRepository.CLASS, CollectionNames.CATEGORY_COLLECTION)).andReturn(categoryList);
        converter.hydrate(category, Category.class);
        expectLastCall();
        replay(template, converter);
View Full Code Here

    }

    @Test
    public void removeFromCreatedOrModifiedFields_Valid(){
        List<MongoDbCategory> categoryList = new ArrayList<MongoDbCategory>();
        MongoDbCategory category = new MongoDbCategory();
        categoryList.add(category);
        String userId = "123";
        category.setCreatedUserId(userId);
        category.setLastModifiedUserId(userId);
        MongoDbCategory converted = new MongoDbCategory();

        expect(template.find(query(Criteria.where("lastModifiedUserId").is(userId).orOperator(Criteria.where("createdUserId").is(userId))), categoryRepository.CLASS, CollectionNames.CATEGORY_COLLECTION)).andReturn(categoryList);
        expect(converter.convert(category, Category.class)).andReturn(converted);
        template.save(converted, CollectionNames.CATEGORY_COLLECTION);
        expectLastCall();
View Full Code Here

    }

    @Test
    public void removeFromCreatedOrModifiedFields_NotUpdated(){
        String userId = "54321";
        MongoDbCategory category = new MongoDbCategory();
        List<MongoDbCategory> categories = Arrays.asList(category);
        category.setCreatedUserId("234");
        category.setLastModifiedUserId("234");
        expect(template.find(query(Criteria.where("lastModifiedUserId").is(userId).orOperator(Criteria.where("createdUserId").is(userId))), categoryRepository.CLASS, CollectionNames.CATEGORY_COLLECTION)).andReturn(categories);
        replay(template);

        int count = categoryRepository.removeFromCreatedOrModifiedFields(userId);
        assertThat(count, is(equalTo(0)));
View Full Code Here

    }

    @Test
    public void get_Valid(){
        String id = "123";
        MongoDbCategory category = new MongoDbCategory();
        expect(template.findById(id, categoryRepository.CLASS, CollectionNames.CATEGORY_COLLECTION)).andReturn(category);
        converter.hydrate(category, Category.class);
        expectLastCall();
        replay(template, converter);
View Full Code Here

    }

    @Test
    public void save_Valid(){
        MongoDbCategory converted = new MongoDbCategory();
        Category item = new MongoDbCategory();

        expect(converter.convert(item, Category.class)).andReturn(converted);
        template.save(converted, CollectionNames.CATEGORY_COLLECTION);
        expectLastCall();
        converter.hydrate(converted, Category.class);
View Full Code Here

        assertThat(converted, is(sameInstance(categoryRepository.save(item))));
    }

    @Test
    public void delete_Valid(){
        Category item = new MongoDbCategory();
        String id = "123";
        item.setId(id);
        MongoDbCategory hydrate = new MongoDbCategory();

        expect(template.findById(id, categoryRepository.CLASS, CollectionNames.CATEGORY_COLLECTION)).andReturn(hydrate);
        template.remove(hydrate, CollectionNames.CATEGORY_COLLECTION);
        expectLastCall();
        converter.hydrate(hydrate, Category.class);
View Full Code Here

        return hydrate(template.findById(id, CLASS, CATEGORY_COLLECTION));
    }

    @Override
    public Category save(Category item) {
        MongoDbCategory converted = converter.convert(item, Category.class);
        template.save(converted, CATEGORY_COLLECTION);
        return hydrate(converted);
    }
View Full Code Here

TOP

Related Classes of org.apache.rave.portal.model.MongoDbCategory

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.