mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
FIX cardDb bug for lazy card loading when issuing a request with a non-existing set code.
Code FIX + Test
This commit is contained in:
@@ -249,6 +249,8 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
}
|
||||
} else {
|
||||
CardEdition e = editions.get(setCode);
|
||||
if (e == null)
|
||||
return; // wrong set code - nothing we can do here!
|
||||
List<CardInSet> cardsInSet = e.getCardInSet(cardName); // empty collection if not present
|
||||
for (CardInSet cis : cardsInSet) {
|
||||
addSetCard(e, cis, cr);
|
||||
|
||||
@@ -89,4 +89,29 @@ public class CardDbTestLazyCardLoading extends ForgeCardMockTestCase {
|
||||
assertNotNull(aetherVialCard);
|
||||
assertEquals(aetherVialCard.getName(), expectedCardName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tesLoadAndGetUnsupportedCardHavingWrongSetCode(){
|
||||
String cardName = "Dominating Licid";
|
||||
String wrongSetCode = "AA";
|
||||
String expectedSetCode = CardEdition.UNKNOWN.getCode();
|
||||
CardRarity expectedCardRarity = CardRarity.Unknown;
|
||||
|
||||
PaperCard dominatingLycidCard = this.cardDb.getCard(cardName);
|
||||
assertNull(dominatingLycidCard);
|
||||
|
||||
// Load the Card (just card name
|
||||
FModel.getMagicDb().attemptToLoadCard(cardName, wrongSetCode);
|
||||
|
||||
dominatingLycidCard = this.cardDb.getCard(cardName);
|
||||
assertNull(dominatingLycidCard); // card still not found
|
||||
|
||||
// Resorting to Unsupported Card Request
|
||||
String cardRequest = CardDb.CardRequest.compose(cardName, wrongSetCode);
|
||||
dominatingLycidCard = this.cardDb.createUnsupportedCard(cardRequest);
|
||||
assertNotNull(dominatingLycidCard);
|
||||
assertEquals(dominatingLycidCard.getName(), cardName);
|
||||
assertEquals(dominatingLycidCard.getEdition(), expectedSetCode);
|
||||
assertEquals(dominatingLycidCard.getRarity(), expectedCardRarity);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user