Search in sources :

Example 16 with TesteeEntity

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);
}
Also used : TesteeEntity(easytests.core.entities.TesteeEntity)

Example 17 with 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);
}
Also used : TesteesOptionsInterface(easytests.core.options.TesteesOptionsInterface) TesteeEntity(easytests.core.entities.TesteeEntity) TesteeModelInterface(easytests.core.models.TesteeModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 18 with TesteeEntity

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);
}
Also used : TesteesOptionsInterface(easytests.core.options.TesteesOptionsInterface) TesteeEntity(easytests.core.entities.TesteeEntity) TesteeModelInterface(easytests.core.models.TesteeModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 19 with TesteeEntity

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);
}
Also used : TesteesOptionsInterface(easytests.core.options.TesteesOptionsInterface) TesteeEntity(easytests.core.entities.TesteeEntity) TesteeModelInterface(easytests.core.models.TesteeModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 20 with TesteeEntity

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());
}
Also used : TesteeEntity(easytests.core.entities.TesteeEntity) QuizModelEmpty(easytests.core.models.empty.QuizModelEmpty) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Aggregations

TesteeEntity (easytests.core.entities.TesteeEntity)20 Test (org.junit.Test)13 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)12 TesteeModelInterface (easytests.core.models.TesteeModelInterface)6 TesteesOptionsInterface (easytests.core.options.TesteesOptionsInterface)3 QuizModelInterface (easytests.core.models.QuizModelInterface)1 QuizModelEmpty (easytests.core.models.empty.QuizModelEmpty)1 DeleteUnidentifiedModelException (easytests.core.services.exceptions.DeleteUnidentifiedModelException)1 ArrayList (java.util.ArrayList)1