### Question:
TermUtils { static String toTermName(String string) { if(!isValidEntityName(string)) { throw new IllegalArgumentException("Object '"+string+"' is not a valid entity name"); } TermUtils.State state=new Start(); TermUtils.Context context=new Context(); for(int i=0;i<string.length();i++) { state=state.accept(i,string.charAt(i),context); } return context.complete(); } private  TermUtils();   }### Answer:
@Test public void testToTermName$valid() throws Exception { for(Entry<String, String> entry:termMappings.entrySet()) { assertThat(entry.getKey()+"-->"+entry.getValue(),TermUtils.toTermName(entry.getKey()),equalTo(entry.getValue())); } }
@Test public void testToTermName$invalid() throws Exception { try { TermUtils.toTermName("invalid name"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(),equalTo("Object 'invalid name' is not a valid entity name")); } }