Testing Query Results

The Business Component Tester lets you validate new or changed values in the data displayed by a view object. When you make changes to the data, the Tester compares the new values against the validation rules or business logic that you defined for the underlying entity objects. If your new value passes the business logic, then the Tester silently accepts it. If the new value does not pass the validation checks, the Tester returns an error message in an alert box. So, testing query results is really testing whether your validation rules and business logic is working correctly.

Note that to use this feature effectively, you should have some knowledge of the business logic which is being applied to the data. That is, you should know which values will be accepted and which will raise an error.

For example, suppose you defined a rule on the salary attribute Sal of the employee entity object Emp such that salaries cannot be less than 1200. To test the rule, change the salary of the employee named Blake in the MyEmpDetailView detail view. The change passes from the row in question to the Emp entity object. Business logic attached to Emp executes and tests the new value. If the new value is greater than 1200, it goes to the database. Otherwise, the Tester throws an exception.

To test the query results, you can:

If the query results are not what you expected or if you want to create different queries, you can use the Business Component Tester to:

Changing Data Values

You can exercise the validation rules and business logic you have defined by inserting, updating, and deleting view object data. For example, suppose you just finished writing some business logic which should fire if an employee's salary is greater than 1200. You can execute the Emp view object and change the value of Sal to 1300 and see if your logic executes correctly.

To change view object or link data:

  1. Double click a view object or view link in the navigator (or right-click the component and select Show). The Tester executes the selected component and opens it in the browser.

  2. Exercise the business logic by changing the values in any of the fields and then tabbing out of the field. You can use any of the following methods to change data values:

  1. Values that pass the business logic or validation rules will be accepted and any logic dependent on the values should execute. Values that violate the business logic or rules will return an exception in an alert box.

Querying a Data Sample

When you are working with a view object or a master-detail set of view objects defined with a view link, you can design a query to return only a subset of the data. Although the Business Component Tester does not let you change the query for an existing view object, it will let you filter for data that meets specific attribute values.

Use the Business Components View Criteria dialog box to provide parameters for the query. Use the fields in the dialog box to construct a WHERE clause, where the elements of the clause are the attributes of the current view. The query allows you to find just the row which you know contains some existing value that you want to test. For example, suppose you just finished writing some business logic which should fire if the status of an order changes from "New" to "Cancelled". You could use the Business Components View Criteria dialog box to query an order which was currently in the "New" state by using the criteria ='New' in the Status attribute field. This would summon to the browser the first "New" order, and then you could try changing "New" to "Cancelled" and see if your logic executes correctly.

The figure below illustrates the content of the Business Components View Criteria dialog box for the DeptView view object. Note that the dialog contains the same attributes as DeptView. For example, if you wanted to view and test the data associated with department number 20, enter =20 in the Deptno field and click Find. The browser will display the department name and location associated with department 20.

To query view object and link data:

  1. Double-click a view object or view link in the Navigator (or right-click a component and select Show).

    The Tester executes the component's query and opens it in the browser.

  2. Right-click the component again and select Find. The Business Components View Criteria dialog box opens.

    Note that you can also open the dialog by clicking the Specify View Criteria icon in the navigation bar.

  3. Enter values to return the row which contains some existing value that you want to test. If you do not enter a value for an attribute, it is not included in the filter.

  4. Click one of the buttons at the bottom of the dialog box. The buttons perform these operations:

The contents of the data in the Business Component browser will change to reflect the output of the filter.

  1. Insert, update, or delete the values in the fields that you want to test. Then tab out of the field. Values that pass the business logic or validation rules will be accepted. Values that violate the business logic or rules will return an exception in an alert box.