9.3. Additional Test Scenario Features

In addition to the previous Test Scenario features, which encompassed the GIVEN and EXPECT input facts, Red Hat JBoss BRMS Test Scenarios include various other features.

Procedure 9.7. Calling Methods

  1. Call Method - allows you to call a method on an existing fact in the beginning of the rule execution. This feature is accessed by clicking on the green plus sign next to the CALL METHOD feature. This opens up a new input box like the following:
    CALL METHOD for JBoss BRMS 6.0.2 Test Scenarios.

    Figure 9.2. Call Method

  2. After selecting an existing fact from the drop-down list, click the Add button. The green arrow button allows you to call a method on the fact.
    The invoke method dialogue box for JBoss BRMS 6.0.3 Test Scenario features

    Figure 9.3. Invoke a Method

Procedure 9.8. Adding Globals

  1. globals - validate the global field values. Globals are named objects that are visible to the rule engine but are different from the objects for facts. Accordingly, the changes in the object of a global do not trigger the reevaluation of rules. This feature is accessed by clicking on the green plus sign next to the (globals) feature.
    New Global pop up dialog for JBoss BRMS Test Scenario feature.

    Figure 9.4. New Global

  2. After selecting an existing global from the drop-down list, click the Add button. Clicking on the newly selected global allows you to assign values to fields of the global variable.
    New Field for global conditions in JBoss BRMS Test Scenarios

    Figure 9.5. Apply Field

  3. After selecting an existing field from the drop-down list, click the OK button. Once you have selected the field, you will be able to set its value. By clicking on this icon, you will be able to edit the field values.
    Field values dialog box for JBoss BRMS Test Scenario global features.

    Figure 9.6. Field Values

Procedure 9.9. Configuring Rules

  1. Configuring rules - allows the user to determine additional constraints on the firing of rules by providing the following options:
    • Allow these rules to fire: - allows you to select which rules are allowed to fire.
    • Prevent these rules from firing: - allows you to prevent certain rules from firing for the test scenario.
    • All rules may fire - will allow all the rules to fire for the given test.
    Configuration rules option for JBoss BRMS Test Scenario features

    Figure 9.7. Configuration

  2. If you select Allow these rules to fire: or Prevent these rules from firing:, you will be supplied with an empty field where you can select the rules which pertain to the configuration by clicking the green plus sign next to the empty field. This will open a dialog to select which rules are affected by the condition.
    Configuration select rule options for the JBoss BRMS Test Scenario feature.

    Figure 9.8. Selecting rules

  3. Choose a rule from the drop-down list and click the OK button. The selected rules will appear in the field next to the rules configuration option. You can add as many rules as you like to this field.

Procedure 9.10. Date and Time Configuration

  1. Use real date and time - the real time is used when running the test scenario.
    Use real date and time choice for the Expect feature in JBoss BRMS Test Scenarios

    Figure 9.9. Real Date and Time

  2. Use a simulated date and time - this option allows you to specify the year, month, day, hour, and minute associated with the test scenario run.
    Simulated date and time for Test Scenarios in JBoss BRMS 6.0.2

    Figure 9.10. Title

Procedure 9.11. Advanced Fact Data

  1. After providing values to editable properties as part of your created fact, the Field value dialog box will appear where you can edit literal values or provide advanced fact data.
    Advanced Fact Data options for JBoss BRMS Test Scenarios.

    Figure 9.11. Advanced Options

  2. Within the Advanced Options section, you will be provided with various choices depending on the type of fact created and the model objects used for the particular Test Scenario.
    • Bound variable - sets the value of the field to the fact bout to the selected variable. The field must be of the right type.
      Bound Variable option for JBoss BRMS Test Scenario features.

      Figure 9.12. Bound Variable

    • Create new fact - allows you to create a new fact. By clicking on the Create new fact button, a new fact will appear as the value of the field. By clicking on that fact, you will be supplied with a drop down of various field values, and these values may be given further field values.
      Create new fact option for JBoss BRMS Test Scenario features.

      Figure 9.13. Create New Fact

Procedure 9.12. Adding More Sections

  • The Test Scenario edit screen allows you to add Given, Call Method, and Expect sections to the scenario by clicking the More button below the EXPECT section. This will open a block encompassing all three sections that can be removed by clicking the delete item button.

Procedure 9.13. Modifying or Deleting an Existing Fact

    • Modifying an existing fact - allows the editing of a fact between knowledge base executions.
    • Delete an existing fact - allows the removing of facts between executions.
    Modify and Delete and existing fact options for JBoss BRMS Test Scenarios

    Figure 9.14. Modifying and Deleting Existing Facts