Package com.porterhead.rest.user.exception

Examples of com.porterhead.rest.user.exception.DuplicateUserException


    @Transactional
    public AuthenticatedUserToken createUser(CreateUserRequest request, Role role) {
        validate(request);
        User searchedForUser = userRepository.findByEmailAddress(request.getUser().getEmailAddress());
        if (searchedForUser != null) {
            throw new DuplicateUserException();
        }

        User newUser = createNewUser(request, role);
        AuthenticatedUserToken token = new AuthenticatedUserToken(newUser.getUuid().toString(), createAuthorizationToken(newUser).getToken());
        userRepository.save(newUser);
View Full Code Here


        assertThat(response.getStatus(), is(400));
    }

    @Test
    public void duplicateUserOnCreateUser() {
        when(userService.createUser(any(CreateUserRequest.class), any(Role.class))).thenThrow(new DuplicateUserException());
        CreateUserRequest request = createSignupRequest();
        ClientResponse response = super.resource().path("user").entity(request, APPLICATION_JSON).accept(APPLICATION_JSON).post(ClientResponse.class);
        assertThat(response.getStatus(), is(409));
    }
View Full Code Here

TOP

Related Classes of com.porterhead.rest.user.exception.DuplicateUserException

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.