Search in sources :

Example 1 with AnswersOptionsInterface

use of easytests.core.options.AnswersOptionsInterface 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 2 with AnswersOptionsInterface

use of easytests.core.options.AnswersOptionsInterface 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)

Example 3 with AnswersOptionsInterface

use of easytests.core.options.AnswersOptionsInterface in project easy-tests by malinink.

the class AnswersServiceTest method testFindWithOptions.

@Test
public void testFindWithOptions() throws Exception {
    final Integer id = 1;
    final AnswerEntity answerEntity = this.createAnswerEntityMock(id, "NewAnswer", 1, 1, true);
    final AnswerModelInterface answerModel = this.mapAnswerModel(answerEntity);
    final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
    given(this.answersMapper.find(id)).willReturn(answerEntity);
    given(answersOptions.withRelations(answerModel)).willReturn(answerModel);
    final AnswerModelInterface foundedAnswerModel = this.answersService.find(id, answersOptions);
    verify(answersOptions).withRelations(answerModel);
    Assert.assertNotNull(foundedAnswerModel);
    Assert.assertEquals(answerModel, foundedAnswerModel);
}
Also used : AnswerModelInterface(easytests.core.models.AnswerModelInterface) AnswerEntity(easytests.core.entities.AnswerEntity) AnswersOptionsInterface(easytests.core.options.AnswersOptionsInterface)

Example 4 with AnswersOptionsInterface

use of easytests.core.options.AnswersOptionsInterface in project easy-tests by malinink.

the class AnswersController method getAnswerModelList.

private List<AnswerModelInterface> getAnswerModelList(QuestionModelInterface questionModel) {
    final AnswersOptionsInterface answersOptions = this.answersOptionsBuilder.forAuth();
    final List<AnswerModelInterface> answersList = answersService.findByQuestion(questionModel, answersOptions);
    return answersList;
}
Also used : AnswersOptionsInterface(easytests.core.options.AnswersOptionsInterface)

Example 5 with AnswersOptionsInterface

use of easytests.core.options.AnswersOptionsInterface 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)

Aggregations

AnswersOptionsInterface (easytests.core.options.AnswersOptionsInterface)8 AnswerModelInterface (easytests.core.models.AnswerModelInterface)6 AnswerEntity (easytests.core.entities.AnswerEntity)3 AnswerModel (easytests.core.models.AnswerModel)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2