Search in sources :

Example 6 with QuestionModelEmpty

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

the class PointModelTest method testMap.

@Test
public void testMap() throws Exception {
    final Integer pointId = 3;
    final Integer questionId = 2;
    final Integer quizId = 2;
    final PointEntity pointEntity = Mockito.mock(PointEntity.class);
    Mockito.when(pointEntity.getId()).thenReturn(pointId);
    Mockito.when(pointEntity.getQuestionId()).thenReturn(questionId);
    Mockito.when(pointEntity.getQuizId()).thenReturn(quizId);
    final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
    Mockito.when(quizModel.getId()).thenReturn(quizId);
    final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
    Mockito.when(questionModel.getId()).thenReturn(questionId);
    final PointModel pointModel = new PointModel();
    pointModel.map(pointEntity);
    Assert.assertEquals(pointId, pointModel.getId());
    Assert.assertEquals(new QuestionModelEmpty(questionId), pointModel.getQuestion());
    Assert.assertEquals(new QuizModelEmpty(quizId), pointModel.getQuiz());
}
Also used : QuestionModelEmpty(easytests.core.models.empty.QuestionModelEmpty) QuizModelEmpty(easytests.core.models.empty.QuizModelEmpty) PointEntity(easytests.core.entities.PointEntity) Test(org.junit.Test)

Example 7 with QuestionModelEmpty

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

the class AnswersOptionsTest method testWithRelationsOnModelsList.

@Test
public void testWithRelationsOnModelsList() throws Exception {
    final AnswerModelInterface answerModelFirst = Mockito.mock(AnswerModelInterface.class);
    answerModelFirst.setId(1);
    given(answerModelFirst.getQuestion()).willReturn(new QuestionModelEmpty(1));
    final AnswerModelInterface answerModelSecond = Mockito.mock(AnswerModelInterface.class);
    answerModelSecond.setId(2);
    given(answerModelSecond.getQuestion()).willReturn(new QuestionModelEmpty(2));
    final List<AnswerModelInterface> answersModels = new ArrayList<>(2);
    answersModels.add(answerModelFirst);
    answersModels.add(answerModelSecond);
    final AnswersOptionsInterface answersOptions = new AnswersOptions();
    final QuestionsServiceInterface questionsService = Mockito.mock(QuestionsServiceInterface.class);
    final QuestionsOptionsInterface questionOptions = Mockito.mock(QuestionsOptionsInterface.class);
    answersOptions.setQuestionsService(questionsService);
    answersOptions.withQuestion(questionOptions);
    final QuestionModelInterface questionModelFirst = Mockito.mock(QuestionModelInterface.class);
    final QuestionModelInterface questionModelSecond = Mockito.mock(QuestionModelInterface.class);
    given(questionsService.find(1, questionOptions)).willReturn(questionModelFirst);
    given(questionsService.find(2, questionOptions)).willReturn(questionModelSecond);
    final List<AnswerModelInterface> answersModelsWithRelations = answersOptions.withRelations(answersModels);
    Assert.assertEquals(answersModelsWithRelations, answersModels);
    verify(questionsService).find(1, questionOptions);
    verify(answersModels.get(0)).setQuestion(questionModelFirst);
    verify(questionsService).find(2, questionOptions);
    verify(answersModels.get(1)).setQuestion(questionModelSecond);
}
Also used : QuestionModelEmpty(easytests.core.models.empty.QuestionModelEmpty) QuestionsServiceInterface(easytests.core.services.QuestionsServiceInterface) ArrayList(java.util.ArrayList) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with QuestionModelEmpty

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

the class AnswersOptionsTest method testWithRelationsOnSingleModel.

@Test
public void testWithRelationsOnSingleModel() throws Exception {
    final AnswerModelInterface answerModel = Mockito.mock(AnswerModelInterface.class);
    answerModel.setId(1);
    given(answerModel.getQuestion()).willReturn(new QuestionModelEmpty(1));
    final AnswersOptionsInterface answersOptions = new AnswersOptions();
    final QuestionsServiceInterface questionsService = Mockito.mock(QuestionsServiceInterface.class);
    final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
    answersOptions.setQuestionsService(questionsService);
    answersOptions.withQuestion(questionsOptions);
    final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
    given(questionsService.find(answerModel.getQuestion().getId(), questionsOptions)).willReturn(questionModel);
    final AnswerModelInterface answerModelWithRelations = answersOptions.withRelations(answerModel);
    Assert.assertEquals(answerModel, answerModelWithRelations);
    verify(questionsService).find(1, questionsOptions);
    verify(answerModel).setQuestion(questionModel);
}
Also used : QuestionModelEmpty(easytests.core.models.empty.QuestionModelEmpty) QuestionsServiceInterface(easytests.core.services.QuestionsServiceInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with QuestionModelEmpty

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

the class AnswerModelTest 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 AnswerEntity answerEntity = Mockito.mock(AnswerEntity.class);
    final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
    Mockito.when(questionModel.getId()).thenReturn(questionId);
    Mockito.when(answerEntity.getId()).thenReturn(id);
    Mockito.when(answerEntity.getTxt()).thenReturn(txt);
    Mockito.when(answerEntity.getQuestionId()).thenReturn(questionId);
    Mockito.when(answerEntity.getSerialNumber()).thenReturn(serialNumber);
    Mockito.when(answerEntity.getRight()).thenReturn(right);
    final AnswerModel answerModel = new AnswerModel();
    answerModel.map(answerEntity);
    Assert.assertEquals(id, answerModel.getId());
    Assert.assertEquals(txt, answerModel.getTxt());
    Assert.assertEquals(right, answerModel.getRight());
    Assert.assertEquals(serialNumber, answerModel.getSerialNumber());
    Assert.assertEquals(new QuestionModelEmpty(questionId), answerModel.getQuestion());
}
Also used : QuestionModelEmpty(easytests.core.models.empty.QuestionModelEmpty) AnswerEntity(easytests.core.entities.AnswerEntity) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 10 with QuestionModelEmpty

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

the class AnswerDto method mapInto.

public void mapInto(AnswerModelInterface answerModel) {
    answerModel.setId(this.getId());
    answerModel.setTxt(this.getTxt());
    if ("on".equals(this.right)) {
        answerModel.setRight(true);
    } else {
        answerModel.setRight(false);
    }
    answerModel.setQuestion(new QuestionModelEmpty(getQuestionId()));
    answerModel.setSerialNumber(this.getSerialNumber());
}
Also used : QuestionModelEmpty(easytests.core.models.empty.QuestionModelEmpty)

Aggregations

QuestionModelEmpty (easytests.core.models.empty.QuestionModelEmpty)13 Test (org.junit.Test)7 QuizModelEmpty (easytests.core.models.empty.QuizModelEmpty)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 QuestionsServiceInterface (easytests.core.services.QuestionsServiceInterface)4 PointModelInterface (easytests.core.models.PointModelInterface)3 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)3 ArrayList (java.util.ArrayList)3 QuestionModelInterface (easytests.core.models.QuestionModelInterface)2 QuizModelInterface (easytests.core.models.QuizModelInterface)2 SolutionModelInterface (easytests.core.models.SolutionModelInterface)2 QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)2 SolutionsServiceInterface (easytests.core.services.SolutionsServiceInterface)2 AnswerEntity (easytests.core.entities.AnswerEntity)1 PointEntity (easytests.core.entities.PointEntity)1 AnswerModelInterface (easytests.core.models.AnswerModelInterface)1