use of pcgen.core.Language in project pcgen by PCGen.
the class FreeLanguageFacetTest method getObject.
@Override
protected Language getObject() {
Language t = new Language();
t.setName("Language" + n++);
return t;
}
use of pcgen.core.Language in project pcgen by PCGen.
the class AbstractGlobalTargetedSaveRestoreTest method testAutoLanguageList.
@Test
public void testAutoLanguageList() {
T target = create(getObjectClass(), "Target");
Language granted = create(Language.class, "Granted");
create(Language.class, "Ignored");
new plugin.lsttokens.auto.LangToken().parseToken(context, target, "%LIST");
new plugin.lsttokens.choose.LangToken().parseToken(context, target, "Granted|Ignored");
additionalChooseSet(target);
Object o = prepare(target);
finishLoad();
assertFalse(pc.hasLanguage(granted));
applyObject(target);
assertTrue(pc.hasLanguage(granted));
runRoundRobin(getPreEqualityCleanup());
assertTrue(pc.hasLanguage(granted));
assertTrue(reloadedPC.hasLanguage(granted));
remove(o);
reloadedPC.setDirty(true);
if (isSymmetric()) {
assertFalse(reloadedPC.hasLanguage(granted));
}
}
use of pcgen.core.Language in project pcgen by PCGen.
the class AbstractGlobalTargetedSaveRestoreTest method testAddLanguage.
//TODO We accept this is not symmetric now due to equipment cloning
// @Test
// public void testAutoEquipment()
// {
// T target = create(getObjectClass(), "Target");
// Equipment granted = create(Equipment.class, "Granted");
// create(Equipment.class, "Ignored");
// new plugin.lsttokens.auto.EquipToken().parseToken(context, target,
// "%LIST");
// new plugin.lsttokens.choose.EquipmentToken().parseToken(context,
// target, "Granted|Ignored");
// Object o = prepare(target);
// finishLoad();
// assertFalse(pc.getEquipmentMasterList().contains(granted));
// applyObject(target);
// assertTrue(pc.getEquipmentMasterList().contains(granted));
// dumpPC(pc);
// runRoundRobin();
// assertTrue(pc.getEquipmentMasterList().contains(granted));
// assertTrue(reloadedPC.getEquipmentMasterList().contains(granted));
// remove(o);
// reloadedPC.setDirty(true);
// assertFalse(reloadedPC.getEquipmentMasterList().contains(granted));
// }
@Test
public void testAddLanguage() {
Language granted = create(Language.class, "MyLanguage");
create(Language.class, "Ignored");
T target = create(getObjectClass(), "Target");
new plugin.lsttokens.add.LanguageToken().parseToken(context, target, "MyLanguage");
Object o = prepare(target);
finishLoad();
assertFalse(pc.hasLanguage(granted));
applyObject(target);
assertTrue(pc.hasLanguage(granted));
runRoundRobin(getPreEqualityCleanup());
assertTrue(pc.hasLanguage(granted));
assertTrue(reloadedPC.hasLanguage(granted));
remove(o);
reloadedPC.setDirty(true);
assertFalse(reloadedPC.hasLanguage(granted));
}
use of pcgen.core.Language in project pcgen by PCGen.
the class AddTargetedAbilityNormalTest method containsExpected.
@Override
protected boolean containsExpected(Ability granted) {
Collection<CNAbility> abilities = getTargetFacet().getPoolAbilities(id, AbilityCategory.FEAT, Nature.NORMAL);
for (CNAbility a : abilities) {
boolean abilityExpected = a.getAbility().equals(context.getReferenceContext().silentlyGetConstructedCDOMObject(Ability.class, AbilityCategory.FEAT, "Granted"));
if (abilityExpected) {
if (pc.getDetailedAssociationCount(a) == 1) {
if (!pc.getAssociationList(a).get(0).equals("English")) {
continue;
}
Language english = context.getReferenceContext().silentlyGetConstructedCDOMObject(Language.class, "English");
languageFacet.contains(id, english);
return true;
}
}
}
return false;
}
use of pcgen.core.Language in project pcgen by PCGen.
the class AutoLangListTest method testFromAbility.
@Test
public void testFromAbility() throws PersistenceLayerException {
Ability source = create(Ability.class, "Source");
ParseResult result = new MultToken().parseToken(context, source, "YES");
if (result != ParseResult.SUCCESS) {
result.printMessages();
fail("Test Setup Failed");
}
context.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, source);
Language granted = createGrantedObject();
processToken(source);
assertEquals(0, getCount());
CNAbilitySelection cas = new CNAbilitySelection(CNAbilityFactory.getCNAbility(AbilityCategory.FEAT, Nature.AUTOMATIC, source), "Granted");
directAbilityFacet.add(id, cas, UserSelection.getInstance());
assertTrue(containsExpected(granted));
assertEquals(1, getCount());
directAbilityFacet.remove(id, cas, UserSelection.getInstance());
assertEquals(0, getCount());
assertTrue(cleanedSideEffects());
}
Aggregations