Esempio n. 1
0
  @Nullable
  private Expectation findPreviousNotStrictExpectation(@Nonnull ExpectedInvocation newInvocation) {
    int n = notStrictExpectations.size();

    if (n == 0) {
      return null;
    }

    Object mock = newInvocation.instance;
    String mockClassDesc = newInvocation.getClassDesc();
    String mockNameAndDesc = newInvocation.getMethodNameAndDescription();
    boolean constructorInvocation = newInvocation.isConstructor();

    for (int i = 0; i < n; i++) {
      Expectation previousExpectation = notStrictExpectations.get(i);

      if (isMatchingInvocation(
              mock, mockClassDesc, mockNameAndDesc, constructorInvocation, previousExpectation)
          && isWithMatchingArguments(newInvocation, previousExpectation.invocation)) {
        return previousExpectation;
      }
    }

    return null;
  }
Esempio n. 2
0
 private void forceMatchingOnMockInstanceIfRequired(@Nonnull ExpectedInvocation invocation) {
   if (isToBeMatchedOnInstance(invocation.instance, invocation.getMethodNameAndDescription())) {
     invocation.matchInstance = true;
   }
 }