Workspace { public void initialize() throws IOException { ensurePageRepositoryPresent(); ensureWidgetRepositoryPresent(); ensureWidgetRepositoryFilled(); } @Inject  Workspace(WorkspacePathResolver workspacePathResolver, WidgetRepository widgetRepository, WidgetFileBasedLoader widgetLoader,
                     WidgetDirectiveBuilder widgetDirectiveBuilder, ResourceLoader resourceLoader, AssetImporter<Widget> widgetAssetImporter); void initialize(); void cleanPageWorkspace();  }
@Test public void should_ensure_that_folders_page_and_widgets_are_created() throws Exception { mockWidgetsBasePath(temporaryFolder.toPath().resolve("widgets")); workspace.initialize(); assertThat(temporaryFolder.toPath().resolve("pages")).exists(); assertThat(temporaryFolder.toPath().resolve("widgets")).exists(); }
@Test public void should_not_throw_exception_when_a_folder_exist_before_init() throws Exception { temporaryFolder.newFolderPath("pages"); Path widgetFolder = temporaryFolder.newFolderPath("widgets"); mockWidgetsBasePath(widgetFolder); workspace.initialize(); assertThat(temporaryFolder.toPath().resolve("pages")).exists(); assertThat(temporaryFolder.toPath().resolve("widgets")).exists(); }
@Test public void should_copy_widget_to_widget_repository_folder() throws Exception { mockWidgetsBasePath(Paths.get("src/test/resources/workspace/widgets")); workspace.initialize(); assertThat(pathResolver.getWidgetsRepositoryPath().resolve("pbLabel/pbLabel.json")).exists(); assertThat(pathResolver.getWidgetsRepositoryPath().resolve("pbText/pbText.json")).exists(); assertThat(pathResolver.getWidgetsRepositoryPath().resolve("pbText/help.html")).exists(); assertThat(pathResolver.getWidgetsRepositoryPath().resolve("pbMissingHelp/pbMissingHelp.json")).exists(); }