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);
}
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());
}
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());
}
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));
}
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);
}
Aggregations