PropertyValidator { static Map<String, Object> validatePropertyTypes(Map<String, Object> map) { HashMap<String, Object> result = new HashMap<>(); if (map != null) { for (String key : map.keySet()) { if (Constants.OBJECTCLASS.equals(key)) { result.put(key, convertToStringArray(map.get(key))); } else { result.put(key, map.get(key)); } } } return result; }    }
@Test public void testValidatePropertyTypes_null_param() throws Exception { assertThat(validatePropertyTypes(null), notNullValue()); assertThat(validatePropertyTypes(null).size(), is(0)); }
@Test public void testValidatePropertyTypes_objectClass() throws Exception { Map<String, Object> map = new HashMap<>(); map.put(Constants.OBJECTCLASS, "test"); Map<String, Object> config = validatePropertyTypes(map); assertThat(config.containsKey(Constants.OBJECTCLASS), is(true)); assertThat(config.get(Constants.OBJECTCLASS), Is.is(new String[]{"test"})); map = new HashMap<>(); map.put(Constants.OBJECTCLASS, new String[]{"test"}); config = validatePropertyTypes(map); assertThat(config.get(Constants.OBJECTCLASS), Is.is(new String[]{"test"})); map = new HashMap<>(); map.put(Constants.OBJECTCLASS, singletonList("test")); config = validatePropertyTypes(map); assertThat(config.get(Constants.OBJECTCLASS), Is.is(new String[]{"test"})); }