DirectivesCollector { public List<String> buildUniqueDirectivesFiles(Previewable previewable, String pageId) { String filename = directiveFileGenerator.generateAllDirectivesFilesInOne(previewable, getDestinationFolderPath(pathResolver.getTmpPagesRepositoryPath().resolve(pageId).resolve(JS_FOLDER))); return Arrays.asList(JS_FOLDER + "/" + filename); } @Inject  DirectivesCollector(WorkspacePathResolver pathResolver, DirectiveFileGenerator directiveFileGenerator); List<String> buildUniqueDirectivesFiles(Previewable previewable, String pageId); static String JS_FOLDER; }
@Test public void should_build_directives_from_the_preview() throws IOException { Page page = aPage().build(); when( pathResolver.getTmpPagesRepositoryPath()).thenReturn(temporaryFolder.toPath()); Path assets = temporaryFolder.toPath().resolve(page.getId()).resolve("js"); when(directiveFileGenerator.generateAllDirectivesFilesInOne(page, assets)).thenReturn("widgets-123456.min.js"); List<String> imports = collector.buildUniqueDirectivesFiles(page, page.getId()); Assertions.assertThat(imports).containsOnly("js/widgets-123456.min.js"); }