### Question:
GoExclusionsFileFilter implements InputFileFilter { @Override public boolean accept(InputFile inputFile) { if (!GoLanguage.KEY.equals(inputFile.language())) { return true; } String[] excludedPatterns = this.configuration.getStringArray(GoPlugin.EXCLUSIONS_KEY); String relativePath = inputFile.uri().toString(); return !WildcardPattern.match(WildcardPattern.create(excludedPatterns), relativePath); } GoExclusionsFileFilter(Configuration configuration); @Override boolean accept(InputFile inputFile);  }### Answer:
@Test public void should_exclude_vendor_dir() throws Exception { MapSettings settings = new MapSettings(); settings.setProperty(GoPlugin.EXCLUSIONS_KEY, GoPlugin.EXCLUSIONS_DEFAULT_VALUE); GoExclusionsFileFilter filter = new GoExclusionsFileFilter(settings.asConfig()); assertTrue(filter.accept(inputFile("file.go"))); assertFalse(filter.accept(inputFile("vendor/file.go"))); assertFalse(filter.accept(inputFile("vendor/someDir/file.go"))); assertFalse(filter.accept(inputFile("someDir/vendor/file.go"))); }
@Test public void should_exclude_only_go() throws Exception { MapSettings settings = new MapSettings(); settings.setProperty(GoPlugin.EXCLUSIONS_KEY, GoPlugin.EXCLUSIONS_DEFAULT_VALUE); GoExclusionsFileFilter filter = new GoExclusionsFileFilter(settings.asConfig()); assertFalse(filter.accept(inputFile("vendor/file.go"))); assertTrue(filter.accept(inputFile("vendor/file.json"))); }
@Test public void should_include_vendor_when_property_is_overridden() throws Exception { MapSettings settings = new MapSettings(); settings.setProperty(GoPlugin.EXCLUSIONS_KEY, ""); GoExclusionsFileFilter filter = new GoExclusionsFileFilter(settings.asConfig()); assertTrue(filter.accept(inputFile("file.go"))); assertTrue(filter.accept(inputFile("vendor/file.go"))); assertTrue(filter.accept(inputFile("vendor/someDir/file.go"))); assertTrue(filter.accept(inputFile("someDir/vendor/file.go"))); }
@Test public void should_exclude_using_custom_path_regex() throws Exception { MapSettings settings = new MapSettings(); settings.setProperty(GoPlugin.EXCLUSIONS_KEY, "**/lib/**"); GoExclusionsFileFilter filter = new GoExclusionsFileFilter(settings.asConfig()); assertTrue(filter.accept(inputFile("file.go"))); assertTrue(filter.accept(inputFile("vendor/file.go"))); assertFalse(filter.accept(inputFile("lib/file.go"))); assertFalse(filter.accept(inputFile("someDir/lib/file.go"))); }
@Test public void should_ignore_empty_path_regex() throws Exception { MapSettings settings = new MapSettings(); settings.setProperty(GoPlugin.EXCLUSIONS_KEY, "," + GoPlugin.EXCLUSIONS_DEFAULT_VALUE + ","); GoExclusionsFileFilter filter = new GoExclusionsFileFilter(settings.asConfig()); assertTrue(filter.accept(inputFile("file.go"))); assertFalse(filter.accept(inputFile("vendor/file.go"))); }