Search in sources :

Example 16 with PointModelInterface

use of easytests.core.models.PointModelInterface in project easy-tests by malinink.

the class QuizzesOptionsTest method testDeleteWithRelations.

@Test
public void testDeleteWithRelations() throws Exception {
    final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
    final TesteesServiceInterface testeesService = Mockito.mock(TesteesServiceInterface.class);
    final TesteesOptionsInterface testeesOptions = Mockito.mock(TesteesOptionsInterface.class);
    final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
    final QuizzesOptionsInterface quizzesOptions = new QuizzesOptions();
    final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    quizzesOptions.setTesteesService(testeesService);
    quizzesOptions.setQuizzesService(quizzesService);
    quizzesOptions.setPointsService(pointsService);
    quizzesOptions.withPoints(pointsOptions);
    quizzesOptions.withTestee(testeesOptions);
    final List<PointModelInterface> pointsModels = new ArrayList<>();
    quizModel.setPoints(pointsModels);
    final TesteeModelInterface testeeModel = Mockito.mock(TesteeModelInterface.class);
    quizModel.setTestee(testeeModel);
    final InOrder inOrder = Mockito.inOrder(pointsService, quizzesService, testeesService);
    quizzesOptions.deleteWithRelations(quizModel);
    inOrder.verify(pointsService).delete(quizModel.getPoints(), pointsOptions);
    inOrder.verify(quizzesService).delete(quizModel);
    inOrder.verify(testeesService).delete(quizModel.getTestee(), testeesOptions);
}
Also used : InOrder(org.mockito.InOrder) ArrayList(java.util.ArrayList) PointModelInterface(easytests.core.models.PointModelInterface) QuizModelInterface(easytests.core.models.QuizModelInterface) PointsServiceInterface(easytests.core.services.PointsServiceInterface) TesteesServiceInterface(easytests.core.services.TesteesServiceInterface) QuizzesServiceInterface(easytests.core.services.QuizzesServiceInterface) TesteeModelInterface(easytests.core.models.TesteeModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 17 with PointModelInterface

use of easytests.core.models.PointModelInterface in project easy-tests by malinink.

the class SolutionsOptionsTest method testWithRelationsOnSingleModel.

@Test
public void testWithRelationsOnSingleModel() throws Exception {
    final SolutionModelInterface solutionModel = Mockito.mock(SolutionModelInterface.class);
    solutionModel.setId(1);
    given(solutionModel.getPoint()).willReturn(new PointModelEmpty(1));
    given(solutionModel.getAnswer()).willReturn(new AnswerModelEmpty(1));
    final SolutionsOptionsInterface solutionsOptions = new SolutionsOptions();
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    final AnswersOptionsInterface answerOptions = Mockito.mock(AnswersOptionsInterface.class);
    final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
    final AnswersServiceInterface answersService = Mockito.mock(AnswersServiceInterface.class);
    solutionsOptions.setPointsService(pointsService);
    solutionsOptions.setAnswersService(answersService);
    solutionsOptions.withPoint(pointsOptions);
    solutionsOptions.withAnswer(answerOptions);
    final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
    final AnswerModelInterface answerModel = Mockito.mock(AnswerModelInterface.class);
    given(pointsService.find(solutionModel.getPoint().getId(), pointsOptions)).willReturn(pointModel);
    given(answersService.find(solutionModel.getAnswer().getId(), answerOptions)).willReturn(answerModel);
    final SolutionModelInterface solutionModelWithRelations = solutionsOptions.withRelations(solutionModel);
    Assert.assertEquals(solutionModel, solutionModelWithRelations);
    verify(pointsService).find(solutionModel.getPoint().getId(), pointsOptions);
    verify(answersService).find(solutionModel.getAnswer().getId(), answerOptions);
    verify(solutionModel).setPoint(pointModel);
    verify(solutionModel).setAnswer(answerModel);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) AnswerModelEmpty(easytests.core.models.empty.AnswerModelEmpty) PointsServiceInterface(easytests.core.services.PointsServiceInterface) AnswersServiceInterface(easytests.core.services.AnswersServiceInterface) AnswerModelInterface(easytests.core.models.AnswerModelInterface) PointModelEmpty(easytests.core.models.empty.PointModelEmpty) PointModelInterface(easytests.core.models.PointModelInterface) Test(org.junit.Test)

Example 18 with PointModelInterface

use of easytests.core.models.PointModelInterface in project easy-tests by malinink.

the class PointsServiceTest method testDeleteUnidentifiedModel.

@Test
public void testDeleteUnidentifiedModel() throws Exception {
    final PointModelInterface pointModel = this.pointsSupport.getModelAdditionalMock(0);
    exception.expect(DeleteUnidentifiedModelException.class);
    this.pointsService.delete(pointModel);
}
Also used : PointModelInterface(easytests.core.models.PointModelInterface) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 19 with PointModelInterface

use of easytests.core.models.PointModelInterface 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());
}
Also used : PointEntity(easytests.core.entities.PointEntity) PointModelInterface(easytests.core.models.PointModelInterface) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 20 with PointModelInterface

use of easytests.core.models.PointModelInterface in project easy-tests by malinink.

the class PointsServiceTest method testDeleteModelWithOptions.

@Test
public void testDeleteModelWithOptions() throws Exception {
    final PointModelInterface pointModel = this.pointsSupport.getModelFixtureMock(0);
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    this.pointsService.delete(pointModel, pointsOptions);
    this.assertServicesSet(pointsOptions);
    verify(pointsOptions, times(1)).deleteWithRelations(pointModel);
    verifyNoMoreInteractions(this.pointsMapper);
}
Also used : PointsOptionsInterface(easytests.core.options.PointsOptionsInterface) PointModelInterface(easytests.core.models.PointModelInterface) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

PointModelInterface (easytests.core.models.PointModelInterface)32 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)21 Test (org.junit.Test)17 SolutionModelInterface (easytests.core.models.SolutionModelInterface)14 QuizModelInterface (easytests.core.models.QuizModelInterface)11 PointsServiceInterface (easytests.core.services.PointsServiceInterface)10 ArrayList (java.util.ArrayList)10 QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)8 SolutionsServiceInterface (easytests.core.services.SolutionsServiceInterface)7 InOrder (org.mockito.InOrder)6 AnswerModelInterface (easytests.core.models.AnswerModelInterface)5 TesteeModelInterface (easytests.core.models.TesteeModelInterface)4 TesteesServiceInterface (easytests.core.services.TesteesServiceInterface)4 PointEntity (easytests.core.entities.PointEntity)3 SolutionEntity (easytests.core.entities.SolutionEntity)3 QuestionModelInterface (easytests.core.models.QuestionModelInterface)3 QuestionModelEmpty (easytests.core.models.empty.QuestionModelEmpty)3 QuizModelEmpty (easytests.core.models.empty.QuizModelEmpty)3 PointsOptionsInterface (easytests.core.options.PointsOptionsInterface)3 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)3