use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.
the class SubjectsServiceTest method testFindByUserPresentList.
@Test
public void testFindByUserPresentList() throws Exception {
final UserModelInterface userModel = this.usersSupport.getModelFixtureMock(0);
final List<SubjectEntity> subjectsEntities = this.getSubjectsFixturesEntities();
when(this.subjectsMapper.findByUserId(userModel.getId())).thenReturn(subjectsEntities);
final List<SubjectModelInterface> subjectsFoundedModels = this.subjectsService.findByUser(userModel);
this.subjectsSupport.assertModelsListEquals(this.getSubjectsFixturesModels(), subjectsFoundedModels);
}
use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.
the class SubjectsMapperTest method testFindAll.
@Test
public void testFindAll() throws Exception {
final List<SubjectEntity> subjectsFoundedEntities = this.subjectsMapper.findAll();
Assert.assertEquals(3, subjectsFoundedEntities.size());
Integer index = 0;
for (SubjectEntity subjectEntity : subjectsFoundedEntities) {
final SubjectEntity subjectFixtureEntity = this.subjectsSupport.getEntityFixtureMock(index);
this.subjectsSupport.assertEquals(subjectFixtureEntity, subjectEntity);
index++;
}
}
use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.
the class SubjectsServiceTest method testFindWithOptions.
@Test
public void testFindWithOptions() throws Exception {
final Integer id = 1;
final Integer userId = 1;
final SubjectEntity subjectEntity = this.createSubjectEntityMock(4, "test3", "description3", userId);
final SubjectModelInterface subjectModel = this.mapSubjectModel(subjectEntity);
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
given(this.subjectsMapper.find(id)).willReturn(subjectEntity);
given(subjectsOptions.withRelations(subjectModel)).willReturn(subjectModel);
final SubjectModelInterface foundedSubjectModel = this.subjectsService.find(id, subjectsOptions);
Assert.assertEquals(subjectModel, foundedSubjectModel);
verify(subjectsOptions).withRelations(subjectModel);
}
use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.
the class SubjectsServiceTest method testFindAllWithOptions.
@Test
public void testFindAllWithOptions() throws Exception {
final List<SubjectEntity> subjectsEntities = this.getSubjectsEntities();
final List<SubjectModelInterface> subjectsModels = this.getUsersModels();
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
given(this.subjectsMapper.findAll()).willReturn(subjectsEntities);
given(subjectsOptions.withRelations(Mockito.anyList())).willReturn(subjectsModels);
final List<SubjectModelInterface> foundedSubjectsModels = this.subjectsService.findAll(subjectsOptions);
verify(subjectsOptions).withRelations(foundedSubjectsModels);
Assert.assertEquals(subjectsModels, foundedSubjectsModels);
}
use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.
the class SubjectsServiceTest method testFindByUserWithOptions.
@Test
public void testFindByUserWithOptions() 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);
given(userModel.getId()).willReturn(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 SubjectsOptionsInterface subjectOptions = Mockito.mock(SubjectsOptionsInterface.class);
given(subjectOptions.withRelations(subjectsModels)).willReturn(subjectsModels);
final List<SubjectModelInterface> foundedSubjectsModels = this.subjectsService.findByUser(userModel, subjectOptions);
verify(this.subjectsMapper).findByUserId(userId);
verify(subjectOptions).withRelations(subjectsModels);
Assert.assertEquals(subjectsModels, foundedSubjectsModels);
}
Aggregations