Search in sources :

Example 51 with User

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

the class SocialServiceIntTest method testCreateSocialUserShouldCreateSocialConnection.

@Test
public void testCreateSocialUserShouldCreateSocialConnection() {
    // Setup
    Connection<?> connection = createConnection("@LOGIN", "mail@mail.com", "FIRST_NAME", "LAST_NAME", "IMAGE_URL", "PROVIDER");
    // Exercise
    socialService.createSocialUser(connection, "fr");
    // Verify
    verify(mockConnectionRepository, times(1)).addConnection(connection);
    // 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 52 with User

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

the class SocialServiceIntTest method testCreateSocialUserShouldThrowExceptionIfConnectionHasNoEmailAndLoginAlreadyExist.

@Test(expected = IllegalArgumentException.class)
public void testCreateSocialUserShouldThrowExceptionIfConnectionHasNoEmailAndLoginAlreadyExist() {
    // Setup
    User user = createExistingUser("@LOGIN", "mail@mail.com", "OTHER_FIRST_NAME", "OTHER_LAST_NAME", "OTHER_IMAGE_URL");
    Connection<?> connection = createConnection("@LOGIN", "", "FIRST_NAME", "LAST_NAME", "IMAGE_URL", "PROVIDER");
    // Exercise
    try {
        // Exercise
        socialService.createSocialUser(connection, "fr");
    } finally {
        // Teardown
        userRepository.delete(user);
    }
}
Also used : User(com.furyviewer.domain.User) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 53 with User

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

the class SocialServiceIntTest method testCreateSocialUserShouldCreateUserWithExactLangKey.

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

Example 54 with User

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

the class UserServiceIntTest method init.

@Before
public void init() {
    user = new User();
    user.setLogin("johndoe");
    user.setPassword(RandomStringUtils.random(60));
    user.setActivated(true);
    user.setEmail("johndoe@localhost");
    user.setFirstName("john");
    user.setLastName("doe");
    user.setImageUrl("http://placehold.it/50x50");
    user.setLangKey("en");
}
Also used : User(com.furyviewer.domain.User) Before(org.junit.Before)

Example 55 with User

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

the class UserServiceIntTest method assertThatResetKeyMustBeValid.

@Test
@Transactional
public void assertThatResetKeyMustBeValid() {
    Instant daysAgo = Instant.now().minus(25, ChronoUnit.HOURS);
    user.setActivated(true);
    user.setResetDate(daysAgo);
    user.setResetKey("1234");
    userRepository.saveAndFlush(user);
    Optional<User> maybeUser = userService.completePasswordReset("johndoe2", user.getResetKey());
    assertThat(maybeUser).isNotPresent();
    userRepository.delete(user);
}
Also used : User(com.furyviewer.domain.User) Instant(java.time.Instant) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

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