Search in sources :

Example 31 with ModelsListEmpty

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

the class UserModel method map.

public void map(UserEntity userEntity) {
    this.setId(userEntity.getId());
    this.setFirstName(userEntity.getFirstName());
    this.setLastName(userEntity.getLastName());
    this.setSurname(userEntity.getSurname());
    this.setEmail(userEntity.getEmail());
    this.setPassword(userEntity.getPassword());
    this.setIsAdmin(userEntity.getIsAdmin());
    this.setState(userEntity.getState());
    this.setSubjects(new ModelsListEmpty());
}
Also used : ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty)

Example 32 with ModelsListEmpty

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

the class IssueStandardOptionsTest method testWithRelationsOnSingleModel.

@Test
public void testWithRelationsOnSingleModel() throws Exception {
    final IssueStandardsOptionsInterface issueStandardsOptions = new IssueStandardsOptions();
    final IssueStandardTopicPrioritiesServiceInterface topicPrioritiesService = Mockito.mock(IssueStandardTopicPrioritiesServiceInterface.class);
    final IssueStandardTopicPrioritiesOptionsInterface topicPrioritiesOptions = Mockito.mock(IssueStandardTopicPrioritiesOptionsInterface.class);
    final IssueStandardQuestionTypeOptionsServiceInterface questionTypeOptionsService = Mockito.mock(IssueStandardQuestionTypeOptionsServiceInterface.class);
    final IssueStandardQuestionTypeOptionsOptionsInterface questionTypeOptionsOptions = Mockito.mock(IssueStandardQuestionTypeOptionsOptionsInterface.class);
    final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
    final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
    final Integer subjectId = 3;
    // модель в начале
    final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModel.getTopicPriorities()).thenReturn(new ModelsListEmpty());
    Mockito.when(issueStandardModel.getQuestionTypeOptions()).thenReturn(new ModelsListEmpty());
    Mockito.when(issueStandardModel.getSubject()).thenReturn(new SubjectModelEmpty(subjectId));
    // возвращаемые сервисами
    final List<IssueStandardTopicPriorityModelInterface> topicPriorityModels = new ArrayList<>(1);
    topicPriorityModels.add(Mockito.mock(IssueStandardTopicPriorityModelInterface.class));
    final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModels = new ArrayList<>(1);
    questionTypeOptionModels.add(Mockito.mock(IssueStandardQuestionTypeOptionModelInterface.class));
    final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
    Mockito.when(subjectModel.getId()).thenReturn(subjectId);
    given(topicPrioritiesService.findByIssueStandard(issueStandardModel, topicPrioritiesOptions)).willReturn(topicPriorityModels);
    given(questionTypeOptionsService.findByIssueStandard(issueStandardModel, questionTypeOptionsOptions)).willReturn(questionTypeOptionModels);
    given(subjectsService.find(subjectId, subjectsOptions)).willReturn(subjectModel);
    // options не заданы
    final IssueStandardModelInterface issueStandardModelWithoutRelations = issueStandardsOptions.withRelations(issueStandardModel);
    verify(topicPrioritiesService, times(0)).findByIssueStandard(issueStandardModel, topicPrioritiesOptions);
    verify(questionTypeOptionsService, times(0)).findByIssueStandard(issueStandardModel, questionTypeOptionsOptions);
    verify(subjectsService, times(0)).find(subjectId, subjectsOptions);
    Assert.assertEquals(issueStandardModel, issueStandardModelWithoutRelations);
    verify(issueStandardModel, times(0)).setTopicPriorities(topicPriorityModels);
    verify(issueStandardModel, times(0)).setQuestionTypeOptions(questionTypeOptionModels);
    verify(issueStandardModel, times(0)).setSubject(subjectModel);
    issueStandardsOptions.setTopicPrioritiesService(topicPrioritiesService);
    issueStandardsOptions.setQuestionTypeOptionsService(questionTypeOptionsService);
    issueStandardsOptions.setSubjectsService(subjectsService);
    issueStandardsOptions.withTopicPriorities(topicPrioritiesOptions).withQuestionTypeOptions(questionTypeOptionsOptions).withSubject(subjectsOptions);
    // теперь options заданы
    final IssueStandardModelInterface issueStandardModelWithRelations = issueStandardsOptions.withRelations(issueStandardModel);
    verify(topicPrioritiesService, times(1)).findByIssueStandard(issueStandardModel, topicPrioritiesOptions);
    verify(questionTypeOptionsService, times(1)).findByIssueStandard(issueStandardModel, questionTypeOptionsOptions);
    verify(subjectsService, times(1)).find(subjectId, subjectsOptions);
    Assert.assertEquals(issueStandardModel, issueStandardModelWithRelations);
    verify(issueStandardModel, times(1)).setTopicPriorities(topicPriorityModels);
    verify(issueStandardModel, times(1)).setQuestionTypeOptions(questionTypeOptionModels);
    verify(issueStandardModel, times(1)).setSubject(subjectModel);
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) SubjectsServiceInterface(easytests.core.services.SubjectsServiceInterface) ArrayList(java.util.ArrayList) IssueStandardTopicPrioritiesServiceInterface(easytests.core.services.IssueStandardTopicPrioritiesServiceInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface) IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardQuestionTypeOptionsServiceInterface(easytests.core.services.IssueStandardQuestionTypeOptionsServiceInterface) IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 33 with ModelsListEmpty

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

