// Path: src/test/java/com/blazemeter/jmeter/debugger/TestProvider.java
// public class TestProvider implements TestTreeProvider {
//     private JMeterTreeModel mdl = new JMeterTreeModel();
// 
//     public TestProvider() throws IllegalUserActionException, IOException {
//         File file = new File(this.getClass().getResource("/com/blazemeter/jmeter/debugger/sample1.jmx").getFile());
//         String basedir = TestJMeterUtils.fixWinPath(file.getParentFile().getAbsolutePath());
// 
//         File f = new File(basedir + "/sample1.jmx");
//         mdl.addSubTree(SaveService.loadTree(f), (JMeterTreeNode) mdl.getRoot());
//     }
// 
//     public TestProvider(String path, String name) throws IllegalUserActionException, IOException {
//         File file = new File(this.getClass().getResource(path).getFile());
//         String basedir = TestJMeterUtils.fixWinPath(file.getParentFile().getAbsolutePath());
// 
//         File f = new File(basedir + '/' + name);
//         mdl.addSubTree(SaveService.loadTree(f), (JMeterTreeNode) mdl.getRoot());
//     }
// 
//     @Override
//     public HashTree getTestTree() {
//         return mdl.getTestPlan();
//     }
// 
//     public AbstractThreadGroup getTG(int i) {
//         SearchClass<AbstractThreadGroup> searcher = new SearchClass<>(AbstractThreadGroup.class);
//         mdl.getTestPlan().traverse(searcher);
//         Collection<AbstractThreadGroup> searchResults = searcher.getSearchResults();
//         return searchResults.toArray(new AbstractThreadGroup[0])[i];
//     }
// 
//     public JMeterTreeModel getTreeModel() {
//         return mdl;
//     }
// }
// 
// Path: src/main/java/com/blazemeter/jmeter/debugger/elements/SamplerDebug.java
// public class SamplerDebug extends AbstractDebugElement<Sampler> implements Sampler {
// 
//     @Override
//     public SampleResult sample(Entry e) {
//         prepareBean();
//         getHook().stepOn(this);
//         return wrapped.sample(e);
//     }
// 
//     @Override
//     public void setThreadContext(JMeterContext inthreadContext) {
//         wrapped.setThreadContext(inthreadContext);
//     }
// 
//     @Override
//     public void setThreadName(String inthreadName) {
//         wrapped.setThreadName(inthreadName);
//     }
// 
//     @Override
//     public void setProperty(JMeterProperty property) {
//         super.setProperty(property);
//         if (wrapped != null && !TestElement.GUI_CLASS.equals(property.getName())) {
//             wrapped.setProperty(property);
//         }
//     }
// }


