What You Need to Know About Testing Using an Oracle Business Rules Function What You Need to Know About Testing Decision Functions

Testing Business Rules 8-3 Figure 8–2 Test Function Results Dialog

9. Click OK to dismiss the Function Test Result dialog.

8.1.2 What You Need to Know About Testing Using an Oracle Business Rules Function

The Test Function icon is only active when the dictionary is valid the Business Rule validation log is empty. The Test Function icon is gray if the dictionary associated with the function contains any validation warnings.

8.1.3 How to Test a Decision Function Using an Oracle Business Rules Function

You can test rulesets by creating a decision function and calling the decision function from Rules Designer with an Oracle Business Rules function. In the body of the Oracle Business Rules function you create input facts, call a decision function, and validate the facts output from the decision function. For more information, see Section 6.1, Introduction to Decision Functions and Section 2.5, Working with Oracle Business Rules Functions . To test a decision function using an Oracle Business Rules function: 1. Confirm that your dictionary is valid. For more information on dictionary validation, see Section 4.4.4, How to Validate a Dictionary

2. In Rules Designer, select the Functions navigation tab.

3. In the Functions area click the Create... icon.

4. Enter the function name in the Name field, or use the default name.

5. Select the return type from the Return Type list.

For a test function, select boolean.

6. In the Arguments table, confirm that there are no arguments. For a test function,

you cannot specify any arguments.

7. In the Body area, enter the test function body.

In the body of the test function you can call a decision function using assign new to call and get the return value of the decision function in the body of the test 8-4 Oracle Fusion Middleware Users Guide for Oracle Business Rules function you create input facts, call a decision function, and validate the facts output from the decision function. A decision function call returns a List. Thus, to test a decision function in a test function you do the following: ■ You create the input data as required for the decision function input arguments. ■ You call the decision function with the arguments you create in the test function. ■ You place results in a List, for example, in the following: assign new List resultsList = DecisionFunction_1testScore Figure 8–3 shows a test function that calls a decision function. Figure 8–3 Test Function to Call a Decision Function that Returns a List

8. Select the function and click the Test Function icon.

The function is executed. The output is shown in a Function Test Result dialog, as Figure 8–4 shows. Testing Business Rules 8-5 Figure 8–4 Test Function Results for Grade Test

9. Click OK to dismiss the Function Test Result dialog.

8.1.4 What You Need to Know About Testing Decision Functions

You can use Oracle Business Rules Functions to test decision functions from within Rules Designer. Keep the following points in mind when using a test function: ■ The Test Function icon is gray if the dictionary associated with the test Oracle Business Rules Function contains any validation warnings. The Test Function icon is only shown when the dictionary validates without warnings. ■ To enable logging you can call RL.watch.all. For more information on RL Language functions, see Oracle Fusion Middleware Language Reference Guide for Oracle Business Rules. In this guide, RL.watch.all is an alias for the RL Language function watchAll. ■ As an alternative to the example shown in Figure 8–3 , you can enter the function body that is shown in Example 8–2 . This function runs and shows the RL.watch.all output. The dialog shows Test Passed when the grade is in the B range as shown in Figure 8–5 . The dialog shows Test Failed when the grade asserted is not in the B range, as shown in Figure 8–6 . Example 8–2 Function Body with True or False Return Value call RL.watch.all assign new TestScore testScore = new TestScore modify testScore, name: Bill Reynolds, testName: Math Test, testScore: 81 assign new TestGrade testGrade = TestGradeDecisionFunction_1testScore.get0 return testGrade.grade == Grade.B For the testScore value 81, this function returns Test Passed as shown in Figure 8–5 . For the testScore value 91, this returns Test Failed, as shown in Figure 8–6 . 8-6 Oracle Fusion Middleware Users Guide for Oracle Business Rules Figure 8–5 Test Passed Test Function Output Figure 8–6 Test Failed Test Function Output

8.2 Testing Oracle Business Rules at Runtime

In an SOA application that uses Oracle Business Rules with a Decision Service you can test rules at runtime with Oracle Enterprise Manager Fusion Middleware Control Console Test function. For more information on using the Test function, see Oracle Fusion Middleware Administrators Guide for Oracle SOA Suite and Oracle Business Process Management Suite.