Search in sources :

Example 1 with ParseResult

use of pcgen.rules.persistence.token.ParseResult in project pcgen by PCGen.

the class PCClassLevelDomainTest method testSimple.

@Test
public void testSimple() throws PersistenceLayerException {
    PCClass source = create(PCClass.class, "Source");
    PCClassLevel pcl = source.getOriginalClassLevel(2);
    Domain granted = create(Domain.class, "Granted");
    ParseResult result = token.parseToken(context, pcl, "Granted");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    finishLoad();
    assertEquals(0, domainFacet.getCount(id));
    classFacet.addClass(id, source);
    PCClass pcc = pc.getClassKeyed(source.getKeyName());
    classFacet.setLevel(id, pcc, 1);
    //TODO get rid of this using facets :)
    DomainApplication.addDomainsUpToLevel(source, 1, pc);
    assertEquals(0, domainFacet.getCount(id));
    classFacet.setLevel(id, pcc, 2);
    DomainApplication.addDomainsUpToLevel(source, 2, pc);
    assertTrue(domainFacet.contains(id, granted));
    assertEquals(1, domainFacet.getCount(id));
    DomainApplication.removeDomainsForLevel(source, 2, pc);
    DomainApplication.removeDomainsForLevel(source, 1, pc);
    pc.validateCharacterDomains();
    classFacet.removeClass(id, source);
    assertEquals(0, domainFacet.getCount(id));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) PCClass(pcgen.core.PCClass) Domain(pcgen.core.Domain) PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 2 with ParseResult

use of pcgen.rules.persistence.token.ParseResult in project pcgen by PCGen.

the class RaceMonsterClassTest method testSimple.

@Test
public void testSimple() throws PersistenceLayerException {
    TokenRegistration.register(plugin.bonustokens.Feat.class);
    Race source = create(Race.class, "Source");
    create(PCClass.class, "Granted").put(ObjectKey.IS_MONSTER, Boolean.TRUE);
    ParseResult result = token.parseToken(context, source, "Granted:3");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    finishLoad();
    assertEquals(0, classFacet.getCount(id));
    raceFacet.directSet(id, source, getAssoc());
    assertEquals(1, classFacet.getCount(id));
    assertNotNull(pc.getClassKeyed("Granted"));
    raceFacet.remove(id);
    assertEquals(0, classFacet.getCount(id));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) Race(pcgen.core.Race) PCClass(pcgen.core.PCClass) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 3 with ParseResult

use of pcgen.rules.persistence.token.ParseResult in project pcgen by PCGen.

the class TemplateAddLevelTest method testSimple.

@Test
public void testSimple() throws PersistenceLayerException {
    PCTemplate source = create(PCTemplate.class, "Source");
    create(PCClass.class, "Granted");
    ParseResult result = token.parseToken(context, source, "Granted|3");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    finishLoad();
    assertEquals(0, classFacet.getCount(id));
    templateInputFacet.directAdd(id, source, getAssoc());
    assertEquals(1, classFacet.getCount(id));
    assertNotNull(pc.getClassKeyed("Granted"));
    templateInputFacet.remove(id, source);
    assertEquals(0, classFacet.getCount(id));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) PCTemplate(pcgen.core.PCTemplate) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 4 with ParseResult

use of pcgen.rules.persistence.token.ParseResult in project pcgen by PCGen.

the class TemplateLangbonusTest method testSimple.

@Test
public void testSimple() throws PersistenceLayerException {
    PCTemplate source = create(PCTemplate.class, "Source");
    Language granted = create(Language.class, "Granted");
    ParseResult result = token.parseToken(context, source, "Granted");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    finishLoad();
    assertEquals(0, startingLanguageFacet.getCount(id));
    templateInputFacet.directAdd(id, source, getAssoc());
    assertTrue(startingLanguageFacet.contains(id, granted));
    assertEquals(1, startingLanguageFacet.getCount(id));
    templateInputFacet.remove(id, source);
    assertEquals(0, startingLanguageFacet.getCount(id));
}
Also used : Language(pcgen.core.Language) ParseResult(pcgen.rules.persistence.token.ParseResult) PCTemplate(pcgen.core.PCTemplate) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 5 with ParseResult

use of pcgen.rules.persistence.token.ParseResult in project pcgen by PCGen.

the class AbstractAbilityGrantCheckTest method getMultYesStackYesChooseNoChoice.

public Ability getMultYesStackYesChooseNoChoice(String s) {
    Ability a = create(Ability.class, s);
    context.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, a);
    ParseResult result = ABILITY_MULT_TOKEN.parseToken(context, a, "YES");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    result = ABILITY_STACK_TOKEN.parseToken(context, a, "YES");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    result = CHOOSE_NOCHOICE_TOKEN.parseToken(context, a, null);
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    return a;
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) ParseResult(pcgen.rules.persistence.token.ParseResult)

Aggregations

ParseResult (pcgen.rules.persistence.token.ParseResult)210 StringTokenizer (java.util.StringTokenizer)68 Test (org.junit.Test)45 CDOMReference (pcgen.cdom.base.CDOMReference)30 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)26 Ability (pcgen.core.Ability)21 ArrayList (java.util.ArrayList)18 Formula (pcgen.base.formula.Formula)18 ParsingSeparator (pcgen.base.text.ParsingSeparator)18 Prerequisite (pcgen.core.prereq.Prerequisite)18 PCClass (pcgen.core.PCClass)17 Ungranted (pcgen.cdom.base.Ungranted)15 PCTemplate (pcgen.core.PCTemplate)14 CNAbility (pcgen.cdom.content.CNAbility)13 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)11 ComplexParseResult (pcgen.rules.persistence.token.ComplexParseResult)11 BigDecimal (java.math.BigDecimal)10 Race (pcgen.core.Race)10 ConcretePersistentTransitionChoice (pcgen.cdom.base.ConcretePersistentTransitionChoice)9 LegalScope (pcgen.base.formula.base.LegalScope)8