Search in sources :

Example 1 with IssueStandardQuestionTypeOptionEntity

use of easytests.core.entities.IssueStandardQuestionTypeOptionEntity in project easy-tests by malinink.

the class IssueStandardQuestionTypeOptionsService method map.

private IssueStandardQuestionTypeOptionEntity map(IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModel) {
    final IssueStandardQuestionTypeOptionEntity questionTypeOptionEntity = new IssueStandardQuestionTypeOptionEntity();
    questionTypeOptionEntity.map(questionTypeOptionModel);
    return questionTypeOptionEntity;
}
Also used : IssueStandardQuestionTypeOptionEntity(easytests.core.entities.IssueStandardQuestionTypeOptionEntity)

Example 2 with IssueStandardQuestionTypeOptionEntity

use of easytests.core.entities.IssueStandardQuestionTypeOptionEntity in project easy-tests by malinink.

the class IssueStandardQuestionTypeOptionsServiceTest method testSaveList.

@Test
public void testSaveList() throws Exception {
    final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModels = new ArrayList<>(2);
    questionTypeOptionModels.add(Models.createQuestionTypeOptionModel(1, 1, 10, 20, 60, 1));
    questionTypeOptionModels.add(Models.createQuestionTypeOptionModel(null, 1, 10, 20, 60, 1));
    final Integer id = 10;
    doAnswer(invocations -> {
        final IssueStandardQuestionTypeOptionEntity questionTypeOptionEntity = (IssueStandardQuestionTypeOptionEntity) invocations.getArguments()[0];
        questionTypeOptionEntity.setId(id);
        return null;
    }).when(this.questionTypeOptionsMapper).insert(Mockito.any(IssueStandardQuestionTypeOptionEntity.class));
    this.questionTypeOptionsService.save(questionTypeOptionModels);
    verify(this.questionTypeOptionsMapper, times(1)).update(this.mapQuestionTypeOptionEntity(questionTypeOptionModels.get(0)));
    verify(this.questionTypeOptionsMapper, times(1)).insert(this.mapQuestionTypeOptionEntity(questionTypeOptionModels.get(1)));
    Assert.assertEquals(id, questionTypeOptionModels.get(1).getId());
}
Also used : IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) ArrayList(java.util.ArrayList) IssueStandardQuestionTypeOptionEntity(easytests.core.entities.IssueStandardQuestionTypeOptionEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with IssueStandardQuestionTypeOptionEntity

use of easytests.core.entities.IssueStandardQuestionTypeOptionEntity in project easy-tests by malinink.

the class IssueStandardQuestionTypeOptionsServiceTest method testFindByIssueStandardWithOptions.

@Test
public void testFindByIssueStandardWithOptions() throws Exception {
    final Integer issueStandardId = 5;
    final List<IssueStandardQuestionTypeOptionEntity> questionTypeOptionEntities = new ArrayList<>(2);
    questionTypeOptionEntities.add(Entities.createQuestionTypeOptionEntityMock(1, 1, 1, 10, null, issueStandardId));
    questionTypeOptionEntities.add(Entities.createQuestionTypeOptionEntityMock(2, 2, 10, 20, 60, issueStandardId));
    final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModels = new ArrayList<>(2);
    questionTypeOptionModels.add(this.mapQuestionTypeOptionModel(questionTypeOptionEntities.get(0)));
    questionTypeOptionModels.add(this.mapQuestionTypeOptionModel(questionTypeOptionEntities.get(1)));
    final IssueStandardQuestionTypeOptionsOptionsInterface questionTypeOptionsOptions = Mockito.mock(IssueStandardQuestionTypeOptionsOptionsInterface.class);
    given(this.questionTypeOptionsMapper.findByIssueStandardId(issueStandardId)).willReturn(questionTypeOptionEntities);
    given(questionTypeOptionsOptions.withRelations(questionTypeOptionModels)).willReturn(questionTypeOptionModels);
    List<IssueStandardQuestionTypeOptionModelInterface> foundedQuestionTypeOptionModels = this.questionTypeOptionsService.findByIssueStandard(questionTypeOptionModels.get(0).getIssueStandard(), questionTypeOptionsOptions);
    verify(questionTypeOptionsOptions).withRelations(questionTypeOptionModels);
    Assert.assertNotNull(foundedQuestionTypeOptionModels);
    Assert.assertEquals(questionTypeOptionModels, foundedQuestionTypeOptionModels);
}
Also used : IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) ArrayList(java.util.ArrayList) IssueStandardQuestionTypeOptionsOptionsInterface(easytests.core.options.IssueStandardQuestionTypeOptionsOptionsInterface) IssueStandardQuestionTypeOptionEntity(easytests.core.entities.IssueStandardQuestionTypeOptionEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with IssueStandardQuestionTypeOptionEntity

use of easytests.core.entities.IssueStandardQuestionTypeOptionEntity in project easy-tests by malinink.

the class IssueStandardQuestionTypeOptionsServiceTest method testFindByIssueStandardPresentList.

@Test
public void testFindByIssueStandardPresentList() throws Exception {
    final Integer issueStandardId = 5;
    final List<IssueStandardQuestionTypeOptionEntity> questionTypeOptionEntities = new ArrayList<>(2);
    questionTypeOptionEntities.add(Entities.createQuestionTypeOptionEntityMock(1, 1, 1, 10, null, issueStandardId));
    questionTypeOptionEntities.add(Entities.createQuestionTypeOptionEntityMock(2, 2, 10, 20, 60, issueStandardId));
    given(this.questionTypeOptionsMapper.findByIssueStandardId(issueStandardId)).willReturn(questionTypeOptionEntities);
    final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModel.getId()).thenReturn(issueStandardId);
    final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModels = this.questionTypeOptionsService.findByIssueStandard(issueStandardModel);
    Assert.assertNotNull(questionTypeOptionModels);
    Assert.assertEquals(questionTypeOptionEntities.size(), questionTypeOptionModels.size());
    for (int i = 0; i < questionTypeOptionModels.size(); i++) {
        Assert.assertEquals(this.mapQuestionTypeOptionModel(questionTypeOptionEntities.get(i)), questionTypeOptionModels.get(i));
    }
}
Also used : IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) ArrayList(java.util.ArrayList) IssueStandardQuestionTypeOptionEntity(easytests.core.entities.IssueStandardQuestionTypeOptionEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with IssueStandardQuestionTypeOptionEntity

use of easytests.core.entities.IssueStandardQuestionTypeOptionEntity in project easy-tests by malinink.

the class IssueStandardQuestionTypeOptionsServiceTest method testSaveInsertsEntity.

@Test
public void testSaveInsertsEntity() throws Exception {
    final IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModel = Models.createQuestionTypeOptionModel(null, 1, 10, 20, 60, 1);
    final Integer id = 10;
    doAnswer(invocations -> {
        final IssueStandardQuestionTypeOptionEntity questionTypeOptionEntity = (IssueStandardQuestionTypeOptionEntity) invocations.getArguments()[0];
        questionTypeOptionEntity.setId(id);
        return null;
    }).when(this.questionTypeOptionsMapper).insert(Mockito.any(IssueStandardQuestionTypeOptionEntity.class));
    this.questionTypeOptionsService.save(questionTypeOptionModel);
    verify(this.questionTypeOptionsMapper, times(1)).insert(this.mapQuestionTypeOptionEntity(questionTypeOptionModel));
    Assert.assertEquals(id, questionTypeOptionModel.getId());
}
Also used : IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) IssueStandardQuestionTypeOptionEntity(easytests.core.entities.IssueStandardQuestionTypeOptionEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

IssueStandardQuestionTypeOptionEntity (easytests.core.entities.IssueStandardQuestionTypeOptionEntity)22 Test (org.junit.Test)14 IssueStandardQuestionTypeOptionModelInterface (easytests.core.models.IssueStandardQuestionTypeOptionModelInterface)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)8 IssueStandardQuestionTypeOptionsOptionsInterface (easytests.core.options.IssueStandardQuestionTypeOptionsOptionsInterface)3 ArrayList (java.util.ArrayList)3 IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)1 IssueStandardModelEmpty (easytests.core.models.empty.IssueStandardModelEmpty)1 DeleteUnidentifiedModelException (easytests.core.services.exceptions.DeleteUnidentifiedModelException)1