Skip to content

Commit 1bef47a

Browse files
committed
Remove deprecated method calls in number assertions
1 parent 372b730 commit 1bef47a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
/**
3+
* Verifies that the actual ${class_to_assert}'s ${property} is equal to the given one.
4+
* @param ${property_safe} the given ${property} to compare the actual ${class_to_assert}'s ${property} to.
5+
* @return this assertion object.
6+
* @throws AssertionError - if the actual ${class_to_assert}'s ${property} is not equal to the given one.${throws_javadoc}
7+
*/
8+
public ${self_type} has${Property}(${propertyType} ${property_safe}) ${throws}{
9+
// check that actual ${class_to_assert} we want to make assertions on is not null.
10+
isNotNull();
11+
12+
// overrides the default error message with a more explicit one
13+
String assertjErrorMessage = "\nExpecting ${property} of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>";
14+
15+
// null safe check
16+
${propertyType} actual${Property} = actual.get${Property}();
17+
if (!java.util.Objects.deepEquals(actual${Property}, ${property_safe})) {
18+
failWithMessage(assertjErrorMessage, actual, ${property_safe}, actual${Property});
19+
}
20+
21+
// return the current assertion for method chaining
22+
return ${myself};
23+
}

0 commit comments

Comments
 (0)