package io.tromba.testdriver.environment;

import java.util.List;

/**
 * Simple URL-based handler for multi-variate tests.
 */
public class WebDriverUrlMvtHandler implements MvtHandler {

    private List<String> mvts;
    private String mvtGetParameter = "?mvt=";
    private String url;

    public WebDriverUrlMvtHandler(String url) {
        this.url = url;
    }

    public List<String> getMvts() {
        return mvts;
    }

    public void setMvts(List<String> mvts) {
        this.mvts = mvts;
    }

    public String addMvts(List<String> mvts) {
        // fudge - use a lib
        for (String mvt: mvts) {
            if (!url.contains("?mvt=")) {
                if (!url.endsWith("/")) {
                    url += "/";
                }
                url += mvtGetParameter;
            }
            url += mvt;
        }
        return url;
    }
}

@@ -556,37 +556,8 @@
 ) %7B%0A
-        // fudge - use a lib%0A
     
@@ -597,25 +597,24 @@
         if (
-!
 url.contains
@@ -620,15 +620,70 @@
 s(%22?
-mvt=%22))
+%22)) %7B%0A                url += %22&mvt=%22 + mvt;%0A            %7D else
  %7B%0A 
@@ -796,31 +796,29 @@
  url += 
+%22?
 mvt
-GetParameter
+=%22 + mvt
 ;%0A      
@@ -829,32 +829,8 @@
   %7D%0A
-            url += mvt;%0A
     

make all mvt tests pass