Search in sources :

Example 1 with AnswerModelInterface

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

the class AnswersSupport method getModelMock.

private AnswerModelInterface getModelMock(Integer id, String txt, Integer questionId, Integer serialNumber, Boolean right) {
    final AnswerModelInterface answerModel = Mockito.mock(AnswerModelInterface.class);
    Mockito.when(answerModel.getId()).thenReturn(id);
    Mockito.when(answerModel.getTxt()).thenReturn(txt);
    Mockito.when(answerModel.getQuestion()).thenReturn(new QuestionModelEmpty(questionId));
    Mockito.when(answerModel.getSerialNumber()).thenReturn(serialNumber);
    Mockito.when(answerModel.getRight()).thenReturn(right);
    return answerModel;
}
Also used : QuestionModelEmpty(easytests.core.models.empty.QuestionModelEmpty) AnswerModelInterface(easytests.core.models.AnswerModelInterface)

Example 2 with AnswerModelInterface

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

the class AnswersServiceTest method testSaveWithOptions.

@Test
public void testSaveWithOptions() throws Exception {
    final AnswerModelInterface answerModel = this.answersSupport.getModelFixtureMock(0);
    final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
    this.answersService.save(answerModel, answersOptions);
    verify(answersOptions, times(1)).saveWithRelations(answerModel);
    verifyNoMoreInteractions(this.answersMapper);
}
Also used : AnswerModelInterface(easytests.core.models.AnswerModelInterface) AnswersOptionsInterface(easytests.core.options.AnswersOptionsInterface)

Example 3 with AnswerModelInterface

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

the class AnswersServiceTest method testFindByAbsentQuestion.

@Test
public void testFindByAbsentQuestion() throws Exception {
    final AnswerModelInterface answerModel = this.answersSupport.getModelAdditionalMock(2);
    final List<AnswerModelInterface> answerFoundedModels = this.answersService.findByQuestion(answerModel.getQuestion());
    Assert.assertEquals(0, answerFoundedModels.size());
}
Also used : AnswerModelInterface(easytests.core.models.AnswerModelInterface)

Example 4 with AnswerModelInterface

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

the class AnswersServiceTest method testFindByPresentQuestion.

@Test
public void testFindByPresentQuestion() throws Exception {
    final List<AnswerModelInterface> answersModels = getAnswersFixturesModels();
    final List<AnswerEntity> answersEntities = getAnswersFixturesEntities();
    when(this.answersMapper.findByQuestionId(answersModels.get(0).getQuestion().getId())).thenReturn(answersEntities);
    final List<AnswerModelInterface> answersFoundedModels = this.answersService.findByQuestion(answersModels.get(0).getQuestion());
    Integer index = 0;
    for (AnswerModelInterface answerModel1 : answersFoundedModels) {
        this.answersSupport.assertEquals(answerModel1, answersEntities.get(index));
        index++;
    }
}
Also used : AnswerModelInterface(easytests.core.models.AnswerModelInterface) AnswerEntity(easytests.core.entities.AnswerEntity)

Example 5 with AnswerModelInterface

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

the class AnswersServiceTest method testDeleteModelListWithOptions.

@Test
public void testDeleteModelListWithOptions() throws Exception {
    final ArgumentCaptor<AnswerModel> answerModelCaptor = ArgumentCaptor.forClass(AnswerModel.class);
    final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
    final List<AnswerModelInterface> answersModels = getAnswersFixturesModels();
    this.answersService.delete(answersModels, answersOptions);
    verify(answersOptions, times(2)).deleteWithRelations(answerModelCaptor.capture());
    final List<AnswerModel> capturedModels = answerModelCaptor.getAllValues();
    Integer index = 0;
    for (AnswerModelInterface answerModel : answersModels) {
        this.answersSupport.assertEquals(answerModel, capturedModels.get(index));
        index++;
    }
    verifyNoMoreInteractions(this.answersMapper);
}
Also used : AnswerModel(easytests.core.models.AnswerModel) AnswerModelInterface(easytests.core.models.AnswerModelInterface) AnswersOptionsInterface(easytests.core.options.AnswersOptionsInterface)

Aggregations

AnswerModelInterface (easytests.core.models.AnswerModelInterface)36 AnswerEntity (easytests.core.entities.AnswerEntity)10 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)7 AnswerModel (easytests.core.models.AnswerModel)6 QuestionModelInterface (easytests.core.models.QuestionModelInterface)6 AnswersOptionsInterface (easytests.core.options.AnswersOptionsInterface)6 PointModelInterface (easytests.core.models.PointModelInterface)5 SolutionModelInterface (easytests.core.models.SolutionModelInterface)5 TopicModelInterface (easytests.core.models.TopicModelInterface)4 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)4 InOrder (org.mockito.InOrder)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 PointsServiceInterface (easytests.core.services.PointsServiceInterface)3 QuestionTypeModelInterface (easytests.core.models.QuestionTypeModelInterface)2 QuestionTypeModelEmpty (easytests.core.models.empty.QuestionTypeModelEmpty)2 TopicModelEmpty (easytests.core.models.empty.TopicModelEmpty)2 QuestionTypesServiceInterface (easytests.core.services.QuestionTypesServiceInterface)2 QuestionsServiceInterface (easytests.core.services.QuestionsServiceInterface)2