java-mall/mall-common/src/test/com/suisung/mall/common/phone/PhoneNumberUtilsTest.java
2024-12-23 21:26:40 +08:00

39 lines
1.2 KiB
Java

package com.suisung.mall.common.phone;
import com.suisung.mall.common.utils.phone.PhoneModel;
import com.suisung.mall.common.utils.phone.PhoneNumberUtils;
import org.junit.Test;
public class PhoneNumberUtilsTest {
/**
* PhoneNumberUtils.getPhoneModelWithCountry(String)
* 手机号信息提取方法测试
* 输出参考 {@link PhoneModel}
* <p>
* input: +8617865933672
* output: PhoneModel(countryName=中国, provinceName=null, cityName=null, carrier=null, countryCode=86, nationalNumber=17865933672)
*/
@Test
public void testGetPhoneModelWithCountry() {
PhoneModel modelChinese = PhoneNumberUtils.getPhoneModelWithCountry("+8617865933672");
System.out.println(modelChinese);
PhoneModel modelJapan = PhoneNumberUtils.getPhoneModelWithCountry("+8109099956017");
System.out.println(modelJapan);
}
/**
* PhoneNumberUtils.isValidNumber(String)
* 手机号合法检测方法测试
* <p>
* input: +8617865933672
* output: true
*/
@Test
public void phoneNumberIsValidTest() {
boolean validNumber = PhoneNumberUtils.isValidNumber("+8617865933672");
System.out.println(validNumber);
}
}