|
|
@@ -5,12 +5,20 @@ import static org.mockito.Mockito.*;
|
|
|
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
+import org.junit.jupiter.api.extension.ExtendWith;
|
|
|
+import org.junit.platform.runner.JUnitPlatform;
|
|
|
+import org.junit.runner.RunWith;
|
|
|
import org.leumasjaffe.mock.MockObserverListener;
|
|
|
import org.leumasjaffe.observer.ObserverDispatch;
|
|
|
import org.leumasjaffe.recipe.model.Amount;
|
|
|
import org.leumasjaffe.recipe.model.Ingredient;
|
|
|
+import org.mockito.Spy;
|
|
|
+import org.mockito.junit.jupiter.MockitoExtension;
|
|
|
|
|
|
+@ExtendWith(MockitoExtension.class)
|
|
|
+@RunWith(JUnitPlatform.class)
|
|
|
class IngredientPanelTest extends SwingTestCase {
|
|
|
+ @Spy MockObserverListener listener;
|
|
|
Ingredient stuff;
|
|
|
IngredientPanel panel;
|
|
|
|
|
|
@@ -18,6 +26,9 @@ class IngredientPanelTest extends SwingTestCase {
|
|
|
void setUp() {
|
|
|
stuff = new Ingredient("Onions", "Sliced", new Amount("100 g"));
|
|
|
panel = new IngredientPanel(stuff);
|
|
|
+ listener.setObserved(stuff);
|
|
|
+ // setObserved invokes our callback.
|
|
|
+ clearInvocations(listener);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
@@ -46,13 +57,9 @@ class IngredientPanelTest extends SwingTestCase {
|
|
|
// TODO: I need to add hook-ups for the rest of the fields, too
|
|
|
@Test
|
|
|
void testViewUpdateSendsNotify() {
|
|
|
- final MockObserverListener mock = spy(MockObserverListener.class);
|
|
|
- mock.setObserved(stuff);
|
|
|
- verify(mock, times(1)).updateWasSignalled();
|
|
|
-
|
|
|
panel.getTxtName().setText("Bacon");
|
|
|
waitForSwing();
|
|
|
- verify(mock, times(2)).updateWasSignalled();
|
|
|
+ verify(listener).updateWasSignalled();
|
|
|
}
|
|
|
|
|
|
}
|