use of org.talend.daikon.NamedThing in project components by Talend.
the class PubSubDatasetProperties method beforeTopic.
public ValidationResult beforeTopic() {
PubSubDatasetDefinition definition = new PubSubDatasetDefinition();
RuntimeInfo runtimeInfo = definition.getRuntimeInfo(this);
try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, getClass().getClassLoader())) {
IPubSubDatasetRuntime runtime = (IPubSubDatasetRuntime) sandboxedInstance.getInstance();
runtime.initialize(null, this);
List<NamedThing> topics = new ArrayList<>();
for (String topicName : runtime.listTopics()) {
topics.add(new SimpleNamedThing(topicName, topicName));
}
topic.setPossibleValues(topics);
return ValidationResult.OK;
} catch (Exception e) {
return new ValidationResult(new ComponentException(e));
}
}
use of org.talend.daikon.NamedThing in project components by Talend.
the class SalesforceDatasetPropertiesTest method testSetDataStorePropertiesWithModuleNameSpecified.
@Test
public void testSetDataStorePropertiesWithModuleNameSpecified() throws Exception {
datastoreProperties.init();
properties.init();
try (MockRuntimeSourceOrSinkTestFixture testFixture = new MockRuntimeSourceOrSinkTestFixture(isA(SalesforceInputProperties.class), createDefaultTestDataset())) {
testFixture.setUp();
properties.moduleName.setValue("Account");
properties.setDatastoreProperties(datastoreProperties);
assertThat((Iterable<String>) properties.moduleName.getPossibleValues(), containsInAnyOrder("Account", "Customer"));
assertThat((Iterable<NamedThing>) properties.selectColumnIds.getPossibleValues(), contains((NamedThing) new SimpleNamedThing("Id", "Id"), new SimpleNamedThing("Name", "Name")));
}
}
use of org.talend.daikon.NamedThing in project components by Talend.
the class OsgiSalesforceEsbTestIT method testStaticGetSchemaNames.
@Test
public void testStaticGetSchemaNames() throws IOException {
SalesforceConnectionProperties scp = setupProps(null, !ADD_QUOTES);
List<NamedThing> schemaNames = SalesforceSourceOrSink.getSchemaNames(null, scp);
assertTrue(schemaNames.size() > 50);
}
use of org.talend.daikon.NamedThing in project components by Talend.
the class SalesforceModuleListPropertiesTest method testBeforeFormPresentMain.
@Test
public void testBeforeFormPresentMain() throws Throwable {
properties.init();
try (MockRuntimeSourceOrSinkTestFixture testFixture = new MockRuntimeSourceOrSinkTestFixture(equalTo(properties), createDefaultTestDataset())) {
testFixture.setUp();
propertiesService.beforeFormPresent("Main", properties);
assertThat((Iterable<NamedThing>) properties.selectedModuleNames.getPossibleValues(), containsInAnyOrder((NamedThing) new SimpleNamedThing("Account"), new SimpleNamedThing("Customer")));
Form mainForm = properties.getForm(Form.MAIN);
assertTrue(mainForm.isAllowBack());
assertTrue(mainForm.isAllowFinish());
}
}
use of org.talend.daikon.NamedThing in project components by Talend.
the class SalesforceSourceOrSink method getSchemaNames.
protected List<NamedThing> getSchemaNames(PartnerConnection connection) throws IOException {
List<NamedThing> returnList = new ArrayList<>();
DescribeGlobalResult result = null;
try {
result = connection.describeGlobal();
} catch (ConnectionException e) {
throw new ComponentException(e);
}
DescribeGlobalSObjectResult[] objects = result.getSobjects();
for (DescribeGlobalSObjectResult obj : objects) {
LOG.debug("module label: " + obj.getLabel() + " name: " + obj.getName());
returnList.add(new SimpleNamedThing(obj.getName(), obj.getLabel()));
}
return returnList;
}
Aggregations