use of plugin.pretokens.parser.PreAbilityParser in project pcgen by PCGen.
the class PreAbilityParserTest method testSingleEntry.
/**
* @throws Exception
*/
@Test
public void testSingleEntry() throws Exception {
PreAbilityParser parser = new PreAbilityParser();
Prerequisite prereq = parser.parse("ability", "1,Sneak Attack", false, false);
assertEquals("Category not specified for single key", "<prereq kind=\"ability\" key=\"Sneak Attack\" operator=\"GTEQ\" operand=\"1\" >\n" + "</prereq>\n" + "", prereq.toString());
}
use of plugin.pretokens.parser.PreAbilityParser in project pcgen by PCGen.
the class PreAbilityParserTest method testInvalidCharacter.
/**
* Test that an error is produced if separators are incorrect
* @throws Exception
*/
@Test
public void testInvalidCharacter() throws Exception {
try {
PreAbilityParser parser = new PreAbilityParser();
Prerequisite prereq = parser.parse("ability", "1,CATEGORY.Mutation,KEY_a|Key_b", false, false);
fail("Should have thrown a PersistenceLayerException.");
} catch (PersistenceLayerException e) {
// Ignore, this is the expected result.
}
}
use of plugin.pretokens.parser.PreAbilityParser in project pcgen by PCGen.
the class PreAbilityParserTest method testInvalidSeparators.
/**
* Test that an error is produced if separators are incorrect
* @throws Exception
*/
@Test
public void testInvalidSeparators() throws Exception {
try {
PreAbilityParser parser = new PreAbilityParser();
Prerequisite prereq = parser.parse("ability", "1,CATEGORY.Mutation,,KEY_a", false, false);
fail("Should have thrown a PersistenceLayerException.");
} catch (PersistenceLayerException e) {
// Ignore, this is the expected result.
}
}
use of plugin.pretokens.parser.PreAbilityParser in project pcgen by PCGen.
the class PreAbilityParserTest method testNoKey.
/**
* @throws Exception
*/
@Test
public void testNoKey() throws Exception {
PreAbilityParser parser = new PreAbilityParser();
Prerequisite prereq = parser.parse("ability", "1,CATEGORY.Mutation", false, false);
assertEquals("Category specified for no key", "<prereq kind=\"ability\" category=\"Mutation\" key=\"ANY\" operator=\"GTEQ\" operand=\"1\" >\n" + "</prereq>\n" + "", prereq.toString());
}
use of plugin.pretokens.parser.PreAbilityParser in project pcgen by PCGen.
the class PreAbilityTest method testAnyMatch.
/**
* Test the function of the ANY key
* @throws PersistenceLayerException
*/
public void testAnyMatch() throws PersistenceLayerException {
Ability ab2 = TestHelper.makeAbility("Dancer", "BARDIC", "General.Bardic");
ab2.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.FALSE);
PlayerCharacter character = getCharacter();
PreAbilityParser parser = new PreAbilityParser();
Prerequisite prereq = parser.parse("ability", "1,CATEGORY.BARDIC,ANY", false, false);
assertFalse("Test any match with no abilities.", PrereqHandler.passes(prereq, character, null));
addAbility(TestHelper.getAbilityCategory(ab2), ab2);
assertTrue("Test any match with an ability.", PrereqHandler.passes(prereq, character, null));
}
Aggregations