use of easytests.core.models.UserModelInterface 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.models.UserModelInterface in project easy-tests by malinink.
the class UsersServiceTest method testSaveWithOptions.
@Test
public void testSaveWithOptions() throws Exception {
final UserModelInterface userModel = Models.createUserModel(null, "FirstName", "LastName", "Surname", "email@gmail.com", "hash", true, 1);
final UsersOptionsInterface usersOptions = Mockito.mock(UsersOptionsInterface.class);
this.usersService.save(userModel, usersOptions);
verify(usersOptions).saveWithRelations(userModel);
}
use of easytests.core.models.UserModelInterface in project easy-tests by malinink.
the class UsersServiceTest method testFindAbsentModel.
@Test
public void testFindAbsentModel() throws Exception {
final Integer id = 10;
given(this.usersMapper.find(id)).willReturn(null);
final UserModelInterface userModel = this.usersService.find(id);
Assert.assertEquals(null, userModel);
}
use of easytests.core.models.UserModelInterface in project easy-tests by malinink.
the class UsersServiceTest method mapUserModel.
private UserModelInterface mapUserModel(UserEntity userEntity) {
final UserModelInterface userModel = new UserModel();
userModel.map(userEntity);
return userModel;
}
use of easytests.core.models.UserModelInterface in project easy-tests by malinink.
the class SubjectsServiceTest method testFindByUser.
@Test
public void testFindByUser() throws Exception {
final Integer userId = 7;
final UserModelInterface userModel = Mockito.mock(UserModelInterface.class);
final SubjectEntity subjectEntityFirst = this.createSubjectEntityMock(3, "test3", "description3", userId);
final SubjectEntity subjectEntitySecond = this.createSubjectEntityMock(12, "test12", "description12", userId);
final List<SubjectEntity> subjectsEntities = new ArrayList<>();
subjectsEntities.add(subjectEntityFirst);
subjectsEntities.add(subjectEntitySecond);
Mockito.when(userModel.getId()).thenReturn(userId);
given(this.subjectsMapper.findByUserId(userId)).willReturn(subjectsEntities);
final List<SubjectModelInterface> subjectsModels = new ArrayList<>();
subjectsModels.add(this.mapSubjectModel(subjectEntityFirst));
subjectsModels.add(this.mapSubjectModel(subjectEntitySecond));
final List<SubjectModelInterface> foundedSubjectsModels = this.subjectsService.findByUser(userModel);
verify(this.subjectsMapper).findByUserId(userId);
Assert.assertEquals(subjectsModels, foundedSubjectsModels);
}
Aggregations