Search in sources :

Example 6 with PrerequisiteWriterInterface

use of pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface in project pcgen by PCGen.

the class PreAbilityRoundRobin method testCombineSubNegativeSub.

@Override
public void testCombineSubNegativeSub() {
    String original = "!PREMULT:2,[!PRE" + getBaseString() + ":1," + getPrefix() + "Foo (Bar)],[!PRE" + getBaseString() + ":1," + getPrefix() + "Spot (Check)]";
    String consolidatedPre = "PRE" + getBaseString() + ":1," + getPrefix() + "Foo (Bar),Spot (Check)";
    try {
        Prerequisite p = PreParserFactory.getInstance().parse(original);
        PrerequisiteWriterInterface writer = PrerequisiteWriterFactory.getInstance().getWriter(p.getKind());
        if (writer == null) {
            fail("Could not find Writer for: " + p.getKind());
        }
        StringWriter w = new StringWriter();
        writer.write(w, p);
        boolean consolidated = w.toString().equals(consolidatedPre);
        boolean separate = w.toString().equals(original);
        assertTrue(consolidated || separate);
    } catch (PersistenceLayerException e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : PersistenceLayerException(pcgen.persistence.PersistenceLayerException) StringWriter(java.io.StringWriter) PrerequisiteWriterInterface(pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 7 with PrerequisiteWriterInterface

use of pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface in project pcgen by PCGen.

the class PreAbilityRoundRobin method testCombineSubAnyCategory.

public void testCombineSubAnyCategory() {
    // runSimpleRoundRobin("PREMULT:2,[!PRE" + getBaseString() + ":1,"
    // + getAnyPrefix() + "Foo],[!PRE" + getBaseString() + ":1,"
    // + getAnyPrefix() + "Spot]", "!PRE" + getBaseString() + ":1,"
    // + getAnyPrefix() + "Foo,Spot");
    String original = "PREMULT:2,[!PRE" + getBaseString() + ":1," + getAnyPrefix() + "Foo],[!PRE" + getBaseString() + ":1," + getAnyPrefix() + "Spot]";
    String consolidatedPre = "!PRE" + getBaseString() + ":1," + getAnyPrefix() + "Foo,Spot";
    try {
        Prerequisite p = PreParserFactory.getInstance().parse(original);
        PrerequisiteWriterInterface writer = PrerequisiteWriterFactory.getInstance().getWriter(p.getKind());
        if (writer == null) {
            fail("Could not find Writer for: " + p.getKind());
        }
        StringWriter w = new StringWriter();
        writer.write(w, p);
        boolean consolidated = w.toString().equals(consolidatedPre);
        boolean separate = w.toString().equals(original);
        assertTrue(consolidated || separate);
    } catch (PersistenceLayerException e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : PersistenceLayerException(pcgen.persistence.PersistenceLayerException) StringWriter(java.io.StringWriter) PrerequisiteWriterInterface(pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 8 with PrerequisiteWriterInterface

use of pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface in project pcgen by PCGen.

the class PreAbilityRoundRobin method testCombineSubNegativeCheckMult.

public void testCombineSubNegativeCheckMult() {
    // runSimpleRoundRobin("!PREMULT:2,[!PRE" + getBaseString() + ":1,"
    // + "CHECKMULT," + getPrefix() + "Foo],[!PRE" + getBaseString()
    // + ":1," + "CHECKMULT," + getPrefix() + "Spot]", "PRE"
    // + getBaseString() + ":1," + "CHECKMULT," + getPrefix()
    // + "Foo,Spot");
    String original = "!PREMULT:2,[!PRE" + getBaseString() + ":1," + "CHECKMULT," + getPrefix() + "Foo],[!PRE" + getBaseString() + ":1," + "CHECKMULT," + getPrefix() + "Spot]";
    String consolidatedPre = "PRE" + getBaseString() + ":1," + "CHECKMULT," + getPrefix() + "Foo,Spot";
    try {
        Prerequisite p = PreParserFactory.getInstance().parse(original);
        PrerequisiteWriterInterface writer = PrerequisiteWriterFactory.getInstance().getWriter(p.getKind());
        if (writer == null) {
            fail("Could not find Writer for: " + p.getKind());
        }
        StringWriter w = new StringWriter();
        writer.write(w, p);
        boolean consolidated = w.toString().equals(consolidatedPre);
        boolean separate = w.toString().equals(original);
        assertTrue(consolidated || separate);
    } catch (PersistenceLayerException e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : PersistenceLayerException(pcgen.persistence.PersistenceLayerException) StringWriter(java.io.StringWriter) PrerequisiteWriterInterface(pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 9 with PrerequisiteWriterInterface

use of pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface in project pcgen by PCGen.

the class PreAbilityRoundRobin method testCombineSub.

@Override
public void testCombineSub() {
    String original = "PREMULT:2,[!PRE" + getBaseString() + ":1," + getPrefix() + "Foo],[!PRE" + getBaseString() + ":1," + getPrefix() + "Spot]";
    String consolidatedPre = "!PRE" + getBaseString() + ":1," + getPrefix() + "Foo,Spot";
    try {
        Prerequisite p = PreParserFactory.getInstance().parse(original);
        PrerequisiteWriterInterface writer = PrerequisiteWriterFactory.getInstance().getWriter(p.getKind());
        if (writer == null) {
            fail("Could not find Writer for: " + p.getKind());
        }
        StringWriter w = new StringWriter();
        writer.write(w, p);
        boolean consolidated = w.toString().equals(consolidatedPre);
        boolean separate = w.toString().equals(original);
        assertTrue(consolidated || separate);
    } catch (PersistenceLayerException e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : PersistenceLayerException(pcgen.persistence.PersistenceLayerException) StringWriter(java.io.StringWriter) PrerequisiteWriterInterface(pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 10 with PrerequisiteWriterInterface

use of pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface in project pcgen by PCGen.

the class PreAbilityRoundRobin method testCombineSubNegativeAnyCategory.

public void testCombineSubNegativeAnyCategory() {
    // runSimpleRoundRobin("!PREMULT:2,[!PRE" + getBaseString() + ":1,"
    // + getAnyPrefix() + "Foo],[!PRE" + getBaseString() + ":1,"
    // + getAnyPrefix() + "Spot]", "PRE" + getBaseString() + ":1,"
    // + getAnyPrefix() + "Foo,Spot");
    String original = "!PREMULT:2,[!PRE" + getBaseString() + ":1," + getAnyPrefix() + "Foo],[!PRE" + getBaseString() + ":1," + getAnyPrefix() + "Spot]";
    String consolidatedPre = "PRE" + getBaseString() + ":1," + getAnyPrefix() + "Foo,Spot";
    try {
        Prerequisite p = PreParserFactory.getInstance().parse(original);
        PrerequisiteWriterInterface writer = PrerequisiteWriterFactory.getInstance().getWriter(p.getKind());
        if (writer == null) {
            fail("Could not find Writer for: " + p.getKind());
        }
        StringWriter w = new StringWriter();
        writer.write(w, p);
        boolean consolidated = w.toString().equals(consolidatedPre);
        boolean separate = w.toString().equals(original);
        assertTrue(consolidated || separate);
    } catch (PersistenceLayerException e) {
        fail(e.getLocalizedMessage());
    }
}
Also used : PersistenceLayerException(pcgen.persistence.PersistenceLayerException) StringWriter(java.io.StringWriter) PrerequisiteWriterInterface(pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface) Prerequisite(pcgen.core.prereq.Prerequisite)

Aggregations

StringWriter (java.io.StringWriter)10 Prerequisite (pcgen.core.prereq.Prerequisite)10 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)10 PrerequisiteWriterInterface (pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface)10 TreeSet (java.util.TreeSet)1 CDOMObject (pcgen.cdom.base.CDOMObject)1 ObjectCache (pcgen.cdom.inst.ObjectCache)1 EditorLoadContext (pcgen.rules.context.EditorLoadContext)1 LoadContext (pcgen.rules.context.LoadContext)1