MCPcopy Create free account
hub / github.com/PCGen/pcgen / testGetPCCText

Method testGetPCCText

code/src/test/pcgen/core/PObjectTest.java:109–159  ·  view source on GitHub ↗

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 recreate the object. @throws PersistenceLayerException the persistence layer exception

()

Source from the content-addressed store, hash-verified

107 * @throws PersistenceLayerException the persistence layer exception
108 */
109 @Test
110 public void testGetPCCText() throws PersistenceLayerException
111 {
112 OrderedPairManager opManager = new OrderedPairManager();
113 LoadContext context = Globals.getContext();
114 context.getVariableContext().assertLegalVariableID(
115 CControl.FACE.getDefaultValue(), context.getActiveScope(), opManager);
116 Race race = new Race();
117 race.setName("TestRace");
118 race.put(ObjectKey.CHALLENGE_RATING, new ChallengeRating(FormulaFactory.getFormulaFor(5)));
119 String racePCCText = race.getPCCText();
120 assertNotNull("PCC Text for race should not be null", racePCCText);
121
122 GenericLoader<Race> raceLoader = new GenericLoader<>(Race.class);
123 CampaignSourceEntry source;
124 try
125 {
126 source = new CampaignSourceEntry(new Campaign(),
127 new URI("file:/" + getClass().getName() + ".java"));
128 }
129 catch (URISyntaxException e)
130 {
131 throw new UnreachableError(e);
132 }
133 raceLoader.parseLine(context, null, racePCCText, source);
134 Race reconstRace = context.getReferenceContext().silentlyGetConstructedCDOMObject(Race.class, "TestRace");
135 assertEquals(
136 "getPCCText should be the same after being encoded and reloaded",
137 racePCCText, reconstRace.getPCCText());
138 assertEquals("Racial CR was not restored after saving and reloading.",
139 race.get(ObjectKey.CHALLENGE_RATING), reconstRace
140 .get(ObjectKey.CHALLENGE_RATING));
141
142 FactKey.getConstant("Abb", new StringManager());
143 PCClass aClass = new PCClass();
144 aClass.setName("TestClass");
145 String classPCCText = aClass.getPCCText();
146 assertNotNull("PCC Text for race should not be null", racePCCText);
147
148 PCClassLoader classLoader = new PCClassLoader();
149 PCClass reconstClass =
150 classLoader.parseLine(context, null, classPCCText,
151 source);
152 assertEquals(
153 "getPCCText should be the same after being encoded and reloaded",
154 classPCCText, reconstClass.getPCCText());
155 assertEquals(
156 "Class abbrev was not restored after saving and reloading.", aClass
157 .getAbbrev(), reconstClass.getAbbrev());
158
159 }
160
161 /**
162 * Test the function of adding a bonus each time an associated value is chosen.

Callers

nothing calls this directly

Calls 15

getContextMethod · 0.95
getVariableContextMethod · 0.95
getActiveScopeMethod · 0.95
getFormulaForMethod · 0.95
parseLineMethod · 0.95
getReferenceContextMethod · 0.95
getConstantMethod · 0.95
getPCCTextMethod · 0.95
parseLineMethod · 0.95
getAbbrevMethod · 0.95
assertLegalVariableIDMethod · 0.65

Tested by

no test coverage detected