package uk.ac.ebi.atlas.acceptance.rest.tests.crossexperiment;

import com.jayway.restassured.response.ResponseBody;
import org.junit.Test;
import uk.ac.ebi.atlas.acceptance.rest.EndPoint;

import java.util.List;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.is;

public class BioentitiesQueryDifferentialDownloadControllerIT {

    private EndPoint subject = new EndPoint("/gxa/query.tsv?geneQuery=AT1G02220");


    @Test
    public void verifyLengthOfDocument() {
        ResponseBody body = subject.getResponseBody();

        String[] lines = body.asString().split("\n");
        assertThat(lines.length, is(6));
    }

    @Test
    public void verifyHeader() {
        List<String> header = subject.getRowValues(3);

        assertThat(header,
                contains("Gene", "Design Element", "Organism", "Contrast", "p-value", "log2foldchange", "t-statistic")
        );

    }

    @Test
    public void verifyBaselineGene() {
        List<String> firstGene = subject.getRowValues(4);

        assertThat(firstGene,
                contains("ANAC003", "", "Arabidopsis thaliana","nrpe1 mutant vs wild type",	"0.00355665145244311", "2.17880566798814", "NA"));
    }

    @Test
    public void verifyMicroArrayGene() {
        List<String> firstGene = subject.getRowValues(5);

        assertThat(firstGene,
                contains("ANAC003", "264148_at", "Arabidopsis thaliana","treatment: 'salicylic acid' vs 'Silwet' at time: '4 hours' in ecotype: 'Col-0'",	"0.0476008286349805", "0.982933333333333", "4.81369176288206"));
    }

}

@@ -53,24 +53,121 @@
 xperiment;%0A%0A
+import com.jayway.restassured.http.ContentType;%0Aimport com.jayway.restassured.response.Response;%0A
 import com.j
@@ -593,17 +593,16 @@
 220%22);%0A%0A
-%0A
     @Tes
@@ -1722,10 +1722,354 @@
 %0A    %7D%0A%0A
+%0A%0A    @Test%0A    public void downloadGeneDifferentialExpressions() %7B%0A        Response response = new EndPoint(%22/gxa/genes/ENSMUSG00000050520.tsv%22).getResponse();%0A%0A        response.then().assertThat().contentType(ContentType.TEXT);%0A%0A        String%5B%5D lines = response.body().asString().split(%22%5Cn%22);%0A        assertThat(lines.length, is(5));%0A    %7D%0A%0A
 %7D%0A

add test for downloadGeneDifferentialExpressions