@Test public void testCreateSocialUserShouldCreateUserWithSocialInformation() { // Setup Connection<?> connection = createConnection("@LOGIN", "*****@*****.**", "FIRST_NAME", "LAST_NAME", "PROVIDER"); // Exercise socialService.createSocialUser(connection, "fr"); // Verify User user = userRepository.findOneByEmail("*****@*****.**").get(); assertThat(user.getFirstName()).isEqualTo("FIRST_NAME"); assertThat(user.getLastName()).isEqualTo("LAST_NAME"); // Teardown userRepository.delete(user); }
@Test public void testCreateSocialUserShouldNotChangeUserIfEmailAlreadyExist() { // Setup long initialUserCount = userRepository.count(); User user = createExistingUser("@OTHER_LOGIN", "*****@*****.**", "OTHER_FIRST_NAME", "OTHER_LAST_NAME"); Connection<?> connection = createConnection("@LOGIN", "*****@*****.**", "FIRST_NAME", "LAST_NAME", "PROVIDER"); // Exercise socialService.createSocialUser(connection, "fr"); // Verify User userToVerify = userRepository.findOneByEmail("*****@*****.**").get(); assertThat(userToVerify.getLogin()).isEqualTo("@OTHER_LOGIN"); assertThat(userToVerify.getFirstName()).isEqualTo("OTHER_FIRST_NAME"); assertThat(userToVerify.getLastName()).isEqualTo("OTHER_LAST_NAME"); // Teardown userRepository.delete(userToVerify); }