PersonAwardParametersExtractor extends AbstractParametersExtractor<PersonAward> { @Override public Map<String, Object> getParameters(final PersonAward entity, final Map<String, Object> parameters) { addParameter(entity.getPerson(), personDao, "person", parameters); addParameter(entity.getPersonPaper(), personPaperDao, "personPaper", parameters); return parameters; }  @Override Map<String, Object> getParameters(final PersonAward entity, final Map<String, Object> parameters);  }
@Test public void testGetParametersWithDefaultEntityAndDisabledStatus() throws Exception { unit.setActive(false); PersonAward entity = new PersonAward(); 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.setSecurity(false); unit.setActive(false); PersonAward entity = new PersonAward(); Map<String, Object> expected = new HashMap<String, Object>(); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testname() throws Exception { Long personId = 1L; Person person = new Person(); person.setId(personId); Long personPaperId = 2L; PersonPaper personPaper = new PersonPaper(); personPaper.setId(personPaperId); PersonAward entity = new PersonAward(); entity.setPerson(person); entity.setPersonPaper(personPaper); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("person", person); expected.put("personPaper", personPaper); expected.put("status", RowStatus.ACTIVE); expected.put("userGroups", groups); when(personDao.getEntityById(anyLong())).thenReturn(person); when(personPaperDao.getEntityById(anyLong())).thenReturn(personPaper); Map<String, Object> actual = unit.getParameters(entity); verify(personDao).getEntityById(personId); verify(personPaperDao).getEntityById(personPaperId); 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 personPaperId = 2L; PersonPaper personPaper = new PersonPaper(); personPaper.setId(personPaperId); PersonAward entity = new PersonAward(); entity.setPerson(person); entity.setPersonPaper(personPaper); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("person", person); expected.put("personPaper", personPaper); when(personDao.getEntityById(anyLong())).thenReturn(person); when(personPaperDao.getEntityById(anyLong())).thenReturn(personPaper); Map<String, Object> actual = unit.getParameters(entity); verify(personDao).getEntityById(personId); verify(personPaperDao).getEntityById(personPaperId); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntity() throws Exception { PersonAward entity = new PersonAward(); 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); PersonAward entity = new PersonAward(); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("status", RowStatus.ACTIVE); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }