Search in sources :

Example 21 with TMarketoInputProperties

use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.

the class MarketoSourceOrSinkTestIT method testGetEndpointSchema.

@Test
public void testGetEndpointSchema() throws Exception {
    TMarketoInputProperties props = new TMarketoInputProperties("test");
    props.connection.setupProperties();
    props.setupProperties();
    props.connection.endpoint.setValue(MarketoBaseTestIT.ENDPOINT_REST);
    props.connection.clientAccessId.setValue(MarketoBaseTestIT.USERID_REST);
    props.connection.secretKey.setValue(MarketoBaseTestIT.SECRETKEY_REST);
    MarketoSourceOrSink sos = new MarketoSourceOrSink();
    sos.initialize(null, props);
    Schema s = sos.getEndpointSchema(null, "smartphone_c");
    LOG.debug("s = {}.", s);
    assertTrue(s.getFields().size() > 0);
    Schema.Field f = s.getField("model");
    assertNotNull(f);
    assertEquals("true", f.getProp(SchemaConstants.TALEND_COLUMN_IS_KEY));
}
Also used : Schema(org.apache.avro.Schema) TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) Test(org.junit.Test)

Example 22 with TMarketoInputProperties

use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.

the class MarketoSourceOrSinkTestIT method validate.

@Test
public void validate() throws Exception {
    TMarketoInputProperties props = new TMarketoInputProperties("test");
    sos.initialize(null, props);
    assertEquals(Result.ERROR, sos.validate(null).getStatus());
}
Also used : TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) Test(org.junit.Test)

Example 23 with TMarketoInputProperties

use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.

the class MarketoSourceOrSinkTestIT method initialize.

@Test
public void initialize() throws Exception {
    TMarketoInputProperties props = new TMarketoInputProperties("test");
    assertEquals(ValidationResult.OK, sos.initialize(null, props));
}
Also used : TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) Test(org.junit.Test)

Example 24 with TMarketoInputProperties

use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.

the class MarketoSourceOrSinkTestIT method setUp.

@Before
public void setUp() throws Exception {
    sos = new MarketoSourceOrSink();
    props = new TMarketoInputProperties("test");
    props.connection.setupProperties();
    props.setupProperties();
    props.connection.endpoint.setValue(MarketoBaseTestIT.ENDPOINT_REST);
    props.connection.clientAccessId.setValue(MarketoBaseTestIT.USERID_REST);
    props.connection.secretKey.setValue(MarketoBaseTestIT.SECRETKEY_REST);
    sos.initialize(null, props);
}
Also used : TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) Before(org.junit.Before)

Example 25 with TMarketoInputProperties

use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.

the class MarketoSourceOrSink method getCompoundKeyFields.

@Override
public List<String> getCompoundKeyFields(String resource) throws IOException {
    MarketoRESTClient client = (MarketoRESTClient) getClientService(null);
    TMarketoInputProperties ip = new TMarketoInputProperties("retrieveSchema");
    Schema describeSchema = MarketoConstants.getCustomObjectDescribeSchema();
    ip.connection = properties.getConnectionProperties();
    ip.inputOperation.setValue(InputOperation.CustomObject);
    ip.customObjectAction.setValue(CustomObjectAction.describe);
    ip.customObjectName.setValue(resource);
    ip.schemaInput.schema.setValue(describeSchema);
    MarketoRecordResult r = client.describeCustomObject(ip);
    if (!r.isSuccess()) {
        return null;
    }
    List<IndexedRecord> records = r.getRecords();
    if (records == null || records.isEmpty()) {
        return null;
    }
    IndexedRecord record = records.get(0);
    String[] keys = new Gson().fromJson(record.get(describeSchema.getField("dedupeFields").pos()).toString(), String[].class);
    return Arrays.asList(keys);
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) Schema(org.apache.avro.Schema) Gson(com.google.gson.Gson) TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) MarketoRESTClient(org.talend.components.marketo.runtime.client.MarketoRESTClient) MarketoRecordResult(org.talend.components.marketo.runtime.client.type.MarketoRecordResult)

Aggregations

TMarketoInputProperties (org.talend.components.marketo.tmarketoinput.TMarketoInputProperties)45 Test (org.junit.Test)25 Before (org.junit.Before)11 IndexedRecord (org.apache.avro.generic.IndexedRecord)10 TMarketoOutputProperties (org.talend.components.marketo.tmarketooutput.TMarketoOutputProperties)9 TMarketoListOperationProperties (org.talend.components.marketo.tmarketolistoperation.TMarketoListOperationProperties)6 Date (java.util.Date)5 Schema (org.apache.avro.Schema)5 SimpleDateFormat (java.text.SimpleDateFormat)4 MarketoRecordResult (org.talend.components.marketo.runtime.client.type.MarketoRecordResult)4 RuntimeContainer (org.talend.components.api.container.RuntimeContainer)2 MarketoRESTClient (org.talend.components.marketo.runtime.client.MarketoRESTClient)2 TMarketoBulkExecProperties (org.talend.components.marketo.tmarketobulkexec.TMarketoBulkExecProperties)2 LeadSelector (org.talend.components.marketo.tmarketoinput.TMarketoInputProperties.LeadSelector)2 NamedThing (org.talend.daikon.NamedThing)2 ValidationResult (org.talend.daikon.properties.ValidationResult)2 ValidationResultMutable (org.talend.daikon.properties.ValidationResultMutable)2 Gson (com.google.gson.Gson)1 AuthenticationHeader (com.marketo.mktows.AuthenticationHeader)1 MktowsPort (com.marketo.mktows.MktowsPort)1