### Question:
NearSpanQuery extends SpanQuery { @Override public void setLevelConstraint(final int levelConstraint) { super.setLevelConstraint(levelConstraint); for (SpanQuery clause : clauses) { clause.setLevelConstraint(levelConstraint); } } NearSpanQuery(final SpanQuery[] clauses, 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); SpanQuery[] getClauses(); int getSlop(); boolean isInOrder(); @Override Weight createWeight(final IndexSearcher searcher); @Override void extractTerms(final Set<Term> terms); @Override String toString(final String field); @Override Query rewrite(final IndexReader reader); @Override NearSpanQuery clone(); @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 NearSpanQuery nsq1 = new NearSpanQuery(new SpanQuery[] {term1, term2}, 0, true); nsq1.setLevelConstraint(3); assertEquals(3, nsq1.getLevelConstraint()); assertEquals(3, nsq1.getClauses()[0].getLevelConstraint()); assertEquals(3, nsq1.getClauses()[1].getLevelConstraint()); NodeSpanQuery term3 = new NodeSpanQuery(ntq("aaa").getQuery()); NodeSpanQuery term4 = new NodeSpanQuery(ntq("bbb").getQuery()); final NearSpanQuery nsq2 = new NearSpanQuery(new SpanQuery[] {term3, term4}, 0, true); nsq2.setLevelConstraint(4); final NearSpanQuery nsq3 = new NearSpanQuery(new SpanQuery[] {nsq1, nsq2}, 0, true); nsq3.setLevelConstraint(6); assertEquals(6, nsq1.getLevelConstraint()); assertEquals(6, nsq2.getLevelConstraint()); }