Search in sources :

Example 6 with IssueModelInterface

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

the class IssuesOptionsTest method testSaveDeleteWithSubject.

@Test
public void testSaveDeleteWithSubject() {
    final IssuesOptionsInterface issuesOptions = new IssuesOptions();
    final IssuesServiceInterface issuesService = Mockito.mock(IssuesServiceInterface.class);
    final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
    final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
    issuesOptions.setIssuesService(issuesService);
    issuesOptions.setSubjectsService(subjectsService);
    issuesOptions.withSubject(subjectsOptions);
    final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
    final IssuesOptionsInterface issuesOptionsSpy = Mockito.spy(issuesOptions);
    issuesOptionsSpy.saveWithRelations(issueModel);
    verify(subjectsService, times(1)).save(issueModel.getSubject(), subjectsOptions);
    issuesOptionsSpy.deleteWithRelations(issueModel);
    verify(subjectsService, times(1)).delete(issueModel.getSubject(), subjectsOptions);
}
Also used : IssuesServiceInterface(easytests.core.services.IssuesServiceInterface) SubjectsServiceInterface(easytests.core.services.SubjectsServiceInterface) IssueModelInterface(easytests.core.models.IssueModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with IssueModelInterface

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

the class IssuesOptionsTest method testWithRelationsOnSingleModel.

@Test
public void testWithRelationsOnSingleModel() throws Exception {
    final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
    issueModel.setId(1);
    given(issueModel.getSubject()).willReturn(new SubjectModelEmpty(1));
    final IssuesOptionsInterface issuesOptions = new IssuesOptions();
    final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
    final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
    final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
    final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
    issuesOptions.setSubjectsService(subjectsService);
    issuesOptions.setQuizzesService(quizzesService);
    issuesOptions.withSubject(subjectsOptions);
    issuesOptions.withQuizzes(quizzesOptions);
    final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
    final List<QuizModelInterface> quizzesModels = new ArrayList<>();
    quizzesModels.add(Mockito.mock(QuizModelInterface.class));
    given(subjectsService.find(issueModel.getSubject().getId(), subjectsOptions)).willReturn(subjectModel);
    given(quizzesService.findByIssue(issueModel, quizzesOptions)).willReturn(quizzesModels);
    final IssueModelInterface issueModelWithRelations = issuesOptions.withRelations(issueModel);
    Assert.assertEquals(issueModel, issueModelWithRelations);
    verify(subjectsService).find(1, subjectsOptions);
    verify(quizzesService).findByIssue(issueModel, quizzesOptions);
    verify(issueModel).setQuizzes(quizzesModels);
    verify(issueModel).setQuizzes(Mockito.anyList());
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) QuizModelInterface(easytests.core.models.QuizModelInterface) SubjectsServiceInterface(easytests.core.services.SubjectsServiceInterface) QuizzesServiceInterface(easytests.core.services.QuizzesServiceInterface) ArrayList(java.util.ArrayList) IssueModelInterface(easytests.core.models.IssueModelInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with IssueModelInterface

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

the class IssueEntityTest method testMap.

@Test
public void testMap() throws Exception {
    final Integer issueId = 420;
    final String name = "Name";
    final Integer subjectId = 13;
    final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
    Mockito.when(issueModel.getId()).thenReturn(issueId);
    Mockito.when(issueModel.getName()).thenReturn(name);
    Mockito.when(issueModel.getSubject()).thenReturn(new SubjectModelEmpty(subjectId));
    final IssueEntity issueEntity = new IssueEntity();
    issueEntity.map(issueModel);
    Assert.assertEquals(issueId, issueEntity.getId());
    Assert.assertEquals(name, issueEntity.getName());
    Assert.assertEquals(subjectId, issueEntity.getSubjectId());
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) IssueModelInterface(easytests.core.models.IssueModelInterface) Test(org.junit.Test)

Example 9 with IssueModelInterface

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

the class IssuesServiceTest method testDeleteIdentifiedModel.

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

Example 10 with IssueModelInterface

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

the class IssuesServiceTest method testFindAbsentModel.

@Test
public void testFindAbsentModel() throws Exception {
    final Integer id = 10;
    given(this.issuesMapper.find(id)).willReturn(null);
    final IssueModelInterface issueModel = this.issuesService.find(id);
    Assert.assertEquals(null, issueModel);
}
Also used : IssueModelInterface(easytests.core.models.IssueModelInterface)

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