{
Map<String, Person> map = new HashMap<String, Person>();
map.put("0", new Person("Gavin"));
map.put("1", new Person("Tom"));
javax.faces.model.DataModel mapDataModel = new MapDataModel();
assert mapDataModel.getRowCount() == -1;
assert mapDataModel.getRowData() == null;
assert !mapDataModel.isRowAvailable();
mapDataModel = new MapDataModel(map);
assert mapDataModel.getWrappedData() instanceof Map;
assert map.get("0").equals(((Map) mapDataModel.getWrappedData()).get("0"));
assert map.get("1").equals(((Map) mapDataModel.getWrappedData()).get("1"));
mapDataModel.setRowIndex(10);
assert !mapDataModel.isRowAvailable();
boolean failed = false;
try
{
mapDataModel.getRowData();
}
catch (IllegalArgumentException e)
{
failed = true;
}
assert failed;
mapDataModel.setRowIndex(1);
assert mapDataModel.isRowAvailable();
assert mapDataModel.getRowIndex() == 1;
assert mapDataModel.getRowCount() == 2;
// JBSEAM-1660
try
{
mapDataModel.setWrappedData(null);
}
catch (NullPointerException e)
{
// Spec allows passing null
assert false;