use of org.onebusaway.users.services.UserPropertiesService in project onebusaway-application-modules by camsys.
the class UserServiceImplTest method testCompletePhoneNumberRegistration.
@Test
public void testCompletePhoneNumberRegistration() {
User userA = createUser(1234);
UserIndexKey key = new UserIndexKey(UserIndexTypes.PHONE_NUMBER, "12065551234");
UserDao userDao = Mockito.mock(UserDao.class);
_service.setUserDao(userDao);
Mockito.when(userDao.getUserForId(1234)).thenReturn(userA);
UserIndex migratedIndex = new UserIndex();
migratedIndex.setId(key);
migratedIndex.setUser(userA);
migratedIndex.setCredentials("");
Mockito.when(userDao.getUserIndexForId(key)).thenReturn(migratedIndex);
UserIndexRegistrationService registrationService = Mockito.mock(UserIndexRegistrationService.class);
_service.setUserIndexRegistrationService(registrationService);
UserRegistration registration = new UserRegistration(1234, "5555");
Mockito.when(registrationService.getRegistrationForUserIndexKey(key)).thenReturn(registration);
UserPropertiesService userPropertiesService = Mockito.mock(UserPropertiesService.class);
_service.setUserPropertiesService(userPropertiesService);
User userB = createUser(1235);
UserIndex index = createUserIndex(key.getType(), key.getValue(), userB);
UserIndex updated = _service.completePhoneNumberRegistration(index, "5554");
assertTrue(updated == null);
updated = _service.completePhoneNumberRegistration(index, "5555");
assertTrue(updated != null);
Mockito.verify(userPropertiesService).mergeProperties(userB, userA);
}
Aggregations