Search in sources :

Example 1 with TMarketoInputProperties

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

the class MarketoSourceOrSinkTest method getTestProps.

public TMarketoInputProperties getTestProps() {
    TMarketoInputProperties props = new TMarketoInputProperties("test");
    props.connection.endpoint.setValue("http://fake.io");
    props.connection.clientAccessId.setValue("client");
    props.connection.secretKey.setValue("sekret");
    return props;
}
Also used : TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties)

Example 2 with TMarketoInputProperties

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

the class MarketoSourceOrSinkTest method testValidate.

@Test
public void testValidate() throws Exception {
    TMarketoInputProperties props = new TMarketoInputProperties("test");
    sos.initialize(null, props);
    assertEquals(Result.ERROR, sos.validate(null).getStatus());
    props.connection.endpoint.setValue("http://fake.io");
    sos.initialize(null, props);
    assertEquals(Result.ERROR, sos.validate(null).getStatus());
    props.connection.clientAccessId.setValue("client");
    sos.initialize(null, props);
    assertEquals(Result.ERROR, sos.validate(null).getStatus());
    props.connection.secretKey.setValue("sekret");
    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 3 with TMarketoInputProperties

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

the class MarketoCustomObjectClientTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    iprops = new TMarketoInputProperties("test");
    iprops.schemaInput.setupProperties();
    iprops.schemaInput.setupLayout();
    iprops.connection.setupProperties();
    iprops.connection.setupLayout();
    iprops.connection.setupProperties();
    iprops.connection.endpoint.setValue("https://fake.io/rest");
    iprops.connection.clientAccessId.setValue("clientaccess");
    iprops.connection.secretKey.setValue("sekret");
    // shorten interval for tests
    iprops.connection.attemptsIntervalTime.setValue(200);
    iprops.setupProperties();
    iprops.setupLayout();
    iprops.customObjectName.setValue("car_c");
    iprops.inputOperation.setValue(InputOperation.CustomObject);
    oprops = new TMarketoOutputProperties("test");
    oprops.schemaInput.setupProperties();
    oprops.schemaInput.setupLayout();
    oprops.connection.setupProperties();
    oprops.connection.setupLayout();
    oprops.connection.setupProperties();
    oprops.connection.endpoint.setValue("https://fake.io/rest");
    oprops.connection.clientAccessId.setValue("clientaccess");
    oprops.connection.secretKey.setValue("sekret");
    // shorten interval for tests
    oprops.connection.attemptsIntervalTime.setValue(200);
    oprops.setupProperties();
    oprops.setupLayout();
    oprops.customObjectName.setValue("car_c");
}
Also used : TMarketoOutputProperties(org.talend.components.marketo.tmarketooutput.TMarketoOutputProperties) TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) Before(org.junit.Before)

Example 4 with TMarketoInputProperties

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

the class MarketoInputReaderTest method getReaderForRetryOperation.

public MarketoInputReader getReaderForRetryOperation(boolean die) {
    TMarketoInputProperties props = new TMarketoInputProperties("test");
    props.connection.setupProperties();
    props.setupProperties();
    props.inputOperation.setValue(InputOperation.getMultipleLeads);
    props.updateSchemaRelated();
    props.dieOnError.setValue(die);
    source.initialize(null, props);
    when(source.createReader(null)).thenReturn(new MarketoInputReader(null, source, props));
    reader = (MarketoInputReader) source.createReader(null);
    return reader;
}
Also used : TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties)

Example 5 with TMarketoInputProperties

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

the class MarketoInputReaderTest method testExecuteOperation.

@Test
public void testExecuteOperation() throws Exception {
    TMarketoInputProperties props = new TMarketoInputProperties("test");
    props.connection.init();
    props.init();
    props.inputOperation.setValue(InputOperation.getLeadChanges);
    props.updateSchemaRelated();
    props.schemaInput.schema.setValue(getFullDynamicSchema());
    props.dieOnError.setValue(false);
    source.initialize(null, props);
    when(source.createReader(null)).thenReturn(new MarketoInputReader(null, source, props));
    reader = (MarketoInputReader) source.createReader(null);
    assertFalse(reader.start());
    // 
    props.inputOperation.setValue(InputOperation.getMultipleLeads);
    props.updateSchemaRelated();
    props.schemaInput.schema.setValue(getFullDynamicSchema());
    source.initialize(null, props);
    when(source.createReader(null)).thenReturn(new MarketoInputReader(null, source, props));
    when(source.getDynamicSchema(any(String.class), any(Schema.class))).thenReturn(MarketoConstants.getRESTSchemaForGetLeadOrGetMultipleLeads());
    reader = (MarketoInputReader) source.createReader(null);
    assertFalse(reader.start());
    // 
    props.inputOperation.setValue(InputOperation.CustomObject);
    props.customObjectAction.setValue(CustomObjectAction.describe);
    props.updateSchemaRelated();
    props.schemaInput.schema.setValue(getFullDynamicSchema());
    source.initialize(null, props);
    when(source.createReader(null)).thenReturn(new MarketoInputReader(null, source, props));
    when(source.getDynamicSchema(any(String.class), any(Schema.class))).thenReturn(MarketoConstants.getRESTSchemaForGetLeadOrGetMultipleLeads());
    reader = (MarketoInputReader) source.createReader(null);
    assertFalse(reader.start());
    // 
    props.customObjectAction.setValue(CustomObjectAction.get);
    props.updateSchemaRelated();
    props.schemaInput.schema.setValue(getFullDynamicSchema());
    source.initialize(null, props);
    when(source.createReader(null)).thenReturn(new MarketoInputReader(null, source, props));
    when(source.getDynamicSchema(any(String.class), any(Schema.class))).thenReturn(MarketoConstants.getRESTSchemaForGetLeadOrGetMultipleLeads());
    reader = (MarketoInputReader) source.createReader(null);
    assertFalse(reader.start());
    // 
    props.customObjectAction.setValue(CustomObjectAction.list);
    props.updateSchemaRelated();
    props.schemaInput.schema.setValue(getFullDynamicSchema());
    source.initialize(null, props);
    when(source.createReader(null)).thenReturn(new MarketoInputReader(null, source, props));
    when(source.getDynamicSchema(any(String.class), any(Schema.class))).thenReturn(MarketoConstants.getRESTSchemaForGetLeadOrGetMultipleLeads());
    reader = (MarketoInputReader) source.createReader(null);
    assertFalse(reader.start());
    // 
    props.customObjectAction.setValue(CustomObjectAction.get);
    props.updateSchemaRelated();
    props.schemaInput.schema.setValue(getFullDynamicSchema());
    source.initialize(null, props);
    when(source.createReader(null)).thenReturn(new MarketoInputReader(null, source, props));
    when(source.getDynamicSchema(any(String.class), any(Schema.class))).thenThrow(new IOException("error"));
    reader = (MarketoInputReader) source.createReader(null);
    try {
        assertFalse(reader.start());
        fail("Should not be here");
    } catch (IOException e) {
    }
// 
}
Also used : Schema(org.apache.avro.Schema) TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) IOException(java.io.IOException) Test(org.junit.Test)

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