use of easytests.core.models.UserModelInterface in project easy-tests by malinink.
the class UsersServiceTest method testSaveUpdatesEntity.
@Test
public void testSaveUpdatesEntity() throws Exception {
final UserModelInterface userModel = Models.createUserModel(1, "FirstName", "LastName", "Surname", "email@gmail.com", "hash", true, 1);
this.usersService.save(userModel);
verify(this.usersMapper, times(1)).update(this.mapUserEntity(userModel));
}
use of easytests.core.models.UserModelInterface in project easy-tests by malinink.
the class UsersServiceTest method testFindByEmailAbsentModel.
@Test
public void testFindByEmailAbsentModel() throws Exception {
final String email = "absent.email@gmail.com";
given(this.usersMapper.findByEmail(email)).willReturn(null);
final UserModelInterface userModel = this.usersService.findByEmail(email);
Assert.assertEquals(null, userModel);
}
use of easytests.core.models.UserModelInterface in project easy-tests by malinink.
the class UsersServiceTest method testFindPresentModel.
@Test
public void testFindPresentModel() throws Exception {
final Integer id = 1;
final UserEntity userEntity = Entities.createUserEntityMock(id, "NewFirstName", "NewLastName1", "NewSurname1", "new.email@gmail.com", "newhash1", false, 3);
given(this.usersMapper.find(id)).willReturn(userEntity);
final UserModelInterface userModel = this.usersService.find(id);
Assert.assertEquals(this.mapUserModel(userEntity), userModel);
}
use of easytests.core.models.UserModelInterface 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.models.UserModelInterface in project easy-tests by malinink.
the class UsersServiceTest method testDeleteWithOptions.
@Test
public void testDeleteWithOptions() throws Exception {
final UserModelInterface userModel = Models.createUserModel(1, "FirstName", "LastName", "Surname", "email@gmail.com", "hash", true, 1);
final UsersOptionsInterface usersOptions = Mockito.mock(UsersOptionsInterface.class);
this.usersService.delete(userModel, usersOptions);
verify(usersOptions).deleteWithRelations(userModel);
}
Aggregations