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!