package com.grayben.riskExtractor.htmlScorer.nodeVisitor.setup;

import com.grayben.riskExtractor.htmlScorer.ScoredText;
import com.grayben.riskExtractor.htmlScorer.ScoringAndFlatteningNodeVisitor;
import com.grayben.riskExtractor.htmlScorer.partScorers.Scorer;
import com.grayben.tools.testOracle.SystemUnderTest;
import com.grayben.tools.testOracle.testContainer.TestContainer;
import org.jsoup.nodes.Element;
import org.jsoup.select.NodeTraversor;

import java.util.Set;
import java.util.function.Supplier;

/**
 * For a nominated test configuration: generates the test input, SUT and expected output.
 * <p>
 *
 */
public class TestContainerSupplier implements Supplier<TestContainer<AnnotatedElement, ScoredText>> {

    @Override
    public TestContainer<AnnotatedElement, ScoredText> get() {
        Supplier<Set<Scorer<Element>>> configElementScorerSetSupplier
                = () -> SetupHelpers.configureElementScorerSet();

        Supplier<AnnotatedElement> configAnnotatedElementSupplier
                = () -> SetupHelpers.configureAnnotatedElement();

        Supplier<SystemUnderTest<AnnotatedElement, ScoredText>> systemUnderTestSupplier = () -> {

            Supplier<ScoringAndFlatteningNodeVisitor> scoringAndFlatteningNodeVisitorSupplier
                    = () -> new ScoringAndFlatteningNodeVisitor(configElementScorerSetSupplier.get());

            return config1 -> {
                Element rootElement = SetupHelpers.configureAnnotatedElement();
                ScoringAndFlatteningNodeVisitor nodeVisitor = scoringAndFlatteningNodeVisitorSupplier.get();
                NodeTraversor nodeTraversor = new NodeTraversor(nodeVisitor);
                nodeTraversor.traverse(rootElement);
                return nodeVisitor.getFlatText();
            };
        };

        //TODO: use AnnotatedElement as test input!
        return new TestContainer.Builder<AnnotatedElement, ScoredText>()
                .begin()
                .systemUnderTest(systemUnderTestSupplier.get())
                .oracle(new ActiveOracleSupplier().get())
                .build();

    }
}
@@ -195,72 +195,8 @@
 or;%0A
-import com.grayben.riskExtractor.htmlScorer.partScorers.Scorer;%0A
 impo
@@ -385,30 +385,8 @@
 r;%0A%0A
-import java.util.Set;%0A
 impo
@@ -710,1023 +710,134 @@
 ) %7B%0A
-        Supplier%3CSet%3CScorer%3CElement%3E%3E%3E configElementScorerSetSupplier%0A                = () -%3E SetupHelpers.configureElementScorerSet();%0A%0A        Supplier%3CAnnotatedElement%3E configAnnotatedElementSupplier%0A                = () -%3E SetupHelpers.configureAnnotatedElement();%0A%0A        Supplier%3CSystemUnderTest%3CAnnotatedElement, ScoredText%3E%3E systemUnderTestSupplier = () -%3E %7B%0A%0A            Supplier%3CScoringAndFlatteningNodeVisitor%3E scoringAndFlatteningNodeVisitorSupplier%0A                    = () -%3E new ScoringAndFlatteningNodeVisitor(configElementScorerSetSupplier.get());%0A%0A            return config1 -%3E %7B%0A                Element rootElement = SetupHelpers.configureAnnotatedElement();%0A                ScoringAndFlatteningNodeVisitor nodeVisitor = scoringAndFlatteningNodeVisitorSupplier.get();%0A                NodeTraversor nodeTraversor = new NodeTraversor(nodeVisitor);%0A                nodeTraversor.traverse(rootElement);%0A                return nodeVisitor.getFlatText();%0A            %7D;%0A        %7D;%0A%0A        //TODO: use
+%0A%0A%0A        //TODO: think about wildcard generics: how to solve problem of SUT(Element) and Oracle(AnnotatedElement): Element =
  Ann
@@ -853,23 +853,8 @@
 ment
- as test input!
 %0A   
@@ -981,17 +981,21 @@
 derTest(
-s
+new S
 ystemUnd
@@ -1008,16 +1008,18 @@
 Supplier
+()
 .get())%0A

Remove duplicate code in TestContainerSupplier