Search in sources :

Example 1 with IDataxContext

use of com.qlangtech.tis.datax.IDataxContext in project plugins by qlangtech.

the class TestDataxMySQLWriter method validateConfigGenerate.

private void validateConfigGenerate(String assertFileName, DataxMySQLWriter mySQLWriter) throws IOException {
    // IDataxProcessor.TableMap tm = new IDataxProcessor.TableMap();
    // tm.setFrom("orderinfo");
    // tm.setTo("orderinfo_new");
    // tm.setSourceCols(Lists.newArrayList("col1", "col2", "col3").stream().map((c) -> {
    // ISelectedTab.ColMeta meta = new ISelectedTab.ColMeta();
    // meta.setName(c);
    // return meta;
    // }).collect(Collectors.toList()));
    Optional<IDataxProcessor.TableMap> tableMap = TestSelectedTabs.createTableMapper();
    IDataxContext subTaskCtx = mySQLWriter.getSubTask(tableMap);
    assertNotNull(subTaskCtx);
    RdbmsDataxContext mySQLDataxContext = (RdbmsDataxContext) subTaskCtx;
    assertEquals("\"`col1`\",\"`col2`\",\"`col3`\"", mySQLDataxContext.getColsQuotes());
    assertEquals(mysqlJdbcUrl, mySQLDataxContext.getJdbcUrl());
    assertEquals("123456", mySQLDataxContext.getPassword());
    assertEquals("orderinfo_new", mySQLDataxContext.tabName);
    assertEquals("root", mySQLDataxContext.getUsername());
    IDataxProcessor processor = EasyMock.mock("dataxProcessor", IDataxProcessor.class);
    IDataxGlobalCfg dataxGlobalCfg = EasyMock.mock("dataxGlobalCfg", IDataxGlobalCfg.class);
    IDataxReader dataxReader = EasyMock.mock("dataxReader", IDataxReader.class);
    EasyMock.expect(processor.getReader(null)).andReturn(dataxReader);
    EasyMock.expect(processor.getWriter(null)).andReturn(mySQLWriter);
    EasyMock.expect(processor.getDataXGlobalCfg()).andReturn(dataxGlobalCfg);
    EasyMock.replay(processor, dataxGlobalCfg, dataxReader);
    DataXCfgGenerator dataProcessor = new DataXCfgGenerator(null, "testDataXName", processor) {

        @Override
        public String getTemplateContent() {
            return mySQLWriter.getTemplate();
        }
    };
    String cfgResult = dataProcessor.generateDataxConfig(null, mySQLWriter, dataxReader, tableMap);
    JsonUtil.assertJSONEqual(this.getClass(), assertFileName, cfgResult, (m, e, a) -> {
        assertEquals(m, e, a);
    });
    EasyMock.verify(processor, dataxGlobalCfg, dataxReader);
}
Also used : DataXCfgGenerator(com.qlangtech.tis.datax.impl.DataXCfgGenerator) IDataxProcessor(com.qlangtech.tis.datax.IDataxProcessor) IDataxGlobalCfg(com.qlangtech.tis.datax.IDataxGlobalCfg) IDataxContext(com.qlangtech.tis.datax.IDataxContext) IDataxReader(com.qlangtech.tis.datax.IDataxReader)

Aggregations

IDataxContext (com.qlangtech.tis.datax.IDataxContext)1 IDataxGlobalCfg (com.qlangtech.tis.datax.IDataxGlobalCfg)1 IDataxProcessor (com.qlangtech.tis.datax.IDataxProcessor)1 IDataxReader (com.qlangtech.tis.datax.IDataxReader)1 DataXCfgGenerator (com.qlangtech.tis.datax.impl.DataXCfgGenerator)1