ConversionHelper { public static int count(final String string, final String substring) { int count = 0; int idx = 0; while ((idx = string.indexOf(substring, idx)) != -1) { idx++; count++; } return count; }  static String firstNonNull(final String ... strings); static int count(final String string, final String substring); static String decapitalize(String param, boolean allCapsStringToLowercase); static String decapitalize(final String param); static boolean isOnlyUpperCase(final String param); static final String getString(final String str, final String defaultValue); static final long getLong(final String strToParse, final long defaultValue); static final int getInt(final String strToParse, final int defaultValue); static final double getDouble(final String strToParse, final double defaultValue); static final boolean getBoolean(final String strToParse, final boolean defaultValue); static final boolean getOnOffBoolean(final String strToParse, final boolean defaultValue); static final List<String> getStringList(final List<String> idList); static final List<Integer> getIntList(final List<String> idList); static Set<T> asSet(final T... array);  }
@Test public void testCount() { assertEquals("'moo' should match 2 o's", 2, ConversionHelper.count("moo", "o")); assertEquals("'moo' should match 1 oo", 1, ConversionHelper.count("moo", "oo")); assertEquals("'moo' should match 1 moo", 1, ConversionHelper.count("moo", "moo")); assertEquals("'moo' should match 1 mo", 1, ConversionHelper.count("moo", "mo")); assertEquals("'moo' should not match 'kvaak", 0, ConversionHelper.count("moo", "kvaak")); assertEquals("'wild**cards*' should match 3 *", 3, ConversionHelper.count("wild**cards*", "*")); }