Exemple #1
0
  /**
   * Convenience method to launch verification
   *
   * @param testItem TestItem instance from which the various parameters to a Verifier instance can
   *     be surmized.
   * @return - Verifier instance with verification result - us isPass() to determine success or
   *     failure
   */
  public static Verifier getVerifier(TestItem testItem) {

    // User may want to get a specific class for the verification (date, integer, amount, etc.)

    String cls = testItem.getDataProperties().getString("class");
    if (isBlank(cls)) cls = "";

    // User may have specified some comparison mode other than equal (the default)
    String md = testItem.getDataProperties().getString("comparemode");
    if (isBlank(md)) md = "";
    if (isBlank(md)) md = DDTSettings.Settings().getDefaultComparison();

    // User may have specified some option for the output (lowecase, ignorecase, etc.)
    String opt = testItem.getDataProperties().getString("option");
    if (isBlank(opt)) opt = "";

    // User typically specifies some expected value
    String ev = testItem.getDataProperties().getString("value");
    if (isBlank(ev)) ev = "";

    // User can indicate whether or not to trim white spaces off of actual value and expected values
    // prior to comparison
    // If the user did not specify anything (blank) then use the settings, else use the specified
    // value
    String strip = testItem.getDataProperties().getString("stripWhiteSpace");
    if (isBlank(strip)) strip = DDTSettings.Settings().getStripWhiteSpace() ? "true" : "false";
    boolean stripWhiteSpace = Util.asBoolean(strip);

    if (testItem.shouldFail()) return new Verifier(ev, "", md, opt, cls, stripWhiteSpace, true);

    // The Actual Value (second param) will be set by caller
    return new Verifier(ev, "", md, opt, cls, stripWhiteSpace);
  }