Search in sources :

Example 1 with UiSpecsPropertiesDto

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;
}
Also used : ObjectReader(com.fasterxml.jackson.databind.ObjectReader) UiSpecsPropertiesDto(org.talend.components.service.rest.dto.UiSpecsPropertiesDto)

Example 2 with UiSpecsPropertiesDto

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()));
}
Also used : UiSpecsPropertiesDto(org.talend.components.service.rest.dto.UiSpecsPropertiesDto) Test(org.junit.Test)

Example 3 with UiSpecsPropertiesDto

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");
}
Also used : UiSpecsPropertiesDto(org.talend.components.service.rest.dto.UiSpecsPropertiesDto) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with UiSpecsPropertiesDto

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());
}
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)

Example 5 with UiSpecsPropertiesDto

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);
}
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)

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