fields.set(indexOfField, new Field(field.getId(), newName, field.getValue()));
}
+ public void setField(Field field, String newValue) {
+ int indexOfField = getFieldIndex(field);
+ if (indexOfField == -1) {
+ return;
+ }
+ fields.get(indexOfField).setValue(newValue);
+ }
+
/**
* Moves the given field up one position in the field list. The index of the
* field to move must be greater than {@code 0} (because you obviously can
assertThat(testField.getId(), is(renamedField.getId()));
}
+ @Test
+ public void testChangingTheValueOfAField() {
+ profile.addField("TestField");
+ Field testField = profile.getFieldByName("TestField");
+ profile.setField(testField, "Test");
+ testField = profile.getFieldByName("TestField");
+ assertThat(testField.getValue(), is("Test"));
+ }
+
}