use of pcgen.persistence.PersistenceLayerException in project pcgen by PCGen.
the class PreVarTest method test2857849and2862276.
public void test2857849and2862276() {
LoadContext context = Globals.getContext();
final PCClass spellcaster = new PCClass();
spellcaster.setName("Spellcaster");
context.getReferenceContext().importObject(spellcaster);
context.unconditionallyProcess(spellcaster, "SPELLTYPE", "Arcane");
context.unconditionallyProcess(spellcaster, "SPELLSTAT", "INT");
context.unconditionallyProcess(spellcaster, "PREVARGTEQ", "BASESPELLSTAT,2");
PCClassLoader loader = new PCClassLoader();
try {
SourceEntry se = new CampaignSourceEntry(new Campaign(), new URI("file://test"));
loader.completeObject(context, se, spellcaster);
context.getReferenceContext().resolveReferences(null);
PlayerCharacter character = this.getCharacter();
setPCStat(character, intel, 16);
assertTrue(spellcaster.qualifies(character, spellcaster));
} catch (URISyntaxException | PersistenceLayerException e) {
fail(e.getMessage());
}
}
use of pcgen.persistence.PersistenceLayerException in project pcgen by PCGen.
the class PreVarTest method test2857849a.
public void test2857849a() {
final PCClass warrior = new PCClass();
warrior.setName("Warrior");
LoadContext context = Globals.getContext();
context.unconditionallyProcess(warrior, "DEFINE", "MyVar|0");
context.unconditionallyProcess(warrior, "BONUS", "VAR|MyVar|2");
PCClassLoader loader = new PCClassLoader();
try {
SourceEntry se = new CampaignSourceEntry(new Campaign(), new URI("file://test"));
final PCClass notawarrior = loader.parseLine(context, null, "CLASS:NotAWarrior\tPREVARGTEQ:MyVar,1", se);
loader.completeObject(context, se, warrior);
loader.completeObject(context, se, notawarrior);
PlayerCharacter character = this.getCharacter();
assertFalse(notawarrior.qualifies(character, notawarrior));
character.incrementClassLevel(1, warrior);
assertTrue(notawarrior.qualifies(character, notawarrior));
} catch (URISyntaxException | PersistenceLayerException e) {
fail(e.getMessage());
}
}
use of pcgen.persistence.PersistenceLayerException in project pcgen by PCGen.
the class PreVarTest method test2857848a.
public void test2857848a() {
LoadContext context = Globals.getContext();
final PCClass spellcaster = new PCClass();
spellcaster.setName("Spellcaster");
context.getReferenceContext().importObject(spellcaster);
Skill concentration = context.getReferenceContext().constructCDOMObject(Skill.class, "Concentration");
context.unconditionallyProcess(spellcaster, "SPELLTYPE", "Arcane");
context.unconditionallyProcess(spellcaster, "SPELLSTAT", "INT");
context.unconditionallyProcess(spellcaster, "CSKILL", "Concentration");
context.unconditionallyProcess(spellcaster, "BONUS", "SKILL|Concentration|5|PREVARGT:BASESPELLSTAT,2");
assertTrue(context.getReferenceContext().resolveReferences(null));
PlayerCharacter character = this.getCharacter();
setPCStat(character, intel, 16);
PCClassLoader loader = new PCClassLoader();
try {
SourceEntry se = new CampaignSourceEntry(new Campaign(), new URI("file://test"));
loader.completeObject(context, se, spellcaster);
assertEquals(0, SkillModifier.modifier(concentration, character).intValue());
character.incrementClassLevel(1, spellcaster);
assertEquals(5, SkillModifier.modifier(concentration, character).intValue());
} catch (URISyntaxException | PersistenceLayerException e) {
fail(e.getMessage());
}
}
use of pcgen.persistence.PersistenceLayerException in project pcgen by PCGen.
the class TableLoaderTest method testBasic.
//TODO Blank Data in middle of Row?
//TODO Blank Data at end of row?
@Test
public void testBasic() {
try {
loader.loadLstString(context, uri, "#Let me tell you about this table\n\n,,,\n" + "STARTTABLE:A\n\n,,,\n" + "#It's the story of a parsing test\n" + "Name,Value,\n\n,,,\n" + "\"#And testing tolerance\",For lots of things\n" + "STRING,NUMBER,,\n\n,,,\n\n" + "#Because really....\n" + "This,1\n\n" + "#Why call the comments?\n,,,\n" + "\"That\",\"2\"\n" + "\"The \"\"Other\"\"\",\"3\"\n,,,\n\n" + "ENDTABLE:A\n" + "#They seem to just take up a lot of space");
DataTable a = context.getReferenceContext().silentlyGetConstructedCDOMObject(DataTable.class, "A");
assertEquals(2, a.getColumnCount());
assertEquals(new StringManager(), a.getFormat(0));
assertEquals(new NumberManager(), a.getFormat(1));
assertEquals("This", a.get("Name", 0));
assertEquals("That", a.get("Name", 1));
assertEquals("The \"Other\"", a.get("Name", 2));
assertEquals(1, a.get("Value", 0));
assertEquals(2, a.get("Value", 1));
assertEquals(3, a.get("Value", 2));
assertEquals(2, a.lookupExact("That", "Value"));
} catch (PersistenceLayerException e) {
fail("Did not Expect Failure: " + e.getLocalizedMessage());
}
}
use of pcgen.persistence.PersistenceLayerException in project pcgen by PCGen.
the class PreClassTest method testInvalidNegate.
/**
* Test that an error is produced if separators are incorrect
* @throws Exception
*/
@Test
public void testInvalidNegate() throws Exception {
try {
PreClassParser parser = new PreClassParser();
Prerequisite prereq = parser.parse("class", "1,Monk=1[Cleric=1]", false, false);
fail("Should have thrown a PersistenceLayerException.");
} catch (PersistenceLayerException e) {
// Ignore, this is the expected result.
}
}
Aggregations