Search in sources :

Example 16 with AnswerModelInterface

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

the class AnswersServiceTest method testDeleteIdentifiedModel.

@Test
public void testDeleteIdentifiedModel() throws Exception {
    final AnswerModelInterface answerModel = this.createAnswerModel(1, "Answer3", 1, 1, true);
    this.answersService.delete(answerModel);
    verify(this.answersMapper, times(1)).delete(this.mapAnswerEntity(answerModel));
}
Also used : AnswerModelInterface(easytests.core.models.AnswerModelInterface)

Example 17 with AnswerModelInterface

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

the class AnswersServiceTest method testSaveCreatesEntity.

@Test
public void testSaveCreatesEntity() throws Exception {
    final AnswerModelInterface answerModel = this.createAnswerModel(null, "Answer11", 1, 1, true);
    doAnswer(invocation -> {
        final AnswerEntity answerEntity = (AnswerEntity) invocation.getArguments()[0];
        answerEntity.setId(100);
        return null;
    }).when(this.answersMapper).insert(Mockito.any(AnswerEntity.class));
    this.answersService.save(answerModel);
    verify(this.answersMapper, times(1)).insert(this.mapAnswerEntity(answerModel));
    Assert.assertEquals((Integer) 100, answerModel.getId());
}
Also used : AnswerModelInterface(easytests.core.models.AnswerModelInterface) AnswerEntity(easytests.core.entities.AnswerEntity)

Example 18 with AnswerModelInterface

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

the class SolutionsServiceTest method createSolutionModel.

private SolutionModelInterface createSolutionModel(Integer id, Integer answerId, Integer pointId) {
    final SolutionModelInterface solutionModel = new SolutionModel();
    final AnswerModelInterface answerModel = mock(AnswerModelInterface.class);
    when(answerModel.getId()).thenReturn(answerId);
    final PointModelInterface pointModel = mock(PointModelInterface.class);
    when(pointModel.getId()).thenReturn(pointId);
    solutionModel.setId(id);
    solutionModel.setAnswer(answerModel);
    solutionModel.setPoint(pointModel);
    return solutionModel;
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionModel(easytests.core.models.SolutionModel) AnswerModelInterface(easytests.core.models.AnswerModelInterface) PointModelInterface(easytests.core.models.PointModelInterface)

Example 19 with AnswerModelInterface

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

the class AnswersServiceTest method testSaveCreatesListEntitiesWithOptions.

@Test
public void testSaveCreatesListEntitiesWithOptions() throws Exception {
    final List<AnswerModelInterface> answersModels = getAnswersAdditionalModels();
    final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
    this.answersService.save(answersModels, answersOptions);
    Integer index = 0;
    for (AnswerModelInterface answersModel : answersModels) {
        verify(answersOptions, times(1)).saveWithRelations(answersModels.get(index));
        index++;
    }
    verifyNoMoreInteractions(this.answersMapper);
}
Also used : AnswerModelInterface(easytests.core.models.AnswerModelInterface) AnswersOptionsInterface(easytests.core.options.AnswersOptionsInterface)

Example 20 with AnswerModelInterface

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

the class AnswersServiceTest method assertEquals.

private void assertEquals(List<AnswerModelInterface> expected, List<AnswerModelInterface> actual) {
    Assert.assertEquals(expected.size(), actual.size());
    Integer i = 0;
    for (AnswerModelInterface answerModel : expected) {
        this.answersSupport.assertEquals(answerModel, actual.get(i));
        i++;
    }
}
Also used : AnswerModelInterface(easytests.core.models.AnswerModelInterface)

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