use of easytests.core.models.TesteeModelInterface in project easy-tests by malinink.
the class TesteesSupport method getModelMock.
private TesteeModelInterface getModelMock(Integer id, String firstName, String lastName, String surName, Integer groupNumber, Integer quizId) {
TesteeModelInterface testeeModel = Mockito.mock(TesteeModelInterface.class);
Mockito.when(testeeModel.getId()).thenReturn(id);
Mockito.when(testeeModel.getFirstName()).thenReturn(firstName);
Mockito.when(testeeModel.getLastName()).thenReturn(lastName);
Mockito.when(testeeModel.getSurname()).thenReturn(surName);
Mockito.when(testeeModel.getGroupNumber()).thenReturn(groupNumber);
Mockito.when(testeeModel.getQuiz()).thenReturn(new QuizModelEmpty(quizId));
return testeeModel;
}
use of easytests.core.models.TesteeModelInterface in project easy-tests by malinink.
the class TesteesServiceTest method testFindPresentModel.
@Test
public void testFindPresentModel() throws Exception {
final Integer id = 1;
final TesteeEntity testeeEntity = Entities.createTesteeEntityMock(id, "NewFirstName", "NewLastName1", "NewSurname1", 307, 7);
given(this.testeesMapper.find(id)).willReturn(testeeEntity);
final TesteeModelInterface testeeModel = this.testeesService.find(id);
Assert.assertEquals(this.mapTesteeModel(testeeEntity), testeeModel);
}
use of easytests.core.models.TesteeModelInterface in project easy-tests by malinink.
the class TesteesServiceTest method testSaveCreatesEntity.
@Test
public void testSaveCreatesEntity() throws Exception {
final TesteeModelInterface testeeModel = Models.createTesteeModel(null, "FirstName", "LastName", "Surname", 301, 1);
doAnswer(invocation -> {
final TesteeEntity testeeEntity = (TesteeEntity) invocation.getArguments()[0];
testeeEntity.setId(5);
return null;
}).when(this.testeesMapper).insert(Mockito.any(TesteeEntity.class));
this.testeesService.save(testeeModel);
verify(this.testeesMapper, times(1)).insert(this.mapTesteeEntity(testeeModel));
Assert.assertEquals((Integer) 5, testeeModel.getId());
}
use of easytests.core.models.TesteeModelInterface in project easy-tests by malinink.
the class TesteesServiceTest method testSaveUpdatesEntity.
@Test
public void testSaveUpdatesEntity() throws Exception {
final TesteeModelInterface testeeModel = Models.createTesteeModel(1, "FirstName", "LastName", "Surname", 301, 1);
this.testeesService.save(testeeModel);
verify(this.testeesMapper, times(1)).update(this.mapTesteeEntity(testeeModel));
}
use of easytests.core.models.TesteeModelInterface in project easy-tests by malinink.
the class TesteesServiceTest method testFindByQuizPresentModel.
@Test
public void testFindByQuizPresentModel() throws Exception {
final Integer quizId = 3;
final TesteeEntity testeeEntity = Entities.createTesteeEntityMock(3, "FirstName", "LastName", "Surname", 301, quizId);
given(this.testeesMapper.findByQuizId(quizId)).willReturn(testeeEntity);
final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
Mockito.when(quizModel.getId()).thenReturn(quizId);
final TesteeModelInterface testeeModel = this.testeesService.findByQuiz(quizModel);
Assert.assertNotNull(testeeModel);
Assert.assertEquals(this.mapTesteeModel(testeeEntity), testeeModel);
}
Aggregations