Search in sources :

Example 1 with TesteeModelInterface

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;
}
Also used : QuizModelEmpty(easytests.core.models.empty.QuizModelEmpty) TesteeModelInterface(easytests.core.models.TesteeModelInterface)

Example 2 with TesteeModelInterface

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

Example 3 with TesteeModelInterface

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

Example 4 with TesteeModelInterface

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

Example 5 with TesteeModelInterface

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

Aggregations

TesteeModelInterface (easytests.core.models.TesteeModelInterface)33 Test (org.junit.Test)28 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)27 QuizModelInterface (easytests.core.models.QuizModelInterface)11 QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)7 TesteeEntity (easytests.core.entities.TesteeEntity)6 TesteesServiceInterface (easytests.core.services.TesteesServiceInterface)6 TesteesOptionsInterface (easytests.core.options.TesteesOptionsInterface)5 ArrayList (java.util.ArrayList)5 PointModelInterface (easytests.core.models.PointModelInterface)4 QuizModelEmpty (easytests.core.models.empty.QuizModelEmpty)4 PointsServiceInterface (easytests.core.services.PointsServiceInterface)4 InOrder (org.mockito.InOrder)4 IssueModelInterface (easytests.core.models.IssueModelInterface)2 TesteeModel (easytests.core.models.TesteeModel)2 IssueModelEmpty (easytests.core.models.empty.IssueModelEmpty)2 IssuesServiceInterface (easytests.core.services.IssuesServiceInterface)2 QuizzesOptions (easytests.core.options.QuizzesOptions)1 TesteesOptions (easytests.core.options.TesteesOptions)1