/** @return a {@link HasChildQueryBuilder} with random values all over the place */
 @Override
 protected HasChildQueryBuilder doCreateTestQueryBuilder() {
   int min = randomIntBetween(0, Integer.MAX_VALUE / 2);
   int max = randomIntBetween(min, Integer.MAX_VALUE);
   InnerHitsBuilder.InnerHit innerHit =
       new InnerHitsBuilder.InnerHit().setSize(100).addSort(STRING_FIELD_NAME, SortOrder.ASC);
   return new HasChildQueryBuilder(
       CHILD_TYPE,
       RandomQueryBuilder.createQuery(random()),
       max,
       min,
       RandomPicks.randomFrom(random(), ScoreMode.values()),
       randomBoolean() ? null : new QueryInnerHits("inner_hits_name", innerHit));
 }
  public void testIllegalValues() {
    QueryBuilder query = RandomQueryBuilder.createQuery(random());
    try {
      new HasChildQueryBuilder(null, query);
      fail("must not be null");
    } catch (IllegalArgumentException ex) {

    }

    try {
      new HasChildQueryBuilder("foo", null);
      fail("must not be null");
    } catch (IllegalArgumentException ex) {

    }
    HasChildQueryBuilder foo = new HasChildQueryBuilder("foo", query); // all good
    try {
      foo.scoreMode(null);
      fail("must not be null");
    } catch (IllegalArgumentException ex) {

    }
    final int positiveValue = randomIntBetween(0, Integer.MAX_VALUE);
    try {
      foo.minChildren(randomIntBetween(Integer.MIN_VALUE, -1));
      fail("must not be negative");
    } catch (IllegalArgumentException ex) {

    }
    foo.minChildren(positiveValue);
    assertEquals(positiveValue, foo.minChildren());
    try {
      foo.maxChildren(randomIntBetween(Integer.MIN_VALUE, -1));
      fail("must not be negative");
    } catch (IllegalArgumentException ex) {

    }

    foo.maxChildren(positiveValue);
    assertEquals(positiveValue, foo.maxChildren());
  }