* }
*
* @see #testSetCollection()
*/
public void testSetInAppendMode() {
final DefaultCitation instance = new DefaultCitation();
final List<InternationalString> oldTitles = Arrays.<InternationalString>asList(
new SimpleInternationalString("Old title 1"),
new SimpleInternationalString("Old title 2"));
final List<InternationalString> newTitles = Arrays.<InternationalString>asList(
new SimpleInternationalString("New title 1"),
new SimpleInternationalString("New title 2"));
final List<InternationalString> merged = new ArrayList<InternationalString>(oldTitles);
assertTrue(merged.addAll(newTitles));
// Set the title.
instance.setAlternateTitles(oldTitles);
final PropertyAccessor accessor = createPropertyAccessor();
final int titleIndex = accessor.indexOf("title", true);
Object titleChanged = accessor.set(titleIndex, instance, "Added title", APPEND);
// Set the alternate titles.
final int index = accessor.indexOf("alternateTitles", true);
final Object changed = accessor.set(index, instance, newTitles, APPEND);
final Object newValue = accessor.get(index, instance);
// Verify the values.
assertEquals("set(…, APPEND)", Boolean.TRUE, titleChanged);
assertEquals("set(…, APPEND)", Boolean.TRUE, changed);
assertEquals("get(…)", merged, newValue);
assertSame ("alternateTitles", newValue, instance.getAlternateTitles());
assertEquals("title", "Added title", instance.getTitle().toString());
// Test setting again the title to the same value.
titleChanged = accessor.set(titleIndex, instance, "Added title", APPEND);
assertEquals("set(…, APPEND)", Boolean.FALSE, titleChanged);
assertEquals("title", "Added title", instance.getTitle().toString());
// Test setting the title to a different value.
titleChanged = accessor.set(titleIndex, instance, "Different title", APPEND);
assertNull("set(…, APPEND)", titleChanged); // Operation shall be refused.
assertEquals("title", "Added title", instance.getTitle().toString());
}