Search in sources :

Example 1 with LangToken

use of plugin.lsttokens.choose.LangToken in project pcgen by PCGen.

the class AutoWeaponProfListTargetTest method testFromAbility.

@Test
public void testFromAbility() throws PersistenceLayerException {
    Ability source = create(Ability.class, "Source");
    context.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, source);
    Ability granted = createGrantedObject();
    context.getReferenceContext().constructCDOMObject(Language.class, "English");
    ParseResult result = new MultToken().parseToken(context, granted, "YES");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    result = new MultToken().parseToken(context, source, "YES");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    result = new LangToken().parseToken(context, granted, "ALL");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    result = new LangToken().parseToken(context, source, "ALL");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    result = token.parseToken(context, source, "FEAT|Granted (%LIST)");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    finishLoad();
    assertEquals(0, directAbilityFacet.getCount(id));
    CNAbilitySelection cas = new CNAbilitySelection(CNAbilityFactory.getCNAbility(AbilityCategory.FEAT, Nature.AUTOMATIC, source), "English");
    directAbilityFacet.add(id, cas, UserSelection.getInstance());
    assertTrue(containsExpected());
    assertEquals(2, directAbilityFacet.getCount(id));
    directAbilityFacet.remove(id, cas, UserSelection.getInstance());
    assertEquals(0, directAbilityFacet.getCount(id));
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) ParseResult(pcgen.rules.persistence.token.ParseResult) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection) MultToken(plugin.lsttokens.ability.MultToken) LangToken(plugin.lsttokens.choose.LangToken) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 2 with LangToken

use of plugin.lsttokens.choose.LangToken in project pcgen by PCGen.

the class AutoWeaponProfListTargetTest method testFromTemplate.

@Test
public void testFromTemplate() throws PersistenceLayerException {
    PCTemplate source = create(PCTemplate.class, "Source");
    Ability granted = createGrantedObject();
    context.getReferenceContext().constructCDOMObject(Language.class, "English");
    ParseResult result = new MultToken().parseToken(context, granted, "YES");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    result = new LangToken().parseToken(context, granted, "ALL");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    result = new LangToken().parseToken(context, source, "ALL");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    result = token.parseToken(context, source, "FEAT|Granted (%LIST)");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    finishLoad();
    assertEquals(0, directAbilityFacet.getCount(id));
    Object sel = getAssoc();
    templateInputFacet.directAdd(id, source, sel);
    assertTrue(containsExpected());
    assertEquals(1, directAbilityFacet.getCount(id));
    templateInputFacet.remove(id, source);
    assertEquals(0, directAbilityFacet.getCount(id));
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) ParseResult(pcgen.rules.persistence.token.ParseResult) PCTemplate(pcgen.core.PCTemplate) MultToken(plugin.lsttokens.ability.MultToken) LangToken(plugin.lsttokens.choose.LangToken) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Aggregations

Test (org.junit.Test)2 CNAbility (pcgen.cdom.content.CNAbility)2 Ability (pcgen.core.Ability)2 ParseResult (pcgen.rules.persistence.token.ParseResult)2 MultToken (plugin.lsttokens.ability.MultToken)2 LangToken (plugin.lsttokens.choose.LangToken)2 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)2 CNAbilitySelection (pcgen.cdom.helper.CNAbilitySelection)1 PCTemplate (pcgen.core.PCTemplate)1