package uk.ac.ebi.atlas.search.baseline;

import org.junit.Test;
import uk.ac.ebi.atlas.model.FactorAcrossExperiments;
import uk.ac.ebi.atlas.model.experiment.baseline.BaselineExperimentTest;
import uk.ac.ebi.atlas.model.experiment.baseline.BaselineExpression;
import uk.ac.ebi.atlas.model.experiment.baseline.Factor;
import uk.ac.ebi.atlas.model.experiment.baseline.impl.FactorSet;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;

public class BaselineExperimentProfilesListTest {

    String factorHeader = "type1";

    @Test
    public void testGetFactorsAcrossExperiments() throws Exception {
        BaselineExperimentProfilesList result = new BaselineExperimentProfilesList();

        BaselineExperimentProfile p1 = new BaselineExperimentProfile(BaselineExperimentTest.mockExperiment(), new FactorSet());
        p1.add(new FactorAcrossExperiments(new Factor(factorHeader, "v1")), new BaselineExpression(1.0));
        p1.add(new FactorAcrossExperiments(new Factor(factorHeader, "v2")), new BaselineExpression(2.0));
        result.add(p1);
        assertThat(result.getFactorsAcrossExperiments().size(), is(2));

        BaselineExperimentProfile p2 = new BaselineExperimentProfile(BaselineExperimentTest.mockExperiment(), new FactorSet());
        p2.add(new FactorAcrossExperiments(new Factor(factorHeader, "v1")), new BaselineExpression(1.0));
        p2.add(new FactorAcrossExperiments(new Factor(factorHeader, "v3")), new BaselineExpression(3.0));
        result.add(p2);
        assertThat(result.getFactorsAcrossExperiments().size(), is(3));
    }

    @Test
    public void zerosDoNotMakeItToTheList() throws Exception {
        BaselineExperimentProfilesList result = new BaselineExperimentProfilesList();

        BaselineExperimentProfile p1 = new BaselineExperimentProfile(BaselineExperimentTest.mockExperiment(), new FactorSet());
        p1.add(new FactorAcrossExperiments(new Factor(factorHeader, "v1")), new BaselineExpression(1.0));
        p1.add(new FactorAcrossExperiments(new Factor(factorHeader, "v2")), new BaselineExpression(2.0));
        p1.add(new FactorAcrossExperiments(new Factor(factorHeader, "v3")), new BaselineExpression(0.0));
        result.add(p1);
        assertThat(result.getFactorsAcrossExperiments().size(), is(2));

        BaselineExperimentProfile p2 = new BaselineExperimentProfile(BaselineExperimentTest.mockExperiment(), new FactorSet());
        p2.add(new FactorAcrossExperiments(new Factor(factorHeader, "v1")), new BaselineExpression(1.0));
        p2.add(new FactorAcrossExperiments(new Factor(factorHeader, "v3")), new BaselineExpression(3.0));
        result.add(p2);
        assertThat(result.getFactorsAcrossExperiments().size(), is(3));
    }

}
@@ -1631,11 +1631,8 @@
 osDo
-Not
 Make
@@ -2225,445 +2225,8 @@
 1);%0A
-        assertThat(result.getFactorsAcrossExperiments().size(), is(2));%0A%0A        BaselineExperimentProfile p2 = new BaselineExperimentProfile(BaselineExperimentTest.mockExperiment(), new FactorSet());%0A        p2.add(new FactorAcrossExperiments(new Factor(factorHeader, %22v1%22)), new BaselineExpression(1.0));%0A        p2.add(new FactorAcrossExperiments(new Factor(factorHeader, %22v3%22)), new BaselineExpression(3.0));%0A        result.add(p2);%0A
     

Revert previous and assert the zeros do make it into the list