Search in sources :

Example 6 with ConsolidatedListCommitStrategy

use of pcgen.rules.context.ConsolidatedListCommitStrategy in project pcgen by PCGen.

the class FactSetDefTokenTest method resetContext.

protected void resetContext() {
    URI testURI = testCampaign.getURI();
    context = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
    context.setSourceURI(testURI);
    context.setExtractURI(testURI);
    fd = new FactSetDefinition();
}
Also used : FactSetDefinition(pcgen.cdom.content.factset.FactSetDefinition) ConsolidatedListCommitStrategy(pcgen.rules.context.ConsolidatedListCommitStrategy) RuntimeReferenceContext(pcgen.rules.context.RuntimeReferenceContext) URI(java.net.URI) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext)

Example 7 with ConsolidatedListCommitStrategy

use of pcgen.rules.context.ConsolidatedListCommitStrategy in project pcgen by PCGen.

the class FunctionTokenTest method resetContext.

protected void resetContext() {
    URI testURI = testCampaign.getURI();
    context = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
    context.setSourceURI(testURI);
    context.setExtractURI(testURI);
    function = new UserFunction();
}
Also used : UserFunction(pcgen.cdom.content.UserFunction) ConsolidatedListCommitStrategy(pcgen.rules.context.ConsolidatedListCommitStrategy) RuntimeReferenceContext(pcgen.rules.context.RuntimeReferenceContext) URI(java.net.URI) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext)

Example 8 with ConsolidatedListCommitStrategy

use of pcgen.rules.context.ConsolidatedListCommitStrategy in project pcgen by PCGen.

the class DisplayNameTokenTest method resetContext.

protected void resetContext() {
    URI testURI = testCampaign.getURI();
    context = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
    context.setSourceURI(testURI);
    context.setExtractURI(testURI);
    cd = new FactDefinition();
}
Also used : FactDefinition(pcgen.cdom.content.fact.FactDefinition) ConsolidatedListCommitStrategy(pcgen.rules.context.ConsolidatedListCommitStrategy) RuntimeReferenceContext(pcgen.rules.context.RuntimeReferenceContext) URI(java.net.URI) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext)

Example 9 with ConsolidatedListCommitStrategy

use of pcgen.rules.context.ConsolidatedListCommitStrategy in project pcgen by PCGen.

the class AbstractTokenTestCase method resetContext.

protected void resetContext() {
    URI testURI = testCampaign.getURI();
    primaryContext = getPrimaryContext();
    secondaryContext = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
    primaryContext.setSourceURI(testURI);
    primaryContext.setExtractURI(testURI);
    secondaryContext.setSourceURI(testURI);
    secondaryContext.setExtractURI(testURI);
    primaryContext.getReferenceContext().importObject(AbilityCategory.FEAT);
    secondaryContext.getReferenceContext().importObject(AbilityCategory.FEAT);
    primaryProf = getPrimary("TestObj");
    primaryProf.setSourceURI(testCampaign.getURI());
    secondaryProf = getSecondary("TestObj");
    secondaryProf.setSourceURI(testCampaign.getURI());
}
Also used : ConsolidatedListCommitStrategy(pcgen.rules.context.ConsolidatedListCommitStrategy) RuntimeReferenceContext(pcgen.rules.context.RuntimeReferenceContext) URI(java.net.URI) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext)

Example 10 with ConsolidatedListCommitStrategy

use of pcgen.rules.context.ConsolidatedListCommitStrategy in project pcgen by PCGen.

the class DropIntoContextFunctionTest method testDynamic.

