Package controller.check

Examples of controller.check.TelephoneNumberChecker


    Country country = null;
    String areaCode = "07645";
    String number = "913635";
    String directAccess = null;
    PhoneContact contactType = null;
    if (new TelephoneNumberChecker(countryCode, areaCode, number, directAccess, contactType).check() != true
        || new TelephoneNumberChecker(country, areaCode, number, directAccess, contactType).check() != true){
      throw new Exception("shortest valid combination declared invalid");
    }
    //valid combination
    countryCode = "+49";
    directAccess = "123";
    contactType = PhoneContact.NO_CONTACT;
    if (new TelephoneNumberChecker(countryCode, areaCode, number, directAccess, contactType).check() != true
        || new TelephoneNumberChecker(country, areaCode, number, directAccess, contactType).check() != true){
      throw new Exception("valid combination declared invalid");
    }
    countryCode = null;
    country = Country.GERMANY;
    if (new TelephoneNumberChecker(countryCode, areaCode, number, directAccess, contactType).check() != true
        || new TelephoneNumberChecker(country, areaCode, number, directAccess, contactType).check() != true){
      throw new Exception("valid combination declared invalid");
    }
    //invalid because areaCode is missing
    areaCode = null;
    if (new TelephoneNumberChecker(countryCode, areaCode, number, directAccess, contactType).check() != false
        || new TelephoneNumberChecker(country, areaCode, number, directAccess, contactType).check() != false){
      throw new Exception("invalid combination declared valid");
    }
    //invalid because number is missing
    areaCode = "07654";
    number = "";
    if (new TelephoneNumberChecker(countryCode, areaCode, number, directAccess, contactType).check() != false
        || new TelephoneNumberChecker(country, areaCode, number, directAccess, contactType).check() != false){
      throw new Exception("invalid combination declared valid");
    }
    //invalid type of coutryCode
    number = "123";
    countryCode = "12";
    if (new TelephoneNumberChecker(countryCode, areaCode, number, directAccess, contactType).check() != false
        || new TelephoneNumberChecker(country, areaCode, number, directAccess, contactType).check() != true){
      throw new Exception("invalid countryCode declared valid");
    }
    countryCode = "+1";
    if (new TelephoneNumberChecker(countryCode, areaCode, number, directAccess, contactType).check() != false
        || new TelephoneNumberChecker(country, areaCode, number, directAccess, contactType).check() != true){
      throw new Exception("invalid countryCode declared valid");
    }
    //invalid type of postalNumber
    countryCode = "+49";
    areaCode = "1234";
    if (new TelephoneNumberChecker(countryCode, areaCode, number, directAccess, contactType).check() != false
        || new TelephoneNumberChecker(country, areaCode, number, directAccess, contactType).check() != false){
      throw new Exception("invalid areaCode declared valid (not beginning with '0')");
    }
    areaCode = "ABCDE";
    if (new TelephoneNumberChecker(countryCode, areaCode, number, directAccess, contactType).check() != false
        || new TelephoneNumberChecker(country, areaCode, number, directAccess, contactType).check() != false){
      throw new Exception("invalid areaCode declared valid (not a number)");
    }
    areaCode = "012";
    if (new TelephoneNumberChecker(countryCode, areaCode, number, directAccess, contactType).check() != false
        || new TelephoneNumberChecker(country, areaCode, number, directAccess, contactType).check() != false){
      throw new Exception("invalid areaCode declared valid (too short)");
    }
    //invalid number
    areaCode = "07645";
    number = "1";
    if (new TelephoneNumberChecker(countryCode, areaCode, number, directAccess, contactType).check() != false
        || new TelephoneNumberChecker(country, areaCode, number, directAccess, contactType).check() != false){
      throw new Exception("invalid number declared valid (too short)");
    }
    number = "123456789012345";
    if (new TelephoneNumberChecker(countryCode, areaCode, number, directAccess, contactType).check() != false
        || new TelephoneNumberChecker(country, areaCode, number, directAccess, contactType).check() != false){
      throw new Exception("invalid number declared valid (too long)");
    }
    number = "ABCDE";
    if (new TelephoneNumberChecker(countryCode, areaCode, number, directAccess, contactType).check() != false
        || new TelephoneNumberChecker(country, areaCode, number, directAccess, contactType).check() != false){
      throw new Exception("invalid number declared valid (not a number)");
    }
    //invalid directAccess
    number = "1234";
    directAccess = "123456789012345";
    if (new TelephoneNumberChecker(countryCode, areaCode, number, directAccess, contactType).check() != false
        || new TelephoneNumberChecker(country, areaCode, number, directAccess, contactType).check() != false){
      throw new Exception("invalid number directAccess valid (too long)");
    }
    directAccess = "ABCDE";
    if (new TelephoneNumberChecker(countryCode, areaCode, number, directAccess, contactType).check() != false
        || new TelephoneNumberChecker(country, areaCode, number, directAccess, contactType).check() != false){
      throw new Exception("invalid directAccess declared valid (not a number)");
    }
  }
View Full Code Here

TOP

Related Classes of controller.check.TelephoneNumberChecker

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.