AnnotationUtils { public static AlgoOperator createOp(String name, IOType type, Params parameter) throws Exception { Wrapper<AlgoOperator> op = IO_OP_CLASSES.get(name, type); Preconditions.checkArgument(op != null, "No OP named %s has IOType: %s", name, type); return op.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 testCreateOp() throws Exception { AlgoOperator op1 = AnnotationUtils.createOp("test_fake_op_1", IOType.SourceBatch, new Params()); Assert.assertTrue(op1 instanceof FakeOp1); AlgoOperator op2 = AnnotationUtils.createOp("test_fake_op_2", IOType.SourceBatch, new Params()); Assert.assertTrue(op2 instanceof FakeOp2); }
@Test(expected = IllegalArgumentException.class) public void testCreateOpError1() throws Exception { AnnotationUtils.createOp("test_fake_op_1", IOType.SinkBatch, new Params()); }
@Test(expected = IllegalArgumentException.class) public void testCreateOpError2() throws Exception { AnnotationUtils.createOp("A_OP_HAS_NO_NAME", IOType.SourceBatch, new Params()); }