Search in sources :

Example 1 with TopicModelEmpty

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

the class IssueStandardTopicPriorityModel method map.

public void map(IssueStandardTopicPriorityEntity topicPriorityEntity) {
    this.setId(topicPriorityEntity.getId());
    this.setTopic(new TopicModelEmpty(topicPriorityEntity.getTopicId()));
    this.setIsPreferable(topicPriorityEntity.getIsPreferable());
    this.setIssueStandard(new IssueStandardModelEmpty(topicPriorityEntity.getIssueStandardId()));
}
Also used : TopicModelEmpty(easytests.core.models.empty.TopicModelEmpty) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty)

Example 2 with TopicModelEmpty

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

the class IssueStandardTopicPrioritiesOptionsTest method testWithRelationsOnModelsList.

@Test
public void testWithRelationsOnModelsList() 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 topicIdFirst = 3;
    final Integer topicIdSecond = 5;
    final Integer issueStandardIdFirst = 10;
    final Integer issueStandardIdSecond = 20;
    IssueStandardTopicPriorityModelInterface topicPriorityModelFirst = Mockito.mock(IssueStandardTopicPriorityModelInterface.class);
    IssueStandardTopicPriorityModelInterface topicPriorityModelSecond = Mockito.mock(IssueStandardTopicPriorityModelInterface.class);
    Mockito.when(topicPriorityModelFirst.getIssueStandard()).thenReturn(new IssueStandardModelEmpty(issueStandardIdFirst));
    Mockito.when(topicPriorityModelFirst.getTopic()).thenReturn(new TopicModelEmpty(topicIdFirst));
    Mockito.when(topicPriorityModelSecond.getIssueStandard()).thenReturn(new IssueStandardModelEmpty(issueStandardIdSecond));
    Mockito.when(topicPriorityModelSecond.getTopic()).thenReturn(new TopicModelEmpty(topicIdSecond));
    final List<IssueStandardTopicPriorityModelInterface> topicPriorityModels = new ArrayList<>(2);
    topicPriorityModels.add(topicPriorityModelFirst);
    topicPriorityModels.add(topicPriorityModelSecond);
    final TopicModelInterface topicModelFirst = Mockito.mock(TopicModelInterface.class);
    Mockito.when(topicModelFirst.getId()).thenReturn(topicIdFirst);
    given(topicsService.find(topicIdFirst, topicsOptions)).willReturn(topicModelFirst);
    final TopicModelInterface topicModelSecond = Mockito.mock(TopicModelInterface.class);
    Mockito.when(topicModelSecond.getId()).thenReturn(topicIdSecond);
    given(topicsService.find(topicIdSecond, topicsOptions)).willReturn(topicModelSecond);
    final IssueStandardModelInterface issueStandardModelFirst = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModelFirst.getId()).thenReturn(issueStandardIdFirst);
    given(issueStandardsService.find(issueStandardIdFirst, issueStandardsOptions)).willReturn(issueStandardModelFirst);
    final IssueStandardModelInterface issueStandardModelSecond = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModelSecond.getId()).thenReturn(issueStandardIdSecond);
    given(issueStandardsService.find(issueStandardIdSecond, issueStandardsOptions)).willReturn(issueStandardModelSecond);
    // options не заданы
    final List<IssueStandardTopicPriorityModelInterface> topicPriorityModelsWithoutRelations = topicPrioritiesOptions.withRelations(topicPriorityModels);
    verify(topicsService, times(0)).find(topicIdFirst, topicsOptions);
    verify(topicsService, times(0)).find(topicIdSecond, topicsOptions);
    verify(issueStandardsService, times(0)).find(issueStandardIdFirst, issueStandardsOptions);
    verify(issueStandardsService, times(0)).find(issueStandardIdSecond, issueStandardsOptions);
    Assert.assertEquals(topicPriorityModels, topicPriorityModelsWithoutRelations);
    Mockito.verify(topicPriorityModelFirst, times(0)).setTopic(topicModelFirst);
    Mockito.verify(topicPriorityModelSecond, times(0)).setTopic(topicModelSecond);
    Mockito.verify(topicPriorityModelFirst, times(0)).setIssueStandard(issueStandardModelFirst);
    Mockito.verify(topicPriorityModelSecond, times(0)).setIssueStandard(issueStandardModelSecond);
    topicPrioritiesOptions.setIssueStandardsService(issueStandardsService);
    topicPrioritiesOptions.setTopicsService(topicsService);
    topicPrioritiesOptions.withTopic(topicsOptions).withIssueStandard(issueStandardsOptions);
    // теперь options заданы
    final List<IssueStandardTopicPriorityModelInterface> topicPriorityModelsWithRelations = topicPrioritiesOptions.withRelations(topicPriorityModels);
    verify(topicsService, times(1)).find(topicIdFirst, topicsOptions);
    verify(topicsService, times(1)).find(topicIdSecond, topicsOptions);
    verify(issueStandardsService, times(1)).find(issueStandardIdFirst, issueStandardsOptions);
    verify(issueStandardsService, times(1)).find(issueStandardIdSecond, issueStandardsOptions);
    Assert.assertEquals(topicPriorityModels, topicPriorityModelsWithRelations);
    Mockito.verify(topicPriorityModelFirst, times(1)).setTopic(topicModelFirst);
    Mockito.verify(topicPriorityModelSecond, times(1)).setTopic(topicModelSecond);
    Mockito.verify(topicPriorityModelFirst, times(1)).setIssueStandard(issueStandardModelFirst);
    Mockito.verify(topicPriorityModelSecond, times(1)).setIssueStandard(issueStandardModelSecond);
}
Also used : IssueStandardsServiceInterface(easytests.core.services.IssueStandardsServiceInterface) ArrayList(java.util.ArrayList) TopicModelInterface(easytests.core.models.TopicModelInterface) TopicModelEmpty(easytests.core.models.empty.TopicModelEmpty) IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with TopicModelEmpty

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

