Search in sources :

Example 6 with UiSpecsPropertiesDto

use of org.talend.components.service.rest.dto.UiSpecsPropertiesDto in project components by Talend.

the class DatasetWritePayload method readData.

public static DatasetWritePayload readData(InputStream input, ObjectMapper mapper) throws IOException {
    JsonParser parser = mapper.getFactory().createParser(input);
    JsonToken objectStartToken = parser.nextToken();
    isTrue(START_OBJECT == objectStartToken, invalidInputMessage(START_OBJECT, objectStartToken));
    UiSpecsPropertiesDto configuration = readConfiguration(parser);
    Schema schema = readAvroSchema(parser);
    Iterator<IndexedRecord> streamToReadData = createStreamToReadData(parser, mapper, schema, input);
    return new DatasetWritePayload(configuration, streamToReadData, parser);
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) Schema(org.apache.avro.Schema) JsonToken(com.fasterxml.jackson.core.JsonToken) UiSpecsPropertiesDto(org.talend.components.service.rest.dto.UiSpecsPropertiesDto) JsonParser(com.fasterxml.jackson.core.JsonParser)

Example 7 with UiSpecsPropertiesDto

use of org.talend.components.service.rest.dto.UiSpecsPropertiesDto in project components by Talend.

the class AbstractSpringIntegrationTests method buildTestDataStoreFormData.

protected UiSpecsPropertiesDto buildTestDataStoreFormData() throws java.io.IOException {
    UiSpecsPropertiesDto formDataContainer = new UiSpecsPropertiesDto();
    formDataContainer.setProperties(mapper.readerFor(ObjectNode.class).readValue(TEST_DATA_STORE_PROPERTIES));
    return formDataContainer;
}
Also used : UiSpecsPropertiesDto(org.talend.components.service.rest.dto.UiSpecsPropertiesDto)

Example 8 with UiSpecsPropertiesDto

use of org.talend.components.service.rest.dto.UiSpecsPropertiesDto in project components by Talend.

the class RuntimeControllerImplTest method validateConnectionUiSpecs.

@Test
public void validateConnectionUiSpecs() throws Exception {
    UiSpecsPropertiesDto propertiesDto = buildTestDataStoreFormData();
    // 
    given().accept(APPLICATION_JSON_UTF8_VALUE).with().content(// 
    propertiesDto).contentType(// 
    ServiceConstants.UI_SPEC_CONTENT_TYPE).when().post(// 
    getVersionPrefix() + "/runtimes/check").then().statusCode(HttpStatus.OK.value()).log().ifError().assertThat().body(// 
    notNullValue()).assertThat().body(instanceOf(String.class));
}
Also used : UiSpecsPropertiesDto(org.talend.components.service.rest.dto.UiSpecsPropertiesDto) Test(org.junit.Test)

Example 9 with UiSpecsPropertiesDto

use of org.talend.components.service.rest.dto.UiSpecsPropertiesDto in project components by Talend.

the class RuntimeControllerImplTest method getDatasetDataUisSpecs.

@Test
public void getDatasetDataUisSpecs() 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/data").then().statusCode(200).log().ifError().assertThat().body(equalTo(MockDatasetRuntime.getRecordJsonRepresentation()));
}
Also used : UiSpecsPropertiesDto(org.talend.components.service.rest.dto.UiSpecsPropertiesDto) Test(org.junit.Test)

Example 10 with UiSpecsPropertiesDto

use of org.talend.components.service.rest.dto.UiSpecsPropertiesDto in project components by Talend.

the class JdbcComponentTestIT method testTrigger.

@Test
public void testTrigger() throws java.io.IOException {
    // given
    String triggerName = "after";
    String triggerProperty = "dbTypes";
    UiSpecsPropertiesDto properties = new UiSpecsPropertiesDto();
    properties.setProperties(getFileAsObjectNode("jdbc_data_store_properties.json"));
    // 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/trigger/{trigger}/{property}", triggerName, triggerProperty);
    ObjectNode jdbcPropertiesAfterTrigger = getResponseAsObjectNode(response);
    // then
    // should resemble jdbc_data_store_form_after_trigger.json
    assertNotNull(jdbcPropertiesAfterTrigger.get("jsonSchema"));
    assertNotNull(jdbcPropertiesAfterTrigger.get("properties"));
    assertNotNull(jdbcPropertiesAfterTrigger.get("uiSchema"));
    assertEquals("JDBCDatastore", jdbcPropertiesAfterTrigger.get("properties").get("@definitionName").textValue());
}
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