Search in sources :

Example 6 with QuizzesOptionsInterface

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

the class QuizzesServiceTest method testSaveEntitiesList.

@Test
public void testSaveEntitiesList() throws Exception {
    final QuizModelInterface quizModelFirst = this.createQuizModel(null, "test1", 1);
    final QuizModelInterface quizModelSecond = this.createQuizModel(null, "test2", 2);
    final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
    final List<QuizModelInterface> quizzesModels = new ArrayList<>();
    quizzesModels.add(quizModelFirst);
    quizzesModels.add(quizModelSecond);
    final QuizzesServiceInterface quizzesServiceSpy = Mockito.spy(quizzesService);
    quizzesServiceSpy.save(quizzesModels);
    verify(quizzesServiceSpy, times(1)).save(quizModelFirst);
    verify(quizzesServiceSpy, times(1)).save(quizModelSecond);
    quizzesServiceSpy.save(quizzesModels, quizzesOptions);
    verify(quizzesServiceSpy, times(1)).save(quizModelFirst, quizzesOptions);
    verify(quizzesServiceSpy, times(1)).save(quizModelSecond, quizzesOptions);
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) QuizzesOptionsInterface(easytests.core.options.QuizzesOptionsInterface) ArrayList(java.util.ArrayList) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with QuizzesOptionsInterface

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

the class QuizzesServiceTest method testFindAllWithOptions.

@Test
public void testFindAllWithOptions() throws Exception {
    final List<QuizEntity> quizzesEntities = this.getQuizzesEntities();
    final List<QuizModelInterface> quizzesModels = this.getIssuesModels();
    final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
    given(this.quizzesMapper.findAll()).willReturn(quizzesEntities);
    given(quizzesOptions.withRelations(Mockito.anyList())).willReturn(quizzesModels);
    final List<QuizModelInterface> foundedQuizzesModels = this.quizzesService.findAll(quizzesOptions);
    verify(quizzesOptions).withRelations(foundedQuizzesModels);
    Assert.assertEquals(quizzesModels, foundedQuizzesModels);
}
Also used : QuizEntity(easytests.core.entities.QuizEntity) QuizModelInterface(easytests.core.models.QuizModelInterface) QuizzesOptionsInterface(easytests.core.options.QuizzesOptionsInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with QuizzesOptionsInterface

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

the class QuizzesServiceTest method testDeleteModelsList.

@Test
public void testDeleteModelsList() throws Exception {
    final QuizModelInterface quizModelFirst = this.createQuizModel(2, "test2", 1);
    final QuizModelInterface quizModelSecond = this.createQuizModel(3, "test3", 2);
    final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
    final List<QuizModelInterface> quizzesModels = new ArrayList<>();
    quizzesModels.add(quizModelFirst);
    quizzesModels.add(quizModelSecond);
    final QuizzesServiceInterface quizzesServiceSpy = Mockito.spy(quizzesService);
    quizzesServiceSpy.delete(quizzesModels);
    verify(quizzesServiceSpy, times(1)).delete(quizModelFirst);
    verify(quizzesServiceSpy, times(1)).delete(quizModelSecond);
    quizzesServiceSpy.delete(quizzesModels, quizzesOptions);
    verify(quizzesServiceSpy, times(1)).delete(quizModelFirst, quizzesOptions);
    verify(quizzesServiceSpy, times(1)).delete(quizModelSecond, quizzesOptions);
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) QuizzesOptionsInterface(easytests.core.options.QuizzesOptionsInterface) ArrayList(java.util.ArrayList) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with QuizzesOptionsInterface

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

the class QuizzesServiceTest method testSaveWithOptions.

@Test
public void testSaveWithOptions() throws Exception {
    final QuizModelInterface quizModel = this.createQuizModel(null, "test", 1);
    final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
    this.quizzesService.save(quizModel, quizzesOptions);
    verify(quizzesOptions).saveWithRelations(quizModel);
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) QuizzesOptionsInterface(easytests.core.options.QuizzesOptionsInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

QuizModelInterface (easytests.core.models.QuizModelInterface)9 QuizzesOptionsInterface (easytests.core.options.QuizzesOptionsInterface)9 Test (org.junit.Test)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 QuizEntity (easytests.core.entities.QuizEntity)3 ArrayList (java.util.ArrayList)3 IssueModelInterface (easytests.core.models.IssueModelInterface)1