Two Minute Guide To: CLONE() for Test Data Creation Or Creating large instances of test data almost effortlessly
We all understand the value of cloning in the physical world. I would love to spin off clones of our developers, testers and documentation engineers to complete projects quickly. Taking a good instance of something and making many replicas is a powerful concept.
With Transformation Extender we have a special function that lets us create clones of our data easily. How many times have you needed to create large amounts of data quickly? Here is a 2-minute guide to get you started.
Our input only has one ‘claims worth’ of data. Sometimes it is hard to be creative when you have to create example data manually! So when we look at what we mapped onto output card #1 we see the following:
This is what we expected based on having one HIPAA claim as the input. However, what we really want is a hundred claims – we can do that with one map instruction. Here is one way to do that.
As output card 1 only created one ClaimDiag (as we see above) we will use the CLONE() function to create as many of them as we want in a second output. In this case we want 100. So we will copy output card 1 and create an output card 2 with a different card name and a different output file location. Then we will add a function call on our repeating component which is simply:
= CLONE ( ClaimDiag:JSON:JSON_mapped ,100 )
Our output cards now look like:
Output card 2 clones the (one instance of) the ClaimDiag component from output card 1, one hundred times.
We can clone any number of times depending on how many instances we need. We would simply change the 100 to some other integer suck as 852.
= CLONE ( ClaimDiag:JSON:JSON_mapped ,852 )
Now our output looks like….
The CLONE() function by itself is great for bulking up data, as we have seen above. However, the data is all exactly the same, which in addition to be boring, may not be exactly what you are looking for in test data. The good news is that with Transformation Extender It is easy to see how we could add some variety to the data we are generating
A very common approach is to:
Call the CLONE() function inside of a functional map and also pass in the INDEX of the repeating component you are mapping on. Inside that functional map use that passed in INDEX to allow for varying output rules using math or using it to reference varied values in a table or other external file. For example, the 5th iteration of the cloned sample data creation could add 5 days to the Service Date and select the 5th value in a random list of Surnames.
CLONE() is a very versatile and useful function – I hope you get the chance to use it soon.
Transformation Extender is a trademark of IBM Corporation in at least one jurisdiction and is used under license.