use of org.talend.components.service.rest.dto.UiSpecsPropertiesDto in project components by Talend.
the class AbstractSpringIntegrationTests method buildTestDataSetFormData.
protected UiSpecsPropertiesDto buildTestDataSetFormData() throws java.io.IOException {
UiSpecsPropertiesDto formDataContainer = new UiSpecsPropertiesDto();
ObjectReader reader = mapper.readerFor(ObjectNode.class);
formDataContainer.setDependencies(singletonList(reader.readValue(TEST_DATA_STORE_PROPERTIES)));
formDataContainer.setProperties(reader.readValue(TEST_DATA_SET_PROPERTIES));
return formDataContainer;
}
use of org.talend.components.service.rest.dto.UiSpecsPropertiesDto in project components by Talend.
the class RuntimeControllerImplTest method getDatasetSchemaUiSpec.
@Test
public void getDatasetSchemaUiSpec() throws Exception {
// given
UiSpecsPropertiesDto formDataContainer = buildTestDataSetFormData();
//
given().accept(APPLICATION_JSON_UTF8_VALUE).with().content(//
formDataContainer).contentType(//
ServiceConstants.UI_SPEC_CONTENT_TYPE).when().post(//
getVersionPrefix() + "/runtimes/schema").then().statusCode(200).log().ifError().assertThat().body(equalTo(MockDatasetRuntime.getSchemaJsonRepresentation()));
}
use of org.talend.components.service.rest.dto.UiSpecsPropertiesDto in project components by Talend.
the class JdbcComponentTestIT method validateDataStoreConnection.
@Test
public void validateDataStoreConnection() throws java.io.IOException {
// given
UiSpecsPropertiesDto properties = new UiSpecsPropertiesDto();
properties.setProperties(getJdbcDataStoreProperties());
// when
//
given().content(properties).contentType(APPLICATION_JSON_UTF8_VALUE).accept(//
APPLICATION_JSON_UTF8_VALUE).expect().statusCode(200).log().ifError().post(getVersionPrefix() + "/runtimes/check");
}
use of org.talend.components.service.rest.dto.UiSpecsPropertiesDto 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());
}
use of org.talend.components.service.rest.dto.UiSpecsPropertiesDto in project components by Talend.
the class JdbcComponentTestIT method testGetData.
@Test
public void testGetData() throws java.io.IOException {
// given
UiSpecsPropertiesDto propertiesDto = new UiSpecsPropertiesDto();
propertiesDto.setProperties(getFileAsObjectNode("jdbc_data_set_properties_with_schema.json"));
propertiesDto.setDependencies(singletonList(getJdbcDataStoreProperties()));
String dataSetDefinitionName = "JDBCDataset";
Response schemaResponse = //
given().content(propertiesDto).contentType(APPLICATION_JSON_UTF8_VALUE).accept(//
APPLICATION_JSON_UTF8_VALUE).expect().statusCode(200).log().ifError().post(getVersionPrefix() + "/runtimes/schema");
Schema schema = new Schema.Parser().parse(schemaResponse.asInputStream());
// when
Response response = //
given().content(propertiesDto).contentType(APPLICATION_JSON_UTF8_VALUE).accept(//
RuntimesController.AVRO_JSON_MIME_TYPE_OFFICIAL_INVALID).expect().statusCode(200).log().ifError().post(getVersionPrefix() + "/runtimes/data");
// then
GenericDatumReader<GenericRecord> reader = new GenericDatumReader<>(schema);
DecoderFactory decoderFactory = DecoderFactory.get();
Decoder decoder = decoderFactory.jsonDecoder(schema, response.asInputStream());
assertRecordsEqualsToTestValues(reader, decoder);
}
Aggregations