Search in sources :

Example 6 with QuizEntity

use of easytests.core.entities.QuizEntity in project easy-tests by malinink.

the class QuizzesMapperTest method testFind.

@Test
public void testFind() throws Exception {
    final QuizEntity quiz = this.quizzesMapper.find(1);
    Assert.assertEquals((long) 1, (long) quiz.getId());
    Assert.assertEquals("test_invite_code1", quiz.getInviteCode());
    Assert.assertEquals(LocalDateTime.of(2003, 2, 1, 0, 0, 0), quiz.getStartedAt());
    Assert.assertEquals(LocalDateTime.of(2003, 3, 1, 0, 0, 0), quiz.getFinishedAt());
    Assert.assertEquals(false, quiz.getCodeExpired());
}
Also used : QuizEntity(easytests.core.entities.QuizEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with QuizEntity

use of easytests.core.entities.QuizEntity in project easy-tests by malinink.

the class QuizzesService method save.

@Override
public void save(QuizModelInterface quizModel) {
    final QuizEntity quizEntity = this.map(quizModel);
    if (quizEntity.getId() == null) {
        this.quizzesMapper.insert(quizEntity);
        quizModel.setId(quizEntity.getId());
        return;
    }
    this.quizzesMapper.update(quizEntity);
}
Also used : QuizEntity(easytests.core.entities.QuizEntity)

Example 8 with QuizEntity

use of easytests.core.entities.QuizEntity in project easy-tests by malinink.

the class QuizzesServiceTest method createQuizEntityMock.

private QuizEntity createQuizEntityMock(Integer id, String inviteCode, Integer issueId) {
    final QuizEntity quizEntity = Mockito.mock(QuizEntity.class);
    Mockito.when(quizEntity.getId()).thenReturn(id);
    Mockito.when(quizEntity.getInviteCode()).thenReturn(inviteCode);
    Mockito.when(quizEntity.getIssueId()).thenReturn(issueId);
    return quizEntity;
}
Also used : QuizEntity(easytests.core.entities.QuizEntity)

Example 9 with QuizEntity

use of easytests.core.entities.QuizEntity in project easy-tests by malinink.

the class QuizzesServiceTest method mapQuizEntity.

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

Example 10 with QuizEntity

use of easytests.core.entities.QuizEntity 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)

Aggregations

QuizEntity (easytests.core.entities.QuizEntity)22 Test (org.junit.Test)14 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)11 QuizModelInterface (easytests.core.models.QuizModelInterface)7 ArrayList (java.util.ArrayList)4 IssueModelInterface (easytests.core.models.IssueModelInterface)3 QuizzesOptionsInterface (easytests.core.options.QuizzesOptionsInterface)3 LocalDateTime (java.time.LocalDateTime)3 IssueModelEmpty (easytests.core.models.empty.IssueModelEmpty)1 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)1 TesteeModelEmpty (easytests.core.models.empty.TesteeModelEmpty)1 DeleteUnidentifiedModelException (easytests.core.services.exceptions.DeleteUnidentifiedModelException)1