Search in sources :

Example 16 with TesteeModelInterface

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

Example 17 with TesteeModelInterface

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

Example 18 with TesteeModelInterface

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

Example 19 with TesteeModelInterface

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);
}
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 TesteeModelInterface

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

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