Bravo extends Rectangle { public void setConfettiOnStart(final GameContext gc) { final Dimension2D dim = gc.getGamePanelDimensionProvider().getDimension2D(); final RandomColorGenerator randomColorGenerator = RandomColorGenerator.getInstance(); for (int i = 0; i <= 100; i++) { final Rectangle r = new Rectangle(-100, -100, dim.getHeight() / 30, dim.getHeight() / 15); r.setFill(randomColorGenerator.randomColor()); gc.getChildren().add(r); final Duration duration = Duration.millis(1500 + (Math.random() * 5000)); final TranslateTransition tt = new TranslateTransition(duration, r); tt.setInterpolator(Interpolator.LINEAR); tt.setFromX(Math.random() * (110 * dim.getWidth() / 100)); tt.setFromY(0); tt.setToY(dim.getHeight()); final RotateTransition rt = new RotateTransition(duration, r); rt.setInterpolator(Interpolator.LINEAR); rt.setByAngle(-360 + Math.random() * 2 * 720); final FadeTransition ft = new FadeTransition(duration, r); ft.setInterpolator(Interpolator.LINEAR); ft.setFromValue(0); ft.setToValue(0.8); final ParallelTransition pt = new ParallelTransition(); pt.getChildren().addAll(tt, rt, ft); pt.setOnFinished(actionEvent -> gc.getChildren().remove(r)); pt.play(); } } Bravo();  Bravo(final String pictureResourceLocation, final String soundResourceLocation, final boolean enableRewardSound); void playWinTransition(final Region root, final EventHandler<ActionEvent> onFinishedEventHandler); void playWinTransition(
        final Region root,
        final long initialDelay,
        final EventHandler<ActionEvent> onFinishedEventHandler
    ); void setConfettiOnStart(final GameContext gc);  }
@Test public void shouldSetConfettiOnStart() throws TimeoutException { ObservableList<Node> mockList = FXCollections.observableArrayList(); when(mockGameContext.getGamePanelDimensionProvider()).thenReturn(mockDimensionProvider); when(mockGameContext.getChildren()).thenReturn(mockList); when(mockDimensionProvider.getDimension2D()).thenReturn(new Dimension2D(100d, 100d)); FxToolkit.registerPrimaryStage(); BravoTestApp bravoTestApp = (BravoTestApp) FxToolkit.setupApplication(BravoTestApp.class); Bravo bravo = bravoTestApp.bravo; bravo.setConfettiOnStart(mockGameContext); FxToolkit.cleanupStages(); assertEquals(101, mockList.size()); }