package jetbrains.mps.baseLanguage.unitTest.execution;

/*Generated by MPS */

import org.jetbrains.mps.annotations.Immutable;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;

/**
 * messages from the process come as strings so the keys here are strings
 */
@Immutable
public final class TestMethodStringKey implements TestRawKey {
  private final String myTestCaseFqName;
  private final String myTestMethodFqName;

  public TestMethodStringKey(@NotNull String classFqName, @NotNull String methodFqName) {
    myTestCaseFqName = classFqName;
    myTestMethodFqName = methodFqName;
  }

  @Override
  @NotNull
  public String getTestCaseFqName() {
    return myTestCaseFqName;
  }

  public String getTestMethodFqName() {
    return myTestMethodFqName;
  }

  @Override
  public String getQualifiedName() {
    return myTestCaseFqName + "." + myTestMethodFqName;
  }

  public boolean isWithInitializationProblem() {
    return myTestMethodFqName.equals("initializationError");
  }

  @NotNull
  public TestCaseStringKey getTestCaseKey() {
    return new TestCaseStringKey(myTestCaseFqName);
  }

  @Override
  public boolean equals(Object object) {
    if (object instanceof TestMethodStringKey) {
      return myTestCaseFqName.equals(((TestMethodStringKey) object).myTestCaseFqName) && myTestMethodFqName.equals(((TestMethodStringKey) object).myTestMethodFqName);
    }
    return false;
  }

  @Override
  public int hashCode() {
    return Objects.hash(myTestCaseFqName, myTestMethodFqName);
  }

  @Override
  public String toString() {
    return "TestMethodStringKey[" + myTestCaseFqName + "." + myTestMethodFqName + "]";
  }

  @NotNull
  @Override
  public TestType getType() {
    return TestType.METHOD;
  }
}
