Search in sources :

Example 6 with IssueEntity

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

the class IssuesMapperTest method testDelete.

@Test
public void testDelete() throws Exception {
    IssueEntity issue = this.issuesMapper.find(1);
    Assert.assertNotNull(issue);
    this.issuesMapper.delete(issue);
    issue = this.issuesMapper.find(1);
    Assert.assertNull(issue);
}
Also used : IssueEntity(easytests.core.entities.IssueEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with IssueEntity

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

the class IssuesService method map.

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

Example 8 with IssueEntity

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

the class IssuesMapperTest method testFind.

@Test
public void testFind() throws Exception {
    final IssueEntity issue = this.issuesMapper.find(1);
    Assert.assertEquals((long) 1, (long) issue.getId());
    Assert.assertEquals("Name1", issue.getName());
    Assert.assertEquals((long) 1, (long) issue.getSubjectId());
}
Also used : IssueEntity(easytests.core.entities.IssueEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with IssueEntity

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

the class IssuesMapperTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    final Integer id = 1;
    final String name = "NewName";
    final Integer subjectId = 2;
    IssueEntity issueEntity = this.issuesMapper.find(id);
    Assert.assertNotNull(issueEntity);
    Assert.assertEquals(id, issueEntity.getId());
    Assert.assertNotEquals(name, issueEntity.getName());
    Assert.assertNotEquals(subjectId, issueEntity.getSubjectId());
    issueEntity = Mockito.mock(IssueEntity.class);
    Mockito.when(issueEntity.getId()).thenReturn(id);
    Mockito.when(issueEntity.getName()).thenReturn(name);
    Mockito.when(issueEntity.getSubjectId()).thenReturn(subjectId);
    this.issuesMapper.update(issueEntity);
    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)

Example 10 with IssueEntity

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

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