### Question:
Stages { public static CompletionStage<Stage> setStylesheet(final Stage stage, final String stylesheet) { LOG.info( "Setting stylesheet {} for stage {}({})", stylesheet, stage.toString(), stage.getTitle() ); return FxAsync.doOnFxThread( stage, theStage -> { final Scene stageScene = theStage.getScene(); stageScene.getStylesheets().clear(); stageScene.getStylesheets().add(stylesheet); } ); } private  Stages(); static CompletionStage<Stage> stageOf(final String title, final Pane rootPane); static CompletionStage<Stage> scheduleDisplaying(final Stage stage); static CompletionStage<Stage> scheduleDisplaying(final CompletionStage<Stage> stageCreationResult); static CompletionStage<Stage> scheduleHiding(final Stage stage); static CompletionStage<Stage> scheduleHiding(final CompletionStage<Stage> stageCreationResult); static CompletionStage<Stage> setStylesheet(final Stage stage, final String stylesheet); static CompletionStage<Stage> setStylesheet(final CompletionStage<Stage> stageCreationResult, final String stylesheet); static CompletionStage<Stage> setStylesheet(final Stage stage, final FxmlStylesheet stylesheet); static CompletionStage<Stage> setStylesheet(final CompletionStage<Stage> stageCreationResult, final FxmlStylesheet stylesheet);  }### Answer:
@Test public void setStylesheet() throws ExecutionException, InterruptedException { final CompletionStage<Stage> setStyleAsyncOp = Stages.setStylesheet(testStage, TEST_STYLE); final Stage stage = setStyleAsyncOp.toCompletableFuture().get(); final ObservableList<String> stylesheets = stage.getScene().getStylesheets(); assertThat(stylesheets).hasSize(1); assertThat(stylesheets).containsExactly(TEST_STYLE.getExternalForm()); }
@Test public void setStylesheetPostAsync() throws ExecutionException, InterruptedException { Try.of(() -> testStage) .map(Stages::scheduleDisplaying) .map(cs -> Stages.setStylesheet(cs, TEST_STYLE)) .get() .toCompletableFuture() .get(); await().until(() -> testStage.getScene().getStylesheets().contains(TEST_STYLE.getExternalForm())); assertThat(testStage.getScene().getStylesheets()).containsExactly(TEST_STYLE.getExternalForm()); }