Search in sources :

Example 1 with QuizEntity

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

the class QuizzesServiceTest method testFindByIssuePresentList.

@Test
public void testFindByIssuePresentList() throws Exception {
    final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
    final List<QuizEntity> quizzesEntities = this.getQuizzesFixturesEntities();
    when(this.quizzesMapper.findByIssueId(issueModel.getId())).thenReturn(quizzesEntities);
    final List<QuizModelInterface> quizzesModels = this.getQuizzesFixturesModels();
    final List<QuizModelInterface> quizzesFoundedModels = this.quizzesService.findByIssue(issueModel);
    this.quizzesSupport.assertModelsListEquals(quizzesModels, quizzesFoundedModels);
}
Also used : QuizEntity(easytests.core.entities.QuizEntity) QuizModelInterface(easytests.core.models.QuizModelInterface) IssueModelInterface(easytests.core.models.IssueModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with QuizEntity

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

the class QuizzesServiceTest method testSaveUpdateEntityIdOnCreation.

@Test
public void testSaveUpdateEntityIdOnCreation() throws Exception {
    final QuizModelInterface quizAdditionalModel = this.quizzesSupport.getModelAdditionalMock(0);
    doAnswer(invocation -> {
        final QuizEntity quizEntity = (QuizEntity) invocation.getArguments()[0];
        quizEntity.setId(5);
        return null;
    }).when(this.quizzesMapper).insert(Mockito.any(QuizEntity.class));
    this.quizzesService.save(quizAdditionalModel);
    verify(quizAdditionalModel, times(1)).setId(5);
}
Also used : QuizEntity(easytests.core.entities.QuizEntity) QuizModelInterface(easytests.core.models.QuizModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with QuizEntity

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

the class QuizzesSupport method getEntityMock.

private QuizEntity getEntityMock(Integer id, Integer issueId, String inviteCode, Boolean codeExpired, LocalDateTime startedAt, LocalDateTime finishedAt) {
    final QuizEntity quizEntity = Mockito.mock(QuizEntity.class);
    Mockito.when(quizEntity.getId()).thenReturn(id);
    Mockito.when(quizEntity.getIssueId()).thenReturn(issueId);
    Mockito.when(quizEntity.getInviteCode()).thenReturn(inviteCode);
    Mockito.when(quizEntity.getCodeExpired()).thenReturn(codeExpired);
    Mockito.when(quizEntity.getStartedAt()).thenReturn(startedAt);
    Mockito.when(quizEntity.getFinishedAt()).thenReturn(finishedAt);
    return quizEntity;
}
Also used : QuizEntity(easytests.core.entities.QuizEntity)

Example 4 with QuizEntity

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

the class QuizzesSupport method assertEntitiesListEquals.

public void assertEntitiesListEquals(List<QuizEntity> expected, List<QuizEntity> actual) {
    Assert.assertEquals(expected.size(), actual.size());
    Integer i = 0;
    for (QuizEntity quizEntity : expected) {
        this.assertEquals(quizEntity, actual.get(i));
        i++;
    }
}
Also used : QuizEntity(easytests.core.entities.QuizEntity)

Example 5 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)

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