EnrolmentParametersExtractor extends AbstractParametersExtractor<Enrolment> { @Override public Map<String, Object> getParameters(final Enrolment entity, final Map<String, Object> parameters) { addParameter(entity.getPerson(), personDao, "person", parameters); addParameter(entity.getSpecOffer(), specOfferDao, "specOffer", parameters); addParameter(entity.getDepartment(), departmentDao, "department", parameters); addParameter(entity.getPersonPaper(), personPaperDao, "personPaper", parameters); addParameter(entity.getEnrolmentType(), enrolmentTypeDao, "enrolmentType", parameters); addParameter(entity.getParent(), enrolmentDao, "parent", parameters); addParameter(entity.getMarkScale(), markScaleDao, "markScale", parameters); addParameter(entity.getMark(), "mark", parameters); addParameter(entity.getDocSeries(), "docSeries", parameters); addParameter(entity.getDocNum(), "docNum", parameters); addParameter(entity.getDocText(), "docText", parameters); addParameter(entity.getIsState(), "isState", parameters); addParameter(entity.getIsHostel(), "isHostel", parameters); addParameter(entity.getIsPrivilege(), "isPrivilege", parameters); addParameter(entity.getIsContract(), "isContract", parameters); addParameter(entity.getIsEducationState(), "isEducationState", parameters); addParameter(entity.getIsInterview(), "isInterview", parameters); addParameter(entity.getIsOriginal(), "isOriginal", parameters); addParameter(entity.getEvDate(), "evDate", parameters); addParameter(entity.getBegDate(), "begDate", parameters); addParameter(entity.getEndDate(), "endDate", parameters); addParameter(entity.getPriority(), "priority", parameters); return parameters; }  @Override Map<String, Object> getParameters(final Enrolment entity, final Map<String, Object> parameters);  }
@Test public void testGetParameters() throws Exception { String docNum = "1213344"; Long markScaleId = 1L; MarkScale markScale = new MarkScale(); markScale.setId(markScaleId); Long personId = 1L; Person person = new Person(); person.setId(personId); Long specOfferId = 2L; SpecOffer specOffer = new SpecOffer(); specOffer.setId(specOfferId); Long personPaperId = 3L; PersonPaper personPaper = new PersonPaper(); personPaper.setId(personPaperId); Long enrolmentTypeId = 4L; EnrolmentType enrolmentType = new EnrolmentType(); enrolmentType.setId(enrolmentTypeId); Long parentId = 5L; Enrolment parent = new Enrolment(); parent.setId(parentId); Long departmentId = 6L; Department department = new Department(); department.setId(departmentId); Double mark = 2.1; String docSeries = "doc series"; String docText = "doc text"; Integer isState = 1; Integer isHostel = 2; Integer isPrivilege = 3; Date evDate = new Date(); Date begDate = new Date(); Date endDate = new Date(); Integer isEducationState = 1; Integer isInterview = 11; Integer isOriginal = 1; Enrolment entity = new Enrolment(); entity.setMarkScale(markScale); entity.setPerson(person); entity.setSpecOffer(specOffer); entity.setDepartment(department); entity.setPersonPaper(personPaper); entity.setEnrolmentType(enrolmentType); entity.setParent(parent); entity.setIsEducationState(isEducationState); entity.setIsInterview(isInterview); entity.setIsOriginal(isOriginal); entity.setMark(mark); entity.setDocSeries(docSeries); entity.setDocNum(docNum); entity.setDocText(docText); entity.setIsState(isState); entity.setIsHostel(isHostel); entity.setIsPrivilege(isPrivilege); entity.setEvDate(evDate); entity.setBegDate(begDate); entity.setEndDate(endDate); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("markScale", markScale); expected.put("person", person); expected.put("specOffer", specOffer); expected.put("department", department); expected.put("personPaper", personPaper); expected.put("enrolmentType", enrolmentType); expected.put("parent", parent); expected.put("mark", mark); expected.put("docSeries", docSeries); expected.put("docNum", docNum); expected.put("docText", docText); expected.put("isState", isState); expected.put("isHostel", isHostel); expected.put("isPrivilege", isPrivilege); expected.put("evDate", evDate); expected.put("begDate", begDate); expected.put("endDate", endDate); expected.put("isEducationState", isEducationState); expected.put("isInterview", isInterview); expected.put("isOriginal", isOriginal); expected.put("status", RowStatus.ACTIVE); expected.put("userGroups", groups); when(markScaleDao.getEntityById(anyLong())).thenReturn(markScale); when(personDao.getEntityById(anyLong())).thenReturn(person); when(specOfferDao.getEntityById(anyLong())).thenReturn(specOffer); when(departmentDao.getEntityById(anyLong())).thenReturn(department); when(personPaperDao.getEntityById(anyLong())).thenReturn(personPaper); when(enrolmentTypeDao.getEntityById(anyLong())).thenReturn(enrolmentType); when(enrolmentDao.getEntityById(anyLong())).thenReturn(parent); Map<String, Object> actual = unit.getParameters(entity); verify(markScaleDao).getEntityById(markScaleId); verify(personDao).getEntityById(personId); verify(specOfferDao).getEntityById(specOfferId); verify(departmentDao).getEntityById(departmentId); verify(personPaperDao).getEntityById(personPaperId); verify(enrolmentTypeDao).getEntityById(enrolmentTypeId); verify(enrolmentDao).getEntityById(parentId); assertEquals(expected, actual); }
@Test public void testGetParametersWithDisabledDefaults() throws Exception { unit.setActive(false); unit.setSecurity(false); String docNum = "1213344"; Long markScaleId = 1L; MarkScale markScale = new MarkScale(); markScale.setId(markScaleId); Long personId = 1L; Person person = new Person(); person.setId(personId); Long specOfferId = 2L; SpecOffer specOffer = new SpecOffer(); specOffer.setId(specOfferId); Long personPaperId = 3L; PersonPaper personPaper = new PersonPaper(); personPaper.setId(personPaperId); Long enrolmentTypeId = 4L; EnrolmentType enrolmentType = new EnrolmentType(); enrolmentType.setId(enrolmentTypeId); Long parentId = 5L; Enrolment parent = new Enrolment(); parent.setId(parentId); Long departmentId = 6L; Department department = new Department(); department.setId(departmentId); Double mark = 2.1; String docSeries = "doc series"; String docText = "doc text"; Integer isState = 1; Integer isHostel = 2; Integer isPrivilege = 3; Date evDate = new Date(); Date begDate = new Date(); Date endDate = new Date(); Enrolment entity = new Enrolment(); entity.setMarkScale(markScale); entity.setPerson(person); entity.setSpecOffer(specOffer); entity.setDepartment(department); entity.setPersonPaper(personPaper); entity.setEnrolmentType(enrolmentType); entity.setParent(parent); entity.setMark(mark); entity.setDocSeries(docSeries); entity.setDocNum(docNum); entity.setDocText(docText); entity.setIsState(isState); entity.setIsHostel(isHostel); entity.setIsPrivilege(isPrivilege); entity.setEvDate(evDate); entity.setBegDate(begDate); entity.setEndDate(endDate); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("markScale", markScale); expected.put("person", person); expected.put("specOffer", specOffer); expected.put("department", department); expected.put("personPaper", personPaper); expected.put("enrolmentType", enrolmentType); expected.put("parent", parent); expected.put("mark", mark); expected.put("docSeries", docSeries); expected.put("docNum", docNum); expected.put("docText", docText); expected.put("isState", isState); expected.put("isHostel", isHostel); expected.put("isPrivilege", isPrivilege); expected.put("evDate", evDate); expected.put("begDate", begDate); expected.put("endDate", endDate); when(markScaleDao.getEntityById(anyLong())).thenReturn(markScale); when(personDao.getEntityById(anyLong())).thenReturn(person); when(specOfferDao.getEntityById(anyLong())).thenReturn(specOffer); when(departmentDao.getEntityById(anyLong())).thenReturn(department); when(personPaperDao.getEntityById(anyLong())).thenReturn(personPaper); when(enrolmentTypeDao.getEntityById(anyLong())).thenReturn(enrolmentType); when(enrolmentDao.getEntityById(anyLong())).thenReturn(parent); Map<String, Object> actual = unit.getParameters(entity); verify(markScaleDao).getEntityById(markScaleId); verify(personDao).getEntityById(personId); verify(specOfferDao).getEntityById(specOfferId); verify(departmentDao).getEntityById(departmentId); verify(personPaperDao).getEntityById(personPaperId); verify(enrolmentTypeDao).getEntityById(enrolmentTypeId); verify(enrolmentDao).getEntityById(parentId); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntity() throws Exception { Enrolment entity = new Enrolment(); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("status", RowStatus.ACTIVE); expected.put("userGroups", groups); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntityAndDisabledSecurity() throws Exception { unit.setSecurity(false); Enrolment entity = new Enrolment(); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("status", RowStatus.ACTIVE); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntityAndDisabledStatus() throws Exception { unit.setActive(false); Enrolment entity = new Enrolment(); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("userGroups", groups); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntityAndDisabledDEfaults() throws Exception { unit.setActive(false); unit.setSecurity(false); Enrolment entity = new Enrolment(); Map<String, Object> expected = new HashMap<String, Object>(); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }