MapperService mapperService = mock(MapperService.class);
FieldMapper fieldMapper = mock(FieldMapper.class);
when(fieldMapper.names()).thenReturn(fieldName());
when(fieldMapper.fieldDataType()).thenReturn(fieldType());
when(mapperService.smartNameFieldMapper(anyString(), Matchers.<String[]>any())).thenReturn(fieldMapper);
IndexFieldData<?> fieldData = ifd.getForField(fieldMapper);
writer = new IndexWriter(new RAMDirectory(),
new IndexWriterConfig(Lucene.VERSION, new StandardAnalyzer(Lucene.VERSION))