All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fitbur.mockito.internal.progress.ThreadSafeMockingProgress Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
/*
 * Copyright (c) 2007 Mockito contributors
 * This program is made available under the terms of the MIT License.
 */

package com.fitbur.mockito.internal.progress;

import com.fitbur.mockito.internal.listeners.MockingProgressListener;
import com.fitbur.mockito.invocation.Invocation;
import com.fitbur.mockito.stubbing.OngoingStubbing;
import com.fitbur.mockito.verification.VerificationMode;
import com.fitbur.mockito.verification.VerificationStrategy;

import java.io.Serializable;

@SuppressWarnings("unchecked")
public class ThreadSafeMockingProgress implements MockingProgress, Serializable {
    
    private static final long serialVersionUID = 6839454041642082618L;
    private static final ThreadLocal mockingProgress = new ThreadLocal();

    static MockingProgress threadSafely() {
        if (mockingProgress.get() == null) {
            mockingProgress.set(new MockingProgressImpl());
        }
        return mockingProgress.get();
    }
    
    public void reportOngoingStubbing(OngoingStubbing iOngoingStubbing) {
        threadSafely().reportOngoingStubbing(iOngoingStubbing);
    }

    public OngoingStubbing pullOngoingStubbing() {
        return threadSafely().pullOngoingStubbing();
    }
    
    public void verificationStarted(VerificationMode verify) {
        threadSafely().verificationStarted(verify);
    }

    public VerificationMode pullVerificationMode() {
        return threadSafely().pullVerificationMode();
    }

    public void stubbingStarted() {
        threadSafely().stubbingStarted();
    }

    public void validateState() {
        threadSafely().validateState();
    }

    public void stubbingCompleted(Invocation invocation) {
        threadSafely().stubbingCompleted(invocation);
    }
    
    public String toString() {
        return threadSafely().toString();
    }

    public void reset() {
        threadSafely().reset();
    }

    public void resetOngoingStubbing() {
        threadSafely().resetOngoingStubbing();
    }

    public ArgumentMatcherStorage getArgumentMatcherStorage() {
        return threadSafely().getArgumentMatcherStorage();
    }
    
    public void mockingStarted(Object mock, Class classToMock) {
        threadSafely().mockingStarted(mock, classToMock);
    }

    public void setListener(MockingProgressListener listener) {
        threadSafely().setListener(listener);
    }

    public void setVerificationStrategy(VerificationStrategy strategy) {
        threadSafely().setVerificationStrategy(strategy);
    }

    public VerificationMode maybeVerifyLazily(VerificationMode mode) {
        return threadSafely().maybeVerifyLazily(mode);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy