SqoopModelAuthorizables { public static SqoopAuthorizable 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 SqoopAuthorizable from(KeyValue keyValue); static SqoopAuthorizable from(String keyValue); static SqoopAuthorizable from(AuthorizableType type, String name);  }
@Test public void testServer() throws Exception { Server server1 = (Server)SqoopModelAuthorizables.from("SERVER=server1"); assertEquals("server1", server1.getName()); }
@Test(expected=IllegalArgumentException.class) public void testNoKV() throws Exception { System.out.println(SqoopModelAuthorizables.from("nonsense")); }
@Test(expected=IllegalArgumentException.class) public void testEmptyKey() throws Exception { System.out.println(SqoopModelAuthorizables.from("=server1")); }
@Test(expected=IllegalArgumentException.class) public void testEmptyValue() throws Exception { System.out.println(SqoopModelAuthorizables.from("SERVER=")); }
@Test public void testNotAuthorizable() throws Exception { assertNull(SqoopModelAuthorizables.from("k=v")); }