Search in sources :

Example 76 with Prerequisite

use of pcgen.core.prereq.Prerequisite 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());
}
Also used : PreAbilityParser(plugin.pretokens.parser.PreAbilityParser) Prerequisite(pcgen.core.prereq.Prerequisite) Test(org.junit.Test)

Example 77 with Prerequisite

use of pcgen.core.prereq.Prerequisite 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.
    }
}
Also used : PreAbilityParser(plugin.pretokens.parser.PreAbilityParser) PersistenceLayerException(pcgen.persistence.PersistenceLayerException) Prerequisite(pcgen.core.prereq.Prerequisite) Test(org.junit.Test)

Example 78 with Prerequisite

use of pcgen.core.prereq.Prerequisite 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.
    }
}
Also used : PreAbilityParser(plugin.pretokens.parser.PreAbilityParser) PersistenceLayerException(pcgen.persistence.PersistenceLayerException) Prerequisite(pcgen.core.prereq.Prerequisite) Test(org.junit.Test)

Example 79 with Prerequisite

use of pcgen.core.prereq.Prerequisite 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());
}
Also used : PreAbilityParser(plugin.pretokens.parser.PreAbilityParser) Prerequisite(pcgen.core.prereq.Prerequisite) Test(org.junit.Test)

Example 80 with Prerequisite

use of pcgen.core.prereq.Prerequisite in project pcgen by PCGen.

the class PreLanguageParserTest method testNot1LanguageOf2.

/**
	 * @throws Exception
	 */
@Test
public void testNot1LanguageOf2() throws Exception {
    PreLanguageParser parser = new PreLanguageParser();
    Prerequisite prereq = parser.parse("LANG", "1,Dwarven,Elven", true, false);
    System.out.println(prereq);
    assertEquals("<prereq operator=\"LT\" operand=\"1\" >\n" + "<prereq kind=\"lang\" count-multiples=\"true\" key=\"Dwarven\" operator=\"GTEQ\" operand=\"1\" >\n" + "</prereq>\n" + "<prereq kind=\"lang\" count-multiples=\"true\" key=\"Elven\" operator=\"GTEQ\" operand=\"1\" >\n" + "</prereq>\n" + "</prereq>\n", prereq.toString());
}
Also used : PreLanguageParser(plugin.pretokens.parser.PreLanguageParser) Prerequisite(pcgen.core.prereq.Prerequisite) Test(org.junit.Test)

Aggregations

Prerequisite (pcgen.core.prereq.Prerequisite)267 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)62 Test (org.junit.Test)61 PrerequisiteOperator (pcgen.core.prereq.PrerequisiteOperator)50 StringTokenizer (java.util.StringTokenizer)36 ArrayList (java.util.ArrayList)35 StringWriter (java.io.StringWriter)19 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)19 CDOMReference (pcgen.cdom.base.CDOMReference)18 ParseResult (pcgen.rules.persistence.token.ParseResult)18 BonusObj (pcgen.core.bonus.BonusObj)13 TreeSet (java.util.TreeSet)12 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)12 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)10 Domain (pcgen.core.Domain)10 QualifiedObject (pcgen.core.QualifiedObject)10 PrerequisiteWriterInterface (pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface)10 PrerequisiteWriter (pcgen.persistence.lst.output.prereq.PrerequisiteWriter)9 Ungranted (pcgen.cdom.base.Ungranted)8 PrerequisiteException (pcgen.core.prereq.PrerequisiteException)8