Search in sources :

Example 11 with IssueEntity

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);
}
Also used : IssueEntity(easytests.core.entities.IssueEntity) ArrayList(java.util.ArrayList) IssueModelInterface(easytests.core.models.IssueModelInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 12 with IssueEntity

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;
}
Also used : IssueEntity(easytests.core.entities.IssueEntity) ArrayList(java.util.ArrayList)

Example 13 with IssueEntity

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);
}
Also used : IssuesOptionsInterface(easytests.core.options.IssuesOptionsInterface) IssueEntity(easytests.core.entities.IssueEntity) IssueModelInterface(easytests.core.models.IssueModelInterface)

Example 14 with IssueEntity

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);
}
Also used : IssueEntity(easytests.core.entities.IssueEntity) IssueModelInterface(easytests.core.models.IssueModelInterface)

Example 15 with IssueEntity

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());
}
Also used : IssueEntity(easytests.core.entities.IssueEntity) IssueModelInterface(easytests.core.models.IssueModelInterface)

Aggregations

IssueEntity (easytests.core.entities.IssueEntity)16 IssueModelInterface (easytests.core.models.IssueModelInterface)6 Test (org.junit.Test)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 IssuesOptionsInterface (easytests.core.options.IssuesOptionsInterface)3 ArrayList (java.util.ArrayList)3 SubjectModelInterface (easytests.core.models.SubjectModelInterface)2 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)1 SubjectModelEmpty (easytests.core.models.empty.SubjectModelEmpty)1 DeleteUnidentifiedModelException (easytests.core.services.exceptions.DeleteUnidentifiedModelException)1