Search in sources :

Example 1 with IDataSourceFactoryGetter

use of com.qlangtech.tis.plugin.ds.IDataSourceFactoryGetter in project plugins by qlangtech.

the class TestDataXMongodbWriter method testDescriptorsJSONGenerate.

public void testDescriptorsJSONGenerate() {
    DataxReader dataxReader = EasyMock.createMock("dataxReader", DataxReader.class);
    List<ISelectedTab> selectedTabs = TestSelectedTabs.createSelectedTabs(1).stream().map((t) -> t).collect(Collectors.toList());
    for (ISelectedTab tab : selectedTabs) {
        for (ISelectedTab.ColMeta cm : tab.getCols()) {
            cm.setType(DataXReaderColType.STRING.dataType);
        }
    }
    EasyMock.expect(dataxReader.getSelectedTabs()).andReturn(selectedTabs).times(4);
    DataxReader.dataxReaderThreadLocal.set(dataxReader);
    EasyMock.replay(dataxReader);
    DataXMongodbWriter writer = new DataXMongodbWriter();
    assertTrue(writer instanceof IDataSourceFactoryGetter);
    DescriptorsJSON descJson = new DescriptorsJSON(writer.getDescriptor());
    JsonUtil.assertJSONEqual(DataXMongodbWriter.class, "mongdodb-datax-writer-descriptor.json", descJson.getDescriptorsJSON(), (m, e, a) -> {
        assertEquals(m, e, a);
    });
    JsonUtil.assertJSONEqual(DataXMongodbWriter.class, "mongdodb-datax-writer-descriptor.json", descJson.getDescriptorsJSON(), (m, e, a) -> {
        assertEquals(m, e, a);
    });
    EasyMock.verify(dataxReader);
}
Also used : PluginExtraProps(com.qlangtech.tis.extension.util.PluginExtraProps) ISelectedTab(com.qlangtech.tis.plugin.ds.ISelectedTab) MangoDBDataSourceFactory(com.qlangtech.tis.plugin.ds.mangodb.MangoDBDataSourceFactory) EasyMock(org.easymock.EasyMock) TestSelectedTabs(com.qlangtech.tis.plugin.datax.test.TestSelectedTabs) Collectors(java.util.stream.Collectors) DescriptorsJSON(com.qlangtech.tis.util.DescriptorsJSON) JsonUtil(com.qlangtech.tis.trigger.util.JsonUtil) DataXReaderColType(com.qlangtech.tis.plugin.ds.DataXReaderColType) IDataSourceFactoryGetter(com.qlangtech.tis.plugin.ds.IDataSourceFactoryGetter) List(java.util.List) DataxReader(com.qlangtech.tis.datax.impl.DataxReader) IOUtils(com.qlangtech.tis.extension.impl.IOUtils) Optional(java.util.Optional) TestCase(junit.framework.TestCase) WriterTemplate(com.qlangtech.tis.plugin.common.WriterTemplate) ISelectedTab(com.qlangtech.tis.plugin.ds.ISelectedTab) DescriptorsJSON(com.qlangtech.tis.util.DescriptorsJSON) DataxReader(com.qlangtech.tis.datax.impl.DataxReader) IDataSourceFactoryGetter(com.qlangtech.tis.plugin.ds.IDataSourceFactoryGetter)

Aggregations

DataxReader (com.qlangtech.tis.datax.impl.DataxReader)1 IOUtils (com.qlangtech.tis.extension.impl.IOUtils)1 PluginExtraProps (com.qlangtech.tis.extension.util.PluginExtraProps)1 WriterTemplate (com.qlangtech.tis.plugin.common.WriterTemplate)1 TestSelectedTabs (com.qlangtech.tis.plugin.datax.test.TestSelectedTabs)1 DataXReaderColType (com.qlangtech.tis.plugin.ds.DataXReaderColType)1 IDataSourceFactoryGetter (com.qlangtech.tis.plugin.ds.IDataSourceFactoryGetter)1 ISelectedTab (com.qlangtech.tis.plugin.ds.ISelectedTab)1 MangoDBDataSourceFactory (com.qlangtech.tis.plugin.ds.mangodb.MangoDBDataSourceFactory)1 JsonUtil (com.qlangtech.tis.trigger.util.JsonUtil)1 DescriptorsJSON (com.qlangtech.tis.util.DescriptorsJSON)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 TestCase (junit.framework.TestCase)1 EasyMock (org.easymock.EasyMock)1