use of easytests.core.entities.IssueEntity in project easy-tests by malinink.
the class IssuesServiceTest method testFindBySubject.
@Test
public void testFindBySubject() throws Exception {
final Integer subjectId = 7;
final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
final IssueEntity issueEntityFirst = Entities.createIssueEntityMock(4, "test3", subjectId);
final IssueEntity issueEntitySecond = Entities.createIssueEntityMock(12, "test12", subjectId);
final List<IssueEntity> issuesEntities = new ArrayList<>();
issuesEntities.add(issueEntityFirst);
issuesEntities.add(issueEntitySecond);
Mockito.when(subjectModel.getId()).thenReturn(subjectId);
given(this.issuesMapper.findBySubjectId(subjectId)).willReturn(issuesEntities);
final List<IssueModelInterface> issuesModels = new ArrayList<>();
issuesModels.add(this.mapIssueModel(issueEntityFirst));
issuesModels.add(this.mapIssueModel(issueEntitySecond));
final List<IssueModelInterface> foundIssuesModels = this.issuesService.findBySubject(subjectModel);
verify(this.issuesMapper).findBySubjectId(subjectId);
Assert.assertEquals(issuesModels, foundIssuesModels);
}
use of easytests.core.entities.IssueEntity in project easy-tests by malinink.
the class IssuesServiceTest method getIssuesEntities.
private List<IssueEntity> getIssuesEntities() {
final List<IssueEntity> issuesEntities = new ArrayList<>(2);
final IssueEntity issueEntityFirst = Entities.createIssueEntityMock(1, "Name1", 1);
final IssueEntity issueEntitySecond = Entities.createIssueEntityMock(2, "Name2", 2);
issuesEntities.add(issueEntityFirst);
issuesEntities.add(issueEntitySecond);
return issuesEntities;
}
use of easytests.core.entities.IssueEntity 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);
}
use of easytests.core.entities.IssueEntity 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);
}
use of easytests.core.entities.IssueEntity 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());
}
Aggregations