テスト・シナリオの作成
エンティティーとイベントにテストを実行して、ソリューションが予期したとおりに機能するかチェックできます。テスト・シナリオでは、1 つのファイルからエンティティーをロードし、イベントを送信します。次に、サーバー上でエンティティーの値、エンティティーの属性、およびイベントをチェックするテストを記述できます。
始める前に
このタスクについて
シナリオを作成し、各構成体をセミコロン (;) で終了させます。テストの結果は「コンソール」タブに表示されるので、結果と予測を比較できます。
手順
例
次の例では、2 つのエンティティー・ローダー (customer_ids および items) のエンティティーがロードされ、2 つのイベント・シーケンス (purchases および returns) のイベントがサーバーに送信されます。次に、テストは、エンティティー「Betty」の属性をチェックします。テストでは、Betty の名前、職業、および住所がチェックされます。
load entities from:
- "customer_ids"
- "items" ;
submit events from :
- "purchases"
- "returns" ;
check that for the customer "Betty" :
- the name of this customer is "Betty"
- the occupation of this customer is not "Software Architect"
- the address of this customer is not null
- the occupation of this customer is not null ;
次の例では、数値演算子を使用して、顧客の年齢が特定の範囲内に入るかチェックします。
check that for the customer "Betty" :
- the age of this customer is between 18 and 65
- the age of this customer is more than 21
- the age of this customer is at most 50 ;
以下の例では、一連のトランザクションが行われた後、顧客のステータスは GOLD になります。時間が経過する中で何が発生するかをチェックするために、3 つのテストで、断続的期間の後に David のステータスをチェックします。continue processing until <date> 構成体は、イベントをスケジュール可能な、イベント・シーケンスの最終タイム・スタンプから、指定された <date> までの時間の経過をシミュレートします。この例で、David に他のトランザクション・イベントはスケジュールされていません。 あるテストでは、08/24/15 にステータスが SILVER であるかチェックし、別のテストでは、ステータス変更が出力されたことをチェックし、3 番目のテストでは、02/24/16 にステータスが BRONZE であるかチェックします。時間が、イベント・シーケンスのイベントの最終タイム・スタンプから 08/24/15 に、その後 02/24/16 に経過するにつれて、David のステータスは、GOLD から SILVER に、その後、BRONZE に結果として移ります。時間が経過する中で、David が新しいトランザクションを行わなかったため、顧客ステータスが下げられました。
submit events from "transactions until gold" ;
check that for the customer "David":
- the status of this customer is GOLD ;
continue processing until 08/24/16 ;
check that for the customer "David" :
- the status of this customer is SILVER ;
check that for the status change in the events emitted
by "CustomerLoyaltyAgent" :
- the customer id of the customer of this status change is "David"
- the new status of this status change is SILVER ;
continue processing until 02/24/17 ;
check that for the customer "David" :
- the status of this customer is BRONZE ;