### Question:
AndPredicate implements StreamPredicate, CompoundPredicate { @Override public void setPredicates(StreamPredicate[] predicates) { if (Objects.isNull(this.predicates)) { this.predicates = predicates; } else { throw new IllegalStateException( "Cannot reset predicates in an AndPredicate after they have been already set"); } } AndPredicate();  AndPredicate(StreamPredicate... predicates); @Override StreamPredicate[] getPredicates(); @Override void setPredicates(StreamPredicate[] predicates); @Override boolean apply(Collection<Attribute> attributes);  }### Answer:
@Test public void testAndPredicateSetTwice(){ StreamPredicate[] predicates = new StreamPredicate[0]; AndPredicate andPredicate = new AndPredicate(predicates); try{ andPredicate.setPredicates(predicates); fail("again setting predicates should throw"); }catch(Exception e){ assertTrue(e instanceof IllegalStateException); } }