Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) 2007 Mockito contributors
   * This program is made available under the terms of the MIT License.
   */
  package org.mockito.internal;
  
 
 import java.util.List;
 
 @SuppressWarnings("unchecked")
 public class MockitoCore {
 
     private final Reporter reporter = new Reporter();
     private final MockUtil mockUtil = new MockUtil();
     private final MockingProgress mockingProgress = new ThreadSafeMockingProgress();
     
     public <T> T mock(Class<T> classToMockMockSettings mockSettings) {
         .validateState();
         return .createMock(classToMock, (MockSettingsImplmockSettings);
     }
     
     public IOngoingStubbing stub() {
         IOngoingStubbing stubbing = .pullOngoingStubbing();
         if (stubbing == null) {
             .reset();
             .missingMethodInvocation();
         }
         return stubbing;
     }
 
     @Deprecated
     public <T> DeprecatedOngoingStubbing<T> stub(T methodCall) {
         .stubbingStarted();
         return (DeprecatedOngoingStubbingstub();
     }
 
     public <T> OngoingStubbing<T> when(T methodCall) {
         .stubbingStarted();
         return (OngoingStubbingstub();
     }
     
     
     public <T> T verify(T mockVerificationMode mode) {
         if (mock == null) {
             .nullPassedToVerify();
         } else if (!.isMock(mock)) {
             .notAMockPassedToVerify();
         }
         .verificationStarted(mode);
         return mock;
     }
     
     public <T> void reset(T ... mocks) {
         .validateState();
         .reset();
         
         for (T m : mocks) {
             .resetMock(m);
         }
     }
     
     public void verifyNoMoreInteractions(Object... mocks) {
         assertMocksNotEmpty(mocks);
         .validateState();
         for (Object mock : mocks) {
             try {
                 if (mock == null) {
                     .nullPassedToVerifyNoMoreInteractions();
                 }
                 .getMockHandler(mock).verifyNoMoreInteractions();
             } catch (NotAMockException e) {
                 .notAMockPassedToVerifyNoMoreInteractions();
             }
         }
     }
     
     private void assertMocksNotEmpty(Object[] mocks) {
         if (mocks == null || mocks.length == 0) {
         }
     }
     
    public InOrder inOrder(Object... mocks) {
        if (mocks == null || mocks.length == 0) {
        }
        for (Object mock : mocks) {
            if (mock == null) {
                .nullPassedWhenCreatingInOrder();
            } else if (!.isMock(mock)) {
                .notAMockPassedWhenCreatingInOrder();
            }
        }
        return new InOrderImpl(Arrays.asList(mocks));
    }
    
    public Stubber doAnswer(Answer answer) {
        return new StubberImpl().doAnswer(answer);
    }
    
    public <T> VoidMethodStubbable<T> stubVoid(T mock) {
        MockHandler<T> handler = .getMockHandler(mock);
        return handler.voidMethodStubbable(mock);
    }
    public void validateMockitoUsage() {
    }

    
For testing purposes only. Is not the part of main API.

Returns:
last invocation
    public Invocation getLastInvocation() {
        List<InvocationallInvocations = ongoingStubbing.getRegisteredInvocations().getAll();
        return allInvocations.get(allInvocations.size()-1);
    }
New to GrepCode? Check out our FAQ X