Search in sources :

Example 6 with QuestionModelInterface

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

the class QuestionsServiceTest method testFindAbsentModel.

@Test
public void testFindAbsentModel() throws Exception {
    final Integer id = 10;
    given(this.questionsMapper.find(id)).willReturn(null);
    final QuestionModelInterface questionModel = this.questionsService.find(id);
    Assert.assertEquals(null, questionModel);
}
Also used : QuestionModelInterface(easytests.core.models.QuestionModelInterface)

Example 7 with QuestionModelInterface

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

the class QuestionsServiceTest method testDeleteWithOptions.

@Test
public void testDeleteWithOptions() throws Exception {
    final QuestionModelInterface questionModel = Models.createQuestionModel(1, "Text", 1, 1);
    final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
    this.questionsService.delete(questionModel, questionsOptions);
    verify(questionsOptions).deleteWithRelations(questionModel);
}
Also used : QuestionModelInterface(easytests.core.models.QuestionModelInterface) QuestionsOptionsInterface(easytests.core.options.QuestionsOptionsInterface)

Example 8 with QuestionModelInterface

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

the class QuestionsServiceTest method testDeleteModelsList.

@Test
public void testDeleteModelsList() throws Exception {
    final QuestionModelInterface questionModelFirst = Models.createQuestionModel(1, "test1", 1, 1);
    final QuestionModelInterface questionModelSecond = Models.createQuestionModel(2, "test2", 2, 1);
    final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
    final List<QuestionModelInterface> questionsModels = new ArrayList<>();
    questionsModels.add(questionModelFirst);
    questionsModels.add(questionModelSecond);
    final QuestionsServiceInterface questionsServiceSpy = Mockito.spy(questionsService);
    questionsServiceSpy.delete(questionsModels);
    verify(questionsServiceSpy, times(1)).delete(questionModelFirst);
    verify(questionsServiceSpy, times(1)).delete(questionModelSecond);
    questionsServiceSpy.delete(questionsModels, questionsOptions);
    verify(questionsServiceSpy, times(1)).delete(questionModelFirst, questionsOptions);
    verify(questionsServiceSpy, times(1)).delete(questionModelSecond, questionsOptions);
}
Also used : QuestionModelInterface(easytests.core.models.QuestionModelInterface) ArrayList(java.util.ArrayList) QuestionsOptionsInterface(easytests.core.options.QuestionsOptionsInterface)

Example 9 with QuestionModelInterface

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

the class QuestionsServiceTest method testSaveUpdatesEntity.

@Test
public void testSaveUpdatesEntity() throws Exception {
    final QuestionModelInterface questionModel = Models.createQuestionModel(1, "Text", 1, 1);
    this.questionsService.save(questionModel);
    verify(this.questionsMapper, times(1)).update(this.mapQuestionEntity(questionModel));
}
Also used : QuestionModelInterface(easytests.core.models.QuestionModelInterface)

Example 10 with QuestionModelInterface

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

the class QuestionsServiceTest method testSaveCreatesEntity.

@Test
public void testSaveCreatesEntity() throws Exception {
    final QuestionModelInterface questionModel = Models.createQuestionModel(null, "Text", 1, 1);
    doAnswer(invocation -> {
        final QuestionEntity questionEntity = (QuestionEntity) invocation.getArguments()[0];
        questionEntity.setId(5);
        return null;
    }).when(this.questionsMapper).insert(Mockito.any(QuestionEntity.class));
    this.questionsService.save(questionModel);
    verify(this.questionsMapper, times(1)).insert(this.mapQuestionEntity(questionModel));
    Assert.assertEquals((Integer) 5, questionModel.getId());
}
Also used : QuestionEntity(easytests.core.entities.QuestionEntity) QuestionModelInterface(easytests.core.models.QuestionModelInterface)

Aggregations

QuestionModelInterface (easytests.core.models.QuestionModelInterface)40 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)15 TopicModelInterface (easytests.core.models.TopicModelInterface)14 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)13 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)10 QuestionsOptionsInterface (easytests.core.options.QuestionsOptionsInterface)9 QuestionsServiceInterface (easytests.core.services.QuestionsServiceInterface)9 QuestionEntity (easytests.core.entities.QuestionEntity)8 AnswerModelInterface (easytests.core.models.AnswerModelInterface)6 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)5 InOrder (org.mockito.InOrder)4 PointModelInterface (easytests.core.models.PointModelInterface)3 QuestionTypeModelInterface (easytests.core.models.QuestionTypeModelInterface)3 QuizModelInterface (easytests.core.models.QuizModelInterface)3 QuestionTypeModelEmpty (easytests.core.models.empty.QuestionTypeModelEmpty)3 TopicModelEmpty (easytests.core.models.empty.TopicModelEmpty)3 QuestionTypesServiceInterface (easytests.core.services.QuestionTypesServiceInterface)3 QuestionModel (easytests.core.models.QuestionModel)2 SolutionModelInterface (easytests.core.models.SolutionModelInterface)2