Utils { public static Integer getInteger(final String str) { Integer rtn = null; try { rtn = Integer.valueOf(str); } catch (final NumberFormatException e) { rtn = null; } return rtn; }  static String getVersion(); static URL getResource(final String resource); static InputStream getResourceAsStream(final String resource); static String getResourceAsString(final String resource); static String getFilename(final String name); static boolean createFile(final String filename); static void appendToFile(final String str, final String filename); static void writeToFile(final String str, final String filename); static boolean deleteFilename(final String name); static boolean isWin(); static boolean isMac(); static boolean isUnix(); static ExecCommand executeAndWaitForCommand(final String cmd); static String getTimeString(); static String getWorkingDirectory(); static String getFileSeparator(); static String getPath(final String[] folders); static String getPathFile(final String[] folders); static String getNewLine(); static String addIndent(final int numIndent, final String str); static String getTabCharacter(); static String getTabCharacterRepeat(final int num); static boolean isBoolean(final Object obj); static boolean isLong(final Object obj); static boolean isDouble(final Object obj); static boolean isString(final Object obj); static boolean isNullRuntimeException(final Object cObj, final String name); static Boolean getBoolean(final String str); static Byte getByte(final String str); static Character getCharacter(final String str); static Short getShort(final String str); static Integer getInteger(final String str); static Long getLong(final String str); static Float getFloat(final String str); static Double getDouble(final String str); static String getString(final String str); static void exit(final int exit); static int random(final int min, final int max); static int random(final int min, final int max, final long seed); static final Pattern SEM_VER_PATTERN; }
@Test public void getInteger_MalformedIntegerInString_ShouldReturnNull() { String str = "abc123467"; assert (Utils.getInteger(str) == null); }
@Test public void getInteger_IntegerInString_ShouldReturnInteger() { String str = "123467"; assert (Utils.getInteger(str).equals(new Integer(123467))); }