Package com.philip.journal.home.dao

Examples of com.philip.journal.home.dao.BranchDAO


    /** Case 2: Normal. Too complex!!! */
    @Test
    public final void testExtractNodeFromDocumentCase2()
    {
        try {
            final BranchDAO branchDAO = getDaoFacade().getBranchDAO();

            final int rootBranchCount = branchDAO.readAllByParent(Constant.ROOT_ID).size();
            final int branchCount = branchDAO.readAllByParent(TEST_ID_RTBRANCH1).size();

            when(mockXPath.evaluate(eq(XmlHelper.TAG_BRANCHES), eq(testBranchEl1), eq(XPathConstants.NODE)))
                    .thenReturn(testBranchesEl1);
            when(mockXPath.evaluate(eq(XmlHelper.TAG_BRANCHES), eq(testSubBranchEl1), eq(XPathConstants.NODE)))
                    .thenReturn(testSubBranchesEl1);
View Full Code Here


        when(getDaoFacade().getEntryDAO().read(TEST_ENTRY_ID)).thenReturn(testEntry);
        when(getDaoFacade().getBranchDAO().read(TEST_SUBBRANCH1_ID)).thenReturn(testSubBranch1);
        when(getDaoFacade().getBranchDAO().read(TEST_SUBBRANCH2_ID)).thenReturn(testSubBranch2);
        when(getDaoFacade().getBranchDAO().read(TEST_SUBBRANCH11_ID)).thenReturn(testSubBranch11);

        final BranchDAO mockBranchDAO = getDaoFacade().getBranchDAO();
        when(mockBranchDAO.readAllByParent(Constant.ROOT_ID)).thenAnswer(new Answer<List<Branch>>() {

            @Override
            public List<Branch> answer(final InvocationOnMock invocation) throws Throwable
            {
                final List<Branch> retval = new ArrayList<Branch>();
                if (Long.valueOf(Constant.ROOT_ID).equals(invocation.getArguments()[0])) {
                    retval.add(testSubBranch1);
                    retval.add(testSubBranch2);
                } else if (Long.valueOf(TEST_SUBBRANCH1_ID).equals(invocation.getArguments()[0])) {
                    retval.add(testSubBranch11);
                }
                return retval;
            }
        });

        doAnswer(new Answer<Object>() {
            /** Simulate an exception if rename conflicted with a sibling. */
            public Object answer(final InvocationOnMock invocation) throws Throwable
            {
                final Branch param = (Branch) invocation.getArguments()[0];
                final Branch parent = param.getParent();
                if (parent != null) {//not Root.
                    final List<Branch> siblings = mockBranchDAO.readAllByParent(parent.getBranchId());
                    for (final Branch branch : siblings) {
                        if (branch.getBranchId() != param.getBranchId() && branch.getName().equals(param.getName())) {
                            throw new JournalException(JournalTestCommon.TEST_JRNL_ERRORMSG);
                        }
                    }
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void testDeleteBranchCase3()
    {

        final BranchDAO mockBranchDAO = getDaoFacade().getBranchDAO();
        doAnswer(new Answer<Object>() {
            @Override
            public Object answer(final InvocationOnMock invocation) throws Throwable
            {
                final List<Branch> argument = (List<Branch>) invocation.getArguments()[0];
View Full Code Here

    @Override
    public void moveEntry(final Map<String, Object> session, final long newParentId, final long entryId)
    {
        final EntryDAO entryDao = getDaoFacade().getEntryDAO();
        final BranchDAO branchDao = getDaoFacade().getBranchDAO();

        final Entry entry = entryDao.read(entryId);
        final Branch parent = branchDao.read(newParentId);
        if (entry == null || parent == null) {
            throw new IllegalArgumentException(Error.IAE_GENERIC);
        } else {
            entry.setBranch(parent);
            entryDao.save(entry);
View Full Code Here

TOP

Related Classes of com.philip.journal.home.dao.BranchDAO

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.