提交 06d3b4bb 编写于 作者: 庄家钜's avatar 庄家钜

修改单元测试

上级 316db1f2
package com.alibaba.excel.metadata;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import com.alibaba.excel.converters.Converter;
......@@ -55,19 +54,16 @@ public abstract class AbstractHolder implements ConfigurationHolder {
}
this.globalConfiguration = new GlobalConfiguration();
if (basicParameter.getAutoTrim() == null) {
if (prentAbstractHolder == null) {
globalConfiguration.setAutoTrim(Boolean.TRUE);
} else {
if (prentAbstractHolder != null) {
globalConfiguration.setAutoTrim(prentAbstractHolder.getGlobalConfiguration().getAutoTrim());
}
} else {
globalConfiguration.setAutoTrim(basicParameter.getAutoTrim());
}
if (basicParameter.getLocale() == null) {
if (prentAbstractHolder == null) {
globalConfiguration.setLocale(Locale.getDefault());
} else {
if (prentAbstractHolder != null) {
globalConfiguration.setLocale(prentAbstractHolder.getGlobalConfiguration().getLocale());
}
} else {
......
......@@ -2,11 +2,14 @@ package com.alibaba.excel.metadata;
import java.util.Locale;
import lombok.Data;
/**
* Global configuration
*
* @author Jiaju Zhuang
*/
@Data
public class GlobalConfiguration {
/**
* Automatic trim includes sheet name and content
......@@ -32,35 +35,10 @@ public class GlobalConfiguration {
*/
private Boolean useScientificFormat;
public Boolean getUse1904windowing() {
return use1904windowing;
}
public void setUse1904windowing(Boolean use1904windowing) {
this.use1904windowing = use1904windowing;
}
public Boolean getAutoTrim() {
return autoTrim;
}
public void setAutoTrim(Boolean autoTrim) {
this.autoTrim = autoTrim;
}
public Locale getLocale() {
return locale;
}
public void setLocale(Locale locale) {
this.locale = locale;
}
public Boolean getUseScientificFormat() {
return useScientificFormat;
}
public void setUseScientificFormat(Boolean useScientificFormat) {
this.useScientificFormat = useScientificFormat;
public GlobalConfiguration() {
this.autoTrim = Boolean.TRUE;
this.use1904windowing = Boolean.FALSE;
this.locale = Locale.getDefault();
this.useScientificFormat = Boolean.FALSE;
}
}
......@@ -49,19 +49,20 @@ public abstract class AbstractReadHolder extends AbstractHolder implements ReadH
public AbstractReadHolder(ReadBasicParameter readBasicParameter, AbstractReadHolder parentAbstractReadHolder,
Boolean convertAllFiled) {
super(readBasicParameter, parentAbstractReadHolder);
if (readBasicParameter.getUse1904windowing() == null && parentAbstractReadHolder != null) {
getGlobalConfiguration()
.setUse1904windowing(parentAbstractReadHolder.getGlobalConfiguration().getUse1904windowing());
if (readBasicParameter.getUse1904windowing() == null) {
if (parentAbstractReadHolder != null) {
getGlobalConfiguration()
.setUse1904windowing(parentAbstractReadHolder.getGlobalConfiguration().getUse1904windowing());
}
} else {
getGlobalConfiguration().setUse1904windowing(readBasicParameter.getUse1904windowing());
}
if (readBasicParameter.getUseScientificFormat() == null) {
if (parentAbstractReadHolder == null) {
getGlobalConfiguration().setUseScientificFormat(Boolean.FALSE);
} else {
getGlobalConfiguration()
.setUseScientificFormat(parentAbstractReadHolder.getGlobalConfiguration().getUseScientificFormat());
if (parentAbstractReadHolder != null) {
getGlobalConfiguration().setUseScientificFormat(
parentAbstractReadHolder.getGlobalConfiguration().getUseScientificFormat());
}
} else {
getGlobalConfiguration().setUseScientificFormat(readBasicParameter.getUseScientificFormat());
......@@ -114,7 +115,6 @@ public abstract class AbstractReadHolder extends AbstractHolder implements ReadH
}
}
@Override
public List<ReadListener<?>> readListenerList() {
return getReadListenerList();
......
......@@ -96,10 +96,9 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
public AbstractWriteHolder(WriteBasicParameter writeBasicParameter, AbstractWriteHolder parentAbstractWriteHolder,
Boolean convertAllField) {
super(writeBasicParameter, parentAbstractWriteHolder);
if (writeBasicParameter.getUse1904windowing() == null) {
if (parentAbstractWriteHolder == null) {
getGlobalConfiguration().setUse1904windowing(Boolean.FALSE);
} else {
if (parentAbstractWriteHolder != null) {
getGlobalConfiguration()
.setUse1904windowing(parentAbstractWriteHolder.getGlobalConfiguration().getUse1904windowing());
}
......@@ -210,7 +209,6 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
}
}
protected void initAnnotationConfig(List<WriteHandler> handlerList, WriteBasicParameter writeBasicParameter) {
if (!HeadKindEnum.CLASS.equals(getExcelWriteHeadProperty().getHeadKind())) {
return;
......@@ -310,7 +308,6 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
handlerList.add(columnWidthStyleStrategy);
}
protected Map<Class<? extends WriteHandler>, List<WriteHandler>> sortAndClearUpAllHandler(
List<WriteHandler> handlerList, Map<Class<? extends WriteHandler>, List<WriteHandler>> parentHandlerMap) {
// add
......@@ -330,7 +327,7 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
for (WriteHandler handler : handlerList) {
int order = Integer.MIN_VALUE;
if (handler instanceof Order) {
order = ((Order) handler).order();
order = ((Order)handler).order();
}
if (orderExcelWriteHandlerMap.containsKey(order)) {
orderExcelWriteHandlerMap.get(order).add(handler);
......@@ -346,7 +343,7 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ
for (Map.Entry<Integer, List<WriteHandler>> entry : orderExcelWriteHandlerMap.entrySet()) {
for (WriteHandler handler : entry.getValue()) {
if (handler instanceof NotRepeatExecutor) {
String uniqueValue = ((NotRepeatExecutor) handler).uniqueValue();
String uniqueValue = ((NotRepeatExecutor)handler).uniqueValue();
if (alreadyExistedHandlerSet.contains(uniqueValue)) {
continue;
}
......
......@@ -39,7 +39,7 @@ public class AnnotationIndexAndNameDataTest {
}
@Test
public void t03ReadAndWrite03() {
public void t03ReadAndWriteCsv() {
readAndWrite(fileCsv);
}
......
......@@ -25,11 +25,14 @@ public class CellDataDataTest {
private static File file07;
private static File file03;
private static File fileCsv;
@BeforeClass
public static void init() {
file07 = TestFileUtil.createNewFile("cellData07.xlsx");
file03 = TestFileUtil.createNewFile("cellData03.xls");
fileCsv = TestFileUtil.createNewFile("cellDataCsv.csv");
}
@Test
......@@ -42,6 +45,12 @@ public class CellDataDataTest {
readAndWrite(file03);
}
@Test
public void t03ReadAndWriteCsv() throws Exception {
readAndWrite(fileCsv);
}
private void readAndWrite(File file) throws Exception {
EasyExcel.write(file, CellDataWriteData.class).sheet().doWrite(data());
EasyExcel.read(file, CellDataReadData.class, new CellDataDataListener()).sheet().doRead();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册