@Test
public void flatFieldMappingsShouldIncludeFieldsOnAllLevels() {

    IndexMappings indexMappings = LocalClusterState.state().getFieldMappings(new String[]{"field_mappings"});
    FieldMappings fieldMappings = indexMappings.firstMapping().firstMapping();
    Map<String, String> typeByFieldName = new HashMap<>();
    fieldMappings.flat(typeByFieldName::put);
    assertThat(
        typeByFieldName,
        allOf(
            aMapWithSize(13),
            hasEntry("address", "text"),
            hasEntry("age", "integer"),
            hasEntry("employer", "text"),
            hasEntry("employer.raw", "text"),
            hasEntry("employer.keyword", "keyword"),
            hasEntry("projects", "nested"),
            hasEntry("projects.active", "boolean"),
            hasEntry("projects.members", "nested"),
            hasEntry("projects.members.name", "text"),
            hasEntry("manager", "object"),
            hasEntry("manager.name", "text"),
            hasEntry("manager.name.keyword", "keyword"),
            hasEntry("manager.address", "keyword")
        )
    );
}