package ecoparasite.completion;

import ecoparasite.input.InputFactory;
import ecoparasite.input.InputFileException;
import ecoparasite.input.RawData;
import ecoparasite.input.RawDataOverflow;
import ecoparasite.nettoyage.Nettoyage;
import ecoparasite.poisson.Mackerel;
import ecoparasite.poisson.Poisson;
import org.junit.jupiter.api.Test;

import java.util.HashSet;
import java.util.function.BiConsumer;
import java.util.function.Function;

import static org.junit.jupiter.api.Assertions.*;

class CompletionTest {

    @org.junit.jupiter.api.Test
    void completePoissonMean() throws InputFileException, RawDataOverflow {

        RawData test = InputFactory.readData("testComplete.csv");

        HashSet<Poisson> testp = Mackerel.parse(test);

        System.out.println(testp);

        Function<Poisson,Double> getInfes = Poisson::getInfestation;
        BiConsumer<Poisson,Double> setInfes = Poisson::setInfestation;

        testp = Completion.completeColumnsMoyenne(testp,getInfes,setInfes);
        System.out.println(testp);
    }

    @org.junit.jupiter.api.Test
    void completePoissonLinear() throws InputFileException, RawDataOverflow {
        RawData test = InputFactory.readData("testComplete.csv");

        HashSet<Poisson> testp = Mackerel.parse(test);

        System.out.println(testp);

        Function<Poisson,Double> getLength = Poisson::getLength;
        Function<Poisson,Double> getInfes = Poisson::getInfestation;
        BiConsumer<Poisson,Double> setInfes = Poisson::setInfestation;

        testp = Nettoyage.nettoieColumns(testp,getInfes,setInfes,false);
        testp = Completion.completeColumnsLinear(testp,getLength,getInfes,setInfes);
        System.out.println(testp);
    }
}