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: 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 6176 next to the CALL METHOD feature. This opens up a new input box like the following:

    Figure 9.2. Call Method

    CALL METHOD for JBoss BRMS 6.0.2 Test Scenarios.
  2. After selecting an existing fact from the drop-down list, click the Add button. The green arrow button 6187 allows you to call a method on the fact.

    Figure 9.3. Invoke a Method

    The invoke method dialogue box for JBoss BRMS 6.0.3 Test Scenario features

Procedure: 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 6176 next to the (globals) feature.

    Figure 9.4. New Global

    New Global pop up dialog for JBoss BRMS Test Scenario feature.
  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.

    Figure 9.5. Apply Field

    New Field for global conditions in JBoss BRMS Test Scenarios
  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. 6191 By clicking on this icon, you will be able to edit the field values.

    Figure 9.6. Field Values

    Field values dialog box for JBoss BRMS Test Scenario global features.

Procedure: 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.

    Figure 9.7. Configuration

    Configuration rules option for JBoss BRMS Test Scenario features
  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 6176 next to the empty field. This will open a dialog to select which rules are affected by the condition.

    Figure 9.8. Selecting rules

    Configuration select rule options for the JBoss BRMS Test Scenario feature.
  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: Date and Time Configuration

  1. Use real date and time - the real time is used when running the test scenario.

    Figure 9.9. Real Date and Time

    Use real date and time choice for the Expect feature in JBoss BRMS Test Scenarios
  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.

    Figure 9.10. Title

    Simulated date and time for Test Scenarios in JBoss BRMS 6.0.2

Procedure: 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.

    Figure 9.11. Advanced Options

    Advanced Fact Data options for JBoss BRMS Test Scenarios.
  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.

      Figure 9.12. Bound Variable

      Bound Variable option for JBoss BRMS Test Scenario features.
    • 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.

      Figure 9.13. Create New Fact

      Create new fact option for JBoss BRMS Test Scenario features.

Procedure: 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 6208 button below the EXPECT section. This will open a block encompassing all three sections that can be removed by clicking the delete item 6209 button.

Procedure: 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.

    Figure 9.14. Modifying and Deleting Existing Facts

    Modify and Delete and existing fact options for JBoss BRMS Test Scenarios