LogoFactory { public Node createLogoStatic(Stage stage) { final Image logoImage = new Image(staticLogoImagePath); final ImageView logoView = new ImageView(logoImage); logoView.setPreserveRatio(true); fitStaticLogo(logoView, stage); stage.heightProperty().addListener((observable, oldValue, newValue) -> { fitStaticLogo(logoView, stage); }); return logoView; }  Node createLogoAnimated(Stage stage); Node createLogoStatic(Stage stage);  }
@Test void shouldCreateStaticLogo() { ReadOnlyDoubleProperty mockHeightProperty = new SimpleDoubleProperty(); when(stage.getHeight()).thenReturn(100d); when(stage.getWidth()).thenReturn(100d); when(stage.heightProperty()).thenReturn(mockHeightProperty); LogoFactory logoFactory = LogoFactory.getInstance(); ImageView result = (ImageView) logoFactory.createLogoStatic(stage); assertTrue(result.getImage().getUrl().contains(LogoFactory.staticLogoImagePath)); }
@Test void shouldResizeStaticLogo() { DoubleProperty mockHeightProperty = new SimpleDoubleProperty(); when(stage.getHeight()).thenReturn(100d).thenReturn(50d); when(stage.getWidth()).thenReturn(100d); when(stage.heightProperty()).thenReturn(mockHeightProperty); LogoFactory logoFactory = LogoFactory.getInstance(); ImageView result = (ImageView) logoFactory.createLogoStatic(stage); assertEquals(10d, result.getFitHeight()); assertEquals(50d, result.getFitWidth()); mockHeightProperty.set(50d); assertEquals(5d, result.getFitHeight()); assertEquals(50d, result.getFitWidth()); }