Search in sources :

Example 1 with EditorLoadContext

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");
}
Also used : EditorLoadContext(pcgen.rules.context.EditorLoadContext) Before(org.junit.Before)

Example 2 with EditorLoadContext

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());
    }
}
Also used : PersistenceLayerException(pcgen.persistence.PersistenceLayerException) EditorLoadContext(pcgen.rules.context.EditorLoadContext) StringWriter(java.io.StringWriter) CDOMObject(pcgen.cdom.base.CDOMObject) ObjectCache(pcgen.cdom.inst.ObjectCache) EditorLoadContext(pcgen.rules.context.EditorLoadContext) LoadContext(pcgen.rules.context.LoadContext) PrerequisiteWriterInterface(pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 3 with EditorLoadContext

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");
}
Also used : EditorLoadContext(pcgen.rules.context.EditorLoadContext) Before(org.junit.Before)

Aggregations

EditorLoadContext (pcgen.rules.context.EditorLoadContext)3 Before (org.junit.Before)2 StringWriter (java.io.StringWriter)1 CDOMObject (pcgen.cdom.base.CDOMObject)1 ObjectCache (pcgen.cdom.inst.ObjectCache)1 Prerequisite (pcgen.core.prereq.Prerequisite)1 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)1 PrerequisiteWriterInterface (pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface)1 LoadContext (pcgen.rules.context.LoadContext)1