26
26
import org .elasticsearch .common .xcontent .XContentType ;
27
27
import org .elasticsearch .test .ESIntegTestCase ;
28
28
29
+ import java .util .HashMap ;
30
+ import java .util .Map ;
31
+
29
32
import static java .util .Collections .singletonMap ;
30
33
import static org .hamcrest .Matchers .instanceOf ;
31
34
@@ -96,8 +99,8 @@ public void testPutMappingDocumentation() throws Exception {
96
99
getMappingsResponse = client .admin ().indices ().prepareGetMappings ("twitter" ).get ();
97
100
assertEquals (1 , getMappingsResponse .getMappings ().size ());
98
101
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 ( ));
101
104
102
105
// tag::putMapping-request-source-append
103
106
client .admin ().indices ().preparePutMapping ("twitter" ) // <1>
@@ -114,8 +117,10 @@ public void testPutMappingDocumentation() throws Exception {
114
117
getMappingsResponse = client .admin ().indices ().prepareGetMappings ("twitter" ).get ();
115
118
assertEquals (1 , getMappingsResponse .getMappings ().size ());
116
119
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" ));
119
124
}
120
125
121
126
}
0 commit comments