SearchModelAuthorizables { public static SearchModelAuthorizable from(KeyValue keyValue) { String prefix = keyValue.getKey().toLowerCase(); String name = keyValue.getValue().toLowerCase(); for(AuthorizableType type : AuthorizableType.values()) { if(prefix.equalsIgnoreCase(type.name())) { return from(type, name); } } return null; }  static SearchModelAuthorizable from(KeyValue keyValue); static SearchModelAuthorizable from(String s);  }
@Test public void testCollection() throws Exception { Collection coll = (Collection)SearchModelAuthorizables.from("CoLleCtiOn=collection1"); assertEquals("collection1", coll.getName()); }
@Test(expected=IllegalArgumentException.class) public void testNoKV() throws Exception { System.out.println(SearchModelAuthorizables.from("nonsense")); }
@Test(expected=IllegalArgumentException.class) public void testEmptyKey() throws Exception { System.out.println(SearchModelAuthorizables.from("=v")); }
@Test(expected=IllegalArgumentException.class) public void testEmptyValue() throws Exception { System.out.println(SearchModelAuthorizables.from("k=")); }
@Test public void testNotAuthorizable() throws Exception { assertNull(SearchModelAuthorizables.from("k=v")); }