Search in sources :

Example 1 with PhonePropertyHandler

use of org.olat.user.propertyhandlers.PhonePropertyHandler in project OpenOLAT by OpenOLAT.

the class UserPropertiesTest method testPhonePropertyHandlerValidation.

@Test
public void testPhonePropertyHandlerValidation() {
    PhonePropertyHandler phoneHandler = new PhonePropertyHandler();
    ValidationError error = new ValidationError();
    // test for valid phone number formats
    assertTrue(phoneHandler.isValidValue(null, "043 544 90 00", error, null));
    assertTrue(phoneHandler.isValidValue(null, "043/544'90'00", error, null));
    assertTrue(phoneHandler.isValidValue(null, "043/544'90'00", error, null));
    assertTrue(phoneHandler.isValidValue(null, "043-544-90-00", error, null));
    assertTrue(phoneHandler.isValidValue(null, "043.544.90.00", error, null));
    assertTrue(phoneHandler.isValidValue(null, "+41 43 544 90 00", error, null));
    assertTrue(phoneHandler.isValidValue(null, "+41 (0)43 544 90 00", error, null));
    assertTrue(phoneHandler.isValidValue(null, "+41 43 544 90 00 x0", error, null));
    assertTrue(phoneHandler.isValidValue(null, "+41 43 544 90 00 ext. 0", error, null));
    assertTrue(phoneHandler.isValidValue(null, "+41 43 544 90 00 ext0", error, null));
    assertTrue(phoneHandler.isValidValue(null, "+41 43 544 90 00 ext 0", error, null));
    assertTrue(phoneHandler.isValidValue(null, "+41 43 544 90 00 extension 0", error, null));
    assertTrue(phoneHandler.isValidValue(null, "+41 43 544 90 00 Extension 0", error, null));
    // test for invalid phone number formats
    assertFalse(phoneHandler.isValidValue(null, "+41 43 frentix GmbH", error, null));
}
Also used : PhonePropertyHandler(org.olat.user.propertyhandlers.PhonePropertyHandler) ValidationError(org.olat.core.gui.components.form.ValidationError) Test(org.junit.Test)

Example 2 with PhonePropertyHandler

use of org.olat.user.propertyhandlers.PhonePropertyHandler in project openolat by klemens.

the class UserPropertiesTest method testPhonePropertyHandlerValidation.

@Test
public void testPhonePropertyHandlerValidation() {
    PhonePropertyHandler phoneHandler = new PhonePropertyHandler();
    ValidationError error = new ValidationError();
    // test for valid phone number formats
    assertTrue(phoneHandler.isValidValue(null, "043 544 90 00", error, null));
    assertTrue(phoneHandler.isValidValue(null, "043/544'90'00", error, null));
    assertTrue(phoneHandler.isValidValue(null, "043/544'90'00", error, null));
    assertTrue(phoneHandler.isValidValue(null, "043-544-90-00", error, null));
    assertTrue(phoneHandler.isValidValue(null, "043.544.90.00", error, null));
    assertTrue(phoneHandler.isValidValue(null, "+41 43 544 90 00", error, null));
    assertTrue(phoneHandler.isValidValue(null, "+41 (0)43 544 90 00", error, null));
    assertTrue(phoneHandler.isValidValue(null, "+41 43 544 90 00 x0", error, null));
    assertTrue(phoneHandler.isValidValue(null, "+41 43 544 90 00 ext. 0", error, null));
    assertTrue(phoneHandler.isValidValue(null, "+41 43 544 90 00 ext0", error, null));
    assertTrue(phoneHandler.isValidValue(null, "+41 43 544 90 00 ext 0", error, null));
    assertTrue(phoneHandler.isValidValue(null, "+41 43 544 90 00 extension 0", error, null));
    assertTrue(phoneHandler.isValidValue(null, "+41 43 544 90 00 Extension 0", error, null));
    // test for invalid phone number formats
    assertFalse(phoneHandler.isValidValue(null, "+41 43 frentix GmbH", error, null));
}
Also used : PhonePropertyHandler(org.olat.user.propertyhandlers.PhonePropertyHandler) ValidationError(org.olat.core.gui.components.form.ValidationError) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 ValidationError (org.olat.core.gui.components.form.ValidationError)2 PhonePropertyHandler (org.olat.user.propertyhandlers.PhonePropertyHandler)2