|
|
@ -1,11 +1,14 @@ |
|
|
|
package com.fr.design.data; |
|
|
|
package com.fr.design.data; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.TableData; |
|
|
|
import com.fr.base.TableData; |
|
|
|
|
|
|
|
import com.fr.data.TableDataSource; |
|
|
|
import com.fr.data.impl.storeproc.StoreProcedure; |
|
|
|
import com.fr.data.impl.storeproc.StoreProcedure; |
|
|
|
import com.fr.design.data.tabledata.wrapper.TableDataFactory; |
|
|
|
import com.fr.design.data.tabledata.wrapper.TableDataFactory; |
|
|
|
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
|
|
|
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
|
|
|
|
|
|
|
import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; |
|
|
|
import com.fr.file.ProcedureConfig; |
|
|
|
import com.fr.file.ProcedureConfig; |
|
|
|
import com.fr.file.TableDataConfig; |
|
|
|
import com.fr.file.TableDataConfig; |
|
|
|
|
|
|
|
import com.fr.invoke.Reflect; |
|
|
|
import org.easymock.EasyMock; |
|
|
|
import org.easymock.EasyMock; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
@ -23,6 +26,7 @@ import java.util.Map; |
|
|
|
@SuppressStaticInitializationFor({"com.fr.design.data.tabledata.wrapper.TableDataFactory"}) |
|
|
|
@SuppressStaticInitializationFor({"com.fr.design.data.tabledata.wrapper.TableDataFactory"}) |
|
|
|
public class DesignTableDataManagerTest { |
|
|
|
public class DesignTableDataManagerTest { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testFireDataChange() { |
|
|
|
public void testFireDataChange() { |
|
|
|
|
|
|
|
|
|
|
@ -99,4 +103,47 @@ public class DesignTableDataManagerTest { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void testGetSelectedColumnNames() throws Exception { |
|
|
|
|
|
|
|
PowerMock.mockStatic(TableDataConfig.class); |
|
|
|
|
|
|
|
PowerMock.mockStatic(TemplateTableDataWrapper.class); |
|
|
|
|
|
|
|
TableDataConfig config = EasyMock.mock(TableDataConfig.class); |
|
|
|
|
|
|
|
TableData td1 = EasyMock.mock(TableData.class); |
|
|
|
|
|
|
|
TableData td2 = EasyMock.mock(TableData.class); |
|
|
|
|
|
|
|
TableDataSource dataSource = EasyMock.mock(TableDataSource.class); |
|
|
|
|
|
|
|
EasyMock.expect(config.getTableData("ds1")).andReturn(td1).anyTimes(); |
|
|
|
|
|
|
|
EasyMock.expect(config.getTableData("ds2")).andReturn(td2).anyTimes(); |
|
|
|
|
|
|
|
EasyMock.expect(dataSource.getTableData("ds1")).andReturn(td1).anyTimes(); |
|
|
|
|
|
|
|
EasyMock.expect(dataSource.getTableData("ds2")).andReturn(td2).anyTimes(); |
|
|
|
|
|
|
|
EasyMock.expect(TableDataConfig.getInstance()).andReturn(config).anyTimes(); |
|
|
|
|
|
|
|
PowerMock.mockStatic(TableDataFactory.class); |
|
|
|
|
|
|
|
EasyMock.expect(TableDataFactory.getSortOfChineseNameOfServerData(config)) |
|
|
|
|
|
|
|
.andReturn(new String[]{"ds1", "ds2"}).anyTimes(); |
|
|
|
|
|
|
|
EasyMock.expect(TableDataFactory.getSortOfChineseNameOfTemplateData(dataSource)) |
|
|
|
|
|
|
|
.andReturn(new String[]{"ds1", "ds2"}); |
|
|
|
|
|
|
|
Map<TableDataSource, Map<String, String[]>> cache = Reflect.on(DesignTableDataManager.class).field( |
|
|
|
|
|
|
|
"columnCache").get(); |
|
|
|
|
|
|
|
Map<String, String[]> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("ds1", new String[]{"a", "b", "c"}); |
|
|
|
|
|
|
|
cache.put(dataSource, map); |
|
|
|
|
|
|
|
ProcedureConfig proConfig = EasyMock.mock(ProcedureConfig.class); |
|
|
|
|
|
|
|
Map<String, StoreProcedure> procedureMap = new HashMap<>(); |
|
|
|
|
|
|
|
EasyMock.expect(proConfig.getProcedures()).andReturn(procedureMap).anyTimes(); |
|
|
|
|
|
|
|
PowerMock.mockStatic(ProcedureConfig.class); |
|
|
|
|
|
|
|
EasyMock.expect(ProcedureConfig.getInstance()).andReturn(proConfig).anyTimes(); |
|
|
|
|
|
|
|
EasyMock.replay(config, proConfig, dataSource); |
|
|
|
|
|
|
|
PowerMock.replay(TableDataFactory.class, TableDataConfig.class, ProcedureConfig.class, |
|
|
|
|
|
|
|
TemplateTableDataWrapper.class); |
|
|
|
|
|
|
|
Assert.assertEquals(new String[]{"a", "b", "c"}, |
|
|
|
|
|
|
|
DesignTableDataManager.getSelectedColumnNames(dataSource, "ds1")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void testAddDsColumnNames() { |
|
|
|
|
|
|
|
DesignTableDataManager.addDsColumnNames("ds1", new String[]{"a", "b", "c"}); |
|
|
|
|
|
|
|
Map<TableDataSource, Map<String, String[]>> map = Reflect.on(DesignTableDataManager.class).field( |
|
|
|
|
|
|
|
"columnCache").get(); |
|
|
|
|
|
|
|
Assert.assertEquals(new String[]{"a", "b", "c"}, map.get(null).get("ds1")); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|