tests: removed and restricted empty commands for choices and targets, improved empty name usages in tests (use EmptyNames.xxx.getTestCommand and EmptyNames.xxx.getObjectName for face down objects)

This commit is contained in:
Oleg Agafonov 2024-10-16 15:19:46 +04:00
parent 06392fecef
commit a16215caed
42 changed files with 391 additions and 264 deletions

View file

@ -1,33 +1,50 @@
package mage.constants;
import java.util.Arrays;
/**
*
* @author JayDi85
*/
public enum EmptyNames {
// TODO: make names for that cards and enable Assert.assertNotEquals("", permanentName); for assertXXX tests
// TODO: replace all getName().equals to haveSameNames and haveEmptyName
FACE_DOWN_CREATURE(""), // "Face down creature"
FACE_DOWN_TOKEN(""), // "Face down token"
FACE_DOWN_CARD(""); // "Face down card"
FACE_DOWN_CREATURE("", "[face_down_creature]"), // "Face down creature"
FACE_DOWN_TOKEN("", "[face_down_token]"), // "Face down token"
FACE_DOWN_CARD("", "[face_down_card]"); // "Face down card"
public static final String EMPTY_NAME_IN_LOGS = "face down object";
private final String cardName;
private final String objectName; // for mtg rules
private final String testCommand; // for unit tests
EmptyNames(String cardName) {
this.cardName = cardName;
EmptyNames(String objectName, String testCommand) {
this.objectName = objectName;
this.testCommand = testCommand;
}
@Override
public String toString() {
return cardName;
return objectName;
}
/**
* Face down choice for unit tests (use it instead empty string)
*/
public String getTestCommand() {
return this.testCommand;
}
public String getObjectName() {
return this.objectName;
}
public static boolean isEmptyName(String objectName) {
return objectName.equals(FACE_DOWN_CREATURE.toString())
|| objectName.equals(FACE_DOWN_TOKEN.toString())
|| objectName.equals(FACE_DOWN_CARD.toString());
return objectName.equals(FACE_DOWN_CREATURE.getObjectName())
|| objectName.equals(FACE_DOWN_TOKEN.getObjectName())
|| objectName.equals(FACE_DOWN_CARD.getObjectName());
}
public static String replaceTestCommandByObjectName(String searchCommand) {
EmptyNames res = Arrays.stream(values()).filter(e -> e.testCommand.equals(searchCommand)).findAny().orElse(null);
return res == null ? searchCommand : res.objectName;
}
}