Search in sources :

Example 11 with QuizEntity

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

Example 12 with QuizEntity

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

the class QuizzesServiceTest method testFindByIssue.

@Test
public void testFindByIssue() 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);
    Mockito.when(issueModel.getId()).thenReturn(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 List<QuizModelInterface> foundedQuizzesModels = this.quizzesService.findByIssue(issueModel);
    verify(this.quizzesMapper).findByIssueId(issueId);
    Assert.assertEquals(quizzesModels, foundedQuizzesModels);
}
Also used : QuizEntity(easytests.core.entities.QuizEntity) QuizModelInterface(easytests.core.models.QuizModelInterface) ArrayList(java.util.ArrayList) IssueModelInterface(easytests.core.models.IssueModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with QuizEntity

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

the class QuizzesMapperTest method testFindByIssueId.

@Test
public void testFindByIssueId() throws Exception {
    final List<QuizEntity> quizzesFixtureEntities = new ArrayList<>();
    quizzesFixtureEntities.add(this.quizzesSupport.getEntityFixtureMock(1));
    final List<QuizEntity> quizzesFoundedEntities = this.quizzesMapper.findByIssueId(2);
    Assert.assertEquals(1, quizzesFoundedEntities.size());
    Integer index = 0;
    for (QuizEntity quizEntity : quizzesFoundedEntities) {
        this.quizzesSupport.assertEquals(quizzesFixtureEntities.get(index), quizEntity);
        index++;
    }
}
Also used : QuizEntity(easytests.core.entities.QuizEntity) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 14 with QuizEntity

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

the class QuizzesMapperTest method testFindAll.

@Test
public void testFindAll() throws Exception {
    final List<QuizEntity> quizFoundedEntities = this.quizzesMapper.findAll();
    Assert.assertEquals(3, quizFoundedEntities.size());
    Integer index = 0;
    for (QuizEntity quizEntity : quizFoundedEntities) {
        final QuizEntity quizFixtureEntity = this.quizzesSupport.getEntityFixtureMock(index);
        this.quizzesSupport.assertEquals(quizFixtureEntity, quizEntity);
        index++;
    }
}
Also used : QuizEntity(easytests.core.entities.QuizEntity) Test(org.junit.Test)

Example 15 with QuizEntity

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

the class QuizzesService method map.

private QuizEntity map(QuizModelInterface quizModel) {
    final QuizEntity quizEntity = new QuizEntity();
    quizEntity.map(quizModel);
    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