WidgetFileBasedLoader extends JsonFileBasedLoader<Widget> { public List<Widget> loadAllCustom(Path widgetsFolder) throws IOException { return loadAll(widgetsFolder, new DirectoryStream.Filter<Path>() { @Override public boolean accept(Path path) throws IOException { return !path.getFileName().toString().startsWith("pb"); } }); } @Inject  WidgetFileBasedLoader(JacksonObjectMapper objectMapper); @Override Widget get(Path path); @Override List<Widget> findByObjectId(Path directory, String objectId); @Override boolean contains(Path directory, String widgetId); List<Widget> loadAllCustom(Path widgetsFolder); @Override Widget getByUUID(Path directory, String uuid); @Override Widget load(Path path);  }
@Test public void should_retrieve_all_custom_widgets() throws Exception { Widget input = aWidget().id("pbInput").build(); Widget custom1 = aWidget().id("custom1").custom().build(); Widget custom2 = aWidget().id("custom2").custom().build(); addToDirectory(widgetDirectory, input, custom1, custom2); List<Widget> widgets = widgetLoader.loadAllCustom(widgetDirectory); assertThat(widgets).containsOnly(custom1, custom2); }