mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-30 09:48:43 +08:00 
			
		
		
		
	test: 修改 code review
This commit is contained in:
		| @@ -39,6 +39,7 @@ | |||||||
|             <groupId>com.google.guava</groupId> |             <groupId>com.google.guava</groupId> | ||||||
|             <artifactId>guava</artifactId> |             <artifactId>guava</artifactId> | ||||||
|         </dependency> |         </dependency> | ||||||
|  |  | ||||||
|         <!-- Test 测试相关 --> |         <!-- Test 测试相关 --> | ||||||
|         <dependency> |         <dependency> | ||||||
|             <groupId>cn.iocoder.boot</groupId> |             <groupId>cn.iocoder.boot</groupId> | ||||||
|   | |||||||
| @@ -2,13 +2,13 @@ package cn.iocoder.yudao.framework.dict.core.util; | |||||||
|  |  | ||||||
| import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||||||
| import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; | import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; | ||||||
| import cn.iocoder.yudao.framework.test.core.util.RandomUtils; |  | ||||||
| import cn.iocoder.yudao.module.system.api.dict.DictDataApi; | import cn.iocoder.yudao.module.system.api.dict.DictDataApi; | ||||||
| import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; | import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; | ||||||
| import org.junit.jupiter.api.BeforeEach; | import org.junit.jupiter.api.BeforeEach; | ||||||
| import org.junit.jupiter.api.Test; | import org.junit.jupiter.api.Test; | ||||||
| import org.mockito.Mock; | import org.mockito.Mock; | ||||||
|  |  | ||||||
|  | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | ||||||
| import static org.junit.jupiter.api.Assertions.assertEquals; | import static org.junit.jupiter.api.Assertions.assertEquals; | ||||||
| import static org.mockito.Mockito.when; | import static org.mockito.Mockito.when; | ||||||
|  |  | ||||||
| @@ -26,28 +26,23 @@ public class DictFrameworkUtilsTest extends BaseMockitoUnitTest { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Test |     @Test | ||||||
|     public void getDictDataLabelTest() { |     public void testGetDictDataLabel() { | ||||||
|         DictDataRespDTO dataRespDTO = randomPojo(); |         // mock 数据 | ||||||
|  |         DictDataRespDTO dataRespDTO = randomPojo(DictDataRespDTO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); | ||||||
|  |         // mock 方法 | ||||||
|         when(dictDataApi.getDictData(dataRespDTO.getDictType(), dataRespDTO.getValue())).thenReturn(dataRespDTO); |         when(dictDataApi.getDictData(dataRespDTO.getDictType(), dataRespDTO.getValue())).thenReturn(dataRespDTO); | ||||||
|         String dictDataLabel = DictFrameworkUtils.getDictDataLabel(dataRespDTO.getDictType(), dataRespDTO.getValue()); |         // 断言返回值 | ||||||
|         assertEquals(dataRespDTO.getLabel(), dictDataLabel); |         assertEquals(dataRespDTO.getLabel(), DictFrameworkUtils.getDictDataLabel(dataRespDTO.getDictType(), dataRespDTO.getValue())); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Test |     @Test | ||||||
|     public void parseDictDataValueTest() { |     public void testParseDictDataValue() { | ||||||
|         DictDataRespDTO resp = randomPojo(); |         // mock 数据 | ||||||
|  |         DictDataRespDTO resp = randomPojo(DictDataRespDTO.class, o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); | ||||||
|  |         // mock 方法 | ||||||
|         when(dictDataApi.parseDictData(resp.getDictType(), resp.getLabel())).thenReturn(resp); |         when(dictDataApi.parseDictData(resp.getDictType(), resp.getLabel())).thenReturn(resp); | ||||||
|         String value = DictFrameworkUtils.parseDictDataValue(resp.getDictType(), resp.getLabel()); |         // 断言返回值 | ||||||
|         assertEquals(resp.getValue(), value); |         assertEquals(resp.getValue(), DictFrameworkUtils.parseDictDataValue(resp.getDictType(), resp.getLabel())); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private DictDataRespDTO randomPojo() { |  | ||||||
|         DictDataRespDTO dataRespDTO = new DictDataRespDTO(); |  | ||||||
|         dataRespDTO.setLabel(RandomUtils.randomString()); |  | ||||||
|         dataRespDTO.setValue(RandomUtils.randomString()); |  | ||||||
|         dataRespDTO.setDictType(RandomUtils.randomString()); |  | ||||||
|         dataRespDTO.setStatus(CommonStatusEnum.ENABLE.getStatus()); |  | ||||||
|  |  | ||||||
|         return dataRespDTO; |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 gaibu
					gaibu