@Test
public void testDynamic() {
    VariableLibrary vl = getVariableLibrary();
    LegalScope equipScope = getScopeLibrary().getScope("EQUIPMENT");
    LegalScope globalScope = getScopeLibrary().getScope("Global");
    vl.assertLegalVariableID("LocalVar", equipScope, numberManager);
    vl.assertLegalVariableID("EquipVar", globalScope, stringManager);
    String formula = "dropIntoContext(\"EQUIPMENT\",EquipVar,LocalVar)";
    SimpleNode node = TestUtilities.doParse(formula);
    SemanticsVisitor semanticsVisitor = new SemanticsVisitor();
    FormulaSemantics semantics = generateFormulaSemantics(getFormulaManager(), getGlobalScope(), null);
    semanticsVisitor.visit(node, semantics);
    if (!semantics.isValid()) {
        TestCase.fail("Expected Valid Formula: " + formula + " but was told: " + semantics.getReport());
    }
    isStatic(formula, node, false);
    Equipment equip = new Equipment();
    equip.setName("EquipKey");
    Equipment equipalt = new Equipment();
    equipalt.setName("EquipAlt");
    ScopeInstance scopeInste = getInstanceFactory().get("EQUIPMENT", equip);
    VariableID varIDe = vl.getVariableID(scopeInste, "LocalVar");
    getVariableStore().put(varIDe, 2);
    ScopeInstance scopeInsta = getInstanceFactory().get("EQUIPMENT", equipalt);
    VariableID varIDa = vl.getVariableID(scopeInsta, "LocalVar");
    getVariableStore().put(varIDa, 3);
    ScopeInstance globalInst = getInstanceFactory().getGlobalInstance("Global");
    VariableID varIDq = vl.getVariableID(globalInst, "EquipVar");
    getVariableStore().put(varIDq, "EquipKey");
    LoadContext context = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
    context.getReferenceContext().importObject(equip);
    context.getReferenceContext().importObject(equipalt);
    evaluatesTo(formula, node, 2, context);
    Object rv = new ReconstructionVisitor().visit(node, new StringBuilder());
    assertEquals(rv.toString(), formula);
    getVariableStore().put(varIDq, "EquipAlt");
    evaluatesTo(formula, node, 3, context);
}
Also used : ScopeInstance(pcgen.base.formula.base.ScopeInstance) ConsolidatedListCommitStrategy(pcgen.rules.context.ConsolidatedListCommitStrategy) FormulaSemantics(pcgen.base.formula.base.FormulaSemantics) RuntimeReferenceContext(pcgen.rules.context.RuntimeReferenceContext) VariableLibrary(pcgen.base.formula.base.VariableLibrary) SimpleNode(pcgen.base.formula.parse.SimpleNode) SemanticsVisitor(pcgen.base.formula.visitor.SemanticsVisitor) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext) Equipment(pcgen.core.Equipment) ReconstructionVisitor(pcgen.base.formula.visitor.ReconstructionVisitor) LegalScope(pcgen.base.formula.base.LegalScope) LoadContext(pcgen.rules.context.LoadContext) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext) VariableID(pcgen.base.formula.base.VariableID) Test(org.junit.Test)

Aggregations

ConsolidatedListCommitStrategy (pcgen.rules.context.ConsolidatedListCommitStrategy)25 RuntimeLoadContext (pcgen.rules.context.RuntimeLoadContext)25 RuntimeReferenceContext (pcgen.rules.context.RuntimeReferenceContext)23 URI (java.net.URI)14 FactDefinition (pcgen.cdom.content.fact.FactDefinition)8 Before (org.junit.Before)4 LoadContext (pcgen.rules.context.LoadContext)3 Test (org.junit.Test)2 FormulaSemantics (pcgen.base.formula.base.FormulaSemantics)2 LegalScope (pcgen.base.formula.base.LegalScope)2 ScopeInstance (pcgen.base.formula.base.ScopeInstance)2 VariableID (pcgen.base.formula.base.VariableID)2 VariableLibrary (pcgen.base.formula.base.VariableLibrary)2 SimpleNode (pcgen.base.formula.parse.SimpleNode)2 ReconstructionVisitor (pcgen.base.formula.visitor.ReconstructionVisitor)2 SemanticsVisitor (pcgen.base.formula.visitor.SemanticsVisitor)2 CDOMObject (pcgen.cdom.base.CDOMObject)2 UserFunction (pcgen.cdom.content.UserFunction)2 Equipment (pcgen.core.Equipment)2 PCClass (pcgen.core.PCClass)2