### Question:
BooleanSpanQuery extends SpanQuery { @Override public void setLevelConstraint(final int levelConstraint) { super.setLevelConstraint(levelConstraint); this.nodeBooleanQuery.setLevelConstraint(levelConstraint); } BooleanSpanQuery(final int slop, final boolean inOrder); @Override void setLevelConstraint(final int levelConstraint); @Override void setNodeConstraint(final int lowerBound, final int upperBound); @Override void setAncestorPointer(final NodeQuery ancestor); void add(final SpanQuery query, final NodeBooleanClause.Occur occur); int getSlop(); boolean isInOrder(); NodeBooleanClause[] getClauses(); List<NodeBooleanClause> clauses(); final Iterator<NodeBooleanClause> iterator(); @Override Weight createWeight(final IndexSearcher searcher); @Override Query rewrite(final IndexReader reader); @Override void extractTerms(final Set<Term> terms); @Override @SuppressWarnings("unchecked") Query clone(); @Override String toString(final String field); @Override boolean equals(final Object o); @Override int hashCode();  }### Answer:
@Test public void testSetLevelConstraint() { NodeSpanQuery term1 = new NodeSpanQuery(ntq("aaa").getQuery()); NodeSpanQuery term2 = new NodeSpanQuery(ntq("bbb").getQuery()); final BooleanSpanQuery bsq1 = new BooleanSpanQuery(0, true); bsq1.add(term1, NodeBooleanClause.Occur.MUST); bsq1.add(term2, NodeBooleanClause.Occur.MUST); bsq1.setLevelConstraint(3); assertEquals(3, bsq1.getLevelConstraint()); assertEquals(3, bsq1.getClauses()[0].getQuery().getLevelConstraint()); assertEquals(3, bsq1.getClauses()[1].getQuery().getLevelConstraint()); NodeSpanQuery term3 = new NodeSpanQuery(ntq("aaa").getQuery()); NodeSpanQuery term4 = new NodeSpanQuery(ntq("bbb").getQuery()); final BooleanSpanQuery bsq2 = new BooleanSpanQuery(0, true); bsq2.add(term3, NodeBooleanClause.Occur.MUST); bsq2.add(term4, NodeBooleanClause.Occur.MUST); bsq2.setLevelConstraint(4); final NearSpanQuery nsq3 = new NearSpanQuery(new SpanQuery[] {bsq1, bsq2}, 0, true); nsq3.setLevelConstraint(6); assertEquals(6, bsq1.getLevelConstraint()); assertEquals(6, bsq1.getLevelConstraint()); }