RandomStringELFunction implements ELFunction { @Override public String evalute(String... args) { Random generator = new Random(); if (args != null) { switch (args.length) { case 1: int maxLength = DEFAULT_LENGTH; try { maxLength = Integer.parseInt(args[0]); } catch (NumberFormatException nfe) { } return generateString(generator, maxLength); } } return generateString(generator, DEFAULT_LENGTH); }  @Override String evalute(String... args); static final int DEFAULT_LENGTH; }
@Test public void testSimpleEvaluation() { RandomStringELFunction function = new RandomStringELFunction(); String result = function.evalute(); assertEquals(RandomStringELFunction.DEFAULT_LENGTH, result.length()); }
@Test public void testCustomSizeEvaluation() { RandomStringELFunction function = new RandomStringELFunction(); String result = function.evalute("64"); assertEquals(64, result.length()); }