the class IssueStandardOptionsTest method testWithRelationsOnModelsList.

@Test
public void testWithRelationsOnModelsList() throws Exception {
    final IssueStandardsOptionsInterface issueStandardsOptions = new IssueStandardsOptions();
    final IssueStandardTopicPrioritiesServiceInterface topicPrioritiesService = Mockito.mock(IssueStandardTopicPrioritiesServiceInterface.class);
    final IssueStandardTopicPrioritiesOptionsInterface topicPrioritiesOptions = Mockito.mock(IssueStandardTopicPrioritiesOptionsInterface.class);
    final IssueStandardQuestionTypeOptionsServiceInterface questionTypeOptionsService = Mockito.mock(IssueStandardQuestionTypeOptionsServiceInterface.class);
    final IssueStandardQuestionTypeOptionsOptionsInterface questionTypeOptionsOptions = Mockito.mock(IssueStandardQuestionTypeOptionsOptionsInterface.class);
    final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
    final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
    final Integer subjectIdFirst = 3;
    final Integer subjectIdSecond = 5;
    // модели в начале
    final IssueStandardModelInterface issueStandardModelFirst = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModelFirst.getTopicPriorities()).thenReturn(new ModelsListEmpty());
    Mockito.when(issueStandardModelFirst.getQuestionTypeOptions()).thenReturn(new ModelsListEmpty());
    Mockito.when(issueStandardModelFirst.getSubject()).thenReturn(new SubjectModelEmpty(subjectIdFirst));
    final IssueStandardModelInterface issueStandardModelSecond = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModelSecond.getTopicPriorities()).thenReturn(new ModelsListEmpty());
    Mockito.when(issueStandardModelSecond.getQuestionTypeOptions()).thenReturn(new ModelsListEmpty());
    Mockito.when(issueStandardModelSecond.getSubject()).thenReturn(new SubjectModelEmpty(subjectIdSecond));
    final List<IssueStandardModelInterface> issueStandardModels = new ArrayList<>(2);
    issueStandardModels.add(issueStandardModelFirst);
    issueStandardModels.add(issueStandardModelSecond);
    final List<IssueStandardTopicPriorityModelInterface> topicPriorityModelsFirst = new ArrayList<>(1);
    topicPriorityModelsFirst.add(Mockito.mock(IssueStandardTopicPriorityModelInterface.class));
    final List<IssueStandardTopicPriorityModelInterface> topicPriorityModelsSecond = new ArrayList<>(1);
    topicPriorityModelsSecond.add(Mockito.mock(IssueStandardTopicPriorityModelInterface.class));
    given(topicPrioritiesService.findByIssueStandard(issueStandardModelFirst, topicPrioritiesOptions)).willReturn(topicPriorityModelsFirst);
    given(topicPrioritiesService.findByIssueStandard(issueStandardModelSecond, topicPrioritiesOptions)).willReturn(topicPriorityModelsSecond);
    final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModelsFirst = new ArrayList<>(1);
    questionTypeOptionModelsFirst.add(Mockito.mock(IssueStandardQuestionTypeOptionModelInterface.class));
    final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModelsSecond = new ArrayList<>(1);
    questionTypeOptionModelsSecond.add(Mockito.mock(IssueStandardQuestionTypeOptionModelInterface.class));
    given(questionTypeOptionsService.findByIssueStandard(issueStandardModelFirst, questionTypeOptionsOptions)).willReturn(questionTypeOptionModelsFirst);
    given(questionTypeOptionsService.findByIssueStandard(issueStandardModelSecond, questionTypeOptionsOptions)).willReturn(questionTypeOptionModelsSecond);
    final SubjectModelInterface subjectModelFirst = Mockito.mock(SubjectModelInterface.class);
    Mockito.when(subjectModelFirst.getId()).thenReturn(subjectIdFirst);
    final SubjectModelInterface subjectModelSecond = Mockito.mock(SubjectModelInterface.class);
    Mockito.when(subjectModelSecond.getId()).thenReturn(subjectIdSecond);
    given(subjectsService.find(subjectIdFirst, subjectsOptions)).willReturn(subjectModelFirst);
    given(subjectsService.find(subjectIdSecond, subjectsOptions)).willReturn(subjectModelSecond);
    // options не заданы
    List<IssueStandardModelInterface> issueStandardModelsWithoutRelations = issueStandardsOptions.withRelations(issueStandardModels);
    verify(topicPrioritiesService, times(0)).findByIssueStandard(issueStandardModelFirst, topicPrioritiesOptions);
    verify(topicPrioritiesService, times(0)).findByIssueStandard(issueStandardModelSecond, topicPrioritiesOptions);
    verify(questionTypeOptionsService, times(0)).findByIssueStandard(issueStandardModelFirst, questionTypeOptionsOptions);
    verify(questionTypeOptionsService, times(0)).findByIssueStandard(issueStandardModelSecond, questionTypeOptionsOptions);
    verify(subjectsService, times(0)).find(subjectIdFirst, subjectsOptions);
    verify(subjectsService, times(0)).find(subjectIdSecond, subjectsOptions);
    Assert.assertEquals(issueStandardModels, issueStandardModelsWithoutRelations);
    verify(issueStandardModelFirst, times(0)).setTopicPriorities(topicPriorityModelsFirst);
    verify(issueStandardModelFirst, times(0)).setQuestionTypeOptions(questionTypeOptionModelsFirst);
    verify(issueStandardModelFirst, times(0)).setSubject(subjectModelFirst);
    verify(issueStandardModelSecond, times(0)).setTopicPriorities(topicPriorityModelsSecond);
    verify(issueStandardModelSecond, times(0)).setQuestionTypeOptions(questionTypeOptionModelsSecond);
    verify(issueStandardModelSecond, times(0)).setSubject(subjectModelSecond);
    issueStandardsOptions.setTopicPrioritiesService(topicPrioritiesService);
    issueStandardsOptions.setQuestionTypeOptionsService(questionTypeOptionsService);
    issueStandardsOptions.setSubjectsService(subjectsService);
    issueStandardsOptions.withTopicPriorities(topicPrioritiesOptions).withQuestionTypeOptions(questionTypeOptionsOptions).withSubject(subjectsOptions);
    // теперь options заданы
    List<IssueStandardModelInterface> issueStandardModelsWithRelations = issueStandardsOptions.withRelations(issueStandardModels);
    verify(topicPrioritiesService, times(1)).findByIssueStandard(issueStandardModelFirst, topicPrioritiesOptions);
    verify(topicPrioritiesService, times(1)).findByIssueStandard(issueStandardModelSecond, topicPrioritiesOptions);
    verify(questionTypeOptionsService, times(1)).findByIssueStandard(issueStandardModelFirst, questionTypeOptionsOptions);
    verify(questionTypeOptionsService, times(1)).findByIssueStandard(issueStandardModelSecond, questionTypeOptionsOptions);
    verify(subjectsService, times(1)).find(subjectIdFirst, subjectsOptions);
    verify(subjectsService, times(1)).find(subjectIdSecond, subjectsOptions);
    Assert.assertEquals(issueStandardModels, issueStandardModelsWithRelations);
    verify(issueStandardModelFirst, times(1)).setTopicPriorities(topicPriorityModelsFirst);
    verify(issueStandardModelFirst, times(1)).setQuestionTypeOptions(questionTypeOptionModelsFirst);
    verify(issueStandardModelFirst, times(1)).setSubject(subjectModelFirst);
    verify(issueStandardModelSecond, times(1)).setTopicPriorities(topicPriorityModelsSecond);
    verify(issueStandardModelSecond, times(1)).setQuestionTypeOptions(questionTypeOptionModelsSecond);
    verify(issueStandardModelSecond, times(1)).setSubject(subjectModelSecond);
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) SubjectsServiceInterface(easytests.core.services.SubjectsServiceInterface) ArrayList(java.util.ArrayList) IssueStandardTopicPrioritiesServiceInterface(easytests.core.services.IssueStandardTopicPrioritiesServiceInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface) IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardQuestionTypeOptionsServiceInterface(easytests.core.services.IssueStandardQuestionTypeOptionsServiceInterface) IssueStandardTopicPriorityModelInterface(easytests.core.models.IssueStandardTopicPriorityModelInterface) IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 34 with ModelsListEmpty

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

