use of pcgen.cdom.format.table.DataTable 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());
}
}
use of pcgen.cdom.format.table.DataTable 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());
}
}
use of pcgen.cdom.format.table.DataTable in project pcgen by PCGen.
the class LookupFunctionTest method testInvalidBadSemantics2.
@Test
public void testInvalidBadSemantics2() {
Finder finder = new Finder();
DataTable dt = doTableSetup();
finder.map.put(DataTable.class, "A", dt);
finder.map.put(TableColumn.class, "Value", buildColumn("Value", numberManager));
finder.map.put(TableColumn.class, "Result", buildColumn("Result", stringManager));
VariableLibrary vl = getVariableLibrary();
WriteableVariableStore vs = getVariableStore();
TableFormatFactory fac = new TableFormatFactory(finder);
FormatManager<?> tableMgr = fac.build("STRING,NUMBER", formatLibrary);
vl.assertLegalVariableID("TableA", getGlobalScope(), tableMgr);
VariableID tableID = vl.getVariableID(getGlobalScopeInst(), "TableA");
vs.put(tableID, tableMgr.convert("A"));
ColumnFormatFactory cfac = new ColumnFormatFactory(finder);
FormatManager<?> columnMgr = cfac.build("STRING", formatLibrary);
vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr);
VariableID columnID = vl.getVariableID(getGlobalScopeInst(), "ResultColumn");
vs.put(columnID, columnMgr.convert("Value"));
String formula = "lookup(TableA,badf(),ResultColumn)";
SimpleNode node = TestUtilities.doParse(formula);
isNotValid(formula, node, numberManager, null);
}
Aggregations