2626import org .elasticsearch .common .xcontent .XContentType ;
2727import org .elasticsearch .test .ESIntegTestCase ;
2828
29+ import java .util .HashMap ;
30+ import java .util .Map ;
31+
2932import static java .util .Collections .singletonMap ;
3033import static org .hamcrest .Matchers .instanceOf ;
3134
@@ -96,8 +99,8 @@ public void testPutMappingDocumentation() throws Exception {
9699 getMappingsResponse = client .admin ().indices ().prepareGetMappings ("twitter" ).get ();
97100 assertEquals (1 , getMappingsResponse .getMappings ().size ());
98101 indexMapping = getMappingsResponse .getMappings ().get ("twitter" );
99- assertEquals (indexMapping . get ( "user" ). getSourceAsMap ( ),
100- singletonMap ( "properties" , singletonMap ( "name" , singletonMap ( "type" , "text" )) ));
102+ assertEquals (singletonMap ( "properties" , singletonMap ( "name" , singletonMap ( "type" , "text" )) ),
103+ indexMapping . get ( "user" ). getSourceAsMap ( ));
101104
102105 // tag::putMapping-request-source-append
103106 client .admin ().indices ().preparePutMapping ("twitter" ) // <1>
@@ -114,8 +117,10 @@ public void testPutMappingDocumentation() throws Exception {
114117 getMappingsResponse = client .admin ().indices ().prepareGetMappings ("twitter" ).get ();
115118 assertEquals (1 , getMappingsResponse .getMappings ().size ());
116119 indexMapping = getMappingsResponse .getMappings ().get ("twitter" );
117- assertEquals (indexMapping .get ("user" ).getSourceAsMap (),
118- singletonMap ("properties" , singletonMap ("user_name" , singletonMap ("type" , "text" ))));
120+ Map <String , Map <?,?>> expected = new HashMap <>();
121+ expected .put ("name" , singletonMap ("type" , "text" ));
122+ expected .put ("user_name" , singletonMap ("type" , "text" ));
123+ assertEquals (expected , indexMapping .get ("user" ).getSourceAsMap ().get ("properties" ));
119124 }
120125
121126}
0 commit comments