OrgSynonymGenerator { protected void chineseCompanyNames(NameOrg name){ for(String nameStr: name.getSynonyms()) { int beginIdx = nameStr.indexOf('('); if (beginIdx != -1) { int endIdx = nameStr.indexOf(')'); if (endIdx != -1) { String bracketWord = nameStr.substring(beginIdx+1, endIdx); if (ChinaRegisteredLocs.contains(bracketWord.toLowerCase())) { String updatedName = nameStr.substring(0, beginIdx-1) + nameStr.substring(endIdx+1); name.addSynonymNorm(updatedName); } else { } } } else { int spaceIdx = nameStr.indexOf(' '); if (spaceIdx != -1) { String firstWord = nameStr.substring(0, spaceIdx); if (ChinaRegisteredLocs.contains(firstWord.toLowerCase())) { String updatedName = nameStr.substring(spaceIdx+1); name.addSynonymNorm(updatedName); } } } } }  void computeSynonyms(Entity entity);  }
@Test public void ChineseCompanyNames() { OrgSynonymGenerator generator = new OrgSynonymGenerator(); for (Entry<String, String> entry : CHINESE_COMPANIES.entrySet()) { NameOrg name = new NameOrg(entry.getKey()); name.addSynonymNorm(entry.getKey()); generator.chineseCompanyNames(name); assertTrue("Failed '" + entry.getKey() + "'\n\t Missing: " + entry.getValue() + "\n\t expect to contain: " + entry.getValue().toString() + "\n\t actual: " + name.getSynonyms().toString(), name.getSynonyms().contains(entry.getValue())); } }