forked from fanruan/finekit
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.3 KiB
86 lines
2.3 KiB
6 years ago
|
package com.fanruan.api.data.open;
|
||
|
|
||
|
import com.fr.general.data.DataModel;
|
||
|
import com.fr.general.data.TableDataException;
|
||
|
import com.fr.measure.metric.DBMetric;
|
||
|
import com.fr.script.Calculator;
|
||
|
import org.junit.Assert;
|
||
|
import org.junit.Test;
|
||
|
|
||
|
import java.util.Iterator;
|
||
|
|
||
|
/**
|
||
|
* @author richie
|
||
|
* @version 10.0
|
||
|
* Created by richie on 2019-09-04
|
||
|
*/
|
||
|
public class BaseTableDataTest {
|
||
|
|
||
|
@Test
|
||
|
public void testCreate() throws Exception {
|
||
|
Calculator calculator = Calculator.createCalculator();
|
||
|
DemoTableData tableData = new DemoTableData();
|
||
|
DataModel model = tableData.createDataModel(calculator);
|
||
|
Object r = model.getValueAt(0, 0);
|
||
|
Assert.assertEquals("abc", r);
|
||
|
}
|
||
|
|
||
|
|
||
|
private static class DemoTableData extends BaseTableData {
|
||
|
|
||
|
@Override
|
||
|
public DataModel createDataModel(Calculator calculator) {
|
||
|
return new DataModel() {
|
||
|
@Override
|
||
|
public int getColumnCount() throws TableDataException {
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public int getColumnIndex(String s) throws TableDataException {
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public String getColumnName(int i) throws TableDataException {
|
||
|
return "test";
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public boolean hasRow(int i) throws TableDataException {
|
||
|
return i < 1;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public int getRowCount() throws TableDataException {
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public Object getValueAt(int i, int i1) throws TableDataException {
|
||
|
return "abc";
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void release() throws Exception {
|
||
|
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public Iterator getDataIterator() {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public Object getIteratorDataByColumn(Object o, int i) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public DBMetric getMetric() {
|
||
|
return null;
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
}
|