use of easytests.core.entities.TopicEntity in project easy-tests by malinink.
the class TopicsSupport method getEntityMock.
private TopicEntity getEntityMock(Integer id, String name, Integer subjectId) {
final TopicEntity topicEntityMock = Mockito.mock(TopicEntity.class);
Mockito.when(topicEntityMock.getId()).thenReturn(id);
Mockito.when(topicEntityMock.getName()).thenReturn(name);
Mockito.when(topicEntityMock.getSubjectId()).thenReturn(subjectId);
return topicEntityMock;
}
use of easytests.core.entities.TopicEntity in project easy-tests by malinink.
the class TopicsServiceTest method testFindBySubject.
@Test
public void testFindBySubject() throws Exception {
final Integer subjectId = 3;
final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
final List<TopicEntity> topicsEntities = this.getTopicsEntities();
final List<TopicModelInterface> topicsModels = getTopicsModels();
Mockito.when(subjectModel.getId()).thenReturn(subjectId);
given(this.topicsMapper.findBySubjectId(subjectId)).willReturn(topicsEntities);
final List<TopicModelInterface> foundedTopicsModels = this.topicsService.findBySubject(subjectModel);
verify(this.topicsMapper).findBySubjectId(subjectId);
Assert.assertEquals(topicsModels, foundedTopicsModels);
}
use of easytests.core.entities.TopicEntity in project easy-tests by malinink.
the class TopicsServiceTest method testFindByUserWithOptions.
@Test
public void testFindByUserWithOptions() throws Exception {
final Integer subjectId = 3;
final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
final List<TopicEntity> topicsEntities = this.getTopicsEntities();
final List<TopicModelInterface> topicsModels = this.getTopicsModels();
given(subjectModel.getId()).willReturn(subjectId);
given(this.topicsMapper.findBySubjectId(subjectId)).willReturn(topicsEntities);
final TopicsOptionsInterface topicOptions = Mockito.mock(TopicsOptionsInterface.class);
given(topicOptions.withRelations(topicsModels)).willReturn(topicsModels);
final List<TopicModelInterface> foundedTopicsModels = this.topicsService.findBySubject(subjectModel, topicOptions);
verify(this.topicsMapper).findBySubjectId(subjectId);
verify(topicOptions).withRelations(topicsModels);
Assert.assertEquals(topicsModels, foundedTopicsModels);
}
use of easytests.core.entities.TopicEntity in project easy-tests by malinink.
the class TopicsServiceTest method getTopicsEntities.
private List<TopicEntity> getTopicsEntities() {
final TopicEntity topicEntityFirst = Entities.createTopicEntityMock(4, 3, "testfirst");
final TopicEntity topicEntitySecond = Entities.createTopicEntityMock(5, 3, "testsecond");
final List<TopicEntity> topicsEntities = new ArrayList<>();
topicsEntities.add(topicEntityFirst);
topicsEntities.add(topicEntitySecond);
return topicsEntities;
}
use of easytests.core.entities.TopicEntity in project easy-tests by malinink.
the class TopicsMapperTest method testDelete.
@Test
public void testDelete() throws Exception {
TopicEntity topicEntity = this.topicsMapper.find(1);
Assert.assertNotNull(topicEntity);
this.topicsMapper.delete(topicEntity);
topicEntity = this.topicsMapper.find(1);
Assert.assertNull(topicEntity);
}
Aggregations