package de.qualicen.maven.ui_tests;

import com.saucelabs.common.SauceOnDemandAuthentication;

import org.junit.*;
import org.junit.rules.TestName;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import com.saucelabs.junit.ConcurrentParameterized;
import com.saucelabs.junit.SauceOnDemandTestWatcher;

import java.net.URL;
import java.util.LinkedList;
import java.util.concurrent.TimeUnit;

import com.saucelabs.common.SauceOnDemandSessionIdProvider;

@Ignore
//@RunWith(ConcurrentParameterized.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestBase implements SauceOnDemandSessionIdProvider {
	public static String username = System.getenv("SAUCE_USERNAME");
    public static String accesskey = System.getenv("SAUCE_ACCESS_KEY");
    public static String seleniumURI;
    public static String buildTag;
    public static final String tunnelidentifier = System.getenv("TRAVIS_JOB_NUMBER");
   
    public SauceOnDemandAuthentication authentication = new SauceOnDemandAuthentication();

    //Mark the Sauce Job as passed/failed when the test succeeds or fails
    @Rule
    public SauceOnDemandTestWatcher resultReportingTestWatcher = new SauceOnDemandTestWatcher(this, authentication);

    @Rule
    public TestName name = new TestName() {
        public String getMethodName() {
            return String.format("%s", super.getMethodName());
        }
    };

    protected String browser;
    protected String os;
    protected String version;
    protected String deviceName;
    protected String deviceOrientation;
    protected String sessionId;
    protected WebDriver driver;

 
    // Constructor for test instances

    public TestBase(String os, String version, String browser, String deviceName, String deviceOrientation) {
        super();
        this.os = os;
        this.version = version;
        this.browser = browser;
        this.deviceName = deviceName;
        this.deviceOrientation = deviceOrientation;
    }

    // Browser configurations
//    @ConcurrentParameterized.Parameters
//    public static LinkedList<String[]> browsersStrings() {
//        LinkedList<String[]> browsers = new LinkedList<String[]>();
//
//        browsers.add(new String[]{"Windows 10", "14.14393", "MicrosoftEdge", null, null});
//        //browsers.add(new String[]{"Windows 10", "11.0", "internet explorer", null, null});
//        return browsers;
//    }

 
    @Before
    public void setUp() throws Exception {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        
        this.browser = "MicrosoftEdge";
        this.version = "14.14393";
        this.os = "Windows 10";
        this.deviceName = null; 
        this.deviceOrientation = null; 

        capabilities.setCapability(CapabilityType.BROWSER_NAME, browser);
        capabilities.setCapability(CapabilityType.VERSION, version);
        capabilities.setCapability("deviceName", deviceName);
        capabilities.setCapability("device-orientation", deviceOrientation);
        capabilities.setCapability("platform", os);
        capabilities.setCapability("tunnel-identifier", tunnelidentifier); 

        String methodName = name.getMethodName();
        capabilities.setCapability("name", methodName);

        if (buildTag != null) {
            capabilities.setCapability("build", buildTag);
        }
        this.driver = new RemoteWebDriver(new URL("https://" + username+ ":" + accesskey + seleniumURI +"/wd/hub"), capabilities);
        
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);

        this.sessionId = (((RemoteWebDriver) driver).getSessionId()).toString();
    }

    @After
    public void tearDown() throws Exception {
        driver.quit();
    }

    public String getSessionId() {
        return sessionId;
    }

    @BeforeClass
    public static void setupClass() {
        // Get the uri to send the commands to
        seleniumURI = "@ondemand.saucelabs.com:443";
        
        // Set the buildTag to the Travis Build number 
        buildTag = System.getenv("TRAVIS_BUILD_NUMBER");
        if (buildTag == null) {
            buildTag = System.getenv("SAUCE_BUILD_NAME");
        }
    }
}

@@ -214,16 +214,107 @@
 orters;%0A
+import org.junit.runners.Parameterized;%0Aimport org.junit.runners.Parameterized.Parameters;%0A
 import o
@@ -764,18 +764,16 @@
 @Ignore%0A
-//
 @RunWith
@@ -773,26 +773,16 @@
 RunWith(
-Concurrent
 Paramete
@@ -2284,39 +2284,13 @@
 ons%0A
-//
     @
-ConcurrentParameterized.
 Para
@@ -2296,18 +2296,16 @@
 ameters%0A
-//
     publ
@@ -2355,18 +2355,16 @@
 ngs() %7B%0A
-//
         
@@ -2427,13 +2427,9 @@
 ();%0A
-//%0A//
+%0A
     
@@ -2507,34 +2507,32 @@
 , null, null%7D);%0A
-//
         //browse
@@ -2608,18 +2608,16 @@
 null%7D);%0A
-//
         
@@ -2633,18 +2633,16 @@
 owsers;%0A
-//
     %7D%0A%0A 
@@ -2770,196 +2770,8 @@
 s();
-%0A        %0A        this.browser = %22MicrosoftEdge%22;%0A        this.version = %2214.14393%22;%0A        this.os = %22Windows 10%22;%0A        this.deviceName = null; %0A        this.deviceOrientation = null;
  %0A%0A 

Change concurrent to sequential execution