Search in sources :

Example 1 with SubjectModelEmpty

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

the class IssueModel method map.

public void map(IssueEntity issueEntity) {
    this.setId(issueEntity.getId());
    this.setName(issueEntity.getName());
    this.setSubject(new SubjectModelEmpty(issueEntity.getSubjectId()));
    this.setQuizzes(new ModelsListEmpty());
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty)

Example 2 with SubjectModelEmpty

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

the class IssueStandardModel method map.

public void map(IssueStandardEntity issueStandardEntity) {
    this.setId(issueStandardEntity.getId());
    this.setTimeLimit(issueStandardEntity.getTimeLimit());
    this.setQuestionsNumber(issueStandardEntity.getQuestionsNumber());
    this.setTopicPriorities(new ModelsListEmpty());
    this.setQuestionTypeOptions(new ModelsListEmpty());
    this.setSubject(new SubjectModelEmpty(issueStandardEntity.getSubjectId()));
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty)

Example 3 with SubjectModelEmpty

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

the class TopicModel method map.

public void map(TopicEntity topicEntity) {
    this.setId(topicEntity.getId());
    this.setName(topicEntity.getName());
    this.setSubject(new SubjectModelEmpty(topicEntity.getSubjectId()));
    this.setQuestions(new ModelsListEmpty());
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty)

Example 4 with SubjectModelEmpty

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

the class IssuesOptionsTest method testWithRelationsOnModelsList.

