{ add(new AssetReference("myPkg", "a", "drl", "http://localhost/c/source", "uuid1")); add(new AssetReference("myPkg", "aa", "drl", "http://localhost/cc/source", "uuid2")); add( new AssetReference( "myPkg", "ab", "changeset", "http://localhost/cd/source", "uuid3")); }
{ add( new Employee() { { setFirstName("Andy"); setLastName("Acheson"); setJobTitle("Barman"); } }); add( new Employee() { { setFirstName("Steven"); setLastName("Blair"); setJobTitle("Professional Golfer"); } }); add( new Employee() { { setFirstName("Matthew"); setLastName("Richardson"); setJobTitle("Fireman"); } }); }
/** Special words. */ @Test public void special_words() { add("com.example.Reserved"); add("com.example.ReservedEnum"); ClassLoader loader = start(new BranchOperatorProcessor()); create(loader, "com.example.ReservedFactory"); }
private Compiled compile(String name) { add(name); add("com.example.Mock"); ClassLoader classLoader = start(operatorProcessor()); Class<?> origin = load(classLoader, name); Object factory = create(classLoader, Constants.getFactoryClass(name)); Object impl = create(classLoader, Constants.getImplementationClass(name)); return new Compiled(origin, factory, impl); }
/** raise errors on process. */ @Test public void failure_process() { add( new Driver() { @Override public OperatorDescription analyze(Context context) { throw new RuntimeException(); } }); add("com.example.Simple"); add("com.example.Mock"); error(operatorProcessor()); }
/** raise errors on initialize. */ @Test public void failure_init() { add("com.example.Simple"); add("com.example.Mock"); error( new OperatorAnnotationProcessor() { @Override protected CompileEnvironment createCompileEnvironment( ProcessingEnvironment processingEnv) { throw new RuntimeException(); } }); }
{ add( new FindRulesByProjectQuery() { @Override public ResponseBuilder getResponseBuilder() { return new DefaultResponseBuilder(ioService()); } }); }
/** ジェネリックメソッド。 */ @Test public void generics() { add("com.example.Generic"); add("com.example.ExampleEnum"); ClassLoader loader = start(new BranchOperatorProcessor()); Object factory = create(loader, "com.example.GenericFactory"); MockIn<MockHoge> in = MockIn.of(MockHoge.class, "in"); MockOut<MockHoge> high = MockOut.of(MockHoge.class, "high"); MockOut<MockHoge> middle = MockOut.of(MockHoge.class, "middle"); MockOut<MockHoge> low = MockOut.of(MockHoge.class, "low"); Object branch = invoke(factory, "example", in); high.add(output(MockHoge.class, branch, "high")); middle.add(output(MockHoge.class, branch, "middle")); low.add(output(MockHoge.class, branch, "low")); Graph<String> graph = toGraph(in); assertThat(graph.getConnected("in"), isJust("Generic.example")); assertThat(graph.getConnected("Generic.example"), isJust("high", "middle", "low")); }
/** generic method. */ @Test public void generics() { add("com.example.Generic"); ClassLoader loader = start(new FoldOperatorProcessor()); Object factory = create(loader, "com.example.GenericFactory"); MockIn<MockHoge> in = MockIn.of(MockHoge.class, "in"); MockOut<MockHoge> out = MockOut.of(MockHoge.class, "out"); Object fold = invoke(factory, "example", in, 100); out.add(output(MockHoge.class, fold, "out")); Graph<String> graph = toGraph(in); assertThat(graph.getConnected("in"), isJust("Generic.example")); assertThat(graph.getConnected("Generic.example"), isJust("out")); }
private Object compile(String name) { add(name); ClassLoader classLoader = start( new Callback() { @Override protected void test() { TypeElement element = env.findTypeElement(new ClassDescription(name)); if (round.getRootElements().contains(element)) { assertThat(name, element, is(notNullValue())); OperatorImplementationEmitter emitter = new OperatorImplementationEmitter(env); emitter.emit(new OperatorClass(element, Collections.emptyList())); } } }); return create(classLoader, Constants.getImplementationClass(name)); }
/** simple testing. */ @Test public void simple() { add( new Driver() { @Override public OperatorDescription analyze(Context context) { List<Node> parameters = new ArrayList<>(); parameters.add( new Node( Kind.INPUT, "in", new ReferenceDocument(new ParameterReference(0)), context.getEnvironment().findDeclaredType(Descriptions.classOf(String.class)), new ParameterReference(0))); List<Node> outputs = new ArrayList<>(); outputs.add( new Node( Kind.OUTPUT, "out", new ReferenceDocument(new ReturnReference()), context .getEnvironment() .findDeclaredType(Descriptions.classOf(CharSequence.class)), new ReturnReference())); return new OperatorDescription( new ReferenceDocument(new MethodReference()), parameters, outputs); } }); Compiled compiled = compile("com.example.Simple"); assertThat(compiled.implementation, is(instanceOf(compiled.originalClass))); Method impleMethod = method(compiled.implementation.getClass(), "method", String.class); assertThat(impleMethod, is(notNullValue())); assertThat(Modifier.isAbstract(impleMethod.getModifiers()), is(false)); Object node = invoke(compiled.factory, "method", MockSource.of(String.class)); assertThat(field(node.getClass(), "out"), is(notNullValue())); }
/** missing key annotation. */ @Test public void noKey() { add("com.example.NoKey"); error(new FoldOperatorProcessor()); }
/** 空の列挙。 */ @Test public void emptyEnum() { add("com.example.Empty"); add("com.example.EmptyEnum"); error(new BranchOperatorProcessor()); }
/** 非モデル。 */ @Test public void notModel() { add("com.example.NotModel"); add("com.example.EmptyEnum"); error(new BranchOperatorProcessor()); }
/** 抽象メソッド。 */ @Test public void _abstract() { add("com.example.Abstract"); add("com.example.EmptyEnum"); error(new BranchOperatorProcessor()); }
/** too many parameters. */ @Test public void tooManyInput() { add("com.example.TooManyInput"); error(new FoldOperatorProcessor()); }
/** ユーザー定義パラメーターでない。 */ @Test public void notUserParameter() { add("com.example.NotUserParameter"); add("com.example.EmptyEnum"); error(new BranchOperatorProcessor()); }
/** not void type method. */ @Test public void returns() { add("com.example.Returns"); error(new FoldOperatorProcessor()); }
/** less parameters. */ @Test public void lessParameters() { add("com.example.LessParameters"); error(new FoldOperatorProcessor()); }
/** abstract method. */ @Test public void isAbstract() { add("com.example.Abstract"); error(new FoldOperatorProcessor()); }
{ add("log4j-1.2.16.jar"); add("jdom-1.0.jar"); }
{ add("getBlockComponent"); add("setBlockComponent"); add("getBiome"); add("getBlock"); add("containsBlock"); // Handled by getBlockDataField add("isBlockDataBitSet"); // Handled by setBlockDataFieldRaw add("setBlockData"); add("setBlockDataField"); add("setBlockDataBits"); add("clearBlockDataBits"); // Handled by addBlockDataFieldRaw add("addBlockData"); add("addBlockDataField"); }
/** inconsistent type between the first and second parameter. */ @Test public void inconsistentType() { add("com.example.InconsistentType"); error(new FoldOperatorProcessor()); }
{ add(new AssetReference("myPkg", "a.jar", "model", "http://localhost/a.jar", "uudi44")); }