### Question:
PEStringUtils { public static String trimToInt(final String numeric) { if (NumberUtils.isNumber(numeric)) { final double doubleValue = Double.parseDouble(numeric); if (MathUtils.isInteger(doubleValue)) { return String.format("%d", (int) doubleValue); } return numeric; } throw new PECodingException("The input must be a valid number but was: " + numeric); } private  PEStringUtils(); static String buildPath(String dir, String sep, String name); static StringBuffer toString(StringBuffer sb, String name, Collection<? extends Object> values); static StringBuffer toArrayString(StringBuffer sb, Collection<? extends Object> values); static String toString(String name, Collection<? extends Object> values); static String toString(Class<T> theClass, Collection<? extends Object> values); static StringBuffer toString(StringBuffer sb, String name, Map<K, V> values); static String toString(String name, Map<K, V> values); static String[] toArray(Collection<String> values); static String trimToInt(final String numeric); static String normalizePrefix(String prefix); static String toString(Throwable e); static Pattern buildSQLPattern(String likeExpr); static String singleQuote(final String value); static boolean isQuoted(final String value); static String dequote(final String in); static String escapeSingleQuoteIfNecessary(String t); static boolean toBoolean(String value); static boolean isHexNumber(final String value); static String getIndented(final String value); static String getIndented(final String value, final int numIndents); static String getIndented(final String value, final String indent, final int numIndents); static String buildIndent(final int numIndents); static String buildIndent(final String indent, final int numIndents); static final String FILE_SEP; }### Answer:
@Test public void testTrimToInt() { assertEquals("3.1415", PEStringUtils.trimToInt("3.1415")); assertEquals("1.0050", PEStringUtils.trimToInt("1.0050")); assertEquals("10", PEStringUtils.trimToInt("10.0")); assertEquals("-1", PEStringUtils.trimToInt("-1.0")); assertEquals("0", PEStringUtils.trimToInt("0.0")); new ExpectedExceptionTester() { @Override public void test() throws Throwable { PEStringUtils.trimToInt("Hello, World!"); } }.assertException(PECodingException.class, "The input must be a valid number but was: Hello, World!"); new ExpectedExceptionTester() { @Override public void test() throws Throwable { PEStringUtils.trimToInt(null); } }.assertException(PECodingException.class, "The input must be a valid number but was: null"); }