Search in sources :

Example 26 with QuestionModelInterface

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

the class AnswerEntityTest method testMap.

@Test
public void testMap() throws Exception {
    final Integer id = 3;
    final String txt = "Text";
    final Integer questionId = 5;
    final Integer serialNumber = 3;
    final Boolean right = true;
    final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
    Mockito.when(questionModel.getId()).thenReturn(questionId);
    final AnswerModelInterface answerModel = Mockito.mock(AnswerModelInterface.class);
    Mockito.when(answerModel.getId()).thenReturn(id);
    Mockito.when(answerModel.getTxt()).thenReturn(txt);
    Mockito.when(answerModel.getQuestion()).thenReturn(questionModel);
    Mockito.when(answerModel.getSerialNumber()).thenReturn(serialNumber);
    Mockito.when(answerModel.getRight()).thenReturn(right);
    final AnswerEntity answerEntity = new AnswerEntity();
    answerEntity.map(answerModel);
    Assert.assertEquals(id, answerEntity.getId());
    Assert.assertEquals(txt, answerEntity.getTxt());
    Assert.assertEquals(questionId, answerEntity.getQuestionId());
    Assert.assertEquals(serialNumber, answerEntity.getSerialNumber());
    Assert.assertEquals(right, answerEntity.getRight());
}
Also used : QuestionModelInterface(easytests.core.models.QuestionModelInterface) AnswerModelInterface(easytests.core.models.AnswerModelInterface) Test(org.junit.Test)

Example 27 with QuestionModelInterface

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

the class QuestionEntityTest 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 TopicModelInterface topic = Mockito.mock(TopicModelInterface.class);
    Mockito.when(topic.getId()).thenReturn(topicId);
    final QuestionTypeModelInterface questionType = Mockito.mock(QuestionTypeModelInterface.class);
    Mockito.when(questionType.getId()).thenReturn(questionTypeId);
    final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
    Mockito.when(questionModel.getId()).thenReturn(questionId);
    Mockito.when(questionModel.getText()).thenReturn(text);
    Mockito.when(questionModel.getQuestionType()).thenReturn(questionType);
    Mockito.when(questionModel.getTopic()).thenReturn(topic);
    final QuestionEntity questionEntity = new QuestionEntity();
    questionEntity.map(questionModel);
    Assert.assertEquals(questionId, questionEntity.getId());
    Assert.assertEquals(text, questionEntity.getText());
    Assert.assertEquals(questionTypeId, questionEntity.getQuestionTypeId());
    Assert.assertEquals(topicId, questionEntity.getTopicId());
}
Also used : QuestionTypeModelInterface(easytests.core.models.QuestionTypeModelInterface) QuestionModelInterface(easytests.core.models.QuestionModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test)

Example 28 with QuestionModelInterface

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

the class AnswersServiceTest method createAnswerModel.

private AnswerModelInterface createAnswerModel(Integer id, String txt, Integer questionId, Integer serialNumber, Boolean right) {
    final AnswerModelInterface answerModel = new AnswerModel();
    answerModel.setId(id);
    answerModel.setTxt(txt);
    answerModel.setSerialNumber(serialNumber);
    answerModel.setRight(true);
    final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
    Mockito.when(questionModel.getId()).thenReturn(questionId);
    answerModel.setQuestion(questionModel);
    return answerModel;
}
Also used : AnswerModel(easytests.core.models.AnswerModel) QuestionModelInterface(easytests.core.models.QuestionModelInterface) AnswerModelInterface(easytests.core.models.AnswerModelInterface)

Example 29 with QuestionModelInterface

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

the class QuestionsServiceTest method testFindWithOptions.

@Test
public void testFindWithOptions() throws Exception {
    final Integer id = 1;
    final QuestionEntity questionEntity = Entities.createQuestionEntityMock(id, "NewText", 1, 1);
    final QuestionModelInterface questionModel = this.mapQuestionModel(questionEntity);
    final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
    given(this.questionsMapper.find(id)).willReturn(questionEntity);
    given(questionsOptions.withRelations(questionModel)).willReturn(questionModel);
    final QuestionModelInterface foundedQuestionModel = this.questionsService.find(id, questionsOptions);
    Assert.assertEquals(questionModel, foundedQuestionModel);
    verify(questionsOptions).withRelations(questionModel);
}
Also used : QuestionEntity(easytests.core.entities.QuestionEntity) QuestionModelInterface(easytests.core.models.QuestionModelInterface) QuestionsOptionsInterface(easytests.core.options.QuestionsOptionsInterface)

Example 30 with QuestionModelInterface

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

the class QuestionsServiceTest method testSaveWithOptions.

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

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