}
}
public void testGetNthStringList() throws Exception {
try {
NonEmptyStringList stringList1 = new NonEmptyStringList(jcas);
stringList1.setHead("2");
stringList1.setTail(new EmptyStringList(jcas));
NonEmptyStringList stringList = new NonEmptyStringList(jcas);
stringList.setHead("1");
stringList.setTail(stringList1);
EmptyStringList emptyFsList = new EmptyStringList(jcas);
try {
emptyFsList.getNthElement(0);
assertTrue(false); // error if we get here
} catch (CASRuntimeException e) {
assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_ON_EMPTY_LIST));
System.out.print("Expected Error: ");
System.out.println(e.getMessage());
}
try {
stringList.getNthElement(-1);
assertTrue(false); // error if we get here
} catch (CASRuntimeException e) {
assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_NEGATIVE_INDEX));
System.out.print("Expected Error: ");
System.out.println(e.getMessage());
}
try {
stringList.getNthElement(2);
assertTrue(false); // error if we get here
} catch (CASRuntimeException e) {
assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_PAST_END));
System.out.print("Expected Error: ");
System.out.println(e.getMessage());
}
assertTrue("1".equals(stringList.getNthElement(0)));
assertTrue("2".equals(stringList.getNthElement(1)));
} catch (Exception e) {
JUnitExtension.handleException(e);
}
}