Testing Dynamic Logic

This page describes the testing of a dynamic logic in Oracle Health Insurance. A Unit Under Test (UUT) is the dynamic logic to test. You can create a test case to verify the correctness of a logic for each use case. A test case is a dynamic logic that runs a test on another dynamic logic unit. It is a dynamic logic that uses Test Unit signature. See Test Dynamic Logic Integration Point for more information.

It is best to create short test cases that test a single use case for a unit.

A typical test case looks like:

//1.
def input1 = <<some expression>>
def input2 = <<some expression>>
//2.
def result = test( "<Dynamic Logic Code>", [
    "<key1>" : input1,
    "<key2>" : input2
])

//3.
if( result.<<some_check>>) {
    log.error( "<Some error message>" )
    return false
} else {
    log.info( "<Some success message>" )
    return true
}
  1. Creating Input Objects: You can create them in your test case or access them from the application database.

  2. Calling the Unit Under Test (UUT): By using the test predefined function.

  3. Verifying the Outcome: Returns true when the test runs successfully and is false when it fails.

Security Context

There are provisions to protect the application from certain actions possible in any dynamic logic. There are no such restrictions in a test case. You can define any object in any state as input to the test function in the second step. The test function has the same restrictions as the application has for the actual invocation.

Changing any object in a test case does not affect the idempotency of the test. A dynamic logic with a Test Unit signature is marked rollback-only. So, no changes in the test case are saved in the database permanently.

How to Test Dynamic Logic Using Test Dynamic Logic IP

Here are the steps to test dynamic logic using the Test Dynamic Logic Integration Point.

A test case is a dynamic logic that tests the UUT.

Step 1 - Setting up the Unit Under Test

Create a dynamic logic function to test. For example, a validation logic that checks if a string is in all uppercase. The UUT uses a Field signature, which accepts a value of any data type and returns a boolean value.

Let the code for this dynamic logic be TEST_001.

return value == value.toUpperCase()

There can be multiple scenarios to consider.

  • The incoming value is not a string

  • The incoming value is an empty string

You can create a separate test case for each scenario.

Step 2 - Setting up a Test Case

The test case is a dynamic logic that tests the UUT. The example test case tests a string, say Hello, for its case. The test case informs you if the unit under test executed successfully. It adds a message: "No results" in the logs when the UUT does not return any value.

The code for this dynamic logic is: TEST_002.

testString = "Hello"

// calling the UUT that determines case of the string
def result = test("TEST_001", [
  "value": testString
])

if (result) {
  log.info("Result=" + result)
  return result
} else {
  // if result is null, the test case has failed
  log.error("No result")
  return false
}

Step 3 - Call the Test Dynamic Logic API

The following web service executes the test case.

Table 1. Step 3 - Call the Test Dynamic Logic API
HTTP Method POST

Base URL

http://<host>:<port>/<context-root>/testdynamiclogic/TEST_002

Table 2. Response
Error Code Description

200

The test is successful and the unit under test(TEST_001) executes successfully.

400

The test failed, and the UUT does not return any value.