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