package ecoparasite.nettoyage;

import ecoparasite.completion.Completion;
import ecoparasite.input.InputFactory;
import ecoparasite.input.InputFileException;
import ecoparasite.input.RawData;
import ecoparasite.input.RawDataOverflow;
import ecoparasite.poisson.Mackerel;
import ecoparasite.poisson.MackerelSerra;
import ecoparasite.poisson.Poisson;
import org.junit.jupiter.api.Test;

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

class NettoyageTest {

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

        RawData test = InputFactory.readData("test2.csv", ",");

        HashSet<Poisson> testp = MackerelSerra.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);

        testp = Nettoyage.nettoieColumnsMoyenne( testp, getInfes, setInfes );

        System.out.println(testp);
    }

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

        RawData test = InputFactory.readData("test2.csv", ",");

        HashSet<Poisson> testp = MackerelSerra.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 );

        System.out.println(testp);
    }

}