Utils { public static boolean checkClassAndMethodForPattern(final String juteTest, final String className, final String methofName, final boolean onlyClass) { if (className == null || (!onlyClass && methofName == null)) { return false; } if (juteTest == null || juteTest.isEmpty()) { return true; } final String classPattern; final String methodPattern; final int methodPrefix = juteTest.indexOf('#'); if (methodPrefix < 0) { classPattern = juteTest; methodPattern = "*"; } else { classPattern = juteTest.substring(0, methodPrefix); methodPattern = juteTest.substring(methodPrefix + 1); } return FilenameUtils.wildcardMatch(className, classPattern) && (onlyClass ? true : FilenameUtils.wildcardMatch(methofName, methodPattern)); } private  Utils(); static boolean checkClassAndMethodForPattern(final String juteTest, final String className, final String methofName, final boolean onlyClass); static String printTimeDelay(final long timeInMilliseconds); static int getMaxLineWidth(final List<String> str); static String makeStr(final int len, final char ch); static List<String> splitToLines(final String str); static int calcNumberOfItems(final Map<TestClassProcessor, List<TestContainer>> map); static List<TestContainer> sortDetectedClassMethodsForNameAndOrder(final List<TestContainer> testMethods); static String toStandardJavaClassName(final String rootPath, final String classFilePath); static final String lineSeparator; }
@Test public void testCheckClassAndMethodForPattern(){ assertFalse(Utils.checkClassAndMethodForPattern(null, null, null, false)); assertFalse(Utils.checkClassAndMethodForPattern(null, null, null, true)); assertFalse(Utils.checkClassAndMethodForPattern(null, null, "", false)); assertFalse(Utils.checkClassAndMethodForPattern(null, "", null, false)); assertFalse(Utils.checkClassAndMethodForPattern("", null, null, false)); assertTrue(Utils.checkClassAndMethodForPattern(null, "", null, true)); assertTrue(Utils.checkClassAndMethodForPattern(null, "", "", false)); assertTrue(Utils.checkClassAndMethodForPattern(null, "", "", false)); assertTrue(Utils.checkClassAndMethodForPattern("com.package.Klazz", "com.package.Klazz", "Some", false)); assertTrue(Utils.checkClassAndMethodForPattern("com.package.Klazz#*", "com.package.Klazz", "Some", false)); assertTrue(Utils.checkClassAndMethodForPattern("*", "com.package.Klazz", "Some", false)); assertTrue(Utils.checkClassAndMethodForPattern("*#*", "com.package.Klazz", "Some", false)); assertTrue(Utils.checkClassAndMethodForPattern("*#So*", "com.package.Klazz", "Some", false)); assertFalse(Utils.checkClassAndMethodForPattern("com.package.Klazzz", "com.package.Klazz", "Some", false)); assertFalse(Utils.checkClassAndMethodForPattern("com.package.Klazz#SomE", "com.package.Klazz", "Some", false)); assertFalse(Utils.checkClassAndMethodForPattern("com.package.Klazz#Som??", "com.package.Klazz", "Some", false)); }