提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.framework.ip.core.utils; |
H |
2 |
|
|
3 |
|
|
4 |
import com.iailab.framework.ip.core.Area; |
|
5 |
import com.iailab.framework.ip.core.enums.AreaTypeEnum; |
|
6 |
import org.junit.jupiter.api.Test; |
|
7 |
|
|
8 |
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
9 |
|
|
10 |
/** |
|
11 |
* {@link AreaUtils} 的单元测试 |
|
12 |
* |
|
13 |
* @author iailab |
|
14 |
*/ |
|
15 |
public class AreaUtilsTest { |
|
16 |
|
|
17 |
@Test |
|
18 |
public void testGetArea() { |
|
19 |
// 调用:北京 |
|
20 |
Area area = AreaUtils.getArea(110100); |
|
21 |
// 断言 |
|
22 |
assertEquals(area.getId(), 110100); |
|
23 |
assertEquals(area.getName(), "北京市"); |
|
24 |
assertEquals(area.getType(), AreaTypeEnum.CITY.getType()); |
|
25 |
assertEquals(area.getParent().getId(), 110000); |
|
26 |
assertEquals(area.getChildren().size(), 16); |
|
27 |
} |
|
28 |
|
|
29 |
@Test |
|
30 |
public void testFormat() { |
|
31 |
assertEquals(AreaUtils.format(110105), "北京 北京市 朝阳区"); |
|
32 |
assertEquals(AreaUtils.format(1), "中国"); |
|
33 |
assertEquals(AreaUtils.format(2), "蒙古"); |
|
34 |
} |
|
35 |
|
|
36 |
} |