package net.ssehub.kernel_haven.test_utils;

import java.util.Properties;

import net.ssehub.kernel_haven.SetUpException;
import net.ssehub.kernel_haven.analysis.AnalysisComponent;
import net.ssehub.kernel_haven.util.BlockingQueue;

/**
 * An analysis component that provides static data. Useful as input for testing other components.
 * 
 * @param <T> The type of data to create.
 * 
 * @author Adam
 */
public class TestAnalysisComponentProvider<T> extends AnalysisComponent<T> {

    private BlockingQueue<T> data;
    
    /**
     * Creates a new instance with the given data.
     * 
     * @param data The data that this component should "create" and pass to the next component.
     * 
     * @throws SetUpException Shouldn't happen.
     */
    public TestAnalysisComponentProvider(Iterable<T> data) throws SetUpException {
        super(new TestConfiguration(new Properties()));
        this.data = new BlockingQueue<>();
        for (T t : data) {
            this.data.add(t);
        }
        this.data.end();
    }
    
    /**
     * Creates a new instance with the given data.
     * 
     * @param data The data that this component should "create" and pass to the next component.
     * 
     * @throws SetUpException Shouldn't happen.
     */
    public TestAnalysisComponentProvider(T data) throws SetUpException {
        super(new TestConfiguration(new Properties()));
        this.data = new BlockingQueue<>();
        this.data.add(data);
        this.data.end();
    }


    @Override
    protected void execute() {
        for (T element : this.data) {
            addResult(element);
        }
    }

    @Override
    public String getResultName() {
        return "TestResult";
    }
    
}

@@ -1062,16 +1062,555 @@
 %7D%0D%0A    %0D
+%0A    /**%0D%0A     * Creates a new instance with the given data.%0D%0A     * %0D%0A     * @param data The data that this component should %22create%22 and pass to the next component.%0D%0A     * %0D%0A     * @throws SetUpException Shouldn't happen.%0D%0A     */%0D%0A    @SafeVarargs%0D%0A    public TestAnalysisComponentProvider(T... data) throws SetUpException %7B%0D%0A        super(new TestConfiguration(new Properties()));%0D%0A        this.data = new BlockingQueue%3C%3E();%0D%0A        for (T t : data) %7B%0D%0A            this.data.add(t);%0D%0A        %7D%0D%0A        this.data.end();%0D%0A    %7D%0D%0A    %0D
     /**%0D

Add additonal ctor to TestAnalysisComponentProvider