Package org.jtalks.common.model.entity

Examples of org.jtalks.common.model.entity.Section


        session.flush();
    }

    @Test
    public void testDelete() {
        Section section = ObjectsFactory.getDefaultSection();
        session.save(section);

        boolean result = dao.delete(section.getId());
        int sectionCount = getSectionCount();

        assertTrue(result, "Entity is not deleted");
        assertEquals(sectionCount, 0);
    }
View Full Code Here


        assertFalse(result, "Entity deleted");
    }

    @Test
    public void testGetAll() {
        Section section1 = ObjectsFactory.getDefaultSection();
        session.save(section1);
        Section section2 = ObjectsFactory.getDefaultSection();
        session.save(section2);

        List<Section> sectiones = dao.getAll();

        assertEquals(sectiones.size(), 2);
View Full Code Here

        assertTrue(sectiones.isEmpty());
    }

    @Test
    public void testIsExist() {
        Section section = ObjectsFactory.getDefaultSection();
        session.save(section);

        assertTrue(dao.isExist(section.getId()));
    }
View Full Code Here

        assertFalse(dao.isExist(99999L));
    }

    @Test
    public void testGetAllTopicInBranchCount() {
        Section section = ObjectsFactory.getDefaultSection();
        Branch branch = ObjectsFactory.getDefaultBranch();
        Topic topic = ObjectsFactory.getDefaultTopic();
        branch.addTopic(topic);
        section.addOrUpdateBranch(branch);
        session.save(section);

        List<Section> sectionList = dao.getAll();

        assertEquals(((Branch) sectionList.get(0).getBranches().get(0)).getTopicCount(), 1);
View Full Code Here

        assertEquals(((Branch) sectionList.get(0).getBranches().get(0)).getTopicCount(), 1);
    }

    @Test
    public void testTopicInBranch() {
        Section section = ObjectsFactory.getDefaultSection();
        Branch branch = ObjectsFactory.getDefaultBranch();
        Topic topic = ObjectsFactory.getDefaultTopic();
        section.addOrUpdateBranch(branch);
        session.save(section);

        Section sectionTwo = dao.get(1L);
        Branch branchTwo = (Branch) section.getBranches().get(0);

        assertEquals(branchTwo.getTopicCount(), 0);
    }
View Full Code Here

        return ((Number) session.createQuery(hql).uniqueResult()).intValue();
    }

    private List<Branch> createAndSaveBranchList(int size, int sectionPosition) {
        List<Branch> branches = new ArrayList<>();
        Section section = ObjectsFactory.getDefaultSection();
        section.setPosition(sectionPosition);
        for (int i = 0; i < size; i++) {
            Branch newBranch = new Branch("Branch #" + i, "Branch #" + i);
            section.addOrUpdateBranch(newBranch);
            newBranch.setSection(section);
            branches.add(newBranch);
        }
        session.save(section);
        return branches;
View Full Code Here

        return branches;
    }

    @Test
    public void shouldReturnNoBranchesWhenDbIsEmpty() {
        Section emptySection = ObjectsFactory.getDefaultSection();
        session.save(emptySection);
        List<Branch> selectedBranches = dao.getAllBranches();
        assertTrue(selectedBranches.isEmpty());
    }
View Full Code Here

TOP

Related Classes of org.jtalks.common.model.entity.Section

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.