이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 5. Test Scenarios


Test Scenarios in Red Hat Decision Manager enable you to validate the functionality of rules, models, and events before deploying them into production. A test scenario uses data for conditions that resemble an instance of your fact or project model. This data is matched against a specific set of rules and if the expected results match the actual results, the test is successful. If the expected results do not match the actual results, then the test fails.

After you run all test scenarios, the status of the scenarios is reported in a Reporting panel.

Test scenarios can be executed one at a time or as a group. The group execution contains all the scenarios from one package. Test scenarios are independent, so that one scenario cannot affect or modify the other.

5.1. Testing the speed limit scenario

Test the speed limit scenario using the data that you specified when you created the traffic violation guided decision table.

Prerequisites

  • You have created the Driver_department_traffic_violations project.
  • You have created the Violation and Driver data objects.
  • You have created the speed violation guided decision table.

Procedure

  1. Log in to Decision Central.
  2. Click Menu Design Projects, then Driver_department_traffic_violations.
  3. Click Add Asset Test Scenario.
  4. In the Create new Test Scenario window wizard, enter the following values:

    1. Test Scenario: Speed limit 10-20.
    2. Package: select com.myspace.driver_department_traffic_violations.
  5. Click Ok.
  6. Click +GIVEN to open the New input window.
  7. Select Violation from the Insert a new fact menu.
  8. Enter violation in the Fact name field and click Add.
  9. Click Add a field located under Insert 'Violation'[violation] to open the Choose a field to add window.
  10. Select speedLimit from the Choose a field to add menu and click OK.
  11. Click ( 6191 ), and then click Literal value next to speedLimit.
  12. Click Literal value in the Field value window, then enter 40 in the speedLimit field.
  13. Click Insert 'Violation'[violation].
  14. Select type from the Choose a field to add menu in the Choose a field to add window, and click OK.
  15. Click ( 6191 ), and then click Literal value next to Literal value.
  16. Enter Speed in the type field.
  17. Click Insert 'Violation'[violation].
  18. Select actualSpeed from the Choose a field to add menu, and click OK.
  19. Click ( 6191 ), and then click Literal value next to Literal value.
  20. Enter 55 in the actualSpeed field.
  21. Click +Expect to open the New expectation window.
  22. Expand the Rule menu, select Row 1 SpeedViolationRule, and click OK.
  23. Click +GIVEN to open the New input window, enter trafficViolation in the Activate rule flow group field, and click Add.
  24. Click +Expect to open the New expectation window and click Add next to Fact value: violation.
  25. Click Violation 'violation' has values: to open the Choose a field to add window.
  26. Select fineAmount from the Choose a field to add menu and click OK.
  27. Enter 100.0 in the fineAmount: equals field.
  28. Click Violation 'violation' has values: to open the Choose a field to add window.
  29. Select points from the Choose a field to add menu and click OK.
  30. Enter 1 in the points: equals field.
  31. Click Save, and then click Save to confirm your changes.
  32. Click Run scenario.

    Figure 5.1. Speed test results screen

If the values and conditions set in the test scenario meet the requirements as specified in the speed violation guided decision table, the Reporting section at the bottom of the window displays a Success message.

5.2. Testing the driver license suspension scenario

Test the driver license suspension scenario using the data that you specified when you set the Driver License Suspension rules and actions.

Prerequisites

  • You have created the Driver_department_traffic_violations project.
  • You have created the Violation and Driver data objects.
  • You have set the Driver License Suspension rules and actions.

Procedure

  1. Log in to Decision Central.
  2. Click Menu Design Projects, then Driver_department_traffic_violations.
  3. Click Add Asset Test Scenario.
  4. In the Create new Test Scenario window wizard, enter the following values:

    1. Test Scenario: Suspend due to total points.
    2. Package: select com.myspace.driver_department_traffic_violations.
  5. Click Ok.
  6. Click +GIVEN to open the New input window.
  7. Select Driver from the Insert a new fact menu.
  8. Enter driver in the Fact name field and click Add.
  9. Click Add a field located under 'Driver'[driver] to open the Choose a field to add window.
  10. Select totalPoints from the Choose a field to add menu and click OK.
  11. Click ( 6191 ) next to totalPoints, click Literal value, then enter 10 in the totalPoints field.
  12. Click +GIVEN to open the New input window.
  13. Select Violation from the Insert a new fact menu.
  14. Enter violation in the Fact name field and click Add.
  15. Click Add a field located under Insert 'Violation'[violation] to open the Choose a field to add window.
  16. Select points from the Choose a field to add menu and click OK.
  17. Click ( 6191 ), and then click Literal value next to Literal value.
  18. Enter 10 in the points field.
  19. Click +Expect to open the New expectation window.
  20. Expand the Rule menu, select DriverLicenseSuspensionRule, and click OK.
  21. Click +GIVEN to open the New input window, enter trafficViolation in the Activate rule flow group field, and click Add.
  22. Click +Expect to open the New expectation window and click Add next to Fact value: driver.
  23. Click Driver 'driver' has values: to open the Choose a field to add window.
  24. Select state from the Choose a field to add menu and click OK.
  25. Enter suspend in the state: equals field.
  26. Click Save, and then click Save to confirm your changes.
  27. Click Run scenario.

    Result

    The rule is fired and the driver’s license is suspended because the total number of points is >= 20.

    Figure 5.2. Suspension test results screen

If the values and conditions set in the test scenario meet the requirements that you specified when you set the Driver License Suspension rules and actions, the Reporting section at the bottom of the window displays a Success message.

5.3. Testing the multiple violations scenario

Copy the Suspend due to total points asset and modify it to create the driver license suspension scenario for drivers with multiple violations using the data that you specified when you set the Driver License Suspension rules and actions.

Prerequisites

  • You have created the Driver_department_traffic_violations project.
  • You have created the Violation and Driver data objects.
  • You have set the driver license suspension rules and actions.

Procedure

  1. Log in to Decision Central.
  2. Click Menu Design Projects, then Driver_department_traffic_violations.
  3. Click Suspend due to total points Copy, enter Suspend due to multiple violations in the New Asset Name field, and click Make a Copy.
  4. Click Space MySpace Driver_department_traffic_violations, and then select the Suspend due to multiple violations Asset.
  5. Click +GIVEN to open the New input window.
  6. Select Violation from the Insert a new fact menu.
  7. Enter violation2 in the Fact name field and click Add.
  8. Click ( 6191 ) next to points, click Literal value, then enter 5 in the points violation2 field.
  9. In the totalPoints field, change the value from 10 to 5.
  10. Click Save, and then click Save to confirm your changes.
  11. Click Run scenario.

    Figure 5.3. Suspension test results screen

If the values and conditions set in the test scenario meet the requirements that you specified when you set the Driver License Suspension rules and actions, the Reporting section at the bottom of the window displays a Success message.

맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat