2727import org .elasticsearch .common .compress .CompressorFactory ;
2828import org .elasticsearch .common .io .stream .BytesStreamOutput ;
2929import org .elasticsearch .common .io .stream .StreamOutput ;
30+ import org .elasticsearch .common .settings .Settings ;
31+ import org .elasticsearch .common .xcontent .XContentBuilder ;
3032import org .elasticsearch .common .xcontent .XContentFactory ;
3133import org .elasticsearch .common .xcontent .XContentType ;
3234import org .elasticsearch .plugins .Plugin ;
@@ -49,32 +51,32 @@ protected Collection<Class<? extends Plugin>> getPlugins() {
4951 }
5052
5153 public void testDefaultMapping () throws Exception {
52- String mapping = Strings . toString ( XContentFactory .jsonBuilder ().startObject ().startObject ("type" )
54+ XContentBuilder mapping = XContentFactory .jsonBuilder ().startObject ().startObject ("type" )
5355 .startObject ("properties" )
5456 .startObject ("field" )
5557 .field ("type" , "binary" )
5658 .endObject ()
5759 .endObject ()
58- .endObject ().endObject ()) ;
60+ .endObject ().endObject ();
5961
60- DocumentMapper mapper = createIndex ("test" ).mapperService ().documentMapperParser ().parse ("type" , new CompressedXContent (mapping ));
62+ MapperService mapperService = createIndex ("test" , Settings .EMPTY , "type" , mapping ).mapperService ();
63+ MappedFieldType fieldType = mapperService .fullName ("field" );
6164
62- FieldMapper fieldMapper = mapper .mappers ().getFieldMapper ("field" );
63- assertThat (fieldMapper , instanceOf (BinaryFieldMapper .class ));
64- assertThat (fieldMapper .fieldType ().stored (), equalTo (false ));
65+ assertThat (fieldType , instanceOf (BinaryFieldMapper .BinaryFieldType .class ));
66+ assertThat (fieldType .stored (), equalTo (false ));
6567 }
6668
6769 public void testStoredValue () throws IOException {
68- String mapping = Strings . toString ( XContentFactory .jsonBuilder ().startObject ().startObject ("type" )
70+ XContentBuilder mapping = XContentFactory .jsonBuilder ().startObject ().startObject ("type" )
6971 .startObject ("properties" )
7072 .startObject ("field" )
7173 .field ("type" , "binary" )
7274 .field ("store" , true )
7375 .endObject ()
7476 .endObject ()
75- .endObject ().endObject ()) ;
77+ .endObject ().endObject ();
7678
77- DocumentMapper mapper = createIndex ("test" ). mapperService (). documentMapperParser (). parse ( "type" , new CompressedXContent ( mapping ));
79+ MapperService mapperService = createIndex ("test" , Settings . EMPTY , "type" , mapping ). mapperService ( );
7880
7981 // case 1: a simple binary value
8082 final byte [] binaryValue1 = new byte [100 ];
@@ -89,13 +91,14 @@ public void testStoredValue() throws IOException {
8991 assertTrue (CompressorFactory .isCompressed (new BytesArray (binaryValue2 )));
9092
9193 for (byte [] value : Arrays .asList (binaryValue1 , binaryValue2 )) {
92- ParsedDocument doc = mapper .parse (SourceToParse .source ("test" , "type" , "id" ,
94+ ParsedDocument doc = mapperService . documentMapper () .parse (SourceToParse .source ("test" , "type" , "id" ,
9395 BytesReference .bytes (XContentFactory .jsonBuilder ().startObject ().field ("field" , value ).endObject ()),
9496 XContentType .JSON ));
9597 BytesRef indexedValue = doc .rootDoc ().getBinaryValue ("field" );
9698 assertEquals (new BytesRef (value ), indexedValue );
97- FieldMapper fieldMapper = mapper .mappers ().getFieldMapper ("field" );
98- Object originalValue = fieldMapper .fieldType ().valueForDisplay (indexedValue );
99+
100+ MappedFieldType fieldType = mapperService .fullName ("field" );
101+ Object originalValue = fieldType .valueForDisplay (indexedValue );
99102 assertEquals (new BytesArray (value ), originalValue );
100103 }
101104 }
0 commit comments