Examples of JSONResponse


Examples of org.apache.sling.servlets.post.JSONResponse

        // Fall through to default behavior
        @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"})
        final MediaRangeList mediaRangeList = new MediaRangeList(req);
        if (JSONResponse.RESPONSE_CONTENT_TYPE.equals(mediaRangeList.prefer("text/html", JSONResponse.RESPONSE_CONTENT_TYPE))) {
            return new JSONResponse();
        } else {
            return new HtmlResponse();
        }
    }
View Full Code Here

Examples of org.apache.sling.servlets.post.JSONResponse

     * </ul>
     * or a {@link org.apache.sling.api.servlets.HtmlResponse} otherwise
     */
    protected AbstractPostResponse createHtmlResponse(SlingHttpServletRequest req) {
        if (JSONResponse.RESPONSE_CONTENT_TYPE.equals(req.getResponseContentType())) {
            return new JSONResponse();
        } else {
            return new HtmlResponse();
        }
    }
View Full Code Here

Examples of org.apache.sling.servlets.post.JSONResponse

     * </ul>
     * or a {@link org.apache.sling.api.servlets.HtmlResponse} otherwise
     */
    protected AbstractPostResponse createHtmlResponse(SlingHttpServletRequest req) {
      if (JSONResponse.RESPONSE_CONTENT_TYPE.equals(req.getResponseContentType())) {
        return new JSONResponse();
      } else {
            return new HtmlResponse();
      }
    }
View Full Code Here

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

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

    @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

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

    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

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

    @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

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

        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.json.JsonResponse

                .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

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

        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
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.