Search in sources :

Example 11 with IssueModelInterface

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

the class IssuesServiceTest method testSaveUpdatesEntity.

@Test
public void testSaveUpdatesEntity() throws Exception {
    final IssueModelInterface issueModel = Models.createIssueModel(1, "Name", 1);
    this.issuesService.save(issueModel);
    verify(this.issuesMapper, times(1)).update(this.mapIssueEntity(issueModel));
}
Also used : IssueModelInterface(easytests.core.models.IssueModelInterface)

Example 12 with IssueModelInterface

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

the class IssuesServiceTest method testFindWithOptions.

@Test
public void testFindWithOptions() throws Exception {
    final Integer id = 1;
    final IssueEntity issueEntity = Entities.createIssueEntityMock(id, "Name", 2);
    final IssueModelInterface issueModel = this.mapIssueModel(issueEntity);
    final IssuesOptionsInterface issuesOptions = Mockito.mock(IssuesOptionsInterface.class);
    given(this.issuesMapper.find(id)).willReturn(issueEntity);
    given(issuesOptions.withRelations(issueModel)).willReturn(issueModel);
    final IssueModelInterface foundedIssueModel = this.issuesService.find(id, issuesOptions);
    Assert.assertEquals(issueModel, foundedIssueModel);
    verify(issuesOptions).withRelations(issueModel);
}
Also used : IssuesOptionsInterface(easytests.core.options.IssuesOptionsInterface) IssueEntity(easytests.core.entities.IssueEntity) IssueModelInterface(easytests.core.models.IssueModelInterface)

Example 13 with IssueModelInterface

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

the class IssuesServiceTest method testSaveWithOptions.

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

Example 14 with IssueModelInterface

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

the class QuizzesServiceTest method testFindByIssueWithOptions.

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

Example 15 with IssueModelInterface

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

the class QuizzesServiceTest method createQuizModel.

private QuizModelInterface createQuizModel(Integer id, String inviteCode, Integer issueId) {
    final QuizModelInterface quizModel = new QuizModel();
    quizModel.setId(id);
    quizModel.setInviteCode(inviteCode);
    final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
    Mockito.when(issueModel.getId()).thenReturn(issueId);
    quizModel.setIssue(issueModel);
    return quizModel;
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) IssueModelInterface(easytests.core.models.IssueModelInterface) QuizModel(easytests.core.models.QuizModel)

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