RandomNumberFunction implements Function { public static String checkLeadingZeros(String generated, boolean paddingOn) { if (paddingOn) { return replaceLeadingZero(generated); } else { return removeLeadingZeros(generated); } }  String execute(List<String> parameterList, TestContext context); static String getRandomNumber(int numberLength, boolean paddingOn); static String checkLeadingZeros(String generated, boolean paddingOn);  }
@Test public void testLeadingZeroNumbers() { String generated = RandomNumberFunction.checkLeadingZeros("0001", true); Assert.assertTrue(Integer.valueOf(generated.substring(0, 1)) > 0); generated = RandomNumberFunction.checkLeadingZeros("0009", true); Assert.assertEquals(generated.length(), 4); generated = RandomNumberFunction.checkLeadingZeros("00000", true); Assert.assertEquals(generated.length(), 5); Assert.assertTrue(Integer.valueOf(generated.substring(0, 1)) > 0); Assert.assertTrue(generated.endsWith("0000")); generated = RandomNumberFunction.checkLeadingZeros("009809", true); Assert.assertEquals(generated.length(), 6); Assert.assertTrue(Integer.valueOf(generated.substring(0, 1)) > 0); Assert.assertTrue(generated.endsWith("09809")); generated = RandomNumberFunction.checkLeadingZeros("01209", true); Assert.assertEquals(generated.length(), 5); Assert.assertTrue(Integer.valueOf(generated.substring(0, 1)) > 0); Assert.assertTrue(generated.endsWith("1209")); generated = RandomNumberFunction.checkLeadingZeros("1209", true); Assert.assertEquals(generated.length(), 4); Assert.assertEquals(generated, "1209"); generated = RandomNumberFunction.checkLeadingZeros("00000", false); Assert.assertEquals(generated.length(), 1); Assert.assertEquals(generated, "0"); generated = RandomNumberFunction.checkLeadingZeros("0009", false); Assert.assertEquals(generated.length(), 1); Assert.assertEquals(generated, "9"); generated = RandomNumberFunction.checkLeadingZeros("01209", false); Assert.assertEquals(generated.length(), 4); Assert.assertEquals(generated, "1209"); generated = RandomNumberFunction.checkLeadingZeros("1209", false); Assert.assertEquals(generated.length(), 4); Assert.assertEquals(generated, "1209"); }