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());
}
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);
}
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());
}
Aggregations