Search in sources :

Example 1 with QuestionsOptionsInterface

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

the class QuestionsServiceTest method testDeleteModelsListWithOptions.

@Test
public void testDeleteModelsListWithOptions() throws Exception {
    final ArgumentCaptor<QuestionModelInterface> questionModelCaptor = ArgumentCaptor.forClass(QuestionModelInterface.class);
    final List<QuestionModelInterface> questionsModels = this.getQuestionsFixturesModels();
    final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
    this.questionsService.delete(questionsModels, questionsOptions);
    this.assertServicesSet(questionsOptions, questionsModels.size());
    verify(questionsOptions, times(questionsModels.size())).deleteWithRelations(questionModelCaptor.capture());
    this.questionsSupport.assertModelsListEquals(questionsModels, questionModelCaptor.getAllValues());
    verifyNoMoreInteractions(this.questionsMapper);
}
Also used : QuestionModelInterface(easytests.core.models.QuestionModelInterface) QuestionsOptionsInterface(easytests.core.options.QuestionsOptionsInterface)

Example 2 with QuestionsOptionsInterface

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

the class QuestionsServiceTest method testSaveModelsListWithOptions.

@Test
public void testSaveModelsListWithOptions() throws Exception {
    final ArgumentCaptor<QuestionModelInterface> questionsModelCaptor = ArgumentCaptor.forClass(QuestionModelInterface.class);
    final List<QuestionModelInterface> questionsModels = this.getQuestionsFixturesModels();
    final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
    this.questionsService.save(questionsModels, questionsOptions);
    this.assertServicesSet(questionsOptions, questionsModels.size());
    verify(questionsOptions, times(questionsModels.size())).saveWithRelations(questionsModelCaptor.capture());
    this.questionsSupport.assertModelsListEquals(questionsModels, questionsModelCaptor.getAllValues());
    verifyNoMoreInteractions(this.questionsMapper);
}
Also used : QuestionModelInterface(easytests.core.models.QuestionModelInterface) QuestionsOptionsInterface(easytests.core.options.QuestionsOptionsInterface)

Example 3 with QuestionsOptionsInterface

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

the class QuestionsServiceTest method testDeleteWithOptions.

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

Example 4 with QuestionsOptionsInterface

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

the class QuestionsServiceTest method testDeleteModelsList.

@Test
public void testDeleteModelsList() throws Exception {
    final QuestionModelInterface questionModelFirst = Models.createQuestionModel(1, "test1", 1, 1);
    final QuestionModelInterface questionModelSecond = Models.createQuestionModel(2, "test2", 2, 1);
    final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
    final List<QuestionModelInterface> questionsModels = new ArrayList<>();
    questionsModels.add(questionModelFirst);
    questionsModels.add(questionModelSecond);
    final QuestionsServiceInterface questionsServiceSpy = Mockito.spy(questionsService);
    questionsServiceSpy.delete(questionsModels);
    verify(questionsServiceSpy, times(1)).delete(questionModelFirst);
    verify(questionsServiceSpy, times(1)).delete(questionModelSecond);
    questionsServiceSpy.delete(questionsModels, questionsOptions);
    verify(questionsServiceSpy, times(1)).delete(questionModelFirst, questionsOptions);
    verify(questionsServiceSpy, times(1)).delete(questionModelSecond, questionsOptions);
}
Also used : QuestionModelInterface(easytests.core.models.QuestionModelInterface) ArrayList(java.util.ArrayList) QuestionsOptionsInterface(easytests.core.options.QuestionsOptionsInterface)

Example 5 with QuestionsOptionsInterface

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

the class AnswersController method getQuestionModel.

private QuestionModelInterface getQuestionModel(Integer id, Boolean forDelete) {
    final QuestionsOptionsInterface questionsOptions = this.questionsOptionsBuilder.forAuth().withAnswers(new AnswersOptions());
    final QuestionModelInterface questionModel = this.questionsService.find(id, questionsOptions);
    // checkModel(questionModel, topicId);
    if (forDelete) {
        return this.questionsService.find(id, this.questionsOptionsBuilder.forDelete());
    }
    return questionModel;
}
Also used : QuestionsOptionsInterface(easytests.core.options.QuestionsOptionsInterface) AnswersOptions(easytests.core.options.AnswersOptions)

Aggregations

QuestionsOptionsInterface (easytests.core.options.QuestionsOptionsInterface)10 QuestionModelInterface (easytests.core.models.QuestionModelInterface)9 QuestionEntity (easytests.core.entities.QuestionEntity)3 ArrayList (java.util.ArrayList)3 TopicModelInterface (easytests.core.models.TopicModelInterface)1 AnswersOptions (easytests.core.options.AnswersOptions)1