Search in sources :

Example 6 with IssueStandardModelEmpty

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

the class IssueStandardTopicPriorityModelTest method testMap.

@Test
public void testMap() {
    final Integer id = 5;
    final Integer topicId = 3;
    final Boolean isPreferable = false;
    final Integer issueStandardId = 2;
    final IssueStandardTopicPriorityEntity topicPriorityEntity = Mockito.mock(IssueStandardTopicPriorityEntity.class);
    Mockito.when(topicPriorityEntity.getId()).thenReturn(id);
    Mockito.when(topicPriorityEntity.getTopicId()).thenReturn(topicId);
    Mockito.when(topicPriorityEntity.getIsPreferable()).thenReturn(isPreferable);
    Mockito.when(topicPriorityEntity.getIssueStandardId()).thenReturn(issueStandardId);
    final IssueStandardTopicPriorityModelInterface topicPriorityModel = new IssueStandardTopicPriorityModel();
    topicPriorityModel.map(topicPriorityEntity);
    Assert.assertEquals(id, topicPriorityModel.getId());
    Assert.assertEquals(new TopicModelEmpty(topicId), topicPriorityModel.getTopic());
    Assert.assertEquals(isPreferable, topicPriorityModel.getIsPreferable());
    Assert.assertEquals(new IssueStandardModelEmpty(issueStandardId), topicPriorityModel.getIssueStandard());
}
Also used : TopicModelEmpty(easytests.core.models.empty.TopicModelEmpty) IssueStandardTopicPriorityEntity(easytests.core.entities.IssueStandardTopicPriorityEntity) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty) Test(org.junit.Test)

Example 7 with IssueStandardModelEmpty

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

the class SubjectEntityTest method testMap.

@Test
public void testMap() throws Exception {
    final Integer subjectId = 5;
    final String subjectName = "Test subject";
    final Integer subjectUserId = 1;
    final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
    Mockito.when(subjectModel.getId()).thenReturn(subjectId);
    Mockito.when(subjectModel.getName()).thenReturn(subjectName);
    Mockito.when(subjectModel.getTopics()).thenReturn(new ModelsListEmpty());
    Mockito.when(subjectModel.getUser()).thenReturn(new UserModelEmpty(subjectUserId));
    Mockito.when(subjectModel.getIssueStandard()).thenReturn(new IssueStandardModelEmpty());
    Mockito.when(subjectModel.getIssues()).thenReturn(new ModelsListEmpty());
    final SubjectEntity subjectEntity = new SubjectEntity();
    subjectEntity.map(subjectModel);
    Assert.assertEquals(subjectId, subjectEntity.getId());
    Assert.assertEquals(subjectName, subjectEntity.getName());
    Assert.assertEquals(subjectUserId, subjectEntity.getUserId());
}
Also used : ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty) UserModelEmpty(easytests.core.models.empty.UserModelEmpty) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty) SubjectModelInterface(easytests.core.models.SubjectModelInterface) Test(org.junit.Test)

Example 8 with IssueStandardModelEmpty

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

the class IssueStandardQuestionTypeOptionDto method mapInto.

public void mapInto(IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModel, Integer issueStandardId) {
    questionTypeOptionModel.setId(this.getId());
    questionTypeOptionModel.setQuestionType(new QuestionTypeModelEmpty(this.getQuestionTypeId()));
    questionTypeOptionModel.setMinQuestions(this.getMinQuestions());
    questionTypeOptionModel.setMaxQuestions(this.getMaxQuestions());
    questionTypeOptionModel.setTimeLimit(this.getTimeLimit());
    questionTypeOptionModel.setIssueStandard(new IssueStandardModelEmpty(issueStandardId));
}
Also used : IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty) QuestionTypeModelEmpty(easytests.core.models.empty.QuestionTypeModelEmpty)

Example 9 with IssueStandardModelEmpty

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

the class IssueStandardTopicPriorityDto method mapInto.

public void mapInto(IssueStandardTopicPriorityModelInterface topicPriorityModel, Integer issueStandardId) {
    topicPriorityModel.setId(this.getId());
    topicPriorityModel.setTopic(new TopicModelEmpty(this.getTopicId()));
    topicPriorityModel.setIsPreferable(this.getIsPreferable());
    topicPriorityModel.setIssueStandard(new IssueStandardModelEmpty(issueStandardId));
}
Also used : TopicModelEmpty(easytests.core.models.empty.TopicModelEmpty) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty)

Example 10 with IssueStandardModelEmpty

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

the class IssueStandardDtoValidator method validateQuestionTypeOptionDtoIdBelongsToIssueStandard.

private void validateQuestionTypeOptionDtoIdBelongsToIssueStandard(Errors errors, IssueStandardDto issueStandardDto) {
    final List<IssueStandardQuestionTypeOptionModelInterface> qtoModels = this.questionTypeOptionsService.findByIssueStandard(new IssueStandardModelEmpty(issueStandardDto.getId()));
    final List<Integer> qtoModelIds = new ArrayList<>(qtoModels.size());
    qtoModelIds.addAll(qtoModels.stream().map(IdentityInterface::getId).collect(Collectors.toList()));
    int index = 0;
    for (IssueStandardQuestionTypeOptionDto qtoDto : issueStandardDto.getQuestionTypeOptions()) {
        if (qtoDto.getId() != null && !qtoModelIds.contains(qtoDto.getId())) {
            reject(errors, qtoField(index, "id"), "Foreign questionTypeOption id for IssueStandard entity");
        }
        index++;
    }
}
Also used : IssueStandardQuestionTypeOptionDto(easytests.personal.dto.IssueStandardQuestionTypeOptionDto) IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) ArrayList(java.util.ArrayList) IdentityInterface(easytests.core.models.IdentityInterface) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty)

Aggregations

IssueStandardModelEmpty (easytests.core.models.empty.IssueStandardModelEmpty)23 Test (org.junit.Test)11 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)7 QuestionTypeModelEmpty (easytests.core.models.empty.QuestionTypeModelEmpty)7 UserModelEmpty (easytests.core.models.empty.UserModelEmpty)7 TopicModelEmpty (easytests.core.models.empty.TopicModelEmpty)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 IssueStandardQuestionTypeOptionModelInterface (easytests.core.models.IssueStandardQuestionTypeOptionModelInterface)5 IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)4 IssueStandardTopicPriorityModelInterface (easytests.core.models.IssueStandardTopicPriorityModelInterface)4 IssueStandardsServiceInterface (easytests.core.services.IssueStandardsServiceInterface)4 ArrayList (java.util.ArrayList)4 IdentityInterface (easytests.core.models.IdentityInterface)2 QuestionTypeModelInterface (easytests.core.models.QuestionTypeModelInterface)2 SubjectModelInterface (easytests.core.models.SubjectModelInterface)2 TopicModelInterface (easytests.core.models.TopicModelInterface)2 QuestionTypesServiceInterface (easytests.core.services.QuestionTypesServiceInterface)2 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)2 IssueStandardQuestionTypeOptionEntity (easytests.core.entities.IssueStandardQuestionTypeOptionEntity)1 IssueStandardTopicPriorityEntity (easytests.core.entities.IssueStandardTopicPriorityEntity)1