package io.tromba.testdriver.environment;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Simple environment handler based on URLs.
 */
public class UrlEnvironmentHandler implements EnvironmentHandler {

    public static final String MAGIC_STRING = "%ENV";
    private Map<String, String> environmentDns;
    private List<String> urls;

    public UrlEnvironmentHandler(List<String> urls, Map<String, String> environment) {
        setUrls(urls);
        environmentDns = environment;
    }

    public UrlEnvironmentHandler(String environmentFileName) {
        throw new RuntimeException("not implemented");
    }

    public UrlEnvironmentHandler() {
        urls = new ArrayList<String>();
    }

    public void setUrls(List<String> urls) {
        this.urls = urls;
    }

    public List<String> getStartUrls(String environment) {
        List<String> formattedUrls = new ArrayList<String>();

        String replacement = environmentDns.get(environment);
        if (null == replacement) {
            replacement = "";
        }
        for (String url : urls) {
            formattedUrls.add(url.replace(MAGIC_STRING, replacement));
        }
        return formattedUrls;
    }
}

@@ -737,81 +737,349 @@
     
-public void setUrls(List%3CString%3E urls) %7B%0A        this.urls = urls;%0A    %7D%0A
+/**%0A     * Set the list of URLs.%0A     * @param urls the URLs to set.%0A     */%0A    public void setUrls(List%3CString%3E urls) %7B%0A        this.urls = urls;%0A    %7D%0A%0A    /**%0A     * Get the list of start URLs.%0A     * @param environment The environment for which the URLs are needed.%0A     * @return the list of URLs for the specified environment.%0A     */
 %0A   

add javadoc to url env handler