public MockingDetails mockingDetails(Object toInspect) { return new DefaultMockingDetails(toInspect); }
private InvocationContainerImpl getInvocationContainer() { assertGoodMock(); return MockUtil.getInvocationContainer(toInspect); }
@Override public Collection<Invocation> getInvocations() { return getInvocationContainer().getInvocations(); }
/** * gets all invocations from mocks. Invocations are ordered earlier first. * * @param mocks mocks * @return invocations */ public static List<Invocation> find(Iterable<?> mocks) { Set<Invocation> invocationsInOrder = new TreeSet<Invocation>(new InvocationComparator()); for (Object mock : mocks) { Collection<Invocation> fromSingleMock = new DefaultMockingDetails(mock).getInvocations(); invocationsInOrder.addAll(fromSingleMock); } return new LinkedList<Invocation>(invocationsInOrder); }
/** * Gets all stubbings from mocks. Invocations are ordered earlier first. * * @param mocks mocks * @return stubbings */ public static Set<Stubbing> findStubbings(Iterable<?> mocks) { Set<Stubbing> stubbings = new TreeSet<Stubbing>(new StubbingComparator()); for (Object mock : mocks) { Collection<? extends Stubbing> fromSingleMock = new DefaultMockingDetails(mock).getStubbings(); stubbings.addAll(fromSingleMock); } return stubbings; } }
private boolean isMock(final Object o) { return new DefaultMockingDetails(o).isMock(); } }
private void assertGoodMock() { if (toInspect == null) { throw new NotAMockException("Argument passed to Mockito.mockingDetails() should be a mock, but is null!"); } else if (!isMock()) { throw new NotAMockException("Argument passed to Mockito.mockingDetails() should be a mock, but is an instance of " + toInspect.getClass() + "!"); } } }
@Override public MockHandler getMockHandler() { return mockHandler(); }
@Override public MockCreationSettings<?> getMockCreationSettings() { return mockHandler().getMockSettings(); }
public MockingDetails mockingDetails(Object toInspect) { return new DefaultMockingDetails(toInspect, new MockUtil()); } }
private MockHandler<Object> mockHandler() { assertGoodMock(); return MockUtil.getMockHandler(toInspect); }
@Override public Collection<Stubbing> getStubbings() { return getInvocationContainer().getStubbingsAscending(); }
@Override public String printInvocations() { assertGoodMock(); return new InvocationsPrinter().printInvocations(toInspect); }