Search in sources :

Example 36 with IssueStandardQuestionTypeOptionModelInterface

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

the class IssueStandardQuestionTypeOptionsServiceTest method testDeleteUnidentifiedModel.

@Test
public void testDeleteUnidentifiedModel() throws Exception {
    final IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModel = Models.createQuestionTypeOptionModel(null, 1, 10, 20, 60, 1);
    exception.expect(DeleteUnidentifiedModelException.class);
    this.questionTypeOptionsService.delete(questionTypeOptionModel);
    verify(this.questionTypeOptionsMapper, times(0)).delete(this.mapQuestionTypeOptionEntity(questionTypeOptionModel));
}
Also used : IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 37 with IssueStandardQuestionTypeOptionModelInterface

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

the class IssueStandardQuestionTypeOptionsServiceTest method testFindWithOptions.

@Test
public void testFindWithOptions() throws Exception {
    final Integer id = 1;
    final IssueStandardQuestionTypeOptionEntity questionTypeOptionEntity = Entities.createQuestionTypeOptionEntityMock(id, 1, 10, 20, 60, 1);
    final IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModel = this.mapQuestionTypeOptionModel(questionTypeOptionEntity);
    final IssueStandardQuestionTypeOptionsOptionsInterface questionTypeOptionsOptions = Mockito.mock(IssueStandardQuestionTypeOptionsOptionsInterface.class);
    given(this.questionTypeOptionsMapper.find(id)).willReturn(questionTypeOptionEntity);
    given(questionTypeOptionsOptions.withRelations(questionTypeOptionModel)).willReturn(questionTypeOptionModel);
    final IssueStandardQuestionTypeOptionModelInterface foundedQuestionTypeOptionModel = this.questionTypeOptionsService.find(id, questionTypeOptionsOptions);
    verify(questionTypeOptionsOptions).withRelations(questionTypeOptionModel);
    Assert.assertNotNull(foundedQuestionTypeOptionModel);
    Assert.assertEquals(questionTypeOptionModel, foundedQuestionTypeOptionModel);
}
Also used : IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) IssueStandardQuestionTypeOptionsOptionsInterface(easytests.core.options.IssueStandardQuestionTypeOptionsOptionsInterface) IssueStandardQuestionTypeOptionEntity(easytests.core.entities.IssueStandardQuestionTypeOptionEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 38 with IssueStandardQuestionTypeOptionModelInterface

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

the class IssueStandardQuestionTypeOptionsOptionsTest method testWithRelationsOnNull.

@Test
public void testWithRelationsOnNull() throws Exception {
    final IssueStandardQuestionTypeOptionsOptionsInterface questionTypeOptionsOptions = new IssueStandardQuestionTypeOptionsOptions();
    final QuestionTypesServiceInterface questionTypesService = Mockito.mock(QuestionTypesServiceInterface.class);
    final QuestionTypesOptionsInterface questionTypesOptions = Mockito.mock(QuestionTypesOptionsInterface.class);
    final IssueStandardsServiceInterface issueStandardsService = Mockito.mock(IssueStandardsServiceInterface.class);
    final IssueStandardsOptionsInterface issueStandardsOptions = Mockito.mock(IssueStandardsOptionsInterface.class);
    questionTypeOptionsOptions.setQuestionTypesService(questionTypesService);
    questionTypeOptionsOptions.setIssueStandardsService(issueStandardsService);
    questionTypeOptionsOptions.withQuestionType(questionTypesOptions).withIssueStandard(issueStandardsOptions);
    final IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModel = null;
    final IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModelWithRelations = questionTypeOptionsOptions.withRelations(questionTypeOptionModel);
    Assert.assertEquals(null, questionTypeOptionModelWithRelations);
}
Also used : IssueStandardsServiceInterface(easytests.core.services.IssueStandardsServiceInterface) QuestionTypesServiceInterface(easytests.core.services.QuestionTypesServiceInterface) IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 39 with IssueStandardQuestionTypeOptionModelInterface

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

the class IssueStandardQuestionTypeOptionsOptionsTest method testWithRelationsOnModelsList.

@Test
public void testWithRelationsOnModelsList() throws Exception {
    final IssueStandardQuestionTypeOptionsOptionsInterface questionTypeOptionsOptions = new IssueStandardQuestionTypeOptionsOptions();
    final QuestionTypesServiceInterface questionTypesService = Mockito.mock(QuestionTypesServiceInterface.class);
    final QuestionTypesOptionsInterface questionTypesOptions = Mockito.mock(QuestionTypesOptionsInterface.class);
    final IssueStandardsServiceInterface issueStandardsService = Mockito.mock(IssueStandardsServiceInterface.class);
    final IssueStandardsOptionsInterface issueStandardsOptions = Mockito.mock(IssueStandardsOptionsInterface.class);
    final Integer issueStandardIdFirst = 10;
    final Integer issueStandardIdSecond = 20;
    final Integer questionTypeIdFirst = 2;
    final Integer questionTypeIdSecond = 3;
    final IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModelFirst = Mockito.mock(IssueStandardQuestionTypeOptionModelInterface.class);
    Mockito.when(questionTypeOptionModelFirst.getQuestionType()).thenReturn(new QuestionTypeModelEmpty(questionTypeIdFirst));
    Mockito.when(questionTypeOptionModelFirst.getIssueStandard()).thenReturn(new IssueStandardModelEmpty(issueStandardIdFirst));
    final IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModelSecond = Mockito.mock(IssueStandardQuestionTypeOptionModelInterface.class);
    Mockito.when(questionTypeOptionModelSecond.getQuestionType()).thenReturn(new QuestionTypeModelEmpty(questionTypeIdSecond));
    Mockito.when(questionTypeOptionModelSecond.getIssueStandard()).thenReturn(new IssueStandardModelEmpty(issueStandardIdSecond));
    final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModels = new ArrayList<>(2);
    questionTypeOptionModels.add(questionTypeOptionModelFirst);
    questionTypeOptionModels.add(questionTypeOptionModelSecond);
    final QuestionTypeModelInterface questionTypeModelFirst = Mockito.mock(QuestionTypeModelInterface.class);
    Mockito.when(questionTypeModelFirst.getId()).thenReturn(questionTypeIdFirst);
    given(questionTypesService.find(questionTypeIdFirst, questionTypesOptions)).willReturn(questionTypeModelFirst);
    final QuestionTypeModelInterface questionTypeModelSecond = Mockito.mock(QuestionTypeModelInterface.class);
    Mockito.when(questionTypeModelSecond.getId()).thenReturn(questionTypeIdSecond);
    given(questionTypesService.find(questionTypeIdSecond, questionTypesOptions)).willReturn(questionTypeModelSecond);
    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<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModelsWithoutRelations = questionTypeOptionsOptions.withRelations(questionTypeOptionModels);
    verify(questionTypesService, times(0)).find(questionTypeIdFirst, questionTypesOptions);
    verify(questionTypesService, times(0)).find(questionTypeIdSecond, questionTypesOptions);
    verify(issueStandardsService, times(0)).find(issueStandardIdFirst, issueStandardsOptions);
    verify(issueStandardsService, times(0)).find(issueStandardIdSecond, issueStandardsOptions);
    Assert.assertEquals(questionTypeOptionModels, questionTypeOptionModelsWithoutRelations);
    Mockito.verify(questionTypeOptionModelFirst, times(0)).setQuestionType(questionTypeModelFirst);
    Mockito.verify(questionTypeOptionModelFirst, times(0)).setIssueStandard(issueStandardModelFirst);
    Mockito.verify(questionTypeOptionModelSecond, times(0)).setQuestionType(questionTypeModelSecond);
    Mockito.verify(questionTypeOptionModelSecond, times(0)).setIssueStandard(issueStandardModelSecond);
    questionTypeOptionsOptions.setQuestionTypesService(questionTypesService);
    questionTypeOptionsOptions.setIssueStandardsService(issueStandardsService);
    questionTypeOptionsOptions.withQuestionType(questionTypesOptions).withIssueStandard(issueStandardsOptions);
    // теперь options заданы
    final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModelsWithRelations = questionTypeOptionsOptions.withRelations(questionTypeOptionModels);
    verify(questionTypesService, times(1)).find(questionTypeIdFirst, questionTypesOptions);
    verify(questionTypesService, times(1)).find(questionTypeIdSecond, questionTypesOptions);
    verify(issueStandardsService, times(1)).find(issueStandardIdFirst, issueStandardsOptions);
    verify(issueStandardsService, times(1)).find(issueStandardIdSecond, issueStandardsOptions);
    Assert.assertEquals(questionTypeOptionModels, questionTypeOptionModelsWithRelations);
    Mockito.verify(questionTypeOptionModelFirst, times(1)).setQuestionType(questionTypeModelFirst);
    Mockito.verify(questionTypeOptionModelFirst, times(1)).setIssueStandard(issueStandardModelFirst);
    Mockito.verify(questionTypeOptionModelSecond, times(1)).setQuestionType(questionTypeModelSecond);
    Mockito.verify(questionTypeOptionModelSecond, times(1)).setIssueStandard(issueStandardModelSecond);
}
Also used : IssueStandardsServiceInterface(easytests.core.services.IssueStandardsServiceInterface) QuestionTypesServiceInterface(easytests.core.services.QuestionTypesServiceInterface) ArrayList(java.util.ArrayList) QuestionTypeModelEmpty(easytests.core.models.empty.QuestionTypeModelEmpty) IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) QuestionTypeModelInterface(easytests.core.models.QuestionTypeModelInterface) IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

