You define a sequence of events in an event sequence file, and then submit the events to
the development server to test whether the solution is working as expected. After the event sequence
runs, you view the results by using the REST API and the Insight Inspector, which is a web
application that you can use to review and troubleshoot solutions.
About this task
An event sequence simulates a series of events. The file in the tutorial uses
define statements to specify some attribute values. It uses emit
statements to specify the event details and the order in which the events are sent.
Procedure
- Switch to the Decision Insight perspective.
- Create a test client project:
- In the solution map, click Add test client project.
- Enter the name CreditCardScenario for the test client project name,
select the MyCreditCardSolution solution project, select Create
empty test client project, and then click Finish.
- Create a test scenario:
- In the solution map, click Create test scenario.
- Select the test client project that you created.
- Enter the name CreditCardTestScenario for the name, and click
Finish.
The .tscn file editor opens, but do not enter anything into it
yet.
- Create an event sequence file:
- In the solution map, click Create event sequence.
- In the Event Sequence wizard, select CreditCardScenario for the test
client project.
- Enter the name CreditCardEventSequence for the event sequence and click
Finish.
An empty .eseq file opens.
- In the event sequence editor, define the sequence of events. You enter the statements in a way similar to how you created the business model
definitions.
- Enter the following define statement: define 'the customer' as the customer identified
by "customer1"; You can press Space or Ctrl+Space and then select an element, or type the statement.
- Complete the rest of the event sequence file.
Important: When you specify the date and time in the time-stamped
lines, you can specify the current date and time for the first event, but ensure that each
subsequent emit statement has a later timestamp.
The final event sequence
file that you create must be as
follows:define 'the customer' as the customer identified by "customer1";
define 'the account' as the account identified by "accountId1";
emit a new account initialization where
the account is 'the account',
the status is Risky ,
the balance is 100,
the customer is 'the customer',
time-stamped 6/18/2015 11:43:49 AM;
emit a new transaction where
the account is 'the account' ,
the amount is 50,
the country code is "US",
time-stamped 6/18/2015 2:43:49 PM;
emit a new transaction where
the account is 'the account',
the amount is 6000,
the country code is "US",
time-stamped 6/19/2015 8:43:49 AM;
- Save the CreditCardEventSequence.eseq file.
- In the CreditCardTestScenario.tscn editor, specify the event sequence file
that you want to run by using the submit events from <event sequence>
construct. Add two checks to verify the account balance value and the number of emitted events after
running the two transactions. The final test scenario file that you create must be as
follows:
submit events from "CreditCardEventSequence" ;
check that for the account identified by "accountId1":
- the balance of this account equals -5950;
check that there are 2 events in the events emitted ;
- Save the .tscn file.
- Submit the events to the server:
- In the Solution Explorer, right-click the CreditCardScenario project and click .
- In the Run Configurations window, right-click Test Scenario and click
New.
- Enter a name for the new configuration: CreditCardConfiguration.
- Specify the CreditCardScenario as the test client project and
CreditCardTestScenario.tscn as the test scenario.
- Select Reset solution state, Delete all entities,
and Enable recording.
- Click Apply and then click Run. The event
sequence is submitted to the server. Several messages are displayed in the Console view. When the
event sequence is complete, a terminated message is displayed at the top of the
Console view.
- Display the account entity that was created:
- Open a browser.
- Enter the following URL:
http://localhost:9080/ibm/ia/rest/solutions/MyCreditCardSolution/entity-types/creditcard.Account
The default port is 9080. If the default is not valid, use the value that
is specified in the
<WLP_USER_DIR>/servers/cisDev/bootstrap.properties
file.
The result is displayed, similar to the following XML:The URL changes to port 9443 because HTTPS is used to display the response, which is
secure traffic.
- Review the events that occurred by starting Insight Inspector.
- Switch to the Samples Console perspective.
- In the Sample Server view, click .
- Accept any security exception that is displayed. The Insight Inspector opens in your
default browser.
- Click the name of the solution, MyCreditCardSolution to display the
timeline, and click Zoom Out until you can see both events on the
timeline.
- Click the second transaction event that was processed by the CreditCardRules agent. The information shows that a transaction event was emitted and processed by the rule agent
that emitted an Authorization Response event. The Java™ agent,
indicated by the default name MyAgent, also processed the event. The initialization event is not
shown because those events are not captured in this version of the application.
At the bottom of the screen, you can
see information about the Transaction event and the Account entity. The properties of the event and
the entity are shown with their values. You can see that the balance of the account is updated with
the last transaction amount of 6000.
- In the timeline for the CreditCardRules agent, select the processed event and then click the
Rules tab. Insight Inspector shows the rules that
fired when the last transaction was emitted.
What to do next
If you want to explore a Java client application, proceed to the next lesson, which is optional. If you are done with the tutorial, stop the sample server by clicking the Stop icon in the Sample Server view of the Samples Console perspective.