public void testChangeAnnotation() throws Exception {
CompilerAssert<File, File> helper = incrementalCompiler("metamodel.controller");
helper.assertCompile();
File ser = helper.getSourceOutput().getPath("juzu", "metamodel.ser");
MetaModelState unserialize = Tools.unserialize(MetaModelState.class, ser);
ModuleMetaModel mm = (ModuleMetaModel)unserialize.metaModel;
mm.getQueue().clear();
Tools.serialize(unserialize, ser);
//
JavaFile file = helper.assertJavaSource("metamodel.controller.A");
ClassOrInterfaceDeclaration a = file.assertDeclaration();
MethodDeclaration decl = (MethodDeclaration)a.getMembers().get(0);
decl.getAnnotations().get(0).setName(ASTHelper.createNameExpr(Action.class.getName()));
file.assertSave();
//
helper.assertCompile();
mm = (ModuleMetaModel)Tools.unserialize(MetaModelState.class, ser).metaModel;
//
JSON expected = json()
.set("applications", json().
list("values", json().
list("controllers", json().
set("handle", "ElementHandle.Class[fqn=metamodel.controller.A]").
list("methods", json().
set("handle", "ElementHandle.Method[fqn=metamodel.controller.A,name=index,parameterTypes[]]").
set("id", null).
set("name", "index").
list("parameters").
set("phase", "ACTION")
)
).
set("handle", "ElementHandle.Package[qn=metamodel.controller]").
list("templates")
)
);
assertEquals(expected, mm.toJSON());
//
List<MetaModelEvent> events = mm.getQueue().clear();
assertEquals(5, events.size());
assertEquals(MetaModelEvent.BEFORE_REMOVE, events.get(0).getType());
assertInstanceOf(HandlerMetaModel.class, events.get(0).getObject());
assertEquals(MetaModelEvent.BEFORE_REMOVE, events.get(1).getType());
assertInstanceOf(ControllerMetaModel.class, events.get(1).getObject());