use of pcgen.rules.context.EditorLoadContext in project pcgen by PCGen.
the class AbstractIntegrationTestCase method setUp.
@Override
@Before
public void setUp() throws PersistenceLayerException, URISyntaxException {
if (!classSetUpFired) {
classSetUp();
}
// Yea, this causes warnings...
TokenRegistration.register(getToken());
primaryContext = new EditorLoadContext();
secondaryContext = new EditorLoadContext();
primaryContext.getReferenceContext().importObject(AbilityCategory.FEAT);
secondaryContext.getReferenceContext().importObject(AbilityCategory.FEAT);
primaryProf = primaryContext.getReferenceContext().constructCDOMObject(getCDOMClass(), "TestObj");
secondaryProf = secondaryContext.getReferenceContext().constructCDOMObject(getCDOMClass(), "TestObj");
}
use of pcgen.rules.context.EditorLoadContext in project pcgen by PCGen.
the class AbstractPreRoundRobin method runSimpleRoundRobin.
public static void runSimpleRoundRobin(String s, String d) {
try {
Prerequisite p = PreParserFactory.getInstance().parse(s);
PrerequisiteWriterInterface writer = PrerequisiteWriterFactory.getInstance().getWriter(p.getKind());
if (writer == null) {
fail("Could not find Writer for: " + p.getKind());
}
StringWriter w = new StringWriter();
writer.write(w, p);
assertEquals(d, w.toString());
/*
* Now try new system
*/
LoadContext context = new EditorLoadContext();
CDOMObject obj = new ObjectCache();
int colonLoc = s.indexOf(':');
String key = s.substring(0, colonLoc);
String value = s.substring(colonLoc + 1);
if (context.processToken(obj, key, value)) {
context.commit();
} else {
context.rollback();
Logging.replayParsedMessages();
fail();
}
Logging.clearParseMessages();
Collection<String> output = context.unparse(obj);
if (output == null || output.isEmpty()) {
// Uh Oh
fail("Unable to unparse: " + key + ":" + value);
}
assertEquals(1, output.size());
assertEquals(d, output.iterator().next());
} catch (PersistenceLayerException e) {
e.printStackTrace();
fail(e.getLocalizedMessage());
}
}
use of pcgen.rules.context.EditorLoadContext in project pcgen by PCGen.
the class AbstractPCClassLevelTokenTestCase method setUp.
@Override
@Before
public void setUp() throws PersistenceLayerException, URISyntaxException {
if (!classSetUpFired) {
classSetUp();
}
// Yea, this causes warnings...
TokenRegistration.register(getToken());
primaryContext = new EditorLoadContext();
secondaryContext = new EditorLoadContext();
primaryProf1 = primaryContext.getReferenceContext().constructCDOMObject(getCDOMClass(), "TestObj1");
secondaryProf1 = secondaryContext.getReferenceContext().constructCDOMObject(getCDOMClass(), "TestObj1");
primaryProf2 = primaryContext.getReferenceContext().constructCDOMObject(getCDOMClass(), "TestObj2");
secondaryProf2 = secondaryContext.getReferenceContext().constructCDOMObject(getCDOMClass(), "TestObj2");
primaryProf3 = primaryContext.getReferenceContext().constructCDOMObject(getCDOMClass(), "TestObj3");
secondaryProf3 = secondaryContext.getReferenceContext().constructCDOMObject(getCDOMClass(), "TestObj3");
}
Aggregations