Functions for Verification Rules ¶
Functions in Verification are used to calculate a rule's name if it is unknown. For example, if there may be 10 properties whose rules must be found: 5 ranging from "ValueOfSubscription_1_before_event"
to "ValueOfSubscription_5_before_event"
and 5 ranging "ValueOfSubscription_1_after_event"
to "ValueOfSubscription_5_after_event"
.
The functions created to find the rules must be saved in a *.function
file and the path to the folder containing the file(s) must be defined in the CdrVerificationConfigurations configuration section under the functionFolderPath
property.
When defining functions, Java methods may be used. This includes String Class Methods and Date Class Methods
Functions for Rules |
---|
Get Property |
Get Record ID |
Get Ticket Type |
Get Source (File Name) |
Get Marks (Selectors) |
Example Function in Online Verification |
Get Property ¶
This method returns the value of a ticket's property.
Syntax
1 2 3 4 5 6 | // Returns the property <ticketProperty TicketProperty> := <ticket Ticket>.getProperty(<property String>) // Returns the name of a property as string <ticketPropertyName String> := ticketProperty.getName() // Returns the value of a property as object, e.g. date, number or string <ticketPropertyValue Any> := ticketProperty.getValue() |
Parameters
-
ticketProperty - The ticket's property.
-
ticketPropertyName - The ticket property's name.
-
ticketPropertyValue - The ticket property's value.
-
ticket - The ticket with properties.
-
property - The property name.
Example
1 2 3 | ticketProperty := ticket1.getProperty("12345") ticketPropertyWithName := ticket2.getProperty("Voice_call").getName() ticketPropertyWithValue := ticket3.getProperty("MSISDN").getValue() |
Get Record ID ¶
This method returns the ticket's record ID.
1 | <recordId String> := <ticket Ticket>.getRecordId() |
Parameters
-
recordId - The ticket's record ID.
-
ticket - The variable that holds a ticket.
Example
1 | ticketRecordId := voiceticket.getRecordId() |
Get Ticket Type ¶
This method returns the ticket's type (format) as a string.
Syntax
1 | <ticketType String> := <ticket Ticket>.getType() |
Parameters
-
ticketType - The ticket type.
-
ticket - The variable that holds a ticket.
Example
1 | returnedTicketType := ticket.getType() |
Get Source (File Name) ¶
This method returns the ticket's file name as a string.
Syntax
1 | <sourceName String> := <ticket Ticket>.getSource() |
Parameters
-
sourceName - The ticket's file name.
-
ticket - The variable that holds a ticket.
Get Marks (Selectors) ¶
This method returns a set of strings consisting of all the selectors matching the specified ticket.
Syntax
1 | <selectorsSet Set<String>> := <ticket Ticket>.getMarks() |
Parameters
-
selectorSet - The set of selectors.
-
ticket - The variable that holds a ticket.
Example
1 | selectorsset := ticket.getMarks() |
Example Function in Online Verification ¶
The function below shows a function that has been created to find a rule containing specific properties.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | subsUsage(subscription, property, beforeOrAfter) code := "__" if subscription = "Unlimited" then code := "001" elif subscription = "BSP" then code := "002" elif subscription = "Flat" then code := "003" end indexes := ticket.getProperty(property).getValue() subsIndex := (indexes.indexOf(code) / 3) + 1 return "ValueOfSubscription_" + subsIndex + "_" + beforeOrAfter + "_event" end |
In the example above:
-
The
subsUsage
function contains three parameters:subscription
,property
andbeforeOrAfter
. A variable with the value"__"
is defined, followed byif
statements that define which subscriptions are passed to the function. -
The
indexes
variable is assigned the value of the property passed to thesubsUsage
function and called in the next variable,subsIndex
.subsIndex
returns the first occurrence of the specifiedcode
, which is divided by3
and added by+1
. -
The
return
statement returns a string representing a property name that is used in the ticket that is comprised of the variables passed from the test case or defined above.
Within the function, the following variables are accessible, meaning methods can be called on them:
-
ticket
- This built-in variable refers to the currently validated ticket and allows access to its properties. -
Context Variables - These are prefixed with a built-in variable,
ctx.
and the method after the context variable's name. For example,ctx.A.number
.