Search in sources :

Example 1 with IssuesOptionsInterface

use of easytests.core.options.IssuesOptionsInterface 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 2 with IssuesOptionsInterface

use of easytests.core.options.IssuesOptionsInterface 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 3 with IssuesOptionsInterface

use of easytests.core.options.IssuesOptionsInterface in project easy-tests by malinink.

the class IssuesServiceTest method testFindBySubjectWithOptions.

@Test
public void testFindBySubjectWithOptions() 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 IssuesOptionsInterface issuesOptions = Mockito.mock(IssuesOptionsInterface.class);
    given(issuesOptions.withRelations(issuesModels)).willReturn(issuesModels);
    final List<IssueModelInterface> foundIssuesModels = this.issuesService.findBySubject(subjectModel, issuesOptions);
    verify(this.issuesMapper).findBySubjectId(subjectId);
    verify(issuesOptions).withRelations(issuesModels);
    Assert.assertEquals(issuesModels, foundIssuesModels);
}
Also used : IssuesOptionsInterface(easytests.core.options.IssuesOptionsInterface) IssueEntity(easytests.core.entities.IssueEntity) ArrayList(java.util.ArrayList) IssueModelInterface(easytests.core.models.IssueModelInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 4 with IssuesOptionsInterface

use of easytests.core.options.IssuesOptionsInterface in project easy-tests by malinink.

the class IssuesServiceTest method testMultipleSaveAndDelete.

@Test
public void testMultipleSaveAndDelete() {
    final IssueModelInterface issueModelFirst = Models.createIssueModel(1, "Name", 1);
    final IssueModelInterface issueModelSecond = Models.createIssueModel(2, "Name2", 2);
    final ArrayList<IssueModelInterface> issueModels = new ArrayList<>();
    issueModels.add(issueModelFirst);
    issueModels.add(issueModelSecond);
    this.issuesService.save(issueModels);
    verify(this.issuesMapper, times(1)).update(this.mapIssueEntity(issueModelFirst));
    verify(this.issuesMapper, times(1)).update(this.mapIssueEntity(issueModelSecond));
    this.issuesService.delete(issueModels);
    verify(this.issuesMapper, times(1)).delete(this.mapIssueEntity(issueModelFirst));
    verify(this.issuesMapper, times(1)).delete(this.mapIssueEntity(issueModelSecond));
    final IssuesOptionsInterface issuesOptions = Mockito.mock(IssuesOptionsInterface.class);
    this.issuesService.save(issueModels, issuesOptions);
    verify(issuesOptions).saveWithRelations(issueModelFirst);
    verify(issuesOptions).saveWithRelations(issueModelSecond);
    this.issuesService.delete(issueModels, issuesOptions);
    verify(issuesOptions).deleteWithRelations(issueModelFirst);
    verify(issuesOptions).deleteWithRelations(issueModelSecond);
}
Also used : IssuesOptionsInterface(easytests.core.options.IssuesOptionsInterface) ArrayList(java.util.ArrayList) IssueModelInterface(easytests.core.models.IssueModelInterface)

Example 5 with IssuesOptionsInterface

use of easytests.core.options.IssuesOptionsInterface 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)

Aggregations

IssueModelInterface (easytests.core.models.IssueModelInterface)6 IssuesOptionsInterface (easytests.core.options.IssuesOptionsInterface)6 IssueEntity (easytests.core.entities.IssueEntity)3 ArrayList (java.util.ArrayList)2 SubjectModelInterface (easytests.core.models.SubjectModelInterface)1