PersonEducationParametersExtractor extends AbstractParametersExtractor<PersonEducation> { @Override protected Map<String, Object> getParameters(final PersonEducation entity, final Map<String, Object> parameters) { addParameter(entity.getPerson(), personDao, "person", parameters); addParameter(entity.getEducationType(), educationTypeDao, "educationType", parameters); addParameter(entity.getPersonPaper(), personPaperDao, "personPaper", parameters); addParameter(entity.getBegDate(), "begDate", parameters); addParameter(entity.getEndDate(), "endDate", parameters); return parameters; }    }
@Test public void testGetParameters() throws Exception { Long personId = 1L; Person person = new Person(); person.setId(personId); Long educationTypeId = 2L; EducationType educationType = new EducationType(); educationType.setId(educationTypeId); Long personPaperId = 3L; PersonPaper personPaper = new PersonPaper(); personPaper.setId(personPaperId); Date begDate = new Date(); Date endDate = new Date(); PersonEducation entity = new PersonEducation(); entity.setPerson(person); entity.setEducationType(educationType); entity.setPersonPaper(personPaper); entity.setBegDate(begDate); entity.setEndDate(endDate); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("person", person); expected.put("educationType", educationType); expected.put("personPaper", personPaper); expected.put("begDate", begDate); expected.put("endDate", endDate); expected.put("status", RowStatus.ACTIVE); expected.put("userGroups", groups); when(personDao.getEntityById(anyLong())).thenReturn(person); when(educationTypeDao.getEntityById(anyLong())).thenReturn(educationType); when(personPaperDao.getEntityById(anyLong())).thenReturn(personPaper); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDisabledDefaults() throws Exception { unit.setActive(false); unit.setSecurity(false); Long personId = 1L; Person person = new Person(); person.setId(personId); Long educationTypeId = 2L; EducationType educationType = new EducationType(); educationType.setId(educationTypeId); Long personPaperId = 3L; PersonPaper personPaper = new PersonPaper(); personPaper.setId(personPaperId); Date begDate = new Date(); Date endDate = new Date(); PersonEducation entity = new PersonEducation(); entity.setPerson(person); entity.setEducationType(educationType); entity.setPersonPaper(personPaper); entity.setBegDate(begDate); entity.setEndDate(endDate); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("person", person); expected.put("educationType", educationType); expected.put("personPaper", personPaper); expected.put("begDate", begDate); expected.put("endDate", endDate); when(personDao.getEntityById(anyLong())).thenReturn(person); when(educationTypeDao.getEntityById(anyLong())).thenReturn(educationType); when(personPaperDao.getEntityById(anyLong())).thenReturn(personPaper); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntity() throws Exception { PersonEducation entity = new PersonEducation(); 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); PersonEducation entity = new PersonEducation(); 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); PersonEducation entity = new PersonEducation(); 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); PersonEducation entity = new PersonEducation(); Map<String, Object> expected = new HashMap<String, Object>(); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }