use of pcgen.cdom.reference.CDOMSimpleSingleRef in project pcgen by PCGen.
the class PlayerCharacterTest method testGetAvailableFollowers.
/**
* Validate the getAvailableFollowers function.
*/
public void testGetAvailableFollowers() {
readyToRun();
Ability ab = TestHelper.makeAbility("Tester1", AbilityCategory.FEAT, "Empty Container");
Ability mab = TestHelper.makeAbility("Tester2", AbilityCategory.FEAT, "Mount Container");
Ability fab = TestHelper.makeAbility("Tester3", AbilityCategory.FEAT, "Familiar Container");
PlayerCharacter pc = getCharacter();
CharacterDisplay display = pc.getDisplay();
addAbility(AbilityCategory.FEAT, ab);
CDOMSingleRef<CompanionList> ref = new CDOMSimpleSingleRef<>(CompanionList.class, "Mount");
CDOMReference<Race> race = new CDOMDirectSingleRef<>(giantRace);
FollowerOption option = new FollowerOption(race, ref);
mab.addToListFor(ListKey.COMPANIONLIST, option);
ref = new CDOMSimpleSingleRef<>(CompanionList.class, "Familiar");
race = new CDOMDirectSingleRef<>(human);
option = new FollowerOption(race, ref);
fab.addToListFor(ListKey.COMPANIONLIST, option);
Set<FollowerOption> fo = display.getAvailableFollowers("Familiar", null).keySet();
assertTrue("Initially familiar list should be empty", fo.isEmpty());
fo = display.getAvailableFollowers("MOUNT", null).keySet();
assertTrue("Initially mount list should be empty", fo.isEmpty());
addAbility(AbilityCategory.FEAT, mab);
fo = display.getAvailableFollowers("Familiar", null).keySet();
assertTrue("Familiar list should still be empty", fo.isEmpty());
fo = display.getAvailableFollowers("MOUNT", null).keySet();
assertFalse("Mount list should not be empty anymore", fo.isEmpty());
assertEquals("Mount should be the giant race", giantRace.getKeyName(), fo.iterator().next().getRace().getKeyName());
assertEquals("Mount list should only have one entry", 1, fo.size());
addAbility(AbilityCategory.FEAT, fab);
fo = display.getAvailableFollowers("Familiar", null).keySet();
assertFalse("Familiar list should not be empty anymore", fo.isEmpty());
assertEquals("Familiar should be the human race", human.getKeyName(), fo.iterator().next().getRace().getKeyName());
assertEquals("Familiar list should only have one entry", 1, fo.size());
fo = display.getAvailableFollowers("MOUNT", null).keySet();
assertFalse("Mount list should not be empty anymore", fo.isEmpty());
assertEquals("Mount should be the giant race", giantRace.getKeyName(), fo.iterator().next().getRace().getKeyName());
assertEquals("Mount list should only have one entry", 1, fo.size());
}
use of pcgen.cdom.reference.CDOMSimpleSingleRef in project pcgen by PCGen.
the class CompanionSupportFacadeImplTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
uiDelegate = new MockUIDelegate();
todoManager = new TodoManager();
ListFacade<CampaignFacade> campaigns = new DefaultListFacade<>();
dataSetFacade = new DataSet(Globals.getContext(), SettingsHandler.getGame(), campaigns);
masterRace = TestHelper.makeRace("Wood Elf");
companionRace = TestHelper.makeRace("Weasel");
CDOMReference<Race> race = new CDOMDirectSingleRef<>(companionRace);
CDOMSingleRef<CompanionList> ref = new CDOMSimpleSingleRef<>(CompanionList.class, companionList.getKeyName());
FollowerOption option = new FollowerOption(race, ref);
masterRace.addToListFor(ListKey.COMPANIONLIST, option);
}
Aggregations