Search in sources :

Example 11 with QuizModelInterface

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

the class TesteesServiceTest method testFindByQuizAbsentModel.

@Test
public void testFindByQuizAbsentModel() throws Exception {
    final Integer quizId = 5;
    given(this.testeesMapper.findByQuizId(quizId)).willReturn(null);
    final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
    Mockito.when(quizModel.getId()).thenReturn(quizId);
    final TesteeModelInterface testeeModel = this.testeesService.findByQuiz(quizModel);
    Assert.assertNull(testeeModel);
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) TesteeModelInterface(easytests.core.models.TesteeModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with QuizModelInterface

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

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

the class QuizzesServiceTest method createQuizModel.

private QuizModelInterface createQuizModel(Integer id, String inviteCode, Integer issueId) {
    final QuizModelInterface quizModel = new QuizModel();
    quizModel.setId(id);
    quizModel.setInviteCode(inviteCode);
    final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
    Mockito.when(issueModel.getId()).thenReturn(issueId);
    quizModel.setIssue(issueModel);
    return quizModel;
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) IssueModelInterface(easytests.core.models.IssueModelInterface) QuizModel(easytests.core.models.QuizModel)

Example 14 with QuizModelInterface

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

the class QuizzesServiceTest method testDeleteIdentifiedModel.

@Test
public void testDeleteIdentifiedModel() throws Exception {
    final QuizModelInterface quizModel = this.createQuizModel(1, "test", 1);
    this.quizzesService.delete(quizModel);
    verify(this.quizzesMapper, times(1)).delete(this.mapQuizEntity(quizModel));
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 15 with QuizModelInterface

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

the class QuizzesServiceTest method mapQuizModel.

private QuizModelInterface mapQuizModel(QuizEntity quizEntity) {
    final QuizModelInterface quizModel = new QuizModel();
    quizModel.map(quizEntity);
    return quizModel;
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) QuizModel(easytests.core.models.QuizModel)

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