Search in sources :

Example 1 with QuizzesOptionsInterface

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

the class QuizzesServiceTest method testSaveModelsListWithOptions.

@Test
public void testSaveModelsListWithOptions() throws Exception {
    final ArgumentCaptor<QuizModelInterface> quizModelCaptor = ArgumentCaptor.forClass(QuizModelInterface.class);
    final List<QuizModelInterface> quizzesModels = this.getQuizzesFixturesModels();
    final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
    this.quizzesService.save(quizzesModels, quizzesOptions);
    this.assertServicesSet(quizzesOptions, quizzesModels.size());
    verify(quizzesOptions, times(quizzesModels.size())).saveWithRelations(quizModelCaptor.capture());
    this.quizzesSupport.assertModelsListEquals(quizzesModels, quizModelCaptor.getAllValues());
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) QuizzesOptionsInterface(easytests.core.options.QuizzesOptionsInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with QuizzesOptionsInterface

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

the class QuizzesServiceTest method testDeleteModelsListWithOptions.

@Test
public void testDeleteModelsListWithOptions() throws Exception {
    final ArgumentCaptor<QuizModelInterface> quizModelCaptor = ArgumentCaptor.forClass(QuizModelInterface.class);
    final List<QuizModelInterface> quizzesModels = this.getQuizzesFixturesModels();
    final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
    this.quizzesService.delete(quizzesModels, quizzesOptions);
    this.assertServicesSet(quizzesOptions, quizzesModels.size());
    verify(quizzesOptions, times(quizzesModels.size())).deleteWithRelations(quizModelCaptor.capture());
    this.quizzesSupport.assertModelsListEquals(quizzesModels, quizModelCaptor.getAllValues());
    verifyNoMoreInteractions(this.quizzesMapper);
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) QuizzesOptionsInterface(easytests.core.options.QuizzesOptionsInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with QuizzesOptionsInterface

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

the class QuizzesServiceTest method testDeleteWithOptions.

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

Example 4 with QuizzesOptionsInterface

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

the class QuizzesServiceTest method testFindByIssueWithOptions.

@Test
public void testFindByIssueWithOptions() throws Exception {
    final Integer issueId = 7;
    final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
    final QuizEntity quizEntityFirst = this.createQuizEntityMock(3, "test3", issueId);
    final QuizEntity quizEntitySecond = this.createQuizEntityMock(12, "test12", issueId);
    final List<QuizEntity> quizzesEntities = new ArrayList<>();
    quizzesEntities.add(quizEntityFirst);
    quizzesEntities.add(quizEntitySecond);
    given(issueModel.getId()).willReturn(issueId);
    given(this.quizzesMapper.findByIssueId(issueId)).willReturn(quizzesEntities);
    final List<QuizModelInterface> quizzesModels = new ArrayList<>();
    quizzesModels.add(this.mapQuizModel(quizEntityFirst));
    quizzesModels.add(this.mapQuizModel(quizEntitySecond));
    final QuizzesOptionsInterface quizOptions = Mockito.mock(QuizzesOptionsInterface.class);
    given(quizOptions.withRelations(quizzesModels)).willReturn(quizzesModels);
    final List<QuizModelInterface> foundedQuizzesModels = this.quizzesService.findByIssue(issueModel, quizOptions);
    verify(this.quizzesMapper).findByIssueId(issueId);
    verify(quizOptions).withRelations(quizzesModels);
    Assert.assertEquals(quizzesModels, foundedQuizzesModels);
}
Also used : QuizEntity(easytests.core.entities.QuizEntity) QuizModelInterface(easytests.core.models.QuizModelInterface) QuizzesOptionsInterface(easytests.core.options.QuizzesOptionsInterface) ArrayList(java.util.ArrayList) IssueModelInterface(easytests.core.models.IssueModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with QuizzesOptionsInterface

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

the class QuizzesServiceTest method testFindWithOptions.

@Test
public void testFindWithOptions() throws Exception {
    final Integer id = 1;
    final Integer issueId = 1;
    final QuizEntity quizEntity = this.createQuizEntityMock(4, "test3", issueId);
    final QuizModelInterface quizModel = this.mapQuizModel(quizEntity);
    final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
    given(this.quizzesMapper.find(id)).willReturn(quizEntity);
    given(quizzesOptions.withRelations(quizModel)).willReturn(quizModel);
    final QuizModelInterface foundedQuizModel = this.quizzesService.find(id, quizzesOptions);
    Assert.assertEquals(quizModel, foundedQuizModel);
    verify(quizzesOptions).withRelations(quizModel);
}
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)

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