mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
new method with tests to get all cards with a filter predicate.
New method in Interface API to get all cards in a given setCode. This has changed the implementation of getArtCount avoiding to iterate over all the possible card prints.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package forge.card;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import forge.StaticData;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.PaperCard;
|
||||
@@ -10,7 +11,10 @@ import org.testng.annotations.Test;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
@@ -101,6 +105,44 @@ public class CardDbTestCase extends ForgeCardMockTestCase {
|
||||
this.legacyCardDb = new LegacyCardDb(data.getCommonCards().getAllCards(), data.getEditions());
|
||||
}
|
||||
|
||||
/*
|
||||
* TEST FOR GET ALL CARDS
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testGetAllCardsWithName(){
|
||||
List<PaperCard> allCounterSpellPrints = this.cardDb.getAllCards(this.cardNameCounterspell);
|
||||
assertNotNull(allCounterSpellPrints);
|
||||
for (PaperCard card : allCounterSpellPrints)
|
||||
assertEquals(card.getName(), this.cardNameCounterspell);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAllCardsThatWerePrintedInSets(){
|
||||
List<String> allowedSets = new ArrayList<>();
|
||||
allowedSets.add(this.latestArtShivanDragonEdition);
|
||||
Predicate<PaperCard> wasPrinted = (Predicate<PaperCard>) this.cardDb.wasPrintedInSets(allowedSets);
|
||||
List<PaperCard> allCardsInSet = this.cardDb.getAllCards(wasPrinted);
|
||||
assertNotNull(allCardsInSet);
|
||||
}
|
||||
|
||||
@Test void testGetAllCardsOfaGivenNameAndLegalInSets(){
|
||||
List<String> allowedSets = new ArrayList<>(Arrays.asList(this.editionsCounterspell));
|
||||
Predicate<PaperCard> printedInSets = (Predicate<PaperCard>) this.cardDb.wasPrintedInSets(allowedSets);
|
||||
List<PaperCard> allCounterSpellsInSets = this.cardDb.getAllCards(this.cardNameCounterspell, printedInSets);
|
||||
assertNotNull(allCounterSpellsInSets);
|
||||
assertTrue(allCounterSpellsInSets.size() > 0);
|
||||
assertTrue(allCounterSpellsInSets.size() > 1);
|
||||
for (PaperCard card : allCounterSpellsInSets) {
|
||||
assertEquals(card.getName(), this.cardNameCounterspell);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TEST FOR CARD RETRIEVAL METHODS
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testGetCardByName() {
|
||||
PaperCard legacyCard = this.legacyCardDb.getCard(cardNameShivanDragon);
|
||||
|
||||
Reference in New Issue
Block a user