PersonLanguageParametersExtractor extends AbstractParametersExtractor<PersonLanguage> { @Override protected Map<String, Object> getParameters(final PersonLanguage entity, final Map<String, Object> parameters) { addParameter(entity.getPerson(), personDao, "person", parameters); addParameter(entity.getLanguage(), languageDao, "language", parameters); addParameter(entity.getLanguageLevel(), languageLevelDao, "languageLevel", parameters); return parameters; }    }
@Test public void testGetParameters() throws Exception { Long personId = 2L; Person person = new Person(); person.setId(personId); Long languageId = 3L; Language language = new Language(); language.setId(languageId); Long languageLevelId = 1L; LanguageLevel languageLevel = new LanguageLevel(); languageLevel.setId(languageLevelId); PersonLanguage entity = new PersonLanguage(); entity.setPerson(person); entity.setLanguage(language); entity.setLanguageLevel(languageLevel); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("person", person); expected.put("language", language); expected.put("languageLevel", languageLevel); expected.put("status", RowStatus.ACTIVE); expected.put("userGroups", groups); when(personDao.getEntityById(anyLong())).thenReturn(person); when(languageDao.getEntityById(anyLong())).thenReturn(language); when(languageLevelDao.getEntityById(anyLong())).thenReturn(languageLevel); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDisabledDefaults() throws Exception { unit.setActive(false); unit.setSecurity(false); Long personId = 2L; Person person = new Person(); person.setId(personId); Long languageId = 3L; Language language = new Language(); language.setId(languageId); Long languageLevelId = 1L; LanguageLevel languageLevel = new LanguageLevel(); languageLevel.setId(languageLevelId); PersonLanguage entity = new PersonLanguage(); entity.setPerson(person); entity.setLanguage(language); entity.setLanguageLevel(languageLevel); Map<String, Object> expected = new HashMap<String, Object>(); expected.put("person", person); expected.put("language", language); expected.put("languageLevel", languageLevel); when(personDao.getEntityById(anyLong())).thenReturn(person); when(languageDao.getEntityById(anyLong())).thenReturn(language); when(languageLevelDao.getEntityById(anyLong())).thenReturn(languageLevel); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }
@Test public void testGetParametersWithDefaultEntity() throws Exception { PersonLanguage entity = new PersonLanguage(); 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); PersonLanguage entity = new PersonLanguage(); 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); PersonLanguage entity = new PersonLanguage(); 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); PersonLanguage entity = new PersonLanguage(); Map<String, Object> expected = new HashMap<String, Object>(); Map<String, Object> actual = unit.getParameters(entity); assertEquals(expected, actual); }