Search in sources :

Example 46 with User

use of com.furyviewer.domain.User in project FuryViewer by TheDoctor-95.

the class SocialServiceIntTest method testCreateSocialUserShouldCreateActivatedUserWithRoleUserAndPassword.

@Test
public void testCreateSocialUserShouldCreateActivatedUserWithRoleUserAndPassword() {
    // Setup
    Connection<?> connection = createConnection("@LOGIN", "mail@mail.com", "FIRST_NAME", "LAST_NAME", "IMAGE_URL", "PROVIDER");
    // Exercise
    socialService.createSocialUser(connection, "fr");
    // Verify
    User user = userRepository.findOneByEmailIgnoreCase("mail@mail.com").get();
    assertThat(user.getActivated()).isEqualTo(true);
    assertThat(user.getPassword()).isNotEmpty();
    Authority userAuthority = authorityRepository.findOne(AuthoritiesConstants.USER);
    assertThat(user.getAuthorities().toArray()).containsExactly(userAuthority);
    // Teardown
    userRepository.delete(user);
}
Also used : User(com.furyviewer.domain.User) Authority(com.furyviewer.domain.Authority) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 47 with User

use of com.furyviewer.domain.User in project FuryViewer by TheDoctor-95.

the class SocialServiceIntTest method testCreateSocialUserShouldSendRegistrationValidationEmail.

@Test
public void testCreateSocialUserShouldSendRegistrationValidationEmail() {
    // Setup
    Connection<?> connection = createConnection("@LOGIN", "mail@mail.com", "FIRST_NAME", "LAST_NAME", "IMAGE_URL", "PROVIDER");
    // Exercise
    socialService.createSocialUser(connection, "fr");
    // Verify
    verify(mockMailService, times(1)).sendSocialRegistrationValidationEmail(anyObject(), anyString());
    // Teardown
    User userToDelete = userRepository.findOneByEmailIgnoreCase("mail@mail.com").get();
    userRepository.delete(userToDelete);
}
Also used : User(com.furyviewer.domain.User) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 48 with User

use of com.furyviewer.domain.User in project FuryViewer by TheDoctor-95.

the class SocialServiceIntTest method createExistingUser.

private User createExistingUser(String login, String email, String firstName, String lastName, String imageUrl) {
    User user = new User();
    user.setLogin(login);
    user.setPassword(passwordEncoder.encode("password"));
    user.setEmail(email);
    user.setFirstName(firstName);
    user.setLastName(lastName);
    user.setImageUrl(imageUrl);
    return userRepository.saveAndFlush(user);
}
Also used : User(com.furyviewer.domain.User)

Example 49 with User

use of com.furyviewer.domain.User in project FuryViewer by TheDoctor-95.

the class SocialServiceIntTest method testCreateSocialUserShouldCreateUserWithSocialLoginWhenIsTwitter.

@Test
public void testCreateSocialUserShouldCreateUserWithSocialLoginWhenIsTwitter() {
    // Setup
    Connection<?> connection = createConnection("@LOGIN", "mail@mail.com", "FIRST_NAME", "LAST_NAME", "IMAGE_URL", "twitter");
    // Exercise
    socialService.createSocialUser(connection, "fr");
    // Verify
    User user = userRepository.findOneByEmailIgnoreCase("mail@mail.com").get();
    assertThat(user.getLogin()).isEqualToIgnoringCase("@LOGIN");
    // Teardown
    userRepository.delete(user);
}
Also used : User(com.furyviewer.domain.User) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 50 with User

use of com.furyviewer.domain.User in project FuryViewer by TheDoctor-95.

the class SocialServiceIntTest method testCreateSocialUserShouldCreateUserWithLoginSameAsEmailIfNotTwitter.

@Test
public void testCreateSocialUserShouldCreateUserWithLoginSameAsEmailIfNotTwitter() {
    // Setup
    Connection<?> connection = createConnection("@LOGIN", "mail@mail.com", "FIRST_NAME", "LAST_NAME", "IMAGE_URL", "PROVIDER_OTHER_THAN_TWITTER");
    // Exercise
    socialService.createSocialUser(connection, "fr");
    // Verify
    User user = userRepository.findOneByEmailIgnoreCase("mail@mail.com").get();
    assertThat(user.getLogin()).isEqualTo("mail@mail.com");
    // Teardown
    userRepository.delete(user);
}
Also used : User(com.furyviewer.domain.User) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

User (com.furyviewer.domain.User)65 Test (org.junit.Test)52 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)52 Transactional (org.springframework.transaction.annotation.Transactional)37 WithMockUser (org.springframework.security.test.context.support.WithMockUser)22 ManagedUserVM (com.furyviewer.web.rest.vm.ManagedUserVM)16 Authority (com.furyviewer.domain.Authority)6 UserDTO (com.furyviewer.service.dto.UserDTO)5 Instant (java.time.Instant)4 MimeMessage (javax.mail.internet.MimeMessage)4 Timed (com.codahale.metrics.annotation.Timed)2 KeyAndPasswordVM (com.furyviewer.web.rest.vm.KeyAndPasswordVM)2 LoginVM (com.furyviewer.web.rest.vm.LoginVM)2 UserExt (com.furyviewer.domain.UserExt)1 UserRepository (com.furyviewer.repository.UserRepository)1 BadRequestAlertException (com.furyviewer.web.rest.errors.BadRequestAlertException)1 EmailAlreadyUsedException (com.furyviewer.web.rest.errors.EmailAlreadyUsedException)1 LoginAlreadyUsedException (com.furyviewer.web.rest.errors.LoginAlreadyUsedException)1 URI (java.net.URI)1 java.util (java.util)1