Package com.philip.journal.home.bean

Examples of com.philip.journal.home.bean.Entry


     * @exception JournalException Expected thrown exception.
     */
    @Test(expected = JournalException.class)
    public void testDelete2()
    {
        testBaseSpringHibernateDAOEntryImpl.delete(new Entry("Test", "Test", null));
        fail("Case 2: Non existing Entry.");
    }
View Full Code Here


     */
    @Test
    public void testDelete3()
    {
        for (int i = 0; i < COUNT_TEST_ENTRY; i++) {
            final Entry entry = entryDAO.read(ID_1ST_TST_BRANCH + i);
            try {
                testBaseSpringHibernateDAOEntryImpl.delete(entry);
            } catch (final JournalException e) {
                getCommon().failUnexpectedException(e);
            }
            assertNull("Case 3.1: Expected null read after delete: " + (i + 1), super.readEntry(entry.getNodeId()));
            assertEquals("Case 3.2: Expected record count after delete: " + (i + 1), COUNT_TEST_ENTRY - 1 - i,
                    super.getRecordCount(super.getEntryTableName()));
        }
    }
View Full Code Here

     * @exception JournalException Expected thrown exception.
     */
    @Test(expected = JournalException.class)
    public void testDelete2()
    {
        testBaseSpringHibernateDAOBranchImpl.delete(new Entry("Test", "Test", null));
        fail("Case 2: Non existing Entry.");
    }
View Full Code Here

     */
    @Test
    public void testDelete3()
    {
        for (int i = 0; i < COUNT_TEST_ENTRY; i++) {
            final Entry entry = entryDAO.read(ID_1ST_TST_BRANCH + i);
            try {
                testBaseSpringHibernateDAOBranchImpl.delete(entry);
            } catch (final JournalException e) {
                getCommon().failUnexpectedException(e);
            }
            assertNull("Case 3.1: Expected null read after delete: " + (i + 1), super.readEntry(entry.getNodeId()));
            assertEquals("Case 3.2: Expected record count after delete: " + (i + 1), COUNT_TEST_ENTRY - 1 - i,
                    super.getRecordCount(super.getEntryTableName()));
        }
    }
View Full Code Here

        final Branch subListParent = branchDao.read(targetBranch.getBranchId());
        final Element entriesElement = (Element) xpath.evaluate(TAG_ENTRIES, branchElement, XPathConstants.NODE);

        if (entriesElement != null) {
            final NodeList entryList = (NodeList) xpath.evaluate(TAG_ENTRY, entriesElement, XPathConstants.NODESET);
            final String[] entryProperties = BeanUtils.getProperties(new Entry(), EXCLUDED_PROPS);
            final Entry entry = new Entry();
            for (int i = 0; entryList != null && i < entryList.getLength(); i++) {
                for (final String property : entryProperties) {
                    final Object val = getElementPropValue((Element) entryList.item(i),
                            BeanUtils.getPropertyType(entry, property), property);
                    if (val != null) {
                        try {
                            org.apache.commons.beanutils.BeanUtils.setProperty(entry, property, val);
                        } catch (final Exception e) {
                            throw new JournalException(e.getMessage(), e);
                        }
                    }
                }
                if (null == entryDao.readByTitle(entry.getTitle(), subListParent.getBranchId())) {
                    entry.setBranch(subListParent);
                    entry.setNodeId(0);
                    entryDao.save(entry);
                }
            }
        }
View Full Code Here

    @Override
    public void execute() throws ServletException, IOException {

        final long locEntryId = parseId(this.entryId);
        try {
            final Entry entry = getServiceProxy().getEntryDetail(locEntryId);
            final BeanToMapConverter entryConverter = getResponseHandler().getConverterFactoryMap().get(
                    Constant.BeanConverter.ENTRY_TO_JSON);
            final Map<String, Object> converted = entryConverter.convert(entry);
            converted.put("branchId", "b-" + entry.getBranch().getBranchId());
            getResponseHandler().respondSuccess(getHttpServletResponse(), converted, DATA);
        } catch (final JournalException e) {
            getLogger().debug(e.getMessage(), e);
            getResponseHandler().respondFail(getHttpServletResponse(), e.getMessage());
        }
View Full Code Here

     * @exception JournalException when the nodeId passed cannot be found.
     */
    Object[] getEntryNodeProperty(final StringBuilder strBuilder, final long nodeId)
    {
        final EntryDAO entryDao = getDaoFacade().getEntryDAO();
        final Entry entry = entryDao.read(nodeId);
        if (entry == null) {
            throw JournalException.wrapperException(new IllegalArgumentException(Messages.Error.IAE_NULL));
        }

        long size = entry.getTitle().length();
        if (entry.getDescription() != null) {
            size += entry.getDescription().length();
        }
        if (strBuilder != null) {
            strBuilder.append("/" + entry.getTitle());
        }
        return new Object[] {
                entry,
                size };
    }
View Full Code Here

    {
        final EntryDAO mockedEntryDAO = getDaoFacade().getEntryDAO();
        final BranchDAO mockedBranchDAO = getDaoFacade().getBranchDAO();

        final long entryId = 1L;
        final Entry testEntry = new Entry();
        testEntry.setTitle("Test Title");
        testEntry.setDescription("Test Description");
        when(mockedEntryDAO.read(entryId)).thenReturn(testEntry);

        final long newBranchId = 666L;
        final String newTitle = "New Title";
        final String newDescription = "New Description";
View Full Code Here

    /** Case 2: Found. */
    @Test
    public final void testGetEntryDetail2()
    {
        when(getDaoFacade().getEntryDAO().read(anyInt())).thenReturn(new Entry());
        assertNotNull("Case 2: Found.", entryServiceImpl.getEntryDetail(null, 1));
    }
View Full Code Here

        oldBranch.setBranchId(oldBranchId);

        final long entryId = 666L;
        final String title = "title";
        final String desc = "desc";
        final Entry entry = new Entry(title, desc, oldBranch);

        when(getDaoFacade().getEntryDAO().read(entryId)).thenReturn(entry);
        when(getDaoFacade().getBranchDAO().read(newBranchId)).thenReturn(newBranch);
        when(getDaoFacade().getBranchDAO().read(oldBranchId)).thenReturn(oldBranch);
View Full Code Here

TOP

Related Classes of com.philip.journal.home.bean.Entry

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.