use of com.qlangtech.tis.datax.IDataxGlobalCfg in project plugins by qlangtech.
the class DefaultDataxProcessor method getDataXGlobalCfg.
public IDataxGlobalCfg getDataXGlobalCfg() {
IDataxGlobalCfg globalCfg = ParamsConfig.getItem(this.globalCfg, IDataxGlobalCfg.KEY_DISPLAY_NAME);
Objects.requireNonNull(globalCfg, "dataX Global config can not be null");
return globalCfg;
}
use of com.qlangtech.tis.datax.IDataxGlobalCfg 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);
}
use of com.qlangtech.tis.datax.IDataxGlobalCfg in project plugins by qlangtech.
the class TestDataXOssWriter method testTempateGenerate.
public void testTempateGenerate() throws Exception {
IDataxProcessor processor = EasyMock.mock("dataxProcessor", IDataxProcessor.class);
IDataxGlobalCfg dataxGlobalCfg = EasyMock.mock("dataxGlobalCfg", IDataxGlobalCfg.class);
EasyMock.expect(processor.getDataXGlobalCfg()).andReturn(dataxGlobalCfg).anyTimes();
// IDataxWriter dataxWriter = EasyMock.mock("dataxWriter", IDataxWriter.class);
// IDataxContext dataxContext = EasyMock.mock("dataxWriterContext", IDataxContext.class);
// EasyMock.expect(dataxWriter.getSubTask(Optional.empty())).andReturn(dataxContext).anyTimes();
DataXOssWriter ossWriter = new DataXOssWriter();
ossWriter.endpoint = "aliyun-bj-endpoint";
ossWriter.bucket = "testBucket";
ossWriter.object = "tis/mytable/*";
ossWriter.template = DataXOssWriter.getDftTemplate();
ossWriter.header = "[\"name\",\"age\",\"degree\"]";
ossWriter.encoding = "utf-8";
ossWriter.fieldDelimiter = "\t";
ossWriter.writeMode = "nonConflict";
ossWriter.dateFormat = "yyyy-MM-dd";
ossWriter.fileFormat = "csv";
ossWriter.maxFileSize = 300;
ossWriter.nullFormat = "\\\\N";
EasyMock.expect(processor.getWriter(null)).andReturn(ossWriter).anyTimes();
EasyMock.replay(processor, dataxGlobalCfg);
valiateWriterCfgGenerate("oss-datax-writer-assert.json", processor, ossWriter);
ossWriter.fieldDelimiter = null;
ossWriter.encoding = null;
ossWriter.nullFormat = null;
ossWriter.dateFormat = null;
ossWriter.fileFormat = null;
ossWriter.header = null;
ossWriter.maxFileSize = null;
valiateWriterCfgGenerate("oss-datax-writer-assert-without-option-val.json", processor, ossWriter);
EasyMock.verify(processor, dataxGlobalCfg);
}
Aggregations