コード例 #1
0
 {
   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"));
 }
コード例 #2
0
        {
          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");
                }
              });
        }
コード例 #3
0
  /** 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");
  }
コード例 #4
0
 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);
 }
コード例 #5
0
 /** 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());
 }
コード例 #6
0
 /** 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());
         }
       });
 }
コード例 #8
0
  /** ジェネリックメソッド。 */
  @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"));
  }
コード例 #9
0
  /** 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"));
  }
コード例 #10
0
 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));
 }
コード例 #11
0
  /** 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()));
  }
コード例 #12
0
 /** missing key annotation. */
 @Test
 public void noKey() {
   add("com.example.NoKey");
   error(new FoldOperatorProcessor());
 }
コード例 #13
0
 /** 空の列挙。 */
 @Test
 public void emptyEnum() {
   add("com.example.Empty");
   add("com.example.EmptyEnum");
   error(new BranchOperatorProcessor());
 }
コード例 #14
0
 /** 非モデル。 */
 @Test
 public void notModel() {
   add("com.example.NotModel");
   add("com.example.EmptyEnum");
   error(new BranchOperatorProcessor());
 }
コード例 #15
0
 /** 抽象メソッド。 */
 @Test
 public void _abstract() {
   add("com.example.Abstract");
   add("com.example.EmptyEnum");
   error(new BranchOperatorProcessor());
 }
コード例 #16
0
 /** too many parameters. */
 @Test
 public void tooManyInput() {
   add("com.example.TooManyInput");
   error(new FoldOperatorProcessor());
 }
コード例 #17
0
 /** ユーザー定義パラメーターでない。 */
 @Test
 public void notUserParameter() {
   add("com.example.NotUserParameter");
   add("com.example.EmptyEnum");
   error(new BranchOperatorProcessor());
 }
コード例 #18
0
 /** not void type method. */
 @Test
 public void returns() {
   add("com.example.Returns");
   error(new FoldOperatorProcessor());
 }
コード例 #19
0
 /** less parameters. */
 @Test
 public void lessParameters() {
   add("com.example.LessParameters");
   error(new FoldOperatorProcessor());
 }
コード例 #20
0
 /** abstract method. */
 @Test
 public void isAbstract() {
   add("com.example.Abstract");
   error(new FoldOperatorProcessor());
 }
コード例 #21
0
 {
   add("log4j-1.2.16.jar");
   add("jdom-1.0.jar");
 }
コード例 #22
0
 {
   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");
 }
コード例 #23
0
 /** inconsistent type between the first and second parameter. */
 @Test
 public void inconsistentType() {
   add("com.example.InconsistentType");
   error(new FoldOperatorProcessor());
 }
コード例 #24
0
 {
   add(new AssetReference("myPkg", "a.jar", "model", "http://localhost/a.jar", "uudi44"));
 }