Package org.apache.rave.model

Examples of org.apache.rave.model.Tag


    }

    @Test
    public void getByKeyword() {
        String keyword = "key";
        Tag t = new TagImpl("1", keyword);
        expect(tagTemplate.findOne(Query.query(Criteria.where("keyword").is(keyword)))).andReturn(t);
        replay(tagTemplate);

        Tag fromRepo = repo.getByKeyword(keyword);
        assertThat(fromRepo.getKeyword(), is(equalTo(keyword)));
    }
View Full Code Here


    @Test
    public void get() {
        String keyword = "key";
        String id = "1";
        Tag t = new TagImpl(id, keyword);
        expect(tagTemplate.get(id)).andReturn(t);
        replay(tagTemplate);

        Tag fromRepo = repo.get(id);
        assertThat(fromRepo.getId(), is(equalTo(id)));
        assertThat(fromRepo.getKeyword(), is(equalTo(keyword)));
    }
View Full Code Here

    }

    @Test
    public void save(){
        String keyword = "KEYWORD";
        Tag tag = new TagImpl("ID", keyword);
        expect(tagTemplate.count(Query.query(Criteria.where("keyword").is(keyword)))).andReturn(0L);
        expect(tagTemplate.save(tag)).andReturn(tag);
        replay(tagTemplate);
        Tag returned = repo.save(tag);
        verify(tagTemplate);
        assertThat(returned, is(sameInstance(tag)));
    }
View Full Code Here

    }

    @Test
    public void save_more(){
        String keyword = "KEYWORD";
        Tag tag = new TagImpl("ID", keyword);
        expect(tagTemplate.count(Query.query(Criteria.where("keyword").is(keyword)))).andReturn(1L);
        replay(tagTemplate);
        Tag returned = repo.save(tag);
        verify(tagTemplate);
        assertThat(returned, is(sameInstance(tag)));
    }
View Full Code Here

    }

    @Test
    public void delete(){
        String id ="id";
        Tag tag = new TagImpl(id, "keyword");
        tagTemplate.remove(Query.query(Criteria.where("_id").is(id)));
        expectLastCall();
        replay(tagTemplate);

        repo.delete(tag);
View Full Code Here

        assertEquals(repository.getType(), JpaTag.class);
    }

    @Test
    public void getById_validId() {
        final Tag tag = repository.get(VALID_ID.toString());
        assertNotNull(tag);
        assertEquals(VALID_ID, ((JpaTag)tag).getEntityId());
        assertEquals(tag.getKeyword(), "news");
    }
View Full Code Here

        assertTrue("Found at least 1 tag", count == 3);
    }

    @Test
    public void getByKeyword() {
        Tag tag = repository.getByKeyword("news");
        assertNotNull(tag);
        assertTrue(((JpaTag)tag).getEntityId() == 1);
        tag = repository.getByKeyword("NEWS");
        assertNotNull(tag);
        assertTrue(((JpaTag)tag).getEntityId() == 1);
View Full Code Here

    public void save_valid(){
        JpaTag tag = new JpaTag();
        String ordnance = "ordnance";
        tag.setKeyword(ordnance);
        repository.save(tag);
        Tag foundTag = repository.getByKeyword(ordnance);
        assertNotNull(foundTag);
        assertEquals(tag.getKeyword(), foundTag.getKeyword());
    }
View Full Code Here

    @Test(expected = NullPointerException.class)
    @Transactional
    @Rollback(true)
    public void save_null(){
        Tag tag = null;
        tag = repository.save(tag);
        assertNull(tag);
    }
View Full Code Here

        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

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.