### Question:
DenialConstraint implements Result { @Override public String toString() { return NOT + "(" + predicates.stream().map(p -> p.toString()).sorted().collect(Collectors.joining(AND)) + ")"; } DenialConstraint();  DenialConstraint(Predicate... predicates); @Override void sendResultTo(OmniscientResultReceiver resultReceiver); Collection<Predicate> getPredicates(); @JsonIgnore int getPredicateCount(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static final String NOT; static final String AND; }### Answer:
@Test public void testToString() { Predicate p1 = mock(Predicate.class); when(p1.toString()).thenReturn("p1"); Predicate p2 = mock(Predicate.class); when(p2.toString()).thenReturn("p2"); DenialConstraint dc1 = new DenialConstraint(p1, p2); DenialConstraint dc2 = new DenialConstraint(p2, p1); String expectedStringRepresentation = DenialConstraint.NOT + "(p1" + DenialConstraint.AND + "p2)"; assertEquals(expectedStringRepresentation, dc1.toString()); assertEquals(expectedStringRepresentation, dc2.toString()); }