• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bean validation

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hello to all!
I have a question about the code below: I can't understand the logic behind using asserts in this method!
I know how the asserts method is working and can use it in different examples, but here i have some confusion!

For example  assertEquals( 1, constraintViolations.size() ); -> In this code we comparing 1 to the value of the length, according to the specification:
(Asserts that two objects are equal. If they are not, an AssertionError without a message is thrown. If expected and actual are null, they are considered equal), so if i have 1 ConstraintViolation and 1 == 1 the values are equal, what is the logic behind such comparison?  
If we would comparing assertEquals( 0, constraintViolations.size() ); i can understand it because i don't have any constraintviloations with this example, if i have 1 and got the length of 1 i do have constraintviolation and no exception is thrown that from mine perspective is not good..
Need your help with that!!

In this example assertEquals( "may not be null", constraintViolations.iterator().next().getMessage() ); -> Can't understand constraintViolations.iterator().next().getMessage(), with this code i actually calling getMessage() method and need to get the result "may not be null" ?
What message is it ? From where and how the message is generated ?
here i don't have any message generated in case of constraint violation!


 
reply
    Bookmark Topic Watch Topic
  • New Topic