*/
public void testSingleAdd()
{
setUpRoleUnresolveds();
RoleUnresolvedList list = new RoleUnresolvedList();
list.add(roleUnresolved1);
list.add(roleUnresolved2);
// Add one
list.add(1, roleUnresolved1);
assertEquals(3, list.size());
assertEquals(roleUnresolved1.toString(), list.get(0).toString());
assertEquals(roleUnresolved1.toString(), list.get(1).toString());
assertEquals(roleUnresolved2.toString(), list.get(2).toString());
Iterator iterator = list.iterator();
assertEquals(roleUnresolved1.toString(), iterator.next().toString());
assertEquals(roleUnresolved1.toString(), iterator.next().toString());
assertEquals(roleUnresolved2.toString(), iterator.next().toString());
// Add a roleUnresolved in the wrong place
boolean caught = false;
try
{
list.add(4, roleUnresolved1);
}
catch (IndexOutOfBoundsException e)
{
caught = true;
}
if (caught == false)
fail ("Shouldn't be able to add a roleUnresolved outside of valid range");
// Add a null should not work
caught = false;
try
{
list.add(1, null);
}
catch (IllegalArgumentException e)
{
caught = true;
}