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

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


        List<Group> selectedGroups;
        try {
            selectedGroups = branchService.getPermissionGroupsFor(forumId, permissionInfo.getBranchId(),
                    permissionInfo.isAllowed(), branchPermission);
        } catch (NotFoundException e) {
            return new JsonResponse(JsonResponseStatus.FAIL, null);
        }
        List<GroupDto> alreadySelected = GroupDto.convertGroupList(selectedGroups, true);

        List<Group> availableGroups = permissionManager.getAllGroupsWithoutExcluded(selectedGroups, branchPermission);
        List<GroupDto> available = GroupDto.convertGroupList(availableGroups, true);

        permission.setSelectedGroups(alreadySelected);
        permission.setAvailableGroups(available);

        return new JsonResponse(JsonResponseStatus.SUCCESS, permission);
    }
View Full Code Here


        PermissionChanges changes = new PermissionChanges(branchPermission, newlyAddedGroups, removedGroups);
        try {
            branchService.changeBranchPermissions(forumId, permissionInfo.getBranchId(), permissionInfo.isAllowed(),changes);
        } catch (NotFoundException e) {
            return new JsonResponse(JsonResponseStatus.FAIL);
        }
        return new JsonResponse(JsonResponseStatus.SUCCESS);
    }
View Full Code Here

     */
    @RequestMapping(value = "/links/save", method = RequestMethod.POST)
    @ResponseBody
    public JsonResponse saveLink(@Valid @RequestBody ExternalLink link, BindingResult result) {
        if (result.hasErrors()) {
            return new JsonResponse(JsonResponseStatus.FAIL, result.getAllErrors());
        }
        Component component = componentService.getComponentOfForum();
        service.saveLink(link, component);
        return new JsonResponse(JsonResponseStatus.SUCCESS, link);
    }
View Full Code Here

    @RequestMapping(value = "/links/delete/{id}", method = RequestMethod.DELETE)
    @ResponseBody
    public JsonResponse deleteLink(@PathVariable Long id) {
        Component component = componentService.getComponentOfForum();
        boolean result = service.deleteLink(id, component);
        return new JsonResponse(JsonResponseStatus.SUCCESS, result);
    }
View Full Code Here

     */
    @RequestMapping(value = "/reviews/{reviewId}/json", method = RequestMethod.GET)
    @ResponseBody
    public JsonResponse getCodeReview(@PathVariable("reviewId") Long reviewId) throws NotFoundException {
        CodeReview review = codeReviewService.get(reviewId);
        return new JsonResponse(JsonResponseStatus.SUCCESS, new CodeReviewDto(review));
    }
View Full Code Here

    @Test
    public void testHasPermissionPermissionGranted() {
        when(permissionService.hasPermission(
                anyLong(), anyString(), anyString())).thenReturn(true);
       
        JsonResponse response = securityController.hasPermission(0, null, null);
       
        assertEquals(response.getStatus(), JsonResponseStatus.SUCCESS);
    }
View Full Code Here

    @Test
    public void testHasPermissionPermissionNotGranted() {
        when(permissionService.hasPermission(
                anyLong(), anyString(), anyString())).thenReturn(false);
       
        JsonResponse response = securityController.hasPermission(0, null, null);
       
        assertEquals(response.getStatus(), JsonResponseStatus.FAIL);
    }
View Full Code Here

    @Test
    public void savingLinkShouldPassIfNoValidationErrorsFound() throws Exception {
        when(bindingResult.hasErrors()).thenReturn(false);

        JsonResponse expected = controller.saveLink(link(), bindingResult);

        assertEquals(expected.getStatus(), JsonResponseStatus.SUCCESS);
        verify(service).saveLink(any(ExternalLink.class), any(Component.class));
    }
View Full Code Here

    @Test
    public void testFailValidationSaveLink() throws Exception {
        when(bindingResult.hasErrors()).thenReturn(true);

        JsonResponse expected = controller.saveLink(link(), bindingResult);

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

    @Test
    public void testDeleteLink() throws Exception {
        boolean expectedResult = true;
        long id = 1L;
        doReturn(expectedResult).when(service).deleteLink(eq(id), any(Component.class));
        JsonResponse expected = controller.deleteLink(id);
        assertEquals(expected.getStatus(), JsonResponseStatus.SUCCESS);
        verify(service).deleteLink(eq(id), any(Component.class));
    }
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.