ImmutableRowData implements RowData { public FieldData getFieldBy(final String fieldName) { if (!containsField(fieldName)) { throw new NoSuchDaleqFieldException("fieldName"); } return this.index.get(fieldName); } ImmutableRowData(final List<FieldData> fields); FieldData getFieldBy(final String fieldName); @Override boolean containsField(final String fieldName); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString();  }
@Test public void getFieldByName_should_getAnExistingField() { final String fieldName = "A"; final FieldData existingField = field(fieldName, "foo"); final ImmutableRowData row = new ImmutableRowData(fields(existingField)); assertThat(row.getFieldBy(fieldName), is(existingField)); }
@Test(expected = NoSuchDaleqFieldException.class) public void getFieldByName_should_throwForNonExistingField() { final String fieldName = "A"; final FieldData existingField = field(fieldName, "foo"); final ImmutableRowData row = new ImmutableRowData(fields(existingField)); final FieldData result = row.getFieldBy("B"); assertThat(result, is(nullValue())); }