use of org.talend.components.service.rest.dto.UiSpecsPropertiesDto in project components by Talend.
the class JdbcComponentTestIT method testGetDataBinary.
@Test
public void testGetDataBinary() 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";
// when
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());
Response response = //
given().content(propertiesDto).contentType(APPLICATION_JSON_UTF8_VALUE).accept(//
RuntimesController.AVRO_BINARY_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.binaryDecoder(response.asInputStream(), null);
assertRecordsEqualsToTestValues(reader, decoder);
}
use of org.talend.components.service.rest.dto.UiSpecsPropertiesDto in project components by Talend.
the class JdbcComponentTestIT method testGetSchema.
@Test
public void testGetSchema() throws java.io.IOException {
// given
UiSpecsPropertiesDto propertiesDto = new UiSpecsPropertiesDto();
propertiesDto.setProperties(getFileAsObjectNode("jdbc_data_set_properties_no_schema.json"));
propertiesDto.setDependencies(singletonList(getJdbcDataStoreProperties()));
String dataSetDefinitionName = "JDBCDataset";
// when
Response response = //
given().content(propertiesDto).contentType(APPLICATION_JSON_UTF8_VALUE).accept(//
APPLICATION_JSON_UTF8_VALUE).expect().statusCode(200).log().ifError().post(getVersionPrefix() + "/runtimes/schema");
// then
ObjectNode result = getResponseAsObjectNode(response);
ObjectNode expected = getFileAsObjectNode("jdbc_data_set_schema.json");
assertEquals(expected, result);
}
use of org.talend.components.service.rest.dto.UiSpecsPropertiesDto in project components by Talend.
the class JdbcComponentTestIT method getJdbcDataSetProperties.
@Test
public void getJdbcDataSetProperties() throws java.io.IOException {
// given
UiSpecsPropertiesDto properties = new UiSpecsPropertiesDto();
properties.setProperties(getJdbcDataStoreProperties());
// when
Response response = //
given().content(properties).contentType(ServiceConstants.UI_SPEC_CONTENT_TYPE).accept(//
ServiceConstants.UI_SPEC_CONTENT_TYPE).expect().statusCode(200).log().ifError().post(getVersionPrefix() + "/properties/dataset");
// then
ObjectNode dataSetProperties = mapper.readerFor(ObjectNode.class).readValue(response.asInputStream());
assertNotNull(dataSetProperties);
}
Aggregations