@Test
public void previewNonDraft() throws Exception {

    // Create a data set
    String dataSetId = given()
            .body(IOUtils.toString(this.getClass().getResourceAsStream(TAGADA_CSV), UTF_8))
            .queryParam("Content-Type", "text/csv")
            .when()
            .post("/datasets")
            .asString();
    final DataSetMetadata dataSetMetadata = dataSetMetadataRepository.get(dataSetId);
    assertThat(dataSetMetadata, notNullValue());
    dataSetMetadata.setDraft(false); // Ensure it is no draft
    dataSetMetadataRepository.save(dataSetMetadata);
    // Should receive a 301 that redirects to the GET data set content operation
    given()
            .redirects()
            .follow(false)
            .contentType(JSON)
            .get("/datasets/{id}/preview", dataSetId) //
            .then() //
            .statusCode(HttpStatus.MOVED_PERMANENTLY.value());
    // Should receive a 200 if code follows redirection
    given()
            .redirects()
            .follow(true)
            .contentType(JSON)
            .get("/datasets/{id}/preview", dataSetId) //
            .then() //
            .statusCode(OK.value());
}