From c4fe9e3121fb15bcd907fb40fca677bb54be7026 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Fri, 29 Dec 2017 17:15:00 +0400 Subject: [PATCH] Tests: added mage-verify warning test for missing sets in xmage (current missing sets: 34 with 1689 cards) --- .../src/main/java/mage/verify/JsonSet.java | 1 + .../src/main/java/mage/verify/MtgJson.java | 30 ++++++++++++++++ .../java/mage/verify/VerifyCardDataTest.java | 36 +++++++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/Mage.Verify/src/main/java/mage/verify/JsonSet.java b/Mage.Verify/src/main/java/mage/verify/JsonSet.java index 4a56a5bd30..831721937f 100644 --- a/Mage.Verify/src/main/java/mage/verify/JsonSet.java +++ b/Mage.Verify/src/main/java/mage/verify/JsonSet.java @@ -10,6 +10,7 @@ class JsonSet { public String gathererCode; public String magicCardsInfoCode; public String[] magicRaritiesCodes; + public String[] alternativeNames; public String releaseDate; public String border; public String type; diff --git a/Mage.Verify/src/main/java/mage/verify/MtgJson.java b/Mage.Verify/src/main/java/mage/verify/MtgJson.java index ea16d99538..79fd872203 100644 --- a/Mage.Verify/src/main/java/mage/verify/MtgJson.java +++ b/Mage.Verify/src/main/java/mage/verify/MtgJson.java @@ -16,6 +16,36 @@ import java.util.Map; import java.util.zip.ZipInputStream; public final class MtgJson { + + public static Map mtgJsonToXMageCodes = new HashMap<>(); + public static Map xMageToMtgJsonCodes = new HashMap<>(); + + static { + mtgJsonToXMageCodes.put("pWCQ", "WMCQ"); + mtgJsonToXMageCodes.put("pSUS", "SUS"); + mtgJsonToXMageCodes.put("pPRE", "PTC"); + mtgJsonToXMageCodes.put("pMPR", "MPRP"); + mtgJsonToXMageCodes.put("pMEI", "MBP"); + mtgJsonToXMageCodes.put("pGTW", "GRC"); // pGTW - Gateway = GRC - WPN Gateway ??? + mtgJsonToXMageCodes.put("pGRU", "GUR"); + mtgJsonToXMageCodes.put("pGPX", "GPX"); + mtgJsonToXMageCodes.put("pFNM", "FNMP"); + mtgJsonToXMageCodes.put("pELP", "EURO"); + mtgJsonToXMageCodes.put("pARL", "ARENA"); + mtgJsonToXMageCodes.put("pALP", "APAC"); + mtgJsonToXMageCodes.put("PO2", "P02"); + mtgJsonToXMageCodes.put("DD3_JVC", "DD3JVC"); + mtgJsonToXMageCodes.put("DD3_GVL", "DDD"); + mtgJsonToXMageCodes.put("DD3_EVG", "DD3EVG"); + mtgJsonToXMageCodes.put("DD3_DVD", "DDC"); + mtgJsonToXMageCodes.put("NMS", "NEM"); + + // revert search + for(Map.Entry entry: mtgJsonToXMageCodes.entrySet()){ + xMageToMtgJsonCodes.put(entry.getValue(), entry.getKey()); + } + } + private MtgJson() {} private static final class CardHolder { diff --git a/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java b/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java index 5835ef9b06..5294eb4379 100644 --- a/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java +++ b/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java @@ -180,6 +180,42 @@ public class VerifyCardDataTest { } } + @Test + public void checkMissingSets(){ + + Collection errorsList = new ArrayList<>(); + + int totalMissingSets = 0; + int totalMissingCards = 0; + Collection sets = Sets.getInstance().values(); + for(Map.Entry refEntry: MtgJson.sets().entrySet()){ + JsonSet refSet = refEntry.getValue(); + + // replace codes for aliases + String searchSet = MtgJson.mtgJsonToXMageCodes.getOrDefault(refSet.code, refSet.code); + + ExpansionSet mageSet = Sets.findSet(searchSet); + if(mageSet == null){ + totalMissingSets = totalMissingSets + 1; + totalMissingCards = totalMissingCards + refSet.cards.size(); + errorsList.add("Warning: missing set " + refSet.code + " - " + refSet.name + " (cards: " + refSet.cards.size() + ")"); + } + } + if(errorsList.size() > 0){ + errorsList.add("Warning: total missing sets: " + totalMissingSets + ", with missing cards: " + totalMissingCards); + } + + + for (String error: errorsList) { + System.out.println(error); + } + + if (errorsList.size() > 0){ + + //Assert.fail("DB have wrong card classes, founded errors: " + errorsList.size()); + } + } + private static final Pattern SHORT_JAVA_STRING = Pattern.compile("(?<=\")[A-Z][a-z]+(?=\")"); private Set findSourceTokens(Class c) throws IOException {