Search in sources :

Example 16 with TopicEntity

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;
}
Also used : TopicEntity(easytests.core.entities.TopicEntity)

Example 17 with TopicEntity

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);
}
Also used : TopicEntity(easytests.core.entities.TopicEntity) SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 18 with TopicEntity

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);
}
Also used : TopicsOptionsInterface(easytests.core.options.TopicsOptionsInterface) TopicEntity(easytests.core.entities.TopicEntity) SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 19 with TopicEntity

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;
}
Also used : TopicEntity(easytests.core.entities.TopicEntity) ArrayList(java.util.ArrayList)

Example 20 with TopicEntity

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);
}
Also used : TopicEntity(easytests.core.entities.TopicEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

TopicEntity (easytests.core.entities.TopicEntity)21 Test (org.junit.Test)15 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)12 TopicModelInterface (easytests.core.models.TopicModelInterface)8 SubjectModelInterface (easytests.core.models.SubjectModelInterface)4 TopicsOptionsInterface (easytests.core.options.TopicsOptionsInterface)4 ArrayList (java.util.ArrayList)4 List (java.util.List)2 DeleteUnidentifiedModelException (easytests.core.services.exceptions.DeleteUnidentifiedModelException)1