Search in sources :

Example 1 with ApiError

use of org.talend.components.service.rest.impl.ApiError in project components by Talend.

the class JdbcComponentTestIT method testGetSchema_wrongSql.

@Test
public void testGetSchema_wrongSql() throws java.io.IOException {
    // given
    UiSpecsPropertiesDto datasetConnectionInfo = new UiSpecsPropertiesDto();
    datasetConnectionInfo.setProperties(mapper.readValue(getClass().getResourceAsStream("jdbc_data_set_properties_no_schema_wrong_table_name.json"), ObjectNode.class));
    datasetConnectionInfo.setDependencies(singletonList(getJdbcDataStoreProperties()));
    String dataSetDefinitionName = "JDBCDataset";
    // when
    ApiError response = // 
    given().content(datasetConnectionInfo).contentType(APPLICATION_JSON_UTF8_VALUE).accept(// 
    APPLICATION_JSON_UTF8_VALUE).expect().statusCode(400).log().ifValidationFails().post(getVersionPrefix() + "/runtimes/schema").as(ApiError.class);
    // then
    assertEquals("TCOMP_JDBC_SQL_SYNTAX_ERROR", response.getCode());
    assertEquals("Table/View 'TOTO' does not exist.", response.getMessage());
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ApiError(org.talend.components.service.rest.impl.ApiError) UiSpecsPropertiesDto(org.talend.components.service.rest.dto.UiSpecsPropertiesDto) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 UiSpecsPropertiesDto (org.talend.components.service.rest.dto.UiSpecsPropertiesDto)1 ApiError (org.talend.components.service.rest.impl.ApiError)1