Package org.jtalks.jcommune.model.entity

Examples of org.jtalks.jcommune.model.entity.ExternalLink


        verify(dao).getAll();
    }

    @Test
    public void testAddLink() throws Exception {
        ExternalLink linkToSave = new ExternalLink();
        Component component = new Component();
        service.saveLink(linkToSave, component);
        verify(dao).saveOrUpdate(linkToSave);
    }
View Full Code Here


        assertEquals(expected.getStatus(), JsonResponseStatus.SUCCESS);
        verify(service).deleteLink(eq(id), any(Component.class));
    }

    private ExternalLink link() {
        ExternalLink link = new ExternalLink("url", "title", "hint");
        link.setId(1L);
        return link;
    }
View Full Code Here

    }

    @Test
    public void testSave() throws Exception {
        long id = 1L;
        ExternalLink expected = ObjectsFactory.getDefaultExternalLink();
        expected.setId(id);
        session.save(expected);
        session.clear();

        ExternalLink actual = (ExternalLink) session.get(ExternalLink.class, expected.getId());
        assertReflectionEquals(expected, actual);
    }
View Full Code Here

        assertNull(dao.get(Long.MAX_VALUE));
    }

    @Test
    public void testUpdate() throws Exception {
        ExternalLink link = ObjectsFactory.getDefaultExternalLink();
        dao.saveOrUpdate(link);
        session.clear();

        link = (ExternalLink) session.get(ExternalLink.class, link.getId());
        fillFieldsRandomly(link);

        dao.saveOrUpdate(link);
        session.flush();
        session.clear();

        ExternalLink actual = (ExternalLink) session.get(ExternalLink.class, link.getId());
        assertReflectionEquals(link, actual);
    }
View Full Code Here

        assertEquals(actual.size(), 3);
    }

    @Test(expectedExceptions = ConstraintViolationException.class)
    public void shouldFailWithEmptyTitle() {
        ExternalLink link = ObjectsFactory.getDefaultExternalLink();
        link.setTitle("");
        dao.saveOrUpdate(link);
    }
View Full Code Here

        dao.saveOrUpdate(link);
    }

    @Test(expectedExceptions = ConstraintViolationException.class)
    public void shouldFailWithNullTitle() {
        ExternalLink link = ObjectsFactory.getDefaultExternalLink();
        link.setTitle(null);
        dao.saveOrUpdate(link);
    }
View Full Code Here

    }


    @Test(expectedExceptions = ConstraintViolationException.class)
    public void shouldFailWithLongTitle() {
        ExternalLink link = ObjectsFactory.getDefaultExternalLink();
        link.setTitle(RandomStringUtils.random(ExternalLink.TITLE_MAX_SIZE + 1, true, false));
        dao.saveOrUpdate(link);
    }
View Full Code Here

        dao.saveOrUpdate(link);
    }

    @Test
    public void shouldSuccessWithMaxLengthTitle() {
        ExternalLink link = ObjectsFactory.getDefaultExternalLink();
        link.setTitle(RandomStringUtils.random(ExternalLink.TITLE_MAX_SIZE, true, false));
        dao.saveOrUpdate(link);
    }
View Full Code Here

        dao.saveOrUpdate(link);
    }

    @Test
    public void shouldSuccessWithMinLengthTitle() {
        ExternalLink link = ObjectsFactory.getDefaultExternalLink();
        link.setTitle(RandomStringUtils.random(ExternalLink.TITLE_MIN_SIZE, true, false));
        dao.saveOrUpdate(link);
    }
View Full Code Here

        dao.saveOrUpdate(link);
    }

    @Test(expectedExceptions = ConstraintViolationException.class)
    public void shouldFailWithNullUrl() {
        ExternalLink link = ObjectsFactory.getDefaultExternalLink();
        link.setUrl(null);
        dao.saveOrUpdate(link);
    }
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.model.entity.ExternalLink

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.