Example #1
0
  public void testStep_SetAndUpdateStateVariablesWithNulls() throws Exception {

    JavaActor actor = new JavaActor();
    actor.setName("MultiplyActor");
    MultiplyBean bean = new MultiplyBean();
    actor.setWrappedBean(bean);

    Yaml yaml = new Yaml();
    actor.setInputs((Map<String, Object>) yaml.load("originalValue:" + EOL));
    actor.setOutputs((Map<String, Object>) yaml.load("multipliedValue:" + EOL));
    actor.setSettings((Map<String, Object>) yaml.load("factor: 3" + EOL));
    actor.setState((Map<String, Object>) yaml.load("accumulator: 0" + EOL + "count: 0" + EOL));
    actor.setApplicationContext(_context);
    actor.afterPropertiesSet();
    actor.elaborate();
    actor.configure();
    actor.initialize();

    actor.setInputValue("originalValue", 4);
    assertEquals(0, bean.getAccumulator());
    assertEquals((Integer) 0, bean.getCount());
    MultiplyBean.setCountToNullInStep = true;
    actor.step();
    assertEquals(12, actor.getOutputValue("multipliedValue"));
    assertNull(bean.getCount());
    assertEquals(12, bean.getAccumulator());

    actor.setInputValue("originalValue", 6);
    bean.setCount(17);
    actor.step();
    assertEquals(18, actor.getOutputValue("multipliedValue"));
    assertNull(bean.getCount());
    assertEquals(30, bean.getAccumulator());
  }
Example #2
0
  public void testInitialize_setStateVariablesInitialValues_Nulls() throws Exception {

    JavaActor actor = new JavaActor();
    actor.setName("MultiplyActor");
    MultiplyBean bean = new MultiplyBean();
    actor.setWrappedBean(bean);

    Yaml yaml = new Yaml();
    actor.setInputs((Map<String, Object>) yaml.load("originalValue:" + EOL));
    actor.setOutputs((Map<String, Object>) yaml.load("multipliedValue:" + EOL));
    actor.setSettings((Map<String, Object>) yaml.load("factor: 3" + EOL));
    actor.setState((Map<String, Object>) yaml.load("accumulator:" + EOL + "count:" + EOL));

    actor.setApplicationContext(_context);
    actor.afterPropertiesSet();
    actor.elaborate();
    actor.configure();

    actor.initialize();
    assertEquals(0, bean.getAccumulator());
    assertEquals(new Integer(0), bean.getCount());
  }