use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class ArmorProfTokenTest method constructTyped.
@Override
protected CDOMObject constructTyped(LoadContext loadContext, String one) {
CDOMObject cdo = loadContext.getReferenceContext().constructCDOMObject(Equipment.class, one);
cdo.addToListFor(ListKey.TYPE, Type.getConstant("Armor"));
return cdo;
}
use of pcgen.cdom.base.CDOMObject 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.cdom.base.CDOMObject in project pcgen by PCGen.
the class LocalSkillCostFacetTest method testAddBadSource.
@Test
public void testAddBadSource() {
Skill t1 = getObject();
PCClassLevel pcl = new PCClassLevel();
DataFacetChangeEvent<CharID, CDOMObject> dfce = new DataFacetChangeEvent<>(id, pcl, new Object(), DataFacetChangeEvent.DATA_ADDED);
ListKey<CDOMReference<Skill>> lk = ListKey.LOCALCSKILL;
pcl.addToListFor(lk, CDOMDirectSingleRef.getRef(t1));
try {
getFacet().dataAdded(dfce);
fail();
} catch (IllegalArgumentException e) {
// Yep!
}
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class LocalSkillCostFacetTest method testRemoveSecondSource.
@Test
public void testRemoveSecondSource() {
Skill t1 = getObject();
assertFalse(getFacet().contains(id, class1, SkillCost.CLASS, t1));
addCost(id, class1, t1, SkillCost.CLASS);
PCClassLevel pcl = new PCClassLevel();
pcl.put(ObjectKey.PARENT, class1);
DataFacetChangeEvent<CharID, CDOMObject> dfce = new DataFacetChangeEvent<>(id, pcl, new Object(), DataFacetChangeEvent.DATA_ADDED);
ListKey<CDOMReference<Skill>> lk = ListKey.LOCALCSKILL;
pcl.addToListFor(lk, CDOMDirectSingleRef.getRef(t1));
getFacet().dataAdded(dfce);
assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
removeCosts(id, pcl);
assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class MovementFacetTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
CDOMObject cdo1 = new PCTemplate();
cdo1.setName("Templ");
CDOMObject cdo2 = new Race();
cdo2.setName("Race");
PCStat pcs1 = new PCStat();
pcs1.setName("Stat1");
PCStat pcs2 = new PCStat();
pcs2.setName("Stat2");
Movement st1 = new Movement(1);
Movement st2 = new Movement(1);
cdo1.addToListFor(ListKey.MOVEMENT, st1);
cdo2.addToListFor(ListKey.MOVEMENT, st2);
source = new CDOMObject[] { cdo1, cdo2 };
target = new Movement[] { st1, st2 };
}
Aggregations