Name extends BaseExpression { @Override public Result apply(PathData item, int depth) throws IOException { String name = getPath(item).getName(); if (!caseSensitive) { name = StringUtils.toLowerCase(name); } if (globPattern.matches(name)) { return Result.PASS; } else { return Result.FAIL; } } Name(); private  Name(boolean caseSensitive); static void registerExpression(ExpressionFactory factory); @Override void addArguments(Deque<String> args); @Override void prepare(); @Override Result apply(PathData item, int depth);  }
@Test(timeout = 1000) public void applyMatch() throws IOException { setup("name"); PathData item = new PathData("/directory/path/name", mockFs.getConf()); assertEquals(Result.PASS, name.apply(item, -1)); }
@Test(timeout = 1000) public void applyNotMatch() throws IOException { setup("name"); PathData item = new PathData("/directory/path/notname", mockFs.getConf()); assertEquals(Result.FAIL, name.apply(item, -1)); }
@Test(timeout = 1000) public void applyMixedCase() throws IOException { setup("name"); PathData item = new PathData("/directory/path/NaMe", mockFs.getConf()); assertEquals(Result.FAIL, name.apply(item, -1)); }
@Test(timeout = 1000) public void applyGlob() throws IOException { setup("n*e"); PathData item = new PathData("/directory/path/name", mockFs.getConf()); assertEquals(Result.PASS, name.apply(item, -1)); }
@Test(timeout = 1000) public void applyGlobMixedCase() throws IOException { setup("n*e"); PathData item = new PathData("/directory/path/NaMe", mockFs.getConf()); assertEquals(Result.FAIL, name.apply(item, -1)); }
@Test(timeout = 1000) public void applyGlobNotMatch() throws IOException { setup("n*e"); PathData item = new PathData("/directory/path/notmatch", mockFs.getConf()); assertEquals(Result.FAIL, name.apply(item, -1)); }