package be.iminds.ilabt.jfed.connectivity_tester;


import be.iminds.ilabt.jfed.lowlevel.GeniUserProvider;
import be.iminds.ilabt.jfed.lowlevel.TestbedInfoSource;
import be.iminds.ilabt.jfed.lowlevel.api_wrapper.impl.AutomaticUserAndSliceApiWrapper;
import be.iminds.ilabt.jfed.fedmon.webapi.service.json.*;
import be.iminds.ilabt.jfed.lowlevel.authority.AuthorityFinder;
import be.iminds.ilabt.jfed.lowlevel.connection.JFedConnection;
import be.iminds.ilabt.jfed.lowlevel.connection.JFedConnectionProvider;
import be.iminds.ilabt.jfed.preferences.JFedPreferences;
import be.iminds.ilabt.jfed.util.JavaFXLogger;

import javax.inject.Inject;
import javax.inject.Singleton;

/**
 * User: twalcari
 * Date: 12/11/2014
 * Time: 12:21
 */
@Singleton
public class ConnectivityTestFactory {

    private final GeniUserProvider geniUserProvider;
    private final TestbedInfoSource testbedInfoSource;
    private final AuthorityFinder authorityFinder;
    private final JavaFXLogger javaFXLogger;
    private final JFedConnectionProvider jFedConnectionProvider;
    private final JFedPreferences jFedPreferences;
    private final AutomaticUserAndSliceApiWrapper.AutomaticUserAndSliceApiWrapperFactory automaticUserAndSliceApiWrapperFactory;


    @Inject
    public ConnectivityTestFactory(GeniUserProvider geniUserProvider, TestbedInfoSource testbedInfoSource, AuthorityFinder authorityFinder,
                                   JavaFXLogger javaFXLogger, JFedConnectionProvider jFedConnectionProvider,
                                   JFedPreferences jFedPreferences,
                                   AutomaticUserAndSliceApiWrapper.AutomaticUserAndSliceApiWrapperFactory automaticUserAndSliceApiWrapperFactory) {
        this.geniUserProvider = geniUserProvider;
        this.testbedInfoSource = testbedInfoSource;
        this.authorityFinder = authorityFinder;
        this.javaFXLogger = javaFXLogger;
        this.jFedConnectionProvider = jFedConnectionProvider;
        this.jFedPreferences = jFedPreferences;
        this.automaticUserAndSliceApiWrapperFactory = automaticUserAndSliceApiWrapperFactory;
    }

    public HasIPv4AddressTest createHasIPv4AddressTest() {
        return new HasIPv4AddressTest();
    }

    public HasIPv6AddressTest createHasIPv6AddressTest() {
        return new HasIPv6AddressTest();
    }

    public SslHostAndPortTest createSslHostAndPortTest(String hostname, int port, String description, String category) {
        return new SslHostAndPortTest(hostname, port, description, category, testbedInfoSource);

    }

    public GetSACredentialTest createGetSACredentialTest() {
        return new GetSACredentialTest(geniUserProvider, jFedConnectionProvider, javaFXLogger, jFedPreferences, automaticUserAndSliceApiWrapperFactory);
    }

    public GetVersionTest createGetVersionTest(String authUrn) {
        return new GetVersionTest(authUrn, testbedInfoSource, authorityFinder, geniUserProvider, javaFXLogger, jFedConnectionProvider, jFedPreferences);
    }

    public GetVersionTest createGetVersionTest(Server auth, JFedConnection.ProxyInfo proxyInfo, int version) {
        return new GetVersionTest(auth, proxyInfo, version, geniUserProvider, javaFXLogger, jFedConnectionProvider, jFedPreferences);

    }
}
