IndexerModelAuthorizables { public static IndexerModelAuthorizable 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 IndexerModelAuthorizable from(KeyValue keyValue); static IndexerModelAuthorizable from(String s);  }
@Test public void testIndexer() throws Exception { Indexer indexer = (Indexer)IndexerModelAuthorizables.from("InDexEr=indexer1"); assertEquals("indexer1", indexer.getName()); }
@Test(expected=IllegalArgumentException.class) public void testNoKV() throws Exception { System.out.println(IndexerModelAuthorizables.from("nonsense")); }
@Test(expected=IllegalArgumentException.class) public void testEmptyKey() throws Exception { System.out.println(IndexerModelAuthorizables.from("=v")); }
@Test(expected=IllegalArgumentException.class) public void testEmptyValue() throws Exception { System.out.println(IndexerModelAuthorizables.from("k=")); }
@Test public void testNotAuthorizable() throws Exception { assertNull(IndexerModelAuthorizables.from("k=v")); }