/**
 * Copyright © CENRA (2016)
 *
 * remi.clement@espaces-naturels.fr
 * 
 * This software is a multi-platform and portable application based on 
 * the scientifical toolbox to monitor wetlands. With this toolbox it’s 
 * possible to calculate indicators «RhoMéO» to monitor quality, 
 * fonctionalities and urban and agricultural pressures of wetlands. 
 * Indicators are calculated using naturalist data entered and/or imported,
 * and geographic data downloaded from a geographic server.
 * 
 * This software is governed by the CeCILL license under French law and
 * abiding by the rules of distribution of free software.  You can  use, 
 * modify and/ or redistribute the software under the terms of the CeCILL
 * license as circulated by CEA, CNRS and INRIA at the following URL
 * "http://www.cecill.info". 
 * 
 * As a counterpart to the access to the source code and  rights to copy,
 * modify and redistribute granted by the license, users are provided only
 * with a limited warranty  and the software's author,  the holder of the
 * economic rights,  and the successive licensors  have only  limited
 * liability. 
 * 
 * In this respect, the user's attention is drawn to the risks associated
 * with loading,  using,  modifying and/or developing or reproducing the
 * software by the user in light of its specific status of free software,
 * that may mean  that it is complicated to manipulate,  and  that  also
 * therefore means  that it is reserved for developers  and  experienced
 * professionals having in-depth computer knowledge. Users are therefore
 * encouraged to load and test the software's suitability as regards their
 * requirements in conditions enabling the security of their systems and/or 
 * data to be ensured and,  more generally, to use and operate it in the 
 * same conditions as regards security. 
 * 
 * The fact that you are presently reading this means that you have had
 * knowledge of the CeCILL license and that you accept its terms.
*/
package fr.cenra.rhomeo.protocol.p01;

import fr.cenra.rhomeo.protocol.p01.PedologyStatement;
import fr.cenra.rhomeo.protocol.p01.I01;
import fr.cenra.rhomeo.RhomeoTestCase;
import fr.cenra.rhomeo.api.data.DataContext;
import fr.cenra.rhomeo.api.data.Dataset;
import fr.cenra.rhomeo.api.data.Protocol;
import fr.cenra.rhomeo.api.data.TrackingPoint;
import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.process.ProcessContext;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.TrackingPointIndex;
import fr.cenra.rhomeo.core.CSVDecoder;
import fr.cenra.rhomeo.protocol.PointResult.DoublePointResult;
import fr.cenra.rhomeo.core.data.site.SiteImpl;
import fr.cenra.rhomeo.protocol.YearResult.DoubleYearResult;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
import java.util.concurrent.RunnableFuture;
import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.embed.swing.JFXPanel;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

/**
 *
 * @author Samuel Andrés (Geomatys)
 */
public class I01Test extends RhomeoTestCase {

    private static final LocalDate SOME_DATE = LocalDate.now();
    private static final String TP_NAME_1 = "trackingPointId 1";
    private static final String TP_NAME_2 = "trackingPointId 2";

    @Autowired
    @Qualifier(P01.NAME)
    private Protocol p01;

    @Autowired
    @Qualifier(I01.NAME)
    private Indicator indicator;

    @Before
    public void before(){
        new JFXPanel().setVisible(false);// necessary to init fx toolkit
    }

