Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/main/resources/templates/has_any_assertion_template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

/**
* Verifies that ${class_to_assert}'s ${property} is not null.
* @param ${property_safe} the given ${property} to compare the actual ${class_to_assert}'s ${property} to.
* @return this assertion object.
* @throws AssertionError - if the actual ${class_to_assert}'s ${property} is null.${throws_javadoc}
*/
public ${self_type} has${Property}() {
// check that actual ${class_to_assert} we want to make assertions on is not null.
isNotNull();

// overrides the default error message with a more explicit one
String assertjErrorMessage = "\nExpecting ${property} of:\n <%s>\nto not be null";

// null safe check
${propertyType} actual${Property} = actual.${getter}();
if (actual${Property} == null) {
failWithMessage(assertjErrorMessage, actual);
}

// return the current assertion for method chaining
return ${myself};
}