Search in sources :

Example 21 with SolutionModelInterface

use of easytests.core.models.SolutionModelInterface in project easy-tests by malinink.

the class SolutionsSupport method assertModelsListEquals.

public void assertModelsListEquals(List<SolutionModelInterface> expected, List<SolutionModelInterface> actual) {
    Assert.assertEquals(expected.size(), actual.size());
    Integer i = 0;
    for (SolutionModelInterface solutionModel : expected) {
        this.assertEquals(solutionModel, actual.get(i));
        i++;
    }
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface)

Example 22 with SolutionModelInterface

use of easytests.core.models.SolutionModelInterface in project easy-tests by malinink.

the class SolutionsSupport method getModelMock.

private SolutionModelInterface getModelMock(Integer id, Integer answer, Integer point) {
    final SolutionModelInterface solutionModel = Mockito.mock(SolutionModelInterface.class);
    Mockito.when(solutionModel.getId()).thenReturn(id);
    Mockito.when(solutionModel.getAnswer()).thenReturn(new AnswerModelEmpty(answer));
    Mockito.when(solutionModel.getPoint()).thenReturn(new PointModelEmpty(point));
    return solutionModel;
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) AnswerModelEmpty(easytests.core.models.empty.AnswerModelEmpty) PointModelEmpty(easytests.core.models.empty.PointModelEmpty)

Example 23 with SolutionModelInterface

use of easytests.core.models.SolutionModelInterface in project easy-tests by malinink.

the class SolutionEntityTest method testMap.

@Test
public void testMap() throws Exception {
    final Integer id = 1;
    final Integer answerId = 10;
    final Integer pointId = 3;
    final AnswerModelInterface answerModel = Mockito.mock(AnswerModelInterface.class);
    Mockito.when(answerModel.getId()).thenReturn(answerId);
    final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
    Mockito.when(pointModel.getId()).thenReturn(pointId);
    final SolutionModelInterface solutionModel = Mockito.mock(SolutionModelInterface.class);
    Mockito.when(solutionModel.getId()).thenReturn(id);
    Mockito.when(solutionModel.getAnswer()).thenReturn(answerModel);
    Mockito.when(solutionModel.getPoint()).thenReturn(pointModel);
    final SolutionEntity solutionEntity = new SolutionEntity();
    solutionEntity.map(solutionModel);
    assertEquals(id, solutionEntity.getId());
    assertEquals(answerId, solutionEntity.getAnswerId());
    assertEquals(pointId, solutionEntity.getPointId());
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) AnswerModelInterface(easytests.core.models.AnswerModelInterface) PointModelInterface(easytests.core.models.PointModelInterface) Test(org.junit.Test)

Example 24 with SolutionModelInterface

use of easytests.core.models.SolutionModelInterface in project easy-tests by malinink.

the class SolutionsServiceTest method testFindByPointPresentModel.

@Test
public void testFindByPointPresentModel() throws Exception {
    Integer pointId = 1;
    final List<SolutionEntity> solutionEntities = new ArrayList<>(2);
    solutionEntities.add(this.createSolutionEntityMock(1, 10, pointId));
    solutionEntities.add(this.createSolutionEntityMock(2, 20, pointId));
    given(this.solutionsMapper.findByPointId(pointId)).willReturn(solutionEntities);
    final PointModelInterface pointModel = mock(PointModelInterface.class);
    when(pointModel.getId()).thenReturn(pointId);
    final List<SolutionModelInterface> solutionModels = this.solutionsService.findByPoint(pointModel);
    Assert.assertNotNull(solutionModels);
    Assert.assertEquals(solutionEntities.size(), solutionModels.size());
    for (int i = 0; i < solutionEntities.size(); i++) {
        Assert.assertEquals(solutionModels.get(i), this.mapSolutionModel(solutionEntities.get(i)));
    }
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionEntity(easytests.core.entities.SolutionEntity) ArrayList(java.util.ArrayList) PointModelInterface(easytests.core.models.PointModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 25 with SolutionModelInterface

use of easytests.core.models.SolutionModelInterface in project easy-tests by malinink.

the class SolutionsServiceTest method testDeleteUnidentifiedModel.

@Test
public void testDeleteUnidentifiedModel() throws Exception {
    final SolutionModelInterface solutionModel = this.createSolutionModel(null, 13, 4);
    exception.expect(DeleteUnidentifiedModelException.class);
    this.solutionsService.delete(solutionModel);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

SolutionModelInterface (easytests.core.models.SolutionModelInterface)35 Test (org.junit.Test)22 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)16 PointModelInterface (easytests.core.models.PointModelInterface)14 SolutionEntity (easytests.core.entities.SolutionEntity)9 SolutionsOptionsInterface (easytests.core.options.SolutionsOptionsInterface)8 PointsServiceInterface (easytests.core.services.PointsServiceInterface)7 SolutionsServiceInterface (easytests.core.services.SolutionsServiceInterface)7 ArrayList (java.util.ArrayList)7 AnswerModelInterface (easytests.core.models.AnswerModelInterface)5 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)5 QuizModelInterface (easytests.core.models.QuizModelInterface)4 QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)4 InOrder (org.mockito.InOrder)4 SolutionModel (easytests.core.models.SolutionModel)3 QuestionModelInterface (easytests.core.models.QuestionModelInterface)2 AnswerModelEmpty (easytests.core.models.empty.AnswerModelEmpty)2 PointModelEmpty (easytests.core.models.empty.PointModelEmpty)2 QuestionModelEmpty (easytests.core.models.empty.QuestionModelEmpty)2 QuizModelEmpty (easytests.core.models.empty.QuizModelEmpty)2