### Question:
Unit { public void accept(UnitVisitor visitor) { Arrays.stream(children).forEach(child -> child.accept(visitor)); } Unit(Unit... children); void accept(UnitVisitor visitor);  }### Answer:
@Test public void testAccept() { final var children = new Unit[5]; Arrays.setAll(children, (i) -> mock(Unit.class)); final var unit = this.factory.apply(children); final var visitor = mock(UnitVisitor.class); unit.accept(visitor); verifyVisit(unit, visitor); Arrays.stream(children).forEach(child -> verify(child).accept(eq(visitor))); verifyNoMoreInteractions(children); verifyNoMoreInteractions(visitor); }