adapt randomFrom to not use null as a first param, in preparation for https://github.com/elastic/elasticsearch/pull/19172

Original commit: elastic/x-pack-elasticsearch@50296d6cfc
This commit is contained in:
Boaz Leskes 2016-06-30 17:31:13 +02:00
parent 8c54887ab8
commit 7c1bc0c8de
2 changed files with 10 additions and 10 deletions

View File

@ -109,16 +109,16 @@ public class IndicesAccessControlTests extends ESTestCase {
} }
public void testMergeNotGrantedAndGranted() { public void testMergeNotGrantedAndGranted() {
final Set<String> notGrantedFields = randomFrom(null, Collections.<String>emptySet(), Collections.singleton("baz")); final Set<String> notGrantedFields = randomFrom(Collections.<String>emptySet(), Collections.singleton("baz"), null);
final Set<BytesReference> notGrantedQueries = randomFrom(null, Collections.<BytesReference>emptySet(), final Set<BytesReference> notGrantedQueries = randomFrom(Collections.<BytesReference>emptySet(), null,
Collections.<BytesReference>singleton(new BytesArray(new byte[] { randomByte() }))); Collections.<BytesReference>singleton(new BytesArray(new byte[] { randomByte() })));
final IndexAccessControl indexAccessControl = new IndexAccessControl(false, notGrantedFields, notGrantedQueries); final IndexAccessControl indexAccessControl = new IndexAccessControl(false, notGrantedFields, notGrantedQueries);
final BytesReference query1 = new BytesArray(new byte[] { 0x1 }); final BytesReference query1 = new BytesArray(new byte[] { 0x1 });
final Set<String> fields = final Set<String> fields =
randomFrom(null, Collections.singleton("foo"), Sets.newHashSet("foo", "bar"), Collections.<String>emptySet()); randomFrom(Collections.singleton("foo"), Sets.newHashSet("foo", "bar"), Collections.<String>emptySet(), null);
final Set<BytesReference> queries = final Set<BytesReference> queries =
randomFrom(null, Collections.singleton(query1), Collections.<BytesReference>emptySet()); randomFrom(Collections.singleton(query1), Collections.<BytesReference>emptySet(), null);
final IndexAccessControl other = new IndexAccessControl(true, fields, queries); final IndexAccessControl other = new IndexAccessControl(true, fields, queries);
IndexAccessControl merged = indexAccessControl.merge(other); IndexAccessControl merged = indexAccessControl.merge(other);
@ -133,16 +133,16 @@ public class IndicesAccessControlTests extends ESTestCase {
} }
public void testMergeNotGranted() { public void testMergeNotGranted() {
final Set<String> notGrantedFields = randomFrom(null, Collections.<String>emptySet(), Collections.singleton("baz")); final Set<String> notGrantedFields = randomFrom(Collections.<String>emptySet(), Collections.singleton("baz"), null);
final Set<BytesReference> notGrantedQueries = randomFrom(null, Collections.<BytesReference>emptySet(), final Set<BytesReference> notGrantedQueries = randomFrom(Collections.<BytesReference>emptySet(), null,
Collections.<BytesReference>singleton(new BytesArray(new byte[] { randomByte() }))); Collections.<BytesReference>singleton(new BytesArray(new byte[] { randomByte() })));
final IndexAccessControl indexAccessControl = new IndexAccessControl(false, notGrantedFields, notGrantedQueries); final IndexAccessControl indexAccessControl = new IndexAccessControl(false, notGrantedFields, notGrantedQueries);
final BytesReference query1 = new BytesArray(new byte[] { 0x1 }); final BytesReference query1 = new BytesArray(new byte[] { 0x1 });
final Set<String> fields = final Set<String> fields =
randomFrom(null, Collections.singleton("foo"), Sets.newHashSet("foo", "bar"), Collections.<String>emptySet()); randomFrom(Collections.singleton("foo"), Sets.newHashSet("foo", "bar"), Collections.<String>emptySet(), null);
final Set<BytesReference> queries = final Set<BytesReference> queries =
randomFrom(null, Collections.singleton(query1), Collections.<BytesReference>emptySet()); randomFrom(Collections.singleton(query1), Collections.<BytesReference>emptySet(), null);
final IndexAccessControl other = new IndexAccessControl(false, fields, queries); final IndexAccessControl other = new IndexAccessControl(false, fields, queries);
IndexAccessControl merged = indexAccessControl.merge(other); IndexAccessControl merged = indexAccessControl.merge(other);

View File

@ -65,7 +65,7 @@ public class IndexActionTests extends ESIntegTestCase {
} }
public void testIndexActionExecuteSingleDoc() throws Exception { public void testIndexActionExecuteSingleDoc() throws Exception {
String timestampField = randomFrom(null, "@timestamp"); String timestampField = randomFrom("@timestamp", null);
boolean customTimestampField = timestampField != null; boolean customTimestampField = timestampField != null;
IndexAction action = new IndexAction("test-index", "test-type", timestampField, null, null); IndexAction action = new IndexAction("test-index", "test-type", timestampField, null, null);
@ -117,7 +117,7 @@ public class IndexActionTests extends ESIntegTestCase {
} }
public void testIndexActionExecuteMultiDoc() throws Exception { public void testIndexActionExecuteMultiDoc() throws Exception {
String timestampField = randomFrom(null, "@timestamp"); String timestampField = randomFrom("@timestamp", null);
boolean customTimestampField = "@timestamp".equals(timestampField); boolean customTimestampField = "@timestamp".equals(timestampField);
assertAcked(prepareCreate("test-index") assertAcked(prepareCreate("test-index")