From d313eb9cbc72f864f1e4eee4d049086782834099 Mon Sep 17 00:00:00 2001 From: Emil Thies Date: Wed, 24 Apr 2024 16:46:52 +0200 Subject: [PATCH] Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberTest: German VPN 018 59995 xxxx is reachable (and fix of original one) --- .../IsPossibleNumberWithReasonTest.groovy | 2 +- .../PhoneNumberUtil/IsValidNumberTest.groovy | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/test/groovy/de/telekom/phonenumbernormalizer/extern/libphonenumber/PhoneNumberUtil/IsPossibleNumberWithReasonTest.groovy b/src/test/groovy/de/telekom/phonenumbernormalizer/extern/libphonenumber/PhoneNumberUtil/IsPossibleNumberWithReasonTest.groovy index a6aafa7..d5dea44 100644 --- a/src/test/groovy/de/telekom/phonenumbernormalizer/extern/libphonenumber/PhoneNumberUtil/IsPossibleNumberWithReasonTest.groovy +++ b/src/test/groovy/de/telekom/phonenumbernormalizer/extern/libphonenumber/PhoneNumberUtil/IsPossibleNumberWithReasonTest.groovy @@ -2326,7 +2326,7 @@ class IsPossibleNumberWithReasonTest extends Specification { PhoneNumberUtil.ValidationResult[] expectedResults = [PhoneNumberUtil.ValidationResult.TOO_SHORT, PhoneNumberUtil.ValidationResult.TOO_SHORT, PhoneNumberUtil.ValidationResult.TOO_SHORT, - PhoneNumberUtil.ValidationResult.TOO_LONG, + PhoneNumberUtil.ValidationResult.TOO_SHORT, PhoneNumberUtil.ValidationResult.IS_POSSIBLE, // is reachable from normal telephony network PhoneNumberUtil.ValidationResult.TOO_LONG, PhoneNumberUtil.ValidationResult.TOO_LONG, diff --git a/src/test/groovy/de/telekom/phonenumbernormalizer/extern/libphonenumber/PhoneNumberUtil/IsValidNumberTest.groovy b/src/test/groovy/de/telekom/phonenumbernormalizer/extern/libphonenumber/PhoneNumberUtil/IsValidNumberTest.groovy index 30211fc..64f775e 100644 --- a/src/test/groovy/de/telekom/phonenumbernormalizer/extern/libphonenumber/PhoneNumberUtil/IsValidNumberTest.groovy +++ b/src/test/groovy/de/telekom/phonenumbernormalizer/extern/libphonenumber/PhoneNumberUtil/IsValidNumberTest.groovy @@ -2190,6 +2190,42 @@ class IsValidNumberTest extends Specification { } + def "check if original lib fixed isValid for German VPN 018 59995 xxxx is reachable"(String reserve, regionCode, boolean[] expectingFails) { + given: + String[] numbersToTest = [reserve + "", + reserve + "2", + reserve + "22", + reserve + "223", + reserve + "2233", + reserve + "22334", + reserve + "223344"] + + Boolean[] expectedResults = [false, false, false, false, true, false, false] + + when: + Boolean[] results = [] + for (number in numbersToTest) { + def phoneNumber = phoneUtil.parse(number, regionCode) + results += phoneUtil.isValidNumber(phoneNumber) + } + + then: + for (int i = 0; i < results.length; i++) { + this.logResult(results[i], expectedResults[i], expectingFails[i], numbersToTest[i], regionCode) + } + + where: + reserve | regionCode | expectingFails + // 018 is VPN: https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/018/018_Node.html + // Number Plan https://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Nummerierung/Rufnummern/018/Nummernplan.pdf?__blob=publicationFile&v=1 + // Historical Reorder: https://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Nummerierung/Rufnummern/018/TWiderruf.pdf?__blob=publicationFile&v=1 + // nation number with 11 digits + "018 59995" | "DE" | [false, false, false, false, false, false, false] + "+4918 59995" | "FR" | [false, false, false, false, false, false, false] + } + + + def "check if original lib fixed isValidNumber for invalid German NDC"(String number, regionCode, expectedResult, expectingFail) { given: