MimicCreator { public void mimicClass(CtClass src, CtClass dst, MimicMode defaultMimicMode, MimicMethod[] mimicMethods) throws NotFoundException, CannotCompileException, MimicException { mimicInterfaces(src, dst); mimicFields(src, dst); mimicConstructors(src, dst); mimicMethods(src, dst, defaultMimicMode, mimicMethods); } MimicCreator();  MimicCreator(String key); boolean hasField(CtClass clazz, CtField field); boolean hasInterface(CtClass dst, CtClass interfazz); void mimicClass(CtClass src, CtClass dst, MimicMode defaultMimicMode, MimicMethod[] mimicMethods); void mimicConstructors(CtClass src, CtClass dst); void mimicFields(CtClass src, CtClass dst); void mimicInterfaces(CtClass src, CtClass dst); void mimicMethods(CtClass src, CtClass dst, MimicMode defaultMimicMode, MimicMethod[] mimicMethods);  }
@Test public void testMimicClass() throws Exception { CtClass interfazz = ClassPool.getDefault().makeInterface("Able" + TestCounter.testCounter); src.addInterface(interfazz); Class<?> interfaceClass = ClassPool.getDefault().toClass(interfazz); src.addField(new CtField(CtClass.intType, "foo", src)); src.addConstructor(CtNewConstructor.make("public Src() { foo = 2; }", src)); src.addMethod(CtNewMethod.make("public boolean foo() { return true;}", src)); mimicCreator.mimicClass(src, dst, MimicMode.AFTER_SUPER, new MimicMethod[0]); Class<?> dstClass = dst.toClass(); assertHasInterface(interfaceClass, dstClass); assertHasFooFieldAndConstructor(dstClass); assertHasFooMethod(dst, dstClass); }