Tools.serialize(unserialize, ser);
//
assertEquals(2, events.size());
assertEquals(MetaModelEvent.AFTER_ADD, events.get(1).getType());
TemplateMetaModel indexTemplate = (TemplateMetaModel)events.get(1).getObject();
assertEquals(Path.parse("/metamodel/template/templates/index.gtmpl"), indexTemplate.getPath());
Collection<ElementMetaModel> indexRefs = indexTemplate.getElementReferences();
assertEquals(1, indexRefs.size());
assertEquals(templateField, indexRefs.iterator().next().getElement());
// Create an inclusion
File foo = new File(templates, "foo.gtmpl");
assertTrue(foo.createNewFile());
Tools.safeClose(Tools.copy(new StringReader("#{include path=foo.gtmpl}#{/include}"), new FileWriter(index)));
assertTrue(index.setLastModified(index.lastModified() + 1000));
// Compile
helper.assertCompile();
unserialize = Tools.unserialize(MetaModelState.class, ser);
mm = (ModuleMetaModel)unserialize.metaModel;
events = mm.getQueue().clear();
Tools.serialize(unserialize, ser);
//
assertEquals(1, events.size());
assertEquals(MetaModelEvent.AFTER_ADD, events.get(0).getType());
TemplateMetaModel fooTemplate = (TemplateMetaModel)events.get(0).getObject();
assertEquals(Path.parse("/metamodel/template/templates/foo.gtmpl"), fooTemplate.getPath());
Collection<ElementMetaModel> fooRefs = fooTemplate.getElementReferences();
assertEquals(1, fooRefs.size());
assertEquals(templateField, fooRefs.iterator().next().getElement());
// Create an neted inclusion
File bar = new File(templates, "bar.gtmpl");
assertTrue(bar.createNewFile());
Tools.safeClose(Tools.copy(new StringReader("#{include path=bar.gtmpl}#{/include}"), new FileWriter(foo)));
assertTrue(foo.setLastModified(index.lastModified() + 1000));
// Compile
helper.assertCompile();
unserialize = Tools.unserialize(MetaModelState.class, ser);
mm = (ModuleMetaModel)unserialize.metaModel;
events = mm.getQueue().clear();
//
assertEquals(1, events.size());
assertEquals(MetaModelEvent.AFTER_ADD, events.get(0).getType());
TemplateMetaModel barTemplate = (TemplateMetaModel)events.get(0).getObject();
assertEquals(Path.parse("/metamodel/template/templates/bar.gtmpl"), barTemplate.getPath());
Collection<ElementMetaModel> barRefs = fooTemplate.getElementReferences();
assertEquals(1, barRefs.size());
assertEquals(templateField, barRefs.iterator().next().getElement());
}