CeilingFunction implements Function { public String execute(List<String> parameterList, TestContext context) { if (CollectionUtils.isEmpty(parameterList)) { throw new InvalidFunctionUsageException("Function parameters must not be empty"); } return String.valueOf(Math.ceil(Double.valueOf(parameterList.get(0)))); }  String execute(List<String> parameterList, TestContext context);  }
@Test public void testFunction() { Assert.assertEquals(function.execute(Collections.singletonList("0.0"), context), "0.0"); Assert.assertEquals(function.execute(Collections.singletonList("0"), context), "0.0"); Assert.assertEquals(function.execute(Collections.singletonList("0.3"), context), "1.0"); Assert.assertEquals(function.execute(Collections.singletonList("1"), context), "1.0"); Assert.assertEquals(function.execute(Collections.singletonList("-1.5"), context), "-1.0"); Assert.assertEquals(function.execute(Collections.singletonList("1.3"), context), "2.0"); }
@Test(expectedExceptions = {NumberFormatException.class}) public void testWrongParameterUsage() { function.execute(Collections.singletonList("no digit"), context); }
@Test(expectedExceptions = {InvalidFunctionUsageException.class}) public void testNoParameters() { function.execute(Collections.<String>emptyList(), context); }