public List<Invocation> getAllInvocations() { return invocations.getInvocations(); }
/** * Finds all unused stubs for given mocks * * @param mocks */ public List<Invocation> find(List<?> mocks) { List<Invocation> unused = new LinkedList<Invocation>(); for (Object mock : mocks) { InternalMockHandler<Object> handler = new MockUtil().getMockHandler(mock); List<StubbedInvocationMatcher> fromSingleMock = handler.getInvocationContainer().getStubbedInvocations(); for(StubbedInvocationMatcher s : fromSingleMock) { if (!s.wasUsed()) { unused.add(s.getInvocation()); } } } return unused; } }
/** * gets all invocations from mocks. Invocations are ordered earlier first. * * @param mocks mocks * @return invocations */ public List<Invocation> find(List<?> mocks) { Set<Invocation> invocationsInOrder = new TreeSet<Invocation>(new SequenceNumberComparator()); for (Object mock : mocks) { InternalMockHandler<Object> handler = new MockUtil().getMockHandler(mock); List<Invocation> fromSingleMock = handler.getInvocationContainer().getInvocations(); invocationsInOrder.addAll(fromSingleMock); } return new LinkedList<Invocation>(invocationsInOrder); }
/** * Finds all unused stubs for given mocks * * @param mocks */ public List<Invocation> find(List<?> mocks) { List<Invocation> unused = new LinkedList<Invocation>(); for (Object mock : mocks) { MockHandlerInterface<Object> handler = new MockUtil().getMockHandler(mock); List<StubbedInvocationMatcher> fromSingleMock = handler.getInvocationContainer().getStubbedInvocations(); for(StubbedInvocationMatcher s : fromSingleMock) { if (!s.wasUsed()) { unused.add(s.getInvocation()); } } } return unused; } }
public Object[] ignoreStubs(Object... mocks) { for (Object m : mocks) { InvocationContainer invocationContainer = new MockUtil().getMockHandler(m).getInvocationContainer(); List<Invocation> ins = invocationContainer.getInvocations(); for (Invocation in : ins) { if (in.stubInfo() != null) { in.ignoreForVerification(); } } } return mocks; }
@Override public void describeMismatch(Object item, final Description description) { description.appendText("had these: "); for (Invocation invocation : new MockUtil().getMockHandler(item).getInvocationContainer().getInvocations()) description.appendText(invocation.toString()); }
public List<Invocation> getAllInvocations() { return invocations.getInvocations(); }
@Override public void destroySingletons() { super.destroySingletons(); int mockedBeansWithoutInvocations = 0; int mockedBeansWithInvocations = 0; MockUtil mockUtil = new MockUtil(); for( Map.Entry<Class, Object> entry : mockedBeans.entrySet() ) { Object mock = entry.getValue(); InvocationContainer container = mockUtil.getMockHandler( mock ).getInvocationContainer(); List<Invocation> invocations = container.getInvocations(); if( invocations.isEmpty() ) { mockedBeansWithoutInvocations++; } else { mockedBeansWithInvocations++; } reset( mock ); } LOG.debug( "*** MockedLoader stats: [" + mockedBeans.size() + "] mocked beans of which [" + mockedBeansWithInvocations + "] with invocations and [" + mockedBeansWithoutInvocations + "] without invocations" ); mockedBeans.clear(); }
/** * gets all invocations from mocks. Invocations are ordered earlier first. * * @param mocks mocks * @return invocations */ public List<Invocation> find(List<?> mocks) { Set<Invocation> invocationsInOrder = new TreeSet<Invocation>(new SequenceNumberComparator()); for (Object mock : mocks) { MockHandlerInterface<Object> handler = new MockUtil().getMockHandler(mock); List<Invocation> fromSingleMock = handler.getInvocationContainer().getInvocations(); invocationsInOrder.addAll(fromSingleMock); } return new LinkedList<Invocation>(invocationsInOrder); }
public Object[] ignoreStubs(Object... mocks) { for (Object m : mocks) { InvocationContainer invocationContainer = new MockUtil().getMockHandler(m).getInvocationContainer(); List<Invocation> ins = invocationContainer.getInvocations(); for (Invocation in : ins) { if (in.stubInfo() != null) { in.ignoreForVerification(); } } } return mocks; } }