the class IssueStandardModelTest method testMap.

@Test
public void testMap() {
    final Integer id = 5;
    final Integer timeLimit = 3600;
    final Integer questionsNumber = 30;
    final Integer subjectId = 3;
    final IssueStandardEntity issueStandardEntity = Mockito.mock(IssueStandardEntity.class);
    Mockito.when(issueStandardEntity.getId()).thenReturn(id);
    Mockito.when(issueStandardEntity.getTimeLimit()).thenReturn(timeLimit);
    Mockito.when(issueStandardEntity.getQuestionsNumber()).thenReturn(questionsNumber);
    Mockito.when(issueStandardEntity.getSubjectId()).thenReturn(subjectId);
    final IssueStandardModelInterface issueStandardModel = new IssueStandardModel();
    issueStandardModel.map(issueStandardEntity);
    Assert.assertEquals(id, issueStandardModel.getId());
    Assert.assertEquals(timeLimit, issueStandardModel.getTimeLimit());
    Assert.assertEquals(questionsNumber, issueStandardModel.getQuestionsNumber());
    Assert.assertEquals(new ModelsListEmpty(), issueStandardModel.getTopicPriorities());
    Assert.assertEquals(new ModelsListEmpty(), issueStandardModel.getQuestionTypeOptions());
    Assert.assertEquals(new SubjectModelEmpty(subjectId), issueStandardModel.getSubject());
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) IssueStandardEntity(easytests.core.entities.IssueStandardEntity) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty) Test(org.junit.Test)

