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} *

* 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) * 手机号合法检测方法测试 *

* input: +8617865933672 * output: true */ @Test public void phoneNumberIsValidTest() { boolean validNumber = PhoneNumberUtils.isValidNumber("+8617865933672"); System.out.println(validNumber); } }