use of easytests.core.models.empty.IssueModelEmpty in project easy-tests by malinink.
the class QuizzesOptionsTest method testWithRelationsOnModelsList.
@Test
public void testWithRelationsOnModelsList() throws Exception {
final QuizModelInterface quizModelFirst = Mockito.mock(QuizModelInterface.class);
quizModelFirst.setId(1);
given(quizModelFirst.getIssue()).willReturn(new IssueModelEmpty(1));
final QuizModelInterface quizModelSecond = Mockito.mock(QuizModelInterface.class);
quizModelSecond.setId(2);
given(quizModelSecond.getIssue()).willReturn(new IssueModelEmpty(2));
final List<QuizModelInterface> quizzesModels = new ArrayList<>(2);
quizzesModels.add(quizModelFirst);
quizzesModels.add(quizModelSecond);
final QuizzesOptionsInterface quizzesOptions = new QuizzesOptions();
final TesteesServiceInterface testeesService = Mockito.mock(TesteesServiceInterface.class);
final TesteesOptionsInterface testeesOptions = Mockito.mock(TesteesOptionsInterface.class);
final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
final IssuesServiceInterface issuesService = Mockito.mock(IssuesServiceInterface.class);
final IssuesOptionsInterface issueOptions = Mockito.mock(IssuesOptionsInterface.class);
quizzesOptions.setTesteesService(testeesService);
quizzesOptions.setPointsService(pointsService);
quizzesOptions.setIssuesService(issuesService);
quizzesOptions.withTestee(testeesOptions);
quizzesOptions.withPoints(pointsOptions);
quizzesOptions.withIssue(issueOptions);
final List<PointModelInterface> pointsModelsFirst = new ArrayList<>();
pointsModelsFirst.add(Mockito.mock(PointModelInterface.class));
final List<PointModelInterface> pointsModelsSecond = new ArrayList<>();
pointsModelsSecond.add(Mockito.mock(PointModelInterface.class));
pointsModelsSecond.add(Mockito.mock(PointModelInterface.class));
given(pointsService.findByQuiz(quizModelFirst, pointsOptions)).willReturn(pointsModelsFirst);
given(pointsService.findByQuiz(quizModelSecond, pointsOptions)).willReturn(pointsModelsSecond);
final IssueModelInterface issueModelFirst = Mockito.mock(IssueModelInterface.class);
final IssueModelInterface issueModelSecond = Mockito.mock(IssueModelInterface.class);
given(issuesService.find(1, issueOptions)).willReturn(issueModelFirst);
given(issuesService.find(2, issueOptions)).willReturn(issueModelSecond);
final TesteeModelInterface testeeModelFirst = Mockito.mock(TesteeModelInterface.class);
final TesteeModelInterface testeeModelSecond = Mockito.mock(TesteeModelInterface.class);
given(testeesService.findByQuiz(quizModelFirst, testeesOptions)).willReturn(testeeModelFirst);
given(testeesService.findByQuiz(quizModelSecond, testeesOptions)).willReturn(testeeModelSecond);
final List<QuizModelInterface> quizzesModelsWithRelations = quizzesOptions.withRelations(quizzesModels);
Assert.assertEquals(quizzesModelsWithRelations, quizzesModels);
verify(testeesService).findByQuiz(quizModelFirst, testeesOptions);
verify(pointsService).findByQuiz(quizModelFirst, pointsOptions);
verify(issuesService).find(1, issueOptions);
verify(quizzesModels.get(0)).setPoints(pointsModelsFirst);
verify(quizzesModels.get(0)).setPoints(Mockito.anyList());
verify(quizzesModels.get(0)).setIssue(issueModelFirst);
verify(quizzesModels.get(0)).setTestee(testeeModelFirst);
verify(testeesService).findByQuiz(quizModelSecond, testeesOptions);
verify(pointsService).findByQuiz(quizModelSecond, pointsOptions);
verify(issuesService).find(2, issueOptions);
verify(quizzesModels.get(1)).setPoints(pointsModelsSecond);
verify(quizzesModels.get(1)).setPoints(Mockito.anyList());
verify(quizzesModels.get(1)).setIssue(issueModelSecond);
verify(quizzesModels.get(1)).setTestee(testeeModelSecond);
}
use of easytests.core.models.empty.IssueModelEmpty in project easy-tests by malinink.
the class QuizModelTest method testMap.
@Test
public void testMap() throws Exception {
final Integer quizId = 5;
final String quizInviteCode = "Test code";
final LocalDateTime quizStartedAt = LocalDateTime.of(2000, 1, 1, 1, 1, 1);
final LocalDateTime quizFinishedAt = LocalDateTime.of(2001, 1, 1, 1, 1, 1);
final Boolean quizCodeExpired = false;
final Integer quizIssueId = 3;
final QuizEntity quizEntity = Mockito.mock(QuizEntity.class);
Mockito.when(quizEntity.getId()).thenReturn(quizId);
Mockito.when(quizEntity.getInviteCode()).thenReturn(quizInviteCode);
Mockito.when(quizEntity.getStartedAt()).thenReturn(quizStartedAt);
Mockito.when(quizEntity.getFinishedAt()).thenReturn(quizFinishedAt);
Mockito.when(quizEntity.getCodeExpired()).thenReturn(quizCodeExpired);
Mockito.when(quizEntity.getIssueId()).thenReturn(quizIssueId);
final QuizModelInterface quizModel = new QuizModel();
quizModel.map(quizEntity);
Assert.assertEquals(quizId, quizModel.getId());
Assert.assertEquals(quizStartedAt, quizModel.getStartedAt());
Assert.assertEquals(quizFinishedAt, quizModel.getFinishedAt());
Assert.assertEquals(quizCodeExpired, quizModel.getCodeExpired());
Assert.assertEquals(new ModelsListEmpty(), quizModel.getPoints());
Assert.assertEquals(new IssueModelEmpty(quizIssueId), quizModel.getIssue());
Assert.assertEquals(new TesteeModelEmpty(), quizModel.getTestee());
}
use of easytests.core.models.empty.IssueModelEmpty in project easy-tests by malinink.
the class QuizEntityTest method testMap.
@Test
public void testMap() throws Exception {
final Integer quizId = 420;
final Integer issueId = 2;
final String inviteCode = "code";
final Boolean codeExpired = false;
final LocalDateTime startedAt = LocalDateTime.of(1, 1, 1, 1, 1);
final LocalDateTime finishedAt = LocalDateTime.of(2, 1, 1, 1, 1);
final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
Mockito.when(quizModel.getId()).thenReturn(quizId);
Mockito.when(quizModel.getIssue()).thenReturn(new IssueModelEmpty(issueId));
Mockito.when(quizModel.getStartedAt()).thenReturn(startedAt);
Mockito.when(quizModel.getInviteCode()).thenReturn(inviteCode);
Mockito.when(quizModel.getFinishedAt()).thenReturn(finishedAt);
Mockito.when(quizModel.getCodeExpired()).thenReturn(codeExpired);
final QuizEntity quizEntity = new QuizEntity();
quizEntity.map(quizModel);
Assert.assertEquals(quizId, quizEntity.getId());
Assert.assertEquals(issueId, quizEntity.getIssueId());
Assert.assertEquals(inviteCode, quizEntity.getInviteCode());
Assert.assertEquals(startedAt, quizEntity.getStartedAt());
Assert.assertEquals(finishedAt, quizEntity.getFinishedAt());
Assert.assertEquals(codeExpired, quizEntity.getCodeExpired());
}
use of easytests.core.models.empty.IssueModelEmpty in project easy-tests by malinink.
the class QuizzesSupport method getModelMock.
private QuizModelInterface getModelMock(Integer id, Integer issueId, String inviteCode, Boolean codeExpired, LocalDateTime startedAt, LocalDateTime finishedAt) {
final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
Mockito.when(quizModel.getId()).thenReturn(id);
Mockito.when(quizModel.getInviteCode()).thenReturn(inviteCode);
Mockito.when(quizModel.getCodeExpired()).thenReturn(codeExpired);
Mockito.when(quizModel.getStartedAt()).thenReturn(startedAt);
Mockito.when(quizModel.getFinishedAt()).thenReturn(finishedAt);
Mockito.when(quizModel.getIssue()).thenReturn(new IssueModelEmpty(issueId));
Mockito.when(quizModel.getPoints()).thenReturn(new ModelsListEmpty());
Mockito.when(quizModel.getTestee()).thenReturn(new TesteeModelEmpty());
return quizModel;
}
use of easytests.core.models.empty.IssueModelEmpty in project easy-tests by malinink.
the class QuizModel method map.
public void map(QuizEntity quizEntity) {
this.setId(quizEntity.getId());
this.setCodeExpired(quizEntity.getCodeExpired());
this.setStartedAt(quizEntity.getStartedAt());
this.setFinishedAt(quizEntity.getFinishedAt());
this.setIssue(new IssueModelEmpty(quizEntity.getIssueId()));
this.setInviteCode(quizEntity.getInviteCode());
this.setPoints(new ModelsListEmpty());
this.setTestee(new TesteeModelEmpty());
}
Aggregations