ListAccessor extends ListPropertyAccessor { @Override public Object getProperty(Map context, Object target, Object value) throws OgnlException { try { return super.getProperty(context, target, value); } catch (IndexOutOfBoundsException ex) { return null; } } ListAccessor(Converters converters); @Override Object getProperty(Map context, Object target, Object value); @Override @SuppressWarnings("unchecked") void setProperty(Map context, Object target, Object key, Object value);  }
@Test public void gettingShouldReturnNullIfIndexNotFound() throws Exception { Object value = accessor.getProperty(null, instance, 1); assertThat(value, is(nullValue())); }
@Test public void gettingShouldReturnValueIfIndexFound() throws Exception { instance.add("nothing"); instance.add("guilherme"); Object value = accessor.getProperty(null, instance, 1); assertThat(value, is(Matchers.equalTo((Object) "guilherme"))); }