use of easytests.core.entities.UserEntity in project easy-tests by malinink.
the class UsersServiceTest method testFindAllWithOptions.
@Test
public void testFindAllWithOptions() throws Exception {
final List<UserEntity> usersEntities = this.getUsersEntities();
final List<UserModelInterface> usersModels = this.getUsersModels();
final UsersOptionsInterface usersOptions = Mockito.mock(UsersOptionsInterface.class);
given(this.usersMapper.findAll()).willReturn(usersEntities);
given(usersOptions.withRelations(Mockito.anyList())).willReturn(usersModels);
final List<UserModelInterface> foundedUsersModels = this.usersService.findAll(usersOptions);
verify(usersOptions).withRelations(usersModels);
Assert.assertEquals(usersModels, foundedUsersModels);
}
use of easytests.core.entities.UserEntity in project easy-tests by malinink.
the class UsersServiceTest method mapUserEntity.
private UserEntity mapUserEntity(UserModelInterface userModel) {
final UserEntity userEntity = new UserEntity();
userEntity.map(userModel);
return userEntity;
}
use of easytests.core.entities.UserEntity in project easy-tests by malinink.
the class UsersServiceTest method getUsersEntities.
private List<UserEntity> getUsersEntities() {
final List<UserEntity> usersEntities = new ArrayList<>(2);
final UserEntity userEntityFirst = Entities.createUserEntityMock(1, "FirstName1", "LastName1", "Surname1", "email1@gmail.com", "hash1", true, 1);
final UserEntity userEntitySecond = Entities.createUserEntityMock(2, "FirstName2", "LastName2", "Surname2", "email2@gmail.com", "hash2", false, 2);
usersEntities.add(userEntityFirst);
usersEntities.add(userEntitySecond);
return usersEntities;
}
use of easytests.core.entities.UserEntity in project easy-tests by malinink.
the class UsersServiceTest method testFindByEmailPresentModel.
@Test
public void testFindByEmailPresentModel() throws Exception {
final String email = "new.email@gmail.com";
final UserEntity userEntity = Entities.createUserEntityMock(1, "NewFirstName", "NewLastName1", "NewSurname1", email, "newhash1", false, 3);
given(this.usersMapper.findByEmail(email)).willReturn(userEntity);
final UserModelInterface userModel = this.usersService.findByEmail(email);
Assert.assertEquals(this.mapUserModel(userEntity), userModel);
}
use of easytests.core.entities.UserEntity in project easy-tests by malinink.
the class UsersMapperTest method testInsert.
@Test
public void testInsert() throws Exception {
final Integer id = this.usersMapper.findAll().size() + 1;
final String firstName = "FirstName";
final String lastName = "LastName";
final String surname = "Surname";
final String email = "email@gmail.com";
final String password = "hash";
final Boolean isAdmin = true;
final Integer state = 1;
UserEntity userEntity = Mockito.mock(UserEntity.class);
Mockito.when(userEntity.getFirstName()).thenReturn(firstName);
Mockito.when(userEntity.getLastName()).thenReturn(lastName);
Mockito.when(userEntity.getSurname()).thenReturn(surname);
Mockito.when(userEntity.getEmail()).thenReturn(email);
Mockito.when(userEntity.getPassword()).thenReturn(password);
Mockito.when(userEntity.getIsAdmin()).thenReturn(isAdmin);
Mockito.when(userEntity.getState()).thenReturn(state);
this.usersMapper.insert(userEntity);
verify(userEntity, times(1)).setId(id);
userEntity = this.usersMapper.find(id);
Assert.assertEquals(id, userEntity.getId());
Assert.assertEquals(firstName, userEntity.getFirstName());
Assert.assertEquals(lastName, userEntity.getLastName());
Assert.assertEquals(surname, userEntity.getSurname());
Assert.assertEquals(email, userEntity.getEmail());
Assert.assertEquals(password, userEntity.getPassword());
Assert.assertEquals(isAdmin, userEntity.getIsAdmin());
Assert.assertEquals(state, userEntity.getState());
}
Aggregations