use of pcgen.base.format.StringManager in project pcgen by PCGen.
the class FactSetKeyActorTest method testListKeyActor.
public void testListKeyActor() {
Deity d = new Deity();
d.setName("Bob");
String expectedResult1 = "Magical";
String expectedResult2 = "Long";
df.set(id, d);
d.addToListFor(ListKey.BOOK_TYPE, expectedResult1);
d.addToListFor(ListKey.BOOK_TYPE, expectedResult2);
StringManager mgr = new StringManager();
FactSetKey<String> fsk = FactSetKey.getConstant("booktype", mgr);
d.addToSetFor(fsk, new BasicIndirect<>(mgr, expectedResult1));
d.addToSetFor(fsk, new BasicIndirect<>(mgr, expectedResult2));
FactSetKeyActor<?> lka = new FactSetKeyActor<>(fsk);
CDOMObjectWrapper.load(dsid, d.getClass(), "booktype", lka);
processThroughFreeMarker("${deity.booktype[0]}", expectedResult1);
processThroughFreeMarker("${deity.booktype[1]}", expectedResult2);
}
use of pcgen.base.format.StringManager in project pcgen by PCGen.
the class FactSetKeyActorTest method testSetJoined.
public void testSetJoined() {
Deity d = new Deity();
d.setName("Bob");
String expectedResult1 = "Magical";
String expectedResult2 = "Long";
df.set(id, d);
d.addToListFor(ListKey.BOOK_TYPE, expectedResult1);
d.addToListFor(ListKey.BOOK_TYPE, expectedResult2);
StringManager mgr = new StringManager();
FactSetKey<String> fsk = FactSetKey.getConstant("booktype", mgr);
d.addToSetFor(fsk, new BasicIndirect<>(mgr, expectedResult1));
d.addToSetFor(fsk, new BasicIndirect<>(mgr, expectedResult2));
FactSetKeyActor<?> lka = new FactSetKeyActor<>(fsk);
CDOMObjectWrapper.load(dsid, d.getClass(), "booktype", lka);
processThroughFreeMarker("${deity.booktype?join(\", \")!}", "Magical, Long");
}
use of pcgen.base.format.StringManager in project pcgen by PCGen.
the class BuildUtilities method createFact.
public static FactDefinition<?, String> createFact(LoadContext context, String factname, Class<? extends Loadable> cls) {
FactDefinition<?, String> fd = new FactDefinition<>();
fd.setUsableLocation(cls);
fd.setName("*" + factname);
fd.setFactName(factname);
fd.setFormatManager(new StringManager());
context.getReferenceContext().importObject(fd);
return fd;
}
use of pcgen.base.format.StringManager in project pcgen by PCGen.
the class PObjectTest method testGetPCCText.
/**
* Test the processing of getPCCText to ensure that it correctly produces
* an LST representation of an object and that the LST can then be reloaded
* to recrete the object.
*
* @throws PersistenceLayerException
*/
public void testGetPCCText() throws PersistenceLayerException {
OrderedPairManager opManager = new OrderedPairManager();
LoadContext context = Globals.getContext();
context.getVariableContext().assertLegalVariableID(context.getActiveScope().getLegalScope(), opManager, "Face");
Race race = new Race();
race.setName("TestRace");
race.put(ObjectKey.CHALLENGE_RATING, new ChallengeRating(FormulaFactory.getFormulaFor(5)));
String racePCCText = race.getPCCText();
assertNotNull("PCC Text for race should not be null", racePCCText);
GenericLoader<Race> raceLoader = new GenericLoader<>(Race.class);
CampaignSourceEntry source;
try {
source = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
} catch (URISyntaxException e) {
throw new UnreachableError(e);
}
raceLoader.parseLine(context, null, racePCCText, source);
Race reconstRace = context.getReferenceContext().silentlyGetConstructedCDOMObject(Race.class, "TestRace");
assertEquals("getPCCText should be the same after being encoded and reloaded", racePCCText, reconstRace.getPCCText());
assertEquals("Racial CR was not restored after saving and reloading.", race.get(ObjectKey.CHALLENGE_RATING), reconstRace.get(ObjectKey.CHALLENGE_RATING));
FactKey.getConstant("Abb", new StringManager());
PCClass aClass = new PCClass();
aClass.setName("TestClass");
String classPCCText = aClass.getPCCText();
assertNotNull("PCC Text for race should not be null", racePCCText);
PCClassLoader classLoader = new PCClassLoader();
PCClass reconstClass = classLoader.parseLine(context, null, classPCCText, source);
assertEquals("getPCCText should be the same after being encoded and reloaded", classPCCText, reconstClass.getPCCText());
assertEquals("Class abbrev was not restored after saving and reloading.", aClass.getAbbrev(), reconstClass.getAbbrev());
}
use of pcgen.base.format.StringManager in project pcgen by PCGen.
the class PreDeityTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
deity = new Deity();
deity.setName("Test Deity");
deity.put(ObjectKey.ALIGNMENT, CDOMDirectSingleRef.getRef(ng));
StringManager sm = new StringManager();
FactSetKey<String> fsk = FactSetKey.getConstant("Pantheon", sm);
deity.addToSetFor(fsk, new BasicIndirect<>(sm, "Celtic"));
}
Aggregations