package com.griddynamics.jagger.user;

import com.griddynamics.jagger.engine.e1.collector.InformationCollectorProvider;
import com.griddynamics.jagger.engine.e1.collector.ValidatorProvider;
import com.griddynamics.jagger.engine.e1.scenario.*;
import com.griddynamics.jagger.invoker.ScenarioFactory;

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

/**
 * Created with IntelliJ IDEA.
 * User: kgribov
 * Date: 8/23/13
 * Time: 2:35 PM
 * To change this template use File | Settings | File Templates.
 */
public class TestDescription {

    private List<ValidatorProvider> validators;

    private List<KernelSideObjectProvider<ScenarioCollector<Object,Object,Object>>> metrics;
    private List<KernelSideObjectProvider<ScenarioCollector<Object,Object,Object>>> standardCollectors;

    private ScenarioFactory<Object, Object, Object> scenarioFactory;
    private Calibrator calibrator = new OneNodeCalibrator();
    private String description = "";
    private String version;

    public List<KernelSideObjectProvider<ScenarioCollector<Object,Object,Object>>> getStandardCollectors() {
        return standardCollectors;
    }

    public void setStandardCollectors(List<KernelSideObjectProvider<ScenarioCollector<Object, Object, Object>>> standardCollectors) {
        this.standardCollectors = standardCollectors;
    }

    public Calibrator getCalibrator() {
        return calibrator;
    }

    public void setCalibrator(Calibrator calibrator) {
        this.calibrator = calibrator;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<ValidatorProvider> getValidators() {
        return validators;
    }

    public void setValidators(List<ValidatorProvider> validators) {
        this.validators = validators;
    }

    public List<KernelSideObjectProvider<ScenarioCollector<Object,Object,Object>>> getMetrics() {
        return metrics;
    }

    public void setMetrics(List<KernelSideObjectProvider<ScenarioCollector<Object,Object,Object>>> metrics) {
        this.metrics = metrics;
    }

    public ScenarioFactory<Object, Object, Object> getScenarioFactory() {
        return scenarioFactory;
    }

    public void setScenarioFactory(ScenarioFactory<Object, Object, Object> scenarioFactory) {
        this.scenarioFactory = scenarioFactory;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public WorkloadTask generatePrototype(){
        WorkloadTask prototype = new WorkloadTask();
        prototype.setCalibrator(calibrator);
        prototype.setDescription(description);
        prototype.setScenarioFactory(scenarioFactory);

        List<KernelSideObjectProvider<ScenarioCollector<Object,Object,Object>>> listeners = new ArrayList<KernelSideObjectProvider<ScenarioCollector<Object,Object,Object>>>(metrics.size()+ standardCollectors.size()+1);
        listeners.addAll(standardCollectors);
        listeners.addAll(metrics);

        InformationCollectorProvider informationCollector = new InformationCollectorProvider();
        informationCollector.setValidators(validators);
        listeners.add(informationCollector);

        prototype.setCollectors(listeners);

        return prototype;
    }
}

@@ -973,16 +973,41 @@
 version;
+%0A    private String name;
 %0A%0A    pu
@@ -2572,32 +2572,162 @@
 version;%0A    %7D%0A%0A
+    public String getName() %7B%0A        return name;%0A    %7D%0A%0A    public void setName(String name) %7B%0A        this.name = name;%0A    %7D%0A%0A
     public Workl
@@ -2954,16 +2954,88 @@
 actory);
+%0A        prototype.setName(name);%0A        prototype.setVersion(version);
 %0A%0A      

Fix parsing name attribute in testDescription