    private Dataset<PedologyStatement> createDataset(final LocalDate date0, final LocalDate date1){

        // Dataset statements
        final Dataset<PedologyStatement> dataset = new Dataset<>(p01);
        final ObservableList<PedologyStatement> statements = dataset.getItems();

        // First tracking point

        final int tp1_h1 = 8;
        final int tp1_h2 = 12;
        final int tp1_h3 = 15;

        final PedologyStatement statement11 = new PedologyStatement(
                TP_NAME_1,
                date0,
                "Some remarks",
                1, // Horizon
                tp1_h1, // Depth (cm)
                1, // Limits
                "GLEY1",
                "4",
                "5",
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H2");
        statements.add(statement11);

        final PedologyStatement statement12 = new PedologyStatement(
                TP_NAME_1,
                date0,
                "Some remarks",
                2, // Horizon
                tp1_h2, // Depth (cm)
                1, // Limits
                "GLEY1",
                "4",
                "5",
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                1, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        statements.add(statement12);

        final PedologyStatement statement13 = new PedologyStatement(
                TP_NAME_1,
                date0,
                "Some remarks",
                3, // Horizon
                tp1_h3, // Depth (cm)
                1, // Limits
                "GLEY1",
                "4",
                "5",
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                1, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                1, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        statements.add(statement13);

        final PedologyStatement statement14 = new PedologyStatement(
                TP_NAME_1,
                date1,
                "Some remarks",
                4, // Horizon
                21, // Depth (cm)
                1, // Limits
                "GLEY1",
                "4",
                "5",
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                1, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                1, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        statements.add(statement14);

        // Second tracking point

        final int tp2_h1 = 5;
        final int tp2_h2 = 11;
        final int tp2_h3 = 14;
        final int tp2_h4 = 19;

        final PedologyStatement statement21 = new PedologyStatement(
                TP_NAME_2,
                date0,
                "Some remarks",
                1, // Horizon
                tp2_h1, // Depth (cm)
                1, // Limits
                "GLEY1",
                "4",
                "5",
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H2");
        statements.add(statement21);

        final PedologyStatement statement22 = new PedologyStatement(
                TP_NAME_2,
                date0,
                "Some remarks",
                2, // Horizon
                tp2_h2, // Depth (cm)
                1, // Limits
                "GLEY1",
                "4",
                "5",
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                1, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        statements.add(statement22);

        final PedologyStatement statement23 = new PedologyStatement(
                TP_NAME_2,
                date0,
                "Some remarks",
                3, // Horizon
                tp2_h3, // Depth (cm)
                1, // Limits
                "GLEY1",
                "4",
                "5",
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                1, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                1, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        statements.add(statement23);

        final PedologyStatement statement24 = new PedologyStatement(
                TP_NAME_2,
                date1,
                "Some remarks",
                4, // Horizon
                tp2_h4, // Depth (cm)
                1, // Limits
                "GLEY1",
                "4",
                "5",
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                1, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                1, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        statements.add(statement24);

        final PedologyStatement statement25 = new PedologyStatement(
                TP_NAME_2,
                date1,
                "Some remarks",
                4, // Horizon
                23, // Depth (cm)
                1, // Limits
                "GLEY1",
                "4",
                "5",
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                1, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                1, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        statements.add(statement25);

        // year0 + point1
        Assert.assertEquals((Integer) 0, I01.getHzCandidate(statement11, 0));
        Assert.assertEquals((Integer) 1, I01.getHzCandidate(statement12, statement11.getDepth()));
        Assert.assertEquals((Integer) 1, I01.getHzCandidate(statement13, statement12.getDepth()));

        // year1 + point1
        Assert.assertEquals((Integer) 1, I01.getHzCandidate(statement14, statement13.getDepth()));

        // year0 + point2
        Assert.assertEquals((Integer) 0, I01.getHzCandidate(statement21, statement14.getDepth()));
        Assert.assertEquals((Integer) 1, I01.getHzCandidate(statement22, statement21.getDepth()));
        Assert.assertEquals((Integer) 1, I01.getHzCandidate(statement23, statement22.getDepth()));

        // year1 + point2
        Assert.assertEquals((Integer) 1, I01.getHzCandidate(statement24, statement23.getDepth()));
        Assert.assertEquals((Integer) 1, I01.getHzCandidate(statement25, statement24.getDepth()));

        // Moyennes sur l'ensemble des points (~ sur le site) :
        // Moyenne sur l'année year0 : 2/3
        // Moyenne sur l'année year1 : 1

        // Moyennes sur l'ensemble le point1 :
        // Moyenne sur l'année year0 : 2/3
        // Moyenne sur l'année year1 : 1

        // Moyennes sur l'ensemble le point2 :
        // Moyenne sur l'année year0 : 2/3
        // Moyenne sur l'année year1 : 1

        return dataset;
    }

    @Test
    public void testMockDataset() {
        createDataset(SOME_DATE, SOME_DATE.plusDays(10));
    }

    public Dataset<PedologyStatement> createRefDataset(final Protocol protocol, final String... fileNames) throws Exception {
        CSVDecoder decoder;
        final Dataset result = new Dataset(protocol);

        for(final String fileName : fileNames){
            final Path path = Paths.get(this.getClass().getResource(fileName).toURI());
            decoder = new CSVDecoder(path, protocol.getDataType(), StandardCharsets.UTF_8);
            result.getItems().addAll(decoder.decode());
        }

        return result;
    }

    /**
     * Compute indices by point and by year from reference data, and check that
     * result is compliant with client's provided ones.
     *
     * @throws java.lang.Exception If something goes wrong.
     */
    @Test
    public void testComputing() throws Exception {

        final ProcessContext pctx = new ProcessContext(createRefDataset(p01, "bidonnes_2011.csv", "chautagne_2012.csv"), new DataContext(new SiteImpl(null), p01));

        // Load expected results
        final List<DoubleYearResult> decodedYears = new CSVDecoder<>(Paths.get(I01Test.class.getResource("yearResults.csv").toURI()), DoubleYearResult.class).decode();
        final Map<Integer, Double> yearResults = new HashMap<>(2);
        for (final DoubleYearResult result : decodedYears) {
            yearResults.put(result.getYear(), result.getResult());
        }

        final List<DoublePointResult> decodedPoints = new CSVDecoder<>(Paths.get(I01Test.class.getResource("pointResults.csv").toURI()), DoublePointResult.class).decode();
        final Map<TrackingPoint, Double> pointResults = new HashMap<>(17);
        for (final DoublePointResult result : decodedPoints) {
            pointResults.put(p01.createTrackingPoint(result.getId(), result.getYear()), result.getResult());
        }

        // Compute indices. Separate them by type.
        final Set<Index<Double>> annualIndices  = new HashSet<>(2);
        final Set<TrackingPointIndex<Double>> pointIndices  = new HashSet<>(17);


        final RunnableFuture f = new FutureTask((Callable) () -> {
                indicator.createProcesses(pctx).forEach(process -> {
                    try {
                        process.run();
                        process.get().forEach(index -> {
                            if (index instanceof TrackingPointIndex) {
                                pointIndices.add((TrackingPointIndex) index);
                            } else {
                                annualIndices.add(index);
                            }
                        });
                    } catch (Exception ex) {
                        Assert.fail("An exception occured…");
                    }
                });
            return "";
        });

        Platform.runLater(f);
        Assert.assertNotNull(f.get());

        // Check results.
        Assert.assertEquals("Number of annual indices is wrong !", 2, annualIndices.size());
        Assert.assertEquals("Number of point indices is wrong !", 17, pointIndices.size());

        for (final Index<Double> year : annualIndices) {
            Assert.assertEquals(
                    "Annual result differs for year : ".concat(String.valueOf(year.getYear())),
                    yearResults.get(year.getYear()),
                    year.getValue(),
                    0.01
            );
        }

        for (final TrackingPointIndex<Double> point : pointIndices) {
            Assert.assertEquals(
                    new StringBuilder("Point result differs for year : ")
                            .append(point.getYear())
                            .append(" and ID ")
                            .append(point.getPoint().getName())
                            .toString(),
                    pointResults.get(p01.createTrackingPoint(point.getPoint().getName(), point.getYear())),
                    point.getValue(),
                    0.01
            );
        }
    }

    @Test
    public void testCheckIfComputable(){

        // Dataset
        final Dataset<PedologyStatement> dataset = new Dataset<>(p01);
        final ObservableList<PedologyStatement> statements = dataset.getItems();

        final PedologyStatement statement1 = new PedologyStatement(
                "trackingPointId 1",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                8, // Depth (cm)
                0, // Limits
                "YR10", // Color
                "5", // Value
                "3", // Chroma
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                0, // Abundance
                0, // Size
                0, // Shape
                0, // Humidity
                0, // Compactness
                0, // Plasticity
                0, // Adhesiveness
                0, // Friability
                0, // Alteration MO
                null);

        statements.add(statement1);

        Assert.assertTrue(I01.checkIfComputable(statement1));


        final PedologyStatement statement2 = new PedologyStatement(
                "trackingPointId 2",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                8, // Depth (cm)
                0, // Limits
                null, // Color
                "5", // Value
                "3", // Chroma
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                0, // Abundance
                0, // Size
                0, // Shape
                0, // Humidity
                0, // Compactness
                0, // Plasticity
                0, // Adhesiveness
                0, // Friability
                0, // Alteration MO
                null);

        statements.add(statement2);
        Assert.assertFalse(I01.checkIfComputable(statement2)); // Color is null


        final PedologyStatement statement3 = new PedologyStatement(
                "trackingPointId 3",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                8, // Depth (cm)
                0, // Limits
                "YR10", // Color
                null, // Value
                "3", // Chroma
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                0, // Abundance
                0, // Size
                0, // Shape
                0, // Humidity
                0, // Compactness
                0, // Plasticity
                0, // Adhesiveness
                0, // Friability
                0, // Alteration MO
                null);

        statements.add(statement3);
        Assert.assertFalse(I01.checkIfComputable(statement3)); // Value is null


        final PedologyStatement statement4 = new PedologyStatement(
                "trackingPointId 4",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                8, // Depth (cm)
                0, // Limits
                "YR10", // Color
                "5", // Value
                null, // Chroma
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                0, // Abundance
                0, // Size
                0, // Shape
                0, // Humidity
                0, // Compactness
                0, // Plasticity
                0, // Adhesiveness
                0, // Friability
                0, // Alteration MO
                null);

        statements.add(statement4);
        Assert.assertFalse(I01.checkIfComputable(statement4)); // Chroma is null



        final PedologyStatement statement5 = new PedologyStatement(
                "trackingPointId 5",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                8, // Depth (cm)
                0, // Limits
                "YR10", // Color
                "5", // Value
                "3", // Chroma
                0, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                0, // Abundance
                0, // Size
                0, // Shape
                0, // Humidity
                0, // Compactness
                0, // Plasticity
                0, // Adhesiveness
                0, // Friability
                0, // Alteration MO
                null);

        statements.add(statement5);
        Assert.assertFalse(I01.checkIfComputable(statement5)); // Texture is null



        final PedologyStatement statement6 = new PedologyStatement(
                "trackingPointId 6",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                8, // Depth (cm)
                0, // Limits
                "YR10", // Color
                "5", // Value
                "3", // Chroma
                1, // Texture
                0, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                0, // Abundance
                0, // Size
                0, // Shape
                0, // Humidity
                0, // Compactness
                0, // Plasticity
                0, // Adhesiveness
                0, // Friability
                0, // Alteration MO
                null);

        statements.add(statement6);
        Assert.assertFalse(I01.checkIfComputable(statement6)); // Structure is null



        final PedologyStatement statement7 = new PedologyStatement(
                "trackingPointId 7",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                8, // Depth (cm)
                0, // Limits
                "YR10", // Color
                "5", // Value
                "3", // Chroma
                1, // Texture
                2, // Structure
                0, // Raw elements
                4, // Roots
                3, // Stains
                0, // Abundance
                0, // Size
                0, // Shape
                0, // Humidity
                0, // Compactness
                0, // Plasticity
                0, // Adhesiveness
                0, // Friability
                0, // Alteration MO
                null);

        statements.add(statement7);
        Assert.assertFalse(I01.checkIfComputable(statement7)); // raw elements are null



        final PedologyStatement statement8 = new PedologyStatement(
                "trackingPointId 8",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                8, // Depth (cm)
                0, // Limits
                "YR10", // Color
                "5", // Value
                "3", // Chroma
                1, // Texture
                2, // Structure
                3, // Raw elements
                0, // Roots
                3, // Stains
                0, // Abundance
                0, // Size
                0, // Shape
                0, // Humidity
                0, // Compactness
                0, // Plasticity
                0, // Adhesiveness
                0, // Friability
                0, // Alteration MO
                null);

        statements.add(statement8);
        Assert.assertFalse(I01.checkIfComputable(statement8)); // Roots are null



        final PedologyStatement statement9 = new PedologyStatement(
                "trackingPointId 9",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                8, // Depth (cm)
                0, // Limits
                "YR10", // Color
                "5", // Value
                "3", // Chroma
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                0, // Stains
                0, // Abundance
                0, // Size
                0, // Shape
                0, // Humidity
                0, // Compactness
                0, // Plasticity
                0, // Adhesiveness
                0, // Friability
                0, // Alteration MO
                null);

        statements.add(statement9);
        Assert.assertFalse(I01.checkIfComputable(statement9)); // Strains are null
    }

    @Test
    public void testL(){
        final PedologyStatement statement = new PedologyStatement(
                "trackingPointId",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H1");
        Assert.assertEquals("H1", statement.getVonPost());
        Assert.assertEquals(0, I01.getL(statement, 0)); // Von-Post is not null

        final PedologyStatement statement1 = new PedologyStatement(
                "trackingPointId 1",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        Assert.assertEquals(null, statement1.getVonPost());
        Assert.assertEquals(1, I01.getL(statement1, 0));

        final PedologyStatement statement2 = new PedologyStatement(
                "trackingPointId 1",
                SOME_DATE,
                "Some remarks",
                2, // Horizon
                16, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        Assert.assertEquals(2, statement2.getNumberH());
        Assert.assertEquals(0, I01.getL(statement2, statement1.getDepth())); // Horizon number = 2

        final PedologyStatement statement3 = new PedologyStatement(
                "trackingPointId 2",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                10, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                3, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        Assert.assertEquals(3, statement3.getTexture());
        Assert.assertEquals(0, I01.getL(statement3, 0)); // Texture = 3

        final PedologyStatement statement4 = new PedologyStatement(
                "trackingPointId 3",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                1, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H1");
        Assert.assertEquals("H1", statement4.getVonPost());
        Assert.assertEquals(0, I01.getL(statement4, 0)); // Roots = 1
    }

    @Test
    public void testGr(){

        final PedologyStatement statement1 = new PedologyStatement(
                "trackingPointId 1",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                "GLEY1",
                "6",
                null,
                2, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H1");
        Assert.assertEquals(2, I01.getGr(statement1));

        final PedologyStatement statement2 = new PedologyStatement(
                "trackingPointId 2",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                "GLEY1",
                "6",
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H1");
        Assert.assertEquals(0, I01.getGr(statement2)); // Texture = 1
    }


    @Test
    public void testGo(){
        final PedologyStatement statement = new PedologyStatement(
                "trackingPointId",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                2, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                2, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H1");
        Assert.assertEquals(1, I01.getGo(statement));

        final PedologyStatement statement1 = new PedologyStatement(
                "trackingPointId 1",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                2, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                2, // Stains
                0, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H1");
        Assert.assertEquals(0, I01.getGo(statement1)); // Abundance = 0

        final PedologyStatement statement2 = new PedologyStatement(
                "trackingPointId 2",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                2, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H1");
        Assert.assertEquals(0, I01.getGo(statement2)); // Texture = 1

        final PedologyStatement statement3 = new PedologyStatement(
                "trackingPointId 3",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                2, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                1, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H1");
        Assert.assertEquals(0, I01.getGo(statement3)); // Stains != 2
    }


    @Test
    public void testJ(){
        final PedologyStatement statement1 = new PedologyStatement(
                "trackingPointId 1",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                2, // Texture
                1, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H1");
        Assert.assertEquals(1, I01.getJ(statement1));

        final PedologyStatement statement2 = new PedologyStatement(
                "trackingPointId 2",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                1, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H1");
        Assert.assertEquals(0, I01.getJ(statement2)); // Texture = 1

        final PedologyStatement statement3 = new PedologyStatement(
                "trackingPointId 3",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                4, // Texture
                1, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H1");
        Assert.assertEquals(0, I01.getJ(statement3)); // Texture = 4

        final PedologyStatement statement4 = new PedologyStatement(
                "trackingPointId 4",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                2, // Texture
                1, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                1, // Friability
                4, // Alteration MO
                "H1");
        Assert.assertEquals(0, I01.getJ(statement4)); // Friability <=2

        final PedologyStatement statement5 = new PedologyStatement(
                "trackingPointId 1",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                2, // Texture
                3, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H1");
        Assert.assertEquals(0, I01.getJ(statement5)); // Structure !=1
    }


    @Test
    public void testT(){
        final PedologyStatement statement1 = new PedologyStatement(
                "trackingPointId 1",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                "4.6",
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                1, // Friability
                4, // Alteration MO
                null);
        Assert.assertEquals(3, I01.getT(statement1));

        final PedologyStatement statement2 = new PedologyStatement(
                "trackingPointId 2",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                "4.5",
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                1, // Friability
                4, // Alteration MO
                null);
        Assert.assertEquals(0, I01.getT(statement2)); // Value <= 4.5

        final PedologyStatement statement3 = new PedologyStatement(
                "trackingPointId 3",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                "4.6",
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                1, // Friability
                4, // Alteration MO
                "H1");
        Assert.assertEquals(0, I01.getT(statement3)); // Von-Post not null

        final PedologyStatement statement4 = new PedologyStatement(
                "trackingPointId 4",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                "4.6",
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        Assert.assertEquals(0, I01.getT(statement4)); // Friability >=2

        final PedologyStatement statement5 = new PedologyStatement(
                "trackingPointId 5",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                "4.6",
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                2, // Plasticity
                2, // Adhesiveness
                1, // Friability
                4, // Alteration MO
                null);
        Assert.assertEquals(0, I01.getT(statement5)); // Plasticity != 1
    }


    @Test
    public void testHf(){
        final PedologyStatement statement1 = new PedologyStatement(
                "trackingPointId 1",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                11, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H2");
        Assert.assertEquals(3, I01.getHf(statement1));

        final PedologyStatement statement2 = new PedologyStatement(
                "trackingPointId 2",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                2, // Texture
                11, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H2");

        Assert.assertEquals(0, I01.getHf(statement2)); // Texture != 1

        final PedologyStatement statement3 = new PedologyStatement(
                "trackingPointId 3",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                10, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H2");
        Assert.assertEquals(0, I01.getHf(statement3)); // Structure <= 10

        final PedologyStatement statement4 = new PedologyStatement(
                "trackingPointId 4",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                11, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H5");
        Assert.assertEquals(0, I01.getHf(statement4)); // Von-Post != H1,H2,H3
    }


    @Test
    public void testHm(){
        final PedologyStatement statement1 = new PedologyStatement(
                "trackingPointId 1",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H6");
        Assert.assertEquals(2, I01.getHm(statement1));

        final PedologyStatement statement2 = new PedologyStatement(
                "trackingPointId 2",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                2, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H6");
        Assert.assertEquals(0, I01.getHm(statement2)); // Texture != 1

        final PedologyStatement statement3 = new PedologyStatement(
                "trackingPointId 3",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H8");
        Assert.assertEquals(0, I01.getHm(statement3)); // Von-Post != [H3 ; H7]
    }


    @Test
    public void testHs(){
        final PedologyStatement statement1 = new PedologyStatement(
                "trackingPointId 1",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H9");
        Assert.assertEquals(2, I01.getHs(statement1));

        final PedologyStatement statement2 = new PedologyStatement(
                "trackingPointId 2",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                2, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H9");
        Assert.assertEquals(0, I01.getHs(statement2)); // Texture = 2

        final PedologyStatement statement3 = new PedologyStatement(
                "trackingPointId 3",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H7");
        Assert.assertEquals(0, I01.getHs(statement3)); // Von-Post = H7

        final PedologyStatement statement4 = new PedologyStatement(
                "trackingPointId 4",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                3, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H7");
        Assert.assertEquals(2, I01.getHs(statement4));

        final PedologyStatement statement5 = new PedologyStatement(
                "trackingPointId 5",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                3, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H2");
        Assert.assertEquals(0, I01.getHs(statement5)); // Von-Post = H2
    }



    @Test
    public void testOrg(){
        final PedologyStatement statement1 = new PedologyStatement(
                "trackingPointId 1",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                4, // Structure
                3, // Raw elements
                4, // Roots
                1, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        Assert.assertEquals(2, I01.getOrg(statement1));

        final PedologyStatement statement2 = new PedologyStatement(
                "trackingPointId 2",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                2, // Texture
                4, // Structure
                3, // Raw elements
                4, // Roots
                1, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        Assert.assertEquals(0, I01.getOrg(statement2)); // Structure <=10

        final PedologyStatement statement3 = new PedologyStatement(
                "trackingPointId 1",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                4, // Structure
                3, // Raw elements
                4, // Roots
                2, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        Assert.assertEquals(0, I01.getOrg(statement3)); // Stains !=1

        final PedologyStatement statement4 = new PedologyStatement(
                "trackingPointId 4",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                2, // Texture
                11, // Structure
                3, // Raw elements
                4, // Roots
                1, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        Assert.assertEquals(2, I01.getOrg(statement4));

        final PedologyStatement statement5 = new PedologyStatement(
                "trackingPointId 5",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                2, // Texture
                10, // Structure
                3, // Raw elements
                4, // Roots
                1, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        Assert.assertEquals(0, I01.getOrg(statement5)); // Structure <=10

        final PedologyStatement statement6 = new PedologyStatement(
                "trackingPointId 6",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                2, // Texture
                11, // Structure
                3, // Raw elements
                4, // Roots
                1, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H1");
        Assert.assertEquals(0, I01.getOrg(statement6)); // Von-Post not null
    }



    @Test
    public void testHa_LH(){
        final PedologyStatement statement1 = new PedologyStatement(
                "trackingPointId 1",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        Assert.assertEquals(1, I01.getHa_LH(statement1));

        final PedologyStatement statement2 = new PedologyStatement(
                "trackingPointId 2",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                11, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        Assert.assertEquals(1, I01.getHa_LH(statement2));



        final PedologyStatement statement3 = new PedologyStatement(
                "trackingPointId 3",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                10, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        Assert.assertEquals(0, I01.getHa_LH(statement3)); // Structure >3 && Structure !=11

        final PedologyStatement statement4 = new PedologyStatement(
                "trackingPointId 4",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                "H2");
        Assert.assertEquals(0, I01.getHa_LH(statement4)); // Von-Post not null

        final PedologyStatement statement5 = new PedologyStatement(
                "trackingPointId 5",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                4, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        Assert.assertEquals(0, I01.getHa_LH(statement5)); // Humidity > 3

        final PedologyStatement statement6 = new PedologyStatement(
                "trackingPointId 6",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                12, // Depth (cm)
                1, // Limits
                null,
                null,
                null,
                2, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                2, // Abundance
                1, // Size
                2, // Shape
                3, // Humidity
                4, // Compactness
                1, // Plasticity
                2, // Adhesiveness
                3, // Friability
                4, // Alteration MO
                null);
        Assert.assertEquals(0, I01.getHa_LH(statement6)); // Texture != 1
    }

    @Test
    public void testGetHzCandidate1(){

        final PedologyStatement statement1 = new PedologyStatement(
                "trackingPointId 1",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                8, // Depth (cm)
                0, // Limits
                "YR10", // Color
                "5", // Value
                "3", // Chroma
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                0, // Abundance
                0, // Size
                0, // Shape
                2, // Humidity
                0, // Compactness
                0, // Plasticity
                0, // Adhesiveness
                0, // Friability
                0, // Alteration MO
                null);

        Assert.assertEquals(1, I01.getL(statement1, 0)); // Max
        Assert.assertEquals(0, I01.getGr(statement1));
        Assert.assertEquals(0, I01.getGo(statement1));
        Assert.assertEquals(0, I01.getJ(statement1));
        Assert.assertEquals(0, I01.getT(statement1));
        Assert.assertEquals(0, I01.getHf(statement1));
        Assert.assertEquals(0, I01.getHm(statement1));
        Assert.assertEquals(0, I01.getHs(statement1));
        Assert.assertEquals(0, I01.getOrg(statement1));
        Assert.assertEquals(1, I01.getHa_LH(statement1)); // Max
        Assert.assertEquals((Integer) 1, I01.getHzCandidate(statement1, 0));
    }

    @Test
    public void testGetHzCandidate2(){

        final PedologyStatement statement1 = new PedologyStatement(
                "trackingPointId 1",
                SOME_DATE,
                "Some remarks",
                1, // Horizon
                8, // Depth (cm)
                0, // Limits
                "YR10", // Color
                "5", // Value
                "3", // Chroma
                1, // Texture
                2, // Structure
                3, // Raw elements
                4, // Roots
                3, // Stains
                0, // Abundance
                0, // Size
                0, // Shape
                1, // Humidity
                0, // Compactness
                1, // Plasticity
                0, // Adhesiveness
                1, // Friability
                0, // Alteration MO
                null);

        Assert.assertEquals(1, I01.getL(statement1, 0));
        Assert.assertEquals(0, I01.getGr(statement1));
        Assert.assertEquals(0, I01.getGo(statement1));
        Assert.assertEquals(0, I01.getJ(statement1));
        Assert.assertEquals(3, I01.getT(statement1));// Max
        Assert.assertEquals(0, I01.getHf(statement1));
        Assert.assertEquals(0, I01.getHm(statement1));
        Assert.assertEquals(0, I01.getHs(statement1));
        Assert.assertEquals(0, I01.getOrg(statement1));
        Assert.assertEquals(1, I01.getHa_LH(statement1));
        Assert.assertEquals((Integer) 3, I01.getHzCandidate(statement1, 0));
    }
}
