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

fit.FixtureName Maven / Gradle / Ivy

There is a newer version: 20241026
Show newest version
// Modified or written by Object Mentor, Inc. for inclusion with FitNesse.
// Copyright (c) 2002 Cunningham & Cunningham, Inc.
// Released under the terms of the GNU General Public License version 2 or later.
package fit;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import util.GracefulNamer;

public class FixtureName {
  private final String nameAsString;

  public FixtureName(String tableName) {
    // REFACTOR Fold GracefulNamer into this class
    if (GracefulNamer.isGracefulName(tableName))
      this.nameAsString = GracefulNamer.disgrace(tableName);
    else
      this.nameAsString = tableName;
  }

  @Override
  public String toString() {
    return nameAsString;
  }

  public boolean isFullyQualified() {
    return nameAsString.indexOf('.') != -1;
  }

  public static boolean fixtureNameHasPackageSpecified(final String fixtureName) {
    return new FixtureName(fixtureName).isFullyQualified();
  }

  public List getPotentialFixtureClassNames(Set fixturePathElements) {
    List candidateClassNames = new ArrayList<>();

    if (!isFullyQualified()) {
      for (String packageName : fixturePathElements) {
        addBlahAndBlahFixture(packageName + ".", candidateClassNames);
      }
    }
    addBlahAndBlahFixture("", candidateClassNames);

    return candidateClassNames;
  }

  private void addBlahAndBlahFixture(String qualifiedBy, List candidateClassNames) {
    candidateClassNames.add(qualifiedBy + nameAsString);
    candidateClassNames.add(qualifiedBy + nameAsString + "Fixture");
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy