Search in sources :

Example 11 with UiSpecsPropertiesDto

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);
}
Also used : Response(com.jayway.restassured.response.Response) GenericDatumReader(org.apache.avro.generic.GenericDatumReader) Schema(org.apache.avro.Schema) DecoderFactory(org.apache.avro.io.DecoderFactory) GenericRecord(org.apache.avro.generic.GenericRecord) Decoder(org.apache.avro.io.Decoder) UiSpecsPropertiesDto(org.talend.components.service.rest.dto.UiSpecsPropertiesDto) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with UiSpecsPropertiesDto

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);
}
Also used : Response(com.jayway.restassured.response.Response) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) UiSpecsPropertiesDto(org.talend.components.service.rest.dto.UiSpecsPropertiesDto) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with UiSpecsPropertiesDto

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);
}
Also used : Response(com.jayway.restassured.response.Response) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) UiSpecsPropertiesDto(org.talend.components.service.rest.dto.UiSpecsPropertiesDto) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

UiSpecsPropertiesDto (org.talend.components.service.rest.dto.UiSpecsPropertiesDto)13 Test (org.junit.Test)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 Response (com.jayway.restassured.response.Response)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 Schema (org.apache.avro.Schema)3 GenericDatumReader (org.apache.avro.generic.GenericDatumReader)2 GenericRecord (org.apache.avro.generic.GenericRecord)2 Decoder (org.apache.avro.io.Decoder)2 DecoderFactory (org.apache.avro.io.DecoderFactory)2 JsonParser (com.fasterxml.jackson.core.JsonParser)1 JsonToken (com.fasterxml.jackson.core.JsonToken)1 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)1 IndexedRecord (org.apache.avro.generic.IndexedRecord)1 ApiError (org.talend.components.service.rest.impl.ApiError)1