Examples of BranchPermissionDto


Examples of org.jtalks.jcommune.web.dto.BranchPermissionDto

    @Test
    public void getGroupsForBranchPermissionShouldReturnFailIfBranchWasNotFound() throws Exception {
        Component component = setupComponentMock();

        BranchPermission targetPermission = BranchPermission.CREATE_POSTS;
        BranchPermissionDto dto = createBranchPermissionDto(targetPermission);
        when(permissionManager.findBranchPermissionByMask(targetPermission.getMask())).thenReturn(targetPermission);
        when(branchService.getPermissionGroupsFor(component.getId(), dto.getBranchId(), dto.isAllowed(), targetPermission))
                .thenThrow(new NotFoundException());

        JsonResponse jsonResponse = administrationController.getGroupsForBranchPermission(dto);

        assertEquals(jsonResponse.getStatus(), JsonResponseStatus.FAIL);
View Full Code Here

Examples of org.jtalks.jcommune.web.dto.BranchPermissionDto

    public void getGroupsForBranchPermissionShouldReturnSuccessIfBranchExistsAndPermissionHasNoGroups()
            throws Exception {
        Component component = setupComponentMock();

        BranchPermission targetPermission = BranchPermission.CREATE_POSTS;
        BranchPermissionDto dto = createBranchPermissionDto(targetPermission);
        when(branchService.getPermissionGroupsFor(component.getId(), dto.getBranchId(), dto.isAllowed(), targetPermission))
                .thenReturn(Collections.EMPTY_LIST);
        when(permissionManager.findBranchPermissionByMask(targetPermission.getMask())).thenReturn(targetPermission);
        when(permissionManager.getAllGroupsWithoutExcluded(anyList(), eq(targetPermission))).thenReturn(Collections.EMPTY_LIST);

View Full Code Here

Examples of org.jtalks.jcommune.web.dto.BranchPermissionDto

    @Test
    public void getGroupsForBranchPermissionShouldReturnSuccessIfBranchExists() throws Exception {
        Component component = setupComponentMock();

        BranchPermission targetPermission = BranchPermission.CREATE_POSTS;
        BranchPermissionDto dto = createBranchPermissionDto(targetPermission);

        List<Group> selectedGroupList = Arrays.asList(new Group("1"), new Group("2"), new Group("3"));
        when(branchService.getPermissionGroupsFor(component.getId(), dto.getBranchId(), dto.isAllowed(), targetPermission))
                .thenReturn(selectedGroupList);

        List<Group> allGroupList = Arrays.asList(new Group("4"), new Group("5"), new Group("6"));
        when(permissionManager.getAllGroupsWithoutExcluded(selectedGroupList, targetPermission)).thenReturn(allGroupList);
        when(permissionManager.findBranchPermissionByMask(targetPermission.getMask())).thenReturn(targetPermission);
View Full Code Here

Examples of org.jtalks.jcommune.web.dto.BranchPermissionDto

    @Test
    public void editBranchPermissionsShouldReturnSuccessIfBranchExist() throws Exception {
        Component component = setupComponentMock();

        BranchPermission targetPermission = BranchPermission.CREATE_POSTS;
        BranchPermissionDto dto = createBranchPermissionDto(targetPermission);

        dto.setNewlyAddedGroupIds(Arrays.asList(1L, 2L));
        dto.setRemovedGroupIds(Arrays.asList(1L, 2L));
        when(permissionManager.findBranchPermissionByMask(targetPermission.getMask())).thenReturn(targetPermission);

        JsonResponse response = administrationController.editBranchPermissions(dto);

        assertEquals(response.getStatus(), JsonResponseStatus.SUCCESS);
        verify(branchService).changeBranchPermissions(anyLong(),
                eq(dto.getBranchId()), eq(dto.isAllowed()), any(PermissionChanges.class));
    }
View Full Code Here

Examples of org.jtalks.jcommune.web.dto.BranchPermissionDto

    @Test
    public void editBranchPermissionsShouldReturnFailIfBranchNotFound() throws Exception {
        Component component = setupComponentMock();

        BranchPermission targetPermission = BranchPermission.CREATE_POSTS;
        BranchPermissionDto dto = createBranchPermissionDto(targetPermission);

        dto.setNewlyAddedGroupIds(Arrays.asList(1L, 2L));
        dto.setRemovedGroupIds(Arrays.asList(1L, 2L));

        when(permissionManager.findBranchPermissionByMask(targetPermission.getMask())).thenReturn(targetPermission);
        doThrow(new NotFoundException()).when(branchService).changeBranchPermissions(anyLong(),
                eq(dto.getBranchId()), eq(dto.isAllowed()), any(PermissionChanges.class));

        JsonResponse response = administrationController.editBranchPermissions(dto);

        assertEquals(response.getStatus(), JsonResponseStatus.FAIL);
    }
View Full Code Here

Examples of org.jtalks.jcommune.web.dto.BranchPermissionDto

        when(componentService.getComponentOfForum()).thenReturn(component);
        return component;
    }

    private BranchPermissionDto createBranchPermissionDto(BranchPermission targetPermission) {
        BranchPermissionDto dto = new BranchPermissionDto();
        dto.setAllowed(true);
        dto.setBranchId(42L);
        dto.setPermissionMask(targetPermission.getMask());
        return dto;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.