MenuActions { @SuppressWarnings("UnusedParameters") protected void showPreferences(ActionEvent actionEvent) { if (preferences == null) { preferences = new PreferencesWindow(overlay); } preferences.show(); } MenuActions(final MainOverlay ol, final ToplevelPane tl);   }
@Test public void showPreferencesTest() throws Exception { ToplevelPane mockToplevelPane = mock(ToplevelPane.class); PreferencesWindow mockPreferencesWindow = mock(PreferencesWindow.class); whenNew(PreferencesWindow.class).withArguments(any()).thenReturn(mockPreferencesWindow); MenuActions menuActions = new MenuActions(mockMainOverlay, mockToplevelPane); menuActions.showPreferences(mockEvent); verify(mockPreferencesWindow, times(1)).show(); }