Package org.apache.rave.model

Examples of org.apache.rave.model.Category


    @Test
    @Transactional(readOnly=false)
    @Rollback(true)
    public void delete_jpaObject() {
        Category category = repository.get(VALID_ENTITY_ID.toString());
        assertThat(category, is(notNullValue()));
        repository.delete(category);
        category = repository.get(VALID_ENTITY_ID.toString());
        assertThat(category, is(nullValue()));
    }
View Full Code Here


    @Test
    @Transactional(readOnly=false)
    @Rollback(true)
    public void delete_implObject() {
        Category category = repository.get(VALID_ENTITY_ID.toString());
        assertThat(category, is(notNullValue()));
        CategoryImpl impl = new CategoryImpl(category.getId());
        repository.delete(impl);
        category = repository.get(VALID_ENTITY_ID.toString());
        assertThat(category, is(nullValue()));
    }
View Full Code Here

        setValue(categoryService.get(text));
    }

    @Override
    public String getAsText() {
        Category category = (Category)getValue();
        return (category == null) ? null : category.getId().toString();
    }
View Full Code Here

    @Test
    public void create() {
        final String NEW_CATEGORY_TEXT = "new category";
        final String NEW_ID = "1";
        Category expectedCategory = new CategoryImpl();
        expectedCategory.setText(NEW_CATEGORY_TEXT);

        expect(repository.save(expectedCategory)).andDelegateTo(new MockCategoryRepository() {
            @Override
            public Category save(Category item) {
                item.setId(NEW_ID);
                return item;
            }
        });
        replay(repository);

        Category wc = service.create(NEW_CATEGORY_TEXT, validCreatedUser);
        assertThat(wc.getText(), is(NEW_CATEGORY_TEXT));
        assertThat(wc.getCreatedDate(), is(notNullValue(Date.class)));
        assertThat(wc.getCreatedDate(), is(wc.getLastModifiedDate()));
        assertThat(wc.getCreatedUserId(), is(VALID_CREATED_USER_ID));
        assertThat(wc.getLastModifiedUserId(), is(VALID_CREATED_USER_ID));
        assertThat(wc.getId(), is(NEW_ID));

        verify(repository);
    }
View Full Code Here

    @Test
    public void update() {
        final String UPDATED_TEXT = "modified category";

        Category expectedSaveCategory = new CategoryImpl();
        expectedSaveCategory.setId(VALID_ID);
        expectedSaveCategory.setText(UPDATED_TEXT);
        expectedSaveCategory.setCreatedUserId(VALID_CREATED_USER_ID);
        expectedSaveCategory.setLastModifiedUserId(VALID_LAST_MODIFIED_USER_ID);
        expectedSaveCategory.setCreatedDate(VALID_CREATED_DATE);
        expectedSaveCategory.setLastModifiedDate(VALID_LAST_MODIFIED_DATE);

        expect(repository.get(VALID_ID)).andReturn(validCategory);
        expect(repository.save(expectedSaveCategory)).andReturn(expectedSaveCategory);
        replay(repository);

        Category updatedCategory = service.update(VALID_ID, UPDATED_TEXT, validLastModifiedUser);
        assertThat(updatedCategory.getId(), is(VALID_ID));
        assertThat(updatedCategory.getText(), is(UPDATED_TEXT));
        assertThat(updatedCategory.getCreatedUserId(), is(VALID_CREATED_USER_ID));
        assertThat(updatedCategory.getLastModifiedUserId(), is(VALID_LAST_MODIFIED_USER_ID));
        assertThat(updatedCategory.getLastModifiedDate().after(updatedCategory.getCreatedDate()), is(true));

        verify(repository);
    }
View Full Code Here

            categoryIds = Lists.newArrayList();
        }
    }

    private void addCategory(List<Category> categories, String id) {
        Category category = categoryRepository.get(id);
        if(category != null) {
            categories.add(category);
        }
    }
View Full Code Here

    }


    @Test
    public void convert_valid(){
        Category c = new CategoryImpl();
        c.setCreatedDate(DATE1);
        c.setCreatedUserId(USER1ID);
        c.setId(USER1ID);
        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

    }//end convert_valid

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

        MongoDbCategory converted = converter.convert(source);

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

    @Test
    public void getCategories_Valid(){
        List<String> categoryIds = Arrays.asList(ID_1, ID_2);
        expect(categoryRepository.get(ID_1)).andReturn(null);
        Category category = new CategoryImpl();
        expect(categoryRepository.get(ID_2)).andReturn(category);
        replay(categoryRepository);
        widget.setCategoryIds(categoryIds);
        List<Category> result = widget.getCategories();
        assertNotNull(result);
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.model.Category

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.