Examples of MongoDbCategory


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

        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

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

        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

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

    }


    @Test
    public void hydrate_valid(){
        MongoDbCategory category = new MongoDbCategory();

        converter.hydrate(category);

        assertThat(category.getWidgetRepository(),is(sameInstance(mongoWidgetOperations)));

    }
View Full Code Here

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

        c.setLastModifiedUserId(USER2ID);
        c.setText("asdf");
        c.setWidgets(Lists.<Widget>newArrayList());
        c.setLastModifiedDate(DATE2);

        MongoDbCategory mongoC = converter.convert(c);
        assertThat(mongoC.getCreatedDate(), is(equalTo(DATE1)));
        assertThat(mongoC.getCreatedUserId(), is(equalTo(USER1ID)));
        assertThat(mongoC.getId(), is(equalTo(USER1ID)));
        assertThat(mongoC.getLastModifiedUserId(), is(equalTo(USER2ID)));
        assertThat(mongoC.getWidgetRepository(), is(nullValue()));
        assertThat(mongoC.getText(), is("asdf"));
        assertThat(c.getWidgets().size(), is(0));

    }//end convert_valid
View Full Code Here

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

    @Test
    public void convert_Null(){
        Category source = new CategoryImpl();

        MongoDbCategory converted = converter.convert(source);

        assertNull(converted.getLastModifiedUserId());
        assertNull(converted.getCreatedUserId());
        assertNotNull(converted.getId());
    }
View Full Code Here

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

    }

    @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

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

    }

    @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

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

    }

    @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

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

    }

    @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

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

    }

    @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
TOP
Copyright © 2018 www.massapi.com. 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.