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

templates.has_assertion_template_for_primitive.txt Maven / Gradle / Ivy

There is a newer version: 3.0.0-M3
Show newest version

  /**
   * Verifies that the actual ${class_to_assert}'s ${property} is equal to the given one.
   * @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 not equal to the given one.${throws_javadoc}
   */
  public ${self_type} has${Property}(${propertyType} ${property_safe}) ${throws}{
    // 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 be:\n  <%s>\nbut was:\n  <%s>";
    
    // check
    ${propertyType} actual${Property} = actual.get${Property}();
    if (actual${Property} != ${property_safe}) {
      failWithMessage(assertjErrorMessage, actual, ${property_safe}, actual${Property});
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy