Package org.apache.rave.portal.model

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


        controller.setPreferenceService(preferenceService);
        categoryService = createMock(CategoryService.class);
        controller.setCategoryService(categoryService);

        categories = new ArrayList<Category>();
        categories.add(new Category());
        categories.add(new Category());

        webDataBinder = createMock(WebDataBinder.class);
        categoryEditor = new CategoryEditor(categoryService);
        controller.setCategoryEditor(categoryEditor);
    }
View Full Code Here


        int offset = 0;
        int pageSize = 10;
        String categoryText = "Social";
        Widget w = new Widget();
        List<Category> categories = new ArrayList<Category>();
        Category c = new Category();
        List<Widget> widgets = new ArrayList<Widget>();
        widgets.add(w);
        c.setWidgets(widgets);
        c.setEntityId(id);
        c.setText(categoryText);
        categories.add(c);
        w.setCategories(categories);
        expect(categoryRepository.get(id)).andReturn(c);
        replay(categoryRepository);
        SearchResult<Widget> result = widgetService.getWidgetsByCategory(id,offset,pageSize);
        verify(categoryRepository);
        assertEquals("number of widgets", 1, result.getTotalResults());
        assertSame(w, result.getResultSet().get(0));
        assertEquals(c.getEntityId(), result.getResultSet().get(0).getCategories().get(0).getEntityId());
    }
View Full Code Here

    }

    @Override
    @Transactional
    public Category create(String text, User createdUser) {
        Category category = new CategoryImpl();
        Date now = new Date();
        category.setText(text);
        category.setCreatedDate(now);
        category.setCreatedUser(createdUser);
        category.setLastModifiedDate(now);
        category.setLastModifiedUser(createdUser);
        categoryRepository.save(category);
        return category;
    }
View Full Code Here

    }

    @Override
    @Transactional
    public Category update(long categoryId, String text, User lastModifiedUser) {
        Category category = categoryRepository.get(categoryId);
        category.setText(text);
        category.setLastModifiedDate(new Date());
        category.setLastModifiedUser(lastModifiedUser);
        categoryRepository.save(category);
        return category;
    }
View Full Code Here

    }

    @Override
    @Transactional
    public void delete(Category category) {
        Category categoryToBeDeleted = categoryRepository.get(category.getId());
        categoryRepository.delete(categoryToBeDeleted);
    }
View Full Code Here

        setValue(categoryService.get(Long.parseLong(text)));
    }

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

    }

    // returns a trusted Category object, either from the CategoryRepository, or the
    // cached container list
    private Category getTrustedCategory(long categoryId, List<Category> trustedCategoryContainer) {
        Category p = null;
        if (trustedCategoryContainer.isEmpty()) {
            p = categoryRepository.get(categoryId);
            trustedCategoryContainer.add(p);
        } else {
            p = trustedCategoryContainer.get(0);
View Full Code Here

    // checks to see if the Authentication object principal is the owner of the supplied category object
    // if trustedDomainObject is false, pull the entity from the database first to ensure
    // the model object is trusted and hasn't been modified
    private boolean isCategoryCreatedUser(Authentication authentication, Category category, List<Category> trustedCategoryContainer, boolean trustedDomainObject) {
        Category trustedCategory = null;
        if (trustedDomainObject) {
            trustedCategory = category;
        } else {
            trustedCategory = getTrustedCategory(category.getId(), trustedCategoryContainer);
        }

        return isCategoryCreatedUserByUsername(authentication, trustedCategory.getCreatedUser().getUsername());
    }
View Full Code Here

        int offset = 0;
        int pageSize = 10;
        String categoryText = "Social";
        Widget w = new WidgetImpl();
        List<Category> categories = new ArrayList<Category>();
        Category c = new CategoryImpl();
        List<Widget> widgets = new ArrayList<Widget>();
        widgets.add(w);
        c.setWidgets(widgets);
        c.setId(id);
        c.setText(categoryText);
        categories.add(c);
        w.setCategories(categories);
        expect(categoryRepository.get(id)).andReturn(c);
        replay(categoryRepository);
        SearchResult<Widget> result = widgetService.getWidgetsByCategory(id,offset,pageSize);
        verify(categoryRepository);
        assertEquals("number of widgets", 1, result.getTotalResults());
        assertSame(w, result.getResultSet().get(0));
        assertEquals(c.getId(), result.getResultSet().get(0).getCategories().get(0).getId());
    }
View Full Code Here

    }

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

        expect(repository.save(expectedCategory)).andReturn(expectedCategory);
        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.getCreatedUser(), is(validCreatedUser));
        assertThat(wc.getLastModifiedUser(), is(validCreatedUser));

        verify(repository);
    }
View Full Code Here

TOP

Related Classes of org.apache.rave.portal.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.