Package org.jtalks.common.model.entity

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


        sectionService = new TransactionalSectionService(sectionDao, branchService, userService, topicDao, postDao);
    }

    @Test
    public void testGet() throws NotFoundException {
        Section expectedSection = new Section(SECTION_NAME);
        when(sectionDao.isExist(SECTION_ID)).thenReturn(true);
        when(sectionDao.get(SECTION_ID)).thenReturn(expectedSection);

        Section section = sectionService.get(SECTION_ID);

        assertEquals(section, expectedSection, "Sections aren't equals");
        verify(sectionDao).isExist(SECTION_ID);
        verify(sectionDao).get(SECTION_ID);
    }
View Full Code Here


    }

    @Test
    public void testGetAll() {
        List<Section> expectedSectionList = new ArrayList<>();
        expectedSectionList.add(new Section(SECTION_NAME));
        when(sectionDao.getAll()).thenReturn(expectedSectionList);

        List<Section> actualSectionList = sectionService.getAll();

        assertEquals(actualSectionList, expectedSectionList);
View Full Code Here

    @Test
    public void getAllAvailableSections() {
        JCUser user = ObjectsFactory.getDefaultUser();
        Topic topic = ObjectsFactory.getTopic(user, 1);
        org.jtalks.jcommune.model.entity.Branch topicBranch = ObjectsFactory.getDefaultBranchWithTopic(100L, topic);
        Section sectionWithAvaliableBranches = ObjectsFactory.getDefaultSectionWithBranches();

        List<Section> allSections = new ArrayList<>();
        allSections.add(ObjectsFactory.getDefaultSection());
        allSections.add(ObjectsFactory.getDefaultSectionWithBranch(topicBranch));
        allSections.add(sectionWithAvaliableBranches);

        List<Section> expectedSections = new ArrayList<>();
        expectedSections.add(sectionWithAvaliableBranches);

        when(sectionDao.getAll()).thenReturn(allSections);
        when(topicDao.get(TOPIC_ID)).thenReturn(topic);
        when(userService.getCurrentUser()).thenReturn(user);
        when(sectionDao.getCountAvailableBranches(user, new ArrayList<Branch>())).thenReturn(0L);
        when(sectionDao.getCountAvailableBranches(user, sectionWithAvaliableBranches.getBranches())).thenReturn(3L);

        List<Section> actualSectionList = sectionService.getAllAvailableSections(TOPIC_ID);
        assertEquals(actualSectionList, expectedSections, "Should return all available sections.");
    }
View Full Code Here

        assertEquals(actualSectionList, expectedSections, "Should return all available sections.");
    }
   
    @Test
    public void testPrepareSectionsForView() {
        List<Section> sections = Arrays.asList(new Section(SECTION_NAME), new Section(SECTION_NAME));
        int sectionSize = sections.size();
       
        sectionService.prepareSectionsForView(sections);

        verify(branchService, Mockito.times(sectionSize))
View Full Code Here

            .fillStatisticInfo(Mockito.anyListOf(Branch.class));
    }
   
    @Test
    public void testDeleteAllBranches() throws NotFoundException {
        Section expectedSection = new Section(SECTION_NAME);
        expectedSection.addOrUpdateBranch(new Branch(null, null));
        expectedSection.addOrUpdateBranch(new Branch(null, null));
       
        when(sectionDao.isExist(SECTION_ID)).thenReturn(true);
        when(sectionDao.get(SECTION_ID)).thenReturn(expectedSection);
       
        Section actualSection = sectionService.deleteAllTopicsInSection(SECTION_ID);
       
        assertEquals(actualSection, expectedSection, "Sections aren't equals");
        verify(sectionDao).isExist(SECTION_ID);
        verify(sectionDao).get(SECTION_ID);
    }
View Full Code Here

        verify(sectionDao).get(SECTION_ID);
    }
   
    @Test
    public void testDeleteAllBranchesInEmptySection() throws NotFoundException {
        Section expectedSection = new Section(SECTION_NAME);
       
        when(sectionDao.isExist(SECTION_ID)).thenReturn(true);
        when(sectionDao.get(SECTION_ID)).thenReturn(expectedSection);
       
        Section actualSection = sectionService.deleteAllTopicsInSection(SECTION_ID);
       
        assertEquals(actualSection, expectedSection, "Sections aren't equals");
        verify(sectionDao).isExist(SECTION_ID);
        verify(sectionDao).get(SECTION_ID);
    }
View Full Code Here

        assertTrue(false);
    }

    @Test
    public void testDeleteAllTopics() throws NotFoundException {
        Section expectedSection = new Section(SECTION_NAME);
        expectedSection.setId(SECTION_ID);
        when(sectionDao.getAll()).thenReturn(Collections.singletonList(expectedSection));
        when(sectionDao.isExist(SECTION_ID)).thenReturn(true);
        when(sectionDao.get(SECTION_ID)).thenReturn(expectedSection);

        sectionService.deleteAllTopicsInForum();
View Full Code Here

        verify(sectionDao).get(SECTION_ID);
    }

    @Test(expectedExceptions=NotFoundException.class)
    public void testDeleteAllTopicsWithIncorrectId() throws NotFoundException {
        Section section = new Section(SECTION_NAME);
        section.setId(SECTION_ID);
        when(sectionDao.isExist(SECTION_ID)).thenReturn(false);
        when(sectionDao.getAll()).thenReturn(Collections.singletonList(section));

        sectionService.deleteAllTopicsInForum();
    }
View Full Code Here

    @Test(expectedExceptions = AccessDeniedException.class)
    public void testCheckAccessForVisibleException()throws AccessDeniedException{
        JCUser user = new JCUser(USER_NAME, EMAIL, USER_PASSWORD);
        List<Branch> branches = new ArrayList<>();
        Section section = new Section(SECTION_NAME);
        when(userService.getCurrentUser()).thenReturn(user);
        when(sectionDao.getCountAvailableBranches(user,branches)).thenReturn(0L);

        sectionService.ifSectionIsVisible(section);
    }
View Full Code Here

    @Test
    public void testCheckAccessForVisibleNoException()throws AccessDeniedException{
        JCUser user = new JCUser(USER_NAME, EMAIL, USER_PASSWORD);
        List<Branch> branches = new ArrayList<>();
        Section section = new Section(SECTION_NAME);
        when(userService.getCurrentUser()).thenReturn(user);
        when(sectionDao.getCountAvailableBranches(user,branches)).thenReturn(1L);

        sectionService.ifSectionIsVisible(section);
    }
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.