Package org.apache.rave.portal.model

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


    public void deleteCategory_invalidValidRequest_falseConfirmation(){
        Model model = new ExtendedModelMap();
        User user = new User();
        long id = 1L;
        String categoryText = "Social";
        Category category = new Category();
        category.setCreatedUser(user);
        category.setText(categoryText);
        category.setEntityId(id);
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        expect(userService.getAuthenticatedUser()).andReturn(user).once();
        replay(userService);
        String view = controller.deleteCategory(category, validToken, validToken,"false", model, sessionStatus);
        assertEquals("ViewName match", ViewNames.ADMIN_CATEGORY_DETAIL, view);
View Full Code Here


    public void editCategory_valid () {
        User user = new User();
        long id = 1L;
        String categoryText = "Social";
        Model model = new ExtendedModelMap();
        Category category = new Category();
        category.setCreatedUser(user);
        category.setText(categoryText);
        category.setEntityId(id);
        expect(categoryService.get(id)).andReturn(category).once();
        replay(categoryService);
        String view = controller.editCategory(id, model);
        assertEquals("ViewName match", ViewNames.ADMIN_CATEGORY_DETAIL, view);
        assertFalse("model is not empty", model.asMap().isEmpty());
View Full Code Here

    @Before
    public void setUp() {
        categoryService = createMock(CategoryService.class);
        categoryEditor = new CategoryEditor(categoryService);

        validCategory = new Category();
        validCategory.setEntityId(CATEGORY_ID);
        validCategory.setText(CATEGORY_TEXT);
    }
View Full Code Here

        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

    }      
   
    // 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.getEntityId(), trustedCategoryContainer);
        }

        return isCategoryCreatedUserByUsername(authentication, trustedCategory.getCreatedUser().getUsername());
    }
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

        service = new DefaultCategoryService(repository);

        validCreatedUser = new User(VALID_CREATED_USER_ID);
        validLastModifiedUser = new User(VALID_LAST_MODIFIED_USER_ID);
       
        validCategory = new Category();
        validCategory.setEntityId(VALID_ID);
        validCategory.setText(VALID_TEXT);
        validCategory.setCreatedUser(validCreatedUser);
        validCategory.setCreatedDate(VALID_CREATED_DATE);
        validCategory.setLastModifiedUser(validLastModifiedUser);
View Full Code Here

    @Test
    public void getAll() {
        List<Category> list = new ArrayList<Category>();
        list.add(validCategory);
        list.add(new Category());
        list.add(new Category());

        expect(repository.getAll()).andReturn(list);
        replay(repository);
        assertThat(service.getAll(), is(list));
        verify(repository);       
View Full Code Here

    }

    @Test
    public void create() {
        final String NEW_CATEGORY_TEXT = "new category";
        Category expectedCategory = new Category();
        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.