@Override
  public Supplier<Object> accept(IMockInvocation invocation) {
    acceptedInvocations.add(invocation);
    if (acceptedInvocations.size() > maxCount) {
      List<IMockInvocation> acceptedInvocationsCopy = new ArrayList<>(acceptedInvocations);
      return () -> {
        throw new TooManyInvocationsError(this, acceptedInvocationsCopy);
      };
    }

    return responseGenerator == null ? () -> null : responseGenerator.getResponseSupplier(invocation);
  }
An anticipated interaction between the SUT and one or more mock objects.

<p>An instance of this class is confined to a {@link MockController} and all method calls
should be done in {@code synchronized} blocks that synchronize on that Mock controller to
ensure proper interaction matching and invocation counting. Due to that this class is not
thread-safe.

@author Peter Niederwieser
spock-core/src/main/java/org/spockframework/mock/runtime/MockInteraction.java