-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
241 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/test/java/com/houkunlin/system/dict/starter/TreeDataTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.houkunlin.system.dict.starter; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.houkunlin.system.dict.starter.bean.DictTypeVo; | ||
import com.houkunlin.system.dict.starter.json.Array; | ||
import com.houkunlin.system.dict.starter.json.DictText; | ||
import com.houkunlin.system.dict.starter.notice.RefreshDictTypeEvent; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
|
||
/** | ||
* 默认注解使用测试 | ||
* | ||
* @author HouKunLin | ||
* @since 1.4.6 | ||
*/ | ||
@SpringBootTest | ||
class TreeDataTest { | ||
public static final String DICT_TYPE = "TreeData"; | ||
@Autowired | ||
private ObjectMapper objectMapper; | ||
@Autowired | ||
private static ApplicationEventPublisher publisher; | ||
|
||
@Autowired | ||
public void setPublisher(final ApplicationEventPublisher publisher) { | ||
final DictTypeVo typeVo = DictTypeVo.newBuilder(DICT_TYPE, "树形结构数据测试") | ||
.add("", "1", "节点1") | ||
.add("", "2", "节点2") | ||
.add("", "3", "节点3") | ||
.add("1", "1-1", "节点1-1") | ||
.add("1", "1-2", "节点1-2") | ||
.add("1", "1-3", "节点1-3") | ||
.add("2", "2-1", "节点2-1") | ||
.add("2", "2-2", "节点2-2") | ||
.add("2", "2-3", "节点2-3") | ||
.add("3", "3-1", "节点3-1") | ||
.add("3", "3-2", "节点3-2") | ||
.add("3", "3-3", "节点3-3") | ||
.build(); | ||
publisher.publishEvent(new RefreshDictTypeEvent(typeVo)); | ||
} | ||
|
||
/** | ||
* 基础测试 | ||
* | ||
* @throws JsonProcessingException 序列化异常 | ||
* @since 1.4.6 | ||
*/ | ||
@Test | ||
void testBasic1() throws JsonProcessingException { | ||
@Data | ||
@AllArgsConstructor | ||
class Bean { | ||
@DictText(value = DICT_TYPE, tree = true) | ||
private String userType; | ||
@DictText(value = DICT_TYPE, tree = true) | ||
private String userType1; | ||
@DictText(value = DICT_TYPE, tree = true, array = @Array(toText = false)) | ||
private String userType3; | ||
} | ||
final Bean bean = new Bean("1", "3-3", "1-1,1-2,1-3,2-1,2-2,2-3,3-1,3-2,3-3,3-4"); | ||
final String value = objectMapper.writeValueAsString(bean); | ||
System.out.println(bean); | ||
System.out.println(value); | ||
} | ||
|
||
} |