use of easytests.core.entities.UserEntity in project easy-tests by malinink.
the class UsersServiceTest method testSaveCreatesEntity.
@Test
public void testSaveCreatesEntity() throws Exception {
final UserModelInterface userModel = Models.createUserModel(null, "FirstName", "LastName", "Surname", "email@gmail.com", "hash", true, 1);
doAnswer(invocation -> {
final UserEntity userEntity = (UserEntity) invocation.getArguments()[0];
userEntity.setId(5);
return null;
}).when(this.usersMapper).insert(Mockito.any(UserEntity.class));
this.usersService.save(userModel);
verify(this.usersMapper, times(1)).insert(this.mapUserEntity(userModel));
Assert.assertEquals((Integer) 5, userModel.getId());
}
use of easytests.core.entities.UserEntity in project easy-tests by malinink.
the class UsersService method save.
@Override
public void save(UserModelInterface userModel) {
final UserEntity userEntity = this.map(userModel);
if (userEntity.getId() == null) {
this.usersMapper.insert(userEntity);
userModel.setId(userEntity.getId());
return;
}
this.usersMapper.update(userEntity);
}
use of easytests.core.entities.UserEntity in project easy-tests by malinink.
the class UsersService method delete.
@Override
public void delete(UserModelInterface userModel) {
final UserEntity userEntity = this.map(userModel);
if (userEntity.getId() == null) {
throw new DeleteUnidentifiedModelException();
}
this.usersMapper.delete(userEntity);
}
use of easytests.core.entities.UserEntity in project easy-tests by malinink.
the class UserModelTest method testMap.
@Test
public void testMap() throws Exception {
final Integer userId = 3;
final String firstName = "FirstName";
final String lastName = "LastName";
final String surname = "Surname";
final String email = "email";
final String password = "password";
final Boolean isAdmin = false;
final Integer state = 2;
final UserEntity userEntity = Entities.createUserEntityMock(userId, firstName, lastName, surname, email, password, isAdmin, state);
final UserModel userModel = new UserModel();
userModel.map(userEntity);
Assert.assertEquals(userId, userModel.getId());
Assert.assertEquals(firstName, userModel.getFirstName());
Assert.assertEquals(lastName, userModel.getLastName());
Assert.assertEquals(surname, userModel.getSurname());
Assert.assertEquals(email, userModel.getEmail());
Assert.assertEquals(password, userModel.getPassword());
Assert.assertEquals(isAdmin, userModel.getIsAdmin());
Assert.assertEquals(state, userModel.getState());
Assert.assertEquals(new ModelsListEmpty(), userModel.getSubjects());
}
use of easytests.core.entities.UserEntity in project easy-tests by malinink.
the class UsersMapperTest method testFindByEmail.
@Test
public void testFindByEmail() throws Exception {
final UserEntity userEntity = this.usersMapper.findByEmail("email1@gmail.com");
Assert.assertEquals((Integer) 1, userEntity.getId());
Assert.assertEquals("FirstName1", userEntity.getFirstName());
Assert.assertEquals("LastName1", userEntity.getLastName());
Assert.assertEquals("Surname1", userEntity.getSurname());
Assert.assertEquals("email1@gmail.com", userEntity.getEmail());
Assert.assertEquals("hash1", userEntity.getPassword());
Assert.assertEquals(true, userEntity.getIsAdmin());
Assert.assertEquals((Integer) 1, userEntity.getState());
}
Aggregations