public void testAddJsonRootElement()
{
EnunciateFreemarkerModel model = new EnunciateFreemarkerModel();
FreemarkerModel.set(model);
final JsonTypeDefinition nameTypeDefinition = JsonTypeDefinition.createTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.json.Name"));
final JsonRootElementDeclaration rootElementDeclaration = new JsonRootElementDeclaration(nameTypeDefinition);
assertNull(model.findJsonRootElementDeclaration(rootElementDeclaration));
model.addJsonRootElement(rootElementDeclaration);
assertNotNull(model.findJsonRootElementDeclaration(rootElementDeclaration));
assertNotNull(model.findJsonTypeDefinition(nameTypeDefinition));
JsonSchemaInfo jsonSchemaInfo = model.getIdsToJsonSchemas().get(JsonSchemaInfo.schemaIdForType(nameTypeDefinition));
assertNotNull(jsonSchemaInfo);
assertNotNull(jsonSchemaInfo.getTypesByName().get(nameTypeDefinition.getTypeName()));
assertNotNull(jsonSchemaInfo.getTopLevelTypesByName().get(nameTypeDefinition.getTypeName()));
}