@Test
public void enhanceGamma()
        throws Exception {

    CtClass gamma = pool.get(TestClassGamma.class.getName());
    CtClass dirtyInterface = pool.get(Persistent.class.getName());
    CtClass enhanced = pool.makeClass(makeNewName());
    enhanced.setSuperclass(gamma);
    enhanced.addInterface(dirtyInterface);
    CtMethod isDirtyMethod = CtNewMethod.make("public boolean isDirty() { return getFoo() != null || getBars() != null; }", enhanced);
    enhanced.addMethod(isDirtyMethod);
    Class<TestClassGamma> cls = ClassLoadingUtil.toClass(enhanced);
    TestClassGamma instance = cls.newInstance();
    assertNotNull(instance);
    assertNull(instance.getBars());
    assertNull(instance.getFoo());
    assertDirty(instance, false);
    instance.setFoo(toString());
    instance.setBars(Collections.singletonList("bar"));
    assertDirty(instance, true);
    assertEquals(toString(), instance.getFoo());
    assertEquals(Collections.singletonList("bar"), instance.getBars());
    instance.setFoo(null);
    instance.setBars(null);
    assertNull(instance.getBars());
    assertNull(instance.getFoo());
    assertDirty(instance, false);
}