SpecOfferParametersExtractor extends AbstractParametersExtractor<SpecOffer> { @Override public Map<String, Object> getParameters(final SpecOffer entity, final Map<String, Object> parameters) { addParameter(entity.getParent(), specOfferDao, "parent", parameters); addParameter(entity.getSpecialty(), specialtyDao, "specialty", parameters); addParameter(entity.getDepartment(), departmentDao, "department", parameters); addParameter(entity.getTimePeriod(), timePeriodDao, "timePeriod", parameters); addParameter(entity.getTimePeriodCourse(), timePeriodDao, "timePeriodCourse", parameters); addParameter(entity.getEducationFormType(), eduFormTypeDao, "educationFormType", parameters); addParameter(entity.getSpecOfferType(), specOfferTypeDao, "specOfferType", parameters); addParameter(entity.getDocSeries(), "docSeries", parameters); addParameter(entity.getDocNum(), "docNum", parameters); addParameter(entity.getLicCount(), "licCount", parameters); addParameter(entity.getStateCount(), "stateCount", parameters); addParameter(entity.getBegDate(), "begDate", parameters); addParameter(entity.getEndDate(), "endDate", parameters); addParameter(entity.getDuration(), "duration", parameters); return parameters; }  @Override Map<String, Object> getParameters(final SpecOffer entity, final Map<String, Object> parameters);  }
@Test public void testGetParameters() throws Exception { Long educationFormTypeId = 3L; EducationFormType eduFormType = new EducationFormType(); eduFormType.setId(educationFormTypeId); Long departmentId = 2L; Department department = new Department(); department.setId(departmentId); Date begDate = new Date(); String docNum = "doc num"; String docSeries = "doc series"; String duration = "213"; SpecOffer entity = new SpecOffer(); entity.setBegDate(begDate); entity.setDepartment(department); entity.setDocNum(docNum); entity.setDocSeries(docSeries); entity.setEducationFormType(eduFormType); entity.setDuration(duration); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("educationFormType", eduFormType); expected.put("department", department); expected.put("begDate", begDate); expected.put("docNum", docNum); expected.put("docSeries", docSeries); expected.put("status", RowStatus.ACTIVE); expected.put("userGroups", groups); expected.put("duration", duration); when(departmentDao.getEntityById(anyLong())).thenReturn(department); when(eduFormTypeDao.getEntityById(anyLong())).thenReturn(eduFormType); Map<String, Object> actual = unit.getParameters(entity); verify(departmentDao).getEntityById(departmentId); verify(eduFormTypeDao).getEntityById(educationFormTypeId); assertEquals(expected, actual); }
@Test public void testGetParametersAndDisabledDefaults() throws Exception { unit.setActive(false); unit.setSecurity(false); Long educationFormTypeId = 3L; EducationFormType eduFormType = new EducationFormType(); eduFormType.setId(educationFormTypeId); Long departmentId = 2L; Department department = new Department(); department.setId(departmentId); Date begDate = new Date(); String docNum = "doc num"; String docSeries = "doc series"; SpecOffer entity = new SpecOffer(); entity.setBegDate(begDate); entity.setDepartment(department); entity.setDocNum(docNum); entity.setDocSeries(docSeries); entity.setEducationFormType(eduFormType); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("educationFormType", eduFormType); expected.put("department", department); expected.put("begDate", begDate); expected.put("docNum", docNum); expected.put("docSeries", docSeries); when(departmentDao.getEntityById(anyLong())).thenReturn(department); when(eduFormTypeDao.getEntityById(anyLong())).thenReturn(eduFormType); Map<String, Object> actual = unit.getParameters(entity); verify(departmentDao).getEntityById(departmentId); verify(eduFormTypeDao).getEntityById(educationFormTypeId); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntity() throws Exception { SpecOffer entity = new SpecOffer(); 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); SpecOffer entity = new SpecOffer(); 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); SpecOffer entity = new SpecOffer(); 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); SpecOffer entity = new SpecOffer(); Map<String, Object> expected = new HashMap<String, Object>(); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }