Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapper for isPossibleNumber & isValidNumber #33

Merged
merged 141 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
cc97ce5
Improve Check of new value for fallbackRegionCode
Anrufliste Oct 11, 2023
8a1c813
Split Up Test and check isPossibleNumberWithReason against invalid Ge…
Anrufliste Oct 11, 2023
fdeca7c
Prepare new ValidationResult Enum for upcomming wrapper method.
Anrufliste Oct 11, 2023
3ec370e
Improve Check of new value for fallbackRegionCode
Anrufliste Oct 11, 2023
a933999
Split Up Test and check isPossibleNumberWithReason against invalid Ge…
Anrufliste Oct 11, 2023
7152398
Prepare new ValidationResult Enum for upcomming wrapper method.
Anrufliste Oct 11, 2023
5650ab7
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 13, 2023
5e4731c
Merge branch 'method_extension/valid_number' of https://github.com/te…
Anrufliste Oct 13, 2023
c8ce23d
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 15, 2023
31c99f6
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 15, 2023
698e72e
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 15, 2023
0a15559
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 16, 2023
486d9ba
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 18, 2023
1c57e4c
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 19, 2023
2cc0f5a
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 19, 2023
4e84073
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 21, 2023
90e803a
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 22, 2023
f6de509
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 23, 2023
19d66fa
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 26, 2023
79df95e
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 27, 2023
5dbe9e7
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 31, 2023
e13b650
Rearranging code order
Anrufliste Nov 26, 2023
f0a40f8
Merge pull request #40 from telekom/main
Anrufliste Dec 17, 2023
bda741a
- add 19222 service number tests to IsPossibleNumberWithReasonTest
Anrufliste Dec 17, 2023
0def454
Use PhoneLib 8.13.27 and prepare release
Anrufliste Dec 23, 2023
b59f634
Merge pull request #41 from telekom/phonelib/8_13_27
Anrufliste Dec 23, 2023
cf6f495
Start Snapshot 1.1.17 after release 1.1.16
Anrufliste Dec 23, 2023
2e9434b
Merge pull request #42 from telekom/phonelib/8_13_27
Anrufliste Dec 23, 2023
2d75975
Improve Check of new value for fallbackRegionCode
Anrufliste Oct 11, 2023
a0a59a5
Split Up Test and check isPossibleNumberWithReason against invalid Ge…
Anrufliste Oct 11, 2023
cc03274
Prepare new ValidationResult Enum for upcomming wrapper method.
Anrufliste Oct 11, 2023
f0f57a5
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 13, 2023
1ee3f78
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 15, 2023
f1c9729
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 15, 2023
ee4cb30
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 15, 2023
1f3e727
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 16, 2023
75b33ab
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 18, 2023
8283e7b
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 19, 2023
134f072
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 19, 2023
3338590
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 21, 2023
3a52849
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 22, 2023
722fc27
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 23, 2023
099513e
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 26, 2023
1e61e81
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 27, 2023
8ff9bef
Extends check of isPossibleNumberWithReason against invalid German ND…
Anrufliste Oct 31, 2023
fa0903e
Rearranging code order
Anrufliste Nov 26, 2023
fd759dc
- add 19222 service number tests to IsPossibleNumberWithReasonTest
Anrufliste Dec 17, 2023
38d0977
- Moving "check if original lib fixed isValidNumber for invalid Germa…
Anrufliste Dec 23, 2023
22997bb
added test at IsPossibleNumberWithReasonTest for 118(y)xx (Call Assis…
Anrufliste Dec 27, 2023
84c9c2e
deactivate loggin known issues in IsValidNumberTest
Anrufliste Dec 27, 2023
38b344d
added test at IsPossibleNumberWithReasonTest for mobile 0115xx(x) for…
Anrufliste Jan 19, 2024
fe78e7b
extends test at IsPossibleNumberWithReasonTest for mobile 0115xx(x) f…
Anrufliste Jan 21, 2024
2394d8e
added test at IsPossibleNumberWithReasonTest for mobile 016(0/2/3) fo…
Anrufliste Jan 24, 2024
eb9cac8
splitting Romain special service 7 check into an own testcase
Anrufliste Jan 28, 2024
f9c9f85
refactored "check if original lib fixed isPossibleNumberWithReason fo…
Anrufliste Feb 3, 2024
ed5c860
updated TODO notes in NDC test for outsourced ranges
Anrufliste Feb 3, 2024
7558a8b
updated 019(1-4) todo in NDC test and prepared 019(8-9) traffic routi…
Anrufliste Feb 3, 2024
01df3a2
Extended the values of PhoneNumberValidationResult enumeration to cov…
Anrufliste Feb 4, 2024
9548b80
Finalized German traffic routing 01981 of mobile Emergency calls
Anrufliste Feb 6, 2024
085832a
Added test for two more digits of German traffic routing 01981 of mob…
Anrufliste Feb 9, 2024
a5f0591
added test at IsPossibleNumberWithReasonTest for emergancy traffic ro…
Anrufliste Feb 10, 2024
8b0243e
added test at IsPossibleNumberWithReasonTest for public service call …
Anrufliste Feb 10, 2024
753f2b2
added test at IsPossibleNumberWithReasonTest for public EU service ca…
Anrufliste Feb 11, 2024
c72b929
added test at IsPossibleNumberWithReasonTest for international free c…
Anrufliste Feb 11, 2024
5d53cfe
added test at IsPossibleNumberWithReasonTest for national call assist…
Anrufliste Feb 18, 2024
e386fa3
added test at IsPossibleNumberWithReasonTest for operator internal tr…
Anrufliste Feb 24, 2024
9468a6c
added test at IsPossibleNumberWithReasonTest for personal numbers in …
Anrufliste Mar 2, 2024
2f2d965
added testcases in IsPossibleNumberWithReasonTest for 0800 range
Anrufliste Mar 9, 2024
842d9ea
added testcases in IsPossibleNumberWithReasonTest for 0900 range
Anrufliste Mar 9, 2024
9f6856d
added testcases in IsPossibleNumberWithReasonTest for 031x testnumbers
Anrufliste Mar 10, 2024
f2aa29f
added testcases in IsPossibleNumberWithReasonTest for 032 personal nu…
Anrufliste Mar 10, 2024
fdc3065
added testcases in IsPossibleNumberWithReasonTest for not assignable …
Anrufliste Mar 10, 2024
c1061b9
besides some assurance ToDo - all additional test are generated.
Anrufliste Mar 10, 2024
7365127
Cloning first testset from IsPossibleNumberWithReasonTest to IsValidN…
Anrufliste Apr 17, 2024
402a40a
German NDC 2626 label had a typo, which is corrected
Anrufliste Apr 19, 2024
14ea34a
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 21, 2024
3f70acb
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 21, 2024
51e7302
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 21, 2024
730cd3b
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 21, 2024
dee6471
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 21, 2024
5cda648
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 21, 2024
efcfa2f
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 22, 2024
bf5f2bb
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 23, 2024
2c74d94
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 23, 2024
37e571f
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 24, 2024
241044e
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 24, 2024
b7d48fb
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 24, 2024
93d832e
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 24, 2024
984cfd9
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 24, 2024
28dd11f
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 24, 2024
ce53799
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 24, 2024
d313eb9
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 24, 2024
3624ff2
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 26, 2024
08603ca
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 26, 2024
3f6ed39
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 26, 2024
8a1af21
Apply suggestions from code review
Anrufliste Apr 26, 2024
440d676
Apply suggestions from code review part 2
Anrufliste Apr 26, 2024
a9f253e
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 26, 2024
4c86acb
Merge branch 'method_extension/valid_number' of https://github.com/te…
Anrufliste Apr 26, 2024
6ccd556
Apply suggestions from code review part 3
Anrufliste Apr 26, 2024
6b7bd46
Use PhoneLib 8.13.28 and prepare release
Anrufliste Jan 20, 2024
5cd8f67
Start Snapshot 1.1.18 after release 1.1.17
Anrufliste Jan 20, 2024
bd4f234
Use PhoneLib 8.13.29 and prepare release
Anrufliste Jan 28, 2024
58e7936
Use PhoneLib 8.13.29 and prepare release
Anrufliste Jan 28, 2024
d56f39d
Start Snapshot 1.2.0 after release 1.1.18, which will bring an upgrad…
Anrufliste Jan 28, 2024
c06f0c5
Use PhoneLib 8.13.30 and prepare release
Anrufliste Feb 9, 2024
fca9c97
Start Snapshot 1.1.20 after release 1.1.19
Anrufliste Feb 9, 2024
6d684ce
Use PhoneLib 8.13.31 and prepare release
Anrufliste Mar 2, 2024
2304467
Upgrade Spring-Context version because of CVE-2024-22233
Anrufliste Mar 2, 2024
b373991
Upgrade Spring-Context version because of CVE-2024-22233
Anrufliste Mar 2, 2024
ee62361
correct typo
Anrufliste Mar 2, 2024
a04bb56
Use PhoneLib 8.13.32 and prepare release
Anrufliste Mar 23, 2024
4fd8a59
Start Snapshot 1.2.22 after release 1.2.21
Anrufliste Mar 23, 2024
fb0700f
Use PhoneLib 8.13.33 and prepare release
Anrufliste Mar 27, 2024
fe82eef
Start Snapshot 1.1.23 after release 1.1.22
Anrufliste Mar 27, 2024
5edf1d8
Use PhoneLib 8.13.34 and prepare release
Anrufliste Apr 17, 2024
8e1a277
Start Snapshot 1.1.24 after release 1.1.23
Anrufliste Apr 17, 2024
7b9f5de
Use PhoneLib 8.13.35 and prepare release
Anrufliste Apr 19, 2024
9cf1dcb
Start Snapshot 1.1.25 after release 1.1.24
Anrufliste Apr 19, 2024
386cb76
Split Up Test and check isPossibleNumberWithReason against invalid Ge…
Anrufliste Oct 11, 2023
5009542
Adapting testset from IsPossibleNumberWithReasonTest to IsValidNumber…
Anrufliste Apr 26, 2024
eced56c
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 27, 2024
5d7b221
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 27, 2024
9f16d95
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 27, 2024
e9a785c
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 28, 2024
7aafb4c
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 28, 2024
5792cb2
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 28, 2024
b9d4875
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 28, 2024
ebe65ea
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 28, 2024
8ae20ce
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 28, 2024
a0321d5
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 28, 2024
c3564b4
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 28, 2024
8e051a4
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 28, 2024
1d522f5
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 28, 2024
29f4e35
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 28, 2024
6648ad4
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 28, 2024
7712b73
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 28, 2024
97b3997
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 28, 2024
ad0de48
Cloning testset from IsPossibleNumberWithReasonTest to IsValidNumberT…
Anrufliste Apr 28, 2024
cb2fc70
Optimizing PhoneNumberValidationResult definition
Anrufliste Apr 28, 2024
8f95b03
Logging for testing
Anrufliste Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<artifactId>normalizer</artifactId>
<name>Phonenumber Normalizer</name>
<description>Library to work with phonenumbers, especially to fix googles PhoneLib ignoring German Landline specifics.</description>
<version>1.1.16-SNAPSHOT</version>
<version>1.1.25-SNAPSHOT</version>
<packaging>jar</packaging>
<url>https://github.com/telekom/phonenumber-normalizer</url>

Expand Down Expand Up @@ -86,7 +86,7 @@
<dependency>
<groupId>com.googlecode.libphonenumber</groupId>
<artifactId>libphonenumber</artifactId>
<version>8.13.26</version>
<version>8.13.35</version>
</dependency>

<dependency>
Expand All @@ -95,10 +95,13 @@
<scope>provided</scope> <!-- must be provided, see docs -->
<version>${lombok.version}</version>
</dependency>
<!--
TODO: need to upgrade spring context to 6.x
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.27</version>
<version>5.3.32</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down Expand Up @@ -136,10 +139,18 @@
<version>1.3.2</version>
</dependency>
<!-- For Testing only -->
<!--
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.7</version>
<scope>test</scope>
</dependency>
-->
<dependency>
<groupId>com.googlecode.libphonenumber</groupId>
<artifactId>geocoder</artifactId>
<version>2.220</version>
<version>2.229</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -175,10 +186,11 @@
<scope>test</scope>
</dependency>
<!--Replaces Version 3.5.1 which has https://devhub.checkmarx.com/cve-details/CVE-2007-2379/?utm_source=jetbrains&utm_medium=referral&utm_campaign=idea -->
<!--Not using Version 3.7.1 which has other vulnerabilities -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.6.4</version>
<version>3.7.0</version>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class PhoneNumberNormalizerImpl implements PhoneNumberNormalizer {

@Override
public void setFallbackRegionCode(String fallBackRegionCode) {
if (PhoneLibWrapper.getCountryCodeForRegion(fallBackRegionCode) > 0) {
if (fallBackRegionCode != null && !fallBackRegionCode.isEmpty() && PhoneLibWrapper.getCountryCodeForRegion(fallBackRegionCode) > 0) {
this.fallbackRegionCode = fallBackRegionCode;
} else {
this.fallbackRegionCode = null; //invalid region code!
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/*
* Copyright © 2024 Deutsche Telekom AG ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.telekom.phonenumbernormalizer.numberplans;
Anrufliste marked this conversation as resolved.
Show resolved Hide resolved

import com.google.i18n.phonenumbers.PhoneNumberUtil.ValidationResult;

/**
* Wrapper around the PhoneLib enum {@link ValidationResult} from Google
* <p>
* When the PhoneLib is validating a phone number it returns a value of the enum {@link ValidationResult}.
* </p><p>
* It differentiates two possible positive and five possible negative results. The value
* {@link ValidationResult#INVALID_LENGTH} is for any negative case, which is not explicitly covered by any of the other
* four values.
* While most of the values for negative cases are focused on the number length, the value
* {@link ValidationResult#INVALID_COUNTRY_CODE} explicitly focuses on a specific number part - the Country Code.
* </p><p>
* This wrapper introduces explicit INVALID_ reason codes for currently undifferentiated number parts IDP, NAC and NDC.
* Lastly there is also {@link PhoneNumberValidationResult#INVALID_DRAMA_NUMBER} reason code for the whole number if it
* is reserved as a fictional number in arts.
* </p><p>
* Furthermore it introduces additional IS_POSSIBLE_ values, to hint for more specific calling restrictions of the
* validated number besides {@link PhoneNumberValidationResult#IS_POSSIBLE_LOCAL_ONLY}.
* </p>
* @see ValidationResult
*/

public enum PhoneNumberValidationResult {

/** The number length matches that of valid numbers for this region or used NDC without any identified calling
* restrictions. */
IS_POSSIBLE(ValidationResult.IS_POSSIBLE),

/**
* The number length/pattern matches that of local numbers for this region only (i.e. numbers that may
* be able to be dialled within an area, but does not have all the information e.g. NDC or is not allowed to be
* dialled from anywhere inside or outside the country).
*/
IS_POSSIBLE_LOCAL_ONLY(ValidationResult.IS_POSSIBLE_LOCAL_ONLY),

/**
* The number length/pattern matches that of national numbers for this region only (i.e. numbers that may
* be able to be dialled within an area or the region itself, but is not allowed to be dialled from
* anywhere outside the country using CC).
*/
IS_POSSIBLE_NATIONAL_ONLY(ValidationResult.IS_POSSIBLE_LOCAL_ONLY),

/**
* The number length/pattern matches that of international number for this region only (i.e. number is not allowed
* to be call from within the region, even if CC of the regions is used).
*/
IS_POSSIBLE_INTERNATIONAL_ONLY(ValidationResult.IS_POSSIBLE),

/**
* The number length/pattern matches that of national VPN number for this region only (i.e. number is only allowed
* to be call from other numbers of same VPN within this region and not by users of the public telephony network).
*/
IS_POSSIBLE_NATIONAL_VPN_ONLY(ValidationResult.IS_POSSIBLE_LOCAL_ONLY),

/**
* The number length/pattern matches that of VPN number for this region only (i.e. number is only allowed to be call
* from other numbers of same VPN even internationally but not by users of the public telephony network).
*/
IS_POSSIBLE_VPN_ONLY(ValidationResult.IS_POSSIBLE),

/**
* The number length/pattern matches that of national operator traffic control numbers for this region only
* (i.e. number is only allowed to be call between national operators for call routing and not directly by users of
* the public telephony network).
*/
IS_POSSIBLE_NATIONAL_OPERATOR_ONLY(ValidationResult.IS_POSSIBLE_LOCAL_ONLY),

/**
* The number length/pattern matches that of operator traffic control numbers for this region only (i.e. number is
* only allowed to be call between operators for call routing and not directly by users of the public telephony
* network).
*/
IS_POSSIBLE_OPERATOR_ONLY(ValidationResult.IS_POSSIBLE),

/** The number has an invalid international dialing prefix (aka IDP) for this region. */
INVALID_INTERNATIONAL_DIALING_PREFIX(ValidationResult.INVALID_LENGTH),

/** The number has an invalid country calling code (aka CC). */
INVALID_COUNTRY_CODE(ValidationResult.INVALID_COUNTRY_CODE),

/** The number has an invalid national access code (aka NAC). */
INVALID_NATIONAL_ACCESS_CODE(ValidationResult.INVALID_LENGTH),

/** The number has an invalid national destination code (aka NDC) for this region. */
INVALID_NATIONAL_DESTINATION_CODE(ValidationResult.INVALID_LENGTH),

/** The number is shorter than all valid numbers for this region or used NDC. */
TOO_SHORT(ValidationResult.TOO_SHORT),

/**
* The number is longer than the shortest valid numbers for this region or used NDC, shorter than the
* longest valid numbers for this region or used NDC, and does not itself have a number length that matches
* valid numbers for this region. This can also be returned in the case where
* isPossibleNumberForTypeWithReason was called, and there are no numbers of this type at all
* for this region or used NDC while none of the other INVALID values would match.
*/
INVALID_LENGTH(ValidationResult.INVALID_LENGTH),

/** The number is longer than all valid numbers for this region, or for the used NDC. */
TOO_LONG(ValidationResult.TOO_LONG),

/** The number is matching a drama number range, which simulates valid number for this region only used in movies or
* other fictional story telling. */
INVALID_DRAMA_NUMBER(ValidationResult.INVALID_LENGTH);

/**
* storing the corresponding enum value of {@link ValidationResult}
*/
private final ValidationResult phoneLibResult;

/**
* Initializing a PhoneNumberValidationResult enum value with a corresponding {@link ValidationResult} enum value
* @param phoneLibResult corresponding {@link ValidationResult} enum value
*/
PhoneNumberValidationResult(ValidationResult phoneLibResult) {
this.phoneLibResult = phoneLibResult;
}

/**
* Returns best matching corresponding {@link ValidationResult} enum value for an instance of a
* {@link PhoneNumberValidationResult} enum value
* @return corresponding {@link ValidationResult} enum value
*/
public ValidationResult getPhoneLibValidationResult() {
return phoneLibResult;
}

/**
* Returns if the validation result identifies a possible number regardless of calling limitations
* @return boolean true for any IS_POSSIBLE(_xxx) enum value
*/
public boolean isSomeHowValid() {
return ( (this == IS_POSSIBLE)
|| (this == IS_POSSIBLE_LOCAL_ONLY)
|| (this == IS_POSSIBLE_NATIONAL_ONLY)
|| (this == IS_POSSIBLE_NATIONAL_VPN_ONLY)
|| (this == IS_POSSIBLE_NATIONAL_OPERATOR_ONLY)
|| (this == IS_POSSIBLE_INTERNATIONAL_ONLY)
|| (this == IS_POSSIBLE_VPN_ONLY)
|| (this == IS_POSSIBLE_OPERATOR_ONLY));
}

/**
* Returns if the validation result identifies a possible number regardless of calling limitations
* @return boolean true for any IS_POSSIBLE(_xxx) enum value except ending with _OPERATOR_ONLY or _VPN_ONLY
*/
public boolean isPubliclyValid() {
return ( (this == IS_POSSIBLE)
|| (this == IS_POSSIBLE_LOCAL_ONLY)
|| (this == IS_POSSIBLE_NATIONAL_ONLY)
|| (this == IS_POSSIBLE_INTERNATIONAL_ONLY));

}

}
2 changes: 1 addition & 1 deletion src/main/resources/arealabels/nationallabels/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@
"2623": "Ransbach Baumbach",
"2624": "Höhr Grenzhausen",
"2625": "Ochtendung",
"2626": "Selters Westferwald",
"2626": "Selters Westerwald",
"2627": "Braubach",
"2628": "Rhens",
"2630": "Mülheim Kärlich",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import de.telekom.phonenumbernormalizer.dto.DeviceContext
import de.telekom.phonenumbernormalizer.dto.DeviceContextDto
import de.telekom.phonenumbernormalizer.dto.DeviceContextLineType
import de.telekom.phonenumbernormalizer.numberplans.PhoneLibWrapper
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import spock.lang.Specification


Expand Down Expand Up @@ -87,6 +89,10 @@ class PhoneNumberNormalizerImplTest extends Specification {
"0176 3 0 6 9 6544" | "DE" | "+4917630696544"
"0203556677" | "DE" | "+49203556677"
"203556677" | "DE" | "203556677"
"55" | "DE" | "55"
"556" | "DE" | "556"
"5566" | "DE" | "5566"
"55667" | "DE" | "55667"
"556677" | "DE" | "556677"
"5566778" | "DE" | "5566778"
"55667789" | "DE" | "55667789"
Expand Down Expand Up @@ -201,6 +207,7 @@ class PhoneNumberNormalizerImplTest extends Specification {
"116000" | "49" | "203" | "116000"
"1160001" | "49" | "203" | "+492031160001"
//New Logic, inside german fixed-line non short numbers
"55" | "49" | "203" | "+4920355"
"556" | "49" | "203" | "+49203556"
"5566" | "49" | "203" | "+492035566"
"55667" | "49" | "203" | "+4920355667"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class PhoneNumberOfflineGeocoderTest extends Specification {

Logger logger = Logger.getLogger(PhoneNumberOfflineGeocoderTest.class.toString())

static final boolean LOGONLYUNEXPECTED = true

def "setup"() {
this.phoneUtil = PhoneNumberUtil.getInstance()
Expand All @@ -48,7 +49,9 @@ class PhoneNumberOfflineGeocoderTest extends Specification {
then: "is number expected: $expectedResult"
if ((result != expectedResult) && (result2 != expectedResult)){
if (expectingFail) {
logger.info("PhoneLib is still not correctly labeling $areacode to $expectedResult by giving $result")
if (!LOGONLYUNEXPECTED) {
logger.info("PhoneLib is still not correctly labeling $areacode to $expectedResult by giving $result")
}
} else {
logger.warning("PhoneLib is suddenly not correctly labeling $areacode to $expectedResult by giving $result")
}
Expand Down Expand Up @@ -379,7 +382,7 @@ class PhoneNumberOfflineGeocoderTest extends Specification {
"2623" | "Ransbach Baumbach" | false
"2624" | "Höhr Grenzhausen" | false
"2625" | "Ochtendung" | false
"2626" | "Selters Westferwald" | false
"2626" | "Selters Westerwald" | false
"2627" | "Braubach" | false
"2628" | "Rhens" | false
"2630" | "Mülheim Kärlich" | false
Expand Down
Loading
Loading