Search in sources :

Example 1 with IssueEntity

use of easytests.core.entities.IssueEntity in project easy-tests by malinink.

the class IssuesServiceTest method mapIssueEntity.

private IssueEntity mapIssueEntity(IssueModelInterface issueModel) {
    final IssueEntity issueEntity = new IssueEntity();
    issueEntity.map(issueModel);
    return issueEntity;
}
Also used : IssueEntity(easytests.core.entities.IssueEntity)

Example 2 with IssueEntity

use of easytests.core.entities.IssueEntity 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 3 with IssueEntity

use of easytests.core.entities.IssueEntity in project easy-tests by malinink.

the class IssuesService method delete.

@Override
public void delete(IssueModelInterface issueModel) {
    final IssueEntity issueEntity = this.map(issueModel);
    if (issueEntity.getId() == null) {
        throw new DeleteUnidentifiedModelException();
    }
    this.issuesMapper.delete(issueEntity);
}
Also used : IssueEntity(easytests.core.entities.IssueEntity) DeleteUnidentifiedModelException(easytests.core.services.exceptions.DeleteUnidentifiedModelException)

Example 4 with IssueEntity

use of easytests.core.entities.IssueEntity in project easy-tests by malinink.

the class IssuesService method save.

@Override
public void save(IssueModelInterface issueModel) {
    final IssueEntity issueEntity = this.map(issueModel);
    if (issueEntity.getId() == null) {
        this.issuesMapper.insert(issueEntity);
        issueModel.setId(issueEntity.getId());
        return;
    }
    this.issuesMapper.update(issueEntity);
}
Also used : IssueEntity(easytests.core.entities.IssueEntity)

Example 5 with IssueEntity

use of easytests.core.entities.IssueEntity in project easy-tests by malinink.

the class IssuesMapperTest method testInsert.

@Test
public void testInsert() throws Exception {
    final Integer id = this.issuesMapper.findAll().size() + 1;
    final String name = "NewName";
    final Integer subjectId = 2;
    IssueEntity issueEntity = Mockito.mock(IssueEntity.class);
    Mockito.when(issueEntity.getName()).thenReturn(name);
    Mockito.when(issueEntity.getSubjectId()).thenReturn(subjectId);
    this.issuesMapper.insert(issueEntity);
    verify(issueEntity, times(1)).setId(id);
    issueEntity = this.issuesMapper.find(id);
    Assert.assertEquals(id, issueEntity.getId());
    Assert.assertEquals(name, issueEntity.getName());
    Assert.assertEquals(subjectId, issueEntity.getSubjectId());
}
Also used : IssueEntity(easytests.core.entities.IssueEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

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