Search in sources :

Example 1 with PointEntity

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

the class PointsServiceTest method testFindByQuizPresentList.

@Test
public void testFindByQuizPresentList() throws Exception {
    final QuizModelInterface quizModel = this.quizzesSupport.getModelFixtureMock(0);
    final List<PointEntity> pointsEntities = this.getPointsFixturesEntities();
    when(this.pointsMapper.findByQuizId(quizModel.getId())).thenReturn(pointsEntities);
    final List<PointModelInterface> pointsFoundedModels = this.pointsService.findByQuiz(quizModel);
    this.pointsSupport.assertModelsListEquals(this.getPointsFixturesModels(), pointsFoundedModels);
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) PointEntity(easytests.core.entities.PointEntity) PointModelInterface(easytests.core.models.PointModelInterface) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with PointEntity

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

the class PointsSupport method assertEntitiesListEquals.

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

Example 3 with PointEntity

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

the class PointsMapperTest method testFindAll.

@Test
public void testFindAll() throws Exception {
    final List<PointEntity> pointsFoundedEntities = this.pointsMapper.findAll();
    Assert.assertEquals(3, pointsFoundedEntities.size());
    Integer index = 0;
    for (PointEntity pointEntity : pointsFoundedEntities) {
        final PointEntity pointFixtureEntity = this.pointsSupport.getEntityFixtureMock(index);
        this.pointsSupport.assertEquals(pointFixtureEntity, pointEntity);
        index++;
    }
}
Also used : PointEntity(easytests.core.entities.PointEntity) Test(org.junit.Test)

Example 4 with PointEntity

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

the class PointsServiceTest method testFindWithOptions.

@Test
public void testFindWithOptions() throws Exception {
    final Integer id = 1;
    final Integer questionId = 1;
    final Integer quizId = 2;
    final PointEntity pointEntity = Entities.createPointEntityMock(4, questionId, quizId);
    final PointModelInterface pointModel = this.mapPointModel(pointEntity);
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    given(this.pointsMapper.find(id)).willReturn(pointEntity);
    given(pointsOptions.withRelations(pointModel)).willReturn(pointModel);
    final PointModelInterface foundPointModel = this.pointsService.find(id, pointsOptions);
    verify(pointsOptions).withRelations(pointModel);
    Assert.assertEquals(pointModel, foundPointModel);
}
Also used : PointsOptionsInterface(easytests.core.options.PointsOptionsInterface) PointEntity(easytests.core.entities.PointEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with PointEntity

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

the class PointsServiceTest method getPointsEntities.

private List<PointEntity> getPointsEntities() {
    final List<PointEntity> pointEntities = new ArrayList<>(2);
    final PointEntity pointEntityFirst = Entities.createPointEntityMock(1, 1, 1);
    final PointEntity pointEntitySecond = Entities.createPointEntityMock(2, 2, 2);
    pointEntities.add(pointEntityFirst);
    pointEntities.add(pointEntitySecond);
    return pointEntities;
}
Also used : ArrayList(java.util.ArrayList) PointEntity(easytests.core.entities.PointEntity)

Aggregations

PointEntity (easytests.core.entities.PointEntity)23 Test (org.junit.Test)13 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 ArrayList (java.util.ArrayList)4 PointModelInterface (easytests.core.models.PointModelInterface)3 PointsOptionsInterface (easytests.core.options.PointsOptionsInterface)3 QuizModelInterface (easytests.core.models.QuizModelInterface)1 QuestionModelEmpty (easytests.core.models.empty.QuestionModelEmpty)1 QuizModelEmpty (easytests.core.models.empty.QuizModelEmpty)1 DeleteUnidentifiedModelException (easytests.core.services.exceptions.DeleteUnidentifiedModelException)1 Ignore (org.junit.Ignore)1