use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.
the class UserDaoImplTest method testUpdateUser_expectChangedValueAfterUpdate.
@Test
public void testUpdateUser_expectChangedValueAfterUpdate() throws Exception {
User userToCreate = UserFactory.createNewUserTemplate();
userToCreate.setDisplayName("old display name");
userToCreate = userService.createUser(userToCreate);
userToCreate.setDisplayName("new display name");
userService.updateUser(userToCreate);
User foundUser = userService.getUserByUuid(userToCreate.getUuid());
assertEquals(userToCreate.getDisplayName(), foundUser.getDisplayName());
}
use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.
the class EntityChangedEventAdapterTest method testDeserializeExpectOkForAllowedClass.
@Test
@SuppressWarnings("unchecked")
public void testDeserializeExpectOkForAllowedClass() {
Gson gson = getFixture();
EntityChangedEvent<User> evt = gson.fromJson("{\"ct\": \"asdasd\", \"vt\": \"org.summerb.microservices.users.api.dto.User\", \"v\": {\"email\": \"asd\"}}", EntityChangedEvent.class);
assertNotNull(evt);
assertEquals("asd", evt.getValue().getEmail());
}
use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.
the class UserServiceImplFactory method createUsersServiceImpl.
public static UserServiceImpl createUsersServiceImpl() {
UserServiceImpl ret = new UserServiceImpl();
UserDao userDao = Mockito.mock(UserDao.class);
ret.setUserDao(userDao);
ret.setEventBus(Mockito.mock(EventBus.class));
User existingUser = UserFactory.createExistingUser();
when(userDao.findUserByUuid(UserFactory.EXISTENT_USER)).thenReturn(existingUser);
when(userDao.findUserByUuid(UserFactory.EXISTENT_USER_2_PROBLEM_WITH_PASSWORD)).thenReturn(UserFactory.createExistingUser2());
when(userDao.findUserByUuid(UserFactory.EXISTENT_USER_WITH_MISSING_PASSWORD)).thenReturn(UserFactory.createUserWithMissingPassword());
when(userDao.findUserByUuid(UserFactory.NON_EXISTENT_USER)).thenReturn(null);
when(userDao.findUserByUuid(UserFactory.USER_RESULT_IN_EXCEPTION)).thenThrow(new IllegalStateException("Simulate unexpected excception"));
when(userDao.findUserByEmail(UserFactory.EXISTENT_USER_EMAIL)).thenReturn(existingUser);
when(userDao.findUserByEmail(UserFactory.NON_EXISTENT_USER_EMAIL)).thenReturn(null);
when(userDao.findUserByEmail(UserFactory.USER_EMAIL_RESULT_IN_EXCEPTION)).thenThrow(new IllegalStateException("Simulate unexpected excception"));
when(userDao.findUserByDisplayNamePartial(eq(UserFactory.EXISTENT_USER), any(PagerParams.class))).thenThrow(new IllegalStateException("Simulate unexpected excception"));
when(userDao.findUserByUuid(UserFactory.EXISTENT_USER_WITH_EXPIRED_TOKEN)).thenReturn(UserFactory.createUserWithExpiredToken());
when(userDao.updateUser(UserFactory.createDuplicateUser())).thenThrow(new DuplicateKeyException("Simulate unexpected excception"));
return ret;
}
use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.
the class UserServiceImplTest method testCreateUser_whitebox_expectDuplicateUserException.
@Test(expected = FieldValidationException.class)
public void testCreateUser_whitebox_expectDuplicateUserException() throws Exception {
UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl();
User user = UserFactory.createNewUserTemplate();
doThrow(new DuplicateKeyException("duplicate user")).when(fixture.getUserDao()).createUser(any(User.class));
fixture.createUser(user);
fail();
}
use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.
the class UserServiceImplTest method testGetUserByEmail_blackbox_expectFoundUser.
@Test
public void testGetUserByEmail_blackbox_expectFoundUser() throws Exception {
UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl();
when(fixture.getUserDao().findUserByEmail(any(String.class))).thenReturn(UserFactory.createNewUserTemplate());
User user = fixture.getUserByEmail(UserFactory.createNewUserTemplate().getEmail());
assertNotNull(user);
}
Aggregations