DirectiveFileGenerator { public List<Path> getWidgetsFilesUsedInPage(Previewable previewable) { return widgetRepository.getByIds(widgetIdVisitor.visit(previewable)).stream() .filter(widget -> !"pbContainer".equals(widget.getId())) .map(w -> Paths.get(w.getId()).resolve(w.getId()+".js")) .map(file -> pathResolver.getWidgetsRepositoryPath().resolve(file)) .collect(Collectors.toList()); } @Inject  DirectiveFileGenerator(WorkspacePathResolver pathResolver, WidgetRepository widgetRepository,
                WidgetIdVisitor widgetIdVisitor); List<Path> getWidgetsFilesUsedInPage(Previewable previewable); byte[] concatenate(List<Path> paths); byte[] minify(byte[] content); String generateAllDirectivesFilesInOne(Previewable previewable, Path path);  }
@Test public void should_list_all_widgets_except_container_used_in_page() throws Exception { Page page = aPage().with(aContainer().build()).build(); mockWidgetIdVisitorAndWidgetRepository(page, "pbLabel", "paragraph", "pbContainer"); List<Path> widgesFiles = generator.getWidgetsFilesUsedInPage(page); assertThat(widgesFiles).containsOnly(temporaryFolder.toPath().resolve("pbLabel").resolve("pbLabel.js"), temporaryFolder.toPath().resolve("paragraph") .resolve("paragraph.js")); assertThat(widgesFiles).doesNotContain(temporaryFolder.toPath().resolve("pbContainer").resolve("pbContainer.js")); }