This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Bean validation

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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!


 
Sometimes you feel like a nut. Sometimes you feel like a tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!