Add "is ported" to CarrierData

This commit is contained in:
Jon Chambers authored and ravi-signal committed 2026-01-29 12:14:26 -05:00
1 parent c69abb5200
commit ff8194ae5f
4 files changed
+17 -10

No files matched your search

@@ -10,12 +10,18 @@ import java.util.Optional;
/// Line type and home network information for a specific phone number.
///
/// @param carrierName the name of the network operator for the specified phone number
/// @param lineType the line type for the specified phone number
/// @param mcc the mobile country code (MCC) of the phone number's home network if known; may be empty if the phone
/// number is not a mobile number
/// @param mnc the mobile network code (MNC) of the phone number's home network if known; may be empty if the phone
/// number is not a mobile number
public record CarrierData(String carrierName, LineType lineType, Optional<String> mcc, Optional<String> mnc) {
/// @param lineType the line type for the specified phone number
/// @param mcc the mobile country code (MCC) of the phone number's home network if known; may be empty if the
/// phone number is not a mobile number
/// @param mnc the mobile network code (MNC) of the phone number's home network if known; may be empty if the
/// phone number is not a mobile number
/// @param isPorted indicates whether the number has been ported from its original network to another network; may be
/// empty if not known
public record CarrierData(String carrierName,
LineType lineType,
Optional<String> mcc,
Optional<String> mnc,
Optional<Boolean> isPorted) {
public enum LineType {
MOBILE,
@@ -147,7 +147,7 @@ public class HlrLookupCarrierDataProvider implements CarrierDataProvider {
networkDetails.name(),
lineType(result.telephoneNumberType()),
mccFromMccMnc(networkDetails.mccmnc()),
mncFromMccMnc(networkDetails.mccmnc())));
mncFromMccMnc(networkDetails.mccmnc()), Optional.empty()));
}
private static Tag getCreditsSpentTag(final HlrLookupResult hlrLookupResult) {
@@ -65,7 +65,7 @@ class VerificationSessionsTest {
final Optional<VerificationSession> absentSession = verificationSessions.findForKey(sessionId).join();
assertTrue(absentSession.isEmpty());
final VerificationSession session = new VerificationSession(null, new CarrierData("Test", CarrierData.LineType.MOBILE, Optional.of("123"), Optional.empty()),
final VerificationSession session = new VerificationSession(null, new CarrierData("Test", CarrierData.LineType.MOBILE, Optional.of("123"), Optional.empty(), Optional.empty()),
List.of(VerificationSession.Information.PUSH_CHALLENGE), Collections.emptyList(), null, null, true,
clock.millis(), clock.millis(), Duration.ofMinutes(1).toSeconds());
@@ -80,7 +80,7 @@ class VerificationSessionsTest {
assertInstanceOf(ConditionalCheckFailedException.class, t,
"inserting with the same key should fail conditional checks");
final VerificationSession updatedSession = new VerificationSession(null, new CarrierData("Test", CarrierData.LineType.MOBILE, Optional.of("123"), Optional.empty()), Collections.emptyList(),
final VerificationSession updatedSession = new VerificationSession(null, new CarrierData("Test", CarrierData.LineType.MOBILE, Optional.of("123"), Optional.empty(), Optional.empty()), Collections.emptyList(),
List.of(VerificationSession.Information.PUSH_CHALLENGE), null, null, true, clock.millis(), clock.millis(),
Duration.ofMinutes(2).toSeconds());
verificationSessions.update(sessionId, updatedSession).join();
@@ -110,7 +110,8 @@ class HlrLookupCarrierDataProviderTest {
final Optional<CarrierData> maybeCarrierData =
hlrLookupCarrierDataProvider.lookupCarrierData(PhoneNumberUtil.getInstance().getExampleNumber("US"), Duration.ZERO);
assertEquals(Optional.of(new CarrierData("Virgin Mobile", CarrierData.LineType.MOBILE, Optional.of("234"), Optional.of("38"))),
assertEquals(Optional.of(new CarrierData("Virgin Mobile", CarrierData.LineType.MOBILE, Optional.of("234"), Optional.of("38"),
Optional.empty())),
maybeCarrierData);
}