1、结构调整
2、抽象工厂优化
This commit is contained in:
@@ -7,7 +7,7 @@ import java.lang.annotation.*;
|
||||
*
|
||||
* 其中 {@link #dictType()} 和 {@link #functionName()} 二选一
|
||||
*
|
||||
* @author HUIHUI
|
||||
* @author hongawen
|
||||
*/
|
||||
@Target({ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
@@ -13,7 +13,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
/**
|
||||
* Excel 数据地区转换器
|
||||
*
|
||||
* @author HUIHUI
|
||||
* @author hongawen
|
||||
*/
|
||||
@Slf4j
|
||||
public class AreaConvert implements Converter<Object> {
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
*
|
||||
* 为什么不直接解析字典还搞个接口?考虑到有的下拉数据不是从字典中获取的所有需要做一个兼容
|
||||
|
||||
* @author HUIHUI
|
||||
* @author hongawen
|
||||
*/
|
||||
public interface ExcelColumnSelectFunction {
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import static com.njcn.msgpush.framework.common.util.collection.CollectionUtils.
|
||||
/**
|
||||
* 基于固定 sheet 实现下拉框
|
||||
*
|
||||
* @author HUIHUI
|
||||
* @author hongawen
|
||||
*/
|
||||
@Slf4j
|
||||
public class SelectSheetWriteHandler implements SheetWriteHandler {
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.njcn.msgpush.framework.dict.core.util;
|
||||
|
||||
import com.njcn.msgpush.framework.common.biz.system.dict.DictDataCommonApi;
|
||||
import com.njcn.msgpush.framework.dict.core.DictFrameworkUtils;
|
||||
import com.njcn.msgpush.framework.test.core.ut.BaseMockitoUnitTest;
|
||||
import com.njcn.msgpush.framework.common.biz.system.dict.dto.DictDataRespDTO;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.njcn.msgpush.framework.common.pojo.CommonResult.success;
|
||||
import static com.njcn.msgpush.framework.test.core.util.RandomUtils.randomPojo;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* {@link DictFrameworkUtils} 的单元测试
|
||||
*/
|
||||
public class DictFrameworkUtilsTest extends BaseMockitoUnitTest {
|
||||
|
||||
@Mock
|
||||
private DictDataCommonApi dictDataApi;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
DictFrameworkUtils.init(dictDataApi);
|
||||
DictFrameworkUtils.clearCache();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseDictDataLabel() {
|
||||
// mock 数据
|
||||
List<DictDataRespDTO> dictDatas = List.of(
|
||||
randomPojo(DictDataRespDTO.class, o -> o.setDictType("animal").setValue("cat").setLabel("猫")),
|
||||
randomPojo(DictDataRespDTO.class, o -> o.setDictType("animal").setValue("dog").setLabel("狗"))
|
||||
);
|
||||
// mock 方法
|
||||
when(dictDataApi.getDictDataList(eq("animal"))).thenReturn(success(dictDatas));
|
||||
|
||||
// 断言返回值
|
||||
assertEquals("狗", DictFrameworkUtils.parseDictDataLabel("animal", "dog"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseDictDataValue() {
|
||||
// mock 数据
|
||||
List<DictDataRespDTO> dictDatas = List.of(
|
||||
randomPojo(DictDataRespDTO.class, o -> o.setDictType("animal").setValue("cat").setLabel("猫")),
|
||||
randomPojo(DictDataRespDTO.class, o -> o.setDictType("animal").setValue("dog").setLabel("狗"))
|
||||
);
|
||||
// mock 方法
|
||||
when(dictDataApi.getDictDataList(eq("animal"))).thenReturn(success(dictDatas));
|
||||
|
||||
// 断言返回值
|
||||
assertEquals("dog", DictFrameworkUtils.parseDictDataValue("animal", "狗"));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user