use of easytests.core.models.QuizModelInterface in project easy-tests by malinink.
the class IssuesOptionsTest method testWithRelationsOnSingleModel.
@Test
public void testWithRelationsOnSingleModel() throws Exception {
final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
issueModel.setId(1);
given(issueModel.getSubject()).willReturn(new SubjectModelEmpty(1));
final IssuesOptionsInterface issuesOptions = new IssuesOptions();
final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
issuesOptions.setSubjectsService(subjectsService);
issuesOptions.setQuizzesService(quizzesService);
issuesOptions.withSubject(subjectsOptions);
issuesOptions.withQuizzes(quizzesOptions);
final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
final List<QuizModelInterface> quizzesModels = new ArrayList<>();
quizzesModels.add(Mockito.mock(QuizModelInterface.class));
given(subjectsService.find(issueModel.getSubject().getId(), subjectsOptions)).willReturn(subjectModel);
given(quizzesService.findByIssue(issueModel, quizzesOptions)).willReturn(quizzesModels);
final IssueModelInterface issueModelWithRelations = issuesOptions.withRelations(issueModel);
Assert.assertEquals(issueModel, issueModelWithRelations);
verify(subjectsService).find(1, subjectsOptions);
verify(quizzesService).findByIssue(issueModel, quizzesOptions);
verify(issueModel).setQuizzes(quizzesModels);
verify(issueModel).setQuizzes(Mockito.anyList());
}
use of easytests.core.models.QuizModelInterface 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.QuizModelInterface 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.QuizModelInterface in project easy-tests by malinink.
the class QuizzesSupport method assertModelsListEquals.
public void assertModelsListEquals(List<QuizModelInterface> expected, List<QuizModelInterface> actual) {
Assert.assertEquals(expected.size(), actual.size());
Integer i = 0;
for (QuizModelInterface quizModel : expected) {
this.assertEquals(quizModel, actual.get(i));
i++;
}
}
use of easytests.core.models.QuizModelInterface in project easy-tests by malinink.
the class QuizzesServiceTest method testSaveEntitiesList.
@Test
public void testSaveEntitiesList() throws Exception {
final QuizModelInterface quizModelFirst = this.createQuizModel(null, "test1", 1);
final QuizModelInterface quizModelSecond = this.createQuizModel(null, "test2", 2);
final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
final List<QuizModelInterface> quizzesModels = new ArrayList<>();
quizzesModels.add(quizModelFirst);
quizzesModels.add(quizModelSecond);
final QuizzesServiceInterface quizzesServiceSpy = Mockito.spy(quizzesService);
quizzesServiceSpy.save(quizzesModels);
verify(quizzesServiceSpy, times(1)).save(quizModelFirst);
verify(quizzesServiceSpy, times(1)).save(quizModelSecond);
quizzesServiceSpy.save(quizzesModels, quizzesOptions);
verify(quizzesServiceSpy, times(1)).save(quizModelFirst, quizzesOptions);
verify(quizzesServiceSpy, times(1)).save(quizModelSecond, quizzesOptions);
}
Aggregations