|
|
|
package com.fanruan.api.data;
|
|
|
|
|
|
|
|
import com.fanruan.api.Prepare;
|
|
|
|
import com.fr.base.TableData;
|
|
|
|
import com.fr.config.Configuration;
|
|
|
|
import com.fr.data.TableDataSource;
|
|
|
|
import com.fr.file.TableDataConfig;
|
|
|
|
import com.fr.main.impl.WorkBook;
|
|
|
|
import com.fr.script.Calculator;
|
|
|
|
import com.fr.transaction.Configurations;
|
|
|
|
import com.fr.transaction.Worker;
|
|
|
|
import org.junit.Assert;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author richie
|
|
|
|
* @version 10.0
|
|
|
|
* Created by richie on 2019-08-15
|
|
|
|
*/
|
|
|
|
public class TableDataKitTest extends Prepare {
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getTableData() {
|
|
|
|
TestTD td = new TestTD();
|
|
|
|
Configurations.update(new Worker() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
TableDataConfig.getInstance().addTableData("first", td);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Class<? extends Configuration>[] targets() {
|
|
|
|
return new Class[]{TableDataConfig.class};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Calculator calculator = Calculator.createCalculator();
|
|
|
|
calculator.setAttribute(TableDataSource.KEY, new WorkBook());
|
|
|
|
TableData r = TableDataKit.getTableData(calculator, "first");
|
|
|
|
Assert.assertEquals(td, r);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testGetTableData() {
|
|
|
|
TestTD td = new TestTD();
|
|
|
|
Calculator calculator = Calculator.createCalculator();
|
|
|
|
WorkBook workBook = new WorkBook();
|
|
|
|
workBook.putTableData("test", td);
|
|
|
|
calculator.setAttribute(TableDataSource.KEY, workBook);
|
|
|
|
TableData r = TableDataKit.getTableData(calculator, "test");
|
|
|
|
Assert.assertEquals(td, r);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|