use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.
the class TopicsOptionsTest method testSaveWithRelationsQuestions.
@Test
public void testSaveWithRelationsQuestions() throws Exception {
final TopicsOptionsInterface topicsOptions = new TopicsOptions();
final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
final QuestionsServiceInterface questionsService = Mockito.mock(QuestionsServiceInterface.class);
final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
topicsOptions.setQuestionsService(questionsService);
topicsOptions.setTopicsService(topicsService);
final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
topicsOptions.withQuestions(questionsOptions);
final List<QuestionModelInterface> questionsModels = new ArrayList<>();
topicModel.setQuestions(questionsModels);
final InOrder inOrder = Mockito.inOrder(topicsService, questionsService);
topicsOptions.saveWithRelations(topicModel);
inOrder.verify(topicsService).save(topicModel);
inOrder.verify(questionsService).save(topicModel.getQuestions(), questionsOptions);
}
use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.
the class TopicsOptionsTest method testSaveDeleteWithRelationsQuestion.
@Test
public void testSaveDeleteWithRelationsQuestion() throws Exception {
final TopicsOptionsInterface topicsOptions = new TopicsOptions();
final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
final QuestionsServiceInterface questionsService = Mockito.mock(QuestionsServiceInterface.class);
final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
topicsOptions.setQuestionsService(questionsService);
topicsOptions.setTopicsService(topicsService);
final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
topicsOptions.withQuestions(questionsOptions);
final List<QuestionModelInterface> questionsModels = new ArrayList<>();
topicModel.setQuestions(questionsModels);
topicsOptions.saveWithRelations((topicModel));
verify(topicsService).save(topicModel);
topicsOptions.deleteWithRelations(topicModel);
verify(topicsService).delete(topicModel);
verify(questionsService, times(2)).save(topicModel.getQuestions(), questionsOptions);
}
use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.
the class TopicsOptionsTest method testSaveDeleteWithRelationsSubject.
@Test
public void testSaveDeleteWithRelationsSubject() {
final TopicsOptionsInterface topicsOptions = new TopicsOptions();
final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
final SubjectModelInterface subjectModelId = Mockito.mock(SubjectModelInterface.class);
given(topicModel.getSubject()).willReturn(subjectModelId);
final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
topicsOptions.setSubjectsService(subjectsService);
topicsOptions.setTopicsService(topicsService);
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
topicsOptions.withSubject(subjectsOptions);
final SubjectModelInterface subjectModel = new SubjectModel();
topicModel.setSubject(subjectModel);
topicsOptions.saveWithRelations(topicModel);
verify(topicsService).save(topicModel);
topicsOptions.deleteWithRelations(topicModel);
verify(topicsService).delete(topicModel);
verify(subjectsService, times(2)).save(topicModel.getSubject(), subjectsOptions);
}
use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.
the class TopicsOptionsTest method testSaveWithRelationsSubject.
@Test
public void testSaveWithRelationsSubject() throws Exception {
final TopicsOptionsInterface topicsOptions = new TopicsOptions();
final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
final SubjectModelInterface subjectModelId = Mockito.mock(SubjectModelInterface.class);
given(topicModel.getSubject()).willReturn(subjectModelId);
final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
topicsOptions.setSubjectsService(subjectsService);
topicsOptions.setTopicsService(topicsService);
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
topicsOptions.withSubject(subjectsOptions);
final SubjectModelInterface subjectModel = new SubjectModel();
topicModel.setSubject(subjectModel);
final InOrder inOrder = Mockito.inOrder(subjectsService, topicsService);
topicsOptions.saveWithRelations(topicModel);
inOrder.verify(subjectsService).save(topicModel.getSubject(), subjectsOptions);
inOrder.verify(topicsService).save(topicModel);
}
use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.
the class TopicsOptionsTest method testWithRelationsOnNull.
@Test
public void testWithRelationsOnNull() throws Exception {
final TopicsOptionsInterface topicsOptions = new TopicsOptions();
final TopicModelInterface nullTopicModel = null;
final TopicModelInterface topicModelWithRelations = topicsOptions.withRelations(nullTopicModel);
Assert.assertNull(topicModelWithRelations);
}
Aggregations