org.mockito.plugins.MockMaker Java Examples

The following examples show how to use org.mockito.plugins.MockMaker. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MockMakerMultiplexer.java    From dexmaker with Apache License 2.0 5 votes vote down vote up
@Override
public <T> T createMock(MockCreationSettings<T> settings, MockHandler handler) {
    for (MockMaker mockMaker : MOCK_MAKERS) {
        T mock = mockMaker.createMock(settings, handler);

        if (mock != null) {
            return mock;
        }
    }

    return null;
}
 
Example #2
Source File: MockMakerMultiplexer.java    From dexmaker with Apache License 2.0 5 votes vote down vote up
@Override
public MockHandler getHandler(Object mock) {
    for (MockMaker mockMaker : MOCK_MAKERS) {
        MockHandler handler = mockMaker.getHandler(mock);

        if (handler != null) {
            return handler;
        }
    }

    return null;
}
 
Example #3
Source File: MockMakerMultiplexer.java    From dexmaker with Apache License 2.0 5 votes vote down vote up
@Override
public TypeMockability isTypeMockable(Class<?> type) {
    for (MockMaker mockMaker : MOCK_MAKERS) {
        TypeMockability mockability = mockMaker.isTypeMockable(type);

        if (mockability != null) {
            return mockability;
        }
    }

    return null;
}
 
Example #4
Source File: MockMakerMultiplexer.java    From dexmaker with Apache License 2.0 5 votes vote down vote up
@Override
public void clearMock(Object mock) {
    for (MockMaker mockMaker : MOCK_MAKERS) {
        if (!(mockMaker instanceof InlineMockMaker)) {
            continue;
        }

        InlineMockMaker inlineMockMaker = (InlineMockMaker) mockMaker;
        inlineMockMaker.clearMock(mock);
    }
}
 
Example #5
Source File: MockMakerMultiplexer.java    From dexmaker with Apache License 2.0 5 votes vote down vote up
@Override
public void clearAllMocks() {
    for (MockMaker mockMaker : MOCK_MAKERS) {
        if (!(mockMaker instanceof InlineMockMaker)) {
            continue;
        }

        InlineMockMaker inlineMockMaker = (InlineMockMaker) mockMaker;
        inlineMockMaker.clearAllMocks();
    }
}
 
Example #6
Source File: ModuleOverrider.java    From DaggerMock with Apache License 2.0 4 votes vote down vote up
private Boolean isUsedMockMaker() {
    if (!isMockitoVersion2()) return false;
    MockMaker mockMaker = Plugins.getMockMaker();
    return !(mockMaker instanceof ByteBuddyMockMaker);
}
 
Example #7
Source File: MockMakerMultiplexer.java    From dexmaker with Apache License 2.0 4 votes vote down vote up
@Override
public void resetMock(Object mock, MockHandler newHandler, MockCreationSettings settings) {
    for (MockMaker mockMaker : MOCK_MAKERS) {
        mockMaker.resetMock(mock, newHandler, settings);
    }
}
 
Example #8
Source File: ClassPathLoader.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the implementation of the mock maker available for the current runtime.
 *
 * <p>Returns {@link org.mockito.internal.creation.CglibMockMaker} if no
 * {@link MockMaker} extension exists or is visible in the current classpath.</p>
 */
public static MockMaker getMockMaker() {
    return mockMaker;
}
 
Example #9
Source File: ClassPathLoader.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Scans the classpath to find a mock maker plugin if one is available,
 * allowing mockito to run on alternative platforms like Android.
 */
static MockMaker findPlatformMockMaker() {
    return findPluginImplementation(MockMaker.class, DEFAULT_MOCK_MAKER_CLASS);
}