EnrolmentResourceConverter extends AbstractConverter<EnrolmentResource, Enrolment> { @Override public Enrolment convert(final EnrolmentResource source, final Enrolment target) { 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.getMarkScaleId() != null) { MarkScale markScale = new MarkScale(); markScale.setId(source.getMarkScaleId()); target.setMarkScale(markScale); } if (source.getPersonId() != null) { Person person = new Person(); person.setId(source.getPersonId()); target.setPerson(person); } if (source.getSpecOfferId() != null) { SpecOffer specOffer = new SpecOffer(); specOffer.setId(source.getSpecOfferId()); target.setSpecOffer(specOffer); } if (source.getDepartmentId() != null) { Department department = new Department(); department.setId(source.getDepartmentId()); target.setDepartment(department); } if (source.getPersonPaperId() != null) { PersonPaper personPaper = new PersonPaper(); personPaper.setId(source.getPersonPaperId()); target.setPersonPaper(personPaper); } if (source.getEnrolmentTypeId() != null) { EnrolmentType enrolmentType = new EnrolmentType(); enrolmentType.setId(source.getEnrolmentTypeId()); target.setEnrolmentType(enrolmentType); } if (source.getParentId() != null) { Enrolment parent = new Enrolment(); parent.setId(source.getParentId()); target.setParent(parent); } return target; }  @Override Enrolment convert(final EnrolmentResource source, final Enrolment target); @Override Enrolment convert(final EnrolmentResource 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 priority = 5; 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 expected = new Enrolment(); 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.setMarkScale(markScale); expected.setPerson(person); expected.setSpecOffer(specOffer); expected.setDepartment(department); expected.setPersonPaper(personPaper); expected.setEnrolmentType(enrolmentType); expected.setParent(parent); expected.setPriority(priority); EnrolmentResource source = new EnrolmentResource(); 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.setMarkScaleId(markScaleId); source.setPersonId(personId); source.setSpecOfferId(specOfferId); source.setDepartmentId(departmentId); source.setPersonPaperId(personPaperId); source.setEnrolmentTypeId(enrolmentTypeId); source.setParentId(parentId); source.setPriority(priority); Enrolment 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; Integer priority = 5; Enrolment expected = new Enrolment(); 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.setPriority(priority); EnrolmentResource source = new EnrolmentResource(); 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.setPriority(priority); Enrolment actual = unit.convert(source); assertEquals(expected, actual); }