Search in sources :

Example 1 with NumberManager

use of pcgen.base.format.NumberManager in project pcgen by PCGen.

the class FactKeyActorTest method testListKeyActorMissingSafe.

public void testListKeyActorMissingSafe() {
    NumberManager mgr = new NumberManager();
    FactKey<Number> fk = FactKey.getConstant("cost", mgr);
    FactKeyActor<?> ika = new FactKeyActor<>(fk);
    CDOMWrapperInfoFacet wiFacet = FacetLibrary.getFacet(CDOMWrapperInfoFacet.class);
    wiFacet.set(dsid, Deity.class, "cost", ika);
    processThroughFreeMarker("${deity.cost!}", "");
}
Also used : CDOMWrapperInfoFacet(pcgen.cdom.facet.CDOMWrapperInfoFacet) NumberManager(pcgen.base.format.NumberManager)

Example 2 with NumberManager

use of pcgen.base.format.NumberManager in project pcgen by PCGen.

the class FactKeyActorTest method testFactKeyActor.

public void testFactKeyActor() {
    Deity d = new Deity();
    d.setName("Bob");
    Integer expectedResult = 475;
    df.set(id, d);
    NumberManager mgr = new NumberManager();
    FactKey<Number> fk = FactKey.getConstant("cost", mgr);
    d.put(fk, new BasicIndirect<>(mgr, expectedResult));
    FactKeyActor<?> ika = new FactKeyActor<>(fk);
    CDOMWrapperInfoFacet wiFacet = FacetLibrary.getFacet(CDOMWrapperInfoFacet.class);
    wiFacet.set(dsid, d.getClass(), "cost", ika);
    processThroughFreeMarker("${deity.cost}", expectedResult.toString());
}
Also used : Deity(pcgen.core.Deity) CDOMWrapperInfoFacet(pcgen.cdom.facet.CDOMWrapperInfoFacet) NumberManager(pcgen.base.format.NumberManager)

Example 3 with NumberManager

use of pcgen.base.format.NumberManager 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());
    }
}
Also used : PersistenceLayerException(pcgen.persistence.PersistenceLayerException) DataTable(pcgen.cdom.format.table.DataTable) NumberManager(pcgen.base.format.NumberManager) StringManager(pcgen.base.format.StringManager) Test(org.junit.Test)

Example 4 with NumberManager

use of pcgen.base.format.NumberManager in project pcgen by PCGen.

the class TableLoaderTest method testIndependence.

@Test
public void testIndependence() {
    try {
        loader.loadLstString(context, uri, "STARTTABLE:A\n\n,,,\n" + "Name,Value,\n\n,,,\n" + "STRING,NUMBER,,\n\n,,,\n\n" + "This,1\n\n" + "\"That\",\"2\"\n" + "ENDTABLE:A\n" + "#What comments?\n,,,\n" + "STARTTABLE:B\n\n,,,\n" + "Name,Value,\n\n,,,\n" + "STRING,NUMBER,,\n\n,,,\n\n" + "\"The \"\"Other\"\"\",\"3\"\n,,,\n\n" + "ENDTABLE:B\n");
        DataTable a = context.getReferenceContext().silentlyGetConstructedCDOMObject(DataTable.class, "A");
        DataTable b = context.getReferenceContext().silentlyGetConstructedCDOMObject(DataTable.class, "B");
        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\"", b.get("Name", 0));
        assertEquals(1, a.get("Value", 0));
        assertEquals(2, a.get("Value", 1));
        assertEquals(3, b.get("Value", 0));
    } catch (PersistenceLayerException e) {
        fail("Did not Expect Failure: " + e.getLocalizedMessage());
    }
}
Also used : PersistenceLayerException(pcgen.persistence.PersistenceLayerException) DataTable(pcgen.cdom.format.table.DataTable) NumberManager(pcgen.base.format.NumberManager) StringManager(pcgen.base.format.StringManager) Test(org.junit.Test)

Example 5 with NumberManager

use of pcgen.base.format.NumberManager in project pcgen by PCGen.

the class TableLoaderTest method testDuplicateIndependence.

@Test
public void testDuplicateIndependence() {
    try {
        loader.loadLstString(context, uri, "STARTTABLE:A\n\n,,,\n" + "Name,Value,\n\n,,,\n" + "STRING,NUMBER,,\n\n,,,\n\n" + "This,1\n\n" + "\"That\",\"2\"\n" + "ENDTABLE:A\n" + "#What comments?\n,,,\n" + "STARTTABLE:A\n\n,,,\n" + "Name,Value,\n\n,,,\n" + "STRING,NUMBER,,\n\n,,,\n\n" + "\"The \"\"Other\"\"\",\"3\"\n,,,\n\n" + "ENDTABLE:A\n");
        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(1, a.get("Value", 0));
        assertEquals(2, a.get("Value", 1));
        context.getReferenceContext().forget(a);
        DataTable b = context.getReferenceContext().silentlyGetConstructedCDOMObject(DataTable.class, "A");
        assertEquals("The \"Other\"", b.get("Name", 0));
        assertEquals(3, b.get("Value", 0));
    } catch (PersistenceLayerException e) {
        fail("Did not Expect Failure: " + e.getLocalizedMessage());
    }
}
Also used : PersistenceLayerException(pcgen.persistence.PersistenceLayerException) DataTable(pcgen.cdom.format.table.DataTable) NumberManager(pcgen.base.format.NumberManager) StringManager(pcgen.base.format.StringManager) Test(org.junit.Test)

Aggregations

NumberManager (pcgen.base.format.NumberManager)5 Test (org.junit.Test)3 StringManager (pcgen.base.format.StringManager)3 DataTable (pcgen.cdom.format.table.DataTable)3 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)3 CDOMWrapperInfoFacet (pcgen.cdom.facet.CDOMWrapperInfoFacet)2 Deity (pcgen.core.Deity)1