|
|
@ -129,4 +129,36 @@ class DictQueryServiceTest extends AbstractDictH2Test { |
|
|
Thread.sleep(2200); |
|
|
Thread.sleep(2200); |
|
|
assertThat(dictQueryService.getItem("g", "late_item")).isNotNull(); |
|
|
assertThat(dictQueryService.getItem("g", "late_item")).isNotNull(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
@DisplayName("listTree:一级为根带 children,仅含启用项,分组停用返空") |
|
|
|
|
|
void listTree_twoLevel() { |
|
|
|
|
|
DictGroup g = newGroup("industry", "所属行业"); |
|
|
|
|
|
DictItem gov = newItem(g.getId(), "gov", "gov"); |
|
|
|
|
|
DictItem edu = newItem(g.getId(), "edu", "edu"); |
|
|
|
|
|
newChildItem(g.getId(), gov.getId(), "gov_ncpol", "gov_ncpol"); |
|
|
|
|
|
newChildItem(g.getId(), gov.getId(), "gov_emg", "gov_emg"); |
|
|
|
|
|
// edu 无启用子项
|
|
|
|
|
|
|
|
|
|
|
|
List<DictItemDTO> tree = dictQueryService.listTree("industry"); |
|
|
|
|
|
assertThat(tree).extracting(DictItemDTO::getCode).containsExactlyInAnyOrder("gov", "edu"); |
|
|
|
|
|
DictItemDTO govNode = tree.stream().filter(t -> "gov".equals(t.getCode())).findFirst().orElseThrow(); |
|
|
|
|
|
assertThat(govNode.getChildren()).extracting(DictItemDTO::getCode) |
|
|
|
|
|
.containsExactlyInAnyOrder("gov_ncpol", "gov_emg"); |
|
|
|
|
|
DictItemDTO eduNode = tree.stream().filter(t -> "edu".equals(t.getCode())).findFirst().orElseThrow(); |
|
|
|
|
|
assertThat(eduNode.getChildren()).isEmpty(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
@DisplayName("listChildren:取一级项直接启用子项;父不存在返空") |
|
|
|
|
|
void listChildren_byParentCode() { |
|
|
|
|
|
DictGroup g = newGroup("industry", "所属行业"); |
|
|
|
|
|
DictItem gov = newItem(g.getId(), "gov", "gov"); |
|
|
|
|
|
newChildItem(g.getId(), gov.getId(), "gov_ncpol", "gov_ncpol"); |
|
|
|
|
|
newChildItem(g.getId(), gov.getId(), "gov_emg", "gov_emg"); |
|
|
|
|
|
|
|
|
|
|
|
assertThat(dictQueryService.listChildren("industry", "gov")) |
|
|
|
|
|
.extracting(DictItemDTO::getCode).containsExactlyInAnyOrder("gov_ncpol", "gov_emg"); |
|
|
|
|
|
assertThat(dictQueryService.listChildren("industry", "not_exist")).isEmpty(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|