@Test
@Issue("JENKINS-44864")
public void given_model_when_fieldRenamed_then_uselessSettersIgnored() throws Exception {

    EvolvedClass instance;
    Map<String,Object> expected = new HashMap<String, Object>();
    instance = new EvolvedClass(false);
    expected.clear();
    expected.put("option", Boolean.FALSE);
    assertThat("Only required properties",
            DescribableModel.uninstantiate2_(instance).toMap(), Matchers.is(expected));
    instance = new EvolvedClass(true);
    expected.clear();
    expected.put("option", Boolean.TRUE);
    assertThat("Only required properties",
            DescribableModel.uninstantiate2_(instance).toMap(), Matchers.is(expected));
    instance = new EvolvedClass(true);
    instance.setName("bob");
    expected.clear();
    expected.put("option", Boolean.TRUE);
    expected.put("name", "bob");
    assertThat("current setters are rendered",
            DescribableModel.uninstantiate2_(instance).toMap(), Matchers.is(expected));
    instance = new EvolvedClass(false);
    instance.setTitle("bill");
    expected.clear();
    expected.put("option", Boolean.FALSE);
    expected.put("name", "bill");
    assertThat("migrated setters are migrated",
            DescribableModel.uninstantiate2_(instance).toMap(), Matchers.is(expected));
    instance = new EvolvedClass(false);
    instance.setName("random");
    instance.setDescription("This is the thing");
    expected.clear();
    expected.put("option", Boolean.FALSE);
    expected.put("name", "random");
    expected.put("description", "This is the thing");
    assertThat("if the old setter mangles the value but has 1:1 mapping, we still ignore redundant setters",
            DescribableModel.uninstantiate2_(instance).toMap(), Matchers.is(expected));
    instance = new EvolvedClass(false);
    instance.setName("random");
    instance.setSummary("Legacy summary");
    expected.clear();
    expected.put("option", Boolean.FALSE);
    expected.put("name", "random");
    expected.put("description", "Prefix: Legacy summary");
    assertThat("Doesn't matter if we set the value through the old setter or the new",
            DescribableModel.uninstantiate2_(instance).toMap(), Matchers.is(expected));
    instance = new EvolvedClass(false);
    instance.setLegacyMode(53);
    expected.clear();
    expected.put("option", Boolean.FALSE);
    expected.put("legacyMode", 53);
    assertThat("A deprecated setter that produces a different object instance is retained",
            DescribableModel.uninstantiate2_(instance).toMap(), Matchers.is(expected));
}