/**
   * Test method for {@link
   * org.jvoicexml.interpreter.ObjectExecutorThread#execute(org.jvoicexml.interpreter.VoiceXmlInterpreterContext,
   * org.jvoicexml.interpreter.VoiceXmlInterpreter,
   * org.jvoicexml.interpreter.FormInterpretationAlgorithm,
   * org.jvoicexml.interpreter.formitem.ObjectFormItem)} .
   *
   * @exception Exception Test failed.
   * @exception JVoiceXMLEvent Test failed.
   */
  @Test
  public void testExecute() throws Exception, JVoiceXMLEvent {
    final VoiceXmlDocument doc = new VoiceXmlDocument();
    final Vxml vxml = doc.getVxml();
    final Form form = vxml.appendChild(Form.class);
    final Subdialog subdialog = form.appendChild(Subdialog.class);
    subdialog.setName("test");
    final Form subform = vxml.appendChild(Form.class);
    subform.setId("subid");
    final Var var = subform.appendChild(Var.class);
    var.setName("testparam");
    final Block block = subform.appendChild(Block.class);
    final Assign assign = block.appendChild(Assign.class);
    assign.setName("testparam");
    assign.setExpr("testparam * 2");
    final Return ret = block.appendChild(Return.class);
    ret.setNamelist("testparam");
    final SubdialogFormItem item = new SubdialogFormItem(context, subdialog);
    final Dialog dialog = new ExecutablePlainForm();
    dialog.setNode(form);
    final FormInterpretationAlgorithm fia = new FormInterpretationAlgorithm(context, null, dialog);
    final EventHandler handler =
        new org.jvoicexml.interpreter.event.JVoiceXmlEventHandler(null, null);
    final EventBus eventbus = context.getEventBus();
    eventbus.subscribe("", handler);
    handler.collect(context, null, fia, item);

    final URI uri = new URI("#subid");
    final Map<String, Object> params = new java.util.HashMap<String, Object>();
    params.put("testparam", new Integer(4));
    final JVoiceXmlApplication application = new JVoiceXmlApplication(null);
    application.addDocument(new URI("test"), doc);

    final SubdialogExecutorThread executor =
        new SubdialogExecutorThread(uri, context, application, params, eventbus);

    executor.start();
    executor.join();
    ReturnEvent event = null;
    try {
      handler.processEvent(item);
    } catch (ReturnEvent e) {
      event = e;
    }
    Assert.assertNotNull(event);
    final Map<String, Object> variables = event.getVariables();
    Assert.assertEquals(1, variables.size());
    Assert.assertEquals(8, variables.get("testparam"));
  }