Search in sources :

Example 36 with TopicModelInterface

use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.

the class TopicsServiceTest method testFindPresentModel.

@Test
public void testFindPresentModel() throws Exception {
    final TopicEntity topicExistentEntity = this.topicsSupport.getEntityFixtureMock(0);
    when(this.topicsMapper.find(topicExistentEntity.getId())).thenReturn(topicExistentEntity);
    final TopicModelInterface topicFoundedModel = this.topicsService.find(topicExistentEntity.getId());
    this.topicsSupport.assertEquals(this.topicsSupport.getModelFixtureMock(0), topicFoundedModel);
}
Also used : TopicEntity(easytests.core.entities.TopicEntity) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 37 with TopicModelInterface

use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.

the class TopicsServiceTest method testFindAllWithOptions.

@Test
public void testFindAllWithOptions() throws Exception {
    final ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
    final List<TopicEntity> topicsEntities = this.getTopicsFixturesEntities();
    final List<TopicModelInterface> topicsModels = this.getTopicsFixturesModels();
    final TopicsOptionsInterface topicsOptions = mock(TopicsOptionsInterface.class);
    when(this.topicsMapper.findAll()).thenReturn(topicsEntities);
    when(topicsOptions.withRelations(listCaptor.capture())).thenReturn(topicsModels);
    final List<TopicModelInterface> topicsFoundedModels = this.topicsService.findAll(topicsOptions);
    this.topicsSupport.assertModelsListEquals(topicsModels, listCaptor.getValue());
    Assert.assertSame(topicsModels, topicsFoundedModels);
    this.assertServicesSet(topicsOptions);
}
Also used : TopicsOptionsInterface(easytests.core.options.TopicsOptionsInterface) TopicEntity(easytests.core.entities.TopicEntity) ArrayList(java.util.ArrayList) List(java.util.List) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 38 with TopicModelInterface

use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.

the class TopicsSupport method assertModelsListEquals.

public void assertModelsListEquals(List<TopicModelInterface> expected, List<TopicModelInterface> actual) {
    Assert.assertEquals(expected.size(), actual.size());
    Integer i = 0;
    for (TopicModelInterface topicModel : expected) {
        this.assertEquals(topicModel, actual.get(i));
        i++;
    }
}
Also used : TopicModelInterface(easytests.core.models.TopicModelInterface)

Example 39 with TopicModelInterface

use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.

the class TopicsSupport method getModelMock.

private TopicModelInterface getModelMock(Integer id, String name, Integer subjectId) {
    final TopicModelInterface topicModelMock = Mockito.mock(TopicModelInterface.class);
    Mockito.when(topicModelMock.getId()).thenReturn(id);
    Mockito.when(topicModelMock.getName()).thenReturn(name);
    Mockito.when(topicModelMock.getSubject()).thenReturn(new SubjectModelEmpty(subjectId));
    Mockito.when(topicModelMock.getQuestions()).thenReturn(new ModelsListEmpty());
    return topicModelMock;
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty) TopicModelInterface(easytests.core.models.TopicModelInterface)

Example 40 with TopicModelInterface

use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.

the class TopicEntityTest method testMap.

@Test
public void testMap() throws Exception {
    final TopicModelInterface topicModelMock = this.topicsSupport.getModelFixtureMock(0);
    final TopicEntity topicEntity = new TopicEntity();
    topicEntity.map(topicModelMock);
    this.topicsSupport.assertEquals(topicModelMock, topicEntity);
}
Also used : TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test)

Aggregations

TopicModelInterface (easytests.core.models.TopicModelInterface)52 Test (org.junit.Test)34 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)32 SubjectModelInterface (easytests.core.models.SubjectModelInterface)18 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)16 ArrayList (java.util.ArrayList)15 QuestionModelInterface (easytests.core.models.QuestionModelInterface)14 TopicsOptionsInterface (easytests.core.options.TopicsOptionsInterface)9 TopicEntity (easytests.core.entities.TopicEntity)8 QuestionsServiceInterface (easytests.core.services.QuestionsServiceInterface)7 InOrder (org.mockito.InOrder)6 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)5 AnswerModelInterface (easytests.core.models.AnswerModelInterface)4 TopicModelEmpty (easytests.core.models.empty.TopicModelEmpty)4 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 QuestionEntity (easytests.core.entities.QuestionEntity)3 QuestionTypeModelInterface (easytests.core.models.QuestionTypeModelInterface)3 SubjectModel (easytests.core.models.SubjectModel)3 TopicModel (easytests.core.models.TopicModel)3