the class QuestionsOptionsTest method testWithRelationsOnSingleModel.

@Test
public void testWithRelationsOnSingleModel() throws Exception {
    final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
    questionModel.setId(1);
    given(questionModel.getTopic()).willReturn(new TopicModelEmpty(1));
    given(questionModel.getQuestionType()).willReturn(new QuestionTypeModelEmpty(1));
    final QuestionsOptionsInterface questionsOptions = new QuestionsOptions();
    final AnswersServiceInterface answersService = Mockito.mock(AnswersServiceInterface.class);
    final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
    final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
    final TopicsOptionsInterface topicsOptions = Mockito.mock(TopicsOptionsInterface.class);
    final QuestionTypesServiceInterface questionTypesService = Mockito.mock(QuestionTypesServiceInterface.class);
    final QuestionTypesOptionsInterface questionTypesOptions = Mockito.mock(QuestionTypesOptionsInterface.class);
    questionsOptions.setAnswersService(answersService);
    questionsOptions.withAnswers(answersOptions);
    questionsOptions.setTopicsService(topicsService);
    questionsOptions.withTopic(topicsOptions);
    questionsOptions.setQuestionTypesService(questionTypesService);
    questionsOptions.withQuestionType(questionTypesOptions);
    final List<AnswerModelInterface> answersModels = new ArrayList<>();
    answersModels.add(Mockito.mock(AnswerModelInterface.class));
    TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
    QuestionTypeModelInterface questionTypeModel = Mockito.mock(QuestionTypeModelInterface.class);
    given(answersService.findByQuestion(questionModel, answersOptions)).willReturn(answersModels);
    given(topicsService.find(questionModel.getTopic().getId(), topicsOptions)).willReturn(topicModel);
    given(questionTypesService.find(questionModel.getQuestionType().getId(), questionTypesOptions)).willReturn(questionTypeModel);
    final QuestionModelInterface questionModelWithRelations = questionsOptions.withRelations(questionModel);
    Assert.assertEquals(questionModel, questionModelWithRelations);
    verify(answersService).findByQuestion(questionModel, answersOptions);
    verify(topicsService).find(questionModel.getTopic().getId(), topicsOptions);
    verify(questionTypesService).find(questionModel.getQuestionType().getId(), questionTypesOptions);
    verify(questionModel).setAnswers(answersModels);
    verify(questionModel).setTopic(topicModel);
    verify(questionModel).setQuestionType(questionTypeModel);
    verify(questionModel).setAnswers(Mockito.anyList());
}
Also used : QuestionTypesServiceInterface(easytests.core.services.QuestionTypesServiceInterface) QuestionModelInterface(easytests.core.models.QuestionModelInterface) ArrayList(java.util.ArrayList) AnswersServiceInterface(easytests.core.services.AnswersServiceInterface) QuestionTypeModelEmpty(easytests.core.models.empty.QuestionTypeModelEmpty) TopicModelInterface(easytests.core.models.TopicModelInterface) TopicModelEmpty(easytests.core.models.empty.TopicModelEmpty) QuestionTypeModelInterface(easytests.core.models.QuestionTypeModelInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) AnswerModelInterface(easytests.core.models.AnswerModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with TopicModelEmpty

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

the class QuestionsOptionsTest method testWithRelationsOnModelsList.

@Test
public void testWithRelationsOnModelsList() throws Exception {
    final QuestionModelInterface questionModelFirst = Mockito.mock(QuestionModelInterface.class);
    questionModelFirst.setId(1);
    given(questionModelFirst.getTopic()).willReturn(new TopicModelEmpty(1));
    given(questionModelFirst.getQuestionType()).willReturn(new QuestionTypeModelEmpty(1));
    final QuestionModelInterface questionModelSecond = Mockito.mock(QuestionModelInterface.class);
    questionModelSecond.setId(2);
    given(questionModelSecond.getTopic()).willReturn(new TopicModelEmpty(2));
    given(questionModelSecond.getQuestionType()).willReturn(new QuestionTypeModelEmpty(2));
    final List<QuestionModelInterface> questionsModels = new ArrayList<>(2);
    questionsModels.add(questionModelFirst);
    questionsModels.add(questionModelSecond);
    final QuestionsOptionsInterface questionsOptions = new QuestionsOptions();
    final AnswersServiceInterface answersService = Mockito.mock(AnswersServiceInterface.class);
    final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
    final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
    final TopicsOptionsInterface topicsOptions = Mockito.mock(TopicsOptionsInterface.class);
    final QuestionTypesServiceInterface questionTypesService = Mockito.mock(QuestionTypesServiceInterface.class);
    final QuestionTypesOptionsInterface questionTypesOptions = Mockito.mock(QuestionTypesOptionsInterface.class);
    questionsOptions.setAnswersService(answersService);
    questionsOptions.withAnswers(answersOptions);
    questionsOptions.setTopicsService(topicsService);
    questionsOptions.withTopic(topicsOptions);
    questionsOptions.setQuestionTypesService(questionTypesService);
    questionsOptions.withQuestionType(questionTypesOptions);
    final List<AnswerModelInterface> answersModelsFirst = new ArrayList<>();
    answersModelsFirst.add(Mockito.mock(AnswerModelInterface.class));
    final List<AnswerModelInterface> answersModelsSecond = new ArrayList<>();
    answersModelsSecond.add(Mockito.mock(AnswerModelInterface.class));
    TopicModelInterface topicModelFirst = Mockito.mock(TopicModelInterface.class);
    TopicModelInterface topicModelSecond = Mockito.mock(TopicModelInterface.class);
    QuestionTypeModelInterface questionTypeModelFirst = Mockito.mock(QuestionTypeModelInterface.class);
    QuestionTypeModelInterface questionTypeModelSecond = Mockito.mock(QuestionTypeModelInterface.class);
    given(answersService.findByQuestion(questionModelFirst, answersOptions)).willReturn(answersModelsFirst);
    given(answersService.findByQuestion(questionModelSecond, answersOptions)).willReturn(answersModelsSecond);
    given(topicsService.find(questionModelFirst.getTopic().getId(), topicsOptions)).willReturn(topicModelFirst);
    given(topicsService.find(questionModelSecond.getTopic().getId(), topicsOptions)).willReturn(topicModelSecond);
    given(questionTypesService.find(questionModelFirst.getQuestionType().getId(), questionTypesOptions)).willReturn(questionTypeModelFirst);
    given(questionTypesService.find(questionModelSecond.getQuestionType().getId(), questionTypesOptions)).willReturn(questionTypeModelSecond);
    final List<QuestionModelInterface> questionsModelsWithRelations = questionsOptions.withRelations(questionsModels);
    Assert.assertEquals(questionsModelsWithRelations, questionsModels);
    verify(answersService).findByQuestion(questionModelFirst, answersOptions);
    verify(questionsModels.get(0)).setAnswers(answersModelsFirst);
    verify(questionsModels.get(0)).setAnswers(Mockito.anyList());
    verify(answersService).findByQuestion(questionModelSecond, answersOptions);
    verify(questionsModels.get(1)).setAnswers(answersModelsSecond);
    verify(questionsModels.get(1)).setAnswers(Mockito.anyList());
    verify(topicsService).find(questionModelFirst.getTopic().getId(), topicsOptions);
    verify(topicsService).find(questionModelSecond.getTopic().getId(), topicsOptions);
    verify(questionsModels.get(0)).setTopic(topicModelFirst);
    verify(questionsModels.get(1)).setTopic(topicModelSecond);
    verify(questionTypesService).find(questionModelFirst.getQuestionType().getId(), questionTypesOptions);
    verify(questionTypesService).find(questionModelSecond.getQuestionType().getId(), questionTypesOptions);
    verify(questionModelFirst).setQuestionType(questionTypeModelFirst);
    verify(questionModelSecond).setQuestionType(questionTypeModelSecond);
}
Also used : QuestionTypesServiceInterface(easytests.core.services.QuestionTypesServiceInterface) QuestionModelInterface(easytests.core.models.QuestionModelInterface) ArrayList(java.util.ArrayList) AnswersServiceInterface(easytests.core.services.AnswersServiceInterface) QuestionTypeModelEmpty(easytests.core.models.empty.QuestionTypeModelEmpty) TopicModelInterface(easytests.core.models.TopicModelInterface) TopicModelEmpty(easytests.core.models.empty.TopicModelEmpty) QuestionTypeModelInterface(easytests.core.models.QuestionTypeModelInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) AnswerModelInterface(easytests.core.models.AnswerModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with TopicModelEmpty

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

the class IssueStandardTopicPriorityModelTest method testMap.

@Test
public void testMap() {
    final Integer id = 5;
    final Integer topicId = 3;
    final Boolean isPreferable = false;
    final Integer issueStandardId = 2;
    final IssueStandardTopicPriorityEntity topicPriorityEntity = Mockito.mock(IssueStandardTopicPriorityEntity.class);
    Mockito.when(topicPriorityEntity.getId()).thenReturn(id);
    Mockito.when(topicPriorityEntity.getTopicId()).thenReturn(topicId);
    Mockito.when(topicPriorityEntity.getIsPreferable()).thenReturn(isPreferable);
    Mockito.when(topicPriorityEntity.getIssueStandardId()).thenReturn(issueStandardId);
    final IssueStandardTopicPriorityModelInterface topicPriorityModel = new IssueStandardTopicPriorityModel();
    topicPriorityModel.map(topicPriorityEntity);
    Assert.assertEquals(id, topicPriorityModel.getId());
    Assert.assertEquals(new TopicModelEmpty(topicId), topicPriorityModel.getTopic());
    Assert.assertEquals(isPreferable, topicPriorityModel.getIsPreferable());
    Assert.assertEquals(new IssueStandardModelEmpty(issueStandardId), topicPriorityModel.getIssueStandard());
}
Also used : TopicModelEmpty(easytests.core.models.empty.TopicModelEmpty) IssueStandardTopicPriorityEntity(easytests.core.entities.IssueStandardTopicPriorityEntity) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty) Test(org.junit.Test)

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