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
()
| 406 | * @throws PersistenceLayerException the persistence layer exception |
| 407 | */ |
| 408 | @Test |
| 409 | void testGetPCCText() throws PersistenceLayerException |
| 410 | { |
| 411 | FactKey.getConstant("Abb", new StringManager()); |
| 412 | // Test a basic class |
| 413 | String classPCCText = humanoidClass.getPCCText(); |
| 414 | assertNotNull(classPCCText, "PCC Text for race should not be null"); |
| 415 | |
| 416 | CampaignSourceEntry source; |
| 417 | try |
| 418 | { |
| 419 | source = new CampaignSourceEntry(new Campaign(), |
| 420 | new URI("file:/" + getClass().getName() + ".java")); |
| 421 | } |
| 422 | catch (URISyntaxException e) |
| 423 | { |
| 424 | throw new UnreachableError(e); |
| 425 | } |
| 426 | PCClass reconstClass; |
| 427 | System.out.println("Got text: " + classPCCText); |
| 428 | reconstClass = parsePCClassText(classPCCText, source); |
| 429 | assertEquals( |
| 430 | classPCCText, reconstClass.getPCCText(), |
| 431 | "getPCCText should be the same after being encoded and reloaded"); |
| 432 | assertEquals( |
| 433 | humanoidClass.getAbbrev(), reconstClass.getAbbrev(), |
| 434 | "Class abbrev was not restored after saving and reloading."); |
| 435 | |
| 436 | // Test a class with some innate spells |
| 437 | String b = |
| 438 | "1" |
| 439 | + "\t" |
| 440 | + "SPELLS:" |
| 441 | + "Humanoid|TIMES=1|CASTERLEVEL=var(\"TCL\")|Create undead,11+WIS"; |
| 442 | PCClassLoader classLoader = new PCClassLoader(); |
| 443 | classLoader.parseLine(Globals.getContext(), humanoidClass, b, source); |
| 444 | classPCCText = humanoidClass.getPCCText(); |
| 445 | assertNotNull(classPCCText, "PCC Text for race should not be null"); |
| 446 | |
| 447 | System.out.println("Got text: " + classPCCText); |
| 448 | reconstClass = parsePCClassText(classPCCText, source); |
| 449 | assertEquals( |
| 450 | classPCCText, reconstClass.getPCCText(), |
| 451 | "getPCCText should be the same after being encoded and reloaded"); |
| 452 | assertEquals( |
| 453 | humanoidClass.getAbbrev(), reconstClass.getAbbrev(), |
| 454 | "Class abbrev was not restored after saving and reloading."); |
| 455 | Collection<CDOMReference<Spell>> startSpells = |
| 456 | humanoidClass.getOriginalClassLevel(1).getListMods(Spell.SPELLS); |
| 457 | Collection<CDOMReference<Spell>> reconstSpells = |
| 458 | reconstClass.getOriginalClassLevel(1).getListMods(Spell.SPELLS); |
| 459 | assertEquals(startSpells.size(), reconstSpells.size(), |
| 460 | "All spell should have been reconstituted."); |
| 461 | assertEquals(startSpells, reconstSpells, "Spell names should been preserved."); |
| 462 | |
| 463 | } |
| 464 | |
| 465 | /** |
nothing calls this directly
no test coverage detected