EnrolmentConverter extends AbstractConverter<Enrolment, EnrolmentResource> { @Override public EnrolmentResource convert(final Enrolment source, final EnrolmentResource target) { target.setId(source.getId()); target.setBegDate(source.getBegDate()); target.setDocNum(source.getDocNum()); target.setDocSeries(source.getDocSeries()); target.setDocText(source.getDocText()); target.setEndDate(source.getEndDate()); target.setEvDate(source.getEvDate()); target.setIsContract(source.getIsContract()); target.setIsHostel(source.getIsHostel()); target.setIsPrivilege(source.getIsPrivilege()); target.setIsState(source.getIsState()); target.setMark(source.getMark()); target.setPriority(source.getPriority()); target.setIsEducationState(source.getIsEducationState()); target.setIsInterview(source.getIsInterview()); target.setIsOriginal(source.getIsOriginal()); if (source.getMarkScale() != null) { target.setMarkScaleId(source.getMarkScale().getId()); } if (source.getPerson() != null) { target.setPersonId(source.getPerson().getId()); } if (source.getSpecOffer() != null) { target.setSpecOfferId(source.getSpecOffer().getId()); } if (source.getDepartment() != null) { target.setDepartmentId(source.getDepartment().getId()); } if (source.getPersonPaper() != null) { target.setPersonPaperId(source.getPersonPaper().getId()); } if (source.getEnrolmentType() != null) { target.setEnrolmentTypeId(source.getEnrolmentType().getId()); } if (source.getParent() != null) { target.setParentId(source.getParent().getId()); } return target; }  @Override EnrolmentResource convert(final Enrolment source, final EnrolmentResource target); @Override EnrolmentResource convert(final Enrolment source);  }
@Test public void testConvert() throws Exception { String docNum = "1234"; Date begDate = new Date(); String docSeries = "doc seroes"; String docText = "dco text"; Date endDate = new Date(); Date evDate = new Date(); Integer isContract = 1; Integer isHostel = 2; Integer isPrivilege = 3; Integer isState = 4; Double mark = 2.5; Integer isOriginal = 0; Integer isEducationState = -1; Integer isInterview = 11; Long markScaleId = 8L; MarkScale markScale = new MarkScale(); markScale.setId(markScaleId); Long personId = 2L; Person person = new Person(); person.setId(personId); Long departmentId = 3L; Department department = new Department(); department.setId(departmentId); Long personPaperId = 4L; PersonPaper personPaper = new PersonPaper(); personPaper.setId(personPaperId); Long enrolmentTypeId = 5L; EnrolmentType enrolmentType = new EnrolmentType(); enrolmentType.setId(enrolmentTypeId); Long parentId = 6L; Enrolment parent = new Enrolment(); parent.setId(parentId); Long specOfferId = 7L; SpecOffer specOffer = new SpecOffer(); specOffer.setId(specOfferId); Enrolment source = new Enrolment(); source.setDocNum(docNum); source.setBegDate(begDate); source.setDocSeries(docSeries); source.setDocText(docText); source.setEndDate(endDate); source.setEvDate(evDate); source.setIsContract(isContract); source.setIsHostel(isHostel); source.setIsPrivilege(isPrivilege); source.setIsState(isState); source.setMark(mark); source.setMarkScale(markScale); source.setPerson(person); source.setSpecOffer(specOffer); source.setDepartment(department); source.setPersonPaper(personPaper); source.setEnrolmentType(enrolmentType); source.setParent(parent); source.setIsEducationState(isEducationState); source.setIsInterview(isInterview); source.setIsOriginal(isOriginal); EnrolmentResource expected = new EnrolmentResource(); expected.setDocNum(docNum); expected.setBegDate(begDate); expected.setDocSeries(docSeries); expected.setDocText(docText); expected.setEndDate(endDate); expected.setEvDate(evDate); expected.setIsContract(isContract); expected.setIsHostel(isHostel); expected.setIsPrivilege(isPrivilege); expected.setIsState(isState); expected.setMark(mark); expected.setMarkScaleId(markScaleId); expected.setPersonId(personId); expected.setSpecOfferId(specOfferId); expected.setDepartmentId(departmentId); expected.setPersonPaperId(personPaperId); expected.setEnrolmentTypeId(enrolmentTypeId); expected.setParentId(parentId); expected.setIsEducationState(isEducationState); expected.setIsInterview(isInterview); expected.setIsOriginal(isOriginal); EnrolmentResource actual = unit.convert(source); assertEquals(expected, actual); }
@Test public void testConvertWithNoRelations() throws Exception { String docNum = "1234"; Date begDate = new Date(); String docSeries = "doc seroes"; String docText = "dco text"; Date endDate = new Date(); Date evDate = new Date(); Integer isContract = 1; Integer isHostel = 2; Integer isPrivilege = 3; Integer isState = 4; Double mark = 2.5; Enrolment source = new Enrolment(); source.setDocNum(docNum); source.setBegDate(begDate); source.setDocSeries(docSeries); source.setDocText(docText); source.setEndDate(endDate); source.setEvDate(evDate); source.setIsContract(isContract); source.setIsHostel(isHostel); source.setIsPrivilege(isPrivilege); source.setIsState(isState); source.setMark(mark); EnrolmentResource expected = new EnrolmentResource(); expected.setDocNum(docNum); expected.setBegDate(begDate); expected.setDocSeries(docSeries); expected.setDocText(docText); expected.setEndDate(endDate); expected.setEvDate(evDate); expected.setIsContract(isContract); expected.setIsHostel(isHostel); expected.setIsPrivilege(isPrivilege); expected.setIsState(isState); expected.setMark(mark); EnrolmentResource actual = unit.convert(source); assertEquals(expected, actual); }