package de.vogel612.helper.ui;

import static org.mockito.Mockito.*;

import de.vogel612.helper.ui.jfx.JFXDialog;
import javafx.application.Platform;
import javafx.stage.Stage;
import org.junit.Before;
import org.junit.Test;
import org.testfx.framework.junit.ApplicationTest;

@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public class OverviewPresenterTest extends ApplicationTest {

    private OverviewView overviewView;
    private JFXDialog dialog;
    private ProjectView projectView;

    private OverviewPresenter cut;

    @Before
    public void beforeTest() {
        overviewView = mock(OverviewView.class);
        dialog = mock(JFXDialog.class);
        projectView = mock(ProjectView.class);

        cut = new OverviewPresenter(overviewView, projectView);
        reset(overviewView);
    }

    @Test
    public void show_callsShow_onView() {
        cut.show();
        verify(overviewView).show();
        verifyNoMoreInteractions(overviewView, dialog);
    }

    @Test
    public void onException_delegatesToView() {
        final Exception e = mock(Exception.class);
        final String message = "testingmessage";
        final String errorMessage = "alsdkj";
        doReturn(errorMessage).when(e).getMessage();

        cut.onException(e, message);

        Platform.runLater(() -> verify(dialog).info(message, errorMessage));
        verify(e).getMessage();
        sleep(60); // await verification
        verifyNoMoreInteractions(overviewView, dialog);
    }

    @Override
    public void start(Stage stage) throws Exception {
        // no-op ... probably ...
    }
}

@@ -29,46 +29,8 @@
 i;%0A%0A
-import static org.mockito.Mockito.*;%0A%0A
 impo
@@ -73,44 +73,8 @@
 og;%0A
-import javafx.application.Platform;%0A
 impo
@@ -196,16 +196,54 @@
 nTest;%0A%0A
+import static org.mockito.Mockito.*;%0A%0A
 @Suppres
@@ -604,20 +604,19 @@
 ialog = 
-mock
+spy
 (JFXDial
@@ -618,21 +618,22 @@
 XDialog.
-class
+DIALOG
 );%0A     
@@ -839,32 +839,32 @@
     cut.show();%0A
+
         verify(o
@@ -951,517 +951,8 @@
  %7D%0A%0A
-    @Test%0A    public void onException_delegatesToView() %7B%0A        final Exception e = mock(Exception.class);%0A        final String message = %22testingmessage%22;%0A        final String errorMessage = %22alsdkj%22;%0A        doReturn(errorMessage).when(e).getMessage();%0A%0A        cut.onException(e, message);%0A%0A        Platform.runLater(() -%3E verify(dialog).info(message, errorMessage));%0A        verify(e).getMessage();%0A        sleep(60); // await verification%0A        verifyNoMoreInteractions(overviewView, dialog);%0A    %7D%0A%0A
     

drop onException from tests