package uk.ac.ebi.atlas.experiments;

import com.google.common.collect.ImmutableSet;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import uk.ac.ebi.atlas.model.experiment.Experiment;
import uk.ac.ebi.atlas.model.experiment.ExperimentType;
import uk.ac.ebi.atlas.model.experiment.baseline.BaselineExperimentTest;
import uk.ac.ebi.atlas.trader.ExperimentTrader;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class ExperimentsInfoListServiceTest {

    private static final String EXPECTED_JSON =
          "{\n" +
          "  \"aaData\": [\n" +
          "    {\n" +
          "      \"experimentType\": \"RNASEQ_MRNA_BASELINE\",\n" +
          "      \"experimentAccession\": \"accession\",\n" +
          "      \"experimentDescription\": \"description\",\n" +
          "      \"lastUpdate\": \"\\d+-\\d+-\\d+\",\n" +
          "      \"numberOfAssays\": \\d+,\n" +
          "      \"numberOfContrasts\": \\d+,\n" +
          "      \"species\": \"species\",\n" +
          "      \"kingdom\": \"kingdom\",\n" +
          "      \"experimentalFactors\": [],\n" +
          "      \"arrayDesigns\": [],\n" +
          "      \"arrayDesignNames\": []\n" +
          "    }\n" +
          "  ]\n" +
          "}";


    @Mock
    private ExperimentTrader experimentTrader;

    private ExperimentInfoListService subject;

    @Before
    public void setUp() throws Exception {

        when(experimentTrader.getPublicExperiments(ExperimentType.RNASEQ_MRNA_BASELINE))
                .thenReturn(ImmutableSet.<Experiment>of(BaselineExperimentTest.mockExperiment()));

        subject =
                new ExperimentInfoListService(experimentTrader, ImmutableSet.of(ExperimentType.RNASEQ_MRNA_BASELINE));

    }



    @Test
    public void sizeIsRight() throws Exception {
        JsonArray result = subject.getExperimentsJson().get("aaData").getAsJsonArray();
       assertThat(result.size(), is(1));
    }

    @Test
    public void formatIsInSyncWithWhatWeExpectAndTheDataOfMockBaselineExperiment() throws Exception {
        JsonElement result = subject.getExperimentsJson();
        assertThat(result.toString().matches(
                EXPECTED_JSON.replace(" ", "")
                             .replace("\n", "")
                             .replace("[","\\[")
                             .replace("]","\\]")
                             .replace("{","\\{")
                             .replace("}","\\}")),
                is(true));
    }
}
@@ -173,24 +173,59 @@
 sonElement;%0A
+import com.google.gson.JsonObject;%0A
 import org.j
@@ -2274,16 +2274,618 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void formatIsInSyncWithWhatWeExpectAndTheDataOfMockBaselineExperiment1() throws Exception %7B%0A        JsonElement result = subject.getExperimentsJson();%0A        JsonObject dataPoint = result.getAsJsonObject().get(%22aaData%22).getAsJsonObject();%0A        assertThat(dataPoint.get(%22experimentType%22).getAsString(), is(%22RNASEQ_MRNA_BASELINE%22));%0A        assertThat(dataPoint.has(%22experimentAccession%22), is(true));%0A        assertThat(dataPoint.has(%22lastUpdate%22), is(true));%0A        assertThat(dataPoint.has(%22species%22), is(true));%0A        assertThat(dataPoint.has(%22kingdom%22), is(true));%0A    %7D%0A%0A
     @Tes

Fix test setup