Search in sources :

Example 16 with IssueModelInterface

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

the class QuizzesServiceTest method testFindByIssue.

@Test
public void testFindByIssue() throws Exception {
    final Integer issueId = 7;
    final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
    final QuizEntity quizEntityFirst = this.createQuizEntityMock(3, "test3", issueId);
    final QuizEntity quizEntitySecond = this.createQuizEntityMock(12, "test12", issueId);
    final List<QuizEntity> quizzesEntities = new ArrayList<>();
    quizzesEntities.add(quizEntityFirst);
    quizzesEntities.add(quizEntitySecond);
    Mockito.when(issueModel.getId()).thenReturn(issueId);
    given(this.quizzesMapper.findByIssueId(issueId)).willReturn(quizzesEntities);
    final List<QuizModelInterface> quizzesModels = new ArrayList<>();
    quizzesModels.add(this.mapQuizModel(quizEntityFirst));
    quizzesModels.add(this.mapQuizModel(quizEntitySecond));
    final List<QuizModelInterface> foundedQuizzesModels = this.quizzesService.findByIssue(issueModel);
    verify(this.quizzesMapper).findByIssueId(issueId);
    Assert.assertEquals(quizzesModels, foundedQuizzesModels);
}
Also used : QuizEntity(easytests.core.entities.QuizEntity) QuizModelInterface(easytests.core.models.QuizModelInterface) ArrayList(java.util.ArrayList) IssueModelInterface(easytests.core.models.IssueModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 17 with IssueModelInterface

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

the class IssuesServiceTest method mapIssueModel.

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

Example 18 with IssueModelInterface

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

the class IssuesServiceTest method testFindPresentModel.

@Test
public void testFindPresentModel() throws Exception {
    final Integer id = 1;
    final IssueModelInterface issueModel = Models.createIssueModel(id, "Name1", 1);
    final IssueModelInterface foundIssueModel = this.issuesService.find(id);
    Assert.assertEquals(issueModel.getId(), foundIssueModel.getId());
    Assert.assertEquals(issueModel.getName(), foundIssueModel.getName());
}
Also used : IssueModelInterface(easytests.core.models.IssueModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 19 with IssueModelInterface

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

the class IssuesService method map.

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

Example 20 with IssueModelInterface

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

the class IssuesServiceTest method testSaveModel.

@Test
public void testSaveModel() throws Exception {
    final IssueModelInterface issueModel = new IssueModel();
    issueModel.setName("test111");
    issueModel.setQuizzes(new ModelsListEmpty());
    issueModel.setSubject(new SubjectModelEmpty(1));
    this.issuesService.save(issueModel);
    final IssueModelInterface foundIssueModel = this.issuesService.find(issueModel.getId());
    Assert.assertEquals(issueModel, foundIssueModel);
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty) IssueModelInterface(easytests.core.models.IssueModelInterface) IssueModel(easytests.core.models.IssueModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

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