Search in sources :

Example 26 with IssueModelInterface

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

the class IssuesServiceTest method testDeleteWithOptions.

@Test
public void testDeleteWithOptions() throws Exception {
    final IssueModelInterface issueModel = Models.createIssueModel(1, "Name", 1);
    final IssuesOptionsInterface issuesOptions = Mockito.mock(IssuesOptionsInterface.class);
    this.issuesService.delete(issueModel, issuesOptions);
    verify(issuesOptions).deleteWithRelations(issueModel);
}
Also used : IssuesOptionsInterface(easytests.core.options.IssuesOptionsInterface) IssueModelInterface(easytests.core.models.IssueModelInterface)

Example 27 with IssueModelInterface

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

the class IssuesServiceTest method testFindAllWithOptions.

@Test
public void testFindAllWithOptions() throws Exception {
    final List<IssueEntity> issuesEntities = this.getIssuesEntities();
    final List<IssueModelInterface> issuesModels = this.getIssuesModels();
    final IssuesOptionsInterface issuesOptions = Mockito.mock(IssuesOptionsInterface.class);
    given(this.issuesMapper.findAll()).willReturn(issuesEntities);
    given(issuesOptions.withRelations(Mockito.anyList())).willReturn(issuesModels);
    final List<IssueModelInterface> foundedIssuesModels = this.issuesService.findAll(issuesOptions);
    verify(issuesOptions).withRelations(issuesModels);
    Assert.assertEquals(issuesModels, foundedIssuesModels);
}
Also used : IssuesOptionsInterface(easytests.core.options.IssuesOptionsInterface) IssueEntity(easytests.core.entities.IssueEntity) IssueModelInterface(easytests.core.models.IssueModelInterface)

Example 28 with IssueModelInterface

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

the class IssuesServiceTest method testFindPresentModel.

@Test
public void testFindPresentModel() throws Exception {
    final Integer id = 1;
    final IssueEntity issueEntity = Entities.createIssueEntityMock(id, "Name", 1);
    given(this.issuesMapper.find(id)).willReturn(issueEntity);
    final IssueModelInterface issueModel = this.issuesService.find(id);
    Assert.assertEquals(this.mapIssueModel(issueEntity), issueModel);
}
Also used : IssueEntity(easytests.core.entities.IssueEntity) IssueModelInterface(easytests.core.models.IssueModelInterface)

Example 29 with IssueModelInterface

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

the class IssuesServiceTest method testSaveCreatesEntity.

@Test
public void testSaveCreatesEntity() throws Exception {
    final IssueModelInterface issueModel = Models.createIssueModel(null, "Name", 1);
    doAnswer(invocation -> {
        final IssueEntity issueEntity = (IssueEntity) invocation.getArguments()[0];
        issueEntity.setId(5);
        return null;
    }).when(this.issuesMapper).insert(Mockito.any(IssueEntity.class));
    this.issuesService.save(issueModel);
    verify(this.issuesMapper, times(1)).insert(this.mapIssueEntity(issueModel));
    Assert.assertEquals((Integer) 5, issueModel.getId());
}
Also used : IssueEntity(easytests.core.entities.IssueEntity) IssueModelInterface(easytests.core.models.IssueModelInterface)

Example 30 with IssueModelInterface

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

the class QuizzesOptionsTest method testWithRelationsOnSingleModel.

@Test
public void testWithRelationsOnSingleModel() throws Exception {
    final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
    quizModel.setId(1);
    given(quizModel.getIssue()).willReturn(new IssueModelEmpty(1));
    final QuizzesOptionsInterface quizzesOptions = new QuizzesOptions();
    final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
    final TesteesServiceInterface testeeService = Mockito.mock(TesteesServiceInterface.class);
    final IssuesServiceInterface issuesService = Mockito.mock(IssuesServiceInterface.class);
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    final TesteesOptionsInterface testeeOptions = Mockito.mock(TesteesOptionsInterface.class);
    final IssuesOptionsInterface issuesOptions = Mockito.mock(IssuesOptionsInterface.class);
    quizzesOptions.setPointsService(pointsService);
    quizzesOptions.setIssuesService(issuesService);
    quizzesOptions.setTesteesService(testeeService);
    quizzesOptions.withTestee(testeeOptions);
    quizzesOptions.withPoints(pointsOptions);
    quizzesOptions.withIssue(issuesOptions);
    final List<PointModelInterface> pointsModels = new ArrayList<>();
    pointsModels.add(Mockito.mock(PointModelInterface.class));
    final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
    final TesteeModelInterface testeeModel = Mockito.mock(TesteeModelInterface.class);
    given(testeeService.findByQuiz(quizModel, testeeOptions)).willReturn(testeeModel);
    given(pointsService.findByQuiz(quizModel, pointsOptions)).willReturn(pointsModels);
    given(issuesService.find(quizModel.getIssue().getId(), issuesOptions)).willReturn(issueModel);
    final QuizModelInterface quizModelWithRelations = quizzesOptions.withRelations(quizModel);
    Assert.assertEquals(quizModel, quizModelWithRelations);
    verify(testeeService).findByQuiz(quizModel, testeeOptions);
    verify(pointsService).findByQuiz(quizModel, pointsOptions);
    verify(issuesService).find(1, issuesOptions);
    verify(quizModel).setTestee(testeeModel);
    verify(quizModel).setPoints(pointsModels);
    verify(quizModel).setIssue(issueModel);
}
Also used : IssuesServiceInterface(easytests.core.services.IssuesServiceInterface) ArrayList(java.util.ArrayList) PointModelInterface(easytests.core.models.PointModelInterface) IssueModelEmpty(easytests.core.models.empty.IssueModelEmpty) QuizModelInterface(easytests.core.models.QuizModelInterface) PointsServiceInterface(easytests.core.services.PointsServiceInterface) TesteesServiceInterface(easytests.core.services.TesteesServiceInterface) IssueModelInterface(easytests.core.models.IssueModelInterface) TesteeModelInterface(easytests.core.models.TesteeModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

IssueModelInterface (easytests.core.models.IssueModelInterface)32 Test (org.junit.Test)16 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)15 QuizModelInterface (easytests.core.models.QuizModelInterface)11 ArrayList (java.util.ArrayList)11 IssueEntity (easytests.core.entities.IssueEntity)6 IssuesOptionsInterface (easytests.core.options.IssuesOptionsInterface)6 IssuesServiceInterface (easytests.core.services.IssuesServiceInterface)5 QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)5 SubjectModelInterface (easytests.core.models.SubjectModelInterface)4 SubjectModelEmpty (easytests.core.models.empty.SubjectModelEmpty)4 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)4 QuizEntity (easytests.core.entities.QuizEntity)3 IssueModel (easytests.core.models.IssueModel)3 PointModelInterface (easytests.core.models.PointModelInterface)2 TesteeModelInterface (easytests.core.models.TesteeModelInterface)2 IssueModelEmpty (easytests.core.models.empty.IssueModelEmpty)2 PointsServiceInterface (easytests.core.services.PointsServiceInterface)2 TesteesServiceInterface (easytests.core.services.TesteesServiceInterface)2 InOrder (org.mockito.InOrder)2