6464import java .util .Arrays ;
6565import java .util .HashSet ;
6666import java .util .List ;
67+ import java .util .Map ;
6768import java .util .Set ;
6869import java .util .concurrent .Executors ;
6970import java .util .stream .Collectors ;
7071
71- import static java .util .Collections .emptyList ;
72- import static java .util .Collections .emptyMap ;
73- import static java .util .Collections .singleton ;
74- import static java .util .Collections .singletonMap ;
7572import static org .elasticsearch .xpack .core .security .SecurityField .DOCUMENT_LEVEL_SECURITY_FEATURE ;
7673import static org .hamcrest .Matchers .containsInAnyOrder ;
7774import static org .hamcrest .Matchers .equalTo ;
@@ -115,7 +112,7 @@ public void testDLS() throws Exception {
115112 null ,
116113 () -> true ,
117114 null ,
118- emptyMap (),
115+ Map . of (),
119116 MapperMetrics .NOOP
120117 );
121118 SearchExecutionContext searchExecutionContext = spy (realSearchExecutionContext );
@@ -172,7 +169,7 @@ public void testDLS() throws Exception {
172169 String termQuery = "{\" term\" : {\" field\" : \" " + values [i ] + "\" } }" ;
173170 IndicesAccessControl .IndexAccessControl indexAccessControl = new IndicesAccessControl .IndexAccessControl (
174171 FieldPermissions .DEFAULT ,
175- DocumentPermissions .filteredBy (singleton (new BytesArray (termQuery )))
172+ DocumentPermissions .filteredBy (Set . of (new BytesArray (termQuery )))
176173 );
177174 SecurityIndexReaderWrapper wrapper = new SecurityIndexReaderWrapper (
178175 s -> searchExecutionContext ,
@@ -184,7 +181,7 @@ public void testDLS() throws Exception {
184181
185182 @ Override
186183 protected IndicesAccessControl getIndicesAccessControl () {
187- return new IndicesAccessControl (true , singletonMap ("_index" , indexAccessControl ));
184+ return new IndicesAccessControl (true , Map . of ("_index" , indexAccessControl ));
188185 }
189186 };
190187
@@ -237,9 +234,9 @@ public void testDLSWithLimitedPermissions() throws Exception {
237234 FieldPermissions .DEFAULT ,
238235 DocumentPermissions .filteredBy (queries )
239236 );
240- queries = singleton (new BytesArray ("{\" terms\" : { \" f1\" : [\" fv11\" , \" fv21\" , \" fv31\" ] } }" ));
237+ queries = Set . of (new BytesArray ("{\" terms\" : { \" f1\" : [\" fv11\" , \" fv21\" , \" fv31\" ] } }" ));
241238 if (restrictiveLimitedIndexPermissions ) {
242- queries = singleton (new BytesArray ("{\" terms\" : { \" f1\" : [\" fv11\" , \" fv31\" ] } }" ));
239+ queries = Set . of (new BytesArray ("{\" terms\" : { \" f1\" : [\" fv11\" , \" fv31\" ] } }" ));
243240 }
244241 IndicesAccessControl .IndexAccessControl limitedIndexAccessControl = new IndicesAccessControl .IndexAccessControl (
245242 FieldPermissions .DEFAULT ,
@@ -271,7 +268,7 @@ public void testDLSWithLimitedPermissions() throws Exception {
271268 null ,
272269 () -> true ,
273270 null ,
274- emptyMap (),
271+ Map . of (),
275272 MapperMetrics .NOOP
276273 );
277274 SearchExecutionContext searchExecutionContext = spy (realSearchExecutionContext );
@@ -289,13 +286,13 @@ public void testDLSWithLimitedPermissions() throws Exception {
289286
290287 @ Override
291288 protected IndicesAccessControl getIndicesAccessControl () {
292- IndicesAccessControl indicesAccessControl = new IndicesAccessControl (true , singletonMap ("_index" , indexAccessControl ));
289+ IndicesAccessControl indicesAccessControl = new IndicesAccessControl (true , Map . of ("_index" , indexAccessControl ));
293290 if (noFilteredIndexPermissions ) {
294291 return indicesAccessControl ;
295292 }
296293 IndicesAccessControl limitedByIndicesAccessControl = new IndicesAccessControl (
297294 true ,
298- singletonMap ("_index" , limitedIndexAccessControl )
295+ Map . of ("_index" , limitedIndexAccessControl )
299296 );
300297 return indicesAccessControl .limitIndicesAccessControl (limitedByIndicesAccessControl );
301298 }
@@ -494,7 +491,7 @@ public void testDLSWithNestedDocs() throws Exception {
494491 protected IndicesAccessControl getIndicesAccessControl () {
495492 IndicesAccessControl indicesAccessControl = new IndicesAccessControl (
496493 true ,
497- singletonMap (indexSettings ().getIndex ().getName (), indexAccessControl )
494+ Map . of (indexSettings ().getIndex ().getName (), indexAccessControl )
498495 );
499496 return indicesAccessControl ;
500497 }
@@ -522,6 +519,6 @@ protected IndicesAccessControl getIndicesAccessControl() {
522519
523520 private static MappingLookup createMappingLookup (List <MappedFieldType > concreteFields ) {
524521 List <FieldMapper > mappers = concreteFields .stream ().map (MockFieldMapper ::new ).collect (Collectors .toList ());
525- return MappingLookup .fromMappers (Mapping .EMPTY , mappers , emptyList ());
522+ return MappingLookup .fromMappers (Mapping .EMPTY , mappers , List . of ());
526523 }
527524}
0 commit comments