Search in sources :

Example 1 with MultToken

use of plugin.lsttokens.ability.MultToken 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 MultToken

use of plugin.lsttokens.ability.MultToken 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)

Example 3 with MultToken

use of plugin.lsttokens.ability.MultToken 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());
}
Also used : Ability(pcgen.core.Ability) ParseResult(pcgen.rules.persistence.token.ParseResult) Language(pcgen.core.Language) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection) MultToken(plugin.lsttokens.ability.MultToken) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Aggregations

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