Ejemplo n.º 1
0
  @Test
  public void testAction() {
    MockClass mock = new MockClass();
    List<Integer> list = new ArrayList<Integer>();

    Action action = PipelineFactory.newMvelAction("this.setValues( [0, 1, 2, 3, 4] ) ");

    assertNull(mock.getValues());
    action.receive(mock, new BasePipelineContext(Thread.currentThread().getContextClassLoader()));

    System.out.println(mock.getValues().get(0));
    assertEquals(5, mock.getValues().size());
    assertEquals(0, mock.getValues().get(0).intValue());
    assertEquals(4, mock.getValues().get(4).intValue());
  }
  @Test
  public void testSplitter() {
    MockClass mock = new MockClass();
    List<Integer> list = new ArrayList<Integer>();

    Action action = PipelineFactory.newMvelAction("this.setValues( [0, 1, 2, 3, 4] ) ");
    Expression expr = PipelineFactory.newMvelExpression("this.values");
    action.setReceiver(expr);

    Splitter splitter = PipelineFactory.newIterateSplitter();
    expr.setReceiver(splitter);

    ListAdapter listAdapter = new ListAdapterImpl(list, true);
    splitter.setReceiver(listAdapter);

    assertNull(mock.getValues());
    action.receive(mock, new BasePipelineContext(Thread.currentThread().getContextClassLoader()));

    System.out.println(list.get(0));
    assertEquals(5, list.size());
    assertEquals(0, list.get(0).intValue());
    assertEquals(4, list.get(4).intValue());
  }