Package com.google.i18n.phonenumbers.Phonenumber

Examples of com.google.i18n.phonenumbers.Phonenumber.PhoneNumber


    assertEquals(0, invalidCases.size());
  }

  public void testEveryRegionHasAnExampleNumber() throws Exception {
    for (String regionCode : phoneNumberUtil.getSupportedRegions()) {
      PhoneNumber exampleNumber = phoneNumberUtil.getExampleNumber(regionCode);
      assertNotNull("None found for region " + regionCode, exampleNumber);
    }
  }
View Full Code Here


        String invalidStringCase = "region_code: " + regionCode + ", national_number: " +
            exampleShortNumber;
        invalidStringCases.add(invalidStringCase);
        LOGGER.log(Level.SEVERE, "Failed validation for string " + invalidStringCase);
      }
      PhoneNumber phoneNumber = phoneNumberUtil.parse(exampleShortNumber, regionCode);
      if (!shortNumberInfo.isValidShortNumber(phoneNumber)) {
        invalidCases.add(phoneNumber);
        LOGGER.log(Level.SEVERE, "Failed validation for " + phoneNumber.toString());
      }

      for (ShortNumberInfo.ShortNumberCost cost : ShortNumberInfo.ShortNumberCost.values()) {
        exampleShortNumber = shortNumberInfo.getExampleShortNumberForCost(regionCode, cost);
        if (!exampleShortNumber.equals("")) {
          if (cost != shortNumberInfo.getExpectedCostForRegion(
              phoneNumberUtil.parse(exampleShortNumber, regionCode), regionCode)) {
            wrongTypeCases.add(phoneNumber);
            LOGGER.log(Level.SEVERE, "Wrong cost for " + phoneNumber.toString());
          }
        }
      }
    }
    assertEquals(0, invalidStringCases.size());
View Full Code Here

    for (String regionCode : shortNumberInfo.getSupportedRegions()) {
      PhoneNumberDesc desc =
          MetadataManager.getShortNumberMetadataForRegion(regionCode).getEmergency();
      if (desc.hasExampleNumber()) {
        String exampleNumber = desc.getExampleNumber();
        PhoneNumber phoneNumber = phoneNumberUtil.parse(exampleNumber, regionCode);
        if (!shortNumberInfo.isPossibleShortNumberForRegion(phoneNumber, regionCode)
            || !shortNumberInfo.isEmergencyNumber(exampleNumber, regionCode)) {
          wrongTypeCounter++;
          LOGGER.log(Level.SEVERE, "Emergency example number test failed for " + regionCode);
        } else if (shortNumberInfo.getExpectedCostForRegion(phoneNumber, regionCode)
View Full Code Here

      // Test the carrier-specific tag.
      PhoneNumberDesc desc =
          MetadataManager.getShortNumberMetadataForRegion(regionCode).getCarrierSpecific();
      if (desc.hasExampleNumber()) {
        String exampleNumber = desc.getExampleNumber();
        PhoneNumber carrierSpecificNumber = phoneNumberUtil.parse(exampleNumber, regionCode);
        if (!shortNumberInfo.isPossibleShortNumberForRegion(carrierSpecificNumber, regionCode)
            || !shortNumberInfo.isCarrierSpecific(carrierSpecificNumber)) {
          wrongTagCounter++;
          LOGGER.log(Level.SEVERE, "Carrier-specific test failed for " + regionCode);
        }
View Full Code Here

* @author Lara Rennie
*/
public class PhonenumberTest extends TestCase {

  public void testEqualSimpleNumber() throws Exception {
    PhoneNumber numberA = new PhoneNumber();
    numberA.setCountryCode(1).setNationalNumber(6502530000L);

    PhoneNumber numberB = new PhoneNumber();
    numberB.setCountryCode(1).setNationalNumber(6502530000L);

    assertEquals(numberA, numberB);
    assertEquals(numberA.hashCode(), numberB.hashCode());
  }
View Full Code Here

    assertEquals(numberA, numberB);
    assertEquals(numberA.hashCode(), numberB.hashCode());
  }

  public void testEqualWithItalianLeadingZeroSetToDefault() throws Exception {
    PhoneNumber numberA = new PhoneNumber();
    numberA.setCountryCode(1).setNationalNumber(6502530000L).setItalianLeadingZero(false);

    PhoneNumber numberB = new PhoneNumber();
    numberB.setCountryCode(1).setNationalNumber(6502530000L);

    // These should still be equal, since the default value for this field is false.
    assertEquals(numberA, numberB);
    assertEquals(numberA.hashCode(), numberB.hashCode());
  }
View Full Code Here

    assertEquals(numberA, numberB);
    assertEquals(numberA.hashCode(), numberB.hashCode());
  }

  public void testEqualWithCountryCodeSourceSet() throws Exception {
    PhoneNumber numberA = new PhoneNumber();
    numberA.setRawInput("+1 650 253 00 00").
        setCountryCodeSource(CountryCodeSource.FROM_NUMBER_WITH_PLUS_SIGN);
    PhoneNumber numberB = new PhoneNumber();
    numberB.setRawInput("+1 650 253 00 00").
        setCountryCodeSource(CountryCodeSource.FROM_NUMBER_WITH_PLUS_SIGN);
    assertEquals(numberA, numberB);
    assertEquals(numberA.hashCode(), numberB.hashCode());
  }
View Full Code Here

    assertEquals(numberA, numberB);
    assertEquals(numberA.hashCode(), numberB.hashCode());
  }

  public void testNonEqualWithItalianLeadingZeroSetToTrue() throws Exception {
    PhoneNumber numberA = new PhoneNumber();
    numberA.setCountryCode(1).setNationalNumber(6502530000L).setItalianLeadingZero(true);

    PhoneNumber numberB = new PhoneNumber();
    numberB.setCountryCode(1).setNationalNumber(6502530000L);

    assertFalse(numberA.equals(numberB));
    assertFalse(numberA.hashCode() == numberB.hashCode());
  }
View Full Code Here

    assertFalse(numberA.equals(numberB));
    assertFalse(numberA.hashCode() == numberB.hashCode());
  }

  public void testNonEqualWithDifferingRawInput() throws Exception {
    PhoneNumber numberA = new PhoneNumber();
    numberA.setCountryCode(1).setNationalNumber(6502530000L).setRawInput("+1 650 253 00 00").
        setCountryCodeSource(CountryCodeSource.FROM_NUMBER_WITH_PLUS_SIGN);

    PhoneNumber numberB = new PhoneNumber();
    // Although these numbers would pass an isNumberMatch test, they are not considered "equal" as
    // objects, since their raw input is different.
    numberB.setCountryCode(1).setNationalNumber(6502530000L).setRawInput("+1-650-253-00-00").
        setCountryCodeSource(CountryCodeSource.FROM_NUMBER_WITH_PLUS_SIGN);

    assertFalse(numberA.equals(numberB));
    assertFalse(numberA.hashCode() == numberB.hashCode());
  }
View Full Code Here

    sortedMap.put(1480, CHICAGO_TZ);
    return sortedMap;
  }

  public void testLookupTimeZonesForNumberCountryLevel_US() {
    PhoneNumber number = new PhoneNumber();
    number.setCountryCode(1).setNationalNumber(1000000000L);
    assertEquals(buildListOfTimeZones(NEW_YORK_TZ, CHICAGO_TZ, LOS_ANGELES_TZ, DENVER_TZ),
                 prefixTimeZonesMapForUS.lookupTimeZonesForNumber(number));
  }
View Full Code Here

TOP

Related Classes of com.google.i18n.phonenumbers.Phonenumber.PhoneNumber

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.