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();
}
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();
}
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();
}
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());
}
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);
}
Aggregations