Package org.apache.rave.portal.model

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


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

        Category expectedSaveCategory = new Category();
        expectedSaveCategory.setEntityId(VALID_ID);
        expectedSaveCategory.setText(UPDATED_TEXT);
        expectedSaveCategory.setCreatedUser(validCreatedUser);
        expectedSaveCategory.setLastModifiedUser(validLastModifiedUser);
        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.getEntityId(), is(VALID_ID));
        assertThat(updatedCategory.getText(), is(UPDATED_TEXT));
        assertThat(updatedCategory.getCreatedUser(), is(validCreatedUser));
        assertThat(updatedCategory.getLastModifiedUser(), is(validLastModifiedUser));
        assertThat(updatedCategory.getLastModifiedDate().after(updatedCategory.getCreatedDate()), is(true));

        verify(repository);
    }
View Full Code Here


    }

    @Override
    @Transactional
    public Category create(String text, User createdUser) {
        Category category = new Category();
        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.getEntityId());
        categoryRepository.delete(categoryToBeDeleted);
    }
View Full Code Here

    @Test
    public void save_duplicateText_exception() {
        Date now = new Date();
        User user = new User(1L);
       
        Category wc = new Category();
        wc.setText(DUPLICATE_TEXT_VALUE);
        wc.setCreatedDate(now);
        wc.setCreatedUser(user);
        wc.setLastModifiedDate(now);
        wc.setLastModifiedUser(user);

        boolean gotExpectedException = false;
        try {
            repository.save(wc);
            manager.flush();
View Full Code Here

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

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

        List<Category> categories = categoryService.getAll();

        model.addAttribute("categories", categories);
        // put category object in the model to allow creating categories from view
        model.addAttribute(ModelKeys.CATEGORY, new Category());
        // add tokencheck attribute for creating new category
        model.addAttribute(ModelKeys.TOKENCHECK, AdminControllerUtil.generateSessionToken());

        if (isCreateDeleteOrUpdate(action)) {
            model.addAttribute("actionresult", action);
View Full Code Here

    public void deleteCategory_invalidValidRequest_nullWidgetToDelete(){
        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();
        expect(categoryService.get(id)).andReturn(null).once();
        replay(userService, categoryService);
        String view = controller.deleteCategory(category, validToken, validToken,"true", model, sessionStatus);
View Full Code Here

    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

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.