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

com.fitbur.mockito.internal.util.DefaultMockingDetails 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.util;

import com.fitbur.mockito.MockingDetails;
import com.fitbur.mockito.invocation.Invocation;

import java.util.Collection;
import java.util.Set;

/**
 * Class to inspect any object, and identify whether a particular object is either a mock or a spy.  This is
 * a wrapper for {@link com.fitbur.mockito.internal.util.MockUtil}.
 */
public class DefaultMockingDetails implements MockingDetails {

    private final Object toInspect;
    private final MockUtil delegate;

    public DefaultMockingDetails(Object toInspect, MockUtil delegate){
        this.toInspect = toInspect;
        this.delegate = delegate;
    }

    @Override
    public boolean isMock(){
        return delegate.isMock(toInspect);
    }

    @Override
    public boolean isSpy(){
        return delegate.isSpy(toInspect);
    }

    @Override
    public Collection getInvocations() {
        return delegate.getMockHandler(toInspect).getInvocationContainer().getInvocations();
    }

    @Override
    public Class getMockedType() {
        return delegate.getMockHandler(toInspect).getMockSettings().getTypeToMock();
    }

    @Override
    @SuppressWarnings("unchecked")
    public Set getExtraInterfaces() {
        return delegate.getMockHandler(toInspect).getMockSettings().getExtraInterfaces();
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy