Package org.apache.rave.model

Examples of org.apache.rave.model.Tag


        service = new DefaultTagService(repository);
    }

    @Test
    public void getTagById() {
        Tag tag = createTag("test");
        expect(repository.get("1")).andReturn(tag);
        replay(repository);
        Tag sTag = service.getTagById("1");
        assertEquals(sTag, tag);
        verify(repository);
    }
View Full Code Here


        verify(repository);
    }

    @Test
    public void getLimitedList() {
        Tag tag1 = new TagImpl("1", "tag");
        Tag tag2 = new TagImpl("2", "fakeTag");
        List<Tag> tags = new ArrayList<Tag>();
        tags.add(tag1);
        tags.add(tag2);
        final int pageSize = 10;
        expect(repository.getCountAll()).andReturn(2);
View Full Code Here

    @Test
    public void getTagById_NotFound() {
        final String entityId = "456";
        expect(repository.get(entityId)).andReturn(null);
        replay(repository);
        Tag sTag = service.getTagById(entityId);
        assertNull(sTag);

        verify(repository);
    }
View Full Code Here

    }

    @Test
    public void allTags() {
        List<Tag> tags = new ArrayList<Tag>();
        Tag tag = createTag("test");
        tags.add(tag);
        expect(repository.getAll()).andReturn(tags);
        replay(repository);
        List<Tag> allTags = service.getAllTagsList();
        verify(repository);
View Full Code Here

        assertTrue(allTags.size() > 0);
    }

    @Test
    public void getByKeyword() {
        Tag tag = createTag("test");
        expect(repository.getByKeyword("test")).andReturn(tag);
        expect(repository.getByKeyword("TEST")).andReturn(tag);
        expect(repository.getByKeyword(" test")).andReturn(tag);

    }
View Full Code Here

    @Override
    public List<Widget> getWidgetsByTag(String tagKeyword, int offset, int pageSize) {
        if (tagKeyword != null) {
            tagKeyword = tagKeyword.toLowerCase();
        }
        Tag tag = tagRepository.getByKeyword(tagKeyword);
        TypedQuery<JpaWidget> query = manager.createNamedQuery(JpaWidget.WIDGET_GET_BY_TAG, JpaWidget.class);
        query.setParameter(JpaWidget.PARAM_TAG_ID, tag == null ? null : Long.parseLong(tag.getId()));
        return expandProperties(getPagedResultList(query, offset, pageSize));
    }
View Full Code Here

    @Override
    public int getCountByTag(String tagKeyword) {
        if (tagKeyword != null) {
            tagKeyword = tagKeyword.toLowerCase();
        }
        Tag tag = tagRepository.getByKeyword(tagKeyword);
        Query query = manager.createNamedQuery(JpaWidget.WIDGET_COUNT_BY_TAG);
        query.setParameter(JpaWidget.PARAM_TAG_ID, tag == null ? null : Long.parseLong(tag.getId()));
        Number countResult = (Number) query.getSingleResult();
        return countResult.intValue();
    }
View Full Code Here

    @Override
    public WidgetTag getTagByWidgetIdAndKeyword(String widgetId, String keyword) {
        if (keyword != null) {
            keyword = keyword.trim();
        }
        Tag tag = tagRepository.getByKeyword(keyword);
        TypedQuery<JpaWidgetTag> query = manager.createNamedQuery(JpaWidgetTag.FIND_BY_WIDGETID_AND_TAGID, JpaWidgetTag.class);
        query.setParameter(JpaWidgetTag.TAG_ID_PARAM, tag == null ? null : Long.parseLong(tag.getId()));
        query.setParameter(JpaWidgetTag.WIDGET_ID_PARAM, widgetId == null ? null : Long.parseLong(widgetId));
        return getSingleResult(query.getResultList());
    }
View Full Code Here

TOP

Related Classes of org.apache.rave.model.Tag

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.