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

fitnesse.fixtures.StringFixture Maven / Gradle / Ivy

There is a newer version: 20181217
Show newest version
// Copyright (C) 2003-2009 by Object Mentor, Inc. All rights reserved.
// Released under the terms of the CPL Common Public License version 1.0.
package fitnesse.fixtures;

import fit.ColumnFixture;
import fit.Parse;
import fit.TypeAdapter;

public class StringFixture extends ColumnFixture {
  public int subStringSize = 10;
  public String value;
  private String expected;

  @Override
  public void check(Parse cell, TypeAdapter a) {
    expected = cell.text();
    super.check(cell, a);
  }

  @Override
  public void execute() throws Exception {
    value = value.trim();
  }

  public String startsWith() {
    if (value.startsWith(expected))
      return expected;
    else {
      if (value.length() <= subStringSize)
        return value;
      else
        return value.substring(0, subStringSize) + "...";
    }
  }

  public String endsWith() {
    if (value.endsWith(expected))
      return expected;
    else {
      if (value.length() <= subStringSize)
        return value;
      else
        return "..." + value.substring(value.length() - subStringSize);
    }
  }

  public String contains() {
    if (value.contains(expected))
      return expected;
    else {
      if (value.length() <= subStringSize)
        return value;
      else
        return "...";
    }
  }

  public String equals() {
    if (value.equals(expected))
      return expected;
    else {
      if (value.length() <= subStringSize)
        return value;
      else
        return "...";
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy