Search in sources :

Example 11 with TopicModelEmpty

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

the class QuestionModel method map.

public void map(QuestionEntity questionEntity) {
    this.setId(questionEntity.getId());
    this.setText(questionEntity.getText());
    this.setQuestionType(new QuestionTypeModelEmpty(questionEntity.getQuestionTypeId()));
    this.setTopic(new TopicModelEmpty(questionEntity.getTopicId()));
    this.setAnswers(new ModelsListEmpty());
}
Also used : TopicModelEmpty(easytests.core.models.empty.TopicModelEmpty) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty) QuestionTypeModelEmpty(easytests.core.models.empty.QuestionTypeModelEmpty)

Example 12 with TopicModelEmpty

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

the class IssueStandardTopicPrioritiesOptionsTest method testWithRelationsOnSingleModel.

@Test
public void testWithRelationsOnSingleModel() throws Exception {
    final IssueStandardTopicPrioritiesOptionsInterface topicPrioritiesOptions = new IssueStandardTopicPrioritiesOptions();
    final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
    final TopicsOptionsInterface topicsOptions = Mockito.mock(TopicsOptionsInterface.class);
    final IssueStandardsServiceInterface issueStandardsService = Mockito.mock(IssueStandardsServiceInterface.class);
    final IssueStandardsOptionsInterface issueStandardsOptions = Mockito.mock(IssueStandardsOptionsInterface.class);
    final Integer topicId = 3;
    final Integer issueStandardId = 10;
    final IssueStandardTopicPriorityModelInterface topicPriorityModel = Mockito.mock(IssueStandardTopicPriorityModelInterface.class);
    Mockito.when(topicPriorityModel.getTopic()).thenReturn(new TopicModelEmpty(topicId));
    Mockito.when(topicPriorityModel.getIssueStandard()).thenReturn(new IssueStandardModelEmpty(issueStandardId));
    final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
    Mockito.when(topicModel.getId()).thenReturn(topicId);
    given(topicsService.find(topicId, topicsOptions)).willReturn(topicModel);
    final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModel.getId()).thenReturn(issueStandardId);
    given(issueStandardsService.find(issueStandardId, issueStandardsOptions)).willReturn(issueStandardModel);
    // options не заданы
    final IssueStandardTopicPriorityModelInterface topicPriorityModelWithoutRelations = topicPrioritiesOptions.withRelations(topicPriorityModel);
    verify(topicsService, times(0)).find(topicId, topicsOptions);
    verify(issueStandardsService, times(0)).find(issueStandardId, issueStandardsOptions);
    Assert.assertEquals(topicPriorityModel, topicPriorityModelWithoutRelations);
    Mockito.verify(topicPriorityModel, times(0)).setTopic(topicModel);
    Mockito.verify(topicPriorityModel, times(0)).setIssueStandard(issueStandardModel);
    topicPrioritiesOptions.setIssueStandardsService(issueStandardsService);
    topicPrioritiesOptions.setTopicsService(topicsService);
    topicPrioritiesOptions.withTopic(topicsOptions).withIssueStandard(issueStandardsOptions);
    // теперь options заданы
    final IssueStandardTopicPriorityModelInterface topicPriorityModelWithRelations = topicPrioritiesOptions.withRelations(topicPriorityModel);
    verify(topicsService, times(1)).find(topicId, topicsOptions);
    verify(issueStandardsService, times(1)).find(issueStandardId, issueStandardsOptions);
    Assert.assertEquals(topicPriorityModel, topicPriorityModelWithRelations);
    Mockito.verify(topicPriorityModel, times(1)).setTopic(topicModel);
    Mockito.verify(topicPriorityModel, times(1)).setIssueStandard(issueStandardModel);
}
Also used : TopicModelEmpty(easytests.core.models.empty.TopicModelEmpty) IssueStandardsServiceInterface(easytests.core.services.IssueStandardsServiceInterface) IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with TopicModelEmpty

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

the class QuestionModelTest method testMap.

@Test
public void testMap() throws Exception {
    final Integer questionId = 1;
    final String text = "test1";
    final Integer questionTypeId = 1;
    final Integer topicId = 1;
    final QuestionEntity questionEntity = Mockito.mock(QuestionEntity.class);
    Mockito.when(questionEntity.getId()).thenReturn(questionId);
    Mockito.when(questionEntity.getText()).thenReturn(text);
    Mockito.when(questionEntity.getQuestionTypeId()).thenReturn(questionTypeId);
    Mockito.when(questionEntity.getTopicId()).thenReturn(topicId);
    final QuestionModel questionModel = new QuestionModel();
    questionModel.map(questionEntity);
    Assert.assertEquals(questionId, questionModel.getId());
    Assert.assertEquals(text, questionModel.getText());
    Assert.assertEquals(new QuestionTypeModelEmpty(questionEntity.getQuestionTypeId()), questionModel.getQuestionType());
    Assert.assertEquals(new ModelsListEmpty(), questionModel.getAnswers());
    Assert.assertEquals(new TopicModelEmpty(questionEntity.getTopicId()), questionModel.getTopic());
}
Also used : TopicModelEmpty(easytests.core.models.empty.TopicModelEmpty) QuestionEntity(easytests.core.entities.QuestionEntity) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty) QuestionTypeModelEmpty(easytests.core.models.empty.QuestionTypeModelEmpty) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

TopicModelEmpty (easytests.core.models.empty.TopicModelEmpty)13 Test (org.junit.Test)8 QuestionTypeModelEmpty (easytests.core.models.empty.QuestionTypeModelEmpty)7 IssueStandardModelEmpty (easytests.core.models.empty.IssueStandardModelEmpty)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)5 TopicModelInterface (easytests.core.models.TopicModelInterface)4 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)4 IssueStandardTopicPriorityModelInterface (easytests.core.models.IssueStandardTopicPriorityModelInterface)3 QuestionModelInterface (easytests.core.models.QuestionModelInterface)3 ArrayList (java.util.ArrayList)3 AnswerModelInterface (easytests.core.models.AnswerModelInterface)2 IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)2 QuestionTypeModelInterface (easytests.core.models.QuestionTypeModelInterface)2 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)2 IssueStandardsServiceInterface (easytests.core.services.IssueStandardsServiceInterface)2 QuestionTypesServiceInterface (easytests.core.services.QuestionTypesServiceInterface)2 IssueStandardTopicPriorityEntity (easytests.core.entities.IssueStandardTopicPriorityEntity)1 QuestionEntity (easytests.core.entities.QuestionEntity)1