Example #1
0
  /** Test resolution of statements across scope hierarchy */
  @Test
  public void testStatementResolution() {
    DialogState dialogState =
        new DialogState(dialog, new NoopContext(), new NoopStateCoordination());

    // statement resolved form parent scope
    dialogState.setStatement(basicAttributes, "foo", "bar");
    String statement = dialogState.getContext(processAttributes).resolve("foo");
    assertNotNull("Statement should be resolved from parent scope", statement);
    assertEquals("bar", statement);

    // child scope overrides statement
    dialogState.setStatement(processAttributes, "foo", "anotherBar");
    statement = dialogState.getContext(processAttributes).resolve("foo");
    assertEquals("anotherBar", statement);

    // collect statement across scopes
    LinkedList<String> statements = dialogState.getContext(processAttributes).collect("foo");
    assertTrue("Expected two statement for key 'foo'", statements.size() == 2);
    assertTrue(
        "Expected correct statement values in right order", statements.get(0).equals("anotherBar"));
    assertTrue("Expected correct statement values in right order", statements.get(1).equals("bar"));
  }