// Path: src/main/java/com/kasirgalabs/etumulator/processor/Stack.java
// @Singleton
// public class Stack implements Observable {
//     private final LinkedList<Integer> list = new LinkedList<>();
//     private final Dispatcher dispatcher;
// 
//     public Stack() {
//         this.dispatcher = new BaseDispatcher();
//     }
// 
//     @Inject
//     public Stack(Dispatcher dispatcher) {
//         this.dispatcher = dispatcher;
//     }
// 
//     @Override
//     public void addObserver(Observer observer) {
//         dispatcher.addObserver(observer);
//     }
// 
//     public void push(Integer item) {
//         list.push(item);
//         dispatcher.notifyObservers(Stack.class, "push");
//     }
// 
//     public int pop() {
//         if(list.isEmpty()) {
//             return (int) (Math.random() * Integer.MAX_VALUE);
//         }
//         int result = list.pop();
//         dispatcher.notifyObservers(Stack.class, "pop");
//         return result;
//     }
// 
//     public int peek() {
//         return list.peek();
//     }
// 
//     public void reset() {
//         list.clear();
//         dispatcher.notifyObservers(Stack.class, "clear");
//     }
// }
// 
// Path: src/main/java/com/kasirgalabs/etumulator/util/GUISafeDispatcher.java
// public class GUISafeDispatcher extends BaseDispatcher {
//     @Override
//     public void notifyObservers(Class<?> clazz, Object arg) {
//         final CountDownLatch latch = new CountDownLatch(1);
//         Platform.runLater(() -> {
//             super.notifyObservers(clazz, arg);
//             latch.countDown();
//         });
//         try {
//             if(!Platform.isFxApplicationThread()) {
//                 latch.await();
//             }
//         } catch(InterruptedException ex) {
//             throw new CancellationException();
//         }
//     }
// 
//     @Override
//     public void notifyObservers(Class<?> clazz) {
//         notifyObservers(clazz, null);
//     }
// }


import com.kasirgalabs.etumulator.processor.Stack;
import com.kasirgalabs.etumulator.util.GUISafeDispatcher;
import java.io.IOException;
import java.util.Random;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.fxml.FXMLLoader;
import org.junit.Test;
package com.kasirgalabs.etumulator.navigator;


public class StackTabTest {
    private Stack stack;
    private Navigator navigator;
    private StackTab stackTab;

    public StackTabTest() throws IOException, InterruptedException, ExecutionException,
            TimeoutException {
        assert !Platform.isFxApplicationThread();
        new JFXPanel();

        FutureTask<Void> futureTask = new FutureTask<>(() -> {
// Path: src/main/java/com/kasirgalabs/etumulator/processor/Stack.java
// @Singleton
// public class Stack implements Observable {
//     private final LinkedList<Integer> list = new LinkedList<>();
//     private final Dispatcher dispatcher;
// 
//     public Stack() {
//         this.dispatcher = new BaseDispatcher();
//     }
// 
//     @Inject
//     public Stack(Dispatcher dispatcher) {
//         this.dispatcher = dispatcher;
//     }
// 
//     @Override
//     public void addObserver(Observer observer) {
//         dispatcher.addObserver(observer);
//     }
// 
//     public void push(Integer item) {
//         list.push(item);
//         dispatcher.notifyObservers(Stack.class, "push");
//     }
// 
//     public int pop() {
//         if(list.isEmpty()) {
//             return (int) (Math.random() * Integer.MAX_VALUE);
//         }
//         int result = list.pop();
//         dispatcher.notifyObservers(Stack.class, "pop");
//         return result;
//     }
// 
//     public int peek() {
//         return list.peek();
//     }
// 
//     public void reset() {
//         list.clear();
//         dispatcher.notifyObservers(Stack.class, "clear");
//     }
// }
// 
// Path: src/main/java/com/kasirgalabs/etumulator/util/GUISafeDispatcher.java
// public class GUISafeDispatcher extends BaseDispatcher {
//     @Override
//     public void notifyObservers(Class<?> clazz, Object arg) {
//         final CountDownLatch latch = new CountDownLatch(1);
//         Platform.runLater(() -> {
//             super.notifyObservers(clazz, arg);
//             latch.countDown();
//         });
//         try {
//             if(!Platform.isFxApplicationThread()) {
//                 latch.await();
//             }
//         } catch(InterruptedException ex) {
//             throw new CancellationException();
//         }
//     }
// 
//     @Override
//     public void notifyObservers(Class<?> clazz) {
//         notifyObservers(clazz, null);
//     }
// }


// Path: src/test/java/com/kasirgalabs/etumulator/navigator/StackTabTest.java
import com.kasirgalabs.etumulator.processor.Stack;
import com.kasirgalabs.etumulator.util.GUISafeDispatcher;
import java.io.IOException;
import java.util.Random;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.fxml.FXMLLoader;
import org.junit.Test;

package com.kasirgalabs.etumulator.navigator;


public class StackTabTest {
    private Stack stack;
    private Navigator navigator;
    private StackTab stackTab;

    public StackTabTest() throws IOException, InterruptedException, ExecutionException,
            TimeoutException {
        assert !Platform.isFxApplicationThread();
        new JFXPanel();

        FutureTask<Void> futureTask = new FutureTask<>(() -> {
            stack = new Stack(new GUISafeDispatcher());