Examples of JSONResponse


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

    @Test
    public void testRegisterAjaxFailIfConnectionErrorOccurred() throws Exception {
        RegisterUserDto dto = createRegisterUserDto(null);
        doThrow(new NoConnectionException()).when(authenticator).register(dto);

        JsonResponse response = userController.registerUserAjax(dto, request, Locale.ENGLISH);

        assertEquals(response.getStatus(), JsonResponseStatus.FAIL, "Connection error should fail registration.");
    }
View Full Code Here

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

   
    @Test
    public void testRegisterAjaxFailIfHoneypotCaptchaNotNull() throws Exception {
        RegisterUserDto dto = createRegisterUserDto("anyString");

        JsonResponse response = userController.registerUserAjax(dto, request, Locale.ENGLISH);
       
        assertEquals(response.getStatus(), JsonResponseStatus.FAIL, "HoneypotException should fail registration.");
    }
View Full Code Here

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

    @Test(enabled = false)
    public void testAjaxLoginSuccess() throws Exception {
        when(userService.loginUser(any(LoginUserDto.class), any(HttpServletRequest.class),
                any(HttpServletResponse.class))).thenReturn(true);

        JsonResponse response = userController.loginAjax(null, null, "on", null, null);
        assertEquals(response.getStatus(), JsonResponseStatus.SUCCESS);
        LoginUserDto loginUserDto = new LoginUserDto("userName", "password", true, "192.168.1.1");
        verify(userService).loginUser(loginUserDto,
                any(HttpServletRequest.class), any(HttpServletResponse.class));
    }
View Full Code Here

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

    @Test
    public void testAjaxLoginFailure() throws Exception {
        when(userService.loginUser(any(LoginUserDto.class),any(HttpServletRequest.class),
                any(HttpServletResponse.class))).thenReturn(false);
        JsonResponse response = userController.loginAjax(null, null, "on", request, null);
        assertEquals(response.getStatus(), JsonResponseStatus.FAIL);
        verify(userService).loginUser(any(LoginUserDto.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
    }
View Full Code Here

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

    @Test
    public void testLoginAjaxUserShouldFailIfConnectionErrorOccurred() throws Exception {
        when(userService.loginUser(any(LoginUserDto.class), any(HttpServletRequest.class), any(HttpServletResponse.class)))
                .thenThrow(new NoConnectionException());
       
        JsonResponse response = userController.loginAjax(null, null, "on", request, null);
        assertEquals(response.getStatus(), JsonResponseStatus.FAIL);
        verify(userService).loginUser(any(LoginUserDto.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
    }
View Full Code Here

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

    @Test
    public void testLoginAjaxUserShouldFailIfUnexpectedErrorOccurred() throws Exception {
        when(userService.loginUser(any(LoginUserDto.class), any(HttpServletRequest.class), any(HttpServletResponse.class)))
                .thenThrow(new UnexpectedErrorException());
       
        JsonResponse response = userController.loginAjax(null, null, "on", request, null);
        assertEquals(response.getStatus(), JsonResponseStatus.FAIL);
        verify(userService).loginUser(any(LoginUserDto.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
    }
View Full Code Here

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

    public void testGetUsernameListSuccess() {
        String pattern = "us";
        List<String> usernames = Lists.newArrayList("User1", "User2", "User3");
        when(userService.getUsernames(pattern)).thenReturn(usernames);

        JsonResponse response = userController.usernameList(pattern);
        assertEquals(response.getStatus(), JsonResponseStatus.SUCCESS);
    }
View Full Code Here

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

        Component component = new Component();
        component.setId(componentId);
        when(componentService.getComponentOfForum()).thenReturn(component);
        PluginActivatingDto pluginActivatingDto = new PluginActivatingDto("Dummy plugin", true);
       
        String expectedStatus = new JsonResponse(JsonResponseStatus.SUCCESS).getStatus().name();
       
        String actualStatus = pluginController.activatePlugin(pluginActivatingDto).getStatus().name();
       
        assertEquals(actualStatus, expectedStatus);
    }
View Full Code Here

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

    @RequestMapping(value = "/activate", method = RequestMethod.POST)
    @ResponseBody
    public JsonResponse activatePlugin(@RequestBody PluginActivatingDto pluginActivatingDto) throws NotFoundException {
        long componentId = getForumComponentId();
        pluginService.updatePluginActivating(pluginActivatingDto, componentId);
        return new JsonResponse(JsonResponseStatus.SUCCESS);
    }
View Full Code Here

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

    public JsonResponse hasPermission(
            @RequestParam("targetId") long targetId,
            @RequestParam("targetType") String targetType,
            @RequestParam("permission") String permission) {
        if (permissionService.hasPermission(targetId, targetType, permission)) {
            return new JsonResponse(JsonResponseStatus.SUCCESS);
        } else {
            return new JsonResponse(JsonResponseStatus.FAIL);
        }
    }
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.