Package org.jtalks.jcommune.model.dto

Examples of org.jtalks.jcommune.model.dto.UserDto


    }

    @Test
    public void testValidateUserIfThereNoValidationErrorsShouldBeSuccessful()
            throws UnexpectedErrorException, NoConnectionException {
        UserDto userDto = new UserDto();
        Long pluginId = 1L;
        KaptchaPluginService service = mock(KaptchaPluginService.class);
        when(service.validateCaptcha(userDto, pluginId)).thenReturn(Collections.EMPTY_MAP);
        when(kaptchaPlugin.getService()).thenReturn(service);
View Full Code Here


    }

    @Test
    public void testValidateUserIfThereWereValidationErrorsShouldReturnErrors()
            throws UnexpectedErrorException, NoConnectionException {
        UserDto userDto = new UserDto();
        Long pluginId = 1L;
        KaptchaPluginService service = mock(KaptchaPluginService.class);
        when(service.validateCaptcha(userDto, pluginId)).thenReturn(new ImmutableMap.Builder<String, String>()
                .put("userDto.captchas[plugin-1]", "Invalid value for captcha").build());
        when(kaptchaPlugin.getService()).thenReturn(service);
View Full Code Here

    }

    @Test
    public void testRegisterUserIfThereNoValidationErrorsShouldBeSuccessful()
            throws UnexpectedErrorException, NoConnectionException {
        UserDto userDto = new UserDto();
        Long pluginId = 1L;
        KaptchaPluginService service = mock(KaptchaPluginService.class);
        when(service.validateCaptcha(userDto, pluginId)).thenReturn(Collections.EMPTY_MAP);
        when(kaptchaPlugin.getService()).thenReturn(service);
View Full Code Here

    }

    @Test
    public void testRegisterUserIfThereWereValidationErrorsShouldReturnErrors()
            throws UnexpectedErrorException, NoConnectionException {
        UserDto userDto = new UserDto();
        Long pluginId = 1L;
        KaptchaPluginService service = mock(KaptchaPluginService.class);
        when(service.validateCaptcha(userDto, pluginId)).thenReturn(new ImmutableMap.Builder<String, String>()
                .put("userDto.captchas[plugin-1]", "Invalid value for captcha").build());
        when(kaptchaPlugin.getService()).thenReturn(service);
View Full Code Here

        assertNull(dto.getUserDto());
        assertNull(dto.getPasswordConfirm());
    }

    private RegisterUserDto createRegisterUserDto(String honeypotCaptcha) {
        UserDto userDto = new UserDto();
        userDto.setUsername(USER_NAME);
        userDto.setEmail(EMAIL);
        userDto.setPassword("password");
        RegisterUserDto dto = new RegisterUserDto();
        dto.setPasswordConfirm("password");
        dto.setUserDto(userDto);
        dto.setHoneypotCaptcha(honeypotCaptcha);
        return dto;
View Full Code Here

        request.setSession(session);
    }

    @Test
    public void testNoCoincidenceCaptchaWithInputValue() throws Exception {
        UserDto userDto = createUserDto();
        String captchaText = "1234";
        session.setAttribute(Constants.KAPTCHA_SESSION_KEY, captchaText);
        RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));

        Map<String, String> errors = service.validateCaptcha(userDto, 1L);
View Full Code Here

        assertFalse(errors.isEmpty(), "Validation of captcha with valid value should not return any errors.");
    }

    @Test
    public void testCoincidenceCaptchaWithInputValue() throws Exception {
        UserDto userDto = createUserDto();
        session.setAttribute(Constants.KAPTCHA_SESSION_KEY, GENERATED_CAPTCHA_TEXT);
        RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));

        Map<String, String> errors = service.validateCaptcha(userDto, 1L);
View Full Code Here

        assertTrue(errors.isEmpty(), "Validation of captcha with valid value should not return any errors.");
    }

    private UserDto createUserDto() {
        UserDto userDto = new UserDto();
        Map<String, String> captchas = new HashMap<>();
        captchas.put("plugin-1", GENERATED_CAPTCHA_TEXT);
        captchas.put("plugin-2", "2222");
        captchas.put("plugin-3", "3333");
        userDto.setCaptchas(captchas);
        return userDto;
    }
View Full Code Here

    }

    @Test
    public void userShouldNotBeRegisteredIfSomeErrorOccurred()
            throws JAXBException, IOException, NoConnectionException, UnexpectedErrorException {
        UserDto userDto = createUserDto("user", "", "");
        Map<String, String> errors = new HashMap<>();
        errors.put("email", "Invalid email");
        errors.put("password", "Invalid password");

        when(service.registerUser(userDto, false)).thenReturn(errors);
View Full Code Here

    }

    @Test
    public void userWithCorrectParametersShouldBeRegistered()
            throws UnexpectedErrorException, NoConnectionException, IOException, JAXBException {
        UserDto userDto = createUserDto("user", "1234", "email@email.em");

        when(service.registerUser(userDto, true)).thenReturn(new HashMap<String, String>());

        Map<String, String> result = plugin.registerUser(userDto, null);
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.model.dto.UserDto

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.