IssueStandardQuestionTypeOptionModelInterface (easytests.core.models.IssueStandardQuestionTypeOptionModelInterface)39 Test (org.junit.Test)30 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)29 IssueStandardQuestionTypeOptionEntity (easytests.core.entities.IssueStandardQuestionTypeOptionEntity)9 IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)9 IssueStandardQuestionTypeOptionsOptionsInterface (easytests.core.options.IssueStandardQuestionTypeOptionsOptionsInterface)9 ArrayList (java.util.ArrayList)7 IssueStandardModelEmpty (easytests.core.models.empty.IssueStandardModelEmpty)5 IssueStandardsServiceInterface (easytests.core.services.IssueStandardsServiceInterface)5 QuestionTypeModelEmpty (easytests.core.models.empty.QuestionTypeModelEmpty)4 IssueStandardQuestionTypeOptionsServiceInterface (easytests.core.services.IssueStandardQuestionTypeOptionsServiceInterface)4 QuestionTypesServiceInterface (easytests.core.services.QuestionTypesServiceInterface)3 IssueStandardQuestionTypeOptionModel (easytests.core.models.IssueStandardQuestionTypeOptionModel)2 IssueStandardTopicPriorityModelInterface (easytests.core.models.IssueStandardTopicPriorityModelInterface)2 QuestionTypeModelInterface (easytests.core.models.QuestionTypeModelInterface)2 SubjectModelInterface (easytests.core.models.SubjectModelInterface)2 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)2 SubjectModelEmpty (easytests.core.models.empty.SubjectModelEmpty)2 IssueStandardTopicPrioritiesServiceInterface (easytests.core.services.IssueStandardTopicPrioritiesServiceInterface)2 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)2