This is the second part of the tutorial for modelling and data generation. We will use the model created in the first part of the tutorial. If you do not have it, you can download it from here and import in the ecFeed web app using the 'File' -> 'Import model' option in the main menu bar.
To show more features of ecFeed, we will create an another test method. It will be named processLoanApplication and will exercise an algorithm that is deciding whether to grant a customer a loan. First, we will add parameters that define customer's name, gender and age. Add parameters named firstName, familyName, age and gender to the model and set their types to String, String, int and come.example.test.Gender accordingly. Now, we could add all the choices manually, as we did in the previous tutorial (or use the copy&paste function), but this wouldn't be optimal. It is much better to use global parameters for this purpose.
Click on the LoanDecisionTest class node with the right mouse button and select "Add global parameter" from the context menu. It will appear in the global parameters viewer in the class details page. Change the name of the parameter to gender and its type to com.example.test.Gender. You can simply copy and paste the choices for this parameter from the gender parameter in the generateCustomerData method. Now go to the processLoanApplication method details page and look at the parameters viewer. There should be a column named "Link". You can use it to select a global parameter that will be linked to this parameter. Select com.example.test.LoadDecisionTest:gender. Now the gender parameter is defined by the global parameter. Any choice you will add to the global parameter will be automaticly considered in the method parameter. In the same way you can change the correesponding parameter in the generateCustomerData method to be linked as well.
You can do the same procedure for the other parameters. To make it quicker, you can automatically convert a parameter to be linked, using drag&drop functionality. In the model page drag&drop the parameters firstName, familyName and age from generateCustomerData method to the LoanDecisionTest class node, keeping CTRL+SHIFT buttons pressed together. The parameters will be copied to the class node as a global parameters, while original nodes will be automatically changed to linked. Now you can set the corresponding parameters in the processLoanApplication method to be linked. Copy and paste the gender constraint from generateCustomerData to the processLoanApplication method.
Expected parameter represents the method's output. Typically, they are used in assert statements in a test code. Expected parameters do not have choices and in test cases may take any value that is allowed by their types. The exceptions are parameters with user type that have defined choices and may take only values that are defined in leaf choices.
Expected parameters do not impact the generation complexity and size of the output domain. In other words they are not cosidered when calculating combinations with other parameters.
Expected parameters can appear only in the consequence statement of a constraint, as a single statement. In this case the statement means "assign value to the parameter".
The processLoanApplication method shall validate if the loan decision was correctly taken. Add a parameter named loanDecision to the method and set it's type to com.example.test.LoanDecision. Add the following choices:
Go to its details page, check the "Expected" checkbox and set the default value to NEGATIVE.
Now we should add some parameters that can be used to define how the loan decision should be taken. Let's then add following parameters:
We will grant a loan to people with indefinite work contract and last year income over 20.000$ and self-employed people with last year income over 50.000$. We can define it with such constraint (named "loan decision"):
Because the value of loanDecision is set to NEGATIVE by default, we do not to define constraint for those cases.
Labels are custom strings that can be assigned to choices on different positions of a choice hierarchy of a parameter. Labels are inherited from parent choices. Next to hierarchical choices they are a way to group some choices with similar properties together.
Let's assume that we will consider granting a loan to retired people and those with temporay contracts if their last year income was very high, after they provide us with some more documents. We can set the loanDecision to INCONCLUSIVE for those cases. We can do it in three ways. One of them is to define a constraint that will enumerate all choices of the employmentStatus parameter that together with a very high income are entitled for the INCONCLUSIVE decision. This is however problematic to maintain in case when we will add some more choices to this parameter in the future - we will have to remember to update the constraint. Other way is to group the choices under an abstract choice called "inconclusive". We may however have some hierarchy for choices of the parameter already and not be able to change it.
The third way is to add a label to those choices. Go to the details page of temporary work contract choice and click the "Add label" button under the Labels viewer. Click on the label string to change its value to "potentially positive loan decission". Do the same with the retired choice. Now define another constraint named "loan decision":
Now you can generate N-Wise test suite for this method and check that the value of loanDecision parameter was correctly set in all cases.