### Question:
FieldNameAliaserNormalizer { public void setup(Type type, Configuration config) { _fieldNameAliases = new HashMap<>(); String[] a = config.getStrings(type.typeName() + FIELD_ALIASES, (String[]) null); if (null != a) { for (String s : a) { String[] parts = StringUtils.split(s, ':'); if (parts.length == 2) _fieldNameAliases.put(parts[0], parts[1]); else throw new IllegalArgumentException("Missing alias for " + parts[0]); } } _indexNameAliases = new HashMap<>(); Boolean indexAliasesAllowed = config.getBoolean(type.typeName() + INDEX_ALIASES_ENABLED, false); if (indexAliasesAllowed) { String indexAliasesConfig = config.get(type.typeName() + INDEX_ALIASES, null); if (null != indexAliasesConfig) { for (String indexAliasStr : StringUtils.split(indexAliasesConfig, ';')) { if (!indexAliasStr.isEmpty()) { String[] parts = StringUtils.split(indexAliasStr, ':'); if (parts.length == 2) { HashSet<String> aliases = new HashSet<>(); for (String alias : StringUtils.split(parts[1], ',')) { aliases.add(canonicalizeFieldName(alias, FIELD.NAME)); } _indexNameAliases.put(parts[0], aliases); } else { throw new IllegalArgumentException("Improperly formatted index alias"); } } } } } }  void setAliases(Map<String,String> aliases); void setIndexAliases(Map<String,HashSet<String>> aliases); Map<String,String> getAliases(); Map<String,HashSet<String>> getIndexAliases(); HashSet<String> getIndexAliases(String fieldName); void setup(Type type, Configuration config); NormalizedContentInterface normalizeAndAlias(NormalizedContentInterface field); String normalizeAndAlias(String fieldName); static final String FIELD_ALIASES; static final String INDEX_ALIASES_ENABLED; static final String INDEX_ALIASES; }### Answer:
@Test(expected = IllegalArgumentException.class) public void testBadAliasConfig() throws Exception { conf.set("test.data.category.index.aliases.enabled", "true"); conf.set("test.data.category.index.aliases", "totalnonsense"); FieldNameAliaserNormalizer fnan = new FieldNameAliaserNormalizer(); fnan.setup(TypeRegistry.getType("test"), conf); }
@Test public void testSetup() { conf.set("test.data.category.index.aliases.enabled", "true"); conf.set("test.data.category.index.aliases", "FOO_1:BAR_1,BAR_2;FOO_2:BAR_3"); conf.set("test.data.category.field.aliases", "HELLOWORLD:HELLO_WORLD"); FieldNameAliaserNormalizer fnan = new FieldNameAliaserNormalizer(); fnan.setup(TypeRegistry.getType("test"), conf); Map<String,String> expectedFieldAliases = new HashMap<>(); expectedFieldAliases.put("HELLOWORLD", "HELLO_WORLD"); Assert.assertEquals(expectedFieldAliases, fnan.getAliases()); Assert.assertEquals(2, fnan.getIndexAliases("FOO_1").size()); Assert.assertEquals(1, fnan.getIndexAliases("FOO_2").size()); }