Example 35 with ModelsListEmpty

use of easytests.core.models.empty.ModelsListEmpty 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

ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)36 Test (org.junit.Test)13 SubjectModelEmpty (easytests.core.models.empty.SubjectModelEmpty)11 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)8 IssueStandardModelEmpty (easytests.core.models.empty.IssueStandardModelEmpty)7 UserModelEmpty (easytests.core.models.empty.UserModelEmpty)7 QuestionTypeModelEmpty (easytests.core.models.empty.QuestionTypeModelEmpty)5 TopicModelEmpty (easytests.core.models.empty.TopicModelEmpty)5 IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)4 SubjectModelInterface (easytests.core.models.SubjectModelInterface)4 IssueModelEmpty (easytests.core.models.empty.IssueModelEmpty)3 QuestionModelEmpty (easytests.core.models.empty.QuestionModelEmpty)3 QuizModelEmpty (easytests.core.models.empty.QuizModelEmpty)3 TesteeModelEmpty (easytests.core.models.empty.TesteeModelEmpty)3 IssueStandardQuestionTypeOptionModelInterface (easytests.core.models.IssueStandardQuestionTypeOptionModelInterface)2 IssueStandardTopicPriorityModelInterface (easytests.core.models.IssueStandardTopicPriorityModelInterface)2 IssueStandardQuestionTypeOptionsServiceInterface (easytests.core.services.IssueStandardQuestionTypeOptionsServiceInterface)2 IssueStandardTopicPrioritiesServiceInterface (easytests.core.services.IssueStandardTopicPrioritiesServiceInterface)2 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)2 ArrayList (java.util.ArrayList)2