5.2. 運転免許停止シナリオのテスト
運転免許停止ルールおよびアクションを設定したときに指定したデータを使用して、運転免許停止シナリオをテストします。
前提条件
- Driver_department_traffic_violations プロジェクトを作成した。
- Violation および Driver データオブジェクトを作成した。
- 運転免許停止ルールおよびアクションを設定した。
手順
-
Menu
Design Projects をクリックしてから Driver_department_traffic_violations をクリックします。 -
Add Asset
Test Scenario の順にクリックします。 Create new Test Scenario ウィザードで、以下の値を入力します。
-
Test Scenario:
Suspend due to total points
。 -
Package:
com.myspace.driver_department_traffic_violations
を選択します。
-
Test Scenario:
- Ok をクリックします。
- +GIVEN をクリックして、New input ウィンドウを開きます。
- Insert a new fact メニューから Driver を選択します。
-
Fact name フィールドに
driver
と入力し、Add をクリックします。 - 'Driver'[driver] の下にある Add a field をクリックして、Choose a field to add ウィンドウを開きます。
- Choose a field to add メニューから totalPoints を選択し、OK をクリックします。
-
totalPoints の横にある (
) をクリックし、Literal value をクリックして totalPoints フィールドに
10
と入力します。 - +GIVEN をクリックして、New input ウィンドウを開きます。
- Insert a new fact メニューから Violation を選択します。
-
Fact name フィールドに
violation
と入力し、Add をクリックします。 - Insert 'Violation'[violation] の下にある Add a field をクリックして、Choose a field to add ウィンドウを開きます。
- Choose a field to add メニューから points を選択し、OK をクリックします。
-
(
) をクリックした後、Literal value の横にある Literal value をクリックします。
-
points フィールドに
10
と入力します。 - +Expect をクリックして、New expectation ウィンドウを開きます。
- Rule メニューを展開し、DriverLicenseSuspensionRule を選択して、OK をクリックします。
-
+GIVEN をクリックして New input ウィンドウを開き、Activate rule flow group フィールドに
trafficViolation
と入力し、Add をクリックします。 - +Expect をクリックして New expectation ウィンドウを開き、Fact value: driver の横にある Add をクリックします。
- Driver 'driver' has values: をクリックして Choose a field to add ウィンドウを開きます。
- Choose a field to add メニューから state を選択し、OK をクリックします。
-
state: equals フィールドに
suspend
と入力します。 - Save をクリックした後、Save をクリックして変更を確認します。
Run scenario をクリックします。
結果
合計点数が 20 以上であるため、ルールが実行され、運転免許が停止されます。
図5.2 停止のテストの結果画面
テストシナリオに設定した値と条件が、運転免許停止ルールおよびアクションを設定したときに指定した要件を満たしている場合、ウィンドウの下部にある Reporting セクションに Success というメッセージが表示されます。