use of easytests.core.models.TesteeModelInterface in project easy-tests by malinink.
the class TesteesOptionsTest method testDeleteWithRelations.
@Test
public void testDeleteWithRelations() throws Exception {
final TesteeModelInterface testeeModel = Mockito.mock(TesteeModelInterface.class);
final TesteesOptionsInterface testeesOptions = new TesteesOptions();
final TesteesServiceInterface testeesService = Mockito.mock(TesteesServiceInterface.class);
final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
final Integer quizId = 3;
final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
Mockito.when(quizModel.getId()).thenReturn(quizId);
Mockito.when(testeeModel.getQuiz()).thenReturn(quizModel);
testeesOptions.setTesteesService(testeesService);
testeesOptions.setQuizzesService(quizzesService);
testeesOptions.withQuiz(quizzesOptions);
final InOrder inOrder = Mockito.inOrder(quizzesService, testeesService);
testeesOptions.deleteWithRelations(testeeModel);
inOrder.verify(quizzesService, times(1)).delete(testeeModel.getQuiz(), quizzesOptions);
inOrder.verify(testeesService, times(1)).delete(testeeModel);
}
use of easytests.core.models.TesteeModelInterface in project easy-tests by malinink.
the class TesteesOptionsTest method testWithRelationsOnSingleModel.
@Test
public void testWithRelationsOnSingleModel() throws Exception {
final TesteeModelInterface testeeModel = Mockito.mock(TesteeModelInterface.class);
final TesteesOptionsInterface testeesOptions = new TesteesOptions();
final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
final Integer quizId = 3;
Mockito.when(testeeModel.getQuiz()).thenReturn(new QuizModelEmpty(quizId));
final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
Mockito.when(quizModel.getId()).thenReturn(quizId);
given(quizzesService.find(quizId, quizzesOptions)).willReturn(quizModel);
final TesteeModelInterface testeeModelWithoutRelations = testeesOptions.withRelations(testeeModel);
verify(quizzesService, times(0)).find(quizId, quizzesOptions);
Assert.assertEquals(testeeModel, testeeModelWithoutRelations);
verify(testeeModel, times(0)).setQuiz(quizModel);
testeesOptions.setQuizzesService(quizzesService);
testeesOptions.withQuiz(quizzesOptions);
final TesteeModelInterface testeeModelWithRelations = testeesOptions.withRelations(testeeModel);
verify(quizzesService, times(1)).find(quizId, quizzesOptions);
Assert.assertEquals(testeeModel, testeeModelWithRelations);
verify(testeeModel, times(1)).setQuiz(quizModel);
}
use of easytests.core.models.TesteeModelInterface in project easy-tests by malinink.
the class TesteesSupport method assertModelsListEquals.
public void assertModelsListEquals(List<TesteeModelInterface> expected, List<TesteeModelInterface> actual) {
Assert.assertEquals(expected.size(), actual.size());
Integer i = 0;
for (TesteeModelInterface testeeModel : expected) {
this.assertEquals(testeeModel, actual.get(i));
i++;
}
}
use of easytests.core.models.TesteeModelInterface in project easy-tests by malinink.
the class TesteesServiceTest method testFindWithOptions.
@Test
public void testFindWithOptions() throws Exception {
final Integer id = 1;
final TesteeEntity testeeEntity = Entities.createTesteeEntityMock(id, "NewFirstName", "NewLastName1", "NewSurname1", 307, 7);
final TesteeModelInterface testeeModel = this.mapTesteeModel(testeeEntity);
final TesteesOptionsInterface testeesOptions = Mockito.mock(TesteesOptionsInterface.class);
given(this.testeesMapper.find(id)).willReturn(testeeEntity);
given(testeesOptions.withRelations(testeeModel)).willReturn(testeeModel);
final TesteeModelInterface foundedTesteeModel = this.testeesService.find(id, testeesOptions);
Assert.assertEquals(testeeModel, foundedTesteeModel);
verify(testeesOptions).withRelations(testeeModel);
}
use of easytests.core.models.TesteeModelInterface in project easy-tests by malinink.
the class TesteesServiceTest method mapTesteeModel.
private TesteeModelInterface mapTesteeModel(TesteeEntity testeeEntity) {
final TesteeModelInterface testeeModel = new TesteeModel();
testeeModel.map(testeeEntity);
return testeeModel;
}
Aggregations