All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.has_assertion_template.txt Maven / Gradle / Ivy

There is a newer version: 1.1
Show newest version

  /**
   * Verifies that the actual ${class_to_assert}'s ${property} is equal to the given one.
   * @param ${property} 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 not equal to the given one.
   */
  public ${class_to_assert}Assert has${Property}(${propertyType} ${property}) {
    // check that actual ${class_to_assert} we want to make assertions on is not null.
    isNotNull();

    // we overrides the default error message with a more explicit one
    String errorMessage = format("Expected ${class_to_assert}'s ${property} to be <%s> but was <%s>", ${property}, actual.get${Property}());
    
    // check
    if (!actual.get${Property}().equals(${property})) { throw new AssertionError(errorMessage); }

    // return the current assertion for method chaining
    return this;
  }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy