use of easytests.core.entities.UserEntity in project easy-tests by malinink.
the class UsersServiceTest method testSaveUpdateEntityIdOnCreation.
@Test
public void testSaveUpdateEntityIdOnCreation() throws Exception {
final UserModelInterface userAdditionalModel = this.usersSupport.getModelAdditionalMock(0);
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(userAdditionalModel);
verify(userAdditionalModel, times(1)).setId(5);
}
use of easytests.core.entities.UserEntity in project easy-tests by malinink.
the class UsersSupport method assertEntitiesListEquals.
public void assertEntitiesListEquals(List<UserEntity> expected, List<UserEntity> actual) {
Assert.assertEquals(expected.size(), actual.size());
Integer i = 0;
for (UserEntity userEntity : expected) {
this.assertEquals(userEntity, actual.get(i));
i++;
}
}
use of easytests.core.entities.UserEntity in project easy-tests by malinink.
the class UsersServiceTest method testFindByEmailWithOptions.
@Test
public void testFindByEmailWithOptions() throws Exception {
final String email = "new.email@gmail.com";
final UserEntity userEntity = Entities.createUserEntityMock(1, "NewFirstName", "NewLastName1", "NewSurname1", email, "newhash1", false, 3);
final UserModelInterface userModel = this.mapUserModel(userEntity);
final UsersOptionsInterface usersOptions = Mockito.mock(UsersOptionsInterface.class);
given(this.usersMapper.findByEmail(email)).willReturn(userEntity);
given(usersOptions.withRelations(userModel)).willReturn(userModel);
final UserModelInterface foundedUserModel = this.usersService.findByEmail(email, usersOptions);
Assert.assertEquals(userModel, foundedUserModel);
verify(usersOptions).withRelations(userModel);
}
use of easytests.core.entities.UserEntity in project easy-tests by malinink.
the class UsersServiceTest method testFindWithOptions.
@Test
public void testFindWithOptions() throws Exception {
final Integer id = 1;
final UserEntity userEntity = Entities.createUserEntityMock(id, "NewFirstName", "NewLastName1", "NewSurname1", "new.email@gmail.com", "newhash1", false, 3);
final UserModelInterface userModel = this.mapUserModel(userEntity);
final UsersOptionsInterface usersOptions = Mockito.mock(UsersOptionsInterface.class);
given(this.usersMapper.find(id)).willReturn(userEntity);
given(usersOptions.withRelations(userModel)).willReturn(userModel);
final UserModelInterface foundedUserModel = this.usersService.find(id, usersOptions);
Assert.assertEquals(userModel, foundedUserModel);
verify(usersOptions).withRelations(userModel);
}
use of easytests.core.entities.UserEntity 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);
}
Aggregations