import com.blazemeter.jmeter.debugger.TestProvider;
import com.blazemeter.jmeter.debugger.elements.SamplerDebug;
import kg.apc.emulators.TestJMeterUtils;
import org.apache.jmeter.exceptions.IllegalUserActionException;
import org.apache.jmeter.functions.TimeFunction;
import org.apache.jmeter.gui.GuiPackage;
import org.apache.jmeter.gui.MainFrame;
import org.apache.jmeter.gui.action.ActionRouter;
import org.apache.jmeter.gui.tree.JMeterTreeListener;
import org.apache.jmeter.gui.tree.JMeterTreeModel;
import org.apache.jmeter.gui.util.JMeterToolBar;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.visualizers.RenderAsHTML;
import org.apache.jorphan.collections.HashTree;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
            return;
        }
        String actions = ActionRouter.class.getProtectionDomain().getCodeSource().getLocation().getFile();
        String renderers = RenderAsHTML.class.getProtectionDomain().getCodeSource().getLocation().getFile();
        JMeterUtils.setProperty("search_paths", actions + ";" + renderers);
        TestProvider prov = new TestProvider();
        JMeterTreeModel mdl = prov.getTreeModel();
        JMeterTreeListener a = new JMeterTreeListener();
        a.setActionHandler(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                log.debug("Action " + actionEvent);
            }
        });
        a.setModel(mdl);
        GuiPackage.getInstance(a, mdl);

        DebuggerDialog obj = new DebuggerDialogMock(prov.getTreeModel());
        obj.componentShown(null);
        obj.started();
        obj.statusRefresh(JMeterContextService.getContext());
        obj.frozenAt(new SamplerDebug());
        obj.continuing();
        obj.stopped();
        obj.componentHidden(null);
    }

    @Test
    public void displayGUI() throws InterruptedException, IOException, IllegalUserActionException {
        if (!GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) {
// Path: src/test/java/com/blazemeter/jmeter/debugger/TestProvider.java
// public class TestProvider implements TestTreeProvider {
//     private JMeterTreeModel mdl = new JMeterTreeModel();
// 
//     public TestProvider() throws IllegalUserActionException, IOException {
//         File file = new File(this.getClass().getResource("/com/blazemeter/jmeter/debugger/sample1.jmx").getFile());
//         String basedir = TestJMeterUtils.fixWinPath(file.getParentFile().getAbsolutePath());
// 
//         File f = new File(basedir + "/sample1.jmx");
//         mdl.addSubTree(SaveService.loadTree(f), (JMeterTreeNode) mdl.getRoot());
//     }
// 
//     public TestProvider(String path, String name) throws IllegalUserActionException, IOException {
//         File file = new File(this.getClass().getResource(path).getFile());
//         String basedir = TestJMeterUtils.fixWinPath(file.getParentFile().getAbsolutePath());
// 
//         File f = new File(basedir + '/' + name);
//         mdl.addSubTree(SaveService.loadTree(f), (JMeterTreeNode) mdl.getRoot());
//     }
// 
//     @Override
//     public HashTree getTestTree() {
//         return mdl.getTestPlan();
//     }
// 
//     public AbstractThreadGroup getTG(int i) {
//         SearchClass<AbstractThreadGroup> searcher = new SearchClass<>(AbstractThreadGroup.class);
//         mdl.getTestPlan().traverse(searcher);
//         Collection<AbstractThreadGroup> searchResults = searcher.getSearchResults();
//         return searchResults.toArray(new AbstractThreadGroup[0])[i];
//     }
// 
//     public JMeterTreeModel getTreeModel() {
//         return mdl;
//     }
// }
// 
// Path: src/main/java/com/blazemeter/jmeter/debugger/elements/SamplerDebug.java
// public class SamplerDebug extends AbstractDebugElement<Sampler> implements Sampler {
// 
//     @Override
//     public SampleResult sample(Entry e) {
//         prepareBean();
//         getHook().stepOn(this);
//         return wrapped.sample(e);
//     }
// 
//     @Override
//     public void setThreadContext(JMeterContext inthreadContext) {
//         wrapped.setThreadContext(inthreadContext);
//     }
// 
//     @Override
//     public void setThreadName(String inthreadName) {
//         wrapped.setThreadName(inthreadName);
//     }
// 
//     @Override
//     public void setProperty(JMeterProperty property) {
//         super.setProperty(property);
//         if (wrapped != null && !TestElement.GUI_CLASS.equals(property.getName())) {
//             wrapped.setProperty(property);
//         }
//     }
// }


// Path: src/test/java/com/blazemeter/jmeter/debugger/gui/DebuggerDialogTest.java
import com.blazemeter.jmeter.debugger.TestProvider;
import com.blazemeter.jmeter.debugger.elements.SamplerDebug;
import kg.apc.emulators.TestJMeterUtils;
import org.apache.jmeter.exceptions.IllegalUserActionException;
import org.apache.jmeter.functions.TimeFunction;
import org.apache.jmeter.gui.GuiPackage;
import org.apache.jmeter.gui.MainFrame;
import org.apache.jmeter.gui.action.ActionRouter;
import org.apache.jmeter.gui.tree.JMeterTreeListener;
import org.apache.jmeter.gui.tree.JMeterTreeModel;
import org.apache.jmeter.gui.util.JMeterToolBar;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.visualizers.RenderAsHTML;
import org.apache.jorphan.collections.HashTree;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

            return;
        }
        String actions = ActionRouter.class.getProtectionDomain().getCodeSource().getLocation().getFile();
        String renderers = RenderAsHTML.class.getProtectionDomain().getCodeSource().getLocation().getFile();
        JMeterUtils.setProperty("search_paths", actions + ";" + renderers);
        TestProvider prov = new TestProvider();
        JMeterTreeModel mdl = prov.getTreeModel();
        JMeterTreeListener a = new JMeterTreeListener();
        a.setActionHandler(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                log.debug("Action " + actionEvent);
            }
        });
        a.setModel(mdl);
        GuiPackage.getInstance(a, mdl);

        DebuggerDialog obj = new DebuggerDialogMock(prov.getTreeModel());
        obj.componentShown(null);
        obj.started();
        obj.statusRefresh(JMeterContextService.getContext());
        obj.frozenAt(new SamplerDebug());
        obj.continuing();
        obj.stopped();
        obj.componentHidden(null);
    }

    @Test
    public void displayGUI() throws InterruptedException, IOException, IllegalUserActionException {
        if (!GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) {
            TestProvider prov = new TestProvider("/com/blazemeter/jmeter/debugger/vars.jmx", "vars.jmx");