Hi Guys
The Decision Table is a smart, compact way of clustering many IF/THEN rules together, as will be demonstrated in this article. As we dealt with simple IF/THEN,Functions in previous posts.
Demo
This article demonstrates how the decision table can be put to good use
to implement the business logic behind the classical game of Dice
Rules for Dice game as defined below :
IF Player 1 ="three" Player 2="three" Player 2 wins
IF Player 1 ="three" Player 2="one,two,four,five,six" Player 1 wins
IF Player 1 ="one" Player 2="one" Player 2 wins
IF Player 1 ="one" Player 2="three,two,four,five,six" Player 1 wins
IF Player 1 ="five" Player 2="five" Player 2 wins
IF Player 1 ="five" Player 2="three,two,four,six,one" Player 1 wins
IF Player 1 ="six" Player 2="six" Player 1,2 are in tie wins
IF Player 1 ="six" Player 2="three,two,four,five,six" Player 1 wins
IF Player 1 ="two,four" Player 2="two,four" response="tryAgain"
Designing SOA Application :
Create a new XSD document, called Diceplayergame.xsd. It should be composed as follows:
The RequestType describes the input that the Business Rule will deal
with. It consists of two entries, here labeled with throwOne and
throwTwo. Both contain exactly one value from the enumerated list of
values Stype1. The Response type
contains a single element outcomeof Stype2 that has one of three values: One_Wins | Two_Wins | tie.
Create and configure the Business Rule
Create new Business Rule component
Set the input and output for the rule based on the Request and Response type defined in the XSD document.
Double click the Business Rule component to edit the rule definition.
o Create XML Facts – go to the Facts tab, click on the green
plus icon, select the complex and simple types from the XSD document to
have XML Facts created from them
Verify/Create Bucketsets as illustrated below
Configure the Decision Function
Edit default rule set; create a Decision Table
Create an action: Assert New InputGamedetailsresponse. The outcomeresponse
property is parametrized (always to be determined for the rule), make
sure the checkbox Always Selected is checked (to make sure this action
is executed for every rule that is triggered) and press the ok button
Add conditions for InputGamedetails.throwone and InputGamedetails .throwtwo. Both conditions are associated
with bucketset Roll_Dice.
Below illustrated Design of decision-table
TestCases :
HappyLearning
By DeepthiReddy
No comments:
Post a Comment