package be.iminds.ilabt.jfed.connectivity_tester;

import be.iminds.ilabt.jfed.BaseGuiModule;
import be.iminds.ilabt.jfed.experimenter_gui.ExperimenterModule;
import be.iminds.ilabt.jfed.experimenter_gui.Launch;
import be.iminds.ilabt.jfed.highlevel.HighLevelModule;
import be.iminds.ilabt.jfed.highlevel.LowLevelModule;
import be.iminds.ilabt.jfed.highlevel.UserLoginModelModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import javafx.embed.swing.JFXPanel;

import java.util.List;

/**
 * User: twalcari
 * Date: 1/3/14
 * Time: 11:04 AM
 */
public class DoTests {

    public static void main(String[] args) {
        //initialize JavaFX-toolkit
        new JFXPanel();


        Injector injector = Guice.createInjector(new LowLevelModule(), new HighLevelModule(),
                /*new SfaOnlyExperimentModule(),*/ new ExperimenterModule(new Launch()), new UserLoginModelModule(true), new BaseGuiModule());
        ConnectivityTestSuite connectivityTestSuite = injector.getInstance(ConnectivityTestSuite.class);
        List<ConnectivityTest> tests = connectivityTestSuite.getTests();

        for (ConnectivityTest test : tests) {
            try {
                ConnectivityTest.ConnectivityTestResult result = test.call();
                System.out.println(test.getName() + " status: " + result.getStatus());
                if (result.getMessage() != null)
                    System.out.println(test.getName() + " message: " + result.getMessage());
                if (result.getException() != null)
                    System.out.println(test.getName() + " exception: " + result.getException());
            } catch (Exception e) {
                System.out.println(test.getName() + " threw an exception: " + e.getMessage());
                e.printStackTrace();
            }
        }

    }
}
