Package org.apache.rave.portal.model.impl

Examples of org.apache.rave.portal.model.impl.CategoryImpl


    public void deleteCategory_invalidValidRequest_nullWidgetToDelete(){
        Model model = new ExtendedModelMap();
        User user = new UserImpl();
        long id = 1L;
        String categoryText = "Social";
        CategoryImpl category = new CategoryImpl();
        category.setCreatedUser(user);
        category.setText(categoryText);
        category.setId(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 UserImpl();
        long id = 1L;
        String categoryText = "Social";
        CategoryImpl category = new CategoryImpl();
        category.setCreatedUser(user);
        category.setText(categoryText);
        category.setId(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 UserImpl();
        long id = 1L;
        String categoryText = "Social";
        Model model = new ExtendedModelMap();
        CategoryImpl category = new CategoryImpl();
        category.setCreatedUser(user);
        category.setText(categoryText);
        category.setId(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 CategoryImpl();
        validCategory.setId(CATEGORY_ID);
        validCategory.setText(CATEGORY_TEXT);
    }
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

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

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

        webDataBinder = createMock(WebDataBinder.class);
        categoryEditor = new CategoryEditor(categoryService);
        controller.setCategoryEditor(categoryEditor);
    }
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 CategoryImpl());
        // add tokencheck attribute for creating new category
        model.addAttribute(ModelKeys.TOKENCHECK, AdminControllerUtil.generateSessionToken());

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

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

        assertThat(categoryConverter.convert(category), is(nullValue()));
    }

    @Test
    public void newCategory() {
        Category category = new CategoryImpl();
        category.setCreatedDate(new Date());
        category.setId(9L);
        category.setLastModifiedDate(new Date());
        category.setText("hello");
        category.setCreatedUser(new JpaUser(1L));
        category.setLastModifiedUser(new JpaUser(1L));
        category.setWidgets(new ArrayList<Widget>());

        JpaCategory converted = categoryConverter.convert(category);
        assertThat(converted, is(not(sameInstance(category))));
        assertThat(converted, is(instanceOf(JpaCategory.class)));
        assertThat(converted.getCreatedDate(), is(equalTo(category.getCreatedDate())));
        assertThat(converted.getCreatedUser(), is(equalTo(category.getCreatedUser())));
        assertThat(converted.getEntityId(), is(equalTo(category.getId())));
        assertThat(converted.getId(), is(equalTo(category.getId())));
        assertThat(converted.getLastModifiedDate(), is(equalTo(category.getLastModifiedDate())));
        assertThat(converted.getLastModifiedUser(), is(equalTo(category.getLastModifiedUser())));
        assertThat(converted.getText(), is(equalTo(category.getText())));
        assertThat(converted.getWidgets(), is(equalTo(category.getWidgets())));
    }
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

TOP

Related Classes of org.apache.rave.portal.model.impl.CategoryImpl

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.