@Test
public void testDataSetListWithDateOrder() throws Exception {

    final ObjectMapper mapper = new ObjectMapper();
    // given
    final String dataSetId1 = testClient.createDataset("dataset/dataset.csv", "aaaa");
    Thread.sleep(100);
    final String dataSetId2 = testClient.createDataset("dataset/dataset.csv", "bbbb");
    // when (sort by date, order is desc)
    String list = when() //
            .get("/api/datasets?sort={sort}&order={order}", CREATION_DATE.camelName(), DESC.camelName()) //
            .asString();
    // then
    Iterator<JsonNode> elements = mapper.readTree(list).elements();
    String[] expectedNames = new String[] { dataSetId2, dataSetId1 };
    int i = 0;
    while (elements.hasNext()) {
        assertThat(elements.next().get("id").asText(), is(expectedNames[i++]));
    }
    // when (sort by date, order is desc)
    list = when() //
            .get("/api/datasets?sort={sort}&order={order}", CREATION_DATE.camelName(), ASC.camelName()) //
            .asString();
    // then
    elements = mapper.readTree(list).elements();
    expectedNames = new String[] { dataSetId1, dataSetId2 };
    i = 0;
    while (elements.hasNext()) {
        assertThat(elements.next().get("id").asText(), is(expectedNames[i++]));
    }
}