Search in sources :

Example 1 with JsonErrorCode

use of org.talend.daikon.exception.json.JsonErrorCode in project data-prep by Talend.

the class DataSetAPITest method testDataSetCreateUnsupportedFormat.

@Test
public void testDataSetCreateUnsupportedFormat() throws Exception {
    // given
    final String datasetContent = IOUtils.toString(DataSetAPITest.class.getResourceAsStream("dataset/dataset.pdf"), UTF_8);
    final int metadataCount = dataSetMetadataRepository.size();
    // then
    final Response response = given().body(datasetContent).when().post("/api/datasets");
    assertThat(response.getStatusCode(), is(400));
    JsonErrorCode code = mapper.readValue(response.asString(), JsonErrorCode.class);
    assertThat(code.getCode(), is(DataSetErrorCodes.UNSUPPORTED_CONTENT.getCode()));
    // No data set metadata should be created
    assertThat(dataSetMetadataRepository.size(), is(metadataCount));
}
Also used : Response(com.jayway.restassured.response.Response) JsonErrorCode(org.talend.daikon.exception.json.JsonErrorCode) Test(org.junit.Test)

Aggregations

Response (com.jayway.restassured.response.Response)1 Test (org.junit.Test)1 JsonErrorCode (org.talend.daikon.exception.json.JsonErrorCode)1