}
private void testRefactoring( final ElementList<TestElement.Item> list, final ReferenceValue<String,TestElement.Item> reference )
{
final String referenceLabel = reference.definition().getLabel( true, CapitalizationType.NO_CAPS, false );
final PossibleValuesService possibleValuesService = reference.service( PossibleValuesService.class );
final TestElement.Item a = list.insert();
a.setName( "a" );
final TestElement.Item b = list.insert();
b.setName( "b" );
final TestElement.Item c = list.insert();
c.setName( "c" );
final TestElement.Item d = list.insert();
d.setName( "d" );
reference.write( "d" );
assertValidationOk( reference );
d.getName().write( "dd", true );
assertEquals( set( "a", "b", "c", "dd" ), possibleValuesService.values() );
assertEquals( "dd", reference.content() );
assertValidationOk( reference );
d.getName().write( "ddd", false );
assertEquals( set( "a", "b", "c", "ddd" ), possibleValuesService.values() );
assertEquals( "dd", reference.content() );
assertValidationError( reference, "Could not resolve " + referenceLabel + " \"dd\"" );
reference.write( "ddd" );
assertValidationOk( reference );
d.getName().write( "dddd", true );
assertEquals( set( "a", "b", "c", "dddd" ), possibleValuesService.values() );
assertEquals( "dddd", reference.content() );
assertValidationOk( reference );
d.getName().write( "ddddd" );
assertEquals( set( "a", "b", "c", "ddddd" ), possibleValuesService.values() );
assertEquals( "dddd", reference.content() );
assertValidationError( reference, "Could not resolve " + referenceLabel + " \"dddd\"" );
}