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

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


    @Test
    public void testGetQuotedAjax() throws NotFoundException {
        String expected = "[quote=\"user\"]" + POST_CONTENT + "[/quote]";
        when(bbCodeService.quote(POST_CONTENT, user)).thenReturn(expected);
        JsonResponse response = controller.getQuote(post.getId(), null);

        assertEquals(response.getResult(), expected);
    }
View Full Code Here


        String selection = "Content";
        String expected = "[quote=\"user\"]" + selection + "[/quote]";
        when(postService.get(anyLong())).thenReturn(post);
        when(bbCodeService.quote(selection, user)).thenReturn(expected);

        JsonResponse response = controller.getQuote(post.getId(), selection);

        assertEquals(response.getResult(), expected);
    }
View Full Code Here

        assertNullFields(dto);
    }

    @Test
    public void testRegistrationFormWithoutAnyPluginShouldBeSuccessful() {
        JsonResponse response = userController.registrationForm(request, Locale.ENGLISH);

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

    public void testRegistrationFormWithAvailablePluginShouldBeSuccessful() {
        RegistrationPlugin plugin = mock(RegistrationPlugin.class);
        when(pluginService.getRegistrationPlugins()).thenReturn(
                new ImmutableMap.Builder<Long, RegistrationPlugin>().put(1L, plugin).build());

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

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

    public void testRegisterUserAjaxShouldBeSuccessful() throws Exception {
        RegisterUserDto dto = createRegisterUserDto(null);
        BindingResult bindingResult = new BeanPropertyBindingResult(dto, "newUser");
        when(authenticator.register(dto)).thenReturn(bindingResult);

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

        assertEquals(response.getStatus(), JsonResponseStatus.SUCCESS,
                "User without validation errors should pass registration.");
    }
View Full Code Here

        RegisterUserDto dto = createRegisterUserDto(null);
        BindingResult bindingResult = mock(BindingResult.class);
        when(bindingResult.hasErrors()).thenReturn(true);
        when(authenticator.register(dto)).thenReturn(bindingResult);

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

        assertEquals(response.getStatus(), JsonResponseStatus.FAIL,
                "User with validation errors should fail registration.");
    }
View Full Code Here

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

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

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

    @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

   
    @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

    @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

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.