Search in sources :

Example 11 with AnswerModelInterface

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

the class AnswersServiceTest method testFindWithOptions.

@Test
public void testFindWithOptions() throws Exception {
    final Integer id = 1;
    final AnswerEntity answerEntity = this.createAnswerEntityMock(id, "NewAnswer", 1, 1, true);
    final AnswerModelInterface answerModel = this.mapAnswerModel(answerEntity);
    final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
    given(this.answersMapper.find(id)).willReturn(answerEntity);
    given(answersOptions.withRelations(answerModel)).willReturn(answerModel);
    final AnswerModelInterface foundedAnswerModel = this.answersService.find(id, answersOptions);
    verify(answersOptions).withRelations(answerModel);
    Assert.assertNotNull(foundedAnswerModel);
    Assert.assertEquals(answerModel, foundedAnswerModel);
}
Also used : AnswerModelInterface(easytests.core.models.AnswerModelInterface) AnswerEntity(easytests.core.entities.AnswerEntity) AnswersOptionsInterface(easytests.core.options.AnswersOptionsInterface)

Example 12 with AnswerModelInterface

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

the class AnswersServiceTest method testSaveUpdatesEntity.

@Test
public void testSaveUpdatesEntity() throws Exception {
    final AnswerModelInterface answerModel = this.createAnswerModel(1, "Answer22", 1, 1, true);
    this.answersService.save(answerModel);
    verify(this.answersMapper, times(1)).update(this.mapAnswerEntity(answerModel));
}
Also used : AnswerModelInterface(easytests.core.models.AnswerModelInterface)

Example 13 with AnswerModelInterface

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

the class AnswersServiceTest method mapAnswerModel.

private AnswerModelInterface mapAnswerModel(AnswerEntity answerEntity) {
    final AnswerModelInterface answerModel = new AnswerModel();
    answerModel.map(answerEntity);
    return answerModel;
}
Also used : AnswerModel(easytests.core.models.AnswerModel) AnswerModelInterface(easytests.core.models.AnswerModelInterface)

Example 14 with AnswerModelInterface

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

the class AnswersServiceTest method testFindPresentModel.

@Test
public void testFindPresentModel() throws Exception {
    final Integer id = 1;
    final AnswerEntity answerEntity = this.createAnswerEntityMock(id, "NewAnswer", 1, 1, true);
    given(this.answersMapper.find(id)).willReturn(answerEntity);
    final AnswerModelInterface answerModel = this.answersService.find(id);
    Assert.assertEquals(this.mapAnswerModel(answerEntity), answerModel);
}
Also used : AnswerModelInterface(easytests.core.models.AnswerModelInterface) AnswerEntity(easytests.core.entities.AnswerEntity)

Example 15 with AnswerModelInterface

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

the class AnswersServiceTest method testDeleteUnidentifiedModel.

@Test
public void testDeleteUnidentifiedModel() throws Exception {
    final AnswerModelInterface answerModel = this.createAnswerModel(null, "Answer4", 1, 1, true);
    exception.expect(DeleteUnidentifiedModelException.class);
    this.answersService.delete(answerModel);
}
Also used : AnswerModelInterface(easytests.core.models.AnswerModelInterface)

Aggregations

AnswerModelInterface (easytests.core.models.AnswerModelInterface)36 AnswerEntity (easytests.core.entities.AnswerEntity)10 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)7 AnswerModel (easytests.core.models.AnswerModel)6 QuestionModelInterface (easytests.core.models.QuestionModelInterface)6 AnswersOptionsInterface (easytests.core.options.AnswersOptionsInterface)6 PointModelInterface (easytests.core.models.PointModelInterface)5 SolutionModelInterface (easytests.core.models.SolutionModelInterface)5 TopicModelInterface (easytests.core.models.TopicModelInterface)4 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)4 InOrder (org.mockito.InOrder)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 PointsServiceInterface (easytests.core.services.PointsServiceInterface)3 QuestionTypeModelInterface (easytests.core.models.QuestionTypeModelInterface)2 QuestionTypeModelEmpty (easytests.core.models.empty.QuestionTypeModelEmpty)2 TopicModelEmpty (easytests.core.models.empty.TopicModelEmpty)2 QuestionTypesServiceInterface (easytests.core.services.QuestionTypesServiceInterface)2 QuestionsServiceInterface (easytests.core.services.QuestionsServiceInterface)2