Project Creation Lab
In this lab, you use Decision Central to create a customer greeting project, data objects, and decision tables. This project serves as a type of "Hello World" example.
Projects can group a set of business assets together. By using projects, you can organize the assets that affect organization decisions.
-
Create a project
-
Practice using data object models
-
Create a decision table
-
Successful completion of the Environment Setup Lab
1. Define Business Case
In this section, you create a decision model to address a simple business problem of greeting a customer. You create a model to produce a customer greeting similar to "Good Morning, Mr. Bond!" A greeting like this is based on the current time of day and includes information about the customer. Such a decision model can be used in an interactive voice response (IVR) system. When you make a call to any customer support system and you are asked to push a button to reach a live agent, you are responding to an IVR system.
Customer greeting variations may be composed of the following elements—a greeting, a salutation (the person’s title), and the person’s name:
2. Create Customer Greeting Project
-
Log in to Decision Central.
-
On the home page, click Design.
-
In the project library view, click Add Project:
TipThe context menu icon is located just above Add Project. The context menu provides options for importing existing projects that you use later in the course:
-
Complete the Add Project dialog using these values:
-
Project Name:
customer-greeting
-
Description:
customer greeting decision project
-
Only the project name is required.
-
It is a common practice to link the words that make up a project name with hyphens, as done in this case. This is preferred to using spaces between the words, because using spaces results in file names with spaces in them.
-
Be sure to select short project names—using one to four words.
-
The Show Advanced Options link allows specification of Maven component details that enable projects to link dependencies between each other.
-
-
Click Add.
-
Expect to see confirmation that the
customer-greeting
project is successfully created. -
An empty project view is displayed for the project:
-
Note the buttons in the middle of the page that allow you to add assets to the project, as well as the importing items link at the bottom of the page.
-
3. Define Greeting Decision
In this section, you define the first part of the customer greeting ("Greeting"):
3.1. Create Request Data Object
Information is communicated to the engine using data objects. Data objects represent the data organized by fields.
Because the greeting used depends on the hour of the day received by the engine, you create the data object that communicates the hour of the day to the engine.
-
In the empty project view of the
customer-greeting
project, click .-
Expect the Create new Data Object form to display:
-
Data Object is one of 16 item types that allow a designer to easily create different business assets such as rules, processes, decisions, and test scenarios:
-
-
Complete the Create new Data Object form using these values:
-
Data Object:
GreetingRequest
-
Package:
com.myteam.customer_greeting
-
Persistable:
False
(unchecked) -
For Data Object Name, use Pascal case—that is the practice of writing compound words or phrases such that the first letter of each concatenated word is capitalized. Following this convention helps when you are integrating the data objects with other IT components and reusing the data objects between other entities.
-
Data objects are organized into packages. By default, the package is defined by the space name and the project. You can also create your own package definitions. Packages help the engine to identify different data objects that are named in the same way. For example, if you define a data object named
Request
inproject1
and another data object also namedRequest
inproject2
, and then create dependencies between both projects, the package name where eachRequest
data object definition is stored differentiates them. This is also the case with reserved item names—the package name of your data objects allows the engine to differentiate your data objects from built-in data objects with reserved names.
-
-
Click Ok.
-
Expect the
GreetingRequest
data object to be displayed in the Project Explorer view. -
You use this interface to add fields to the data object definition:
-
-
Click + add field and complete the New Field form using these values, then click Create:
-
Id:
currentHour
-
Label:
Current Hour
-
Type:
Integer
-
List:
False
(unchecked) -
For Id, you use Camel case—that is, the practice of writing compound words or phrases in which the first letter of each word in the middle of the phrase is capitalized. The use of Camel case helps to integrate the data object fields with other IT components, to reuse data objects between other entities, and to differentiate data object names from their field names.
-
-
At the top of the Data Object description, click Save to create the field:
-
Expect the Confirm Save dialog to appear.
-
Note that you can enter a save comment for easier monitoring of your changes by clicking add a comment.
-
-
Click Save to save the changes:
-
Expect to see a notification that your field is successfully saved.
-
-
In the far right upper corner, click the x to close the
GreetingRequest
object.-
When you close the greeting object, expect the project’s library view to be displayed, containing your new
GreetingRequest
data object.
-
3.2. Create Response Data Object
So far, you have a data object to communicate parameters from the client to Decision Server. In this section, you define the response from Decision Server to the client:
For each decision, a different set of data object models may be required to define the inputs and outputs.
Following the same steps you used in the previous section, create a GreetingResponse
data object asset.
-
Create the
GreetingResponse
data object asset. -
Add the following fields to the data object:
Field ID Type greeting
String
salutation
String
3.3. Create Determine Greeting Decision Table
Now that the communication models are in place, you create assets that enable Decision Server to provide the required response. To do this, you create a decision table.
-
From the library list of the
customer-greeting
project, click Create New Asset and select Guided Decision Table: -
Enter
Determine Greeting
in the Guided Decision Table field to name the decision table and check Use Wizard to enable the wizard: -
Click Ok to start the wizard.
-
Explore the steps displayed by the Guided Decision Table Wizard to gain an understanding of the options provided by the wizard:
-
Add the
GreetingRequest
fact pattern to handle the request parameters and theGreetingResponse
fact pattern to provide the response, then click Finish: -
Provide a binding for each fact pattern by clicking each of the Chosen patterns and entering
request
for the value of Binding for theGreetingRequest
data object andresponse
for the value of Binding for theGreetingResponse
data object:-
A binding is used to create an internal alias for a given fact in the decision table. With this alias, you can refer to the specific fact later and perform operations and evaluations with it. If you do not specify one, the wizard provides a default binding for you, but it is more difficult to reference your facts later with these default bindings. Red Hat recommends that you provide a binding each time you add a fact pattern.
-
-
Add a constraint named
Before Hour
for thecurrentHour
field that specifies that the value must be less than a literal value: -
Add a constraint named
After Hour
for thecurrentHour
field that specifies that the value must be greater than a literal value:-
This constraint specifies that a given hour provided by the client must be greater than a specified rule value.
-
-
Add a constraint to the
this
field in theGreetingResponse
data object to detect the presence of a response fact:-
This constraint causes Decision Server to detect that the response fact is present, allowing an action to fill in the appropriate decision value. You define this action next.
-
-
Add an action to update the
GreetingResponse
with the appropriate value in thegreeting
field: -
Click Finish.
-
Expect the decision table to display, indicating that you defined the constraints and decision result values:
-
3.4. Define Conditions and Actions
Each row of the decision table is a rule that defines conditions and actions.
-
From the Insert menu, select the Append row option:
-
Double click in each column of the added row to edit the value.
-
When you are finished editing, the automatic analysis validates your change and shows a green status.
-
When adding a rule, the automatic analysis is launched.
-
The newly added row is shown in green:
-
If there is an error in the row, it is shown in yellow.
-
-
Continue to add more rules so that the 24-hour period is covered:
-
Save and close the decision table.
4. Create Test Scenarios
The Test Scenario
asset allows you to test your decision table.
4.1. Create Test Scenario Asset
-
Click Create New Asset and select Test Scenario:
-
For Test Scenario, enter
Good Morning Greeting
for the test scenario name and click Ok:
5. Set Up Inputs and Expected Results
The two most important—and most involved—parts of the test scenario are the GIVEN and EXPECT sections:
In this section, you complete the GIVEN parameters for the test scenario to specify the input facts to Decision Server that you want to test. You also specify the expected results by setting the EXPECT parameters.
5.1. Set Up Given Facts
-
Click GIVEN to add a value to the test scenario:
-
In the New input form, insert a new fact of type
GreetingRequest
with the namerequest
and click Add: -
Click Add a field to specify the hour of the day that you want to test.
-
This opens the Choose a field to add dialog.
-
-
Select currentHour and click Ok:
-
To the right of the
currentHour
field name, click the pencil icon to specify the value: -
In the Field value form, click Literal value to enable data entry for the expected currentHour value:
-
For currentHour, enter
8
: -
Repeat the preceding steps to add a second (
GreetingResponse
) GIVEN fact to collect the result values:
5.2. Specify Expected Results
In this section, you specify the expected results.
-
Click EXPECT.
-
In the New expectation dialog, add
GreetingResponse
to the Any fact that matches field:-
The
GreetingResponse
type is added to theEXPECT
section.
-
-
Save the test scenario.
-
Click Run scenario to execute the test.
5.3. Examine Reporting and Audit Log Sections
After the scenario is executed, you analyze the Reporting
and Audit Log
sections.
-
Examine the
Reporting
section and expect to see aSuccess
result of executing the scenario:-
At this point, the test is not examining or checking the response content, so a successful result verifies only that the result has a
GreetingResponse
type.
-
-
Examine the
Audit Log
section, paying special attention to the record showing the activation ofRow 1
: -
To the right of the EXPECT button, click Show fired rules.
-
Note the execution of the
Row 1 Determine Greeting
rule:
5.4. Update Expected Results to Verify Correct Response
In this section, you update the expected results to check for the correct value in the GreetingResponse
data object.
-
In the EXPECT section, click
A fact of type GreetingResponse has values:
.-
This opens the Choose a field to add form.
-
-
Select the
greeting
field, and click Ok: -
Select the
greeting
field type, and enterequals
andGood morning
as the expected result. -
Save and click Run scenario.
-
Expect the test execution to succeed.
-
-
Examine the
Reporting
,Audit Log
, andShow fired rules
sections.
6. Finish Creating Scenarios
In this section, you finish creating the greeting scenarios. You can use Copy from the top menu in the test scenario view.
-
Create a Good afternoon greeting scenario.
-
Create a Good evening greeting scenario.
-
Create a Good night greeting scenario.
-
You can see the current version of the
customer-greeting
project in thegreeting
branch of theGithub repository
(Greeting Repository^).