FIX cardDb tests in Maven for ImageKeys Mock configuration between subclasses

This commit is contained in:
leriomaggio
2021-09-13 10:15:32 +01:00
parent 99fdd4b551
commit 236fd99862
4 changed files with 38 additions and 22 deletions

View File

@@ -556,9 +556,11 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
// Before returning make sure that actual candidate has Image.
// If not, try to replace current candidate with one having image,
// so to align this implementation with old one.
while (!candidate.hasImage() && candidatesIterator.hasNext()) {
// If none will have image, the original candidate will be retained!
PaperCard firstCandidate = candidate;
while (!candidate.hasImage() && candidatesIterator.hasNext())
candidate = candidatesIterator.next();
}
candidate = candidate.hasImage() ? candidate : firstCandidate;
return isFoil ? candidate.getFoiled() : candidate;
}
@@ -724,10 +726,12 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
final Iterator<CardEdition> editionIterator = acceptedEditions.iterator();
CardEdition ed = editionIterator.next();
PaperCard candidate = candidatesCard.get(ed.getCode());
PaperCard firstCandidate = candidate;
while (!candidate.hasImage() && editionIterator.hasNext()) {
ed = editionIterator.next();
candidate = candidatesCard.get(ed.getCode());
}
candidate = candidate.hasImage() ? candidate : firstCandidate;
//If any, we're sure that at least one candidate is always returned despite it having any image
return cr.isFoil ? candidate.getFoiled() : candidate;
}