Ejemplo n.º 1
0
  public void testWrapup_SetStatusException() throws Exception {

    JavaActor actor = new JavaActor();
    actor.setName("MultiplyActor");
    MultiplyBean bean = new MultiplyBean();
    actor.setWrappedBean(bean);
    actor.setApplicationContext(_context);
    actor.afterPropertiesSet();
    actor.elaborate();
    actor.configure();
    actor.initialize();

    bean.statusSet = false;
    bean.actorStatus = null;
    assertFalse(bean.wrappedUp);

    MultiplyBean.throwExceptionInStatusSetter = true;

    Exception exception = null;
    try {
      actor.wrapup();
    } catch (RestFlowException e) {
      exception = e;
    }
    assertNotNull(exception);
    assertEquals(
        "org.restflow.exceptions.WorkflowRuntimeException: "
            + "Exception in setStatus() method of actor MultiplyActor",
        exception.toString());
    assertNotNull(exception.getCause());
    assertEquals(
        "java.lang.Exception: Exception in status setter", exception.getCause().toString());
  }
Ejemplo n.º 2
0
  public void testWrapup_SetStateVariablesWithNulls() 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());

    bean.setCount(17);
    bean.setAccumulator(0);
    actor.wrapup();
    assertNull(bean.getCount());
    assertEquals(12, bean.getAccumulator());
  }
Ejemplo n.º 3
0
  public void testConfigure_NoDefaultMethodsOnBean() throws Exception {

    JavaActor actor = new JavaActor();
    EmptyBean bean = new EmptyBean();
    actor.setWrappedBean(bean);
    actor.setApplicationContext(_context);
    actor.afterPropertiesSet();
    actor.elaborate();
    actor.configure();
    actor.initialize();
    actor.step();
    actor.wrapup();
  }
Ejemplo n.º 4
0
  public void testConfigure_DefaultWrapup() throws Exception {

    JavaActor actor = new JavaActor();
    MultiplyBean bean = new MultiplyBean();
    actor.setWrappedBean(bean);
    actor.setApplicationContext(_context);
    actor.afterPropertiesSet();
    actor.elaborate();

    actor.configure();
    actor.initialize();
    assertFalse(bean.wrappedUp);
    actor.wrapup();
    assertTrue(bean.wrappedUp);
    assertFalse(bean.customWrapup);
  }
Ejemplo n.º 5
0
  public void testWrapup_SetStatus() throws Exception {

    JavaActor actor = new JavaActor();
    actor.setName("MultiplyActor");
    MultiplyBean bean = new MultiplyBean();
    actor.setWrappedBean(bean);
    actor.setApplicationContext(_context);
    actor.afterPropertiesSet();
    actor.elaborate();
    actor.configure();
    actor.initialize();

    bean.statusSet = false;
    bean.actorStatus = null;
    assertFalse(bean.wrappedUp);
    actor.wrapup();
    assertTrue(bean.wrappedUp);
    assertNotNull(bean.actorStatus);
    assertTrue(bean.statusSet);
  }