@Test
public void testWithRelationsOnModelsList() throws Exception {
    final IssueModelInterface issueModelFirst = Mockito.mock(IssueModelInterface.class);
    issueModelFirst.setId(1);
    given(issueModelFirst.getSubject()).willReturn(new SubjectModelEmpty(1));
    final IssueModelInterface issueModelSecond = Mockito.mock(IssueModelInterface.class);
    issueModelSecond.setId(2);
    given(issueModelSecond.getSubject()).willReturn(new SubjectModelEmpty(2));
    final List<IssueModelInterface> issuesModels = new ArrayList<>(2);
    issuesModels.add(issueModelFirst);
    issuesModels.add(issueModelSecond);
    final IssuesOptionsInterface issuesOptions = new IssuesOptions();
    final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
    final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
    final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
    final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
    issuesOptions.setSubjectsService(subjectsService);
    issuesOptions.setQuizzesService(quizzesService);
    issuesOptions.withSubject(subjectsOptions);
    issuesOptions.withQuizzes(quizzesOptions);
    final List<QuizModelInterface> quizzesModelsFirst = new ArrayList<>();
    quizzesModelsFirst.add(Mockito.mock(QuizModelInterface.class));
    final List<QuizModelInterface> quizzesModelsSecond = new ArrayList<>();
    quizzesModelsSecond.add(Mockito.mock(QuizModelInterface.class));
    quizzesModelsSecond.add(Mockito.mock(QuizModelInterface.class));
    given(quizzesService.findByIssue(issueModelFirst, quizzesOptions)).willReturn(quizzesModelsFirst);
    given(quizzesService.findByIssue(issueModelSecond, quizzesOptions)).willReturn(quizzesModelsSecond);
    final SubjectModelInterface subjectModelFirst = Mockito.mock(SubjectModelInterface.class);
    final SubjectModelInterface subjectModelSecond = Mockito.mock(SubjectModelInterface.class);
    given(subjectsService.find(1, subjectsOptions)).willReturn(subjectModelFirst);
    given(subjectsService.find(2, subjectsOptions)).willReturn(subjectModelSecond);
    final List<IssueModelInterface> issuesModelsWithRelations = issuesOptions.withRelations(issuesModels);
    Assert.assertEquals(issuesModelsWithRelations, issuesModels);
    verify(quizzesService).findByIssue(issueModelFirst, quizzesOptions);
    verify(subjectsService).find(1, subjectsOptions);
    verify(issuesModels.get(0)).setQuizzes(quizzesModelsFirst);
    verify(issuesModels.get(0)).setQuizzes(Mockito.anyList());
    verify(issuesModels.get(0)).setSubject(subjectModelFirst);
    verify(quizzesService).findByIssue(issueModelSecond, quizzesOptions);
    verify(subjectsService).find(2, subjectsOptions);
    verify(issuesModels.get(1)).setQuizzes(quizzesModelsSecond);
    verify(issuesModels.get(1)).setQuizzes(Mockito.anyList());
    verify(issuesModels.get(1)).setSubject(subjectModelSecond);
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) SubjectsServiceInterface(easytests.core.services.SubjectsServiceInterface) ArrayList(java.util.ArrayList) SubjectModelInterface(easytests.core.models.SubjectModelInterface) QuizModelInterface(easytests.core.models.QuizModelInterface) QuizzesServiceInterface(easytests.core.services.QuizzesServiceInterface) IssueModelInterface(easytests.core.models.IssueModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with SubjectModelEmpty

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

the class IssuesOptionsTest method testWithRelationsOnSingleModel.

@Test
public void testWithRelationsOnSingleModel() throws Exception {
    final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
    issueModel.setId(1);
    given(issueModel.getSubject()).willReturn(new SubjectModelEmpty(1));
    final IssuesOptionsInterface issuesOptions = new IssuesOptions();
    final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
    final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
    final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
    final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
    issuesOptions.setSubjectsService(subjectsService);
    issuesOptions.setQuizzesService(quizzesService);
    issuesOptions.withSubject(subjectsOptions);
    issuesOptions.withQuizzes(quizzesOptions);
    final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
    final List<QuizModelInterface> quizzesModels = new ArrayList<>();
    quizzesModels.add(Mockito.mock(QuizModelInterface.class));
    given(subjectsService.find(issueModel.getSubject().getId(), subjectsOptions)).willReturn(subjectModel);
    given(quizzesService.findByIssue(issueModel, quizzesOptions)).willReturn(quizzesModels);
    final IssueModelInterface issueModelWithRelations = issuesOptions.withRelations(issueModel);
    Assert.assertEquals(issueModel, issueModelWithRelations);
    verify(subjectsService).find(1, subjectsOptions);
    verify(quizzesService).findByIssue(issueModel, quizzesOptions);
    verify(issueModel).setQuizzes(quizzesModels);
    verify(issueModel).setQuizzes(Mockito.anyList());
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) QuizModelInterface(easytests.core.models.QuizModelInterface) SubjectsServiceInterface(easytests.core.services.SubjectsServiceInterface) QuizzesServiceInterface(easytests.core.services.QuizzesServiceInterface) ArrayList(java.util.ArrayList) IssueModelInterface(easytests.core.models.IssueModelInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

SubjectModelEmpty (easytests.core.models.empty.SubjectModelEmpty)16 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)11 Test (org.junit.Test)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)5 SubjectModelInterface (easytests.core.models.SubjectModelInterface)5 ArrayList (java.util.ArrayList)5 IssueModelInterface (easytests.core.models.IssueModelInterface)4 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)4 IssueStandardQuestionTypeOptionModelInterface (easytests.core.models.IssueStandardQuestionTypeOptionModelInterface)2 IssueStandardTopicPriorityModelInterface (easytests.core.models.IssueStandardTopicPriorityModelInterface)2 QuizModelInterface (easytests.core.models.QuizModelInterface)2 IssueStandardQuestionTypeOptionsServiceInterface (easytests.core.services.IssueStandardQuestionTypeOptionsServiceInterface)2 IssueStandardTopicPrioritiesServiceInterface (easytests.core.services.IssueStandardTopicPrioritiesServiceInterface)2 QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)2 IssueEntity (easytests.core.entities.IssueEntity)1 IssueStandardEntity (easytests.core.entities.IssueStandardEntity)1 IssueModel (easytests.core.models.IssueModel)1 IssueStandardModel (easytests.core.models.IssueStandardModel)1 SubjectModel (easytests.core.models.SubjectModel)1