use of easytests.core.entities.TesteeEntity in project easy-tests by malinink.
the class TesteesService method save.
@Override
public void save(TesteeModelInterface testeeModel) {
final TesteeEntity testeeEntity = this.map(testeeModel);
if (testeeEntity.getId() == null) {
this.testeesMapper.insert(testeeEntity);
testeeModel.setId(testeeEntity.getId());
return;
}
this.testeesMapper.update(testeeEntity);
}
use of easytests.core.entities.TesteeEntity 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.entities.TesteeEntity in project easy-tests by malinink.
the class TesteesServiceTest method testFindAllWithOptions.
@Test
public void testFindAllWithOptions() throws Exception {
final List<TesteeEntity> testeesEntities = this.getTesteesEntities();
final List<TesteeModelInterface> testeesModels = this.getTesteesModels();
final TesteesOptionsInterface testeesOptions = Mockito.mock(TesteesOptionsInterface.class);
given(this.testeesMapper.findAll()).willReturn(testeesEntities);
given(testeesOptions.withRelations(Mockito.anyList())).willReturn(testeesModels);
final List<TesteeModelInterface> foundedTesteesModels = this.testeesService.findAll(testeesOptions);
verify(testeesOptions).withRelations(testeesModels);
Assert.assertEquals(testeesModels, foundedTesteesModels);
}
use of easytests.core.entities.TesteeEntity in project easy-tests by malinink.
the class TesteesServiceTest method testFindByQuizWithOptions.
@Test
public void testFindByQuizWithOptions() throws Exception {
final Integer quizId = 3;
final TesteeEntity testeeEntity = Entities.createTesteeEntityMock(3, "FirstName", "LastName", "Surname", 301, quizId);
final TesteeModelInterface testeeModel = this.mapTesteeModel(testeeEntity);
final TesteesOptionsInterface testeesOptions = Mockito.mock(TesteesOptionsInterface.class);
given(this.testeesMapper.findByQuizId(quizId)).willReturn(testeeEntity);
given(testeesOptions.withRelations(testeeModel)).willReturn(testeeModel);
final TesteeModelInterface foundedTesteeModel = this.testeesService.findByQuiz(testeeModel.getQuiz(), testeesOptions);
verify(testeesOptions).withRelations(testeeModel);
Assert.assertNotNull(foundedTesteeModel);
Assert.assertEquals(testeeModel, foundedTesteeModel);
}
use of easytests.core.entities.TesteeEntity in project easy-tests by malinink.
the class TesteeModelTest method testMap.
@Test
public void testMap() throws Exception {
final Integer testeeId = 3;
final String firstName = "FirstName";
final String lastName = "LastName";
final String surname = "Surname";
final Integer groupNumber = 307;
final Integer quizId = 5;
final TesteeEntity testeeEntity = Mockito.mock(TesteeEntity.class);
Mockito.when(testeeEntity.getId()).thenReturn(testeeId);
Mockito.when(testeeEntity.getFirstName()).thenReturn(firstName);
Mockito.when(testeeEntity.getLastName()).thenReturn(lastName);
Mockito.when(testeeEntity.getSurname()).thenReturn(surname);
Mockito.when(testeeEntity.getGroupNumber()).thenReturn(groupNumber);
Mockito.when(testeeEntity.getQuizId()).thenReturn(quizId);
final TesteeModel testeeModel = new TesteeModel();
testeeModel.map(testeeEntity);
Assert.assertEquals(testeeId, testeeModel.getId());
Assert.assertEquals(firstName, testeeModel.getFirstName());
Assert.assertEquals(lastName, testeeModel.getLastName());
Assert.assertEquals(surname, testeeModel.getSurname());
Assert.assertEquals(groupNumber, testeeModel.getGroupNumber());
Assert.assertEquals(new QuizModelEmpty(quizId), testeeModel.getQuiz());
}
Aggregations