use of easytests.core.entities.PointEntity in project easy-tests by malinink.
the class PointsServiceTest method testFindByQuiz.
@Test
public void testFindByQuiz() throws Exception {
final Integer quizId = 5;
final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
Mockito.when(quizModel.getId()).thenReturn(quizId);
final PointEntity pointEntityFirst = Entities.createPointEntityMock(1, 1, 1);
final PointEntity pointEntitySecond = Entities.createPointEntityMock(4, 4, 4);
final List<PointEntity> pointsEntities = new ArrayList<>();
pointsEntities.add(pointEntityFirst);
pointsEntities.add(pointEntitySecond);
given(this.pointsMapper.findByQuizId(quizId)).willReturn(pointsEntities);
final List<PointModelInterface> pointsModels = new ArrayList<>();
pointsModels.add(this.mapPointModel(pointEntityFirst));
pointsModels.add(this.mapPointModel(pointEntitySecond));
final List<PointModelInterface> foundPointsModels = this.pointsService.findByQuiz(quizModel);
verify(this.pointsMapper).findByQuizId(quizId);
Assert.assertEquals(pointsModels, foundPointsModels);
}
use of easytests.core.entities.PointEntity in project easy-tests by malinink.
the class PointsServiceTest method testSaveUpdatesEntity.
@Test
public void testSaveUpdatesEntity() throws Exception {
final ArgumentCaptor<PointEntity> pointEntityCaptor = ArgumentCaptor.forClass(PointEntity.class);
final PointModelInterface pointModel = this.pointsSupport.getModelFixtureMock(0);
this.pointsService.save(pointModel);
verify(this.pointsMapper, times(1)).update(pointEntityCaptor.capture());
this.pointsSupport.assertEquals(this.pointsSupport.getEntityFixtureMock(0), pointEntityCaptor.getValue());
}
use of easytests.core.entities.PointEntity in project easy-tests by malinink.
the class PointsServiceTest method testSaveUpdateEntityIdOnCreation.
@Test
public void testSaveUpdateEntityIdOnCreation() throws Exception {
final Integer id = 5;
final PointModelInterface pointModel = this.pointsSupport.getModelAdditionalMock(0);
doAnswer(invocation -> {
final PointEntity answerEntity = (PointEntity) invocation.getArguments()[0];
answerEntity.setId(id);
return null;
}).when(this.pointsMapper).insert(any());
this.pointsService.save(pointModel);
verify(pointModel, times(1)).setId(id);
}
use of easytests.core.entities.PointEntity in project easy-tests by malinink.
the class PointsSupport method getEntityMock.
private PointEntity getEntityMock(Integer id, Integer quizId, Integer questionId) {
final PointEntity pointEntity = Mockito.mock(PointEntity.class);
Mockito.when(pointEntity.getId()).thenReturn(id);
Mockito.when(pointEntity.getQuizId()).thenReturn(quizId);
Mockito.when(pointEntity.getQuestionId()).thenReturn(questionId);
return pointEntity;
}
use of easytests.core.entities.PointEntity in project easy-tests by malinink.
the class PointsMapperTest method testUpdate.
@Test
public void testUpdate() throws Exception {
final PointEntity pointChangedEntity = this.pointsSupport.getEntityAdditionalMock(1);
final PointEntity pointBeforeUpdateEntity = this.pointsMapper.find(pointChangedEntity.getId());
Assert.assertNotNull(pointBeforeUpdateEntity);
this.pointsSupport.assertNotEqualsWithoutId(pointChangedEntity, pointBeforeUpdateEntity);
this.pointsMapper.update(pointChangedEntity);
final PointEntity pointUpdatedEntity = this.pointsMapper.find(pointChangedEntity.getId());
this.pointsSupport.assertEquals(pointChangedEntity, pointUpdatedEntity);
}
Aggregations