use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.
the class SubjectsSupport method getEntityMock.
private SubjectEntity getEntityMock(Integer id, String name, String description, Integer userId) {
final SubjectEntity subjectEntity = Mockito.mock(SubjectEntity.class);
Mockito.when(subjectEntity.getId()).thenReturn(id);
Mockito.when(subjectEntity.getName()).thenReturn(name);
Mockito.when(subjectEntity.getDescription()).thenReturn(description);
Mockito.when(subjectEntity.getUserId()).thenReturn(userId);
return subjectEntity;
}
use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.
the class SubjectsMapperTest method testFindByUserId.
@Test
public void testFindByUserId() throws Exception {
final List<SubjectEntity> subjectsFixtureEntities = new ArrayList<>();
subjectsFixtureEntities.add(this.subjectsSupport.getEntityFixtureMock(0));
subjectsFixtureEntities.add(this.subjectsSupport.getEntityFixtureMock(1));
final List<SubjectEntity> subjectsFoundedEntities = this.subjectsMapper.findByUserId(2);
Assert.assertEquals(2, subjectsFoundedEntities.size());
Integer index = 0;
for (SubjectEntity subjectEntity : subjectsFoundedEntities) {
this.subjectsSupport.assertEquals(subjectsFixtureEntities.get(index), subjectEntity);
index++;
}
}
use of easytests.core.entities.SubjectEntity 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);
}
use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.
the class SubjectsMapperTest method testFind.
@Test
public void testFind() throws Exception {
final SubjectEntity subject = this.subjectsMapper.find(1);
Assert.assertEquals((long) 1, (long) subject.getId());
Assert.assertEquals("test1", subject.getName());
Assert.assertEquals("testdescription1", subject.getDescription());
}
Aggregations