Search in sources :

Example 36 with QuizModelInterface

use of easytests.core.models.QuizModelInterface 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 37 with QuizModelInterface

use of easytests.core.models.QuizModelInterface 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 38 with QuizModelInterface

use of easytests.core.models.QuizModelInterface in project easy-tests by malinink.

the class QuizzesServiceTest method testDeleteUnidentifiedModel.

@Test
public void testDeleteUnidentifiedModel() throws Exception {
    final QuizModelInterface quizModel = this.createQuizModel(null, "test", 1);
    exception.expect(DeleteUnidentifiedModelException.class);
    this.quizzesService.delete(quizModel);
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 39 with QuizModelInterface

use of easytests.core.models.QuizModelInterface 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)

Example 40 with QuizModelInterface

use of easytests.core.models.QuizModelInterface in project easy-tests by malinink.

the class QuizzesServiceTest method testFindPresentModel.

@Test
public void testFindPresentModel() throws Exception {
    final Integer id = 1;
    final QuizEntity quizEntity = this.createQuizEntityMock(id, "test", 1);
    given(this.quizzesMapper.find(id)).willReturn(quizEntity);
    final QuizModelInterface quizModel = this.quizzesService.find(id);
    Assert.assertEquals(this.mapQuizModel(quizEntity), quizModel);
}
Also used : QuizEntity(easytests.core.entities.QuizEntity) QuizModelInterface(easytests.core.models.QuizModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

QuizModelInterface (easytests.core.models.QuizModelInterface)48 Test (org.junit.Test)42 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)42 ArrayList (java.util.ArrayList)17 QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)15 IssueModelInterface (easytests.core.models.IssueModelInterface)11 PointModelInterface (easytests.core.models.PointModelInterface)11 TesteeModelInterface (easytests.core.models.TesteeModelInterface)11 QuizzesOptionsInterface (easytests.core.options.QuizzesOptionsInterface)9 InOrder (org.mockito.InOrder)8 QuizEntity (easytests.core.entities.QuizEntity)7 PointsServiceInterface (easytests.core.services.PointsServiceInterface)7 TesteesServiceInterface (easytests.core.services.TesteesServiceInterface)7 IssuesServiceInterface (easytests.core.services.IssuesServiceInterface)6 SolutionModelInterface (easytests.core.models.SolutionModelInterface)4 IssueModelEmpty (easytests.core.models.empty.IssueModelEmpty)4 QuizModelEmpty (easytests.core.models.empty.QuizModelEmpty)4 SolutionsServiceInterface (easytests.core.services.SolutionsServiceInterface)4 QuestionModelInterface (easytests.core.models.QuestionModelInterface)3 QuizModel (easytests.core.models.QuizModel)2