In order to get fake IDs for testing needs I wrote something that works and is reusable, but I'd like to know if there is better ways because my code seems heavy.
n is the total caracters of the string I want.
First, I think about the conversion between number and strings I could do better.
Got some ideas ?
final integer STRING_LENGTH = 14;
String aleaNumberN=String.valueOf((integer)(Math.ceil(Math.random()*9)));
for(integer j = 1; j<n; j++) {
aleaNumberN += String.valueOf((integer)(Math.ceil(Math.random()*9)));
}
System.debug('aleaNumberN ? --> ' + aleaNumberN);
System.assert(aleaNumberN.length()==STRING_LENGTH);