org.mockito.internal.util.DefaultMockingDetails Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockito-core Show documentation
Show all versions of mockito-core Show documentation
Mock objects library for java
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.internal.util;
import org.mockito.MockingDetails;
import org.mockito.exceptions.misusing.NotAMockException;
import org.mockito.internal.InternalMockHandler;
import org.mockito.invocation.Invocation;
import org.mockito.mock.MockCreationSettings;
import java.util.Collection;
import static org.mockito.internal.util.MockUtil.getMockHandler;
/**
* Class to inspect any object, and identify whether a particular object is either a mock or a spy. This is
* a wrapper for {@link org.mockito.internal.util.MockUtil}.
*/
public class DefaultMockingDetails implements MockingDetails {
private final Object toInspect;
public DefaultMockingDetails(Object toInspect){
this.toInspect = toInspect;
}
@Override
public boolean isMock(){
return MockUtil.isMock(toInspect);
}
@Override
public boolean isSpy(){
return MockUtil.isSpy(toInspect);
}
@Override
public Collection getInvocations() {
return mockHandler().getInvocationContainer().getInvocations();
}
@Override
public MockCreationSettings getMockCreationSettings() {
return mockHandler().getMockSettings();
}
private InternalMockHandler