Search in sources :

Example 21 with IssueModelInterface

use of easytests.core.models.IssueModelInterface in project easy-tests by malinink.

the class IssuesServiceTest method testFindAbsentModel.

@Test
public void testFindAbsentModel() throws Exception {
    final Integer id = 10;
    final IssueModelInterface issueModel = this.issuesService.find(id);
    Assert.assertEquals(null, issueModel);
}
Also used : IssueModelInterface(easytests.core.models.IssueModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 22 with IssueModelInterface

use of easytests.core.models.IssueModelInterface 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 23 with IssueModelInterface

use of easytests.core.models.IssueModelInterface 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 24 with IssueModelInterface

use of easytests.core.models.IssueModelInterface 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 25 with IssueModelInterface

use of easytests.core.models.IssueModelInterface in project easy-tests by malinink.

the class IssuesServiceTest method testDeleteUnidentifiedModel.

@Test
public void testDeleteUnidentifiedModel() throws Exception {
    final IssueModelInterface issueModel = Models.createIssueModel(null, "Name", 1);
    exception.expect(DeleteUnidentifiedModelException.class);
    this.issuesService.delete(issueModel);
}
Also used : IssueModelInterface(easytests.core.models.IssueModelInterface)

Aggregations

IssueModelInterface (easytests.core.models.IssueModelInterface)32 Test (org.junit.Test)16 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)15 QuizModelInterface (easytests.core.models.QuizModelInterface)11 ArrayList (java.util.ArrayList)11 IssueEntity (easytests.core.entities.IssueEntity)6 IssuesOptionsInterface (easytests.core.options.IssuesOptionsInterface)6 IssuesServiceInterface (easytests.core.services.IssuesServiceInterface)5 QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)5 SubjectModelInterface (easytests.core.models.SubjectModelInterface)4 SubjectModelEmpty (easytests.core.models.empty.SubjectModelEmpty)4 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)4 QuizEntity (easytests.core.entities.QuizEntity)3 IssueModel (easytests.core.models.IssueModel)3 PointModelInterface (easytests.core.models.PointModelInterface)2 TesteeModelInterface (easytests.core.models.TesteeModelInterface)2 IssueModelEmpty (easytests.core.models.empty.IssueModelEmpty)2 PointsServiceInterface (easytests.core.services.PointsServiceInterface)2 TesteesServiceInterface (easytests.core.services.TesteesServiceInterface)2 InOrder (org.mockito.InOrder)2