Package org.apache.rave.portal.model

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


    }

    @Override
    @Transactional
    public void saveWidgetRating(WidgetRating rating) {
        WidgetRating existingRating = getByWidgetIdAndUserId(rating.getWidgetId(), rating.getUserId());
        if (existingRating == null) {
            repository.save(rating);
        } else {
            updateScore(existingRating, rating.getScore());
        }
View Full Code Here


    }

    @Override
    @Transactional
    public void removeWidgetRating(Long widgetId, Long userId) {
        WidgetRating widgetRating = repository.getByWidgetIdAndUserId(widgetId, userId);
        if (widgetRating == null) {
            return;
        }
        repository.delete(widgetRating);
    }
View Full Code Here

    }

    @Override
    @Transactional
    public void saveWidgetRating(WidgetRating rating) {
        WidgetRating existingRating = getByWidgetIdAndUserId(rating.getWidgetId(), rating.getUserId());
        if (existingRating == null) {
            repository.save(rating);
        } else {
            updateScore(existingRating, rating.getScore());
        }
View Full Code Here

    }

    @Override
    @Transactional
    public void removeWidgetRating(Long widgetId, Long userId) {
        WidgetRating widgetRating = repository.getByWidgetIdAndUserId(widgetId, userId);
        if (widgetRating == null) {
            return;
        }
        repository.delete(widgetRating);
    }
View Full Code Here

        service = new DefaultWidgetRatingService(repository);
    }

    @Test
    public void testGetByWidgetIdAndUserId() {
        WidgetRating widgetRating = new WidgetRating(1L, 2L, 3L, 5);
        expect(repository.getByWidgetIdAndUserId(2L, 3L)).andReturn(widgetRating);
        replay(repository);
        final WidgetRating rating = service.getByWidgetIdAndUserId(2L, 3L);
        assertEquals("Score is 5", Integer.valueOf(5), rating.getScore());
    }
View Full Code Here

        assertEquals("Score is 5", Integer.valueOf(5), rating.getScore());
    }

    @Test
    public void updateScore() {
        WidgetRating widgetRating = createMock(WidgetRating.class);
        widgetRating.setScore(10);

        expectLastCall().once();
        expect(repository.save(widgetRating)).andReturn(widgetRating);
        replay(repository, widgetRating);
        service.updateScore(widgetRating, 10);
View Full Code Here

        verify(repository, widgetRating);
    }

    @Test
    public void saveWidgetRating_new() {
        WidgetRating newRating = new WidgetRating();
        newRating.setWidgetId(2L);
        newRating.setUserId(1L);
        newRating.setScore(10);

        expect(repository.getByWidgetIdAndUserId(2L, 1L)).andReturn(null);
        expect(repository.save(newRating)).andReturn(newRating);
        replay(repository);
View Full Code Here

        verify(repository);
    }

    @Test
    public void saveWidgetRating_existing() {
        WidgetRating existingRating = new WidgetRating(1L, 1L, 1L, 5);
        WidgetRating newRating = new WidgetRating();
        newRating.setWidgetId(1L);
        newRating.setUserId(1L);
        newRating.setScore(10);

        expect(repository.getByWidgetIdAndUserId(1L, 1L)).andReturn(existingRating);
        expect(repository.save(existingRating)).andReturn(existingRating);
        replay(repository);
View Full Code Here

        assertEquals("Updated score", Integer.valueOf(10), existingRating.getScore());
    }

    @Test
    public void removeWidgetRating_existingRating() {
        final WidgetRating widgetRating = new WidgetRating(1L, 1L, 1L, 5);

        expect(repository.getByWidgetIdAndUserId(1L, 1L)).andReturn(widgetRating);
        repository.delete(widgetRating);
        expectLastCall();
        replay(repository);
View Full Code Here

    @Test
    public void getByWidgetIdAndUserId_found() {
        Long widgetId = 1L;
        Long userId = 1L;
        WidgetRating widgetRating = repository.get(1L);
        WidgetRating byWidgetAndUser = repository.getByWidgetIdAndUserId(widgetId, userId);
        assertEquals(widgetRating, byWidgetAndUser);
    }
View Full Code Here

TOP

Related Classes of org.apache.rave.portal.model.WidgetRating

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.