package org.elasticsearch.mapping;

import java.beans.IntrospectionException;
import java.io.IOException;

import junit.framework.Assert;

import org.elasticsearch.mapping.model.Person;
import org.junit.Test;

import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonMappingException;

/**
 * Test the mappings.
 * 
 * @author luc boutier
 */
public class MappingBuilderTest {

    @Test
    public void testSimpleClassMapping() throws IntrospectionException, JsonGenerationException, JsonMappingException,
            IOException {
        MappingBuilder mappingBuilder = new MappingBuilder();
        mappingBuilder.initialize("org.elasticsearch.mapping.model");
        String personMapping = mappingBuilder.getMapping(Person.class);
        Assert.assertEquals(
                "{\"person\":{\"_type\":{\"index\":\"not_analyzed\",\"store\":false},\"_id\":{\"index\":\"no\",\"store\":false,\"path\":\"id\"},\"_source\":{\"enabled\":true},\"properties\":{\"lastname\":{\"include_in_all\":true,\"index\":\"analyzed\",\"store\":false,\"boost\":1.0,\"term_vector\":\"no\",\"type\":\"string\"},\"firstname\":{\"include_in_all\":false,\"index\":\"no\",\"store\":false,\"boost\":1.0,\"term_vector\":\"no\",\"type\":\"string\"}},\"_all\":{\"enabled\":true}}}",
                personMapping);
    }
}
@@ -996,16 +996,203 @@
 es%5C%22:%7B%5C%22
+address%5C%22:%7B%5C%22properties%5C%22:%7B%5C%22city%5C%22:%7B%5C%22include_in_all%5C%22:false,%5C%22index%5C%22:%5C%22not_analyzed%5C%22,%5C%22store%5C%22:false,%5C%22boost%5C%22:1.0,%5C%22term_vector%5C%22:%5C%22no%5C%22,%5C%22type%5C%22:%5C%22string%5C%22%7D%7D,%5C%22type%5C%22:%5C%22nested%5C%22%7D,%5C%22
 lastname

Fix test as we now have the address mapping (nested type)