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 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

    }


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

        converter.hydrate(category);

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

    }
View Full Code Here

        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

    @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

    }

    @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

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.