Search in sources :

Example 66 with ConstraintViolation

use of javax.validation.ConstraintViolation in project camel by apache.

the class SMSMessageTest method testE164NullNumberIsInValid.

@Test
public void testE164NullNumberIsInValid() throws Exception {
    final String phoneNumber = null;
    final SMSMessage m = new SMSMessage("Hello world!", phoneNumber);
    final Set<ConstraintViolation<SMSMessage>> constraintViolations = validator.validate(m);
    Assert.isTrue(1 == constraintViolations.size());
}
Also used : SMSMessage(org.apache.camel.component.cm.client.SMSMessage) ConstraintViolation(javax.validation.ConstraintViolation) Test(org.junit.Test)

Example 67 with ConstraintViolation

use of javax.validation.ConstraintViolation in project camel by apache.

the class SMSMessageTest method testE164NoPlusSignedNumberBut00IsInvalid.

@Test
public void testE164NoPlusSignedNumberBut00IsInvalid() throws Exception {
    final String phoneNumber = new PhoneNumber().setCountryCodeSource(CountryCodeSource.FROM_NUMBER_WITHOUT_PLUS_SIGN).setNationalNumber(0034600000000).toString();
    final SMSMessage m = new SMSMessage("Hello world!", phoneNumber);
    final Set<ConstraintViolation<SMSMessage>> constraintViolations = validator.validate(m);
    Assert.isTrue(1 == constraintViolations.size());
}
Also used : SMSMessage(org.apache.camel.component.cm.client.SMSMessage) ConstraintViolation(javax.validation.ConstraintViolation) PhoneNumber(com.google.i18n.phonenumbers.Phonenumber.PhoneNumber) Test(org.junit.Test)

Example 68 with ConstraintViolation

use of javax.validation.ConstraintViolation in project camel by apache.

the class SMSMessageTest method testIdAsStringMaxLength.

@Test
public void testIdAsStringMaxLength() throws Exception {
    String idAsString = "thisistheidastringlengthgreaterthan32";
    final SMSMessage m = new SMSMessage(idAsString, "Hello World", validNumber, "MySelf");
    final Set<ConstraintViolation<SMSMessage>> constraintViolations = validator.validate(m);
    Assert.isTrue(1 == constraintViolations.size());
}
Also used : SMSMessage(org.apache.camel.component.cm.client.SMSMessage) ConstraintViolation(javax.validation.ConstraintViolation) Test(org.junit.Test)

Example 69 with ConstraintViolation

use of javax.validation.ConstraintViolation in project camel by apache.

the class SMSMessageTest method testE164NoPlusSignedNumberIsInvalid.

@Test
public void testE164NoPlusSignedNumberIsInvalid() throws Exception {
    final String phoneNumber = "34600000000";
    final SMSMessage m = new SMSMessage("Hello world!", phoneNumber);
    final Set<ConstraintViolation<SMSMessage>> constraintViolations = validator.validate(m);
    Assert.isTrue(1 == constraintViolations.size());
}
Also used : SMSMessage(org.apache.camel.component.cm.client.SMSMessage) ConstraintViolation(javax.validation.ConstraintViolation) Test(org.junit.Test)

Example 70 with ConstraintViolation

use of javax.validation.ConstraintViolation in project camel by apache.

the class SMSMessageTest method testNullMessageField.

@Test
public void testNullMessageField() throws Exception {
    final SMSMessage m = new SMSMessage(null, validNumber);
    final Set<ConstraintViolation<SMSMessage>> constraintViolations = validator.validate(m);
    Assert.isTrue(1 == constraintViolations.size());
}
Also used : SMSMessage(org.apache.camel.component.cm.client.SMSMessage) ConstraintViolation(javax.validation.ConstraintViolation) Test(org.junit.Test)

Aggregations

ConstraintViolation (javax.validation.ConstraintViolation)95 Test (org.junit.Test)78 Validator (javax.validation.Validator)19 ConstraintViolationException (javax.validation.ConstraintViolationException)12 SMSMessage (org.apache.camel.component.cm.client.SMSMessage)12 ChangePasswordForm (org.orcid.frontend.web.forms.ChangePasswordForm)11 CmsDocumentBlobSegment (gov.ca.cwds.data.persistence.cms.CmsDocumentBlobSegment)10 ValidatorFactory (javax.validation.ValidatorFactory)9 ManagePasswordOptionsForm (org.orcid.frontend.web.forms.ManagePasswordOptionsForm)8 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 CMConfiguration (org.apache.camel.component.cm.CMConfiguration)6 Set (java.util.Set)5 InitialContext (javax.naming.InitialContext)5 Session (org.hibernate.Session)5 Transaction (org.hibernate.Transaction)5 Method (java.lang.reflect.Method)4 ExecutableValidator (javax.validation.executable.ExecutableValidator)4 CamelExecutionException (org.apache.camel.CamelExecutionException)4 Exchange (org.apache.camel.Exchange)4