AnnotationUtils { public static BaseDB createDB(String name, Params parameter) throws Exception { Wrapper<BaseDB> db = DB_CLASSES.get(name); Preconditions.checkArgument(db != null, "No DB named %s", name); return db.clazz.getConstructor(Params.class).newInstance(parameter); }  static String annotatedName(Class<?> clazz); static String annotatedAlias(Class<? extends BaseDB> cls); static String annotatedAlias(String name); static IOType annotatedIoType(Class<? extends AlgoOperator> cls); static ParamInfo<String> tableAliasParamKey(String name); static ParamInfo<String> tableAliasParamKey(Class<? extends BaseDB> dbClazz); static ParamInfo<String> dynamicParamKey(String key); static List<String> allDBAndOpNames(); static List<String> allFileSystemNames(); static BaseDB createDB(String name, Params parameter); static BaseFileSystem<?> createFileSystem(String name, Params parameter); static boolean isDB(String name); static boolean isDBHasTimestamp(String name); static boolean isIoOpHasTimestamp(String name, IOType type); static boolean isFileSystem(String name); static AlgoOperator createOp(String name, IOType type, Params parameter);  }
@Test public void testCreateDB() throws Exception { BaseDB db1 = AnnotationUtils.createDB("test_fake_db_1", new Params()); Assert.assertTrue(db1 instanceof FakeDB1); BaseDB db2 = AnnotationUtils.createDB("test_fake_db_2", new Params()); Assert.assertTrue(db2 instanceof FakeDB2); }
@Test(expected = IllegalArgumentException.class) public void testCreateDBError1() throws Exception { AnnotationUtils.createDB("A_DB_HAS_NO_NAME", new Params()); }