示例#1
0
 @Test
 public void whenInvalidRegExCaseSensitiveThenThrowsException() {
   try {
     custJsWO.setRegExCaseSensitiveField("abCfoobar");
     fail("Should have thrown exception");
   } catch (final InvalidException ex) {
     assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Reg Ex Case Sensitive Field"));
   }
 }
示例#2
0
 @Test
 public void whenInvalidMaxLengthThenThrowsException() {
   try {
     custJsWO.setMaxLengthField("This is far too long");
     fail("Should have thrown exception");
   } catch (final InvalidException ex) {
     assertThat(ex.getAdvisorClass(), classEqualTo(MaxLengthFacetAnnotationForProperty.class));
     assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Max Length Field"));
   }
 }
示例#3
0
 @Test
 public void whenAssociationInvalidMandatoryThenThrowsException() {
   try {
     custJsWO.setMandatoryAssociation(null);
     fail("Should have thrown exception");
   } catch (final InvalidException ex) {
     assertThat(ex.getAdvisorClass(), classEqualTo(MandatoryFacetDefault.class));
     assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Mandatory Association"));
   }
 }
示例#4
0
 @Test
 public void whenInvalidRegExCaseInsensitiveThenThrowsException() {
   try {
     custJsWO.setRegExCaseInsensitiveField("abXfoobar");
     fail("Should have thrown exception");
   } catch (final InvalidException ex) {
     assertThat(ex.getAdvisorClass(), classEqualTo(RegExFacetAnnotationForProperty.class));
     assertThat(
         ex.getIdentifier().getMemberNaturalName(), equalTo("Reg Ex Case Insensitive Field"));
   }
 }
示例#5
0
 @Test
 public void whenActionInvalidImperativelyThenThrowsException() {
   custJsDO.validatePlaceOrder = "can't place order";
   try {
     custJsWO.placeOrder(product355DO, 3);
     fail("Should have thrown exception");
   } catch (final InvalidException ex) {
     assertThat(ex.getAdvisorClass(), classEqualTo(ActionValidationFacetViaMethod.class));
     assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Place Order"));
     assertThat(ex.getMessage(), Matchers.containsString("can't place order"));
   }
 }
示例#6
0
 @Test
 public void whenCollectionInvalidImperativelyThenAddToThrowsException() {
   custJsDO.validateAddToVisitedCountries = "bad country";
   try {
     custJsWO.addToVisitedCountries(countryGbrDO);
     fail("Should have thrown exception");
   } catch (final InvalidException ex) {
     assertThat(ex.getAdvisorClass(), classEqualTo(CollectionValidateAddToFacetViaMethod.class));
     assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
     assertThat(ex.getMessage(), Matchers.containsString("bad country"));
   }
 }
示例#7
0
 @Test
 public void whenAssociationInvalidImperativelyThenThrowsException() {
   custJsDO.validateCountryOfBirth = "bad country of birth";
   final Country[] values = new Country[] {countryUsaDO};
   for (final Country value : values) {
     try {
       custJsWO.setCountryOfBirth(value);
       fail("Should have thrown exception");
     } catch (final InvalidException ex) {
       assertThat(ex.getAdvisorClass(), classEqualTo(PropertyValidateFacetViaMethod.class));
       assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
       assertThat(ex.getMessage(), Matchers.containsString("bad country of birth"));
     }
   }
 }
示例#8
0
 @Test
 public void whenValueInvalidImperativelyThenThrowsException() {
   final String[] values = new String[] {"Dick", "Harry"};
   for (final String value : values) {
     custJsDO.validateFirstNameExpectedArg = value;
     custJsDO.validateFirstName = "bad first name";
     try {
       custJsWO.setFirstName(value);
       fail("Should have thrown exception");
     } catch (final InvalidException ex) {
       assertThat(ex.getAdvisorClass(), classEqualTo(PropertyValidateFacetViaMethod.class));
       assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
       assertThat(ex.getMessage(), Matchers.containsString("bad first name"));
     }
   }
 }
示例#9
0
 @Ignore // different behaviour testing in Eclipse vs Maven (different exception type thrown); not
         // sure why
 @Test
 public void whenValueInvalidImperativelyOnMandatoryThenThrowsException() {
   final String[] values = new String[] {null};
   for (final String value : values) {
     custJsDO.validateFirstNameMandatoryExpectedArg = value;
     custJsDO.validateFirstNameMandatory = "bad first name";
     try {
       custJsWO.setFirstNameMandatory(value);
       fail("Should have thrown exception");
     } catch (final InvalidException ex) {
       // assertThat(ex.getAdvisorClass(), classEqualTo(MandatoryFacetDefault.class)); // in
       // Eclipse?
       assertThat(
           ex.getAdvisorClass(), classEqualTo(PropertyValidateFacetViaMethod.class)); // in Maven?
       assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name Mandatory"));
       assertThat(ex.getMessage(), Matchers.containsString("bad first name"));
     }
   }
 }
示例#10
0
 @Ignore // different behaviour testing in Eclipse vs Maven (different exception type thrown); not
         // sure why
 @Test
 public void whenAssociationNullOnMandatoryImperativelyThenThrowsException() {
   custJsDO.validateCountryOfBirthMandatory = "bad country of birth";
   final Country[] values = new Country[] {null};
   for (final Country value : values) {
     try {
       custJsWO.setCountryOfBirthMandatory(value);
       fail("Should have thrown exception");
     } catch (final InvalidException ex) {
       // assertThat(ex.getAdvisorClass(), classEqualTo(MandatoryFacetDefault.class)); // in
       // Eclipse?
       assertThat(
           ex.getAdvisorClass(), classEqualTo(PropertyValidateFacetViaMethod.class)); // in Maven?
       assertThat(
           ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth Mandatory"));
       assertThat(ex.getMessage(), Matchers.containsString("bad country of birth"));
     }
   }
 }