Package org.jtalks.jcommune.web.dto.json

Examples of org.jtalks.jcommune.web.dto.json.JsonResponse


        Component component = setupComponentMock();

        BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(new Object(), "");
        ComponentInformation ci = new ComponentInformation();
        when(favIconIcoControllerUtils.getImageService()).thenReturn(iconImageService);
        JsonResponse response = administrationController.setForumInformation(ci, bindingResult, Locale.UK);

        verify(componentService).setComponentInformation(ci);
        assertEquals(response.getStatus(), JsonResponseStatus.SUCCESS);
    }
View Full Code Here


    @Test
    public void invalidForumInformationShouldProduceFailResponse() {
        BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(new Object(), "");
        bindingResult.addError(new ObjectError("name", "message"));
        JsonResponse response = administrationController.setForumInformation(new ComponentInformation(), bindingResult,
                Locale.UK);

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

    public void validBranchInformationShouldProduceSuccessResponse() throws NotFoundException {
        Component component = setupComponentMock();

        BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(new Object(), "");
        BranchDto branchDto = new BranchDto();
        JsonResponse response = administrationController.setBranchInformation(branchDto, bindingResult, Locale.UK);

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

    @Test
    public void invalidBranchInformationShouldProduceFailResponse() throws NotFoundException {
        BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(new Object(), "");
        bindingResult.addError(new ObjectError("name", "message"));
        BranchDto branchDto = new BranchDto();
        JsonResponse response = administrationController.setBranchInformation(branchDto, bindingResult, Locale.UK);

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

        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

                .thenReturn(Collections.EMPTY_LIST);
        when(permissionManager.findBranchPermissionByMask(targetPermission.getMask())).thenReturn(targetPermission);
        when(permissionManager.getAllGroupsWithoutExcluded(anyList(), eq(targetPermission))).thenReturn(Collections.EMPTY_LIST);


        JsonResponse jsonResponse = administrationController.getGroupsForBranchPermission(dto);

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

        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);

        JsonResponse jsonResponse = administrationController.getGroupsForBranchPermission(dto);

        assertEquals(jsonResponse.getStatus(), JsonResponseStatus.SUCCESS);
        assertTrue(jsonResponse.getResult() instanceof PermissionGroupsDto);
        PermissionGroupsDto result = (PermissionGroupsDto)jsonResponse.getResult();
        assertEquals(result.getAvailableGroups().size(), 3);
        assertEquals(result.getSelectedGroups().size(), 3);
    }
View Full Code Here

        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

        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

    public void getCodeReviewSuccess() throws NotFoundException {
        CodeReview review = new CodeReview();
        review.setId(REVIEW_ID);
        when(codeReviewService.get(REVIEW_ID)).thenReturn(review);

        JsonResponse response = controller.getCodeReview(REVIEW_ID);

        assertEquals(response.getStatus(), JsonResponseStatus.SUCCESS);
        assertEquals(((CodeReviewDto) response.getResult()).getId(), REVIEW_ID);
    }
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.web.dto.json.JsonResponse

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.